Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Some more fixes #145

Closed
wants to merge 13 commits into from

4 participants

@Flameeyes

Okay this is a bunch of different fixes that I applied to my blog — the akismet one is not live on my blog but it's tested, I just don't want to run the migration myself, until it's in master.

The gravatar change could break IE6 on some rare cases when accessing it through https using SNI certificates, but that's such a corner case that I honestly don't care.

HTH,
Diego

Flameeyes added some commits
@Flameeyes Flameeyes admin/feedback: make sure that "Mark checked item as (Ham|Spam)" do w…
…hat they say.

The behaviour of these was to just toggle the state, now they are
actually marking them as ham/spam so that they don't misbehave.
1c09ab7
@Flameeyes Flameeyes akismet: save the user agent and submit it when checking for/submitti…
…ng spam.

The User-Agent sent by the commenter is often a good piece of
information to identify whether a comment is spam or not, so make sure
not to blackhole it and instead store and submit it.
0f9582e
@Flameeyes Flameeyes gravatar: use protocol-relative URIs for HTTPS compatibility. c051dfc
@Flameeyes Flameeyes Fix text filter settings on editing/autosaving old posts and pages. 2f864a5
@Flameeyes Flameeyes flickr: make use of protocol-relative URIs on the returned source data.
Also, for lightbox, make sure that it uses fully relative paths for
the stylesheets and lightbox as otherwise it can also escape the HTTPS
protocol.
49f5cc1
...o_textfilter_lightbox/lib/typo_textfilter_lightbox.rb
@@ -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="/stylesheets/lightbox.css" media="all" rel="Stylesheet" type="text/css" />
+ <script src="/javascripts/lightbox.js" type="text/javascript"></script>
@mvz Owner
mvz added a note

This breaks if the blog is not located at the root URI. It might be better to use javascript_include_tag and stylesheet_link_tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mvz
Owner

These are some great fixes. I may be able to take a look at the javascript and stylesheet tags in the lightbox plugin later in the week.

@Flameeyes
Flameeyes added some commits
@Flameeyes Flameeyes comments: use relative URLs for comment forms.
Using full, absoltue URLs will cause testing environment to comment on
production instances, and will also break HTTPS support on
mixed-protocols sites.
f28c8b6
@Flameeyes Flameeyes Remove executable permissions to files that shouldn't be executed. 9043a05
@Flameeyes Flameeyes Fix links to relative paths instead of absolute paths.
This unbreaks the view on a local test system and supports HTTPS more
properly.
3bff4ad
@Flameeyes Flameeyes excerpts: pre-process the excerpts with the filter
This allows posts with markup early in the body to not show said markup.
58f615f
@Flameeyes

Do you have a non-root install to try this method on? It should work fine.

@xenji

I would like to see those patches reviewed and in the master as soon as possible. I'm about to start a fixing-round on my own and I do not want to do the work in double ... ;)

@mvz
Owner

@Flameeyes Yes, I have a non-root install for testing.
@xenji I should be able to test and merge this weekend. Still need to go over the new commits.

@mvz
Owner

@Flameeyes did you mean for the opengraph commit to be part of this pull request? GitHub automatically adds any commits on the same branch to the pull request ...

@Flameeyes

@mvz yeah do you find anything against it? It provides very basic information but at least this way the links look correctly on Facebook with it.

@mvz
Owner

Interesting ... no I have no problem with it. I don't really use Facebook myself so wouldn't know what 'correctly' means in this case.

@mvz
Owner

It turns out this breaks the specs pretty badly and actually keeps the text filter at textile unless set through params.

How does it break it exactly? Besides, I honestly care less about the specs than the actual behaviour. Current master is TFU in this regard, as editing always reset to none.

Owner

Article sets text_filter to textile automatically, so the calls to set_textfilter never happen. This will also happen in production, so this means set_textfilter can just be removed.

With failing specs there is nothing to fall back on in development, so I'm not going to merge anything in with specs failing.

Do as you wish, but know that right now the thing is messed up in production.

Maybe I should just give up on Typo, if specs are more important than behaviour.

@mvz
Owner

This causes as failing spec

@mvz
Owner

I'm sorry, but there are just too many things that break right now. Some involve fixes to the specs to match improved behavior, and I can do these myself, but the changes to lightbox cause several of the lightbox specs to break in a way that suggests it breaks in production as well.

I do agree wholeheartedly that the text filter bug needs to be fixed ASAP.

@Flameeyes

