hot-glue 0.4.0 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/config/database.yml CHANGED
@@ -1,11 +1,86 @@
1
+ # PostgreSQL. Versions 9.3 and up are supported.
2
+ #
3
+ # Install the pg driver:
4
+ # gem install pg
5
+ # On macOS with Homebrew:
6
+ # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7
+ # On macOS 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
+ # https://guides.rubyonrails.org/configuring.html#database-pooling
22
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23
+
1
24
  development:
2
- adapter: sqlite3
3
- database: ../spec/dummy/db/development.sqlite3
4
- pool: 5
5
- timeout: 5000
25
+ <<: *default
26
+ database: Dummy_development
27
+
28
+ # The specified database role being used to connect to postgres.
29
+ # To create additional roles in postgres see `$ createuser --help`.
30
+ # When left blank, postgres will use the default role. This is
31
+ # the same name as the operating system user running Rails.
32
+ #username: Dummy
33
+
34
+ # The password associated with the postgres role (username).
35
+ #password:
36
+
37
+ # Connect on a TCP socket. Omitted by default since the client uses a
38
+ # domain socket that doesn't need configuration. Windows does not have
39
+ # domain sockets, so uncomment these lines.
40
+ #host: localhost
6
41
 
42
+ # The TCP port the server listens on. Defaults to 5432.
43
+ # If your server runs on a different port number, change accordingly.
44
+ #port: 5432
45
+
46
+ # Schema search path. The server defaults to $user,public
47
+ #schema_search_path: myapp,sharedapp,public
48
+
49
+ # Minimum log levels, in increasing order:
50
+ # debug5, debug4, debug3, debug2, debug1,
51
+ # log, notice, warning, error, fatal, and panic
52
+ # Defaults to warning.
53
+ #min_messages: notice
54
+
55
+ # Warning: The database defined as "test" will be erased and
56
+ # re-generated from your development database when you run "rake".
57
+ # Do not set this db to the same as development or production.
7
58
  test:
8
- adapter: sqlite3
9
- database: ../spec/dummy/db/test.sqlite3
10
- pool: 5
11
- timeout: 5000
59
+ <<: *default
60
+ database: Dummy_test
61
+
62
+ # As with config/credentials.yml, you never want to store sensitive information,
63
+ # like your database password, in your source code. If your source code is
64
+ # ever seen by anyone, they now have access to your database.
65
+ #
66
+ # Instead, provide the password or a full connection URL as an environment
67
+ # variable when you boot the app. For example:
68
+ #
69
+ # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
70
+ #
71
+ # If the connection URL is provided in the special DATABASE_URL environment
72
+ # variable, Rails will automatically merge its configuration values on top of
73
+ # the values provided in this file. Alternatively, you can specify a connection
74
+ # URL environment variable explicitly:
75
+ #
76
+ # production:
77
+ # url: <%= ENV['MY_APP_DATABASE_URL'] %>
78
+ #
79
+ # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
80
+ # for a full overview on how database connection configuration can be specified.
81
+ #
82
+ production:
83
+ <<: *default
84
+ database: Dummy_production
85
+ username: Dummy
86
+ password: <%= ENV['DUMMY_DATABASE_PASSWORD'] %>
@@ -0,0 +1,3 @@
1
+ ---
2
+ :layout: hotglue
3
+ :markup: erb
data/db/schema.rb CHANGED
@@ -15,12 +15,12 @@ ActiveRecord::Schema.define(version: 2021_03_06_225506) do
15
15
  create_table "abcs", force: :cascade do |t|
16
16
  t.integer "xxx"
17
17
  t.string "yyy"
18
- t.integer "def_id"
18
+ t.integer "dfg_id"
19
19
  t.datetime "created_at", precision: 6, null: false
20
20
  t.datetime "updated_at", precision: 6, null: false
21
21
  end
22
22
 
23
- create_table "defs", force: :cascade do |t|
23
+ create_table "dfg", force: :cascade do |t|
24
24
  t.integer "user_id"
25
25
  t.string "name"
26
26
  t.datetime "created_at", precision: 6, null: false
@@ -28,7 +28,7 @@ ActiveRecord::Schema.define(version: 2021_03_06_225506) do
28
28
  end
29
29
 
30
30
  create_table "ghis", force: :cascade do |t|
31
- t.integer "def_id"
31
+ t.integer "dfg_id"
32
32
  t.datetime "created_at", precision: 6, null: false
33
33
  t.datetime "updated_at", precision: 6, null: false
34
34
  end
@@ -0,0 +1,13 @@
1
+ class HotGlue::Helpers
2
+
3
+
4
+ def self.open_page( link)
5
+ if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
6
+ system "start #{link}"
7
+ elsif RbConfig::CONFIG['host_os'] =~ /darwin/
8
+ system "open #{link}"
9
+ elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/
10
+ system "xdg-open #{link}"
11
+ end
12
+ end
13
+ end
@@ -1,4 +1,5 @@
1
1
  require 'rails/generators/erb/scaffold/scaffold_generator'
