From: Tom Hughes Date: Thu, 14 Jan 2010 00:35:09 +0000 (+0000) Subject: Rework the pagination of the trace list to avoid having to count X-Git-Tag: live~6339^2~16 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/62e7006a2131eef9f7569e8c25207b3777bc3d74 Rework the pagination of the trace list to avoid having to count the total number of matching records/pages. --- diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index 3769202da..ea107c2b5 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -81,11 +81,15 @@ class TraceController < ApplicationController conditions[0] += " AND gpx_files.visible = ?" conditions << true - @trace_pages, @traces = paginate(:traces, - :include => [:user, :tags], - :conditions => conditions, - :order => "gpx_files.timestamp DESC", - :per_page => 20) + @page = (params[:page] || 1).to_i + @page_size = 20 + + @traces = Trace.find(:all, + :include => [:user, :tags], + :conditions => conditions, + :order => "gpx_files.timestamp DESC", + :offset => (@page - 1) * @page_size, + :limit => @page_size) # put together SET of tags across traces, for related links tagset = Hash.new diff --git a/app/views/trace/_trace_paging_nav.html.erb b/app/views/trace/_trace_paging_nav.html.erb index 9ac80d4cd..c338a1469 100644 --- a/app/views/trace/_trace_paging_nav.html.erb +++ b/app/views/trace/_trace_paging_nav.html.erb @@ -1,12 +1,17 @@ -<% current_page = @trace_pages.current_page %> +

