mercury-rails 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. data/LICENSE +5 -0
  2. data/{README.rdoc → README.md} +150 -60
  3. data/VERSION +1 -1
  4. data/annotated_source.template +57 -0
  5. data/app/controllers/mercury_controller.rb +8 -4
  6. data/app/models/image.rb +2 -2
  7. data/app/views/layouts/mercury.html.erb +14 -0
  8. data/app/views/mercury/lightviews/about.html +7 -0
  9. data/app/views/mercury/lightviews/imageprocessor.html +3 -0
  10. data/app/views/mercury/modals/character.html +255 -0
  11. data/app/views/mercury/modals/htmleditor.html +13 -0
  12. data/app/views/mercury/modals/link.html +75 -0
  13. data/app/views/mercury/modals/media.html +82 -0
  14. data/app/views/mercury/modals/sanitizer.html +9 -0
  15. data/app/views/mercury/modals/table.html +84 -0
  16. data/app/views/mercury/palettes/backcolor.html +73 -0
  17. data/app/views/mercury/palettes/forecolor.html +73 -0
  18. data/app/views/mercury/panels/history.html +3 -0
  19. data/app/views/mercury/panels/notes.html +3 -0
  20. data/app/views/mercury/panels/snippets.html +12 -0
  21. data/app/views/mercury/selects/formatblock.html +11 -0
  22. data/app/views/mercury/selects/style.html +5 -0
  23. data/app/views/mercury/snippets/example.html.erb +1 -0
  24. data/app/views/mercury/snippets/example_options.html.erb +23 -0
  25. data/config/routes.rb +1 -1
  26. data/features/editing/basic.feature +1 -1
  27. data/features/support/paths.rb +1 -0
  28. data/lib/generators/mercury/install/install_generator.rb +14 -0
  29. data/mercury-rails.gemspec +115 -106
  30. data/spec/javascripts/mercury/dialog_spec.js.coffee +54 -38
  31. data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +1 -1
  32. data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +1 -1
  33. data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +1 -1
  34. data/spec/javascripts/mercury/dialogs/{objectspanel_spec.js.coffee → snippetpanel_spec.js.coffee} +4 -4
  35. data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +1 -1
  36. data/spec/javascripts/mercury/history_buffer_spec.js.coffee +0 -1
  37. data/spec/javascripts/mercury/lightview_spec.js.coffee +448 -0
  38. data/spec/javascripts/mercury/mercury_spec.js.coffee +1 -1
  39. data/spec/javascripts/mercury/modal_spec.js.coffee +474 -0
  40. data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +1 -1
  41. data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +1 -1
  42. data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +8 -2
  43. data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +1 -1
  44. data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +1 -1
  45. data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +1 -1
  46. data/spec/javascripts/mercury/native_extensions_spec.js.coffee +1 -1
  47. data/spec/javascripts/mercury/page_editor_spec.js.coffee +160 -20
  48. data/spec/javascripts/mercury/palette_spec.js.coffee +1 -1
  49. data/spec/javascripts/mercury/panel_spec.js.coffee +1 -1
  50. data/spec/javascripts/mercury/region_spec.js.coffee +1 -1
  51. data/spec/javascripts/mercury/regions/editable_spec.js.coffee +191 -6
  52. data/spec/javascripts/mercury/regions/markupable_spec.js.coffee +369 -0
  53. data/spec/javascripts/mercury/regions/snippetable_spec.js.coffee +1 -1
  54. data/spec/javascripts/mercury/select_spec.js.coffee +1 -1
  55. data/spec/javascripts/mercury/snippet_spec.js.coffee +3 -3
  56. data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +2 -2
  57. data/spec/javascripts/mercury/statusbar_spec.js.coffee +91 -17
  58. data/spec/javascripts/mercury/table_editor_spec.js.coffee +5 -1
  59. data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +1 -1
  60. data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +1 -1
  61. data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +1 -1
  62. data/spec/javascripts/mercury/toolbar_spec.js.coffee +70 -15
  63. data/spec/javascripts/mercury/tooltip_spec.js.coffee +1 -1
  64. data/spec/javascripts/mercury/uploader_spec.js.coffee +9 -1
  65. data/spec/javascripts/templates/mercury/dialogs/{objectspanel.html → snippetpanel.html} +0 -0
  66. data/spec/javascripts/templates/mercury/lightview.html +13 -0
  67. data/spec/javascripts/templates/mercury/modal.html +13 -0
  68. data/spec/javascripts/templates/mercury/page_editor.html +11 -1
  69. data/spec/javascripts/templates/mercury/statusbar.html +1 -0
  70. data/spec/javascripts/templates/mercury/toolbar.html +1 -0
  71. data/{app → vendor}/assets/images/mercury/button.png +0 -0
  72. data/{app → vendor}/assets/images/mercury/clippy.png +0 -0
  73. data/{app → vendor}/assets/images/mercury/default-snippet.png +0 -0
  74. data/{app → vendor}/assets/images/mercury/loading-dark.gif +0 -0
  75. data/{app → vendor}/assets/images/mercury/loading-light.gif +0 -0
  76. data/{app → vendor}/assets/images/mercury/search-icon.png +0 -0
  77. data/vendor/assets/images/mercury/temp-logo.png +0 -0
  78. data/{app → vendor}/assets/images/mercury/toolbar/editable/buttons.png +0 -0
  79. data/{app → vendor}/assets/images/mercury/toolbar/primary/_expander.png +0 -0
  80. data/{app → vendor}/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
  81. data/{app → vendor}/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
  82. data/{app → vendor}/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
  83. data/{app → vendor}/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
  84. data/{app → vendor}/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
  85. data/{app → vendor}/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
  86. data/{app → vendor}/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
  87. data/{app → vendor}/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
  88. data/{app → vendor}/assets/images/mercury/toolbar/primary/preview.png +0 -0
  89. data/{app → vendor}/assets/images/mercury/toolbar/primary/redo.png +0 -0
  90. data/{app → vendor}/assets/images/mercury/toolbar/primary/save.png +0 -0
  91. data/{app/assets/images/mercury/toolbar/primary/objectspanel.png → vendor/assets/images/mercury/toolbar/primary/snippetpanel.png} +0 -0
  92. data/{app → vendor}/assets/images/mercury/toolbar/primary/undo.png +0 -0
  93. data/{app → vendor}/assets/images/mercury/toolbar/snippetable/buttons.png +0 -0
  94. data/vendor/assets/javascripts/mercury.js +302 -0
  95. data/vendor/assets/javascripts/mercury/dialog.js.coffee +157 -0
  96. data/{app → vendor}/assets/javascripts/mercury/dialogs/backcolor.js.coffee +0 -0
  97. data/{app → vendor}/assets/javascripts/mercury/dialogs/forecolor.js.coffee +0 -0
  98. data/{app → vendor}/assets/javascripts/mercury/dialogs/formatblock.js.coffee +0 -0
  99. data/{app → vendor}/assets/javascripts/mercury/dialogs/objectspanel.js.coffee +1 -1
  100. data/{app → vendor}/assets/javascripts/mercury/dialogs/style.js.coffee +0 -0
  101. data/{app → vendor}/assets/javascripts/mercury/history_buffer.js.coffee +0 -0
  102. data/vendor/assets/javascripts/mercury/lightview.js.coffee +156 -0
  103. data/vendor/assets/javascripts/mercury/lightviews/imageprocessor.js.coffee +2 -0
  104. data/vendor/assets/javascripts/mercury/mercury.js.coffee +63 -0
  105. data/{app → vendor}/assets/javascripts/mercury/modal.js.coffee +25 -17
  106. data/{app → vendor}/assets/javascripts/mercury/modals/htmleditor.js.coffee +0 -0
  107. data/{app → vendor}/assets/javascripts/mercury/modals/insertcharacter.js.coffee +0 -0
  108. data/{app → vendor}/assets/javascripts/mercury/modals/insertlink.js.coffee +3 -0
  109. data/{app → vendor}/assets/javascripts/mercury/modals/insertmedia.js.coffee +10 -2
  110. data/{app → vendor}/assets/javascripts/mercury/modals/insertsnippet.js.coffee +0 -0
  111. data/{app → vendor}/assets/javascripts/mercury/modals/inserttable.js.coffee +2 -2
  112. data/{app → vendor}/assets/javascripts/mercury/native_extensions.js.coffee +0 -0
  113. data/{app → vendor}/assets/javascripts/mercury/page_editor.js.coffee +44 -13
  114. data/{app → vendor}/assets/javascripts/mercury/palette.js.coffee +0 -0
  115. data/{app → vendor}/assets/javascripts/mercury/panel.js.coffee +0 -0
  116. data/{app → vendor}/assets/javascripts/mercury/region.js.coffee +0 -0
  117. data/{app → vendor}/assets/javascripts/mercury/regions/editable.js.coffee +58 -12
  118. data/{app → vendor}/assets/javascripts/mercury/regions/markupable.js.coffee +26 -24
  119. data/{app → vendor}/assets/javascripts/mercury/regions/snippetable.js.coffee +0 -0
  120. data/{app → vendor}/assets/javascripts/mercury/select.js.coffee +3 -0
  121. data/{app → vendor}/assets/javascripts/mercury/snippet.js.coffee +9 -5
  122. data/{app → vendor}/assets/javascripts/mercury/snippet_toolbar.js.coffee +0 -0
  123. data/vendor/assets/javascripts/mercury/statusbar.js.coffee +51 -0
  124. data/{app → vendor}/assets/javascripts/mercury/table_editor.js.coffee +9 -8
  125. data/{app → vendor}/assets/javascripts/mercury/toolbar.button.js.coffee +0 -0
  126. data/{app → vendor}/assets/javascripts/mercury/toolbar.button_group.js.coffee +0 -0
  127. data/{app → vendor}/assets/javascripts/mercury/toolbar.expander.js.coffee +0 -0
  128. data/{app → vendor}/assets/javascripts/mercury/toolbar.js.coffee +14 -1
  129. data/{app → vendor}/assets/javascripts/mercury/tooltip.js.coffee +3 -0
  130. data/{app → vendor}/assets/javascripts/mercury/uploader.js.coffee +22 -13
  131. data/vendor/assets/javascripts/{jquery-1.6.js → mercury_dependencies/jquery-1.6.js} +0 -0
  132. data/vendor/assets/javascripts/{jquery-ui-1.8.13.custom.js → mercury_dependencies/jquery-ui-1.8.13.custom.js} +0 -0
  133. data/vendor/assets/javascripts/{jquery.additions.js → mercury_dependencies/jquery.additions.js} +0 -0
  134. data/vendor/assets/javascripts/{liquidmetal.js → mercury_dependencies/liquidmetal.js} +0 -0
  135. data/vendor/assets/javascripts/{showdown.js → mercury_dependencies/showdown.js} +0 -0
  136. data/vendor/assets/javascripts/mercury_loader.js +191 -0
  137. data/{app → vendor}/assets/stylesheets/mercury.css +3 -6
  138. data/vendor/assets/stylesheets/mercury/dialog.css +199 -0
  139. data/vendor/assets/stylesheets/mercury/lightview.css +92 -0
  140. data/vendor/assets/stylesheets/mercury/mercury.css +134 -0
  141. data/vendor/assets/stylesheets/mercury/modal.css +191 -0
  142. data/{app/assets/stylesheets/mercury/statusbar.scss → vendor/assets/stylesheets/mercury/statusbar.css} +9 -1
  143. data/vendor/assets/stylesheets/mercury/toolbar.css +329 -0
  144. data/{app/assets/stylesheets/mercury/tooltip.scss → vendor/assets/stylesheets/mercury/tooltip.css} +7 -7
  145. data/vendor/assets/stylesheets/mercury/uploader.css +111 -0
  146. metadata +230 -225
  147. data/app/assets/images/mercury/toolbar/markupable/buttons.png +0 -0
  148. data/app/assets/images/mercury/toolbar/primary/todospanel.png +0 -0
  149. data/app/assets/javascripts/mercury.js +0 -30
  150. data/app/assets/javascripts/mercury/dialog.js.coffee +0 -75
  151. data/app/assets/javascripts/mercury/mercury.js.coffee +0 -286
  152. data/app/assets/javascripts/mercury/statusbar.js.coffee +0 -29
  153. data/app/assets/javascripts/mercury_loader.js +0 -98
  154. data/app/assets/stylesheets/mercury/dialog.scss +0 -179
  155. data/app/assets/stylesheets/mercury/mercury.scss +0 -127
  156. data/app/assets/stylesheets/mercury/modal.scss +0 -194
  157. data/app/assets/stylesheets/mercury/toolbar.scss +0 -415
  158. data/app/assets/stylesheets/mercury/uploader.scss +0 -109
  159. data/app/views/layouts/mercury.html.haml +0 -8
  160. data/app/views/mercury/modals/character.html.haml +0 -252
  161. data/app/views/mercury/modals/htmleditor.html.haml +0 -8
  162. data/app/views/mercury/modals/link.html.haml +0 -31
  163. data/app/views/mercury/modals/media.html.haml +0 -33
  164. data/app/views/mercury/modals/sanitizer.html.haml +0 -4
  165. data/app/views/mercury/modals/table.html.haml +0 -49
  166. data/app/views/mercury/palettes/backcolor.html.haml +0 -79
  167. data/app/views/mercury/palettes/forecolor.html.haml +0 -79
  168. data/app/views/mercury/panels/history.html.haml +0 -0
  169. data/app/views/mercury/panels/notes.html.haml +0 -0
  170. data/app/views/mercury/panels/snippets.html.haml +0 -10
  171. data/app/views/mercury/selects/formatblock.html.haml +0 -10
  172. data/app/views/mercury/selects/style.html.haml +0 -4
  173. data/app/views/mercury/snippets/example.html.haml +0 -2
  174. data/app/views/mercury/snippets/example_options.html.haml +0 -16
  175. data/log/.gitkeep +0 -0
  176. data/spec/javascripts/mercury/regions/_markupable_.js.coffee +0 -0
