exposition 0.0.3.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +25 -0
- data/app/assets/images/exposition/twitter.svg +10 -0
- data/app/assets/javascripts/exposition/admin/application.js +3 -0
- data/app/assets/stylesheets/exposition/_breakpoints.scss +5 -0
- data/app/assets/stylesheets/exposition/_code.scss +83 -0
- data/app/assets/stylesheets/exposition/_footer.scss +9 -0
- data/app/assets/stylesheets/exposition/_header.scss +62 -0
- data/app/assets/stylesheets/exposition/_layout.scss +28 -0
- data/app/assets/stylesheets/exposition/_mixins.scss +4 -0
- data/app/assets/stylesheets/exposition/_normalize.scss +427 -0
- data/app/assets/stylesheets/exposition/_pagination.scss +18 -0
- data/app/assets/stylesheets/exposition/_posts.scss +96 -0
- data/app/assets/stylesheets/exposition/_tags.scss +12 -0
- data/app/assets/stylesheets/exposition/_variables.scss +16 -0
- data/app/assets/stylesheets/exposition/admin/_layout.scss +58 -0
- data/app/assets/stylesheets/exposition/admin/_mixins.scss +3 -0
- data/app/assets/stylesheets/exposition/admin/_notifications.scss +46 -0
- data/app/assets/stylesheets/exposition/admin/_pagination.scss +12 -0
- data/app/assets/stylesheets/exposition/admin/_posts.scss +7 -0
- data/app/assets/stylesheets/exposition/admin/application.scss +9 -0
- data/app/assets/stylesheets/exposition/admin/base/_base.scss +15 -0
- data/app/assets/stylesheets/exposition/admin/base/_buttons.scss +31 -0
- data/app/assets/stylesheets/exposition/admin/base/_forms.scss +78 -0
- data/app/assets/stylesheets/exposition/admin/base/_grid-settings.scss +14 -0
- data/app/assets/stylesheets/exposition/admin/base/_lists.scss +31 -0
- data/app/assets/stylesheets/exposition/admin/base/_tables.scss +25 -0
- data/app/assets/stylesheets/exposition/admin/base/_typography.scss +55 -0
- data/app/assets/stylesheets/exposition/admin/base/_variables.scss +35 -0
- data/app/assets/stylesheets/exposition/admin/normalize.scss +427 -0
- data/app/assets/stylesheets/exposition/application.scss +17 -0
- data/app/controllers/exposition/admin/admin_controller.rb +5 -0
- data/app/controllers/exposition/admin/posts_controller.rb +5 -0
- data/app/controllers/exposition/admin/sessions_controller.rb +31 -0
- data/app/controllers/exposition/admin/tags_controller.rb +5 -0
- data/app/controllers/exposition/application_controller.rb +8 -0
- data/app/controllers/exposition/posts_controller.rb +5 -0
- data/app/controllers/exposition/tags_controller.rb +5 -0
- data/app/helpers/exposition/admin/flashes_helper.rb +7 -0
- data/app/helpers/exposition/admin/sessions_helper.rb +20 -0
- data/app/helpers/exposition/markdown_helper.rb +21 -0
- data/app/models/categorical/tag.rb +6 -0
- data/app/models/exposition/encryptor.rb +10 -0
- data/app/models/exposition/post.rb +5 -0
- data/app/models/exposition/user.rb +5 -0
- data/app/views/exposition/admin/images/index.html.haml +12 -0
- data/app/views/exposition/admin/images/new.html.haml +0 -0
- data/app/views/exposition/admin/posts/_error_handler.html.haml +8 -0
- data/app/views/exposition/admin/posts/_form_fields.html.haml +23 -0
- data/app/views/exposition/admin/posts/edit.html.haml +5 -0
- data/app/views/exposition/admin/posts/index.html.haml +23 -0
- data/app/views/exposition/admin/posts/new.html.haml +7 -0
- data/app/views/exposition/admin/posts/update.html.haml +2 -0
- data/app/views/exposition/admin/sessions/new.html.haml +10 -0
- data/app/views/exposition/admin/tags/_error_handler.html.haml +8 -0
- data/app/views/exposition/admin/tags/edit.html.haml +10 -0
- data/app/views/exposition/admin/tags/index.html.haml +18 -0
- data/app/views/exposition/admin/tags/new.html.haml +10 -0
- data/app/views/exposition/posts/_post.html.haml +8 -0
- data/app/views/exposition/posts/_tags.html.haml +6 -0
- data/app/views/exposition/posts/index.html.haml +8 -0
- data/app/views/exposition/posts/show.html.haml +5 -0
- data/app/views/exposition/tags/show.html.haml +6 -0
- data/app/views/layouts/exposition/admin.html.haml +22 -0
- data/app/views/layouts/exposition/application.html.haml +20 -0
- data/config/locales/en.yml +37 -0
- data/config/routes.rb +14 -0
- data/db/migrate/20160106220615_create_exposition_posters.rb +12 -0
- data/db/migrate/20160112194424_add_author_id_to_posts.rb +5 -0
- data/db/migrate/20160112200248_create_exposition_users.rb +14 -0
- data/db/migrate/20160112202302_add_slug_to_expositon_posts.rb +7 -0
- data/db/migrate/20160112204019_add_categorial_tags.rb +17 -0
- data/db/migrate/20160225203524_add_summary_to_posts.rb +5 -0
- data/db/migrate/20160226035733_convert_published_at_to_datetime.rb +9 -0
- data/lib/exposition.rb +19 -0
- data/lib/exposition/concerns/controllers/admin/admin_controller.rb +39 -0
- data/lib/exposition/concerns/controllers/admin/posts_controller.rb +70 -0
- data/lib/exposition/concerns/controllers/admin/tags_controller.rb +63 -0
- data/lib/exposition/concerns/controllers/posts_controller.rb +19 -0
- data/lib/exposition/concerns/controllers/tags_controller.rb +31 -0
- data/lib/exposition/concerns/models/post.rb +52 -0
- data/lib/exposition/concerns/models/user.rb +43 -0
- data/lib/exposition/engine.rb +14 -0
- data/lib/exposition/setup.rb +15 -0
- data/lib/exposition/version.rb +3 -0
- data/lib/tasks/exposition_tasks.rake +4 -0
- data/lib/tasks/setup.rb +17 -0
- data/spec/controllers/exposition/admin/admin_controller_spec.rb +88 -0
- data/spec/controllers/exposition/admin/posts_controller_spec.rb +153 -0
- data/spec/controllers/exposition/admin/sessions_controller_spec.rb +46 -0
- data/spec/controllers/exposition/admin/tags_controller_spec.rb +106 -0
- data/spec/controllers/exposition/posts_controller_spec.rb +43 -0
- data/spec/controllers/exposition/tags_controller_spec.rb +40 -0
- data/spec/dummy/Gemfile +5 -0
- data/spec/dummy/Gemfile.lock +173 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/Thorfile +1 -0
- data/spec/dummy/app/assets/javascripts/application.js +1 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +9 -0
- data/spec/dummy/bin/rake +9 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/bin/spring +15 -0
- data/spec/dummy/bin/thor +16 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +26 -0
- data/spec/dummy/config/boot.rb +3 -0
- data/spec/dummy/config/database.yml +12 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/schema.rb +62 -0
- data/spec/dummy/db/seeds.rb +22 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/factories/categorical/tags.rb +5 -0
- data/spec/factories/posts.rb +8 -0
- data/spec/factories/taggings.rb +7 -0
- data/spec/factories/users.rb +7 -0
- data/spec/features/admin/post_management_spec.rb +95 -0
- data/spec/features/admin/session_management_spec.rb +40 -0
- data/spec/features/admin/tags_management_spec.rb +59 -0
- data/spec/features/posts_index_spec.rb +28 -0
- data/spec/features/viewing_a_post_spec.rb +21 -0
- data/spec/features/viewing_posts_by_tag_spec.rb +17 -0
- data/spec/helpers/admin/flashes_helper_spec.rb +29 -0
- data/spec/helpers/admin/sessions_helper_spec.rb +56 -0
- data/spec/helpers/markdown_helper_spec.rb +10 -0
- data/spec/models/categorical/tag_spec.rb +35 -0
- data/spec/models/exposition/post_spec.rb +123 -0
- data/spec/models/exposition/user_spec.rb +15 -0
- data/spec/rails_helper.rb +47 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/controllers.rb +6 -0
- data/spec/support/controllers/pagination.rb +17 -0
- data/spec/support/controllers/session_management.rb +20 -0
- data/spec/support/features.rb +6 -0
- data/spec/support/features/pagination.rb +22 -0
- data/spec/support/features/session_management.rb +17 -0
- data/spec/support/models.rb +5 -0
- data/spec/support/models/sluggable.rb +11 -0
- data/spec/tasks/setup_spec.rb +32 -0
- data/spec/views/admin/posts/index.html.haml_spec.rb +16 -0
- metadata +619 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
@import url(https://fonts.googleapis.com/css?family=Merriweather:300);
|
2
|
+
@import url(https://fonts.googleapis.com/css?family=Merriweather+Sans:300);
|
3
|
+
|
4
|
+
@import 'normalize';
|
5
|
+
@import 'bourbon';
|
6
|
+
@import 'neat';
|
7
|
+
@import 'variables';
|
8
|
+
@import 'mixins';
|
9
|
+
@import 'breakpoints';
|
10
|
+
@import 'layout';
|
11
|
+
@import 'posts';
|
12
|
+
@import 'tags';
|
13
|
+
@import 'header';
|
14
|
+
@import 'footer';
|
15
|
+
@import 'code';
|
16
|
+
@import 'pagination';
|
17
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Exposition
|
2
|
+
class Admin::SessionsController < Admin::AdminController
|
3
|
+
skip_before_action :authorize, only: [:new, :create]
|
4
|
+
|
5
|
+
def new
|
6
|
+
end
|
7
|
+
|
8
|
+
def create
|
9
|
+
user = User.find_by(email: params[:session][:email].downcase)
|
10
|
+
if user && user.authenticate(params[:session][:password])
|
11
|
+
# Log the user in and redirect to the user's show page.
|
12
|
+
|
13
|
+
user.set_encrypted_remember_token!
|
14
|
+
session[:user_id] = user.id
|
15
|
+
cookies.permanent.signed[:user_id] = user.id
|
16
|
+
cookies.permanent[:remember_token] = user.remember_token
|
17
|
+
redirect_to admin_posts_path
|
18
|
+
else
|
19
|
+
flash.now[:error] = t("sessions.failed_login")
|
20
|
+
render 'new'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def destroy
|
25
|
+
session.delete(:user_id)
|
26
|
+
cookies.delete(:user_id)
|
27
|
+
cookies.delete(:remember_token)
|
28
|
+
redirect_to root_url
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Exposition
|
2
|
+
module Admin::SessionsHelper
|
3
|
+
def current_user
|
4
|
+
if (user_id = session[:user_id])
|
5
|
+
@current_user ||= User.find_by(id: user_id)
|
6
|
+
elsif (user_id = cookies.signed[:user_id])
|
7
|
+
# TODO put this in admin controller for authentication check
|
8
|
+
user = User.find_by(id: user_id)
|
9
|
+
if user && user.authenticated?(cookies[:remember_token])
|
10
|
+
session[:user_id] = user.id
|
11
|
+
@current_user = user
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def logged_in?
|
17
|
+
!current_user.nil?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'redcarpet'
|
2
|
+
require 'rouge'
|
3
|
+
require 'rouge/plugins/redcarpet'
|
4
|
+
|
5
|
+
module Exposition
|
6
|
+
module MarkdownHelper
|
7
|
+
|
8
|
+
# Create a Redcarpet Renderer with Rouge code formatting.
|
9
|
+
# See: https://github.com/jneen/rouge#you-can-even-use-it-with-redcarpet
|
10
|
+
class HTMLwithHighlighting < Redcarpet::Render::HTML
|
11
|
+
include Rouge::Plugins::Redcarpet
|
12
|
+
end
|
13
|
+
|
14
|
+
def markdown_to_html(markdown)
|
15
|
+
@renderer ||=
|
16
|
+
Redcarpet::Markdown.new(HTMLwithHighlighting,
|
17
|
+
extensions = {fenced_code_blocks: true})
|
18
|
+
@renderer.render(markdown).html_safe
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Exposition
|
2
|
+
class Encryptor
|
3
|
+
# Returns the hash digest of the given string.
|
4
|
+
def self.encrypt(string)
|
5
|
+
cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST :
|
6
|
+
BCrypt::Engine.cost
|
7
|
+
BCrypt::Password.create(string, cost: cost)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
%p
|
2
|
+
= form.label :title
|
3
|
+
= form.text_field :title
|
4
|
+
%p
|
5
|
+
= form.label :summary
|
6
|
+
= form.text_area :summary
|
7
|
+
%p
|
8
|
+
= form.label :body
|
9
|
+
= form.text_area :body
|
10
|
+
%p
|
11
|
+
= form.label :author
|
12
|
+
= form.collection_select(:author_id, @authors, :id, :name)
|
13
|
+
%p
|
14
|
+
= form.label :slug
|
15
|
+
= form.text_field :slug
|
16
|
+
%p
|
17
|
+
= form.label :tag_ids, 'Tags'
|
18
|
+
= form.collection_check_boxes(:tag_ids, @tags, :id, :label) do |b|
|
19
|
+
= b.label { b.check_box + b.text }
|
20
|
+
%p
|
21
|
+
= form.label :published
|
22
|
+
= form.check_box :published
|
23
|
+
%p= form.submit
|
@@ -0,0 +1,23 @@
|
|
1
|
+
%section.posts
|
2
|
+
.admin-title-header
|
3
|
+
%h2 Posts
|
4
|
+
= link_to "Add New", exposition.new_admin_post_path
|
5
|
+
%table
|
6
|
+
%thead
|
7
|
+
%tr
|
8
|
+
%th Title
|
9
|
+
%th Article
|
10
|
+
%th Author
|
11
|
+
%th Slug
|
12
|
+
%th Tags
|
13
|
+
%th Manage
|
14
|
+
%tbody
|
15
|
+
- @posts.each do |post|
|
16
|
+
%tr.post{class: "#{post.css_classes}"}
|
17
|
+
%td= "#{post.title}"
|
18
|
+
%td= truncate(post.summary, length: 40, separator: ' ')
|
19
|
+
%td= "#{post.author.name}"
|
20
|
+
%td= "#{post.slug}"
|
21
|
+
%td= "#{post.tags.to_sentence}"
|
22
|
+
%td= link_to "Edit", exposition.edit_admin_post_path(post)
|
23
|
+
= paginate @posts
|
@@ -0,0 +1,7 @@
|
|
1
|
+
%section.new-post
|
2
|
+
.admin-title-header
|
3
|
+
%h2 New Post
|
4
|
+
= link_to "Back to Posts", admin_posts_path
|
5
|
+
= form_for @post, url: admin_posts_path, method: :post do |f|
|
6
|
+
= render partial: 'error_handler', locals: { model: @post }
|
7
|
+
= render partial: 'form_fields', locals: { form: f }
|
@@ -0,0 +1,10 @@
|
|
1
|
+
%section.new-tag
|
2
|
+
.admin-title-header
|
3
|
+
%h2 Edit Tag
|
4
|
+
= link_to "Back to Tags", admin_tags_path
|
5
|
+
= form_for @tag, url: admin_tag_path(@tag), method: :patch do |f|
|
6
|
+
= render partial: 'error_handler', locals: { model: @tag }
|
7
|
+
%p
|
8
|
+
= f.label :label
|
9
|
+
= f.text_field :label
|
10
|
+
%p= f.submit
|
@@ -0,0 +1,18 @@
|
|
1
|
+
%section.tags
|
2
|
+
.admin-title-header
|
3
|
+
%h2 Tags
|
4
|
+
= link_to "Add New", new_admin_tag_path
|
5
|
+
%table
|
6
|
+
%thead
|
7
|
+
%tr
|
8
|
+
%th Label
|
9
|
+
%th Manage
|
10
|
+
%tbody
|
11
|
+
- @tags.each do |tag|
|
12
|
+
%tr.tag
|
13
|
+
%td= "#{tag.label}"
|
14
|
+
%td
|
15
|
+
= link_to "Edit", edit_admin_tag_path(tag)
|
16
|
+
= link_to "Delete", admin_tag_path(tag), method: :delete
|
17
|
+
|
18
|
+
= paginate @tags
|
@@ -0,0 +1,10 @@
|
|
1
|
+
%section.new-tag
|
2
|
+
.admin-title-header
|
3
|
+
%h2 New Tag
|
4
|
+
= link_to "Back to Tags", admin_tags_path
|
5
|
+
= form_for @tag, url: admin_tags_path, method: :post do |f|
|
6
|
+
= render partial: 'error_handler', locals: { model: @tag }
|
7
|
+
%p
|
8
|
+
= f.label :label
|
9
|
+
= f.text_field :label
|
10
|
+
%p= f.submit
|
@@ -0,0 +1,22 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
|
5
|
+
%title Exposition
|
6
|
+
= stylesheet_link_tag 'exposition/admin/application', media: 'all', 'data-turbolinks-track' => true
|
7
|
+
= javascript_include_tag 'exposition/admin/application', 'data-turbolinks-track' => true
|
8
|
+
= csrf_meta_tags
|
9
|
+
%body
|
10
|
+
%nav.admin
|
11
|
+
%ul
|
12
|
+
%li= link_to "Posts", admin_posts_path
|
13
|
+
%li= link_to "Tags", admin_tags_path
|
14
|
+
- if logged_in?
|
15
|
+
%ul.login
|
16
|
+
%li= link_to current_user.name, admin_posts_path
|
17
|
+
%li= link_to t('sessions.destroy'), admin_logout_path, method: :delete
|
18
|
+
- if flash.any?
|
19
|
+
.flashes
|
20
|
+
- user_facing_flashes.each do |key, value|
|
21
|
+
%div{:class => "flash-#{key}"}= value
|
22
|
+
= yield
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%title= t('title')
|
5
|
+
= stylesheet_link_tag "exposition/application"
|
6
|
+
= csrf_meta_tags
|
7
|
+
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1.0, maximum-scale=1.0"}
|
8
|
+
%body
|
9
|
+
%header
|
10
|
+
%nav
|
11
|
+
%h1= link_to t('title'), '/'
|
12
|
+
%ul.social
|
13
|
+
%li= link_to(image_tag('exposition/twitter.svg', class: 'twitter'), '#')
|
14
|
+
%ul.menu
|
15
|
+
%li= link_to 'Static Page', '#'
|
16
|
+
= yield
|
17
|
+
|
18
|
+
%footer
|
19
|
+
.info
|
20
|
+
%p= "By #{t('owner')}"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
+
|
22
|
+
en:
|
23
|
+
title: 'Your Title'
|
24
|
+
owner: 'Your Name'
|
25
|
+
date:
|
26
|
+
formats:
|
27
|
+
default: "%m/%d/%Y"
|
28
|
+
time:
|
29
|
+
formats:
|
30
|
+
default: "%m/%d/%Y"
|
31
|
+
posts:
|
32
|
+
index:
|
33
|
+
no_posts_warning: 'There are no posts yet. Please check back later!'
|
34
|
+
sessions:
|
35
|
+
submit: 'Log in'
|
36
|
+
failed_login: 'Invalid user/password combination.'
|
37
|
+
destroy: 'Log Out'
|