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

✨ Custom post templates #9073

Merged
merged 24 commits into from
Oct 10, 2017
Merged

Conversation

kirrg001
Copy link
Contributor

@kirrg001 kirrg001 commented Sep 27, 2017

refs #9060

Please look at the single commits for context.

TODO

  • merge gscan PR and release new gscan version, update version here
  • more tests
  • if you configure a custom template. ensure cache is cleared
  • quality check
  • reconsider length of new db field
  • rebase master, migration for 1.13

@kirrg001 kirrg001 changed the title ✨ Custom post templates [WIP] ✨ Custom post templates Sep 27, 2017
@kevinansfield kevinansfield mentioned this pull request Sep 27, 2017
20 tasks
kevinansfield added a commit to TryGhost/Admin that referenced this pull request Sep 28, 2017
refs TryGhost/Ghost#9060, requires TryGhost/Ghost#9073
- add `{{gh-psm-template-select}}` component
  - allows selection of a custom template for a post if the active theme has custom templates
  - loads themes on render, only hitting the server if not already in the store
  - disables select if post slug matches a `post-*.hbs` or `page-*.hbs` template
- adds `customTemplate` attr to `Post` model
- adds `templates` attr to `Theme` model with CPs to pull out custom vs post/page override templates
- add `.gh-select.disabled` styles to make disabled selects look visually disabled
@kirrg001 kirrg001 force-pushed the custom-post-templates branch 3 times, most recently from cc2def3 to 9c7c55f Compare October 2, 2017 14:56
@kirrg001 kirrg001 changed the title [WIP] ✨ Custom post templates ✨ Custom post templates Oct 2, 2017
@kirrg001
Copy link
Contributor Author

kirrg001 commented Oct 2, 2017

Ready for testing!

@aileen
Copy link
Member

aileen commented Oct 3, 2017

I tested this successfully with a custom template. Also changed the theme, which doesn't have this specific template and it falls back to the default post.hbs / page.hbs. Changing then back again, the chosen post will automatically use the assigned custom template again when available.

@@ -34,5 +38,10 @@ module.exports = function toJSON(name, checkedTheme) {
}
}

// CASE: if you want a JSON response for a single theme, which is not active.
if (_.find(themeResult, {active: true}) && active.get()) {
_.find(themeResult, {active: true}).templates = active.get().customTemplates;

This comment was marked as abuse.

This comment was marked as abuse.

@kirrg001 kirrg001 force-pushed the custom-post-templates branch 2 times, most recently from 34113bd to 2a99504 Compare October 6, 2017 05:56
templateList.unshift(postObject.custom_template);
if (themes.getActive() && !themes.getActive().hasTemplate(slugTemplate)) {
templateList.unshift(postObject.custom_template);
}

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

- i've added the basic logic to gscan on my branch
- the changes there aren't final at all, just for testing
- @todo: permissions
- return 404 of :name does not exist
- right now it only returns the active theme hardcoded
- API endpoint implementation (RAW)
- gscan extracts the custom templates
- ensure we return custom templates
- take care if no active theme instance exists
- if custom_template exists, it has the highest priority
- same behaviour in Admin panel
Copy link
Member

@ErisDS ErisDS left a comment

Choose a reason for hiding this comment

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

I am still keen to change GQL to not return 2 different template lists, but we can work on that later.

kevinansfield added a commit to TryGhost/Admin that referenced this pull request Oct 10, 2017
refs TryGhost/Ghost#9060, requires TryGhost/Ghost#9073
- add `{{gh-psm-template-select}}` component
  - allows selection of a custom template for a post if the active theme has custom templates
  - loads themes on render, only hitting the server if not already in the store
  - disables select if post slug matches a `post-*.hbs` or `page-*.hbs` template
- adds `customTemplate` attr to `Post` model
- adds `templates` attr to `Theme` model with CPs to pull out custom vs post/page override templates
- add `.gh-select.disabled` styles to make disabled selects look visually disabled
@kevinansfield kevinansfield merged commit 594b0c2 into TryGhost:master Oct 10, 2017
@wassimseif
Copy link

any documentation on this ?

@kirrg001
Copy link
Contributor Author

@wassimseif There is documentation on https://themes.ghost.org and a blog post, plus a help guide is coming early next week. If you have any suggestions for documentation improvements, say hello in slack 🙃

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.

5 participants