-<%= t'trace.trace_paging_nav.showing' %> -<%= current_page.number %> (<%= current_page.first_item %><% -if (current_page.first_item < current_page.last_item) # if more than 1 trace on page - %>-<%= current_page.last_item %><% -end %> -<%= t'trace.trace_paging_nav.of' %> <%= @trace_pages.item_count %>) +<% if @page > 1 %> +<%= link_to t('trace.trace_paging_nav.previous'), params.merge({ :page => @page - 1 }) %> +<% else %> +<%= t('trace.trace_paging_nav.previous') %> +<% end %> + +| <%= t('trace.trace_paging_nav.showing_page', :page => @page) %> | -<% if @trace_pages.page_count > 1 %> - | <%= pagination_links_each(@trace_pages, {}) { |n| link_to_page(n) } %> +<% if @traces.size < @page_size %> +<%= t('trace.trace_paging_nav.next') %> +<% else %> +<%= link_to t('trace.trace_paging_nav.next'), params.merge({ :page => @page + 1 }) %> <% end %> + +

diff --git a/config/locales/af.yml b/config/locales/af.yml index 3c8345ac5..3c5d9d323 100644 --- a/config/locales/af.yml +++ b/config/locales/af.yml @@ -685,9 +685,6 @@ af: see_your_traces: Sien al u spore trace_optionals: tags: Etikette - trace_paging_nav: - of: van - showing: Wys bladsy view: delete_track: Verwyder hierdie spoor description: "Beskrywing:" diff --git a/config/locales/ar.yml b/config/locales/ar.yml index 3d43e7c65..2de058b8a 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -1284,9 +1284,6 @@ ar: traces_waiting: لديك {{count}} أثر في انتظار التحميل. يرجى مراعاة الانتظار قبل تحميل أكثر من ذلك، بحيث تتجنب إعاقة طابور التحميل لباقي المستخدمين. trace_optionals: tags: الوسوم - trace_paging_nav: - of: من - showing: إظهار الصفحة view: delete_track: احذف هذا الأثر description: "الوصف:" diff --git a/config/locales/arz.yml b/config/locales/arz.yml index 5ba43d9e2..c49bdbfa9 100644 --- a/config/locales/arz.yml +++ b/config/locales/arz.yml @@ -1224,9 +1224,6 @@ arz: traces_waiting: لديك {{count}} أثر فى انتظار التحميل. يرجى مراعاه الانتظار قبل تحميل أكثر من ذلك، بحيث تتجنب إعاقه طابور التحميل لباقى المستخدمين. trace_optionals: tags: الوسوم - trace_paging_nav: - of: من - showing: إظهار الصفحة view: delete_track: احذف هذا الأثر description: "الوصف:" diff --git a/config/locales/be.yml b/config/locales/be.yml index 7822d26f5..b176549b5 100644 --- a/config/locales/be.yml +++ b/config/locales/be.yml @@ -541,9 +541,6 @@ be: traces_waiting: У вас {{count}} трэкаў у чарзе. Калі ласка, пачакайце, пакуль яны будуць апрацаваныя, каб не блакірваць чаргу для астатніх карстальнікаў. trace_optionals: tags: Цэтлікі - trace_paging_nav: - of: з - showing: Прагляд старонкі view: delete_track: Выдаліць гэты трэк description: "Апісанне:" diff --git a/config/locales/br.yml b/config/locales/br.yml index b107e641d..2342aa496 100644 --- a/config/locales/br.yml +++ b/config/locales/br.yml @@ -1271,9 +1271,6 @@ br: traces_waiting: Bez' hoc'h eus {{count}} roud a c'hortoz bezañ kaset. Gwell e vefe gortoz a-raok kas re all, evit chom hep stankañ al lostennad evit an implijerien all. trace_optionals: tags: Balizennoù - trace_paging_nav: - of: eus - showing: O tiskouez ar bajenn view: delete_track: Dilemel ar roudenn-mañ description: "Deskrivadur :" diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 1625c756c..953942daf 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -559,9 +559,6 @@ cs: visibility_help: co tohle znamená? trace_optionals: tags: Tagy - trace_paging_nav: - of: z - showing: Zobrazuji stranu view: description: "Popis:" download: stáhnout diff --git a/config/locales/da.yml b/config/locales/da.yml index 55f0b9ea8..bebd73bc1 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -441,9 +441,6 @@ da: traces_waiting: Du har allerede {{count}} GPS-spor i køen. Overvej at vente pÃ¥ disse før du uploader flere spor for ikke at blokkere køen for andre brugere. trace_optionals: tags: Egenskaber - trace_paging_nav: - of: af - showing: Viser side view: delete_track: Slet dette spor description: "Beskrivelse:" diff --git a/config/locales/de.yml b/config/locales/de.yml index c3addc0e9..f3f3d8c68 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1287,9 +1287,6 @@ de: traces_waiting: "{{count}} deiner Tracks sind momentan in der Warteschlange. Bitte warte bis diese fertig sind, um die Verarbeitung nicht für andere Nutzer zu blockieren." trace_optionals: tags: Tags - trace_paging_nav: - of: von - showing: Zeige Seite view: delete_track: Diesen Track löschen description: "Beschreibung:" diff --git a/config/locales/dsb.yml b/config/locales/dsb.yml index f261650e1..34309269f 100644 --- a/config/locales/dsb.yml +++ b/config/locales/dsb.yml @@ -1206,9 +1206,6 @@ dsb: traces_waiting: MaÅ¡ {{count}} slědow, kótarež cakaju na nagraśe. PÅ¡osym cakaj, až njejsu nagrate, nježli až nagrajoÅ¡ dalÅ¡ne, až njeby cakański rěd blokěrował za drugich wužywarjow. trace_optionals: tags: Atributy - trace_paging_nav: - of: z - showing: Pokazujo se bok view: delete_track: Toś tu ceru wulaÅ¡owaś description: "Wopisanje:" diff --git a/config/locales/en.yml b/config/locales/en.yml index 6231f0dbe..7819a11f3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1235,8 +1235,9 @@ en: trace_not_found: "Trace not found!" visibility: "Visibility:" trace_paging_nav: - showing: "Showing page" - of: "of" + showing_page: "Showing page {{page}}" + next: "Next »" + previous: "« Previous" trace: pending: "PENDING" count_points: "{{count}} points" diff --git a/config/locales/eo.yml b/config/locales/eo.yml index 28bae4f3d..090652dd1 100644 --- a/config/locales/eo.yml +++ b/config/locales/eo.yml @@ -594,9 +594,6 @@ eo: traces_waiting: Vi havas {{count}} spurojn atendanta alŝutado. Bonvolu konsideri atendi ke ili terminas alŝuti antaÅ­ alŝuti aliajn. Tiel vi ne blokus la atendovicon por aliaj uzantoj. trace_optionals: tags: Etikedoj - trace_paging_nav: - of: de - showing: Montrante paĝon view: delete_track: Forviŝi tiun spuron description: "Priskribo:" diff --git a/config/locales/es.yml b/config/locales/es.yml index 0f2b4bba9..b06526e09 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1253,9 +1253,6 @@ es: traces_waiting: Tienes {{count}} trazas esperando ser agregadas a la Base de Datos. Por favor considera el esperar que estas terminen antes de subir otras, para no bloquear la lista de espera a otros usuario. trace_optionals: tags: Etiquetas - trace_paging_nav: - of: de - showing: Mostrando página view: delete_track: Borrar esta traza description: "Descripción:" diff --git a/config/locales/fi.yml b/config/locales/fi.yml index e233f8e23..1a1744ee4 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -1013,9 +1013,6 @@ fi: traces_waiting: Lähettämiäsi jälkiä on jo {{count}} käsittelyjonossa odottamassa tallennusta tietokantaan. Olisi huomaavaista jos odottaisit näiden valmistuvan ennen kuin lähetät lisää jälkiä. Näin muidenkin käyttäjien lähettämät jäljet pääsevät aiemmin tietokantaan. trace_optionals: tags: Tägit - trace_paging_nav: - of: " /" - showing: Sivu view: delete_track: Poista tämä jälki description: "Kuvaus:" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index d08e86324..f9fca5d19 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1283,9 +1283,6 @@ fr: traces_waiting: Vous avez {{count}} traces en attente d’envoi. Il serait peut-être préférable d’attendre avant d’en envoyer d’autres, pour ne pas bloquer la file d’attente aux autres utilisateurs. trace_optionals: tags: Balises - trace_paging_nav: - of: sur - showing: Affichage de la page view: delete_track: Supprimer cette piste description: "Description :" diff --git a/config/locales/fur.yml b/config/locales/fur.yml index d55fa5b07..598cb9c7b 100644 --- a/config/locales/fur.yml +++ b/config/locales/fur.yml @@ -510,9 +510,6 @@ fur: see_all_traces: Cjale ducj i percors see_just_your_traces: Cjale dome i tiei percors o cjame un percors see_your_traces: Cjale ducj i miei percors - trace_paging_nav: - of: su - showing: Mostrant la pagjine view: delete_track: Elimine chest percors description: "Descrizion:" diff --git a/config/locales/hr.yml b/config/locales/hr.yml index abb05694c..830232820 100644 --- a/config/locales/hr.yml +++ b/config/locales/hr.yml @@ -834,9 +834,6 @@ hr: traces_waiting: Imate {{count}} trasa na čekanju za slanje. Uzmite ovo u obzir, i pričekajte da se zavrÅ¡e prije slanja novih trasa, da ne blokirate ostale korisnike. trace_optionals: tags: Oznake - trace_paging_nav: - of: od - showing: Prikazujem stranicu view: delete_track: IzbriÅ¡i ovu trasu description: "Opis:" diff --git a/config/locales/hsb.yml b/config/locales/hsb.yml index 945dd4a7e..dde5547fc 100644 --- a/config/locales/hsb.yml +++ b/config/locales/hsb.yml @@ -1282,9 +1282,6 @@ hsb: traces_waiting: MaÅ¡ {{count}} ćěrjow, kotrež na nahraće čakaja. ProÅ¡u čakaj, doniž njejsu nahrate, prjedy hač dalÅ¡e nahrawaÅ¡, zo njeby so čakanski rynk za druhich wužiwarjow blokował. trace_optionals: tags: Atributy - trace_paging_nav: - of: wot - showing: Pokazuje so strona view: delete_track: Tutu čaru zničić description: "Wopisanje:" diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 13ecf1c16..94af8c060 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -947,9 +947,6 @@ hu: traces_waiting: "{{count}} nyomvonalad várakozik feltöltésre. Kérlek fontold meg, hogy megvárod, amíg ezek befejeződnek mielőtt feltöltesz továbbiakat, hogy így ne tartsd fel a többi felhasználót a sorban." trace_optionals: tags: Címkék - trace_paging_nav: - of: "összesen:" - showing: "Jelenlegi oldal:" view: delete_track: Ezen nyomvonal törlése description: "Leírás:" diff --git a/config/locales/ia.yml b/config/locales/ia.yml index 4c542a00e..9d2c2be77 100644 --- a/config/locales/ia.yml +++ b/config/locales/ia.yml @@ -933,9 +933,6 @@ ia: traces_waiting: Tu ha {{count}} tracias attendente cargamento. Per favor considera attender le completion de istes ante de cargar alteres, pro non blocar le cauda pro altere usatores. trace_optionals: tags: Etiquettas - trace_paging_nav: - of: de - showing: Monstrante pagina view: delete_track: Deler iste tracia description: "Description:" diff --git a/config/locales/is.yml b/config/locales/is.yml index cbbb44614..dddaa16d0 100644 --- a/config/locales/is.yml +++ b/config/locales/is.yml @@ -917,9 +917,6 @@ is: traces_waiting: Þú ert með {{count}} ferla í bið. Íhugaðu að bíða með að senda inn fleiri ferla til að aðrir notendur komist að. trace_optionals: tags: Tögg - trace_paging_nav: - of: af - showing: Sýni síðu view: delete_track: Eyða description: "Lýsing:" diff --git a/config/locales/it.yml b/config/locales/it.yml index 2b22b1f28..af914302c 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -942,9 +942,6 @@ it: traces_waiting: Ci sono {{count}} tracciati in attesa di caricamento. Si consiglia di aspettare il loro completamento prima di caricarne altri, altrimenti si blocca la lista di attesa per altri utenti. trace_optionals: tags: Etichette - trace_paging_nav: - of: di - showing: Visualizzata la pagina view: delete_track: Elimina questo tracciato description: "Descrizione:" diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 7449fc5cf..57b67b53e 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -752,8 +752,6 @@ ja: traces_waiting: あなたは {{count}} のトレースがアップロード待ちになっています。それらのアップロードが終了するまでお待ちください。他のユーザーのアップロードが制限されてしまいます。 trace_optionals: tags: タグ(複数可) - trace_paging_nav: - showing: ページ表示 view: delete_track: このトラックの削除 description: "詳細:" diff --git a/config/locales/km.yml b/config/locales/km.yml index 0c421cae0..68305de82 100644 --- a/config/locales/km.yml +++ b/config/locales/km.yml @@ -369,8 +369,6 @@ km: visibility_help: តើនេះមានន័យ​ដូចម្ដេច​? trace_optionals: tags: ស្លាក​ - trace_paging_nav: - of: នៃ​ view: description: បរិយាយ​៖ download: ទាញយក diff --git a/config/locales/mk.yml b/config/locales/mk.yml index 52fe522e6..912261c70 100644 --- a/config/locales/mk.yml +++ b/config/locales/mk.yml @@ -1269,9 +1269,6 @@ mk: traces_waiting: Имате {{count}} траги спремни за подигање. Советуваме за ги почекате да завршат пред да подигате други, инаку ќе го блокирате редоследот за други корисници. trace_optionals: tags: Ознаки - trace_paging_nav: - of: од - showing: Приказ на страницата view: delete_track: Избриши ја трагава description: "Опис:" diff --git a/config/locales/nds.yml b/config/locales/nds.yml index e2cc0eab2..e2ac2427c 100644 --- a/config/locales/nds.yml +++ b/config/locales/nds.yml @@ -437,8 +437,6 @@ nds: upload_button: Hoochladen upload_gpx: GPX-Datei hoochladen visibility: Sichtborkeit - trace_paging_nav: - of: von view: description: "Beschrieven:" download: dalladen diff --git a/config/locales/nl.yml b/config/locales/nl.yml index ab16d389e..34d9be631 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -1280,9 +1280,6 @@ nl: traces_waiting: U hebt al {{count}} tracks die wachten om geüpload te worden. Overweeg om te wachten totdat die verwerkt zijn, om te voorkomen dat de wachtrij voor andere gebruikers geblokkeerd wordt. trace_optionals: tags: Labels - trace_paging_nav: - of: van - showing: Bezig met weergeven van pagina view: delete_track: Deze track verwijderen description: "Beschrijving:" diff --git a/config/locales/no.yml b/config/locales/no.yml index 82ffb851a..0909c2b98 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -813,9 +813,6 @@ traces_waiting: Du har {{count}} spor som venter pÃ¥ opplasting. Du bør vurdere Ã¥ la disse bli ferdig før du laster opp flere spor slik at du ikke blokkerer køa for andre brukere. trace_optionals: tags: Markelapper - trace_paging_nav: - of: av - showing: Viser side view: delete_track: Slett dette sporet description: "Beskrivelse:" diff --git a/config/locales/pl.yml b/config/locales/pl.yml index e8ec469b7..0252679d6 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -1224,9 +1224,6 @@ pl: traces_waiting: Masz w tym momencie {{count}} śladów nadal oczekujących na dodanie. Prosimy poczekaj aż wgrywanie ich zostanie zakończone przed dodaniem kolejnych aby nie blokować kolejki innym użytkownikom. trace_optionals: tags: Znaczniki - trace_paging_nav: - of: z - showing: Widoczna jest strona view: delete_track: Wykasuj ten ślad description: "Opis:" diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index c415c7456..8a54cdae2 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -969,9 +969,6 @@ pt-BR: traces_waiting: Você tem {{count}} trilhas esperando para subir. Por favor considere esperar que elas terminem antes de subir mais, para não bloquear a fila para outros usuários. trace_optionals: tags: Etiquetas - trace_paging_nav: - of: de - showing: Mostrando página view: delete_track: Apague esta trilha description: "Descrição:" diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 838dcacdd..4ac591b2f 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -130,9 +130,6 @@ pt: more: mais pending: PENDENTE view_map: Ver Mapa - trace_paging_nav: - of: de - showing: Mostrando página view: edit: editar map: mapa diff --git a/config/locales/ru.yml b/config/locales/ru.yml index e6a1f3211..9873ab1fa 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -1295,9 +1295,6 @@ ru: traces_waiting: "{{count}} ваших треков ожидают передачи на сервер. Пожалуйста, подождите окончания передачи этих треков, а потом передавайте на сервер другие. Это позволит не блокировать сервер для других пользователей." trace_optionals: tags: "Теги:" - trace_paging_nav: - of: из - showing: Страница view: delete_track: Удалить этот трек description: "Описание:" diff --git a/config/locales/sk.yml b/config/locales/sk.yml index d05dc3833..d8aee2349 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -780,9 +780,6 @@ sk: traces_waiting: Máte {{count}} stopy čakajúce na nahratie. Prosím zvážte toto čakanie, dokedy neukončíte nahrávanie niečoho iného, pokiaľ nie je blok v rade pre iných užívateľov. trace_optionals: tags: Tagy - trace_paging_nav: - of: z - showing: Náhľad stránky view: delete_track: VymazaÅ¥ túto stopu description: "Popis:" diff --git a/config/locales/sl.yml b/config/locales/sl.yml index d5e8a03c1..4f3165f82 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -692,9 +692,6 @@ sl: see_your_traces: Seznam vseh mojih sledi trace_optionals: tags: Oznake - trace_paging_nav: - of: od - showing: Prikaz strani view: delete_track: IzbriÅ¡i to sled description: "Opis:" diff --git a/config/locales/sr-EC.yml b/config/locales/sr-EC.yml index 5480d5821..d7f70fe17 100644 --- a/config/locales/sr-EC.yml +++ b/config/locales/sr-EC.yml @@ -613,8 +613,6 @@ sr-EC: see_your_traces: Види све твоје трагове trace_optionals: tags: Ознаке - trace_paging_nav: - of: од view: description: "Опис:" download: преузми diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 4bfc153b6..01f785258 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -927,9 +927,6 @@ sv: traces_waiting: Du har {{count}} GPS-spÃ¥r som laddas upp. Det är en bra idé att lÃ¥ta dessa bli klara innan du laddar upp fler, sÃ¥ att du inte blockerar uppladdningskön för andra användare. trace_optionals: tags: Taggar - trace_paging_nav: - of: av - showing: Visar sida view: delete_track: Radera detta spÃ¥r description: "Beskrivning:" diff --git a/config/locales/uk.yml b/config/locales/uk.yml index dcdc10709..39da3f8f5 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -1258,9 +1258,6 @@ uk: traces_waiting: "{{count}} з ваших треків очікують завантаження на сервер. Будь ласка, дочекайтесь завершення їх завантаження перед завантаженням на сервер інших треків, що дозволить іншим користувачам також надіслати свої треки." trace_optionals: tags: "Теґи:" - trace_paging_nav: - of: з - showing: Сторінка view: delete_track: Вилучити цей трек description: "Опис:" diff --git a/config/locales/vi.yml b/config/locales/vi.yml index dce68a0c6..323a77f80 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -1115,9 +1115,6 @@ vi: traces_waiting: Bạn có {{count}} tuyến đường đang chờ được tải lên. Xin hãy chờ đợi việc xong trước khi tải lên thêm tuyến đường, để cho người khác vào hàng đợi kịp. trace_optionals: tags: Thẻ - trace_paging_nav: - of: trong - showing: Xem trang view: delete_track: Xóa tuyến đường này description: "Miêu tả:" diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 09bc53176..a62f76d65 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -463,8 +463,6 @@ zh-CN: traces_waiting: 您有 {{count}} 条追踪路径正等待上传,请再您上传更多路径前等待这些传完,以确保不会给其他用户造成队列拥堵。 trace_optionals: tags: 标签 - trace_paging_nav: - showing: 显示页 view: delete_track: 删除这条路径 description: "描述:" diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index de558359a..2885c3afd 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -770,9 +770,6 @@ zh-TW: traces_waiting: 您有 {{count}} 個軌跡等待上傳。請先等待這些結束後才做進一步的上傳,如此才不會阻擋其他使用者的排程。 trace_optionals: tags: 標籤 - trace_paging_nav: - of: / - showing: 正在顯示頁面 view: delete_track: 刪除這個軌跡 description: 描述: