Commit e370f672 authored by Milan's avatar Milan

add rails_admin, refactor basic blogging pages

parent f48647a4
......@@ -8,6 +8,12 @@ gem "pg", "0.18.4"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0'
gem 'remotipart', github: 'mshibuya/remotipart'
gem 'rails_admin', '>= 1.0.0.rc'
#gem "feedjira", github: "feedjira/feedjira"
# Use sqlite3 as the database for Active Record
# Use Puma as the app server
gem 'puma', '~> 3.0'
......
GIT
remote: git://github.com/feedjira/feedjira.git
revision: faae46e3cdc59ab136c276166b2ed8164f27e987
specs:
feedjira (2.0.0)
faraday (~> 0.9)
faraday_middleware (~> 0.9)
loofah (~> 2.0)
sax-machine (~> 1.0)
GIT
remote: git://github.com/mshibuya/remotipart.git
revision: 88d9a7d55bde66acb6cf3a3c6036a5a1fc991d5e
specs:
remotipart (1.2.1)
GEM
remote: https://rubygems.org/
specs:
......@@ -56,9 +72,17 @@ GEM
concurrent-ruby (1.0.2)
erubis (2.7.0)
execjs (2.7.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.10.0)
faraday (>= 0.7.4, < 0.10)
ffi (1.9.14)
font-awesome-rails (4.6.3.1)
railties (>= 3.2, < 5.1)
globalid (0.3.7)
activesupport (>= 4.1.0)
haml (4.0.7)
tilt
i18n (0.7.0)
jbuilder (2.6.0)
activesupport (>= 3.0.0, < 5.1)
......@@ -67,6 +91,11 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (5.0.5)
railties (>= 3.2.16)
kaminari (0.17.0)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
......@@ -82,6 +111,8 @@ GEM
mini_portile2 (2.1.0)
minitest (5.9.0)
multi_json (1.12.1)
multipart-post (2.0.0)
nested_form (0.3.2)
nio4r (1.2.1)
nokogiri (1.6.8)
mini_portile2 (~> 2.1.0)
......@@ -90,6 +121,9 @@ GEM
pkg-config (1.1.7)
puma (3.6.0)
rack (2.0.1)
rack-pjax (1.0.0)
nokogiri (~> 1.5)
rack (>= 1.1)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.0.1)
......@@ -109,6 +143,19 @@ GEM
nokogiri (~> 1.6.0)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails_admin (1.0.0.rc)
builder (~> 3.1)
coffee-rails (~> 4.0)
font-awesome-rails (>= 3.0, < 5)
haml (~> 4.0)
jquery-rails (>= 3.0, < 5)
jquery-ui-rails (~> 5.0)
kaminari (~> 0.14)
nested_form (~> 0.3)
rack-pjax (>= 0.7)
rails (>= 4.0, < 6)
remotipart (~> 1.0)
sass-rails (>= 4.0, < 6)
railties (5.0.0.1)
actionpack (= 5.0.0.1)
activesupport (= 5.0.0.1)
......@@ -128,6 +175,7 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sax-machine (1.3.2)
simple_form (3.3.1)
actionpack (> 4, < 5.1)
activemodel (> 4, < 5.1)
......@@ -159,13 +207,16 @@ DEPENDENCIES
bootstrap-sass (~> 3.3)
byebug
coffee-rails (~> 4.2)
feedjira!
jbuilder (~> 2.5)
jquery-rails
listen
pg (= 0.18.4)
puma (~> 3.0)
rails (~> 5.0.0)
rails_admin (>= 1.0.0.rc)
redcarpet (= 3.3.4)
remotipart!
sass-rails (~> 5.0)
simple_form (~> 3.2)
turbolinks (~> 5)
......
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
// Place all the styles related to the blog controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
......@@ -6,15 +6,19 @@ module ApplicationHelper
not request.authorization.nil?
end
def markdown(content)
@markdown ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, {
autolink: true,
space_after_headers: true,
fenced_code_blocks: true,
underline: true,
highlight: true,
footnotes: true,
tables: true
})
@markdown.render(content)
end
@markdown ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, {
autolink: true,
space_after_headers: true,
fenced_code_blocks: true,
underline: true,
highlight: true,
footnotes: true,
tables: true
})
@markdown.render(content)
end
def markdownify text
Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true).render(text).html_safe
end
end
module BlogHelper
end
<% content_for :title, t('blogposts.index.title') %>
<h1>Blog</h1>
<ul id="posts">
<%- @blogposts.each_with_index do |blogpost,index| %>
<div class="page-header clearfix <%- if index != 0 %>headline-only<%- end %>">
<h2><%= link_to blogpost.title, blog_path(blogpost) %> <small class="pull-right"><%= l blogpost.created_at, format: :blog_headline %></small></h2>
</div>
<%- if index == 0 %>
<%= markdownify blogpost.body %>
<%- end %>
<% end %>
</ul>
<% content_for :title, t('blogposts.show.title') %>
<div class="content">
<h2><%= @blogposts.title %>
<span class="lead pull-right"><%= l @blogposts.created_at, format: :blog_headline %></span></h2>
<p><%= markdown(@blogposts.body).html_safe %></p>
<hr>
<%= link_to t('blogposts.show.all_posts'), blog_index_path, class: "btn btn-default" %>
</div>
<h1>Edit a Post</h1>
<% content_for :title, t('blogposts.edit.title') %>
<%= render partial: 'form' %>
<% content_for :title, t('blogposts.index.title') %>
<h1>All Posts</h1>
<ul id="posts">
......
<% content_for :title, t('blogposts.new.title') %>
<h1>New Post</h1>
<%= render partial: 'form' %>
<% content_for :title, t('blogposts.show.title') %>
<div class="content">
<h2><%= @blogposts.title %></h2>
<p><%= markdown(@blogposts.body).html_safe %></p>
<hr>
<%= link_to "<< Back to all Posts", blogposts_path %><div style="padding-left:1em;"></div>
<%= link_to "edit", edit_blogpost_path(@blogposts) %><div style="padding-left:1em;"></div>
<%= link_to "delete", blogpost_path(@blogposts), method: :delete, data: {confirm: "Really delete the article?"} %>
<%= link_to t('blogposts.show.all_posts'), blogposts_path, class: "btn btn-default" %>
<%= link_to t('blogposts.show.edit_post'), edit_blogpost_path(@blogposts), class: "btn btn-info" %>
<%= link_to t('blogposts.show.delete_post'), blogpost_path(@blogposts), method: :delete, data: {confirm: t('blogposts.delete_post_confirm')}, class: "btn btn-danger" %>
</div>
RailsAdmin.config do |config|
### Popular gems integration
## == Devise ==
# config.authenticate_with do
# warden.authenticate! scope: :user
# end
# config.current_user_method(&:current_user)
## == Cancan ==
# config.authorize_with :cancan
## == Pundit ==
# config.authorize_with :pundit
## == PaperTrail ==
# config.audit_with :paper_trail, 'User', 'PaperTrail::Version' # PaperTrail >= 3.0.0
### More at https://github.com/sferik/rails_admin/wiki/Base-configuration
## == Gravatar integration ==
## To disable Gravatar integration in Navigation Bar set to false
# config.show_gravatar true
config.actions do
dashboard # mandatory
index # mandatory
new
export
bulk_delete
show
edit
delete
show_in_app
## With an audit adapter, you can add:
# history_index
# history_show
end
end
de:
time:
formats:
blog_headline: ~
nav:
home: "Home"
rules: "Regeln"
......@@ -187,3 +190,15 @@ de:
townhall:
title: "coeseta's Stadthalle"
headline: "..:: coeseta's stadthalle ::.."
blogposts:
show:
title: "Titel"
all_posts: "Alle Posts"
edit_post: "Editieren"
delete_post: "Löschen"
edit:
title: "Post editieren"
header: "Editieren von"
en:
time:
formats:
blog_headline: "%d.%m.%Y"
nav:
home: "Home"
rules: "Rules"
......
Rails.application.routes.draw do
mount RailsAdmin::Engine => '/rails_admin', as: 'rails_admin'
get '/change_locale/:locale', to: 'settings#change_locale', as: :change_locale
controller :home do
......@@ -30,7 +31,7 @@ controller :admin do
end
#controller :blog do
resources :blogposts
resources :blog, only: [:index, :show]
# get 'blog' => 'blog#index', :as => 'blog'
# get 'blog
# root :to => 'blog#index'
......
class CreateBlogposts < ActiveRecord::Migration[5.0]
def change
create_table :blogposts do |t|
t.string :title
t.text :body
t.string :title, :null => false
t.text :body, :null => false
t.boolean :published, :default => false
t.timestamps
end
......
......@@ -10,16 +10,25 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160829101821) do
ActiveRecord::Schema.define(version: 20160830214608) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "blogposts", force: :cascade do |t|
t.string "title"
t.text "body"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "title", null: false
t.text "body", null: false
t.boolean "published", default: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "feeds", force: :cascade do |t|
t.string "name"
t.string "url"
t.text "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment