Refactor theme handling so that it is unified via a helper method
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
require 'lib/screenshot_generator'
|
require 'lib/screenshot_generator'
|
||||||
|
require 'ostruct'
|
||||||
###
|
###
|
||||||
# Compass
|
# Compass
|
||||||
###
|
###
|
||||||
@@ -91,3 +92,14 @@ activate :deploy do |deploy|
|
|||||||
# deploy.strategy = :submodule # commit strategy: can be :force_push or :submodule, default: :force_push
|
# deploy.strategy = :submodule # commit strategy: can be :force_push or :submodule, default: :force_push
|
||||||
# deploy.commit_message = 'custom-message' # commit message (can be empty), default: Automated commit at `timestamp` by middleman-deploy `version`
|
# deploy.commit_message = 'custom-message' # commit message (can be empty), default: Automated commit at `timestamp` by middleman-deploy `version`
|
||||||
end
|
end
|
||||||
|
|
||||||
|
helpers do
|
||||||
|
def themes
|
||||||
|
data.themes.sort_by { |theme| theme[:name] }.map do |theme|
|
||||||
|
OpenStruct.new(theme.merge(
|
||||||
|
slug: theme[:name].parameterize.underscore,
|
||||||
|
digest: Digest::MD5.new.hexdigest(theme[:colors])
|
||||||
|
))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
+1
-4
@@ -20,10 +20,7 @@ class Screenshot
|
|||||||
end
|
end
|
||||||
|
|
||||||
def initialize(theme)
|
def initialize(theme)
|
||||||
@theme = OpenStruct.new(theme.merge(
|
@theme = theme
|
||||||
slug: theme[:name].parameterize.underscore,
|
|
||||||
digest: Digest::MD5.new.hexdigest(theme[:colors])
|
|
||||||
))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_theme_image
|
def generate_theme_image
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ class ScreenshotGenerator < ::Middleman::Extension
|
|||||||
super
|
super
|
||||||
app.before_build do |builder|
|
app.before_build do |builder|
|
||||||
Screenshot.prepare
|
Screenshot.prepare
|
||||||
data = YAML.load_file('data/themes.yml')
|
|
||||||
data.each do |theme|
|
themes.each do |theme|
|
||||||
Screenshot.new(theme).generate_theme_image
|
Screenshot.new(theme).generate_theme_image
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Hello World"
|
puts "Hello World"
|
||||||
# builder.run './my_deploy_script.sh'
|
# builder.run './my_deploy_script.sh'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,11 +2,9 @@
|
|||||||
title: Slack Themes
|
title: Slack Themes
|
||||||
---
|
---
|
||||||
|
|
||||||
<% data.themes.each do |theme| %>
|
<% themes.each do |theme| %>
|
||||||
<% theme_slug = theme[:name].parameterize.underscore %>
|
<label class="radio theme_label theme_<%= theme.slug %>">
|
||||||
<% digest = Digest::MD5.new.hexdigest(theme[:colors]) %>
|
<img src="/images/theme/<%= theme.slug %>-<%= theme.digest %>.png" class="theme_thumb"><br>
|
||||||
<label class="radio theme_label theme_<%= theme[:name].parameterize.underscore %>">
|
<input name="sidebar_theme_rd" type="radio" value="<%= theme.colors %>" ng-model="theme" ng-change="setTheme()"> <%= theme.name %>
|
||||||
<img src="/images/theme/<%= theme_slug %>-<%= digest %>.png" class="theme_thumb"><br>
|
|
||||||
<input name="sidebar_theme_rd" type="radio" value="<%= theme[:colors] %>" ng-model="theme" ng-change="setTheme()"> <%= theme[:name] %>
|
|
||||||
</label>
|
</label>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user