data/LICENSE CHANGED
@@ -1,3 +1,8 @@
1
+ Mercury Editor is a Coffeescript and jQuery based WYSIWYG editor.
2
+
3
+ Documentation and other useful information can be found at
4
+ https://github.com/jejacks0n/mercury
5
+
1
6
  Copyright (c) 2011 Jeremy Jackson
2
7
 
3
8
  Permission is hereby granted, free of charge, to any person obtaining
@@ -1,4 +1,4 @@
1
- = Mercury Editor
1
+ # Mercury Editor
2
2
 
3
3
  Mercury Editor is a fully featured editor much like TinyMCE or CKEditor, but with a different usage paradigm. It
4
4
  expects that an entire page is something that can be editable, and allows different types of editable regions to be
@@ -8,19 +8,28 @@ block elements, instead of iframes, which allows for CSS to be applied in ways t
8
8
  Mercury has been written using CoffeeScript and jQuery for the Javascript portions, and is written on top of Rails 3.1.
9
9
 
10
10
 
11
- == Browser Support
11
+ ## Browser Support
12
12
 
13
13
  Mercury has been written for the future, and thus doesn't support legacy browsers or browsers that don't follow the W3C
14
14
  specifications for content editing. Any browser will be supported if they support the W3C specification in the future,
15
15
  but there aren't plans for adding support for alternate implementations at this time.
