whowish_word 0.2.1 → 0.2.2
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.md +4 -3
- data/lib/whowish_word/initializer.rb +2 -4
- data/lib/whowish_word/rails/app/controllers/whowish_word_controller.rb +0 -10
- data/rails/app/controllers/application_controller.rb +2 -0
- data/rails/config/initializers/whowish_word.rb +0 -2
- data/rails/spec/integration/whowish_word_spec.rb +7 -0
- data/rails/spec/spec_helper.rb +0 -8
- data/whowish_word.gemspec +1 -1
- metadata +1 -25
- data/lib/legacy/whowish_word/config.rb +0 -1
- data/lib/legacy/whowish_word/init.rb +0 -4
- data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_controller.rb +0 -115
- data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb +0 -66
- data/lib/legacy/whowish_word/lib/app/controllers/whowish_word_facebook_controller.rb +0 -62
- data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word.rb +0 -12
- data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word_email.rb +0 -10
- data/lib/legacy/whowish_word/lib/app/models/mongodb/whowish_word_facebook.rb +0 -28
- data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word.rb +0 -5
- data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word_email.rb +0 -5
- data/lib/legacy/whowish_word/lib/app/models/mysql/whowish_word_facebook.rb +0 -18
- data/lib/legacy/whowish_word/lib/app/views/layouts/whowish_word_blank.html.erb +0 -94
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/_javascript.html.erb +0 -82
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/_row.html.erb +0 -50
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/index.html.erb +0 -219
- data/lib/legacy/whowish_word/lib/app/views/whowish_word/login.html.erb +0 -5
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_email/_row.html.erb +0 -42
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_email/index.html.erb +0 -99
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_facebook/_row.html.erb +0 -48
- data/lib/legacy/whowish_word/lib/app/views/whowish_word_facebook/index.html.erb +0 -100
- data/lib/legacy/whowish_word/lib/db_migration/mongodb.rb +0 -0
- data/lib/legacy/whowish_word/lib/db_migration/mysql.rb +0 -60
- data/lib/legacy/whowish_word/lib/db_migration.rb +0 -2
- data/lib/legacy/whowish_word/lib/hook.rb +0 -186
@@ -1,60 +0,0 @@
|
|
1
|
-
## define schema for words
|
2
|
-
|
3
|
-
begin
|
4
|
-
ActiveRecord::Schema.define do
|
5
|
-
|
6
|
-
create_table "whowish_words", :force => false do |t|
|
7
|
-
t.string "word_id", :null => false
|
8
|
-
t.text "content", :null => false
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
ActiveRecord::Base.connection.execute("ALTER TABLE `whowish_words` ADD UNIQUE (`word_id`)")
|
14
|
-
|
15
|
-
add_index :whowish_word_emails, :word_id
|
16
|
-
|
17
|
-
rescue Exception=>e
|
18
|
-
puts "Create whowish_words failed: #{e}"
|
19
|
-
end
|
20
|
-
|
21
|
-
## define schema for emails
|
22
|
-
begin
|
23
|
-
ActiveRecord::Schema.define do
|
24
|
-
|
25
|
-
create_table "whowish_word_emails", :force => false do |t|
|
26
|
-
t.string "word_id", :null => false
|
27
|
-
t.text "content", :null => false
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
ActiveRecord::Base.connection.execute("ALTER TABLE `whowish_word_emails` ADD UNIQUE (`word_id`)")
|
33
|
-
|
34
|
-
add_index :whowish_word_emails, :word_id
|
35
|
-
|
36
|
-
rescue Exception=>e
|
37
|
-
puts "Create whowish_words failed: #{e}"
|
38
|
-
end
|
39
|
-
|
40
|
-
## define schema for facebooks
|
41
|
-
begin
|
42
|
-
ActiveRecord::Schema.define do
|
43
|
-
|
44
|
-
create_table "whowish_word_facebooks", :force => false do |t|
|
45
|
-
t.string "publish_id", :null => false
|
46
|
-
t.string "message", :null => false
|
47
|
-
t.string "name", :null => false
|
48
|
-
t.string "caption", :null => false
|
49
|
-
t.text "description", :null => false
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
ActiveRecord::Base.connection.execute("ALTER TABLE `whowish_word_facebooks` ADD UNIQUE (`publish_id`)")
|
55
|
-
|
56
|
-
add_index :whowish_word_facebooks, :publish_id
|
57
|
-
|
58
|
-
rescue Exception=>e
|
59
|
-
puts "Create whowish_words failed: #{e}"
|
60
|
-
end
|
@@ -1,186 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__)+"/../config"
|
2
|
-
|
3
|
-
paths = ["controllers","views","models/#{WHOWISH_WORD_DATABASE_ENGINE}"]
|
4
|
-
|
5
|
-
# load all controllers, helpers, and models
|
6
|
-
paths.each do |dir|
|
7
|
-
path = File.join(File.dirname(__FILE__), 'app', dir)
|
8
|
-
$LOAD_PATH.insert(0, path)
|
9
|
-
ActiveSupport::Dependencies.autoload_paths.insert(0, path)
|
10
|
-
ActiveSupport::Dependencies.autoload_once_paths.delete(path)
|
11
|
-
end
|
12
|
-
|
13
|
-
ActionController::Base.append_view_path(File.join(File.dirname(__FILE__), 'app', 'views'))
|
14
|
-
|
15
|
-
class ActionController::Base
|
16
|
-
|
17
|
-
def choose_locale
|
18
|
-
|
19
|
-
$locale = "en"
|
20
|
-
$locale = session[:whowish_locale].downcase.strip if session[:whowish_locale]
|
21
|
-
$locale = params[:whowish_locale].downcase.strip if params[:whowish_locale]
|
22
|
-
|
23
|
-
session[:whowish_locale] = $locale
|
24
|
-
|
25
|
-
logger.debug { "locale=#{$locale}"}
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
class ActionView::Base
|
32
|
-
|
33
|
-
@@whowish_word = {}
|
34
|
-
|
35
|
-
def self.whowish_word
|
36
|
-
@@whowish_word
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.init_whowish_word
|
40
|
-
|
41
|
-
words = WhowishWord.all() + WhowishWordEmail.all()
|
42
|
-
|
43
|
-
@@whowish_word = {}
|
44
|
-
words.each { |word|
|
45
|
-
@@whowish_word[word.word_id] = word.content
|
46
|
-
}
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.whowish_word_for(page_id,id,*p)
|
50
|
-
|
51
|
-
$locale = "en" if !$locale
|
52
|
-
|
53
|
-
word_id = WhowishWord.generate_word_id(page_id,id,$locale)
|
54
|
-
|
55
|
-
css = "cursor:pointer;\
|
56
|
-
position:absolute;\
|
57
|
-
left:0px;\
|
58
|
-
top:-15px;\
|
59
|
-
width:15px;\
|
60
|
-
height:18px;";
|
61
|
-
|
62
|
-
js_arg = []
|
63
|
-
|
64
|
-
content = "##{page_id}:#{id}(#{$locale})".downcase
|
65
|
-
if p.length > 0
|
66
|
-
content_params = []
|
67
|
-
p[0].each_pair { |key,val|
|
68
|
-
content_params.push("#{key}: \"#{val}\"")
|
69
|
-
}
|
70
|
-
content += "{#{content_params.join(',')}}"
|
71
|
-
end
|
72
|
-
|
73
|
-
|
74
|
-
if @@whowish_word[word_id]
|
75
|
-
|
76
|
-
content = "#{@@whowish_word[word_id]}"
|
77
|
-
|
78
|
-
if p.length > 0
|
79
|
-
p = p[0]
|
80
|
-
|
81
|
-
p.each_pair { |key,val|
|
82
|
-
content.gsub!("{#{key}}","#{val}")
|
83
|
-
js_arg.push("\"#{key}\":\"#{val.to_s.gsub('"','\\"')}\"")
|
84
|
-
}
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
edit_icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAKDSURBVHjabJJLaJRXGIaf75z5J5M4TLxFF4GELLIUqsa6kNqAiyJ0odBVRUHBhfQmIgpSLzVIcFFcRKGblBYC2dh2RCjiptgGNCZBUTBVaRwTkpCQONO5/Zdz/v+48BLR+dbPw/vy8skv7e00PBESY8jE8f5sS8vBxNpDkTEFEVlBbl79o7GrFLZc3TR/4fxINF3IrV+3rpTW+mgURb86514xC/cHG8pKkFC80YWltm1PL/3M0o08q3M5VmUyl40x3wCIvf9Do1xw9vugdK/Pxydq/4on+VkeX+pHlhcHtE59CyDhvb5Gck9UfXo7qDxM2foUopuwXUcpTHUXlsf+3aS0VAEkmDj9nqfTcbh4xy+Ob3YuxARzpJs7sLVJW87u2hXkdv4tLnqF+mMn310JFwcX/eLdE4hgg3mUtxqcJaoXTokL+sXFK3h99LsV2bnPg8rk9cT+j0rliKNldHotUfXJrSSu9YIADiUWRYyURs+9qZsinHkUlW51Z1p7MP5zdLoN4z+v2XBhq4g8VsQIMcW4i1LcibwYH3iT24HSBS1lofIAbJ0kqRP5018L5koKQyXZwH/Bp8yZzRjXjPiPBtFaoZT6OFGZ0ZAsSADLt4mW/rqmXG1P6LJM+duZDrcSJDm0RAgJcu74AYrFIsDe3h0f/b77s0+QzBqU1/Rbafz04ZnSmuKzYDvluI3Ua+ntYANXfmJiYoJ8Pn8s8Os/9p85cm3fl1+ceTZbfjA7M0M5yqJIUBJ/+A3Dw8Pa87z1IyP/nG1qytDR2flna67VGms3au1pJUkCVAEH+EAFmAOmZWhoKA1s8TyvWymVM8ZsiJOkRaD5nZAQqL2Wl4BJYPzlAKO+L7lvWnFqAAAAAElFTkSuQmCC"
|
90
|
-
|
91
|
-
return_data = ""
|
92
|
-
if !$whowish_word_admin
|
93
|
-
return_data = content
|
94
|
-
elsif id.to_s.match("default") or id.to_s.match("whowish_box_title")
|
95
|
-
|
96
|
-
edit = "<span style='"+css+"' onclick=\"change_whowish_word(this,'#{word_id}',{},arguments[0] );return false;\"><img src='#{edit_icon}'/></span>"
|
97
|
-
|
98
|
-
|
99
|
-
return_data = content.gsub("\"", "\"")+"\",({whowish_word_class:\"#{word_id}\",edit:\"" + edit.gsub('"', '\\"') + "\"}),\""
|
100
|
-
else
|
101
|
-
|
102
|
-
arg_id = "whowish_word_arg_" + word_id.gsub('.','_').gsub('/','__')
|
103
|
-
|
104
|
-
edit = "<span style='"+css+"' onclick=\"change_whowish_word(this,'#{word_id}',{},arguments[0] );return false;\"><img src='#{edit_icon}'/></span>"
|
105
|
-
|
106
|
-
|
107
|
-
return_data = "<span style='position:relative;'><span class='#{word_id}'>" + content + "</span>" + edit + "</span>"
|
108
|
-
end
|
109
|
-
|
110
|
-
return return_data.html_safe
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
def global_word_for(namespace, id, *p)
|
115
|
-
ActionView::Base.whowish_word_for(namespace,id,*p)
|
116
|
-
end
|
117
|
-
|
118
|
-
def word_for(id, *p)
|
119
|
-
page_id = @last_template.identifier.sub("#{Rails.root}/app/views/", '')
|
120
|
-
ActionView::Base.whowish_word_for(page_id,id,*p)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
class ActionController::Base
|
125
|
-
|
126
|
-
def word_for(namespace,id,*p)
|
127
|
-
ActionView::Base.whowish_word_for(namespace,id,*p)
|
128
|
-
end
|
129
|
-
|
130
|
-
def self.word_for(namespace,id,*p)
|
131
|
-
ActionView::Base.whowish_word_for(namespace,id,*p)
|
132
|
-
end
|
133
|
-
|
134
|
-
|
135
|
-
end
|
136
|
-
|
137
|
-
|
138
|
-
module ActionView::Rendering
|
139
|
-
alias_method :_render_template_original, :_render_template
|
140
|
-
def _render_template(template, layout = nil, options = {})
|
141
|
-
@last_template = template
|
142
|
-
_render_template_original(template, layout, options)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
module ActionView::Layouts
|
147
|
-
alias_method :_render_layout_original, :_render_layout
|
148
|
-
# Contains the logic that actually renders the layout.
|
149
|
-
def _render_layout(layout, locals, &block) #:nodoc:
|
150
|
-
@last_template = layout
|
151
|
-
|
152
|
-
_render_layout_original(layout, locals, &block)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
module ActionView::Partials
|
157
|
-
alias_method :_render_partial_original, :_render_partial
|
158
|
-
|
159
|
-
def _render_partial(options, &block) #:nodoc:
|
160
|
-
|
161
|
-
@last_template ||= nil
|
162
|
-
|
163
|
-
previous_template = @last_template
|
164
|
-
prefix = self.controller_path unless options[:partial].include?(?/)
|
165
|
-
@last_template = self.find_template(options[:partial], prefix, true)
|
166
|
-
|
167
|
-
html = _render_partial_original(options, &block)
|
168
|
-
|
169
|
-
@last_template = previous_template
|
170
|
-
|
171
|
-
return html
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
|
177
|
-
# init all words
|
178
|
-
ActionView::Base.init_whowish_word
|
179
|
-
|
180
|
-
class ActionMailer::Base
|
181
|
-
|
182
|
-
def word_for(id, *p)
|
183
|
-
|
184
|
-
ActionView::Base.whowish_word_for(mailer_name + "/" + @template+".html.erb",id,*p)
|
185
|
-
end
|
186
|
-
end
|