Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.9 #8

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions app/views/admin/pages/_image_popup.html.haml
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
- content_for 'popups' do
#image-popup.popup{:style => "display: none"}
%h3 Add Image
%h3= t('textile_editor.add_image')
%form#image_transform_form.transform_form{ :name => "transform_form" }
.transform_container
.transform_title
%strong 1. Link to:
%strong= t('textile_editor.add_link')
.add_border_container
.transform_choice_container
#image_transform_choice_web.transform_choice.transform_current
%label
%input{:type => "radio", :name => "transform_choice", :value => "web", :checked => true}
\ Web Address
= t('textile_editor.web_address')
- if @page && @page.respond_to?(:attachments)
#image_transform_choice_attachment.transform_choice
%label
%input{:type => "radio", :name => "transform_choice", :value => "attachment"}
\ Attachment
= t('textile_editor.attachment')
.transform_input_container
#image_transform_input_web.transform_input
%input#img_web_text{:type => "text", :name => "img_web_text", :value => "", :size => "30"}
%p.help
Paste the URL of an existing image on your site.
= t('textile_editor.image_url')
- if @page && @page.respond_to?(:attachments)
#image_transform_input_attachment.transform_input{:style => "display:none;"}
= hidden_field(:page, :ancestor_attachments_count)
= select_tag('img_attachment_text', option_groups_from_collection_for_select(@page.self_and_ancestors, :attachments, :title, :filename, :filename))
= select_tag('img_attachment_text', option_groups_from_collection_for_select(@page.self_and_ancestors, :attachments, :title, :filename, :filename))
%p.help.advisory
%strong Is your image the right size and type?
Images need to be resized and compressed for the web using a graphics program like Photoshop.
%strong= t('textile_editor.image_size_and_type')
= t('textile_editor.image_resized')
%p.help.no-files{:style => 'display:none;'}
%strong There are no images attached to this page.
Attach one and save changes, then return here to insert it.
%strong= t('textile_editor.missing_image_attachment')
= t('textile_editor.attach_image_and_return')
%br{:clear => "all"}/
.transform_container
.transform_title
%strong 2. Alternate text:
%strong= t('textile_editor.alt_text')
%input#alt_text{:type => "text", :size => "25", :name => "alt_text"}
%input#image-popup-submit.submit{:type=>"submit", :value => "OK"}
or
= link_to_function('Cancel', :class => 'close-link') {|page| page.hide 'image-popup' }
%input#image-popup-submit.submit{:type=>"submit", :value => t('textile_editor.ok')}
= t('or')
= link_to_function(t('cancel'), :class => 'close-link') {|page| page.hide 'image-popup' }
34 changes: 17 additions & 17 deletions app/views/admin/pages/_link_popup.html.haml
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
- content_for 'popups' do
#link-popup.popup{:style => "display:none;"}
%h3 Add Link
%h3= t('textile_editor.add_link')

