hera_cms 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ab63c7e96a93e9b9bad69355b57d5379aa28d7f5d1728bdd0402bad5243658b
4
- data.tar.gz: c1d924cd2a13543552fb3b64e61c6cab530a6b5e404dbba9b8c9a66c752b6245
3
+ metadata.gz: 59772e5b5e2184b62826db82401b6cca00739bdf9bc35388893ae081d4908793
4
+ data.tar.gz: bc2eb8324e8fd527e5002f1c23060e863effa81ed341859f06faa884014bee69
5
5
  SHA512:
6
- metadata.gz: f4846dfa4cbdd921f78b0ae60ac1cbdfff6f6416d71afbe16225b065082844b4c6ac531e30c7e1b5378e5610eaee234c6f1d188f9f5e2f295dc6387e1dc2eaea
7
- data.tar.gz: 2defba654284916930c0b0e98ab892a6193d23927a68eecdf29a4fd8ec27ee8187b8358fa97ff6a9659e6366ed777479829931cc67b3a28dcb954e7069a47bec
6
+ metadata.gz: cc0bce2b2b970264219687acfe7767fb344513404192811df7366f51ca0c05993ac39e4baad8b6342e6b429b7904308a45880c761e3d95961a1ebc8244e9ae64
7
+ data.tar.gz: 3c4608285ef81aec585c542f23755cf7c0f0dc342591077ee394fae576ddbf18038d16d8cf05cb0d4eacde69b880396e328e4357ffbc0f59bf3464a388ff2319
@@ -1,19 +1,7 @@
1
1
  require_dependency "hera_cms/application_controller"
2
- require 'json'
3
2
 
4
3
  module HeraCms
5
4
  class LinksController < ApplicationController
6
- # layout "admin"
7
-
8
- # def index
9
- # link_json = HeraCms::Link.read_json
10
- # @seed_link = JSON.pretty_generate(link_json)
11
- # @links = HeraCms::Link.all.order(created_at: :desc)
12
- # end
13
-
14
- # def edit
15
- # @link = HeraCms::Link.find(params[:id])
16
- # end
17
5
 
18
6
  def update
19
7
  @link = HeraCms::Link.find(params[:id])
@@ -25,32 +13,10 @@ module HeraCms
25
13
  end
26
14
  end
27
15
 
28
- # def new
29
- # @link = HeraCms::Link.new
30
- # end
31
-
32
- # def create
33
- # @link = HeraCms::Link.new(link_params)
34
-
35
- # @link[:translated_text] << translate_service.mount_translation(params[:link]["inner_text"])
36
-
37
- # if @HeraCms::link.save
38
- # redirect_to URI(request.referer).path
39
- # else
40
- # render :new
41
- # end
42
- # end
43
-
44
- # def destroy
45
- # @link = HeraCms::Link.find(params[:id])
46
- # @HeraCms::link.destroy
47
- # redirect_to URI(request.referer).path
48
- # end
49
-
50
16
  private
51
17
 
52
18
  def link_params
53
- params.require(:link).permit(:identifier, :classes, :style, :path)
19
+ params.require(:link).permit(:identifier, :classes, :style, :path, :inner_text)
54
20
  end
55
21
  end
56
22
  end
@@ -0,0 +1,22 @@
1
+ require_dependency "hera_cms/application_controller"
2
+
3
+ module HeraCms
4
+ class TextsController < ApplicationController
5
+
6
+ def update
7
+ @text = HeraCms::Text.find(params[:id])
8
+
9
+ if @text.update(text_params)
10
+ render json: { redirect: URI(request.referer).path }, status: 200
11
+ else
12
+ render json: { errors: @text.errors.full_messages }, status: 422
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def text_params
19
+ params.require(:text).permit(:identifier, :inner_text, :classes, :style)
20
+ end
21
+ end
22
+ end
@@ -29,53 +29,53 @@ module HeraCms
29
29
  end
30
30
 
31
31
  # BANNER
32
- def hera_media_banner(identifier, args={}, &block)
33
- media = HeraCms::Image.identify(identifier)
34
- identifier, upload, style = media.identifier, media.upload, media.style
35
- classes = set_classes(args, media)
36
-
37
- url = upload.url.to_s
38
- html_options = {
39
- class: classes,
40
- style: "background: url(\"#{url}\"); width: 100vw;, padding: 0; height: calc(100vh - 80px); background-position: center center; background-size: cover;",
41
- id: identifier,
42
- data: { editable_id: media.id, editable_type: media.model_name.route_key}
43
- }
44
- if block_given?
45
- content_tag(:div, "", html_options, &block)
46
- else
47
- content_tag(:div, "", html_options)
48
- end
49
- end
32
+ # def hera_media_banner(identifier, args={}, &block)
33
+ # media = HeraCms::Image.identify(identifier)
34
+ # identifier, upload, style = media.identifier, media.upload, media.style
35
+ # classes = set_classes(args, media)
36
+
37
+ # url = upload.url.to_s
38
+ # html_options = {
39
+ # class: classes,
40
+ # style: "background: url(\"#{url}\"); width: 100vw;, padding: 0; height: calc(100vh - 80px); background-position: center center; background-size: cover;",
41
+ # id: identifier,
42
+ # data: { editable_id: media.id, editable_type: media.model_name.route_key}
43
+ # }
44
+ # if block_given?
45
+ # content_tag(:div, "", html_options, &block)
46
+ # else
47
+ # content_tag(:div, "", html_options)
48
+ # end
49
+ # end
50
50
 
