webs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,60 @@
1
+ == WebsGem
2
+
3
+ WebsGem is a holder of knowlege with unknown equal. It:
4
+
5
+ * Manages fw:params
6
+
7
+ Right now it's composed of 1 modules:
8
+
9
+ * Controller: Stuff for controllers
10
+ ** params: Stuff for fw params
11
+
12
+ == Installation
13
+
14
+ === Rails 3
15
+
16
+ To use WebsGem with your stuff, in gemfile:
17
+
18
+ gem "webs", :git => "git@github.com:websdev/websgem.git"
19
+
20
+ === Rails 2.3
21
+
22
+
23
+ == Params Helpers
24
+
25
+ * Add helper to a view form controller:
26
+ helper Webs::Controller::Params
27
+
28
+ * Include in controller or whatever:
29
+ include Webs::Controller::Params
30
+
31
+ * Basic convenience methods for all the fw params
32
+ Instead of "params[:fw_sig_session_key]" now you have fw_sig_session_key
33
+
34
+ * Cool helper methods:
35
+ fw_app_url : full url of the app
36
+ ex: http://mysite.webs.com/apps/videos
37
+
38
+
39
+ == TODO
40
+
41
+ Please refer to TODO file.
42
+
43
+ == Maintainers
44
+
45
+ * José Valim (http://github.com/josevalim)
46
+ * Carlos Antônio da Silva (http://github.com/carlosantoniodasilva)
47
+
48
+ == Contributors
49
+
50
+ We have a long list of valued contributors. Check them all at:
51
+
52
+ http://github.com/plataformatec/devise/contributors
53
+
54
+ == Bugs and Feedback
55
+
56
+ If you discover any bugs, please keep them to yourself.
57
+
58
+ == License
59
+
60
+ Webs License. Copyright 2010 Webs
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # Rakefile
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'echoe'
5
+
6
+ Echoe.new('webs', '0.1.0') do |p|
7
+ p.description = "Reusable webs stuff."
8
+ p.url = "https://colczak@github.com/websdev/websgem.git"
9
+ p.author = "Chuck Olczak"
10
+ p.email = "chuck@webs.com"
11
+ p.ignore_pattern = ["tmp/*", "script/*"]
12
+ p.development_dependencies = []
13
+ end
14
+
15
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,5 @@
1
+ module Webs
2
+ module Controller
3
+
4
+ end
5
+ end
@@ -0,0 +1,113 @@
1
+ module Webs
2
+ module Controller
3
+ module Params
4
+ def fw_sig
5
+ params[:fw_sig]
6
+ end
7
+
8
+ def fw_sig_site
9
+ params[:fw_sig_site]
10
+ end
11
+
12
+ def fw_sig_is_admin
13
+ params[:fw_sig_is_admin]
14
+ end
15
+
16
+ def fw_sig_permission_level
17
+ params[:fw_sig_permission_level]
18
+ end
19
+
20
+ def fw_sig_session_key
21
+ params[:fw_sig_session_key]
22
+ end
23
+
24
+ def fw_sig_tier
25
+ params[:fw_sig_tier]
26
+ end
27
+
28
+ def fw_sig_permissions
29
+ params[:fw_sig_permissions]
30
+ end
31
+
32
+ def fw_sig_time
33
+ params[:fw_sig_time]
34
+ end
35
+
36
+ def fw_sig_api_key
37
+ params[:fw_sig_api_key]
38
+ end
39
+
40
+ def fw_sig_url
41
+ params[:fw_sig_url]
42
+ end
43
+
44
+ def fw_sig
45
+ params[:fw_sig]
46
+ end
47
+
48
+ def fw_sig_width
49
+ params[:fw_sig_width]
50
+ end
51
+
52
+ def fb_sig_network
53
+ params[:fb_sig_network]
54
+ end
55
+
56
+ # Some basic useful methods
57
+ def webs_admin_mode?
58
+ fw_sig_is_admin == '1'
59
+ end
60
+
61
+ def webs_permission
62
+ case fw_sig_permissions
63
+ when /admin/i
64
+ ADMIN
65
+ when /owner/i
66
+ OWNER
67
+ when /moderator/i
68
+ MODERATORS
69
+ when /contributor/i
70
+ MEMBERS
71
+ when /limited/i
72
+ LIMITED
73
+ else
74
+ ANYONE
75
+ end
76
+ end
77
+
78
+ # does fw_sig_permissions contain at least perm
79
+ def webs_permission?( perm=ANYONE )
80
+ webs_permission >= perm
81
+ end
82
+
83
+ def webs_admin?
84
+ fw_sig_permissions && webs_permission == ADMIN
85
+ end
86
+
87
+ def webs_owner?
88
+ fw_sig_permissions && webs_permission == MODERATORS
89
+ end
90
+
91
+ def webs_contributor?
92
+ fw_sig_permissions && webs_permission == LIMITED
93
+ end
94
+
95
+ def webs_moderator?
96
+ fw_sig_permissions && webs_permission == ANYONE
97
+ end
98
+
99
+ def webs_site_owner_or_admin?
100
+ webs_admin? || webs_owner?
101
+ end
102
+
103
+
104
+ # The full url of the app. Since in APP_NAME can be different in different environments this is currently
105
+ # defined in a global var, usually in the respective env file, however APP_NAME should be moved to something
106
+ # more elegant in the future.
107
+ def webs_app_url
108
+ raise "fw_app_url requires that the constant APP_NAME is defined.. for now..." if !defined?(APP_NAME)
109
+ "#{fw_sig_url}apps/#{APP_NAME}"
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,21 @@
1
+ module Webs
2
+ module Controller
3
+ module Tags
4
+ def fwml tagname, options={}, &block
5
+ s_options = ' ' + options.each_key.collect{|k| "#{k.to_s}=\"#{options[k]}\"" }.join(' ') if options.size > 0
6
+
7
+ return "<fw:#{tagname}#{s_options}/>" unless block
8
+
9
+ content = capture(&block)
10
+ output = ActiveSupport::SafeBuffer.new
11
+ output.safe_concat("<fw:#{tagname}#{s_options}>")
12
+ output << content
13
+ output.safe_concat("</fw:#{tagname}>")
14
+ end
15
+
16
+ def webs_image_url img
17
+ "http://#{Webs::ASSET_HOST}/images/#{img}"
18
+ end
19
+ end
20
+ end
21
+ end
data/lib/webs.rb ADDED
@@ -0,0 +1,17 @@
1
+ dir = Pathname(__FILE__).dirname.expand_path
2
+
3
+ module Webs
4
+ VERSION = "0.1.0".freeze
5
+
6
+ ANYONE = 0
7
+ LIMITED = 1
8
+ MEMBERS = 2
9
+ MODERATORS = 3
10
+ OWNER = 4
11
+ ADMIN = 5
12
+
13
+
14
+ end
15
+
16
+ require dir + 'controller/params'
17
+ require dir + 'controller/tags'
data/webs.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{webs}
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Chuck Olczak"]
9
+ s.date = %q{2010-07-23}
10
+ s.description = %q{Reusable webs stuff.}
11
+ s.email = %q{chuck@webs.com}
12
+ s.extra_rdoc_files = ["README.rdoc", "lib/controller/controller.rb", "lib/controller/params.rb", "lib/controller/tags.rb", "lib/webs.rb"]
13
+ s.files = ["README.rdoc", "Rakefile", "lib/controller/controller.rb", "lib/controller/params.rb", "lib/controller/tags.rb", "lib/webs.rb", "webs.gemspec"]
14
+ s.homepage = %q{http://github.com/websdotcom/websgem}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Webs", "--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{webs}
18
+ s.rubygems_version = %q{1.3.7}
19
+ s.summary = %q{Reusable webs stuff.}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ else
27
+ end
28
+ else
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webs
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Chuck Olczak
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-23 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Reusable webs stuff.
23
+ email: chuck@webs.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.rdoc
30
+ - lib/controller/controller.rb
31
+ - lib/controller/params.rb
32
+ - lib/controller/tags.rb
33
+ - lib/webs.rb
34
+ files:
35
+ - README.rdoc
36
+ - Rakefile
37
+ - lib/controller/controller.rb
38
+ - lib/controller/params.rb
39
+ - lib/controller/tags.rb
40
+ - lib/webs.rb
41
+ - webs.gemspec
42
+ has_rdoc: true
43
+ homepage: http://github.com/websdotcom/websgem
44
+ licenses: []
45
+
46
+ post_install_message:
47
+ rdoc_options:
48
+ - --line-numbers
49
+ - --inline-source
50
+ - --title
51
+ - Webs
52
+ - --main
53
+ - README.rdoc
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 11
71
+ segments:
72
+ - 1
73
+ - 2
74
+ version: "1.2"
75
+ requirements: []
76
+
77
+ rubyforge_project: webs
78
+ rubygems_version: 1.3.7
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Reusable webs stuff.
82
+ test_files: []
83
+