nacelle 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22e80566ff4a1407bd07ac2519ceb84f45c354e7
4
- data.tar.gz: 129e8cbbdf6c777549d17c55ae0bb0141fbdd681
3
+ metadata.gz: c31812f7e6de7f7be944bb8601f3a9bceb0343a2
4
+ data.tar.gz: c2606339159163faee9c275a2c5dd74de1292672
5
5
  SHA512:
6
- metadata.gz: 4c59cebe992329fc4bb80659005da6867fe1a9241d68b44d8a2f08747edff8401562dec8f3518307222cfdeb0ae52d5faae03324998c83e9fc2f1a56914a5c53
7
- data.tar.gz: 6f85b7a28a057fce45eaae53dd818f0a09d252573b6cdfbb834b4cd004dd54f8ac5e760c059414c94f9c3a20538b6eff28a5cd802a7b85377c5aba38f5998fbe
6
+ metadata.gz: af7d8964d04d74242f7e6687b8a5a55d9bc16b1ebb6b1f42f9f07b12b7595ad25250b3a7abdef6e8900c5b18463bbf82f5a76e3c5527cd5df017c9b4b9b4585c
7
+ data.tar.gz: 38a819ab94884465e6ab9e561942a10eec0473ce5fc2bddab0fea8b107cb9f2f0b6eee598535bc965c10642f740c8f6e5c48cedc1676fb2c663754208cb5a0da
data/README.md CHANGED
@@ -1,8 +1,13 @@
1
1
  # Nacelle
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/nacelle`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Rails engine for inserting magic blocks into CMS content via cells.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
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
- And then execute:
20
+ # Optional CKEditor integration
16
21
 
17
- $ bundle
22
+ Cells you want to show up in the cell selection menu must inherit from Nacelle::Cell.
18
23
 
19
- Or install it yourself as:
24
+ ```javascript
25
+ // ckeditor/config.js
20
26
 
21
- $ gem install nacelle
27
+ //= require nacelle/ckeditor
28
+ ...
29
+ config.extraPlugins = 'cells';
22
30
 
23
- ## Usage
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/[my-github-username]/nacelle/fork )
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
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
@@ -0,0 +1,2 @@
1
+ //= require ./cells/plugin
2
+ //= require ./cells/dialogs/cells
@@ -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
+
@@ -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
@@ -0,0 +1,9 @@
1
+ require "nacelle/cells_serializer"
2
+
3
+ module Nacelle
4
+ class CellsController < ApplicationController
5
+ def index
6
+ render json: CellsSerializer.new
7
+ end
8
+ end
9
+ end
data/config/routes.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  Rails.application.routes.draw do
2
- namespace :admin do
3
- get "cells" => "cells#index"
2
+ namespace :nacelle do
3
+ resources :cells, only: :index
4
4
  end
5
5
  end
6
6
 
data/lib/nacelle.rb CHANGED
@@ -1,8 +1,7 @@
1
- require "rails/all"
2
- require "cells"
3
1
  require "nacelle/version"
2
+ require "action_controller/railtie"
3
+ require "nacelle/cell"
4
4
  require "nacelle/middleware"
5
- require "nacelle/cells_ext"
6
5
 
7
6
  module Nacelle
8
7
  class Engine < ::Rails::Engine
@@ -0,0 +1,6 @@
1
+ require "cells"
2
+
3
+ module Nacelle
4
+ class Cell < Cell::Base
5
+ end
6
+ end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Nacelle
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.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: 2017-10-31 00:00:00.000000000 Z
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/controllers/admin/cells_controller.rb
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/cells_ext.rb
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
@@ -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