cryogen-project / cryogen-core

Cryogen's core
Eclipse Public License 1.0
69 stars 62 forks source link

Fallback to resources/templates/{pages,posts} #67

Closed arsenerei closed 8 years ago

arsenerei commented 8 years ago

By default, when using markdown files, Cryogen will look for resources/templates/md/pages/*.md. This commits allows Cryogen to fall back to resources/templates/pages/*.md in the case that it can't find any files in the former directory. It works similarly for posts and Asciidoc files.

Since we're looking specifically for *.md for Markdown files and *.asc for Ascii files, this is an opportunity to eliminate redundancy.

lacarmen commented 8 years ago

Thanks!

lacarmen commented 8 years ago

So I should have checked this PR more carefully but this (and probably the AsciiDoc plugin too) actually needs to be updated as well which is why I've reverted the merge.

If you submit an updated PR I'll take another look :)

arsenerei commented 8 years ago

I can do that, but I'm not sure what you're referencing? This PR should work for both Markdown and Asciidoc. I can add more tests if necessary, but if there's something wrong let me know. :)

arsenerei commented 8 years ago

The default functionality of using mu/dir is preserved here

If a user chooses to (or the Cryogen template is updated) it will drop the mu/dir here.

yogthos commented 8 years ago

So, the problem is that each plugin injects the part of the path matching its extension as seen in the snippet @lacarmen linked. So, the plugins for each type of parser need to also be updated to use a fallback path.

arsenerei commented 8 years ago

I'm sorry, it's still not clear to me what you or @lacarmen are saying. Here's my understanding. The only place where dir is used is in the find-assets function. In this function I preserve using the mu/dir command, which will either be Markdown's "md" or Asciidoc's "asc". It will inject this into the first case as "templates/{dir}/pages/", so either "templates/md/pages/" or "templates/asc/pages/". If no assets are found there, then the new functionality will look at "templates/pages" instead.

With this as the proposed functionality, why must the plugins be updated to use a fallback path? Is dir used elsewhere?

yogthos commented 8 years ago

Ah sorry, I've looked a bit more and I misunderstood what was happening there. You're right the dir from the plugins should be used in the core. However, there are a few more places where the path is used, e.g. here. The full test would be to generate a new project with lein new cryogen blog, then use the latest version of cryogen-core and move the templates to the new location.

arsenerei commented 8 years ago

Ah, darn. I'll pay more attention and proceed as you described. I didn't know how to test a library locally, but I found that leiningen has a really neat feature called checkouts that makes it easier for me to iteratively develop.