Skip to content

Commit

Permalink
Merge pull request #33 from michellebonat/seo_1
Browse files Browse the repository at this point in the history
SEO part 1: meta titles and descriptions using variables; friendly ID install and setup; update forms and files for these configs; add google analytics.
  • Loading branch information
michellebonat committed Feb 9, 2017
2 parents 75f131a + 5fb548e commit d589078
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 38 deletions.
16 changes: 6 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,19 @@ gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem 'redcarpet'

group :development, :test do
gem 'byebug'
end

group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
gem 'bootstrap-sass'
gem 'devise'
gem 'haml-rails'
gem 'high_voltage'
gem 'pundit'
gem 'sendgrid'

gem 'simple_form'
gem 'google-analytics-rails', '1.1.0'
gem 'friendly_id'

group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'better_errors'
gem 'guard-bundler'
gem 'guard-rails'
Expand All @@ -39,6 +34,7 @@ group :development do
end

group :development, :test do
gem 'byebug'
gem 'factory_girl_rails'
gem 'faker'
gem 'rspec-rails'
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ GEM
i18n (~> 0.5)
ffi (1.9.10)
formatador (0.2.5)
friendly_id (5.0.4)
activerecord (>= 4.0.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
google-analytics-rails (1.1.0)
guard (2.13.0)
formatador (>= 0.2.4)
listen (>= 2.7, <= 4.0)
Expand Down Expand Up @@ -303,6 +306,8 @@ DEPENDENCIES
devise
factory_girl_rails
faker
friendly_id
google-analytics-rails (= 1.1.0)
guard-bundler
guard-rails
guard-rspec
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ class PostsController < ApplicationController
before_filter :authenticate, :except => [ :index, :show ]

def index
@meta_title = "Blog about full stack ruby rails programming, startups, and fintech"
@posts = Post.all.order('created_at DESC')
end

def new
end

def show
@post = Post.find(params[:id])
@meta_title = "Blog post on full stack ruby rails web software development, startups, and fintech"
@post = Post.friendly.find(params[:id])
end

def create
Expand Down
1 change: 1 addition & 0 deletions app/controllers/visitors_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class VisitorsController < ApplicationController
def resume
@meta_title = "Software engineer full stack ruby rails Michelle Bonat"
end
end
7 changes: 7 additions & 0 deletions app/models/post.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
class Post < ActiveRecord::Base
extend FriendlyId
friendly_id :permalink, use: [:slugged, :history, :finders]
# validates :permalink, presence: true, uniqueness: true

def should_generate_new_friendly_id?
permalink_changed?
end
end
3 changes: 2 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<%= analytics_init if GoogleAnalytics.valid_tracker? %>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= content_for?(:title) ? yield(:title) : "Michelle Bonat: software engineer and entrepreneur" %></title>
<title><%= @meta_title %></title>
<meta name="description" content="<%= content_for?(:description) ? yield(:description) : "My Application" %>">
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
Expand Down
30 changes: 15 additions & 15 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
!!!
%html
%head
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1.0"}
%title= content_for?(:title) ? yield(:title) : 'Mbonat Site'
%meta{:name => "description", :content => "#{content_for?(:description) ? yield(:description) : 'Mbonat Site'}"}
= stylesheet_link_tag 'application', media: 'all'
= javascript_include_tag 'application'
= csrf_meta_tags
%body
%header
= render 'layouts/navigation'
%main{:role => "main"}
= render 'layouts/messages'
= yield
-#!!!
-#%html
-# %head
-# %meta{:name => "viewport", :content => "width=device-width, initial-scale=1.0"}
-# %title= content_for?(:title) ? yield(:title) : 'Mbonat Site'
-# %meta{:name => "description", :content => "#{content_for?(:description) ? yield(:description) : 'Mbonat Site'}"}
-# = stylesheet_link_tag 'application', media: 'all'
-# = javascript_include_tag 'application'
-# = csrf_meta_tags
-# %body
-# %header
-# = render 'layouts/navigation'
-# %main{:role => "main"}
-# = render 'layouts/messages'
-# = yield
11 changes: 9 additions & 2 deletions app/views/posts/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@
<%= f.label :title %><br>
<%= f.text_field :title %><br>

<%= f.label :meta_title %><br>
<%= f.text_field :meta_title %><br>
<%= f.label :meta_description %><br>
<%= f.text_field :meta_description %><br>
<%= f.label :permalink %><br>
<%= f.text_field :permalink %><br>
<%= f.label :no_index %><br>
<%= f.check_box :no_index %><br>
<%= f.label :body %><br>
<%= f.text_area :body %><br>
<br>
<%= f.submit %>
<% end %>
<% end %>

<br>

10 changes: 5 additions & 5 deletions app/views/posts/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
%section.panel.panel-default
.row
.col-lg-10.col-lg-offset-1.text-left
%br/
%br/
%br
%br
%h1.title
= markdown_to_html @post.title
%p.date
Expand All @@ -15,8 +15,8 @@
%section
.row
.col-lg-10.col-lg-offset-1.text-left
%br/
%br
%h3 Like this? Star it on GitHub
%a.btn.btn-dark{:href => "https://github.com/michellebonat/mbonat_site", :target => "_blank"} Star It
%br/
%br/
%br
%br
3 changes: 3 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,7 @@

# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false

# This is the tracking code for Google Analytics using the Google Analytics Rails gem
GA.tracker = "UA-91104959-1"
end
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
# root to: 'visitors#index'
devise_for :users
resources :users
resources :posts

root to: 'visitors#index'
get 'resume', to: 'visitors#resume'

resources :posts, only: [:new, :index, :create]
resources :posts, :path=>'', except: [:new, :index, :create]
end
26 changes: 23 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160604225051) do
ActiveRecord::Schema.define(version: 20170208001323) do

create_table "blogit_comments", force: :cascade do |t|
t.string "name", null: false
Expand Down Expand Up @@ -45,13 +45,33 @@
t.datetime "updated_at", null: false
end

create_table "friendly_id_slugs", force: :cascade do |t|
t.string "slug", null: false
t.integer "sluggable_id", null: false
t.string "sluggable_type", limit: 50
t.string "scope"
t.datetime "created_at"
end

add_index "friendly_id_slugs", ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true
add_index "friendly_id_slugs", ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type"
add_index "friendly_id_slugs", ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id"
add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type"

create_table "posts", force: :cascade do |t|
t.string "title"
t.text "body"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "meta_title"
t.text "meta_description"
t.string "permalink"
t.boolean "no_index"
t.string "slug"
end

add_index "posts", ["slug"], name: "index_posts_on_slug", unique: true

create_table "taggings", force: :cascade do |t|
t.integer "tag_id"
t.integer "taggable_id"
Expand Down

0 comments on commit d589078

Please sign in to comment.