I've asked to see how the specs break and you haven't pasted a single line of output, so I'm afraid that if you want to accept the fixes and figure out why the specs break, it's your call. I really won't care about whether Typo upstream merges this or not at this point: on my blog it works. That includes lightbox, which I even used again today.

Honestly, you should consider whether to make it easier to run those specs, and whether specs are more important than what the user gets or not. Good luck.

@mvz
Owner

Huh? Is there a particular difficulty with running the specs that we are not aware of?

@mvz
Owner

BTW, you can now freely apply your own migrations, since Typo now uses time stamped migrations (although no new migrations have been generated since the switch.

Below is the output of the broken tests. Note that I had to merge in current master to make the tests run at all. Perhaps this will also solve your inability to run the tests.

Failures:

  1) Admin::ContentController with admin connection it should behave like new action should create a filtered article
     Failure/Error: new_article.text_filter.name.should eq @user.text_filter.name

       expected: "markdown"
            got: "textile"

       (compared using ==)
     Shared Example Group: "new action" called from ./spec/controllers/admin/content_controller_spec.rb:486
     # ./spec/controllers/admin/content_controller_spec.rb:350:in `block (3 levels) in <top (required)>'

  2) Admin::ContentController with publisher connection it should behave like new action should create a filtered article
     Failure/Error: new_article.text_filter.name.should eq @user.text_filter.name

       expected: "markdown"
            got: "textile"

       (compared using ==)
     Shared Example Group: "new action" called from ./spec/controllers/admin/content_controller_spec.rb:632
     # ./spec/controllers/admin/content_controller_spec.rb:350:in `block (3 levels) in <top (required)>'

  3) String#to_title should handle the case where item.body is nil
     Failure/Error: item.should_receive(:body).and_return(nil)
       (Double "item").body(any args)
           expected: 1 time
           received: 0 times
     # ./spec/lib/transforms_spec.rb:8:in `block (3 levels) in <top (required)>'

  4) Article#comment_url should render complete url of comment
     Failure/Error: article.comment_url.should == "http://myblog.net/comments?article_id=#{article.id}"
       expected: "http://myblog.net/comments?article_id=123"
            got: "/comments?article_id=123" (using ==)
     # ./spec/models/article_spec.rb:472:in `block (3 levels) in <top (required)>'

  5) Article#preview_comment_url should render complete url of comment
     Failure/Error: article.preview_comment_url.should == "http://myblog.net/comments/preview?article_id=#{article.id}"
       expected: "http://myblog.net/comments/preview?article_id=123"
            got: "/comments/preview?article_id=123" (using ==)
     # ./spec/models/article_spec.rb:479:in `block (3 levels) in <top (required)>'

  6) With the list of available filters #filter_text specific typo tags flickr should show with default settings
     Failure/Error: assert_equal "<div style=\"float:left\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p></div>",
     MiniTest::Assertion:
       <"<div style=\"float:left\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p></div>"> expected but was
       <"<div style=\"float:left\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"//photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p></div>">.
     # ./spec/models/text_filter_spec.rb:80:in `block (5 levels) in <top (required)>'

  7) With the list of available filters #filter_text specific typo tags flickr should use default image size
     Failure/Error: assert_equal "<div style=\"\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p></div>",
     MiniTest::Assertion:
       <"<div style=\"\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p></div>"> expected but was
       <"<div style=\"\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"//photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p></div>">.
     # ./spec/models/text_filter_spec.rb:87:in `block (5 levels) in <top (required)>'

  8) With the list of available filters #filter_text specific typo tags flickr should use caption
     Failure/Error: assert_equal "<div style=\"\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a></div>",
     MiniTest::Assertion:
       <"<div style=\"\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a></div>"> expected but was
       <"<div style=\"\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"//photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a></div>">.
     # ./spec/models/text_filter_spec.rb:94:in `block (5 levels) in <top (required)>'

  9) With the list of available filters #filter_text lightbox should work
     Failure/Error: assert_equal "<a href=\"http://photos23.flickr.com/31366117_b1a791d68e_b.jpg\" rel=\"lightbox\" title=\"Matz\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_t.jpg\" width=\"67\" height=\"100\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:67px\">This is Matz, Ruby's creator</p>",
     MiniTest::Assertion:
       <"<a href=\"http://photos23.flickr.com/31366117_b1a791d68e_b.jpg\" rel=\"lightbox\" title=\"Matz\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_t.jpg\" width=\"67\" height=\"100\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:67px\">This is Matz, Ruby's creator</p>"> expected but was
       <"<typo:lightbox img=\"31366117\" thumbsize=\"Thumbnail\" displaysize=\"Large\" style=\"float:left\"/>">.
     # ./spec/models/text_filter_spec.rb:189:in `block (4 levels) in <top (required)>'

  10) With the list of available filters #filter_text lightbox shoudl use default thumb image size
     Failure/Error: assert_equal "<a href=\"http://photos23.flickr.com/31366117_b1a791d68e_b.jpg\" rel=\"lightbox\" title=\"Matz\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p>",
     MiniTest::Assertion:
       <"<a href=\"http://photos23.flickr.com/31366117_b1a791d68e_b.jpg\" rel=\"lightbox\" title=\"Matz\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p>"> expected but was
       <"<typo:lightbox img=\"31366117\" displaysize=\"Large\"/>">.
     # ./spec/models/text_filter_spec.rb:196:in `block (4 levels) in <top (required)>'

  11) With the list of available filters #filter_text lightbox should use default display image size
     Failure/Error: assert_equal "<a href=\"http://photos23.flickr.com/31366117_b1a791d68e_o.jpg\" rel=\"lightbox\" title=\"Matz\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p>",
     MiniTest::Assertion:
       <"<a href=\"http://photos23.flickr.com/31366117_b1a791d68e_o.jpg\" rel=\"lightbox\" title=\"Matz\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p>"> expected but was
       <"<typo:lightbox img=\"31366117\"/>">.
     # ./spec/models/text_filter_spec.rb:203:in `block (4 levels) in <top (required)>'

  12) With the list of available filters #filter_text lightbox should work with caption
     Failure/Error: assert_equal "<a href=\"http://photos23.flickr.com/31366117_b1a791d68e_o.jpg\" rel=\"lightbox\" title=\"Matz\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a>",
     MiniTest::Assertion:
       <"<a href=\"http://photos23.flickr.com/31366117_b1a791d68e_o.jpg\" rel=\"lightbox\" title=\"Matz\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a>"> expected but was
       <"<typo:lightbox img=\"31366117\" caption=\"\"/>">.
     # ./spec/models/text_filter_spec.rb:210:in `block (4 levels) in <top (required)>'

  13) With the list of available filters #filter_text combining a post-macro with markdown correctly interprets the macro
     Failure/Error: result.should =~ %r{<div style="float:left" class="flickrplugin"><a href="http://www.flickr.com/users/scottlaird/31366117"><img src="http://photos23.flickr.com/31366117_b1a791d68e_s.jpg" width="75" height="75" alt="Matz" title="Matz"/></a><p class="caption" style="width:75px">This is Matz, Ruby's creator</p></div>}
       expected: /<div style="float:left" class="flickrplugin"><a href="http:\/\/www.flickr.com\/users\/scottlaird\/31366117"><img src="http:\/\/photos23.flickr.com\/31366117_b1a791d68e_s.jpg" width="75" height="75" alt="Matz" title="Matz"\/><\/a><p class="caption" style="width:75px">This is Matz, Ruby's creator<\/p><\/div>/
            got: "<p><div style=\"float:left\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"//photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p></div></p>" (using =~)
       Diff:
       @@ -1,2 +1,2 @@
       -/<div style="float:left" class="flickrplugin"><a href="http:\/\/www.flickr.com\/users\/scottlaird\/31366117"><img src="http:\/\/photos23.flickr.com\/31366117_b1a791d68e_s.jpg" width="75" height="75" alt="Matz" title="Matz"\/><\/a><p class="caption" style="width:75px">This is Matz, Ruby's creator<\/p><\/div>/
       +"<p><div style=\"float:left\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"//photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p></div></p>"

     # ./spec/models/text_filter_spec.rb:222:in `block (5 levels) in <top (required)>'

  14) With the list of available filters #filter_text combining a post-macro with markdown correctly interprets the macro
     Failure/Error: result.should == "<div style=\"float:left\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p></div>"
       expected: "<div style=\"float:left\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"http://photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p></div>"
            got: "<div style=\"float:left\" class=\"flickrplugin\"><a href=\"http://www.flickr.com/users/scottlaird/31366117\"><img src=\"//photos23.flickr.com/31366117_b1a791d68e_s.jpg\" width=\"75\" height=\"75\" alt=\"Matz\" title=\"Matz\"/></a><p class=\"caption\" style=\"width:75px\">This is Matz, Ruby's creator</p></div>" (using ==)
     # ./spec/models/text_filter_spec.rb:230:in `block (5 levels) in <top (required)>'

