webs 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/controller/webs_controller.rb +53 -1
- data/lib/helper/params.rb +12 -57
- data/lib/helper/tags.rb +12 -4
- data/lib/webs.rb +3 -1
- data/webs.gemspec +12 -4
- metadata +9 -9
data/Rakefile
CHANGED
@@ -25,10 +25,61 @@ module Webs
|
|
25
25
|
# http://wiki.developers.webs.com/wiki/Verifying_Requests
|
26
26
|
def webs_auth( secret )
|
27
27
|
s = webs_auth_string
|
28
|
-
Rails.logger.debug "****************** WEBS AUTH STRING=> #{s}"
|
29
28
|
Digest::MD5.hexdigest(webs_auth_string + secret)
|
30
29
|
end
|
31
30
|
|
31
|
+
# mappings to http://wiki.beta.freewebs.com/index.php/Fw:member-level-select
|
32
|
+
def webs_member_level_to_int member_level
|
33
|
+
{
|
34
|
+
'anyone'=>Webs::Permission::ANYONE,
|
35
|
+
'limited'=>Webs::Permission::LIMITED,
|
36
|
+
'member'=>Webs::Permission::MEMBERS,
|
37
|
+
'moderator'=>Webs::Permission::MODERATORS,
|
38
|
+
'admin'=>Webs::Permission::ADMIN
|
39
|
+
}[member_level.downcase]
|
40
|
+
end
|
41
|
+
|
42
|
+
# mappings of the select value of fw:member-level-select to the old int vals
|
43
|
+
# TODO: convert data to new vals, don't have time right now
|
44
|
+
def webs_member_level_value_to_old_member_level webs_member_level
|
45
|
+
{
|
46
|
+
'-255'=>Webs::Permission::ANYONE,
|
47
|
+
'25'=>Webs::Permission::LIMITED,
|
48
|
+
'50'=>Webs::Permission::MEMBERS,
|
49
|
+
'75'=>Webs::Permission::MODERATORS,
|
50
|
+
'100'=>Webs::Permission::ADMIN,
|
51
|
+
'125'=>Webs::Permission::OWNER,
|
52
|
+
'255'=>Webs::Permission::DISABLED
|
53
|
+
}[webs_member_level]
|
54
|
+
end
|
55
|
+
|
56
|
+
def webs_int_to_member_level n
|
57
|
+
{
|
58
|
+
Webs::Permission::DISABLED=>'disabled',
|
59
|
+
Webs::Permission::ANYONE=>'anyone',
|
60
|
+
Webs::Permission::LIMITED=>'limited',
|
61
|
+
Webs::Permission::MEMBERS=>'member',
|
62
|
+
Webs::Permission::MODERATORS=>'moderator',
|
63
|
+
Webs::Permission::ADMIN=>'admin',
|
64
|
+
Webs::Permission::OWNER=>'admin'
|
65
|
+
}[n]
|
66
|
+
end
|
67
|
+
|
68
|
+
# converts level which is an int for the select options of a fw:member-level-select
|
69
|
+
# first to an associated Webs::Permission then to a blog member level
|
70
|
+
# TODO: This should be cleaned up and blogs should use the fw:member-level-select values
|
71
|
+
# the mapping is useful if you need to change the result, generally sending returning admin if owner
|
72
|
+
# since most of the apps use owner not admin
|
73
|
+
# The generally needs to be done in params since some objects contain validations
|
74
|
+
# example:
|
75
|
+
# convert_webs_member_level( params[:entries], :view_level, {Webs::Permission::ADMIN=>Webs::Permission::OWNER} )
|
76
|
+
# will take a webs member-level-select and convert it to a Webs::Permission mapping ADMIN to OWNER
|
77
|
+
def convert_webs_member_level h, key, mapping={}
|
78
|
+
return if h.nil?
|
79
|
+
v = webs_member_level_value_to_old_member_level( h[key] )
|
80
|
+
h[key] = mapping[v] || v
|
81
|
+
end
|
82
|
+
|
32
83
|
# FILTERS
|
33
84
|
def validate_webs_session
|
34
85
|
render :text => "Access Denied: Webs::SECRET not defined." and return(false) unless defined?( Webs::SECRET )
|
@@ -42,6 +93,7 @@ module Webs
|
|
42
93
|
def require_webs_admin
|
43
94
|
render(:text => "You are not authorized.") unless webs_admin?
|
44
95
|
end
|
96
|
+
|
45
97
|
end
|
46
98
|
end
|
47
99
|
end
|
data/lib/helper/params.rb
CHANGED
@@ -1,62 +1,11 @@
|
|
1
1
|
module Webs
|
2
2
|
module Helper
|
3
3
|
module Params
|
4
|
-
|
5
|
-
|
6
|
-
|
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_user
|
49
|
-
params[:fw_sig_user]
|
50
|
-
end
|
51
|
-
|
52
|
-
def fw_sig_width
|
53
|
-
params[:fw_sig_width]
|
54
|
-
end
|
55
|
-
|
56
|
-
def fb_sig_network
|
57
|
-
params[:fb_sig_network]
|
4
|
+
[:fw_sig, :fw_sig_site, :fw_sig_is_admin, :fw_sig_permission_level, :fw_sig_session_key, :fw_sig_tier, :fw_sig_permissions, :fw_sig_time, :fw_sig_api_key,
|
5
|
+
:fw_sig_url, :fw_sig, :fw_sig_user, :fw_sig_width, :fw_sig_social, :fb_sig_network].each do |fw_param|
|
6
|
+
module_eval( "def #{fw_param.to_s}() params[:#{fw_param.to_s}] end" )
|
58
7
|
end
|
59
|
-
|
8
|
+
|
60
9
|
# Some basic useful methods
|
61
10
|
def webs_admin_mode?
|
62
11
|
fw_sig_is_admin == '1'
|
@@ -100,6 +49,10 @@ module Webs
|
|
100
49
|
fw_sig_permissions && webs_permission == Permission::ANYONE
|
101
50
|
end
|
102
51
|
|
52
|
+
def webs_social?
|
53
|
+
fw_sig_social == '1'
|
54
|
+
end
|
55
|
+
|
103
56
|
def webs_site_owner_or_admin?
|
104
57
|
webs_admin? || webs_owner?
|
105
58
|
end
|
@@ -112,8 +65,10 @@ module Webs
|
|
112
65
|
# defined in a global var, usually in the respective env file, however APP_NAME should be moved to something
|
113
66
|
# more elegant in the future.
|
114
67
|
def webs_app_url
|
115
|
-
|
116
|
-
|
68
|
+
app_name = APP_NAME if defined?(APP_NAME)
|
69
|
+
app_name ||= Webs::APP_NAME if defined?(Webs::APP_NAME)
|
70
|
+
raise "fw_app_url requires that the constant APP_NAME is defined.. for now..." if app_name.blank?
|
71
|
+
"#{fw_sig_url}apps/#{app_name}"
|
117
72
|
end
|
118
73
|
end
|
119
74
|
end
|
data/lib/helper/tags.rb
CHANGED
@@ -7,10 +7,18 @@ module Webs
|
|
7
7
|
return "<fw:#{tagname}#{s_options}/>" unless block
|
8
8
|
|
9
9
|
content = capture(&block)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
begin
|
11
|
+
# Rails 3
|
12
|
+
output = ActiveSupport::SafeBuffer.new
|
13
|
+
output.safe_concat("<fw:#{tagname}#{s_options}>")
|
14
|
+
output << content
|
15
|
+
output.safe_concat("</fw:#{tagname}>")
|
16
|
+
rescue
|
17
|
+
concat("<fw:#{tagname}#{s_options}>", block.binding)
|
18
|
+
concat( content, block.binding)
|
19
|
+
concat("</fw:#{tagname}>", block.binding)
|
20
|
+
|
21
|
+
end
|
14
22
|
end
|
15
23
|
|
16
24
|
def webs_image_url img
|
data/lib/webs.rb
CHANGED
@@ -5,9 +5,10 @@ require dir + 'helper/params'
|
|
5
5
|
require dir + 'helper/tags'
|
6
6
|
|
7
7
|
module Webs
|
8
|
-
VERSION = "0.1.
|
8
|
+
VERSION = "0.1.6".freeze
|
9
9
|
|
10
10
|
module Permission
|
11
|
+
DISABLED = -1
|
11
12
|
ANYONE = 0
|
12
13
|
LIMITED = 1
|
13
14
|
MEMBERS = 2
|
@@ -15,5 +16,6 @@ module Webs
|
|
15
16
|
OWNER = 4
|
16
17
|
ADMIN = 5
|
17
18
|
end
|
19
|
+
|
18
20
|
end
|
19
21
|
|
data/webs.gemspec
CHANGED
@@ -2,15 +2,23 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{webs}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.6"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Chuck Olczak"]
|
9
|
-
s.date = %q{2010-
|
9
|
+
s.date = %q{2010-11-04}
|
10
10
|
s.description = %q{Reusable webs stuff.}
|
11
11
|
s.email = %q{chuck@webs.com}
|
12
|
-
|
13
|
-
|
12
|
+
gemfiles = [
|
13
|
+
"README.rdoc",
|
14
|
+
"lib/webs.rb",
|
15
|
+
"lib/config/webs_initializer.rb",
|
16
|
+
"lib/controller/webs_controller.rb",
|
17
|
+
"lib/helper/params.rb",
|
18
|
+
"lib/helper/tags.rb",
|
19
|
+
]
|
20
|
+
s.extra_rdoc_files = gemfiles
|
21
|
+
s.files = gemfiles + [ "Rakefile", "webs.gemspec" ]
|
14
22
|
s.homepage = %q{http://github.com/websdotcom/websgem}
|
15
23
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Webs", "--main", "README.rdoc"]
|
16
24
|
s.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chuck Olczak
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-04 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -27,19 +27,19 @@ extensions: []
|
|
27
27
|
|
28
28
|
extra_rdoc_files:
|
29
29
|
- README.rdoc
|
30
|
+
- lib/webs.rb
|
31
|
+
- lib/config/webs_initializer.rb
|
30
32
|
- lib/controller/webs_controller.rb
|
31
33
|
- lib/helper/params.rb
|
32
34
|
- lib/helper/tags.rb
|
33
|
-
- lib/webs.rb
|
34
|
-
- lib/config/webs_initializer.rb
|
35
35
|
files:
|
36
36
|
- README.rdoc
|
37
|
-
-
|
37
|
+
- lib/webs.rb
|
38
|
+
- lib/config/webs_initializer.rb
|
38
39
|
- lib/controller/webs_controller.rb
|
39
40
|
- lib/helper/params.rb
|
40
41
|
- lib/helper/tags.rb
|
41
|
-
-
|
42
|
-
- lib/config/webs_initializer.rb
|
42
|
+
- Rakefile
|
43
43
|
- webs.gemspec
|
44
44
|
has_rdoc: true
|
45
45
|
homepage: http://github.com/websdotcom/websgem
|