Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix pretty permalinks in server auto #219

Closed
wants to merge 1 commit into from

3 participants

@darwin

The problem is that directory creation code for pages does not update them in --server --auto mode when user modifies the source file. It generates them just during initial generation after launching jekyll.

I introduced pretty_flat mode which behaves consistently in my opinion. It does not create directories /pagename/index.html for pages but generates simple /pagename and works consistently both in batch and --server --auto mode. My other pull requests are solving the problem of mime type with naked /pagename urls (which was probably your original motivation why to implement it as /pagename/index.html)

@darwin darwin introducing pretty_flat permalink mode
it behaves like pretty mode, but it does not create directories for non-index pages. it also works correctly in --server --auto mode.
3118c56
@mojombo
Owner

I like this idea, but this implementation only works for pages. To merge this in, it will need to work for posts as well.

@parkr
Owner

Agreed, this should be more general. @darwin, want me to take a stab at it or do you have a solution in mind?

@darwin

@parkr yes, that would be great. Thanks!

@parkr
Owner

@darwin How would you envision :pretty_flat for posts? "/:categories/:year/:month/:day/:title" or "/:categories-:year-:month-:day-:title"?

@darwin

@parkr I'm sorry I have unloaded it from my head. I have no idea how this should work for posts.

@parkr
Owner

@darwin Ok, I'm going to use the latter.

@parkr
Owner

@mojombo Any thoughts on these PRs?

@parkr
Owner

We seem to have lost interest in this feature. Closing.

@parkr parkr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 20, 2010
  1. @darwin

    introducing pretty_flat permalink mode

    darwin authored
    it behaves like pretty mode, but it does not create directories for non-index pages. it also works correctly in --server --auto mode.
This page is out of date. Refresh to see the latest.
Showing with 40 additions and 0 deletions.
  1. +2 −0  lib/jekyll/page.rb
  2. +38 −0 test/test_page.rb
View
2  lib/jekyll/page.rb
@@ -45,6 +45,8 @@ def permalink
def template
if self.site.permalink_style == :pretty && !index? && html?
"/:basename/"
+ elsif self.site.permalink_style == :pretty_flat && !index? && html?
+ "/:basename"
else
"/:basename:output_ext"
end
View
38 test/test_page.rb
@@ -39,6 +39,22 @@ def do_render(page)
end
end
+ context "with pretty_flat url style" do
+ setup do
+ @site.permalink_style = :pretty_flat
+ end
+
+ should "return dir correctly" do
+ @page = setup_page('contacts.html')
+ assert_equal '/contacts', @page.url
+ end
+
+ should "return dir correctly for index page" do
+ @page = setup_page('index.html')
+ assert_equal '/', @page.dir
+ end
+ end
+
context "with any other url style" do
should "return dir correctly" do
@site.permalink_style = nil
@@ -92,6 +108,28 @@ def do_render(page)
assert File.directory?(dest_dir)
assert File.exists?(File.join(dest_dir,'sitemap.xml'))
end
+
+ should "pretty_flat: write properly without html extension" do
+ page = setup_page('contacts.html')
+ page.site.permalink_style = :pretty_flat
+ do_render(page)
+ page.write(dest_dir)
+
+ assert File.exists?(File.join(dest_dir, 'contacts'))
+ end
+
+ should "pretty_flat: write properly with extension different from html" do
+ page = setup_page("sitemap.xml")
+ page.site.permalink_style = :pretty_flat
+ do_render(page)
+ page.write(dest_dir)
+
+ assert_equal("/sitemap.xml", page.url)
+ assert_nil(page.url[/\.html$/])
+ assert File.directory?(dest_dir)
+ assert File.exists?(File.join(dest_dir,'sitemap.xml'))
+ end
+
end
end
Something went wrong with that request. Please try again.