51
51
  # Assign media to rails helpers for videos and images
52
- def hera_image_tag(identifier, args = {})
53
- media = HeraCms::Image.identify(identifier)
54
- identifier, upload, style = media.identifier, media.upload, media.style
55
- classes = set_classes(args, media)
56
- args[:type] ||= "image"
57
- url = upload.url if upload
58
-
59
- html_options = {
60
- class: classes,
61
- style: style,
62
- id: identifier,
63
- data: { editable_id: media.id, editable_type: media.model_name.route_key}
64
- }
65
-
66
- if args[:type] == "video"
67
- content_tag(:div, video_tag(url, style: "max-width: 100%; max-height: 100%;"), html_options)
68
- else
69
- content_tag(:div, image_tag(url, style: "max-width: 100%; max-height: 100%;"), html_options)
70
- end
71
- end
52
+ # def hera_image_tag(identifier, args = {})
53
+ # media = HeraCms::Image.identify(identifier)
54
+ # identifier, upload, style = media.identifier, media.upload, media.style
55
+ # classes = set_classes(args, media)
56
+ # args[:type] ||= "image"
57
+ # url = upload.url if upload
58
+
59
+ # html_options = {
60
+ # class: classes,
61
+ # style: style,
62
+ # id: identifier,
63
+ # data: { editable_id: media.id, editable_type: media.model_name.route_key}
64
+ # }
65
+
66
+ # if args[:type] == "video"
67
+ # content_tag(:div, video_tag(url, style: "max-width: 100%; max-height: 100%;"), html_options)
68
+ # else
69
+ # content_tag(:div, image_tag(url, style: "max-width: 100%; max-height: 100%;"), html_options)
70
+ # end
71
+ # end
72
72
 
73
73
  # Generate HTML tag
74
74
  def hera_text(identifier, args = {})
75
75
  text = Text.identify(identifier)
76
- inner_text, style, identifier = translate_service.translate(text), text.style, text.identifier
76
+ inner_text, style, identifier = text.inner_text, text.style, text.identifier
77
77
  classes = set_classes(args, text)
78
- args[:html_tag] ||= "div"
78
+ args[:html_tag] ||= "p"
79
79
 
