slices 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/README.md +51 -0
- data/Rakefile +9 -0
- data/app/assets/images/slices/ajax-loader.gif +0 -0
- data/app/assets/images/slices/asset-background.png +0 -0
- data/app/assets/images/slices/asset-spinner.gif +0 -0
- data/app/assets/images/slices/bg_header.gif +0 -0
- data/app/assets/images/slices/black-Linen.png +0 -0
- data/app/assets/images/slices/calendar.svg +68 -0
- data/app/assets/images/slices/chosen-sprite.png +0 -0
- data/app/assets/images/slices/drag-handle.svg +9 -0
- data/app/assets/images/slices/icon_admins.png +0 -0
- data/app/assets/images/slices/icon_app.png +0 -0
- data/app/assets/images/slices/icon_assets.png +0 -0
- data/app/assets/images/slices/icon_collapse.png +0 -0
- data/app/assets/images/slices/icon_drag.png +0 -0
- data/app/assets/images/slices/icon_files.png +0 -0
- data/app/assets/images/slices/icon_generic_file.png +0 -0
- data/app/assets/images/slices/icon_images.png +0 -0
- data/app/assets/images/slices/icon_padlock.png +0 -0
- data/app/assets/images/slices/icon_page.png +0 -0
- data/app/assets/images/slices/icon_search.png +0 -0
- data/app/assets/images/slices/icon_set-link.png +0 -0
- data/app/assets/images/slices/icon_set.png +0 -0
- data/app/assets/images/slices/icon_sitemap.png +0 -0
- data/app/assets/images/slices/icon_snippets.png +0 -0
- data/app/assets/images/slices/icon_template.jpg +0 -0
- data/app/assets/images/slices/icon_upload_happy.png +0 -0
- data/app/assets/images/slices/icon_upload_sad.png +0 -0
- data/app/assets/images/slices/icon_upload_thinking.png +0 -0
- data/app/assets/images/slices/noise.png +0 -0
- data/app/assets/images/slices/sitemap_icon_ghost.png +0 -0
- data/app/assets/images/slices/sitemap_icon_home.png +0 -0
- data/app/assets/images/slices/sitemap_icon_page.png +0 -0
- data/app/assets/images/slices/sitemap_icon_set_page.png +0 -0
- data/app/assets/images/slices/sitemap_icon_virtual_page.png +0 -0
- data/app/assets/images/slices/sitemap_overlay.png +0 -0
- data/app/assets/images/slices/spinner.gif +0 -0
- data/app/assets/images/slices/trash.png +0 -0
- data/app/assets/javascripts/admin.js.erb +18 -0
- data/app/assets/javascripts/slices/app/backbones/admins.js +114 -0
- data/app/assets/javascripts/slices/app/backbones/entries.js +172 -0
- data/app/assets/javascripts/slices/app/backbones/generic.js +101 -0
- data/app/assets/javascripts/slices/app/backbones/snippets.js +113 -0
- data/app/assets/javascripts/slices/app/helpers/assets.js +61 -0
- data/app/assets/javascripts/slices/app/helpers/breadcrumbs.js +30 -0
- data/app/assets/javascripts/slices/app/helpers/composer.js +26 -0
- data/app/assets/javascripts/slices/app/helpers/date_field.js +16 -0
- data/app/assets/javascripts/slices/app/helpers/get_value.js +31 -0
- data/app/assets/javascripts/slices/app/helpers/icon_upload_names.js.erb +5 -0
- data/app/assets/javascripts/slices/app/helpers/layout.js +20 -0
- data/app/assets/javascripts/slices/app/helpers/sitemap.js +150 -0
- data/app/assets/javascripts/slices/app/helpers/slice_preview.js +48 -0
- data/app/assets/javascripts/slices/app/helpers/tagging.js +73 -0
- data/app/assets/javascripts/slices/app/helpers/token_field.js +17 -0
- data/app/assets/javascripts/slices/app/helpers/upload_icons.js.erb +5 -0
- data/app/assets/javascripts/slices/app/helpers/uploader.js +127 -0
- data/app/assets/javascripts/slices/app/models/asset.js +29 -0
- data/app/assets/javascripts/slices/app/models/asset_collection.js +41 -0
- data/app/assets/javascripts/slices/app/models/attachment.js +29 -0
- data/app/assets/javascripts/slices/app/models/attachment_collection.js +7 -0
- data/app/assets/javascripts/slices/app/models/composer_item.js +1 -0
- data/app/assets/javascripts/slices/app/models/composer_item_collection.js +3 -0
- data/app/assets/javascripts/slices/app/models/file.js +103 -0
- data/app/assets/javascripts/slices/app/models/page.js +186 -0
- data/app/assets/javascripts/slices/app/models/s3_file.js +64 -0
- data/app/assets/javascripts/slices/app/slices.js +661 -0
- data/app/assets/javascripts/slices/app/views/asset_editor_view.js.erb +209 -0
- data/app/assets/javascripts/slices/app/views/asset_library_view.js +720 -0
- data/app/assets/javascripts/slices/app/views/asset_thumb_view.js.erb +191 -0
- data/app/assets/javascripts/slices/app/views/attachment_composer_view.js +350 -0
- data/app/assets/javascripts/slices/app/views/attachment_view.js +101 -0
- data/app/assets/javascripts/slices/app/views/calendar_view.js +198 -0
- data/app/assets/javascripts/slices/app/views/composer_item_view.js +54 -0
- data/app/assets/javascripts/slices/app/views/composer_view.js +130 -0
- data/app/assets/javascripts/slices/app/views/date_field_view.js +177 -0
- data/app/assets/javascripts/slices/app/views/file_view.js +142 -0
- data/app/assets/javascripts/slices/app/views/token_field_view.js +253 -0
- data/app/assets/javascripts/slices/lib/freeze.js +14 -0
- data/app/assets/javascripts/slices/lib/human_file_size.js +16 -0
- data/app/assets/javascripts/slices/lib/json_patch.js +9 -0
- data/app/assets/javascripts/slices/lib/moment.js +47 -0
- data/app/assets/javascripts/slices/lib/plugins.js +101 -0
- data/app/assets/javascripts/slices/lib/sortable.js +14 -0
- data/app/assets/javascripts/slices/slices.js +27 -0
- data/app/assets/javascripts/slices/vendor/autoscroll.js +188 -0
- data/app/assets/javascripts/slices/vendor/backbone.js +38 -0
- data/app/assets/javascripts/slices/vendor/handlebars.js +1920 -0
- data/app/assets/javascripts/slices/vendor/jqmodal.js +69 -0
- data/app/assets/javascripts/slices/vendor/jquery-ui.js +274 -0
- data/app/assets/javascripts/slices/vendor/jquery-ui_nested-sortable.js +357 -0
- data/app/assets/javascripts/slices/vendor/jquery.ajaxprogress.js +76 -0
- data/app/assets/javascripts/slices/vendor/jquery.js +2 -0
- data/app/assets/javascripts/slices/vendor/livefield.js +459 -0
- data/app/assets/javascripts/slices/vendor/moment.js +6 -0
- data/app/assets/javascripts/slices/vendor/rails.js +315 -0
- data/app/assets/javascripts/slices/vendor/underscore-string.js +1 -0
- data/app/assets/javascripts/slices/vendor/underscore.js +5 -0
- data/app/assets/stylesheets/admin.css +1 -0
- data/app/assets/stylesheets/slices/admin.css.erb +2237 -0
- data/app/assets/stylesheets/slices/reset_html5.css +106 -0
- data/app/assets/stylesheets/slices/slices.css +7 -0
- data/app/controllers/admin/admin_controller.rb +10 -0
- data/app/controllers/admin/admins_controller.rb +76 -0
- data/app/controllers/admin/assets_controller.rb +53 -0
- data/app/controllers/admin/auth/omniauth_callbacks_controller.rb +15 -0
- data/app/controllers/admin/auth/passwords_controller.rb +4 -0
- data/app/controllers/admin/auth/sessions_controller.rb +4 -0
- data/app/controllers/admin/entries_controller.rb +88 -0
- data/app/controllers/admin/page_search_controller.rb +12 -0
- data/app/controllers/admin/pages_controller.rb +103 -0
- data/app/controllers/admin/site_maps_controller.rb +15 -0
- data/app/controllers/admin/snippets_controller.rb +33 -0
- data/app/controllers/application_controller.rb +4 -0
- data/app/controllers/pages_controller.rb +45 -0
- data/app/controllers/slices_controller.rb +63 -0
- data/app/controllers/static_assets_controller.rb +52 -0
- data/app/helpers/admin/admin_helper.rb +63 -0
- data/app/helpers/admin/assets_helper.rb +36 -0
- data/app/helpers/admin/entries_helper.rb +13 -0
- data/app/helpers/admin/site_maps_helper.rb +104 -0
- data/app/helpers/assets_helper.rb +64 -0
- data/app/helpers/navigation_helper.rb +195 -0
- data/app/helpers/pages_helper.rb +119 -0
- data/app/models/admin.rb +34 -0
- data/app/models/asset.rb +211 -0
- data/app/models/attachment.rb +11 -0
- data/app/models/layout.rb +44 -0
- data/app/models/page.rb +214 -0
- data/app/models/placeholder_slice.rb +8 -0
- data/app/models/set_page.rb +12 -0
- data/app/models/set_slice.rb +57 -0
- data/app/models/site_map.rb +24 -0
- data/app/models/slice.rb +80 -0
- data/app/models/snippet.rb +21 -0
- data/app/observers/asset_observer.rb +6 -0
- data/app/observers/page_observer.rb +37 -0
- data/app/presenters/entry_presenter.rb +17 -0
- data/app/presenters/page_presenter.rb +67 -0
- data/app/presenters/presenter.rb +9 -0
- data/app/presenters/set_page_presenter.rb +2 -0
- data/app/views/admin/admins/index.html.erb +26 -0
- data/app/views/admin/admins/show.html.erb +27 -0
- data/app/views/admin/assets/index.html.erb +1 -0
- data/app/views/admin/auth/passwords/edit.html.erb +20 -0
- data/app/views/admin/auth/passwords/new.html.erb +14 -0
- data/app/views/admin/auth/sessions/_form.html.erb +35 -0
- data/app/views/admin/auth/sessions/new.html.erb +14 -0
- data/app/views/admin/entries/index.html.erb +32 -0
- data/app/views/admin/pages/_breadcrumbs.html.erb +32 -0
- data/app/views/admin/pages/_slices.html.erb +27 -0
- data/app/views/admin/pages/new.html.erb +14 -0
- data/app/views/admin/pages/show.html.erb +50 -0
- data/app/views/admin/shared/_asset_storage.html.erb +17 -0
- data/app/views/admin/shared/_custom_links.html.erb +1 -0
- data/app/views/admin/shared/_custom_navigation.html.erb +1 -0
- data/app/views/admin/shared/_navigation.html.erb +5 -0
- data/app/views/admin/site_maps/_page_li.html.erb +20 -0
- data/app/views/admin/site_maps/_set_page_li.html.erb +23 -0
- data/app/views/admin/site_maps/index.html.erb +29 -0
- data/app/views/admin/snippets/form.html.erb +12 -0
- data/app/views/admin/snippets/index.html.erb +20 -0
- data/app/views/admin/snippets/update.html.erb +0 -0
- data/app/views/layouts/admin.html.erb +72 -0
- data/lib/ext/file_store_cache.rb +18 -0
- data/lib/generators/humans/USAGE +8 -0
- data/lib/generators/humans/humans_generator.rb +10 -0
- data/lib/generators/humans/templates/humans.txt +6 -0
- data/lib/generators/slice/USAGE +28 -0
- data/lib/generators/slice/slice_generator.rb +123 -0
- data/lib/generators/slice/templates/main_fields.hbs +11 -0
- data/lib/generators/slice/templates/meta_fields.hbs +11 -0
- data/lib/generators/slice/templates/page.rb +19 -0
- data/lib/generators/slice/templates/presenter.rb +53 -0
- data/lib/generators/slice/templates/set.html.erb +8 -0
- data/lib/generators/slice/templates/set_slice.rb +14 -0
- data/lib/generators/slice/templates/set_slice_fields.hbs +5 -0
- data/lib/generators/slice/templates/show.html.erb +48 -0
- data/lib/generators/slice/templates/show_slice.rb +20 -0
- data/lib/generators/slice/templates/slice.rb +58 -0
- data/lib/generators/slice/templates/slice_fields.hbs +74 -0
- data/lib/generators/templates/slices.rb +211 -0
- data/lib/mongo_search.rb +84 -0
- data/lib/paperclip_validator.rb +5 -0
- data/lib/rack_utf8_fix.rb +10 -0
- data/lib/sRGB.icc +0 -0
- data/lib/set_link_renderer.rb +31 -0
- data/lib/slices.rb +68 -0
- data/lib/slices/asset/maker.rb +55 -0
- data/lib/slices/asset/rename.rb +67 -0
- data/lib/slices/available_slices.rb +43 -0
- data/lib/slices/cms_form_builder.rb +42 -0
- data/lib/slices/config.rb +93 -0
- data/lib/slices/container_parser.rb +70 -0
- data/lib/slices/generator_macros.rb +36 -0
- data/lib/slices/has_attachments.rb +111 -0
- data/lib/slices/has_slices.rb +88 -0
- data/lib/slices/i18n.rb +6 -0
- data/lib/slices/i18n/backend.rb +32 -0
- data/lib/slices/i18n_backend.rb +24 -0
- data/lib/slices/paperclip.rb +13 -0
- data/lib/slices/position_helper.rb +98 -0
- data/lib/slices/renderer.rb +52 -0
- data/lib/slices/slices_engine.rb +51 -0
- data/lib/slices/split_date_time_field.rb +14 -0
- data/lib/slices/tasks/assets.rake +35 -0
- data/lib/slices/tasks/db.rake +50 -0
- data/lib/slices/tasks/seeds.rake +93 -0
- data/lib/slices/tasks/validate.rake +62 -0
- data/lib/slices/tree.rb +306 -0
- data/lib/slices/version.rb +4 -0
- data/lib/slices/will_paginate.rb +12 -0
- data/lib/slices/will_paginate_mongoid.rb +45 -0
- data/lib/standard_tree.rb +193 -0
- metadata +483 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
class <%= page_name.classify %> < Page
|
2
|
+
<%= field_definitions %>
|
3
|
+
|
4
|
+
def entry?
|
5
|
+
true
|
6
|
+
end
|
7
|
+
|
8
|
+
def template
|
9
|
+
"<%= file_name %>/views/show"
|
10
|
+
end
|
11
|
+
|
12
|
+
# Uncomment the as_json method if the page defines fields that are
|
13
|
+
# shown in the admin UI. Pass a hash to merge() that contains each
|
14
|
+
# field.
|
15
|
+
#
|
16
|
+
# def as_json(options = {})
|
17
|
+
# super.merge(published: published.to_s)
|
18
|
+
# end
|
19
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class <%= page_name.classify %>Presenter < PagePresenter
|
2
|
+
include EntryPresenter
|
3
|
+
|
4
|
+
# We need to tell the admin UI which fields to show when presenting a
|
5
|
+
# table of entries in the admin UI. Each key in the column hash should
|
6
|
+
# be a symbol matching the name of one of the fields defined on the
|
7
|
+
# page.
|
8
|
+
#
|
9
|
+
# The hash's values (e.g. 'Date Published') will be used for the
|
10
|
+
# column headings in the admin UI.
|
11
|
+
|
12
|
+
@columns = {
|
13
|
+
name: 'Name',
|
14
|
+
# published_at: 'Date Published'
|
15
|
+
}
|
16
|
+
class << self
|
17
|
+
attr_reader :columns
|
18
|
+
end
|
19
|
+
|
20
|
+
<%- if options.with_entry_templates? -%>
|
21
|
+
def main_extra_template
|
22
|
+
'<%= file_name %>/<%= page_name %>_main'
|
23
|
+
end
|
24
|
+
|
25
|
+
def meta_extra_template
|
26
|
+
'<%= file_name %>/<%= page_name %>_meta'
|
27
|
+
end
|
28
|
+
<%- else -%>
|
29
|
+
# If you want to display extra information while editing or creating a
|
30
|
+
# page (i.e. in the admin UI's side bar) you'll need to define some
|
31
|
+
# .hbs files, and then tell the CMS to use them by uncommenting these
|
32
|
+
# methods.
|
33
|
+
|
34
|
+
# def main_extra_template
|
35
|
+
# '<%= file_name %>/<%= page_name %>_main'
|
36
|
+
# end
|
37
|
+
|
38
|
+
# def meta_extra_template
|
39
|
+
# '<%= file_name %>/<%= page_name %>_meta'
|
40
|
+
# end
|
41
|
+
<%- end -%>
|
42
|
+
|
43
|
+
# The CMS needs to know how to present the data stored on a page;
|
44
|
+
# it's not always good enough just to convert it to a string and
|
45
|
+
# render it into the page. You can access the page through the @source
|
46
|
+
# variable.
|
47
|
+
|
48
|
+
def name
|
49
|
+
@source.name.blank? ? "(name isn't set)" : @source.name
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%%= will_paginate slice.page_entries, renderer: SetLinkRenderer, class: 'pagination above' %>
|
2
|
+
<ul class="entries">
|
3
|
+
<%% slice.page_entries.each do |entry| -%>
|
4
|
+
<li><%%= link_to entry.name, entry.path %></li>
|
5
|
+
<%% end -%>
|
6
|
+
</ul>
|
7
|
+
<%%= will_paginate slice.page_entries, renderer: SetLinkRenderer, class: 'pagination below' %>
|
8
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<div class="slice <%= file_name %>">
|
2
|
+
<% if form_slice? -%>
|
3
|
+
<%%= form_for slice, url: slice.page.path do |f| %>
|
4
|
+
<% end -%>
|
5
|
+
|
6
|
+
<!--
|
7
|
+
Stick the HTML that should be rendered when your slice is displayed here.
|
8
|
+
|
9
|
+
You can refer to data stored on your slice by calling slice.foo inside
|
10
|
+
a normal ERB code block.
|
11
|
+
|
12
|
+
<%- if form_slice? -%>
|
13
|
+
For more information on available form helpers, see:
|
14
|
+
http://guides.rubyonrails.org/form_helpers.html
|
15
|
+
<%- end -%>
|
16
|
+
-->
|
17
|
+
|
18
|
+
<% attributes.each do |attribute| -%>
|
19
|
+
<% case attribute.type
|
20
|
+
when :attachments -%>
|
21
|
+
<ul class="<%= attribute.name %>">
|
22
|
+
<%%- slice.<%= attribute.name %>.each do |<%= attribute.name.singularize %>| -%>
|
23
|
+
<li>
|
24
|
+
<%%= image_if_present <%= attribute.name.singularize %>.asset, :original %>
|
25
|
+
<div class="caption"><%%= markdown <%= attribute.name.singularize %>.caption %></div>
|
26
|
+
</li>
|
27
|
+
<%%- end -%>
|
28
|
+
</ul>
|
29
|
+
<% when :date_time, :datetime, :date -%>
|
30
|
+
<div class="<%= attribute.name %>"><%%=l slice.<%= attribute.name %> %></div>
|
31
|
+
<% when :string, :text -%>
|
32
|
+
<div class="<%= attribute.name %>"><%%= markdown slice.<%= attribute.name %> %></div>
|
33
|
+
<% when :boolean -%>
|
34
|
+
<%%- if slice.<%= attribute.name %>? -%>
|
35
|
+
<div class="<%= attribute.name %>"><%= attribute.name.humanize %>!</div>
|
36
|
+
<%%- end -%>
|
37
|
+
<% else -%>
|
38
|
+
<div class="<%= attribute.name %>"><%%= slice.<%= attribute.name %> %></div>
|
39
|
+
<% end -%>
|
40
|
+
|
41
|
+
<% end -%>
|
42
|
+
<p>Change me by editing app/slices/<%= file_name %>/views/show.html.erb</p>
|
43
|
+
|
44
|
+
<% if form_slice? -%>
|
45
|
+
<%% end %>
|
46
|
+
<% end -%>
|
47
|
+
</div>
|
48
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class <%= page_name.classify %>ShowSlice < Slice
|
2
|
+
restricted_slice
|
3
|
+
|
4
|
+
# A "show slice" is handy if every page in a set will have the same
|
5
|
+
# fields defined up on them, and no slices will be involved in the
|
6
|
+
# display of the page. Append it to the set page's entry_content.slices.
|
7
|
+
#
|
8
|
+
# Here's an example of how to give the slice the ability to access the
|
9
|
+
# copy field on the <%= page_name %>'s content document:
|
10
|
+
#
|
11
|
+
# attr_reader :copy
|
12
|
+
#
|
13
|
+
# def prepare(params)
|
14
|
+
# @copy = page.content[:copy]
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# Don't forget to add each field to the as_json method in <%= page_name %>.rb
|
18
|
+
# if you want to be able to edit the fields in the admin UI.
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class <%= class_name %>Slice < Slice
|
2
|
+
<%= field_definitions %>
|
3
|
+
|
4
|
+
# For each field that you want to store on the slice, declare the
|
5
|
+
# field as follow:
|
6
|
+
# field :title
|
7
|
+
# field :body
|
8
|
+
#
|
9
|
+
# You can also specify more complex fields like this:
|
10
|
+
# field :potatoes, type: Array, default: []
|
11
|
+
#
|
12
|
+
# For date/time fields use the following convention:
|
13
|
+
# field :published_on, type: Date
|
14
|
+
# field :published_at, type: DateTime
|
15
|
+
#
|
16
|
+
# For more details of available fields, see the Mongoid
|
17
|
+
# documentation: http://mongoid.org/docs/documents/fields.html
|
18
|
+
#
|
19
|
+
# You can also attach assets to a slice, like this:
|
20
|
+
# has_attachments
|
21
|
+
#
|
22
|
+
# You can name your attachments like this:
|
23
|
+
# has_attachments :images
|
24
|
+
#
|
25
|
+
# You can map your attachments to a custom class like this:
|
26
|
+
# class Image < Attachment
|
27
|
+
# field :caption
|
28
|
+
# end
|
29
|
+
# has_attachments :images, class_name: "MySlice::Image"
|
30
|
+
|
31
|
+
<%- if form_slice? -%>
|
32
|
+
# The handle_post method will get passed the params from the POST
|
33
|
+
# request, and should return true or false, depending on whether or
|
34
|
+
# not processing was successful.
|
35
|
+
#
|
36
|
+
# def handle_post(params)
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
#
|
40
|
+
# Form slices get a chance to set a flash message after they have
|
41
|
+
# successfully handled a post. Set 'name' in the flash key to
|
42
|
+
# something specific to this slice.
|
43
|
+
#
|
44
|
+
# def set_success_message(flash)
|
45
|
+
# flash['slices.name.notice'] = 'Nicely done'
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
#
|
49
|
+
# After a successful POST request the CMS will redirect the user to a
|
50
|
+
# URL (this prevents them from being able to re-submit the form by
|
51
|
+
# reloading the page). This is the URL they end up at.
|
52
|
+
#
|
53
|
+
# def redirect_url
|
54
|
+
# '/path/to/a/page'
|
55
|
+
# end
|
56
|
+
<%- end -%>
|
57
|
+
end
|
58
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<% attributes.each do |attribute| -%>
|
2
|
+
<li>
|
3
|
+
<% case attribute.type
|
4
|
+
when :attachments -%>
|
5
|
+
<%= label_if_needed_for attribute %>
|
6
|
+
{{#attachmentComposer field="<%= attribute.name %>"}}
|
7
|
+
<textarea name="caption" placeholder="Caption…" class="full-height">{{caption}}</textarea>
|
8
|
+
{{/attachmentComposer}}
|
9
|
+
<% when :date %>
|
10
|
+
<%= label_if_needed_for attribute %>
|
11
|
+
{{dateField field="<%= attribute.name %>"}}
|
12
|
+
<% when :date_time, :datetime -%>
|
13
|
+
<%= label_if_needed_for attribute %>
|
14
|
+
{{dateField field="<%= attribute.name %>"}}
|
15
|
+
<% when :boolean -%>
|
16
|
+
<label>
|
17
|
+
<input type="checkbox" id="slices-{{id}}-<%= attribute.name %>" data-value="{{<%= attribute.name %>}}">
|
18
|
+
<%= attribute.name.humanize %>
|
19
|
+
</label>
|
20
|
+
<% when :text %>
|
21
|
+
<%= label_if_needed_for attribute %>
|
22
|
+
<textarea id="slices-{{id}}-<%= attribute.name %>" placeholder="<%= attribute.name.humanize %>…" rows="24">{{<%= attribute.name %>}}</textarea>
|
23
|
+
<% else -%>
|
24
|
+
<%= label_if_needed_for attribute %>
|
25
|
+
<input type="text" id="slices-{{id}}-<%= attribute.name %>" placeholder="<%= attribute.name.humanize %>…" value="{{<%= attribute.name %>}}">
|
26
|
+
<% end -%>
|
27
|
+
</li>
|
28
|
+
<% end -%>
|
29
|
+
|
30
|
+
<!--
|
31
|
+
To change the text that is displayed when this slice is minimised,
|
32
|
+
use the `slicePreview` helper below. The method is scoped to this slice
|
33
|
+
so you can easily access any contained elements.
|
34
|
+
|
35
|
+
Examples:
|
36
|
+
|
37
|
+
return this.find('textarea').val();
|
38
|
+
return this.find('option:selected').text();
|
39
|
+
|
40
|
+
-->
|
41
|
+
{{#slicePreview}}
|
42
|
+
{{/slicePreview}}
|
43
|
+
|
44
|
+
<!--
|
45
|
+
To use radio buttons, follow this formula...
|
46
|
+
|
47
|
+
Let's say we've a field on the slice called 'color', this is how we'd
|
48
|
+
structure the radio buttons:
|
49
|
+
|
50
|
+
<ul id="slices-{{id}}-color" data-value="{{color}}">
|
51
|
+
<li>
|
52
|
+
<input type="radio" value="red"
|
53
|
+
id="option-{{id}}-red" name="slices-{{id}}-color">
|
54
|
+
<label for="option-{{id}}-red">Red</label>
|
55
|
+
</li>
|
56
|
+
<li>
|
57
|
+
<input type="radio" value="green"
|
58
|
+
id="option-{{id}}-green" name="slices-{{id}}-color">
|
59
|
+
<label for="option-{{id}}-green">Green</label>
|
60
|
+
</li>
|
61
|
+
<li>
|
62
|
+
<input type="radio" value="blue"
|
63
|
+
id="option-{{id}}-blue" name="slices-{{id}}-color">
|
64
|
+
<label for="option-{{id}}-blue">Blue</label>
|
65
|
+
</li>
|
66
|
+
</ul>
|
67
|
+
|
68
|
+
The important points to note:
|
69
|
+
|
70
|
+
* The field id `slices-{{id}}-color` goes on the common parent.
|
71
|
+
* The value `data-value="{{color}}"` also goes on the common parent.
|
72
|
+
* The name attribute of the radio buttons is the field id (see above).
|
73
|
+
* To relate labels to inputs, use `option-{{id}}-value` in `for` and `id`.
|
74
|
+
-->
|
@@ -0,0 +1,211 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../slices/version'
|
2
|
+
|
3
|
+
# Remove files
|
4
|
+
remove_file "README.rdoc"
|
5
|
+
remove_file "public/index.html"
|
6
|
+
remove_file "public/404.html"
|
7
|
+
remove_file "public/422.html"
|
8
|
+
remove_file "public/500.html"
|
9
|
+
remove_file "public/favicon.ico"
|
10
|
+
remove_dir "doc"
|
11
|
+
|
12
|
+
create_file "public/favicon.ico"
|
13
|
+
|
14
|
+
file "README.md", <<-END
|
15
|
+
# #{app_const_base}
|
16
|
+
|
17
|
+
Built with [Slices](http://slices.withassociates.com).
|
18
|
+
|
19
|
+
Need help? See the [Slices wiki](https://github.com/withassociates/slices/wiki).
|
20
|
+
END
|
21
|
+
|
22
|
+
# Set up .gitignore files
|
23
|
+
remove_file ".gitignore"
|
24
|
+
file ".gitignore", <<-END
|
25
|
+
.DS_Store
|
26
|
+
*.swp
|
27
|
+
.bundle
|
28
|
+
.sass-cache
|
29
|
+
coverage
|
30
|
+
db/*.sqlite3
|
31
|
+
db/*development*
|
32
|
+
db/*production*
|
33
|
+
db/*test*
|
34
|
+
db/mongod.lock
|
35
|
+
log/*.log
|
36
|
+
public/assets
|
37
|
+
public/cache
|
38
|
+
public/system
|
39
|
+
tmp
|
40
|
+
END
|
41
|
+
|
42
|
+
# mongoid.yml
|
43
|
+
file "config/mongoid.yml", <<-END
|
44
|
+
development:
|
45
|
+
host: localhost
|
46
|
+
database: #{app_name}_development
|
47
|
+
|
48
|
+
test:
|
49
|
+
host: localhost
|
50
|
+
database: #{app_name}_test
|
51
|
+
|
52
|
+
production:
|
53
|
+
host: localhost
|
54
|
+
database: #{app_name}_development
|
55
|
+
END
|
56
|
+
|
57
|
+
initializer "slices.rb", <<-END
|
58
|
+
# Slices::Config.add_asset_styles(
|
59
|
+
# slice_full_width: '945x496>',
|
60
|
+
# avatar: '30x30#',
|
61
|
+
# )
|
62
|
+
|
63
|
+
# Configure the Google Apps domain to use for quick auth.
|
64
|
+
# Press the '=' key on the admin sign-in screen to authenticate via
|
65
|
+
# a Google Apps account within the domain configured here.
|
66
|
+
# Slices::Config.google_apps_domain = 'example.com'
|
67
|
+
|
68
|
+
ActionView::Base.send(:include, AssetsHelper)
|
69
|
+
|
70
|
+
END
|
71
|
+
|
72
|
+
# Gemfile
|
73
|
+
run "rm Gemfile"
|
74
|
+
file "Gemfile", <<-END
|
75
|
+
source 'https://rubygems.org'
|
76
|
+
|
77
|
+
gem 'slices',
|
78
|
+
git: 'git@github.com:withassociates/slices.git',
|
79
|
+
tag: 'v#{Slices::VERSION}'
|
80
|
+
|
81
|
+
group :assets do
|
82
|
+
gem 'sass-rails'
|
83
|
+
gem 'therubyracer'
|
84
|
+
gem 'uglifier'
|
85
|
+
end
|
86
|
+
|
87
|
+
group :development do
|
88
|
+
gem 'capistrano', require: false
|
89
|
+
gem 'foreman', require: false
|
90
|
+
gem 'unicorn', require: false
|
91
|
+
end
|
92
|
+
|
93
|
+
group :test do
|
94
|
+
gem 'capybara'
|
95
|
+
gem 'database_cleaner'
|
96
|
+
gem 'launchy'
|
97
|
+
gem 'rspec-rails'
|
98
|
+
end
|
99
|
+
|
100
|
+
END
|
101
|
+
|
102
|
+
# Generate example slices
|
103
|
+
generate("slice text text:text")
|
104
|
+
generate("slice images images:attachments")
|
105
|
+
|
106
|
+
# Default layout
|
107
|
+
remove_file "app/views/layouts/application.html.erb"
|
108
|
+
|
109
|
+
file "app/views/layouts/default.html.erb", <<-END
|
110
|
+
<!doctype html>
|
111
|
+
<html>
|
112
|
+
<head>
|
113
|
+
<%= render "shared/head" %>
|
114
|
+
</head>
|
115
|
+
<body class="layout-default">
|
116
|
+
<section id="main" role="main">
|
117
|
+
<%= container "content" %>
|
118
|
+
</section>
|
119
|
+
</body>
|
120
|
+
</html>
|
121
|
+
END
|
122
|
+
|
123
|
+
file "app/views/shared/_head.html.erb", <<-END
|
124
|
+
<meta charset="utf-8">
|
125
|
+
<%= csrf_meta_tags %>
|
126
|
+
|
127
|
+
<title>#{app_const_base}</title>
|
128
|
+
|
129
|
+
<!-- <meta name="description" content=""> -->
|
130
|
+
|
131
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
132
|
+
|
133
|
+
<%= stylesheet_link_tag *%w[
|
134
|
+
application
|
135
|
+
] %>
|
136
|
+
|
137
|
+
<%= javascript_include_tag *%w[
|
138
|
+
//cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js
|
139
|
+
application
|
140
|
+
] %>
|
141
|
+
|
142
|
+
<!--[if lt IE 9]>
|
143
|
+
<%= javascript_include_tag *%w[
|
144
|
+
//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.2/html5shiv.min.js
|
145
|
+
] %>
|
146
|
+
<![endif]-->
|
147
|
+
|
148
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
149
|
+
END
|
150
|
+
|
151
|
+
# Assets directory structure
|
152
|
+
remove_file "app/assets/images/rails.png"
|
153
|
+
create_file "app/assets/images/.gitkeep"
|
154
|
+
|
155
|
+
# Rspec
|
156
|
+
generate("rspec:install")
|
157
|
+
|
158
|
+
file ".rspec", <<-END, force: true
|
159
|
+
--colour
|
160
|
+
--format=documentation
|
161
|
+
END
|
162
|
+
|
163
|
+
file "spec/spec_helper.rb", <<-END, force: true
|
164
|
+
ENV['RAILS_ENV'] ||= 'test'
|
165
|
+
|
166
|
+
require File.expand_path '../../config/environment', __FILE__
|
167
|
+
require 'rspec/rails'
|
168
|
+
require 'rspec/autorun'
|
169
|
+
|
170
|
+
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
171
|
+
|
172
|
+
RSpec.configure do |config|
|
173
|
+
config.order = 'random'
|
174
|
+
|
175
|
+
config.before :suite do
|
176
|
+
DatabaseCleaner.orm = 'mongoid'
|
177
|
+
DatabaseCleaner.strategy = :truncation
|
178
|
+
end
|
179
|
+
|
180
|
+
config.before do
|
181
|
+
DatabaseCleaner.start
|
182
|
+
end
|
183
|
+
|
184
|
+
config.after do
|
185
|
+
DatabaseCleaner.clean
|
186
|
+
end
|
187
|
+
end
|
188
|
+
END
|
189
|
+
|
190
|
+
# Admin nav partials
|
191
|
+
file "app/views/admin/shared/_custom_navigation.html.erb", <<-END
|
192
|
+
<%# Place custom navbar controls here i.e. %>
|
193
|
+
<%#= admin_nav_link 'Example', example_path %>
|
194
|
+
END
|
195
|
+
|
196
|
+
file "app/views/admin/shared/_custom_links.html.erb", <<-END
|
197
|
+
<%# Place custom navbar links here i.e. %>
|
198
|
+
<%#= content_tag :li, link_to('Example', example_path) %>
|
199
|
+
END
|
200
|
+
|
201
|
+
# Procfile
|
202
|
+
file "Procfile", "web: bundle exec unicorn -p $PORT"
|
203
|
+
git add: "--all"
|
204
|
+
git commit: "-m 'Add Procfile'"
|
205
|
+
|
206
|
+
# Seed the database
|
207
|
+
rake "slices:seed"
|
208
|
+
|
209
|
+
say "All done!", :green
|
210
|
+
say "Remember to run `bundle install` when you first cd into the project", :green
|
211
|
+
|