widgets 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/widgets_controller.rb +13 -1
- data/app/helpers/application_helper.rb~ +27 -0
- data/app/views/widgets/destroy.js.haml~ +2 -0
- data/app/views/widgets/remove.js.haml +2 -0
- data/app/views/widgets/replace.js.haml +3 -0
- data/app/views/widgets/show.html.haml +1 -0
- data/config/routes.rb +7 -2
- data/config/routes.rb~ +5 -0
- data/lib/widgets/version.rb +1 -1
- metadata +10 -6
- data/lib/widgets.rb~ +0 -10
- data/lib/widgets/version.rb~ +0 -3
@@ -1,9 +1,21 @@
|
|
1
1
|
class WidgetsController < ApplicationController
|
2
2
|
layout false
|
3
3
|
|
4
|
+
def remove
|
5
|
+
@id = params.delete(:id)
|
6
|
+
respond_to :js
|
7
|
+
end
|
8
|
+
|
9
|
+
def replace
|
10
|
+
@id = params.delete(:id)
|
11
|
+
@name = params.delete(:name)
|
12
|
+
@options = params.except(:controller, :action).to_hash.symbolize_keys!
|
13
|
+
|
14
|
+
respond_to :js
|
15
|
+
end
|
16
|
+
|
4
17
|
def show
|
5
18
|
@name = params.delete(:id)
|
6
|
-
@id = params.delete(:widget_id)
|
7
19
|
@options = params.except(:controller, :action).to_hash.symbolize_keys!
|
8
20
|
|
9
21
|
respond_to :html, :js
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'guid'
|
2
|
+
|
3
|
+
module ApplicationHelper
|
4
|
+
#include ActionView::Helpers::UrlHelper
|
5
|
+
|
6
|
+
def widget(name, options={}, &block)
|
7
|
+
id = Guid.new.to_s
|
8
|
+
partial = File.join 'widgets', name.to_s
|
9
|
+
attributes = {:id => id, :'data-widget' => name, :style => options.delete(:style), :class => options.delete(:effects)}
|
10
|
+
options = {widget_id: id, widget_name: name}.merge options
|
11
|
+
|
12
|
+
html = if block_given?
|
13
|
+
render :layout => partial, :inline => capture(&block), :locals => options, :formats => [:html]
|
14
|
+
else
|
15
|
+
render :template => partial, :locals => options, :formats => [:html]
|
16
|
+
end
|
17
|
+
|
18
|
+
javascript = render :template => partial, :locals => options, :formats => [:js] rescue ActionView::MissingTemplate
|
19
|
+
|
20
|
+
content = content_tag :div, html, attributes
|
21
|
+
if javascript
|
22
|
+
content += content_tag :script, javascript, :type => 'text/javascript'
|
23
|
+
end
|
24
|
+
|
25
|
+
content
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
= widget @name, @options
|
data/config/routes.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
|
3
|
-
|
2
|
+
resources :widgets, only: [] do
|
3
|
+
member do
|
4
|
+
get :remove
|
5
|
+
get :replace
|
6
|
+
get :show, constraints: {id: /.+/} # Widget names are path names and can have slashes in them.
|
7
|
+
end
|
8
|
+
end
|
4
9
|
end
|
data/config/routes.rb~
ADDED
data/lib/widgets/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: widgets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guid
|
@@ -114,7 +114,7 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.0.
|
117
|
+
version: 0.0.9
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
requirements:
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.0.
|
125
|
+
version: 0.0.9
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: sqlite3
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,12 +164,16 @@ extra_rdoc_files: []
|
|
164
164
|
files:
|
165
165
|
- app/controllers/widgets_controller.rb
|
166
166
|
- app/helpers/application_helper.rb
|
167
|
+
- app/helpers/application_helper.rb~
|
168
|
+
- app/views/widgets/destroy.js.haml~
|
169
|
+
- app/views/widgets/remove.js.haml
|
170
|
+
- app/views/widgets/replace.js.haml
|
171
|
+
- app/views/widgets/show.html.haml
|
167
172
|
- config/routes.rb
|
173
|
+
- config/routes.rb~
|
168
174
|
- lib/tasks/widgets_tasks.rake
|
169
175
|
- lib/widgets/version.rb
|
170
|
-
- lib/widgets/version.rb~
|
171
176
|
- lib/widgets.rb
|
172
|
-
- lib/widgets.rb~
|
173
177
|
- MIT-LICENSE
|
174
178
|
- Rakefile
|
175
179
|
- README.rdoc
|
data/lib/widgets.rb~
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
module Widgets
|
2
|
-
class Engine < Rails::Engine
|
3
|
-
engine_name :widgets
|
4
|
-
|
5
|
-
config.after_initialize do
|
6
|
-
require File.expand_path '../../app/controllers/widgets_controller', __FILE__
|
7
|
-
require File.expand_path '../../app/helpers/application_helper', __FILE__
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
data/lib/widgets/version.rb~
DELETED