smithycms 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +142 -0
  3. data/Rakefile +27 -0
  4. data/app/assets/images/smithy/logo.png +0 -0
  5. data/app/assets/images/smithy/logo2.png +0 -0
  6. data/app/assets/javascripts/smithy/application.js +13 -0
  7. data/app/assets/javascripts/smithy/assets.js.coffee +35 -0
  8. data/app/assets/javascripts/smithy/guides.js +23 -0
  9. data/app/assets/javascripts/smithy/jquery-ui.min.js +5 -0
  10. data/app/assets/javascripts/smithy/nested_forms.js +55 -0
  11. data/app/assets/javascripts/smithy/page_contents.js +4 -0
  12. data/app/assets/javascripts/smithy/pages.js +41 -0
  13. data/app/assets/javascripts/smithy/settings.js +0 -0
  14. data/app/assets/javascripts/smithy/templates.js +25 -0
  15. data/app/assets/stylesheets/smithy/application.css.scss +29 -0
  16. data/app/assets/stylesheets/smithy/assets.css.scss +3 -0
  17. data/app/assets/stylesheets/smithy/bootstrap_and_overrides.css.scss +12 -0
  18. data/app/assets/stylesheets/smithy/content_blocks.css.scss +2 -0
  19. data/app/assets/stylesheets/smithy/forms.css.scss +3 -0
  20. data/app/assets/stylesheets/smithy/guides.css.scss +5 -0
  21. data/app/assets/stylesheets/smithy/layout.css.scss +113 -0
  22. data/app/assets/stylesheets/smithy/pages.css.scss +35 -0
  23. data/app/assets/stylesheets/smithy/templates.css.scss +14 -0
  24. data/app/controllers/smithy/assets_controller.rb +50 -0
  25. data/app/controllers/smithy/base_controller.rb +14 -0
  26. data/app/controllers/smithy/caches_controller.rb +13 -0
  27. data/app/controllers/smithy/content_blocks_controller.rb +50 -0
  28. data/app/controllers/smithy/content_pieces_controller.rb +97 -0
  29. data/app/controllers/smithy/contents_controller.rb +41 -0
  30. data/app/controllers/smithy/guides_controller.rb +9 -0
  31. data/app/controllers/smithy/images_controller.rb +41 -0
  32. data/app/controllers/smithy/page_contents_controller.rb +90 -0
  33. data/app/controllers/smithy/pages_controller.rb +110 -0
  34. data/app/controllers/smithy/settings_controller.rb +46 -0
  35. data/app/controllers/smithy/sitemap_controller.rb +13 -0
  36. data/app/controllers/smithy/templates_controller.rb +79 -0
  37. data/app/helpers/smithy/application_helper.rb +36 -0
  38. data/app/helpers/smithy/assets_helper.rb +9 -0
  39. data/app/helpers/smithy/pages_helper.rb +12 -0
  40. data/app/helpers/smithy/settings_helper.rb +4 -0
  41. data/app/helpers/smithy/templates_helper.rb +4 -0
  42. data/app/helpers/smithy/upload_helper.rb +110 -0
  43. data/app/models/smithy/asset.rb +64 -0
  44. data/app/models/smithy/content.rb +35 -0
  45. data/app/models/smithy/content_block.rb +41 -0
  46. data/app/models/smithy/content_block_template.rb +26 -0
  47. data/app/models/smithy/image.rb +41 -0
  48. data/app/models/smithy/page.rb +94 -0
  49. data/app/models/smithy/page_content.rb +62 -0
  50. data/app/models/smithy/page_list.rb +61 -0
  51. data/app/models/smithy/page_proxy.rb +63 -0
  52. data/app/models/smithy/setting.rb +6 -0
  53. data/app/models/smithy/site.rb +30 -0
  54. data/app/models/smithy/template.rb +53 -0
  55. data/app/models/smithy/template_container.rb +16 -0
  56. data/app/views/layouts/smithy/application.html.erb +27 -0
  57. data/app/views/layouts/smithy/guides.html.erb +16 -0
  58. data/app/views/layouts/smithy/modal.html.erb +10 -0
  59. data/app/views/layouts/smithy/shared/_flash.html.erb +6 -0
  60. data/app/views/layouts/smithy/shared/_footer.html.erb +3 -0
  61. data/app/views/layouts/smithy/shared/_head.html.erb +8 -0
  62. data/app/views/layouts/smithy/shared/_nav.html.erb +37 -0
  63. data/app/views/layouts/smithy/shared/_tail.html.erb +4 -0
  64. data/app/views/layouts/smithy/wide.html.erb +24 -0
  65. data/app/views/smithy/assets/_asset.html.erb +10 -0
  66. data/app/views/smithy/assets/_form.html.erb +13 -0
  67. data/app/views/smithy/assets/_upload_form.html.erb +13 -0
  68. data/app/views/smithy/assets/create.js.erb +5 -0
  69. data/app/views/smithy/assets/edit.html.erb +5 -0
  70. data/app/views/smithy/assets/index.html.erb +13 -0
  71. data/app/views/smithy/assets/new.html.erb +13 -0
  72. data/app/views/smithy/caches/show.html.erb +8 -0
  73. data/app/views/smithy/content_blocks/_content_block.html.erb +1 -0
  74. data/app/views/smithy/content_blocks/_secondary_nav.html.erb +12 -0
  75. data/app/views/smithy/content_blocks/_template_fields.html.erb +19 -0
  76. data/app/views/smithy/content_blocks/edit.html.erb +31 -0
  77. data/app/views/smithy/content_blocks/index.html.erb +17 -0
  78. data/app/views/smithy/content_blocks/new.html.erb +12 -0
  79. data/app/views/smithy/content_pieces/edit.html.erb +13 -0
  80. data/app/views/smithy/content_pieces/index.html.erb +21 -0
  81. data/app/views/smithy/content_pieces/new.html.erb +1 -0
  82. data/app/views/smithy/contents/_form.html.erb +6 -0
  83. data/app/views/smithy/contents/_form_fields.html.erb +12 -0
  84. data/app/views/smithy/contents/edit.html.erb +3 -0
  85. data/app/views/smithy/contents/new.html.erb +3 -0
  86. data/app/views/smithy/guides/markdown.html.erb +150 -0
  87. data/app/views/smithy/images/_form.html.erb +6 -0
  88. data/app/views/smithy/images/_form_fields.html.erb +28 -0
  89. data/app/views/smithy/images/edit.html.erb +3 -0
  90. data/app/views/smithy/images/new.html.erb +3 -0
  91. data/app/views/smithy/page_contents/edit.html.erb +18 -0
  92. data/app/views/smithy/page_contents/new.html.erb +28 -0
  93. data/app/views/smithy/page_lists/_form_fields.html.erb +6 -0
  94. data/app/views/smithy/pages/_container.html.erb +24 -0
  95. data/app/views/smithy/pages/_form.html.erb +57 -0
  96. data/app/views/smithy/pages/_page.html.erb +6 -0
  97. data/app/views/smithy/pages/_page_nav.html.erb +6 -0
  98. data/app/views/smithy/pages/_page_related.html.erb +21 -0
  99. data/app/views/smithy/pages/_parent.html.erb +10 -0
  100. data/app/views/smithy/pages/_root.html.erb +5 -0
  101. data/app/views/smithy/pages/edit.html.erb +7 -0
  102. data/app/views/smithy/pages/index.html.erb +17 -0
  103. data/app/views/smithy/pages/new.html.erb +7 -0
  104. data/app/views/smithy/settings/_form.html.erb +7 -0
  105. data/app/views/smithy/settings/_setting.html.erb +6 -0
  106. data/app/views/smithy/settings/edit.html.erb +3 -0
  107. data/app/views/smithy/settings/index.html.erb +9 -0
  108. data/app/views/smithy/settings/new.html.erb +3 -0
  109. data/app/views/smithy/settings/show.html.erb +10 -0
  110. data/app/views/smithy/sitemap/show.xml.erb +10 -0
  111. data/app/views/smithy/templates/_secondary_nav.html.erb +21 -0
  112. data/app/views/smithy/templates/_template.html.erb +1 -0
  113. data/app/views/smithy/templates/edit.html.erb +36 -0
  114. data/app/views/smithy/templates/index.html.erb +17 -0
  115. data/app/views/smithy/templates/new.html.erb +13 -0
  116. data/config/initializers/aws.rb +5 -0
  117. data/config/initializers/dragonfly.rb +48 -0
  118. data/config/initializers/formtastic.rb +77 -0
  119. data/config/initializers/kaminari_config.rb +10 -0
  120. data/config/initializers/liquid.rb +2 -0
  121. data/config/routes.rb +38 -0
  122. data/db/migrate/20120911193140_create_smithy_templates.rb +11 -0
  123. data/db/migrate/20120911203618_create_smithy_settings.rb +10 -0
  124. data/db/migrate/20121018182146_create_smithy_pages.rb +27 -0
  125. data/db/migrate/20121019145543_create_smithy_template_containers.rb +11 -0
  126. data/db/migrate/20121019160426_create_smithy_page_contents.rb +21 -0
  127. data/db/migrate/20121024213357_create_smithy_content_blocks.rb +10 -0
  128. data/db/migrate/20121025011733_create_smithy_content_block_templates.rb +12 -0
  129. data/db/migrate/20121029175812_create_smithy_contents.rb +9 -0
  130. data/db/migrate/20121105222537_create_smithy_assets.rb +16 -0
  131. data/db/migrate/20121115215053_create_smithy_images.rb +15 -0
  132. data/db/migrate/20121127205022_add_external_link_to_smithy_pages.rb +5 -0
  133. data/db/migrate/20130115190505_add_markdown_content_to_smithy_contents.rb +5 -0
  134. data/db/migrate/20130123170918_set_defaults_for_show_in_navigation_and_cache_length.rb +6 -0
  135. data/db/migrate/20130311203806_create_smithy_page_lists.rb +15 -0
  136. data/db/migrate/20130312161116_remove_description_from_content_block.rb +5 -0
  137. data/db/migrate/20130326191051_add_html_attributes_to_images.rb +5 -0
  138. data/db/migrate/20131003210228_add_publishable_to_smithy_page_contents.rb +11 -0
  139. data/db/migrate/20131220160755_add_content_to_images.rb +5 -0
  140. data/db/migrate/20131223145710_add_position_to_smithy_template_containers.rb +5 -0
  141. data/lib/smithy/content_blocks/model.rb +16 -0
  142. data/lib/smithy/content_blocks/registry.rb +30 -0
  143. data/lib/smithy/content_blocks.rb +2 -0
  144. data/lib/smithy/content_pieces/base.rb +10 -0
  145. data/lib/smithy/content_pieces/registry.rb +39 -0
  146. data/lib/smithy/dependencies.rb +19 -0
  147. data/lib/smithy/dragonfly/asset_helper.rb +67 -0
  148. data/lib/smithy/dragonfly/remote_data_store.rb +33 -0
  149. data/lib/smithy/dragonfly.rb +30 -0
  150. data/lib/smithy/engine.rb +48 -0
  151. data/lib/smithy/formatter.rb +46 -0
  152. data/lib/smithy/liquid/database.rb +12 -0
  153. data/lib/smithy/liquid/drops/base.rb +16 -0
  154. data/lib/smithy/liquid/drops/page.rb +78 -0
  155. data/lib/smithy/liquid/filters/asset_tag.rb +33 -0
  156. data/lib/smithy/liquid/filters/resize.rb +12 -0
  157. data/lib/smithy/liquid/rendering.rb +50 -0
  158. data/lib/smithy/liquid/tags/asset.rb +54 -0
  159. data/lib/smithy/liquid/tags/csrf.rb +30 -0
  160. data/lib/smithy/liquid/tags/html.rb +61 -0
  161. data/lib/smithy/liquid/tags/nav.rb +76 -0
  162. data/lib/smithy/liquid.rb +8 -0
  163. data/lib/smithy/logger.rb +12 -0
  164. data/lib/smithy/version.rb +3 -0
  165. data/lib/smithy.rb +21 -0
  166. data/lib/smithycms.rb +1 -0
  167. data/lib/tasks/smithy_tasks.rake +4 -0
  168. data/lib/templates/erb/scaffold/_form.html.erb +11 -0
  169. metadata +871 -0
