Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Some more fixes #145

Closed
wants to merge 13 commits into
from
@@ -86,7 +86,7 @@ def autosave
id = params[:article][:id] if params[:article] && params[:article][:id]
@article = Article.get_or_build_article(id)
- @article.text_filter = current_user.text_filter if current_user.simple_editor?
+ @article.text_filter ||= set_textfilter
get_fresh_or_existing_draft_for_article
@@ -140,7 +140,7 @@ def new_or_edit
id = params[:id]
id = params[:article][:id] if params[:article] && params[:article][:id]
@article = Article.get_or_build_article(id)
- @article.text_filter = set_textfilter
+ @article.text_filter ||= set_textfilter
@post_types = PostType.find(:all)
if request.post?
@@ -156,10 +156,10 @@ def bulkops
return
end
when 'Mark Checked Items as Ham'
- update_feedback(items, :change_state!)
+ update_feedback(items, :mark_as_ham!)
flash[:notice]= _("Marked %d item(s) as Ham",ids.size)
when 'Mark Checked Items as Spam'
- update_feedback(items, :change_state!)
+ update_feedback(items, :mark_as_spam!)
flash[:notice]= _("Marked %d item(s) as Spam",ids.size)
when 'Confirm Classification of Checked Items'
update_feedback(items, :confirm_classification!)
@@ -17,7 +17,7 @@ def index
def new
@page = Page.new(params[:page])
@page.user_id = current_user.id
- @page.text_filter = set_textfilter
+ @page.text_filter ||= set_textfilter
if request.post?
@page.published_at = Time.now
if @page.save
@@ -56,8 +56,8 @@ def reset_local_cache
# The base URL for this request, calculated by looking up the URL for the main
# blog index page.
- def blog_base_url
- url_for(:controller => '/articles').gsub(%r{/$},'')
+ def blog_base_url(only_path = false)
+ url_for(:controller => '/articles', :only_path => only_path).gsub(%r{/$},'')
end
def add_to_cookies(name, value, path=nil, expires=nil)
@@ -21,19 +21,19 @@ def pluralize(size, zero, one , many )
end
# Produce a link to the permalink_url of 'item'.
- def link_to_permalink(item, title, anchor=nil, style=nil, nofollow=nil)
+ def link_to_permalink(item, title, anchor=nil, style=nil, nofollow=nil, only_path=false)
options = {}
options[:class] = style if style
options[:rel] = "nofollow" if nofollow
- link_to title, item.permalink_url(anchor), options
+ link_to title, item.permalink_url(anchor,only_path), options
end
# The '5 comments' link from the bottom of articles
def comments_link(article)
comment_count = article.published_comments.size
# FIXME Why using own pluralize metchod when the Localize._ provides the same funciotnality, but better? (by simply calling _('%d comments', comment_count) and using the en translation: l.store "%d comments", ["No nomments", "1 comment", "%d comments"])
- link_to_permalink(article,pluralize(comment_count, _('no comments'), _('1 comment'), _('%d comments', comment_count)),'comments')
+ link_to_permalink(article,pluralize(comment_count, _('no comments'), _('1 comment'), _('%d comments', comment_count)),'comments', nil, nil, true)
end
def avatar_tag(options = {})
@@ -1,11 +1,11 @@
require 'digest/sha1'
module ContentHelper
def category_links(article, prefix="Posted in")
- _(prefix) + " " + article.categories.map { |c| link_to h(c.name), category_url(c), :rel => 'tag'}.join(", ")
+ _(prefix) + " " + article.categories.map { |c| link_to h(c.name), c.permalink_url(nil, true), :rel => 'tag'}.join(", ")
end
def tag_links(article, prefix="Tags")
- _(prefix) + " " + article.tags.map { |tag| link_to tag.display_name, tag.permalink_url, :rel => "tag"}.sort.join(", ")
+ _(prefix) + " " + article.tags.map { |tag| link_to tag.display_name, tag.permalink_url(nil, true), :rel => "tag"}.sort.join(", ")
end
def next_link(article, prefix="")
View
@@ -144,11 +144,11 @@ def trackback_url
end
def comment_url
- blog.url_for("comments?article_id=#{self.id}", :only_path => false)
+ blog.url_for("comments?article_id=#{self.id}", :only_path => true)
end
def preview_comment_url
- blog.url_for("comments/preview?article_id=#{self.id}", :only_path => false)
+ blog.url_for("comments/preview?article_id=#{self.id}", :only_path => true)
end
def feed_url(format)
@@ -243,6 +243,11 @@ def self.search(query, args={})
end
def keywords_to_tags
+ # if keywords is empty, we want to reset the tags altogether, but
+ # if they do not exists (for instance because we're triggered by a
+ # publication_pending) we don't want to destroy the tags
+ return if keywords.nil?
+
Article.transaction do
tags.clear
tags <<
View
@@ -7,7 +7,6 @@ class Comment < Feedback
content_fields :body
validates_presence_of :author, :body
- attr_accessor :user_agent
attr_accessor :referrer
attr_accessor :permalink
View
@@ -70,6 +70,19 @@ def html_map field
content_fields.include? field
end
+ def excerpt_text(length = 160)
+ if respond_to?(:excerpt) and (excerpt || "") != ""
+ text = generate_html(:excerpt, excerpt)
+ else
+ text = html(:all)
+ end
+
+ text = text.strip_html
+
+ return text.slice(0, length) +
+ (text.length > length ? '...' : '');
+ end
+
def invalidates_cache?(on_destruction = false)
@invalidates_cache ||= if on_destruction
just_changed_published_status? || published?
View
@@ -66,8 +66,7 @@ def blog_allows_feedback?
end
def akismet_options
- {:user_ip => ip,
- :comment_type => self.class.to_s.downcase,
+ {:comment_type => self.class.to_s.downcase,
:comment_author => originator,
:comment_author_email => email,
:comment_author_url => url,
@@ -110,7 +109,7 @@ def akismet_is_spam?(options={})
begin
Timeout.timeout(defined?($TESTING) ? 30 : 60) do
- akismet.comment_check(ip, nil, akismet_options)
+ akismet.comment_check(ip, user_agent, akismet_options)
end
rescue Timeout::Error => e
nil
@@ -130,6 +129,16 @@ def change_state!
result
end
+ def mark_as_ham!
+ mark_as_ham
+ save!
+ end
+
+ def mark_as_spam!
+ mark_as_ham
+ save!
+ end
+
def report_as_spam
report_as('spam')
end
@@ -143,7 +152,7 @@ def report_as spam_or_ham
begin
Timeout.timeout(defined?($TESTING) ? 5 : 3600) {
akismet.send("submit_#{spam_or_ham}",
- ip, nil, akismet_options)
+ ip, user_agent, akismet_options)
}
rescue Timeout::Error => e
nil
@@ -22,3 +22,5 @@
<%= this_blog.custom_tracking_field unless this_blog.custom_tracking_field.blank? %>
<%= google_analytics %>
+<%= meta_tag 'og:site_name', this_blog.blog_name %>
+<%= meta_tag 'og:title', @article ? @article.title : @page_title %>
@@ -0,0 +1,9 @@
+class AddsFeedbackUseragent < ActiveRecord::Migration
+ def up
+ add_column :feedback, :user_agent, :string
+ end
+
+ def down
+ remove_column :feedback, :user_agent
+ end
+end
View
No changes.
View
@@ -43,28 +43,28 @@ def to_title(item, settings, params)
s = self
# Tags for params
- s = s.gsub('%date%', parse_date(s, params)) if s =~ /(%date%)/
+ s = s.gsub('%date%', parse_date(s, params)) if s =~ /%date%/
s = s.gsub('%search%', params[:q]) if params[:q]
- s = s.gsub('%page%', parse_page(s, params)) if s=~ /(%page%)/
+ s = s.gsub('%page%', parse_page(s, params)) if s=~ /%page%/
# Tags for settings
s = s.gsub('%blog_name%', settings.blog_name)
s = s.gsub('%blog_subtitle%', settings.blog_subtitle)
s = s.gsub('%meta_keywords%', settings.meta_keywords)
# Tags for item
- s = s.gsub('%title%', item.title) if s =~ /(%title)/ and item.respond_to? :title
- s = s.gsub('%excerpt%', (item.body || '').strip_html.slice(0, 160)) if s =~ /(%excerpt%)/ and item.respond_to? :body
- s = s.gsub('%description%', item.description) if s =~ /(%description%)/ and item.respond_to? :description
- s = s.gsub('%name%', item.name) if s =~ /(%name%)/ and item.respond_to? :name
- s = s.gsub('%author%', item.name) if s =~ /(%author%)/ and item.respond_to? :name
+ s = s.gsub('%title%', item.title) if s =~ /%title/ and item.respond_to? :title
+ s = s.gsub('%excerpt%', item.excerpt_text) if s =~ /%excerpt%/ and item.respond_to? :excerpt_text
+ s = s.gsub('%description%', item.description) if s =~ /%description%/ and item.respond_to? :description
+ s = s.gsub('%name%', item.name) if s =~ /%name%/ and item.respond_to? :name
+ s = s.gsub('%author%', item.name) if s =~ /%author%/ and item.respond_to? :name
- if s =~ /(%categories%)/ and item.respond_to? :categories
- s = s.gsub('%categories%', article.categories.map { |c| c.name }.join(", "))
+ if s =~ /%categories%/ and item.respond_to? :categories
+ s = s.gsub('%categories%', item.categories.map { |c| c.name }.join(", "))
end
- if s =~ /(%tags%)/ and item.respond_to? :tags
- s = s.gsub('%tags%', article.tags.map { |t| t.display_name }.join(", "))
+ if s =~ /%tags%/ and item.respond_to? :tags
+ s = s.gsub('%tags%', item.tags.map { |t| t.display_name }.join(", "))
end
# Other
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0 public/javascripts/ckcustom.js 100755 → 100644
No changes.
View
0 public/javascripts/growler.js 100755 → 100644
No changes.
View
0 public/stylesheets/growler.css 100755 → 100644
No changes.
View
0 public/stylesheets/lightbox.css 100755 → 100644
No changes.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0 themes/typographic/images/tag.png 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Diff not rendered.
View
Diff not rendered.
View
Diff not rendered.
View
Diff not rendered.
View
No changes.
View
No changes.
View
No changes.
View
No changes.
No changes.
@@ -25,7 +25,7 @@ def gravatar_tag(email, options={})
options[:default] = CGI::escape(options[:default]) if options.include?(:default)
options[:size] ||= 48
- url = "http://www.gravatar.com/avatar.php?" << options.map { |key,value| "#{key}=#{value}" }.sort.join("&amp;")
+ url = "//www.gravatar.com/avatar.php?" << options.map { |key,value| "#{key}=#{value}" }.sort.join("&amp;")
"<img src=\"#{url}\" class=\"avatar gravatar\" alt=\"Gravatar\" />"
end
end
@@ -54,7 +54,9 @@ def self.macrofilter(blog,content,attrib,params,text="")
details = sizes.find {|s| s['label'].downcase == size.downcase } || sizes.first
width = details['width']
height = details['height']
- imageurl = details['source']
+ # use protocol-relative URL after getting the source address
+ # so not to break HTTPS support
+ imageurl = details['source'].sub(/^https?:/, '')
imagelink = flickrimage.urls.find {|u| u.type == "photopage"}.to_s
caption ||= sanitize(CGI.unescapeHTML(flickrimage.description)) unless flickrimage.description.blank?
@@ -89,9 +89,11 @@ def self.macrofilter(blog,content,attrib,params,text="")
width = thumbdetails['width']
height = thumbdetails['height']
- thumburl = thumbdetails['source']
- displayurl = displaydetails['source']
+ # use protocol-relative URL after getting the source address
+ # so not to break HTTPS support
+ thumburl = thumbdetails['source'].sub(/^https?:/, '')
+ displayurl = displaydetails['source'].sub(/^https?:/, '')
caption ||= flickrimage.description
title ||= flickrimage.title
@@ -123,8 +125,8 @@ def self.macrofilter(blog,content,attrib,params,text="")
def self.set_whiteboard(blog, content)
content.whiteboard['page_header_lightbox'] = <<-HTML
- <link href="#{blog.base_url}/stylesheets/lightbox.css" media="all" rel="Stylesheet" type="text/css" />
- <script src="#{blog.base_url}/javascripts/lightbox.js" type="text/javascript"></script>
+ <link href="#{blog_base_url(true)}/stylesheets/lightbox.css" media="all" rel="Stylesheet" type="text/css" />
+ <script src="#{blog_base_url(true)}/javascripts/lightbox.js" type="text/javascript"></script>
HTML
end
end