...
 
Commits (135)
image: 0xacab.org:4567/riseuplabs/docker/crabgrass:latest
image: 0xacab.org:4567/riseuplabs/docker/crabgrass:stretch_amd64
variables:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
......@@ -23,37 +23,14 @@ bundle_audit:
bundle-audit check
test:
stage: test
services:
- mysql:5.5
script: |
bundle exec rake create_a_secret
cp config/database.yml.example config/database.yml
bundle exec rake db:create
bundle exec rake db:schema:load
bundle exec rake cg:test:update_fixtures
bundle exec rake db:test:prepare
RAILS_ENV=test bundle exec rake db:fixtures:load
RAILS_ENV=test bundle exec rake ts:index ts:start
bundle exec rake
bundle exec rake cg:cleanup:all # test cleanup tasks
artifacts:
when: on_failure
paths:
- log/test.log
- tmp/*.log
- tmp/*.html
- tmp/*.png
test_stretch:
image: 0xacab.org:4567/riseuplabs/docker/crabgrass:stretch_amd64
stage: test
services:
- mariadb:10.1
variables:
MYSQL_HOST: 'mariadb'
RAILS_ENV: 'test'
COVERAGE: 'true'
script: |
bundle exec rake create_a_secret
cp config/database.yml.example config/database.yml
bundle exec rake db:create
bundle exec rake db:schema:load
......@@ -61,8 +38,9 @@ test_stretch:
bundle exec rake db:test:prepare
RAILS_ENV=test bundle exec rake db:fixtures:load
RAILS_ENV=test bundle exec rake ts:index ts:start
bundle exec rake
bundle exec rake cg:cleanup:all # test cleanup tasks
bundle exec rails test test/functional test/unit test/integration extensions/pages
echo 'Number of deprecations in the test logs:'
grep DEPRECATION log/test.log | wc -l
artifacts:
when: on_failure
paths:
......
AllCops:
TargetRailsVersion: 5.1
TargetRubyVersion: 2.3
Exclude:
- 'bin/*'
DisplayCopNames: true
......@@ -17,3 +19,8 @@ Metrics/LineLength:
- 'config/deploy.rb'
- 'config/permissions.rb'
- 'lib/**/*'
Style/ClassAndModuleChildren:
Exclude:
- 'app/helpers/**/*'
Style/FrozenStringLiteralComment:
AutoCorrect: false
SimpleCov.start 'rails' do
add_filter 'vendor/ruby' # Don't include bundled stuff
end
......@@ -20,7 +20,6 @@ addons:
before_install:
- "bundle --version"
before_script:
- "bundle exec rake create_a_secret"
- "cp config/database.yml.example config/database.yml"
- "bundle exec rake db:create"
- "bundle exec rake db:schema:load"
......
source 'https://rubygems.org'
# ensure github urls use https rather than insecure git protocol.
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
"https://github.com/#{repo_name}.git"
end
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
##
# Core components
##
# Rails is the framework we use.
# use the 4.2 series including all security fixes
gem 'rails', '~> 4.2.11'
gem 'rails', '~> 5.2.3'
# Security updates
# https://github.com/sparklemotion/nokogiri/issues/1785
gem 'nokogiri', '~> 1.8.5'
#https://github.com/sparklemotion/nokogiri/issues/1892
gem 'nokogiri', '~> 1.10.3'
# Rake is rubys make... performing tasks
# locking in to latest major to fix API
......@@ -25,13 +21,15 @@ gem 'rake', '~> 10.0', require: false
# Application preloader for faster start time
gem 'spring', group: :development
# translating strings for the user interface
# reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
# locking in to latest major to fix API
gem 'i18n', '~> 0.7'
# improved gem to access mysql database
# locking in to latest major to fix API
gem 'mysql2', '~> 0.3.18'
gem 'mysql2', '~> 0.5.2'
# parsing and generating JSON
# locking in to latest major to fix API
......@@ -39,8 +37,8 @@ gem 'json', '~> 1.8'
# Markup language that uses indent to indicate nesting
# locking in to latest major to fix API
gem 'haml', '~> 4.0'
gem 'haml-rails', '~> 0.9.0'
gem 'haml', '~> 5.0'
gem 'haml-rails', '~> 1.0'
# Extendet scriptable CSS language
# locking in to latest major to fix API
......@@ -48,29 +46,21 @@ gem 'sass'
##
# Prototype - yes. we still use it.
# these will be replaced by jquery equivalents at some point:
##
# main part of prototype
# needs special branch for rails 4.2
gem 'prototype-rails', github: 'rails/prototype-rails', branch: '4.2'
# we use a fork which is rails 5.x compatible
# tests do not pass for this fork
gem 'prototype-rails', github: 'voxmedia/prototype-rails', ref: 'e385756cbabb5608d1eab47b6416cdd49613c73b'
# Full text search for the database
gem 'thinking-sphinx', '~> 3.4.2'
# Enhanced Tagging lib. Used to tag pages
gem 'acts-as-taggable-on', '~> 4.0'
gem 'acts-as-taggable-on', '~> 6.0'
# Rails 5 migration
##
# security updates
##
#
# CVE-2018-16471
# Criticality: Unknown
# URL:
# https://groups.google.com/forum/#!topic/ruby-security-ann/NAalCee8n6o
# Title: Possible XSS vulnerability in Rack
gem 'rack', '~> 1.6.11'
# ActionView::Helpers::RecordTagHelper moved to external gem
gem 'record_tag_helper', '~> 1.0'
##
# Upgrade pending
......@@ -95,10 +85,8 @@ gem 'pundit', '~> 1.1'
# Bcrypt for has_secure_password
gem 'bcrypt', '~> 3.1.7'
#
gem 'secure_headers', '~> 4.0.2'
# ?
# locking in to latest major to fix API
gem 'http_accept_language', '~> 2.0'
......@@ -144,7 +132,7 @@ gem 'greencloth', require: 'greencloth',
# media upload post processing has it's own repo
# version is rather strict for now as api may still change.
gem 'crabgrass_media', '~> 0.2.1', require: 'media'
gem 'crabgrass_media', '~> 0.3.1', require: 'media'
##
## not required, but a really good idea
......@@ -181,6 +169,7 @@ group :production do
# runs independendly - so no version restriction for now
# TODO: check if we want this or nodejs
gem 'therubyracer'
# gem 'mini_racer', platforms: :ruby # new default in Rails 5.2
end
group :production, :development do
......@@ -204,6 +193,8 @@ group :test, :development do
gem 'byebug'
end
gem 'web-console', group: :development
group :test, :ci do
##
## TESTS
......@@ -212,7 +203,11 @@ group :test, :ci do
gem 'factory_bot_rails'
gem 'faker', '~> 1.0.0'
gem 'minitest', require: false
# temporary fix for minitest 5.11 issue
gem 'minitest', '~>5.10.3', require: false
# contains helper methods like assigns and assert_template
gem 'rails-controller-testing'
##
## INTEGRATION TESTS
......
GIT
remote: https://github.com/rails/prototype-rails.git
revision: 0fed929ff48c10c3b978edd3baa983a81f404dbf
branch: 4.2
remote: https://github.com/voxmedia/prototype-rails.git
revision: e385756cbabb5608d1eab47b6416cdd49613c73b
ref: e385756cbabb5608d1eab47b6416cdd49613c73b
specs:
prototype-rails (4.0.0)
rails (~> 4.0)
prototype-rails (4.1.3)
rails (>= 4.2)
PATH
remote: vendor/gems/riseuplabs-greencloth-0.1
......@@ -17,111 +17,124 @@ GEM
specs:
RedCloth (4.3.2)
aasm (3.4.0)
actionmailer (4.2.11.1)
actionpack (= 4.2.11.1)
actionview (= 4.2.11.1)
activejob (= 4.2.11.1)
actioncable (5.2.3)
actionpack (= 5.2.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailer (5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
activejob (= 5.2.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.11.1)
actionview (= 4.2.11.1)
activesupport (= 4.2.11.1)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
actionpack (5.2.3)
actionview (= 5.2.3)
activesupport (= 5.2.3)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionpack-page_caching (1.1.0)
actionpack-page_caching (1.1.1)
actionpack (>= 4.0.0, < 6)
actionview (4.2.11.1)
activesupport (= 4.2.11.1)
actionview (5.2.3)
activesupport (= 5.2.3)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (4.2.11.1)
activesupport (= 4.2.11.1)
globalid (>= 0.3.0)
activemodel (4.2.11.1)
activesupport (= 4.2.11.1)
builder (~> 3.1)
activerecord (4.2.11.1)
activemodel (= 4.2.11.1)
activesupport (= 4.2.11.1)
arel (~> 6.0)
activesupport (4.2.11.1)
i18n (~> 0.7)
activejob (5.2.3)
activesupport (= 5.2.3)
globalid (>= 0.3.6)
activemodel (5.2.3)
activesupport (= 5.2.3)
activerecord (5.2.3)
activemodel (= 5.2.3)
activesupport (= 5.2.3)
arel (>= 9.0)
activestorage (5.2.3)
actionpack (= 5.2.3)
activerecord (= 5.2.3)
marcel (~> 0.3.1)
activesupport (5.2.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
acts-as-taggable-on (4.0.0)
activerecord (>= 4.0)
acts_as_list (0.9.1)
acts-as-taggable-on (6.0.0)
activerecord (~> 5.0)
acts_as_list (0.9.19)
activerecord (>= 3.0)
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
arel (6.0.4)
bcrypt (3.1.11)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
arel (9.0.0)
bcrypt (3.1.12)
bindex (0.7.0)
bootsnap (1.4.4)
msgpack (~> 1.0)
builder (3.2.3)
bundler-audit (0.6.1)
bundler (>= 1.2.0, < 3)
thor (~> 0.18)
byebug (9.0.6)
capybara (2.12.0)
byebug (11.0.1)
capybara (3.15.1)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.2)
xpath (~> 3.2)
chronic (0.10.2)
cliver (0.3.2)
concurrent-ruby (1.1.5)
crabgrass_media (0.2.1)
activesupport (~> 4.2)
crabgrass_media (0.3.1)
activesupport (~> 5.0)
mime-types (~> 3.1)
crass (1.0.4)
daemons (1.2.4)
delayed_job (4.1.2)
activesupport (>= 3.0, < 5.1)
delayed_job_active_record (4.1.1)
activerecord (>= 3.0, < 5.1)
daemons (1.3.1)
delayed_job (4.1.5)
activesupport (>= 3.0, < 5.3)
delayed_job_active_record (4.1.3)
activerecord (>= 3.0, < 5.3)
delayed_job (>= 3.0, < 5)
docile (1.1.5)
docile (1.3.1)
erubi (1.8.0)
erubis (2.7.0)
execjs (2.7.0)
factory_bot (4.8.2)
activesupport (>= 3.0.0)
factory_bot_rails (4.8.2)
factory_bot (~> 4.8.2)
railties (>= 3.0.0)
factory_bot (5.0.2)
activesupport (>= 4.2.0)
factory_bot_rails (5.0.2)
factory_bot (~> 5.0.2)
railties (>= 4.2.0)
faker (1.0.1)
i18n (~> 0.4)
ffi (1.9.25)
ffi (1.10.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
gpgme (2.0.16)
gpgme (2.0.18)
mini_portile2 (~> 2.3)
haml (4.0.7)
haml (5.0.4)
temple (>= 0.8.0)
tilt
haml-rails (0.9.0)
haml-rails (1.0.0)
actionpack (>= 4.0.1)
activesupport (>= 4.0.1)
haml (>= 4.0.6, < 5.0)
haml (>= 4.0.6, < 6.0)
html2haml (>= 1.0.1)
railties (>= 4.0.1)
html2haml (2.1.0)
html2haml (2.2.0)
erubis (~> 2.7.0)
haml (~> 4.0)
haml (>= 4.0, < 6)
nokogiri (>= 1.6.0)
ruby_parser (~> 3.5)
http_accept_language (2.1.0)
http_accept_language (2.1.1)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
innertube (1.1.0)
joiner (0.3.4)
activerecord (>= 4.1.0)
joiner (0.4.2)
activerecord (>= 5.2.beta1)
json (1.8.6)
libv8 (3.16.14.17)
libv8 (3.16.14.19)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
......@@ -130,72 +143,91 @@ GEM
mail-gpg (0.3.3)
gpgme (~> 2.0, >= 2.0.2)
mail (~> 2.5, >= 2.5.3)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (0.9.2)
middleware (0.1.0)
mime-types (3.1)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mime-types-data (3.2019.0331)
mimemagic (0.3.3)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
minitest (5.11.3)
mysql2 (0.3.21)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
mini_portile2 (2.4.0)
minitest (5.10.3)
msgpack (1.2.10)
mysql2 (0.5.2)
nio4r (2.3.1)
nokogiri (1.10.4)
mini_portile2 (~> 2.4.0)
phantomjs-binaries (2.1.1.1)
sys-uname (= 0.9.0)
poltergeist (1.13.0)
capybara (~> 2.1)
poltergeist (1.18.1)
capybara (>= 2.1, < 4)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
public_suffix (2.0.5)
public_suffix (3.0.3)
pundit (1.1.0)
activesupport (>= 3.0.0)
rack (1.6.11)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.11.1)
actionmailer (= 4.2.11.1)
actionpack (= 4.2.11.1)
actionview (= 4.2.11.1)
activejob (= 4.2.11.1)
activemodel (= 4.2.11.1)
activerecord (= 4.2.11.1)
activesupport (= 4.2.11.1)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.11.1)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.9)
activesupport (>= 4.2.0, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rack (2.0.7)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.3)
actioncable (= 5.2.3)
actionmailer (= 5.2.3)
actionpack (= 5.2.3)
actionview (= 5.2.3)
activejob (= 5.2.3)
activemodel (= 5.2.3)
activerecord (= 5.2.3)
activestorage (= 5.2.3)
activesupport (= 5.2.3)
bundler (>= 1.3.0)
railties (= 5.2.3)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.4)
actionpack (>= 5.0.1.x)
actionview (>= 5.0.1.x)
activesupport (>= 5.0.1.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (4.2.11.1)
actionpack (= 4.2.11.1)
activesupport (= 4.2.11.1)
railties (5.2.3)
actionpack (= 5.2.3)
activesupport (= 5.2.3)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
thor (>= 0.19.0, < 2.0)
rake (10.5.0)
rdoc (4.3.0)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
rdoc (6.1.1)
record_tag_helper (1.0.0)
actionview (~> 5.x)
ref (2.0.0)
riddle (2.2.2)
ruby_parser (3.8.4)
sexp_processor (~> 4.1)
regexp_parser (1.4.0)
riddle (2.3.2)
ruby_parser (3.13.1)
sexp_processor (~> 4.9)
rubyzip (1.2.2)
sass (3.4.23)
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sdoc (1.0.0)
rdoc (>= 5.0)
secure_headers (4.0.2)
useragent (>= 0.15.0)
sexp_processor (4.7.0)
simplecov (0.14.1)
docile (~> 1.1.0)
sexp_processor (4.12.0)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.1)
spring (2.0.1)
simplecov-html (0.10.2)
spring (2.0.2)
activesupport (>= 4.2)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
......@@ -204,9 +236,10 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
sqlite3 (1.4.1)
sys-uname (0.9.0)
ffi (>= 1.0.0)
temple (0.8.1)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
......@@ -219,27 +252,33 @@ GEM
riddle (>= 2.0.0)
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.6)
ts-delayed-delta (2.0.2)
tilt (2.0.9)
ts-delayed-delta (2.1.0)
activerecord (>= 2.0)
delayed_job
thinking-sphinx (>= 1.5.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (3.0.4)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
useragent (0.16.9)
useragent (0.16.10)
utf8-cleaner (0.2.5)
activesupport
validates_email_format_of (1.6.3)
i18n
websocket-driver (0.6.5)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
whenever (0.9.7)
websocket-extensions (0.1.3)
whenever (0.11.0)
chronic (>= 0.6.3)
will_paginate (3.1.5)
xpath (2.0.0)
nokogiri (~> 1.3)
will_paginate (3.1.7)
xpath (3.2.0)
nokogiri (~> 1.8)
zip-zip (0.3)
rubyzip (>= 1.0.0)
......@@ -250,35 +289,37 @@ DEPENDENCIES
RedCloth (~> 4.2)
aasm (~> 3.4)
actionpack-page_caching
acts-as-taggable-on (~> 4.0)
acts-as-taggable-on (~> 6.0)
acts_as_list (~> 0.4)
bcrypt (~> 3.1.7)
bootsnap (>= 1.1.0)
bundler-audit
byebug
capybara
crabgrass_media (~> 0.2.1)
crabgrass_media (~> 0.3.1)
daemons
delayed_job_active_record (~> 4.0)
factory_bot_rails
faker (~> 1.0.0)
greencloth!
haml (~> 4.0)
haml-rails (~> 0.9.0)
haml (~> 5.0)
haml-rails (~> 1.0)
http_accept_language (~> 2.0)
i18n (~> 0.7)
json (~> 1.8)
mail-gpg (~> 0.3.3)
mime-types
minitest
mysql2 (~> 0.3.18)
nokogiri (~> 1.8.5)
minitest (~> 5.10.3)
mysql2 (~> 0.5.2)
nokogiri (~> 1.10.3)
phantomjs-binaries (~> 2.1.1)
poltergeist (~> 1.5)
prototype-rails!
pundit (~> 1.1)
rack (~> 1.6.11)
rails (~> 4.2.11)
rails (~> 5.2.3)
rails-controller-testing
rake (~> 10.0)
record_tag_helper (~> 1.0)
rubyzip (~> 1.2.2)
sass
sdoc
......@@ -292,6 +333,7 @@ DEPENDENCIES
uglifier (>= 1.3.0)
utf8-cleaner
validates_email_format_of (~> 1.6)
web-console
whenever
will_paginate (~> 3.1)
zip-zip
......
......@@ -68,7 +68,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provision 'Install project dependencies', type: 'shell', privileged: false, inline: <<-SHELL
cd /vagrant/
bundle install
rake create_a_secret
SHELL
config.vm.provision 'Connect MySQL DB', type: 'shell', privileged: false, inline: <<-SHELL
......
......@@ -2,6 +2,7 @@ Javascripts
==============================================
Javascript are served using the Sprockets gem for asset pipelining.
We load all scripts by including application.js on all pages.
About these scripts
----------------------------------------------
......@@ -20,19 +21,6 @@ app/javascripts/prototype.js
scriptaculous effects for prototype that we also use.
Using scripts
----------------------------------------------
We currently load all scripts on all pages (e.g. there is nothing in
as_needed). If you want an 'as_needed' script that is only loaded for a
particular controller:
class MyController < ApplicationController
javascript :tasks, :wiki
javascript :extra, :action => :index
end
Stylesheets
==============================================
......
......@@ -16,18 +16,18 @@ function cgAutocompleteEntities(id, url, opts) {
rowRenderer: autoCompleteRowRenderer,
selectValue: autoCompleteSelectValue
};
if (opts) { Object.extend(options, opts); }
new Autocomplete(id, options, random_id);
}
if (opts) { Object.extend(options, opts); }
new Autocomplete(id, options, random_id);
function autoCompleteRowRenderer(value, re, data) {
return "<p class='icon xsmall' style='background-image: url(/avatars/" + data + "/xsmall.jpg)'>" + value.replace(/^<em>(.*)<\/em>(<br\/>(.*))?$/gi, function(m, m1, m2, m3){return "<em>" + Autocomplete.highlight(m1,re) + "</em>" + (m3 ? "<br/>" + Autocomplete.highlight(m3, re) : "")}) + "</p>";
}
function autoCompleteRowRenderer(value, re, data) {
return "<p class='icon xsmall' style='background-image: url(/avatars/" + data + "/xsmall.jpg)'>" + value.replace(/^<em>(.*)<\/em>(<br\/>(.*))?$/gi, function(m, m1, m2, m3){return "<em>" + Autocomplete.highlight(m1,re) + "</em>" + (m3 ? "<br/>" + Autocomplete.highlight(m3, re) : "")}) + "</p>";
}
function autoCompleteSelectValue(value){
// if there are two rows pick the second one
row = value.replace(/.*<br\/>(.*)/g,'$1');
// encode text without the tags
return row.replace(/<[^>]*>/g,'');
// return encodeURIComponent(row.replace(/<[^>]*>/g,''));
function autoCompleteSelectValue(value){
// if there are two rows pick the second one
row = value.replace(/.*<br\/>(.*)/g,'$1');
// encode text without the tags
return row.replace(/<[^>]*>/g,'');
// return encodeURIComponent(row.replace(/<[^>]*>/g,''));
}
}
......@@ -48,16 +48,6 @@ function replaceClassName(element, old_class, new_class) {
element.removeClassName(old_class); element.addClassName(new_class)
}
//
// replaces an element with a new one if it is empty.
//
function replaceIfEmpty(selector, newElement) {
var el = $$(selector).first()
if (el && el.empty()) {
el.replace(newElement);
}
}
//
// EVENTS
//
......@@ -102,40 +92,3 @@ var LocationHash = {
this.polling = true;
}
}
//
// split panel
//
function activatePanelRow(row_id) {
// reset styles
$$('.panel_right .row').invoke('hide');
$$('.panel_arrow').invoke('hide');
$$('.panel_left .row').invoke('removeClassName', 'active');
if (row_id) {
// highlight left panel row
$('panel_left_'+row_id).addClassName('active');
var halfHeight = $('panel_left_'+row_id).getHeight() / 2 + "px";
var borderWidthStr = "#{top} #{right} #{bottom} #{left}".interpolate({top: halfHeight, right:"0px", bottom: halfHeight, left:"10px"});
$('panel_arrow_'+row_id).setStyle({borderWidth: borderWidthStr, display: 'block'});
// position and show right panel row
var offset = $('panel_left_'+row_id).offsetTop + 'px';
$$('.panel_right').first().setStyle({paddingTop:offset})
$('panel_right_'+row_id).show();
}
}
//
// sliding list
//
// left and right contain these keys:
// path -- the url path of the panel. this is used both for history
// and loading content via ajax.
// domid -- dom id of the element to update
//
function activateSlidingRow(left, right) {
History.replaceState({slide_right:'sliding-list', update:left}, null, left.path);
History.pushState({slide_left:'sliding-list', update:right}, null, right.path);
}
//
// Busy cursor
//
// When a ajax request is pending, this will change the cursor to be a busy cursor.
// It depends on this css:
//
// html.busy, html.busy * {
// cursor: wait !important;
// }
//
// source: http://postpostmodern.com/instructional/global-ajax-cursor-change/
//
// NOTE: currently disabled. This is really cool, but some ajax queries
// cause activeRequestCount to keep incrementing. Until that is fixed,
// this must be disabled.
//
// in prototype:
// Ajax.Responders.register({
// onCreate: function() {
// if (Ajax.activeRequestCount > 0) {
// $$('html')[0].addClassName('busy');
// }
// },
// onComplete: function() {
// console.log("Ajax.activeRequestCount " + Ajax.activeRequestCount);
// if (Ajax.activeRequestCount == 0) {
// $$('html')[0].removeClassName('busy');
// }
// }
// });
// in jquery:
// function globalAjaxCursorChange() {
// $("html").bind("ajaxStart", function() {
// $(this).addClass('busy');
// }).bind("ajaxStop", function() {
// $(this).removeClass('busy');
// });
// }
\ No newline at end of file
//
// a modification of Effect.Move to support percentage offsets.
//
Effect.MoveByPercent = Class.create(Effect.Base, {
initialize: function(element) {
this.element = $(element);
if (!this.element) throw(Effect._elementDoesNotExistError);
var options = Object.extend({x:0, y:0}, arguments[1] || { });
this.start(options);
},
setup: function() {
this.element.makePositioned();
this.originalLeft = parseFloat(this.element.getStyle('left') || '0');
this.originalTop = parseFloat(this.element.getStyle('top') || '0');
},
update: function(position) {
this.element.setStyle({
left: (this.options.x * position + this.originalLeft).round() + '%',
top: (this.options.y * position + this.originalTop).round() + '%'
});
}
});
......@@ -91,22 +91,6 @@ function linkToggle(link, element, functn) {
}
}
// Finds all elements with the selector and removes the
// 'disabled' class.
// Options:
// * selector: selects the elements to apply on
// * disable: if set class 'disabled' will be set instead
// function enableAll(selector, disable) {
// var affectedElements = $$(selector);
// affectedElements.each(function(e) {
// if (disable) {
// e.addClassName('disabled');
// } else {
// e.removeClassName('disabled');
// }
// });
// }
//
// Checks if this element is in an disabled part of the DOM
// Can be used as a condition for onclick actions that should
......
// //
// // crabgrass pushState history support.
// //
// History.Adapter.bind(window,'statechange',function() {
// var state = History.getState();
// console.log('history state change: ' + JSON.stringify({url:state.url, data:state.data}))
// if (state.data) {
// process_history_state_change(state);
// }
// });
// function process_history_state_change(state) {
// var data = state.data;
// //
// // update a dom element with an ajax request
// //
// if (data.update && $(data.update.domid)) {
// new Ajax.Updater(data.update.domid, data.update.path, {
// asynchronous:true, evalScripts:true, method:'get'
// //parameters: 'authenticity_token=' + encodeURIComponent(data.token)
// });
// }
// //
// // hide and show a dom element
// //
// //if (data.hide && $(data.hide)) { $(data.hide).hide(); }
// //if (data.show && $(data.show)) { $(data.show).show(); }
// //
// // slide an dom element around
// //
// if (data.slide_left && $(data.slide_left)) {
// new Effect.MoveByPercent(data.slide_left, {duration: 0.5, x:-100});
// }
// if (data.slide_right && $(data.slide_right)) {
// new Effect.MoveByPercent(data.slide_right, {duration: 0.5, x:100});
// }
// }
A library to make HTML5 window.history work better, and also fallback
gracefully for HTML4 browsers.
https://github.com/balupton/History.js/
It is a little heavyweight, and includes a bunch of features we don't
need -- like storing data with history. For this reason, I created
json2-dummy.js, which tricks history.js into not storing data.
To update the source files in this directory:
cd app/assets/javascripts/libraries/history
curl https://nodeload.github.com/balupton/History.js/tarball/master | tar -vxz --transform 's/.*\/scripts\/uncompressed\///' --overwrite --wildcards '*/uncompressed/*.js'
rm history.adapter.jquery.js
rm history.adapter.mootools.js
rm history.adapter.right.js
rm history.adapter.zepto.js
There are two options we have for history.js support: html5 only or html5+html4.
For html5 only support, bundle these files:
history/history.adapter.native.js
history/history.js
For html4+html5 support, bundle these files (in this order):
history/json2.js
history/history.adapter.native.js
history/history.html4.js
history/history.js
See https://github.com/balupton/history.js/blob/master/buildr.coffee for the build rules.
NOTE: if/when we switch to jquery, replace native adapter with jquery adaptor.
/**
* History.js Native Adapter
* @author Benjamin Arthur Lupton <contact@balupton.com>
* @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/
// Closure
(function(window,undefined){
"use strict";
// Localise Globals
var History = window.History = window.History||{};
// Check Existence
if ( typeof History.Adapter !== 'undefined' ) {
throw new Error('History.js Adapter has already been loaded...');
}
// Add the Adapter
History.Adapter = {
/**
* History.Adapter.handlers[uid][eventName] = Array
*/
handlers: {},
/**
* History.Adapter._uid
* The current element unique identifier
*/
_uid: 1,
/**
* History.Adapter.uid(element)
* @param {Element} element
* @return {String} uid
*/
uid: function(element){
return element._uid || (element._uid = History.Adapter._uid++);
},
/**
* History.Adapter.bind(el,event,callback)
* @param {Element} element
* @param {String} eventName - custom and standard events
* @param {Function} callback
* @return
*/
bind: function(element,eventName,callback){
// Prepare
var uid = History.Adapter.uid(element);
// Apply Listener
History.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};
History.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];
History.Adapter.handlers[uid][eventName].push(callback);
// Bind Global Listener
element['on'+eventName] = (function(element,eventName){
return function(event){
History.Adapter.trigger(element,eventName,event);
};
})(element,eventName);
},
/**
* History.Adapter.trigger(el,event)
* @param {Element} element
* @param {String} eventName - custom and standard events
* @param {Object} event - a object of event data
* @return
*/
trigger: function(element,eventName,event){
// Prepare
event = event || {};
var uid = History.Adapter.uid(element),
i,n;
// Apply Listener
History.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};
History.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];
// Fire Listeners
for ( i=0,n=History.Adapter.handlers[uid][eventName].length; i<n; ++i ) {
History.Adapter.handlers[uid][eventName][i].apply(this,[event]);
}
},
/**
* History.Adapter.extractEventData(key,event,extra)
* @param {String} key - key for the event data to extract
* @param {String} event - custom and standard events
* @return {mixed}
*/
extractEventData: function(key,event){
var result = (event && event[key]) || undefined;
return result;
},
/**
* History.Adapter.onDomLoad(callback)
* @param {Function} callback
* @return
*/
onDomLoad: function(callback) {
var timeout = window.setTimeout(function(){
callback();
},2000);
window.onload = function(){
clearTimeout(timeout);
callback();
};