Skip to content

Instantly share code, notes, and snippets.

@ThomasBush
Last active July 16, 2016 13:12
Show Gist options
  • Save ThomasBush/fb65862644ca89bce176103b031f4ca2 to your computer and use it in GitHub Desktop.
Save ThomasBush/fb65862644ca89bce176103b031f4ca2 to your computer and use it in GitHub Desktop.
# /app/views/spina/admin/structure_partables/icons/_form.html.haml
.horizontal-form-label
= f.object.title
.horizontal-form-content
= f.fields_for :page_partable, f.object.page_partable do |ff|
= ff.text_field :content, class: 'icon-picker', value: 'fa-anchor'
# db/migrate/create_spina_icons.rb
class CreateSpinaIcons < ActiveRecord::Migration[5.0]
def change
create_table :spina_icons do |t|
t.string :content
t.timestamps
end
end
end
# config/initializers/themes/default.rb
::Spina::Theme.register do |theme|
theme.name = 'default'
theme.title = 'Default Theme'
theme.page_parts = [{
name: 'text',
title: 'Text',
partable_type: 'Spina::Text'
},
{
name: 'side_image',
title: 'Side Image',
partable_type: 'Spina::Photo'
},
{
name: 'structure_list',
title: 'Structure',
partable_type: 'Spina::Structure'
}]
theme.structures = [{
name: 'structure_list',
structure_parts: [{
name: 'title',
title: 'Title',
partable_type: 'Spina::Line'
},
{
name: 'icon_picker',
title: 'Icon',
partable_type: 'Spina::Icon'
},
{
name: 'description',
title: 'Description',
partable_type: 'Spina::Text'
}]
}]
theme.layout_parts = [{
name: 'brand_color',
title: 'Brand Color',
partable_type: 'Spina::Color'
}]
theme.view_templates = [{
name: 'homepage',
title: 'Homepage',
page_parts: ['text']
},
{
name: 'show',
title: 'Default',
description: 'A simple page',
usage: 'Use for your content',
page_parts: ['side_image', 'text']
},
{
name: 'list',
title: 'List',
description: 'A simple page',
usage: 'Use for listing content',
page_parts: ['text', 'structure_list']
}]
theme.custom_pages = [{
name: 'homepage',
title: 'Homepage',
deletable: false,
view_template: 'homepage'
}]
end
# models/spina/icon.rb
module Spina
class Icon < ApplicationRecord
translates :content
has_many :page_parts, as: :page_partable
has_many :layout_parts, as: :layout_partable
has_many :structure_parts, as: :structure_partable
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment