glib-web 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +7 -0
  2. data/app/controllers/concerns/glib/auth/policy.rb +148 -0
  3. data/app/controllers/concerns/glib/json/dynamic_text.rb +126 -0
  4. data/app/controllers/concerns/glib/json/libs.rb +144 -0
  5. data/app/controllers/concerns/glib/json/new_dynamic_text.rb +122 -0
  6. data/app/controllers/concerns/glib/json/transformation.rb +11 -0
  7. data/app/controllers/concerns/glib/json/traversal.rb +85 -0
  8. data/app/controllers/concerns/glib/json/ui.rb +70 -0
  9. data/app/controllers/concerns/glib/json/validation.rb +13 -0
  10. data/app/controllers/glib/home_controller.rb +16 -0
  11. data/app/helpers/glib/app_feature_support_helper.rb +16 -0
  12. data/app/helpers/glib/dynamic_images_helper.rb +52 -0
  13. data/app/helpers/glib/dynamic_texts_helper.rb +42 -0
  14. data/app/helpers/glib/forms_helper.rb +15 -0
  15. data/app/helpers/glib/json_ui/abstract_builder.rb +281 -0
  16. data/app/helpers/glib/json_ui/action_builder.rb +81 -0
  17. data/app/helpers/glib/json_ui/action_builder/dialogs.rb +58 -0
  18. data/app/helpers/glib/json_ui/action_builder/http.rb +19 -0
  19. data/app/helpers/glib/json_ui/action_builder/sheets.rb +15 -0
  20. data/app/helpers/glib/json_ui/action_builder/snackbars.rb +41 -0
  21. data/app/helpers/glib/json_ui/action_builder/windows.rb +25 -0
  22. data/app/helpers/glib/json_ui/dynamic_field_builders.rb +25 -0
  23. data/app/helpers/glib/json_ui/generic_builders.rb +28 -0
  24. data/app/helpers/glib/json_ui/list_builders.rb +87 -0
  25. data/app/helpers/glib/json_ui/menu_builder.rb +52 -0
  26. data/app/helpers/glib/json_ui/page_helper.rb +187 -0
  27. data/app/helpers/glib/json_ui/response_helper.rb +23 -0
  28. data/app/helpers/glib/json_ui/split_builders.rb +32 -0
  29. data/app/helpers/glib/json_ui/styling_helper.rb +25 -0
  30. data/app/helpers/glib/json_ui/table_builders.rb +74 -0
  31. data/app/helpers/glib/json_ui/view_builder.rb +185 -0
  32. data/app/helpers/glib/json_ui/view_builder/banners.rb +24 -0
  33. data/app/helpers/glib/json_ui/view_builder/charts.rb +33 -0
  34. data/app/helpers/glib/json_ui/view_builder/fields.rb +213 -0
  35. data/app/helpers/glib/json_ui/view_builder/panels.rb +219 -0
  36. data/app/models/glib/active_storage/attachment.rb +9 -0
  37. data/app/models/glib/active_storage/blob.rb +9 -0
  38. data/app/models/glib/dynamic_text_record.rb +9 -0
  39. data/app/models/glib/text.rb +96 -0
  40. data/app/policies/glib/application_policy.rb +164 -0
  41. data/app/validators/email_typo_validator.rb +38 -0
  42. data/app/validators/email_validator.rb +7 -0
  43. data/app/validators/url_validator.rb +20 -0
  44. data/app/views/app/views/json_ui/vue/renderer.html.erb +35 -0
  45. data/app/views/json_ui/garage/_nav_menu.json.jbuilder +71 -0
  46. data/app/views/json_ui/garage/actions/_dialogs.json.jbuilder +104 -0
  47. data/app/views/json_ui/garage/actions/_http.json.jbuilder +18 -0
  48. data/app/views/json_ui/garage/actions/_reload.json.jbuilder +17 -0
  49. data/app/views/json_ui/garage/actions/_sheets.json.jbuilder +19 -0
  50. data/app/views/json_ui/garage/actions/_snackbars.json.jbuilder +33 -0
  51. data/app/views/json_ui/garage/actions/_timeouts.json.jbuilder +18 -0
  52. data/app/views/json_ui/garage/actions/_windows.json.jbuilder +24 -0
  53. data/app/views/json_ui/garage/actions/dialogs_oauth_post.json.jbuilder +6 -0
  54. data/app/views/json_ui/garage/actions/index.json.jbuilder +23 -0
  55. data/app/views/json_ui/garage/forms/_alert_post_data.json.jbuilder +7 -0
  56. data/app/views/json_ui/garage/forms/basic.json.jbuilder +34 -0
  57. data/app/views/json_ui/garage/forms/basic_post.json.jbuilder +8 -0
  58. data/app/views/json_ui/garage/forms/checkboxes.json.jbuilder +44 -0
  59. data/app/views/json_ui/garage/forms/dynamic_group.json.jbuilder +41 -0
  60. data/app/views/json_ui/garage/forms/dynamic_select.json.jbuilder +25 -0
  61. data/app/views/json_ui/garage/forms/dynamic_select_data.json.jbuilder +38 -0
  62. data/app/views/json_ui/garage/forms/file_upload.json.jbuilder +58 -0
  63. data/app/views/json_ui/garage/forms/floating_submit.json.jbuilder +31 -0
  64. data/app/views/json_ui/garage/forms/generic_post.json.jbuilder +3 -0
  65. data/app/views/json_ui/garage/forms/get_request.json.jbuilder +28 -0
  66. data/app/views/json_ui/garage/forms/index.json.jbuilder +101 -0
  67. data/app/views/json_ui/garage/forms/pickers.json.jbuilder +46 -0
  68. data/app/views/json_ui/garage/forms/rich_text.json.jbuilder +40 -0
  69. data/app/views/json_ui/garage/forms/selects.json.jbuilder +70 -0
  70. data/app/views/json_ui/garage/forms/show_hide.json.jbuilder +88 -0
  71. data/app/views/json_ui/garage/forms/styled_boxes.json.jbuilder +32 -0
  72. data/app/views/json_ui/garage/forms/submission_flow.json.jbuilder +17 -0
  73. data/app/views/json_ui/garage/forms/submission_flow_post.json.jbuilder +24 -0
  74. data/app/views/json_ui/garage/forms/submission_indicator.json.jbuilder +63 -0
  75. data/app/views/json_ui/garage/forms/submission_indicator_post.json.jbuilder +25 -0
  76. data/app/views/json_ui/garage/forms/text_validation.json.jbuilder +22 -0
  77. data/app/views/json_ui/garage/home/blank.json.jbuilder +11 -0
  78. data/app/views/json_ui/garage/home/index.json.jbuilder +32 -0
  79. data/app/views/json_ui/garage/home/slow.json.jbuilder +11 -0
  80. data/app/views/json_ui/garage/lists/_infinite_scroll_section.json.jbuilder +20 -0
  81. data/app/views/json_ui/garage/lists/edit_actions.json.jbuilder +19 -0
  82. data/app/views/json_ui/garage/lists/fab.json.jbuilder +14 -0
  83. data/app/views/json_ui/garage/lists/index.json.jbuilder +23 -0
  84. data/app/views/json_ui/garage/lists/infinite_scroll.json.jbuilder +38 -0
  85. data/app/views/json_ui/garage/lists/templating.json.jbuilder +35 -0
  86. data/app/views/json_ui/garage/notifications/index.json.jbuilder +18 -0
  87. data/app/views/json_ui/garage/notifications/web_socket.json.jbuilder +60 -0
  88. data/app/views/json_ui/garage/pages/flat_centered.json.jbuilder +29 -0
  89. data/app/views/json_ui/garage/pages/full_width.json.jbuilder +29 -0
  90. data/app/views/json_ui/garage/pages/full_width_height.json.jbuilder +16 -0
  91. data/app/views/json_ui/garage/pages/index.json.jbuilder +47 -0
  92. data/app/views/json_ui/garage/pages/layout.json.jbuilder +19 -0
  93. data/app/views/json_ui/garage/pages/loading_indicator.json.jbuilder +10 -0
  94. data/app/views/json_ui/garage/pages/nav_buttons.json.jbuilder +21 -0
  95. data/app/views/json_ui/garage/pages/tab_bar.json.jbuilder +27 -0
  96. data/app/views/json_ui/garage/panels/_styled.json.jbuilder +78 -0
  97. data/app/views/json_ui/garage/panels/card.json.jbuilder +4 -0
  98. data/app/views/json_ui/garage/panels/carousel.json.jbuilder +16 -0
  99. data/app/views/json_ui/garage/panels/custom.json.jbuilder +17 -0
  100. data/app/views/json_ui/garage/panels/flow.json.jbuilder +49 -0
  101. data/app/views/json_ui/garage/panels/horizontal.json.jbuilder +91 -0
  102. data/app/views/json_ui/garage/panels/index.json.jbuilder +132 -0
  103. data/app/views/json_ui/garage/panels/outlined.json.jbuilder +4 -0
  104. data/app/views/json_ui/garage/panels/responsive.json.jbuilder +88 -0
  105. data/app/views/json_ui/garage/panels/split.json.jbuilder +183 -0
  106. data/app/views/json_ui/garage/panels/vertical.json.jbuilder +50 -0
  107. data/app/views/json_ui/garage/services/dynamic_text.json.jbuilder +13 -0
  108. data/app/views/json_ui/garage/services/image.json.jbuilder +47 -0
  109. data/app/views/json_ui/garage/services/index.json.jbuilder +17 -0
  110. data/app/views/json_ui/garage/tables/_autoload_section.json.jbuilder +13 -0
  111. data/app/views/json_ui/garage/tables/autoload_all.json.jbuilder +38 -0
  112. data/app/views/json_ui/garage/tables/autoload_as_needed.json.jbuilder +39 -0
  113. data/app/views/json_ui/garage/tables/export_import.json.jbuilder +29 -0
  114. data/app/views/json_ui/garage/tables/horizontal_scroll.json.jbuilder +26 -0
  115. data/app/views/json_ui/garage/tables/index.json.jbuilder +26 -0
  116. data/app/views/json_ui/garage/tables/layout.json.jbuilder +38 -0
  117. data/app/views/json_ui/garage/views/_chart_data.json.jbuilder +17 -0
  118. data/app/views/json_ui/garage/views/banners.json.jbuilder +51 -0
  119. data/app/views/json_ui/garage/views/calendar_data.json.jbuilder +30 -0
  120. data/app/views/json_ui/garage/views/carousels.json.jbuilder +37 -0
  121. data/app/views/json_ui/garage/views/charts.json.jbuilder +115 -0
  122. data/app/views/json_ui/garage/views/images.json.jbuilder +89 -0
  123. data/app/views/json_ui/garage/views/index.json.jbuilder +48 -0
  124. data/app/views/json_ui/garage/views/links.json.jbuilder +70 -0
  125. data/app/views/json_ui/garage/views/map_data.json.jbuilder +43 -0
  126. data/app/views/json_ui/garage/views/markdowns.json.jbuilder +41 -0
  127. data/app/views/json_ui/garage/views/misc.json.jbuilder +34 -0
  128. data/app/views/json_ui/garage/views/texts.json.jbuilder +41 -0
  129. data/app/views/layouts/json_ui/renderer.html.erb +32 -0
  130. data/config/routes.rb +8 -0
  131. data/lib/generators/glib/install_generator.rb +24 -0
  132. data/lib/generators/templates/20191017062519_create_texts.rb +12 -0
  133. data/lib/generators/templates/20191024063257_add_scope_to_texts.rb +7 -0
  134. data/lib/generators/templates/20191112095018_add_lang_to_texts.rb +7 -0
  135. data/lib/generators/templates/20191126071051_create_active_storage_tables.active_storage.rb +27 -0
  136. data/lib/generators/templates/database.yml +107 -0
  137. data/lib/generators/templates/dynamic_text.rb +2 -0
  138. data/lib/glib-web.rb +8 -0
  139. data/lib/glib/crypt.rb +1 -0
  140. data/lib/glib/crypt/utils.rb +26 -0
  141. data/lib/glib/dynamic_text.rb +1 -0
  142. data/lib/glib/dynamic_text/config.rb +21 -0
  143. data/lib/glib/engine.rb +7 -0
  144. data/lib/glib/json_crawler.rb +10 -0
  145. data/lib/glib/json_crawler/action_crawler.rb +20 -0
  146. data/lib/glib/json_crawler/action_crawlers/action_http.rb +14 -0
  147. data/lib/glib/json_crawler/action_crawlers/forms_submit.rb +48 -0
  148. data/lib/glib/json_crawler/action_crawlers/menu.rb +12 -0
  149. data/lib/glib/json_crawler/action_crawlers/nav_initiate.rb +15 -0
  150. data/lib/glib/json_crawler/action_crawlers/windows_open.rb +28 -0
  151. data/lib/glib/json_crawler/coverage.rb +20 -0
  152. data/lib/glib/json_crawler/http.rb +120 -0
  153. data/lib/glib/json_crawler/router.rb +86 -0
  154. data/lib/glib/test_helpers.rb +40 -0
  155. data/lib/glib/value.rb +7 -0
  156. data/lib/glib/version.rb +5 -0
  157. data/lib/tasks/db.rake +95 -0
  158. metadata +246 -0
