Commit 92261235 by tady

Merge pull request #94 from tadyjp/feat/templates

templatesページ作成
parents f27cab5b 98ce919b
# 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 templates controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
class TemplatesController < ApplicationController
def show
end
end
class TemplateDecorator < Draper::Decorator
delegate_all
# Define presentation-specific methods here. Helpers are accessed through
# `helpers` (aka `h`). You can override attributes, for example:
#
# def created_at
# helpers.content_tag :span, class: 'time' do
# object.created_at.strftime("%a %m/%d/%y")
# end
# end
end
module TemplatesHelper
end
......@@ -74,11 +74,11 @@ class Post < ActiveRecord::Base
# `id`以外をコピーする
_forked_post = Post.new(self.attributes.except('id'))
# `%Name`をユーザー名に置換
_forked_post.title = _forked_post.title.gsub(/%Name/, user.name)
# `%name`をユーザー名に置換
_forked_post.title = _forked_post.title.gsub(/%name/, user.name)
# `%Y`などを日付に変換
_forked_post.title = Time.now.strftime(_forked_post.title) # TODO
_forked_post.title = _forked_post.title + ' のコピー'
_forked_post.title = _forked_post.title
_forked_post.tag_ids = self.tag_ids
_forked_post.author = user
......
......@@ -4,8 +4,8 @@ html lang="ja"
head
title Rendezvous
meta content="width=device-width, initial-scale=1.0" name="viewport" /
link href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" rel="stylesheet" /
link href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap-theme.min.css" rel="stylesheet" /
link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" /
link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css" rel="stylesheet" /
link href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.css" rel="stylesheet" /
link href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.print.css" rel="stylesheet" /
link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"
......@@ -21,8 +21,8 @@ html lang="ja"
script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"
script src="//cdnjs.cloudflare.com/ajax/libs/underscore.string/2.3.3/underscore.string.min.js"
script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"
script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"
script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"
script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"
script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.5.1/moment.min.js"
script src="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/1.6.4/fullcalendar.min.js"
javascript:
......
......@@ -18,6 +18,9 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation"
li class=('active' if current_page?(flow_path))
a href=flow_path title="Frow"
| Flow
li class=('active' if current_page?(templates_path))
a href=templates_path title="Templates"
| Templates
ul.nav.navbar-nav.navbar-right
li
......
/ locals:
/ post {Post}
.list-group-item.post-list.mod-hover-hidden
.container-fluid
.row
.col-xs-9
h4.text-link #{post.title}
.col-xs-3
small.pull-right "##{post.id}"
.row
.col-xs-8
p.small.text-success
| #{post.author.name} posted&nbsp;
abbr.js-time-ago data-time-ago-at=post.updated_at
|.&nbsp;&nbsp;
- post.tags.each do |tag|
span.label.label-success ##{tag.name}
| &nbsp;
.col-xs-4
span.pull-right.label.label-danger = post.display_specified_date if post.specified_date
.btn-group.mod-hover-hidden
a.btn.btn-info.mod-hover-hidden-item href=fork_post_path(post)
| このテンプレートを利用する
a.btn.btn-default.mod-hover-hidden-item href=edit_post_path(post)
| このテンプレートを編集する
h1 テンプレートから作成
.panel.panel-info
.panel-heading
span.glyphicon.glyphicon-info-sign
| テンプレートの使い方
.panel-body
ul
li 「template」 というタグをつけた投稿はこのページに現れます
li コピーすることで同じフォーマットの文章が簡単に書けます
.list-group
- if template_tag = Tag.find_by(name: 'template')
- template_tag.posts.decorate.each do |_post|
= render partial: 'post', locals: { post: _post }
- else
| テンプレートが存在しません
Rendezvous::Application.routes.draw do
get 'templates/show'
post 'apis/markdown_preview'
post 'apis/file_receiver'
get 'apis/user_mention'
......@@ -11,6 +13,7 @@ Rendezvous::Application.routes.draw do
get 'stock' => 'stock#show', as: 'stock'
get 'flow' => 'flow#show', as: 'flow'
get 'search' => 'search#show', as: 'search'
get 'templates' => 'templates#show', as: 'templates'
get 'posts/:id/fork' => 'posts#fork', as: 'fork_post'
post 'posts/:id/mail' => 'posts#mail', as: 'mail_post'
......
require 'spec_helper'
require 'rails_helper'
describe ApisController, type: :controller do
......
require 'spec_helper'
require 'rails_helper'
describe ApplicationController do
......
require 'spec_helper'
require 'rails_helper'
class DummyClass; end
......
require 'spec_helper'
require 'rails_helper'
describe FlowController, type: :controller do
......
require 'spec_helper'
require 'rails_helper'
describe SearchController, type: :controller do
......
require 'spec_helper'
require 'rails_helper'
describe StockController, type: :controller do
......
require 'spec_helper'
require 'rails_helper'
describe TagsController, type: :controller do
......
require 'rails_helper'
RSpec.describe TemplatesController, :type => :controller do
describe "GET 'show' without template" do
it "returns http success" do
sign_in FactoryGirl.create(:alice)
get 'show'
expect(response).to be_success
end
end
describe "GET 'show' with template" do
it "returns http success" do
sign_in FactoryGirl.create(:alice)
get 'show'
expect(response).to be_success
end
end
end
require 'spec_helper'
require 'rails_helper'
describe UsersController, type: :controller do
......
require 'spec_helper'
require 'rails_helper'
describe WelcomeController, type: :controller do
......
require 'spec_helper'
require 'rails_helper'
describe ApisDecorator do
end
require 'spec_helper'
require 'rails_helper'
describe FlowDecorator do
end
require 'spec_helper'
require 'rails_helper'
describe SearchDecorator do
end
require 'spec_helper'
require 'rails_helper'
describe StockDecorator do
end
require 'spec_helper'
require 'rails_helper'
describe TagDecorator do
end
require 'rails_helper'
describe TemplateDecorator do
end
require 'spec_helper'
require 'rails_helper'
describe UsersDecorator do
end
require 'spec_helper'
require 'rails_helper'
include Warden::Test::Helpers
Warden.test_mode!
......
require 'spec_helper'
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the ApisHelper. For example:
......
require 'spec_helper'
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the FlowHelper. For example:
......
require 'spec_helper'
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the SearchHelper. For example:
......
require 'spec_helper'
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the StockHelper. For example:
......
require 'spec_helper'
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the TagsHelper. For example:
......
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the TemplatesHelper. For example:
#
# describe TemplatesHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe TemplatesHelper, :type => :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'spec_helper'
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the UsersHelper. For example:
......
......@@ -10,7 +10,7 @@
# updated_at :datetime
#
require 'spec_helper'
require 'rails_helper'
describe Comment do
describe 'validations' do
......
......@@ -12,7 +12,7 @@
# updated_at :datetime
#
require 'spec_helper'
require 'rails_helper'
describe Notification do
pending "add some examples to (or delete) #{__FILE__}"
......
......@@ -12,7 +12,7 @@
# specified_date :date
#
require 'spec_helper'
require 'rails_helper'
require 'date'
describe Post do
......@@ -36,7 +36,7 @@ describe Post do
end
it 'valid title' do
expect(@new_post.title).to eq('sample title のコピー')
expect(@new_post.title).to eq('sample title')
end
it 'valid body' do
......
......@@ -11,7 +11,7 @@
# posts_count :integer default(0), not null
#
require 'spec_helper'
require 'rails_helper'
describe Tag do
describe '#move_all_posts_to!' do
......
......@@ -23,7 +23,7 @@
# nickname :string(255) default(""), not null
#
require 'spec_helper'
require 'rails_helper'
describe User do
......
# coveralls
require 'coveralls'
Coveralls.wear!
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
require 'rspec/rails'
require 'rspec/autorun'
# require 'email_spec'
require 'factory_girl'
require 'capybara'
require 'capybara/rspec'
## Setting for polterguist.
require 'capybara/poltergeist'
def register_poltergeist(config)
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, timeout: 60, js_errors: false)
end
# Capybara.run_server = true
# Capybara.default_driver = :poltergeist
Capybara.javascript_driver = :poltergeist
Capybara.default_wait_time = 10
end
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
# Setting for turnip.
Dir.glob("spec/steps/**/*steps.rb") { |f| load f, true }
require 'turnip'
require 'turnip/capybara'
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = 'random'
config.include FactoryGirl::Syntax::Methods
# config.include(EmailSpec::Helpers)
# config.include(EmailSpec::Matchers)
config.before(:all) do
FactoryGirl.reload
end
config.include Capybara::DSL
config.before :suite do
DatabaseRewinder.clean_all
end
# config.before :each do
# end
config.after :each do
DatabaseRewinder.clean
end
config.include Devise::TestHelpers, :type => :controller
# config.extend ControllerMacros, :type => :controller
# Capybara.app_host = "http://127.0.0.1/"
register_poltergeist(config)
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:google_oauth2, {
'uid' => '12345',
'provider' => 'google_oauth2',
'info' => {'name' => 'Taro Yamada', 'email' => 'taro@zigexn.co.jp'},
'credentials' => {'token' => 'aaaaa', 'refresh_token' => 'bbbbb', 'expires_at' => 9999999999}
})
end
# coveralls
require 'coveralls'
Coveralls.wear!
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
Dir["./spec/support/**/*.rb"].sort.each { |f| require f }
require 'rspec/rails'
require 'rspec/autorun'
# require 'email_spec'
require 'factory_girl'
require 'capybara'
require 'capybara/rspec'
## Setting for polterguist.
require 'capybara/poltergeist'
def register_poltergeist(config)
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, timeout: 60, js_errors: false)
end
# Capybara.run_server = true
# Capybara.default_driver = :poltergeist
Capybara.javascript_driver = :poltergeist
Capybara.default_wait_time = 10
end
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
# Setting for turnip.
Dir.glob("spec/steps/**/*steps.rb") { |f| load f, true }
require 'turnip'
require 'turnip/capybara'
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = 'random'
config.include FactoryGirl::Syntax::Methods
# config.include(EmailSpec::Helpers)
# config.include(EmailSpec::Matchers)
config.before(:all) do
FactoryGirl.reload
end
config.include Capybara::DSL
config.before :suite do
DatabaseRewinder.clean_all
end
# config.before :each do
# end
config.after :each do
DatabaseRewinder.clean
end
config.include Devise::TestHelpers, :type => :controller
# config.extend ControllerMacros, :type => :controller
# Capybara.app_host = "http://127.0.0.1/"
register_poltergeist(config)
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:google_oauth2, {
'uid' => '12345',
'provider' => 'google_oauth2',
'info' => {'name' => 'Taro Yamada', 'email' => 'taro@zigexn.co.jp'},
'credentials' => {'token' => 'aaaaa', 'refresh_token' => 'bbbbb', 'expires_at' => 9999999999}
})
end
require 'rails_helper'
require 'rails_helper'
step 'access :site' do |site|
Capybara.app_host = site
end
......
require 'spec_helper'
describe "apis/markdown_preview.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'spec_helper'
describe "flow/show.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'spec_helper'
describe "posts/show.html.erb" do
describe "パンくず" do
pending
end
end
require 'spec_helper'
describe "search/show.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'spec_helper'
describe "stock/show.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'spec_helper'
describe "tags/show.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'spec_helper'
describe "users/edit.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'spec_helper'
describe "users/update.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
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