breeze_cms 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +24 -0
  4. data/Rakefile +6 -0
  5. data/app/assets/config/breeze_manifest.js +2 -0
  6. data/app/assets/images/breeze/breeze_logo.png +0 -0
  7. data/app/assets/images/breeze/card_preview/card_feature_box.png +0 -0
  8. data/app/assets/images/breeze/card_preview/card_feature_normal.png +0 -0
  9. data/app/assets/images/breeze/card_preview/card_full_image.png +0 -0
  10. data/app/assets/images/breeze/card_preview/card_gap_square.png +0 -0
  11. data/app/assets/images/breeze/card_preview/card_large_image.png +0 -0
  12. data/app/assets/images/breeze/card_preview/card_normal_round.png +0 -0
  13. data/app/assets/images/breeze/card_preview/card_normal_square.png +0 -0
  14. data/app/assets/images/breeze/card_preview/card_wide_square.png +0 -0
  15. data/app/assets/images/breeze/card_preview/form_field.png +0 -0
  16. data/app/assets/images/breeze/home.jpg +0 -0
  17. data/app/assets/images/breeze/section_preview/blog_header.png +0 -0
  18. data/app/assets/images/breeze/section_preview/form_section.png +0 -0
  19. data/app/assets/images/breeze/section_preview/section_cards.png +0 -0
  20. data/app/assets/images/breeze/section_preview/section_feature.png +0 -0
  21. data/app/assets/images/breeze/section_preview/section_full_image.png +0 -0
  22. data/app/assets/images/breeze/section_preview/section_full_up.png +0 -0
  23. data/app/assets/images/breeze/section_preview/section_half_image.png +0 -0
  24. data/app/assets/images/breeze/section_preview/section_large_image.png +0 -0
  25. data/app/assets/images/breeze/section_preview/section_news.png +0 -0
  26. data/app/assets/images/breeze/section_preview/section_slider.png +0 -0
  27. data/app/assets/images/breeze/section_preview/section_small_image.png +0 -0
  28. data/app/assets/images/breeze/section_preview/section_spacer.png +0 -0
  29. data/app/assets/images/breeze/section_preview/section_text.png +0 -0
  30. data/app/assets/javascript/breeze_application.js.rb +101 -0
  31. data/app/assets/javascript/marked.js +6 -0
  32. data/app/assets/stylesheets/breeze/breeze.css +3633 -0
  33. data/app/assets/stylesheets/breeze/breeze.email.css +1344 -0
  34. data/app/assets/stylesheets/breeze.tailwind.css +2 -0
  35. data/app/assets/stylesheets/breeze_tailwind_styles.css +21 -0
  36. data/app/assets/stylesheets/tailwind_base.css +3 -0
  37. data/app/controllers/breeze/application_controller.rb +4 -0
  38. data/app/controllers/breeze/breeze_controller.rb +16 -0
  39. data/app/controllers/breeze/cards_controller.rb +58 -0
  40. data/app/controllers/breeze/changes_controller.rb +45 -0
  41. data/app/controllers/breeze/form_controller.rb +67 -0
  42. data/app/controllers/breeze/images_controller.rb +100 -0
  43. data/app/controllers/breeze/pages_controller.rb +66 -0
  44. data/app/controllers/breeze/sections_controller.rb +96 -0
  45. data/app/controllers/breeze/styles_controller.rb +11 -0
  46. data/app/controllers/breeze/translations_controller.rb +56 -0
  47. data/app/controllers/breeze/view_controller.rb +10 -0
  48. data/app/helpers/breeze/breeze_helper.rb +54 -0
  49. data/app/helpers/breeze/cards_helper.rb +11 -0
  50. data/app/helpers/breeze/changes_helper.rb +29 -0
  51. data/app/helpers/breeze/form_helper.rb +5 -0
  52. data/app/helpers/breeze/images_helper.rb +57 -0
  53. data/app/helpers/breeze/options_helper.rb +120 -0
  54. data/app/helpers/breeze/pages_helper.rb +5 -0
  55. data/app/helpers/breeze/sections_helper.rb +14 -0
  56. data/app/helpers/breeze/styles_helper.rb +4 -0
  57. data/app/helpers/breeze/translations_helper.rb +14 -0
  58. data/app/helpers/breeze/view_helper.rb +74 -0
  59. data/app/jobs/breeze/application_job.rb +4 -0
  60. data/app/mailers/breeze/application_mailer.rb +6 -0
  61. data/app/models/breeze/active_base.rb +34 -0
  62. data/app/models/breeze/active_yaml.rb +143 -0
  63. data/app/models/breeze/card.rb +90 -0
  64. data/app/models/breeze/card_style.rb +12 -0
  65. data/app/models/breeze/change_set.rb +58 -0
  66. data/app/models/breeze/image.rb +104 -0
  67. data/app/models/breeze/option_definition.rb +43 -0
  68. data/app/models/breeze/page.rb +97 -0
  69. data/app/models/breeze/page_style.rb +12 -0
  70. data/app/models/breeze/section.rb +137 -0
  71. data/app/models/breeze/section_style.rb +17 -0
  72. data/app/models/breeze/shared_base.rb +20 -0
  73. data/app/models/breeze/style.rb +17 -0
  74. data/app/models/breeze/translation.rb +83 -0
  75. data/app/models/breeze/view_base.rb +134 -0
  76. data/app/views/breeze/cards/index.haml +84 -0
  77. data/app/views/breeze/changes/index.haml +52 -0
  78. data/app/views/breeze/form/_editor.haml +33 -0
  79. data/app/views/breeze/form/form.haml +8 -0
  80. data/app/views/breeze/images/_editor.haml +144 -0
  81. data/app/views/breeze/images/index.haml +83 -0
  82. data/app/views/breeze/images/new.haml +12 -0
  83. data/app/views/breeze/images/show.haml +60 -0
  84. data/app/views/breeze/pages/_sections.rabl +4 -0
  85. data/app/views/breeze/pages/index.haml +49 -0
  86. data/app/views/breeze/pages/show.haml +85 -0
  87. data/app/views/breeze/sections/_option_form_date.haml +4 -0
  88. data/app/views/breeze/sections/_option_form_select.haml +4 -0
  89. data/app/views/breeze/sections/_option_form_text.haml +4 -0
  90. data/app/views/breeze/sections/_overlay.haml +33 -0
  91. data/app/views/breeze/sections/_section.rabl +5 -0
  92. data/app/views/breeze/sections/_sections_pagination.haml +29 -0
  93. data/app/views/breeze/sections/index.haml +88 -0
  94. data/app/views/breeze/sections/new.haml +12 -0
  95. data/app/views/breeze/sections/select_card_template.haml +13 -0
  96. data/app/views/breeze/sections/select_template.haml +15 -0
  97. data/app/views/breeze/sections/show.haml +91 -0
  98. data/app/views/breeze/styles/_options.haml +9 -0
  99. data/app/views/breeze/styles/index.haml +84 -0
  100. data/app/views/breeze/translations/_row.haml +29 -0
  101. data/app/views/breeze/translations/show.haml +79 -0
  102. data/app/views/breeze/view/_blog_header.haml +13 -0
  103. data/app/views/breeze/view/_form_section.haml +21 -0
  104. data/app/views/breeze/view/_section_cards.haml +17 -0
  105. data/app/views/breeze/view/_section_feature.haml +13 -0
  106. data/app/views/breeze/view/_section_full_image.haml +10 -0
  107. data/app/views/breeze/view/_section_full_up.haml +11 -0
  108. data/app/views/breeze/view/_section_half_image.haml +13 -0
  109. data/app/views/breeze/view/_section_large_image.haml +13 -0
  110. data/app/views/breeze/view/_section_news.haml +16 -0
  111. data/app/views/breeze/view/_section_slider.haml +51 -0
  112. data/app/views/breeze/view/_section_small_image.haml +11 -0
  113. data/app/views/breeze/view/_section_spacer.haml +1 -0
  114. data/app/views/breeze/view/_section_text.haml +17 -0
  115. data/app/views/breeze/view/cards/_card_feature_box.haml +13 -0
  116. data/app/views/breeze/view/cards/_card_feature_normal.haml +7 -0
  117. data/app/views/breeze/view/cards/_card_full_image.haml +10 -0
  118. data/app/views/breeze/view/cards/_card_gap_square.haml +11 -0
  119. data/app/views/breeze/view/cards/_card_large_image.haml +6 -0
  120. data/app/views/breeze/view/cards/_card_normal_round.haml +8 -0
  121. data/app/views/breeze/view/cards/_card_normal_square.haml +9 -0
  122. data/app/views/breeze/view/cards/_card_wide_square.haml +8 -0
  123. data/app/views/breeze/view/cards/_form_field.haml +8 -0
  124. data/app/views/breeze/view/elements/_button.haml +4 -0
  125. data/app/views/breeze/view/page.haml +2 -0
  126. data/app/views/layouts/breeze/_header.haml +37 -0
  127. data/app/views/layouts/breeze/_messages.haml +28 -0
  128. data/app/views/layouts/breeze/application.haml +20 -0
  129. data/app/views/layouts/mailer.html.haml +8 -0
  130. data/app/views/layouts/mailer.text.erb +1 -0
  131. data/config/breeze/card_styles.yml +129 -0
  132. data/config/breeze/option_definitions.yml +129 -0
  133. data/config/breeze/page_styles.yml +12 -0
  134. data/config/breeze/section_styles.yml +199 -0
  135. data/config/initializers/breeze.rb +13 -0
  136. data/config/initializers/rabl.rb +31 -0
  137. data/config/initializers/simple_form.rb +212 -0
  138. data/config/routes.rb +40 -0
  139. data/config/tailwind.config.js +17 -0
  140. data/config/tailwind.email.js +14 -0
  141. data/lib/breeze/engine.rb +97 -0
  142. data/lib/breeze/shared_helper.rb +44 -0
  143. data/lib/breeze/version.rb +3 -0
  144. data/lib/breeze.rb +104 -0
  145. data/lib/generators/breeze/install/install_generator.rb +19 -0
  146. data/lib/generators/breeze/install/templates/empty.yml +1 -0
  147. data/lib/generators/breeze/install/templates/initializer.rb +70 -0
  148. data/lib/generators/breeze/update/update_generator.rb +11 -0
  149. data/lib/tasks/condense.rake +60 -0
  150. data/lib/tasks/consistency.rake +84 -0
  151. metadata +371 -0
