ordinary_cms 0.0.1 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c81e01a5f85d2dc8c54bcc4da7ae209ef9a23288
4
- data.tar.gz: b955bdeac74f448b6242f2ce242ed962700d3585
3
+ metadata.gz: ce29f59c5459ab8098f81cd11b4319f6ecdd2943
4
+ data.tar.gz: ceed02fa468b550b64cb5c7469635f38e4fd8aff
5
5
  SHA512:
6
- metadata.gz: dc56c185582ff11c374fb68c882f5901560e84d964007efa344f51ae7726ec4ac20ed6f90860f810e7bd120eef7f5c9d435528a87b3dc3fad5b31cc2e30e47aa
7
- data.tar.gz: dd60cf4e7d902d719504ffe9e0f794cd0aa8a9ab78aecb41dcbf4d5cca20bd77ac907dbb9a085ccc6c7a50562e513a2c3459d1f05c46988aadde287af1358250
6
+ metadata.gz: 4bf730a0e35eda6a122378ff749f7f7be9fb1532bbec1b08b158279e7539654fd39851bc8c7de03c0599ca37d1b50a7dc324bffb3662d5271201ee2f9bffa3d3
7
+ data.tar.gz: 7df40e85119d1beaefd36b9be369e3c0b47d47eb3a8a9c4918e9fbd00ba91abe16887edf9ef30ff149533aa661c690e6effa83178f38a84f1faf0d025a582134
@@ -0,0 +1,44 @@
1
+ ActiveAdmin.register OrdinaryCms::Page do
2
+
3
+ permit_params :name, seo_attributes: [ :id, :title, :description, :keywords ],
4
+ sections_attributes: [:id, :name, :text, :_destroy]
5
+
6
+ member_action :set_as_root, method: :patch do
7
+ OrdinaryCms::Page.find(params[:id]).set_as_root!
8
+ redirect_to :back
9
+ end
10
+
11
+
12
+ index do
13
+ selectable_column
14
+ column :name
15
+ column do |page|
16
+ link_to t('edit_content'),
17
+ "/editor#{ordinary_cms.page_path(page)}"
18
+ end
19
+ column do |page|
20
+ link_to t(:set_as_root), set_as_root_admin_ordinary_cms_page_path(page), {method: :patch} unless page.root?
21
+ end
22
+ default_actions
23
+ end
24
+
25
+ form do |f|
26
+ f.inputs do
27
+ f.input :name
28
+ f.has_many :sections, allow_destroy: true do |section|
29
+ section.input :name
30
+ section.input :alias
31
+ section.input :content, as: :text
32
+ end
33
+ end
34
+
35
+ f.inputs name: 'Seo', for: [:seo, f.object.seo] do |s|
36
+ s.input :title
37
+ s.input :description
38
+ s.input :keywords
39
+ end
40
+
41
+ f.actions
42
+ end
43
+
44
+ end
@@ -0,0 +1,461 @@
1
+ /*!
2
+ * Mercury Editor is a CoffeeScript and jQuery based WYSIWYG editor. Documentation and other useful information can be
3
+ * found at https://github.com/jejacks0n/mercury
4
+ *
5
+ * Minimum jQuery requirements are 1.7
6
+ *= require_self
7
+ *= require jquery
8
+ * You can include the Rails jQuery ujs script here to get some nicer behaviors in modals, panels and lightviews when
9
+ * using :remote => true within the contents rendered in them.
10
+ * require jquery_ujs
11
+ *
12
+ * Add any requires for the support libraries that integrate nicely with Mercury Editor.
13
+ * require mercury/support/history
14
+ *
15
+ * Require Mercury Editor itself.
16
+ *= require mercury/mercury
17
+ *
18
+ * Require any localizations you wish to support
19
+ * Example: es.locale, or fr.locale -- regional dialects are in each language file so never en_US for instance.
20
+ * Make sure you enable the localization feature in the configuration.
21
+ * require mercury/locales/swedish_chef.locale
22
+ *
23
+ * Add all requires for plugins that extend or change the behavior of Mercury Editor.
24
+ * require mercury/plugins/save_as_xml/plugin.js
25
+ *
26
+ * Require any files you want to use that either extend, or change the default Mercury behavior.
27
+ * require mercury_overrides
28
+ */
29
+
30
+
31
+
32
+ window.Mercury = {
33
+
34
+ // # Mercury Configuration
35
+ config: {
36
+ // ## Toolbars
37
+ //
38
+ // This is where you can customize the toolbars by adding or removing buttons, or changing them and their
39
+ // behaviors. Any top level object put here will create a new toolbar. Buttons are simply nested inside the
40
+ // toolbars, along with button groups.
41
+ //
42
+ // Some toolbars are custom (the snippets toolbar for instance), and to denote that use _custom: true. You can then
43
+ // build the toolbar yourself with it's own behavior.
44
+ //
45
+ // Buttons can be grouped, and a button group is simply a way to wrap buttons for styling -- they can also handle
46
+ // enabling or disabling all the buttons within it by using a context. The table button group is a good example of
47
+ // this.
48
+ //
49
+ // It's important to note that each of the button names (keys), in each toolbar object must be unique, regardless of
50
+ // if it's in a button group, or nested, etc. This is because styling is applied to them by name, and because their
51
+ // name is used in the event that's fired when you click on them.
52
+ //
53
+ // Button format: `[label, description, {type: action, type: action, etc}]`
54
+ //
55
+ // ### The available button types are:
56
+ //
57
+ // - toggle: toggles on or off when clicked, otherwise behaves like a button
58
+ // - modal: opens a modal window, expects the action to be one of:
59
+ // 1. a string url
60
+ // 2. a function that returns a string url
61
+ // - lightview: opens a lightview window (like modal, but different UI), expects the action to be one of:
62
+ // 1. a string url
63
+ // 2. a function that returns a string url
64
+ // - panel: opens a panel dialog, expects the action to be one of:
65
+ // 1. a string url
66
+ // 2. a function that returns a string url
67
+ // - palette: opens a palette window, expects the action to be one of:
68
+ // 1. a string url
69
+ // 2. a function that returns a string url
70
+ // - select: opens a pulldown style window, expects the action to be one of:
71
+ // 1. a string url
72
+ // 2. a function that returns a string url
73
+ // - context: calls a callback function, expects the action to be:
74
+ // 1. a function that returns a boolean to highlight the button
75
+ // note: if a function isn't provided, the key will be passed to the contextHandler, in which case a default
76
+ // context will be used (for more info read the Contexts section below)
77
+ // - mode: toggle a given mode in the editor, expects the action to be:
78
+ // 1. a string, denoting the name of the mode
79
+ // note: it's assumed that when a specific mode is turned on, all other modes will be turned off, which happens
80
+ // automatically, thus putting the editor into a specific "state"
81
+ // - regions: allows buttons to be enabled/disabled based on what region type has focus, expects:
82
+ // 1. an array of region types (eg. ['full', 'markdown'])
83
+ // - preload: allows some dialog views to be loaded when the button is created instead of on first open, expects:
84
+ // 1. a boolean true / false
85
+ // note: this is only used by panels, selects, and palettes
86
+ //
87
+ // Separators are any "button" that's not an array, and are expected to be a string. You can use two different
88
+ // separator styles: line ('-'), and spacer (' ').
89
+ //
90
+ // ### Adding Contexts
91
+ //
92
+ // Contexts are used callback functions used for highlighting and disabling/enabling buttons and buttongroups. When
93
+ // the cursor enters an element within an html region for instance we want to disable or highlight buttons based on
94
+ // the properties of the given node. You can see examples of contexts in, and add your own to:
95
+ // `Mercury.Toolbar.Button.contexts` and `Mercury.Toolbar.ButtonGroup.contexts`
96
+ toolbars: {
97
+ primary: {
98
+ save: ['Save', 'Save this page'],
99
+ preview: ['Preview', 'Preview this page', { toggle: true, mode: true }],
100
+ sep1: ' ',
101
+ undoredo: {
102
+ undo: ['Undo', 'Undo your last action'],
103
+ redo: ['Redo', 'Redo your last action'],
104
+ sep: ' '
105
+ },
106
+ insertLink: ['Link', 'Insert Link', { modal: '/mercury/modals/link.html', regions: ['full', 'markdown'] }],
107
+ insertMedia: ['Media', 'Insert Media (images and videos)', { modal: '/mercury/modals/media.html', regions: ['full', 'markdown'] }],
108
+ insertTable: ['Table', 'Insert Table', { modal: '/mercury/modals/table.html', regions: ['full', 'markdown'] }],
109
+ insertCharacter: ['Character', 'Special Characters', { modal: '/mercury/modals/character.html', regions: ['full', 'markdown'] }],
110
+ snippetPanel: ['Snippet', 'Snippet Panel', { panel: '/mercury/panels/snippets.html' }],
111
+ sep2: ' ',
112
+ historyPanel: ['History', 'Page Version History', { panel: '/mercury/panels/history.html' }],
113
+ sep3: ' ',
114
+ notesPanel: ['Notes', 'Page Notes', { panel: '/mercury/panels/notes.html' }]
115
+ },
116
+
117
+ editable: {
118
+ _regions: ['full', 'markdown'],
119
+ predefined: {
120
+ style: ['Style', null, { select: '/mercury/selects/style.html', preload: true }],
121
+ sep1: ' ',
122
+ formatblock: ['Block Format', null, { select: '/mercury/selects/formatblock.html', preload: true }],
123
+ sep2: '-'
124
+ },
125
+ colors: {
126
+ backColor: ['Background Color', null, { palette: '/mercury/palettes/backcolor.html', context: true, preload: true, regions: ['full'] }],
127
+ sep1: ' ',
128
+ foreColor: ['Text Color', null, { palette: '/mercury/palettes/forecolor.html', context: true, preload: true, regions: ['full'] }],
129
+ sep2: '-'
130
+ },
131
+ decoration: {
132
+ bold: ['Bold', null, { context: true }],
133
+ italic: ['Italicize', null, { context: true }],
134
+ overline: ['Overline', null, { context: true, regions: ['full'] }],
135
+ strikethrough: ['Strikethrough', null, { context: true, regions: ['full'] }],
136
+ underline: ['Underline', null, { context: true, regions: ['full'] }],
137
+ sep: '-'
138
+ },
139
+ script: {
140
+ subscript: ['Subscript', null, { context: true }],
141
+ superscript: ['Superscript', null, { context: true }],
142
+ sep: '-'
143
+ },
144
+ justify: {
145
+ justifyLeft: ['Align Left', null, { context: true, regions: ['full'] }],
146
+ justifyCenter: ['Center', null, { context: true, regions: ['full'] }],
147
+ justifyRight: ['Align Right', null, { context: true, regions: ['full'] }],
148
+ justifyFull: ['Justify Full', null, { context: true, regions: ['full'] }],
149
+ sep: '-'
150
+ },
151
+ list: {
152
+ insertUnorderedList: ['Unordered List', null, { context: true }],
153
+ insertOrderedList: ['Numbered List', null, { context: true }],
154
+ sep: '-'
155
+ },
156
+ indent: {
157
+ outdent: ['Decrease Indentation'],
158
+ indent: ['Increase Indentation'],
159
+ sep: '-'
160
+ },
161
+ table: {
162
+ _context: true,
163
+ insertRowBefore: ['Insert Table Row', 'Insert a table row before the cursor', { regions: ['full'] }],
164
+ insertRowAfter: ['Insert Table Row', 'Insert a table row after the cursor', { regions: ['full'] }],
165
+ deleteRow: ['Delete Table Row', 'Delete this table row', { regions: ['full'] }],
166
+ insertColumnBefore: ['Insert Table Column', 'Insert a table column before the cursor', { regions: ['full'] }],
167
+ insertColumnAfter: ['Insert Table Column', 'Insert a table column after the cursor', { regions: ['full'] }],
168
+ deleteColumn: ['Delete Table Column', 'Delete this table column', { regions: ['full'] }],
169
+ sep1: ' ',
170
+ increaseColspan: ['Increase Cell Columns', 'Increase the cells colspan'],
171
+ decreaseColspan: ['Decrease Cell Columns', 'Decrease the cells colspan and add a new cell'],
172
+ increaseRowspan: ['Increase Cell Rows', 'Increase the cells rowspan'],
173
+ decreaseRowspan: ['Decrease Cell Rows', 'Decrease the cells rowspan and add a new cell'],
174
+ sep2: '-'
175
+ },
176
+ rules: {
177
+ horizontalRule: ['Horizontal Rule', 'Insert a horizontal rule'],
178
+ sep1: '-'
179
+ },
180
+ formatting: {
181
+ removeFormatting: ['Remove Formatting', 'Remove formatting for the selection', { regions: ['full'] }],
182
+ sep2: ' '
183
+ },
184
+ editors: {
185
+ htmlEditor: ['Edit HTML', 'Edit the HTML content', { regions: ['full'] }]
186
+ }
187
+ },
188
+
189
+ snippets: {
190
+ _custom: true,
191
+ actions: {
192
+ editSnippet: ['Edit Snippet Settings'],
193
+ sep1: ' ',
194
+ removeSnippet: ['Remove Snippet']
195
+ }
196
+ }
197
+ },
198
+
199
+
200
+ // ## Region Options
201
+ //
202
+ // You can customize some aspects of how regions are found, identified, and saved.
203
+ //
204
+ // attribute: Mercury identifies editable regions by a data-mercury attribute. This attribute has to be added in
205
+ // your HTML in advance, and is the only real code/naming exposed in the implementation of Mercury. To allow this
206
+ // to be as configurable as possible, you can set the name of this attribute. If you change this, you should adjust
207
+ // the injected styles as well.
208
+ //
209
+ // identifier: This is used as a unique identifier for any given region (and thus should be unique to the page).
210
+ // By default this is the id attribute but can be changed to a data attribute should you want to use something
211
+ // custom instead.
212
+ //
213
+ // dataAttributes: The dataAttributes is an array of data attributes that will be serialized and returned to the
214
+ // server upon saving. These attributes, when applied to a Mercury region element, will be automatically serialized
215
+ // and submitted with the AJAX request sent when a page is saved. These are expected to be HTML5 data attributes,
216
+ // and 'data-' will automatically be prepended to each item in this directive. (ex. ['scope', 'version'])
217
+ //
218
+ // determineType: This function is called after checking the data-type attribute for the correct field type. Use
219
+ // it if you want to dynamically set the type based on inspection of the region.
220
+ regions: {
221
+ attribute: 'data-mercury',
222
+ identifier: 'id',
223
+ dataAttributes: []
224
+ // determineType: function(region){},
225
+ },
226
+
227
+
228
+ // ## Snippet Options / Preview
229
+ //
230
+ // When a user drags a snippet onto the page they'll be prompted to enter options for the given snippet. The server
231
+ // is expected to respond with a form. Once the user submits this form, an Ajax request is sent to the server with
232
+ // the options provided; this preview request is expected to respond with the rendered markup for the snippet.
233
+ //
234
+ // method: The HTTP method used when submitting both the options and the preview. We use POST by default because a
235
+ // snippet options form may contain large text inputs and we don't want that to be truncated when sent to the
236
+ // server.
237
+ //
238
+ // optionsUrl: The url that the options form will be loaded from.
239
+ //
240
+ // previewUrl: The url that the options will be submitted to, and will return the rendered snippet markup.
241
+ //
242
+ // **Note:** `:name` will be replaced with the snippet name in the urls (eg. /mercury/snippets/example/options.html)
243
+ snippets: {
244
+ method: 'POST',
245
+ optionsUrl: '/mercury/snippets/:name/options.html',
246
+ previewUrl: '/mercury/snippets/:name/preview.html'
247
+ },
248
+
249
+
250
+ // ## Image Uploading
251
+ //
252
+ // If you drag images from your desktop into regions that support it, it will be uploaded to the server and inserted
253
+ // into the region. You can disable or enable this feature, the accepted mime-types, file size restrictions, and
254
+ // other things related to uploading.
255
+ //
256
+ // **Note:** Image uploading is only supported in some region types, and some browsers.
257
+ //
258
+ // enabled: You can set this to true, or false if you want to disable the feature entirely.
259
+ //
260
+ // allowedMimeTypes: You can restrict the types of files that can be uploaded by providing a list of allowed mime
261
+ // types.
262
+ //
263
+ // maxFileSize: You can restrict large files by setting the maxFileSize (in bytes).
264
+ //
265
+ // inputName: When uploading, a form is generated and submitted to the server via Ajax. If your server would prefer
266
+ // a different name for how the image comes through, you can change the inputName.
267
+ //
268
+ // url: The url that the image upload will be submitted to.
269
+ //
270
+ // handler: You can use false to let Mercury handle it for you, or you can provide a handler function that can
271
+ // modify the response from the server. This can be useful if your server doesn't respond the way Mercury expects.
272
+ // The handler function should take the response from the server and return an object that matches:
273
+ // `{image: {url: '[your provided url]'}`
274
+ uploading: {
275
+ enabled: true,
276
+ allowedMimeTypes: ['image/jpeg', 'image/gif', 'image/png'],
277
+ maxFileSize: 1235242880,
278
+ inputName: 'image[image]',
279
+ url: '/mercury/images',
280
+ handler: false
281
+ },
282
+
283
+
284
+ // ## Localization / I18n
285
+ //
286
+ // Include the .locale files you want to support when loading Mercury. The files are always named by the language,
287
+ // and not the regional dialect (eg. en.locale.js) because the regional dialects are nested within the primary
288
+ // locale files.
289
+ //
290
+ // The client locale will be used first, and if no proper locale file is found for their language then the fallback
291
+ // preferredLocale configuration will be used. If one isn't provided, and the client locale isn't included, the
292
+ // strings will remain untranslated.
293
+ //
294
+ // enabled: Set to false to disable, true to enable.
295
+ //
296
+ // preferredLocale: If a client doesn't support the locales you've included, this is used as a fallback.
297
+ localization: {
298
+ enabled: false,
299
+ preferredLocale: 'swedish_chef-BORK'
300
+ },
301
+
302
+
303
+ // ## Behaviors
304
+ //
305
+ // Behaviors are used to change the default behaviors of a given region type when a given button is clicked. For
306
+ // example, you may prefer to add HR tags using an HR wrapped within a div with a classname (for styling). You
307
+ // can add your own complex behaviors here and they'll be shared across all regions.
308
+ //
309
+ // If you want to add behaviors to specific region types, you can mix them into the actions property of any region
310
+ // type.
311
+ //
312
+ // Mercury.Regions.Full.actions.htmlEditor = function() {}
313
+ //
314
+ // You can see how the behavior matches up directly with the button names. It's also important to note that the
315
+ // callback functions are executed within the scope of the given region, so you have access to all it's methods.
316
+ behaviors: {
317
+ //foreColor: function(selection, options) { selection.wrap('<span style="color:' + options.value.toHex() + '">', true) },
318
+ htmlEditor: function() { Mercury.modal('/mercury/modals/htmleditor.html', { title: 'HTML Editor', fullHeight: true, handler: 'htmlEditor' }); }
319
+ },
320
+
321
+
322
+ // ## Global Behaviors
323
+ //
324
+ // Global behaviors are much like behaviors, but are more "global". Things like save, exit, etc. can be included
325
+ // here. They'll only be called once, and execute within the scope of whatever editor is instantiated (eg.
326
+ // PageEditor).
327
+ //
328
+ // An example of changing how saving works:
329
+ //
330
+ // save: function() {
331
+ // var data = top.JSON.stringify(this.serialize(), null, ' ');
332
+ // var content = '<textarea style="width:500px;height:200px" wrap="off">' + data + '</textarea>';
333
+ // Mercury.modal(null, {title: 'Saving', closeButton: true, content: content})
334
+ // }
335
+ //
336
+ // This is a nice way to add functionality, when the behaviors aren't region specific. These can be triggered by a
337
+ // button, or manually with `Mercury.trigger('action', {action: 'barrelRoll'})`
338
+ globalBehaviors: {
339
+ exit: function() { window.location.href = this.iframeSrc() },
340
+ barrelRoll: function() { $('body').css({webkitTransform: 'rotate(360deg)'}) }
341
+ },
342
+
343
+
344
+ // ## Ajax and CSRF Headers
345
+ //
346
+ // Some server frameworks require that you provide a specific header for Ajax requests. The values for these CSRF
347
+ // tokens are typically stored in the rendered DOM. By default, Mercury will look for the Rails specific meta tag,
348
+ // and provide the X-CSRF-Token header on Ajax requests, but you can modify this configuration if the system you're
349
+ // using doesn't follow the same standard.
350
+ csrfSelector: 'meta[name="csrf-token"]',
351
+ csrfHeader: 'X-CSRF-Token',
352
+
353
+
354
+ // ## Editor URLs
355
+ //
356
+ // When loading a given page, you may want to tweak this regex. It's to allow the url to differ from the page
357
+ // you're editing, and the url at which you access it.
358
+ editorUrlRegEx: /([http|https]:\/\/.[^\/]*)\/editor\/?(.*)/i,
359
+
360
+
361
+ // ## Hijacking Links & Forms
362
+ //
363
+ // Mercury will hijack links and forms that don't have a target set, or the target is set to _self and will set it
364
+ // to _parent. This is because the target must be set properly for Mercury to not get in the way of some
365
+ // functionality, like proper page loads on form submissions etc. Mercury doesn't do this to links or forms that
366
+ // are within editable regions because it doesn't want to impact the html that's saved. With that being explained,
367
+ // you can add classes to links or forms that you don't want this behavior added to. Let's say you have links that
368
+ // open a lightbox style window, and you don't want the targets of these to be set to _parent. You can add classes
369
+ // to this array, and they will be ignored when the hijacking is applied.
370
+ nonHijackableClasses: [],
371
+
372
+
373
+ // ## Pasting & Sanitizing
374
+ //
375
+ // When pasting content into Mercury it may sometimes contain HTML tags and attributes. This markup is used to
376
+ // style the content and makes the pasted content look (and behave) the same as the original content. This can be a
377
+ // desired feature or an annoyance, so you can enable various sanitizing methods to clean the content when it's
378
+ // pasted.
379
+ //
380
+ // sanitize: Can be any of the following:
381
+ // - false: no sanitizing is done, the content is pasted the exact same as it was copied by the user
382
+ // - 'whitelist': content is cleaned using the settings specified in the tag white list (described below)
383
+ // - 'text': all html is stripped before pasting, leaving only the raw text
384
+ //
385
+ // whitelist: The white list allows you to specify tags and attributes that are allowed when pasting content. Each
386
+ // item in this object should contain the allowed tag, and an array of attributes that are allowed on that tag. If
387
+ // the allowed attributes array is empty, all attributes will be removed. If a tag is not present in this list, it
388
+ // will be removed, but without removing any of the text or tags inside it.
389
+ //
390
+ // **Note:** Content is *always* sanitized if looks like it's from MS Word or similar editors regardless of this
391
+ // configuration.
392
+ pasting: {
393
+ sanitize: 'whitelist',
394
+ whitelist: {
395
+ h1: [],
396
+ h2: [],
397
+ h3: [],
398
+ h4: [],
399
+ h5: [],
400
+ h6: [],
401
+ table: [],
402
+ thead: [],
403
+ tbody: [],
404
+ tfoot: [],
405
+ tr: [],
406
+ th: ['colspan', 'rowspan'],
407
+ td: ['colspan', 'rowspan'],
408
+ div: ['class'],
409
+ span: ['class'],
410
+ ul: [],
411
+ ol: [],
412
+ li: [],
413
+ b: [],
414
+ strong: [],
415
+ i: [],
416
+ em: [],
417
+ u: [],
418
+ strike: [],
419
+ br: [],
420
+ p: [],
421
+ hr: [],
422
+ a: ['href', 'target', 'title', 'name'],
423
+ img: ['src', 'title', 'alt']
424
+ }
425
+ },
426
+
427
+
428
+ // ## Injected Styles
429
+ //
430
+ // Mercury tries to stay as much out of your code as possible, but because regions appear within your document we
431
+ // need to include a few styles to indicate regions, as well as the different states of them (eg. focused). These
432
+ // styles are injected into your document, and as simple as they might be, you may want to change them.
433
+ injectedStyles: '' +
434
+ '[data-mercury] { min-height: 10px; outline: 1px dotted #09F } ' +
435
+ '[data-mercury]:focus { outline: none; -webkit-box-shadow: 0 0 10px #09F, 0 0 1px #045; box-shadow: 0 0 10px #09F, 0 0 1px #045 }' +
436
+ '[data-mercury].focus { outline: none; -webkit-box-shadow: 0 0 10px #09F, 0 0 1px #045; box-shadow: 0 0 10px #09F, 0 0 1px #045 }' +
437
+ '[data-mercury]:after { content: "."; display: block; visibility: hidden; clear: both; height: 0; overflow: hidden; }' +
438
+ '[data-mercury] table { border: 1px dotted red; min-width: 6px; }' +
439
+ '[data-mercury] th { border: 1px dotted red; min-width: 6px; }' +
440
+ '[data-mercury] td { border: 1px dotted red; min-width: 6px; }' +
441
+ '[data-mercury] .mercury-textarea { border: 0; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; resize: none; }' +
442
+ '[data-mercury] .mercury-textarea:focus { outline: none; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; }'
443
+ },
444
+
445
+ // ## Silent Mode
446
+ //
447
+ // Turning silent mode on will disable asking about unsaved changes before leaving the page.
448
+ silent: false,
449
+
450
+ // ## Debug Mode
451
+ //
452
+ // Turning debug mode on will log events and other various things (using console.debug if available).
453
+ debug: false,
454
+
455
+ onload: function() {
456
+ Mercury.on('saved', function() {
457
+ window.location.href = window.location.href.replace(/\/editor\//i, '/');
458
+ });
459
+ }
460
+
461
+ };
@@ -0,0 +1,32 @@
1
+ require_dependency "ordinary_cms/application_controller"
2
+
3
+ module OrdinaryCms
4
+ class PagesController < ApplicationController
5
+ before_action :set_page, only: [:show, :update]
6
+ before_action ActiveAdmin.application.authentication_method, only: :update
7
+
8
+ def show
9
+ request.subdomain
10
+ end
11
+
12
+ def update
13
+ sections_keys = params[:content].keys - [:undefined]
14
+ sections_keys.each do |key|
15
+ section = @page.section(key)
16
+ section.update_attributes content: params[:content][key][:value] unless section.nil?
17
+ end
18
+ render text: ''
19
+ end
20
+
21
+ private
22
+ # Use callbacks to share common setup or constraints between actions.
23
+ def set_page
24
+ @page = Page.find(params[:id])
25
+ end
26
+
27
+ # Only allow a trusted parameter "white list" through.
28
+ def page_params
29
+ []
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,8 @@
1
+ module OrdinaryCms
2
+ class RootController < ApplicationController
3
+ def show
4
+ @page = Page.find_by root: true
5
+ render 'ordinary_cms/pages/show'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ module OrdinaryCms
2
+ module PagesHelper
3
+ end
4
+ end
@@ -0,0 +1,20 @@
1
+ module OrdinaryCms
2
+ class Page
3
+ include Mongoid::Document
4
+ include ActsAsPage
5
+
6
+ field :root, type: Boolean, default: false
7
+
8
+ embeds_many :sections, class_name: 'OrdinaryCms::Section'
9
+ accepts_nested_attributes_for :sections
10
+
11
+ def section(name)
12
+ sections.where(name: name).first
13
+ end
14
+
15
+ def set_as_root!
16
+ Page.where(root: true).update_all root: false
17
+ self.update_attributes! root: true
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,29 @@
1
+ module OrdinaryCms
2
+ class Section
3
+ include Mongoid::Document
4
+ include ActionView::Helpers::OutputSafetyHelper
5
+
6
+ field :name
7
+ field :alias
8
+ field :content
9
+
10
+ embedded_in :ordinary_cms_page
11
+
12
+ validates :name, uniqueness: true, presence: true
13
+
14
+ def self.[](key)
15
+ find_by name: key
16
+ end
17
+
18
+ def render(what=:content)
19
+ if what == :alias
20
+ ActionController::Base.helpers.content_tag(:span, 'data-mercury' => 'simple') {self.alias}
21
+ else
22
+ ActionController::Base.helpers.content_tag(
23
+ :div,
24
+ {class: 'section', id: self.name, 'data-mercury' => 'full'}) {raw self.content}
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,12 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p data-mercury="simple">
4
+ <strong>Name:</strong>
5
+ <%= @page.name %>
6
+ </p>
7
+ <strong>Text:</strong>
8
+ <p data-mercury="full">
9
+ <%= @page.text %>
10
+ </p>
11
+
12
+ <%= @page.section('first').render %>
@@ -0,0 +1,5 @@
1
+ require 'active_admin'
2
+ ActiveAdmin.application.tap do |config|
3
+ config.load_paths << "#{OrdinaryCms::Engine.root}/app/admin"
4
+ config.load_paths << File.expand_path('app/admin', Rails.root)
5
+ end
@@ -0,0 +1,19 @@
1
+ en:
2
+ edit_content: Edit content
3
+ set_as_root: Set as Root
4
+ mongoid: &mongoid
5
+ models:
6
+ ordinary_cms/page:
7
+ one: Page
8
+ other: Pages
9
+ ordinary_cms/section:
10
+ one: Section
11
+ other: Sections
12
+
13
+ attributes:
14
+ ordinary_cms/page:
15
+ name: Name
16
+ ordinary_cms/section:
17
+ name: Name
18
+ alias: Alias
19
+ content: Content
@@ -0,0 +1,24 @@
1
+ ru:
2
+ edit_content: Редактировать стариницу
3
+ set_as_root: Установить главной
4
+
5
+ mongoid: &mongoid
6
+ models:
7
+ ordinary_cms/page:
8
+ one: Страница
9
+ few: Страницы
10
+ many: Страниц
11
+ other: Страницы
12
+ ordinary_cms/section:
13
+ one: Раздел
14
+ few: Раздела
15
+ many: Разделов
16
+ other: Разделы
17
+
18
+ attributes:
19
+ ordinary_cms/page:
20
+ name: Имя
21
+ ordinary_cms/section:
22
+ name: Имя
23
+ alias: Псевдоним
24
+ content: Контент
data/config/routes.rb CHANGED
@@ -1,2 +1,6 @@
1
1
  OrdinaryCms::Engine.routes.draw do
2
+
3
+ resources :pages, only: [:show, :update]
4
+
5
+ root 'root#show'
2
6
  end
@@ -0,0 +1,22 @@
1
+ require 'rails/generators'
2
+
3
+ module OrdinaryCms
4
+ class InstallGenerator < Rails::Generators::Base
5
+ source_root OrdinaryCms::Engine.root
6
+ argument :name, type: :string, default: "AdminUser"
7
+
8
+ def generate_activeadmin
9
+ generate("active_admin:install", name) unless ARGV.include? "--skip-activeadmin"
10
+ end
11
+
12
+ def copy_mercury_config
13
+ copy_file 'app/assets/javascripts/mercury.js'
14
+ end
15
+
16
+ def add_routes
17
+ route %Q{mount Mercury::Engine => '/'}
18
+ route %Q{mount OrdinaryCms::Engine => '/'}
19
+ end
20
+
21
+ end
22
+ end
@@ -1,3 +1,7 @@
1
+ require 'acts_as_page'
2
+ require 'active_admin'
3
+ require 'active_admin-mongoid'
4
+
1
5
  module OrdinaryCms
2
6
  class Engine < ::Rails::Engine
3
7
  isolate_namespace OrdinaryCms
@@ -1,3 +1,3 @@
1
1
  module OrdinaryCms
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,29 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ordinary_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - max-konin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-14 00:00:00.000000000 Z
11
+ date: 2014-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.0.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: haml-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sass-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mongoid_acts_as_page
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mongoid
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 4.0.0.beta1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 4.0.0.beta1
27
83
  description: Description of OrdinaryCms.
28
84
  email:
29
85
  - maxim21214@gmail.com
@@ -34,12 +90,24 @@ files:
34
90
  - MIT-LICENSE
35
91
  - README.rdoc
36
92
  - Rakefile
93
+ - app/admin/ordinary_cms/page.rb
94
+ - app/assets/javascripts/mercury.js
37
95
  - app/assets/javascripts/ordinary_cms/application.js
38
96
  - app/assets/stylesheets/ordinary_cms/application.css
39
97
  - app/controllers/ordinary_cms/application_controller.rb
98
+ - app/controllers/ordinary_cms/pages_controller.rb
99
+ - app/controllers/ordinary_cms/root_controller.rb
40
100
  - app/helpers/ordinary_cms/application_helper.rb
101
+ - app/helpers/ordinary_cms/pages_helper.rb
102
+ - app/models/ordinary_cms/page.rb
103
+ - app/models/ordinary_cms/section.rb
41
104
  - app/views/layouts/ordinary_cms/application.html.erb
105
+ - app/views/ordinary_cms/pages/show.html.erb
106
+ - config/initializers/active_admin.rb
107
+ - config/locales/en.yml
108
+ - config/locales/ru.yml
42
109
  - config/routes.rb
110
+ - lib/generators/ordinary_cms/install/install_generator.rb
43
111
  - lib/ordinary_cms.rb
44
112
  - lib/ordinary_cms/engine.rb
45
113
  - lib/ordinary_cms/version.rb