-
Notifications
You must be signed in to change notification settings - Fork 62
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
Shallower project structure #117
Shallower project structure #117
Conversation
The change looks good to me, and it should be possible to specify the |
c093f7a
to
479b72c
Compare
Ok so looking into it, we can make the ring server point to The downside of this is that it will make migration marginally more difficult. Though if it's worth changing probably might as well break everything at once and have some migration instruction - the easiest way might just be "check out the latest template and port your content over". |
One idea could be to add an optional config variable for the path, so it would default to |
Yeah that certainly could be useful. A few things to think about first:
I'm happy to look into these at some point if you think it's necessary, but it might take me a little while before I manage to get round to it. If you're happy without the safeguards and the more stateful approach then it should be really straightforward. I'm also happy to revert it back to |
I'd say specifying the path is mostly a nice to have, but I agree that having a guard would be good. I'd vote for merging things in without that, and creating an enhancement issue for later. Ideally, I think it would be best to pass the config around explicitly. |
I do like the idea of being able to configure the output location. It would make GH pages deployment a lot simpler. I'm okay with setting the path in
I'm okay with the "break everything at once" approach as well :) |
Ok thanks for all the feedback! Making GH deploy easier would be a nice win. Don’t mind leaving this open in case there’s need to fix something else before it’s finished, or merge into a dev branch, whatever works for you |
OK there's now an option for setting paths ( I've gone for setting the path in the var for the sake of reducing the scope of the change - I did have a go at passing the config around but then it felt like I should be changing much more when going down that path. Probably best to leave as a separate change in the future? I've added path-validation to ensure :public-dest, :resources and the main folders (content, themes, src, target) don't overlap, with some tests to check this. I split some things out in to a new Some other thoughts:
server.clj in the main cryogen repo would need to look something like this for things to work properly: (ns cryogen.server
(:require [compojure.core :refer [GET defroutes]]
[compojure.route :as route]
[ring.util.response :refer [redirect file-response]]
[ring.util.codec :refer [url-decode]]
[ring.middleware.file :refer [wrap-file]]
[cryogen-core.watcher :refer [start-watcher!]]
[cryogen-core.plugins :refer [load-plugins]]
[cryogen-core.compiler :refer [compile-assets-timed]]
[cryogen-core.config :refer [resolve-config]]
[cryogen-core.io :refer [path]]))
(defn init []
(load-plugins)
(compile-assets-timed)
(let [ignored-files (-> (resolve-config) :ignored-files)]
(start-watcher! "content" ignored-files compile-assets-timed)))
(defn wrap-subdirectories
[handler]
(fn [request]
(let [req-uri (.substring (url-decode (:uri request)) 1)
res-path (if (or (= req-uri "") (= req-uri "/"))
(path "/index.html")
(path (str req-uri ".html")))]
(or (file-response res-path {:root (:public-dest (resolve-config))})
(handler request)))))
(defroutes routes
(GET "/" [] (redirect (let [config (resolve-config)]
(path (:blog-prefix config)
(when-not (:clean-urls? config) "index.html")))))
(route/files "/" {:root (:public-dest (resolve-config))})
(route/not-found "Page not found"))
(def handler (wrap-subdirectories routes)) |
Thanks @dominicfreeston! I'll try to review/test soon. 😄 |
I'm okay with this.
I'd prefer this. I find it's a bit weird having assets like
If we go with assets relative to I tested with each of the templates as well and nothing seems to be broken :) I think we can merge this after the assets are addressed. |
OK great, I'm away this weekend so not sure I'll get to it before next week - I think making the root |
@lacarmen apologies for the delay Now changed so all resources paths are with reference to I've also updated it so that all paths in a theme are with reference to the theme folder (this will require updating the default lotus theme) - seems more consistent and predictable, what do you think? As part of the changes I've modified how the config-specified resources for a theme are loaded, with the nice side-effect that they now get printed to the console as part of the "copying theme resources" phase. The main risk is that I no longer use |
Thanks @dominicfreeston! I'll try to get around to testing this week.
Sounds good to me
Not sure about this one off the top of my head - I'll investigate. I'd like to release this after #119. I don't think there will be any conflicts in cryogen-core, but |
Just to update, I haven't forgotten about this, just been quite busy - should be able to get to it this weekend. Todo:
Let me know if there's anything else that needs doing for this |
No worries @dominicfreeston. I appreciate the work you've done on this! I think that list covers everything. The tests could use some beefing up as you mentioned, but it's not critical for this PR. (Of course I'm not going to stop you though if you want to add to them 😄) |
@lacarmen OK I've opened a couple of PRs against the other relevant repos, I think that's everything 😅. The main thing missing is updating version numbers (I wasn't sure if you wanted to go up to 0.2.0 because of quite big breaking changes or if you wanted to just bump it as normal). Thanks for your help and patience! |
@dominicfreeston I tested the whole thing together and looks like it's all good! Thanks a bunch for taking this on 😄 I can bump up all the numbers - the core will go up to 0.2.0 and the template will go to 0.5.0. |
This
(mostly)addresses issue #98. It will obviously require some related changes to the docs and the template (and maybe a quick migration guide for people who want to update), which I'm also happy to help with.This leaves the output intoresources/public/
because the ring server relies on this. I don't know if it can be changed.Project Structure Changes:
resources/templates
folder altogethercontent/
in root folderconfig.edn
tocontent/
in root folderthemes
to root folderpublic
to root folder (specifiable via:public-dest
)content/
folderOther code changes:
copy-resources
now requires a root foldercompile-sass->css!
doesn't need a base-dir (it's just root folder) so just pass in whole configpath
helper function instead ofstr
The test coverage, although useful, is obviously not total so there's certainly a risk I've broken other things. I've ran this against all 4 included templates and everything seems to be working OK.
Thanks 😃