Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 474
- Log:
Gravatar URL changed to HTTPS
- Author:
- rool
- Date:
- Mon May 27 06:58:41 +0100 2019
- Size:
- 2666 Bytes
1 | require 'md5' |
2 | |
3 | module ApplicationHelper |
4 | def submit_tag(value = "Save Changes", options={} ) |
5 | or_option = options.delete(:or) |
6 | return super + "<span class='button_or'>or " + or_option + "</span>" if or_option |
7 | super |
8 | end |
9 | |
10 | def ajax_spinner_for(id, spinner="spinner.gif") |
11 | "<img src='/images/#{spinner}' style='display:none; vertical-align:middle;' id='#{id.to_s}_spinner'> " |
12 | end |
13 | |
14 | def avatar_for(user, size=32) |
15 | image_tag "https://www.gravatar.com/avatar.php?gravatar_id=#{MD5.md5(user.email)}&size=#{size}", :size => "#{size}x#{size}", :class => 'photo' |
16 | end |
17 | |
18 | def feed_icon_tag(title, url) |
19 | (@feed_icons ||= []) << { :url => url, :title => title } |
20 | link_to image_tag('feed-icon.png', :size => '14x14', :alt => "Subscribe to #{title}"), url |
21 | end |
22 | |
23 | def search_posts_title |
24 | returning(params[:q].blank? ? 'Recent Posts' : "Searching for '#{h params[:q]}'") do |title| |
25 | title << " by #{h User.find(params[:user_id]).display_name}" if params[:user_id] |
26 | title << " in #{h Forum.find(params[:forum_id]).name}" if params[:forum_id] |
27 | end |
28 | end |
29 | |
30 | def search_posts_path(rss = false) |
31 | options = params[:q].blank? ? {} : {:q => params[:q]} |
32 | prefix = rss ? 'formatted_' : '' |
33 | options[:format] = 'rss' if rss |
34 | [[:user, :user_id], [:forum, :forum_id]].each do |(route_key, param_key)| |
35 | return send("#{prefix}#{route_key}_posts_path", options.update(param_key => params[param_key])) if params[param_key] |
36 | end |
37 | options[:q] ? all_search_posts_path(options) : send("#{prefix}all_posts_path", options) |
38 | end |
39 | |
40 | def apphelp_pagination_fields |
41 | "#{hidden_field_tag :page, params[:page] if params.has_key?(:page)}" << |
42 | "#{hidden_field_tag :posts_per_page, params[:posts_per_page] if params.has_key?(:posts_per_page)}" |
43 | end |
44 | |
45 | def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false) |
46 | from_time = from_time.to_time if from_time.respond_to?(:to_time) |
47 | to_time = to_time.to_time if to_time.respond_to?(:to_time) |
48 | distance_in_minutes = (((to_time - from_time).abs)/60).round |
49 | |
50 | case distance_in_minutes |
51 | when 0..1 then (distance_in_minutes==0) ? 'a few seconds ago' : '1 minute ago' |
52 | when 2..59 then "#{distance_in_minutes} minutes ago" |
53 | when 60..90 then "1 hour ago" |
54 | when 90..1440 then "#{(distance_in_minutes.to_f / 60.0).round} hours ago" |
55 | when 1440..2160 then '1 day ago' # 1 day to 1.5 days |
56 | when 2160..2880 then "#{(distance_in_minutes.to_f / 1440.0).round} days ago" # 1.5 days to 2 days |
57 | else from_time.strftime("%b %e, %Y %l:%M%p").gsub(/([AP]M)/) { |x| x.downcase } |
58 | end |
59 | end |
60 | |
61 | end |