80
80
  html_options = {
81
81
  class: classes,
@@ -87,25 +87,25 @@ module HeraCms
87
87
  end
88
88
 
89
89
  # Generate Form Tag
90
- def hera_form(identifier, args = {})
91
- form = Form.identify(identifier)
92
- set_editable(form) unless args[:editable] == false
93
- identifier, send_to, classes, style = form.identifier, form.send_to, form.classes, form.style
94
- html_options = {
95
- class: classes,
96
- style: style,
97
- id: identifier,
98
- data: { editable_id: form.id, editable_type: form.model_name.route_key, mail: form.send_to}
99
- }
100
- form_tag("/contact", html_options ) do
101
- concat hidden_field_tag("form_id", form.id)
102
- concat text_field_tag('name',"", placeholder: "Nome")
103
- concat text_field_tag('email',"", placeholder: "E-mail")
104
- concat text_field_tag('phone',"", placeholder: "Telefone")
105
- concat text_area_tag('message',"", placeholder: "Digite sua mensagem aqui")
106
- concat submit_tag('Enviar')
107
- end
108
- end
90
+ # def hera_form(identifier, args = {})
91
+ # form = Form.identify(identifier)
92
+ # set_editable(form) unless args[:editable] == false
93
+ # identifier, send_to, classes, style = form.identifier, form.send_to, form.classes, form.style
94
+ # html_options = {
95
+ # class: classes,
96
+ # style: style,
97
+ # id: identifier,
98
+ # data: { editable_id: form.id, editable_type: form.model_name.route_key, mail: form.send_to}
99
+ # }
100
+ # form_tag("/contact", html_options ) do
101
+ # concat hidden_field_tag("form_id", form.id)
102
+ # concat text_field_tag('name',"", placeholder: "Nome")
103
+ # concat text_field_tag('email',"", placeholder: "E-mail")
104
+ # concat text_field_tag('phone',"", placeholder: "Telefone")
105
+ # concat text_area_tag('message',"", placeholder: "Digite sua mensagem aqui")
106
+ # concat submit_tag('Enviar')
107
+ # end
108
+ # end
109
109
 
110
110
  def set_editable(editable)
111
111
  editable.classes += " hera-editable" if editable.editable? && (editable.classes && !editable.classes.include?("hera-editable"))
@@ -110,7 +110,7 @@ const sendRequest = (e) => {
110
110
  fetch(url, options)
111
111
  .then(response => response.json())
112
112
  .then((data) => {
113
- console.log(data);
113
+ window.location.replace(data.redirect);
114
114
  });
115
115
 
116
116
  console.log('end');
@@ -152,7 +152,7 @@ const createForm = (e) => {
152
152
  form = linkForm(form, editable);
153
153
  break;
154
154
  case 'media_index':
155
- form = mediaForm(form, editable);
155
+ form = imageForm(form, editable);
156
156
  break;
157
157
  case 'texts':
158
158
  form = textForm(form, editable);
@@ -189,8 +189,7 @@ const createForm = (e) => {
189
189
  let screenWidth = window.screen.width;
190
190
  let relativeY = (boxPositionY / screenHeight) * screenHeight;
191
191
  let relativeX = boxPositionX / screenWidth * screenWidth;
192
- console.log(relativeX);
193
- console.log(screenWidth/2);
192
+
194
193
  if(relativeX > screenWidth / 2){
195
194
  formBox.style.left = "-308px";
196
195
  }else{
@@ -231,18 +230,28 @@ const createForm = (e) => {
231
230
 
232
231
  const linkForm = (form, editable) => {
233
232
 
234
- // Creates text input for the content of the element and appends it to the form
235
- i = document.createElement("input");
236
- i.setAttribute('type', "text");
237
- i.setAttribute('name', "link[path]");
238
- i.setAttribute('value', editable);
233
+ // Creates text input for the content of the element and appends it to the form
234
+ pathInput = document.createElement("input");
235
+ pathInput.setAttribute('type', "text");
236
+ pathInput.setAttribute('name', "link[path]");
237
+ pathInput.setAttribute('autocomplete', "off");
238
+ pathInput.setAttribute('value', editable);
239
239
 
240
- form.appendChild(i);
240
+ form.appendChild(pathInput);
241
241
 
242
- return form;
242
+ // Creates text input for the content of the element and appends it to the form
243
+ innerTextInput = document.createElement("input");
244
+ innerTextInput.setAttribute('type', "text");
245
+ innerTextInput.setAttribute('name', "link[inner_text]");
246
+ innerTextInput.setAttribute('autocomplete', "off");
247
+ innerTextInput.innerHTML = editable.innerText;
248
+ innerTextInput.setAttribute('value', editable.innerText);
249
+
250
+ form.appendChild(innerTextInput);
251
+ return form;
243
252
  }
244
253
 
245
- const mediaForm = (form, editable) => {
254
+ const imageForm = (form, editable) => {
246
255
 
247
256
  // Creates text input for the content of the element and appends it to the form
248
257
  i = document.createElement("input");
@@ -266,6 +275,7 @@ const textForm = (form, editable) => {
266
275
  i = document.createElement("textarea");
267
276
  i.setAttribute('type', "text");
268
277
  i.setAttribute('name', "text[inner_text]");
278
+ i.setAttribute('autocomplete', "off");
269
279
  i.innerHTML = editable.innerText;
270
280
  i.setAttribute('value', editable.innerText);
271
281
 
data/config/routes.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  HeraCms::Engine.routes.draw do
2
- root to: "dashboard#home"
2
+ # root to: "dashboard#home"
3
3
 
4
4
  resources :links, only: :update
5
+ resources :texts, only: :update
5
6
  end
@@ -1,3 +1,3 @@
1
1
  module HeraCms
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hera_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rayan Castro
@@ -149,8 +149,8 @@ files:
149
149
  - app/controllers/hera_cms/base_controller.rb
150
150
  - app/controllers/hera_cms/dashboard_controller.rb
151
151
  - app/controllers/hera_cms/links_controller.rb
152
+ - app/controllers/hera_cms/texts_controller.rb
152
153
  - app/helpers/hera_cms/application_helper.rb
153
- - app/helpers/hera_cms/links_helper.rb
154
154
  - app/helpers/hera_cms/tag_helper.rb
155
155
  - app/jobs/hera_cms/application_job.rb
156
156
  - app/mailers/hera_cms/application_mailer.rb
@@ -1,4 +0,0 @@
1
- module HeraCms
2
- module LinksHelper
3
- end
4
- end