Finished in 3 minutes 37.31 seconds
1248 examples, 14 failures, 7 pending

Failed examples:

rspec ./spec/controllers/admin/content_controller_spec.rb:338 # Admin::ContentController with admin connection it should behave like new action should create a filtered article
rspec ./spec/controllers/admin/content_controller_spec.rb:338 # Admin::ContentController with publisher connection it should behave like new action should create a filtered article
rspec ./spec/lib/transforms_spec.rb:6 # String#to_title should handle the case where item.body is nil
rspec ./spec/models/article_spec.rb:470 # Article#comment_url should render complete url of comment
rspec ./spec/models/article_spec.rb:477 # Article#preview_comment_url should render complete url of comment
rspec ./spec/models/text_filter_spec.rb:79 # With the list of available filters #filter_text specific typo tags flickr should show with default settings
rspec ./spec/models/text_filter_spec.rb:86 # With the list of available filters #filter_text specific typo tags flickr should use default image size
rspec ./spec/models/text_filter_spec.rb:93 # With the list of available filters #filter_text specific typo tags flickr should use caption
rspec ./spec/models/text_filter_spec.rb:188 # With the list of available filters #filter_text lightbox should work
rspec ./spec/models/text_filter_spec.rb:195 # With the list of available filters #filter_text lightbox shoudl use default thumb image size
rspec ./spec/models/text_filter_spec.rb:202 # With the list of available filters #filter_text lightbox should use default display image size
rspec ./spec/models/text_filter_spec.rb:209 # With the list of available filters #filter_text lightbox should work with caption
rspec ./spec/models/text_filter_spec.rb:219 # With the list of available filters #filter_text combining a post-macro with markdown correctly interprets the macro
rspec ./spec/models/text_filter_spec.rb:227 # With the list of available filters #filter_text combining a post-macro with markdown correctly interprets the macro
@brodock

