ledge 0.1.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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +32 -0
- data/app/assets/javascripts/ledge/index.coffee +138 -0
- data/app/assets/javascripts/ledge/rows/heading.coffee +20 -0
- data/app/assets/javascripts/ledge/rows/heading.rb +19 -0
- data/app/assets/javascripts/ledge/rows/row.coffee +9 -0
- data/app/assets/javascripts/ledge/rows/row.rb +9 -0
- data/app/assets/javascripts/ledge/rows/text.coffee +6 -0
- data/app/assets/javascripts/ledge/rows/text.rb +5 -0
- data/app/assets/stylesheets/ledge/index.scss +165 -0
- data/lib/ledge/column.rb +20 -0
- data/lib/ledge/columns.rb +21 -0
- data/lib/ledge/row.rb +25 -0
- data/lib/ledge/row_heading.rb +13 -0
- data/lib/ledge/uses_ledge.rb +50 -0
- data/lib/ledge/version.rb +3 -0
- data/lib/ledge.rb +6 -0
- data/lib/tasks/ledge_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +14 -0
- data/test/dummy/app/assets/javascripts/jquery-1.11.2.min.js +4 -0
- data/test/dummy/app/assets/javascripts/pages.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +16 -0
- data/test/dummy/app/assets/stylesheets/pages.css +4 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/pages_controller.rb +58 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/pages_helper.rb +2 -0
- data/test/dummy/app/models/page.rb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/pages/_form.html.erb +22 -0
- data/test/dummy/app/views/pages/edit.html.erb +6 -0
- data/test/dummy/app/views/pages/index.html.erb +27 -0
- data/test/dummy/app/views/pages/new.html.erb +5 -0
- data/test/dummy/app/views/pages/show.html.erb +8 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +78 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20150117205728_create_pages.rb +10 -0
- data/test/dummy/db/schema.rb +23 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +31988 -0
- data/test/dummy/log/test.log +5 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/controllers/pages_controller_test.rb +49 -0
- data/test/dummy/test/fixtures/pages.yml +9 -0
- data/test/dummy/test/helpers/pages_helper_test.rb +4 -0
- data/test/dummy/test/models/page_test.rb +7 -0
- data/test/dummy/tmp/cache/assets/development/sass/54bc5845a5f08ddefe5e6129fbfbcfb558803baa/index.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/098457da4db950157d6036137af33f0a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0f1e224003d74d132651ab92f55c07cd +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0f37e92e88f4c499c249b9cc41b4934b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1bb9d859b60e4d4d172d0add00b00c6e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1f178edd2e49aaded12690c902dbc08a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/23bd01f0b9d4c39189b2656987b34fc7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/250642107cf0f70ba78131e594a4f018 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2aa25ec184514bb7dd20b552e78db810 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/31002ec7f30dc508e631e1e5e7de35de +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/50dd5048cba4d140a7e7bc341b7f5fb8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/524593e2befad4fd9aa51cb8783cae20 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/58e369b37e5157ea746a485eea17e9f7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/634d5e38cd0bb46b9824d6bdef4033a8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6bf8868ce94dffa71bcb360c1ec27f12 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/748ad4e3b45037904c6542e308ebc4bd +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7ae10239eda2588a95fdcc7d871bef52 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7e8959ae4ffe0a173b25b1887e335126 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8d5d60255600aa010a32e1d1a9bc6db6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/98f11b8b54ab770bc4be1edf16cf659a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9ae6aabb17f9b9e45c62912f21f52883 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b3d9b0e88cdded276ebdce333e338a85 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b8c3c878749c531d3d75b1ae89675b53 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b9d0d3f5d1a22e97fe46db5da4c6a129 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c545cb75e6b46b9004b22dd12ec23abb +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d8a859e7c3478ca6cbfcfbf2ced98000 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/dd4918aca468e2fe7bf61814631a1758 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e17e7b5a8e469593820bdbb4bed3283e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e372415e69cccb3eda079f6be49ad225 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f6501694c4b72c124f167de3e87b8cee +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f72e72ebd1884d808afb460eaafa915f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/ledge_test.rb +7 -0
- data/test/test_helper.rb +16 -0
- metadata +328 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: be0aecb9d2290337c03bf425ae884b658502e971
|
4
|
+
data.tar.gz: 359ed51aa76479a9560cf13562673d507dcdbb49
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3d7054de79abf5916c979b0135866fc14f9c4690662b665f693f52acc331761ae3d7102f22a953f3fc8dd9e86cda6e968ae165a2d636b4ba487a4d73c7c09931
|
7
|
+
data.tar.gz: 6e656391bd4b58cf64b75b662d4c92b8af5e5ef59a2a3f5987037048422ff6d08522d9d9fa08b6334b4d69d0ad4b4507baa7dca901c21e816ea1feef0c94f5ec
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Ledge'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
|
24
|
+
Rake::TestTask.new(:test) do |t|
|
25
|
+
t.libs << 'lib'
|
26
|
+
t.libs << 'test'
|
27
|
+
t.pattern = 'test/**/*_test.rb'
|
28
|
+
t.verbose = false
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1,138 @@
|
|
1
|
+
#= require ./rows/row
|
2
|
+
#= require_tree ./rows
|
3
|
+
|
4
|
+
String.prototype.capitalize = ->
|
5
|
+
@charAt(0).toUpperCase() + @slice(1)
|
6
|
+
|
7
|
+
class Ledge
|
8
|
+
ROW_TYPES: [ Heading, Text ]
|
9
|
+
ROW_TYPE_PAIR: {}
|
10
|
+
ROW_ADD_HTML: ""
|
11
|
+
|
12
|
+
html_for: (type, content) ->
|
13
|
+
if type == "heading"
|
14
|
+
data = JSON.parse content
|
15
|
+
"<#{data["type"]}>#{data["text"]}</#{data["type"]}>"
|
16
|
+
else
|
17
|
+
content
|
18
|
+
|
19
|
+
object_for: (type, div) ->
|
20
|
+
if type == "heading"
|
21
|
+
type: type,
|
22
|
+
content: JSON.stringify
|
23
|
+
type: div.children().get(0).tagName.toLowerCase(),
|
24
|
+
text: $(div.children()[0]).text()
|
25
|
+
else
|
26
|
+
type: type,
|
27
|
+
content: div.html()
|
28
|
+
|
29
|
+
jsonify: (div) ->
|
30
|
+
json =
|
31
|
+
columns: []
|
32
|
+
div.children("div.__ledge_column").each (i) ->
|
33
|
+
json.columns.push {rows: []}
|
34
|
+
$(this).children("div.__ledge_row").each ->
|
35
|
+
json.columns[i].rows.push Ledge::object_for($(this).data("ledge-type"), $(this).children(".__ledge_row_content")) unless $(this).hasClass("__ledge_row_new")
|
36
|
+
JSON.stringify(json)
|
37
|
+
|
38
|
+
setup: ->
|
39
|
+
|
40
|
+
$("textarea#ledge").hide()
|
41
|
+
$("textarea#ledge").before("<div class='__ledge_edit'></div>")
|
42
|
+
|
43
|
+
data = JSON.parse($("textarea#ledge").text())
|
44
|
+
for column in data["columns"]
|
45
|
+
column_div = Ledge::create_column (col) ->
|
46
|
+
$("div.__ledge_edit").append(col)
|
47
|
+
Ledge::click_delete_column(column_div.find(".__ledge_delete"))
|
48
|
+
for row in column["rows"]
|
49
|
+
Ledge::create_row(row["type"], Ledge::html_for(row["type"], row["content"])).appendTo(column_div)
|
50
|
+
|
51
|
+
Ledge::refresh_row_adders()
|
52
|
+
Ledge::refresh_column_adders()
|
53
|
+
Ledge::update_textarea()
|
54
|
+
|
55
|
+
update_textarea: ->
|
56
|
+
$("textarea#ledge").text(Ledge::jsonify($("div.__ledge_edit")))
|
57
|
+
|
58
|
+
create_row: (type, content) ->
|
59
|
+
row = $("<div class='__ledge_row __ledge_row_#{type}' data-ledge-type='#{type}' contenteditable><div class='__ledge_options'></div><div class='__ledge_row_content'>#{content}</div></div>")
|
60
|
+
row.on "input", ->
|
61
|
+
Ledge::update_textarea()
|
62
|
+
if (Ledge::ROW_TYPE_PAIR[type] != undefined)
|
63
|
+
Ledge::add_options(Ledge::ROW_TYPE_PAIR[type], row.find(".__ledge_options"))
|
64
|
+
return row
|
65
|
+
|
66
|
+
create_column: (cb = ->) ->
|
67
|
+
column = $("<div class='__ledge_column'><div class='__ledge_options'><div class='__ledge_delete'>Delete</div></div><div class='__ledge_add'>+</div></div>")
|
68
|
+
cb(column)
|
69
|
+
Ledge::refresh_column_adders()
|
70
|
+
Ledge::refresh_row_adders()
|
71
|
+
Ledge::click_delete_column(column.find(".__ledge_delete"))
|
72
|
+
Ledge::update_textarea()
|
73
|
+
return column
|
74
|
+
|
75
|
+
refresh_column_adders: ->
|
76
|
+
$(".__ledge_add.__ledge_add_left").remove()
|
77
|
+
$(".__ledge_column").after("<div class='__ledge_add __ledge_add_left'><span>+</span></div>")
|
78
|
+
$(".__ledge_edit").prepend("<div class='__ledge_add __ledge_add_left'><span>+</span></div>")
|
79
|
+
$(".__ledge_add.__ledge_add_left").click ->
|
80
|
+
Ledge::create_column (col) =>
|
81
|
+
$(this).after(col)
|
82
|
+
|
83
|
+
refresh_row_adders: ->
|
84
|
+
$(".__ledge_column .__ledge_add").remove()
|
85
|
+
$(".__ledge_row").after("<div class='__ledge_add'>+</div>")
|
86
|
+
$(".__ledge_column").prepend("<div class='__ledge_add'>+</div>")
|
87
|
+
$(".__ledge_column .__ledge_add").click ->
|
88
|
+
row = Ledge::create_row "new", Ledge::ROW_ADD_HTML
|
89
|
+
row.attr("contenteditable", false)
|
90
|
+
$(this).after(row)
|
91
|
+
Ledge::refresh_row_adders()
|
92
|
+
row.find(".__ledge_add_item").click ->
|
93
|
+
type = $(this).attr("data-ledge-type")
|
94
|
+
index = $(this).attr("data-ledge-type-index")
|
95
|
+
Ledge::add_options(index, $(this).parent().parent().find(".__ledge_options"))
|
96
|
+
$(this).parent().parent()
|
97
|
+
.removeClass("__ledge_row_new")
|
98
|
+
.attr("contenteditable", true)
|
99
|
+
.addClass("__ledge_row_#{type}")
|
100
|
+
.attr("data-ledge-type", type)
|
101
|
+
.find(".__ledge_row_content")
|
102
|
+
.html(Ledge::ROW_TYPES[index]::initial_content)
|
103
|
+
Ledge::update_textarea()
|
104
|
+
click_delete_column: (del) ->
|
105
|
+
del.click ->
|
106
|
+
$(this).parent().parent().remove()
|
107
|
+
Ledge::update_textarea()
|
108
|
+
Ledge::refresh_column_adders()
|
109
|
+
|
110
|
+
click_delete_row: (del) ->
|
111
|
+
del.click ->
|
112
|
+
$(this).parent().parent().remove()
|
113
|
+
Ledge::update_textarea()
|
114
|
+
Ledge::refresh_row_adders()
|
115
|
+
|
116
|
+
add_options: (index, options) ->
|
117
|
+
options.html("");
|
118
|
+
for option in Ledge::ROW_TYPES[index]::options
|
119
|
+
$("<div>#{option}</div>")
|
120
|
+
.attr("data-ledge-option", option)
|
121
|
+
.attr("data-ledge-type-index", index)
|
122
|
+
.css("background-image", "url(#{Ledge::ROW_TYPES[index]::icons[option]})")
|
123
|
+
.click(->
|
124
|
+
cindex = $(this).attr("data-ledge-type-index")
|
125
|
+
Ledge::ROW_TYPES[index]::on_option($(this).parent().parent(), $(this).attr("data-ledge-option"))
|
126
|
+
).appendTo(options)
|
127
|
+
options.append("<div class='__ledge_delete'>Delete</div>")
|
128
|
+
Ledge::click_delete_row(options.find(".__ledge_delete"))
|
129
|
+
|
130
|
+
$(document).ready ->
|
131
|
+
for type, index in Ledge::ROW_TYPES
|
132
|
+
Ledge::ROW_ADD_HTML += "<div class='__ledge_add_item' data-ledge-type='#{type::type}' data-ledge-type-index='#{index}'>#{type::name}</div>"
|
133
|
+
Ledge::ROW_TYPE_PAIR[type::type] = index
|
134
|
+
Ledge::setup()
|
135
|
+
$(document).on 'page:load', ->
|
136
|
+
Ledge::setup()
|
137
|
+
|
138
|
+
window.Ledge = Ledge
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Heading extends Row
|
2
|
+
type: "heading"
|
3
|
+
name: "Heading"
|
4
|
+
initial_content: "<h1>Heading</h1>"
|
5
|
+
options: ["H1", "H2", "H3", "H4", "H5", "H6"]
|
6
|
+
icons:
|
7
|
+
"H1": "https://cdn1.iconfinder.com/data/icons/silk2/text_heading_1.png"
|
8
|
+
"H2": "https://cdn1.iconfinder.com/data/icons/silk2/text_heading_2.png"
|
9
|
+
"H3": "https://cdn1.iconfinder.com/data/icons/silk2/text_heading_3.png"
|
10
|
+
"H4": "https://cdn1.iconfinder.com/data/icons/silk2/text_heading_4.png"
|
11
|
+
"H5": "https://cdn1.iconfinder.com/data/icons/silk2/text_heading_5.png"
|
12
|
+
"H6": "https://cdn1.iconfinder.com/data/icons/silk2/text_heading_6.png"
|
13
|
+
|
14
|
+
on_option: (row, option) ->
|
15
|
+
text = $(row).find(".__ledge_row_content").children().text()
|
16
|
+
text = "Heading" if text == ""
|
17
|
+
$(row).find(".__ledge_row_content").html("<#{option}>#{text}</#{option}>")
|
18
|
+
Ledge::update_textarea()
|
19
|
+
|
20
|
+
window.Heading = Heading
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Heading < Row
|
2
|
+
@@type = "heading"
|
3
|
+
@@name = "Heading"
|
4
|
+
@@initial_content = "<h1>Heading</h1>"
|
5
|
+
@@options = ["H1", "H2", "H3", "H4", "H5", "H6"]
|
6
|
+
@@icons = {
|
7
|
+
h1: "https://cdn1.iconfinder.com/data/icons/silk2/text_heading_1.png",
|
8
|
+
h2: "https://cdn1.iconfinder.com/data/icons/silk2/text_heading_2.png",
|
9
|
+
h3: "https://cdn1.iconfinder.com/data/icons/silk2/text_heading_3.png",
|
10
|
+
h4: "https://cdn1.iconfinder.com/data/icons/silk2/text_heading_4.png",
|
11
|
+
h5: "https://cdn1.iconfinder.com/data/icons/silk2/text_heading_5.png",
|
12
|
+
h6: "https://cdn1.iconfinder.com/data/icons/silk2/text_heading_6.png"
|
13
|
+
}
|
14
|
+
|
15
|
+
def on_option row, option
|
16
|
+
text = jQuery(row).find("__ledge_row_content").children.text
|
17
|
+
jQuery(row).find("__ledge_row_content").html("<#{option}>#{text}</#{option}>")
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
.__ledge_edit {
|
2
|
+
display: table;
|
3
|
+
|
4
|
+
.__ledge_column{
|
5
|
+
position: relative;
|
6
|
+
min-width: 200px;
|
7
|
+
box-sizing: border-box;
|
8
|
+
display: table-cell;
|
9
|
+
border: 1px dashed gray;
|
10
|
+
padding: 10px;
|
11
|
+
border-radius: 5px;
|
12
|
+
}
|
13
|
+
|
14
|
+
.__ledge_row {
|
15
|
+
position: relative;
|
16
|
+
min-height: 36px;
|
17
|
+
line-height: 36px;
|
18
|
+
padding: 5px 10px;
|
19
|
+
border-radius: 5px;
|
20
|
+
transition: 0.15s all;
|
21
|
+
|
22
|
+
.__ledge_options {
|
23
|
+
visibility: hidden;
|
24
|
+
transition: 0.2s all;
|
25
|
+
opacity: 0;
|
26
|
+
}
|
27
|
+
|
28
|
+
&:hover {
|
29
|
+
background: #ECEFF1;
|
30
|
+
|
31
|
+
.__ledge_options {
|
32
|
+
visibility: visible;
|
33
|
+
opacity: 1;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
&.__ledge_row_new {
|
38
|
+
background: #ECEFF1;
|
39
|
+
margin: 10px 0;
|
40
|
+
text-align: center;
|
41
|
+
padding: 10px 20px;
|
42
|
+
|
43
|
+
// .__ledge_delete {
|
44
|
+
// border-top-left-radius: 0;
|
45
|
+
// border-bottom-right-radius: 0;
|
46
|
+
// }
|
47
|
+
|
48
|
+
.__ledge_row_content {
|
49
|
+
margin: auto;
|
50
|
+
display: inline-block;
|
51
|
+
|
52
|
+
.__ledge_add_item {
|
53
|
+
background-color: #607D8B;
|
54
|
+
color: white;
|
55
|
+
cursor: pointer;
|
56
|
+
margin: 0 5px;
|
57
|
+
display: inline-block;
|
58
|
+
line-height: 30px;
|
59
|
+
padding: 0 8px;
|
60
|
+
border-radius: 5px;
|
61
|
+
}
|
62
|
+
|
63
|
+
&:after {
|
64
|
+
content: "";
|
65
|
+
display: table;
|
66
|
+
clear: both;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
&:after {
|
71
|
+
content: "";
|
72
|
+
display: table;
|
73
|
+
clear: both;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
.__ledge_add {
|
79
|
+
text-align: center;
|
80
|
+
color: #444;
|
81
|
+
border-radius: 5px;
|
82
|
+
transition: 0.15s all;
|
83
|
+
padding: 10px 0;
|
84
|
+
font-size: 20pt;
|
85
|
+
height: 20px;
|
86
|
+
overflow: hidden;
|
87
|
+
cursor: pointer;
|
88
|
+
|
89
|
+
&.__ledge_add_left {
|
90
|
+
position: relative;
|
91
|
+
min-width: 30px;
|
92
|
+
text-align: center;
|
93
|
+
display: table-cell;
|
94
|
+
|
95
|
+
span {
|
96
|
+
position: absolute;
|
97
|
+
top: 0;
|
98
|
+
left: 0;
|
99
|
+
bottom: 50%;
|
100
|
+
top: 50%;
|
101
|
+
transform: translateY(-50%);
|
102
|
+
width: 30px;
|
103
|
+
text-align: center;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
&:hover {
|
108
|
+
background: rgba(0, 0, 0, .05);
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
.__ledge_options {
|
113
|
+
position: absolute;
|
114
|
+
top: 0;
|
115
|
+
right: 0;
|
116
|
+
background: rgba(255, 255, 255, .8);
|
117
|
+
border-bottom-left-radius: 5px;
|
118
|
+
border-top-right-radius: 5px;
|
119
|
+
|
120
|
+
> div {
|
121
|
+
transition: 0.15s all;
|
122
|
+
text-indent: -100000px;
|
123
|
+
width: 32px;
|
124
|
+
height: 32px;
|
125
|
+
background-position: center;
|
126
|
+
background-repeat: no-repeat;
|
127
|
+
cursor: pointer;
|
128
|
+
float:left;
|
129
|
+
|
130
|
+
&:hover {
|
131
|
+
background-color: rgba(255, 0, 0, .4);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
.__ledge_delete {
|
136
|
+
background-image: url(https://cdn2.iconfinder.com/data/icons/freecns-cumulus/16/519583-080_Trash-16.png);
|
137
|
+
}
|
138
|
+
|
139
|
+
.__ledge_settings {
|
140
|
+
background-image: url(https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/settings-16.png);
|
141
|
+
}
|
142
|
+
|
143
|
+
:last-child {
|
144
|
+
border-top-right-radius: 5px;
|
145
|
+
}
|
146
|
+
|
147
|
+
:first-child {
|
148
|
+
border-bottom-left-radius: 5px;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
.__ledge_content {
|
154
|
+
display: table;
|
155
|
+
.__ledge_column {
|
156
|
+
padding-right: 20px;
|
157
|
+
display: table-cell;
|
158
|
+
min-width: 200px;
|
159
|
+
box-sizing: border-box;
|
160
|
+
|
161
|
+
&:last-child {
|
162
|
+
padding-right: 0;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
}
|
data/lib/ledge/column.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "ledge/row"
|
2
|
+
|
3
|
+
module Ledge
|
4
|
+
class Column
|
5
|
+
def initialize data
|
6
|
+
@rows = []
|
7
|
+
data["rows"].each do |row|
|
8
|
+
@rows << Ledge::Row.row_from(row)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def render
|
13
|
+
r = ""
|
14
|
+
@rows.each do |row|
|
15
|
+
r << "<div class='__ledge_row'>#{row.render}</div>"
|
16
|
+
end
|
17
|
+
r
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "ledge/column"
|
2
|
+
|
3
|
+
module Ledge
|
4
|
+
class Columns
|
5
|
+
def initialize data
|
6
|
+
@columns = []
|
7
|
+
data["columns"].each do |column|
|
8
|
+
@columns << Ledge::Column.new(column)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def render
|
13
|
+
r = "<div class='__ledge_content'>"
|
14
|
+
@columns.each do |column|
|
15
|
+
r << "<div class='__ledge_column'>#{column.render}</div>"
|
16
|
+
end
|
17
|
+
r << "</div>"
|
18
|
+
r.html_safe
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/ledge/row.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "ledge/row_heading"
|
2
|
+
|
3
|
+
module Ledge
|
4
|
+
class Row
|
5
|
+
ROW_TYPES = {
|
6
|
+
"heading" => Ledge::RowHeading
|
7
|
+
}
|
8
|
+
|
9
|
+
def self.row_from data
|
10
|
+
unless ROW_TYPES[data["type"]].nil?
|
11
|
+
ROW_TYPES[data["type"]].new data["content"]
|
12
|
+
else
|
13
|
+
Ledge::Row.new data["content"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize content
|
18
|
+
@content = content
|
19
|
+
end
|
20
|
+
|
21
|
+
def render
|
22
|
+
@content
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "ledge/columns"
|
2
|
+
|
3
|
+
module Ledge
|
4
|
+
module UsesLedge
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def uses_ledge options = {}
|
12
|
+
cattr_accessor :field
|
13
|
+
self.field = (options[:field] || :content).to_s
|
14
|
+
|
15
|
+
include Ledge::UsesLedge::LocalInstanceMethods
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module LocalInstanceMethods
|
20
|
+
|
21
|
+
def method_missing method, *args, &block
|
22
|
+
if method.to_s == "#{self.field}_ledge"
|
23
|
+
content = JSON.parse read_attribute(self.class.field)
|
24
|
+
return Ledge::Columns.new content
|
25
|
+
else
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def respond_to? method
|
31
|
+
if method.to_s == "#{self.field}_ledge"
|
32
|
+
true
|
33
|
+
else
|
34
|
+
super
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def ledge_init
|
39
|
+
self.content ||= '{"columns": [{"rows":[]}]}'
|
40
|
+
end
|
41
|
+
|
42
|
+
def initialize hash = {}
|
43
|
+
super
|
44
|
+
ledge_init
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
ActiveRecord::Base.send :include, Ledge::UsesLedge
|
data/lib/ledge.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
14
|
+
//= require ledge
|