Skip to content

Commit

Permalink
Merge pull request #5 from codelation/4-migrations-issue
Browse files Browse the repository at this point in the history
Fixing copy file issues
  • Loading branch information
humphreyja authored Oct 24, 2016
2 parents d002ea8 + 7842ebc commit 777f3b9
Show file tree
Hide file tree
Showing 15 changed files with 306 additions and 254 deletions.
79 changes: 79 additions & 0 deletions app/admin/blogelator/author.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
ActiveAdmin.register Blogelator::Author, as: "Author" do
permit_params [
:bio_markdown,
:cover_photo,
:location,
:meta_description,
:meta_keywords,
:name,
:profile_photo,
:slug,
:website
]

controller do
defaults finder: :find_by_slug!
end

filter :name
filter :bio_html
filter :location
filter :website

index do
selectable_column
column :id
column :title do |author|
link_to author.name, admin_author_path(author)
end
column :created_at
column :updated_at
end

form do |f|
inputs "#{t('activerecord.models.author', count: 1)} Details" do
input :name, input_html: { class: "title-to-slug-title" }
input :bio_markdown, as: :codemirror, codemirror: { mode: "gfm" }
input :profile_photo, as: :file
input :cover_photo, as: :file
input :location
input :website
end

inputs "Search Engine Optimization" do
input :meta_keywords
input :meta_description
input :slug, input_html: { class: "title-to-slug-slug" }
end

actions
end

show do
attributes_table do
row :name
row :bio do
raw author.bio_html
end
row :profile_photo do
if author.profile_photo.exists?
img src: author.profile_photo.url(:small)
else
"No Profile Photo"
end
end
row :cover_photo do
if author.cover_photo.exists?
img src: author.cover_photo.url(:small)
else
"No Cover Photo"
end
end
row :location
row :website
row :created_at
row :updated_at
end
active_admin_comments
end
end
125 changes: 125 additions & 0 deletions app/admin/blogelator/post.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
ActiveAdmin.register Blogelator::Post, as: "Post" do
permit_params [
:author_id,
:body_markdown,
:featured,
:image,
:meta_description,
:meta_keywords,
:published_at,
:slug,
:status,
:summary_markdown,
:title,
related_post_ids: [],
tag_ids: []
]

controller do
defaults finder: :find_by_slug!
end

filter :title
filter :body_html
filter :published_at
filter :tags

index do
selectable_column
column :id
column :title do |post|
link_to post.title, admin_post_path(post)
end
column :published_at
column :status do |post|
post.status.titleize
end
end

form do |f|
inputs "#{t('activerecord.models.post', count: 1)} Details" do
input :title, input_html: { class: "title-to-slug-title" }
input :image, as: :file
input :body_markdown, as: :codemirror, codemirror: { lineWrapping: true, mode: "gfm" }
input :summary_markdown, as: :codemirror, codemirror: { lineWrapping: true, mode: "gfm" }
end

inputs "Publish Settings" do
input :status, as: :select, collection: Blogelator::Post.statuses.map {|status| [status[0].titleize, status[0]] }, include_blank: false
input :author, as: :select
input :featured
input :published_at, as: :datepicker
end

inputs "Tags" do
input :tags, as: :check_boxes, label: false
end

inputs "Related Posts" do
input :related_posts, as: :check_boxes, label: false
end

inputs "Search Engine Optimization" do
input :meta_keywords
input :meta_description
input :slug, input_html: { class: "title-to-slug-slug" }
end

actions
end

show do
attributes_table do
row :title
row :author
row :status do
post.status.titleize
end
row :url do
a href: post.url, target: "_blank" do
post.url
end
end
row :published_at
row :image do
if post.image.exists?
img src: post.image.url(:small)
else
"No Image"
end
end
row :created_at
row :updated_at
row :tags do
post.tags.each do |tag|
a href: admin_tag_path(tag) do
tag.name
end
end
end
row :summary do
raw post.summary_html
end
row :content do
raw post.body_html
end
end

panel "Related Posts" do
if post.related_posts.length > 0
ul do
post.related_posts.each do |post|
li do
a href: admin_post_path(post) do
post.title
end
end
end
end
else
para "No related posts"
end
end
active_admin_comments
end
end
41 changes: 41 additions & 0 deletions app/admin/blogelator/tag.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
ActiveAdmin.register Blogelator::Tag, as: "Tag" do
permit_params [
:name,
:slug
]

controller do
defaults finder: :find_by_slug!
end

filter :name

index do
selectable_column
column :id
column :name do |tag|
link_to tag.name, admin_tag_path(tag)
end
column :created_at
column :updated_at
end

form do |f|
inputs "#{t('activerecord.models.tag', count: 1)} Details" do
input :name, input_html: { class: "title-to-slug-title" }
input :slug, input_html: { class: "title-to-slug-slug" }
end

actions
end

show do
attributes_table do
row :name
row :slug
row :created_at
row :updated_at
end
active_admin_comments
end
end
6 changes: 6 additions & 0 deletions app/models/blogelator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Blogelator allows you to add a blog to a Rails app.
module Blogelator
def self.table_name_prefix
"blogelator_"
end
end
2 changes: 1 addition & 1 deletion blogelator.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ Gem::Specification.new do |s|
s.add_dependency "pygments.rb", "~> 0.6"
s.add_dependency "rails", "~> 4.0"
s.add_dependency "redcarpet", "~> 3.3"
s.add_dependency "turbolinks", "~> 2.5"
s.add_dependency "turbolinks", "~> 5.0"
s.add_development_dependency "rake"
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
81 changes: 0 additions & 81 deletions lib/blogelator/admin/author.rb

This file was deleted.

Loading

0 comments on commit 777f3b9

Please sign in to comment.