@@ -0,0 +1,2 @@
1
+ @import "./tailwind_base.css";
2
+ @import "./breeze_tailwind_styles.css";
@@ -0,0 +1,21 @@
1
+ .prose {
2
+ max-width: 100%;
3
+ color: inherit;
4
+ --tw-prose-bullets: #6b7280;
5
+ --tw-prose-headings: inherit;
6
+ }
7
+
8
+ @layer components {
9
+ .button {
10
+ @apply inline-block rounded-lg px-3 py-2 text-base font-medium border border-gray-500 hover:border-black;
11
+ }
12
+ .change {
13
+ @apply bg-cyan-200;
14
+ }
15
+ .remove {
16
+ @apply bg-red-200;
17
+ }
18
+ .action {
19
+ @apply bg-green-200;
20
+ }
21
+ }
@@ -0,0 +1,3 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
@@ -0,0 +1,4 @@
1
+ module Breeze
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,16 @@
1
+ module Breeze
2
+ class BreezeController < ::ApplicationController
3
+ before_action :authenticate_if
4
+ layout "breeze/application"
5
+
6
+ def authenticate_if
7
+ return unless respond_to? :"authenticate_member!"
8
+ authenticate_member!
9
+ end
10
+
11
+ def current_member_email
12
+ return "breeze_user" unless respond_to? :current_member
13
+ current_member.email
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,58 @@
1
+ module Breeze
2
+ class CardsController < BreezeController
3
+ before_action :set_card , except: [:index , :new]
4
+
5
+ def index
6
+ @section = Section.find(params[:section_id])
7
+ end
8
+
9
+ def set_image
10
+ @card.image_id = params[:image_id].to_i
11
+ @card.edit_save(current_member_email)
12
+ message = @card.image ? "#{@card.image.name} selected" : "Image removed"
13
+ redirect_to section_cards_url(@card.section.id) , notice: message
14
+ end
15
+
16
+ def move
17
+ if( params[:dir] == "up")
18
+ @card.move_up
19
+ else
20
+ @card.move_down
21
+ end
22
+ @card.edit_save(current_member_email)
23
+ redirect_to section_cards_url(@card.section.id),notice: "#{@card.header} moved"
24
+ end
25
+
26
+ def new
27
+ @section = Section.find(params[:section_id] || params[:card_id])
28
+ new_card = @section.new_card
29
+ new_card.add_save(current_member_email)
30
+ redirect_to section_cards_url(@section.id) , notice: "Card created"
31
+ end
32
+
33
+ def destroy
34
+ @card.delete_and_reset_index(current_member_email)
35
+ redirect_to section_cards_url(@card.section.id) , notice: "#{@card.header} removed"
36
+ end
37
+
38
+ def update
39
+ @card.update(params[:card])
40
+ @card.update_options( params[:options])
41
+ @card.edit_save(current_member_email)
42
+ respond_to do |format|
43
+ format.html do
44
+ redirect_to section_cards_url(@card.section_id) , notice: "Updated #{@card.header}"
45
+ end
46
+ format.json { render status: 200, json: {} }
47
+ end
48
+
49
+ end
50
+
51
+ private
52
+ def set_card
53
+ card_id = params[:id] || params[:card_id]
54
+ @card = Card.find( card_id )
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,45 @@
1
+ require "open3"
2
+
3
+ module Breeze
4
+ class ChangesController < BreezeController
5
+
6
+ def index
7
+ end
8
+
9
+ def commit
10
+ if params[:message].blank?
11
+ message = "must have message"
12
+ redirect_to changes_index_url , alert: message
13
+ else
14
+ out = capture("git add breeze")
15
+ out = capture("git add #{Image.asset_root}" , out)
16
+ out = capture("git config --local user.email #{current_member_email}" ,out)
17
+ out = capture('git commit -m "' + params[:message] + '"' ,out)
18
+ out = capture("git pull --rebase=true" ,out)
19
+ out = capture("git push" ,out)
20
+ ChangeSet.current.zero
21
+ redirect_to changes_index_url , notice: "Changes commited, #{out}"
22
+ end
23
+ end
24
+
25
+ def reset
26
+ begin
27
+ out = capture("git checkout #{Breeze.data_dir}")
28
+ out = capture("git checkout #{Breeze::Image.asset_root}" , out)
29
+ ChangeSet.current.zero
30
+ message = "Changes reset"
31
+ rescue
32
+ message = "Unknown error occured"
33
+ end
34
+ redirect_to changes_index_url , notice: message
35
+ end
36
+
37
+ private
38
+ def capture(cmd , previous = "")
39
+ out , ignore_status = Open3.capture2e(cmd)
40
+ puts "CMD:#{ignore_status}: #{cmd}"
41
+ puts out
42
+ previous + "\n" + out
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,67 @@
1
+ module Breeze
2
+ class FormController < ::ApplicationController
3
+
4
+ def post
5
+ @section = Section.find( params[:section_id] )
6
+ @errors = { }
7
+ return if bot_alert
8
+ check_maths
9
+ verify_data
10
+ if( @errors.length > 0)
11
+ render "breeze/form/form"
12
+ else
13
+ dispatch_form_data( )
14
+ redirect_to main_app.root_url , notice: @section.option("ok_message")
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def dispatch_form_data
21
+ puts "Dispatch data"
22
+ data = {}
23
+ @section.cards.each do |card|
24
+ data[card.header] = params[card.header]
25
+ end
26
+ if(@section.has_option?("handler") )
27
+ puts "Sending data"
28
+ @section.option("handler").constantize.new.handle_form(@section, data)
29
+ end
30
+ end
31
+
32
+ def verify_data
33
+ @section.cards.each do |card|
34
+ check_option( card , params[card.header])
35
+ end
36
+ end
37
+ def check_option(card , value)
38
+ return unless value.blank?
39
+ compulsory = card.option("compulsory") != "no"
40
+ return unless compulsory
41
+ # check different types
42
+ message = card.text
43
+ message = "May not be empty" if message.blank?
44
+ @errors[card.header] = message
45
+ end
46
+
47
+ def check_maths
48
+ key = params[:bot_fudder].to_i / 2
49
+ if( (2*key + 1).to_s != params[:challenge])
50
+ @errors[:challenge] = "Check the anti bot maths, it wasn't: #{params[:challenge]}"
51
+ end
52
+ end
53
+
54
+ def bot_alert
55
+ if @section.nil?
56
+ head :ok
57
+ return true
58
+ end
59
+ key = params[:bot_fudder]
60
+ if key.to_i.to_s != key
61
+ head :ok
62
+ return true
63
+ end
64
+ return false
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,100 @@
1
+ require "mini_magick"
2
+
3
+ module Breeze
4
+ class ImagesController < BreezeController
5
+ before_action :set_image, only: %i[ update destroy show scale crop copy ]
6
+
7
+ def index
8
+ @images = get_images
9
+ @image_data = @images.collect{|i|
10
+ data = i.data.dup
11
+ data[:url] = view_context.asset_path(i.asset_name)
12
+ data[:link] = build_select_link_for(i)
13
+ data[:updated_at] = i.updated_at.to_date if i.updated_at
14
+ data[:created] = i.updated_at.to_i
15
+ data[:aspect_ratio] = i.aspect_ratio.join("/")
16
+ data[:ratio] = i.aspect_ratio
17
+ data
18
+ }
19
+ end
20
+
21
+ def destroy
22
+ @image.destroy(current_member_email)
23
+ redirect_to :images , notice: "Image #{@image.name} deleted"
24
+ end
25
+
26
+ def update
27
+ @image.name = params[:name]
28
+ @image.tags = params[:tags]
29
+ @image.edit_save(current_member_email)
30
+ redirect_to image_path(@image) , notice: "Image updated"
31
+ end
32
+
33
+ def scale
34
+ @image.scale( params[:scale] )
35
+ @image.edit_save(current_member_email)
36
+ redirect_to image_path(@image) , notice: "Image was scaled"
37
+ end
38
+
39
+ def crop
40
+ size = "#{params[:size_x]}x#{params[:size_y]}+#{params[:off_x]}+#{params[:off_y]}"
41
+ @image.crop( size )
42
+ @image.edit_save(current_member_email)
43
+ redirect_to image_path(@image) , notice: "Image was resized"
44
+ end
45
+
46
+ def show
47
+ @sections = Section.find_all(:image_id, params[:id].to_i)
48
+ @cards = Card.find_all(:image_id, params[:id].to_i)
49
+ @used = ((@cards.length > 0) || (@sections.length > 0))
50
+ @image_data = @image.data
51
+ end
52
+
53
+ def copy
54
+ image = @image.copy
55
+ image.add_save(current_member_email)
56
+ redirect_to image_path(image.id) , notice: "Image copied"
57
+ end
58
+
59
+ def create
60
+ image = Image.create_new(params['filename'] ,params['tags'], params['image_file'])
61
+ image.add_save current_member_email
62
+ where_to = determine_redirect(image)
63
+ redirect_to where_to , notice: "New image created: #{image.name}"
64
+ end
65
+
66
+ private
67
+
68
+ def get_images
69
+ images = Image.all
70
+ return images unless params[:unused]
71
+ hash = images.collect{|i| [i.id , i ] }.to_h
72
+ Section.all.each{ |s| hash.delete(s.image&.id)}
73
+ Card.all.each{ |s| hash.delete(s.image&.id)}
74
+ hash.values
75
+ end
76
+ def set_image
77
+ @image = Image.find(params[:id] || params[:image_id])
78
+ end
79
+ def determine_redirect(image)
80
+ if(params[:section_id])
81
+ view_context.section_set_image_url(params[:section_id],image_id: image.id )
82
+ elsif(params[:card_id])
83
+ view_context.card_set_image_url(params[:card_id],image_id: image.id )
84
+ else
85
+ :images
86
+ end
87
+ end
88
+
89
+ def build_select_link_for(image)
90
+ if(params[:section_id])
91
+ return view_context.section_set_image_url(params[:section_id] , image_id: image.id)
92
+ end
93
+ if(params[:card_id])
94
+ return view_context.card_set_image_url(params[:card_id] , image_id: image.id)
95
+ end
96
+ view_context.image_url(image.id)
97
+ end
98
+ end
99
+
100
+ end
@@ -0,0 +1,66 @@
1
+ module Breeze
2
+ class PagesController < BreezeController
3
+
4
+ before_action :set_page, only: %i[ update destroy show ]
5
+
6
+ def index
7
+ if(! params[:type].blank?)
8
+ @pages = Page.find_all(:type, params[:type])
9
+ else
10
+ @pages = Page.all
11
+ end
12
+ @page_styles = PageStyle.all
13
+ end
14
+
15
+ def show
16
+
17
+ end
18
+
19
+ def update
20
+ if( !params[:name].blank? && (params[:name] != @page.name))
21
+ @page.set_name params[:name]
22
+ @page.edit_save(current_member_email)
23
+ message = "Page renamed"
24
+ end
25
+ options = params[:option]
26
+ if options
27
+ @page.option_definitions.each do |option|
28
+ @page.set_option(option.name, options[option.name])
29
+ end
30
+ @page.edit_save(current_member_email)
31
+ message = "Options saved"
32
+ end
33
+ redirect_to page_url(@page) , notice: message
34
+ end
35
+
36
+ def create
37
+ name = params[:name]
38
+ if( name.blank? )
39
+ flash.alert = "Must enter name"
40
+ redirect_to pages_url
41
+ else
42
+ @page = Page.new_page(name , params[:type])
43
+ @page.add_save(current_member_email)
44
+ template = PageStyle.find_by_type(@page.type).section_template
45
+ if(template)
46
+ section = @page.new_section(template)
47
+ section.add_save(current_member_email)
48
+ redirect_to section_url(section.id) , notice: "Page was successfully created."
49
+ else
50
+ redirect_to page_url(@page.id) , notice: "Page was successfully created. Choose first section"
51
+ end
52
+ end
53
+ end
54
+
55
+ def destroy
56
+ @page.delete_save!(current_member_email)
57
+ redirect_to pages_url, notice: "Page #{@page.name} was removed."
58
+ end
59
+
60
+ private
61
+ def set_page
62
+ @page = Page.find(params[:id])
63
+ end
64
+
65
+ end
66
+ end
@@ -0,0 +1,96 @@
1
+ module Breeze
2
+ class SectionsController < BreezeController
3
+ before_action :set_section , except: [:index, :new]
4
+
5
+ def index
6
+ @page = Page.find(params[:page_id])
7
+ end
8
+
9
+ def show
10
+ @ids = [ @section.type_id ]
11
+ end
12
+
13
+ def select_template
14
+ @sections = SectionStyle.all
15
+ end
16
+
17
+ def select_card_template
18
+ @cards = CardStyle.all
19
+ end
20
+
21
+ def new
22
+ page = Page.find(params[:page_id] || params[:section_id])
23
+ template = params[:template]
24
+ new_section = page.new_section(template)
25
+ new_section.add_save(current_member_email)
26
+ if(template.blank?) # new
27
+ redirect_to section_select_template_url(new_section.id), notice: "New section created"
28
+ else # copy
29
+ redirect_to section_url(new_section.id), notice: "Section copied"
30
+ end
31
+ end
32
+
33
+ def destroy
34
+ @section.delete_and_reset_index(current_member_email)
35
+ redirect_to page_sections_url(@section.page.id) , notice: "Section #{@section.header} removed"
36
+ end
37
+
38
+ def set_image
39
+ @section.image_id = params[:image_id].to_i
40
+ @section.edit_save(current_member_email)
41
+ message = @section.image ? "#{@section.image.name} selected" : "Image removed"
42
+ redirect_to section_url(@section.id) , notice: message
43
+ end
44
+
45
+ def set_template
46
+ template = params[:template]
47
+ raise "no template given" if template.blank?
48
+ style = SectionStyle.find_by_template(template)
49
+ raise "no such template #{template}" unless style
50
+ if(! style.has_cards?)
51
+ if( @section.cards.length > 0 )
52
+ redirect_to section_url(@section.id) , alert: "Must delete cards first"
53
+ return
54
+ end
55
+ @section.card_template = ""
56
+ end
57
+ @section.set_template( template )
58
+ @section.edit_save(current_member_email)
59
+ redirect_to section_url(@section.id)
60
+ end
61
+
62
+ def set_card_template
63
+ card_template = params[:card_template]
64
+ raise "no card template given" if card_template.blank?
65
+ @section.card_template = card_template
66
+ @section.edit_save(current_member_email)
67
+ redirect_to section_url(@section.id)
68
+ end
69
+
70
+ def move
71
+ if( params[:dir] == "up")
72
+ @section.move_up
73
+ else
74
+ @section.move_down
75
+ end
76
+ @section.edit_save(current_member_email)
77
+ redirect_to page_sections_url(@section.page.id)
78
+ end
79
+
80
+ def update
81
+ @section.update(params[:section])
82
+ @section.update_options( params[:options])
83
+ @section.edit_save(current_member_email)
84
+ respond_to do |format|
85
+ format.html { redirect_to :section , notice: "Update ok" }
86
+ format.json { render status: 200, json: {} }
87
+ end
88
+ end
89
+
90
+ private
91
+ def set_section
92
+ @section = Section.find( params[:id] || params[:section_id] )
93
+ end
94
+
95
+ end
96
+ end
@@ -0,0 +1,11 @@
1
+ module Breeze
2
+ class StylesController < BreezeController
3
+
4
+ def index
5
+ @page_styles = PageStyle.all
6
+ @section_styles = SectionStyle.all
7
+ @cards_styles = CardStyle.all
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,56 @@
1
+ module Breeze
2
+ class TranslationsController < BreezeController
3
+ before_action :set_translation, only: %i[ edit update destroy ]
4
+
5
+ # show all translation for a page
6
+ def show
7
+ @page = Page.find(params[:id].to_i)
8
+ end
9
+
10
+ # GET /translations/new
11
+ def new
12
+ @translation = Translation.new
13
+ end
14
+
15
+ # GET /translations/1/edit
16
+ def edit
17
+ end
18
+
19
+ # POST /translations
20
+ def create
21
+ @translation = Translation.new(translation_params)
22
+
23
+ if @translation.save
24
+ redirect_to @translation, notice: "Translation was successfully created."
25
+ else
26
+ render :new, status: :unprocessable_entity
27
+ end
28
+ end
29
+
30
+ # PATCH/PUT /translations/1
31
+ def update
32
+ respond_to do |format|
33
+ @translation.update(params[:translation] , "user")
34
+ format.html { redirect_to(@translation, :notice => 'User was successfully updated.') }
35
+ format.json { render status: 200, json: {} }
36
+ end
37
+ end
38
+
39
+ # DELETE /translations/1
40
+ def destroy
41
+ @translation.destroy
42
+ redirect_to translations_url, notice: "Translation was successfully destroyed.", status: :see_other
43
+ end
44
+
45
+ private
46
+ # Use callbacks to share common setup or constraints between actions.
47
+ def set_translation
48
+ @translation = Translation.find(params[:id])
49
+ end
50
+
51
+ # Only allow a list of trusted parameters through.
52
+ def translation_params
53
+ params.fetch(:translation, {})
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,10 @@
1
+ module Breeze
2
+ class ViewController < ::ApplicationController
3
+
4
+ def page
5
+ @page = Page.find_by_name(params[:id])
6
+ redirect_to "/" , alert: "No page #{params[:id]}" unless @page
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,54 @@
1
+
2
+ module Breeze
3
+ module BreezeHelper
4
+ include OptionsHelper
5
+ include SharedHelper
6
+
7
+ def updated_by(owner)
8
+ member = owner.updated_by
9
+ return member if member.is_a? String
10
+ return "" if member.nil?
11
+ return member.name if member.respond_to? :name
12
+ member.email
13
+ end
14
+ def aspect_ratio image
15
+ x , y = image.aspect_ratio
16
+ "#{x} / #{y}"
17
+ end
18
+
19
+ def card_field_name(card)
20
+ name = card.header
21
+ name += "*" unless card.option("compulsory") == "no"
22
+ name
23
+ end
24
+
25
+ def last_change_digit
26
+ last = ChangeSet.current.last
27
+ return 10 unless last
28
+ last = (Time.now - last).to_i
29
+ return 10 if ( last >= 600 )
30
+ digit = last / 60
31
+ digit
32
+ end
33
+
34
+ def last_change_class
35
+ digit = last_change_digit
36
+ return "" if digit > 9
37
+ digit = 9 - digit
38
+ reds = { "1" => "bg-red-100","2" => "bg-red-200","3" => "bg-red-100",
39
+ "4" => "bg-red-400","5" => "bg-red-500","6" => "bg-red-600",
40
+ "7" => "bg-red-700","8" => "bg-red-600","9" => "bg-red-900"}
41
+
42
+ clazz = reds[digit.to_s].to_s
43
+ clazz += " " + "text-white" if digit > 7
44
+ clazz
45
+ end
46
+
47
+ def last_change_text
48
+ digit = last_change_digit
49
+ return "no change" if digit > 9
50
+ "#{digit} min. by #{ChangeSet.current.last_editor}"
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,11 @@
1
+ module Breeze
2
+ module CardsHelper
3
+ include ViewHelper #for previews
4
+
5
+ def card_section_select(card)
6
+ card_sections = card.section.page.sections
7
+ card_sections.delete_if{|c| c.card_template.blank?}
8
+ card_sections.collect{|s| [s.header , s.id]}
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,29 @@
1
+ require 'open3'
2
+ module Breeze
3
+ module ChangesHelper
4
+
5
+ def branch
6
+ %x[git branch]
7
+ end
8
+
9
+ def cms_part? name
10
+ return true if name.include?( Breeze.images_dir )
11
+ return true if name.include?(Breeze.data_dir)
12
+ false
13
+ end
14
+
15
+ def changeset( type , element)
16
+ case type
17
+ when :add
18
+ ChangeSet.current.added( element )
19
+ when :edit
20
+ ChangeSet.current.edited( element )
21
+ when :delete
22
+ ChangeSet.current.deleted( element )
23
+ else
24
+ raise "unrecognized type #{type}"
25
+ end
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,5 @@
1
+ module Breeze
2
+ module FormHelper
3
+ include ViewHelper
4
+ end
5
+ end