Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
Added fckeditor to content section edit page
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Adams committed Sep 7, 2008
1 parent 07b18dc commit ea48385
Show file tree
Hide file tree
Showing 1,150 changed files with 184,231 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/controllers/content_sections_controller.rb
@@ -1,4 +1,5 @@
class ContentSectionsController < ApplicationController
layout 'admin'
before_filter :load_content_section, :only => [:show, :edit, :update]
protected
def load_content_section
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_sections/edit.html.erb
@@ -1,6 +1,6 @@
<h1>Editing Content Section</h1>
<% form_for :content_section, :url => content_section_path(@content_section), :html => { :method => :put } do |f| -%>
<%= f.text_field(:name) -%><br />
<%= f.text_area(:contents) -%><br />
<%= fckeditor_textarea(:content_section, :contents, :toolbarSet => 'Simple', :width => '100%', :height => '400px') -%><br />
<%= submit_tag("Update Content Section") -%>
<% end -%>
3 changes: 2 additions & 1 deletion app/views/layouts/admin.html.erb
Expand Up @@ -16,6 +16,7 @@
<%= stylesheet_link_tag 'admin' %>
<%= javascript_include_tag :defaults %>
<%= javascript_include_tag 'show_and_hide' %>
<%= javascript_include_tag :fckeditor %>
<!--[if lt IE 7.]><%= javascript_include_tag 'pngfix.js' %><![endif]-->
</head>
<body>
Expand All @@ -35,4 +36,4 @@
<div id="footer"></div> <!-- end #footer -->
</div> <!-- end #wrap -->
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion config/environment.rb
Expand Up @@ -33,7 +33,7 @@
# Only load the plugins named here, in the order given. By default, all plugins
# in vendor/plugins are loaded in alphabetical order.
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
config.plugins = [ :version_fu, :all ]

# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )
Expand Down
16 changes: 16 additions & 0 deletions db/migrate/20080907232248_add_version_to_content_sections.rb
@@ -0,0 +1,16 @@
class AddVersionToContentSections < ActiveRecord::Migration
def self.up
create_table :content_section_versions do |t|
t.integer :content_section_id, :version, :author_id
t.string :name
t.text :contents
t.timestamps
end
add_column :content_sections, :version, :integer, :default => 1
end

def self.down
remove_column :content_sections, :version
drop_table :content_section_versions
end
end
33 changes: 33 additions & 0 deletions public/javascripts/fckcustom.js
@@ -0,0 +1,33 @@
// CHANGE FOR APPS HOSTED IN SUBDIRECTORY
FCKRelativePath = '';

// DON'T CHANGE THESE
FCKConfig.LinkBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Connector='+FCKRelativePath+'/fckeditor/command';
FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Image&Connector='+FCKRelativePath+'/fckeditor/command';
FCKConfig.FlashBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Flash&Connector='+FCKRelativePath+'/fckeditor/command';

FCKConfig.LinkUploadURL = FCKRelativePath+'/fckeditor/upload';
FCKConfig.ImageUploadURL = FCKRelativePath+'/fckeditor/upload?Type=Image';
FCKConfig.FlashUploadURL = FCKRelativePath+'/fckeditor/upload?Type=Flash';
FCKConfig.SpellerPagesServerScript = FCKRelativePath+'/fckeditor/check_spelling';
FCKConfig.AllowQueryStringDebug = false;
FCKConfig.SpellChecker = 'SpellerPages';

// ONLY CHANGE BELOW HERE
FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/silver/';

