hot-glue 0.4.1 → 0.4.5

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,28 +28,58 @@ module HotGlue
25
28
  end
26
29
 
27
30
  ### INTERACTIVE LICENSING
28
- #
29
31
 
30
32
 
31
- if Socket.gethostname != "Rose21"
32
- print "(To purchase a license, please see https://heliosdev.shop/hot-glue-license) \n Please enter your license key: "
33
- 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"
34
35
 
35
- print "Please enter the EMAIL you used to purchase this license: "
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: "
36
38
  license_email = STDIN.gets.strip
37
- app_name = Rails.application.class.module_parent_name
38
- license_should_be = Digest::SHA1.hexdigest("HOT-GLUE-LICENSE--#{app_name}--#{license_email}")
39
+ require 'open-uri'
39
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)
40
44
 
41
- if (license_should_be != license_activation_key)
42
- 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."
43
- 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"
44
79
  end
80
+ return
45
81
  end
46
82
 
47
-
48
-
49
-
50
83
  @markup = options['markup']
51
84
  if @markup == "haml"
52
85
  copy_file "haml/_flash_notices.haml", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.haml"
@@ -146,10 +179,8 @@ module HotGlue
146
179
  begin
147
180
 
148
181
  if !File.exists?("config/hot_glue.yml")
149
-
150
182
  yaml = {layout: @layout,
151
183
  markup: @markup,
152
- license_activation_key: license_activation_key,
153
184
  license_email: license_email}.to_yaml
154
185
  File.write("#{'spec/dummy/' if Rails.env.test?}config/hot_glue.yml", yaml)
155
186
 
@@ -0,0 +1,117 @@
1
+
2
+
3
+ module HotGlue
4
+ module Layout
5
+ class Builder
6
+ attr_reader :include_setting, :downnest_children, :buttons_width, :columns, :smart_layout
7
+
8
+ def initialize(params)
9
+ @include_setting = params[:include_setting]
10
+ @downnest_children = params[:downnest_children]
11
+
12
+ @buttons_width = params[:buttons_width]
13
+
14
+ @no_buttons = @buttons_width == 0
15
+ @columns = params[:columns]
16
+ @smart_layout = params[:smart_layout]
17
+ end
18
+
19
+ def construct
20
+ layout_object = {
21
+ columns: {
22
+ size_each: nil,
23
+ container: [] # array of arrays
24
+ },
25
+ portals: {
26
+
27
+ },
28
+ buttons: { size: @buttons_width}
29
+ }
30
+
31
+ downnest_children.each do |child|
32
+ layout_object[:portals][child] = {size: 4}
33
+ end
34
+
35
+ # smart layout: 2 columns per field; 4 column for EACH downnested portals, 2 column for buttons
36
+ how_many_downnest = downnest_children.size
37
+
38
+ bootstrap_columns = (12-@buttons_width )
39
+ bootstrap_columns = bootstrap_columns - (how_many_downnest*4)
40
+ available_columns = (bootstrap_columns / 2).floor # bascially turns the 12-column grid into a 6-column grid
41
+
42
+ if available_columns < 0
43
+ raise "Cannot build layout with #{how_many_downnest} downnested portals"
44
+ end
45
+
46
+ @downnest_children_width = []
47
+ @downnest_children.each_with_index{ |child, i| @downnest_children_width[i] = 4}
48
+
49
+ if include_setting.nil?
50
+
51
+ end
52
+
53
+ if smart_layout
54
+ # automatic control
55
+ #
56
+
57
+ if columns.size > available_columns
58
+ each_col_can_have = (columns.size.to_f / available_columns.to_f).round
59
+
60
+ layout_object[:columns][:container] = (0..available_columns-1).collect { |x|
61
+ columns.slice(0+(x*each_col_can_have),each_col_can_have)
62
+ }
63
+ layout_object[:columns][:container].last.append *columns.slice(0+(available_columns*each_col_can_have),each_col_can_have)
64
+
65
+ else
66
+ layout_object[:columns][:container] = (0..available_columns-1).collect { |x|
67
+ [ columns[x]]
68
+ }
69
+ layout_object[:columns][:container].reject!{|x| x == [nil]}
70
+ end
71
+ elsif !include_setting.include?(":")
72
+ layout_object[:columns][:container] = columns.collect{|col| [col]}
73
+
74
+ else
75
+
76
+ (0..available_columns-1).each do |int|
77
+ layout_object[:columns][:container][int] = []
78
+ end
79
+
80
+ # input control
81
+ user_layout_columns = options['include'].split(":")
82
+
83
+ if user_layout_columns.size > available_columns
84
+ raise "Your include statement #{options['include']} has #{user_layout_columns.size} columns, but I can only construct up to #{available_columns}"
85
+ end
86
+ user_layout_columns.each_with_index do |column,i|
87
+ layout_object[:columns][:container][i] = column.split(",")
88
+ end
89
+
90
+ if user_layout_columns.size < layout_object[:columns][:container].size
91
+ layout_object[:columns][:container].reject!{|x| x == []}
92
+ end
93
+ end
94
+
95
+ if layout_object[:columns][:container].size < available_columns
96
+ available = available_columns - layout_object[:columns][:container].size
97
+ downnest_child_count = 0
98
+
99
+ while(available > 0)
100
+ if (downnest_child_count <= downnest_children.size-1)
101
+ layout_object[:portals][downnest_children[downnest_child_count]][:size] = layout_object[:portals][downnest_children[downnest_child_count]][:size] + 2
102
+ else
103
+ # leave as-is
104
+ end
105
+ downnest_child_count = downnest_child_count + 1
106
+ available = available - 1
107
+ end
108
+ # give some space back to the downnest
109
+ end
110
+
111
+ puts "*** constructed layout columns #{layout_object.inspect}"
112
+ layout_object
113
+ end
114
+
115
+ end
116
+ end
117
+ end