forked from revolutionhealth/acts_as_seo_friendly
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15baddf
commit ac11843
Showing
25 changed files
with
535 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Place all the behaviors and hooks related to the matching controller here. | ||
// All this logic will automatically be available in application.js. |
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,4 @@ | ||
/* | ||
Place all the styles related to the matching controller here. | ||
They will automatically be included in application.css. | ||
*/ |
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,56 @@ | ||
body { background-color: #fff; color: #333; } | ||
|
||
body, p, ol, ul, td { | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; | ||
} | ||
|
||
pre { | ||
background-color: #eee; | ||
padding: 10px; | ||
font-size: 11px; | ||
} | ||
|
||
a { color: #000; } | ||
a:visited { color: #666; } | ||
a:hover { color: #fff; background-color:#000; } | ||
|
||
div.field, div.actions { | ||
margin-bottom: 10px; | ||
} | ||
|
||
#notice { | ||
color: green; | ||
} | ||
|
||
.field_with_errors { | ||
padding: 2px; | ||
background-color: red; | ||
display: table; | ||
} | ||
|
||
#error_explanation { | ||
width: 450px; | ||
border: 2px solid red; | ||
padding: 7px; | ||
padding-bottom: 0; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; | ||
} | ||
|
||
#error_explanation h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 5px 5px 15px; | ||
font-size: 12px; | ||
margin: -7px; | ||
margin-bottom: 0px; | ||
background-color: #c00; | ||
color: #fff; | ||
} | ||
|
||
#error_explanation ul li { | ||
font-size: 12px; | ||
list-style: square; | ||
} |
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,58 @@ | ||
class ArticlesController < ApplicationController | ||
before_action :set_article, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /articles | ||
def index | ||
@articles = Article.all | ||
end | ||
|
||
# GET /articles/1 | ||
def show | ||
end | ||
|
||
# GET /articles/new | ||
def new | ||
@article = Article.new | ||
end | ||
|
||
# GET /articles/1/edit | ||
def edit | ||
end | ||
|
||
# POST /articles | ||
def create | ||
@article = Article.new(article_params) | ||
|
||
if @article.save | ||
redirect_to @article, notice: 'Article was successfully created.' | ||
else | ||
render action: 'new' | ||
end | ||
end | ||
|
||
# PATCH/PUT /articles/1 | ||
def update | ||
if @article.update(article_params) | ||
redirect_to @article, notice: 'Article was successfully updated.' | ||
else | ||
render action: 'edit' | ||
end | ||
end | ||
|
||
# DELETE /articles/1 | ||
def destroy | ||
@article.destroy | ||
redirect_to articles_url, notice: 'Article was successfully destroyed.' | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_article | ||
@article = Article.find(params[:id]) | ||
end | ||
|
||
# Only allow a trusted parameter "white list" through. | ||
def article_params | ||
params.require(:article).permit(:title, :body) | ||
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ArticlesHelper | ||
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Article < ActiveRecord::Base | ||
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<%= form_for(@article) do |f| %> | ||
<% if @article.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@article.errors.count, "error") %> prohibited this article from being saved:</h2> | ||
|
||
<ul> | ||
<% @article.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :title %><br> | ||
<%= f.text_field :title %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :body %><br> | ||
<%= f.text_area :body %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing article</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Show', @article %> | | ||
<%= link_to 'Back', articles_path %> |
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,29 @@ | ||
<h1>Listing articles</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Title</th> | ||
<th>Body</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @articles.each do |article| %> | ||
<tr> | ||
<td><%= article.title %></td> | ||
<td><%= article.body %></td> | ||
<td><%= link_to 'Show', article %></td> | ||
<td><%= link_to 'Edit', edit_article_path(article) %></td> | ||
<td><%= link_to 'Destroy', article, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Article', new_article_path %> |
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,5 @@ | ||
<h1>New article</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Back', articles_path %> |
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 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Title:</strong> | ||
<%= @article.title %> | ||
</p> | ||
|
||
<p> | ||
<strong>Body:</strong> | ||
<%= @article.body %> | ||
</p> | ||
|
||
<%= link_to 'Edit', edit_article_path(@article) %> | | ||
<%= link_to 'Back', articles_path %> |
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
Binary file not shown.
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,11 @@ | ||
class CreateArticles < ActiveRecord::Migration | ||
def change | ||
create_table :articles do |t| | ||
t.string :title | ||
t.text :body | ||
|
||
t.timestamps | ||
end | ||
Articles.create_seo_friendly_column() | ||
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[1m[36m (29.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m | ||
[1m[35m (5.3ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version") | ||
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m | ||
Migrating to CreateArticles (20130703005336) | ||
[1m[35m (0.1ms)[0m begin transaction | ||
[1m[36m (0.6ms)[0m [1mCREATE TABLE "articles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "body" text, "created_at" datetime, "updated_at" datetime) [0m | ||
[1m[35m (0.0ms)[0m rollback transaction | ||
[1m[36mActiveRecord::SchemaMigration Load (0.2ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m | ||
Migrating to CreateArticles (20130703005336) | ||
[1m[35m (0.1ms)[0m begin transaction | ||
[1m[36m (0.5ms)[0m [1mCREATE TABLE "articles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "body" text, "created_at" datetime, "updated_at" datetime) [0m | ||
[1m[35m (0.2ms)[0m rollback transaction |
Oops, something went wrong.