@@ -0,0 +1,70 @@
1
+ json.title 'Views'
2
+
3
+ json_ui_page json do |page|
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
5
+
6
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
7
+
8
+ scroll.h2 text: 'Standard button'
9
+ scroll.spacer height: 6
10
+ scroll.button text: 'Button', onClick: ->(action) do
11
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
12
+ end
13
+
14
+ scroll.spacer height: 20
15
+ scroll.h2 text: 'Button with icon'
16
+ scroll.spacer height: 6
17
+ scroll.button icon: 'info', text: 'Button', onClick: ->(action) do
18
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
19
+ end
20
+
21
+ scroll.spacer height: 20
22
+ scroll.h2 text: 'Button with link style'
23
+ scroll.spacer height: 6
24
+ scroll.button text: 'Link Button', styleClass: 'link', onClick: ->(action) do
25
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
26
+ end
27
+
28
+ scroll.spacer height: 20
29
+ scroll.h2 text: 'Button with icon style'
30
+ scroll.spacer height: 6
31
+ scroll.button icon: 'info', styleClass: 'icon', onClick: ->(action) do
32
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
33
+ end
34
+
35
+ scroll.spacer height: 20
36
+ scroll.h2 text: 'Label with onClick URL'
37
+ scroll.spacer height: 6
38
+ scroll.label text: 'Clickable Link', onClick: ->(action) do
39
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
40
+ end
41
+
42
+ scroll.spacer height: 20
43
+ scroll.h2 text: 'Avatar with onClick'
44
+ # TODO: Make sure "open in new tab" works
45
+ scroll.spacer height: 10
46
+ scroll.avatar url: glib_json_image_avatar_url, styleClass: 'link', onClick: ->(action) do
47
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
48
+ end
49
+
50
+ scroll.spacer height: 20
51
+ scroll.h2 text: 'Image with onClick'
52
+ # TODO: Make sure "open in new tab" works
53
+ scroll.spacer height: 10
54
+ scroll.image width: 100, url: glib_json_image_standard_url, styleClass: 'link', onClick: ->(action) do
55
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
56
+ end
57
+
58
+ scroll.spacer height: 20
59
+ scroll.h2 text: 'Icon with onClick'
60
+ scroll.spacer height: 6
61
+ scroll.icon spec: 'info', onClick: ->(action) do
62
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
63
+ end
64
+
65
+ scroll.fab icon: 'add', onClick: ->(action) do
66
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
67
+ end
68
+
69
+ end
70
+ end
@@ -0,0 +1,43 @@
1
+
2
+ json.pins do
3
+
4
+ latitude = params[:lat]&.to_f
5
+ longitude = params[:long]&.to_f
6
+
7
+ json.child! do
8
+ json.latitude 13.516680
9
+ json.longitude 144.817322
10
+ json.infoWindow do
11
+ json.title 'Place 1'
12
+ json.subtitle 'Big shopping mall'
13
+ end
14
+ end
15
+
16
+ json.child! do
17
+ json.latitude 13.473001
18
+ json.longitude 144.771303
19
+ json.infoWindow do
20
+ json.title 'Place 2'
21
+ json.subtitle 'High class restaurant'
22
+ end
23
+ end
24
+
25
+ json.child! do
26
+ json.latitude 13.375903 + rand(0..0.1)
27
+ json.longitude 144.749791 + rand(0..0.1)
28
+ json.infoWindow do
29
+ json.title 'Place 3'
30
+ json.subtitle 'Random location'
31
+ end
32
+ end
33
+
34
+ json.child! do
35
+ json.latitude latitude
36
+ json.longitude longitude
37
+ json.infoWindow do
38
+ json.title 'You'
39
+ json.subtitle 'Current location'
40
+ json.subsubtitle "#{latitude}, #{longitude}"
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,41 @@
1
+ json.title 'Views'
2
+
3
+ json_ui_page json do |page|
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
5
+
6
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
7
+ scroll.spacer height: 20
8
+ scroll.h2 text: 'Markdown'
9
+ scroll.spacer height: 6
10
+ scroll.markdown text:
11
+ '# h1 Heading' + "\n" +
12
+ '## h2 Heading' + "\n" +
13
+ '### h3 Heading' + "\n" +
14
+ '#### h4 Heading' + "\n" +
15
+ '##### h5 Heading' + "\n" +
16
+ '###### h6 Heading' + "\n" +
17
+ "\n" +
18
+ '## Emphasis' + "\n" +
19
+ "\n" +
20
+ '**This is bold text**' + "\n" +
21
+ "\n" +
22
+ '__This is bold text__' + "\n" +
23
+ "\n" +
24
+ '*This is italic text*' + "\n" +
25
+ "\n" +
26
+ '_This is italic text_' + "\n" +
27
+ "\n" +
28
+ '~~Strikethrough~~' + "\n" +
29
+ "\n" +
30
+ 'https://www.google.com' + "\n"
31
+
32
+ scroll.spacer height: 20
33
+ scroll.h2 text: 'Markdown with preview (Web Only)'
34
+ scroll.spacer height: 6
35
+ scroll.markdown text: 'Here is the video: https://www.youtube.com/watch?v=947op8yKJRY', previewVideo: true
36
+
37
+ scroll.spacer height: 10
38
+ scroll.markdown text: 'Some videos: https://youtu.be/ATnpEOo3GJA, https://www.youtube.com/watch?v=947op8yKJRY', previewVideo: true
39
+
40
+ end
41
+ end
@@ -0,0 +1,34 @@
1
+ json.title 'Views'
2
+
3
+ json_ui_page json do |page|
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
5
+
6
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
7
+
8
+ scroll.h2 text: 'Unordered List'
9
+ scroll.spacer height: 6
10
+ scroll.panels_ul childViews: ->(ul) do
11
+ ul.button text: 'Button', styleClass: 'link', onClick: ->(action) do
12
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
13
+ end
14
+ ul.label text: 'Label'
15
+ end
16
+
17
+ scroll.spacer height: 20
18
+ scroll.h2 text: 'Time'
19
+ scroll.spacer height: 6
20
+ scroll.datetime value: 1.week.ago, format: 'YYYY-MM-DD'
21
+ scroll.datetime value: DateTime.current, format: 'hh:mm:ss', tick: true
22
+
23
+ scroll.spacer height: 20
24
+ scroll.h2 text: 'Map'
25
+ scroll.spacer height: 6
26
+ scroll.map width: 'matchParent', latitude: 13.4837, longitude: 144.7917, zoom: 11, height: 250, dataUrl: json_ui_garage_url(path: 'views/map_data')
27
+
28
+ scroll.spacer height: 20
29
+ scroll.h2 text: 'Calendar'
30
+ scroll.spacer height: 6
31
+ scroll.calendar width: 'matchParent', height: 500, dataUrl: json_ui_garage_url(path: 'views/calendar_data')
32
+
33
+ end
34
+ end
@@ -0,0 +1,41 @@
1
+ json.title 'Views'
2
+
3
+ json_ui_page json do |page|
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
5
+
6
+ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
7
+ scroll.h1 text: 'Heading 1'
8
+
9
+ scroll.spacer height: 10
10
+ scroll.h2 text: 'Heading 2'
11
+
12
+ scroll.spacer height: 10
13
+ scroll.h3 text: 'Heading 3'
14
+
15
+ scroll.spacer height: 10
16
+ scroll.h4 text: 'Heading 4'
17
+
18
+ scroll.spacer height: 10
19
+ scroll.label text: 'Label'
20
+
21
+ scroll.spacer height: 20
22
+ scroll.hr width: 'matchParent'
23
+
24
+ scroll.spacer height: 20
25
+ scroll.h2 text: 'Paragraph'
26
+ scroll.spacer height: 6
27
+ scroll.p text: 'Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC,'\
28
+ ' making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words,'\
29
+ ' consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source.'\
30
+ ' Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC.'\
31
+ ' This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..",'\
32
+ ' comes from a line in section 1.10.32.' + "\n\n" +
33
+ 'The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum"'\
34
+ ' by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.'
35
+
36
+ scroll.spacer height: 20
37
+ scroll.h2 text: 'Chip'
38
+ scroll.spacer height: 6
39
+ scroll.chip text: 'pending'
40
+ end
41
+ end
@@ -0,0 +1,32 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="utf-8" />
6
+ <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport" />
7
+
8
+ <title>App</title>
9
+ <%= csrf_meta_tags %>
10
+
11
+ <%= javascript_pack_tag 'vue_renderer', defer: true %>
12
+ <%#= javascript_include_tag 'vue_renderer_extras', defer: true %>
13
+
14
+ <%= stylesheet_pack_tag 'vue_renderer' %>
15
+
16
+ <link href="https://fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet" />
17
+
18
+ <%= yield :head %>
19
+ </head>
20
+
21
+ <body>
22
+ <noscript>Please enable JavaScript to view this web site.</noscript>
23
+ <div id="app"></div>
24
+
25
+ <script>
26
+ var __page = <%= raw @__json_ui_orig_page%>;
27
+ </script>
28
+
29
+ <%= yield :footer %>
30
+ </body>
31
+
32
+ </html>
@@ -0,0 +1,8 @@
1
+ Glib::Web::Engine.routes.draw do
2
+ scope module: :glib do
3
+ get 'json_ui_garage', to: 'home#json_ui_garage'
4
+ post 'json_ui_garage', to: 'home#json_ui_garage'
5
+ patch 'json_ui_garage', to: 'home#json_ui_garage'
6
+ delete 'json_ui_garage', to: 'home#json_ui_garage'
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ module Glib
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../../templates', __FILE__)
5
+
6
+ class_option :redis_env_key, type: :string, default: 'DT_REDIS_URL'
7
+ class_option :database_env_key, type: :string, default: 'DT_DATABASE_URL'
8
+ class_option :app_name, type: :string, default: Rails.application.class.parent_name
9
+
10
+ def copy_initializer
11
+ [
12
+ '20191017062519_create_texts.rb',
13
+ '20191024063257_add_scope_to_texts.rb',
14
+ '20191112095018_add_lang_to_texts.rb',
15
+ '20191126071051_create_active_storage_tables.active_storage.rb'
16
+ ].each do |migration_file|
17
+ template migration_file, "db/dynamic_text_migrate/#{migration_file}"
18
+ end
19
+ template 'dynamic_text.rb', 'config/initializers/dynamic_text.rb'
20
+ template 'database.yml', 'config/database.yml'
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,12 @@
1
+ class CreateTexts < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :texts do |t|
4
+ t.string :key
5
+ t.text :content
6
+
7
+ t.timestamps
8
+ end
9
+
10
+ add_index :texts, :key, unique: true
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ class AddScopeToTexts < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :texts, :scope, :string
4
+ remove_index :texts, :key
5
+ add_index :texts, [:scope, :key], unique: true
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class AddLangToTexts < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :texts, :lang, :string
4
+ remove_index :texts, [:scope, :key]
5
+ add_index :texts, [:scope, :lang, :key], unique: true
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ # This migration comes from active_storage (originally 20170806125915)
2
+ class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
3
+ def change
4
+ create_table :active_storage_blobs do |t|
5
+ t.string :key, null: false
6
+ t.string :filename, null: false
7
+ t.string :content_type
8
+ t.text :metadata
9
+ t.bigint :byte_size, null: false
10
+ t.string :checksum, null: false
11
+ t.datetime :created_at, null: false
12
+
13
+ t.index [ :key ], unique: true
14
+ end
15
+
16
+ create_table :active_storage_attachments do |t|
17
+ t.string :name, null: false
18
+ t.references :record, null: false, polymorphic: true, index: false
19
+ t.references :blob, null: false
20
+
21
+ t.datetime :created_at, null: false
22
+
23
+ t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
24
+ t.foreign_key :active_storage_blobs, column: :blob_id
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,107 @@
1
+ # PostgreSQL. Versions 9.1 and up are supported.
2
+ #
3
+ # Install the pg driver:
4
+ # gem install pg
5
+ # On OS X with Homebrew:
6
+ # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7
+ # On OS X with MacPorts:
8
+ # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9
+ # On Windows:
10
+ # gem install pg
11
+ # Choose the win32 build.
12
+ # Install PostgreSQL and put its /bin directory on your path.
13
+ #
14
+ # Configure Using Gemfile
15
+ # gem 'pg'
16
+ #
17
+ default: &default
18
+ adapter: postgresql
19
+ encoding: unicode
20
+ # For details on connection pooling, see Rails configuration guide
21
+ # http://guides.rubyonrails.org/configuring.html#database-pooling
22
+ pool: <%= "\<\%\= ENV.fetch(\"RAILS_MAX_THREADS\") { 5 } \%\>" %>
23
+ host: <%= "\<\%\= ENV.fetch(\"DATABASE_HOST\") {} \%\>" %>
24
+ username: <%= "\<\%\= ENV.fetch(\"DATABASE_USER\") {} \%\>" %>
25
+ password: <%= "\<\%\= ENV.fetch(\"DATABASE_PASSWORD\") {} \%\>" %>
26
+
27
+ development:
28
+ primary:
29
+ <<: *default
30
+ database: <%= "\<\%\= ENV.fetch(\"DATABASE_NAME\") { \"#{options[:app_name]}\" } + \"_development\" \%\>" %>
31
+ dynamic_text:
32
+ <<: *default
33
+ migrations_paths: db/dynamic_text_migrate
34
+ database: <%= "\<\%\= ENV.fetch(\"DT_DATABASE_NAME\") { \"DynamicText\" } + \"_development\" \%\>" %>
35
+
36
+ # The specified database role being used to connect to postgres.
37
+ # To create additional roles in postgres see `$ createuser --help`.
38
+ # When left blank, postgres will use the default role. This is
39
+ # the same name as the operating system user that initialized the database.
40
+ #username: ItineraryBuilder
41
+
42
+ # The password associated with the postgres role (username).
43
+ #password:
44
+
45
+ # Connect on a TCP socket. Omitted by default since the client uses a
46
+ # domain socket that doesn't need configuration. Windows does not have
47
+ # domain sockets, so uncomment these lines.
48
+ #host: localhost
49
+
50
+ # The TCP port the server listens on. Defaults to 5432.
51
+ # If your server runs on a different port number, change accordingly.
52
+ #port: 5432
53
+
54
+ # Schema search path. The server defaults to $user,public
55
+ #schema_search_path: myapp,sharedapp,public
56
+
57
+ # Minimum log levels, in increasing order:
58
+ # debug5, debug4, debug3, debug2, debug1,
59
+ # log, notice, warning, error, fatal, and panic
60
+ # Defaults to warning.
61
+ #min_messages: notice
62
+
63
+ # Warning: The database defined as "test" will be erased and
64
+ # re-generated from your development database when you run "rake".
65
+ # Do not set this db to the same as development or production.
66
+ test:
67
+ primary:
68
+ <<: *default
69
+ database: <%= "\<\%\= ENV.fetch(\"DATABASE_NAME\") { \"#{options[:app_name]}\" } + \"_test\" \%\>" %>
70
+ dynamic_text:
71
+ <<: *default
72
+ migrations_paths: db/dynamic_text_migrate
73
+ database: <%= "\<\%\= ENV.fetch(\"DT_DATABASE_NAME\") { \"DynamicText\" } + \"_test\" \%\>" %>
74
+
75
+ # As with config/secrets.yml, you never want to store sensitive information,
76
+ # like your database password, in your source code. If your source code is
77
+ # ever seen by anyone, they now have access to your database.
78
+ #
79
+ # Instead, provide the password as a unix environment variable when you boot
80
+ # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
81
+ # for a full rundown on how to provide these environment variables in a
82
+ # production deployment.
83
+ #
84
+ # On Heroku and other platform providers, you may have a full connection URL
85
+ # available as an environment variable. For example:
86
+ #
87
+ # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
88
+ #
89
+ # You can use this database configuration with:
90
+ #
91
+ # production:
92
+ # url: <%= "\<\%\= ENV[\'DATABASE_URL\'] \%\>" %>
93
+ #
94
+
95
+ production_default: &production_default
96
+ adapter: postgresql
97
+ encoding: unicode
98
+ pool: <%= "\<\%\= ENV.fetch(\"RAILS_MAX_THREADS\") { 5 } \%\>" %>
99
+
100
+ production:
101
+ primary:
102
+ <<: *production_default
103
+ url: <%= "\<\%\= ENV[\"DATABASE_URL\"] \%\>" %>
104
+ dynamic_text:
105
+ <<: *production_default
106
+ migrations_paths: db/dynamic_text_migrate
107
+ url: <%= "\<\%\= ENV[\"#{options[:database_env_key]}\"] \%\>" %>