16
16
 
17
17
  Supported Browsers:
18
- * Chrome 10+
19
- * Safari 5+
20
- * Firefox 4+
21
18
 
19
+ - Chrome 10+
20
+ - Safari 5+
21
+ - Firefox 4+
22
22
 
23
- == The Story
23
+
24
+ ## A Demo
25
+
26
+ Feel free to check out [the demo](http://jejacks0n.github.com/mercury/). The demo will be updated quite a bit in the
27
+ next weeks, so feel free to check back every now and then.. We'll be adding a full walkthrough that details each of the
28
+ major features shortly. If you would like to see how Mercury was implemented in the demo check the gh-pages branch,
29
+ it's a useful resource to see how you can integrate the Mercury bundle.
30
+
31
+
32
+ ## The Story
24
33
 
25
34
  I was looking for a fully featured editor that didn't use iframes, and there weren't any decent ones. My primary goal
26
35
  was to have areas that were editable, but that also allowed CSS to flow naturally. A few have cropped up since then
@@ -31,68 +40,97 @@ configuration, we chose a mix of configuration and code simplicity, which should
31
40
  customizing Mercury to suit your exact needs. This doesn't mean there's not configuration, and what's there provides
32
41
  much of what you'll need, but efforts were taken to keep it simple and powerful.
33
42
 
34
- Even though it's a great editor, Mercury Editor may not be the best for your needs (based on browser support, javascript
35
- library, etc.) so here's a list of some other editors that you might want to check out:
43
+ Even though it's a great editor, Mercury Editor may not be the best for your needs (based on browser support,
44
+ functionality, etc.) so here's a list of some other editors that you might want to check out:
36
45
 
