nacelle 0.1.0 → 0.2.0
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 +4 -4
- data/README.md +17 -10
- data/Rakefile +6 -0
- data/app/assets/javascripts/ckeditor/plugins/cells.js +2 -0
- data/app/assets/javascripts/ckeditor/plugins/cells/dialogs/cells.js.coffee +25 -0
- data/app/assets/javascripts/ckeditor/plugins/cells/icons/insertcell.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/cells/plugin.js.coffee +15 -0
- data/app/assets/javascripts/nacelle/ckeditor.js +1 -0
- data/app/controllers/nacelle/cells_controller.rb +9 -0
- data/config/routes.rb +2 -2
- data/lib/nacelle.rb +2 -3
- data/lib/nacelle/cell.rb +6 -0
- data/lib/nacelle/cells_serializer.rb +33 -0
- data/lib/nacelle/version.rb +1 -1
- metadata +10 -4
- data/app/controllers/admin/cells_controller.rb +0 -10
- data/lib/nacelle/cells_ext.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c31812f7e6de7f7be944bb8601f3a9bceb0343a2
|
4
|
+
data.tar.gz: c2606339159163faee9c275a2c5dd74de1292672
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af7d8964d04d74242f7e6687b8a5a55d9bc16b1ebb6b1f42f9f07b12b7595ad25250b3a7abdef6e8900c5b18463bbf82f5a76e3c5527cd5df017c9b4b9b4585c
|
7
|
+
data.tar.gz: 38a819ab94884465e6ab9e561942a10eec0473ce5fc2bddab0fea8b107cb9f2f0b6eee598535bc965c10642f740c8f6e5c48cedc1676fb2c663754208cb5a0da
|
data/README.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
# Nacelle
|
2
2
|
|
3
|
-
|
3
|
+
Rails engine for inserting magic blocks into CMS content via cells.
|
4
4
|
|
5
|
-
|
5
|
+
In your CMS content:
|
6
|
+
```html
|
7
|
+
<cell name="my_account/form" />
|
8
|
+
```
|
9
|
+
|
10
|
+
The Nacelle middleware will replace this with the result of MyAccountCell#form.
|
6
11
|
|
7
12
|
## Installation
|
8
13
|
|
@@ -12,17 +17,19 @@ Add this line to your application's Gemfile:
|
|
12
17
|
gem 'nacelle'
|
13
18
|
```
|
14
19
|
|
15
|
-
|
20
|
+
# Optional CKEditor integration
|
16
21
|
|
17
|
-
|
22
|
+
Cells you want to show up in the cell selection menu must inherit from Nacelle::Cell.
|
18
23
|
|
19
|
-
|
24
|
+
```javascript
|
25
|
+
// ckeditor/config.js
|
20
26
|
|
21
|
-
|
27
|
+
//= require nacelle/ckeditor
|
28
|
+
...
|
29
|
+
config.extraPlugins = 'cells';
|
22
30
|
|
23
|
-
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
31
|
+
// finally, add 'InsertCell' to your toolbar config
|
32
|
+
```
|
26
33
|
|
27
34
|
## Development
|
28
35
|
|
@@ -32,7 +39,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
39
|
|
33
40
|
## Contributing
|
34
41
|
|
35
|
-
1. Fork it ( https://github.com/
|
42
|
+
1. Fork it ( https://github.com/botandrose/nacelle/fork )
|
36
43
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
44
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
45
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
CKEDITOR.dialog.add "cellDialog", (editor) ->
|
2
|
+
title: "Insert Cell"
|
3
|
+
minWidth: 400
|
4
|
+
minHeight: 200
|
5
|
+
contents: [
|
6
|
+
id: "main"
|
7
|
+
elements: [
|
8
|
+
type: "select"
|
9
|
+
id: "cellName"
|
10
|
+
label: "Select Cell"
|
11
|
+
items: []
|
12
|
+
]
|
13
|
+
]
|
14
|
+
|
15
|
+
onShow: ->
|
16
|
+
$.getJSON "/nacelle/cells.json", (data) =>
|
17
|
+
select = @getContentElement("main", "cellName")
|
18
|
+
for item in data.cells
|
19
|
+
select.add item.name, item.id
|
20
|
+
|
21
|
+
onOk: ->
|
22
|
+
cell = editor.document.createElement("cell")
|
23
|
+
cell.setAttribute "name", @getValueOf("main", "cellName")
|
24
|
+
editor.insertElement cell
|
25
|
+
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
CKEDITOR.plugins.add "cells",
|
2
|
+
icons: "insertcell"
|
3
|
+
init: (editor) ->
|
4
|
+
editor.addCommand "insertCellDialog", new CKEDITOR.dialogCommand("cellDialog")
|
5
|
+
|
6
|
+
CKEDITOR.dialog.add "cellDialog", "#{@path}dialogs/cells.js"
|
7
|
+
|
8
|
+
editor.ui.addButton "InsertCell",
|
9
|
+
label: "Insert Cell"
|
10
|
+
command: "insertCellDialog"
|
11
|
+
|
12
|
+
CKEDITOR.dtd.$empty.cell = 1
|
13
|
+
CKEDITOR.dtd.$nonEditable.cell = 1
|
14
|
+
CKEDITOR.dtd.$object.cell = 1
|
15
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require ../ckeditor/plugins/cells.js
|
data/config/routes.rb
CHANGED
data/lib/nacelle.rb
CHANGED
data/lib/nacelle/cell.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
class Nacelle::CellsSerializer
|
2
|
+
def as_json(*)
|
3
|
+
{ cells: cell_classes.flat_map(&method(:serialize)) }
|
4
|
+
end
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def serialize klass
|
9
|
+
cell = klass.to_s.sub("Cell", "").underscore
|
10
|
+
cell_name = cell.humanize
|
11
|
+
|
12
|
+
klass.action_methods.map do |action|
|
13
|
+
action_name = action.to_s.humanize
|
14
|
+
{
|
15
|
+
id: "#{cell}/#{action}",
|
16
|
+
name: "#{cell_name} #{action_name}",
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def cell_classes
|
22
|
+
@all ||= begin
|
23
|
+
require_all_cells
|
24
|
+
Nacelle::Cell.subclasses
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def require_all_cells
|
29
|
+
# TODO pull in cells from engines, too
|
30
|
+
cell_files = Dir[::Rails.root.join('app/cells/*.rb')]
|
31
|
+
cell_files.each(&method(:require))
|
32
|
+
end
|
33
|
+
end
|
data/lib/nacelle/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nacelle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -125,12 +125,18 @@ files:
|
|
125
125
|
- LICENSE.txt
|
126
126
|
- README.md
|
127
127
|
- Rakefile
|
128
|
-
- app/
|
128
|
+
- app/assets/javascripts/ckeditor/plugins/cells.js
|
129
|
+
- app/assets/javascripts/ckeditor/plugins/cells/dialogs/cells.js.coffee
|
130
|
+
- app/assets/javascripts/ckeditor/plugins/cells/icons/insertcell.png
|
131
|
+
- app/assets/javascripts/ckeditor/plugins/cells/plugin.js.coffee
|
132
|
+
- app/assets/javascripts/nacelle/ckeditor.js
|
133
|
+
- app/controllers/nacelle/cells_controller.rb
|
129
134
|
- bin/console
|
130
135
|
- bin/setup
|
131
136
|
- config/routes.rb
|
132
137
|
- lib/nacelle.rb
|
133
|
-
- lib/nacelle/
|
138
|
+
- lib/nacelle/cell.rb
|
139
|
+
- lib/nacelle/cells_serializer.rb
|
134
140
|
- lib/nacelle/middleware.rb
|
135
141
|
- lib/nacelle/version.rb
|
136
142
|
- nacelle.gemspec
|
@@ -1,10 +0,0 @@
|
|
1
|
-
class Admin::CellsController < Admin::BaseController
|
2
|
-
def index
|
3
|
-
@cells = Cell.all
|
4
|
-
|
5
|
-
respond_to do |format|
|
6
|
-
format.xml { render :xml => @cells.to_xml(:root => 'cells', :skip_types => true) }
|
7
|
-
format.json { render :json => { cells: @cells.map(&:to_json).flatten } }
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
data/lib/nacelle/cells_ext.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
module Cell
|
2
|
-
class << self
|
3
|
-
def to_json
|
4
|
-
cell_name = self.to_s.sub("Cell", "").underscore
|
5
|
-
action_methods.map do |state|
|
6
|
-
{
|
7
|
-
id: "#{cell_name}/#{state.to_s}",
|
8
|
-
name: "#{cell_name.humanize} #{state.to_s.humanize}",
|
9
|
-
}
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def all
|
14
|
-
@all ||= begin
|
15
|
-
require_all_cells
|
16
|
-
BaseCell.subclasses
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def require_all_cells
|
23
|
-
# TODO pull in cells from engines, too
|
24
|
-
cell_files = Dir[::Rails.root.join('app/cells/*.rb')]
|
25
|
-
cell_files.each { |cell_file| require cell_file }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|