conjoin 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/conjoin.rb +4 -0
- data/lib/conjoin/as.rb +38 -0
- data/lib/conjoin/assets.rb +2 -2
- data/lib/conjoin/auth.rb +1 -1
- data/lib/conjoin/cuba.rb +1 -1
- data/lib/conjoin/form_builder.rb +3 -3
- data/lib/conjoin/inputs/datetime.rb +11 -0
- data/lib/conjoin/inputs/display.rb +16 -0
- data/lib/conjoin/inputs/radio.rb +15 -15
- data/lib/conjoin/inputs/select.rb +28 -20
- data/lib/conjoin/inputs/state.rb +62 -60
- data/lib/conjoin/inputs/year.rb +18 -0
- data/lib/conjoin/jquery.rb +50 -0
- data/lib/conjoin/middleware.rb +5 -3
- data/lib/conjoin/nav.rb +63 -0
- data/lib/conjoin/ui.rb +25 -0
- data/lib/conjoin/version.rb +1 -1
- data/lib/conjoin/widgets.rb +31 -7
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37b3b3e0dea3d26b4c82214d197eb158e543c5da
|
4
|
+
data.tar.gz: 3b309564ec3d2a4cf8077d104f9cdeb8a39f1c79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 017d486d53c6159088e8d2facb64e9956519d9d81852688c4e20ea209d4debf43d884b1e5de2dd4407425eb3334041d2790559cc8767cfd5e21afd6f7a617f6b
|
7
|
+
data.tar.gz: fa8ddf1a40b6035986e16799695891208c6d2f09b1adaaafc1adb73ce8966cb6ae3211ab0aa6947f491c7771fac27d5fc33a925ba00866bb56552050007bb92e
|
data/lib/conjoin.rb
CHANGED
@@ -25,6 +25,10 @@ module Conjoin
|
|
25
25
|
autoload :I18N , "conjoin/i18n"
|
26
26
|
autoload :Widgets , "conjoin/widgets"
|
27
27
|
autoload :Csrf , "conjoin/csrf"
|
28
|
+
autoload :As , "conjoin/as"
|
29
|
+
autoload :Ui , "conjoin/ui"
|
30
|
+
autoload :JQuery , "conjoin/jquery"
|
31
|
+
autoload :Nav , "conjoin/nav"
|
28
32
|
# ActionMailer
|
29
33
|
# https://gist.github.com/acwright/1944639
|
30
34
|
# DelayedJob
|
data/lib/conjoin/as.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Conjoin
|
2
|
+
module As
|
3
|
+
# Public: Sugar to do some common response tasks
|
4
|
+
#
|
5
|
+
# http_code - Response status code (default: 200)
|
6
|
+
# extra_headers - Extra headers hash (default: {})
|
7
|
+
#
|
8
|
+
# Examples:
|
9
|
+
#
|
10
|
+
# on post, "users" do
|
11
|
+
# as 201 do
|
12
|
+
# "User successfully created!"
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
def as(http_code = 200, extra_headers = {}, &block)
|
16
|
+
res.status = http_code
|
17
|
+
res.headers.merge! extra_headers
|
18
|
+
yield if block
|
19
|
+
end
|
20
|
+
|
21
|
+
# Public: Sugar to do some common response tasks as_json
|
22
|
+
#
|
23
|
+
# http_code - Response status code (default: 200)
|
24
|
+
# extra_headers - Extra headers hash (default: {})
|
25
|
+
# Examples:
|
26
|
+
#
|
27
|
+
# on post, "users" do
|
28
|
+
# as_json 201 do
|
29
|
+
# "User successfully created!"
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
def as_json(http_code = 200, extra_headers = {}, &block)
|
33
|
+
require 'json'
|
34
|
+
extra_headers["Content-Type"] ||= "application/json"
|
35
|
+
as(http_code, extra_headers) { yield.to_json if block }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/conjoin/assets.rb
CHANGED
@@ -81,13 +81,13 @@ module Conjoin
|
|
81
81
|
Assets.app.settings[:assets]
|
82
82
|
end
|
83
83
|
|
84
|
-
def
|
84
|
+
def links_for type, opts = {}
|
85
85
|
method = :link
|
86
86
|
path = :href
|
87
87
|
extention = :css
|
88
88
|
|
89
89
|
options = {
|
90
|
-
'data-turbolinks-track' => true
|
90
|
+
'data-turbolinks-track' => 'true'
|
91
91
|
}
|
92
92
|
|
93
93
|
case type
|
data/lib/conjoin/auth.rb
CHANGED
data/lib/conjoin/cuba.rb
CHANGED
@@ -64,7 +64,7 @@ module Conjoin
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def partial template, locals = {}
|
67
|
-
partial_template = template.gsub(/([a-zA-Z_]+)$/, '_\1')
|
67
|
+
partial_template = template.to_s.gsub(/([a-zA-Z_]+)$/, '_\1')
|
68
68
|
render(template_path(partial_template), locals, settings[:render][:options])
|
69
69
|
end
|
70
70
|
end
|
data/lib/conjoin/form_builder.rb
CHANGED
@@ -3,9 +3,9 @@ require "rack/csrf"
|
|
3
3
|
module Conjoin
|
4
4
|
module FormBuilder
|
5
5
|
INPUTS = [
|
6
|
-
:boolean, :checkbox, :date, :decimal, :file, :hidden,
|
7
|
-
:integer, :password, :radio, :select, :state, :string,
|
8
|
-
:time
|
6
|
+
:boolean , :checkbox , :date , :decimal , :file , :hidden ,
|
7
|
+
:integer , :password , :radio , :select , :state , :string ,
|
8
|
+
:display , :datetime , :time , :year
|
9
9
|
]
|
10
10
|
|
11
11
|
def self.setup app
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Conjoin
|
2
|
+
module FormBuilder
|
3
|
+
class DisplayInput < Input
|
4
|
+
def display
|
5
|
+
options[:class].gsub!(/form-control/, '')
|
6
|
+
options[:class] += ' form-control-static'
|
7
|
+
|
8
|
+
mab do
|
9
|
+
p class: options[:class] do
|
10
|
+
text options[:value]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/conjoin/inputs/radio.rb
CHANGED
@@ -7,25 +7,25 @@ module Conjoin
|
|
7
7
|
|
8
8
|
radios = options[:radios] || [:yes, :no]
|
9
9
|
|
10
|
-
opts = options.dup
|
11
|
-
|
12
10
|
mab do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
radios.each_with_index do |name, i|
|
12
|
+
opts = options.dup
|
13
|
+
|
14
|
+
name = name.to_s
|
15
|
+
opts[:value] = name
|
16
|
+
opts[:id] = "#{options[:id]}_#{i}"
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
if (opts[:value] == 'no' and data.value == 'no') \
|
19
|
+
or (opts[:value] == 'yes' and data.value == 'yes') \
|
20
|
+
or (opts[:value] == data.value)
|
21
|
+
opts[:checked] = 'checked'
|
22
|
+
else
|
23
|
+
opts.delete :checked
|
24
|
+
end
|
26
25
|
|
26
|
+
label class: 'radio-inline' do
|
27
27
|
input opts
|
28
|
-
|
28
|
+
text! name.humanize
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -1,30 +1,31 @@
|
|
1
1
|
module Conjoin
|
2
2
|
module FormBuilder
|
3
3
|
class SelectInput < Input
|
4
|
-
@select_options = {}
|
5
|
-
|
6
4
|
def display
|
7
|
-
|
5
|
+
append_button = options.delete :append_button
|
6
|
+
|
7
|
+
content = mab do
|
8
8
|
# automatically add a prompt by default
|
9
|
-
options[:prompt] = true unless options.key? :prompt
|
10
|
-
options[:class] += '
|
9
|
+
options[:prompt] = 'true' unless options.key? :prompt
|
10
|
+
options[:class] += ' selectize'
|
11
11
|
selected_value = options.delete :value
|
12
12
|
|
13
13
|
select options do
|
14
|
+
opts = {
|
15
|
+
value: ''
|
16
|
+
}
|
17
|
+
|
14
18
|
if prompt = options.delete(:prompt)
|
15
|
-
opts = {
|
16
|
-
value: ''
|
17
|
-
}
|
18
19
|
opts['selected'] = 'selected' unless selected_value
|
19
20
|
option opts do
|
20
|
-
text prompt.to_s == 'true' ? 'Please Choose One.' : prompt
|
21
|
+
text! prompt.to_s == 'true' ? 'Please Choose One.' : prompt
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
25
|
if not options[:group]
|
25
|
-
select_options.each do |name, value|
|
26
|
+
select_options.invert.each do |name, value|
|
26
27
|
option render_opts(value, selected_value, opts) do
|
27
|
-
text name.titleize
|
28
|
+
text (name != name.upcase ? name.titleize : name)
|
28
29
|
end
|
29
30
|
end
|
30
31
|
else
|
@@ -40,6 +41,21 @@ module Conjoin
|
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
44
|
+
|
45
|
+
if not append_button
|
46
|
+
content
|
47
|
+
else
|
48
|
+
mab do
|
49
|
+
div class: 'input-group' do
|
50
|
+
text! content
|
51
|
+
div class: 'input-group-btn' do
|
52
|
+
button class: 'btn btn-primary', type: 'button', 'on-click-get' => append_button[:href] do
|
53
|
+
text append_button[:text]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
43
59
|
end
|
44
60
|
|
45
61
|
def render_opts value, selected_value, opts
|
@@ -49,19 +65,11 @@ module Conjoin
|
|
49
65
|
if selected_value.is_a? ActiveRecord::Associations::CollectionProxy
|
50
66
|
opts['selected'] = 'selected' if selected_value.map(&:id).include? value
|
51
67
|
else
|
52
|
-
opts['selected'] = 'selected' if selected_value == value.to_s
|
68
|
+
opts['selected'] = 'selected' if selected_value.to_s == value.to_s
|
53
69
|
end
|
54
70
|
|
55
71
|
opts
|
56
72
|
end
|
57
|
-
|
58
|
-
def self.select_options
|
59
|
-
@select_options
|
60
|
-
end
|
61
|
-
|
62
|
-
def select_options
|
63
|
-
self.class.select_options.invert
|
64
|
-
end
|
65
73
|
end
|
66
74
|
end
|
67
75
|
end
|
data/lib/conjoin/inputs/state.rb
CHANGED
@@ -3,66 +3,68 @@ require_relative 'select'
|
|
3
3
|
module Conjoin
|
4
4
|
module FormBuilder
|
5
5
|
class StateInput < SelectInput
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
6
|
+
def select_options
|
7
|
+
{
|
8
|
+
'AL' => 'Alabama',
|
9
|
+
'AK' => 'Alaska',
|
10
|
+
'AS' => 'America Samoa',
|
11
|
+
'AZ' => 'Arizona',
|
12
|
+
'AR' => 'Arkansas',
|
13
|
+
'CA' => 'California',
|
14
|
+
'CO' => 'Colorado',
|
15
|
+
'CT' => 'Connecticut',
|
16
|
+
'DE' => 'Delaware',
|
17
|
+
'DC' => 'District of Columbia',
|
18
|
+
'FM' => 'Micronesia',
|
19
|
+
'FL' => 'Florida',
|
20
|
+
'GA' => 'Georgia',
|
21
|
+
'GU' => 'Guam',
|
22
|
+
'HI' => 'Hawaii',
|
23
|
+
'ID' => 'Idaho',
|
24
|
+
'IL' => 'Illinois',
|
25
|
+
'IN' => 'Indiana',
|
26
|
+
'IA' => 'Iowa',
|
27
|
+
'KS' => 'Kansas',
|
28
|
+
'KY' => 'Kentucky',
|
29
|
+
'LA' => 'Louisiana',
|
30
|
+
'ME' => 'Maine',
|
31
|
+
'MH' => 'Islands',
|
32
|
+
'MD' => 'Maryland',
|
33
|
+
'MA' => 'Massachusetts',
|
34
|
+
'MI' => 'Michigan',
|
35
|
+
'MN' => 'Minnesota',
|
36
|
+
'MS' => 'Mississippi',
|
37
|
+
'MO' => 'Missouri',
|
38
|
+
'MT' => 'Montana',
|
39
|
+
'NE' => 'Nebraska',
|
40
|
+
'NV' => 'Nevada',
|
41
|
+
'NH' => 'New Hampshire',
|
42
|
+
'NJ' => 'New Jersey',
|
43
|
+
'NM' => 'New Mexico',
|
44
|
+
'NY' => 'New York',
|
45
|
+
'NC' => 'North Carolina',
|
46
|
+
'ND' => 'North Dakota',
|
47
|
+
'OH' => 'Ohio',
|
48
|
+
'OK' => 'Oklahoma',
|
49
|
+
'OR' => 'Oregon',
|
50
|
+
'PW' => 'Palau',
|
51
|
+
'PA' => 'Pennsylvania',
|
52
|
+
'PR' => 'Puerto Rico',
|
53
|
+
'RI' => 'Rhode Island',
|
54
|
+
'SC' => 'South Carolina',
|
55
|
+
'SD' => 'South Dakota',
|
56
|
+
'TN' => 'Tennessee',
|
57
|
+
'TX' => 'Texas',
|
58
|
+
'UT' => 'Utah',
|
59
|
+
'VT' => 'Vermont',
|
60
|
+
'VI' => 'Virgin Island',
|
61
|
+
'VA' => 'Virginia',
|
62
|
+
'WA' => 'Washington',
|
63
|
+
'WV' => 'West Virginia',
|
64
|
+
'WI' => 'Wisconsin',
|
65
|
+
'WY' => 'Wyoming'
|
66
|
+
}
|
67
|
+
end
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'select'
|
2
|
+
|
3
|
+
module Conjoin
|
4
|
+
module FormBuilder
|
5
|
+
class YearInput < SelectInput
|
6
|
+
def select_options
|
7
|
+
years_select = {}
|
8
|
+
years = (1900..(Date.today.year+2)).to_a.reverse!
|
9
|
+
|
10
|
+
years.each do |year|
|
11
|
+
years_select[year] = year.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
years_select
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Conjoin
|
2
|
+
class JQuery
|
3
|
+
JS_ESCAPE = { '\\' => '\\\\', '</' => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'" }
|
4
|
+
|
5
|
+
attr_accessor :html, :selector, :options
|
6
|
+
|
7
|
+
def initialize selector, options = {}
|
8
|
+
@html = ''
|
9
|
+
@selector = selector
|
10
|
+
@options = options
|
11
|
+
|
12
|
+
@options.empty? \
|
13
|
+
? @html += "$('#{selector}')" \
|
14
|
+
: @html += "$('#{selector}', #{options.to_json})"
|
15
|
+
end
|
16
|
+
|
17
|
+
def method_missing(m, *args, &block)
|
18
|
+
elem = args.first
|
19
|
+
|
20
|
+
case elem
|
21
|
+
when JQuery
|
22
|
+
content = elem.to_s.chomp(';')
|
23
|
+
when String
|
24
|
+
content = "'#{escape elem}'"
|
25
|
+
when Hash, OpenStruct
|
26
|
+
content = elem.to_json
|
27
|
+
else
|
28
|
+
content = elem
|
29
|
+
end
|
30
|
+
|
31
|
+
@html += ".#{m.to_s.camelize(:lower)}(#{content})"
|
32
|
+
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
return_html = html.dup.to_s
|
38
|
+
@html = "$('#{selector}')"
|
39
|
+
"#{return_html};"
|
40
|
+
end
|
41
|
+
|
42
|
+
def escape js
|
43
|
+
Conjoin::JQuery.escape js
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.escape js
|
47
|
+
js.to_s.gsub(/(\\|<\/|\r\n|\\3342\\2200\\2250|[\n\r"'])/) {|match| JS_ESCAPE[match] }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/conjoin/middleware.rb
CHANGED
@@ -26,9 +26,11 @@ module Conjoin
|
|
26
26
|
if Conjoin.env.test? or Conjoin.env.development?
|
27
27
|
require 'better_errors'
|
28
28
|
use BetterErrors::Middleware
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
if ENV['PRY_RESCUE']
|
30
|
+
require 'pry'
|
31
|
+
require 'pry-rescue'
|
32
|
+
use PryRescue::Rack
|
33
|
+
end
|
32
34
|
end
|
33
35
|
|
34
36
|
# continue running the application
|
data/lib/conjoin/nav.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
module Conjoin
|
2
|
+
module Nav
|
3
|
+
def self.setup app
|
4
|
+
@settings = OpenStruct.new({
|
5
|
+
navs: OpenStruct.new,
|
6
|
+
icon_class: 'ico',
|
7
|
+
active_class: 'active open'
|
8
|
+
})
|
9
|
+
require "#{app.root}/config/nav.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.settings
|
13
|
+
@settings
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.config &block
|
17
|
+
Config.new(block, self).run
|
18
|
+
end
|
19
|
+
|
20
|
+
def nav name, &block
|
21
|
+
Config.new(block, self).load_nav name
|
22
|
+
end
|
23
|
+
|
24
|
+
class Config < Struct.new(:block, :app)
|
25
|
+
def run
|
26
|
+
self.instance_eval(&block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_menu name, links
|
30
|
+
config.navs[name] ||= []
|
31
|
+
config.navs[name].concat links
|
32
|
+
end
|
33
|
+
|
34
|
+
def load_nav name
|
35
|
+
if links = config.navs[name]
|
36
|
+
loaded_links = []
|
37
|
+
|
38
|
+
links.each do |link|
|
39
|
+
link = OpenStruct.new(link)
|
40
|
+
|
41
|
+
if !link.if or app.instance_exec(&link.if)
|
42
|
+
link.icon = config.icon_class + '-' + link.icon if link.icon
|
43
|
+
link.active = app.req.env['REQUEST_PATH'][link.path]
|
44
|
+
link.active_class = link.active ? config.active_class : false
|
45
|
+
|
46
|
+
if link.active_class or !link.hidden
|
47
|
+
loaded_links << link
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
else
|
52
|
+
raise "There isn't a nav called: #{name}"
|
53
|
+
end
|
54
|
+
|
55
|
+
block.call loaded_links
|
56
|
+
end
|
57
|
+
|
58
|
+
def config
|
59
|
+
Conjoin::Nav.settings
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/conjoin/ui.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Conjoin
|
2
|
+
module Ui
|
3
|
+
def panel options = {}, &block
|
4
|
+
helper = self
|
5
|
+
|
6
|
+
mab do
|
7
|
+
div class: 'panel panel-default', id: options[:id] do
|
8
|
+
if options.key? :header
|
9
|
+
div class: 'panel-heading' do
|
10
|
+
h3 class: 'panel-title' do
|
11
|
+
if options.key? :icon
|
12
|
+
fa_icon options[:icon]
|
13
|
+
end
|
14
|
+
text! options[:header]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
div class: "panel-body #{options.key?(:no_padding) ? 'no-padding' : ''}" do
|
19
|
+
text! helper.instance_exec(&block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/conjoin/version.rb
CHANGED
data/lib/conjoin/widgets.rb
CHANGED
@@ -74,7 +74,7 @@ module Conjoin
|
|
74
74
|
|
75
75
|
def url_for_event event, options = {}
|
76
76
|
widget_name = req.env[:widget_name]
|
77
|
-
"#{Conjoin.env.mounted?? settings[:mounted_url] : ''}/widgets?widget_event=#{event}&widget_name=#{widget_name}
|
77
|
+
"#{Conjoin.env.mounted?? settings[:mounted_url] : ''}/widgets?widget_event=#{event}&widget_name=#{widget_name}" + (options.any?? '&' + URI.encode_www_form(options) : '')
|
78
78
|
end
|
79
79
|
|
80
80
|
def load_widgets
|
@@ -184,7 +184,9 @@ module Conjoin
|
|
184
184
|
|
185
185
|
res.write '$("' + selector + '").replaceWith("' + escape(content) + '");'
|
186
186
|
# scroll to the top of the page just as if we went to the url directly
|
187
|
-
|
187
|
+
# if opts[:scroll_to_top]
|
188
|
+
# res.write 'window.scrollTo(0, 0);'
|
189
|
+
# end
|
188
190
|
end
|
189
191
|
|
190
192
|
def hide selector
|
@@ -209,6 +211,11 @@ module Conjoin
|
|
209
211
|
js.to_s.gsub(/(\\|<\/|\r\n|\\3342\\2200\\2250|[\n\r"'])/) {|match| JS_ESCAPE[match] }
|
210
212
|
end
|
211
213
|
|
214
|
+
def trigger event, data = {}
|
215
|
+
req.env[:widget_name] = req.params['widget_name']
|
216
|
+
trigger_event event, req.env[:widget_name], data.to_ostruct
|
217
|
+
end
|
218
|
+
|
212
219
|
def trigger_event event, widget_name, data = {}
|
213
220
|
if events = self.class.events
|
214
221
|
events.each do |class_event, opts|
|
@@ -233,6 +240,15 @@ module Conjoin
|
|
233
240
|
render state: widget_state
|
234
241
|
end
|
235
242
|
|
243
|
+
def partial view, options
|
244
|
+
render view, options
|
245
|
+
end
|
246
|
+
|
247
|
+
def partial template, locals = {}
|
248
|
+
locals[:partial] = template
|
249
|
+
render locals
|
250
|
+
end
|
251
|
+
|
236
252
|
def render *args
|
237
253
|
if args.first.kind_of? Hash
|
238
254
|
locals = args.first
|
@@ -252,20 +268,26 @@ module Conjoin
|
|
252
268
|
end
|
253
269
|
end
|
254
270
|
|
255
|
-
if locals.key?(:state) and state.to_s == view.to_s
|
256
|
-
|
271
|
+
if locals.key?(:state) and state and state.to_s == view.to_s
|
272
|
+
if method(state).parameters.length > 0
|
273
|
+
send(state, locals)
|
274
|
+
else
|
275
|
+
send(state)
|
276
|
+
end
|
257
277
|
end
|
258
278
|
|
259
279
|
tmpl_engine = settings[:render][:template_engine]
|
260
280
|
|
261
281
|
if (req_helper_methods = req.env[:widgets][folder][:req_helper_methods]) \
|
262
282
|
and (!options.key?(:cache))
|
263
|
-
locals.
|
283
|
+
locals.reverse_merge! req_helper_methods
|
264
284
|
else
|
265
285
|
req.env[:widgets][folder][:req_helper_methods] = {}
|
266
286
|
|
267
287
|
helper_methods.each do |method|
|
268
|
-
|
288
|
+
unless locals.key? method
|
289
|
+
req.env[:widgets][folder][:req_helper_methods][method] = locals[method] = self.send method
|
290
|
+
end
|
269
291
|
end
|
270
292
|
end
|
271
293
|
|
@@ -274,7 +296,8 @@ module Conjoin
|
|
274
296
|
|
275
297
|
locals[:w] = locals[:widget] = self
|
276
298
|
|
277
|
-
|
299
|
+
view_folder = self.class.to_s.gsub(/\w+::Widgets::/, '').split('::').map(&:underscore).join('/')
|
300
|
+
app.render "#{app.widgets_root}/#{view_folder}/#{view}.#{tmpl_engine}", locals
|
278
301
|
end
|
279
302
|
|
280
303
|
private
|
@@ -321,6 +344,7 @@ module Conjoin
|
|
321
344
|
App.plugin Conjoin::I18N
|
322
345
|
App.plugin Conjoin::FormBuilder
|
323
346
|
App.plugin Conjoin::Widgets
|
347
|
+
App.plugin Conjoin::Ui
|
324
348
|
|
325
349
|
App
|
326
350
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conjoin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cuba
|
@@ -319,6 +319,7 @@ files:
|
|
319
319
|
- conjoin.gemspec
|
320
320
|
- lib/conjoin.rb
|
321
321
|
- lib/conjoin/active_record.rb
|
322
|
+
- lib/conjoin/as.rb
|
322
323
|
- lib/conjoin/assets.rb
|
323
324
|
- lib/conjoin/auth.rb
|
324
325
|
- lib/conjoin/class_methods.rb
|
@@ -330,7 +331,9 @@ files:
|
|
330
331
|
- lib/conjoin/inputs/boolean.rb
|
331
332
|
- lib/conjoin/inputs/checkbox.rb
|
332
333
|
- lib/conjoin/inputs/date.rb
|
334
|
+
- lib/conjoin/inputs/datetime.rb
|
333
335
|
- lib/conjoin/inputs/decimal.rb
|
336
|
+
- lib/conjoin/inputs/display.rb
|
334
337
|
- lib/conjoin/inputs/file.rb
|
335
338
|
- lib/conjoin/inputs/hidden.rb
|
336
339
|
- lib/conjoin/inputs/integer.rb
|
@@ -340,12 +343,16 @@ files:
|
|
340
343
|
- lib/conjoin/inputs/state.rb
|
341
344
|
- lib/conjoin/inputs/string.rb
|
342
345
|
- lib/conjoin/inputs/time.rb
|
346
|
+
- lib/conjoin/inputs/year.rb
|
347
|
+
- lib/conjoin/jquery.rb
|
343
348
|
- lib/conjoin/middleware.rb
|
349
|
+
- lib/conjoin/nav.rb
|
344
350
|
- lib/conjoin/recursive_ostruct.rb
|
345
351
|
- lib/conjoin/seeds.rb
|
346
352
|
- lib/conjoin/tasks.rb
|
347
353
|
- lib/conjoin/tasks/migrate.rake
|
348
354
|
- lib/conjoin/tasks/migrate.rb
|
355
|
+
- lib/conjoin/ui.rb
|
349
356
|
- lib/conjoin/version.rb
|
350
357
|
- lib/conjoin/widgets.rb
|
351
358
|
homepage: ''
|