radiant-autoresize_textarea-extension 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ *.DS_Store
@@ -0,0 +1,4 @@
1
+ == Change Log
2
+
3
+ === 0.1.0 (September 21, 2010)
4
+ * Initial Release [Mario Visic]
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010 SquareTalent
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,13 @@
1
+ # radiant autoresize-textarea extension
2
+
3
+ a simple radiant extension that provides magical textareas that automatically resize to fit their contents within the admin interface.
4
+
5
+ ## install instructions
6
+
7
+ gem install radiant-autoresize_textarea-extension
8
+ # add the following line to your config/environment.rb: config.gem 'radiant-autoresize_textarea-extension', :lib => false
9
+ rake radiant:extensions:autoresize_textarea:update
10
+
11
+ ## license
12
+
13
+ the radiant autoresize textarea extension is licensed under the MIT standard license. see LICENSE for further information.
@@ -0,0 +1,136 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gem|
4
+ gem.name = "radiant-autoresize_textarea-extension"
5
+ gem.summary = %Q{Automatically resizes textarea controls to fit their contents in the radiant admin interface.}
6
+ gem.description = %Q{Automatically resizes textarea controls to fit their contents in the radiant admin interface.}
7
+ gem.email = "mario@squaretalent.com"
8
+ gem.homepage = "http://github.com/squaretalent/radiant-autoresize_textarea-extension"
9
+ gem.authors = ["SquareTalent"]
10
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
11
+ end
12
+ rescue LoadError
13
+ puts "Jeweler (or a dependency) not available. This is only required if you plan to package autoresize_textarea as a gem."
14
+ end
15
+
16
+ # In rails 1.2, plugins aren't available in the path until they're loaded.
17
+ # Check to see if the rspec plugin is installed first and require
18
+ # it if it is. If not, use the gem version.
19
+
20
+ # Determine where the RSpec plugin is by loading the boot
21
+ unless defined? RADIANT_ROOT
22
+ ENV["RAILS_ENV"] = "test"
23
+ case
24
+ when ENV["RADIANT_ENV_FILE"]
25
+ require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
26
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
27
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
28
+ else
29
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
30
+ end
31
+ end
32
+
33
+ require 'rake'
34
+ require 'rake/rdoctask'
35
+ require 'rake/testtask'
36
+
37
+ rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
38
+ $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
39
+ require 'spec/rake/spectask'
40
+ require 'cucumber'
41
+ require 'cucumber/rake/task'
42
+
43
+ # Cleanup the RADIANT_ROOT constant so specs will load the environment
44
+ Object.send(:remove_const, :RADIANT_ROOT)
45
+
46
+ extension_root = File.expand_path(File.dirname(__FILE__))
47
+
48
+ task :default => :spec
49
+ task :stats => "spec:statsetup"
50
+
51
+ desc "Run all specs in spec directory"
52
+ Spec::Rake::SpecTask.new(:spec) do |t|
53
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
54
+ t.spec_files = FileList['spec/**/*_spec.rb']
55
+ end
56
+
57
+ task :features => 'spec:integration'
58
+
59
+ namespace :spec do
60
+ desc "Run all specs in spec directory with RCov"
61
+ Spec::Rake::SpecTask.new(:rcov) do |t|
62
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
63
+ t.spec_files = FileList['spec/**/*_spec.rb']
64
+ t.rcov = true
65
+ t.rcov_opts = ['--exclude', 'spec', '--rails']
66
+ end
67
+
68
+ desc "Print Specdoc for all specs"
69
+ Spec::Rake::SpecTask.new(:doc) do |t|
70
+ t.spec_opts = ["--format", "specdoc", "--dry-run"]
71
+ t.spec_files = FileList['spec/**/*_spec.rb']
72
+ end
73
+
74
+ [:models, :controllers, :views, :helpers].each do |sub|
75
+ desc "Run the specs under spec/#{sub}"
76
+ Spec::Rake::SpecTask.new(sub) do |t|
77
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
78
+ t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
79
+ end
80
+ end
81
+
82
+ desc "Run the Cucumber features"
83
+ Cucumber::Rake::Task.new(:integration) do |t|
84
+ t.fork = true
85
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
86
+ # t.feature_pattern = "#{extension_root}/features/**/*.feature"
87
+ t.profile = "default"
88
+ end
89
+
90
+ # Setup specs for stats
91
+ task :statsetup do
92
+ require 'code_statistics'
93
+ ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
94
+ ::STATS_DIRECTORIES << %w(View\ specs spec/views)
95
+ ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
96
+ ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
97
+ ::CodeStatistics::TEST_TYPES << "Model specs"
98
+ ::CodeStatistics::TEST_TYPES << "View specs"
99
+ ::CodeStatistics::TEST_TYPES << "Controller specs"
100
+ ::CodeStatistics::TEST_TYPES << "Helper specs"
101
+ ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
102
+ end
103
+
104
+ namespace :db do
105
+ namespace :fixtures do
106
+ desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
107
+ task :load => :environment do
108
+ require 'active_record/fixtures'
109
+ ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
110
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
111
+ Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
117
+
118
+ desc 'Generate documentation for the autoresize_textarea extension.'
119
+ Rake::RDocTask.new(:rdoc) do |rdoc|
120
+ rdoc.rdoc_dir = 'rdoc'
121
+ rdoc.title = 'AutoresizeTextareaExtension'
122
+ rdoc.options << '--line-numbers' << '--inline-source'
123
+ rdoc.rdoc_files.include('README')
124
+ rdoc.rdoc_files.include('lib/**/*.rb')
125
+ end
126
+
127
+ # For extensions that are in transition
128
+ desc 'Test the autoresize_textarea extension.'
129
+ Rake::TestTask.new(:test) do |t|
130
+ t.libs << 'lib'
131
+ t.pattern = 'test/**/*_test.rb'
132
+ t.verbose = true
133
+ end
134
+
135
+ # Load any custom rakefiles for extension
136
+ Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,14 @@
1
+ module AutoResizeInterface
2
+ def self.included(base)
3
+ base.class_eval {
4
+ before_filter :add_auto_resize, :only => [:edit, :new]
5
+ include InstanceMethods
6
+ }
7
+ end
8
+
9
+ module InstanceMethods
10
+ def add_auto_resize
11
+ include_javascript 'admin/auto_resize.js'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ class AutoresizeTextareaExtension < Radiant::Extension
2
+ version "1.0"
3
+ description "Describe your extension here"
4
+ url "http://yourwebsite.com/autoresize_textarea"
5
+
6
+
7
+ def activate
8
+ Admin::ResourceController.send :include, AutoResizeInterface
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ ---
2
+ en:
3
+ autoresize textarea: Autoresize Textarea
@@ -0,0 +1,5 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ # map.namespace :admin, :member => { :remove => :get } do |admin|
3
+ # admin.resources :autoresize_textarea
4
+ # end
5
+ end
@@ -0,0 +1 @@
1
+ default: --format progress features --tags ~@proposed,~@in_progress
@@ -0,0 +1,16 @@
1
+ # Sets up the Rails environment for Cucumber
2
+ ENV["RAILS_ENV"] = "test"
3
+ # Extension root
4
+ extension_env = File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
5
+ require extension_env+'.rb'
6
+
7
+ Dir.glob(File.join(RADIANT_ROOT, "features", "**", "*.rb")).each {|step| require step}
8
+
9
+ Cucumber::Rails::World.class_eval do
10
+ include Dataset
11
+ datasets_directory "#{RADIANT_ROOT}/spec/datasets"
12
+ Dataset::Resolver.default = Dataset::DirectoryResolver.new("#{RADIANT_ROOT}/spec/datasets", File.dirname(__FILE__) + '/../../spec/datasets', File.dirname(__FILE__) + '/../datasets')
13
+ self.datasets_database_dump_path = "#{Rails.root}/tmp/dataset"
14
+
15
+ # dataset :autoresize_textarea
16
+ end
@@ -0,0 +1,14 @@
1
+ def path_to(page_name)
2
+ case page_name
3
+
4
+ when /the homepage/i
5
+ root_path
6
+
7
+ when /login/i
8
+ login_path
9
+ # Add more page name => path mappings here
10
+
11
+ else
12
+ raise "Can't find mapping from \"#{page_name}\" to a path."
13
+ end
14
+ end
@@ -0,0 +1,48 @@
1
+ namespace :radiant do
2
+ namespace :extensions do
3
+ namespace :autoresize_textarea do
4
+
5
+ desc "Runs the migration of the Autoresize Textarea extension"
6
+ task :migrate => :environment do
7
+ puts "radiant:autoresize_textarea:migrate - Nohing to do"
8
+ end
9
+
10
+ desc "Copies public assets of the Autoresize Textarea to the instance public/ directory."
11
+ task :update => :environment do
12
+ is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
13
+ puts "Copying assets from AutoresizeTextareaExtension"
14
+ Dir[AutoresizeTextareaExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
15
+ path = file.sub(AutoresizeTextareaExtension.root, '')
16
+ directory = File.dirname(path)
17
+ mkdir_p RAILS_ROOT + directory, :verbose => false
18
+ cp file, RAILS_ROOT + path, :verbose => false
19
+ end
20
+ unless AutoresizeTextareaExtension.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
21
+ puts "Copying rake tasks from AutoresizeTextareaExtension"
22
+ local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
23
+ mkdir_p local_tasks_path, :verbose => false
24
+ Dir[File.join AutoresizeTextareaExtension.root, %w(lib tasks *.rake)].each do |file|
25
+ cp file, local_tasks_path, :verbose => false
26
+ end
27
+ end
28
+ end
29
+
30
+ desc "Syncs all available translations for this ext to the English ext master"
31
+ task :sync => :environment do
32
+ # The main translation root, basically where English is kept
33
+ language_root = AutoresizeTextareaExtension.root + "/config/locales"
34
+ words = TranslationSupport.get_translation_keys(language_root)
35
+
36
+ Dir["#{language_root}/*.yml"].each do |filename|
37
+ next if filename.match('_available_tags')
38
+ basename = File.basename(filename, '.yml')
39
+ puts "Syncing #{basename}"
40
+ (comments, other) = TranslationSupport.read_file(filename, basename)
41
+ words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
42
+ other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
43
+ TranslationSupport.write_file(filename, basename, comments, other)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,65 @@
1
+ /* Based on http://stackoverflow.com/questions/7477/autosizing-textarea/948445#948445 Heavily modified by Mario Visic */
2
+
3
+ if (window.Widget == undefined)
4
+ {
5
+ window.Widget = {};
6
+ }
7
+
8
+ Widget.Textarea = Class.create(
9
+ {
10
+ initialize: function(textarea, options)
11
+ {
12
+ this.textarea = $(textarea);
13
+ this.options = $H(
14
+ {
15
+ 'min_height' : 280,
16
+ 'max_length' : 400
17
+ }).update(options);
18
+
19
+ this.textarea.setStyle(
20
+ {
21
+ overflow : 'hidden',
22
+ lineHeight : '18px'
23
+
24
+ });
25
+
26
+ this.textarea.observe('keyup', this.refresh.bind(this));
27
+
28
+ this._shadow = new Element('div').setStyle(
29
+ {
30
+ lineHeight : this.textarea.getStyle('lineHeight'),
31
+ fontSize : this.textarea.getStyle('fontSize'),
32
+ fontFamily : this.textarea.getStyle('fontFamily'),
33
+ position : 'absolute',
34
+ top : '-10000px',
35
+ left : '-10000px',
36
+ width : this.textarea.getWidth() + 'px'
37
+ });
38
+
39
+ this.textarea.insert(
40
+ {
41
+ after: this._shadow
42
+ });
43
+
44
+ this.refresh();
45
+ },
46
+
47
+ refresh: function()
48
+ {
49
+ this._shadow.update($F(this.textarea).replace(/\n/g, '<br/>'));
50
+ this.textarea.setStyle(
51
+ {
52
+ height: Math.max(parseInt(this._shadow.getHeight()) + parseInt(this.textarea.getStyle('lineHeight').replace('px', '')), this.options.get('min_height')) + 'px'
53
+ });
54
+ }
55
+ });
56
+
57
+
58
+ /* Create widgets for resizing our textareas when the page is loaded */
59
+ document.observe('dom:loaded', function()
60
+ {
61
+ $$('textarea').each(function(textarea)
62
+ {
63
+ new Widget.Textarea(textarea);
64
+ });
65
+ });
@@ -0,0 +1,6 @@
1
+ --colour
2
+ --format
3
+ progress
4
+ --loadby
5
+ mtime
6
+ --reverse
@@ -0,0 +1,36 @@
1
+ unless defined? RADIANT_ROOT
2
+ ENV["RAILS_ENV"] = "test"
3
+ case
4
+ when ENV["RADIANT_ENV_FILE"]
5
+ require ENV["RADIANT_ENV_FILE"]
6
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
7
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
8
+ else
9
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
10
+ end
11
+ end
12
+ require "#{RADIANT_ROOT}/spec/spec_helper"
13
+
14
+ Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
15
+
16
+ if File.directory?(File.dirname(__FILE__) + "/matchers")
17
+ Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
18
+ end
19
+
20
+ Spec::Runner.configure do |config|
21
+ # config.use_transactional_fixtures = true
22
+ # config.use_instantiated_fixtures = false
23
+ # config.fixture_path = RAILS_ROOT + '/spec/fixtures'
24
+
25
+ # You can declare fixtures for each behaviour like this:
26
+ # describe "...." do
27
+ # fixtures :table_a, :table_b
28
+ #
29
+ # Alternatively, if you prefer to declare them only once, you can
30
+ # do so here, like so ...
31
+ #
32
+ # config.global_fixtures = :table_a, :table_b
33
+ #
34
+ # If you declare global fixtures, be aware that they will be declared
35
+ # for all of your examples, even those that don't use them.
36
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiant-autoresize_textarea-extension
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - SquareTalent
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-21 00:00:00 +08:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Automatically resizes textarea controls to fit their contents in the radiant admin interface.
23
+ email: mario@squaretalent.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - LICENSE
30
+ - README.md
31
+ files:
32
+ - .gitignore
33
+ - CHANGELOG
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - VERSION
38
+ - app/models/auto_resize_interface.rb
39
+ - autoresize_textarea_extension.rb
40
+ - config/locales/en.yml
41
+ - config/routes.rb
42
+ - cucumber.yml
43
+ - features/support/env.rb
44
+ - features/support/paths.rb
45
+ - lib/tasks/autoresize_textarea_extension_tasks.rake
46
+ - public/javascripts/admin/auto_resize.js
47
+ - spec/spec.opts
48
+ - spec/spec_helper.rb
49
+ has_rdoc: true
50
+ homepage: http://github.com/squaretalent/radiant-autoresize_textarea-extension
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options:
55
+ - --charset=UTF-8
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ requirements: []
77
+
78
+ rubyforge_project:
79
+ rubygems_version: 1.3.7
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Automatically resizes textarea controls to fit their contents in the radiant admin interface.
83
+ test_files:
84
+ - spec/spec_helper.rb