Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

gestion du noTag comme un tag a part entière

  • Loading branch information...
commit 1a3e90d5d9c18ef91fdcc447236fc83e4f6288aa 1 parent 9304156
@nicogiard authored
Showing with 15 additions and 15 deletions.
  1. +11 −11 app/controllers/Application.java
  2. +4 −4 app/views/Application/index.html
View
22 app/controllers/Application.java
@@ -50,21 +50,21 @@ public static void index() {
}
public static void tag(String tagName) {
- Tag activeTag = Tag.findByName(tagName);
- notFoundIfNull(activeTag);
- TORRENTS_PAGER.setElementCount(Torrent.countTaggedWith(activeTag));
- List<Torrent> torrents = Torrent.findTaggedWith(activeTag, TORRENTS_PAGER.getPage(), TORRENTS_PAGER.getPageSize());
+ String activeTag = tagName;
+ List<Torrent> torrents = null;
+ if ("noTag".equals(activeTag)) {
+ TORRENTS_PAGER.setElementCount(Torrent.countNotTagged());
+ torrents = Torrent.findNotTagged(TORRENTS_PAGER.getPage(), TORRENTS_PAGER.getPageSize());
+ } else {
+ Tag tag = Tag.findByName(activeTag);
+ notFoundIfNull(tag);
+ TORRENTS_PAGER.setElementCount(Torrent.countTaggedWith(tag));
+ torrents = Torrent.findTaggedWith(tag, TORRENTS_PAGER.getPage(), TORRENTS_PAGER.getPageSize());
+ }
Pager pager = TORRENTS_PAGER;
renderTemplate("Application/index.html", pager, torrents, activeTag);
}
- public static void noTag() {
- TORRENTS_PAGER.setElementCount(Torrent.countNotTagged());
- List<Torrent> torrents = Torrent.findNotTagged(TORRENTS_PAGER.getPage(), TORRENTS_PAGER.getPageSize());
- Pager pager = TORRENTS_PAGER;
- renderTemplate("Application/index.html", torrents, pager);
- }
-
public static void search(String keywords) {
TORRENTS_PAGER.setElementCount(Torrent.countSearch(keywords));
int offset = TORRENTS_PAGER.getPage() > 1 ? (TORRENTS_PAGER.getPage() - 1) * TORRENTS_PAGER.getPageSize() : 0;
View
8 app/views/Application/index.html
@@ -23,9 +23,9 @@ <h1 class="screen-title"><i class="big-icon-page"></i>&nbsp;Torrents</h1>
<ul class="tagCloud">
<li><a href="@{Application.index}" class="btn #{if request.action != "Application.noTag" && !activeTag && !keywords}active#{/if}">Tous</a></li>
- <li><a href="@{Application.noTag}" class="btn #{if request.action =~ "Application.noTag"}active#{/if}">Pas de Tag</a></li>
+ <li><a href="@{Application.tag("noTag")}" class="btn #{if activeTag && activeTag == "noTag"}active#{/if}">Pas de Tag</a></li>
#{list tags, as:'tag'}
- <li><a href="@{Application.tag(tag.name)}" class="btn #{if activeTag && activeTag.name == tag.name}active#{/if}">${tag.name}</a></li>
+ <li><a href="@{Application.tag(tag.name)}" class="btn #{if activeTag && activeTag == tag.name}active#{/if}">${tag.name}</a></li>
#{/list}
</ul>
@@ -67,7 +67,7 @@ <h1 class="screen-title"><i class="big-icon-page"></i>&nbsp;Torrents</h1>
${torrent.creationDate?.format("dd/MM/yyyy")}
</td>
<td class="actions">
- <a href="@{Application.update(torrent.id)}#{if keywords}?keywords=${keywords}#{/if}#{if activeTag}?activeTag=${activeTag.name}#{/if}" class="btn" title="Modifier"><i class="icon-pencil"></i>Modifier</a>
+ <a href="@{Application.update(torrent.id)}#{if keywords}?keywords=${keywords}#{/if}#{if activeTag}?activeTag=${activeTag}#{/if}" class="btn" title="Modifier"><i class="icon-pencil"></i>Modifier</a>
#{if controllers.Security.connectedUser() == torrent.uploader || controllers.Security.connectedUser().isAdmin}
<a href="@{Application.delete(torrent.id)}" class="btn btn-danger" onclick="if(!confirm('Etes vous sûr de vouloir supprimer ce torrent ?'))return false;" title="Supprimer"><i class="icon-trash icon-white"></i>Supprimer</a>
#{/if}
@@ -78,7 +78,7 @@ <h1 class="screen-title"><i class="big-icon-page"></i>&nbsp;Torrents</h1>
#{if pager.pageCount > 1}
#{if activeTag}
- <div class="pagination">#{pager pager, url:actionBridge.Application.tag(activeTag.name) /}</div>
+ <div class="pagination">#{pager pager, url:actionBridge.Application.tag(activeTag) /}</div>
#{/if}
#{elseif keywords}
<div class="pagination">#{pager pager, url:actionBridge.Application.search(keywords) /}</div>
Please sign in to comment.
Something went wrong with that request. Please try again.