2
+ require_relative './helpers'
2
3
  require 'ffaker'
3
4
 
4
5
  module HotGlue
@@ -10,6 +11,8 @@ module HotGlue
10
11
 
11
12
  source_root File.expand_path('templates', __dir__)
12
13
 
14
+
15
+
13
16
  def initialize(*args) #:nodoc:
14
17
  super
15
18
  @layout = options['layout'] || "hotglue"
@@ -17,7 +20,7 @@ module HotGlue
17
20
 
18
21
  if @layout == "hotglue" && options['theme'].nil?
19
22
  puts "You have selected to install Hot Glue without a theme. You can either use the --layout=bootstrap to install NO HOT GLUE THEME, or to use a Hot Glue theme please choose: like_boostrap, like_menlo_park, like_cupertino, like_mountain_view, dark_knight"
20
- exit
23
+ return
21
24
  end
22
25
 
23
26
  if @layout == 'boostrap'
@@ -25,26 +28,58 @@ module HotGlue
25
28
  end
26
29
 
27
30
  ### INTERACTIVE LICENSING
28
- #
29
31
 
30
32
 
31
- print "(To purchase a license, please see https://heliosdev.shop/hot-glue-license) \n Please enter your license key: "
32
- license_activation_key = STDIN.gets.strip
33
+ print "Do you have a license key (y/N)? "
34
+ do_you_have_a_license = STDIN.gets.strip || "N"
33
35
 
34
- print "Please enter the EMAIL you used to purchase this license: "
35
- license_email = STDIN.gets.strip
36
- app_name = Rails.application.class.module_parent_name
37
- license_should_be = Digest::SHA1.hexdigest("HOT-GLUE-LICENSE--#{app_name}--#{license_email}")
36
+ if do_you_have_a_license.downcase == "y"
37
+ print "Please enter the EMAIL you used to purchase a Hot Glue license, \nTeachable tutorial, or Helios Merch Shop product: "
38
+ license_email = STDIN.gets.strip
39
+ require 'open-uri'
38
40
 
41
+ # ask HeliosDev.shop if this email is good
42
+ stream = URI.open("https://heliosdev.shop/check_licenses/hot-glue-license?email=#{license_email}")
43
+ resp = JSON.parse(stream.read)
39
44
 
40
- if (license_should_be != license_activation_key)
41
- puts "Ooops... it seems that Hot Glue license is not valid. Please check 1) the email address you used for this license, 2) The app name you used to purchase this license, and 3) the activation key itself."
42
- exit
45
+ if resp['status'] == 'success'
46
+ if resp['redirect']
47
+ HotGlue::Helpers.open_page(resp['redirect'])
48
+ end
49
+ puts "\n" + " * " + resp['response'] + " * \n\n"
50
+ else
51
+ puts "\n" + " * " + resp['response'] + " * \n\n"
52
+
53
+ print "You can get a license in one of the follow ways: \n"
54
+ print "https://heliosdev.shop/hot-glue-license \n"
55
+ print "https://jfb.teachable.com/p/hot-glue-in-depth-tutorial \n"
56
+ print "https://shop.heliosdev.shop/ \n"
57
+ print "All purchases come with a Hot Glue lifetime license for individuals and hobbyists\n"
58
+ return
59
+ end
60
+ else
61
+ print "Please pick an option to get a Hot Glue license: \n"
62
+ print "1) Professional/Business with support (see heliosdev.shop/hot-glue-license for prices) \n"
63
+ print "2) Individual/hobbyist: Get the tutorial on Teachable ($60) \n"
64
+ print "3) Individual/hobbyist: Get some merchandise ($5 and up) \n"
65
+ print "Please type 1, 2, or 3: "
66
+ choice = STDIN.gets.strip
67
+
68
+ if choice == "1"
69
+ HotGlue::Helpers.open_page("https://heliosdev.shop/hot-glue-license?utm_campaing=hotglue-installer")
70
+ elsif choice == "2"
71
+ HotGlue::Helpers.open_page("https://jfb.teachable.com/p/hot-glue-in-depth-tutorial?utm_source=hotglue-installer")
72
+ print "All purchases come with a Hot Glue lifetime license for individuals and hobbyists\n"
73
+
74
+ else
75
+ HotGlue::Helpers.open_page("https://shop.heliosdev.shop/?utm_source=hotglue-installer")
76
+ print "ALSO check out the HOT GLUE TUTORIAL here: \n"
77
+ print "https://jfb.teachable.com/p/hot-glue-in-depth-tutorial \n"
78
+ print "All purchases come with a Hot Glue lifetime license for individuals and hobbyists\n"
79
+ end
80
+ return
43
81
  end
44
82
 
45
-
46
-
47
-
48
83
  @markup = options['markup']
49
84
  if @markup == "haml"
