This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Naming is one of the hardest things in computer science: Using a „Page“ model is suboptimal, because it conflicts with Kaminari „paginator“ concept and Capybara #page method
- Loading branch information
Showing
50 changed files
with
399 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...s/javascripts/channels/page_update.coffee → ...s/javascripts/channels/post_update.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ssets/javascripts/init/pages/index.coffee → ...ssets/javascripts/init/posts/index.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class PostUpdateChannel < ApplicationCable::Channel | ||
def subscribed | ||
stop_all_streams | ||
|
||
if params[:post_id] | ||
post = Post.find(params[:post_id]) | ||
stream_for post | ||
end | ||
end | ||
|
||
def unsubscribed | ||
stop_all_streams | ||
end | ||
end |
72 changes: 36 additions & 36 deletions
72
app/controllers/pages_controller.rb → app/controllers/posts_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class PostRelayJob < ApplicationJob | ||
queue_as :default | ||
|
||
def perform(post) | ||
PostUpdateChannel.broadcast_to post, html: PostsController.render(action: 'show', layout: false, assigns: { post: post }) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
class Page < ApplicationRecord | ||
class Post < ApplicationRecord | ||
validates_presence_of :title, :content | ||
|
||
searchkick word_start: [ :title, :content ], | ||
highlight: [ :title, :content ], | ||
callbacks: :async | ||
|
||
after_commit on: :update do |page| | ||
PageRelayJob.perform_later(page) | ||
after_commit on: :update do |post| | ||
PostRelayJob.perform_later(post) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
10 changes: 5 additions & 5 deletions
10
app/views/pages/_form.html.slim → app/views/posts/_form.html.slim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
tr[data-href=url_for(post)] | ||
td.js-row-link | ||
- if search_string && post.search_highlights[:title] | ||
== post.search_highlights[:title] | ||
- else | ||
= post.title.truncate(80) | ||
td.js-row-link.text-muted | ||
- if search_string && post.search_highlights[:content] | ||
== post.search_highlights[:content] | ||
- else | ||
= post.content.truncate(100) | ||
td.js-row-link.text-right | ||
= time_tag post.updated_at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! post, :id, :title, :content, :created_at, :updated_at | ||
json.url post_url(post, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
h1 Editing Post | ||
= render 'form', post: @post |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.array! @posts, partial: 'posts/post', as: :post |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
h1 New Post | ||
= render 'form', post: @post |
14 changes: 7 additions & 7 deletions
14
app/views/pages/show.html.slim → app/views/posts/show.html.slim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
article data-cable-page-id=@page.id | ||
article data-cable-post-id=@post.id | ||
header.row | ||
.col-sm-11.col-sm-offset-1 | ||
h1 | ||
= @page.title | ||
= @post.title | ||
|
||
p.text-muted | ||
| Updated | ||
' | ||
= time_tag(@page.updated_at) | ||
= time_tag(@post.updated_at) | ||
|
||
.row | ||
.col-sm-1 | ||
.btn-group-vertical[role='group'] | ||
= link_to page_path(@page, format: 'pdf'), class: 'btn btn-default btn-lg', data: { turbolinks: 'false' }, title: 'Export Page as PDF' do | ||
= link_to post_path(@post, format: 'pdf'), class: 'btn btn-default btn-lg', data: { turbolinks: 'false' }, title: 'Export Post as PDF' do | ||
= icon('file-pdf-o') | ||
|
||
= link_to edit_page_path(@page), class: 'btn btn-default btn-lg', title: 'Edit Page' do | ||
= link_to edit_post_path(@post), class: 'btn btn-default btn-lg', title: 'Edit Post' do | ||
= icon('pencil') | ||
|
||
= link_to @page, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-lg', role: 'button', title: 'Destroy' do | ||
= link_to @post, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-lg', role: 'button', title: 'Destroy' do | ||
= icon('trash') | ||
|
||
.col-sm-11 | ||
= simple_format h(@page.content) | ||
= simple_format h(@post.content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "posts/post", post: @post |
Oops, something went wrong.