FCKConfig.ToolbarSets["Simple"] = [
['Source','-','-','Templates'],
['Cut','Copy','Paste','PasteWord','-','Print','SpellCheck'],
['Undo','Redo','-','Find','Replace','-','SelectAll'],
'/',
['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
['OrderedList','UnorderedList','-','Outdent','Indent'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Link','Unlink'],
'/',
['Image','Table','Rule','Smiley'],
['FontName','FontSize'],
['TextColor','BGColor'],
['-','About']
] ;
38 changes: 38 additions & 0 deletions public/javascripts/fckeditor/_documentation.html
@@ -0,0 +1,38 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2008 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or later (the "GPL")
* http://www.gnu.org/licenses/gpl.html
*
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* http://www.gnu.org/licenses/lgpl.html
*
* - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>FCKeditor - Documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body { font-family: arial, verdana, sans-serif }
p { margin-left: 20px }
</style>
</head>
<body>
<h1>
FCKeditor Documentation</h1>
<p>
You can find the official documentation for FCKeditor online, at <a href="http://docs.fckeditor.net/">
http://docs.fckeditor.net/</a>.</p>
</body>
</html>
@@ -0,0 +1,38 @@
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2008 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or later (the "GPL")
* http://www.gnu.org/licenses/gpl.html
*
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* http://www.gnu.org/licenses/lgpl.html
*
* - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*
* This is the sample plugin definition file.
*/

// Register the related commands.
FCKCommands.RegisterCommand( 'My_Find' , new FCKDialogCommand( FCKLang['DlgMyFindTitle'] , FCKLang['DlgMyFindTitle'] , FCKConfig.PluginsPath + 'findreplace/find.html' , 340, 170 ) ) ;
FCKCommands.RegisterCommand( 'My_Replace' , new FCKDialogCommand( FCKLang['DlgMyReplaceTitle'], FCKLang['DlgMyReplaceTitle'] , FCKConfig.PluginsPath + 'findreplace/replace.html', 340, 200 ) ) ;

// Create the "Find" toolbar button.
var oFindItem = new FCKToolbarButton( 'My_Find', FCKLang['DlgMyFindTitle'] ) ;
oFindItem.IconPath = FCKConfig.PluginsPath + 'findreplace/find.gif' ;

FCKToolbarItems.RegisterItem( 'My_Find', oFindItem ) ; // 'My_Find' is the name used in the Toolbar config.

// Create the "Replace" toolbar button.
var oReplaceItem = new FCKToolbarButton( 'My_Replace', FCKLang['DlgMyReplaceTitle'] ) ;
oReplaceItem.IconPath = FCKConfig.PluginsPath + 'findreplace/replace.gif' ;

FCKToolbarItems.RegisterItem( 'My_Replace', oReplaceItem ) ; // 'My_Replace' is the name used in the Toolbar config.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
172 changes: 172 additions & 0 deletions public/javascripts/fckeditor/_samples/_plugins/findreplace/find.html
@@ -0,0 +1,172 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2008 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or later (the "GPL")
* http://www.gnu.org/licenses/gpl.html
*
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* http://www.gnu.org/licenses/lgpl.html
*
* - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*
* This is the sample "Find" plugin window.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta content="noindex, nofollow" name="robots">
<script type="text/javascript">

var oEditor = window.parent.InnerDialogLoaded() ;

function OnLoad()
{
// Whole word is available on IE only.
if ( oEditor.FCKBrowserInfo.IsIE )
document.getElementById('divWord').style.display = '' ;

// First of all, translate the dialog box texts.
oEditor.FCKLanguageManager.TranslatePage( document ) ;

window.parent.SetAutoSize( true ) ;
}

function btnStat(frm)
{
document.getElementById('btnFind').disabled =
( document.getElementById('txtFind').value.length == 0 ) ;
}

function ReplaceTextNodes( parentNode, regex, replaceValue, replaceAll )
{
for ( var i = 0 ; i < parentNode.childNodes.length ; i++ )
{
var oNode = parentNode.childNodes[i] ;
if ( oNode.nodeType == 3 )
{
var sReplaced = oNode.nodeValue.replace( regex, replaceValue ) ;
if ( oNode.nodeValue != sReplaced )
{
oNode.nodeValue = sReplaced ;
if ( ! replaceAll )
return true ;
}
}
else
{
if ( ReplaceTextNodes( oNode, regex, replaceValue ) )
return true ;
}
}
return false ;
}

function GetRegexExpr()
{
if ( document.getElementById('chkWord').checked )
var sExpr = '\\b' + document.getElementById('txtFind').value + '\\b' ;
else
var sExpr = document.getElementById('txtFind').value ;

return sExpr ;
}

function GetCase()
{
return ( document.getElementById('chkCase').checked ? '' : 'i' ) ;
}

function Ok()
{
if ( document.getElementById('txtFind').value.length == 0 )
return ;

if ( oEditor.FCKBrowserInfo.IsIE )
FindIE() ;
else
FindGecko() ;
}

var oRange = null ;

function FindIE()
{
if ( oRange == null )
oRange = oEditor.FCK.EditorDocument.body.createTextRange() ;

var iFlags = 0 ;

if ( chkCase.checked )
iFlags = iFlags | 4 ;

if ( chkWord.checked )
iFlags = iFlags | 2 ;

var bFound = oRange.findText( document.getElementById('txtFind').value, 1, iFlags ) ;

if ( bFound )
{
oRange.scrollIntoView() ;
oRange.select() ;
oRange.collapse(false) ;
oLastRangeFound = oRange ;
}
else
{
oRange = null ;
alert( oEditor.FCKLang.DlgFindNotFoundMsg ) ;
}
}

function FindGecko()
{
var bCase = document.getElementById('chkCase').checked ;
var bWord = document.getElementById('chkWord').checked ;

// window.find( searchString, caseSensitive, backwards, wrapAround, wholeWord, searchInFrames, showDialog ) ;
oEditor.FCK.EditorWindow.find( document.getElementById('txtFind').value, bCase, false, false, bWord, false, false ) ;

}
</script>
</head>
<body onload="OnLoad()" scroll="no" style="OVERFLOW: hidden">
<div align="center">
This is my Plugin!
</div>
<table cellSpacing="3" cellPadding="2" width="100%" border="0">
<tr>
<td nowrap>
<label for="txtFind" fckLang="DlgMyReplaceFindLbl">Find what:</label>&nbsp;
</td>
<td width="100%">
<input id="txtFind" onkeyup="btnStat(this.form)" style="WIDTH: 100%" tabIndex="1" type="text">
</td>
<td>
<input id="btnFind" style="WIDTH: 100%; PADDING-RIGHT: 5px; PADDING-LEFT: 5px" disabled
onclick="Ok();" type="button" value="Find" fckLang="DlgMyFindFindBtn">
</td>
</tr>
<tr>
<td valign="bottom" colSpan="3">
&nbsp;<input id="chkCase" tabIndex="3" type="checkbox"><label for="chkCase" fckLang="DlgMyReplaceCaseChk">Match
case</label>
<br>
<div id="divWord" style="DISPLAY: none">
&nbsp;<input id="chkWord" tabIndex="4" type="checkbox"><label for="chkWord" fckLang="DlgMyReplaceWordChk">Match
whole word</label>
</div>
</td>
</tr>
</table>
</body>
</html>
@@ -0,0 +1,33 @@
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2008 Frederico Caldeira Knabben
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of any of the following licenses at your
* choice:
*
* - GNU General Public License Version 2 or later (the "GPL")
* http://www.gnu.org/licenses/gpl.html
*
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
* http://www.gnu.org/licenses/lgpl.html
*
* - Mozilla Public License Version 1.1 or later (the "MPL")
* http://www.mozilla.org/MPL/MPL-1.1.html
*
* == END LICENSE ==
*
* English language file for the sample plugin.
*/

FCKLang['DlgMyReplaceTitle'] = 'Plugin - Replace' ;
FCKLang['DlgMyReplaceFindLbl'] = 'Find what:' ;
FCKLang['DlgMyReplaceReplaceLbl'] = 'Replace with:' ;
FCKLang['DlgMyReplaceCaseChk'] = 'Match case' ;
FCKLang['DlgMyReplaceReplaceBtn'] = 'Replace' ;
FCKLang['DlgMyReplaceReplAllBtn'] = 'Replace All' ;
FCKLang['DlgMyReplaceWordChk'] = 'Match whole word' ;

FCKLang['DlgMyFindTitle'] = 'Plugin - Find' ;
FCKLang['DlgMyFindFindBtn'] = 'Find' ;

0 comments on commit ea48385

Please sign in to comment.