50
85
  copy_file "haml/_flash_notices.haml", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.haml"
@@ -144,10 +179,8 @@ module HotGlue
144
179
  begin
145
180
 
146
181
  if !File.exists?("config/hot_glue.yml")
147
-
148
182
  yaml = {layout: @layout,
149
183
  markup: @markup,
150
- license_activation_key: license_activation_key,
151
184
  license_email: license_email}.to_yaml
152
185
  File.write("#{'spec/dummy/' if Rails.env.test?}config/hot_glue.yml", yaml)
153
186
 
@@ -0,0 +1,115 @@
1
+
2
+
3
+ module HotGlue
4
+ module Layout
5
+ class Builder
6
+ attr_reader :include_setting, :downnest_children, :no_edit, :no_delete, :columns, :smart_layout
7
+
8
+ def initialize(params)
9
+ @include_setting = params[:include_setting]
10
+ @downnest_children = params[:downnest_children]
11
+ @no_edit = params[:no_edit]
12
+ @no_delete = params[:no_delete]
13
+ @columns = params[:columns]
14
+ @smart_layout = params[:smart_layout]
15
+ end
16
+
17
+ def construct
18
+ layout_object = {
19
+ columns: {
20
+ size_each: nil,
21
+ container: [] # array of arrays
22
+ },
23
+ portals: {
24
+
25
+ },
26
+ buttons: { size: ''}
27
+ }
28
+
29
+ downnest_children.each do |child|
30
+ layout_object[:portals][child] = {size: 4}
31
+ end
32
+
33
+ # smart layout: 2 columns per field; 4 column for EACH downnested portals, 2 column for buttons
34
+ how_many_downnest = downnest_children.size
35
+ button_column_size = (no_edit && no_delete) ? 0 : 2
36
+
37
+ bootstrap_columns = (12-button_column_size)
38
+ bootstrap_columns = bootstrap_columns - (how_many_downnest*4)
39
+ available_columns = (bootstrap_columns / 2).floor # bascially turns the 12-column grid into a 6-column grid
40
+
41
+ if available_columns < 0
42
+ raise "Cannot build layout with #{how_many_downnest} downnested portals"
43
+ end
44
+
45
+ @downnest_children_width = []
46
+ @downnest_children.each_with_index{ |child, i| @downnest_children_width[i] = 4}
47
+
48
+ if include_setting.nil?
49
+
50
+ end
51
+
52
+ if smart_layout
53
+ # automatic control
54
+ #
55
+
56
+ if columns.size > available_columns
57
+ each_col_can_have = (columns.size.to_f / available_columns.to_f).round
58
+ # byebug
59
+ layout_object[:columns][:container] = (0..available_columns-1).collect { |x|
60
+ columns.slice(0+(x*each_col_can_have),each_col_can_have)
61
+ }
62
+ layout_object[:columns][:container].last.append *columns.slice(0+(available_columns*each_col_can_have),each_col_can_have)
63
+
64
+ else
65
+ layout_object[:columns][:container] = (0..available_columns-1).collect { |x|
66
+ [ columns[x]]
67
+ }
68
+ layout_object[:columns][:container].reject!{|x| x == [nil]}
69
+ end
70
+ elsif !include_setting.include?(":")
71
+ layout_object[:columns][:container] = columns.collect{|col| [col]}
72
+
73
+ else
74
+ (0..available_columns-1).each do |int|
75
+ layout_object[:columns][:container][int] = []
76
+ end
77
+
78
+ # input control
79
+ user_layout_columns = options['include'].split(":")
80
+
81
+ if user_layout_columns.size > available_columns
82
+ raise "Your include statement #{options['include']} has #{user_layout_columns.size} columns, but I can only construct up to #{available_columns}"
83
+ end
84
+ user_layout_columns.each_with_index do |column,i|
85
+ layout_object[:columns][:container][i] = column.split(",")
86
+ end
87
+
88
+ if user_layout_columns.size < layout_object[:columns][:container].size
89
+ layout_object[:columns][:container].reject!{|x| x == []}
90
+ end
91
+ end
92
+
93
+ if layout_object[:columns][:container].size < available_columns
94
+ available = available_columns - layout_object[:columns][:container].size
95
+ downnest_child_count = 0
96
+
97
+ while(available > 0)
98
+ if (downnest_child_count <= downnest_children.size-1)
99
+ layout_object[:portals][downnest_children[downnest_child_count]][:size] = layout_object[:portals][downnest_children[downnest_child_count]][:size] + 2
100
+ else
101
+ # leave as-is
102
+ end
103
+ downnest_child_count = downnest_child_count + 1
104
+ available = available - 1
105
+ end
106
+ # give some space back to the downnest
107
+ end
108
+
109
+ puts "*** constructed layout columns #{layout_object.inspect}"
110
+ layout_object
111
+ end
112
+
113
+ end
114
+ end
115
+ end