webs 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +15 -0
- data/lib/cache/cache.rb +42 -0
- data/lib/config/webs_constants.rb +67 -0
- data/lib/config/webs_initializer.rb +3 -1
- data/lib/controller/webs_controller.rb +67 -50
- data/lib/helper/application.rb +40 -0
- data/lib/helper/params.rb +39 -33
- data/lib/helper/tags.rb +44 -19
- data/lib/views/layouts/webs_page.html.erb +19 -0
- data/lib/views/layouts/webs_utility.html.erb +8 -0
- data/lib/views/shared/_webs_info.html.erb +38 -0
- data/lib/webs.rb +38 -9
- data/webs.gemspec +44 -0
- metadata +18 -4
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.10') 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 }
|
data/lib/cache/cache.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Webs
|
2
|
+
mattr_accessor :cache
|
3
|
+
module Cache
|
4
|
+
mattr_accessor :debug
|
5
|
+
|
6
|
+
def cache_remove(key)
|
7
|
+
Rails.logger.debug "*********** cache_remove(#{key})" if debug
|
8
|
+
return if key.nil?
|
9
|
+
Webs.cache.delete(key.to_s)
|
10
|
+
rescue Exception => e
|
11
|
+
Rails.logger.error "------------------------------------------------\nmemcache_error: #{e.message}"
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
def cache_block(key, options=nil, &block)
|
16
|
+
return if key.nil?
|
17
|
+
unless data = Webs.cache.read(key)
|
18
|
+
if self.respond_to?('capture')
|
19
|
+
data = capture(&block) # called from view
|
20
|
+
else
|
21
|
+
data = yield
|
22
|
+
end
|
23
|
+
s_data = Marshal.dump(data)
|
24
|
+
block_size = s_data.size
|
25
|
+
#TODO: Check to see if dalli cache & compressed then up the size to 3MB
|
26
|
+
# should get almost 10:1 compression ratio. This will be key for caching pages & fragments
|
27
|
+
if block_size < 1.megabyte
|
28
|
+
Rails.logger.debug "*********** cache_block[#{block_size}](#{key}, #{data} )" if debug
|
29
|
+
Webs.cache.write(key, data)
|
30
|
+
else
|
31
|
+
Rails.logger.debug "*********** block not cached since exceeds 3M @ #{block_size} )" if debug
|
32
|
+
end
|
33
|
+
else
|
34
|
+
Rails.logger.debug "****HIT**** cache_block(#{key}, #{data} )" if debug
|
35
|
+
end
|
36
|
+
data
|
37
|
+
rescue Exception => e
|
38
|
+
Rails.logger.error "------------------------------------------------\nmemcache_error: #{e.message}"
|
39
|
+
data
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Webs
|
2
|
+
module PermissionLevel
|
3
|
+
LEVEL = {
|
4
|
+
:anyone => { :name=>'Anyone', :value=>-255 },
|
5
|
+
:none => { :name=>'None', :value=>0 },
|
6
|
+
:requesting => { :name=>'Requesting Members', :value=>10 },
|
7
|
+
:limited => { :name=>'Limited Members', :value=>25 },
|
8
|
+
:member => { :name=>'Members', :value=>50 },
|
9
|
+
:moderator => { :name=>'Moderators', :value=>75 },
|
10
|
+
:admin => { :name=>'Administrators', :value=>100 },
|
11
|
+
:owner => { :name=>'Only Me (Site Owner)', :value=>125 },
|
12
|
+
:disabled => { :name=>'Disabled', :value=>255 }
|
13
|
+
}
|
14
|
+
|
15
|
+
LEVELS=LEVEL.keys
|
16
|
+
VALUES=LEVEL.values.collect{ |v| v[:value] }.sort
|
17
|
+
|
18
|
+
PERMISSION_LEVELS_BY_VALUE=LEVELS.inject({}) do |level_hash, level_key|
|
19
|
+
lvl = LEVEL[level_key]
|
20
|
+
level_hash[lvl[:value]] = lvl
|
21
|
+
level_hash
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.[](k)
|
25
|
+
value_for_level k
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.level_for_value v
|
29
|
+
PERMISSION_LEVELS_BY_VALUE[v]
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.value_for_level k
|
33
|
+
LEVEL[k][:value]
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.options_for_select options={}
|
37
|
+
levels = LEVELS
|
38
|
+
names = options.delete(:names)
|
39
|
+
names ||= {}
|
40
|
+
only = options.delete(:only)
|
41
|
+
levels = only if only
|
42
|
+
except = options.delete(:except)
|
43
|
+
levels = levels-except if except
|
44
|
+
levels.collect { |lvl_key| [ names[lvl_key] || LEVEL[lvl_key][:name], LEVEL[lvl_key][:value] ] }
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.compare(k1, k2)
|
48
|
+
value_for_level( k1 ) - value_for_level( k2 )
|
49
|
+
end
|
50
|
+
|
51
|
+
# ex: Webs::PermissionLevel.is_at_least( 25, :limited ) => true
|
52
|
+
def self.is_at_least( v, k )
|
53
|
+
value_for_level( k ) >= v
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
module CommentsOrder
|
58
|
+
ASC = 0
|
59
|
+
DESC = 1
|
60
|
+
VIEWS = [[ASC, "Oldest first (default)"], [DESC, "Newest first"]]
|
61
|
+
SELECT_OPTIONS = VIEWS.map { |val, disp| [disp, val] }
|
62
|
+
VAL_LIST = VIEWS.map {|val, disp| val}
|
63
|
+
def self.val_to_str(val)
|
64
|
+
val.to_i == ASC ? "ASC": "DESC"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -4,7 +4,9 @@ module Webs
|
|
4
4
|
# additionally check the webs_config.yml which should support overriding for dev & test environments
|
5
5
|
# by adding a 'development.webs_config.yml" file.
|
6
6
|
def self.webs_config &block
|
7
|
-
|
7
|
+
# load_constants
|
8
|
+
|
9
|
+
config = YAML.load( ERB.new( File.read("#{Rails.root.to_s}/config/webs_config.yml") ).result )[Rails.env]
|
8
10
|
|
9
11
|
# CREATE CONSTANTS FOR EACH KEY
|
10
12
|
config.each_key { |k| self.const_set(k.to_s.upcase, config[k]) }
|
@@ -1,4 +1,6 @@
|
|
1
1
|
module Webs
|
2
|
+
mattr_accessor :app_name
|
3
|
+
|
2
4
|
module Controller
|
3
5
|
module WebsController
|
4
6
|
def self.included(base)
|
@@ -7,18 +9,21 @@ module Webs
|
|
7
9
|
|
8
10
|
module ClassMethods
|
9
11
|
def webs_helpers
|
12
|
+
helper Webs::Helper::Application
|
10
13
|
helper Webs::Helper::Params
|
11
14
|
helper Webs::Helper::Tags
|
15
|
+
helper Webs::Cache
|
12
16
|
include Webs::Helper::Params
|
13
17
|
include Webs::Helper::Tags
|
18
|
+
include Webs::Cache
|
19
|
+
helper_method :webs_site
|
14
20
|
helper_method :webs_app_name
|
15
21
|
helper_method :webs_appenv_name
|
16
22
|
end
|
17
23
|
end
|
18
24
|
|
19
25
|
def webs_app_name
|
20
|
-
|
21
|
-
app_name ||= Webs::APP_NAME if defined?(Webs::APP_NAME)
|
26
|
+
Webs::APP_NAME || APP_NAME
|
22
27
|
end
|
23
28
|
|
24
29
|
def webs_appenv_name
|
@@ -46,60 +51,42 @@ module Webs
|
|
46
51
|
s = webs_auth_string
|
47
52
|
Digest::MD5.hexdigest(webs_auth_string + secret)
|
48
53
|
end
|
49
|
-
|
50
|
-
# mappings to http://wiki.beta.freewebs.com/index.php/Fw:member-level-select
|
51
|
-
def webs_member_level_to_int member_level
|
52
|
-
{
|
53
|
-
'anyone'=>Webs::Permission::ANYONE,
|
54
|
-
'limited'=>Webs::Permission::LIMITED,
|
55
|
-
'member'=>Webs::Permission::MEMBERS,
|
56
|
-
'moderator'=>Webs::Permission::MODERATORS,
|
57
|
-
'admin'=>Webs::Permission::ADMIN
|
58
|
-
}[member_level.downcase]
|
59
|
-
end
|
60
54
|
|
61
|
-
#
|
62
|
-
#
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
55
|
+
# Examples:
|
56
|
+
# webs_redirect acontroller_path( @model_object )
|
57
|
+
# webs_redirect acontroller_path( @model_object ), :partials=>[partial1, partial2]
|
58
|
+
# webs_redirect :controller=>:acontroller, :flash=>'a message'
|
59
|
+
def webs_redirect(*args)
|
60
|
+
if args && args[0] && args[0].class.to_s =~ /String/
|
61
|
+
url = args[0]
|
62
|
+
options = args[1]
|
63
|
+
else
|
64
|
+
options = args[0]
|
65
|
+
end
|
66
|
+
|
67
|
+
if options.class.to_s =~ /Hash/
|
68
|
+
partials = options.delete(:partials)
|
69
|
+
end
|
70
|
+
|
71
|
+
message = options.delete(:flash)
|
72
|
+
flash[:notice] = message if !message.blank?
|
73
|
+
|
74
|
+
url = url_for( options.merge(:only_path=>true) ) if url.blank?
|
75
|
+
|
76
|
+
render_text = %(<fw:redirect url="#{url}">#{partials.collect{ |p| render_to_string :partial=>p } if partials && partials.any?}Redirecting, please wait...</fw:redirect>)
|
77
|
+
Rails.logger.debug render_text
|
78
|
+
render :text => render_text
|
73
79
|
end
|
74
80
|
|
75
|
-
def
|
76
|
-
|
77
|
-
Webs::Permission::DISABLED=>'disabled',
|
78
|
-
Webs::Permission::ANYONE=>'anyone',
|
79
|
-
Webs::Permission::LIMITED=>'limited',
|
80
|
-
Webs::Permission::MEMBERS=>'member',
|
81
|
-
Webs::Permission::MODERATORS=>'moderator',
|
82
|
-
Webs::Permission::ADMIN=>'admin',
|
83
|
-
Webs::Permission::OWNER=>'admin'
|
84
|
-
}[n]
|
85
|
-
end
|
86
|
-
|
87
|
-
# converts level which is an int for the select options of a fw:member-level-select
|
88
|
-
# first to an associated Webs::Permission then to a blog member level
|
89
|
-
# TODO: This should be cleaned up and blogs should use the fw:member-level-select values
|
90
|
-
# the mapping is useful if you need to change the result, generally sending returning admin if owner
|
91
|
-
# since most of the apps use owner not admin
|
92
|
-
# The generally needs to be done in params since some objects contain validations
|
93
|
-
# example:
|
94
|
-
# convert_webs_member_level( params[:entries], :view_level, {Webs::Permission::ADMIN=>Webs::Permission::OWNER} )
|
95
|
-
# will take a webs member-level-select and convert it to a Webs::Permission mapping ADMIN to OWNER
|
96
|
-
def convert_webs_member_level h, key, mapping={}
|
97
|
-
return if h.nil?
|
98
|
-
v = webs_member_level_value_to_old_member_level( h[key] )
|
99
|
-
h[key] = mapping[v] || v
|
81
|
+
def webs_info
|
82
|
+
render :partial=>'shared/webs_info'
|
100
83
|
end
|
101
84
|
|
102
85
|
# FILTERS
|
86
|
+
def set_page_title
|
87
|
+
@title = Webs::app_title
|
88
|
+
end
|
89
|
+
|
103
90
|
def validate_webs_session
|
104
91
|
render :text => "Access Denied: Webs::SECRET not defined." and return(false) unless defined?( Webs::SECRET )
|
105
92
|
render :text => "Access Denied" and return(false) unless fw_sig == webs_auth( Webs::SECRET )
|
@@ -113,6 +100,36 @@ module Webs
|
|
113
100
|
render(:text => "You are not authorized.") unless webs_admin?
|
114
101
|
end
|
115
102
|
|
103
|
+
def webs_site
|
104
|
+
@webs_site
|
105
|
+
end
|
106
|
+
|
107
|
+
# options include primary_key_col
|
108
|
+
def load_site_model modelname, options={}
|
109
|
+
Rails.logger.debug "load_site_model #{modelname} #{options.inspect}"
|
110
|
+
model = modelname.constantize
|
111
|
+
pk = options.delete(:primary_key_col)
|
112
|
+
if pk
|
113
|
+
@webs_site = model.find( :first, :conditions=>{ pk=>webs_site_id } )
|
114
|
+
else
|
115
|
+
@webs_site = model.find( webs_site_id )
|
116
|
+
end
|
117
|
+
|
118
|
+
rescue
|
119
|
+
Rails.logger.debug "!!!!!!!!!!!!!!!!!!! load_site_model Failed"
|
120
|
+
nil
|
121
|
+
end
|
122
|
+
|
123
|
+
def log_fw_params
|
124
|
+
Rails.logger.debug "FW_PARAMS={"
|
125
|
+
Rails.logger.debug params.select{ |k,v| k.starts_with?("fw_sig_") }.sort.collect { |k,v| " :#{k}=>'#{v}'" }.join(",\n")
|
126
|
+
Rails.logger.debug "}"
|
127
|
+
end
|
128
|
+
|
129
|
+
# Usefull for debugging, set FW_PARAMS in development.rb and you can see the raw html in a browser
|
130
|
+
def set_fw_params
|
131
|
+
params.merge!( FW_PARAMS ) if defined?( FW_PARAMS )
|
132
|
+
end
|
116
133
|
end
|
117
134
|
end
|
118
135
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Webs
|
2
|
+
module Helper
|
3
|
+
module Application
|
4
|
+
def cdata str="", &block
|
5
|
+
return "<![CDATA[#{str}]]>" unless block
|
6
|
+
|
7
|
+
content = capture(&block)
|
8
|
+
begin
|
9
|
+
# Rails 3
|
10
|
+
output = ActiveSupport::SafeBuffer.new
|
11
|
+
output.safe_concat("<![CDATA[")
|
12
|
+
output << content
|
13
|
+
output.safe_concat("]]>")
|
14
|
+
rescue
|
15
|
+
concat("<![CDATA[", block.binding)
|
16
|
+
concat( content, block.binding)
|
17
|
+
concat("]]>", block.binding)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# shouldn't need this anymore for Rails 3, just use image_tag
|
22
|
+
# def webs_image_url img
|
23
|
+
# "http://#{Webs::ASSET_HOST}/images/#{img}"
|
24
|
+
# end
|
25
|
+
|
26
|
+
def webs_info
|
27
|
+
render :partial=>'shared/webs_info'
|
28
|
+
end
|
29
|
+
|
30
|
+
# return an array of value, name select options for the given levels
|
31
|
+
# if names are present map the names by level key
|
32
|
+
def webs_permission_level_select_options levels=Webs::PERMISSION_LEVELS, names={}
|
33
|
+
levels.collect do |lvl_key|
|
34
|
+
lvl = PERMISSION_LEVEL[lvl_key]
|
35
|
+
[ lvl[:value], names[lvl_key] || lvl[:name] ]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/helper/params.rb
CHANGED
@@ -1,59 +1,53 @@
|
|
1
1
|
module Webs
|
2
2
|
module Helper
|
3
3
|
module Params
|
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, :
|
4
|
+
FW_PARAMS = [: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_user, :fw_sig_width, :fw_sig_social, :fw_sig_premium, :fb_sig_network]
|
6
|
+
|
7
|
+
FW_PARAMS.each do |fw_param|
|
6
8
|
module_eval( "def #{fw_param.to_s}() params[:#{fw_param.to_s}] end" )
|
7
9
|
end
|
8
10
|
|
9
11
|
# Some basic useful methods
|
10
|
-
def
|
12
|
+
def webs_sitebuilder?
|
11
13
|
fw_sig_is_admin == '1'
|
12
14
|
end
|
13
15
|
|
14
|
-
def
|
15
|
-
|
16
|
-
when /admin/i
|
17
|
-
Permission::ADMIN
|
18
|
-
when /owner/i
|
19
|
-
Permission::OWNER
|
20
|
-
when /moderator/i
|
21
|
-
Permission::MODERATORS
|
22
|
-
when /contributor/i
|
23
|
-
Permission::MEMBERS
|
24
|
-
when /limited/i
|
25
|
-
Permission::LIMITED
|
26
|
-
else
|
27
|
-
Permission::ANYONE
|
28
|
-
end
|
16
|
+
def webs_anyone?
|
17
|
+
fw_sig_permission_level == Webs::PermissionLevel[:anyone].to_s
|
29
18
|
end
|
30
19
|
|
31
|
-
#
|
32
|
-
def
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
def webs_admin?
|
37
|
-
webs_permission == Permission::ADMIN
|
20
|
+
#TODO: is this same as anyone and can we ditch the -255??
|
21
|
+
def webs_anonymous?
|
22
|
+
fw_sig_permission_level == Webs::PermissionLevel[:none].to_s
|
38
23
|
end
|
39
24
|
|
40
|
-
def
|
41
|
-
|
25
|
+
def webs_limited?
|
26
|
+
fw_sig_permission_level == Webs::PermissionLevel[:limited].to_s
|
42
27
|
end
|
43
28
|
|
44
|
-
def
|
45
|
-
|
29
|
+
def webs_member?
|
30
|
+
fw_sig_permission_level == Webs::PermissionLevel[:member].to_s
|
46
31
|
end
|
47
32
|
|
48
33
|
def webs_moderator?
|
49
|
-
|
34
|
+
fw_sig_permission_level == Webs::PermissionLevel[:moderator].to_s
|
50
35
|
end
|
51
36
|
|
52
|
-
def
|
53
|
-
|
37
|
+
def webs_admin?
|
38
|
+
fw_sig_permission_level == Webs::PermissionLevel[:admin].to_s
|
54
39
|
end
|
55
40
|
|
56
|
-
def
|
41
|
+
def webs_owner?
|
42
|
+
fw_sig_permission_level == Webs::PermissionLevel[:owner].to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
#TODO: Also need to check the java??
|
46
|
+
def webs_disabled?
|
47
|
+
fw_sig_permission_level == Webs::PermissionLevel[:disabled].to_s
|
48
|
+
end
|
49
|
+
|
50
|
+
def webs_premium?
|
57
51
|
fw_sig_premium == '1'
|
58
52
|
end
|
59
53
|
|
@@ -61,6 +55,18 @@ module Webs
|
|
61
55
|
fw_sig_social == '1'
|
62
56
|
end
|
63
57
|
|
58
|
+
def webs_admin_owner_sitebuilder?
|
59
|
+
webs_admin? || webs_owner? || webs_sitebuilder?
|
60
|
+
end
|
61
|
+
|
62
|
+
def webs_admin_owner?
|
63
|
+
webs_admin? || webs_owner?
|
64
|
+
end
|
65
|
+
|
66
|
+
def webs_site_id
|
67
|
+
fw_sig_site.to_i if !fw_sig_site.blank?
|
68
|
+
end
|
69
|
+
|
64
70
|
def webs_params
|
65
71
|
params.select{ |k,v| k.starts_with?("fw_sig_") }.sort
|
66
72
|
end
|
data/lib/helper/tags.rb
CHANGED
@@ -2,28 +2,53 @@ module Webs
|
|
2
2
|
module Helper
|
3
3
|
module Tags
|
4
4
|
def fwml tagname, options={}, &block
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
5
|
+
# Rails.logger.debug "****** fwml #{tagname} #{options.inspect}"
|
6
|
+
if ['sanitize', 'wizzywig'].include?(tagname.to_s)
|
7
|
+
self.send( "fw_#{tagname}", options, &block )
|
8
|
+
else
|
9
|
+
return inline_tag( tagname, options ) unless block
|
10
|
+
render_tag_with_block tagname, options, false, &block
|
21
11
|
end
|
22
12
|
end
|
23
13
|
|
24
|
-
|
25
|
-
|
14
|
+
private
|
15
|
+
def html_options options
|
16
|
+
' ' + options.each_key.select{ |k| !options[k].blank? }.collect{|k| "#{k.to_s}=\"#{options[k]}\"" }.join(' ') if options.any?
|
17
|
+
end
|
18
|
+
|
19
|
+
def render_tag_with_block tagname, options, cdata_wrapper=false, &block
|
20
|
+
# Rails.logger.debug "****** render_tag_with_block #{tagname} #{options.inspect} cdata=#{cdata_wrapper}"
|
21
|
+
content = capture(&block)
|
22
|
+
output = ActiveSupport::SafeBuffer.new
|
23
|
+
output.safe_concat("<fw:#{tagname}#{html_options(options)}>")
|
24
|
+
output.safe_concat("<![CDATA[") if cdata_wrapper
|
25
|
+
output << content
|
26
|
+
output.safe_concat("]]>") if cdata_wrapper
|
27
|
+
output.safe_concat("</fw:#{tagname}>")
|
28
|
+
end
|
29
|
+
|
30
|
+
def inline_tag tagname, options
|
31
|
+
"<fw:#{tagname}#{html_options(options)}/>"
|
32
|
+
end
|
33
|
+
|
34
|
+
def fw_sanitize options={}, &block
|
35
|
+
cdata_wrapper = options.delete(:cdata)
|
36
|
+
cdata_wrapper = true if cdata_wrapper.nil?
|
37
|
+
render_tag_with_block 'sanitize', options, cdata_wrapper, &block
|
38
|
+
end
|
39
|
+
|
40
|
+
# fw_wizzywig should never be called with a block the text is passed in via text
|
41
|
+
def fw_wizzywig options={}
|
42
|
+
wizzywig_text = options.delete( :wizzywig_text )
|
43
|
+
"<fw:wizzywig #{html_options(options)}><![CDATA[#{wizzywig_text}]]></fw:wizzywig>"
|
26
44
|
end
|
27
45
|
end
|
28
46
|
end
|
29
|
-
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# No support for rails 2
|
50
|
+
# concat("<fw:#{tagname}#{s_options}>", block.binding)
|
51
|
+
# concat("<![CDATA[") if cdata_wrapper
|
52
|
+
# concat( content, block.binding)
|
53
|
+
# concat("]]>") if cdata_wrapper
|
54
|
+
# concat("</fw:#{tagname}>", block.binding)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= fwml :page, :permapath=>@permapath, :title=>@title do %>
|
2
|
+
<fw:head>
|
3
|
+
<%= javascript_include_tag 'application' %>
|
4
|
+
<%= stylesheet_link_tag 'styles' %>
|
5
|
+
<%= yield :fw_head %>
|
6
|
+
</fw:head>
|
7
|
+
|
8
|
+
<fw:paragraph>
|
9
|
+
<fw:title>
|
10
|
+
<span style="float:left" class="pageTitle">
|
11
|
+
<%= raw( %(<fw:page-title path='/' />) ) %>
|
12
|
+
<%= yield :fw_title %>
|
13
|
+
</span>
|
14
|
+
<div class="clear"></div>
|
15
|
+
</fw:title>
|
16
|
+
|
17
|
+
<%= yield %>
|
18
|
+
</fw:paragraph>
|
19
|
+
<% end %>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<h1>Webs Info</h1>
|
2
|
+
<table >
|
3
|
+
<% Webs::Helper::Params::FW_PARAMS.collect{|p| p.to_s}.sort.each do |fw_param| %>
|
4
|
+
<tr>
|
5
|
+
<td><%= fw_param %></td>
|
6
|
+
<td><%= eval fw_param %></td>
|
7
|
+
</tr>
|
8
|
+
<% end %>
|
9
|
+
<tr>
|
10
|
+
<td>webs_app_url</td>
|
11
|
+
<td><a href="<%= webs_app_url %>" target="_blank"><%= webs_app_url %></a></td>
|
12
|
+
</tr>
|
13
|
+
<% %w[webs_app_name
|
14
|
+
webs_appenv_name
|
15
|
+
webs_site_id
|
16
|
+
webs_sitebuilder?
|
17
|
+
webs_admin_owner?
|
18
|
+
webs_admin_owner_sitebuilder?
|
19
|
+
webs_premium?
|
20
|
+
webs_social?
|
21
|
+
webs_anyone?
|
22
|
+
webs_anonymous?
|
23
|
+
webs_limited?
|
24
|
+
webs_member?
|
25
|
+
webs_moderator?
|
26
|
+
webs_admin?
|
27
|
+
webs_owner?
|
28
|
+
webs_disabled? ].each do |p| %>
|
29
|
+
<tr>
|
30
|
+
<td><%= p %></td>
|
31
|
+
<td><%= eval p %></td>
|
32
|
+
</tr>
|
33
|
+
<% end %>
|
34
|
+
|
35
|
+
</table>
|
36
|
+
|
37
|
+
<%#
|
38
|
+
%>
|
data/lib/webs.rb
CHANGED
@@ -1,21 +1,50 @@
|
|
1
1
|
dir = Pathname(__FILE__).dirname.expand_path
|
2
2
|
|
3
|
+
require dir + 'config/webs_constants'
|
3
4
|
require dir + 'controller/webs_controller'
|
5
|
+
require dir + 'helper/application'
|
4
6
|
require dir + 'helper/params'
|
5
7
|
require dir + 'helper/tags'
|
6
8
|
|
7
9
|
module Webs
|
8
|
-
VERSION = "0.1.
|
10
|
+
VERSION = "0.1.10".freeze
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
# def self.load_constants
|
13
|
+
# s = File.read("#{Pathname(__FILE__).dirname.expand_path}/config/webs_constants.yml")
|
14
|
+
# Rails.logger.debug ERB.new( File.read("#{Pathname(__FILE__).dirname.expand_path}/config/webs_constants.yml") ).result
|
15
|
+
# config = YAML.load( ERB.new( File.read("#{Pathname(__FILE__).dirname.expand_path}/config/webs_constants.yml") ).result )
|
16
|
+
#
|
17
|
+
# # CREATE CONSTANTS FOR EACH KEY
|
18
|
+
# config.each_key do |k|
|
19
|
+
# v = config[k]
|
20
|
+
# # convert strings to symbols
|
21
|
+
# # TODO: might need to do children
|
22
|
+
# if v.is_a?(Hash)
|
23
|
+
# h = {}
|
24
|
+
# v.each_key { |vk| vk.is_a?(String) ? h[vk.to_sym] = v[vk] : h[vk] = v[vk] }
|
25
|
+
# v = h
|
26
|
+
# end
|
27
|
+
# self.const_set(k.to_s.upcase, v)
|
28
|
+
# end
|
29
|
+
# map_permission_levels
|
30
|
+
# end
|
31
|
+
|
32
|
+
# def self.map_permission_levels
|
33
|
+
# h = {}
|
34
|
+
# PERMISSION_LEVEL.each_value{ |v| h[v['value']] = v }
|
35
|
+
# self.const_set('PERMISSION_LEVELS_BY_VALUE', h)
|
36
|
+
# self.const_set('PERMISSION_LEVELS', PERMISSION_LEVEL.keys)
|
37
|
+
# end
|
38
|
+
|
39
|
+
def self.app_title
|
40
|
+
APP_NAME.titleize
|
18
41
|
end
|
19
42
|
|
43
|
+
class Railtie < Rails::Railtie
|
44
|
+
initializer 'webs_view-path' do |app|
|
45
|
+
path = "#{Pathname(__FILE__).dirname.expand_path}/views"
|
46
|
+
app.paths.app.views.push path
|
47
|
+
end
|
48
|
+
end
|
20
49
|
end
|
21
50
|
|
data/webs.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{webs}
|
5
|
+
s.version = "0.1.10"
|
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-11-04}
|
10
|
+
s.description = %q{Reusable webs stuff.}
|
11
|
+
s.email = %q{chuck@webs.com}
|
12
|
+
gemfiles = [
|
13
|
+
"README.rdoc",
|
14
|
+
"lib/webs.rb",
|
15
|
+
"lib/cache/cache.rb",
|
16
|
+
"lib/config/webs_constants.rb",
|
17
|
+
"lib/config/webs_initializer.rb",
|
18
|
+
"lib/controller/webs_controller.rb",
|
19
|
+
"lib/helper/application.rb",
|
20
|
+
"lib/helper/params.rb",
|
21
|
+
"lib/helper/tags.rb",
|
22
|
+
"lib/views/layouts/webs_page.html.erb",
|
23
|
+
"lib/views/layouts/webs_utility.html.erb",
|
24
|
+
"lib/views/shared/_webs_info.html.erb"
|
25
|
+
]
|
26
|
+
s.extra_rdoc_files = gemfiles
|
27
|
+
s.files = gemfiles + [ "Rakefile", "webs.gemspec" ]
|
28
|
+
s.homepage = %q{http://github.com/websdotcom/websgem}
|
29
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Webs", "--main", "README.rdoc"]
|
30
|
+
s.require_paths = ["lib"]
|
31
|
+
s.rubyforge_project = %q{webs}
|
32
|
+
s.rubygems_version = %q{1.3.7}
|
33
|
+
s.summary = %q{Reusable webs stuff.}
|
34
|
+
|
35
|
+
if s.respond_to? :specification_version then
|
36
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
37
|
+
s.specification_version = 3
|
38
|
+
|
39
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
40
|
+
else
|
41
|
+
end
|
42
|
+
else
|
43
|
+
end
|
44
|
+
end
|
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: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 10
|
10
|
+
version: 0.1.10
|
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-11-
|
18
|
+
date: 2010-11-04 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -28,17 +28,31 @@ extensions: []
|
|
28
28
|
extra_rdoc_files:
|
29
29
|
- README.rdoc
|
30
30
|
- lib/webs.rb
|
31
|
+
- lib/cache/cache.rb
|
32
|
+
- lib/config/webs_constants.rb
|
31
33
|
- lib/config/webs_initializer.rb
|
32
34
|
- lib/controller/webs_controller.rb
|
35
|
+
- lib/helper/application.rb
|
33
36
|
- lib/helper/params.rb
|
34
37
|
- lib/helper/tags.rb
|
38
|
+
- lib/views/layouts/webs_page.html.erb
|
39
|
+
- lib/views/layouts/webs_utility.html.erb
|
40
|
+
- lib/views/shared/_webs_info.html.erb
|
35
41
|
files:
|
36
42
|
- README.rdoc
|
37
43
|
- lib/webs.rb
|
44
|
+
- lib/cache/cache.rb
|
45
|
+
- lib/config/webs_constants.rb
|
38
46
|
- lib/config/webs_initializer.rb
|
39
47
|
- lib/controller/webs_controller.rb
|
48
|
+
- lib/helper/application.rb
|
40
49
|
- lib/helper/params.rb
|
41
50
|
- lib/helper/tags.rb
|
51
|
+
- lib/views/layouts/webs_page.html.erb
|
52
|
+
- lib/views/layouts/webs_utility.html.erb
|
53
|
+
- lib/views/shared/_webs_info.html.erb
|
54
|
+
- Rakefile
|
55
|
+
- webs.gemspec
|
42
56
|
has_rdoc: true
|
43
57
|
homepage: http://github.com/websdotcom/websgem
|
44
58
|
licenses: []
|