Class: CortexReaver::TagController
- Inherits:
-
Controller
- Object
- Ramaze::Controller
- Controller
- CortexReaver::TagController
- Defined in:
- lib/cortex_reaver/controller/tag.rb
Constant Summary collapse
- MODEL =
Tag
Instance Method Summary collapse
-
#autocomplete ⇒ Object
Returns a few autocomplete candidates for a given tag by title, separated by newlines.
- #index(*ids) ⇒ Object
-
#new ⇒ Object
Tags are only created through tagging.
- #show(*ids) ⇒ Object
Instance Method Details
#autocomplete ⇒ Object
Returns a few autocomplete candidates for a given tag by title, separated by newlines.
43 44 45 46 47 48 49 50 |
# File 'lib/cortex_reaver/controller/tag.rb', line 43 def autocomplete q = request[:q].gsub(/[^A-Za-z0-9 -_]/, '') if q.empty? respond '' else respond Tag.filter(:title.like(/^#{q}/i)).limit(8).select(:name, :title).map(:title).join("\n") end end |
#index(*ids) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/cortex_reaver/controller/tag.rb', line 31 def index(*ids) if ids.size > 0 raw_redirect rs([:show] + ids), :status => 301 else # Index @title = "All Tags" @tags = Tag.order(:count).reverse end end |
#new ⇒ Object
Tags are only created through tagging.
80 81 82 |
# File 'lib/cortex_reaver/controller/tag.rb', line 80 def new error_404 end |
#show(*ids) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/cortex_reaver/controller/tag.rb', line 52 def show(*ids) # Find tags = [] bad_ids = [] ids.each do |id| if tag = Tag.get(id) << tag else bad_ids << id end end # Error message unless bad_ids.empty? flash[:error] = "No tags called #{h bad_ids.join(', ')}." end if .empty? # Index redirect :index else # Specific tags @tags = @title = "Tags: #{.join(', ')}" end end |