Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blog/Page/Post/Tag uri customisation #56

Merged
merged 1 commit into from
Jan 8, 2016
Merged

Blog/Page/Post/Tag uri customisation #56

merged 1 commit into from
Jan 8, 2016

Conversation

sbondaryev
Copy link
Contributor

Add possibility to configure uri root directory for pages, posts and tags
via config params:

:page-root-uri
:post-root-uri
:tag-root-uri
  • to place entity to the root directory use empty value (ex. :page-root-uri "")
  • if parameter is not set corresponding {entity}-root parameter will be used
  • set empty blog-prefix to use server root

Issues:
#32
cryogen-project/cryogen#83

Related PR:
cryogen-project/cryogen#96

@sbondaryev
Copy link
Contributor Author

The core thing is the function io/path - which compose the path from elements and throw appart the empty ones (you can also specify the "/" at the beginning and the end) .
Example:
(path "/" "blog" "post" "post.name") -> "/blog/post/post.name"
(path "/" "" "post" "img" "/") -> "/post/post/img/"

I also added the function io/create-file (similar to io/create-folder) to localise "public" variable in "io" namespace.

All the other changes are:

  • replacements "str" with "path" to compose urls and file paths
  • replacements "spit" with "create-file" to save files in public dir

(copy-resources
(merge config
{:resources (for [mu (m/markups)
t ["posts" "pages"]] (str (m/dir mu) "/" t))
t (distinct [post-root page-root])] (str (m/dir mu) "/" t))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace hardcoded post/pages dir names with names from the config

@danielcompton
Copy link

Does this let you have URL's like mysite.com/2015/11/23/mypost?

@sbondaryev
Copy link
Contributor Author

No, it does not.
But it could be a good issue to discuss this feature with project maintainers.
As it could affect quite a lot the current directores structure

@lacarmen
Copy link
Member

lacarmen commented Jan 7, 2016

Hey @sbondaryev, I finally got around to looking at this pr. Sorry it took so long! Everything looks great but there's one little bug. On line 293 of compiler.clj you have

(path "/" blog-prefix "p" "index.html")

as the else condition but it should be

(path "/" blog-prefix "p" (str index ".html"))

since index is supposed to be the page number of each preview page. (I suppose it can be named better, you can change it if you want.)

If you could fix that and then squash your commits I'll merge in the pr. :)

@sbondaryev
Copy link
Contributor Author

Hello, sure I will take a look this week-end

add :tag-root-uri :page-root-uri :post-root-uri parsing

replace {entity}-root with {entity}-root-uri parameters to set uri

fix root-path call

fix root-path function params order
(worked erlier because of keyword<->map transposition)

fix keyword :{entity}-root-uri to :{entity}-root transformation

misprint: congig -> config

add function to compose file path

add create-file function

add function to compose a path

handle empty blog-path using path function

fix filename for preview
@sbondaryev
Copy link
Contributor Author

done

lacarmen pushed a commit that referenced this pull request Jan 8, 2016
Blog/Page/Post/Tag uri customisation
@lacarmen lacarmen merged commit 7040e1d into cryogen-project:master Jan 8, 2016
@lacarmen
Copy link
Member

lacarmen commented Jan 8, 2016

Thanks! I'll push a new version to Clojars and update the template as well as the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants