Skip to content

Commit

Permalink
fixes licesnse checker
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonfb committed Dec 10, 2021
1 parent 2d4dec9 commit 9db529f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 23 deletions.
8 changes: 5 additions & 3 deletions lib/generators/hot_glue/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ def initialize(*args) #:nodoc:


print "(To purchase a license, please see https://heliosdev.shop/hot-glue-license) \n Please enter your license key: "
license_activation_key = STDIN.gets
license_activation_key = STDIN.gets.strip

print "Please enter the EMAIL you used to purchase this license: "
license_email = STDIN.gets
license_email = STDIN.gets.strip
app_name = Rails.application.class.module_parent_name
license_should_be = Digest::SHA1.hexdigest("HotGlueLicense--#{app_name}--#{license_email}")
license_should_be = Digest::SHA1.hexdigest("HOT-GLUE-LICENSE--#{app_name}--#{license_email}")


if (license_should_be != license_activation_key)
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."
exit
Expand Down
33 changes: 16 additions & 17 deletions lib/generators/hot_glue/markup_templates/erb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,20 @@ def all_line_fields(*args)
singular_class = args[0][:singular_class]
singular = args[0][:singular]
perc_width = args[0][:perc_width]
layout = args[0][:layout]

columns_count = columns.count + 1
perc_width = (perc_width).floor

if @layout == "boostrap"
if layout == "bootstrap"
col_identifer = "col"

style_with_flex_basis = ""
else
style_with_flex_basis = " style='flex-basis: #{perc_width}%'"
col_identifer = "scaffold-cell"

end


columns.map { |col|
type = eval("#{singular_class}.columns_hash['#{col}']").type
limit = eval("#{singular_class}.columns_hash['#{col}']").limit
Expand All @@ -203,46 +206,46 @@ def all_line_fields(*args)

display_column = HotGlue.derrive_reference_name(assoc.class_name)

"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
"<div class='#{col_identifer}'#{style_with_flex_basis}>
<%= #{singular}.#{assoc.name.to_s}.try(:#{display_column}) || '<span class=\"content alert-danger\">MISSING</span>'.html_safe %>
</div>"

else
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
"<div class='#{col_identifer}'#{style_with_flex_basis}>
<%= #{singular}.#{col}%></div>"
end
when :float
width = (limit && limit < 40) ? limit : (40)
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
"<div class='#{col_identifer}'#{style_with_flex_basis}>
<%= #{singular}.#{col}%></div>"
when :string
width = (limit && limit < 40) ? limit : (40)
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
"<div class='#{col_identifer}'#{style_with_flex_basis} >
<%= #{singular}.#{col} %>
</div>"
when :text
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
"<div class='#{col_identifer}'#{style_with_flex_basis}>
<%= #{singular}.#{col} %>
</div>"
when :datetime

"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
"<div class='#{col_identifer}' #{style_with_flex_basis} >
<% unless #{singular}.#{col}.nil? %>
<%= #{singular}.#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ') + timezonize(current_timezone) %>
<% else %>
<span class='alert-danger'>MISSING</span>
<% end %>
</div>"
when :date
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
"<div class='#{col_identifer}' #{style_with_flex_basis} >
<% unless #{singular}.#{col}.nil? %>
<%= #{singular}.#{col} %>
<% else %>
<span class='alert-danger'>MISSING</span>
<% end %>
</div>"
when :time
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
"<div class='#{col_identifer}' #{style_with_flex_basis} >
<% unless #{singular}.#{col}.nil? %>
<%= #{singular}.#{col}.in_time_zone(current_timezone).strftime('%l:%M %p ') + timezonize(current_timezone) %>
<% else %>
Expand All @@ -251,7 +254,7 @@ def all_line_fields(*args)
</div>
"
when :boolean
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
"<div class='#{col_identifer}' #{style_with_flex_basis} >
<% if #{singular}.#{col}.nil? %>
<span class='alert-danger'>MISSING</span>
<% elsif #{singular}.#{col} %>
Expand All @@ -261,7 +264,7 @@ def all_line_fields(*args)
<% end %>
</div>
" when :enum
"<div class='#{col_identifer}' style='flex-basis: #{perc_width}%'>
"<div class='#{col_identifer}' #{style_with_flex_basis} >
<% if #{singular}.#{col}.nil? %>
<span class='alert-danger'>MISSING</span>
<% else %>
Expand All @@ -273,8 +276,4 @@ def all_line_fields(*args)
}.join("\n")
end
end




end
3 changes: 2 additions & 1 deletion lib/generators/hot_glue/scaffold_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,8 @@ def all_line_fields
columns: @columns,
show_only: @show_only,
singular_class: singular_class,
singular: singular
singular: singular,
layout: @layout
)
end

Expand Down
6 changes: 4 additions & 2 deletions lib/generators/hot_glue/templates/erb/_show.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<% each_downnest_width = @downnest_children.count == 1 ? 33 : (53/@downnest_children.count).floor %>

<% @downnest_children.each do |downnest| %>
<div class="<%= @col_identifier %> scaffold-downnest" style="flex-basis: <%= each_downnest_width %>%" >
<% downnest_style = @layout == "hotglue" ? 'style="flex-basis: ' + each_downnest_width + '%"' : "" %>
<div class="<%= @col_identifier %> scaffold-downnest" <%= downnest_style %> >
<\%= render partial: "<%= namespace_with_trailing_dash %><%= downnest %>/list", locals: {
nested_for: "<% if @nested_args.any? %>#{nested_for + "__" if nested_for}<% end %><%= @singular %>-#{<%= @singular %>.id}",
<%= @singular %>: <%= @singular %><%= nest_assignments_operator(false, true) %>,
Expand All @@ -13,7 +14,8 @@
<% end %>
<% end %>

<div class="<%= @col_identifier %> scaffold-line-buttons" style="flex-basis: <%= (100 - (column_width * @columns.count)).floor %>%;">
<% button_style = @layout == "hotglue" ? 'style="flex-basis: ' + (100 - (column_width * @columns.count)).floor + '%;' : "" %>
<div class="<%= @col_identifier %> scaffold-line-buttons" <%= button_style %>>
<% if destroy_action %>
<\%= form_with url: <%= path_helper_singular %>(<%= path_helper_args %>), html: {style: "display: inline-block;"}, method: :delete do |f| %>
<\%= f.submit "Delete".html_safe, data: <%= delete_confirmation_syntax %>, class: "delete-<%= singular %>-button btn btn-primary btn-sm" %>
Expand Down

0 comments on commit 9db529f

Please sign in to comment.