Sha256: 353573331687ac2636c81e651509d6157e2223c7646d0fe3888b41cfa2de8d72
Contents?: true
Size: 2 KB
Versions: 2
Compression:
Stored size: 2 KB
Contents
class TagsController < ApplicationController def index @tags = Tag.find_all(nil, 'tag') end def show @tag = Tag.find_by_tag(CGI.unescape(@params['tag'])) rescue Tag.new @posts = @tag.posts render 'post/index' end def add post = Post.find(@params['post_id']) post_tags = post.tags.collect { |t| t.tag } unless @params['tags'].empty? @params['tags'].split(',').each do |tag| unless post_tags.include? tag.strip thetag = Tag.find_by_tag(tag.strip) || Tag.new('tag' => tag.strip) thetag.increment('numitems') thetag.save post.tags << thetag end end end redirect_to :controller => 'post', :action => 'view', :id => post.id end def addxml @post = Post.find(@params['post_id']) post_tags = @post.tags.collect { |t| t.tag } unless @params['tags'].empty? @params['tags'].split(',').each do |tag| unless post_tags.include? tag.strip thetag = Tag.find_by_tag(tag.strip) || Tag.new('tag' => tag.strip) thetag.increment('numitems') thetag.save @post.tags << thetag end end end render_without_layout 'tags/addxml' end def search if @params['qu'] if /,\W*$/ =~ @params['qu'] render_without_layout 'tags/no_completions' return end items = @params['qu'].split(',') item = items[-1].strip if items.length > 1 notin = "AND tag NOT IN (" notin += items[0...-1].collect {|t| "'#{t.strip}'"}.join(',') + ")" else notin = '' end if item != '' @tags = Tag.find_all("tag LIKE '#{item}%' #{notin}", 'tag') else @tags = [] end @tagarray = @tags.collect { |t| "\"#{t.tag}\"" }.join(', ') @postsarray = @tags.collect { |t| "\"#{t.posts_count} posts\"" }.join(', ') render_without_layout 'tags/search_completer' else render_without_layout 'tags/search' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
EliteJournal-1.9.480 | app/controllers/tags_controller.rb |
EliteJournal-1.9.492 | app/controllers/tags_controller.rb |