37
- * {Aloha Editor}[http://www.aloha-editor.org/]
38
- * {jHtmlArea}[http://jhtmlarea.codeplex.com/]
39
- * {MarkItUp}[http://markitup.jaysalvat.com/home/]
40
- * {TinyMCE}[http://tinymce.moxiecode.com/]
41
- * {CKEditor}[http://ckeditor.com/]
42
- * {NicEdit}[http://nicedit.com/]
46
+ - [Aloha Editor](http://www.aloha-editor.org/)
47
+ - [jHtmlArea](http://jhtmlarea.codeplex.com/)
48
+ - [MarkItUp](http://markitup.jaysalvat.com/home/)
49
+ - [TinyMCE](http://tinymce.moxiecode.com/)
50
+ - [CKEditor](http://ckeditor.com/)
51
+ - [NicEdit](http://nicedit.com/)
43
52
 
44
53
 
45
- == Features
54
+ ## Features
46
55
 
47
56
  The feature list is actually pretty long, so here's a short list that need highlighting.
48
57
 
49
- * Previewing: Preview content while you're working to see exactly how it'll look.
50
- * Link Tools: Insert and edit links, including TOC/Bookmark links.
51
- * Media Tools: Insert and edit images, youtube videos, and vimeo videos.
52
- * Image Uploading: Drag images from your desktop and they'll be automatically uploaded and inserted.
53
- * Table Editing: Advanced table editing and creation.
54
- * Snippets: Insert and edit predefined and reusable bits of markup/code using drag and drop.
55
- * Notes: Attach notes to any page and communicate with other content authors.
56
- * Colaborative Editing: Edit any page that others are editing at the same time and see their changes in real time.
58
+ - Previewing: Preview content while you're working to see exactly how it'll look.
59
+ - Link Tools: Insert and edit links, including TOC/Bookmark links.
60
+ - Media Tools: Insert and edit images, youtube videos, and vimeo videos.
61
+ - Image Uploading: Drag images from your desktop and they'll be automatically uploaded and inserted.
62
+ - Table Editing: Advanced table editing and creation.
63
+ - Snippets: Insert and edit predefined and reusable bits of markup/code using drag and drop.
64
+ - Notes: Attach notes to any page and communicate with other content authors.
65
+ - Colaborative Editing: Edit any page that others are editing at the same time and see their changes in real time.
57
66
 
58
67
 
59
- == Installation
68
+ ## Installation
69
+
70
+ ### For Rails
60
71
 
61
72
  Include the gem in your Gemfile and bundle to install the gem.
62
73
 
63
- gem 'mercury-rails'
74
+ gem 'mercury-rails'
75
+
76
+ Make sure you get the migrations that you'll need.
77
+
78
+ rake mercury_engine:install:migrations
79
+ rake db:migrate
80
+
81
+ You can also get the configuration file by running the generator.
82
+
83
+ rails generate mercury:install
84
+
85
+ This generator puts the mercury base file (configuration) into your project in /app/assets/javascripts/mercury.js.
86
+
87
+ ### For Other Frameworks / Languages
88
+
89
+ Get the distro files by downloading them from github using the downloads feature, or pull them out of the project
90
+ manually (the files are in /public/mercury). Copy the files into your project, and if you adjust where they're
91
+ located (eg. not within mercury/javascripts or mercury/stylesheets) make sure you update the
92
+ mercury_loader.js file to reflect this.
93
+
94
+ Images are bundled into the CSS if you use the mercury.bundle.css file, but if you'd rather not use the bundled CSS
95
+ you'll need to grab the images manually and adjust the paths in the css file.
96
+
97
+ The dialogs (eg. color palettes, modals, and other dialog types) are bundled into the mercury_dialogs.js file. If you
98
+ would like to customize a view you can remove the view from the mercury_dialogs.js file and adjust the path you want to
99
+ load using the configuration -- your custom view will then load using Ajax.
64
100
 
65
- There's a migration for images that you'll need as well.
101
+ Bundling snippet options and snippets doesn't work in this way, so you may need to disable snippets or adjust where
102
+ they're loaded from.. We'll see how this pans out and adjust over time if needed, so feedback would be useful here.
66
103
 
67
- rake mercury_engine:install:migrations
68
- rake db:migrate
104
+ If you use the distro instead of using the Rails Engine, you won't be able to utilize the Route usage method outlined in
105
+ the Usage portion of this documentation.
69
106
 
70
107
 
71
- == Usage
108
+ ## Usage
72
109
 
73
110
  Mercury has an expectation that content regions will be on the page (not required, but probably useful). To define
74
111
  content regions that Mercury will make editable you need to add a `mercury-region` class attribute to a div. Then
75
112
  specify what region type by using the `data-type` attribute -- which can be *editable*, *markupable*, or *snippetable*.
76
- Region types are outlined below.
113
+ It's important for saving that an id attribute be set on regions, you should always include. Region types are outlined
114
+ below.
77
115
 
78
- <div class="mercury-region" data-type="editable">
79
- default content
80
- </div>
116
+ <div id="primary" class="mercury-region" data-type="editable">
117
+ default content
118
+ </div>
81
119
 
82
- There's two methods to initialize Mercury Editor, and each one has it's benefits.
120
+ There's two methods to initialize Mercury Editor, and each one has it's benefits and drawbacks.
83
121
 
84
- === Script Method
122
+ ### Script Method
85
123
 
86
124
  Include the mercury_loader.js file. The loader will reload the page and enable Mercury in full page editing mode, so
87
125
  you may want to wrap this in conditional logic (eg. only admins or something).
88
126
 
89
- javascript_include_tag 'mercury_loader.js'
127
+ javascript_include_tag 'mercury_loader.js'
90
128
 
91
129
  Even though many efforts have been made to keep conflicts with javascript libraries from happening, we can't avoid all
92
130
  of them. If you use this method, understand that there may be conflicts with javascript and css. You should use the
93
131
  route method if you see any issues.
94
132
 
95
- === Route Method
133
+ ### Route Method
96
134
 
97
135
  The other way to initialize Mercury, which provides some slight performance improvements to the script method, is to
98
136
  access the editor route. There's a glob route that captures everything beginning with /editor, so for instance to edit
@@ -104,30 +142,30 @@ trigger the initialize:frame event. You can do this when the dom is ready to be
104
142
  document.ready), or at the bottom of your body tag. It's recommended that you do this because it gives you some load
105
143
  performance improvements, but it's not required.
106
144
 
107
- top.Mercury.trigger('initialize:frame');
145
+ Mercury.trigger('initialize:frame');
108
146
 
109
147
 
110
- == Region Types
148
+ ## Region Types
111
149
 
112
- === Editable
150
+ ### Editable
113
151
 
114
152
  Editable Regions are HTML markup, and use the HTML5 contentEditable feature. This is the core of what Mercury is about,
115
153
  and provides the most flexibility and visual representation of what the content will look like when saved.
116
154
 
117
- === Markupable
155
+ ### Markupable
118
156
 
119
157
  These regions are based on Markdown syntax (specifically the github flavored version), and isn't as full featured as the
120
158
  editable region type -- primarily because markdown is meant to be simple, so to keep it such you can't do things like
121
159
  set colors etc. This region type is super useful if you want to keep the markup clean and simple.
122
160
 
123
- === Snippetable
161
+ ### Snippetable
124
162
 
125
163
  Snippetable regions only allow snippets. There isn't any content editing in these regions, but snippets can sometimes
126
164
  be the way to go with complex markup and functionality. Snippets are basically chunks of reusable markup, that can be
127
165
  defined by a developer and placed into content regions later. More on this below.
128
166
 
129
167
 
130
- == Snippets
168
+ ## Snippets
131
169
 
132
170
  Snippets are reusable and configurable chunks of markup. They can be defined by developers, and then placed anywhere in
133
171
  content regions. When you drag a snippet into a region you'll be prompted to enter options, and after entering options
@@ -137,52 +175,104 @@ edited or removed.
137
175
  Mercury does very little to save content and snippets for you, but it does provide the ability to load snippets from
138
176
  your own storage implementation. Here's an example of loading existing snippet options back into Mercury.
139
177
 
140
- top.Mercury.Snippet.load({
141
- 'snippet_1': {name: 'example', options: {'options[favorite_beer]': "Bells Hopslam", 'options[first_name]': "Jeremy"}},
142
- });
178
+ if (top.Mercury) top.Mercury.Snippet.load({
179
+ snippet_1: {name: 'example', options: {'options[favorite_beer]': "Bells Hopslam", 'options[first_name]': "Jeremy"}}
180
+ });
143
181
 
144
182
 
145
- == Project Details
183
+ ## Saving Content / Rendering Content
146
184
 
147
- === WYSIWYG Editors Suck
185
+ Note: Mercury doesn't implement saving or rendering of content. We leave this part up to you because it can vary in so
186
+ many different ways.. You may want to implement content versioning, use a nosql data store like mongo etc. and we don't
187
+ want to force our opinions.
188
+
189
+ Mercury will submit JSON or form values back to the server on save, and this can be adjusted in the configuration. By
190
+ default it will use JSON, that JSON looks like:
191
+
192
+ {
193
+ "region_name": {
194
+ "type": "editable",
195
+ "value": "[contents with a snippet]",
196
+ "snippets": {
197
+ "snippet_1": {
198
+ "name": "example",
199
+ "options": {
200
+ "options[favorite_beer]": "Bells Hopslam",
201
+ "options[first_name]": "Jeremy"
202
+ }
203
+ }
204
+ }
205
+ },
206
+ }
207
+
208
+ Where it gets saved to is also up to you.. by default it submits a post to the current url, but you can adjust this by
209
+ setting Mercury.saveURL, or passing it into the Mercury.PageEditor constructor.. how you do this is dependent on how
210
+ you're using loading mercury (via the loader, or by using the route method). In both situations setting Mercury.saveURL
211
+ is the most consistent.
212
+
213
+ top.Mercury.saveURL = '/contents';
214
+
215
+ Assuming you have a ContentsController and a RESTful route, this will make it through to the create action. Where you
216
+ can store the content in whatever way you think is appropriate for your project.
217
+
218
+ Rendering content is up to you as well.. Now that you have content saved, you can add that content back to your pages,
219
+ and there's a lot of ways you could approach this. In the past I've used Nokogiri to find and replace the contents of
220
+ regions, and do some additional handling for putting snippets back into the content. You could also use regular
221
+ expressions to do this, which is probably faster, but maybe not as safe.
222
+
223
+ I'm interested in what solutions people are looking for and end up using for this, so feel free to shoot me a line if
224
+ you write something (eg. a middleware layer, an nginx module, or just something simple to get the job done).
225
+
226
+
227
+ ## Project Details
228
+
229
+ ### WYSIWYG Editors Suck
148
230
 
149
231
  They just do. Which as I've learned, is primarily due to the browser implementations. Don't get me wrong, what the
150
232
  browsers have implemented is amazing, because it's hard stuff, plain and simple. But if you're expecting a WYSIWYG
151
233
  editor to solve all your content problems you're wrong. A better perception is that it will solve many of them, but
152
234
  shifts some into a new area.
153
235
 
154
- With that being said, Mercury tries to solve many of those issues and succeeds to a great degree, but alas, it's nearly
155
- impossible to address everything, and the browsers don't expose enough to fix some things. This is true for every
156
- editor that I've looked into as well.
236
+ With that being said, Mercury tries to solve many of those issues and succeeds to a great degree, but it seems to be
237
+ nearly impossible (impractical at least) to address everything, and the browsers don't expose enough to fix some things.
238
+ This is true for every editor that I've looked into as well, and will likely just take time as the browser vendors begin
239
+ to prioritize and fix these issues.
157
240
 
158
241
  It's important to understand this, and the details are more suited for long nerdy blog posts, so they won't be covered
159
242
  here.
160
243
 
161
- === The Code and Why
244
+ ### The Code and Why
162
245
 
163
- ==== CoffeeScript
246
+ #### CoffeeScript
164
247
 
165
248
  Mercury has been written entirely in CoffeeScript because it simplifies a lot of the patterns that are used, and allows
166
249
  for very readable code. The goal was to provide good readable code that could be adjusted based on need, instead of a
167
250
  complex configuration that makes the code harder to understand and tweak.
168
251
 
169
- ==== jQuery
252
+ #### jQuery
170
253
 
171
254
  jQuery was used as the javascript library, but is primarily used for the selectors, traversing, and manipulating the
172
255
  DOM. Chaining is kept to a minimum for readability, and even though much of Mercury could've been written as jQuery
173
256
  plugins, it was not.
174
257
 
175
- ==== Rails
258
+ #### Rails
176
259
 
177
260
  With the asset handling that comes bundled with Rails 3.1, Rails Engines, and the gem tools, there really wasn't any
178
261
  other option. The javascript from Mercury can be used by any back end system, and isn't limited to Rails. Many of the
179
- features do require a back end, and that stuff would have to be rewritten in whatever language you wanted support for.
262
+ features do require a back end, and those features would have to be written in whatever language you wanted support for.
180
263
  The coffeescript files can be found in the repo, and I would be fully supportive of anyone who wanted to add support for
181
- different back end frameworks or languages.
264
+ different back end frameworks or languages. There's a server specification in the wiki that will help as well.
182
265
 
183
- ==== Specs / Integration Tests
266
+ #### Specs / Integration Tests
184
267
 
185
268
  Mercury is fully tested using Jasmine (via Evergreen) and Cucumber. You can clone the project to run the full suite.
186
269
 
187
- rake spec:javascripts
188
- rake cucumber
270
+ rake spec:javascripts
271
+ rake cucumber
272
+
273
+
274
+ ## License
275
+
276
+ Licensed under the [MIT License](http://creativecommons.org/licenses/MIT/)
277
+
278
+ Copyright 2011 [Jeremy Jackson](https://github.com/jejacks0n)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html;charset=utf-8">
5
+ <title>Mercury Editor - Annotated Source - {{ title }}</title>
6
+ <link href="/mercury/assets/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css"/>
7
+ <script src="/mercury/assets/javascripts/application.js" type="text/javascript"></script>
8
+ <!--[if lt IE 7]>
9
+ <script type="text/javascript" src="/mercury/assets/javascripts/unitpngfix.js"></script>
10
+ <![endif]-->
11
+ </head>
12
+ <body>
13
+
14
+ <div id="background"></div>
15
+
16
+ <h1 id="logo"><a href="/mercury">Mercury Editor</a></h1>
17
+
18
+ <ul id="navigation">
19
+ <li><a href="/mercury">Home</a></li>
20
+ <li><a href="/mercury/downloads">Downloads</a></li>
21
+ <li><a href="/mercury/walkthrough">Walkthrough</a></li>
22
+ <li><a href="/mercury/documentation">Documentation</a></li>
23
+ <li class="active"><a href="/mercury/annotated_source">Annotated Source</a></li>
24
+ </ul>
25
+
26
+ <table cellspacing=0 cellpadding=0>
27
+ <thead>
28
+ <tr>
29
+ <th class=docs><h1>{{ title }}</h1></th>
30
+ <th class=code></th>
31
+ </tr>
32
+ </thead>
33
+ <tbody>
34
+ {{#sections}}
35
+ <tr id='section-{{ section_id }}'>
36
+ <td class=docs>
37
+ <div class="pilwrap">
38
+ <a class="pilcrow" href="#section-{{ section_id }}">&#182;</a>
39
+ </div>
40
+ {{{ docs }}}
41
+ </td>
42
+ <td class=code>
43
+ <div class='highlight'><pre>{{{ code }}}</pre></div>
44
+ </td>
45
+ </tr>
46
+ {{/sections}}
47
+ </table>
48
+
49
+ <div id="footer">
50
+ <hr>
51
+ Copyright 2011 Jeremy Jackson. All rights reserved.
52
+ </div>
53
+
54
+ </body>
55
+ </html>
56
+
57
+
@@ -2,19 +2,23 @@ class MercuryController < ActionController::Base
2
2
  protect_from_forgery
3
3
 
4
4
  def edit
5
- render text: '', layout: 'mercury'
5
+ render :text => '', :layout => 'mercury'
6
6
  end
7
7
 
8
8
  def resource
9
- render action: "/#{params[:type]}/#{params[:resource]}", layout: false
9
+ render :action => "/#{params[:type]}/#{params[:resource]}", :layout => false
10
10
  end
11
11
 
12
12
  def snippet_options
13
- render action: "/snippets/#{params[:name]}_options", layout: false
13
+ render :action => "/snippets/#{params[:name]}_options", :layout => false
14
14
  end
15
15
 
16
16
  def snippet_preview
17
- render action: "/snippets/#{params[:name]}", layout: false
17
+ render :action => "/snippets/#{params[:name]}", :layout => false
18
+ end
19
+
20
+ def post
21
+ render :json => params
18
22
  end
19
23
 
20
24
  end
data/app/models/image.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  class Image < ActiveRecord::Base
2
2
 
3
- has_attached_file :image, styles: { medium: "300x300>", thumb: "100x100>" }
3
+ has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" }
4
4
 
5
- delegate :url, to: :image
5
+ delegate :url, :to => :image
6
6
 
7
7
  def serializable_hash(options = nil)
8
8
  options ||= {}
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <%= csrf_meta_tags %>
5
+ <title>Mercury Editor</title>
6
+ <link href="/assets/mercury.css" media="screen" rel="stylesheet" type="text/css" />
7
+ <script src="/assets/mercury.js" type="text/javascript"></script>
8
+ </head>
9
+ <body>
10
+ <script type="text/javascript">
11
+ new Mercury.PageEditor()
12
+ </script>
13
+ </body>
14
+ </html>