sinatra_more 0.0.4 → 0.0.5
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.
- data/README.rdoc +2 -4
- data/VERSION +1 -1
- data/lib/sinatra_more.rb +3 -13
- data/lib/sinatra_more/markup_plugin.rb +12 -0
- data/lib/sinatra_more/{view_helpers → markup_plugin}/asset_tag_helpers.rb +0 -0
- data/lib/sinatra_more/{form_builder → markup_plugin/form_builder}/abstract_form_builder.rb +0 -0
- data/lib/sinatra_more/{form_builder → markup_plugin/form_builder}/standard_form_builder.rb +0 -0
- data/lib/sinatra_more/{view_helpers → markup_plugin}/form_helpers.rb +0 -0
- data/lib/sinatra_more/{view_helpers → markup_plugin}/format_helpers.rb +0 -0
- data/lib/sinatra_more/{view_helpers → markup_plugin}/render_helpers.rb +0 -0
- data/lib/sinatra_more/{view_helpers → markup_plugin}/tag_helpers.rb +0 -0
- data/lib/sinatra_more/render_plugin.rb +9 -0
- data/lib/sinatra_more/warden_plugin.rb +24 -0
- data/lib/sinatra_more/{warden_helpers.rb → warden_plugin/warden_helpers.rb} +1 -22
- data/sinatra_more.gemspec +12 -10
- metadata +12 -10
- data/lib/sinatra_more/view_helpers.rb +0 -1
data/README.rdoc
CHANGED
@@ -37,11 +37,9 @@ different components based on which pieces are useful for your application.
|
|
37
37
|
require 'sinatra_more'
|
38
38
|
|
39
39
|
class Application < Sinatra::Base
|
40
|
-
register SinatraMore
|
40
|
+
register SinatraMore::MarkupPlugin
|
41
|
+
register SinatraMore::RenderPlugin
|
41
42
|
register SinatraMore::WardenPlugin
|
42
|
-
# (Not yet) register SinatraMore::MarkupHelpers
|
43
|
-
# (Not yet) register SinatraMore::RenderHelpers
|
44
|
-
# (Not yet) register SinatraMore::FormHelpers
|
45
43
|
end
|
46
44
|
|
47
45
|
This will then allow you to use whichever components that have been registered. A breakdown is below:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/sinatra_more.rb
CHANGED
@@ -1,15 +1,5 @@
|
|
1
1
|
require 'sinatra/base'
|
2
2
|
|
3
|
-
require File.join(File.dirname(__FILE__) + '/sinatra_more/
|
4
|
-
require File.join(File.dirname(__FILE__) + '/sinatra_more/
|
5
|
-
|
6
|
-
|
7
|
-
module SinatraMore
|
8
|
-
def self.registered(app)
|
9
|
-
app.helpers TagHelpers
|
10
|
-
app.helpers AssetTagHelpers
|
11
|
-
app.helpers FormHelpers
|
12
|
-
app.helpers FormatHelpers
|
13
|
-
app.helpers RenderHelpers
|
14
|
-
end
|
15
|
-
end
|
3
|
+
require File.join(File.dirname(__FILE__) + '/sinatra_more/markup_plugin')
|
4
|
+
require File.join(File.dirname(__FILE__) + '/sinatra_more/render_plugin')
|
5
|
+
require File.join(File.dirname(__FILE__) + '/sinatra_more/warden_plugin')
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Dir.glob(File.dirname(__FILE__) + '/markup_plugin/**/*.rb').each { |f| require f }
|
2
|
+
|
3
|
+
module SinatraMore
|
4
|
+
module MarkupPlugin
|
5
|
+
def self.registered(app)
|
6
|
+
app.helpers TagHelpers
|
7
|
+
app.helpers AssetTagHelpers
|
8
|
+
app.helpers FormHelpers
|
9
|
+
app.helpers FormatHelpers
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Dir.glob(File.dirname(__FILE__) + '/warden_plugin/**/*.rb').each { |f| require f }
|
2
|
+
|
3
|
+
module SinatraMore
|
4
|
+
module WardenPlugin
|
5
|
+
def self.registered(app)
|
6
|
+
app.helpers SinatraMore::WardenHelpers
|
7
|
+
|
8
|
+
# TODO Improve serializing methods
|
9
|
+
Warden::Manager.serialize_into_session{ |user| user.nil? ? nil : user.id }
|
10
|
+
Warden::Manager.serialize_from_session{ |id| id.nil? ? nil : User.find(id) }
|
11
|
+
|
12
|
+
Warden::Strategies.add(:password) do
|
13
|
+
def valid?
|
14
|
+
params['username'] || params['password']
|
15
|
+
end
|
16
|
+
|
17
|
+
def authenticate!
|
18
|
+
u = User.authenticate(params['username'], params['password'])
|
19
|
+
u.nil? ? fail!("Could not log in") : success!(u)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -42,25 +42,4 @@ module SinatraMore
|
|
42
42
|
request.env['warden']
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
46
|
-
module WardenPlugin
|
47
|
-
def self.registered(app)
|
48
|
-
app.helpers SinatraMore::WardenHelpers
|
49
|
-
|
50
|
-
# TODO Improve serializing
|
51
|
-
Warden::Manager.serialize_into_session{ |user| user.nil? ? nil : user.id }
|
52
|
-
Warden::Manager.serialize_from_session{ |id| id.nil? ? nil : User.find(id) }
|
53
|
-
|
54
|
-
Warden::Strategies.add(:password) do
|
55
|
-
def valid?
|
56
|
-
params['username'] || params['password']
|
57
|
-
end
|
58
|
-
|
59
|
-
def authenticate!
|
60
|
-
u = User.authenticate(params['username'], params['password'])
|
61
|
-
u.nil? ? fail!("Could not log in") : success!(u)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
45
|
+
end
|
data/sinatra_more.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sinatra_more}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nathan Esquenazi"]
|
@@ -25,15 +25,17 @@ Gem::Specification.new do |s|
|
|
25
25
|
"TODO",
|
26
26
|
"VERSION",
|
27
27
|
"lib/sinatra_more.rb",
|
28
|
-
"lib/sinatra_more/
|
29
|
-
"lib/sinatra_more/
|
30
|
-
"lib/sinatra_more/
|
31
|
-
"lib/sinatra_more/
|
32
|
-
"lib/sinatra_more/
|
33
|
-
"lib/sinatra_more/
|
34
|
-
"lib/sinatra_more/
|
35
|
-
"lib/sinatra_more/
|
36
|
-
"lib/sinatra_more/
|
28
|
+
"lib/sinatra_more/markup_plugin.rb",
|
29
|
+
"lib/sinatra_more/markup_plugin/asset_tag_helpers.rb",
|
30
|
+
"lib/sinatra_more/markup_plugin/form_builder/abstract_form_builder.rb",
|
31
|
+
"lib/sinatra_more/markup_plugin/form_builder/standard_form_builder.rb",
|
32
|
+
"lib/sinatra_more/markup_plugin/form_helpers.rb",
|
33
|
+
"lib/sinatra_more/markup_plugin/format_helpers.rb",
|
34
|
+
"lib/sinatra_more/markup_plugin/render_helpers.rb",
|
35
|
+
"lib/sinatra_more/markup_plugin/tag_helpers.rb",
|
36
|
+
"lib/sinatra_more/render_plugin.rb",
|
37
|
+
"lib/sinatra_more/warden_plugin.rb",
|
38
|
+
"lib/sinatra_more/warden_plugin/warden_helpers.rb",
|
37
39
|
"sinatra_more.gemspec",
|
38
40
|
"test/helper.rb",
|
39
41
|
"test/test_sinatra_more.rb"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra_more
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Esquenazi
|
@@ -40,15 +40,17 @@ files:
|
|
40
40
|
- TODO
|
41
41
|
- VERSION
|
42
42
|
- lib/sinatra_more.rb
|
43
|
-
- lib/sinatra_more/
|
44
|
-
- lib/sinatra_more/
|
45
|
-
- lib/sinatra_more/
|
46
|
-
- lib/sinatra_more/
|
47
|
-
- lib/sinatra_more/
|
48
|
-
- lib/sinatra_more/
|
49
|
-
- lib/sinatra_more/
|
50
|
-
- lib/sinatra_more/
|
51
|
-
- lib/sinatra_more/
|
43
|
+
- lib/sinatra_more/markup_plugin.rb
|
44
|
+
- lib/sinatra_more/markup_plugin/asset_tag_helpers.rb
|
45
|
+
- lib/sinatra_more/markup_plugin/form_builder/abstract_form_builder.rb
|
46
|
+
- lib/sinatra_more/markup_plugin/form_builder/standard_form_builder.rb
|
47
|
+
- lib/sinatra_more/markup_plugin/form_helpers.rb
|
48
|
+
- lib/sinatra_more/markup_plugin/format_helpers.rb
|
49
|
+
- lib/sinatra_more/markup_plugin/render_helpers.rb
|
50
|
+
- lib/sinatra_more/markup_plugin/tag_helpers.rb
|
51
|
+
- lib/sinatra_more/render_plugin.rb
|
52
|
+
- lib/sinatra_more/warden_plugin.rb
|
53
|
+
- lib/sinatra_more/warden_plugin/warden_helpers.rb
|
52
54
|
- sinatra_more.gemspec
|
53
55
|
- test/helper.rb
|
54
56
|
- test/test_sinatra_more.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
Dir.glob(File.dirname(__FILE__) + '/view_helpers/*.rb').each { |f| require f }
|