any update on this issue?

@Flameeyes

Doubt so, I'm not going to spend much time on trying to fix specs that are vastly broken by design, and the rest of the Typo team does not seem to care about fixing their stuff.

I actually have a couple more fixes, mostly to use a modern version of the Gravatar API, but for the most part I only care about re-applying my fixes on top of master nowadays, from time to time.

@brodock

I can do the heavy work of fixing specs... I just want to have some directions to what fix first. I've noticed by what mvz posted here, that there are specs that are wrong by default... if someone from the core team could just create a simple "todo" list of what have to be changed I can do it.

I'm asking that because I don't have that much time to figure out that information by myself, but want to contribute some time doing actual useful work.

@mvz
Owner

@Flameeyes can you please tell me what needs fixing? I have provided output of the failing tests and have not heard back since. There's a lot wrong with the specs, mostly because they're an accretion of 7 years of different insights into TDD/BDD. Unfortunately, it's all we have, and doing a massive overhaul is a lot of work.

As to this branch: The text filter settings issue has been fixed differently in master, but the other fixes are still worth merging. I can cherry-pick the commits that apply cleanly and leave the ones that break the specs. Then, we can see what still needs to be done.

@mvz mvz referenced this pull request from a commit
@mvz mvz Merge branch 'several-fixes'
Merges in most of pull request #145.
eaa038c
@mvz
Owner

I was able to cherry-pick most of these commits by applying simple fixes to the specs, except for the following commits:

  • 49f5cc1: This breaks the lightbox filter because the #base_blog_url controller method cannot be accessed from the filter.
  • 2f864a5: The text filter issues were fixed differently in master.
@mvz
Owner
mvz commented

No further information received. I'm done here.

@mvz mvz closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 17, 2013
  1. @Flameeyes

    admin/feedback: make sure that "Mark checked item as (Ham|Spam)" do w…

    Flameeyes authored
    …hat they say.
    
    The behaviour of these was to just toggle the state, now they are
    actually marking them as ham/spam so that they don't misbehave.
  2. @Flameeyes

    akismet: save the user agent and submit it when checking for/submitti…

    Flameeyes authored
    …ng spam.
    
    The User-Agent sent by the commenter is often a good piece of
    information to identify whether a comment is spam or not, so make sure
    not to blackhole it and instead store and submit it.
  3. @Flameeyes
  4. @Flameeyes
  5. @Flameeyes

    flickr: make use of protocol-relative URIs on the returned source data.

    Flameeyes authored
    Also, for lightbox, make sure that it uses fully relative paths for
    the stylesheets and lightbox as otherwise it can also escape the HTTPS
    protocol.
  6. @Flameeyes

    comments: use relative URLs for comment forms.

    Flameeyes authored
    Using full, absoltue URLs will cause testing environment to comment on
    production instances, and will also break HTTPS support on
    mixed-protocols sites.
  7. @Flameeyes
  8. @Flameeyes

    Fix links to relative paths instead of absolute paths.

    Flameeyes authored
    This unbreaks the view on a local test system and supports HTTPS more
    properly.
  9. @Flameeyes

    excerpts: pre-process the excerpts with the filter

    Flameeyes authored
    This allows posts with markup early in the body to not show said markup.
