diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3d61cce..ba0910c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,10 +3,18 @@ def customized_emoji(user) user.favicon.present? ? user.favicon : "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/apple/155/writing-hand_270d.png" end + def post_pathy(post) + custom_domain? ? "/#{post.slug}" : "/#{post.user.username}/#{post.slug}" + end + def editable?(user) current_user && current_user == user end + def custom_domain? + request.host.present? && request.host != "localhost" && request.host != "youdontneedwp.com" && request.host != "www.youdontneedwp.com" + end + def set_home_meta_tags set_meta_tags( title: "You Don't Need WordPress: Create A Blog With Google Docs", diff --git a/app/views/i/posts/_bio.html.haml b/app/views/i/posts/_bio.html.haml index f36bac4..493d2af 100644 --- a/app/views/i/posts/_bio.html.haml +++ b/app/views/i/posts/_bio.html.haml @@ -1,6 +1,8 @@ +- home = custom_domain? ? "/" : "/#{user.username}" + .index-bio .index-bio__left - = link_to "/#{user.username}" do + = link_to home do - if user.avatar.present? = image_tag(user.avatar.url) - else @@ -12,7 +14,7 @@ = fa_icon "twitter" .index-bio__right .name - = link_to user.name, "/#{user.username}" + = link_to user.name, home .bio= user.bio - if editable?(user) .edit= link_to("edit bio", profile_path) diff --git a/app/views/i/posts/index.html.haml b/app/views/i/posts/index.html.haml index 0fb55a5..cbfb1f7 100644 --- a/app/views/i/posts/index.html.haml +++ b/app/views/i/posts/index.html.haml @@ -27,7 +27,7 @@ = post.published&.strftime("%B #{post.published&.day&.ordinalize}, %Y") - if post.meta.exists? .post-meta{ style: "background-image: url(#{post.meta.url})"} - = link_to(post.title, "/#{@user.username}/#{post.slug}") + = link_to(post.title, post_pathy(post)) - if editable?(@user) .post-bottom = link_to "Edit Post", edit_post_path(post.id) diff --git a/db/migrate/20190103102215_custom_domain.rb b/db/migrate/20190103102215_custom_domain.rb new file mode 100644 index 0000000..a71871d --- /dev/null +++ b/db/migrate/20190103102215_custom_domain.rb @@ -0,0 +1,5 @@ +class CustomDomain < ActiveRecord::Migration[5.2] + def change + add_column :users, :custom_domain, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 9d3567f..3b7d5ed 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_12_24_051544) do +ActiveRecord::Schema.define(version: 2019_01_03_102215) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -64,6 +64,7 @@ t.string "avatar_content_type" t.integer "avatar_file_size" t.datetime "avatar_updated_at" + t.string "custom_domain" t.index ["email"], name: "index_users_on_email", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end