Skip to content
Browse files

tags and contributor pages

  • Loading branch information...
1 parent 1757683 commit 0cbc0adb272307c704c12cee2d16cba137cb0d5d @jywarren committed Dec 11, 2012
View
14 webserver/app/controllers/tag_controller.rb
@@ -40,4 +40,18 @@ def delete
end
end
+ def index
+ @tags = Tag.find :all, :order => "id DESC"
+ count = {}
+ @tagnames = @tags.collect(&:name).each do |tag|
+ if count[tag]
+ count[tag] += 1
+ else
+ count[tag] = 1
+ end
+ end
+ @tagnames = count.sort_by {|k,v| v }.reverse
+ render :layout => "bootstrap"
+ end
+
end
View
2 webserver/app/models/tag.rb
@@ -4,7 +4,7 @@ class Tag < ActiveRecord::Base
validates_presence_of :spectrum_id, :on => :create, :message => "can't be blank"
def spectrum
- Spectrum.find self.spectrum_id
+ Spectrum.find_by_id self.spectrum_id
end
def spectra
View
7 webserver/app/views/layouts/bootstrap.html.erb
@@ -59,6 +59,13 @@ and justice issues. PLOTS provides an online research space for citizens, linkin
<ul class="hidden-phone nav nav-pills pull-right">
<li><a class="btn btn-link" href="/"><i class="icon icon-home"></i></a></li>
<li class="dropdown">
+ <a class="btn btn-link dropdown-toggle" data-toggle="dropdown">Browse <b class="caret"></b></a>
+ <ul class="dropdown-menu">
+ <li><a href="/contributors">Contributors</a></li>
+ <li><a href="/tags">Tags</a></li>
+ </ul>
+ </li>
+ <li class="dropdown">
<a class="btn btn-link dropdown-toggle" data-toggle="dropdown">Learn <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="http://publiclaboratory.org/wiki/spectral-workbench-usage">Using Spectral Workbench</a></li>
View
24 webserver/app/views/tag/index.html.erb
@@ -0,0 +1,24 @@
+<div class="container">
+
+<h2>Tags</h2>
+
+ <table class="table">
+ <tr>
+ <th></th>
+ <th>Name</th>
+ <th>Count</th>
+ </tr>
+ <% @tagnames.each do |name,count| %>
+ <% if tag = Tag.find_by_name(name, :order => "id DESC") %>
+ <% if tag.spectrum %>
+ <tr>
+ <td><img width="120px" class="img" src="<%= tag.spectrum.photo.url(:thumb) %>" /></td>
+ <td><a href="/tag/<%= name %>"><%= name %></a></td>
+ <td><%= count %></td>
+ </tr>
+ <% end %>
+ <% end %>
+ <% end %>
+ </table>
+
+</div>
View
1 webserver/config/routes.rb
@@ -23,6 +23,7 @@
map.assign '/spectra/assign', :controller => 'spectrums', :action => 'assign'
map.tags '/tag/create', :controller => 'tag', :action => 'create'
map.tags '/tag/:id', :controller => 'tag', :action => 'show'
+ map.tags '/tags', :controller => 'tag', :action => 'index'
map.resources :spectrums
# map.resources :spectrums, :collection=>{
# :doSomething= > :get,

0 comments on commit 0cbc0ad

Please sign in to comment.
Something went wrong with that request. Please try again.