%form#link_transform_form.transform_form{:name => "transform_form"}
.transform_container
.transform_title
%strong 1. Link to:
%strong= t('textile_editor.link_to')
.add_border_container
.transform_choice_container
#link_transform_choice_web.transform_choice.transform_current
%label
%input{:type => "radio", :name => "transform_choice", :value => "web", :checked => true}
\ Web Address
= t('textile_editor.web_address')
- if Page.instance_methods.include?("tag:enkode_mailto")
#link_transform_choice_email.transform_choice
%label
%input{:type => "radio", :name => "transform_choice", :value => "email"}
\ Email Address
= t('textile_editor.email_address')
- if @page && @page.respond_to?(:attachments)
#link_transform_choice_attachment.transform_choice
%label
%input{:type => "radio", :name => "transform_choice", :value => "attachment"}
\ Attachment
= t('textile_editor.attachment')
.transform_input_container
#transform_input_web.transform_input
%input#web_text{:type => "text", :name => "web_text", :value => "", :size => "30"}
%br/
%p.help
%strong Not sure what to put in the box above?
First, find the page on the web you want to link to. Then, copy the web address from your browser's address bar, and paste it into in the box above.
%strong= t('textile_editor.not_sure_question')
= t('textile_editor.not_sure_answer')
- if Page.instance_methods.include?("tag:enkode_mailto")
#transform_input_email.transform_input{:style => "display:none;"}
%input#email_text{:type => "text", :name => "email_text", :value => "", :size => "30"}
%p.help
%strong.warning Spam warning:
The “enkode” tag that this form inserts is the only safe way to put email addresses on the Web. Without the protection it provides, the address is vulnerable to harvesting by spammers.
%strong.warning= t('textile_editor.spam_warning')
= t('textile_editor.spam_description')
- if @page && @page.respond_to?(:attachments)
#transform_input_attachment.transform_input{:style => "display:none;"}
= hidden_field(:page, :ancestor_attachments_count)
= select_tag('attachment_text', option_groups_from_collection_for_select(@page.self_and_ancestors, :attachments, :title, :filename, :filename))
%p.help.advisory
%strong Should it be a PDF instead?
Your document will be accessible to a wider audience if you publish your Word, Powerpoint, or other document type as a PDF.
%strong= t('textile_editor.document_type')
= t('textile_editor.document_accessibility')
%p.help.no-files{:style => 'display:none;'}
%strong There are no files attached to this page.
Attach one and then return here to add a link to it.
%strong= t('textile_editor.missing_file_attachment')
= t('textile_editor.attach_file_and_return')
%br{:clear => "all"}/
.transform_container
.transform_title
%strong 2. Text to display:
%strong= t('textile_editor.text_to_display')
%input#display_text{:type => "text", :size => "25", :name => "display_text"}
%input#link-popup-submit.submit{:type => "submit", :value => "OK"}
or
= link_to_function('Cancel', :class => 'close-link') {|page| page.hide 'link-popup' }
%input#link-popup-submit.submit{:type => "submit", :value => t('textile_editor.ok')}
= t('or')
= link_to_function(t('cancel'), :class => 'close-link') {|page| page.hide 'link-popup' }
24 changes: 24 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
de:
textile_editor:
add_image: "Bild hinzufügen"
add_link: "Link hinzufügen"
alt_text: "2. alternativer Text:"
attach_file_and_return: "Fügen Sie der Seite eine Datei hinzu (unten auf der Seite mit dem Plus bei den Attachments) und kommen Sie hierher zurück, um einen Link zu dieser Datei zu erstellen."
attach_image_and_return: "Fügen Sie der Seite ein Bild hinzu (unten auf der Seite mit dem Plus bei den Attachments) und kommen Sie hierher zurück, um es einzufügen."
attachment: "angehängte Datei"
document_accessibility: "Ihr Dokument kann von einem breiteren Publikum genutzt werden, wenn Sie es als PDF Datei anstatt im Word oder Powerpoint Format zum Download anbieten."
document_type: "Sollte es eine PDF Datei sein?"
email_address: "Email Adresse"
image_resized: "Bilder sollten *vor* dem Hinzufügen auf die auf die richtige Grösse und Kompression gebracht werden. Sie können dazu Photoshop oder ein ähnliches Programm verwenden."
image_size_and_type: "Ist ihr Bild in der richtigen Grösse und Art (Jpg,Gif,Png)?"
image_url: "Das Bild mit einer bereits existierenden URL in die Seite einbinden."
link_to: "1. Link zu:"
missing_file_attachment: "Diese Seite hat keine angehängten Dateien."
missing_image_attachment: "Diese Seite hat keine angehängten Bilder."
not_sure_answer: "Navigieren Sie mit Ihrem Webbrowser zu der Seite zu der Sie verlinken möchten. Kopieren Sie den Link in der Adresszeile von Ihrem Webbrowser. Fügen Sie diesen kopierten Link in das obere Feld."
not_sure_question: "Sie sind sich nicht sicher was Sie in das obere Feld einfügen sollen?"
ok: "OK"
spam_description: "Das “enkode” tag ist der einzige sichere Weg Email Adressen in die Seite einzufügen. Ohne diesen Schutz können Spammer die Email Adresse von dieser Webseite sammeln und verwenden."
spam_warning: "Spam Warnung:"
text_to_display: "2. Text der angezeigt werden soll:"
web_address: "Web Adresse"
24 changes: 24 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
en:
textile_editor:
add_image: "Add Image"
add_link: "Add Link"
alt_text: "2. Alternate text:"
attach_file_and_return: "Attach one and then return here to add a link to it."
attach_image_and_return: "Attach one and save changes, then return here to insert it."
attachment: "Attachment"
document_accessibility: "Your document will be accessible to a wider audience if you publish your Word, Powerpoint, or other document type as a PDF."
document_type: "Should it be a PDF instead?"
email_address: "Email Address"
image_resized: "Images need to be resized and compressed for the web using a graphics program like Photoshop."
image_size_and_type: "Is your image the right size and type?"
image_url: "Paste the URL of an existing image on your site."
link_to: "1. Link to:"
missing_file_attachment: "There are no files attached to this page."
missing_image_attachment: "There are no images attached to this page."
not_sure_answer: "First, find the page on the web you want to link to. Then, copy the web address from your browser’s address bar, and paste it into in the box above."
not_sure_question: "Not sure what to put in the box above?"
ok: "OK"
spam_description: "The “enkode” tag that this form inserts is the only safe way to put email addresses on the Web. Without the protection it provides, the address is vulnerable to harvesting by spammers."
spam_warning: "Spam warning:"
text_to_display: "2. Text to display:"
web_address: "Web Address"
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ActionController::Routing::Routes.draw do |map|
map.connect 'admin/textile_editor/:action', :controller => 'admin/textile_editor'
end
35 changes: 31 additions & 4 deletions lib/tasks/textile_editor_extension_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,50 @@ namespace :radiant do
require 'radiant/extension_migrator'
if ENV["VERSION"]
TextileEditorExtension.migrator.migrate(ENV["VERSION"].to_i)
Rake::Task['db:schema:dump'].invoke
else
TextileEditorExtension.migrator.migrate
Rake::Task['db:schema:dump'].invoke
end
end

