Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Url (issue #59) #64

Closed
wants to merge 3 commits into from

2 participants

@msevestre
Collaborator

All right. That should fix the url issue for issue #59
However, all old previous url are not compatible anymore if the blog was not mounted under /

@jipiboily
Owner

How would you handle upgrades? A migration? Just an upgrade instruction? Maybe in a UPGRADE.md and specified in the CHANGELOG.md?

I would probably do a migration. Your thoughts?

@msevestre
Collaborator

Migration would be ideal. (it would just remove the // from any url if required.
On the other hand, an upgrade.md file might be enough. We could also provide a rake task that would do the migration. The user would be in charged of running the rake file if required

@jipiboily
Owner

This was merged here 096ee35

I also added a migration (832ea73), changed tips in UI (7e7f51b) and added a UPGRADE.md file to help people with upgrades(5b6bbac).

@jipiboily jipiboily closed this
@jipiboily
Owner

Thanks a lot Michael!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 14, 2012
  1. @msevestre

    initial commit

    msevestre authored
Commits on May 23, 2012
  1. @msevestre
  2. @msevestre
This page is out of date. Refresh to see the latest.
View
4 .gitignore
@@ -9,4 +9,8 @@ spec/dummy/tmp/
.DS_Store
.dropbox
+.idea/
+
+.idea/**/*
+
Gemfile.lock
View
2  .rvmrc
@@ -1 +1 @@
-rvm use 1.9.3@monologue
+rvm use 1.9.3@monologue --create
View
4 app/controllers/monologue/posts_controller.rb
@@ -8,9 +8,9 @@ def index
def show
unless current_user
- post = Monologue::Post.published.where("monologue_posts_revisions.url = :url", {:url => root_path + params[:post_url]}).first
+ post = Monologue::Post.published.where("monologue_posts_revisions.url = :url", {:url => params[:post_url]}).first
else
- post = Monologue::Post.default.where("monologue_posts_revisions.url = :url", {:url => root_path + params[:post_url]}).first
+ post = Monologue::Post.default.where("monologue_posts_revisions.url = :url", {:url => params[:post_url]}).first
end
if post.nil?
not_found
View
6 app/models/monologue/posts_revision.rb
@@ -23,12 +23,16 @@ def latest_revision_is_current
post.save!
end
+ def full_url
+ "#{Monologue::Engine.routes.url_helpers.root_path}#{self.url}"
+ end
+
private
def generate_url
year = self.published_at.class == ActiveSupport::TimeWithZone ? self.published_at.year : DateTime.now.year
self.title = "" if self.title.nil?
- self.url = "#{Monologue::Engine.routes.url_helpers.root_path}#{year}/#{self.title.parameterize}" if self.url.nil? || self.url.strip == ""
+ self.url = "#{year}/#{self.title.parameterize}" if self.url.nil? || self.url.strip == ""
end
end
end
View
2  app/views/monologue/admin/posts/_form.html.erb
@@ -7,7 +7,7 @@
<% end %>
<%= post.check_box :published, :label => t(".published") %>
-<%= post.submit t(".save"), :class => "btn btn-large btn-primary" %> <a href="<%= @revision.url %>" target="_blank" class="btn btn-large"><%= t(".preview") %></a>
+<%= post.submit t(".save"), :class => "btn btn-large btn-primary" %> <a href="<%= @revision.full_url %>" target="_blank" class="btn btn-large"><%= t(".preview") %></a>
<script>
if($.fn.datepicker.defaults_<%= I18n.locale %>){
View
2  app/views/monologue/posts/index.html.erb
@@ -3,7 +3,7 @@
<section>
<header>
- <h1><%= link_to revision.title, revision.url %></h1>
+ <h1><%= link_to revision.title, revision.full_url %></h1>
<time datetime="<%= revision.published_at %>">
<%= revision.published_at.to_date.to_formatted_s(:long_ordinal) %>
</time>&nbsp;&nbsp;|&nbsp;&nbsp;<%= revision.user.name %>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="<%= revision.url + "#disqus_thread" %>"></a>
View
2  spec/dummy/config/database.yml
@@ -6,7 +6,6 @@ development:
pool: 5
username: root
password:
- socket: /tmp/mysql.sock
test:
adapter: mysql2
@@ -16,7 +15,6 @@ test:
pool: 5
username: root
password:
- socket: /tmp/mysql.sock
production:
adapter: sqlite3
View
8 spec/factories/monologue_posts_and_revisions.rb
@@ -7,7 +7,7 @@
factory :posts_revision, :class => Monologue::PostsRevision do
sequence(:title) {|i| "post #{i} | revision 1"}
content "this is some text with french accents éàöûù and so on...even html tags like <br />"
- sequence(:url) { |i| "/monologue/post/#{i}" }
+ sequence(:url) { |i| "post/#{i}" }
association :user
association :post
sequence(:published_at) {|i| DateTime.new(2012,1,1,12,0,17) + i.days }
@@ -15,11 +15,11 @@
factory :unpublished_post, :class => Monologue::Post, :parent => :post do |post|
published false
- post.after_create { |p| Factory(:posts_revision, :post => p, :title => "unpublished", :url => "/monologue/unpublished") }
+ post.after_create { |p| Factory(:posts_revision, :post => p, :title => "unpublished", :url => "unpublished") }
end
factory :post_with_multiple_revisions, :class => Monologue::Post, :parent => :post do |post|
- post.after_create { |p| Factory(:posts_revision, :post => p, :title => "post X | revision 1", :url => "/monologue/post/x") }
- post.after_create { |p| Factory(:posts_revision, :post => p, :title => "post X | revision 2", :url => "/monologue/post/x") }
+ post.after_create { |p| Factory(:posts_revision, :post => p, :title => "post X | revision 1", :url => "post/x") }
+ post.after_create { |p| Factory(:posts_revision, :post => p, :title => "post X | revision 2", :url => "post/x") }
end
end
View
2  spec/models/monologue/posts_revision_spec.rb
@@ -25,7 +25,7 @@
it "should create permalink (url) automaticly with title and year if none is provided" do
title = "this is a great title!!!"
post = Factory(:posts_revision, :url => "", :title => title, :published_at => "2012-02-02")
- post.url.should == "/monologue/2012/this-is-a-great-title"
+ post.url.should == "2012/this-is-a-great-title"
end
it { validate_presence_of(:title) }
View
14 spec/requests/cache_spec.rb
@@ -5,7 +5,7 @@
@post_1 = Factory(:posts_revision).post
@post_2 = Factory(:posts_revision).post
@post_3 = Factory(:posts_revision).post
- 25.times { |i| Factory(:posts_revision, :title => "post #{i}", :url => "/monologue/post/#{i}") }
+ 25.times { |i| Factory(:posts_revision, :title => "post #{i}", :url => "post/#{i}") }
ActionController::Base.perform_caching = true
clear_cache
end
@@ -31,7 +31,7 @@
describe "sweeper" do
before(:each) do
- @test_paths = ["/monologue", @post_1.latest_revision.url, @post_2.latest_revision.url, @post_3.latest_revision.url]
+ @test_paths = ["/monologue","/monologue/#{@post_1.latest_revision.url}", "/monologue/#{@post_2.latest_revision.url}", "/monologue/#{@post_3.latest_revision.url}"]
@test_paths.each do |path|
assert_create_cache(path)
end
@@ -41,7 +41,7 @@
it "should clear cache on create" do
post = Factory(:post)
cache_sweeped?(["/monologue"]).should be_true
- cache_sweeped?([@post_2.latest_revision.url, @post_3.latest_revision.url]).should be_false
+ cache_sweeped?(["/monologue/#{@post_2.latest_revision.url}", "/monologue/#{@post_3.latest_revision.url}"]).should be_false
cache_sweeped?([feed_path], "rss").should be_true
end
@@ -49,23 +49,23 @@
@post_1.save!
cache_sweeped?([@post_1.latest_revision.url]).should be_true
cache_sweeped?(["/monologue/"]).should be_true
- cache_sweeped?([@post_2.latest_revision.url, @post_3.latest_revision.url]).should be_false
+ cache_sweeped?(["/monologue/#{@post_2.latest_revision.url}", "/monologue/#{@post_3.latest_revision.url}"]).should be_false
cache_sweeped?([feed_path], "rss").should be_true
end
it "should clear cache on destroy" do
@post_1.destroy
cache_sweeped?(["/monologue/"]).should be_true
- cache_sweeped?([@post_2.latest_revision.url, @post_3.latest_revision.url]).should be_false
+ cache_sweeped?(["/monologue/#{@post_2.latest_revision.url}", "/monologue/#{@post_3.latest_revision.url}"]).should be_false
cache_sweeped?([feed_path], "rss").should be_true
end
it "won't clean cache if saving a not yet published post" do
@post_1.published = false
@post_1.save!
- cache_sweeped?([@post_1.latest_revision.url]).should be_false
+ cache_sweeped?(["/monologue/#{@post_1.latest_revision.url}"]).should be_false
cache_sweeped?(["/monologue/"]).should be_false
- cache_sweeped?([@post_2.latest_revision.url, @post_3.latest_revision.url]).should be_false
+ cache_sweeped?(["/monologue/#{@post_2.latest_revision.url}", "/monologue/#{@post_3.latest_revision.url}"]).should be_false
cache_sweeped?([feed_path], "rss").should be_false
end
end
View
5 spec/requests/preview_spec.rb
@@ -1,9 +1,10 @@
require 'spec_helper'
describe "preview" do
before(:each) do
- @post_path = "/monologue/post/1"
+ url ="post/1"
+ @post_path = "/monologue/#{url}"
@post_title = "post 1 | revision 1"
- Factory(:posts_revision, :title => @post_title, :url => @post_path)
+ Factory(:posts_revision, :title => @post_title, :url => url)
ActionController::Base.perform_caching = true
clear_cache
end
Something went wrong with that request. Please try again.