From 54750688c876a84172fa8d8556788d22a0561461 Mon Sep 17 00:00:00 2001 From: Alex Tharp Date: Sun, 12 Jul 2015 23:36:45 -0400 Subject: [PATCH] Implement "Use WYSIWYG" toggle functionality for Posts, to allow for raw HTML editing. --- .editorconfig | 1 + Gemfile.lock | 3 + app/api/v1/entities/post.rb | 1 + .../javascripts/controllers/posts/edit.js | 3 +- app/assets/javascripts/states.js | 1 + .../stylesheets/states/posts.edit.info.scss | 7 + app/assets/stylesheets/states/posts.edit.scss | 4 +- app/assets/templates/posts/article/info.html | 18 +++ app/assets/templates/posts/article/seo.html | 20 ++- app/assets/templates/posts/edit.html | 15 +- db/schema.rb | 133 ++++++++++-------- 11 files changed, 138 insertions(+), 68 deletions(-) diff --git a/.editorconfig b/.editorconfig index 7e423fca5..8484116e6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,5 +4,6 @@ root = true indent_style = space indent_size = 2 end_of_line = lf +insert_final_newline = true charset = utf-8 trim_trailing_whitespace = true diff --git a/Gemfile.lock b/Gemfile.lock index bf0ab3306..97f752206 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -701,3 +701,6 @@ DEPENDENCIES uglifier (~> 2.7.1) underscore-rails (~> 1.8.2) unicorn-rails (~> 2.2.0) + +BUNDLED WITH + 1.10.3 diff --git a/app/api/v1/entities/post.rb b/app/api/v1/entities/post.rb index 4cb76a68f..3c21e5e33 100644 --- a/app/api/v1/entities/post.rb +++ b/app/api/v1/entities/post.rb @@ -6,6 +6,7 @@ class Post < Grape::Entity expose :title, documentation: {desc: "Post Title", type: "String" , required: true} expose :type, documentation: {desc: "Post Type", type: "String", enum: ["ArticlePost", "VideoPost", "InfographicPost", "PromoPost"], required: true} expose :draft, documentation: {desc: "Draft status", type: "Boolean"} + expose :is_wysiwyg, documentation: {desc: "Post needs a WYSIWYG editor", type: "Boolean"} expose :comment_count, documentation: {desc: "Number of comments", type: "Integer"} expose :short_description, documentation: {desc: "Short description of the post", type: "String", required: true} expose :job_phase, documentation: {desc: "Job Phase", type: "String", enum: ["discovery", "find_the_job", "get_the_job", "on_the_job"], required: true} diff --git a/app/assets/javascripts/controllers/posts/edit.js b/app/assets/javascripts/controllers/posts/edit.js index b0fce57f7..e46866ff6 100644 --- a/app/assets/javascripts/controllers/posts/edit.js +++ b/app/assets/javascripts/controllers/posts/edit.js @@ -59,7 +59,8 @@ angular.module('cortex.controllers.posts.edit', [ plugins: ['media', 'imageFit'], minHeight: 800, buttonSource: true, - deniedTags: ['html', 'head', 'link', 'body', 'meta', 'applet'] // Allow script, style + deniedTags: [], + replaceDivs: false }; $scope.isAuthorUser = function(post) { diff --git a/app/assets/javascripts/states.js b/app/assets/javascripts/states.js index 9625089e4..4598ffe16 100644 --- a/app/assets/javascripts/states.js +++ b/app/assets/javascripts/states.js @@ -268,6 +268,7 @@ angular.module('cortex.states', [ var post = new cortex.posts(); post.body = ''; post.draft = true; + post.is_wysiwyg = true; post.author = currentUser.full_name; post.copyright_owner = post.copyright_owner || "CareerBuilder, LLC"; post.tag_list = ''; diff --git a/app/assets/stylesheets/states/posts.edit.info.scss b/app/assets/stylesheets/states/posts.edit.info.scss index e69de29bb..c0806ca7a 100644 --- a/app/assets/stylesheets/states/posts.edit.info.scss +++ b/app/assets/stylesheets/states/posts.edit.info.scss @@ -0,0 +1,7 @@ +.is-wysiwyg { + @extend .form-group; + + .is-wysiwyg-group { + @extend .input-group; + } +} diff --git a/app/assets/stylesheets/states/posts.edit.scss b/app/assets/stylesheets/states/posts.edit.scss index 6d8b4a38b..e77871f08 100644 --- a/app/assets/stylesheets/states/posts.edit.scss +++ b/app/assets/stylesheets/states/posts.edit.scss @@ -9,6 +9,8 @@ .editor { @extend .form-control; + + min-height: 800px; } } } @@ -134,4 +136,4 @@ span.has-error i::before { .form-control-feedback.select-feedback { pointer-events: none; right: 15px; - } \ No newline at end of file + } diff --git a/app/assets/templates/posts/article/info.html b/app/assets/templates/posts/article/info.html index 971439dfd..3bca9578c 100644 --- a/app/assets/templates/posts/article/info.html +++ b/app/assets/templates/posts/article/info.html @@ -78,3 +78,21 @@ required> + +
+ +
+ +
+

Consider disabling the WYSIWYG editor if you'd like to input raw HTML

+
diff --git a/app/assets/templates/posts/article/seo.html b/app/assets/templates/posts/article/seo.html index 99b2ddf35..bd64925db 100644 --- a/app/assets/templates/posts/article/seo.html +++ b/app/assets/templates/posts/article/seo.html @@ -24,4 +24,22 @@ ng-model="data.post.seo_description" ng-maxlength="255"> - \ No newline at end of file + + +
+ +
+ +
+

Consider disabling the WYSIWYG editor if you'd like to input raw HTML

+
diff --git a/app/assets/templates/posts/edit.html b/app/assets/templates/posts/edit.html index 429fc1519..cf8daf621 100644 --- a/app/assets/templates/posts/edit.html +++ b/app/assets/templates/posts/edit.html @@ -1,10 +1,17 @@
- +
+
+ +
+
+ +
+
diff --git a/db/schema.rb b/db/schema.rb index 6463a3de0..9ee8052e9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150512200711) do +ActiveRecord::Schema.define(version: 20150713025436) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -62,8 +62,8 @@ add_index "bulk_jobs", ["user_id"], name: "index_bulk_jobs_on_user_id", using: :btree create_table "categories", force: :cascade do |t| - t.string "name", limit: 255 - t.integer "user_id", null: false + t.string "name" + t.integer "user_id", null: false t.integer "parent_id" t.integer "lft" t.integer "rgt" @@ -72,6 +72,12 @@ t.datetime "updated_at" end + add_index "categories", ["depth"], name: "index_categories_on_depth", using: :btree + add_index "categories", ["lft"], name: "index_categories_on_lft", using: :btree + add_index "categories", ["parent_id"], name: "index_categories_on_parent_id", using: :btree + add_index "categories", ["rgt"], name: "index_categories_on_rgt", using: :btree + add_index "categories", ["user_id"], name: "index_categories_on_user_id", using: :btree + create_table "categories_posts", id: false, force: :cascade do |t| t.integer "post_id", null: false t.integer "category_id", null: false @@ -112,25 +118,26 @@ add_index "localizations", ["user_id"], name: "index_localizations_on_user_id", using: :btree create_table "media", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name" t.integer "user_id" - t.string "attachment_file_name", limit: 255 - t.string "attachment_content_type", limit: 255 + t.string "attachment_file_name" + t.string "attachment_content_type" t.integer "attachment_file_size" t.datetime "attachment_updated_at" - t.string "dimensions", limit: 255 + t.string "dimensions" t.text "description" - t.string "alt", limit: 255 + t.string "alt" t.boolean "active" t.datetime "deactive_at" t.datetime "created_at" t.datetime "updated_at" - t.string "digest", limit: 255 + t.string "digest" t.datetime "deleted_at" t.hstore "meta" - t.string "type", limit: 255, default: "Media", null: false + t.string "type", default: "Media", null: false end + add_index "media", ["name"], name: "index_media_on_name", using: :btree add_index "media", ["user_id"], name: "index_media_on_user_id", using: :btree create_table "media_posts", id: false, force: :cascade do |t| @@ -139,14 +146,14 @@ end create_table "oauth_access_grants", force: :cascade do |t| - t.integer "resource_owner_id", null: false - t.integer "application_id", null: false - t.string "token", limit: 255, null: false - t.integer "expires_in", null: false - t.text "redirect_uri", null: false - t.datetime "created_at", null: false + t.integer "resource_owner_id", null: false + t.integer "application_id", null: false + t.string "token", null: false + t.integer "expires_in", null: false + t.text "redirect_uri", null: false + t.datetime "created_at", null: false t.datetime "revoked_at" - t.string "scopes", limit: 255 + t.string "scopes" end add_index "oauth_access_grants", ["token"], name: "index_oauth_access_grants_on_token", unique: true, using: :btree @@ -154,12 +161,12 @@ create_table "oauth_access_tokens", force: :cascade do |t| t.integer "resource_owner_id" t.integer "application_id" - t.string "token", limit: 255, null: false - t.string "refresh_token", limit: 255 + t.string "token", null: false + t.string "refresh_token" t.integer "expires_in" t.datetime "revoked_at" - t.datetime "created_at", null: false - t.string "scopes", limit: 255 + t.datetime "created_at", null: false + t.string "scopes" end add_index "oauth_access_tokens", ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, using: :btree @@ -167,23 +174,23 @@ add_index "oauth_access_tokens", ["token"], name: "index_oauth_access_tokens_on_token", unique: true, using: :btree create_table "oauth_applications", force: :cascade do |t| - t.string "name", limit: 255, null: false - t.string "uid", limit: 255, null: false - t.string "secret", limit: 255, null: false - t.text "redirect_uri", null: false + t.string "name", null: false + t.string "uid", null: false + t.string "secret", null: false + t.text "redirect_uri", null: false t.datetime "created_at" t.datetime "updated_at" t.integer "owner_id" - t.string "owner_type", limit: 255 - t.string "scopes", default: "", null: false + t.string "owner_type" + t.string "scopes", default: "", null: false end add_index "oauth_applications", ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree add_index "oauth_applications", ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree create_table "onet_occupations", force: :cascade do |t| - t.string "soc", limit: 255 - t.string "title", limit: 255 + t.string "soc" + t.string "title" t.text "description" t.datetime "created_at" t.datetime "updated_at" @@ -195,38 +202,40 @@ end create_table "posts", force: :cascade do |t| - t.integer "user_id", null: false - t.string "title", limit: 255 + t.integer "user_id", null: false + t.string "title" t.datetime "published_at" t.datetime "expired_at" t.datetime "deleted_at" - t.boolean "draft", default: true, null: false - t.integer "comment_count", default: 0, null: false + t.boolean "draft", default: true, null: false + t.integer "comment_count", default: 0, null: false t.text "body" t.datetime "created_at" t.datetime "updated_at" - t.string "short_description", limit: 255 - t.integer "job_phase", null: false - t.integer "display", null: false + t.string "short_description" + t.integer "job_phase", null: false + t.integer "display", null: false t.text "notes" - t.string "copyright_owner", limit: 255 - t.string "seo_title", limit: 255 - t.string "seo_description", limit: 255 - t.string "seo_preview", limit: 255 - t.string "custom_author", limit: 255 - t.string "slug", null: false + t.string "copyright_owner" + t.string "seo_title" + t.string "seo_description" + t.string "seo_preview" + t.string "custom_author" + t.string "slug", null: false t.integer "featured_media_id" t.integer "primary_industry_id" t.integer "primary_category_id" t.integer "tile_media_id" t.hstore "meta" - t.string "type", default: "Post", null: false + t.string "type", default: "Post", null: false t.integer "author_id" + t.boolean "is_wysiwyg", default: true end add_index "posts", ["author_id"], name: "index_posts_on_author_id", using: :btree add_index "posts", ["slug"], name: "index_posts_on_slug", unique: true, using: :btree add_index "posts", ["type"], name: "index_posts_on_type", using: :btree + add_index "posts", ["user_id"], name: "index_posts_on_user_id", using: :btree create_table "snippets", force: :cascade do |t| t.integer "webpage_id", null: false @@ -242,9 +251,9 @@ create_table "taggings", force: :cascade do |t| t.integer "tag_id" t.integer "taggable_id" - t.string "taggable_type", limit: 255 + t.string "taggable_type" t.integer "tagger_id" - t.string "tagger_type", limit: 255 + t.string "tagger_type" t.string "context", limit: 128 t.datetime "created_at" end @@ -253,8 +262,8 @@ add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree create_table "tags", force: :cascade do |t| - t.string "name", limit: 255 - t.integer "taggings_count", default: 0 + t.string "name" + t.integer "taggings_count", default: 0 end add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree @@ -270,8 +279,8 @@ t.string "contact_email", limit: 200 t.string "contact_phone", limit: 20 t.datetime "deleted_at" - t.string "contract", limit: 255 - t.string "did", limit: 255 + t.string "contract" + t.string "did" t.datetime "active_at" t.datetime "deactive_at" t.integer "owner_id" @@ -279,27 +288,29 @@ t.datetime "updated_at" end + add_index "tenants", ["did"], name: "index_tenants_on_did", using: :btree + add_index "tenants", ["owner_id"], name: "index_tenants_on_owner_id", using: :btree add_index "tenants", ["parent_id"], name: "index_tenants_on_parent_id", using: :btree create_table "users", force: :cascade do |t| - t.string "email", limit: 255, default: "", null: false + t.string "email", default: "", null: false t.datetime "created_at" t.datetime "updated_at" - t.integer "tenant_id", null: false - t.string "encrypted_password", limit: 255, default: "", null: false - t.string "reset_password_token", limit: 255 + t.integer "tenant_id", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.string "current_sign_in_ip", limit: 255 - t.string "last_sign_in_ip", limit: 255 - t.string "firstname", limit: 255, null: false - t.string "lastname", limit: 255 - t.string "locale", limit: 30, default: "en_US", null: false - t.string "timezone", limit: 30, default: "EST", null: false - t.boolean "admin", default: false, null: false + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.string "firstname", null: false + t.string "lastname" + t.string "locale", limit: 30, default: "en_US", null: false + t.string "timezone", limit: 30, default: "EST", null: false + t.boolean "admin", default: false, null: false end add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree