Permalink
Browse files

Removed formatted_* paths and replaced with paths that use :format =>…

… *, since formatted_ not compatible with Rails 2.3

Added task for creating database tables
Added task for copying assets without use of Engines plugin
Rearranged application_helper to be namedspaced, and accessible without Engines plugin
  • Loading branch information...
1 parent 6491737 commit 55090e3c3d2198ceb5700ffae090c9dbcb58615e @wbharding committed Nov 6, 2009
@@ -35,7 +35,7 @@ def create
@forum.save!
respond_to do |format|
format.html { redirect_to @forum }
- format.xml { head :created, :location => formatted_forum_url(@forum, :xml) }
+ format.xml { head :created, :location => forum_url(@forum, :format => :xml) }
end
end
@@ -64,7 +64,7 @@ def create
format.html do
redirect_to forum_topic_path(:forum_id => params[:forum_id], :id => params[:topic_id], :anchor => @post.dom_id, :page => params[:page] || '1')
end
- format.xml { head :created, :location => formatted_post_url(:forum_id => params[:forum_id], :topic_id => params[:topic_id], :id => @post, :format => :xml) }
+ format.xml { head :created, :location => post_url(:forum_id => params[:forum_id], :topic_id => params[:topic_id], :id => @post, :format => :xml) }
end
rescue ActiveRecord::RecordInvalid
flash[:bad_reply] = 'Please post something at least...'[:post_something_message]
@@ -62,7 +62,7 @@ def create
if topic_saved && post_saved
respond_to do |format|
format.html { redirect_to forum_topic_path(@forum, @topic) }
- format.xml { head :created, :location => formatted_topic_url(:forum_id => @forum, :id => @topic, :format => :xml) }
+ format.xml { head :created, :location => topic_url(:forum_id => @forum, :id => @topic, :format => :xml) }
end
else
render :action => "new"
@@ -1,96 +0,0 @@
-require 'md5'
-
-module ApplicationHelper
- # convenient plugin point
- def head_extras
- end
-
- def submit_tag(value = "Save Changes"[], options={} )
- or_option = options.delete(:or)
- return super + "<span class='button_or'>"+"or"[]+" " + or_option + "</span>" if or_option
- super
- end
-
- def ajax_spinner_for(id, spinner="spinner.gif")
- "<img src='/plugin_assets/savage_beast/images/#{spinner}' style='display:none; vertical-align:middle;' id='#{id.to_s}_spinner'> "
- end
-
- def avatar_for(user, size=32)
- image_tag "http://www.gravatar.com/avatar.php?gravatar_id=#{MD5.md5(user.email)}&rating=PG&size=#{size}", :size => "#{size}x#{size}", :class => 'photo'
- end
-
- def beast_user_name
- (current_user ? current_user.display_name : "Guest" )
- end
-
- def beast_user_link
- user_link = (current_user ? user_path(current_user) : "#")
- link_to beast_user_name, user_link
- end
-
- def feed_icon_tag(title, url)
- (@feed_icons ||= []) << { :url => url, :title => title }
- link_to image_tag('feed-icon.png', :size => '14x14', :style => 'margin-right:5px', :alt => "Subscribe to #{title}", :plugin => "savage_beast"), url
- end
-
- def search_posts_title
- returning(params[:q].blank? ? 'Recent Posts'[] : "Searching for"[] + " '#{h params[:q]}'") do |title|
- title << " "+'by {user}'[:by_user,h(User.find(params[:user_id]).display_name)] if params[:user_id]
- title << " "+'in {forum}'[:in_forum,h(Forum.find(params[:forum_id]).name)] if params[:forum_id]
- end
- end
-
- def topic_title_link(topic, options)
- if topic.title =~ /^\[([^\]]{1,15})\]((\s+)\w+.*)/
- "<span class='flag'>#{$1}</span>" +
- link_to(h($2.strip), forum_topic_path(@forum, topic), options)
- else
- link_to(h(topic.title), forum_topic_path(@forum, topic), options)
- end
- end
-
- def search_posts_path(rss = false)
- options = params[:q].blank? ? {} : {:q => params[:q]}
- prefix = rss ? 'formatted_' : ''
- options[:format] = 'rss' if rss
- [[:user, :user_id], [:forum, :forum_id]].each do |(route_key, param_key)|
- return send("#{prefix}#{route_key}_posts_path", options.update(param_key => params[param_key])) if params[param_key]
- end
- options[:q] ? search_all_posts_path(options) : send("#{prefix}all_posts_path", options)
- end
-
- # on windows and this isn't working like you expect?
- # check: http://beast.caboo.se/forums/1/topics/657
- # strftime on windows doesn't seem to support %e and you'll need to
- # use the less cool %d in the strftime line below
- def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)
- from_time = from_time.to_time if from_time.respond_to?(:to_time)
- to_time = to_time.to_time if to_time.respond_to?(:to_time)
- distance_in_minutes = (((to_time - from_time).abs)/60).round
-
- case distance_in_minutes
- when 0..1 then (distance_in_minutes==0) ? 'a few seconds ago'[] : '1 minute ago'[]
- when 2..59 then "{minutes} minutes ago"[:minutes_ago, distance_in_minutes]
- when 60..90 then "1 hour ago"[]
- when 90..1440 then "{hours} hours ago"[:hours_ago, (distance_in_minutes.to_f / 60.0).round]
- when 1440..2160 then '1 day ago'[] # 1 day to 1.5 days
- when 2160..2880 then "{days} days ago"[:days_ago, (distance_in_minutes.to_f / 1440.0).round] # 1.5 days to 2 days
- else from_time.strftime("%b %e, %Y %l:%M%p"[:datetime_format]).gsub(/([AP]M)/) { |x| x.downcase }
- end
- end
-
- def pagination collection
- if collection.page_count > 1
- "<p class='pages'>" + 'Pages'[:pages_title] + ": <strong>" +
- will_paginate(collection, :inner_window => 10, :next_label => "next"[], :prev_label => "previous"[]) +
- "</strong></p>"
- end
- end
-
- def next_page collection
- unless collection.current_page == collection.page_count or collection.page_count == 0
- "<p style='float:right;'>" + link_to("Next page"[], { :page => collection.current_page.next }.merge(params.reject{|k,v| k=="page"})) + "</p>"
- end
- end
-
-end
@@ -9,7 +9,7 @@
<h1 style="margin-top:0;"><%= 'Forums'[:forums_title] %></h1>
<p class="subtitle">
-<%= feed_icon_tag "Recent Posts"[:recent_posts], formatted_posts_path(:format => 'rss') %>
+<%= feed_icon_tag "Recent Posts"[:recent_posts], all_posts_path(:format => 'rss') %>
<%= '{count} topic(s)'[(count=Topic.count)==1 ? :topic_count : :topics_count, number_with_delimiter(count)] %>,
<%= '{count} post(s)'[(count=Post.count)==1 ? :post_count : :posts_count, number_with_delimiter(count)] %>, <%= '{count} voice(s)'[(count=User.count(:conditions => "posts_count > 0"))==1 ? :voice_count : :voices_count, number_with_delimiter(count)] %>
@@ -30,7 +30,7 @@
</h1>
<p class="subtitle">
- <%= feed_icon_tag @forum.name, formatted_forum_posts_path(@forum, :rss) %>
+ <%= feed_icon_tag @forum.name, forum_posts_path(@forum, :format => :rss) %>
<%= '{count} topic(s)'[(count=@forum.topics.size)==1 ? :topic_count : :topics_count, number_with_delimiter(count)] %>,
<%= '{count} post(s)'[(count=@forum.posts.size)==1 ? :post_count : :posts_count, number_with_delimiter(count)] %>
</p>
@@ -13,7 +13,7 @@
<h1><%= @page_title %></h1>
<p class="subtitle">
- <%= feed_icon_tag @page_title, formatted_monitored_posts_path(:user_id => @user, :format => 'rss') %>
+ <%= feed_icon_tag @page_title, monitored_posts_path(:user_id => @user, :format => 'rss') %>
<%= '{count} post(s) found'[(count=@posts.total_entries)==1 ? :post_count_found : :posts_count_found, number_with_delimiter(count)] %>
</p>
@@ -58,7 +58,7 @@
</h1>
<p class="subtitle">
- <%= feed_icon_tag @topic.title, formatted_forum_topic_path(@forum, @topic, :rss) %>
+ <%= feed_icon_tag @topic.title, forum_topic_path(@forum, @topic, :format => :rss) %>
<%= '{count} post(s)'[(count=@topic.posts.size)==1 ? :post_count : :posts_count, number_with_delimiter(count)] %>,
<%= '{count} voice(s)'[(count=@topic.voices.size)==1 ? :voice_count : :voices_count, number_with_delimiter(count)] %>
</p>
File renamed without changes.
View
@@ -1,5 +1,6 @@
ActionView::Base.send :include, SavageBeast::AuthenticationSystem
ActionController::Base.send :include, SavageBeast::AuthenticationSystem
+ApplicationHelper.send :include, SavageBeast::ApplicationHelper
# FIX for engines model reloading issue in development mode
if ENV['RAILS_ENV'] != 'production'
@@ -0,0 +1,100 @@
+require 'md5'
+
+module SavageBeast
+ module ApplicationHelper
+ # convenient plugin point
+ def head_extras
+ end
+
+=begin
+ def submit_tag(value = "Save Changes"[], options={} )
+ or_option = options.delete(:or)
+ return super + "<span class='button_or'>"+"or"[]+" " + or_option + "</span>" if or_option
+ super
+ end
+=end
+
+ def ajax_spinner_for(id, spinner="spinner.gif")
+ "<img src='/plugin_assets/savage_beast/images/#{spinner}' style='display:none; vertical-align:middle;' id='#{id.to_s}_spinner'> "
+ end
+
+ def avatar_for(user, size=32)
+ image_tag "http://www.gravatar.com/avatar.php?gravatar_id=#{MD5.md5(user.email)}&rating=PG&size=#{size}", :size => "#{size}x#{size}", :class => 'photo'
+ end
+
+ def beast_user_name
+ (current_user ? current_user.display_name : "Guest" )
+ end
+
+ def beast_user_link
+ user_link = (current_user ? user_path(current_user) : "#")
+ link_to beast_user_name, user_link
+ end
+
+ def feed_icon_tag(title, url)
+ (@feed_icons ||= []) << { :url => url, :title => title }
+ link_to image_tag('feed-icon.png', :size => '14x14', :style => 'margin-right:5px', :alt => "Subscribe to #{title}", :plugin => "savage_beast"), url
+ end
+
+ def search_posts_title
+ returning(params[:q].blank? ? 'Recent Posts'[] : "Searching for"[] + " '#{h params[:q]}'") do |title|
+ title << " "+'by {user}'[:by_user,h(User.find(params[:user_id]).display_name)] if params[:user_id]
+ title << " "+'in {forum}'[:in_forum,h(Forum.find(params[:forum_id]).name)] if params[:forum_id]
+ end
+ end
+
+ def topic_title_link(topic, options)
+ if topic.title =~ /^\[([^\]]{1,15})\]((\s+)\w+.*)/
+ "<span class='flag'>#{$1}</span>" +
+ link_to(h($2.strip), forum_topic_path(@forum, topic), options)
+ else
+ link_to(h(topic.title), forum_topic_path(@forum, topic), options)
+ end
+ end
+
+ def search_posts_path(rss = false)
+ options = params[:q].blank? ? {} : {:q => params[:q]}
+ options[:format] = 'rss' if rss
+ [[:user, :user_id], [:forum, :forum_id]].each do |(route_key, param_key)|
+ return send("#{route_key}_posts_path", options.update(param_key => params[param_key])) if params[param_key]
+ end
+ options[:q] ? search_all_posts_path(options) : send("all_posts_path", options)
+ end
+
+=begin
+ # on windows and this isn't working like you expect?
+ # check: http://beast.caboo.se/forums/1/topics/657
+ # strftime on windows doesn't seem to support %e and you'll need to
+ # use the less cool %d in the strftime line below
+ def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)
+ from_time = from_time.to_time if from_time.respond_to?(:to_time)
+ to_time = to_time.to_time if to_time.respond_to?(:to_time)
+ distance_in_minutes = (((to_time - from_time).abs)/60).round
+
+ case distance_in_minutes
+ when 0..1 then (distance_in_minutes==0) ? 'a few seconds ago'[] : '1 minute ago'[]
+ when 2..59 then "{minutes} minutes ago"[:minutes_ago, distance_in_minutes]
+ when 60..90 then "1 hour ago"[]
+ when 90..1440 then "{hours} hours ago"[:hours_ago, (distance_in_minutes.to_f / 60.0).round]
+ when 1440..2160 then '1 day ago'[] # 1 day to 1.5 days
+ when 2160..2880 then "{days} days ago"[:days_ago, (distance_in_minutes.to_f / 1440.0).round] # 1.5 days to 2 days
+ else from_time.strftime("%b %e, %Y %l:%M%p"[:datetime_format]).gsub(/([AP]M)/) { |x| x.downcase }
+ end
+ end
+
+ def pagination collection
+ if collection.page_count > 1
+ "<p class='pages'>" + 'Pages'[:pages_title] + ": <strong>" +
+ will_paginate(collection, :inner_window => 10, :next_label => "next"[], :prev_label => "previous"[]) +
+ "</strong></p>"
+ end
+ end
+
+ def next_page collection
+ unless collection.current_page == collection.page_count or collection.page_count == 0
+ "<p style='float:right;'>" + link_to("Next page"[], { :page => collection.current_page.next }.merge(params.reject{|k,v| k=="page"})) + "</p>"
+ end
+ end
+=end
+ end
+end
@@ -22,15 +22,10 @@ def update_last_seen_at
end
def login_required
- #attempt_login
- #respond_to do |format|
- # format.html { redirect_to login_path }
- # format.js { render(:update) { |p| p.redirect_to login_path } }
- # format.xml do
- # headers["WWW-Authenticate"] = %(Basic realm="Beast")
- # render :text => "HTTP Basic: Access denied.\n", :status => :unauthorized
- # end
- #end unless logged_in? && authorized?
+ if !current_user
+ # redirect to login page
+ return false
+ end
end
def authorized?()
@@ -16,7 +16,7 @@ def self.included(base)
#implement in your user model
def display_name
- "implement display_name in your user model"
+ "Foo Diddly"
end
#implement in your user model
Oops, something went wrong.

0 comments on commit 55090e3

Please sign in to comment.