@@ -0,0 +1,55 @@
1
+ /*
2
+ Nested Forms
3
+ */
4
+ $(function() {
5
+ $('form').on('click', 'a.add_nested_fields', function() {
6
+ // Setup
7
+ var assoc = $(this).attr('data-association'); // Name of child
8
+ var content = $('#' + assoc + '_fields_blueprint').html(); // Fields template
9
+
10
+ // Make the context correct by replacing new_<parents> with the generated ID
11
+ // of each of the parent objects
12
+ var context = ($(this).parents('.fields').children('input:first').attr('name') || '').replace(new RegExp('[[a-z]+]$'), '');
13
+
14
+ // context will be something like this for a brand new form:
15
+ // project[tasks_attributes][1255929127459][assignments_attributes][1255929128105]
16
+ // or for an edit form:
17
+ // project[tasks_attributes][0][assignments_attributes][1]
18
+ if(context) {
19
+ var parent_names = context.match(/[a-z]+_attributes/g) || []
20
+ var parent_ids = context.match(/[0-9]+/g)
21
+
22
+ for(i = 0; i < parent_names.length; i++) {
23
+ if(parent_ids[i]) {
24
+ content = content.replace(
25
+ new RegExp('(\[' + parent_names[i] + '\])\[.+?\]', 'g'),
26
+ '$1[' + parent_ids[i] + ']'
27
+ )
28
+ }
29
+ }
30
+ }
31
+
32
+ // Make a unique ID for the new child
33
+ var regexp = new RegExp('new_' + assoc, 'g');
34
+ var new_id = new Date().getTime();
35
+ content = content.replace(regexp, new_id)
36
+
37
+ $(this).parent().after(content);
38
+ return false;
39
+ });
40
+
41
+ $('form').on('click', 'a.remove_nested_fields', function() {
42
+ var container = $(this).closest('.destroy');
43
+ var hidden_field = $('input[type=hidden]', container).val('1');
44
+ $(this).closest('.nested').hide();
45
+ return false;
46
+ });
47
+
48
+ // replace the remover checkboxes with a link
49
+ $('form .destroy > label').hide();
50
+ $('form .destroy .controls label').each(function(i) {
51
+ link = $('<a href="javascript:void(0);" class="btn btn-danger btn-mini">Delete</a>').addClass("remove_nested_fields");
52
+ $(this).empty().append($(link));
53
+ });
54
+
55
+ });
@@ -0,0 +1,4 @@
1
+ $("form#new_page_content .page_content_block").click(function() {
2
+ $('#page_content_content_block_type').val($(this).attr('data-content_block'));
3
+ $('form#new_page_content').submit();
4
+ });
@@ -0,0 +1,41 @@
1
+ $(function() {
2
+ // Support for AJAX loaded modal window.
3
+ // Focuses on first input textbox after it loads the window.
4
+ $("[data-previewtoggle='modal']").on('click', function(e) {
5
+ e.preventDefault();
6
+ var url = $(this).attr('href');
7
+ if (url.indexOf('#') == 0) {
8
+ $(url).modal('open');
9
+ } else {
10
+ $.get(url, function(data) {
11
+ $('<div class="modal hide fade">' + data + '</div>').modal();
12
+ }).success(function() { $('input:text:visible:first').focus(); });
13
+ }
14
+ });
15
+
16
+ $(".page-contents").sortable({
17
+ distance: 20,
18
+ handle: ".handle",
19
+ items: "tr.page_content",
20
+ update: function() {
21
+ $.ajax($(this).attr('data-reorder-href'), {
22
+ data: $(this).sortable("serialize", { key: "order[]" })
23
+ });
24
+ }
25
+ });
26
+
27
+ $(".page-list").sortable({
28
+ distance: 20,
29
+ handle: ".handle",
30
+ items: "> li.child",
31
+ update: function() {
32
+ $.ajax("/smithy/pages/order", {
33
+ data: $(".page-list").sortable("serialize", { key: "order[]" })
34
+ // highlight on failure?
35
+ // failure: function(xhr, status, error) {}
36
+ });
37
+ }
38
+ });
39
+ });
40
+
41
+
File without changes
@@ -0,0 +1,25 @@
1
+ var ace_edit = function(id, template_type, name) {
2
+ if (!name) { name = 'template_content' }
3
+ var editor_name = name + '_editor-' + id
4
+ $('#'+editor_name).show();
5
+ var editor = ace.edit(editor_name);
6
+ var textarea = $('textarea[id="' + name + '-'+id+'"]').hide();
7
+ var session = editor.getSession();
8
+ session.setMode("ace/mode/" + template_type);
9
+ session.setValue(textarea.val());
10
+ session.setTabSize(2);
11
+ session.setUseSoftTabs(true);
12
+ session.setUseWrapMode(true);
13
+ session.on('change', function(){
14
+ textarea.val(editor.getSession().getValue());
15
+ });
16
+ editor.commands.addCommand({
17
+ name: 'save',
18
+ bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
19
+ exec: function(editor) {
20
+ $("#"+editor.container.id).closest('form').submit();
21
+ },
22
+ readOnly: false
23
+ });
24
+ return editor;
25
+ }
@@ -0,0 +1,29 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= depend_on smithy/bootstrap_and_overrides.css.scss
13
+ *= depend_on smithy/assets.css.scss
14
+ *= depend_on smithy/content_blocks.css.scss
15
+ *= depend_on smithy/layout.css.scss
16
+ *= depend_on smithy/forms.css.scss
17
+ *= depend_on smithy/guides.css.scss
18
+ *= depend_on smithy/pages.css.scss
19
+ *= depend_on smithy/templates.css.scss
20
+ */
21
+
22
+ @import 'bootstrap_and_overrides';
23
+ @import 'layout';
24
+ @import 'forms';
25
+ @import 'guides';
26
+ @import 'pages';
27
+ @import 'templates';
28
+ @import 'content_blocks';
29
+ @import 'assets';
@@ -0,0 +1,3 @@
1
+ #asset-thumbnails>li { width:180px;
2
+ .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
3
+ }
@@ -0,0 +1,12 @@
1
+ @import "bootstrap";
2
+ @import "bootstrap-responsive";
3
+ @import "font-awesome";
4
+ .icon-white,
5
+ .nav > .active > a > [class^="icon-"],
6
+ .nav > .active > a > [class*=" icon-"],
7
+ .dropdown-menu > li > a:hover > [class^="icon-"],
8
+ .dropdown-menu > li > a:hover > [class*=" icon-"],
9
+ .dropdown-menu > .active > a > [class^="icon-"],
10
+ .dropdown-menu > .active > a > [class*=" icon-"] {
11
+ background-image: none;
12
+ }
@@ -0,0 +1,2 @@
1
+ // #content_block_description { width:97%; }
2
+ .content_block_template_fields textarea { width:97%; }
@@ -0,0 +1,3 @@
1
+ #template_content,
2
+ #content_content,
3
+ #content_block_content { height:100%; width:97%; }
@@ -0,0 +1,5 @@
1
+ #guideHeader {
2
+ background:#444; border-bottom:1px solid #999; color:#999; padding:0 16px;
3
+ h1 { font-size:16px; line-height:1.2; }
4
+ h2 { font-size:14px; line-height:1.2; }
5
+ }
@@ -0,0 +1,113 @@
1
+ body { background:#444; padding:0; }
2
+
3
+ #header { border-bottom:1px solid #666; position:relative; top:0; z-index:-5;
4
+ h1 {
5
+ margin:0;
6
+ padding:2px 8px;
7
+ text-align:center;
8
+ width:20%;
9
+ img { max-width:100%; }
10
+ }
11
+ }
12
+ #header {
13
+ background: #333333; /* Old browsers */
14
+ background: -moz-linear-gradient(top, #333333 0%, #222222 100%); /* FF3.6+ */
15
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#333333), color-stop(100%,#222222)); /* Chrome,Safari4+ */
16
+ background: -webkit-linear-gradient(top, #333333 0%,#222222 100%); /* Chrome10+,Safari5.1+ */
17
+ background: -o-linear-gradient(top, #333333 0%,#222222 100%); /* Opera 11.10+ */
18
+ background: -ms-linear-gradient(top, #333333 0%,#222222 100%); /* IE10+ */
19
+ background: linear-gradient(to bottom, #333333 0%,#222222 100%); /* W3C */
20
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#333333', endColorstr='#222222',GradientType=0 ); /* IE6-9 */
21
+ }
22
+ #main-nav {
23
+ background:transparent;
24
+ left:20%;
25
+ right:0;
26
+ position:absolute;
27
+ top:0;
28
+ z-index:5;
29
+
30
+ .navbar-inner { background:transparent; border:0; padding-left:0;
31
+ box-shadow:none;
32
+ -webkit-box-shadow:none;
33
+ -moz-box-shadow:none;
34
+ }
35
+ .container { padding-top: 6px; }
36
+ }
37
+ @media (max-width: 979px) {
38
+ #main-nav {
39
+ .nav-collapse {
40
+ background-color:#333;
41
+ }
42
+ }
43
+ }
44
+
45
+ #side {
46
+ border-top:1px solid #393939; float:left; position:relative; width:20%;
47
+ .actions { padding:16px 15px 0 15px ; }
48
+ .nav-list {
49
+ border-top:1px solid #393939;
50
+ margin:16px 0 0 0;
51
+ padding:0;
52
+ .nav-list { margin:0; }
53
+ li + .nav-header {
54
+ margin-top:16px;
55
+ }
56
+ .nav-header {
57
+ color:#DDD;
58
+ }
59
+ > li {
60
+ border-top:1px solid #4e4e4e;
61
+ border-bottom:1px solid #393939;
62
+ color:#AAA;
63
+ }
64
+ > li > a,
65
+ .nav-header {
66
+ text-shadow: 0 1px 0 rgba(0,0,0,.5);
67
+ margin:0;
68
+ padding:8px 15px;
69
+ }
70
+ > li > a {
71
+ background-color:transparent;
72
+ color:#AAA;
73
+ }
74
+ > li > a:hover {
75
+ background-color:#4f4f4f;
76
+ color:#CCC;
77
+ }
78
+ > .active {
79
+ background: #292929; /* Old browsers */
80
+ background: -moz-linear-gradient(top, #292929 0%, #3a3a3a 100%);
81
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#292929), color-stop(100%,#3a3a3a));
82
+ background: -webkit-linear-gradient(top, #292929 0%,#3a3a3a 100%);
83
+ background: -o-linear-gradient(top, #292929 0%,#3a3a3a 100%);
84
+ background: -ms-linear-gradient(top, #292929 0%,#3a3a3a 100%);
85
+ background: linear-gradient(to bottom, #292929 0%,#3a3a3a 100%);
86
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#292929', endColorstr='#3a3a3a',GradientType=0 );
87
+ > a,
88
+ > a:hover{ background-color:transparent; }
89
+ }
90
+ }
91
+ }
92
+ #main { background:#f9f9f9; margin:-52px 0 0 20%; padding:0 0 24px 0; position:relative;
93
+ -webkit-border-radius: 10px 0px 0px 10px;
94
+ border-radius: 10px 0px 0px 10px;
95
+ -webkit-box-shadow: 0px 0px 18px 0px rgba(0, 0, 0, 0.4);
96
+ box-shadow: 0px 0px 18px 0px rgba(0, 0, 0, 0.4);
97
+ > h1 { padding:24px 0 0 12px; }
98
+ > .container-fluid { padding-right:0; }
99
+ #content { border-right:1px solid #DDD; }
100
+ #related {}
101
+ }
102
+
103
+ .wide #main {
104
+ > .container-fluid { padding-right:20px; }
105
+ #content { border-right:0; }
106
+ }
107
+
108
+ #main-wide { background:#f9f9f9; padding:0 0 24px 0; position:relative; }
109
+
110
+ #footer {
111
+ color:#BBB; font-size:12px; text-align:right; padding:1em;
112
+ a { color:#EEE; }
113
+ }
@@ -0,0 +1,35 @@
1
+ .page-contents {
2
+ .handle { color:#999; cursor:move; padding-right:6px; }
3
+ }
4
+
5
+ #side .page-list {
6
+ position:relative; overflow:hidden;
7
+ .back { background:#444; }
8
+ .back > a { border-top:1px solid #444; }
9
+ .add-page a { color:#888; text-align:right; padding-right:45px; }
10
+
11
+ }
12
+
13
+ #side .page-list > li {
14
+ position:relative;
15
+
16
+ > .handle { color:#777; cursor:move; position:absolute; left:6px; top:50%; margin-top:-0.75em;
17
+ &:hover { color:#DDD; }
18
+ }
19
+ > a.edit-page {
20
+ padding:8px 28px;
21
+ display: block;
22
+ white-space: nowrap;
23
+ text-overflow: ellipsis;
24
+ overflow: hidden;
25
+ }
26
+ > a.add-page {
27
+ color:#666; padding:6px; position:absolute; right:0px; top:50%; margin-top:-1.25em;
28
+ &:hover,
29
+ &:active { background:transparent; color:#DDD; }
30
+ }
31
+ &.home > a {
32
+ padding-left:6px;
33
+ }
34
+ }
35
+
@@ -0,0 +1,14 @@
1
+ .template_types {}
2
+
3
+ textarea[name="template[content]"],
4
+ textarea[name="content[content]"],
5
+ #template_content,
6
+ #content_content { height:100%; width:97%; }
7
+
8
+ .template_content_editor,
9
+ .ace_editor {
10
+ display:none;
11
+ min-height:40em;
12
+ width:97%;
13
+ position:relative;
14
+ }
@@ -0,0 +1,50 @@
1
+ require_dependency "smithy/base_controller"
2
+
3
+ module Smithy
4
+ class AssetsController < BaseController
5
+ before_filter :load_assets, :only => :index
6
+ respond_to :html, :json, :js
7
+
8
+ def index
9
+ respond_with @assets, :layout => 'smithy/wide'
10
+ end
11
+
12
+ def new
13
+ @asset = Asset.new(params[:asset])
14
+ respond_with @asset
15
+ end
16
+
17
+ def create
18
+ @asset = Asset.new(params[:asset])
19
+ @asset.save
20
+ flash.notice = "Your asset was created" if @asset.persisted?
21
+ respond_with @asset do |format|
22
+ format.html { redirect_to assets_path }
23
+ end
24
+ end
25
+
26
+ def edit
27
+ @asset = Asset.find(params[:id])
28
+ respond_with @asset
29
+ end
30
+
31
+ def update
32
+ @asset = Asset.find(params[:id])
33
+ flash.notice = "Your asset was saved" if @asset.update_attributes(params[:asset])
34
+ respond_with @asset do |format|
35
+ format.html { redirect_to assets_path }
36
+ end
37
+ end
38
+
39
+ def destroy
40
+ @asset = Asset.find(params[:id])
41
+ @asset.destroy
42
+ respond_with @asset
43
+ end
44
+
45
+ private
46
+ def load_assets
47
+ @assets = Asset.order(:name).page(params[:page])
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,14 @@
1
+ class Smithy::BaseController < ApplicationController
2
+ layout 'smithy/application'
3
+
4
+ before_filter :authenticate_smithy_admin
5
+
6
+ private
7
+
8
+ def authenticate_smithy_admin
9
+ unless smithy_current_user && smithy_current_user.smithy_admin?
10
+ flash.alert = "Please login to continue."
11
+ redirect_to smithy_login_path
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ require_dependency "smithy/base_controller"
2
+
3
+ module Smithy
4
+ class CachesController < BaseController
5
+ def show
6
+ end
7
+
8
+ def destroy
9
+ Rails.cache.clear
10
+ redirect_to cache_path, :notice => "The cache has been cleared"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,50 @@
1
+ require_dependency "smithy/base_controller"
2
+
3
+ module Smithy
4
+ class ContentBlocksController < BaseController
5
+ before_filter :load_content_blocks
6
+ respond_to :html, :json
7
+
8
+ def index
9
+ respond_with @content_blocks
10
+ end
11
+
12
+ def new
13
+ @content_block = ContentBlock.new(params[:content_block])
14
+ respond_with @content_block
15
+ end
16
+
17
+ def create
18
+ @content_block = ContentBlock.new(params[:content_block])
19
+ @content_block.save
20
+ flash.notice = "Your content_block was created" if @content_block.persisted?
21
+ respond_with @content_block do |format|
22
+ format.html { redirect_to [:edit, @content_block] }
23
+ end
24
+ end
25
+
26
+ def edit
27
+ @content_block = ContentBlock.find(params[:id])
28
+ respond_with @content_block
29
+ end
30
+
31
+ def update
32
+ @content_block = ContentBlock.find(params[:id])
33
+ flash.notice = "Your content_block was saved" if @content_block.update_attributes(params[:content_block])
34
+ respond_with @content_block do |format|
35
+ format.html { redirect_to [:edit, @content_block] }
36
+ end
37
+ end
38
+
39
+ def destroy
40
+ @content_block = ContentBlock.find(params[:id])
41
+ @content_block.destroy
42
+ respond_with @content_block
43
+ end
44
+
45
+ private
46
+ def load_content_blocks
47
+ @content_blocks = ContentBlock.all
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,97 @@
1
+ require_dependency "smithy/base_controller"
2
+
3
+ class Smithy::ContentPiecesController < Smithy::BaseController
4
+ before_filter :set_controller_path
5
+ respond_to :html, :json
6
+
7
+ helper_method :accessible_attributes
8
+ helper_method :klass_name
9
+ helper_method :readable_attributes
10
+
11
+ def index
12
+ @records = find_records
13
+ respond_with @records, :layout => 'smithy/wide'
14
+ end
15
+
16
+ def show
17
+ @record = find_record
18
+ respond_with @record
19
+ end
20
+
21
+ def new
22
+ @record = new_record
23
+ respond_with @record
24
+ end
25
+
26
+ def create
27
+ @record = new_record
28
+ @record.save
29
+ flash.notice = "Your #{klass_name} was created" if @record.persisted?
30
+ respond_with @record do |format|
31
+ format.html { @record.persisted? ? redirect_to([:edit, @record]) : render(:action => 'new') }
32
+ end
33
+ end
34
+
35
+ def edit
36
+ @record = find_record
37
+ respond_with @record
38
+ end
39
+
40
+ def update
41
+ @record = find_record
42
+ @saved = update_record(@record)
43
+ flash.notice = "Your #{klass_name} was saved" if @saved
44
+ respond_with @page_content do |format|
45
+ format.html { @saved ? redirect_to(:action => :index) : render(:action => "edit") }
46
+ end
47
+ end
48
+
49
+ def destroy
50
+ @record = find_record
51
+ @record.destroy
52
+ flash.notice = "Your #{klass_name} was deleted"
53
+ respond_with @record
54
+ end
55
+
56
+ private
57
+ def klass
58
+ # override to provide an object for each class
59
+ raise "You must inherit from this Smithy::ContentPiecesController and provide a private #klass method"
60
+ end
61
+
62
+ def klass_name
63
+ @klass_name ||= klass.name.sub(/^Smithy::/, '').titleize
64
+ end
65
+
66
+ def klass_params
67
+ params[klass.name.sub(/^Smithy::/, '').underscore]
68
+ end
69
+
70
+ def new_record
71
+ klass.new(klass_params)
72
+ end
73
+
74
+ def find_record
75
+ klass.find(params[:id])
76
+ end
77
+
78
+ def find_records
79
+ klass.all
80
+ end
81
+
82
+ def set_controller_path
83
+ @controller_path = self.class.superclass.name.sub(/Controller$/, '').deconstantize.underscore
84
+ end
85
+
86
+ def update_record(record)
87
+ record.update_attributes(klass_params)
88
+ end
89
+
90
+ def readable_attributes
91
+ accessible_attributes
92
+ end
93
+
94
+ def accessible_attributes
95
+ klass.accessible_attributes.select(&:present?).map(&:to_sym)
96
+ end
97
+ end
@@ -0,0 +1,41 @@
1
+ require_dependency "smithy/base_controller"
2
+
3
+ module Smithy
4
+ class ContentsController < BaseController
5
+ respond_to :html, :json
6
+
7
+ def show
8
+ @content = Smithy::Content.find(params[:id])
9
+ respond_with @content
10
+ end
11
+
12
+ def new
13
+ @content = Smithy::Content.new(params[:content])
14
+ respond_with @content
15
+ end
16
+
17
+ def create
18
+ @content = Smithy::Content.new(params[:content])
19
+ @content.save
20
+ flash.notice = "Your content was created" if @content.persisted?
21
+ respond_with @content
22
+ end
23
+
24
+ def edit
25
+ @content = Smithy::Content.find(params[:id])
26
+ respond_with @content
27
+ end
28
+
29
+ def update
30
+ @content = Smithy::Content.find(params[:id])
31
+ flash.notice = "Your content was saved" if @content.update_attributes(params[:content])
32
+ respond_with @content
33
+ end
34
+
35
+ def destroy
36
+ @content = Smithy::Content.find(params[:id])
37
+ @content.destroy
38
+ respond_with @content
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,9 @@
1
+ require_dependency "smithy/base_controller"
2
+
3
+ module Smithy
4
+ class GuidesController < BaseController
5
+ def show
6
+ render :action => params[:id], :layout => request.xhr? ? false : 'smithy/guides'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,41 @@
1
+ require_dependency "smithy/base_controller"
2
+
3
+ module Smithy
4
+ class ImagesController < BaseController
5
+ respond_to :html, :json
6
+
7
+ def show
8
+ @image = Smithy::Image.find(params[:id])
9
+ respond_with @image
10
+ end
11
+
12
+ def new
13
+ @image = Smithy::Image.new(params[:image])
14
+ respond_with @image
15
+ end
16
+
17
+ def create
18
+ @image = Smithy::Image.new(params[:image])
19
+ @image.save
20
+ flash.notice = "Your image was created" if @image.persisted?
21
+ respond_with @image
22
+ end
23
+
24
+ def edit
25
+ @image = Smithy::Image.find(params[:id])
26
+ respond_with @image
27
+ end
28
+
29
+ def update
30
+ @image = Smithy::Image.find(params[:id])
31
+ flash.notice = "Your image was saved" if @image.update_attributes(params[:image])
32
+ respond_with @image
33
+ end
34
+
35
+ def destroy
36
+ @image = Smithy::Image.find(params[:id])
37
+ @image.destroy
38
+ respond_with @image
39
+ end
40
+ end
41
+ end