Try to fill the samples generated by the content type generator as much as possible thanks to Faker
did
committed Jan 14, 2013
commit 29cacfe1e39913abd2b40e72b5edcece415a67af
Showing 7
changed files with
41 additions
and 15 deletions
TODO
+7
-5
| @@ | @@ -15,11 +15,11 @@ x static js/css assets (non coffeescript or sass files) are not reloaded if got |
| x content types / liquid | |
| x group_contents_by | |
| x select_names | |
| + | x params to launch the thin server (port, address ?) |
| - nice error page (replace the default exception middleware) to display: | |
| - liquid errors | |
| - other exceptions | |
| - nice logs | |
| - | - params to launch the thin server (port, address ?) |
| - commands: | |
| - create | |
| - sites | |
| @@ | @@ -28,9 +28,11 @@ x content types / liquid |
| ? localized | |
| ? boilerplate | |
| - copy Bundler / Gemfile (pending) | |
| - | - content types |
| + | x content types |
| x definitions | |
| - | - data (Faker) |
| + | x data (Faker) |
| + | - page |
| + | - snippet |
| - push: | |
| - option to select to push only some parts (pages, ...etc) | |
| - --force option | |
| @@ | @@ -40,9 +42,9 @@ x content types / liquid |
| - builder when running it | |
| - engine when pushing a site | |
| - | - translations |
| + | - translations (Rod) |
| - | - tests |
| + | - tests (Rod/Did) |
| - refactoring: | |
| x generators/sites -> generators/site | |
generators/bootstrap/public/samples/.empty_directory
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | .empty_directory |
| \ No newline at end of file | |
generators/content_type/app/content_types/%name%.yml.tt
+9
-9
| @@ | @@ -25,9 +25,9 @@ order_by: manually # default: manually, also available: created_at or any field |
| # Emails to be notified on new entries using the public API | |
| # public_submission_accounts: ['john@acme.net'] | |
| - | # Describe each field |
| + | # Describe each field. The name shoud always be an underscored string |
| fields: <% config[:fields].each_with_index do |field, index| %> | |
| - | - <%= field.name -%>: # Name of the field - should be a slug |
| + | - <%= field.name -%>: # Name of the field |
| label: <%= field.name.humanize %> | |
| type: <%= field.type %> | |
| required: <%= index == 0 ? true : field.required %> | |
| @@ | @@ -36,20 +36,20 @@ fields: <% config[:fields].each_with_index do |field, index| %> |
| # if localized, use | |
| # en: ['option1_en', 'option2_en'] | |
| # fr: ['option1_fr', 'option2_fr'] | |
| - | select_options: ['option 1', 'option 2', 'option 3'] |
| - | <% end -%><% if field.type == 'belongs_to' -%> |
| + | select_options: ['option 1', 'option 2', 'option 3']<% end -%><% if field.type == 'belongs_to'%> |
| # Slug of the target content type (eg post if this content type is a comment) | |
| - | class_name: <your class slug> |
| - | <% end -%><% if field.type == 'has_many' -%> |
| + | class_name: <your class slug><% end -%><% if field.type == 'has_many' -%> |
| # Define the slug of the target content type (eg. comments) | |
| class_name: <your class slug> | |
| - | # Define the name of the field referring to <%= config[:name].humanize %> in the target content type (eg. post) |
| + | # Define the name of the field referring to <%= config[:name].humanize -%> in the target content type (eg. post) |
| inverse_of: <field in your target content type> | |
| + | # If you want to manage the entries of the relationship directly from the source entry |
| ui_enabled: true | |
| <% end -%><% if field.type == 'many_to_many' -%> | |
| # Define the slug of the target content type | |
| - | class_name: SLUG OF THE TARGET CONTENT TYPE |
| - | inverse_of: NAME OF THE FIELD IN THE TARGET CONTENT TYPE |
| + | class_name: <your class slug> |
| + | inverse_of: <field in your target content type> |
| + | # If you want to manage the entries of the relationship directly from the source entry |
| ui_enabled: true | |
| <% end -%> | |
generators/content_type/data/%name%.yml.tt
+19
-1
| @@ | @@ -1,6 +1,24 @@ |
| <% 4.times do |i| -%> | |
| - "Sample <%= i + 1 %>": | |
| <% config[:fields][1..-1].each do |field| -%> | |
| - | <%= field.name -%>: <some value from Faker> |
| + | <% case field.type -%> |
| + | <% when 'string' -%> |
| + | <%= field.name -%>: "<%= Faker::Lorem.sentence -%>" |
| + | <% when 'text' -%> |
| + | <%= field.name -%>: "<%= Faker::Lorem.paragraph -%>" |
| + | <% when 'select' -%> |
| + | <%= field.name -%>: null # Use the value of a select option defined in the app/content_types/<%= config[:name] -%>.rb file. |
| + | <% when 'boolean' -%> |
| + | <%= field.name -%>: true # Or false |
| + | <% when 'date' -%> |
| + | <%= field.name -%>: <%= Time.now.strftime('%Y/%M/%d') -%> # YYYY/MM/DD |
| + | <% when 'file' -%> |
| + | <%= field.name -%>: null # Path to a file in the public/samples folder or to a remote and external file. |
| + | <% when 'belongs_to' -%> |
| + | <%= field.name -%>: null # Permalink of the target entry |
| + | <% when 'many_to_many' -%> |
| + | <%= field.name -%>: [] # Permalink of the target entries |
| <% end -%> | |
| + | <% end -%> |
| + | |
| <% end -%> | |
| \ No newline at end of file | |
locomotive/builder/generators/content_type.rb b/lib/locomotive/builder/generators/content_type.rb
+1
-0
| @@ | @@ -2,6 +2,7 @@ require 'thor/group' |
| require 'ostruct' | |
| require 'active_support' | |
| require 'active_support/core_ext' | |
| + | require 'faker' |
| module Locomotive | |
| module Builder | |
locomotive/builder/liquid/drops/content_entry.rb b/lib/locomotive/builder/liquid/drops/content_entry.rb
+2
-0
| @@ | @@ -14,6 +14,8 @@ module Locomotive |
| @_source._permalink.try(:parameterize) | |
| end | |
| + | alias :_slug :_permalink |
| + | |
| def next | |
| self | |
| end | |
locomotivecms_builder.gemspec
+2
-0
| @@ | @@ -33,6 +33,8 @@ Gem::Specification.new do |gem| |
| gem.add_dependency 'will_paginate', '~> 3.0.3' | |
| # gem.add_dependency 'locomotivecms_mounter' # remove from Gemfile before adding it here | |
| + | gem.add_dependency 'faker', '~> 0.9.5' |
| + | |
| gem.add_development_dependency 'rspec' | |
| gem.add_development_dependency 'vcr' | |
| gem.add_development_dependency 'webmock', '~> 1.8.0' | |