Commits on Feb 18, 2013
  1. @Flameeyes

    Add very basic support for OpenGraph data.

    Flameeyes authored
    This allows at least the title of the page and the title of the site
    to be expressed as OpenGraphs
  2. @Flameeyes
  3. @Flameeyes
Commits on Mar 1, 2013
  1. @Flameeyes
This page is out of date. Refresh to see the latest.
Showing with 77 additions and 36 deletions.
  1. +2 −2 app/controllers/admin/content_controller.rb
  2. +2 −2 app/controllers/admin/feedback_controller.rb
  3. +1 −1  app/controllers/admin/pages_controller.rb
  4. +2 −2 app/controllers/application_controller.rb
  5. +3 −3 app/helpers/application_helper.rb
  6. +2 −2 app/helpers/content_helper.rb
  7. +7 −2 app/models/article.rb
  8. +0 −1  app/models/comment.rb
  9. +13 −0 app/models/content_base.rb
  10. +13 −4 app/models/feedback.rb
  11. +2 −0  app/views/shared/_page_header.html.erb
  12. +9 −0 db/migrate/108_adds_feedback_useragent.rb
  13. 0  lib/generators/sidebar/templates/Rakefile
  14. +11 −11 lib/transforms.rb
  15. 0  public/images/admin/blue/ui-bg_diagonals-thick_90_eeeeee_40x40.png
  16. 0  public/images/admin/blue/ui-bg_flat_100_bbd451_40x100.png
  17. 0  public/images/admin/blue/ui-bg_flat_100_f9f9f9_40x100.png
  18. 0  public/images/admin/blue/ui-bg_flat_15_cd0a0a_40x100.png
  19. 0  public/images/admin/blue/ui-bg_glass_100_e4f1fb_1x400.png
  20. 0  public/images/admin/blue/ui-bg_glass_50_4b7f9e_1x400.png
  21. 0  public/images/admin/blue/ui-bg_glass_80_d7ebf9_1x400.png
  22. 0  public/images/admin/blue/ui-bg_highlight-hard_70_000000_1x100.png
  23. 0  public/images/admin/blue/ui-bg_highlight-soft_100_719ab2_1x100.png
  24. 0  public/images/admin/blue/ui-icons_2694e8_256x240.png
  25. 0  public/images/admin/blue/ui-icons_2e83ff_256x240.png
  26. 0  public/images/admin/blue/ui-icons_3d80b3_256x240.png
  27. 0  public/images/admin/blue/ui-icons_72a7cf_256x240.png
  28. 0  public/images/admin/blue/ui-icons_ffffff_256x240.png
  29. 0  public/javascripts/ckcustom.js
  30. 0  public/javascripts/growler.js
  31. 0  public/stylesheets/growler.css
  32. 0  public/stylesheets/lightbox.css
  33. 0  themes/typographic/images/accept.png
  34. 0  themes/typographic/images/accept50.png
  35. 0  themes/typographic/images/bg_white.png
  36. 0  themes/typographic/images/bullet_bottom.png
  37. 0  themes/typographic/images/bullet_right.png
  38. 0  themes/typographic/images/email_open.png
  39. 0  themes/typographic/images/email_open50.png
  40. 0  themes/typographic/images/meta.png
  41. 0  themes/typographic/images/page_edit.png
  42. 0  themes/typographic/images/page_edit50.png
  43. 0  themes/typographic/images/tag.png
  44. 0  themes/typographic/images/user.png
  45. 0  themes/typographic/images/user50.png
  46. 0  themes/typographic/images/world_link.png
  47. 0  themes/typographic/images/world_link50.png
  48. 0  themes/typographic/stylesheets/colors.css
  49. 0  themes/typographic/stylesheets/layout.css
  50. 0  themes/typographic/stylesheets/reset.css
  51. 0  themes/typographic/stylesheets/style.css
  52. 0  themes/typographic/views/theme/static_view_test.html.erb
  53. +1 −1  vendor/plugins/typo_avatar_gravatar/lib/typo_avatar_gravatar.rb
  54. +3 −1 vendor/plugins/typo_textfilter_flickr/lib/typo_textfilter_flickr.rb
  55. +6 −4 vendor/plugins/typo_textfilter_lightbox/lib/typo_textfilter_lightbox.rb