desc "Copies public assets of the Textile Editor extension to the instance public/ directory."
task :update => [:environment, "textile_editor_helper:install"] do
is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
puts "Copying assets from TextileEditorExtension"
Dir[TextileEditorExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
path = file.sub(TextileEditorExtension.root, '')
directory = File.dirname(path)
puts "Copying #{path}..."
mkdir_p RAILS_ROOT + directory
cp file, RAILS_ROOT + path
mkdir_p RAILS_ROOT + directory, :verbose => false
cp file, RAILS_ROOT + path, :verbose => false
end

unless TextileEditorExtension.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
puts "Copying rake tasks from TextileEditorExtension"
local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
mkdir_p local_tasks_path, :verbose => false
Dir[File.join TextileEditorExtension.root, %w(lib tasks *.rake)].each do |file|
cp file, local_tasks_path, :verbose => false
end
end
end

desc "Syncs all available translations for this ext to the English ext master"
task :sync => :environment do
# The main translation root, basically where English is kept
language_root = TextileEditorExtension.root + "/config/locales"
words = TranslationSupport.get_translation_keys(language_root)

Dir["#{language_root}/*.yml"].each do |filename|
next if filename.match('_available_tags')
basename = File.basename(filename, '.yml')
puts "Syncing #{basename}"
(comments, other) = TranslationSupport.read_file(filename, basename)
words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
TranslationSupport.write_file(filename, basename, comments, other)
end
end
end
end
end
end
17 changes: 9 additions & 8 deletions lib/textile_editor/ext/admin/pages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ def self.included(receiver)

def page_edit_javascripts_with_textile_editor
page_edit_javascripts_without_textile_editor + <<-CODE
part_added_without_textile_editor_observation = part_added;
function part_added_with_textile_editor_observation() {
var partName = $F('part-name-field');
var page = 'page-' + partName.toSlug();
part_added_without_textile_editor_observation();
new filterObserver( $(page).getElementsByClassName('textarea')[0] );
if (typeof partAdded === 'function') {
partAdded = partAdded.wrap(
function(partAdded_without_textile_editor_observation) {
var partName = $F('part_name_field');
var page = 'page_' + partName.toSlug();
partAdded_without_textile_editor_observation();
new filterObserver( $(page).getElementsByClassName('textarea')[0] );
});
}
part_added = part_added_with_textile_editor_observation;

CODE
end

end
end
end
end
12 changes: 6 additions & 6 deletions public/javascripts/textile-editor-radiant.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ filterObserver.prototype = {
Event.observe(window, 'load', load_textile_editor);

function load_textile_editor(){
parts = $$('.form-area textarea').each(function(e) {
parts = $$('#tab_control .pages .page textarea', '.form_area textarea').each(function(e) {
new filterObserver(e);
});
}

var Popup = Class.create();
Popup.prototype = {
var TextileEditorPopup = Class.create();
TextileEditorPopup.prototype = {
initialize: function(button) {
this.textArea = $(button).canvas;
this.popupElement = this.getPopupWindow();
Expand Down Expand Up @@ -175,9 +175,9 @@ Popup.prototype = {
}
}

// Subclass of Popup specifically for adding links
// Subclass of TextileEditorPopup specifically for adding links
var LinkPopup = Class.create();
Object.extend(Object.extend(LinkPopup.prototype,Popup.prototype),{
Object.extend(Object.extend(LinkPopup.prototype,TextileEditorPopup.prototype),{
getPopupWindow: function() {
return $('link-popup');
},
Expand Down Expand Up @@ -288,7 +288,7 @@ Object.extend(Object.extend(LinkPopup.prototype,Popup.prototype),{

// Subclass of Popup specifically for adding images
var ImagePopup = Class.create();
Object.extend(Object.extend(ImagePopup.prototype,Popup.prototype), {
Object.extend(Object.extend(ImagePopup.prototype,TextileEditorPopup.prototype), {
getPopupWindow: function() {
return $('image-popup');
},
Expand Down
6 changes: 1 addition & 5 deletions textile_editor_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ class TextileEditorExtension < Radiant::Extension
version "2.2"
description "Places a toolbar above the textarea when Textile is the current input filter."

define_routes do |map|
map.connect 'admin/textile_editor/:action', :controller => 'admin/textile_editor'
end

def activate
ApplicationController.send :include, TextileEditor::Ext::ApplicationController
Admin::PagesHelper.send :include, TextileEditor::Ext::Admin::PagesHelper
Expand All @@ -25,4 +21,4 @@ def activate
def deactivate
end

end
end