Created
April 6, 2014 01:29
-
-
Save halsk/10000300 to your computer and use it in GitHub Desktop.
LocomotiveCMS でニュース記事一覧機能を作る ref: http://qiita.com/hal_sk/items/b72db4a288566e92096c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: Content type templates | |
slug: content_type_template | |
listed: false | |
published: true | |
position: 100 | |
content_type: news | |
--- | |
{% extends parent %} | |
{% block main %} | |
.row | |
.large-8.columns | |
.topic | |
%h3 {{news.title | escape}} | |
.date {{news.posted_at | localized_date}} | |
.lead {{news.lead}} | |
.body {{news.body}} | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% bundle exec wagon generate content_type testnews title:string posted_at:date lead:text body:text | |
exist | |
create app/content_types/news.yml | |
create data/news.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
more content_type/news.yml | |
# Public name of this content type | |
name: News | |
# TODO: explain | |
slug: News | |
# Explanation for the backoffice | |
description: A description of the content type for the editors | |
# Default field (e.g title) | |
label_field_name: title | |
# Order of entries | |
order_by: manually # default: manually, also available: created_at or any field slug | |
…中略… | |
# Describe each field. The name shoud always be an underscored string | |
fields: | |
- title: # Name of the field | |
label: Title | |
type: string | |
required: true | |
hint: A description of the field for the editors | |
localized: false | |
- posted_at: # Name of the field | |
label: Posted at | |
type: date | |
required: false | |
hint: A description of the field for the editors | |
localized: false | |
…省略… |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
order_by: posted_at | |
order_direction: desc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/Documents/.../locomotive/hackcamptest% more data/testnews.yml dev | |
- "Sample 1": | |
posted_at: 2014/04/04 # YYYY/MM/DD | |
lead: "Atque est hic dolor nihil facilis et dolores. Vero occaecati quis aliquam rem enim quia magni deserunt. Nihil ea repellat assumenda aut. Dolorem modi aut labore debitis aspernatur eius deserunt omnis. Dolorem eum ullam aut error." | |
body: "Ab quia repellat sint et dolore nesciunt. Voluptatem qui ipsam ut autem quaerat. At dolor vero dolorem qui ipsam maxime. Quis ea enim atque nobis vero est nostrum voluptatem." | |
- "Sample 2": | |
posted_at: 2014/04/04 # YYYY/MM/DD | |
lead: "Omnis eaque labore perferendis. Qui quo nulla id deserunt consectetur qui possimus. Ea est aspernatur corrupti facere pariatur. Est provident iusto ducimus itaque architecto repellat." | |
body: "Quia qui rerum corporis veniam autem quis. Ipsam atque sit blanditiis dolore eum. Natus quia quaerat eaque aliquid veritatis." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% bundle exec wagon push development -r content_types | |
* Pushing Site | |
* Pushing ContentTypes | |
updating News...............................................................[done] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% bundle exec wagon generate page news | |
Do you prefer a HAML template ? y | |
create app/views/pages/news.liquid.haml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% bundle exec wagon generate page news/content_type_templates | |
Do you prefer a HAML template ? y | |
create app/views/pages/news/content_type_templates.liquid.haml | |
conflict app/views/pages/news.liquid.haml | |
Overwrite /Users/hal/Documents/workspace/locomotive/hackcamptest/app/views/pages/news.liquid.haml? (enter "h" for help) [Ynaqdh] n | |
skip app/views/pages/news.liquid.haml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: お知らせ | |
slug: content_type_template | |
listed: true | |
published: true | |
position: 1 | |
--- | |
{% extends parent %} | |
{% block main %} | |
.row | |
.large-8.columns | |
.news | |
{% for topic in contents.news %} | |
.topic | |
%a{href:"/news/{{topic._slug}}"} | |
%h3 {{topic.title | escape}} | |
.date {{topic.posted_at | localized_date}} | |
.lead {{topic.lead}} | |
%a{href:"/news/{{topic._slug}}"} 詳細 | |
{% endfor %} | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment