sinatra_more 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@ Here is a small list of what sinatra_more might contain:
20
20
  * Lots of generic view helpers (tag, content_tag, ...)
21
21
  * Asset helpers (link_to, image_tag, javascript_include_tag, ...)
22
22
  * Form helpers and form builder support (form_tag, form_for, text_field, ...)
23
- * Plug and play components for Warden (authentication), ActiveRecord (datastore) and MongoMapper (datastore)
23
+ * Plug and play components for Warden (authentication)
24
24
 
25
25
  Keep in mind, the user will be able to pull in components as necessary and leave out any that are not required.
26
26
 
data/TODO CHANGED
@@ -1,3 +1,5 @@
1
- * Pull from sinatra-helpers to make erb work (and credit keldredd)
1
+ * I have got to add tests, basically create dummy sinatra applications and use Rack::Test
2
+ * Pull from sinatra-helpers and make erb templates work (and credit keldredd)
2
3
  - http://github.com/kelredd/sinatra-helpers/tree/master/lib/sinatra_helpers/erb/
3
- * Become total warden solution (basically just require warden installed, do everything else)
4
+ * Become total warden solution (basically just require warden gem installed, do everything else)
5
+ * Add support for plugin
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -3,6 +3,10 @@ Dir.glob(File.dirname(__FILE__) + '/warden_plugin/**/*.rb').each { |f| require
3
3
  module SinatraMore
4
4
  module WardenPlugin
5
5
  def self.registered(app)
6
+ app.use Warden::Manager do |manager|
7
+ manager.default_strategies :password
8
+ manager.failure_app = app
9
+ end
6
10
  app.helpers SinatraMore::WardenHelpers
7
11
 
8
12
  # TODO Improve serializing methods
@@ -24,12 +24,25 @@ module SinatraMore
24
24
  # If no block is given, returns true if the user is logged in
25
25
  def authenticated?(&block)
26
26
  if block_given?
27
+ return '' unless logged_in?
27
28
  authenticated_content = capture_haml(&block)
28
- logged_in? ? haml_concat(authenticated_content) : ''
29
+ haml_concat(authenticated_content)
29
30
  else
30
31
  return logged_in?
31
32
  end
32
33
  end
34
+
35
+ # If a block is given, only yields the content if the user is unregistered
36
+ # If no block is given, returns true if the user is not logged in
37
+ def unregistered?(&block)
38
+ if block_given?
39
+ return '' if logged_in?
40
+ unregistered_content = capture_haml(&block)
41
+ haml_concat(unregistered_content)
42
+ else
43
+ return !logged_in?
44
+ end
45
+ end
33
46
 
34
47
  # Forces a user to return to a fail path unless they are authorized
35
48
  # Used to require a user be authenticated before routing to an action
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra_more}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
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"]
12
- s.date = %q{2009-10-24}
12
+ s.date = %q{2009-10-25}
13
13
  s.description = %q{Expands sinatra with standard helpers and tools to allow for complex applications}
14
14
  s.email = %q{nesquena@gmail.com}
15
15
  s.extra_rdoc_files = [
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.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Esquenazi
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-24 00:00:00 -07:00
12
+ date: 2009-10-25 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency