forked from spree-contrib/spree_editor
-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 7ddba28
Showing
20 changed files
with
519 additions
and
0 deletions.
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,9 @@ | ||
\#* | ||
*~ | ||
.#* | ||
.DS_Store | ||
.idea | ||
.project | ||
tmp | ||
nbproject | ||
*.swp |
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,23 @@ | ||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
* Neither the name of the Rails Dog LLC nor the names of its | ||
contributors may be used to endorse or promote products derived from this | ||
software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,13 @@ | ||
SpreeEditor | ||
=========== | ||
|
||
Introduction goes here. | ||
|
||
|
||
Example | ||
======= | ||
|
||
Example goes here. | ||
|
||
|
||
Copyright (c) 2010 [name of extension creator], released under the New BSD License |
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,31 @@ | ||
require File.expand_path('../../config/application', __FILE__) | ||
|
||
require 'rubygems' | ||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/packagetask' | ||
require 'rake/gempackagetask' | ||
|
||
spec = eval(File.read('spree_editor.gemspec')) | ||
|
||
Rake::GemPackageTask.new(spec) do |p| | ||
p.gem_spec = spec | ||
end | ||
|
||
desc "Release to gemcutter" | ||
task :release => :package do | ||
require 'rake/gemcutter' | ||
Rake::Gemcutter::Tasks.new(spec).define | ||
Rake::Task['gem:push'].invoke | ||
end | ||
|
||
desc "Default Task" | ||
task :default => [ :spec ] | ||
|
||
require 'rspec/core/rake_task' | ||
RSpec::Core::RakeTask.new | ||
|
||
# require 'cucumber/rake/task' | ||
# Cucumber::Rake::Task.new do |t| | ||
# t.cucumber_opts = %w{--format pretty} | ||
# 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,10 @@ | ||
class ContentFilesController < Spree::BaseController | ||
|
||
def create | ||
@content_file = ContentFile.new(params[:content_file]) | ||
@content_file.save! | ||
|
||
render :text => "#{@content_file.attachment.url},#{@content_file.attachment_file_name}" | ||
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,10 @@ | ||
class ContentImagesController < Spree::BaseController | ||
|
||
def create | ||
@content_image = ContentImage.new(params[:content_image]) | ||
@content_image.save! | ||
|
||
render :text => @content_image.attachment.url | ||
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,5 @@ | ||
class ContentFile < Asset | ||
has_attached_file :attachment, | ||
:url => "/assets/content_files/:id/:basename.:extension", | ||
:path => ":rails_root/public/assets/content_files/:id/:basename.:extension" | ||
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,7 @@ | ||
class ContentImage < Image | ||
has_attached_file :attachment, | ||
:styles => {:mini => '48x48#', :large => '600x600>'}, | ||
:default_style => :large, | ||
:url => "/assets/content_images/:id/:style/:basename.:extension", | ||
:path => ":rails_root/public/assets/content_images/:id/:style/:basename.:extension" | ||
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,207 @@ | ||
<% content_for :head do %> | ||
<%= stylesheet_link_tag 'editor' %> | ||
<% end %> | ||
|
||
<div class="editor-mask-container"> | ||
<div class="editor-mask"></div | ||
<div class="editor-mask-label"><%= t("editor.loading") %></div | ||
</div> | ||
|
||
<!-- Skin CSS file --> | ||
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.2r1/build/assets/skins/sam/skin.css"> | ||
<!-- Utility Dependencies --> | ||
<script src="http://yui.yahooapis.com/2.8.2r1/build/yahoo-dom-event/yahoo-dom-event.js"></script> | ||
<script src="http://yui.yahooapis.com/2.8.2r1/build/element/element-min.js"></script> | ||
<!-- Needed for Menus, Buttons and Overlays used in the Toolbar --> | ||
<script src="http://yui.yahooapis.com/2.8.2r1/build/container/container_core-min.js"></script> | ||
<script src="http://yui.yahooapis.com/2.8.2r1/build/menu/menu-min.js"></script> | ||
<script src="http://yui.yahooapis.com/2.8.2r1/build/button/button-min.js"></script> | ||
<!-- Source file for Rich Text Editor--> | ||
<script src="http://yui.yahooapis.com/2.8.2r1/build/editor/editor-min.js"></script> | ||
|
||
<script type="text/javascript" charset="utf-8"> | ||
var <%= editor_id %>_editor = new YAHOO.widget.Editor('<%= editor_id %>', { | ||
height: '300px', | ||
width: '790px', | ||
animate: true, | ||
autoHeight: true, | ||
handleSubmit: true, | ||
toolbar: { | ||
collapse: true, | ||
titlebar: false, | ||
draggable: false, | ||
buttonType: 'advanced', | ||
buttons: [ | ||
{ group: 'fontstyle', label: '<%= t("editor.font_name_and_size") %>', | ||
buttons: [ | ||
{ type: 'select', label: 'Arial', value: 'fontname', disabled: true, | ||
menu: [ | ||
{ text: 'Arial', checked: true }, | ||
{ text: 'Arial Black' }, | ||
{ text: 'Comic Sans MS' }, | ||
{ text: 'Courier New' }, | ||
{ text: 'Lucida Console' }, | ||
{ text: 'Tahoma' }, | ||
{ text: 'Times New Roman' }, | ||
{ text: 'Trebuchet MS' }, | ||
{ text: 'Verdana' } | ||
] | ||
}, | ||
{ type: 'spin', label: '13', value: 'fontsize', range: [ 9, 75 ], disabled: true } | ||
] | ||
}, | ||
{ type: 'separator' }, | ||
{ group: 'textstyle', label: '<%= t("editor.font_style") %>', | ||
buttons: [ | ||
{ type: 'push', label: 'Bold CTRL + SHIFT + B', value: 'bold' }, | ||
{ type: 'push', label: 'Italic CTRL + SHIFT + I', value: 'italic' }, | ||
{ type: 'push', label: 'Underline CTRL + SHIFT + U', value: 'underline' }, | ||
{ type: 'separator' }, | ||
{ type: 'push', label: 'Subscript', value: 'subscript', disabled: true }, | ||
{ type: 'push', label: 'Superscript', value: 'superscript', disabled: true }, | ||
{ type: 'separator' }, | ||
{ type: 'color', label: 'Font Color', value: 'forecolor', disabled: true }, | ||
{ type: 'color', label: 'Background Color', value: 'backcolor', disabled: true }, | ||
{ type: 'separator' }, | ||
{ type: 'push', label: 'Remove Formatting', value: 'removeformat', disabled: true }, | ||
{ type: 'push', label: 'Show/Hide Hidden Elements', value: 'hiddenelements' } | ||
] | ||
}, | ||
{ type: 'separator' }, | ||
{ group: 'alignment', label: '<%= t("editor.alignment") %>', | ||
buttons: [ | ||
{ type: 'push', label: 'Align Left CTRL + SHIFT + [', value: 'justifyleft' }, | ||
{ type: 'push', label: 'Align Center CTRL + SHIFT + |', value: 'justifycenter' }, | ||
{ type: 'push', label: 'Align Right CTRL + SHIFT + ]', value: 'justifyright' }, | ||
{ type: 'push', label: 'Justify', value: 'justifyfull' } | ||
] | ||
}, | ||
{ type: 'separator' }, | ||
{ group: 'parastyle', label: '<%= t("editor.paragraph_style") %>', | ||
buttons: [ | ||
{ type: 'select', label: 'Normal', value: 'heading', disabled: true, | ||
menu: [ | ||
{ text: 'Normal', value: 'none', checked: true }, | ||
{ text: 'Header 1', value: 'h1' }, | ||
{ text: 'Header 2', value: 'h2' }, | ||
{ text: 'Header 3', value: 'h3' }, | ||
{ text: 'Header 4', value: 'h4' }, | ||
{ text: 'Header 5', value: 'h5' }, | ||
{ text: 'Header 6', value: 'h6' } | ||
] | ||
} | ||
] | ||
}, | ||
{ type: 'separator' }, | ||
{ group: 'indentlist', label: '<%= t("editor.indenting_and_lists") %>', | ||
buttons: [ | ||
{ type: 'push', label: 'Indent', value: 'indent', disabled: true }, | ||
{ type: 'push', label: 'Outdent', value: 'outdent', disabled: true }, | ||
{ type: 'push', label: 'Create an Unordered List', value: 'insertunorderedlist' }, | ||
{ type: 'push', label: 'Create an Ordered List', value: 'insertorderedlist' } | ||
] | ||
}, | ||
{ type: 'separator' }, | ||
{ group: 'insertitem', label: '<%= t("editor.insert_item") %>', | ||
buttons: [ | ||
{ type: 'push', label: 'HTML Link CTRL + SHIFT + L', value: 'createlink', disabled: true }, | ||
{ type: 'push', label: '<%= t("editor.insert_image") %>', value: 'insertimage' } | ||
] | ||
} | ||
] | ||
} | ||
}); | ||
|
||
<%= editor_id %>_editor.on('toolbarLoaded', function() { | ||
var imageUploadConfig = { | ||
type: 'push', | ||
label: '<%= t("editor.upload_image") %>', | ||
value: 'imageUpload' | ||
}; | ||
<%= editor_id %>_editor.toolbar.addButtonToGroup(imageUploadConfig, 'insertitem'); | ||
|
||
var fileUploadConfig = { | ||
type: 'push', | ||
label: '<%= t("editor.upload_file") %>', | ||
value: 'fileUpload' | ||
}; | ||
<%= editor_id %>_editor.toolbar.addButtonToGroup(fileUploadConfig, 'insertitem'); | ||
}); | ||
|
||
<%= editor_id %>_editor.addListener('editorContentLoaded', function() { | ||
$(".yui-toolbar-imageUpload").upload({ | ||
name: 'content_image[attachment]', | ||
action: '/content_images', | ||
enctype: 'multipart/form-data', | ||
params: {'content_image[viewable_type]': 'Page', 'content_image[viewable_id]': '<%= @page.id %>]'}, | ||
autoSubmit: true, | ||
onSubmit: function() { | ||
$(".editor-mask-container").addClass("active"); | ||
}, | ||
onComplete: function(image_src) { | ||
var img_html = "<img src='"+image_src+"'/>"; | ||
<%= editor_id %>_editor.execCommand('inserthtml', img_html); | ||
$(".editor-mask-container").removeClass("active"); | ||
} | ||
}); | ||
|
||
$(".yui-toolbar-fileUpload").upload({ | ||
name: 'content_file[attachment]', | ||
action: '/content_files', | ||
enctype: 'multipart/form-data', | ||
params: {'content_file[viewable_type]': 'Page', 'content_file[viewable_id]': '<%= @page.id %>]'}, | ||
autoSubmit: true, | ||
onSubmit: function() { | ||
$(".editor-mask-container").addClass("active"); | ||
}, | ||
onComplete: function(file_url_and_name) { | ||
var file_url = file_url_and_name.split(",")[0]; | ||
var file_name_original = file_url_and_name.split(",")[1]; | ||
$(".editor-mask-container").removeClass("active"); | ||
var file_name = prompt('<%= t("editor.enter_file_name") %>', file_name_original); | ||
var link_html = "<a href='"+file_url+"'/>"+file_name+"</a>"; | ||
<%= editor_id %>_editor.execCommand('inserthtml', link_html); | ||
} | ||
}); | ||
}); | ||
|
||
<%= editor_id %>_editor.render(); | ||
|
||
$("#<%= editor_id %>_switch_simple, #<%= editor_id %>_switch_rich").click(function() { | ||
$("#<%= editor_id %>_switch_simple, #<%= editor_id %>_switch_rich").toggle(); | ||
return false; | ||
}); | ||
$("#<%= editor_id %>_switch_simple").click(function() { | ||
page_body_editor.saveHTML(); | ||
|
||
var fc = page_body_editor.get('element').previousSibling, | ||
el = page_body_editor.get('element'); | ||
|
||
YAHOO.util.Dom.setStyle(fc, 'position', 'absolute'); | ||
YAHOO.util.Dom.setStyle(fc, 'top', '-9999px'); | ||
YAHOO.util.Dom.setStyle(fc, 'left', '-9999px'); | ||
page_body_editor.get('element_cont').removeClass('yui-editor-container'); | ||
YAHOO.util.Dom.setStyle(el, 'visibility', 'visible'); | ||
YAHOO.util.Dom.setStyle(el, 'top', ''); | ||
YAHOO.util.Dom.setStyle(el, 'left', ''); | ||
YAHOO.util.Dom.setStyle(el, 'position', 'static'); | ||
YAHOO.util.Dom.setStyle(el, 'width', '780px'); | ||
return false; | ||
}); | ||
$("#<%= editor_id %>_switch_rich").click(function() { | ||
var fc = page_body_editor.get('element').previousSibling, | ||
el = page_body_editor.get('element'); | ||
|
||
YAHOO.util.Dom.setStyle(fc, 'position', 'static'); | ||
YAHOO.util.Dom.setStyle(fc, 'top', '0'); | ||
YAHOO.util.Dom.setStyle(fc, 'left', '0'); | ||
YAHOO.util.Dom.setStyle(el, 'visibility', 'hidden'); | ||
YAHOO.util.Dom.setStyle(el, 'top', '-9999px'); | ||
YAHOO.util.Dom.setStyle(el, 'left', '-9999px'); | ||
YAHOO.util.Dom.setStyle(el, 'position', 'absolute'); | ||
page_body_editor.get('element_cont').addClass('yui-editor-container'); | ||
page_body_editor._setDesignMode('on'); | ||
page_body_editor.setEditorHTML(page_body_editor.get('textarea').value); | ||
return false; | ||
}); | ||
</script> |
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 @@ | ||
--- | ||
en: | ||
editor: | ||
loading: Loading | ||
font_name_and_size: Font Name and Size | ||
font_style: Font Style | ||
alignment: Alignment | ||
paragraph_style: Paragraph Style | ||
indenting_and_lists: "Indenting/Lists" | ||
insert_item: Insert Item | ||
insert_image: Insert Image | ||
upload_image: Upload Image | ||
upload_image: Upload File | ||
show_more_fields: Show more fields | ||
hide_more_fields: Hide more fields | ||
switch_simple: Switch to Simple Editor | ||
switch_rich: Switch to Rich Editor | ||
no_link: "No link<br/>Add Slug Or Foreign Link" | ||
in_menu: Menu | ||
sidebar: Sidebar | ||
header: Header | ||
footer: Footer | ||
parent: Parent page | ||
main_page: Main | ||
enter_file_name: Enter file name |
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,24 @@ | ||
ru: | ||
editor: | ||
loading: Загружается | ||
font_name_and_size: Шрифт и размер | ||
font_style: Стиль | ||
alignment: Выравнивание | ||
paragraph_style: Стиль | ||
indenting_and_lists: "Отступы/списки" | ||
insert_item: Вставка | ||
insert_image: Вставить картинки по адресу | ||
upload_image: Загрузить картинку | ||
upload_image: Загрузить файл | ||
show_more_fields: Показать дополнительные поля | ||
hide_more_fields: Скрыть дополнительные поля | ||
switch_simple: Переключиться на простой редактор | ||
switch_rich: Переключиться на расширенный | ||
no_link: "Нет ссылки<br/>Добавьте Адрес или Внешнюю ссылку" | ||
in_menu: Меню | ||
sidebar: Боковое меню | ||
header: Верхнее меню | ||
footer: Нижнее меню | ||
parent: Находится на странице | ||
main_page: Главная | ||
enter_file_name: Введите имя файла |
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 @@ | ||
Rails.application.routes.draw do | ||
|
||
resources :content_images, :only => [:create] | ||
resources :content_files, :only => [:create] | ||
|
||
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,10 @@ | ||
module EditorHelper | ||
|
||
def rich_editor(options) | ||
options[:editor_id] = options[:id] | ||
options.delete(:id) | ||
|
||
render :partial => "shared/editor", :locals => options | ||
end | ||
|
||
end |
Oops, something went wrong.