goldencobra 1.4.0 → 1.4.27
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.markdown +3 -2
- data/app/assets/images/goldencobra/Jcrop.gif +0 -0
- data/app/assets/javascripts/goldencobra/active_admin.js +145 -84
- data/app/assets/javascripts/goldencobra/jquery.Jcrop.min.js +22 -0
- data/app/assets/javascripts/goldencobra/jquery.color.js +661 -0
- data/app/assets/stylesheets/goldencobra/active_admin.css.scss +375 -252
- data/app/assets/stylesheets/goldencobra/{application.css → application.css.scss} +0 -0
- data/app/assets/stylesheets/goldencobra/ikusei_active_admin.scss +35 -26
- data/app/assets/stylesheets/goldencobra/jquery.Jcrop.min.css +29 -0
- data/app/controllers/goldencobra/api/v2/articles_controller.rb +221 -0
- data/app/controllers/goldencobra/api/v2/locales_controller.rb +31 -0
- data/app/controllers/goldencobra/api/v2/settings_controller.rb +31 -0
- data/app/controllers/goldencobra/articles_controller.rb +42 -16
- data/app/controllers/goldencobra/sessions_controller.rb +8 -1
- data/app/helpers/goldencobra/application_helper.rb +3 -1
- data/app/helpers/goldencobra/articles_helper.rb +14 -8
- data/app/middleware/goldencobra/handle_invalid_percent_encoding.rb +40 -0
- data/app/models/ability.rb +43 -48
- data/app/models/goldencobra/article.rb +292 -218
- data/app/models/goldencobra/article_author.rb +19 -0
- data/app/models/goldencobra/article_image.rb +2 -0
- data/app/models/goldencobra/articletype.rb +30 -28
- data/app/models/goldencobra/author.rb +5 -3
- data/app/models/goldencobra/domain.rb +2 -0
- data/app/models/goldencobra/import.rb +2 -2
- data/app/models/goldencobra/link_checker.rb +64 -0
- data/app/models/goldencobra/menue.rb +4 -2
- data/app/models/goldencobra/permission.rb +3 -1
- data/app/models/goldencobra/redirector.rb +131 -0
- data/app/models/goldencobra/setting.rb +29 -3
- data/app/models/goldencobra/upload.rb +60 -1
- data/app/models/goldencobra/url_builder.rb +58 -0
- data/app/models/goldencobra/vita.rb +4 -0
- data/app/models/goldencobra/widget.rb +10 -0
- data/app/models/user.rb +1 -1
- data/app/views/goldencobra/admin/articles/_article_type.html.erb +1 -1
- data/app/views/goldencobra/admin/articles/_articles_index.html.erb +3 -3
- data/app/views/goldencobra/admin/articles/_image_module_sidebar.html.erb +19 -7
- data/app/views/goldencobra/admin/articles/_layout_sidebar.html.erb +2 -2
- data/app/views/goldencobra/admin/articles/_link_checker.html.erb +4 -4
- data/app/views/goldencobra/admin/articles/_link_checker_index.html.erb +1 -1
- data/app/views/goldencobra/admin/articles/_select_article_type.html.erb +8 -8
- data/app/views/goldencobra/admin/articles/_sort_articles_index.html.erb +1 -1
- data/app/views/goldencobra/admin/articles/_widgets_sidebar.html.erb +2 -2
- data/app/views/goldencobra/admin/articles/toggle_expert_mode.js.erb +2 -2
- data/app/views/goldencobra/admin/settings/_index.html.erb +14 -0
- data/app/views/goldencobra/admin/settings/_key_value.html.erb +12 -0
- data/app/views/goldencobra/admin/settings/_settings_group.html.erb +14 -0
- data/app/views/goldencobra/admin/shared/_help.html.erb +12 -10
- data/app/views/goldencobra/admin/shared/_item.html.erb +4 -4
- data/app/views/goldencobra/admin/shared/_overview.html.erb +14 -4
- data/app/views/goldencobra/admin/shared/load_overviewtree.js.erb +6 -0
- data/app/views/goldencobra/admin/uploads/_jcrop.html.erb +23 -0
- data/app/views/goldencobra/articles/_edit_article_link.html.erb +1 -1
- data/app/views/goldencobra/articles/show.rss.builder +5 -0
- data/app/views/goldencobra/articles/sitemap.xml.builder +15 -1
- data/app/views/goldencobra/manage/_admin_article_management.html.erb +1 -1
- data/app/views/goldencobra/manage/_admin_article_management_content.html.erb +4 -4
- data/app/views/goldencobra/manage/render_admin_menue.html.erb +1 -0
- data/app/views/goldencobra/manage/render_admin_menue.js.erb +0 -1
- data/app/views/goldencobra/sessions/_login.html.erb +4 -4
- data/app/views/goldencobra/sessions/_register.html.erb +6 -6
- data/app/views/layouts/goldencobra/active_admin_resque.html.erb +1 -1
- data/app/worker/articles_cache_worker.rb +1 -1
- data/config/initializers/check_for_missing_articletypes.rb +40 -37
- data/config/initializers/devise.rb +3 -1
- data/config/initializers/http_validator.rb +9 -2
- data/config/initializers/liquid_tags.rb +2 -2
- data/config/locales/active_admin.de.yml +509 -3
- data/config/locales/active_admin.en.yml +580 -64
- data/config/locales/de.yml +478 -4
- data/config/locales/en.yml +406 -10
- data/config/pre-commit.rb +3 -0
- data/config/routes.rb +12 -1
- data/config/settings.yml +51 -50
- data/db/migrate/20130114154115_add_sorter_to_goldencobra_permissions.rb +4 -1
- data/db/migrate/20140204221345_add_operator_to_goldencobra_permissions.rb +5 -0
- data/db/migrate/20140411152728_add_creator_id_to_goldencobra_articles.rb +5 -0
- data/db/migrate/20140505144517_add_taggingcounter.rb +15 -0
- data/db/migrate/20140603084537_add_domain_to_goldencobra_permissions.rb +7 -0
- data/db/migrate/20140615200342_resize_link_checkfield.rb +13 -0
- data/db/migrate/20140626135753_add_externalreferee_to_goldencobra_articles.rb +6 -0
- data/db/migrate/20140702103024_add_externaldate_to_goldencobra_articles.rb +5 -0
- data/db/migrate/20140702105550_add_remoteurl_to_goldencobra_uploads.rb +5 -0
- data/db/migrate/20140702142818_add_image_gallery_type_to_goldencobra_articles.rb +5 -0
- data/db/migrate/20140819101033_add_urlpath_to_goldencobra_articles.rb +5 -0
- data/db/migrate/20141009104216_set_db_and_tables_to_utf8.rb +20 -0
- data/db/migrate/20141104115144_create_goldencobra_redirectors.rb +15 -0
- data/db/migrate/20141112124531_add_globalsorting_to_goldencobra_articles.rb +7 -0
- data/db/migrate/20141124170930_add_indiex_to_gc.rb +26 -0
- data/db/migrate/20150115111024_create_goldencobra_article_authors.rb +28 -0
- data/db/migrate/20150115134707_add_remove_author_stuff.rb +11 -0
- data/db/migrate/20150417153454_add_status_to_goldencobra_vita_steps.rb +5 -0
- data/db/seeds.rb +4 -153
- data/lib/generators/goldencobra/articletype/templates/edit_index.html.erb +1 -1
- data/lib/generators/goldencobra/articletype/templates/initializer.rb +4 -2
- data/lib/generators/goldencobra/install_generator.rb +3 -0
- data/lib/generators/goldencobra/server_generator.rb +67 -0
- data/lib/generators/goldencobra/templates/active_admin.rb.erb +3 -0
- data/lib/generators/goldencobra/templates/robots.txt +5 -0
- data/lib/generators/goldencobra/templates/views/articletypes/default/_edit_index.html.erb +9 -0
- data/lib/generators/goldencobra/templates/views/articletypes/default/_edit_show.html.erb +0 -0
- data/lib/generators/goldencobra/templates/views/articletypes/default/_index.html.erb +31 -18
- data/lib/generators/goldencobra/templates/views/articletypes/default/_show.html.erb +22 -15
- data/lib/goldencobra/engine.rb +19 -3
- data/lib/goldencobra/version.rb +1 -1
- data/lib/tasks/article_cache.rake +19 -0
- data/lib/tasks/i18n.rake +1 -1
- data/lib/tasks/import.rake +31 -3
- data/lib/tasks/link_checker.rake +4 -2
- metadata +217 -23
- data/config/locales/activerecord.de.yml +0 -227
- data/config/locales/activerecord.en.yml +0 -148
- data/config/locales/devise.de.yml +0 -54
- data/config/locales/devise.en.yml +0 -57
- data/config/locales/formtastic.de.yml +0 -10
- data/config/locales/formtastic.en.yml +0 -10
- data/config/locales/goldencobra.de.yml +0 -40
- data/config/locales/goldencobra.en.yml +0 -3
File without changes
|
@@ -2,53 +2,61 @@
|
|
2
2
|
@import "/compass/css3";
|
3
3
|
|
4
4
|
|
5
|
-
$light_color
|
6
|
-
$dark_color
|
5
|
+
$light_color: #EFC;
|
6
|
+
$dark_color: #800080;
|
7
7
|
|
8
|
-
#header{
|
8
|
+
#header {
|
9
9
|
text-shadow: $dark_color 0 1px 0;
|
10
|
-
@include background(
|
11
|
-
|
12
|
-
|
10
|
+
@include background(linear-gradient($light_color, $dark_color));
|
11
|
+
|
12
|
+
h1 {
|
13
|
+
color: $dark_color;
|
13
14
|
}
|
15
|
+
|
14
16
|
ul#tabs > li a {
|
15
|
-
color:darken($dark_color,15%);
|
17
|
+
color: darken($dark_color, 15%);
|
16
18
|
}
|
19
|
+
|
17
20
|
ul#tabs > li.current a {
|
18
|
-
background-color
|
19
|
-
color
|
21
|
+
background-color: $dark_color;
|
22
|
+
color: $light_color;
|
20
23
|
}
|
24
|
+
|
21
25
|
ul#tabs > li:hover a {
|
22
|
-
background-color
|
23
|
-
color
|
26
|
+
background-color: $dark_color;
|
27
|
+
color: $light_color;
|
24
28
|
}
|
25
29
|
|
26
30
|
ul#tabs > li.has_nested:hover a {
|
27
|
-
background-color
|
28
|
-
color
|
31
|
+
background-color: $dark_color;
|
32
|
+
color: $light_color;
|
29
33
|
border-bottom: 5px solid $dark_color;
|
30
34
|
}
|
31
35
|
|
32
|
-
p#utility_nav{
|
33
|
-
color:darken($dark_color,15%);
|
36
|
+
p#utility_nav {
|
37
|
+
color: darken($dark_color, 15%);
|
34
38
|
}
|
35
|
-
|
36
|
-
|
39
|
+
|
40
|
+
a, a:link {
|
41
|
+
color: $light_color;
|
42
|
+
display: block;
|
37
43
|
}
|
38
|
-
|
39
|
-
|
44
|
+
|
45
|
+
ul#tabs > li ul {
|
46
|
+
background-color: $dark_color;
|
40
47
|
}
|
41
48
|
}
|
42
49
|
|
43
|
-
#title_bar{
|
44
|
-
@include background(
|
50
|
+
#title_bar {
|
51
|
+
@include background(linear-gradient(lighten($light_color, 50%), $light_color));
|
52
|
+
|
45
53
|
h2 {
|
46
|
-
color
|
54
|
+
color: $dark_color;
|
47
55
|
}
|
48
56
|
}
|
49
57
|
|
50
58
|
.breadcrumb a, .breadcrumb a:link {
|
51
|
-
color:lighten($dark_color,25%);
|
59
|
+
color: lighten($dark_color, 25%);
|
52
60
|
}
|
53
61
|
|
54
62
|
div#title_bar.title_bar div#titlebar_left span.breadcrumb{
|
@@ -57,7 +65,8 @@ div#title_bar.title_bar div#titlebar_left span.breadcrumb{
|
|
57
65
|
|
58
66
|
table.dashboard .dashboard_section{
|
59
67
|
background-color:$light_color;
|
60
|
-
|
61
|
-
|
68
|
+
|
69
|
+
h3
|
70
|
+
@include background(linear-gradient($light_color, lighten($dark_color,20%)));
|
62
71
|
}
|
63
|
-
}
|
72
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/* jquery.Jcrop.min.css v0.9.12 (build:20130126) */
|
2
|
+
.jcrop-holder{direction:ltr;text-align:left;}
|
3
|
+
.jcrop-vline,.jcrop-hline{background:#FFF url(/assets/goldencobra/Jcrop.gif);font-size:0;position:absolute;}
|
4
|
+
.jcrop-vline{height:100%;width:1px!important;}
|
5
|
+
.jcrop-vline.right{right:0;}
|
6
|
+
.jcrop-hline{height:1px!important;width:100%;}
|
7
|
+
.jcrop-hline.bottom{bottom:0;}
|
8
|
+
.jcrop-tracker{-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none;height:100%;width:100%;}
|
9
|
+
.jcrop-handle{background-color:#333;border:1px #EEE solid;font-size:1px;height:7px;width:7px;}
|
10
|
+
.jcrop-handle.ord-n{left:50%;margin-left:-4px;margin-top:-4px;top:0;}
|
11
|
+
.jcrop-handle.ord-s{bottom:0;left:50%;margin-bottom:-4px;margin-left:-4px;}
|
12
|
+
.jcrop-handle.ord-e{margin-right:-4px;margin-top:-4px;right:0;top:50%;}
|
13
|
+
.jcrop-handle.ord-w{left:0;margin-left:-4px;margin-top:-4px;top:50%;}
|
14
|
+
.jcrop-handle.ord-nw{left:0;margin-left:-4px;margin-top:-4px;top:0;}
|
15
|
+
.jcrop-handle.ord-ne{margin-right:-4px;margin-top:-4px;right:0;top:0;}
|
16
|
+
.jcrop-handle.ord-se{bottom:0;margin-bottom:-4px;margin-right:-4px;right:0;}
|
17
|
+
.jcrop-handle.ord-sw{bottom:0;left:0;margin-bottom:-4px;margin-left:-4px;}
|
18
|
+
.jcrop-dragbar.ord-n,.jcrop-dragbar.ord-s{height:7px;width:100%;}
|
19
|
+
.jcrop-dragbar.ord-e,.jcrop-dragbar.ord-w{height:100%;width:7px;}
|
20
|
+
.jcrop-dragbar.ord-n{margin-top:-4px;}
|
21
|
+
.jcrop-dragbar.ord-s{bottom:0;margin-bottom:-4px;}
|
22
|
+
.jcrop-dragbar.ord-e{margin-right:-4px;right:0;}
|
23
|
+
.jcrop-dragbar.ord-w{margin-left:-4px;}
|
24
|
+
.jcrop-light .jcrop-vline,.jcrop-light .jcrop-hline{background:#FFF;filter:alpha(opacity=70)!important;opacity:.70!important;}
|
25
|
+
.jcrop-light .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#000;border-color:#FFF;border-radius:3px;}
|
26
|
+
.jcrop-dark .jcrop-vline,.jcrop-dark .jcrop-hline{background:#000;filter:alpha(opacity=70)!important;opacity:.7!important;}
|
27
|
+
.jcrop-dark .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#FFF;border-color:#000;border-radius:3px;}
|
28
|
+
.solid-line .jcrop-vline,.solid-line .jcrop-hline{background:#FFF;}
|
29
|
+
.jcrop-holder img,img.jcrop-preview{max-width:none;}
|
@@ -0,0 +1,221 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Goldencobra
|
4
|
+
module Api
|
5
|
+
module V2
|
6
|
+
class ArticlesController < ActionController::Base
|
7
|
+
skip_before_filter :verify_authenticity_token
|
8
|
+
|
9
|
+
respond_to :json
|
10
|
+
|
11
|
+
# /api/v2/articles/search[.json]
|
12
|
+
# ---------------------------------------------------------------------------------------
|
13
|
+
def search
|
14
|
+
|
15
|
+
# Check if we have an argument.
|
16
|
+
unless params[:q]
|
17
|
+
render status: 200, json: { :status => 200 }
|
18
|
+
return
|
19
|
+
end
|
20
|
+
|
21
|
+
# Check if the query string contains something.
|
22
|
+
if params[:q].length == 0
|
23
|
+
render status: 200, json: { :status => 200 }
|
24
|
+
else
|
25
|
+
# Search and return the result array.
|
26
|
+
render status: 200, json: Goldencobra::Article.simple_search(
|
27
|
+
ActionController::Base.helpers.sanitize(params[:q])
|
28
|
+
).to_json
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
# /api/v2/articles[.json]
|
34
|
+
#
|
35
|
+
# @return [json] Liefert Alle Artikel :id,:title, :ancestry
|
36
|
+
# map{|c| [c.parent_path, c.id]}
|
37
|
+
def index
|
38
|
+
render status: 200, json: Goldencobra::Article.select([:id,:title, :ancestry]).sort{ |a, b|
|
39
|
+
a[0] <=> b[0]
|
40
|
+
}.map{ |a|
|
41
|
+
a.as_json(:only => [:id, :title], :methods => [:parent_path])
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# /api/v2/articles/create[.json]
|
47
|
+
# ---------------------------------------------------------------------------------------
|
48
|
+
def create
|
49
|
+
# Check if a user is currently logged in.
|
50
|
+
unless current_user
|
51
|
+
render status: 403, json: { :status => 403 }
|
52
|
+
return
|
53
|
+
end
|
54
|
+
|
55
|
+
# Check if we do have an article passed by the parameters.
|
56
|
+
unless params[:article]
|
57
|
+
render status: 400, json: { :status => 400, :error => "article data missing" }
|
58
|
+
return
|
59
|
+
end
|
60
|
+
|
61
|
+
#check if an external referee is passed by the parameters
|
62
|
+
unless params[:referee_id]
|
63
|
+
render status: 400, json: { :status => 400, :error => "referee_id missing" }
|
64
|
+
return
|
65
|
+
end
|
66
|
+
|
67
|
+
#check if Article already exists by comparing external referee and current user of caller
|
68
|
+
existing_articles = Goldencobra::Article.where(:creator_id => current_user.id, :external_referee_id => params[:referee_id])
|
69
|
+
if existing_articles.any?
|
70
|
+
render status: 423, json: { :status => 423, :error => "article already exists", :id => existing_articles.first.id }
|
71
|
+
return
|
72
|
+
end
|
73
|
+
|
74
|
+
# Try to save the article
|
75
|
+
response = create_article(params[:article])
|
76
|
+
if response.id.present?
|
77
|
+
render status: 200, json: { :status => 200, :id => response.id }
|
78
|
+
else
|
79
|
+
render status: 500, json: { :status => 500, :error => response.errors, :id => nil }
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def update
|
86
|
+
unless current_user
|
87
|
+
render status: 403, json: { :status => 403 }
|
88
|
+
return
|
89
|
+
end
|
90
|
+
|
91
|
+
# Check if we do have an article passed by the parameters.
|
92
|
+
unless params[:article]
|
93
|
+
render status: 400, json: { :status => 400, :error => "article data missing" }
|
94
|
+
return
|
95
|
+
end
|
96
|
+
|
97
|
+
#check if an external referee is passed by the parameters
|
98
|
+
unless params[:referee_id]
|
99
|
+
render status: 400, json: { :status => 400, :error => "referee_id missing" }
|
100
|
+
return
|
101
|
+
end
|
102
|
+
|
103
|
+
#check if Article already exists by comparing external referee and current user of caller
|
104
|
+
existing_articles = Goldencobra::Article.where(:creator_id => current_user.id, :external_referee_id => params[:referee_id])
|
105
|
+
if existing_articles.blank?
|
106
|
+
render status: 423, json: { :status => 423, :error => "article not found", :id => nil }
|
107
|
+
return
|
108
|
+
end
|
109
|
+
|
110
|
+
# Try to save the article
|
111
|
+
response = update_article(params[:article])
|
112
|
+
if response.id.present?
|
113
|
+
render status: 200, json: { :status => 200, :id => response.id }
|
114
|
+
|
115
|
+
#Erst render ergebnis dann den rest machen
|
116
|
+
if params[:images].present?
|
117
|
+
params[:images].each do |key,value|
|
118
|
+
existing_images = Goldencobra::Upload.where(:image_remote_url => value[:image][:image_url])
|
119
|
+
if existing_images.blank?
|
120
|
+
img = Goldencobra::Upload.create(value[:image])
|
121
|
+
else
|
122
|
+
img = existing_images.first
|
123
|
+
end
|
124
|
+
image_position = Goldencobra::Setting.for_key("goldencobra.article.image_positions").to_s.split(",").map(&:strip).first
|
125
|
+
existing_articles.first.article_images.create(:image => img, :position => image_position)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
else
|
130
|
+
render status: 500, json: { :status => 500, :error => response.errors, :id => nil }
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
protected
|
136
|
+
|
137
|
+
# Creates an article from the given article array.
|
138
|
+
# ---------------------------------------------------------------------------------------
|
139
|
+
def create_article(article_param)
|
140
|
+
|
141
|
+
# Input validation
|
142
|
+
return nil unless article_param
|
143
|
+
return nil unless params[:article]
|
144
|
+
return nil unless current_user
|
145
|
+
return nil unless params[:referee_id]
|
146
|
+
|
147
|
+
# Create a new article
|
148
|
+
new_article = Goldencobra::Article.new(params[:article])
|
149
|
+
new_article.creator_id = current_user.id
|
150
|
+
|
151
|
+
if params[:article][:article_type]
|
152
|
+
new_article.article_type = params[:article][:article_type]
|
153
|
+
else
|
154
|
+
new_article.article_type = 'Default Show'
|
155
|
+
end
|
156
|
+
|
157
|
+
if params[:author].present? && params[:author][:lastname].present?
|
158
|
+
author = Goldencobra::Author.find_or_create_by_lastname(params[:author][:lastname])
|
159
|
+
new_article.author = author
|
160
|
+
end
|
161
|
+
|
162
|
+
if params[:images].present?
|
163
|
+
params[:images].each do |i|
|
164
|
+
img = Goldencobra::Upload.create(i[:image])
|
165
|
+
article.images << img
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
#Set externel Referee
|
171
|
+
new_article.external_referee_id = params[:referee_id]
|
172
|
+
new_article.external_referee_ip = request.env['REMOTE_ADDR']
|
173
|
+
|
174
|
+
# Try to save the article
|
175
|
+
new_article.save
|
176
|
+
return new_article
|
177
|
+
end
|
178
|
+
|
179
|
+
|
180
|
+
def update_article(article_param)
|
181
|
+
# Input validation
|
182
|
+
return nil unless article_param
|
183
|
+
return nil unless params[:article]
|
184
|
+
return nil unless current_user
|
185
|
+
return nil unless params[:referee_id]
|
186
|
+
|
187
|
+
# Get existing article
|
188
|
+
article = Goldencobra::Article.where(:creator_id => current_user.id).find_by_external_referee_id(params[:referee_id])
|
189
|
+
|
190
|
+
if params[:author].present? && params[:author][:lastname].present?
|
191
|
+
author = Goldencobra::Author.find_or_create_by_lastname(params[:author][:lastname])
|
192
|
+
article.author = author
|
193
|
+
article.save
|
194
|
+
end
|
195
|
+
|
196
|
+
# if params[:images].present?
|
197
|
+
# params[:images].each do |key,value|
|
198
|
+
# existing_images = Goldencobra::Upload.where(:image_remote_url => value[:image][:image_url])
|
199
|
+
# if existing_images.blank?
|
200
|
+
# img = Goldencobra::Upload.create(value[:image])
|
201
|
+
# else
|
202
|
+
# img = existing_images.first
|
203
|
+
# end
|
204
|
+
# image_position = Goldencobra::Setting.for_key("goldencobra.article.image_positions").to_s.split(",").map(&:strip).first
|
205
|
+
# article.article_images.create(:image => img, :position => image_position)
|
206
|
+
# end
|
207
|
+
# end
|
208
|
+
|
209
|
+
# Update existing article
|
210
|
+
article.update_attributes(params[:article])
|
211
|
+
|
212
|
+
# Try to save the article
|
213
|
+
return article
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Goldencobra
|
4
|
+
module Api
|
5
|
+
module V2
|
6
|
+
class LocalesController < ActionController::Base
|
7
|
+
|
8
|
+
respond_to :text
|
9
|
+
|
10
|
+
# /api/v2/locale_string
|
11
|
+
# ---------------------------------------------------------------------------------------
|
12
|
+
def get_string
|
13
|
+
# check if we have the argument
|
14
|
+
unless params[:locale_key]
|
15
|
+
render status: 200, text: ""
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
# check if the locale_key contains something
|
20
|
+
if params[:locale_key].length == 0
|
21
|
+
render status: 200, text: ""
|
22
|
+
else
|
23
|
+
# get the translation for locale_key and return the locale value
|
24
|
+
render status: 200, text: t(params[:locale_key])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Goldencobra
|
4
|
+
module Api
|
5
|
+
module V2
|
6
|
+
class SettingsController < ActionController::Base
|
7
|
+
|
8
|
+
respond_to :text
|
9
|
+
|
10
|
+
# /api/v2/setting_string
|
11
|
+
# ---------------------------------------------------------------------------------------
|
12
|
+
def get_string
|
13
|
+
# check if we have the argument
|
14
|
+
unless params[:setting_key]
|
15
|
+
render status: 200, text: ""
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
# check if the setting_key contains something
|
20
|
+
if params[:setting_key].length == 0
|
21
|
+
render status: 200, text: ""
|
22
|
+
else
|
23
|
+
# get the translation for setting_key and return the locale value
|
24
|
+
render status: 200, text: s(params[:setting_key])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -4,6 +4,7 @@ module Goldencobra
|
|
4
4
|
class ArticlesController < Goldencobra::ApplicationController
|
5
5
|
layout "application"
|
6
6
|
before_filter :check_format
|
7
|
+
before_filter :get_redirectors, :only => [:show]
|
7
8
|
before_filter :get_article, :only => [:show, :convert_to_pdf]
|
8
9
|
before_filter :verify_token, :only => [:show]
|
9
10
|
before_filter :geocode_ip_address, only: [:show]
|
@@ -21,22 +22,26 @@ module Goldencobra
|
|
21
22
|
user_cache = current_user.present? ? current_user.id : "no_user"
|
22
23
|
flash_message = session.present? && session['flash'].present? ? Time.now.to_i : ""
|
23
24
|
auth_code = params[:auth_token].present? ? 'with_auth' : ''
|
24
|
-
|
25
|
+
offset = params[:start].present? ? "offset_#{params[:start].to_i}" : ""
|
26
|
+
limit = params[:limit].present? ? "limit_#{params[:limit].to_i}" : ""
|
27
|
+
generated_cache_key = "c-#{current_client_id}/g/#{I18n.locale.to_s}/#{geo_cache}/#{user_cache}/#{date_cache}/#{params[:article_id]}/#{art_cache}_#{params[:pdf]}_#{params[:frontend_tags]}__#{params[:iframe]}#{flash_message}_#{auth_code}#{offset}#{limit}"
|
28
|
+
return Zlib.crc32(generated_cache_key).to_s
|
25
29
|
end
|
26
30
|
|
27
31
|
|
28
32
|
def show
|
29
|
-
#flash[:confirmation] = "test"
|
30
33
|
ActiveSupport::Notifications.instrument("goldencobra.article.show", :params => params) #Possible Callbacks on start
|
31
34
|
before_init() #Possible Callbacks on start
|
35
|
+
params[:session] = session.except(:user_location)
|
36
|
+
Goldencobra::Article::LiquidParser["url_params"] = params
|
32
37
|
if serve_iframe?
|
33
38
|
respond_to do |format|
|
34
39
|
format.html { render layout: "/goldencobra/bare_layout" }
|
35
40
|
end
|
36
41
|
elsif serve_basic_article?
|
37
42
|
initialize_article(@article)
|
43
|
+
# TODO fix session_params like url_params mit liquid method
|
38
44
|
Goldencobra::Article.load_liquid_methods(location: session[:user_location], article: @article, params: params)
|
39
|
-
Goldencobra::Article::LiquidParser["url_params"] = params
|
40
45
|
load_associated_model_into_liquid() if can_load_associated_model?
|
41
46
|
after_init()
|
42
47
|
|
@@ -47,8 +52,8 @@ module Goldencobra
|
|
47
52
|
end
|
48
53
|
|
49
54
|
if serve_fresh_page?
|
50
|
-
|
51
|
-
|
55
|
+
set_expires_in()
|
56
|
+
ActiveSupport::Notifications.instrument("goldencobra.article.render", :params => params)
|
52
57
|
before_render()
|
53
58
|
respond_to do |format|
|
54
59
|
format.html { render layout: choose_layout() }
|
@@ -73,8 +78,12 @@ module Goldencobra
|
|
73
78
|
end
|
74
79
|
|
75
80
|
def switch_language
|
76
|
-
|
77
|
-
|
81
|
+
if params[:locale].present?
|
82
|
+
I18n.locale = params[:locale]
|
83
|
+
session[:locale] = I18n.locale.to_s
|
84
|
+
else
|
85
|
+
I18n.locale = session[:locale]
|
86
|
+
end
|
78
87
|
if params[:redirect_to].present?
|
79
88
|
redirect_to params[:redirect_to]
|
80
89
|
else
|
@@ -108,7 +117,7 @@ module Goldencobra
|
|
108
117
|
|
109
118
|
def get_article
|
110
119
|
if is_startpage?
|
111
|
-
I18n.locale =
|
120
|
+
I18n.locale = I18n.default_locale
|
112
121
|
@article = Goldencobra::Article.active.startpage.first
|
113
122
|
else
|
114
123
|
begin
|
@@ -122,7 +131,18 @@ module Goldencobra
|
|
122
131
|
end
|
123
132
|
|
124
133
|
|
134
|
+
|
125
135
|
# ------------------ Redirection ------------------------------------------
|
136
|
+
def get_redirectors
|
137
|
+
#check if Goldencobra::Redirector has any redirections, with match before rendering this article
|
138
|
+
#request.original_url
|
139
|
+
#base_request_url = request.original_url.to_s.split("?")[0] # nimmt nur den teil ohne urlparameter
|
140
|
+
redirect_url, redirect_code = Goldencobra::Redirector.get_by_request(request.original_url)
|
141
|
+
if redirect_url.present? && redirect_code.present?
|
142
|
+
redirect_to redirect_url, :status => redirect_code
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
126
146
|
def redirect_dynamically
|
127
147
|
target_article = @article.find_related_subarticle
|
128
148
|
if target_article.present?
|
@@ -187,7 +207,7 @@ module Goldencobra
|
|
187
207
|
end
|
188
208
|
|
189
209
|
def serve_basic_article?
|
190
|
-
@article && @article.external_url_redirect.blank? && @article.dynamic_redirection == "false"
|
210
|
+
@article.present? && @article.external_url_redirect.blank? && @article.dynamic_redirection == "false"
|
191
211
|
end
|
192
212
|
|
193
213
|
def serve_fresh_page?
|
@@ -254,14 +274,23 @@ module Goldencobra
|
|
254
274
|
@article = Goldencobra::Article.search_by_url(params[:article_id])
|
255
275
|
else
|
256
276
|
article = Goldencobra::Article.active.search_by_url(params[:article_id])
|
257
|
-
if article
|
277
|
+
if article.present?
|
258
278
|
operator = current_user || current_visitor
|
259
|
-
a = Ability.new(operator)
|
279
|
+
a = Ability.new(operator,@current_client)
|
280
|
+
logger.warn("###"*40)
|
281
|
+
logger.warn(a.can?(:read, article))
|
260
282
|
if a.can?(:read, article)
|
261
283
|
@article = article
|
262
284
|
else
|
263
285
|
@unauthorized = true
|
264
286
|
end
|
287
|
+
# elsif current_visitor.present?
|
288
|
+
# ap = Goldencobra::Permission.where(:subject_class => "Goldencobra::Article", :operator_id => current_visitor.id, :action => "read").pluck(:subject_id)
|
289
|
+
# if ap.any?
|
290
|
+
# @article = Goldencobra::Article.where("id in (?)", ap).search_by_url(params[:article_id])
|
291
|
+
# else
|
292
|
+
# @unauthorized = true
|
293
|
+
# end
|
265
294
|
end
|
266
295
|
end
|
267
296
|
end
|
@@ -285,11 +314,9 @@ module Goldencobra
|
|
285
314
|
if session[:user_location].blank?
|
286
315
|
#Geokit::Geocoders::MultiGeocoder.geocode("194.39.218.11") schlägt fehl (Completed 500 Internal Server Error) daher...
|
287
316
|
begin
|
288
|
-
|
289
|
-
|
317
|
+
@ip_result = Geokit::Geocoders::MultiGeocoder.geocode(request.remote_ip)
|
318
|
+
session[:user_location] = @ip_result
|
290
319
|
rescue Exception => e
|
291
|
-
logger.error("***********")
|
292
|
-
logger.error(e)
|
293
320
|
@ip_result = nil
|
294
321
|
end
|
295
322
|
if @ip_result.present? && @ip_result.city.present?
|
@@ -325,6 +352,5 @@ module Goldencobra
|
|
325
352
|
Goldencobra::Tracking.analytics(request, session[:user_location])
|
326
353
|
end
|
327
354
|
|
328
|
-
|
329
355
|
end
|
330
356
|
end
|