Commit 213c4c140215c4318fe497d8e132ab0d60e11378
1 parent
ff2455db
work on Image part, check disabled page and block
Showing
11 changed files
with
111 additions
and
75 deletions
| @@ -194,21 +194,16 @@ jQuery(document).ready(function(){ | @@ -194,21 +194,16 @@ jQuery(document).ready(function(){ | ||
| 194 | }else{ | 194 | }else{ |
| 195 | var $cell = $this.closest('.col') | 195 | var $cell = $this.closest('.col') |
| 196 | } | 196 | } |
| 197 | - var id = $cell.data('id'); | ||
| 198 | - var $block = $cell.closest('.html-generator'); | ||
| 199 | - var disable_url = $block.data('disable-url'); | ||
| 200 | - | ||
| 201 | 197 | ||
| 202 | - jQuery.ajax({ | ||
| 203 | - type: 'POST', | ||
| 204 | - url: disable_url, | ||
| 205 | - data: {structure_id: id}, | ||
| 206 | - success: function (data) { | ||
| 207 | - if(data.status == 'ok'){ | ||
| 208 | - alert('1'); | ||
| 209 | - } | ||
| 210 | - } | ||
| 211 | - }); | 198 | + if($cell.data('status') == undefined || $cell.data('status') == 'enabled'){ |
| 199 | + $cell.data('status', 'disabled'); | ||
| 200 | + $this.find('i').removeClass('glyphicon-eye-open'); | ||
| 201 | + $this.find('i').addClass('glyphicon-eye-close'); | ||
| 202 | + }else{ | ||
| 203 | + $cell.data('status', 'enabled'); | ||
| 204 | + $this.find('i').removeClass('glyphicon-eye-close'); | ||
| 205 | + $this.find('i').addClass('glyphicon-eye-open'); | ||
| 206 | + } | ||
| 212 | 207 | ||
| 213 | return false; | 208 | return false; |
| 214 | }); | 209 | }); |
| @@ -426,10 +421,18 @@ jQuery(document).ready(function(){ | @@ -426,10 +421,18 @@ jQuery(document).ready(function(){ | ||
| 426 | $block.find('.col').each(function(){ | 421 | $block.find('.col').each(function(){ |
| 427 | var $this = $(this), | 422 | var $this = $(this), |
| 428 | html = $this.html(), | 423 | html = $this.html(), |
| 429 | - innerContent = '<div class="col-inner">' + | 424 | + statusClass = ''; |
| 425 | + | ||
| 426 | + if($this.data('status') == 'enabled'){ | ||
| 427 | + statusClass = 'glyphicon-eye-open'; | ||
| 428 | + }else{ | ||
| 429 | + statusClass = 'glyphicon-eye-close'; | ||
| 430 | + } | ||
| 431 | + | ||
| 432 | + var innerContent = '<div class="col-inner">' + | ||
| 430 | '<div class="col-html">'+ html +'</div>' + | 433 | '<div class="col-html">'+ html +'</div>' + |
| 431 | '<div class="col-operation">' + | 434 | '<div class="col-operation">' + |
| 432 | - '<a class="col-disable" href="javascript;void(0);"><i class="glyphicon glyphicon-eye-open"></i></a>' + | 435 | + '<a class="col-disable" href="javascript;void(0);"><i class="glyphicon '+ statusClass +'"></i></a>' + |
| 433 | '<a class="col-duplicate" href="javascript;void(0);"><i class="glyphicon glyphicon-file"></i></a>' + | 436 | '<a class="col-duplicate" href="javascript;void(0);"><i class="glyphicon glyphicon-file"></i></a>' + |
| 434 | '<a class="col-content" href="javascript;void(0);"><i class="glyphicon glyphicon-pencil"></i></a>' + | 437 | '<a class="col-content" href="javascript;void(0);"><i class="glyphicon glyphicon-pencil"></i></a>' + |
| 435 | '<a class="col-edit" href="javascript;void(0);"><i class="glyphicon glyphicon-cog"></i></a>' + | 438 | '<a class="col-edit" href="javascript;void(0);"><i class="glyphicon glyphicon-cog"></i></a>' + |
| @@ -442,13 +445,21 @@ jQuery(document).ready(function(){ | @@ -442,13 +445,21 @@ jQuery(document).ready(function(){ | ||
| 442 | 445 | ||
| 443 | 446 | ||
| 444 | $block.find('.row-fluid').each(function(){ | 447 | $block.find('.row-fluid').each(function(){ |
| 448 | + var $cell = $(this), | ||
| 449 | + statusClass = ''; | ||
| 450 | + | ||
| 451 | + if($cell.data('status') == 'enabled'){ | ||
| 452 | + statusClass = 'glyphicon-eye-open'; | ||
| 453 | + }else{ | ||
| 454 | + statusClass = 'glyphicon-eye-close'; | ||
| 455 | + } | ||
| 445 | 456 | ||
| 446 | var innerContent = '<div class="row-inner">' + | 457 | var innerContent = '<div class="row-inner">' + |
| 447 | '<div class="row-operation">' + | 458 | '<div class="row-operation">' + |
| 448 | '<a class="row-remove" href="javascript;void(0);"><i class="glyphicon glyphicon-trash"></i></a>'; | 459 | '<a class="row-remove" href="javascript;void(0);"><i class="glyphicon glyphicon-trash"></i></a>'; |
| 449 | 460 | ||
| 450 | if($(this).hasClass('row-element-block')) { | 461 | if($(this).hasClass('row-element-block')) { |
| 451 | - innerContent += '<a class="col-disable" href="javascript;void(0);"><i class="glyphicon glyphicon-eye-open"></i></a>'; | 462 | + innerContent += '<a class="col-disable" href="javascript;void(0);"><i class="glyphicon '+ statusClass +'"></i></a>'; |
| 452 | innerContent += '<a class="col-duplicate" href="javascript;void(0);"><i class="glyphicon glyphicon-file"></i></a>'; | 463 | innerContent += '<a class="col-duplicate" href="javascript;void(0);"><i class="glyphicon glyphicon-file"></i></a>'; |
| 453 | innerContent += '<a class="col-content" href="javascript;void(0);"><i class="glyphicon glyphicon-pencil"></i></a>'; | 464 | innerContent += '<a class="col-content" href="javascript;void(0);"><i class="glyphicon glyphicon-pencil"></i></a>'; |
| 454 | } | 465 | } |
| @@ -617,8 +628,13 @@ jQuery(document).ready(function(){ | @@ -617,8 +628,13 @@ jQuery(document).ready(function(){ | ||
| 617 | row_attributes = {}; | 628 | row_attributes = {}; |
| 618 | 629 | ||
| 619 | if($row.hasClass('row-element-block')){ | 630 | if($row.hasClass('row-element-block')){ |
| 620 | - row_attributes['type'] = 'block'; | ||
| 621 | - row_attributes['id'] = $row.data('id'); | 631 | + row_attributes['type'] = 'block'; |
| 632 | + row_attributes['id'] = $row.data('id'); | ||
| 633 | + if($row.data('status') == undefined || $row.data('status') == 'enabled'){ | ||
| 634 | + row_attributes['status'] = 'enabled'; | ||
| 635 | + }else{ | ||
| 636 | + row_attributes['status'] = 'disabled'; | ||
| 637 | + } | ||
| 622 | }else{ | 638 | }else{ |
| 623 | row_attributes['type'] = 'row'; | 639 | row_attributes['type'] = 'row'; |
| 624 | } | 640 | } |
| @@ -637,6 +653,12 @@ jQuery(document).ready(function(){ | @@ -637,6 +653,12 @@ jQuery(document).ready(function(){ | ||
| 637 | id: id | 653 | id: id |
| 638 | }; | 654 | }; |
| 639 | 655 | ||
| 656 | + if($cell.data('status') == undefined || $cell.data('status') == 'enabled'){ | ||
| 657 | + attributes['status'] = 'enabled'; | ||
| 658 | + }else{ | ||
| 659 | + attributes['status'] = 'disabled'; | ||
| 660 | + } | ||
| 661 | + | ||
| 640 | if(className != undefined){ | 662 | if(className != undefined){ |
| 641 | attributes['className'] = className; | 663 | attributes['className'] = className; |
| 642 | } | 664 | } |
| @@ -649,7 +671,6 @@ jQuery(document).ready(function(){ | @@ -649,7 +671,6 @@ jQuery(document).ready(function(){ | ||
| 649 | res.push({attributes: row_attributes, cells: cells}); | 671 | res.push({attributes: row_attributes, cells: cells}); |
| 650 | }); | 672 | }); |
| 651 | 673 | ||
| 652 | - | ||
| 653 | jQuery.ajax({ | 674 | jQuery.ajax({ |
| 654 | type: 'GET', | 675 | type: 'GET', |
| 655 | url: url, | 676 | url: url, |
| @@ -136,16 +136,6 @@ module Kanjai | @@ -136,16 +136,6 @@ module Kanjai | ||
| 136 | end | 136 | end |
| 137 | end | 137 | end |
| 138 | 138 | ||
| 139 | - def disable_block | ||
| 140 | - @page = Page.find(params[:id]) | ||
| 141 | - @page_data = @page.page_data.find_by_lang(params[:lang]) | ||
| 142 | - @structure_id = params[:structure_id] | ||
| 143 | - @obj = @page_data.page_contents.find_by_structure_id(@structure_id) | ||
| 144 | - Page.transaction do | ||
| 145 | - render json: {status: 'ok'} | ||
| 146 | - end | ||
| 147 | - end | ||
| 148 | - | ||
| 149 | def update_editor | 139 | def update_editor |
| 150 | @page = Page.find(params[:id]) | 140 | @page = Page.find(params[:id]) |
| 151 | @page_data = @page.page_data.find_by_lang(params[:lang]) | 141 | @page_data = @page.page_data.find_by_lang(params[:lang]) |
| @@ -7,6 +7,9 @@ module Kanjai | @@ -7,6 +7,9 @@ module Kanjai | ||
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | def show | 9 | def show |
| 10 | + if @page_data.page.block? | ||
| 11 | + render :template => 'kanjai/shared/401', status: 401, layout: false and return | ||
| 12 | + end | ||
| 10 | #expires_in 10.minutes, :public => true | 13 | #expires_in 10.minutes, :public => true |
| 11 | if @page_data | 14 | if @page_data |
| 12 | if @page_data.page.private_flag == true | 15 | if @page_data.page.private_flag == true |
| @@ -12,6 +12,8 @@ module Kanjai | @@ -12,6 +12,8 @@ module Kanjai | ||
| 12 | html_attributes = {} | 12 | html_attributes = {} |
| 13 | html_attributes[:class] = class_name | 13 | html_attributes[:class] = class_name |
| 14 | 14 | ||
| 15 | + html_attributes['data-status'] = row['attributes']['status'].to_s == 'enabled' || row['attributes']['status'].to_s.empty? ? 'enabled' : 'disabled' | ||
| 16 | + | ||
| 15 | row_html = '' | 17 | row_html = '' |
| 16 | if client_view == false and row['attributes']['type'] == 'block' | 18 | if client_view == false and row['attributes']['type'] == 'block' |
| 17 | html_attributes['data-id'] = row['attributes']['id'] | 19 | html_attributes['data-id'] = row['attributes']['id'] |
| @@ -28,7 +30,7 @@ module Kanjai | @@ -28,7 +30,7 @@ module Kanjai | ||
| 28 | cell_class_name = '' | 30 | cell_class_name = '' |
| 29 | 31 | ||
| 30 | 32 | ||
| 31 | - ActionController::Base.helpers.concat(ActionController::Base.helpers.content_tag(:div, html.html_safe, :class => "col-md-#{cell['size']} col #{cell_class_name}", 'data-size' => cell['size'], 'data-offset' => cell['offset'], 'data-id' => cell['id'], 'data-page_data_id' => page_data.id , 'data-class' => cell['className'])) | 33 | + ActionController::Base.helpers.concat(ActionController::Base.helpers.content_tag(:div, html.html_safe, :class => "col-md-#{cell['size']} col #{cell_class_name}", 'data-size' => cell['size'], 'data-offset' => cell['offset'], 'data-id' => cell['id'], 'data-page_data_id' => page_data.id , 'data-class' => cell['className'], 'data-status' => cell['status'].to_s == 'enabled' || cell['status'].to_s.empty? ? 'enabled' : 'disabled' )) |
| 32 | end | 34 | end |
| 33 | end | 35 | end |
| 34 | end | 36 | end |
| @@ -49,30 +51,32 @@ module Kanjai | @@ -49,30 +51,32 @@ module Kanjai | ||
| 49 | 51 | ||
| 50 | 52 | ||
| 51 | if row['attributes']['type'] == 'block' | 53 | if row['attributes']['type'] == 'block' |
| 52 | - #show direct content | ||
| 53 | - structure_id = row['attributes']['id'] | ||
| 54 | - page_content = page_data.page_contents.where(:structure_id => structure_id).first | ||
| 55 | - | ||
| 56 | - html_attributes = {} | ||
| 57 | - html_attributes[:class] = 'col' | ||
| 58 | - html_attributes['data-id'] = row['attributes']['id'] | ||
| 59 | - html_attributes['data-page_data_id'] = page_data.id | ||
| 60 | - | ||
| 61 | - if page_content.type_content.split('-').include?('wrapper') | ||
| 62 | - html += (page_content.get_simple_content).html_safe | ||
| 63 | - else | ||
| 64 | - cells = page_content.nil? ? '' : page_content.get_content_frontend | 54 | + if row['attributes']['status'].to_s == 'enabled' || row['attributes']['status'].to_s.empty? |
| 55 | + #show direct content | ||
| 56 | + structure_id = row['attributes']['id'] | ||
| 57 | + page_content = page_data.page_contents.where(:structure_id => structure_id).first | ||
| 58 | + | ||
| 59 | + html_attributes = {} | ||
| 60 | + html_attributes[:class] = 'col' | ||
| 61 | + html_attributes['data-id'] = row['attributes']['id'] | ||
| 62 | + html_attributes['data-page_data_id'] = page_data.id | ||
| 63 | + | ||
| 64 | + if page_content.type_content.split('-').include?('wrapper') | ||
| 65 | + html += (page_content.get_simple_content).html_safe | ||
| 66 | + else | ||
| 67 | + cells = page_content.nil? ? '' : page_content.get_content_frontend | ||
| 65 | 68 | ||
| 66 | - data_attributes = [ | ||
| 67 | - "data-id=#{row['attributes']['id']}", | ||
| 68 | - "data-page_data_id=#{page_data.id}" | ||
| 69 | - ] | 69 | + data_attributes = [ |
| 70 | + "data-id=#{row['attributes']['id']}", | ||
| 71 | + "data-page_data_id=#{page_data.id}" | ||
| 72 | + ] | ||
| 70 | 73 | ||
| 71 | - html += ApplicationController.render(file: 'kanjai/pages/templates/block', assigns: {content: cells.html_safe, data_attributes: data_attributes.join(' ')}, layout: false).html_safe | 74 | + html += ApplicationController.render(file: 'kanjai/pages/templates/block', assigns: {content: cells.html_safe, data_attributes: data_attributes.join(' ')}, layout: false).html_safe |
| 72 | 75 | ||
| 73 | - #html += ActionController::Base.helpers.content_tag(:div, '', html_attributes) do | ||
| 74 | - # ActionController::Base.helpers.concat((page_content.nil? ? '' : page_content.get_content_frontend).html_safe) | ||
| 75 | - #end | 76 | + #html += ActionController::Base.helpers.content_tag(:div, '', html_attributes) do |
| 77 | + # ActionController::Base.helpers.concat((page_content.nil? ? '' : page_content.get_content_frontend).html_safe) | ||
| 78 | + #end | ||
| 79 | + end | ||
| 76 | end | 80 | end |
| 77 | 81 | ||
| 78 | else | 82 | else |
| @@ -104,19 +108,21 @@ module Kanjai | @@ -104,19 +108,21 @@ module Kanjai | ||
| 104 | 108 | ||
| 105 | cells = '' | 109 | cells = '' |
| 106 | row["cells"].each do |cell| | 110 | row["cells"].each do |cell| |
| 107 | - page_content = page_data.page_contents.where(:structure_id => cell['id']).first | ||
| 108 | - html_content = page_content.nil? ? '' : page_content.get_content_frontend | ||
| 109 | - cell_class_name = cell['className'] | ||
| 110 | - | ||
| 111 | - data_attributes = [ | ||
| 112 | - "data-size=#{cell['size']}", | ||
| 113 | - "data-offset=#{cell['offset']}", | ||
| 114 | - "data-id=#{cell['id']}", | ||
| 115 | - "data-page_data_id=#{page_data.id}", | ||
| 116 | - "data-class=#{cell['className']}", | ||
| 117 | - ] | ||
| 118 | - | ||
| 119 | - cells += ApplicationController.render file: 'kanjai/pages/templates/cell', assigns: {content: html_content.html_safe, cell: cell, class_name: cell_class_name, data_attributes: data_attributes.join(' ')}, layout: false | 111 | + if cell['status'].to_s == 'enabled' || cell['status'].to_s.empty? |
| 112 | + page_content = page_data.page_contents.where(:structure_id => cell['id']).first | ||
| 113 | + html_content = page_content.nil? ? '' : page_content.get_content_frontend | ||
| 114 | + cell_class_name = cell['className'] | ||
| 115 | + | ||
| 116 | + data_attributes = [ | ||
| 117 | + "data-size=#{cell['size']}", | ||
| 118 | + "data-offset=#{cell['offset']}", | ||
| 119 | + "data-id=#{cell['id']}", | ||
| 120 | + "data-page_data_id=#{page_data.id}", | ||
| 121 | + "data-class=#{cell['className']}", | ||
| 122 | + ] | ||
| 123 | + | ||
| 124 | + cells += ApplicationController.render file: 'kanjai/pages/templates/cell', assigns: {content: html_content.html_safe, cell: cell, class_name: cell_class_name, data_attributes: data_attributes.join(' ')}, layout: false | ||
| 125 | + end | ||
| 120 | end | 126 | end |
| 121 | 127 | ||
| 122 | html += ApplicationController.render(file: 'kanjai/pages/templates/row', assigns: {content: cells.html_safe}, layout: false).html_safe | 128 | html += ApplicationController.render(file: 'kanjai/pages/templates/row', assigns: {content: cells.html_safe}, layout: false).html_safe |
| @@ -9,7 +9,6 @@ module Kanjai | @@ -9,7 +9,6 @@ module Kanjai | ||
| 9 | has_many :page_content_markers, dependent: :destroy | 9 | has_many :page_content_markers, dependent: :destroy |
| 10 | accepts_nested_attributes_for :page_content_markers | 10 | accepts_nested_attributes_for :page_content_markers |
| 11 | 11 | ||
| 12 | - | ||
| 13 | def self.edit_template(content_type) | 12 | def self.edit_template(content_type) |
| 14 | case content_type | 13 | case content_type |
| 15 | when 'rte_editor' | 14 | when 'rte_editor' |
| @@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
| 3 | <h3><%= t('admin.pages.edit_page', title: @page.lang_attributes(Kanjai::PageLang.default, :title)) %></h3> | 3 | <h3><%= t('admin.pages.edit_page', title: @page.lang_attributes(Kanjai::PageLang.default, :title)) %></h3> |
| 4 | 4 | ||
| 5 | <div class="row"> | 5 | <div class="row"> |
| 6 | - <div class="col-md-10 html-generator" data-editor-url="<%= show_editor_admin_page_url(@page_data.page, lang: params[:lang]) %>" data-save_url="<%= save_structure_admin_page_url(@page_data.page, lang: params[:lang]) %>" data-delete_cell_url="<%= delete_content_admin_page_url(@page_data.page, lang: params[:lang]) %>" data-duplicate-url="<%= duplicate_block_admin_page_url(@page_data.page, lang: params[:lang]) %>" data-disable-url="<%= disable_block_admin_page_url(@page_data.page, lang: params[:lang]) %>" > | 6 | + <div class="col-md-10 html-generator" data-editor-url="<%= show_editor_admin_page_url(@page_data.page, lang: params[:lang]) %>" data-save_url="<%= save_structure_admin_page_url(@page_data.page, lang: params[:lang]) %>" data-delete_cell_url="<%= delete_content_admin_page_url(@page_data.page, lang: params[:lang]) %>" data-duplicate-url="<%= duplicate_block_admin_page_url(@page_data.page, lang: params[:lang]) %>" > |
| 7 | 7 | ||
| 8 | <div id="structure_area" > | 8 | <div id="structure_area" > |
| 9 | <div class="html-elements"> | 9 | <div class="html-elements"> |
| 1 | -Aws.config.update({ | ||
| 2 | - region: ENV['S3_REGION'], | ||
| 3 | - credentials: Aws::Credentials.new(ENV['S3_ACCESS_KEY'], ENV['S3_SECRET_KEY']) | ||
| 4 | - }) | 1 | +if ENV['S3_BUCKET'] |
| 2 | + Aws.config.update({ | ||
| 3 | + region: ENV['S3_REGION'], | ||
| 4 | + credentials: Aws::Credentials.new(ENV['S3_ACCESS_KEY'], ENV['S3_SECRET_KEY']) | ||
| 5 | + }) | ||
| 5 | 6 | ||
| 6 | -S3_BUCKET = Aws::S3::Resource.new.bucket(ENV['S3_BUCKET']) | 7 | + S3_BUCKET = Aws::S3::Resource.new.bucket(ENV['S3_BUCKET']) |
| 8 | +end |
| @@ -37,7 +37,6 @@ Kanjai::Engine.routes.draw do | @@ -37,7 +37,6 @@ Kanjai::Engine.routes.draw do | ||
| 37 | post :show_editor, on: :member | 37 | post :show_editor, on: :member |
| 38 | post :update_editor, on: :member | 38 | post :update_editor, on: :member |
| 39 | post :duplicate_block, on: :member | 39 | post :duplicate_block, on: :member |
| 40 | - post :disable_block, on: :member | ||
| 41 | 40 | ||
| 42 | post :show_frontend_editor, on: :member | 41 | post :show_frontend_editor, on: :member |
| 43 | post :update_frontend_editor, on: :member | 42 | post :update_frontend_editor, on: :member |
test/dummy/config/admin.yml
0 → 100644
| 1 | +defaults: &defaults | ||
| 2 | + admin_email_noreply: "admin@admin.com" | ||
| 3 | + admin_email: "ms@edit.de" | ||
| 4 | + expiring_time: 60 | ||
| 5 | + expiring_time_long: 300 | ||
| 6 | + | ||
| 7 | +development: | ||
| 8 | + <<: *defaults | ||
| 9 | + domain_name: "localhost:3000" | ||
| 10 | + | ||
| 11 | +test: | ||
| 12 | + <<: *defaults | ||
| 13 | + | ||
| 14 | +production: | ||
| 15 | + <<: *defaults | ||
| 16 | + domain_name: <%= ENV['KANJAI_DOMAIN'] %> |