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
data/CHANGELOG.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Slices CMS
|
2
|
+
|
3
|
+
In-house CMS of [With Associates](http://withassociates.com/)
|
4
|
+
|
5
|
+
## Starting a new slices project
|
6
|
+
|
7
|
+
Follow this [guide](https://github.com/withassociates/slices/wiki/Installation.md)
|
8
|
+
first if you don't have MongoDB, ImageMagick and Ruby installed.
|
9
|
+
|
10
|
+
We'll need to checkout the slices project, install the relevant gems using
|
11
|
+
bundler and then use a Rails template to create the new project.
|
12
|
+
|
13
|
+
$ cd ~/Projects # or where you store git repos
|
14
|
+
$ git clone git@github.com:withassociates/slices.git
|
15
|
+
$ cd slices
|
16
|
+
$ gem install bundler
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or if you have slices already installed
|
20
|
+
|
21
|
+
$ cd ~/Projects/slices # or where you store git repos
|
22
|
+
$ git pull
|
23
|
+
$ bundle install
|
24
|
+
|
25
|
+
Now we're ready to create the slices project.
|
26
|
+
|
27
|
+
$ cd ~/Projects
|
28
|
+
$ gem install rails -v '~> 3.2.0'
|
29
|
+
$ rails new mywebsite -JOT -m ~/Projects/slices/lib/generators/templates/slices.rb
|
30
|
+
|
31
|
+
At the end of this process we should have a new slices project with git repository
|
32
|
+
created, gems installed, database seeded and ready to run:
|
33
|
+
|
34
|
+
$ cd ~/Projects/mywebsite
|
35
|
+
$ foreman start
|
36
|
+
|
37
|
+
Visit http://localhost:5000/admin to begin using Slices.
|
38
|
+
|
39
|
+
The next step is to create some [slices](https://github.com/withassociates/slices-legacy/wiki/Creating-Slices)
|
40
|
+
and theres more guides in the [wiki](https://github.com/withassociates/slices/wiki)
|
41
|
+
|
42
|
+
## Code Status
|
43
|
+
|
44
|
+
[![Travis CI ](https://api.travis-ci.org/withassociates/slices.png) ](https://travis-ci.org/withassociates/slices)
|
45
|
+
[![Code Climate](https://codeclimate.com/github/withassociates/slices.png) ](https://codeclimate.com/github/withassociates/slices)
|
46
|
+
[![Gemnasium ](https://gemnasium.com/withassociates/slices.png) ](https://gemnasium.com/withassociates/slices)
|
47
|
+
|
48
|
+
## Copyright
|
49
|
+
|
50
|
+
Copyright (c) 2014 With Associates
|
51
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
require 'bundler'
|
8
|
+
Bundler::GemHelper.install_tasks
|
9
|
+
Slices::Application.load_tasks
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Calque_1" x="0px" y="0px" width="82.7272727273px" height="100px" viewBox="0 0 91.59 110.063" enable-background="new 0 0 91.59 110.063" xml:space="preserve">
|
2
|
+
<g>
|
3
|
+
<g>
|
4
|
+
<g>
|
5
|
+
<g>
|
6
|
+
<path d="M74.812,14.155v5.839c1.396,1.43,2.263,3.379,2.263,5.536c0,4.392-3.557,7.951-7.95,7.951 c-4.39,0-7.951-3.559-7.951-7.951c0-2.157,0.867-4.106,2.263-5.536v-5.839H28.152v5.839c1.396,1.43,2.263,3.379,2.263,5.536 c0,4.392-3.559,7.951-7.95,7.951c-4.39,0-7.947-3.559-7.947-7.951c0-2.157,0.865-4.106,2.259-5.536v-5.839H0v95.909h91.59 V14.155H74.812z M84.234,102.358H7.358v-64.73h76.876V102.358z"/>
|
7
|
+
</g>
|
8
|
+
</g>
|
9
|
+
<g>
|
10
|
+
<rect x="68.404" y="47.278" width="9.158" height="9.504"/>
|
11
|
+
</g>
|
12
|
+
<g>
|
13
|
+
<rect x="55.013" y="47.278" width="9.157" height="9.504"/>
|
14
|
+
</g>
|
15
|
+
<g>
|
16
|
+
<rect x="41.62" y="47.278" width="9.154" height="9.504"/>
|
17
|
+
</g>
|
18
|
+
<g>
|
19
|
+
<rect x="68.404" y="60.526" width="9.158" height="9.504"/>
|
20
|
+
</g>
|
21
|
+
<g>
|
22
|
+
<rect x="55.013" y="60.526" width="9.157" height="9.504"/>
|
23
|
+
</g>
|
24
|
+
<g>
|
25
|
+
<rect x="41.62" y="60.526" width="9.154" height="9.504"/>
|
26
|
+
</g>
|
27
|
+
<g>
|
28
|
+
<rect x="28.226" y="60.526" width="9.158" height="9.504"/>
|
29
|
+
</g>
|
30
|
+
<g>
|
31
|
+
<rect x="14.834" y="60.526" width="9.156" height="9.504"/>
|
32
|
+
</g>
|
33
|
+
<g>
|
34
|
+
<rect x="68.404" y="73.773" width="9.158" height="9.506"/>
|
35
|
+
</g>
|
36
|
+
<g>
|
37
|
+
<rect x="55.013" y="73.773" width="9.157" height="9.506"/>
|
38
|
+
</g>
|
39
|
+
<g>
|
40
|
+
<rect x="41.62" y="73.773" width="9.154" height="9.506"/>
|
41
|
+
</g>
|
42
|
+
<g>
|
43
|
+
<rect x="28.226" y="73.773" width="9.158" height="9.506"/>
|
44
|
+
</g>
|
45
|
+
<g>
|
46
|
+
<rect x="14.834" y="73.773" width="9.156" height="9.506"/>
|
47
|
+
</g>
|
48
|
+
<g>
|
49
|
+
<rect x="55.013" y="87.025" width="9.157" height="9.502"/>
|
50
|
+
</g>
|
51
|
+
<g>
|
52
|
+
<rect x="41.62" y="87.025" width="9.154" height="9.502"/>
|
53
|
+
</g>
|
54
|
+
<g>
|
55
|
+
<rect x="28.226" y="87.025" width="9.158" height="9.502"/>
|
56
|
+
</g>
|
57
|
+
<g>
|
58
|
+
<rect x="14.834" y="87.025" width="9.156" height="9.502"/>
|
59
|
+
</g>
|
60
|
+
<g>
|
61
|
+
<path d="M69.336,28.783c1.486,0,2.697-1.206,2.697-2.696V2.696C72.033,1.208,70.822,0,69.336,0c-1.487,0-2.694,1.208-2.694,2.696 v23.39C66.642,27.577,67.849,28.783,69.336,28.783z"/>
|
62
|
+
</g>
|
63
|
+
<g>
|
64
|
+
<path d="M22.416,28.783c1.489,0,2.696-1.206,2.696-2.696V2.696C25.112,1.208,23.904,0,22.416,0c-1.487,0-2.694,1.208-2.694,2.696 v23.39C19.721,27.577,20.928,28.783,22.416,28.783z"/>
|
65
|
+
</g>
|
66
|
+
</g>
|
67
|
+
</g>
|
68
|
+
</svg>
|
Binary file
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!-- Generator: Adobe Illustrator 15.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<svg version="1.1" id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
5
|
+
width="10px" height="9px" viewBox="0 0 10 9" enable-background="new 0 0 10 9" xml:space="preserve">
|
6
|
+
<rect fill="#020202" width="10" height="1"/>
|
7
|
+
<rect y="4" fill="#020202" width="10" height="1"/>
|
8
|
+
<rect y="8" fill="#020202" width="10" height="1"/>
|
9
|
+
</svg>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<% if Rails.env.test? %>
|
2
|
+
var LunchPicker = {
|
3
|
+
run: function(target) {
|
4
|
+
$(target).change(function(e) {
|
5
|
+
$(target).siblings('.lunch-comment').text('Good choice');
|
6
|
+
});
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
// jQuery plugin
|
11
|
+
$.fn.lunchPicker = function(options) {
|
12
|
+
return this.each(function() {
|
13
|
+
LunchPicker.run(this);
|
14
|
+
});
|
15
|
+
}
|
16
|
+
<% else %>
|
17
|
+
// This file is overrideable by the host app, allowing javascript customisation.
|
18
|
+
<% end %>
|
@@ -0,0 +1,114 @@
|
|
1
|
+
var AdminsBackbone = $.extend(true, {}, GenericBackbone, {
|
2
|
+
collection_prototype: {
|
3
|
+
page_id: '',
|
4
|
+
search_url: '',
|
5
|
+
search_data: function() {
|
6
|
+
return { search: this.search_term, page: this.page }
|
7
|
+
},
|
8
|
+
|
9
|
+
initialize: function(models, options) {
|
10
|
+
this.page_id = options.page_id;
|
11
|
+
this.search_url = '/admin/admins';
|
12
|
+
}
|
13
|
+
},
|
14
|
+
|
15
|
+
model_prototype: {
|
16
|
+
for_template: function() {
|
17
|
+
var obj = this.toJSON();
|
18
|
+
obj.url = this.url();
|
19
|
+
return obj;
|
20
|
+
},
|
21
|
+
|
22
|
+
initialize: function() {
|
23
|
+
if (!this.get('last_sign_in_at')) {
|
24
|
+
this.set({'last_sign_in_at': 'never'});
|
25
|
+
}
|
26
|
+
if (!this.get('name')) {
|
27
|
+
this.set({'name': 'No Name Set'});
|
28
|
+
}
|
29
|
+
},
|
30
|
+
|
31
|
+
url: function() {
|
32
|
+
return "/admin/admins/" + this.id;
|
33
|
+
}
|
34
|
+
|
35
|
+
},
|
36
|
+
|
37
|
+
view_prototype: {
|
38
|
+
events: {
|
39
|
+
"click a.delete": "clear"
|
40
|
+
},
|
41
|
+
|
42
|
+
tagName: 'tr',
|
43
|
+
|
44
|
+
template: Handlebars.compile(
|
45
|
+
"<td class='name'><a href='{{url}}'>{{name}}</a></td>" +
|
46
|
+
"<td class='email'>{{email}}</td>" +
|
47
|
+
"<td class='login'>{{last_sign_in_at}}</td>" +
|
48
|
+
"<td>{{#if current_admin}}This is you{{else}}<a href='#' class='delete'>Delete</a>{{/if}}</td>"
|
49
|
+
),
|
50
|
+
},
|
51
|
+
|
52
|
+
app_view_prototype: {
|
53
|
+
events: {
|
54
|
+
"click #pagination a": "paginate",
|
55
|
+
"keyup #entries-search": "call_search",
|
56
|
+
"click #add-admin": "new_admin"
|
57
|
+
},
|
58
|
+
|
59
|
+
new_admin: function() {
|
60
|
+
document.location.href = document.location.href + '/new';
|
61
|
+
},
|
62
|
+
|
63
|
+
setup_search: function() {
|
64
|
+
var self = this;
|
65
|
+
setInterval(function() {
|
66
|
+
if ( self.search_now ) {
|
67
|
+
self.search_now = false;
|
68
|
+
var search_length = self.$search_box.val().length;
|
69
|
+
if ((search_length > 2) || (search_length === 0)) {
|
70
|
+
self.collection.page = 1;
|
71
|
+
self.search();
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}, 450);
|
75
|
+
},
|
76
|
+
|
77
|
+
initialize: function(options) {
|
78
|
+
this.collection = this.options.collection;
|
79
|
+
this.view_prototype = this.options.view_prototype;
|
80
|
+
_.bindAll(this, "render");
|
81
|
+
this.collection.bind('reset', this.render);
|
82
|
+
this.$search_box = this.$('#entries-search');
|
83
|
+
this.setup_search();
|
84
|
+
this.search();
|
85
|
+
},
|
86
|
+
|
87
|
+
render: function() {
|
88
|
+
var view_prototype = this.view_prototype;
|
89
|
+
this.$('#entries-list tbody').empty();
|
90
|
+
_.each(this.collection.models, function(admin) {
|
91
|
+
var view = new view_prototype({model: admin});
|
92
|
+
self.$("#entries-list tbody").append(view.render().el);
|
93
|
+
});
|
94
|
+
this.render_pagination();
|
95
|
+
}
|
96
|
+
|
97
|
+
},
|
98
|
+
|
99
|
+
bind_prototypes: function() {
|
100
|
+
this.collection_prototype = Backbone.Collection.extend(this.collection_prototype);
|
101
|
+
this.view_prototype = Backbone.View.extend(this.view_prototype);
|
102
|
+
this.model_prototype = Backbone.Model.extend(this.model_prototype);
|
103
|
+
this.app_view_prototype.el = $('#container');
|
104
|
+
this.app_view_prototype = Backbone.View.extend(this.app_view_prototype);
|
105
|
+
},
|
106
|
+
|
107
|
+
boot: function(page_id) {
|
108
|
+
this.bind_prototypes();
|
109
|
+
this.collection = new this.collection_prototype(null, {page_id: page_id});
|
110
|
+
this.collection.model = this.model_prototype;
|
111
|
+
this.app_view = new this.app_view_prototype({collection: this.collection, view_prototype: this.view_prototype});
|
112
|
+
}
|
113
|
+
|
114
|
+
});
|
@@ -0,0 +1,172 @@
|
|
1
|
+
var EntriesBackbone = $.extend(true, {}, GenericBackbone, {
|
2
|
+
collection_prototype: {
|
3
|
+
page_id: '',
|
4
|
+
search_url: '',
|
5
|
+
search_data: function() {
|
6
|
+
return { search: this.search_term, page: this.page }
|
7
|
+
},
|
8
|
+
|
9
|
+
initialize: function(models, options) {
|
10
|
+
this.page_id = options.page_id;
|
11
|
+
this.search_url = '/admin/pages/' + this.page_id + '/entries';
|
12
|
+
}
|
13
|
+
},
|
14
|
+
|
15
|
+
model_prototype: {
|
16
|
+
for_template: function() {
|
17
|
+
return this.toJSON();
|
18
|
+
},
|
19
|
+
|
20
|
+
url: function() {
|
21
|
+
return this.get('url');
|
22
|
+
}
|
23
|
+
|
24
|
+
},
|
25
|
+
|
26
|
+
view_prototype: {
|
27
|
+
events: {
|
28
|
+
"click a.delete": "clear"
|
29
|
+
},
|
30
|
+
|
31
|
+
tagName: 'tr',
|
32
|
+
|
33
|
+
},
|
34
|
+
|
35
|
+
app_view_prototype: {
|
36
|
+
events: {
|
37
|
+
"click #pagination a": "paginate",
|
38
|
+
"keyup #entries-search": "call_search",
|
39
|
+
"click #add-entry": "add_entry"
|
40
|
+
},
|
41
|
+
|
42
|
+
setup_search: function() {
|
43
|
+
var self = this;
|
44
|
+
setInterval(function() {
|
45
|
+
if ( self.search_now ) {
|
46
|
+
self.search_now = false;
|
47
|
+
var search_length = self.$search_box.val().length;
|
48
|
+
if ((search_length > 2) || (search_length === 0)) {
|
49
|
+
self.collection.page = 1;
|
50
|
+
self.search();
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}, 450);
|
54
|
+
},
|
55
|
+
|
56
|
+
initialize: function(options) {
|
57
|
+
this.collection = this.options.collection;
|
58
|
+
this.view_prototype = this.options.view_prototype;
|
59
|
+
_.bindAll(this, "render", "set_view_template");
|
60
|
+
this.collection.bind('reset', this.set_view_template);
|
61
|
+
this.collection.bind('reset', this.render);
|
62
|
+
this.$search_box = this.$('#entries-search');
|
63
|
+
this.setup_search();
|
64
|
+
this.search();
|
65
|
+
|
66
|
+
if (options.sort_field === 'position') {
|
67
|
+
var that = this;
|
68
|
+
this.$('tbody').sortable({
|
69
|
+
update: function() { that.update_on_sort(); }
|
70
|
+
});
|
71
|
+
}
|
72
|
+
|
73
|
+
},
|
74
|
+
|
75
|
+
set_view_template: function() {
|
76
|
+
if(this.collection.models.length == 0) {
|
77
|
+
attributes = {};
|
78
|
+
} else {
|
79
|
+
attributes = this.collection.models[0].attributes;
|
80
|
+
}
|
81
|
+
var fields = _.chain(attributes).
|
82
|
+
keys().
|
83
|
+
reject(function(key) { return key.indexOf('_') === 0 }).
|
84
|
+
value();
|
85
|
+
|
86
|
+
fields = _.map(fields, function(key) {
|
87
|
+
var string;
|
88
|
+
if (key == 'name') {
|
89
|
+
string = "<td class='"+key+"'><a href='<%= url %>'><%= "+key+" %></a></td>"
|
90
|
+
} else if ( key != 'url' ) {
|
91
|
+
string = "<td class='"+key+"'><%= "+key+" %></td>";
|
92
|
+
}
|
93
|
+
return string;
|
94
|
+
});
|
95
|
+
fields.push("<td><a href='#' class='delete'>Delete</a></td>");
|
96
|
+
var template = _.template(fields.join(''));
|
97
|
+
this.view_prototype = this.view_prototype.extend({template: template});
|
98
|
+
this.collection.unbind('reset', this.set_view_template);
|
99
|
+
},
|
100
|
+
|
101
|
+
render: function() {
|
102
|
+
var view_prototype = this.view_prototype;
|
103
|
+
this.$('#entries-list tbody').empty();
|
104
|
+
_.each(this.collection.models, function(entry) {
|
105
|
+
var view = new view_prototype({model: entry}),
|
106
|
+
$view = $(view.render().el);
|
107
|
+
|
108
|
+
$view.data('model', entry);
|
109
|
+
|
110
|
+
self.$("#entries-list tbody").append($view);
|
111
|
+
});
|
112
|
+
this.render_pagination();
|
113
|
+
},
|
114
|
+
|
115
|
+
add_entry: function(event) {
|
116
|
+
var button = $(event.target);
|
117
|
+
|
118
|
+
$('#general-modal').jqm({
|
119
|
+
ajax: button.attr('href'),
|
120
|
+
modal: false,
|
121
|
+
onHide: function (h) {
|
122
|
+
h.w.fadeOut(100);
|
123
|
+
h.o.fadeOut(100);
|
124
|
+
},
|
125
|
+
onShow: function (h) {},
|
126
|
+
onLoad: function (h) {
|
127
|
+
h.w.fadeIn(50);
|
128
|
+
h.o.fadeIn(100);
|
129
|
+
},
|
130
|
+
overlay: 40
|
131
|
+
}).jqmShow();
|
132
|
+
|
133
|
+
return false;
|
134
|
+
},
|
135
|
+
|
136
|
+
update_on_sort: function() {
|
137
|
+
var parent = { id: this.collection.page_id };
|
138
|
+
|
139
|
+
parent.children = this.$('#entries-list tbody tr').map(function() {
|
140
|
+
return { id: $(this).data('model').id };
|
141
|
+
}).toArray();
|
142
|
+
|
143
|
+
$.ajax({
|
144
|
+
url: '/admin/site_maps/update',
|
145
|
+
type: 'PUT',
|
146
|
+
data: JSON.stringify({ sitemap: [parent] }),
|
147
|
+
contentType: 'application/json',
|
148
|
+
dataType: 'json'
|
149
|
+
});
|
150
|
+
}
|
151
|
+
|
152
|
+
},
|
153
|
+
|
154
|
+
bind_prototypes: function() {
|
155
|
+
this.collection_prototype = Backbone.Collection.extend(this.collection_prototype);
|
156
|
+
this.view_prototype = Backbone.View.extend(this.view_prototype);
|
157
|
+
this.model_prototype = Backbone.Model.extend(this.model_prototype);
|
158
|
+
this.app_view_prototype.el = $('#container');
|
159
|
+
this.app_view_prototype = Backbone.View.extend(this.app_view_prototype);
|
160
|
+
},
|
161
|
+
|
162
|
+
boot: function(page_id, options) {
|
163
|
+
this.bind_prototypes();
|
164
|
+
this.collection = new this.collection_prototype(null, {page_id: page_id});
|
165
|
+
this.collection.model = this.model_prototype;
|
166
|
+
this.app_view = new this.app_view_prototype($.extend({}, options, {
|
167
|
+
collection: this.collection,
|
168
|
+
view_prototype: this.view_prototype
|
169
|
+
}));
|
170
|
+
}
|
171
|
+
|
172
|
+
});
|