View
4 app/controllers/admin/content_controller.rb
@@ -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?
View
4 app/controllers/admin/feedback_controller.rb
@@ -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!)
View
2  app/controllers/admin/pages_controller.rb
@@ -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
View
4 app/controllers/application_controller.rb
@@ -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)
View
6 app/helpers/application_helper.rb
@@ -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 = {})
View
4 app/helpers/content_helper.rb
@@ -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
9 app/models/article.rb
@@ -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
1  app/models/comment.rb
@@ -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
13 app/models/content_base.rb
@@ -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
17 app/models/feedback.rb
@@ -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
View
2  app/views/shared/_page_header.html.erb
@@ -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 %>
View
9 db/migrate/108_adds_feedback_useragent.rb
@@ -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
0  lib/generators/sidebar/templates/Rakefile 100755 → 100644
File mode changed
View
22 lib/transforms.rb
@@ -43,9 +43,9 @@ 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)
@@ -53,18 +53,18 @@ def to_title(item, settings, params)
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
View
0  public/images/admin/blue/ui-bg_diagonals-thick_90_eeeeee_40x40.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
0  public/images/admin/blue/ui-bg_flat_100_bbd451_40x100.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
0  public/images/admin/blue/ui-bg_flat_100_f9f9f9_40x100.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
0  public/images/admin/blue/ui-bg_flat_15_cd0a0a_40x100.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
0  public/images/admin/blue/ui-bg_glass_100_e4f1fb_1x400.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
0  public/images/admin/blue/ui-bg_glass_50_4b7f9e_1x400.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
0  public/images/admin/blue/ui-bg_glass_80_d7ebf9_1x400.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
0  public/images/admin/blue/ui-bg_highlight-hard_70_000000_1x100.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
0  public/images/admin/blue/ui-bg_highlight-soft_100_719ab2_1x100.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
0  public/images/admin/blue/ui-icons_2694e8_256x240.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
0  public/images/admin/blue/ui-icons_2e83ff_256x240.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
0  public/images/admin/blue/ui-icons_3d80b3_256x240.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
0  public/images/admin/blue/ui-icons_72a7cf_256x240.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
0  public/images/admin/blue/ui-icons_ffffff_256x240.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
0  public/javascripts/ckcustom.js 100755 → 100644
File mode changed
View
0  public/javascripts/growler.js 100755 → 100644
File mode changed
View
0  public/stylesheets/growler.css 100755 → 100644
File mode changed
View
0  public/stylesheets/lightbox.css 100755 → 100644
File mode changed
View
0  themes/typographic/images/accept.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
0  themes/typographic/images/accept50.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
0  themes/typographic/images/bg_white.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
0  themes/typographic/images/bullet_bottom.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
0  themes/typographic/images/bullet_right.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
0  themes/typographic/images/email_open.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
0  themes/typographic/images/email_open50.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
0  themes/typographic/images/meta.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
0  themes/typographic/images/page_edit.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
0  themes/typographic/images/page_edit50.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
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
0  themes/typographic/images/user.png 100755 → 100644
Diff not rendered
View
0  themes/typographic/images/user50.png 100755 → 100644
Diff not rendered
View
0  themes/typographic/images/world_link.png 100755 → 100644
Diff not rendered
View
0  themes/typographic/images/world_link50.png 100755 → 100644
Diff not rendered
View
0  themes/typographic/stylesheets/colors.css 100755 → 100644
File mode changed
View
0  themes/typographic/stylesheets/layout.css 100755 → 100644
File mode changed
View
0  themes/typographic/stylesheets/reset.css 100755 → 100644
File mode changed
View
0  themes/typographic/stylesheets/style.css 100755 → 100644
File mode changed
View
0  themes/typographic/views/theme/static_view_test.html.erb 100755 → 100644
File mode changed
View
2  vendor/plugins/typo_avatar_gravatar/lib/typo_avatar_gravatar.rb
@@ -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
View
4 vendor/plugins/typo_textfilter_flickr/lib/typo_textfilter_flickr.rb
@@ -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?
View
10 vendor/plugins/typo_textfilter_lightbox/lib/typo_textfilter_lightbox.rb
@@ -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
Something went wrong with that request. Please try again.