From 1f1c8094fe342feb851c681dcde25459b82faff0 Mon Sep 17 00:00:00 2001 From: Alex Denisov <1101.debian@gmail.com> Date: Mon, 3 Sep 2012 20:48:38 +0300 Subject: [PATCH 001/288] After commit instead of after_update --- app/observers/users_project_observer.rb | 12 ++++++++---- spec/observers/users_project_observer_spec.rb | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/observers/users_project_observer.rb b/app/observers/users_project_observer.rb index 763b2c87..e2fa1676 100644 --- a/app/observers/users_project_observer.rb +++ b/app/observers/users_project_observer.rb @@ -1,9 +1,13 @@ class UsersProjectObserver < ActiveRecord::Observer - def after_create(users_project) - Notify.project_access_granted_email(users_project.id).deliver - end + #def after_create(users_project) + #Notify.project_access_granted_email(users_project.id).deliver + #end - def after_update(users_project) + #def after_update(users_project) + #Notify.project_access_granted_email(users_project.id).deliver + #end + + def after_commit(users_project) Notify.project_access_granted_email(users_project.id).deliver end end diff --git a/spec/observers/users_project_observer_spec.rb b/spec/observers/users_project_observer_spec.rb index 3e392040..68fbcc4f 100644 --- a/spec/observers/users_project_observer_spec.rb +++ b/spec/observers/users_project_observer_spec.rb @@ -12,7 +12,7 @@ describe UsersProjectObserver do describe "#after_create" do it "should called when UsersProject created" do - subject.should_receive(:after_create) + subject.should_receive(:after_commit) UsersProject.observers.enable :users_project_observer do Factory.create(:users_project, project: project, @@ -21,20 +21,20 @@ describe UsersProjectObserver do end it "should send email to user" do Notify.should_receive(:project_access_granted_email).with(users_project.id).and_return(double(deliver: true)) - subject.after_create(users_project) + subject.after_commit(users_project) end end describe "#after_update" do it "should called when UsersProject updated" do - subject.should_receive(:after_update) + subject.should_receive(:after_commit) UsersProject.observers.enable :users_project_observer do users_project.update_attribute(:project_access, 40) end end it "should send email to user" do Notify.should_receive(:project_access_granted_email).with(users_project.id).and_return(double(deliver: true)) - subject.after_update(users_project) + subject.after_commit(users_project) end end end From af63607a5cf245b358acd153279faa3c22c099b0 Mon Sep 17 00:00:00 2001 From: Alex Denisov <1101.debian@gmail.com> Date: Mon, 3 Sep 2012 21:46:17 +0300 Subject: [PATCH 002/288] test_after_commit gem added --- Gemfile | 1 + Gemfile.lock | 2 ++ app/observers/users_project_observer.rb | 8 -------- spec/observers/users_project_observer_spec.rb | 15 +++++++++------ 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index b0724fad..5105e550 100644 --- a/Gemfile +++ b/Gemfile @@ -117,6 +117,7 @@ group :test do gem 'email_spec' gem 'resque_spec' gem "webmock" + gem 'test_after_commit' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 7ec37f59..da6c068b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -341,6 +341,7 @@ GEM tilt (~> 1.1, != 1.3.0) sqlite3 (1.3.6) stamp (0.1.6) + test_after_commit (0.0.1) therubyracer (0.10.1) libv8 (~> 3.3.10) thin (1.3.1) @@ -431,6 +432,7 @@ DEPENDENCIES six sqlite3 stamp + test_after_commit therubyracer thin uglifier (= 1.0.3) diff --git a/app/observers/users_project_observer.rb b/app/observers/users_project_observer.rb index e2fa1676..728607f0 100644 --- a/app/observers/users_project_observer.rb +++ b/app/observers/users_project_observer.rb @@ -1,12 +1,4 @@ class UsersProjectObserver < ActiveRecord::Observer - #def after_create(users_project) - #Notify.project_access_granted_email(users_project.id).deliver - #end - - #def after_update(users_project) - #Notify.project_access_granted_email(users_project.id).deliver - #end - def after_commit(users_project) Notify.project_access_granted_email(users_project.id).deliver end diff --git a/spec/observers/users_project_observer_spec.rb b/spec/observers/users_project_observer_spec.rb index 68fbcc4f..5bc4c877 100644 --- a/spec/observers/users_project_observer_spec.rb +++ b/spec/observers/users_project_observer_spec.rb @@ -10,9 +10,9 @@ describe UsersProjectObserver do user: user )} subject { UsersProjectObserver.instance } - describe "#after_create" do + describe "#after_commit" do it "should called when UsersProject created" do - subject.should_receive(:after_commit) + subject.should_receive(:after_commit).once UsersProject.observers.enable :users_project_observer do Factory.create(:users_project, project: project, @@ -23,11 +23,8 @@ describe UsersProjectObserver do Notify.should_receive(:project_access_granted_email).with(users_project.id).and_return(double(deliver: true)) subject.after_commit(users_project) end - end - - describe "#after_update" do it "should called when UsersProject updated" do - subject.should_receive(:after_commit) + subject.should_receive(:after_commit).once UsersProject.observers.enable :users_project_observer do users_project.update_attribute(:project_access, 40) end @@ -36,5 +33,11 @@ describe UsersProjectObserver do Notify.should_receive(:project_access_granted_email).with(users_project.id).and_return(double(deliver: true)) subject.after_commit(users_project) end + it "should not called after UsersProject destroyed" do + subject.should_not_receive(:after_commit) + UsersProject.observers.enable :users_project_observer do + users_project.destroy + end + end end end From 85db51f660c4d861c9adf97ed114d4bd4d14ff7d Mon Sep 17 00:00:00 2001 From: Alex Denisov <1101.debian@gmail.com> Date: Fri, 7 Sep 2012 10:23:45 +0300 Subject: [PATCH 003/288] don't send notification when UsersProject destroyed --- app/observers/users_project_observer.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/observers/users_project_observer.rb b/app/observers/users_project_observer.rb index 728607f0..34cae93f 100644 --- a/app/observers/users_project_observer.rb +++ b/app/observers/users_project_observer.rb @@ -1,5 +1,6 @@ class UsersProjectObserver < ActiveRecord::Observer def after_commit(users_project) + return if users_project.destroyed? Notify.project_access_granted_email(users_project.id).deliver end end From e3b149fae611d9c66d3e41048970bd78f322cc9c Mon Sep 17 00:00:00 2001 From: Caley Woods Date: Wed, 19 Sep 2012 10:27:27 -0500 Subject: [PATCH 004/288] Update comment in example unicorn config The timeout was changed to 30 and the comment wasn't updated. Also I've seen several reports of this timeout not being long enough for quite a few people. It resulted in me getting a 502 bad gateway from nginx until I upped it. Perhaps could back to the default 60 would be better? I changed mine to 300, running on an AWS micro instance. --- config/unicorn.rb.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/unicorn.rb.example b/config/unicorn.rb.example index 23746d25..425dbf33 100644 --- a/config/unicorn.rb.example +++ b/config/unicorn.rb.example @@ -6,7 +6,7 @@ working_directory app_dir # worker spawn times preload_app true -# nuke workers after 60 seconds (the default) +# nuke workers after 30 seconds (60 is the default) timeout 30 # listen on a Unix domain socket and/or a TCP port, From 6424fc715b14880448407b457215124b9dbde59c Mon Sep 17 00:00:00 2001 From: Florin Stan Date: Fri, 21 Sep 2012 13:02:59 -0600 Subject: [PATCH 005/288] changed the post-receive hook in order to push the correct repository name when the name contain special characters --- lib/hooks/post-receive | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hooks/post-receive b/lib/hooks/post-receive index a4fa9f1c..4e596679 100755 --- a/lib/hooks/post-receive +++ b/lib/hooks/post-receive @@ -7,6 +7,6 @@ while read oldrev newrev ref do # For every branch or tag that was pushed, create a Resque job in redis. pwd=`pwd` - reponame=`basename "$pwd" | cut -d. -f1` + reponame=`basename "$pwd" | sed s/\.git$//` env -i redis-cli rpush "resque:queue:post_receive" "{\"class\":\"PostReceive\",\"args\":[\"$reponame\",\"$oldrev\",\"$newrev\",\"$ref\",\"$GL_USER\"]}" > /dev/null 2>&1 done From 80bcba4ee25b34052c920d2c8ff58f7a72b44852 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Sun, 23 Sep 2012 08:53:48 -0700 Subject: [PATCH 006/288] install jquery-atwho-rails --- Gemfile | 1 + Gemfile.lock | 2 ++ app/assets/javascripts/application.js | 1 + app/assets/stylesheets/application.css | 1 + 4 files changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index 8e569c5b..3024d92c 100644 --- a/Gemfile +++ b/Gemfile @@ -96,6 +96,7 @@ group :assets do gem "therubyracer" gem 'chosen-rails' + gem 'jquery-atwho-rails', '0.1.6' gem "jquery-rails", "2.0.2" gem "jquery-ui-rails", "0.5.0" gem "modernizr", "2.5.3" diff --git a/Gemfile.lock b/Gemfile.lock index 3d27d3fb..e517bb36 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -199,6 +199,7 @@ GEM httpauth (0.1) i18n (0.6.1) journey (1.0.4) + jquery-atwho-rails (0.1.6) jquery-rails (2.0.2) railties (>= 3.2.0, < 5.0) thor (~> 0.14) @@ -440,6 +441,7 @@ DEPENDENCIES haml-rails headless httparty + jquery-atwho-rails (= 0.1.6) jquery-rails (= 2.0.2) jquery-ui-rails (= 0.5.0) kaminari diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index f9fdb0f7..02ef6cab 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -11,6 +11,7 @@ //= require jquery.endless-scroll //= require jquery.highlight //= require jquery.waitforimages +//= require jquery.atwho //= require bootstrap //= require modernizr //= require chosen-jquery diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 92d542a9..424ba71f 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -4,6 +4,7 @@ * the top of the compiled file, but it's generally better to create a new file per style scope. *= require jquery.ui.all *= require jquery.ui.aristo + *= require jquery.atwho *= require chosen *= require_self *= require main From 9c75fcbef16e68dd3898545fc5d11b1261de1a26 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Sun, 23 Sep 2012 09:52:01 -0700 Subject: [PATCH 007/288] auto complete team member mentions --- app/views/notes/_common_form.html.haml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/views/notes/_common_form.html.haml b/app/views/notes/_common_form.html.haml index fc6e3c7e..f91e921b 100644 --- a/app/views/notes/_common_form.html.haml +++ b/app/views/notes/_common_form.html.haml @@ -37,3 +37,8 @@ = f.file_field :attachment, class: "input-file" %span.hint Any file less than 10 MB +:javascript + $(function(){ + var names = #{@project.users.pluck(:name)}; + $('.note-text').atWho('@', { data: names }); + }); From c701507b6cf9ab4099d4d5847516436ca35658d8 Mon Sep 17 00:00:00 2001 From: Staicu Ionut Date: Mon, 24 Sep 2012 10:06:41 +0300 Subject: [PATCH 008/288] Removed float on emoji -`remove comment` button will not make the text jump anymore. --- app/assets/stylesheets/sections/notes.scss | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/sections/notes.scss b/app/assets/stylesheets/sections/notes.scss index 267a9b43..d24d070d 100644 --- a/app/assets/stylesheets/sections/notes.scss +++ b/app/assets/stylesheets/sections/notes.scss @@ -43,7 +43,9 @@ padding: 8px 0; overflow: hidden; display: block; + position:relative; img {float: left; margin-right: 10px;} + img.emoji {float:none;margin:0;} .note-author cite{font-style: italic;} p { color:$style_color; } .note-author { color: $style_color;} @@ -55,7 +57,9 @@ .delete-note { display:none; - float:right; + position:absolute; + right:0; + top:0; } &:hover { From d23022c6f68bd78a1d3b63a8bf7551145b1f46fd Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Sep 2012 12:32:51 +0300 Subject: [PATCH 009/288] Working on dashboard restyle and events refactoring --- app/assets/stylesheets/common.scss | 81 -------------- .../stylesheets/gitlab_bootstrap/lists.scss | 4 +- app/assets/stylesheets/main.scss | 1 + app/assets/stylesheets/sections/commits.scss | 46 ++++---- app/assets/stylesheets/sections/events.scss | 105 ++++++++++++++++++ app/views/events/_commit.html.haml | 2 +- app/views/events/_event.html.haml | 17 +-- app/views/events/_event_issue.html.haml | 18 ++- .../_event_membership_changed.html.haml | 15 +-- .../events/_event_merge_request.html.haml | 26 ++--- app/views/events/_event_push.html.haml | 49 ++++---- 11 files changed, 194 insertions(+), 170 deletions(-) create mode 100644 app/assets/stylesheets/sections/events.scss diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index c5b37916..f13a1d6d 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -185,36 +185,6 @@ span.update-author { } } -.event_label { - @extend .label; - background-color: #999; - - &.pushed { - background-color: #4A97BD; - } - - &.opened { - background-color: #469847; - } - - &.closed { - background-color: #B94A48; - } - - &.merged { - background-color: #2A2; - } - - &.joined { - background-color: #1ca9dd; - } - - &.left { - background-color: #888; - float:none; - } -} - form { @extend .form-horizontal; @@ -355,41 +325,6 @@ p.time { border:2px solid #ddd; } -.event_feed { - min-height:40px; - border-bottom:1px solid #ddd; - .avatar { - width:32px; - } - .event_icon { - float:right; - margin-right:2px; - img { - width:20px; - } - } - ul { - margin-left:50px; - margin-bottom:5px; - .avatar { - width:24px; - } - } - - padding: 15px 5px; - &:last-child { border:none } - .wll:hover { background:none } - - .event_commits { - margin-top: 5px; - - li.commit { - background: transparent; - padding:5px; - border:none; - } - } -} .ico { background: url("images.png") no-repeat -85px -77px; @@ -639,22 +574,6 @@ li.note { background:#fff; } -/** - * Push event widget - * - */ -.event_lp { - @extend .ui-box; - color:#777; - margin-bottom:20px; - padding:8px; - @include border-radius(4px); - min-height:22px; - - .avatar { - width:24px; - } -} .supp_diff_link, .mr_show_all_commits { diff --git a/app/assets/stylesheets/gitlab_bootstrap/lists.scss b/app/assets/stylesheets/gitlab_bootstrap/lists.scss index 402ba04b..5585c35c 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/lists.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/lists.scss @@ -1,6 +1,6 @@ /** LISTS **/ -ul { +ul { /** * List li block element #1 * @@ -18,7 +18,7 @@ ul { .author { color: #999; } p { - padding-top:5px; + padding-top:5px; margin:0; color:#222; img { diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index 75001d3a..14b289c0 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -143,6 +143,7 @@ $hover: #fdf5d9; @import "sections/projects.scss"; @import "sections/merge_requests.scss"; @import "sections/graph.scss"; +@import "sections/events.scss"; /** * This scss file redefine chozen selectbox styles for diff --git a/app/assets/stylesheets/sections/commits.scss b/app/assets/stylesheets/sections/commits.scss index 75e38aee..33b05135 100644 --- a/app/assets/stylesheets/sections/commits.scss +++ b/app/assets/stylesheets/sections/commits.scss @@ -1,7 +1,7 @@ .commit-box { @extend .main_box; - .commit-head { + .commit-head { @extend .top_box_content; .commit-title { @@ -29,11 +29,11 @@ .sha-block { text-align:right; - &:first-child { + &:first-child { padding-bottom:6px; } - a { + a { border-bottom: 1px solid #aaa; margin-left: 9px; } @@ -54,7 +54,7 @@ } /** - * + * * COMMIT SHOw * */ @@ -71,7 +71,7 @@ background-image: -moz-linear-gradient(#eee 6.6%, #dfdfdf); background-image: -o-linear-gradient(#eee 6.6%, #dfdfdf); - span { + span { font-size:14px; } } @@ -111,8 +111,8 @@ } } - &.img_compared { - img { + &.img_compared { + img { max-width:300px; } } @@ -120,12 +120,12 @@ } .diff_file_content{ - table { + table { border:none; margin:0px; padding:0px; tr { - td { + td { font-size:12px; } } @@ -145,29 +145,29 @@ moz-user-select: none; -khtml-user-select: none; user-select: none; - a { + a { float:left; width:35px; font-weight:normal; color:#666; - &:hover { + &:hover { text-decoration:underline; } } } - .line_content { - white-space:pre; + .line_content { + white-space:pre; height:14px; margin:0px; padding:0px; border:none; - &.new { + &.new { background: #CFD; } - &.old { + &.old { background: #FDD; } - &.matched { + &.matched { color:#ccc; background:#fafafa; } @@ -182,32 +182,32 @@ /** COMMIT ROW **/ -.commit { +.commit { @extend .wll; - .browse_code_link_holder { + .browse_code_link_holder { @extend .span2; float:right; } - .committed_ago { + .committed_ago { float:right; @extend .cgray; } - code { + code { background:#FCEEC1; color:$style_color; } - .commit_short_id { + .commit_short_id { float:left; @extend .lined; min-width:65px; font-family: 'Menlo', 'Liberation Mono', 'Consolas', 'Courier New', 'andale mono','lucida console',monospace; } - - .commit-author-name { + + .commit-author-name { color: #777; } } diff --git a/app/assets/stylesheets/sections/events.scss b/app/assets/stylesheets/sections/events.scss new file mode 100644 index 00000000..7c414d05 --- /dev/null +++ b/app/assets/stylesheets/sections/events.scss @@ -0,0 +1,105 @@ +/** + * Events labels + * + */ +.event_label { + /*@extend .label;*/ + /*background-color: #999;*/ + + /*&.pushed {*/ + /*background-color: #4A97BD;*/ + /*}*/ + + /*&.opened {*/ + /*background-color: #469847;*/ + /*}*/ + + /*&.closed {*/ + /*background-color: #B94A48;*/ + /*}*/ + + /*&.merged {*/ + /*background-color: #2A2;*/ + /*}*/ + + /*&.joined {*/ + /*background-color: #1ca9dd;*/ + /*}*/ + + /*&.left {*/ + /*background-color: #888;*/ + /*float:none;*/ + /*}*/ +} + +/** + * Dashboard events feed + * + */ +.event-item { + min-height:40px; + border-bottom:1px solid #eee; + .event-title { + color:#333; + font-weight: bold; + .author_name { + color:#777; + } + } + .event-body { + p { + color:#666; + } + } + .avatar { + width:32px; + } + .event_icon { + float: right; + border: 1px solid #EEE; + padding: 5px; + @include border-radius(5px); + background: #F9F9F9; + img { + width:20px; + } + } + ul { + margin-left:50px; + margin-bottom:5px; + .avatar { + width:22px; + } + } + + padding: 15px 5px; + &:last-child { border:none } + .wll:hover { background:none } + + .event_commits { + margin-top: 5px; + + li.commit { + background: transparent; + padding:5px; + border:none; + } + } +} + +/** + * Push event widget + * + */ +.event_lp { + @extend .ui-box; + color:#777; + margin-bottom:20px; + padding:8px; + @include border-radius(4px); + min-height:22px; + + .avatar { + width:24px; + } +} diff --git a/app/views/events/_commit.html.haml b/app/views/events/_commit.html.haml index cb25d831..ed4f33c0 100644 --- a/app/views/events/_commit.html.haml +++ b/app/views/events/_commit.html.haml @@ -2,7 +2,7 @@ %li.commit %p = link_to commit.short_id(8), project_commit_path(project, id: commit.id), class: "commit_short_id" - %strong.cdark= commit.author_name + %span= commit.author_name – = image_tag gravatar_icon(commit.author_email), class: "avatar", width: 16 = gfm escape_once(truncate(commit.title, length: 50)) rescue "--broken encoding" diff --git a/app/views/events/_event.html.haml b/app/views/events/_event.html.haml index 7bae8db1..716a214b 100644 --- a/app/views/events/_event.html.haml +++ b/app/views/events/_event.html.haml @@ -1,17 +1,18 @@ - if event.allowed? - - if event.issue? - .event_feed + %div.event-item + - if event.issue? = render "events/event_issue", event: event - - elsif event.merge_request? - .event_feed + - elsif event.merge_request? = render "events/event_merge_request", event: event - - elsif event.push? - .event_feed + - elsif event.push? = render "events/event_push", event: event - - elsif event.membership_changed? - .event_feed + - elsif event.membership_changed? = render "events/event_membership_changed", event: event + %span.cgray.right + = time_ago_in_words(event.created_at) + ago. + .clearfix diff --git a/app/views/events/_event_issue.html.haml b/app/views/events/_event_issue.html.haml index 4d357b7f..6ac69524 100644 --- a/app/views/events/_event_issue.html.haml +++ b/app/views/events/_event_issue.html.haml @@ -1,11 +1,9 @@ = image_tag gravatar_icon(event.author_email), class: "avatar" -%strong #{event.author_name} -%span.event_label{class: event.action_name}= event.action_name -issue -= link_to project_issue_path(event.project, event.issue) do - %strong= truncate event.issue_title -at -%strong= link_to event.project.name, event.project -%span.cgray - = time_ago_in_words(event.created_at) - ago. +.event-title + %strong.author_name #{event.author_name} + %span.event_label{class: event.action_name}= event.action_name + issue + = link_to project_issue_path(event.project, event.issue) do + %strong= truncate event.issue_title + at + %strong= link_to event.project.name, event.project diff --git a/app/views/events/_event_membership_changed.html.haml b/app/views/events/_event_membership_changed.html.haml index 464f24b3..1c11f993 100644 --- a/app/views/events/_event_membership_changed.html.haml +++ b/app/views/events/_event_membership_changed.html.haml @@ -1,9 +1,10 @@ = image_tag gravatar_icon(event.author_email), class: "avatar" -%strong #{event.author_name} -%span.event_label{class: event.action_name}= event.action_name -project -%strong= link_to event.project_name, event.project -%span.cgray - = time_ago_in_words(event.created_at) - ago. +.event-title + %strong.author_name #{event.author_name} + %span.event_label{class: event.action_name}= event.action_name + project + %strong= link_to event.project_name, event.project + %span.cgray + = time_ago_in_words(event.created_at) + ago. diff --git a/app/views/events/_event_merge_request.html.haml b/app/views/events/_event_merge_request.html.haml index ceb39371..fe961612 100644 --- a/app/views/events/_event_merge_request.html.haml +++ b/app/views/events/_event_merge_request.html.haml @@ -1,18 +1,16 @@ - if event.action_name == "merged" .event_icon= image_tag "event_mr_merged.png" = image_tag gravatar_icon(event.author_email), class: "avatar" -%strong #{event.author_name} -%span.event_label{class: event.action_name}= event.action_name -merge request -= link_to project_merge_request_path(event.project, event.merge_request) do - %strong= truncate event.merge_request_title -at -%strong= link_to event.project.name, event.project -%span.cgray - = time_ago_in_words(event.created_at) - ago. -%br -%span= event.merge_request.source_branch -→ -%span= event.merge_request.target_branch +.event-title + %strong.author_name #{event.author_name} + %span.event_label{class: event.action_name}= event.action_name + merge request + = link_to project_merge_request_path(event.project, event.merge_request) do + %strong= truncate event.merge_request_title + at + %strong= link_to event.project.name, event.project +.event-body + %span= event.merge_request.source_branch + → + %span= event.merge_request.target_branch diff --git a/app/views/events/_event_push.html.haml b/app/views/events/_event_push.html.haml index 0adcaf9d..1cedd27f 100644 --- a/app/views/events/_event_push.html.haml +++ b/app/views/events/_event_push.html.haml @@ -1,30 +1,31 @@ %div .event_icon= image_tag "event_push.png" = image_tag gravatar_icon(event.author_email), class: "avatar" - %strong #{event.author_name} - %span.event_label.pushed= event.push_action_name - = event.ref_type - = link_to project_commits_path(event.project, ref: event.ref_name) do - %strong= event.ref_name - at - %strong= link_to event.project.name, event.project - %span.cgray - = time_ago_in_words(event.created_at) - ago. + + .event-title + %strong.author_name #{event.author_name} + %span.event_label.pushed= event.push_action_name + = event.ref_type + = link_to project_commits_path(event.project, ref: event.ref_name) do + %strong= event.ref_name + at + %strong= link_to event.project.name, event.project + - if event.push_with_commits? + - if event.commits_count > 1 + = link_to compare_project_commits_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do + %strong #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]} - if event.push_with_commits? - - if event.commits_count > 1 - = link_to compare_project_commits_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do - %strong #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]} - project = event.project - %ul.unstyled.event_commits - - if event.commits_count > 3 - - event.commits[0...2].each do |commit| - = render "events/commit", commit: commit, project: project - %li - %br - \... and #{event.commits_count - 2} more commits - - else - - event.commits.each do |commit| - = render "events/commit", commit: commit, project: project - + .event-body + %ul.unstyled.event_commits + - if event.commits_count > 3 + - event.commits[0...2].each do |commit| + = render "events/commit", commit: commit, project: project + %li + %br + \... and #{event.commits_count - 2} more commits + - else + - event.commits.each do |commit| + = render "events/commit", commit: commit, project: project + .clearfix From 6667f3dbf920d9bcf0e6f3218d27c92811f74224 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 24 Sep 2012 13:33:51 +0300 Subject: [PATCH 010/288] Colored labels for events --- app/assets/stylesheets/sections/events.scss | 53 ++++++++++--------- app/models/event.rb | 1 + app/views/events/_event_issue.html.haml | 3 +- .../_event_membership_changed.html.haml | 3 +- .../events/_event_merge_request.html.haml | 10 ++-- app/views/events/_event_push.html.haml | 3 +- 6 files changed, 38 insertions(+), 35 deletions(-) diff --git a/app/assets/stylesheets/sections/events.scss b/app/assets/stylesheets/sections/events.scss index 7c414d05..0fb010d3 100644 --- a/app/assets/stylesheets/sections/events.scss +++ b/app/assets/stylesheets/sections/events.scss @@ -3,33 +3,35 @@ * */ .event_label { - /*@extend .label;*/ - /*background-color: #999;*/ + &.pushed { + padding:0 2px; + @extend .alert; + @extend .alert-info; + } - /*&.pushed {*/ - /*background-color: #4A97BD;*/ - /*}*/ + &.opened { + padding:0 2px; + @extend .alert; + @extend .alert-success; + } - /*&.opened {*/ - /*background-color: #469847;*/ - /*}*/ + &.closed { + padding:0 2px; + @extend .alert; + @extend .alert-error; + } - /*&.closed {*/ - /*background-color: #B94A48;*/ - /*}*/ + &.merged { + padding:0 2px; + @extend .alert; + @extend .alert-success; + } - /*&.merged {*/ - /*background-color: #2A2;*/ - /*}*/ - - /*&.joined {*/ - /*background-color: #1ca9dd;*/ - /*}*/ - - /*&.left {*/ - /*background-color: #888;*/ - /*float:none;*/ - /*}*/ + &.left, + &.joined { + padding:0 2px; + @extend .alert; + } } /** @@ -43,13 +45,16 @@ color:#333; font-weight: bold; .author_name { - color:#777; + color:#333; } } .event-body { p { color:#666; } + .event-info { + color:#666; + } } .avatar { width:32px; diff --git a/app/models/event.rb b/app/models/event.rb index b11b21bd..dc76b6fd 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -132,6 +132,7 @@ class Event < ActiveRecord::Base end end + delegate :name, :email, to: :author, prefix: true, allow_nil: true delegate :title, to: :issue, prefix: true, allow_nil: true delegate :title, to: :merge_request, prefix: true, allow_nil: true diff --git a/app/views/events/_event_issue.html.haml b/app/views/events/_event_issue.html.haml index 6ac69524..60e82c4d 100644 --- a/app/views/events/_event_issue.html.haml +++ b/app/views/events/_event_issue.html.haml @@ -1,8 +1,7 @@ = image_tag gravatar_icon(event.author_email), class: "avatar" .event-title %strong.author_name #{event.author_name} - %span.event_label{class: event.action_name}= event.action_name - issue + %span.event_label{class: event.action_name} #{event.action_name} issue = link_to project_issue_path(event.project, event.issue) do %strong= truncate event.issue_title at diff --git a/app/views/events/_event_membership_changed.html.haml b/app/views/events/_event_membership_changed.html.haml index 1c11f993..e89065b9 100644 --- a/app/views/events/_event_membership_changed.html.haml +++ b/app/views/events/_event_membership_changed.html.haml @@ -1,8 +1,7 @@ = image_tag gravatar_icon(event.author_email), class: "avatar" .event-title %strong.author_name #{event.author_name} - %span.event_label{class: event.action_name}= event.action_name - project + %span.event_label{class: event.action_name} #{event.action_name} project %strong= link_to event.project_name, event.project %span.cgray = time_ago_in_words(event.created_at) diff --git a/app/views/events/_event_merge_request.html.haml b/app/views/events/_event_merge_request.html.haml index fe961612..655337f3 100644 --- a/app/views/events/_event_merge_request.html.haml +++ b/app/views/events/_event_merge_request.html.haml @@ -3,14 +3,14 @@ = image_tag gravatar_icon(event.author_email), class: "avatar" .event-title %strong.author_name #{event.author_name} - %span.event_label{class: event.action_name}= event.action_name - merge request + %span.event_label{class: event.action_name} #{event.action_name} merge request = link_to project_merge_request_path(event.project, event.merge_request) do %strong= truncate event.merge_request_title at %strong= link_to event.project.name, event.project .event-body - %span= event.merge_request.source_branch - → - %span= event.merge_request.target_branch + .event-info + %span= event.merge_request.source_branch + → + %span= event.merge_request.target_branch diff --git a/app/views/events/_event_push.html.haml b/app/views/events/_event_push.html.haml index 1cedd27f..a1bbc124 100644 --- a/app/views/events/_event_push.html.haml +++ b/app/views/events/_event_push.html.haml @@ -4,8 +4,7 @@ .event-title %strong.author_name #{event.author_name} - %span.event_label.pushed= event.push_action_name - = event.ref_type + %span.event_label.pushed #{event.push_action_name} #{event.ref_type} = link_to project_commits_path(event.project, ref: event.ref_name) do %strong= event.ref_name at From 0b8e956f32cac5847029c29a607816b743e52465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Leutgo=CC=88b?= Date: Mon, 24 Sep 2012 11:01:44 +0200 Subject: [PATCH 011/288] Add a more verbose dashboard event feed - Add project name to event title - Push: Entry links to single commit or commits overview depending on number of pushed commits - Push: Display first 15 commits with commit message and author and link to single commit - Issues: Display issue description --- app/decorators/event_decorator.rb | 26 +++++++++++++++++++++---- app/views/dashboard/index.atom.builder | 3 ++- app/views/events/_event_issue.atom.haml | 2 ++ app/views/events/_event_push.atom.haml | 14 +++++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 app/views/events/_event_issue.atom.haml create mode 100644 app/views/events/_event_push.atom.haml diff --git a/app/decorators/event_decorator.rb b/app/decorators/event_decorator.rb index ce0aaa03..b2f9c439 100644 --- a/app/decorators/event_decorator.rb +++ b/app/decorators/event_decorator.rb @@ -3,11 +3,11 @@ class EventDecorator < ApplicationDecorator def feed_title if self.issue? - "#{self.author_name} #{self.action_name} issue ##{self.target_id}:" + self.issue_title + "#{self.author_name} #{self.action_name} issue ##{self.target_id}: #{self.issue_title} at #{self.project.name}" elsif self.merge_request? - "#{self.author_name} #{self.action_name} MR ##{self.target_id}:" + self.merge_request_title + "#{self.author_name} #{self.action_name} MR ##{self.target_id}: #{self.merge_request_title} at #{self.project.name}" elsif self.push? - "#{self.author_name} #{self.push_action_name} #{self.ref_type} " + self.ref_name + "#{self.author_name} #{self.push_action_name} #{self.ref_type} #{self.ref_name} at #{self.project.name}" elsif self.membership_changed? "#{self.author_name} #{self.action_name} #{self.project.name}" else @@ -20,8 +20,26 @@ class EventDecorator < ApplicationDecorator h.project_issue_url(self.project, self.issue) elsif self.merge_request? h.project_merge_request_url(self.project, self.merge_request) + elsif self.push? - h.project_commits_url(self.project, ref: self.ref_name) + if self.push_with_commits? + if self.commits_count > 1 + h.compare_project_commits_path(self.project, :from => self.parent_commit.id, :to => self.last_commit.id) + else + h.project_commit_path(self.project, :id => self.last_commit.id) + end + else + h.project_commits_url(self.project, ref: self.ref_name) + end + end + + end + + def feed_summary + if self.issue? + h.render "events/event_issue", issue: self.issue + elsif self.push? + h.render "events/event_push", event: self end end end diff --git a/app/views/dashboard/index.atom.builder b/app/views/dashboard/index.atom.builder index fa3bfade..ffa15258 100644 --- a/app/views/dashboard/index.atom.builder +++ b/app/views/dashboard/index.atom.builder @@ -12,6 +12,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://sear xml.entry do event_link = event.feed_url event_title = event.feed_title + event_summary = event.feed_summary xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}" xml.link :href => event_link @@ -22,7 +23,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://sear xml.name event.author_name xml.email event.author_email end - xml.summary event_title + xml.summary(:type => "xhtml") { |x| x << event_summary unless event_summary.nil? } end end end diff --git a/app/views/events/_event_issue.atom.haml b/app/views/events/_event_issue.atom.haml new file mode 100644 index 00000000..64dc02e3 --- /dev/null +++ b/app/views/events/_event_issue.atom.haml @@ -0,0 +1,2 @@ +%div{:xmlns => "http://www.w3.org/1999/xhtml"} + %p= simple_format issue.description diff --git a/app/views/events/_event_push.atom.haml b/app/views/events/_event_push.atom.haml new file mode 100644 index 00000000..340275a5 --- /dev/null +++ b/app/views/events/_event_push.atom.haml @@ -0,0 +1,14 @@ +%div{:xmlns => "http://www.w3.org/1999/xhtml"} + - event.commits.first(15).each do |commit| + %p + %strong= commit.author_name + = link_to "(##{commit.short_id})", project_commit_path(event.project, :id => commit.id) + %i + at + = commit.committed_date.strftime("%Y-%m-%d %H:%M:%S") + %blockquote= simple_format commit.safe_message + - if event.commits_count > 15 + %p + %i + \... and + = pluralize(event.commits_count - 15, "more commit") From f3ce02b5c944e5956eb7208506ec513623d092d8 Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Fri, 21 Sep 2012 18:22:43 +0200 Subject: [PATCH 012/288] Reject ssh keys that break gitolite. Failing test. Working check. --- app/models/key.rb | 17 ++++++++++++++++- spec/factories.rb | 12 +++++++----- spec/models/key_spec.rb | 12 ++++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/app/models/key.rb b/app/models/key.rb index a39a4a16..3982a946 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -18,7 +18,7 @@ class Key < ActiveRecord::Base before_save :set_identifier before_validation :strip_white_space delegate :name, :email, to: :user, prefix: true - validate :unique_key + validate :unique_key, :fingerprintable_key def strip_white_space self.key = self.key.strip unless self.key.blank? @@ -32,6 +32,21 @@ class Key < ActiveRecord::Base end end + def fingerprintable_key + return true unless key # Don't test if there is no key. + # `ssh-keygen -lf /dev/stdin <<< "#{key}"` errors with: redirection unexpected + file = Tempfile.new('key_file') + begin + file.puts key + file.rewind + fingerprint_output = `ssh-keygen -lf #{file.path} 2>&1` # Catch stderr. + ensure + file.close + file.unlink # deletes the temp file + end + errors.add(:key, "can't be fingerprinted") if fingerprint_output.match("failed") + end + def set_identifier if is_deploy_key self.identifier = "deploy_" + Digest::MD5.hexdigest(key) diff --git a/spec/factories.rb b/spec/factories.rb index 92790a3f..848fc01f 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -83,11 +83,7 @@ FactoryGirl.define do factory :key do title key do - """ - ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 - 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 - soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0= - """ + "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" end factory :deploy_key do @@ -97,6 +93,12 @@ FactoryGirl.define do factory :personal_key do user end + + factory :key_with_a_space_in_the_middle do + key do + "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa ++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" + end + end end factory :milestone do diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 85cd291d..9bb31a16 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -46,4 +46,16 @@ describe Key do end end end + + context "validate it is a fingerprintable key" do + let(:user) { Factory.create(:user) } + + it "accepts the fingerprintable key" do + build(:key, user: user).should be_valid + end + + it "rejects the unfingerprintable key" do + build(:key_with_a_space_in_the_middle).should_not be_valid + end + end end From c3efcf7a626ca2621b6fc9977aae8740ed7b10a8 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 25 Sep 2012 13:14:20 +0300 Subject: [PATCH 013/288] Pollished push event --- app/assets/stylesheets/sections/events.scss | 20 +++++++++++++------ app/views/events/_event_push.html.haml | 22 +++++++++------------ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/app/assets/stylesheets/sections/events.scss b/app/assets/stylesheets/sections/events.scss index 0fb010d3..db034e25 100644 --- a/app/assets/stylesheets/sections/events.scss +++ b/app/assets/stylesheets/sections/events.scss @@ -50,7 +50,7 @@ } .event-body { p { - color:#666; + color:#555; } .event-info { color:#666; @@ -73,7 +73,8 @@ margin-left:50px; margin-bottom:5px; .avatar { - width:22px; + width:18px; + margin-top:3px; } } @@ -84,10 +85,17 @@ .event_commits { margin-top: 5px; - li.commit { - background: transparent; - padding:5px; - border:none; + li { + &.commit { + background: transparent; + padding:3px; + border:none; + font-size:12px; + } + &.commits-stat { + display: block; + margin-top: 5px; + } } } } diff --git a/app/views/events/_event_push.html.haml b/app/views/events/_event_push.html.haml index a1bbc124..c0be9cf5 100644 --- a/app/views/events/_event_push.html.haml +++ b/app/views/events/_event_push.html.haml @@ -9,22 +9,18 @@ %strong= event.ref_name at %strong= link_to event.project.name, event.project - - if event.push_with_commits? - - if event.commits_count > 1 - = link_to compare_project_commits_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do - %strong #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]} - if event.push_with_commits? - project = event.project .event-body %ul.unstyled.event_commits - - if event.commits_count > 3 - - event.commits[0...2].each do |commit| - = render "events/commit", commit: commit, project: project - %li - %br - \... and #{event.commits_count - 2} more commits - - else - - event.commits.each do |commit| - = render "events/commit", commit: commit, project: project + - few_commits = event.commits[0...2] + - few_commits.each do |commit| + = render "events/commit", commit: commit, project: project + + %li.commits-stat + - if event.commits_count > 2 + %span ... and #{event.commits_count - 2} more commits. + = link_to compare_project_commits_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do + %strong Compare → #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]} .clearfix From 6df515a56dd426abd6a65cfeb2a75305c04eed6e Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Tue, 25 Sep 2012 04:56:21 -0700 Subject: [PATCH 014/288] add auto-completion for +1, -1 emoji --- app/views/notes/_common_form.html.haml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/views/notes/_common_form.html.haml b/app/views/notes/_common_form.html.haml index f91e921b..626a448c 100644 --- a/app/views/notes/_common_form.html.haml +++ b/app/views/notes/_common_form.html.haml @@ -39,6 +39,12 @@ :javascript $(function(){ - var names = #{@project.users.pluck(:name)}; - $('.note-text').atWho('@', { data: names }); + var names = #{@project.users.pluck(:name)}, emoji = ['+1', '-1']; + var emoji = $.map(emoji, function(value, i) {return {key:value + ':', name:value}}); + $('#note_note'). + atWho('@', { data: names }). + atWho(':', { + data: emoji, + tpl: "
  • ${name} #{escape_javascript image_tag('emoji/${name}.png', :size => '20x20')}
  • " + }); }); From 81ffb0afddfe101910cff3dd51fe27dd85e11f28 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 25 Sep 2012 14:07:13 +0200 Subject: [PATCH 015/288] Add valid looking key to test. Conflicts: features/steps/profile/profile_ssh_keys.rb --- features/steps/profile/profile_ssh_keys.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/steps/profile/profile_ssh_keys.rb b/features/steps/profile/profile_ssh_keys.rb index 96df2d73..535c3862 100644 --- a/features/steps/profile/profile_ssh_keys.rb +++ b/features/steps/profile/profile_ssh_keys.rb @@ -13,7 +13,7 @@ class ProfileSshKeys < Spinach::FeatureSteps And 'I submit new ssh key "Laptop"' do fill_in "key_title", :with => "Laptop" - fill_in "key_key", :with => "ssh-rsa publickey234=" + fill_in "key_key", :with => "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzrEJUIR6Y03TCE9rIJ+GqTBvgb8t1jI9h5UBzCLuK4VawOmkLornPqLDrGbm6tcwM/wBrrLvVOqi2HwmkKEIecVO0a64A4rIYScVsXIniHRS6w5twyn1MD3sIbN+socBDcaldECQa2u1dI3tnNVcs8wi77fiRe7RSxePsJceGoheRQgC8AZ510UdIlO+9rjIHUdVN7LLyz512auAfYsgx1OfablkQ/XJcdEwDNgi9imI6nAXhmoKUm1IPLT2yKajTIC64AjLOnE0YyCh6+7RFMpiMyu1qiOCpdjYwTgBRiciNRZCH8xIedyCoAmiUgkUT40XYHwLuwiPJICpkAzp7Q== user@laptop" click_button "Save" end From 012dc2278c1b7cb3cf4021912fca81c4ccf74b2f Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 25 Sep 2012 15:29:17 +0200 Subject: [PATCH 016/288] Valid key for deploy keys spec test. --- spec/requests/projects_deploy_keys_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/requests/projects_deploy_keys_spec.rb b/spec/requests/projects_deploy_keys_spec.rb index 894aa6d3..df1be79d 100644 --- a/spec/requests/projects_deploy_keys_spec.rb +++ b/spec/requests/projects_deploy_keys_spec.rb @@ -42,7 +42,7 @@ describe "Projects", "DeployKeys" do describe "fill in" do before do fill_in "key_title", with: "laptop" - fill_in "key_key", with: "ssh-rsa publickey234=" + fill_in "key_key", with: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzrEJUIR6Y03TCE9rIJ+GqTBvgb8t1jI9h5UBzCLuK4VawOmkLornPqLDrGbm6tcwM/wBrrLvVOqi2HwmkKEIecVO0a64A4rIYScVsXIniHRS6w5twyn1MD3sIbN+socBDcaldECQa2u1dI3tnNVcs8wi77fiRe7RSxePsJceGoheRQgC8AZ510UdIlO+9rjIHUdVN7LLyz512auAfYsgx1OfablkQ/XJcdEwDNgi9imI6nAXhmoKUm1IPLT2yKajTIC64AjLOnE0YyCh6+7RFMpiMyu1qiOCpdjYwTgBRiciNRZCH8xIedyCoAmiUgkUT40XYHwLuwiPJICpkAzp7Q== user@laptop" end it { expect { click_button "Save" }.to change {Key.count}.by(1) } From 7284c58c5fb54965b078a2ba9e3634479700416d Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Tue, 25 Sep 2012 15:54:07 +0200 Subject: [PATCH 017/288] Don't test if invalid key is valid. --- spec/factories_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/factories_spec.rb b/spec/factories_spec.rb index 5ccc17bd..caf9ac9a 100644 --- a/spec/factories_spec.rb +++ b/spec/factories_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' FactoryGirl.factories.map(&:name).each do |factory_name| + next if :key_with_a_space_in_the_middle == factory_name describe "#{factory_name} factory" do it 'should be valid' do build(factory_name).should be_valid From 252d3a0c9d84cef8d939c2c444f8763079eded1e Mon Sep 17 00:00:00 2001 From: Cyril Date: Tue, 25 Sep 2012 22:32:20 +0200 Subject: [PATCH 018/288] remove duplicate before_filter --- app/controllers/hooks_controller.rb | 1 - app/controllers/issues_controller.rb | 1 - app/controllers/labels_controller.rb | 1 - app/controllers/merge_requests_controller.rb | 1 - app/controllers/milestones_controller.rb | 1 - app/controllers/snippets_controller.rb | 1 - 6 files changed, 6 deletions(-) diff --git a/app/controllers/hooks_controller.rb b/app/controllers/hooks_controller.rb index c81e6b05..4359e996 100644 --- a/app/controllers/hooks_controller.rb +++ b/app/controllers/hooks_controller.rb @@ -1,5 +1,4 @@ class HooksController < ApplicationController - before_filter :authenticate_user! before_filter :project layout "project" diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 1d78a6d9..ceeee009 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -1,5 +1,4 @@ class IssuesController < ApplicationController - before_filter :authenticate_user! before_filter :project before_filter :module_enabled before_filter :issue, only: [:edit, :update, :destroy, :show] diff --git a/app/controllers/labels_controller.rb b/app/controllers/labels_controller.rb index e703f822..189d8d98 100644 --- a/app/controllers/labels_controller.rb +++ b/app/controllers/labels_controller.rb @@ -1,5 +1,4 @@ class LabelsController < ApplicationController - before_filter :authenticate_user! before_filter :project before_filter :module_enabled diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index 187bb407..1d0da43f 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -1,5 +1,4 @@ class MergeRequestsController < ApplicationController - before_filter :authenticate_user! before_filter :project before_filter :module_enabled before_filter :merge_request, only: [:edit, :update, :destroy, :show, :commits, :diffs, :automerge, :automerge_check, :raw] diff --git a/app/controllers/milestones_controller.rb b/app/controllers/milestones_controller.rb index 10f089f1..e8dbc8e4 100644 --- a/app/controllers/milestones_controller.rb +++ b/app/controllers/milestones_controller.rb @@ -1,5 +1,4 @@ class MilestonesController < ApplicationController - before_filter :authenticate_user! before_filter :project before_filter :module_enabled before_filter :milestone, only: [:edit, :update, :destroy, :show] diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index f852e425..b00c9283 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -1,5 +1,4 @@ class SnippetsController < ApplicationController - before_filter :authenticate_user! before_filter :project before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw] layout "project" From 83696b127b7822482957a894816b0e3c2daea0b5 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 26 Sep 2012 04:18:10 -0700 Subject: [PATCH 019/288] cleanup rake tasks --- lib/tasks/bulk_add_permission.rake | 28 ++++------ lib/tasks/bulk_import.rake | 74 ++++++++------------------ lib/tasks/gitlab/backup.rake | 46 ++++++++-------- lib/tasks/gitlab/enable_automerge.rake | 2 +- lib/tasks/gitlab/gitolite_rebuild.rake | 5 +- lib/tasks/gitlab/setup.rake | 3 +- lib/tasks/gitlab/status.rake | 37 +++++++------ lib/tasks/gitlab/write_hook.rake | 2 - 8 files changed, 77 insertions(+), 120 deletions(-) diff --git a/lib/tasks/bulk_add_permission.rake b/lib/tasks/bulk_add_permission.rake index 55797825..bf08ace8 100644 --- a/lib/tasks/bulk_add_permission.rake +++ b/lib/tasks/bulk_add_permission.rake @@ -1,26 +1,20 @@ -desc "Add all users to all projects, system administratos are added as masters" +desc "Add all users to all projects (admin users are added as masters)" task :add_users_to_project_teams => :environment do |t, args| - users = User.find_all_by_admin(false, :select => 'id').map(&:id) - admins = User.find_all_by_admin(true, :select => 'id').map(&:id) + user_ids = User.where(:admin => false).pluck(:id) + admin_ids = User.where(:admin => true).pluck(:id) - users.each do |user| - puts "#{user}" - end - - Project.all.each do |project| - puts "Importing #{users.length} users into #{project.path}" - UsersProject.bulk_import(project, users, UsersProject::DEVELOPER) - puts "Importing #{admins.length} admins into #{project.path}" - UsersProject.bulk_import(project, admins, UsersProject::MASTER) + Project.find_each do |project| + puts "Importing #{user_ids.size} users into #{project.code}" + UsersProject.bulk_import(project, user_ids, UsersProject::DEVELOPER) + puts "Importing #{admin_ids.size} admins into #{project.code}" + UsersProject.bulk_import(project, admin_ids, UsersProject::MASTER) end end desc "Add user to as a developer to all projects" task :add_user_to_project_teams, [:email] => :environment do |t, args| - user_email = args.email - user = User.find_by_email(user_email) + user = User.find_by_email args.email + project_ids = Project.pluck(:id) - project_ids = Project.all.map(&:id) - - UsersProject.user_bulk_import(user,project_ids,UsersProject::DEVELOPER) + UsersProject.user_bulk_import(user, project_ids, UsersProject::DEVELOPER) end diff --git a/lib/tasks/bulk_import.rake b/lib/tasks/bulk_import.rake index edb4a599..914f920a 100644 --- a/lib/tasks/bulk_import.rake +++ b/lib/tasks/bulk_import.rake @@ -1,20 +1,17 @@ - desc "Imports existing Git repos from a directory into new projects in git_base_path" task :import_projects, [:directory,:email] => :environment do |t, args| - user_email = args.email - import_directory = args.directory + user_email, import_directory = args.email, args.directory repos_to_import = Dir.glob("#{import_directory}/*") git_base_path = Gitlab.config.git_base_path - puts "Found #{repos_to_import.length} repos to import" + imported_count, skipped_count, failed_count = 0 + + puts "Found #{repos_to_import.size} repos to import" - imported_count = 0 - skipped_count = 0 - failed_count = 0 repos_to_import.each do |repo_path| repo_name = File.basename repo_path + clone_path = "#{git_base_path}#{repo_name}.git" puts " Processing #{repo_name}" - clone_path = "#{git_base_path}#{repo_name}.git" if Dir.exists? clone_path if Project.find_by_code(repo_name) @@ -38,7 +35,6 @@ task :import_projects, [:directory,:email] => :environment do |t, args| else failed_count += 1 end - end puts "Finished importing #{imported_count} projects (skipped #{skipped_count}, failed #{failed_count})." @@ -49,63 +45,39 @@ def clone_bare_repo_as_git(existing_path, new_path) git_user = Gitlab.config.ssh_user begin sh "sudo -u #{git_user} -i git clone --bare '#{existing_path}' #{new_path}" - true - rescue Exception=> msg - puts " ERROR: Faild to clone #{existing_path} to #{new_path}" - puts " Make sure #{git_user} can reach #{existing_path}" - puts " Exception-MSG: #{msg}" - false + rescue Exception => msg + puts " ERROR: Failed to clone #{existing_path} to #{new_path}" + puts " Make sure #{git_user} can reach #{existing_path}" + puts " Exception-MSG: #{msg}" end end -# Creats a project in Gitlag given a @project_name@ to use (for name, web url, and code -# url) and a @user_email@ that will be assigned as the owner of the project. +# Creates a project in GitLab given a `project_name` to use +# (for name, web url, and code url) and a `user_email` that will be +# assigned as the owner of the project. def create_repo_project(project_name, user_email) - user = User.find_by_email(user_email) - if user + if user = User.find_by_email(user_email) # Using find_by_code since that's the most important identifer to be unique if Project.find_by_code(project_name) puts " INFO: Project #{project_name} already exists in Gitlab, skipping." - false else - project = nil - if Project.find_by_code(project_name) - puts " ERROR: Project already exists #{project_name}" - return false - project = Project.find_by_code(project_name) - else - project = Project.create( - name: project_name, - code: project_name, - path: project_name, - owner: user, - description: "Automatically created from Rake on #{Time.now.to_s}" - ) - end - - unless project.valid? - puts " ERROR: Failed to create project #{project} because #{project.errors.first}" - return false - end - - # Add user as admin for project - project.users_projects.create!( - :project_access => UsersProject::MASTER, - :user => user + project = Project.create( + name: project_name, + code: project_name, + path: project_name, + owner: user, + description: "Automatically created from 'import_projects' rake task on #{Time.now}" ) - # Per projects_controller.rb#37 - project.update_repository - if project.valid? - true + # Add user as admin for project + project.users_projects.create!(:project_access => UsersProject::MASTER, :user => user) + project.update_repository else puts " ERROR: Failed to create project #{project} because #{project.errors.first}" - false end end else - puts " ERROR: #{user_email} not found, skipping" - false + puts " ERROR: user with #{user_email} not found, skipping" end end diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake index 04d240f6..06d7cb65 100644 --- a/lib/tasks/gitlab/backup.rake +++ b/lib/tasks/gitlab/backup.rake @@ -2,22 +2,20 @@ require 'active_record/fixtures' namespace :gitlab do namespace :app do - - # Create backup of gitlab system - desc "GITLAB | Create a backup of the gitlab system" + # Create backup of GitLab system + desc "GITLAB | Create a backup of the GitLab system" task :backup_create => :environment do - Rake::Task["gitlab:app:db_dump"].invoke Rake::Task["gitlab:app:repo_dump"].invoke Dir.chdir(Gitlab.config.backup_path) # saving additional informations - s = Hash.new - s["db_version"] = "#{ActiveRecord::Migrator.current_version}" - s["backup_created_at"] = "#{Time.now}" - s["gitlab_version"] = %x{git rev-parse HEAD}.gsub(/\n/,"") - s["tar_version"] = %x{tar --version | head -1}.gsub(/\n/,"") + s = {} + s[:db_version] = "#{ActiveRecord::Migrator.current_version}" + s[:backup_created_at] = "#{Time.now}" + s[:gitlab_version] = %x{git rev-parse HEAD}.gsub(/\n/,"") + s[:tar_version] = %x{tar --version | head -1}.gsub(/\n/,"") File.open("#{Gitlab.config.backup_path}/backup_information.yml", "w+") do |file| file << s.to_yaml.gsub(/^---\n/,'') @@ -32,7 +30,7 @@ namespace :gitlab do end # cleanup: remove tmp files - print "Deletion of tmp directories..." + print "Deleting tmp directories..." if Kernel.system("rm -rf repositories/ db/ backup_information.yml") puts "[DONE]".green else @@ -52,26 +50,23 @@ namespace :gitlab do else puts "[SKIPPING]".yellow end - end - - # Restore backup of gitlab system + # Restore backup of GitLab system desc "GITLAB | Restore a previously created backup" task :backup_restore => :environment do - Dir.chdir(Gitlab.config.backup_path) # check for existing backups in the backup dir file_list = Dir.glob("*_gitlab_backup.tar").each.map { |f| f.split(/_/).first.to_i } - puts "no backup found" if file_list.count == 0 + puts "no backups found" if file_list.count == 0 if file_list.count > 1 && ENV["BACKUP"].nil? puts "Found more than one backup, please specify which one you want to restore:" puts "rake gitlab:app:backup_restore BACKUP=timestamp_of_backup" exit 1; end - tar_file = ENV["BACKUP"].nil? ? File.join(file_list.first.to_s + "_gitlab_backup.tar") : File.join(ENV["BACKUP"] + "_gitlab_backup.tar") + tar_file = ENV["BACKUP"].nil? ? File.join("#{file_list.first}_gitlab_backup.tar") : File.join(ENV["BACKUP"] + "_gitlab_backup.tar") unless File.exists?(tar_file) puts "The specified backup doesn't exist!" @@ -102,16 +97,14 @@ namespace :gitlab do Rake::Task["gitlab:app:repo_restore"].invoke # cleanup: remove tmp files - print "Deletion of tmp directories..." + print "Deleting tmp directories..." if Kernel.system("rm -rf repositories/ db/ backup_information.yml") puts "[DONE]".green else puts "[FAILED]".red end - end - ################################################################################ ################################# invoked tasks ################################ @@ -121,7 +114,7 @@ namespace :gitlab do backup_path_repo = File.join(Gitlab.config.backup_path, "repositories") FileUtils.mkdir_p(backup_path_repo) until Dir.exists?(backup_path_repo) puts "Dumping repositories:" - project = Project.all.map { |n| [n.path,n.path_to_repo] } + project = Project.all.map { |n| [n.path, n.path_to_repo] } project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")] project.each do |project| print "- Dumping repository #{project.first}... " @@ -136,11 +129,11 @@ namespace :gitlab do task :repo_restore => :environment do backup_path_repo = File.join(Gitlab.config.backup_path, "repositories") puts "Restoring repositories:" - project = Project.all.map { |n| [n.path,n.path_to_repo] } + project = Project.all.map { |n| [n.path, n.path_to_repo] } project << ["gitolite-admin.git", File.join(File.dirname(project.first.second), "gitolite-admin.git")] project.each do |project| print "- Restoring repository #{project.first}... " - FileUtils.rm_rf(project.second) if File.dirname(project.second) # delet old stuff + FileUtils.rm_rf(project.second) if File.dirname(project.second) # delete old stuff if Kernel.system("cd #{File.dirname(project.second)} > /dev/null 2>&1 && git clone --bare #{backup_path_repo}/#{project.first}.bundle #{project.first}.git > /dev/null 2>&1") permission_commands = [ "sudo chmod -R g+rwX #{Gitlab.config.git_base_path}", @@ -157,8 +150,9 @@ namespace :gitlab do ###################################### DB ###################################### task :db_dump => :environment do - backup_path_db = File.join(Gitlab.config.backup_path, "db") - FileUtils.mkdir_p(backup_path_db) until Dir.exists?(backup_path_db) + backup_path_db = File.join(Gitlab.config.backup_path, "db") + FileUtils.mkdir_p(backup_path_db) unless Dir.exists?(backup_path_db) + puts "Dumping database tables:" ActiveRecord::Base.connection.tables.each do |tbl| print "- Dumping table #{tbl}... " @@ -176,9 +170,11 @@ namespace :gitlab do end task :db_restore=> :environment do - backup_path_db = File.join(Gitlab.config.backup_path, "db") + backup_path_db = File.join(Gitlab.config.backup_path, "db") + puts "Restoring database tables:" Rake::Task["db:reset"].invoke + Dir.glob(File.join(backup_path_db, "*.yml") ).each do |dir| fixture_file = File.basename(dir, ".*" ) print "- Loading fixture #{fixture_file}..." diff --git a/lib/tasks/gitlab/enable_automerge.rake b/lib/tasks/gitlab/enable_automerge.rake index 0a1a0fa7..13b4bab6 100644 --- a/lib/tasks/gitlab/enable_automerge.rake +++ b/lib/tasks/gitlab/enable_automerge.rake @@ -1,7 +1,7 @@ namespace :gitlab do namespace :app do desc "GITLAB | Enable auto merge" - task :enable_automerge => :environment do + task :enable_automerge => :environment do Gitlab::Gitolite.new.enable_automerge Project.find_each do |project| diff --git a/lib/tasks/gitlab/gitolite_rebuild.rake b/lib/tasks/gitlab/gitolite_rebuild.rake index 534aa315..fce10eb5 100644 --- a/lib/tasks/gitlab/gitolite_rebuild.rake +++ b/lib/tasks/gitlab/gitolite_rebuild.rake @@ -1,11 +1,10 @@ namespace :gitlab do namespace :gitolite do desc "GITLAB | Rebuild each project at gitolite config" - task :update_repos => :environment do + task :update_repos => :environment do puts "Starting Projects" Project.find_each(:batch_size => 100) do |project| - puts - puts "=== #{project.name}" + puts "\n=== #{project.name}" project.update_repository puts end diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake index 49c86461..08f35c7e 100644 --- a/lib/tasks/gitlab/setup.rake +++ b/lib/tasks/gitlab/setup.rake @@ -4,8 +4,7 @@ namespace :gitlab do task :setup => [ 'db:setup', 'db:seed_fu', - 'gitlab:app:enable_automerge' + 'gitlab:app:enable_automerge' ] end end - diff --git a/lib/tasks/gitlab/status.rake b/lib/tasks/gitlab/status.rake index e5b5e122..302f417c 100644 --- a/lib/tasks/gitlab/status.rake +++ b/lib/tasks/gitlab/status.rake @@ -1,37 +1,37 @@ namespace :gitlab do namespace :app do - desc "GITLAB | Check gitlab installation status" + desc "GITLAB | Check GitLab installation status" task :status => :environment do - puts "Starting diagnostic".yellow + puts "Starting diagnostics".yellow git_base_path = Gitlab.config.git_base_path print "config/database.yml............" - if File.exists?(File.join Rails.root, "config", "database.yml") + if File.exists?(Rails.root.join "config", "database.yml") puts "exists".green - else + else puts "missing".red return end print "config/gitlab.yml............" - if File.exists?(File.join Rails.root, "config", "gitlab.yml") - puts "exists".green + if File.exists?(Rails.root.join "config", "gitlab.yml") + puts "exists".green else puts "missing".red return end print "#{git_base_path}............" - if File.exists?(git_base_path) - puts "exists".green - else + if File.exists?(git_base_path) + puts "exists".green + else puts "missing".red return end print "#{git_base_path} is writable?............" if File.stat(git_base_path).writable? - puts "YES".green + puts "YES".green else puts "NO".red return @@ -41,16 +41,16 @@ namespace :gitlab do `git clone #{Gitlab.config.gitolite_admin_uri} /tmp/gitolite_gitlab_test` FileUtils.rm_rf("/tmp/gitolite_gitlab_test") print "Can clone gitolite-admin?............" - puts "YES".green - rescue + puts "YES".green + rescue print "Can clone gitolite-admin?............" puts "NO".red return end print "UMASK for .gitolite.rc is 0007? ............" - unless open("#{git_base_path}/../.gitolite.rc").grep(/UMASK([ \t]*)=([ \t>]*)0007/).empty? - puts "YES".green + if open("#{git_base_path}/../.gitolite.rc").grep(/UMASK([ \t]*)=([ \t>]*)0007/).any? + puts "YES".green else puts "NO".red return @@ -69,16 +69,15 @@ namespace :gitlab do end end - - if Project.count > 0 + if Project.count > 0 puts "Validating projects repositories:".yellow Project.find_each(:batch_size => 100) do |project| print "#{project.name}....." - hook_file = File.join(project.path_to_repo, 'hooks','post-receive') + hook_file = File.join(project.path_to_repo, 'hooks', 'post-receive') unless File.exists?(hook_file) - puts "post-receive file missing".red - next + puts "post-receive file missing".red + return end puts "post-receive file ok".green diff --git a/lib/tasks/gitlab/write_hook.rake b/lib/tasks/gitlab/write_hook.rake index 5e9fc8eb..ccc96aad 100644 --- a/lib/tasks/gitlab/write_hook.rake +++ b/lib/tasks/gitlab/write_hook.rake @@ -4,7 +4,6 @@ namespace :gitlab do task :write_hooks => :environment do gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common") gitlab_hooks_path = Rails.root.join("lib", "hooks") - gitlab_hook_files = ['post-receive'] gitlab_hook_files.each do |file_name| @@ -20,4 +19,3 @@ namespace :gitlab do end end end - From 5928388b1c5b41cf11471391b3ec6226167132fd Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 26 Sep 2012 13:20:44 +0200 Subject: [PATCH 020/288] Protect users projects_limit from mass assignment. --- app/controllers/admin/users_controller.rb | 6 +++--- app/models/user.rb | 5 +++-- spec/models/user_spec.rb | 26 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index e2d61864..c9586ad5 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -30,7 +30,7 @@ class Admin::UsersController < AdminController def new - @admin_user = User.new(projects_limit: Gitlab.config.default_projects_limit) + @admin_user = User.new({ projects_limit: Gitlab.config.default_projects_limit }, as: :admin) end def edit @@ -60,7 +60,7 @@ class Admin::UsersController < AdminController def create admin = params[:user].delete("admin") - @admin_user = User.new(params[:user]) + @admin_user = User.new(params[:user], as: :admin) @admin_user.admin = (admin && admin.to_i > 0) respond_to do |format| @@ -86,7 +86,7 @@ class Admin::UsersController < AdminController @admin_user.admin = (admin && admin.to_i > 0) respond_to do |format| - if @admin_user.update_attributes(params[:user]) + if @admin_user.update_attributes(params[:user], as: :admin) format.html { redirect_to [:admin, @admin_user], notice: 'User was successfully updated.' } format.json { head :ok } else diff --git a/app/models/user.rb b/app/models/user.rb index 47876722..a8626cc1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -6,8 +6,9 @@ class User < ActiveRecord::Base :recoverable, :rememberable, :trackable, :validatable, :omniauthable attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, - :name, :projects_limit, :skype, :linkedin, :twitter, :dark_scheme, - :theme_id, :force_random_password, :extern_uid, :provider + :name, :skype, :linkedin, :twitter, :dark_scheme, + :theme_id, :force_random_password, :extern_uid, :provider, :as => [:default, :admin] + attr_accessible :projects_limit, :as => :admin attr_accessor :force_random_password diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 08176754..14a373e1 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -73,4 +73,30 @@ describe User do user.authentication_token.should_not be_blank end end + + describe "attributes can be changed by a regular user" do + before do + @user = Factory :user + @user.update_attributes(skype: "testskype", linkedin: "testlinkedin") + end + it { @user.skype.should == 'testskype' } + it { @user.linkedin.should == 'testlinkedin' } + end + + describe "attributes that shouldn't be changed by a regular user" do + before do + @user = Factory :user + @user.update_attributes(projects_limit: 50) + end + it { @user.projects_limit.should_not == 50 } + end + + describe "attributes can be changed by an admin user" do + before do + @admin_user = Factory :admin + @admin_user.update_attributes({ skype: "testskype", projects_limit: 50 }, as: :admin) + end + it { @admin_user.skype.should == 'testskype' } + it { @admin_user.projects_limit.should == 50 } + end end From 9270b6c3c7cdb99eef1c99af8274dae5789d9830 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 26 Sep 2012 16:49:20 +0300 Subject: [PATCH 021/288] Fix milestone calendar, Removed unnecessary selects from admin --- app/assets/stylesheets/common.scss | 1 + app/assets/stylesheets/sections/issues.scss | 14 ++++++++++++++ app/assets/stylesheets/sections/projects.scss | 2 +- app/views/admin/projects/show.html.haml | 10 ++++++---- app/views/admin/users/show.html.haml | 10 ++++++---- app/views/milestones/show.html.haml | 5 ++++- 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index f13a1d6d..46de2cf3 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -661,3 +661,4 @@ li.note { margin-right: 30px; } } + diff --git a/app/assets/stylesheets/sections/issues.scss b/app/assets/stylesheets/sections/issues.scss index 10def510..485a9766 100644 --- a/app/assets/stylesheets/sections/issues.scss +++ b/app/assets/stylesheets/sections/issues.scss @@ -113,3 +113,17 @@ input.check_all_issues { .milestone { @extend .wll; } + +/** + * Fix milestone calendar + */ + +.ui-datepicker { + border:none; + box-shadow:none; + .ui-datepicker-header { + @include solid_shade; + margin-bottom:10px; + border:1px solid #bbb; + } +} diff --git a/app/assets/stylesheets/sections/projects.scss b/app/assets/stylesheets/sections/projects.scss index 92d0fc43..a29504ec 100644 --- a/app/assets/stylesheets/sections/projects.scss +++ b/app/assets/stylesheets/sections/projects.scss @@ -74,7 +74,7 @@ @include bg-gray-gradient; padding: 4px 7px; border: 1px solid #CCC; - margin-bottom:5px; + margin-bottom:20px; } .project_clone_holder { diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index 63987410..ede48ea2 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -1,6 +1,8 @@ -%h3 - = @admin_project.name - = link_to 'Edit', edit_admin_project_path(@admin_project), class: "btn right small" +%h3.page_title + Project: #{@admin_project.name} + = link_to edit_admin_project_path(@admin_project), class: "btn right" do + %i.icon-edit + Edit %br %table.zebra-striped @@ -56,7 +58,7 @@ %tr %td = link_to tm.user_name, admin_user_path(tm.user) - %td= select_tag :tm_project_access, options_for_select(Project.access_options, tm.project_access), class: "medium project-access-select", disabled: :disabled + %td= tm.project_access_human %td= link_to 'Edit Access', edit_admin_team_member_path(tm), class: "btn small" %td= link_to 'Remove from team', admin_team_member_path(tm), confirm: 'Are you sure?', method: :delete, class: "btn danger small" diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index 731916e9..e73f4d10 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -1,10 +1,12 @@ -%h3 - = @admin_user.name +%h3.page_title + User: #{@admin_user.name} - if @admin_user.blocked %small Blocked - if @admin_user.admin %small Administrator - = link_to 'Edit', edit_admin_user_path(@admin_user), class: "btn small right" + = link_to edit_admin_user_path(@admin_user), class: "btn right" do + %i.icon-edit + Edit %br @@ -94,6 +96,6 @@ - project = tm.project %tr %td= link_to project.name, admin_project_path(project) - %td= select_tag :tm_project_access, options_for_select(Project.access_options, tm.project_access), class: "medium project-access-select", disabled: :disabled + %td= tm.project_access_human %td= link_to 'Edit Access', edit_admin_team_member_path(tm), class: "btn small" %td= link_to 'Remove from team', admin_team_member_path(tm), confirm: 'Are you sure?', method: :delete, class: "btn small danger" diff --git a/app/views/milestones/show.html.haml b/app/views/milestones/show.html.haml index ba71ead7..4d0c9a4c 100644 --- a/app/views/milestones/show.html.haml +++ b/app/views/milestones/show.html.haml @@ -1,9 +1,12 @@ -%h3 +%h3.page_title Milestone ##{@milestone.id} %small = @milestone.expires_at %span.right + = link_to new_project_issue_path(@project, issue: { milestone_id: @milestone.id }), class: "btn small grouped", title: "New Issue" do + %i.icon-plus + New Issue = link_to 'Browse Issues', project_issues_path(@milestone.project, milestone_id: @milestone.id), class: "btn edit-milestone-link small grouped" - if can?(current_user, :admin_milestone, @project) = link_to edit_project_milestone_path(@project, @milestone), class: "btn small grouped" do From 965b6701abc450b1ac8fb4556367c34f2c8a9889 Mon Sep 17 00:00:00 2001 From: Alex Denisov <1101.debian@gmail.com> Date: Wed, 26 Sep 2012 17:01:13 +0300 Subject: [PATCH 022/288] Comment removed --- spec/observers/users_project_observer_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/observers/users_project_observer_spec.rb b/spec/observers/users_project_observer_spec.rb index 2009b85f..a8e0834b 100644 --- a/spec/observers/users_project_observer_spec.rb +++ b/spec/observers/users_project_observer_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper' describe UsersProjectObserver do -# let(:users_project) { stub.as_null_object } let(:user) { Factory.create :user } let(:project) { Factory.create(:project, code: "Fuu", From a58d3112620a62240c5f98f1cc0111e89de6b543 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 26 Sep 2012 16:02:31 +0200 Subject: [PATCH 023/288] Secure and httponly options on cookie. --- config/initializers/session_store.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 36c5f466..e777ae2b 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,6 +1,8 @@ # Be sure to restart your server when you modify this file. -Gitlab::Application.config.session_store :cookie_store, key: '_gitlab_session' +Gitlab::Application.config.session_store :cookie_store, key: '_gitlab_session', + secure: Gitlab::Application.config.force_ssl, + httponly: true # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information From 0261b0c64c9df0a1a6834fa4f31395989244c2a9 Mon Sep 17 00:00:00 2001 From: randx Date: Wed, 26 Sep 2012 21:01:54 +0300 Subject: [PATCH 024/288] Project activity inifinite scroll paging --- app/controllers/projects_controller.rb | 3 ++- app/views/projects/show.html.haml | 4 ++++ app/views/projects/show.js.haml | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 app/views/projects/show.js.haml diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 170b8892..b4d026f5 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -46,7 +46,7 @@ class ProjectsController < ApplicationController def show limit = (params[:limit] || 20).to_i - @events = @project.events.recent.limit(limit) + @events = @project.events.recent.limit(limit).offset(params[:offset] || 0) respond_to do |format| format.html do @@ -57,6 +57,7 @@ class ProjectsController < ApplicationController render "projects/empty" end end + format.js end end diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index 21459da2..2c4f55eb 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -2,3 +2,7 @@ = render 'clone_panel' = render "events/event_last_push", event: @last_push .content_list= render @events +.loading.hide + +:javascript + $(function(){ Pager.init(20); }); diff --git a/app/views/projects/show.js.haml b/app/views/projects/show.js.haml new file mode 100644 index 00000000..511f2789 --- /dev/null +++ b/app/views/projects/show.js.haml @@ -0,0 +1,2 @@ +:plain + Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}"); From dddb5b5de99e54d31c9ac3bff82210adf3fa7069 Mon Sep 17 00:00:00 2001 From: randx Date: Wed, 26 Sep 2012 21:05:04 +0300 Subject: [PATCH 025/288] fix left project event --- app/assets/stylesheets/sections/events.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/sections/events.scss b/app/assets/stylesheets/sections/events.scss index db034e25..5cd3fb7d 100644 --- a/app/assets/stylesheets/sections/events.scss +++ b/app/assets/stylesheets/sections/events.scss @@ -31,6 +31,7 @@ &.joined { padding:0 2px; @extend .alert; + float:none; } } From 4629cc44d6b7fa7ebdec8ce47bb0825e255d7763 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 26 Sep 2012 11:06:31 -0700 Subject: [PATCH 026/288] fix mass assignment error in create_from_omniauth after a6a229a --- lib/gitlab/auth.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb index 90bd5d74..500cb64d 100644 --- a/lib/gitlab/auth.rb +++ b/lib/gitlab/auth.rb @@ -30,7 +30,7 @@ module Gitlab log.info "#{ldap_prefix}Creating user from #{provider} login"\ " {uid => #{uid}, name => #{name}, email => #{email}}" password = Devise.friendly_token[0, 8].downcase - @user = User.new( + @user = User.new({ extern_uid: uid, provider: provider, name: name, @@ -38,7 +38,7 @@ module Gitlab password: password, password_confirmation: password, projects_limit: Gitlab.config.default_projects_limit, - ) + }, as: :admin) if Gitlab.config.omniauth['block_auto_created_users'] && !ldap @user.blocked = true end From 83efcabc829083f11553df0f1eb67a8fbbc3e000 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 26 Sep 2012 11:17:17 -0700 Subject: [PATCH 027/288] set activerecord whitelist_attributes to true --- app/models/event.rb | 3 +++ app/models/issue.rb | 3 +++ app/models/key.rb | 2 +- app/models/merge_request.rb | 6 +++++- app/models/milestone.rb | 2 ++ app/models/note.rb | 4 +++- app/models/project.rb | 8 +++---- app/models/protected_branch.rb | 2 ++ app/models/snippet.rb | 7 ++++--- app/models/users_project.rb | 4 ++-- app/models/web_hook.rb | 6 ++++-- app/models/wiki.rb | 2 ++ app/roles/issue_commonality.rb | 2 -- config/application.rb | 6 ++++++ config/environments/development.rb | 2 +- config/environments/test.rb | 3 +++ spec/models/issue_spec.rb | 5 +++++ spec/models/key_spec.rb | 5 +++++ spec/models/merge_request_spec.rb | 5 +++++ spec/models/milestone_spec.rb | 4 ++++ spec/models/note_spec.rb | 5 +++++ spec/models/project_spec.rb | 5 +++++ spec/models/protected_branch_spec.rb | 4 ++++ spec/models/snippet_spec.rb | 5 +++++ spec/models/user_spec.rb | 31 +++++----------------------- spec/models/users_project_spec.rb | 4 ++++ spec/models/web_hook_spec.rb | 4 ++++ spec/models/wiki_spec.rb | 5 +++++ 28 files changed, 100 insertions(+), 44 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index dc76b6fd..76e428ad 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -1,6 +1,9 @@ class Event < ActiveRecord::Base include PushEvent + attr_accessible :project, :action, :data, :author_id, :project_id, + :target_id, :target_type + default_scope where("author_id IS NOT NULL") Created = 1 diff --git a/app/models/issue.rb b/app/models/issue.rb index 96a54907..e1181b97 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -2,6 +2,9 @@ class Issue < ActiveRecord::Base include IssueCommonality include Votes + attr_accessible :title, :assignee_id, :closed, :position, :description, + :milestone_id, :label_list, :author_id_of_changes + acts_as_taggable_on :labels belongs_to :milestone diff --git a/app/models/key.rb b/app/models/key.rb index a39a4a16..e23447e6 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -4,7 +4,7 @@ class Key < ActiveRecord::Base belongs_to :user belongs_to :project - attr_protected :user_id + attr_accessible :key, :title validates :title, presence: true, diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 184ac5fc..bb7b53fa 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -4,6 +4,9 @@ class MergeRequest < ActiveRecord::Base include IssueCommonality include Votes + attr_accessible :title, :assignee_id, :closed, :target_branch, :source_branch, + :author_id_of_changes + BROKEN_DIFF = "--broken-diff" UNCHECKED = 1 @@ -48,7 +51,8 @@ class MergeRequest < ActiveRecord::Base end def mark_as_unchecked - self.update_attributes(state: UNCHECKED) + self.state = UNCHECKED + self.save end def can_be_merged? diff --git a/app/models/milestone.rb b/app/models/milestone.rb index d416fb63..65fa461f 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -13,6 +13,8 @@ # class Milestone < ActiveRecord::Base + attr_accessible :title, :description, :due_date, :closed + belongs_to :project has_many :issues diff --git a/app/models/note.rb b/app/models/note.rb index 34edb94e..9ac77ef7 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -2,6 +2,9 @@ require 'carrierwave/orm/activerecord' require 'file_size_validator' class Note < ActiveRecord::Base + attr_accessible :note, :noteable, :noteable_id, :noteable_type, :project_id, + :attachment, :line_code + belongs_to :project belongs_to :noteable, polymorphic: true belongs_to :author, @@ -16,7 +19,6 @@ class Note < ActiveRecord::Base to: :author, prefix: true - attr_protected :author, :author_id attr_accessor :notify attr_accessor :notify_author diff --git a/app/models/project.rb b/app/models/project.rb index 56d5d791..7470bd95 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -6,6 +6,9 @@ class Project < ActiveRecord::Base include Authority include Team + attr_accessible :name, :path, :description, :code, :default_branch, :issues_enabled, + :wall_enabled, :merge_requests_enabled, :wiki_enabled + # # Relations # @@ -25,11 +28,6 @@ class Project < ActiveRecord::Base attr_accessor :error_code - # - # Protected attributes - # - attr_protected :private_flag, :owner_id - # # Scopes # diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index 7c30f7a0..4ea083c1 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -1,6 +1,8 @@ class ProtectedBranch < ActiveRecord::Base include GitHost + attr_accessible :name + belongs_to :project validates_presence_of :project_id validates_presence_of :name diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 2c941499..bfd28684 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -1,6 +1,8 @@ class Snippet < ActiveRecord::Base include Linguist::BlobHelper + attr_accessible :title, :content, :file_name, :expires_at + belongs_to :project belongs_to :author, class_name: "User" has_many :notes, as: :noteable, dependent: :destroy @@ -9,7 +11,6 @@ class Snippet < ActiveRecord::Base :email, to: :author, prefix: true - attr_protected :author, :author_id, :project, :project_id validates_presence_of :project_id validates_presence_of :author_id @@ -46,11 +47,11 @@ class Snippet < ActiveRecord::Base 0 end - def name + def name file_name end - def mode + def mode nil end diff --git a/app/models/users_project.rb b/app/models/users_project.rb index ce64a10f..c42cc865 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -6,11 +6,11 @@ class UsersProject < ActiveRecord::Base DEVELOPER = 30 MASTER = 40 + attr_accessible :user, :user_id, :project_access + belongs_to :user belongs_to :project - attr_protected :project_id, :project - after_save :update_repository after_destroy :update_repository diff --git a/app/models/web_hook.rb b/app/models/web_hook.rb index 76efa501..5d826d2f 100644 --- a/app/models/web_hook.rb +++ b/app/models/web_hook.rb @@ -1,6 +1,8 @@ class WebHook < ActiveRecord::Base include HTTParty + attr_accessible :url + # HTTParty timeout default_timeout 10 @@ -18,11 +20,11 @@ class WebHook < ActiveRecord::Base post_url = url.gsub(parsed_url.userinfo+"@", "") WebHook.post(post_url, body: data.to_json, - headers: { "Content-Type" => "application/json" }, + headers: { "Content-Type" => "application/json" }, basic_auth: {username: parsed_url.user, password: parsed_url.password}) end end - + end # == Schema Information # diff --git a/app/models/wiki.rb b/app/models/wiki.rb index ebb1ff49..b053f5ad 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -1,4 +1,6 @@ class Wiki < ActiveRecord::Base + attr_accessible :title, :content, :slug + belongs_to :project belongs_to :user has_many :notes, as: :noteable, dependent: :destroy diff --git a/app/roles/issue_commonality.rb b/app/roles/issue_commonality.rb index ac972a70..55b46ec0 100644 --- a/app/roles/issue_commonality.rb +++ b/app/roles/issue_commonality.rb @@ -3,8 +3,6 @@ module IssueCommonality extend ActiveSupport::Concern included do - attr_protected :author, :author_id, :project, :project_id - belongs_to :project belongs_to :author, class_name: "User" belongs_to :assignee, class_name: "User" diff --git a/config/application.rb b/config/application.rb index ad41f196..27de3fa2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -39,6 +39,12 @@ module Gitlab # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] + # Enforce whitelist mode for mass assignment. + # This will create an empty whitelist of attributes available for mass-assignment for all models + # in your app. As such, your models will need to explicitly whitelist or blacklist accessible + # parameters by using an attr_accessible or attr_protected declaration. + config.active_record.whitelist_attributes = true + # Enable the asset pipeline config.assets.enabled = true diff --git a/config/environments/development.rb b/config/environments/development.rb index 87b095e2..38400d17 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -33,7 +33,7 @@ Gitlab::Application.configure do # Raise exception on mass assignment protection for Active Record models config.active_record.mass_assignment_sanitizer = :strict - + # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) config.active_record.auto_explain_threshold_in_seconds = 0.5 diff --git a/config/environments/test.rb b/config/environments/test.rb index 1e7765d9..f5816e42 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -34,6 +34,9 @@ Gitlab::Application.configure do # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql + # Raise exception on mass assignment protection for Active Record models + # config.active_record.mass_assignment_sanitizer = :strict + # Print deprecation notices to the stderr config.active_support.deprecation = :stderr diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 34192da9..099c4198 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -5,6 +5,11 @@ describe Issue do it { should belong_to(:milestone) } end + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:author_id) } + it { should_not allow_mass_assignment_of(:project_id) } + end + describe "Validation" do it { should ensure_length_of(:description).is_within(0..2000) } it { should ensure_inclusion_of(:closed).in_array([true, false]) } diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 85cd291d..3ccfdf03 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -6,6 +6,11 @@ describe Key do it { should belong_to(:project) } end + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:project_id) } + it { should_not allow_mass_assignment_of(:user_id) } + end + describe "Validation" do it { should validate_presence_of(:title) } it { should validate_presence_of(:key) } diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 523e823d..a5484924 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -6,6 +6,11 @@ describe MergeRequest do it { should validate_presence_of(:source_branch) } end + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:author_id) } + it { should_not allow_mass_assignment_of(:project_id) } + end + describe 'modules' do it { should include_module(IssueCommonality) } it { should include_module(Votes) } diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index f0f0f883..9c11a7b1 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -6,6 +6,10 @@ describe Milestone do it { should have_many(:issues) } end + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:project_id) } + end + describe "Validation" do it { should validate_presence_of(:title) } it { should validate_presence_of(:project_id) } diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 7809953f..34493a11 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -7,6 +7,11 @@ describe Note do it { should belong_to(:author).class_name('User') } end + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:author) } + it { should_not allow_mass_assignment_of(:author_id) } + end + describe "Validation" do it { should validate_presence_of(:note) } it { should validate_presence_of(:project) } diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 756f69de..c313b58e 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -17,6 +17,11 @@ describe Project do it { should have_many(:protected_branches).dependent(:destroy) } end + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:owner_id) } + it { should_not allow_mass_assignment_of(:private_flag) } + end + describe "Validation" do let!(:project) { create(:project) } diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb index 9180bc3b..4b292362 100644 --- a/spec/models/protected_branch_spec.rb +++ b/spec/models/protected_branch_spec.rb @@ -5,6 +5,10 @@ describe ProtectedBranch do it { should belong_to(:project) } end + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:project_id) } + end + describe 'Validation' do it { should validate_presence_of(:project_id) } it { should validate_presence_of(:name) } diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index ffb861c4..66c36e51 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -7,6 +7,11 @@ describe Snippet do it { should have_many(:notes).dependent(:destroy) } end + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:author_id) } + it { should_not allow_mass_assignment_of(:project_id) } + end + describe "Validation" do it { should validate_presence_of(:author_id) } it { should validate_presence_of(:project_id) } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 14a373e1..b77d8878 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -15,6 +15,11 @@ describe User do it { should have_many(:assigned_merge_requests).dependent(:destroy) } end + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:projects_limit) } + it { should allow_mass_assignment_of(:projects_limit).as(:admin) } + end + describe 'validations' do it { should validate_presence_of(:projects_limit) } it { should validate_numericality_of(:projects_limit) } @@ -73,30 +78,4 @@ describe User do user.authentication_token.should_not be_blank end end - - describe "attributes can be changed by a regular user" do - before do - @user = Factory :user - @user.update_attributes(skype: "testskype", linkedin: "testlinkedin") - end - it { @user.skype.should == 'testskype' } - it { @user.linkedin.should == 'testlinkedin' } - end - - describe "attributes that shouldn't be changed by a regular user" do - before do - @user = Factory :user - @user.update_attributes(projects_limit: 50) - end - it { @user.projects_limit.should_not == 50 } - end - - describe "attributes can be changed by an admin user" do - before do - @admin_user = Factory :admin - @admin_user.update_attributes({ skype: "testskype", projects_limit: 50 }, as: :admin) - end - it { @admin_user.skype.should == 'testskype' } - it { @admin_user.projects_limit.should == 50 } - end end diff --git a/spec/models/users_project_spec.rb b/spec/models/users_project_spec.rb index 33cb358e..a13a08db 100644 --- a/spec/models/users_project_spec.rb +++ b/spec/models/users_project_spec.rb @@ -6,6 +6,10 @@ describe UsersProject do it { should belong_to(:user) } end + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:project_id) } + end + describe "Validation" do let!(:users_project) { create(:users_project) } diff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rb index 3cba5b64..422d67cf 100644 --- a/spec/models/web_hook_spec.rb +++ b/spec/models/web_hook_spec.rb @@ -5,6 +5,10 @@ describe ProjectHook do it { should belong_to :project } end + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:project_id) } + end + describe "Validations" do it { should validate_presence_of(:url) } diff --git a/spec/models/wiki_spec.rb b/spec/models/wiki_spec.rb index de6ce426..1e27954c 100644 --- a/spec/models/wiki_spec.rb +++ b/spec/models/wiki_spec.rb @@ -7,6 +7,11 @@ describe Wiki do it { should have_many(:notes).dependent(:destroy) } end + describe "Mass assignment" do + it { should_not allow_mass_assignment_of(:project_id) } + it { should_not allow_mass_assignment_of(:user_id) } + end + describe "Validation" do it { should validate_presence_of(:title) } it { should ensure_length_of(:title).is_within(1..250) } From 078a8f0e662a1626b53bbf7f7c3e2b0599c94810 Mon Sep 17 00:00:00 2001 From: Cyril Date: Wed, 26 Sep 2012 01:21:37 +0200 Subject: [PATCH 028/288] factorize before_filters and layout for projects related controllers --- app/controllers/application_controller.rb | 2 +- app/controllers/commits_controller.rb | 6 +----- app/controllers/deploy_keys_controller.rb | 9 +------- app/controllers/hooks_controller.rb | 6 +----- app/controllers/issues_controller.rb | 8 +------ app/controllers/labels_controller.rb | 8 +------ app/controllers/merge_requests_controller.rb | 7 +------ app/controllers/milestones_controller.rb | 7 +------ app/controllers/notes_controller.rb | 6 +----- app/controllers/project_controller.rb | 16 ++++++++++++++ app/controllers/projects_controller.rb | 21 ++----------------- .../protected_branches_controller.rb | 7 +------ app/controllers/refs_controller.rb | 6 +----- app/controllers/repositories_controller.rb | 7 +------ app/controllers/snippets_controller.rb | 7 +------ app/controllers/team_members_controller.rb | 6 +----- app/controllers/wikis_controller.rb | 5 +---- 17 files changed, 33 insertions(+), 101 deletions(-) create mode 100644 app/controllers/project_controller.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5ac5c639..9ea11daf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -76,7 +76,7 @@ class ApplicationController < ActionController::Base end def project - @project ||= current_user.projects.find_by_code(params[:project_id]) + @project ||= current_user.projects.find_by_code(params[:project_id] || params[:id]) @project || render_404 end diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index 1e7aec00..c79784d6 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -1,11 +1,7 @@ require "base64" -class CommitsController < ApplicationController - before_filter :project - layout "project" - +class CommitsController < ProjectController # Authorize - before_filter :add_project_abilities before_filter :authorize_read_project! before_filter :authorize_code_access! before_filter :require_non_empty_project diff --git a/app/controllers/deploy_keys_controller.rb b/app/controllers/deploy_keys_controller.rb index 82c10512..29f924e8 100644 --- a/app/controllers/deploy_keys_controller.rb +++ b/app/controllers/deploy_keys_controller.rb @@ -1,16 +1,9 @@ -class DeployKeysController < ApplicationController +class DeployKeysController < ProjectController respond_to :html - layout "project" - before_filter :project # Authorize - before_filter :add_project_abilities before_filter :authorize_admin_project! - def project - @project ||= Project.find_by_code(params[:project_id]) - end - def index @keys = @project.deploy_keys.all end diff --git a/app/controllers/hooks_controller.rb b/app/controllers/hooks_controller.rb index 4359e996..23b81194 100644 --- a/app/controllers/hooks_controller.rb +++ b/app/controllers/hooks_controller.rb @@ -1,9 +1,5 @@ -class HooksController < ApplicationController - before_filter :project - layout "project" - +class HooksController < ProjectController # Authorize - before_filter :add_project_abilities before_filter :authorize_read_project! before_filter :authorize_admin_project!, only: [:new, :create, :destroy] diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index ceeee009..114a6a19 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -1,14 +1,8 @@ -class IssuesController < ApplicationController - before_filter :project +class IssuesController < ProjectController before_filter :module_enabled before_filter :issue, only: [:edit, :update, :destroy, :show] helper_method :issues_filter - layout "project" - - # Authorize - before_filter :add_project_abilities - # Allow read any issue before_filter :authorize_read_issue! diff --git a/app/controllers/labels_controller.rb b/app/controllers/labels_controller.rb index 189d8d98..203bff56 100644 --- a/app/controllers/labels_controller.rb +++ b/app/controllers/labels_controller.rb @@ -1,12 +1,6 @@ -class LabelsController < ApplicationController - before_filter :project +class LabelsController < ProjectController before_filter :module_enabled - layout "project" - - # Authorize - before_filter :add_project_abilities - # Allow read any issue before_filter :authorize_read_issue! diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index 1d0da43f..db6e48d5 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -1,13 +1,8 @@ -class MergeRequestsController < ApplicationController - before_filter :project +class MergeRequestsController < ProjectController before_filter :module_enabled before_filter :merge_request, only: [:edit, :update, :destroy, :show, :commits, :diffs, :automerge, :automerge_check, :raw] before_filter :validates_merge_request, only: [:show, :diffs, :raw] before_filter :define_show_vars, only: [:show, :diffs] - layout "project" - - # Authorize - before_filter :add_project_abilities # Allow read any merge_request before_filter :authorize_read_merge_request! diff --git a/app/controllers/milestones_controller.rb b/app/controllers/milestones_controller.rb index e8dbc8e4..19baf531 100644 --- a/app/controllers/milestones_controller.rb +++ b/app/controllers/milestones_controller.rb @@ -1,11 +1,6 @@ -class MilestonesController < ApplicationController - before_filter :project +class MilestonesController < ProjectController before_filter :module_enabled before_filter :milestone, only: [:edit, :update, :destroy, :show] - layout "project" - - # Authorize - before_filter :add_project_abilities # Allow read any milestone before_filter :authorize_read_milestone! diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index f003ea7b..138d5170 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -1,9 +1,5 @@ -class NotesController < ApplicationController - before_filter :project - +class NotesController < ProjectController # Authorize - before_filter :add_project_abilities - before_filter :authorize_read_note! before_filter :authorize_write_note!, only: [:create] diff --git a/app/controllers/project_controller.rb b/app/controllers/project_controller.rb new file mode 100644 index 00000000..84c81ce2 --- /dev/null +++ b/app/controllers/project_controller.rb @@ -0,0 +1,16 @@ +class ProjectController < ApplicationController + before_filter :project + # Authorize + before_filter :add_project_abilities + + layout :determine_layout + + protected + def determine_layout + if @project && !@project.new_record? + 'project' + else + 'application' + end + end +end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index b4d026f5..2a11611e 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,11 +1,9 @@ require Rails.root.join('lib', 'gitlab', 'graph_commit') -class ProjectsController < ApplicationController - before_filter :project, except: [:index, :new, :create] - layout :determine_layout +class ProjectsController < ProjectController + skip_before_filter :project, only: [:new, :create] # Authorize - before_filter :add_project_abilities before_filter :authorize_read_project!, except: [:index, :new, :create] before_filter :authorize_admin_project!, only: [:edit, :update, :destroy] before_filter :require_non_empty_project, only: [:blob, :tree, :graph] @@ -93,19 +91,4 @@ class ProjectsController < ApplicationController format.html { redirect_to root_path } end end - - protected - - def project - @project ||= Project.find_by_code(params[:id]) - @project || render_404 - end - - def determine_layout - if @project && !@project.new_record? - "project" - else - "application" - end - end end diff --git a/app/controllers/protected_branches_controller.rb b/app/controllers/protected_branches_controller.rb index 78c9c9ef..7675d3eb 100644 --- a/app/controllers/protected_branches_controller.rb +++ b/app/controllers/protected_branches_controller.rb @@ -1,16 +1,11 @@ -class ProtectedBranchesController < ApplicationController - before_filter :project - +class ProtectedBranchesController < ProjectController # Authorize - before_filter :add_project_abilities before_filter :authorize_read_project! before_filter :require_non_empty_project before_filter :authorize_admin_project!, only: [:destroy, :create] before_filter :render_full_content - layout "project" - def index @branches = @project.protected_branches.all @protected_branch = @project.protected_branches.new diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index 90361437..0139c09c 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -1,11 +1,9 @@ require 'github/markup' -class RefsController < ApplicationController +class RefsController < ProjectController include Gitlab::Encode - before_filter :project # Authorize - before_filter :add_project_abilities before_filter :authorize_read_project! before_filter :authorize_code_access! before_filter :require_non_empty_project @@ -14,8 +12,6 @@ class RefsController < ApplicationController before_filter :define_tree_vars, only: [:tree, :blob, :blame, :logs_tree] before_filter :render_full_content - layout "project" - def switch respond_to do |format| format.html do diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index cd20677e..5f55ee43 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -1,15 +1,10 @@ -class RepositoriesController < ApplicationController - before_filter :project - +class RepositoriesController < ProjectController # Authorize - before_filter :add_project_abilities before_filter :authorize_read_project! before_filter :authorize_code_access! before_filter :require_non_empty_project before_filter :render_full_content - layout "project" - def show @activities = @project.commits_with_refs(20) end diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index b00c9283..3d404e67 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -1,10 +1,5 @@ -class SnippetsController < ApplicationController - before_filter :project +class SnippetsController < ProjectController before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw] - layout "project" - - # Authorize - before_filter :add_project_abilities # Allow read any snippet before_filter :authorize_read_snippet! diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb index a50dcd3e..8261acfe 100644 --- a/app/controllers/team_members_controller.rb +++ b/app/controllers/team_members_controller.rb @@ -1,9 +1,5 @@ -class TeamMembersController < ApplicationController - before_filter :project - layout "project" - +class TeamMembersController < ProjectController # Authorize - before_filter :add_project_abilities before_filter :authorize_read_project! before_filter :authorize_admin_project!, except: [:index, :show] diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb index 55ccfe72..f13d0724 100644 --- a/app/controllers/wikis_controller.rb +++ b/app/controllers/wikis_controller.rb @@ -1,10 +1,7 @@ -class WikisController < ApplicationController - before_filter :project - before_filter :add_project_abilities +class WikisController < ProjectController before_filter :authorize_read_wiki! before_filter :authorize_write_wiki!, only: [:edit, :create, :history] before_filter :authorize_admin_wiki!, only: :destroy - layout "project" def pages @wikis = @project.wikis.group(:slug).order("created_at") From bdf317addc2ae586c76f46ccb1aa8659513baf16 Mon Sep 17 00:00:00 2001 From: Cyril Date: Wed, 26 Sep 2012 22:24:52 +0200 Subject: [PATCH 029/288] layout selected by controller name --- app/controllers/application_controller.rb | 22 +++++-------------- app/controllers/errors_controller.rb | 2 -- app/controllers/profile_controller.rb | 1 - app/controllers/project_controller.rb | 11 ---------- app/controllers/projects_controller.rb | 2 ++ .../{error.html.haml => errors.html.haml} | 0 config/application.rb | 4 ++++ 7 files changed, 12 insertions(+), 30 deletions(-) rename app/views/layouts/{error.html.haml => errors.html.haml} (100%) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9ea11daf..a299a83b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -11,19 +11,17 @@ class ApplicationController < ActionController::Base helper_method :abilities, :can? rescue_from Gitlab::Gitolite::AccessDenied do |exception| - render "errors/gitolite", layout: "error", status: 500 + render "errors/gitolite", layout: "errors", status: 500 end rescue_from Encoding::CompatibilityError do |exception| - render "errors/encoding", layout: "error", status: 500 + render "errors/encoding", layout: "errors", status: 500 end rescue_from ActiveRecord::RecordNotFound do |exception| - render "errors/not_found", layout: "error", status: 404 + render "errors/not_found", layout: "errors", status: 404 end - layout :layout_by_resource - protected def check_token_auth @@ -51,14 +49,6 @@ class ApplicationController < ActionController::Base end end - def layout_by_resource - if devise_controller? - "devise_layout" - else - "application" - end - end - def set_current_user_for_mailer MailerObserver.current_user = current_user end @@ -93,15 +83,15 @@ class ApplicationController < ActionController::Base end def access_denied! - render "errors/access_denied", layout: "error", status: 404 + render "errors/access_denied", layout: "errors", status: 404 end def not_found! - render "errors/not_found", layout: "error", status: 404 + render "errors/not_found", layout: "errors", status: 404 end def git_not_found! - render "errors/git_not_found", layout: "error", status: 404 + render "errors/git_not_found", layout: "errors", status: 404 end def method_missing(method_sym, *arguments, &block) diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index 9f60c645..e998d723 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -1,6 +1,4 @@ class ErrorsController < ApplicationController - layout "error" - def githost render "errors/gitolite" end diff --git a/app/controllers/profile_controller.rb b/app/controllers/profile_controller.rb index 7ddbfe11..2b8e18f6 100644 --- a/app/controllers/profile_controller.rb +++ b/app/controllers/profile_controller.rb @@ -1,5 +1,4 @@ class ProfileController < ApplicationController - layout "profile" before_filter :user def show diff --git a/app/controllers/project_controller.rb b/app/controllers/project_controller.rb index 84c81ce2..de4f317a 100644 --- a/app/controllers/project_controller.rb +++ b/app/controllers/project_controller.rb @@ -2,15 +2,4 @@ class ProjectController < ApplicationController before_filter :project # Authorize before_filter :add_project_abilities - - layout :determine_layout - - protected - def determine_layout - if @project && !@project.new_record? - 'project' - else - 'application' - end - end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 2a11611e..81c267a8 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -8,6 +8,8 @@ class ProjectsController < ProjectController before_filter :authorize_admin_project!, only: [:edit, :update, :destroy] before_filter :require_non_empty_project, only: [:blob, :tree, :graph] + layout 'application', only: [:new, :create] + def new @project = Project.new end diff --git a/app/views/layouts/error.html.haml b/app/views/layouts/errors.html.haml similarity index 100% rename from app/views/layouts/error.html.haml rename to app/views/layouts/errors.html.haml diff --git a/config/application.rb b/config/application.rb index 27de3fa2..fd0dd019 100644 --- a/config/application.rb +++ b/config/application.rb @@ -53,5 +53,9 @@ module Gitlab # Add fonts config.assets.paths << "#{Rails.root}/app/assets/fonts" + + config.to_prepare do + Devise::SessionsController.layout 'devise_layout' + end end end From ed26ecae0c3303b5554b033abd6f0a078b7573c0 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sun, 16 Sep 2012 16:21:46 -0400 Subject: [PATCH 030/288] Add branches method to Repository role --- app/roles/repository.rb | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/roles/repository.rb b/app/roles/repository.rb index 01156ac1..7118f156 100644 --- a/app/roles/repository.rb +++ b/app/roles/repository.rb @@ -45,8 +45,16 @@ module Repository File.exists?(hook_file) end + def branches + repo.branches.collect(&:name).sort + end + def tags - repo.tags.map(&:name).sort.reverse + repo.tags.collect(&:name).sort.reverse + end + + def ref_names + [branches + tags].flatten end def repo @@ -79,14 +87,6 @@ module Repository @heads ||= repo.heads end - def branches_names - heads.map(&:name) - end - - def ref_names - [branches_names + tags].flatten - end - def tree(fcommit, path = nil) fcommit = commit if fcommit == :head tree = fcommit.tree @@ -109,8 +109,6 @@ module Repository # - If two or more branches are present, returns the one that has a name # matching root_ref (default_branch or 'master' if default_branch is nil) def discover_default_branch - branches = heads.collect(&:name) - if branches.length == 0 nil elsif branches.length == 1 From 5e1ef575df927a1132e8991f7d5dcc2f43217456 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 10:08:02 -0400 Subject: [PATCH 031/288] Add CommitController --- app/controllers/commit_controller.rb | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 app/controllers/commit_controller.rb diff --git a/app/controllers/commit_controller.rb b/app/controllers/commit_controller.rb new file mode 100644 index 00000000..73a55614 --- /dev/null +++ b/app/controllers/commit_controller.rb @@ -0,0 +1,33 @@ +# Controller for a specific Commit +# +# Not to be confused with CommitsController, plural. +class CommitController < ApplicationController + before_filter :project + layout "project" + + # Authorize + before_filter :add_project_abilities + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def show + result = CommitLoad.new(project, current_user, params).execute + + @commit = result[:commit] + + if @commit + @suppress_diff = result[:suppress_diff] + @note = result[:note] + @line_notes = result[:line_notes] + @notes_count = result[:notes_count] + @comments_allowed = true + else + return git_not_found! + end + + if result[:status] == :huge_commit + render "huge_commit" and return + end + end +end From bde5088525512643434ab88b491c0ba9ad6e248b Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Sun, 16 Sep 2012 21:14:21 -0400 Subject: [PATCH 032/288] Add routing specs for new routes --- spec/routing/project_routing_spec.rb | 59 ++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index b3f9db01..d4ee5c33 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -396,3 +396,62 @@ describe NotesController, "routing" do let(:controller) { 'notes' } end end + +# TODO: Pending +# +# /:project_id/blame/*path +# /gitlabhq/blame/master/app/contexts/base_context.rb +# /gitlabhq/blame/test/branch/name/app/contexts/base_context.rb +# +# /:project_id/blob/*path +# /gitlabhq/blob/master/app/contexts/base_context.rb +# /gitlabhq/blob/test/branch/name/app/contexts/base_context.rb +# +# /:project_id/commit/:id +# /gitlabhq/commit/caef9ed1121a16ca0cc78715695daaa974271bfd +# +# /:project_id/commits +# +# /:project_id/commits/*path +# /gitlabhq/commits/master/app/contexts/base_context.rb +# /gitlabhq/commits/test/branch/name/app/contexts/base_context.rb +# +# /:project_id/raw/*path +# /gitlabhq/raw/master/app/contexts/base_context.rb +# /gitlabhq/raw/test/branch/name/app/contexts/base_context.rb +# +# /:project_id/tree/*path +# /gitlabhq/tree/master/app +# /gitlabhq/tree/test/branch/name/app +describe "pending routing" do + describe "/:project_id/blame/:id" do + it "routes to a ref with a path" do + get("/gitlabhq/blame/master/app/models/project.rb").should route_to('blame#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + end + end + + describe "/:project_id/blob/:id" do + it "routes to a ref with a path" do + get("/gitlabhq/blob/master/app/models/project.rb").should route_to('blob#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + end + end + + describe "/:project_id/commit/:id" do + it "routes to a specific commit" do + get("/gitlabhq/commit/f4b1449").should route_to('commit#show', project_id: 'gitlabhq', id: 'f4b1449') + get("/gitlabhq/commit/f4b14494ef6abf3d144c28e4af0c20143383e062").should route_to('commit#show', project_id: 'gitlabhq', id: 'f4b14494ef6abf3d144c28e4af0c20143383e062') + end + end + + describe "/:project_id/raw/:id" do + it "routes to a ref with a path" do + get("/gitlabhq/raw/master/app/models/project.rb").should route_to('raw#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + end + end + + describe "/:project_id/tree/:id" do + it "routes to a ref with a path" do + get("/gitlabhq/tree/master/app/models/project.rb").should route_to('tree#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + end + end +end From a21abce94f25d24b48c038e4a36974735a5b7149 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 10:06:03 -0400 Subject: [PATCH 033/288] Add tree-ish route placeholders, modify commit(s) routes --- config/routes.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index cfb9bdb9..4f55d7e5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -182,7 +182,10 @@ Gitlab::Application.routes.draw do get :test end end - resources :commits do + + resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} + + resources :commits, only: [:index, :show] do collection do get :compare end @@ -191,6 +194,7 @@ Gitlab::Application.routes.draw do get :patch end end + resources :team, controller: 'team_members', only: [:index] resources :team_members resources :milestones @@ -208,6 +212,12 @@ Gitlab::Application.routes.draw do post :preview end end + + # XXX: WIP + # resources :blame, only: [:show], constraints: {id: /.+/} + # resources :blob, only: [:show], constraints: {id: /.+/} + # resources :raw, only: [:show], constraints: {id: /.+/} + # resources :tree, only: [:show], constraints: {id: /.+/} end root to: "dashboard#index" From b389247c029b21f5e85abb5896d2cf22230c9cb1 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 10:06:56 -0400 Subject: [PATCH 034/288] Use Commit#show instead of Commits#show to view a single commit Commits#show (plural) is going to be for showing commit history on a specific path. --- app/controllers/commits_controller.rb | 32 +++++++++---------- app/roles/static_model.rb | 4 +++ app/views/{commits => commit}/show.html.haml | 0 app/views/commits/_commit.html.haml | 7 ++-- app/views/events/_commit.html.haml | 2 +- app/views/refs/blame.html.haml | 4 +-- app/views/repositories/_branch.html.haml | 2 +- lib/gitlab/markdown.rb | 2 +- .../requests/gitlab_flavored_markdown_spec.rb | 6 ++-- spec/routing/project_routing_spec.rb | 9 ++++++ 10 files changed, 40 insertions(+), 28 deletions(-) rename app/views/{commits => commit}/show.html.haml (100%) diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index 1e7aec00..83404bdc 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -26,25 +26,25 @@ class CommitsController < ApplicationController end end - def show - result = CommitLoad.new(project, current_user, params).execute + # def show + # result = CommitLoad.new(project, current_user, params).execute - @commit = result[:commit] + # @commit = result[:commit] - if @commit - @suppress_diff = result[:suppress_diff] - @note = result[:note] - @line_notes = result[:line_notes] - @notes_count = result[:notes_count] - @comments_allowed = true - else - return git_not_found! - end + # if @commit + # @suppress_diff = result[:suppress_diff] + # @note = result[:note] + # @line_notes = result[:line_notes] + # @notes_count = result[:notes_count] + # @comments_allowed = true + # else + # return git_not_found! + # end - if result[:status] == :huge_commit - render "huge_commit" and return - end - end + # if result[:status] == :huge_commit + # render "huge_commit" and return + # end + # end def compare result = Commit.compare(project, params[:from], params[:to]) diff --git a/app/roles/static_model.rb b/app/roles/static_model.rb index d26c8f47..d67af243 100644 --- a/app/roles/static_model.rb +++ b/app/roles/static_model.rb @@ -25,6 +25,10 @@ module StaticModel id end + def new_record? + false + end + def persisted? false end diff --git a/app/views/commits/show.html.haml b/app/views/commit/show.html.haml similarity index 100% rename from app/views/commits/show.html.haml rename to app/views/commit/show.html.haml diff --git a/app/views/commits/_commit.html.haml b/app/views/commits/_commit.html.haml index 61371d14..6abea76c 100644 --- a/app/views/commits/_commit.html.haml +++ b/app/views/commits/_commit.html.haml @@ -1,16 +1,15 @@ %li.commit .browse_code_link_holder %p - %strong= link_to "Browse Code »", tree_project_ref_path(@project, commit.id), class: "right" + %strong= link_to "Browse Code »", tree_project_ref_path(@project, commit), class: "right" %p - = link_to commit.short_id(8), project_commit_path(@project, id: commit.id), class: "commit_short_id" + = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" %strong.commit-author-name= commit.author_name %span.dash – = image_tag gravatar_icon(commit.author_email), class: "avatar", width: 16 - = link_to_gfm truncate(commit.title, length: 50), project_commit_path(@project, id: commit.id), class: "row_title" + = link_to_gfm truncate(commit.title, length: 50), project_commit_path(@project, commit.id), class: "row_title" %span.committed_ago = time_ago_in_words(commit.committed_date) ago   - diff --git a/app/views/events/_commit.html.haml b/app/views/events/_commit.html.haml index ed4f33c0..ea417aa9 100644 --- a/app/views/events/_commit.html.haml +++ b/app/views/events/_commit.html.haml @@ -1,7 +1,7 @@ - commit = CommitDecorator.decorate(commit) %li.commit %p - = link_to commit.short_id(8), project_commit_path(project, id: commit.id), class: "commit_short_id" + = link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id" %span= commit.author_name – = image_tag gravatar_icon(commit.author_email), class: "avatar", width: 16 diff --git a/app/views/refs/blame.html.haml b/app/views/refs/blame.html.haml index eb66f597..ba0fad52 100644 --- a/app/views/refs/blame.html.haml +++ b/app/views/refs/blame.html.haml @@ -32,8 +32,8 @@ = commit.author_name %td.blame_commit   - %code= link_to commit.short_id, project_commit_path(@project, id: commit.id) - = link_to_gfm truncate(commit.title, length: 30), project_commit_path(@project, id: commit.id), class: "row_title" rescue "--broken encoding" + %code= link_to commit.short_id, project_commit_path(@project, commit) + = link_to_gfm truncate(commit.title, length: 30), project_commit_path(@project, commit), class: "row_title" rescue "--broken encoding" %td.lines = preserve do %pre diff --git a/app/views/repositories/_branch.html.haml b/app/views/repositories/_branch.html.haml index 64a633be..80028a82 100644 --- a/app/views/repositories/_branch.html.haml +++ b/app/views/repositories/_branch.html.haml @@ -7,7 +7,7 @@ - if branch.name == @project.root_ref %span.label default %td - = link_to project_commit_path(@project, id: commit.id) do + = link_to project_commit_path(@project, commit) do %code= commit.short_id = image_tag gravatar_icon(commit.author_email), class: "", width: 16 diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 9201003e..9eb35b84 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -174,7 +174,7 @@ module Gitlab def reference_commit(identifier) if commit = @project.commit(identifier) - link_to(identifier, project_commit_path(@project, id: commit.id), html_options.merge(title: CommitDecorator.new(commit).link_title, class: "gfm gfm-commit #{html_options[:class]}")) + link_to(identifier, project_commit_path(@project, commit), html_options.merge(title: CommitDecorator.new(commit).link_title, class: "gfm gfm-commit #{html_options[:class]}")) end end end diff --git a/spec/requests/gitlab_flavored_markdown_spec.rb b/spec/requests/gitlab_flavored_markdown_spec.rb index 68d354b7..807d17d7 100644 --- a/spec/requests/gitlab_flavored_markdown_spec.rb +++ b/spec/requests/gitlab_flavored_markdown_spec.rb @@ -49,13 +49,13 @@ describe "Gitlab Flavored Markdown" do end it "should render title in commits#show" do - visit project_commit_path(project, id: commit.id) + visit project_commit_path(project, commit) page.should have_link("##{issue.id}") end it "should render description in commits#show" do - visit project_commit_path(project, id: commit.id) + visit project_commit_path(project, commit) page.should have_link("@#{fred.name}") end @@ -175,7 +175,7 @@ describe "Gitlab Flavored Markdown" do describe "for notes" do it "should render in commits#show", js: true do - visit project_commit_path(project, id: commit.id) + visit project_commit_path(project, commit) fill_in "note_note", with: "see ##{issue.id}" click_button "Add Comment" diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index d4ee5c33..9900a31f 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -298,6 +298,14 @@ describe HooksController, "routing" do end end +# project_commit GET /:project_id/commit/:id(.:format) commit#show {:id=>/[[:alnum:]]{6,40}/, :project_id=>/[^\/]+/} +describe CommitController, "routing" do + it "to #show" do + get("/gitlabhq/commit/4246fb").should route_to('commit#show', project_id: 'gitlabhq', id: '4246fb') + get("/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5").should route_to('commit#show', project_id: 'gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5') + end +end + # compare_project_commits GET /:project_id/commits/compare(.:format) commits#compare # patch_project_commit GET /:project_id/commits/:id/patch(.:format) commits#patch # project_commits GET /:project_id/commits(.:format) commits#index @@ -317,6 +325,7 @@ describe CommitsController, "routing" do end it_behaves_like "RESTful project resources" do + let(:actions) { [:index, :show] } let(:controller) { 'commits' } end end From 567767bcf2af2c330c46fde820101fcf847e852f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 10:44:36 -0400 Subject: [PATCH 035/288] Add ref_extractor helper module for upcoming controllers --- lib/ref_extractor.rb | 64 ++++++++++++++++++++++++++++++++++ spec/lib/ref_extractor_spec.rb | 39 +++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 lib/ref_extractor.rb create mode 100644 spec/lib/ref_extractor_spec.rb diff --git a/lib/ref_extractor.rb b/lib/ref_extractor.rb new file mode 100644 index 00000000..d3f02d6e --- /dev/null +++ b/lib/ref_extractor.rb @@ -0,0 +1,64 @@ +# Module providing an extract_ref method for controllers working with Git +# tree-ish + path params +# +# Given a string containing both a Git ref - such as a branch or tag - and a +# filesystem path joined by forward slashes, attempts to separate the two. +# +# Expects a @project instance variable to contain the active project. Used to +# check the input against a list of valid repository refs. +# +# Examples +# +# # No @project available +# extract_ref('master') +# # => ['', ''] +# +# extract_ref('master') +# # => ['master', '/'] +# +# extract_ref("f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG") +# # => ['f4b14494ef6abf3d144c28e4af0c20143383e062', '/CHANGELOG'] +# +# extract_ref("v2.0.0/README.md") +# # => ['v2.0.0', '/README.md'] +# +# extract_ref('issues/1234/app/models/project.rb') +# # => ['issues/1234', '/app/models/project.rb'] +# +# # Given an invalid branch, we fall back to just splitting on the first slash +# extract_ref('non/existent/branch/README.md') +# # => ['non', '/existent/branch/README.md'] +# +# Returns an Array where the first value is the tree-ish and the second is the +# path +module RefExtractor + def extract_ref(input) + pair = ['', ''] + + return pair unless @project + + if input.match(/^([[:alnum:]]{40})(.+)/) + # If the ref appears to be a SHA, we're done, just split the string + pair = $~.captures + else + # Append a trailing slash if we only get a ref and no file path + id = input + id += '/' unless id.include?('/') + + # Otherwise, attempt to detect the ref using a list of the project's + # branches and tags + valid_refs = @project.branches + @project.tags + valid_refs.select! { |v| id.start_with?("#{v}/") } + + if valid_refs.length != 1 + # No exact ref match, so just try our best + pair = id.match(/([^\/]+)(.+)/).captures + else + # Partition the string into the ref and the path, ignoring the empty first value + pair = id.partition(valid_refs.first)[1..-1] + end + end + + pair + end +end diff --git a/spec/lib/ref_extractor_spec.rb b/spec/lib/ref_extractor_spec.rb new file mode 100644 index 00000000..84347977 --- /dev/null +++ b/spec/lib/ref_extractor_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper' + +describe RefExtractor do + include RefExtractor + + let(:project) { double('project') } + + before do + @project = project + project.stub(:branches).and_return(['master', 'foo/bar/baz']) + project.stub(:tags).and_return(['v1.0.0', 'v2.0.0']) + end + + it "extracts a ref without a path" do + extract_ref('master').should == ['master', '/'] + end + + it "extracts a valid branch ref" do + extract_ref('foo/bar/baz/CHANGELOG').should == ['foo/bar/baz', '/CHANGELOG'] + end + + it "extracts a valid tag ref" do + extract_ref('v2.0.0/CHANGELOG').should == ['v2.0.0', '/CHANGELOG'] + end + + it "extracts a valid commit ref" do + extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG').should == + ['f4b14494ef6abf3d144c28e4af0c20143383e062', '/CHANGELOG'] + end + + it "falls back to a primitive split for an invalid ref" do + extract_ref('stable/CHANGELOG').should == ['stable', '/CHANGELOG'] + end + + it "returns an empty pair when no @project is set" do + @project = nil + extract_ref('master/CHANGELOG').should == ['', ''] + end +end From 6ddb35bd5e27829609e40b8dd87313a01fb6f293 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 10:57:13 -0400 Subject: [PATCH 036/288] Move tree-related views from refs to trees --- app/views/tree/_head.html.haml | 11 +++++++++++ app/views/{refs => tree}/_submodule_item.html.haml | 0 app/views/{refs => tree}/_tree.html.haml | 0 app/views/{refs => tree}/_tree_commit.html.haml | 0 app/views/{refs => tree}/_tree_file.html.haml | 0 app/views/{refs => tree}/_tree_item.html.haml | 0 .../{refs/tree.html.haml => tree/show.html.haml} | 0 app/views/{refs/tree.js.haml => tree/show.js.haml} | 0 8 files changed, 11 insertions(+) create mode 100644 app/views/tree/_head.html.haml rename app/views/{refs => tree}/_submodule_item.html.haml (100%) rename app/views/{refs => tree}/_tree.html.haml (100%) rename app/views/{refs => tree}/_tree_commit.html.haml (100%) rename app/views/{refs => tree}/_tree_file.html.haml (100%) rename app/views/{refs => tree}/_tree_item.html.haml (100%) rename app/views/{refs/tree.html.haml => tree/show.html.haml} (100%) rename app/views/{refs/tree.js.haml => tree/show.js.haml} (100%) diff --git a/app/views/tree/_head.html.haml b/app/views/tree/_head.html.haml new file mode 100644 index 00000000..3592f573 --- /dev/null +++ b/app/views/tree/_head.html.haml @@ -0,0 +1,11 @@ +%ul.nav.nav-tabs + %li + = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]} + %li{class: "#{'active' if (controller.controller_name == "refs") }"} + = link_to tree_project_ref_path(@project, @ref) do + Source + %li.right + .input-prepend.project_clone_holder + %button{class: "btn small active", :"data-clone" => @project.ssh_url_to_repo} SSH + %button{class: "btn small", :"data-clone" => @project.http_url_to_repo} HTTP + = text_field_tag :project_clone, @project.url_to_repo, class: "one_click_select span5" diff --git a/app/views/refs/_submodule_item.html.haml b/app/views/tree/_submodule_item.html.haml similarity index 100% rename from app/views/refs/_submodule_item.html.haml rename to app/views/tree/_submodule_item.html.haml diff --git a/app/views/refs/_tree.html.haml b/app/views/tree/_tree.html.haml similarity index 100% rename from app/views/refs/_tree.html.haml rename to app/views/tree/_tree.html.haml diff --git a/app/views/refs/_tree_commit.html.haml b/app/views/tree/_tree_commit.html.haml similarity index 100% rename from app/views/refs/_tree_commit.html.haml rename to app/views/tree/_tree_commit.html.haml diff --git a/app/views/refs/_tree_file.html.haml b/app/views/tree/_tree_file.html.haml similarity index 100% rename from app/views/refs/_tree_file.html.haml rename to app/views/tree/_tree_file.html.haml diff --git a/app/views/refs/_tree_item.html.haml b/app/views/tree/_tree_item.html.haml similarity index 100% rename from app/views/refs/_tree_item.html.haml rename to app/views/tree/_tree_item.html.haml diff --git a/app/views/refs/tree.html.haml b/app/views/tree/show.html.haml similarity index 100% rename from app/views/refs/tree.html.haml rename to app/views/tree/show.html.haml diff --git a/app/views/refs/tree.js.haml b/app/views/tree/show.js.haml similarity index 100% rename from app/views/refs/tree.js.haml rename to app/views/tree/show.js.haml From 2ddb19170624f81ec0cb3da26805a5515878aede Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 11:10:04 -0400 Subject: [PATCH 037/288] Require 'github/markup' in Gemfile --- Gemfile | 2 +- app/controllers/refs_controller.rb | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 71eafaba..8e2bdb9c 100644 --- a/Gemfile +++ b/Gemfile @@ -57,7 +57,7 @@ gem "seed-fu" # Markdown to HTML gem "redcarpet", "~> 2.1.1" -gem "github-markup", "~> 0.7.4" +gem "github-markup", "~> 0.7.4", require: 'github/markup' # Servers gem "thin" diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index 90361437..3f81a2ca 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -1,5 +1,3 @@ -require 'github/markup' - class RefsController < ApplicationController include Gitlab::Encode before_filter :project From 884eb732977ee785c48a954542e8735cd572e1fe Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 12:26:29 -0400 Subject: [PATCH 038/288] Enable tree resource, remove old tree routes --- config/routes.rb | 16 +++------------- spec/routing/project_routing_spec.rb | 21 +++++++-------------- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 4f55d7e5..d1ed8749 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -122,24 +122,14 @@ Gitlab::Application.routes.draw do end member do - get "tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } - get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } - get "blob", constraints: { id: /[a-zA-Z.0-9\/_\-]+/, path: /.*/ } - # tree viewer - get "tree/:path" => "refs#tree", - as: :tree_file, - constraints: { - id: /[a-zA-Z.0-9\/_\-]+/, - path: /.*/ - } - - # tree viewer + # tree viewer logs + get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } get "logs_tree/:path" => "refs#logs_tree", as: :logs_file, constraints: { @@ -217,7 +207,7 @@ Gitlab::Application.routes.draw do # resources :blame, only: [:show], constraints: {id: /.+/} # resources :blob, only: [:show], constraints: {id: /.+/} # resources :raw, only: [:show], constraints: {id: /.+/} - # resources :tree, only: [:show], constraints: {id: /.+/} + resources :tree, only: [:show], constraints: {id: /.+/} end root to: "dashboard#index" diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 9900a31f..f9c99a20 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -192,10 +192,8 @@ describe ProtectedBranchesController, "routing" do end # switch_project_refs GET /:project_id/switch(.:format) refs#switch -# tree_project_ref GET /:project_id/:id/tree(.:format) refs#tree -# logs_tree_project_ref GET /:project_id/:id/logs_tree(.:format) refs#logs_tree # blob_project_ref GET /:project_id/:id/blob(.:format) refs#blob -# tree_file_project_ref GET /:project_id/:id/tree/:path(.:format) refs#tree +# logs_tree_project_ref GET /:project_id/:id/logs_tree(.:format) refs#logs_tree # logs_file_project_ref GET /:project_id/:id/logs_tree/:path(.:format) refs#logs_tree # blame_file_project_ref GET /:project_id/:id/blame/:path(.:format) refs#blame describe RefsController, "routing" do @@ -203,11 +201,6 @@ describe RefsController, "routing" do get("/gitlabhq/switch").should route_to('refs#switch', project_id: 'gitlabhq') end - it "to #tree" do - get("/gitlabhq/stable/tree").should route_to('refs#tree', project_id: 'gitlabhq', id: 'stable') - get("/gitlabhq/stable/tree/foo/bar/baz").should route_to('refs#tree', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz') - end - it "to #logs_tree" do get("/gitlabhq/stable/logs_tree").should route_to('refs#logs_tree', project_id: 'gitlabhq', id: 'stable') get("/gitlabhq/stable/logs_tree/foo/bar/baz").should route_to('refs#logs_tree', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz') @@ -406,6 +399,12 @@ describe NotesController, "routing" do end end +describe TreeController, "routing" do + it "to #show" do + get("/gitlabhq/tree/master/app/models/project.rb").should route_to('tree#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + end +end + # TODO: Pending # # /:project_id/blame/*path @@ -457,10 +456,4 @@ describe "pending routing" do get("/gitlabhq/raw/master/app/models/project.rb").should route_to('raw#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') end end - - describe "/:project_id/tree/:id" do - it "routes to a ref with a path" do - get("/gitlabhq/tree/master/app/models/project.rb").should route_to('tree#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - end - end end From e33cbb9b4252e2617bcb4c3f850c47aae43e4d83 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 12:38:59 -0400 Subject: [PATCH 039/288] Add TreeController and spec --- app/controllers/tree_controller.rb | 49 ++++++++++++++++++++++++ app/models/tree.rb | 10 +++-- spec/controllers/tree_controller_spec.rb | 43 +++++++++++++++++++++ spec/spec_helper.rb | 1 + 4 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 app/controllers/tree_controller.rb create mode 100644 spec/controllers/tree_controller_spec.rb diff --git a/app/controllers/tree_controller.rb b/app/controllers/tree_controller.rb new file mode 100644 index 00000000..15bbb1a3 --- /dev/null +++ b/app/controllers/tree_controller.rb @@ -0,0 +1,49 @@ +# Controller for viewing a repository's file structure +class TreeController < ApplicationController + # Thrown when given an invalid path + class InvalidPathError < StandardError; end + + include RefExtractor + + layout "project" + + before_filter :project + + # Authorize + before_filter :add_project_abilities + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + before_filter :define_tree_vars + + def show + respond_to do |format| + format.html + # Disable cache so browser history works + format.js { no_cache_headers } + end + end + + private + + def define_tree_vars + @ref, @path = extract_ref(params[:id]) + + @id = File.join(@ref, @path) + @repo = @project.repo + @commit = CommitDecorator.decorate(@project.commit(@ref)) + + @tree = Tree.new(@commit.tree, @project, @ref, @path.gsub(/^\//, '')) + @tree = TreeDecorator.new(@tree) + + raise InvalidPathError if @tree.invalid? + + @hex_path = Digest::SHA1.hexdigest(@path) + + @history_path = project_tree_path(@project, @id) + @logs_path = logs_file_project_ref_path(@project, @ref, @path) + rescue NoMethodError, InvalidPathError + not_found! + end +end diff --git a/app/models/tree.rb b/app/models/tree.rb index d65e50ab..88e8f2f4 100644 --- a/app/models/tree.rb +++ b/app/models/tree.rb @@ -1,5 +1,5 @@ class Tree - include Linguist::BlobHelper + include Linguist::BlobHelper attr_accessor :path, :tree, :project, :ref delegate :contents, @@ -14,8 +14,8 @@ class Tree to: :tree def initialize(raw_tree, project, ref = nil, path = nil) - @project, @ref, @path = project, ref, path, - @tree = if path + @project, @ref, @path = project, ref, path + @tree = if path.present? raw_tree / path.dup.force_encoding('ascii-8bit') else raw_tree @@ -26,6 +26,10 @@ class Tree tree.is_a?(Grit::Blob) end + def invalid? + tree.nil? + end + def empty? data.blank? end diff --git a/spec/controllers/tree_controller_spec.rb b/spec/controllers/tree_controller_spec.rb new file mode 100644 index 00000000..b9295537 --- /dev/null +++ b/spec/controllers/tree_controller_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe TreeController do + let(:project) { create(:project) } + let(:user) { create(:user) } + + before do + sign_in(user) + + project.add_access(user, :read, :admin) + + project.stub(:branches).and_return(['master', 'foo/bar/baz']) + project.stub(:tags).and_return(['v1.0.0', 'v2.0.0']) + controller.instance_variable_set(:@project, project) + end + + describe "GET show" do + # Make sure any errors accessing the tree in our views bubble up to this spec + render_views + + before { get :show, project_id: project.code, id: id } + + context "valid branch, no path" do + let(:id) { 'master' } + it { should respond_with(:success) } + end + + context "valid branch, valid path" do + let(:id) { 'master/README.md' } + it { should respond_with(:success) } + end + + context "valid branch, invalid path" do + let(:id) { 'master/invalid-path.rb' } + it { should respond_with(:not_found) } + end + + context "invalid branch, valid path" do + let(:id) { 'invalid-branch/README.md' } + it { should respond_with(:not_found) } + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d381b3f1..4700c3fe 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -28,6 +28,7 @@ RSpec.configure do |config| config.include LoginHelpers, type: :request config.include GitoliteStub config.include FactoryGirl::Syntax::Methods + config.include Devise::TestHelpers, type: :controller # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false From 79a02df92e18137787371468be5c8897ad2f97b0 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 12:39:57 -0400 Subject: [PATCH 040/288] Update usages of tree_file_project_ref_path to project_tree_path --- app/controllers/refs_controller.rb | 6 +++--- app/decorators/tree_decorator.rb | 4 ++-- app/helpers/application_helper.rb | 10 +++++----- app/helpers/tree_helper.rb | 5 +++++ app/views/commits/_commit.html.haml | 2 +- app/views/commits/_commit_box.html.haml | 2 +- app/views/commits/_diffs.html.haml | 2 +- app/views/layouts/_head.html.haml | 2 +- app/views/layouts/_project_menu.html.haml | 2 +- app/views/refs/_head.html.haml | 2 +- app/views/refs/blame.html.haml | 4 ++-- app/views/refs/logs_tree.js.haml | 2 +- app/views/tree/_head.html.haml | 4 ++-- app/views/tree/_tree.html.haml | 10 +++++----- app/views/tree/_tree_file.html.haml | 4 ++-- app/views/tree/_tree_item.html.haml | 4 ++-- features/steps/project/project_browse_files.rb | 2 +- features/steps/shared/paths.rb | 6 +++--- spec/requests/gitlab_flavored_markdown_spec.rb | 2 +- spec/requests/security/project_access_spec.rb | 2 +- 20 files changed, 41 insertions(+), 36 deletions(-) diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index 3f81a2ca..6cdd0953 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -18,7 +18,7 @@ class RefsController < ApplicationController respond_to do |format| format.html do new_path = if params[:destination] == "tree" - tree_project_ref_path(@project, params[:ref]) + project_tree_path(@project, params[:ref]) else project_commits_path(@project, ref: params[:ref]) end @@ -96,10 +96,10 @@ class RefsController < ApplicationController @hex_path = Digest::SHA1.hexdigest(params[:path] || "/") if params[:path] - @history_path = tree_file_project_ref_path(@project, @ref, params[:path]) + @history_path = project_tree_path(@project, File.join(@ref, params[:path])) @logs_path = logs_file_project_ref_path(@project, @ref, params[:path]) else - @history_path = tree_project_ref_path(@project, @ref) + @history_path = project_tree_path(@project, @ref) @logs_path = logs_tree_project_ref_path(@project, @ref) end rescue diff --git a/app/decorators/tree_decorator.rb b/app/decorators/tree_decorator.rb index 80c48da7..05f029d0 100644 --- a/app/decorators/tree_decorator.rb +++ b/app/decorators/tree_decorator.rb @@ -15,7 +15,7 @@ class TreeDecorator < ApplicationDecorator part_path = part if part_path.empty? next unless parts.last(2).include?(part) if parts.count > max_links - yield(h.link_to(h.truncate(part, length: 40), h.tree_file_project_ref_path(project, ref, path: part_path), remote: :true)) + yield(h.link_to(h.truncate(part, length: 40), h.project_tree_path(project, h.tree_join(ref, part_path)), remote: :true)) end end end @@ -26,7 +26,7 @@ class TreeDecorator < ApplicationDecorator def up_dir_path file = File.join(path, "..") - h.tree_file_project_ref_path(project, ref, file) + h.project_tree_path(project, h.tree_join(ref, file)) end def history_path diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0938dc23..d90fb32f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -58,11 +58,11 @@ module ApplicationHelper if @project && !@project.new_record? project_nav = [ - { label: "#{@project.name} / Issues", url: project_issues_path(@project) }, - { label: "#{@project.name} / Wall", url: wall_project_path(@project) }, - { label: "#{@project.name} / Tree", url: tree_project_ref_path(@project, @project.root_ref) }, - { label: "#{@project.name} / Commits", url: project_commits_path(@project) }, - { label: "#{@project.name} / Team", url: project_team_index_path(@project) } + { label: "#{@project.name} / Issues", url: project_issues_path(@project) }, + { label: "#{@project.name} / Wall", url: wall_project_path(@project) }, + { label: "#{@project.name} / Tree", url: project_tree_path(@project, @ref || @project.root_ref) }, + { label: "#{@project.name} / Commits", url: project_commits_path(@project, @ref || @project.root_ref) }, + { label: "#{@project.name} / Team", url: project_team_index_path(@project) } ] end diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index 2b7265ca..81a16989 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -39,4 +39,9 @@ module TreeHelper def gitlab_markdown?(filename) filename.end_with?(*%w(.mdown .md .markdown)) end + + # Simple shortcut to File.join + def tree_join(*args) + File.join(*args) + end end diff --git a/app/views/commits/_commit.html.haml b/app/views/commits/_commit.html.haml index 6abea76c..259e8e26 100644 --- a/app/views/commits/_commit.html.haml +++ b/app/views/commits/_commit.html.haml @@ -1,7 +1,7 @@ %li.commit .browse_code_link_holder %p - %strong= link_to "Browse Code »", tree_project_ref_path(@project, commit), class: "right" + %strong= link_to "Browse Code »", project_tree_path(@project, commit), class: "right" %p = link_to commit.short_id(8), project_commit_path(@project, commit), class: "commit_short_id" %strong.commit-author-name= commit.author_name diff --git a/app/views/commits/_commit_box.html.haml b/app/views/commits/_commit_box.html.haml index 572337de..3daf63f4 100644 --- a/app/views/commits/_commit_box.html.haml +++ b/app/views/commits/_commit_box.html.haml @@ -8,7 +8,7 @@ = link_to patch_project_commit_path(@project, @commit.id), class: "btn small grouped" do %i.icon-download-alt Get Patch - = link_to tree_project_ref_path(@project, @commit.id), class: "browse-button primary grouped" do + = link_to project_tree_path(@project, @commit), class: "browse-button primary grouped" do %strong Browse Code » %h3.commit-title.page_title = gfm escape_once(@commit.title) diff --git a/app/views/commits/_diffs.html.haml b/app/views/commits/_diffs.html.haml index b590d64c..bc53911c 100644 --- a/app/views/commits/_diffs.html.haml +++ b/app/views/commits/_diffs.html.haml @@ -24,7 +24,7 @@ %i.icon-file %span{id: "#{diff.old_path}"}= diff.old_path - else - = link_to tree_file_project_ref_path(@project, @commit.id, diff.new_path) do + = link_to project_tree_path(@project, @commit, diff.new_path) do %i.icon-file %span{id: "#{diff.new_path}"}= diff.new_path %br/ diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index c076a3a1..06da82d3 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -10,7 +10,7 @@ - if controller_name == 'projects' && action_name == 'index' = auto_discovery_link_tag :atom, projects_url(:atom, private_token: current_user.private_token), title: "Dashboard feed" - if @project && !@project.new_record? - - if current_page?(tree_project_ref_path(@project, @project.root_ref)) || current_page?(project_commits_path(@project)) + - if current_page?(project_tree_path(@project, @project.root_ref)) || current_page?(project_commits_path(@project)) = auto_discovery_link_tag(:atom, project_commits_url(@project, :atom, ref: @ref, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}") - if request.path == project_issues_path(@project) = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues") diff --git a/app/views/layouts/_project_menu.html.haml b/app/views/layouts/_project_menu.html.haml index 04eaec5a..11e632b9 100644 --- a/app/views/layouts/_project_menu.html.haml +++ b/app/views/layouts/_project_menu.html.haml @@ -5,7 +5,7 @@ - if @project.repo_exists? - if can? current_user, :download_code, @project %li{class: tree_tab_class} - = link_to tree_project_ref_path(@project, @project.root_ref) do + = link_to project_tree_path(@project, @project.root_ref) do Files %li{class: commit_tab_class} = link_to "Commits", project_commits_path(@project) diff --git a/app/views/refs/_head.html.haml b/app/views/refs/_head.html.haml index 3592f573..2a6052a1 100644 --- a/app/views/refs/_head.html.haml +++ b/app/views/refs/_head.html.haml @@ -2,7 +2,7 @@ %li = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]} %li{class: "#{'active' if (controller.controller_name == "refs") }"} - = link_to tree_project_ref_path(@project, @ref) do + = link_to project_tree_path(@project, @ref) do Source %li.right .input-prepend.project_clone_holder diff --git a/app/views/refs/blame.html.haml b/app/views/refs/blame.html.haml index ba0fad52..75b86315 100644 --- a/app/views/refs/blame.html.haml +++ b/app/views/refs/blame.html.haml @@ -4,7 +4,7 @@ %ul.breadcrumb %li %span.arrow - = link_to tree_project_ref_path(@project, @ref, path: nil) do + = link_to project_tree_path(@project, @ref) do = @project.name - @tree.breadcrumbs(6) do |link| \/ @@ -20,7 +20,7 @@ %span.options = link_to "raw", blob_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small", target: "_blank" = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" - = link_to "source", tree_file_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small" + = link_to "source", project_tree_path(@project, tree_join(@ref, params[:path])), class: "btn very_small" .file_content.blame %table - @blame.each do |commit, lines| diff --git a/app/views/refs/logs_tree.js.haml b/app/views/refs/logs_tree.js.haml index 61ccbaee..b0ac0c4b 100644 --- a/app/views/refs/logs_tree.js.haml +++ b/app/views/refs/logs_tree.js.haml @@ -6,4 +6,4 @@ :plain var row = $("table.table_#{@hex_path} tr.file_#{hexdigest(file_name)}"); row.find("td.tree_time_ago").html('#{escape_javascript(time_ago_in_words(content_commit.committed_date))} ago'); - row.find("td.tree_commit").html('#{escape_javascript(render("tree_commit", tm: tm, content_commit: content_commit))}'); + row.find("td.tree_commit").html('#{escape_javascript(render("tree/tree_commit", tm: tm, content_commit: content_commit))}'); diff --git a/app/views/tree/_head.html.haml b/app/views/tree/_head.html.haml index 3592f573..5126891e 100644 --- a/app/views/tree/_head.html.haml +++ b/app/views/tree/_head.html.haml @@ -1,8 +1,8 @@ %ul.nav.nav-tabs %li = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]} - %li{class: "#{'active' if (controller.controller_name == "refs") }"} - = link_to tree_project_ref_path(@project, @ref) do + %li{class: "#{'active' if (controller.controller_name == "tree") }"} + = link_to project_tree_path(@project, @ref) do Source %li.right .input-prepend.project_clone_holder diff --git a/app/views/tree/_tree.html.haml b/app/views/tree/_tree.html.haml index 55078718..439b4ec2 100644 --- a/app/views/tree/_tree.html.haml +++ b/app/views/tree/_tree.html.haml @@ -1,7 +1,7 @@ %ul.breadcrumb %li %span.arrow - = link_to tree_project_ref_path(@project, @ref, path: nil), remote: true do + = link_to project_tree_path(@project, @ref), remote: true do = @project.name - tree.breadcrumbs(6) do |link| \/ @@ -10,7 +10,7 @@ %div.tree_progress #tree-content-holder - if tree.is_blob? - = render partial: "refs/tree_file", locals: { name: tree.name, content: tree.data, file: tree } + = render partial: "tree/tree_file", locals: { name: tree.name, content: tree.data, file: tree } - else - contents = tree.contents %table#tree-slider{class: "table_#{@hex_path}" } @@ -31,11 +31,11 @@ - index = 0 - contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content| - = render partial: "refs/tree_item", locals: { content: content, index: (index += 1) } + = render partial: "tree/tree_item", locals: { content: content, index: (index += 1) } - contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content| - = render partial: "refs/tree_item", locals: { content: content, index: (index += 1) } + = render partial: "tree/tree_item", locals: { content: content, index: (index += 1) } - contents.select{ |i| i.is_a?(Grit::Submodule)}.each do |content| - = render partial: "refs/submodule_item", locals: { content: content, index: (index += 1) } + = render partial: "tree/submodule_item", locals: { content: content, index: (index += 1) } - if content = contents.select{ |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }.first .file_holder#README diff --git a/app/views/tree/_tree_file.html.haml b/app/views/tree/_tree_file.html.haml index 76173e24..ae8f1ccf 100644 --- a/app/views/tree/_tree_file.html.haml +++ b/app/views/tree/_tree_file.html.haml @@ -5,9 +5,9 @@ = name.force_encoding('utf-8') %small #{file.mode} %span.options - = link_to "raw", blob_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small", target: "_blank" + = link_to "raw", blob_project_ref_path(@project, @ref, path: @path), class: "btn very_small", target: "_blank" = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" - = link_to "blame", blame_file_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small" + = link_to "blame", blame_file_project_ref_path(@project, @ref, path: @path.gsub(/^\//, '')), class: "btn very_small" - if file.text? - if gitlab_markdown?(name) .file_content.wiki diff --git a/app/views/tree/_tree_item.html.haml b/app/views/tree/_tree_item.html.haml index d4c4ee8d..226c380f 100644 --- a/app/views/tree/_tree_item.html.haml +++ b/app/views/tree/_tree_item.html.haml @@ -1,8 +1,8 @@ - file = tree_full_path(content) -%tr{ class: "tree-item #{tree_hex_class(content)}", url: tree_file_project_ref_path(@project, @ref, file) } +%tr{ class: "tree-item #{tree_hex_class(content)}", url: project_tree_path(@project, tree_join(@id, file)) } %td.tree-item-file-name = tree_icon(content) - %strong= link_to truncate(content.name, length: 40), tree_file_project_ref_path(@project, @ref || @commit.id, file), remote: :true + %strong= link_to truncate(content.name, length: 40), project_tree_path(@project, tree_join(@id || @commit.id, file)), remote: :true %td.tree_time_ago.cgray - if index == 1 %span.log_loading diff --git a/features/steps/project/project_browse_files.rb b/features/steps/project/project_browse_files.rb index 67c553ce..652daba0 100644 --- a/features/steps/project/project_browse_files.rb +++ b/features/steps/project/project_browse_files.rb @@ -10,7 +10,7 @@ class ProjectBrowseFiles < Spinach::FeatureSteps end Then 'I should see files from repository for "8470d70"' do - current_path.should == tree_project_ref_path(@project, "8470d70") + current_path.should == project_tree_path(@project, "8470d70") page.should have_content "app" page.should have_content "History" page.should have_content "Gemfile" diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 93ad0219..1839bc81 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -51,15 +51,15 @@ module SharedPaths end Given 'I visit project source page' do - visit tree_project_ref_path(@project, @project.root_ref) + visit project_tree_path(@project, @project.root_ref) end Given 'I visit blob file from repo' do - visit tree_project_ref_path(@project, ValidCommit::ID, :path => ValidCommit::BLOB_FILE_PATH) + visit project_tree_path(@project, File.join(ValidCommit::ID, ValidCommit::BLOB_FILE_PATH)) end Given 'I visit project source page for "8470d70"' do - visit tree_project_ref_path(@project, "8470d70") + visit project_tree_path(@project, "8470d70") end Given 'I visit project tags page' do diff --git a/spec/requests/gitlab_flavored_markdown_spec.rb b/spec/requests/gitlab_flavored_markdown_spec.rb index 807d17d7..db3f89cb 100644 --- a/spec/requests/gitlab_flavored_markdown_spec.rb +++ b/spec/requests/gitlab_flavored_markdown_spec.rb @@ -61,7 +61,7 @@ describe "Gitlab Flavored Markdown" do end it "should render title in refs#tree", js: true do - visit tree_project_ref_path(project, id: @branch_name) + visit project_tree_path(project, @branch_name) within(".tree_commit") do page.should have_link("##{issue.id}") diff --git a/spec/requests/security/project_access_spec.rb b/spec/requests/security/project_access_spec.rb index af0d5fcd..4b6abd3e 100644 --- a/spec/requests/security/project_access_spec.rb +++ b/spec/requests/security/project_access_spec.rb @@ -37,7 +37,7 @@ describe "Application access" do end describe "GET /project_code/master/tree" do - subject { tree_project_ref_path(@project, @project.root_ref) } + subject { project_tree_path(@project, @project.root_ref) } it { should be_allowed_for @u1 } it { should be_allowed_for @u3 } From 339dfa32b810b8f15c26c85e692a18a0f47b9fca Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 13:07:17 -0400 Subject: [PATCH 041/288] Fix ref_switcher path --- app/views/shared/_ref_switcher.html.haml | 2 +- app/views/tree/_head.html.haml | 2 +- app/views/tree/show.js.haml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/shared/_ref_switcher.html.haml b/app/views/shared/_ref_switcher.html.haml index e0c89522..8b44cf19 100644 --- a/app/views/shared/_ref_switcher.html.haml +++ b/app/views/shared/_ref_switcher.html.haml @@ -1,5 +1,5 @@ = form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form" do = select_tag "ref", grouped_options_refs, class: "project-refs-select chosen" = hidden_field_tag :destination, destination - - if respond_to?(:path) + - if defined?(path) = hidden_field_tag :path, path diff --git a/app/views/tree/_head.html.haml b/app/views/tree/_head.html.haml index 5126891e..c7ebbf88 100644 --- a/app/views/tree/_head.html.haml +++ b/app/views/tree/_head.html.haml @@ -1,6 +1,6 @@ %ul.nav.nav-tabs %li - = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]} + = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: @path} %li{class: "#{'active' if (controller.controller_name == "tree") }"} = link_to project_tree_path(@project, @ref) do Source diff --git a/app/views/tree/show.js.haml b/app/views/tree/show.js.haml index 92e90579..3d0215ff 100644 --- a/app/views/tree/show.js.haml +++ b/app/views/tree/show.js.haml @@ -2,7 +2,7 @@ // Load Files list $("#tree-holder").html("#{escape_javascript(render(partial: "tree", locals: {repo: @repo, commit: @commit, tree: @tree}))}"); $("#tree-content-holder").show("slide", { direction: "right" }, 150); - $('.project-refs-form #path').val("#{params[:path]}"); + $('.project-refs-form #path').val("#{@path}"); // Load last commit log for each file in tree $('#tree-slider').waitForImages(function() { From 94af622c879681683c84b6537c2adea52c78b2a2 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 13:32:17 -0400 Subject: [PATCH 042/288] Move refs/blame view to blame/show --- app/views/{refs/blame.html.haml => blame/show.html.haml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/views/{refs/blame.html.haml => blame/show.html.haml} (100%) diff --git a/app/views/refs/blame.html.haml b/app/views/blame/show.html.haml similarity index 100% rename from app/views/refs/blame.html.haml rename to app/views/blame/show.html.haml From 37f0b600bc9a994136791e6838b3228c56f909b2 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 13:33:04 -0400 Subject: [PATCH 043/288] Another RefExtractor refactor --- lib/ref_extractor.rb | 74 ++++++++++++++++++---------------- spec/lib/ref_extractor_spec.rb | 57 +++++++++++++++++--------- 2 files changed, 78 insertions(+), 53 deletions(-) diff --git a/lib/ref_extractor.rb b/lib/ref_extractor.rb index d3f02d6e..d7d446b1 100644 --- a/lib/ref_extractor.rb +++ b/lib/ref_extractor.rb @@ -1,37 +1,39 @@ # Module providing an extract_ref method for controllers working with Git # tree-ish + path params -# -# Given a string containing both a Git ref - such as a branch or tag - and a -# filesystem path joined by forward slashes, attempts to separate the two. -# -# Expects a @project instance variable to contain the active project. Used to -# check the input against a list of valid repository refs. -# -# Examples -# -# # No @project available -# extract_ref('master') -# # => ['', ''] -# -# extract_ref('master') -# # => ['master', '/'] -# -# extract_ref("f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG") -# # => ['f4b14494ef6abf3d144c28e4af0c20143383e062', '/CHANGELOG'] -# -# extract_ref("v2.0.0/README.md") -# # => ['v2.0.0', '/README.md'] -# -# extract_ref('issues/1234/app/models/project.rb') -# # => ['issues/1234', '/app/models/project.rb'] -# -# # Given an invalid branch, we fall back to just splitting on the first slash -# extract_ref('non/existent/branch/README.md') -# # => ['non', '/existent/branch/README.md'] -# -# Returns an Array where the first value is the tree-ish and the second is the -# path module RefExtractor + # Thrown when given an invalid path + class InvalidPathError < StandardError; end + + # Given a string containing both a Git ref - such as a branch or tag - and a + # filesystem path joined by forward slashes, attempts to separate the two. + # + # Expects a @project instance variable to contain the active project. Used to + # check the input against a list of valid repository refs. + # + # Examples + # + # # No @project available + # extract_ref('master') + # # => ['', ''] + # + # extract_ref('master') + # # => ['master', ''] + # + # extract_ref("f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG") + # # => ['f4b14494ef6abf3d144c28e4af0c20143383e062', 'CHANGELOG'] + # + # extract_ref("v2.0.0/README.md") + # # => ['v2.0.0', 'README.md'] + # + # extract_ref('issues/1234/app/models/project.rb') + # # => ['issues/1234', 'app/models/project.rb'] + # + # # Given an invalid branch, we fall back to just splitting on the first slash + # extract_ref('non/existent/branch/README.md') + # # => ['non', 'existent/branch/README.md'] + # + # Returns an Array where the first value is the tree-ish and the second is the + # path def extract_ref(input) pair = ['', ''] @@ -41,24 +43,28 @@ module RefExtractor # If the ref appears to be a SHA, we're done, just split the string pair = $~.captures else + # Otherwise, attempt to detect the ref using a list of the project's + # branches and tags + # Append a trailing slash if we only get a ref and no file path id = input id += '/' unless id.include?('/') - # Otherwise, attempt to detect the ref using a list of the project's - # branches and tags valid_refs = @project.branches + @project.tags valid_refs.select! { |v| id.start_with?("#{v}/") } if valid_refs.length != 1 # No exact ref match, so just try our best - pair = id.match(/([^\/]+)(.+)/).captures + pair = id.match(/([^\/]+)(.*)/).captures else # Partition the string into the ref and the path, ignoring the empty first value pair = id.partition(valid_refs.first)[1..-1] end end + # Remove leading slash from path + pair[1].gsub!(/^\//, '') + pair end end diff --git a/spec/lib/ref_extractor_spec.rb b/spec/lib/ref_extractor_spec.rb index 84347977..1e3d178f 100644 --- a/spec/lib/ref_extractor_spec.rb +++ b/spec/lib/ref_extractor_spec.rb @@ -11,29 +11,48 @@ describe RefExtractor do project.stub(:tags).and_return(['v1.0.0', 'v2.0.0']) end - it "extracts a ref without a path" do - extract_ref('master').should == ['master', '/'] - end + describe '#extract_ref' do + it "returns an empty pair when no @project is set" do + @project = nil + extract_ref('master/CHANGELOG').should == ['', ''] + end - it "extracts a valid branch ref" do - extract_ref('foo/bar/baz/CHANGELOG').should == ['foo/bar/baz', '/CHANGELOG'] - end + context "without a path" do + it "extracts a valid branch" do + extract_ref('master').should == ['master', ''] + end - it "extracts a valid tag ref" do - extract_ref('v2.0.0/CHANGELOG').should == ['v2.0.0', '/CHANGELOG'] - end + it "extracts a valid tag" do + extract_ref('v2.0.0').should == ['v2.0.0', ''] + end - it "extracts a valid commit ref" do - extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG').should == - ['f4b14494ef6abf3d144c28e4af0c20143383e062', '/CHANGELOG'] - end + it "extracts a valid commit ref without a path" do + extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062').should == + ['f4b14494ef6abf3d144c28e4af0c20143383e062', ''] + end - it "falls back to a primitive split for an invalid ref" do - extract_ref('stable/CHANGELOG').should == ['stable', '/CHANGELOG'] - end + it "falls back to a primitive split for an invalid ref" do + extract_ref('stable').should == ['stable', ''] + end + end - it "returns an empty pair when no @project is set" do - @project = nil - extract_ref('master/CHANGELOG').should == ['', ''] + context "with a path" do + it "extracts a valid branch" do + extract_ref('foo/bar/baz/CHANGELOG').should == ['foo/bar/baz', 'CHANGELOG'] + end + + it "extracts a valid tag" do + extract_ref('v2.0.0/CHANGELOG').should == ['v2.0.0', 'CHANGELOG'] + end + + it "extracts a valid commit SHA" do + extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG').should == + ['f4b14494ef6abf3d144c28e4af0c20143383e062', 'CHANGELOG'] + end + + it "falls back to a primitive split for an invalid ref" do + extract_ref('stable/CHANGELOG').should == ['stable', 'CHANGELOG'] + end + end end end From 39c657930625ddc3ac8a921f01ffc83acadce68f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 13:36:13 -0400 Subject: [PATCH 044/288] Add BlameController, remove Refs#blame action --- app/controllers/blame_controller.rb | 45 +++++++++++++++++++ app/controllers/refs_controller.rb | 6 +-- app/views/{refs => blame}/_head.html.haml | 0 app/views/blame/show.html.haml | 2 +- app/views/tree/_tree_file.html.haml | 2 +- config/routes.rb | 10 +---- .../requests/gitlab_flavored_markdown_spec.rb | 2 +- spec/routing/project_routing_spec.rb | 17 +++---- 8 files changed, 57 insertions(+), 27 deletions(-) create mode 100644 app/controllers/blame_controller.rb rename app/views/{refs => blame}/_head.html.haml (100%) diff --git a/app/controllers/blame_controller.rb b/app/controllers/blame_controller.rb new file mode 100644 index 00000000..d159a83c --- /dev/null +++ b/app/controllers/blame_controller.rb @@ -0,0 +1,45 @@ +# Controller for viewing a file's blame +class BlameController < ApplicationController + # Thrown when given an invalid path + class InvalidPathError < StandardError; end + + include RefExtractor + + layout "project" + + before_filter :project + + # Authorize + before_filter :add_project_abilities + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + before_filter :define_tree_vars + + def show + @blame = Grit::Blob.blame(@repo, @commit.id, @path) + end + + private + + def define_tree_vars + @ref, @path = extract_ref(params[:id]) + + @id = File.join(@ref, @path) + @repo = @project.repo + @commit = CommitDecorator.decorate(@project.commit(@ref)) + + @tree = Tree.new(@commit.tree, @project, @ref, @path) + @tree = TreeDecorator.new(@tree) + + raise InvalidPathError if @tree.invalid? + + @hex_path = Digest::SHA1.hexdigest(@path) + + @history_path = project_tree_path(@project, @id) + @logs_path = logs_file_project_ref_path(@project, @ref, @path) + rescue NoMethodError, InvalidPathError + not_found! + end +end diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index 6cdd0953..334dfc7f 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -9,7 +9,7 @@ class RefsController < ApplicationController before_filter :require_non_empty_project before_filter :ref - before_filter :define_tree_vars, only: [:tree, :blob, :blame, :logs_tree] + before_filter :define_tree_vars, only: [:blob, :logs_tree] before_filter :render_full_content layout "project" @@ -79,10 +79,6 @@ class RefsController < ApplicationController end end - def blame - @blame = Grit::Blob.blame(@repo, @commit.id, params[:path]) - end - protected def define_tree_vars diff --git a/app/views/refs/_head.html.haml b/app/views/blame/_head.html.haml similarity index 100% rename from app/views/refs/_head.html.haml rename to app/views/blame/_head.html.haml diff --git a/app/views/blame/show.html.haml b/app/views/blame/show.html.haml index 75b86315..0b2f93be 100644 --- a/app/views/blame/show.html.haml +++ b/app/views/blame/show.html.haml @@ -20,7 +20,7 @@ %span.options = link_to "raw", blob_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small", target: "_blank" = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" - = link_to "source", project_tree_path(@project, tree_join(@ref, params[:path])), class: "btn very_small" + = link_to "source", project_tree_path(@project, @id), class: "btn very_small" .file_content.blame %table - @blame.each do |commit, lines| diff --git a/app/views/tree/_tree_file.html.haml b/app/views/tree/_tree_file.html.haml index ae8f1ccf..052172be 100644 --- a/app/views/tree/_tree_file.html.haml +++ b/app/views/tree/_tree_file.html.haml @@ -7,7 +7,7 @@ %span.options = link_to "raw", blob_project_ref_path(@project, @ref, path: @path), class: "btn very_small", target: "_blank" = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" - = link_to "blame", blame_file_project_ref_path(@project, @ref, path: @path.gsub(/^\//, '')), class: "btn very_small" + = link_to "blame", project_blame_path(@project, @id), class: "btn very_small" - if file.text? - if gitlab_markdown?(name) .file_content.wiki diff --git a/config/routes.rb b/config/routes.rb index d1ed8749..1aa10c5d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -136,14 +136,6 @@ Gitlab::Application.routes.draw do id: /[a-zA-Z.0-9\/_\-]+/, path: /.*/ } - - # blame - get "blame/:path" => "refs#blame", - as: :blame_file, - constraints: { - id: /[a-zA-Z.0-9\/_\-]+/, - path: /.*/ - } end end @@ -204,7 +196,7 @@ Gitlab::Application.routes.draw do end # XXX: WIP - # resources :blame, only: [:show], constraints: {id: /.+/} + resources :blame, only: [:show], constraints: {id: /.+/} # resources :blob, only: [:show], constraints: {id: /.+/} # resources :raw, only: [:show], constraints: {id: /.+/} resources :tree, only: [:show], constraints: {id: /.+/} diff --git a/spec/requests/gitlab_flavored_markdown_spec.rb b/spec/requests/gitlab_flavored_markdown_spec.rb index db3f89cb..2e5d4209 100644 --- a/spec/requests/gitlab_flavored_markdown_spec.rb +++ b/spec/requests/gitlab_flavored_markdown_spec.rb @@ -69,7 +69,7 @@ describe "Gitlab Flavored Markdown" do end it "should render title in refs#blame" do - visit blame_file_project_ref_path(project, id: @branch_name, path: @test_file) + visit blame_file_project_ref_path(project, File.join(@branch_name, @test_file)) within(".blame_commit") do page.should have_link("##{issue.id}") diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index f9c99a20..303df02c 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -195,7 +195,6 @@ end # blob_project_ref GET /:project_id/:id/blob(.:format) refs#blob # logs_tree_project_ref GET /:project_id/:id/logs_tree(.:format) refs#logs_tree # logs_file_project_ref GET /:project_id/:id/logs_tree/:path(.:format) refs#logs_tree -# blame_file_project_ref GET /:project_id/:id/blame/:path(.:format) refs#blame describe RefsController, "routing" do it "to #switch" do get("/gitlabhq/switch").should route_to('refs#switch', project_id: 'gitlabhq') @@ -209,10 +208,6 @@ describe RefsController, "routing" do it "to #blob" do get("/gitlabhq/stable/blob").should route_to('refs#blob', project_id: 'gitlabhq', id: 'stable') end - - it "to #blame" do - get("/gitlabhq/stable/blame/foo/bar/baz").should route_to('refs#blame', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz') - end end # diffs_project_merge_request GET /:project_id/merge_requests/:id/diffs(.:format) merge_requests#diffs @@ -399,6 +394,12 @@ describe NotesController, "routing" do end end +describe BlameController, "routing" do + it "to #show" do + get("/gitlabhq/blame/master/app/models/project.rb").should route_to('blame#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + end +end + describe TreeController, "routing" do it "to #show" do get("/gitlabhq/tree/master/app/models/project.rb").should route_to('tree#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') @@ -432,11 +433,7 @@ end # /gitlabhq/tree/master/app # /gitlabhq/tree/test/branch/name/app describe "pending routing" do - describe "/:project_id/blame/:id" do - it "routes to a ref with a path" do - get("/gitlabhq/blame/master/app/models/project.rb").should route_to('blame#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - end - end + before { pending } describe "/:project_id/blob/:id" do it "routes to a ref with a path" do From 576cec6c67dcc4ee00b8220ca1a45385583e25b2 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 13:49:57 -0400 Subject: [PATCH 045/288] Add BlobController, remove Refs#blob --- app/controllers/blob_controller.rb | 62 +++++++++++++++++++ app/controllers/refs_controller.rb | 49 +++------------ app/views/blame/show.html.haml | 2 +- app/views/commits/_diffs.html.haml | 2 +- app/views/tree/_tree_file.html.haml | 6 +- config/routes.rb | 8 +-- spec/requests/security/project_access_spec.rb | 2 +- spec/routing/project_routing_spec.rb | 17 ++--- 8 files changed, 83 insertions(+), 65 deletions(-) create mode 100644 app/controllers/blob_controller.rb diff --git a/app/controllers/blob_controller.rb b/app/controllers/blob_controller.rb new file mode 100644 index 00000000..bb051281 --- /dev/null +++ b/app/controllers/blob_controller.rb @@ -0,0 +1,62 @@ +# Controller for viewing a file's blame +class BlobController < ApplicationController + # Thrown when given an invalid path + class InvalidPathError < StandardError; end + + include RefExtractor + include Gitlab::Encode + + layout "project" + + before_filter :project + + # Authorize + before_filter :add_project_abilities + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + before_filter :define_tree_vars + + def show + if @tree.is_blob? + if @tree.text? + encoding = detect_encoding(@tree.data) + mime_type = encoding ? "text/plain; charset=#{encoding}" : "text/plain" + else + mime_type = @tree.mime_type + end + + send_data( + @tree.data, + type: mime_type, + disposition: 'inline', + filename: @tree.name + ) + else + not_found! + end + end + + private + + def define_tree_vars + @ref, @path = extract_ref(params[:id]) + + @id = File.join(@ref, @path) + @repo = @project.repo + @commit = CommitDecorator.decorate(@project.commit(@ref)) + + @tree = Tree.new(@commit.tree, @project, @ref, @path) + @tree = TreeDecorator.new(@tree) + + raise InvalidPathError if @tree.invalid? + + @hex_path = Digest::SHA1.hexdigest(@path) + + @history_path = project_tree_path(@project, @id) + @logs_path = logs_file_project_ref_path(@project, @ref, @path) + rescue NoMethodError, InvalidPathError + not_found! + end +end diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index 334dfc7f..f9cd4734 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -18,14 +18,14 @@ class RefsController < ApplicationController respond_to do |format| format.html do new_path = if params[:destination] == "tree" - project_tree_path(@project, params[:ref]) + project_tree_path(@project, @ref) else - project_commits_path(@project, ref: params[:ref]) + project_commits_path(@project, ref: @ref) end - redirect_to new_path + redirect_to new_path end - format.js do + format.js do @ref = params[:ref] define_tree_vars render "tree" @@ -33,19 +33,6 @@ class RefsController < ApplicationController end end - # - # Repository preview - # - def tree - respond_to do |format| - format.html - format.js do - # disable cache to allow back button works - no_cache_headers - end - end - end - def logs_tree contents = @tree.contents @logs = contents.map do |content| @@ -53,32 +40,12 @@ class RefsController < ApplicationController last_commit = @project.commits(@commit.id, file, 1).last last_commit = CommitDecorator.decorate(last_commit) { - file_name: content.name, + file_name: content.name, commit: last_commit } end end - def blob - if @tree.is_blob? - if @tree.text? - encoding = detect_encoding(@tree.data) - mime_type = encoding ? "text/plain; charset=#{encoding}" : "text/plain" - else - mime_type = @tree.mime_type - end - - send_data( - @tree.data, - type: mime_type, - disposition: 'inline', - filename: @tree.name - ) - else - head(404) - end - end - protected def define_tree_vars @@ -93,15 +60,15 @@ class RefsController < ApplicationController if params[:path] @history_path = project_tree_path(@project, File.join(@ref, params[:path])) - @logs_path = logs_file_project_ref_path(@project, @ref, params[:path]) + @logs_path = logs_file_project_ref_path(@project, @ref, params[:path]) else @history_path = project_tree_path(@project, @ref) - @logs_path = logs_tree_project_ref_path(@project, @ref) + @logs_path = logs_tree_project_ref_path(@project, @ref) end rescue return render_404 end - + def ref @ref = params[:id] end diff --git a/app/views/blame/show.html.haml b/app/views/blame/show.html.haml index 0b2f93be..12b4e668 100644 --- a/app/views/blame/show.html.haml +++ b/app/views/blame/show.html.haml @@ -18,7 +18,7 @@ = @tree.name %small blame %span.options - = link_to "raw", blob_project_ref_path(@project, @ref, path: params[:path]), class: "btn very_small", target: "_blank" + = link_to "raw", project_blob_path(@project, @id), class: "btn very_small", target: "_blank" = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" = link_to "source", project_tree_path(@project, @id), class: "btn very_small" .file_content.blame diff --git a/app/views/commits/_diffs.html.haml b/app/views/commits/_diffs.html.haml index bc53911c..301cd554 100644 --- a/app/views/commits/_diffs.html.haml +++ b/app/views/commits/_diffs.html.haml @@ -24,7 +24,7 @@ %i.icon-file %span{id: "#{diff.old_path}"}= diff.old_path - else - = link_to project_tree_path(@project, @commit, diff.new_path) do + = link_to project_tree_path(@project, tree_join(@commit.id, diff.new_path)) do %i.icon-file %span{id: "#{diff.new_path}"}= diff.new_path %br/ diff --git a/app/views/tree/_tree_file.html.haml b/app/views/tree/_tree_file.html.haml index 052172be..b4c4566b 100644 --- a/app/views/tree/_tree_file.html.haml +++ b/app/views/tree/_tree_file.html.haml @@ -5,8 +5,8 @@ = name.force_encoding('utf-8') %small #{file.mode} %span.options - = link_to "raw", blob_project_ref_path(@project, @ref, path: @path), class: "btn very_small", target: "_blank" - = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" + = link_to "raw", project_blob_path(@project, @id), class: "btn very_small", target: "_blank" + = link_to "history", project_commits_path(@project, path: @path, ref: @ref), class: "btn very_small" = link_to "blame", project_blame_path(@project, @id), class: "btn very_small" - if file.text? - if gitlab_markdown?(name) @@ -32,7 +32,7 @@ - else .file_content.blob_file %center - = link_to blob_project_ref_path(@project, @ref, path: params[:path]) do + = link_to project_blob_path(@project, @id) do %div.padded %br = image_tag "download.png", width: 64 diff --git a/config/routes.rb b/config/routes.rb index 1aa10c5d..af7b9bd4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -122,12 +122,6 @@ Gitlab::Application.routes.draw do end member do - get "blob", - constraints: { - id: /[a-zA-Z.0-9\/_\-]+/, - path: /.*/ - } - # tree viewer logs get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } get "logs_tree/:path" => "refs#logs_tree", @@ -197,7 +191,7 @@ Gitlab::Application.routes.draw do # XXX: WIP resources :blame, only: [:show], constraints: {id: /.+/} - # resources :blob, only: [:show], constraints: {id: /.+/} + resources :blob, only: [:show], constraints: {id: /.+/} # resources :raw, only: [:show], constraints: {id: /.+/} resources :tree, only: [:show], constraints: {id: /.+/} end diff --git a/spec/requests/security/project_access_spec.rb b/spec/requests/security/project_access_spec.rb index 4b6abd3e..9b07df6c 100644 --- a/spec/requests/security/project_access_spec.rb +++ b/spec/requests/security/project_access_spec.rb @@ -95,7 +95,7 @@ describe "Application access" do before do commit = @project.commit path = commit.tree.contents.select { |i| i.is_a?(Grit::Blob)}.first.name - @blob_path = blob_project_ref_path(@project, commit.id, path: path) + @blob_path = project_blob_path(@project, File.join(commit.id, path)) end it { @blob_path.should be_allowed_for @u1 } diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 303df02c..01bc303d 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -192,7 +192,6 @@ describe ProtectedBranchesController, "routing" do end # switch_project_refs GET /:project_id/switch(.:format) refs#switch -# blob_project_ref GET /:project_id/:id/blob(.:format) refs#blob # logs_tree_project_ref GET /:project_id/:id/logs_tree(.:format) refs#logs_tree # logs_file_project_ref GET /:project_id/:id/logs_tree/:path(.:format) refs#logs_tree describe RefsController, "routing" do @@ -204,10 +203,6 @@ describe RefsController, "routing" do get("/gitlabhq/stable/logs_tree").should route_to('refs#logs_tree', project_id: 'gitlabhq', id: 'stable') get("/gitlabhq/stable/logs_tree/foo/bar/baz").should route_to('refs#logs_tree', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz') end - - it "to #blob" do - get("/gitlabhq/stable/blob").should route_to('refs#blob', project_id: 'gitlabhq', id: 'stable') - end end # diffs_project_merge_request GET /:project_id/merge_requests/:id/diffs(.:format) merge_requests#diffs @@ -400,6 +395,12 @@ describe BlameController, "routing" do end end +describe BlobController, "routing" do + it "to #show" do + get("/gitlabhq/blob/master/app/models/project.rb").should route_to('blob#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') + end +end + describe TreeController, "routing" do it "to #show" do get("/gitlabhq/tree/master/app/models/project.rb").should route_to('tree#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') @@ -435,12 +436,6 @@ end describe "pending routing" do before { pending } - describe "/:project_id/blob/:id" do - it "routes to a ref with a path" do - get("/gitlabhq/blob/master/app/models/project.rb").should route_to('blob#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - end - end - describe "/:project_id/commit/:id" do it "routes to a specific commit" do get("/gitlabhq/commit/f4b1449").should route_to('commit#show', project_id: 'gitlabhq', id: 'f4b1449') From 398ba6f1bb60f176444dedc7b26188e08b920f54 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 17 Sep 2012 14:24:31 -0400 Subject: [PATCH 046/288] DRY up Blame, Blob and Tree controllers --- app/controllers/blame_controller.rb | 27 ++------------------------- app/controllers/blob_controller.rb | 24 +----------------------- app/controllers/tree_controller.rb | 29 ++++++----------------------- app/views/tree/show.html.haml | 2 +- app/views/tree/show.js.haml | 2 +- lib/ref_extractor.rb | 27 +++++++++++++++++++++++++++ 6 files changed, 38 insertions(+), 73 deletions(-) diff --git a/app/controllers/blame_controller.rb b/app/controllers/blame_controller.rb index d159a83c..dd5be6dc 100644 --- a/app/controllers/blame_controller.rb +++ b/app/controllers/blame_controller.rb @@ -1,7 +1,5 @@ # Controller for viewing a file's blame class BlameController < ApplicationController - # Thrown when given an invalid path - class InvalidPathError < StandardError; end include RefExtractor @@ -15,31 +13,10 @@ class BlameController < ApplicationController before_filter :authorize_code_access! before_filter :require_non_empty_project - before_filter :define_tree_vars + before_filter :assign_ref_vars def show + @repo = @project.repo @blame = Grit::Blob.blame(@repo, @commit.id, @path) end - - private - - def define_tree_vars - @ref, @path = extract_ref(params[:id]) - - @id = File.join(@ref, @path) - @repo = @project.repo - @commit = CommitDecorator.decorate(@project.commit(@ref)) - - @tree = Tree.new(@commit.tree, @project, @ref, @path) - @tree = TreeDecorator.new(@tree) - - raise InvalidPathError if @tree.invalid? - - @hex_path = Digest::SHA1.hexdigest(@path) - - @history_path = project_tree_path(@project, @id) - @logs_path = logs_file_project_ref_path(@project, @ref, @path) - rescue NoMethodError, InvalidPathError - not_found! - end end diff --git a/app/controllers/blob_controller.rb b/app/controllers/blob_controller.rb index bb051281..58e70bc9 100644 --- a/app/controllers/blob_controller.rb +++ b/app/controllers/blob_controller.rb @@ -16,7 +16,7 @@ class BlobController < ApplicationController before_filter :authorize_code_access! before_filter :require_non_empty_project - before_filter :define_tree_vars + before_filter :assign_ref_vars def show if @tree.is_blob? @@ -37,26 +37,4 @@ class BlobController < ApplicationController not_found! end end - - private - - def define_tree_vars - @ref, @path = extract_ref(params[:id]) - - @id = File.join(@ref, @path) - @repo = @project.repo - @commit = CommitDecorator.decorate(@project.commit(@ref)) - - @tree = Tree.new(@commit.tree, @project, @ref, @path) - @tree = TreeDecorator.new(@tree) - - raise InvalidPathError if @tree.invalid? - - @hex_path = Digest::SHA1.hexdigest(@path) - - @history_path = project_tree_path(@project, @id) - @logs_path = logs_file_project_ref_path(@project, @ref, @path) - rescue NoMethodError, InvalidPathError - not_found! - end end diff --git a/app/controllers/tree_controller.rb b/app/controllers/tree_controller.rb index 15bbb1a3..e0dd8f8b 100644 --- a/app/controllers/tree_controller.rb +++ b/app/controllers/tree_controller.rb @@ -15,35 +15,18 @@ class TreeController < ApplicationController before_filter :authorize_code_access! before_filter :require_non_empty_project - before_filter :define_tree_vars + before_filter :assign_ref_vars def show + @hex_path = Digest::SHA1.hexdigest(@path) + + @history_path = project_tree_path(@project, @id) + @logs_path = logs_file_project_ref_path(@project, @ref, @path) + respond_to do |format| format.html # Disable cache so browser history works format.js { no_cache_headers } end end - - private - - def define_tree_vars - @ref, @path = extract_ref(params[:id]) - - @id = File.join(@ref, @path) - @repo = @project.repo - @commit = CommitDecorator.decorate(@project.commit(@ref)) - - @tree = Tree.new(@commit.tree, @project, @ref, @path.gsub(/^\//, '')) - @tree = TreeDecorator.new(@tree) - - raise InvalidPathError if @tree.invalid? - - @hex_path = Digest::SHA1.hexdigest(@path) - - @history_path = project_tree_path(@project, @id) - @logs_path = logs_file_project_ref_path(@project, @ref, @path) - rescue NoMethodError, InvalidPathError - not_found! - end end diff --git a/app/views/tree/show.html.haml b/app/views/tree/show.html.haml index 181be642..d95f90e0 100644 --- a/app/views/tree/show.html.haml +++ b/app/views/tree/show.html.haml @@ -1,5 +1,5 @@ = render "head" -#tree-holder= render partial: "tree", locals: {repo: @repo, commit: @commit, tree: @tree} +#tree-holder= render partial: "tree", locals: {commit: @commit, tree: @tree} :javascript $(function() { diff --git a/app/views/tree/show.js.haml b/app/views/tree/show.js.haml index 3d0215ff..174e3e03 100644 --- a/app/views/tree/show.js.haml +++ b/app/views/tree/show.js.haml @@ -1,6 +1,6 @@ :plain // Load Files list - $("#tree-holder").html("#{escape_javascript(render(partial: "tree", locals: {repo: @repo, commit: @commit, tree: @tree}))}"); + $("#tree-holder").html("#{escape_javascript(render(partial: "tree", locals: {commit: @commit, tree: @tree}))}"); $("#tree-content-holder").show("slide", { direction: "right" }, 150); $('.project-refs-form #path').val("#{@path}"); diff --git a/lib/ref_extractor.rb b/lib/ref_extractor.rb index d7d446b1..b9c02917 100644 --- a/lib/ref_extractor.rb +++ b/lib/ref_extractor.rb @@ -67,4 +67,31 @@ module RefExtractor pair end + + # Assigns common instance variables for views working with Git tree-ish objects + # + # Assignments are: + # + # - @id - A string representing the joined ref and path + # - @ref - A string representing the ref (e.g., the branch, tag, or commit SHA) + # - @path - A string representing the filesystem path + # - @commit - A CommitDecorator representing the commit from the given ref + # - @tree - A TreeDecorator representing the tree at the given ref/path + # + # Automatically renders `not_found!` if a valid tree could not be resolved + # (e.g., when a user inserts an invalid path or ref). + def assign_ref_vars + @ref, @path = extract_ref(params[:id]) + + @id = File.join(@ref, @path) + + @commit = CommitDecorator.decorate(@project.commit(@ref)) + + @tree = Tree.new(@commit.tree, @project, @ref, @path) + @tree = TreeDecorator.new(@tree) + + raise InvalidPathError if @tree.invalid? + rescue NoMethodError, InvalidPathError + not_found! + end end From a8ea8d98a4f88a292289ddfedef4358033b68ec0 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 20 Sep 2012 13:25:28 -0400 Subject: [PATCH 047/288] Update RefExtractor to handle atom feeds --- app/controllers/tree_controller.rb | 3 --- lib/ref_extractor.rb | 8 +++++++- spec/routing/project_routing_spec.rb | 16 +++++----------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/app/controllers/tree_controller.rb b/app/controllers/tree_controller.rb index e0dd8f8b..43087664 100644 --- a/app/controllers/tree_controller.rb +++ b/app/controllers/tree_controller.rb @@ -1,8 +1,5 @@ # Controller for viewing a repository's file structure class TreeController < ApplicationController - # Thrown when given an invalid path - class InvalidPathError < StandardError; end - include RefExtractor layout "project" diff --git a/lib/ref_extractor.rb b/lib/ref_extractor.rb index b9c02917..1db74b95 100644 --- a/lib/ref_extractor.rb +++ b/lib/ref_extractor.rb @@ -1,7 +1,7 @@ # Module providing an extract_ref method for controllers working with Git # tree-ish + path params module RefExtractor - # Thrown when given an invalid path + # Raised when given an invalid path class InvalidPathError < StandardError; end # Given a string containing both a Git ref - such as a branch or tag - and a @@ -81,6 +81,12 @@ module RefExtractor # Automatically renders `not_found!` if a valid tree could not be resolved # (e.g., when a user inserts an invalid path or ref). def assign_ref_vars + # Handle formats embedded in the id + if params[:id].ends_with?('.atom') + params[:id].gsub!(/\.atom$/, '') + request.format = :atom + end + @ref, @path = extract_ref(params[:id]) @id = File.join(@ref, @path) diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 01bc303d..04164d5d 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -293,11 +293,7 @@ end # patch_project_commit GET /:project_id/commits/:id/patch(.:format) commits#patch # project_commits GET /:project_id/commits(.:format) commits#index # POST /:project_id/commits(.:format) commits#create -# new_project_commit GET /:project_id/commits/new(.:format) commits#new -# edit_project_commit GET /:project_id/commits/:id/edit(.:format) commits#edit # project_commit GET /:project_id/commits/:id(.:format) commits#show -# PUT /:project_id/commits/:id(.:format) commits#update -# DELETE /:project_id/commits/:id(.:format) commits#destroy describe CommitsController, "routing" do it "to #compare" do get("/gitlabhq/commits/compare").should route_to('commits#compare', project_id: 'gitlabhq') @@ -307,6 +303,10 @@ describe CommitsController, "routing" do get("/gitlabhq/commits/1/patch").should route_to('commits#patch', project_id: 'gitlabhq', id: '1') end + it "does something with atom feeds" do + get("/gitlabhq/commits/master.atom").should route_to('commits#show', project_id: 'gitlabhq', id: 'master.atom') + end + it_behaves_like "RESTful project resources" do let(:actions) { [:index, :show] } let(:controller) { 'commits' } @@ -425,6 +425,7 @@ end # /:project_id/commits/*path # /gitlabhq/commits/master/app/contexts/base_context.rb # /gitlabhq/commits/test/branch/name/app/contexts/base_context.rb +# /gitlabhq/commits/master.atom # # /:project_id/raw/*path # /gitlabhq/raw/master/app/contexts/base_context.rb @@ -436,13 +437,6 @@ end describe "pending routing" do before { pending } - describe "/:project_id/commit/:id" do - it "routes to a specific commit" do - get("/gitlabhq/commit/f4b1449").should route_to('commit#show', project_id: 'gitlabhq', id: 'f4b1449') - get("/gitlabhq/commit/f4b14494ef6abf3d144c28e4af0c20143383e062").should route_to('commit#show', project_id: 'gitlabhq', id: 'f4b14494ef6abf3d144c28e4af0c20143383e062') - end - end - describe "/:project_id/raw/:id" do it "routes to a ref with a path" do get("/gitlabhq/raw/master/app/models/project.rb").should route_to('raw#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') From a1e68a91205186287f21fb5fd1669acebcd7e79e Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 20 Sep 2012 13:55:14 -0400 Subject: [PATCH 048/288] Rename RefExtractor to ExtractsPath Update docs a bit --- app/controllers/blame_controller.rb | 3 +- app/controllers/blob_controller.rb | 5 +- app/controllers/tree_controller.rb | 2 +- lib/{ref_extractor.rb => extracts_path.rb} | 31 ++++++++---- spec/lib/extracts_path_spec.rb | 58 ++++++++++++++++++++++ spec/lib/ref_extractor_spec.rb | 4 +- 6 files changed, 84 insertions(+), 19 deletions(-) rename lib/{ref_extractor.rb => extracts_path.rb} (77%) create mode 100644 spec/lib/extracts_path_spec.rb diff --git a/app/controllers/blame_controller.rb b/app/controllers/blame_controller.rb index dd5be6dc..dd0837ea 100644 --- a/app/controllers/blame_controller.rb +++ b/app/controllers/blame_controller.rb @@ -1,7 +1,6 @@ # Controller for viewing a file's blame class BlameController < ApplicationController - - include RefExtractor + include ExtractsPath layout "project" diff --git a/app/controllers/blob_controller.rb b/app/controllers/blob_controller.rb index 58e70bc9..33387842 100644 --- a/app/controllers/blob_controller.rb +++ b/app/controllers/blob_controller.rb @@ -1,9 +1,6 @@ # Controller for viewing a file's blame class BlobController < ApplicationController - # Thrown when given an invalid path - class InvalidPathError < StandardError; end - - include RefExtractor + include ExtractsPath include Gitlab::Encode layout "project" diff --git a/app/controllers/tree_controller.rb b/app/controllers/tree_controller.rb index 43087664..e6313783 100644 --- a/app/controllers/tree_controller.rb +++ b/app/controllers/tree_controller.rb @@ -1,6 +1,6 @@ # Controller for viewing a repository's file structure class TreeController < ApplicationController - include RefExtractor + include ExtractsPath layout "project" diff --git a/lib/ref_extractor.rb b/lib/extracts_path.rb similarity index 77% rename from lib/ref_extractor.rb rename to lib/extracts_path.rb index 1db74b95..6648ffdc 100644 --- a/lib/ref_extractor.rb +++ b/lib/extracts_path.rb @@ -1,14 +1,22 @@ -# Module providing an extract_ref method for controllers working with Git -# tree-ish + path params -module RefExtractor - # Raised when given an invalid path +# Module providing methods for dealing with separating a tree-ish string and a +# file path string when combined in a request parameter +module ExtractsPath + extend ActiveSupport::Concern + + # Raised when given an invalid file path class InvalidPathError < StandardError; end - # Given a string containing both a Git ref - such as a branch or tag - and a - # filesystem path joined by forward slashes, attempts to separate the two. + included do + if respond_to?(:before_filter) + before_filter :assign_ref_vars + end + end + + # Given a string containing both a Git tree-ish, such as a branch or tag, and + # a filesystem path joined by forward slashes, attempts to separate the two. # - # Expects a @project instance variable to contain the active project. Used to - # check the input against a list of valid repository refs. + # Expects a @project instance variable to contain the active project. This is + # used to check the input against a list of valid repository refs. # # Examples # @@ -78,8 +86,11 @@ module RefExtractor # - @commit - A CommitDecorator representing the commit from the given ref # - @tree - A TreeDecorator representing the tree at the given ref/path # - # Automatically renders `not_found!` if a valid tree could not be resolved - # (e.g., when a user inserts an invalid path or ref). + # If the :id parameter appears to be requesting a specific response format, + # that will be handled as well. + # + # Automatically renders `not_found!` if a valid tree path could not be + # resolved (e.g., when a user inserts an invalid path or ref). def assign_ref_vars # Handle formats embedded in the id if params[:id].ends_with?('.atom') diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb new file mode 100644 index 00000000..8876373d --- /dev/null +++ b/spec/lib/extracts_path_spec.rb @@ -0,0 +1,58 @@ +require 'spec_helper' + +describe ExtractsPath do + include ExtractsPath + + let(:project) { double('project') } + + before do + @project = project + project.stub(:branches).and_return(['master', 'foo/bar/baz']) + project.stub(:tags).and_return(['v1.0.0', 'v2.0.0']) + end + + describe '#extract_ref' do + it "returns an empty pair when no @project is set" do + @project = nil + extract_ref('master/CHANGELOG').should == ['', ''] + end + + context "without a path" do + it "extracts a valid branch" do + extract_ref('master').should == ['master', ''] + end + + it "extracts a valid tag" do + extract_ref('v2.0.0').should == ['v2.0.0', ''] + end + + it "extracts a valid commit ref without a path" do + extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062').should == + ['f4b14494ef6abf3d144c28e4af0c20143383e062', ''] + end + + it "falls back to a primitive split for an invalid ref" do + extract_ref('stable').should == ['stable', ''] + end + end + + context "with a path" do + it "extracts a valid branch" do + extract_ref('foo/bar/baz/CHANGELOG').should == ['foo/bar/baz', 'CHANGELOG'] + end + + it "extracts a valid tag" do + extract_ref('v2.0.0/CHANGELOG').should == ['v2.0.0', 'CHANGELOG'] + end + + it "extracts a valid commit SHA" do + extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG').should == + ['f4b14494ef6abf3d144c28e4af0c20143383e062', 'CHANGELOG'] + end + + it "falls back to a primitive split for an invalid ref" do + extract_ref('stable/CHANGELOG').should == ['stable', 'CHANGELOG'] + end + end + end +end diff --git a/spec/lib/ref_extractor_spec.rb b/spec/lib/ref_extractor_spec.rb index 1e3d178f..8876373d 100644 --- a/spec/lib/ref_extractor_spec.rb +++ b/spec/lib/ref_extractor_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe RefExtractor do - include RefExtractor +describe ExtractsPath do + include ExtractsPath let(:project) { double('project') } From 5a5d214de499b678802ac12c5c6cbe583a85ae36 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 20 Sep 2012 14:43:38 -0400 Subject: [PATCH 049/288] Remove unused render_full_content filter --- app/controllers/application_controller.rb | 4 ---- app/controllers/commits_controller.rb | 1 - app/controllers/protected_branches_controller.rb | 1 - app/controllers/refs_controller.rb | 1 - app/controllers/repositories_controller.rb | 1 - app/controllers/snippets_controller.rb | 1 - 6 files changed, 9 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5ac5c639..a3eb3e3e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -126,10 +126,6 @@ class ApplicationController < ActionController::Base response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT" end - def render_full_content - @full_content = true - end - def dev_tools Rack::MiniProfiler.authorize_request end diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index 83404bdc..712b842c 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -10,7 +10,6 @@ class CommitsController < ApplicationController before_filter :authorize_code_access! before_filter :require_non_empty_project before_filter :load_refs, only: :index # load @branch, @tag & @ref - before_filter :render_full_content def index @repo = project.repo diff --git a/app/controllers/protected_branches_controller.rb b/app/controllers/protected_branches_controller.rb index 78c9c9ef..2556f095 100644 --- a/app/controllers/protected_branches_controller.rb +++ b/app/controllers/protected_branches_controller.rb @@ -7,7 +7,6 @@ class ProtectedBranchesController < ApplicationController before_filter :require_non_empty_project before_filter :authorize_admin_project!, only: [:destroy, :create] - before_filter :render_full_content layout "project" diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index f9cd4734..5e36be30 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -10,7 +10,6 @@ class RefsController < ApplicationController before_filter :ref before_filter :define_tree_vars, only: [:blob, :logs_tree] - before_filter :render_full_content layout "project" diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index cd20677e..583edf8e 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -6,7 +6,6 @@ class RepositoriesController < ApplicationController before_filter :authorize_read_project! before_filter :authorize_code_access! before_filter :require_non_empty_project - before_filter :render_full_content layout "project" diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index b00c9283..a38fd52f 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -55,7 +55,6 @@ class SnippetsController < ApplicationController def show @note = @project.notes.new(noteable: @snippet) - render_full_content end def destroy From 169f16fb32091701bcaa962872ea35b5772a1539 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 20 Sep 2012 15:20:48 -0400 Subject: [PATCH 050/288] Remove Commits#compare, add CompareController --- app/controllers/commits_controller.rb | 12 ---------- app/controllers/compare_controller.rb | 22 ++++++++++++++++++ app/views/compare/_head.html.haml | 23 +++++++++++++++++++ .../show.html.haml} | 0 config/routes.rb | 5 +--- spec/routing/project_routing_spec.rb | 12 ++++++---- 6 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 app/controllers/compare_controller.rb create mode 100644 app/views/compare/_head.html.haml rename app/views/{commits/compare.html.haml => compare/show.html.haml} (100%) diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index 712b842c..b508d287 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -45,18 +45,6 @@ class CommitsController < ApplicationController # end # end - def compare - result = Commit.compare(project, params[:from], params[:to]) - - @commits = result[:commits] - @commit = result[:commit] - @diffs = result[:diffs] - @refs_are_same = result[:same] - @line_notes = [] - - @commits = CommitDecorator.decorate(@commits) - end - def patch @commit = project.commit(params[:id]) diff --git a/app/controllers/compare_controller.rb b/app/controllers/compare_controller.rb new file mode 100644 index 00000000..1124fd0c --- /dev/null +++ b/app/controllers/compare_controller.rb @@ -0,0 +1,22 @@ +class CompareController < ApplicationController + before_filter :project + layout "project" + + # Authorize + before_filter :add_project_abilities + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project + + def show + result = Commit.compare(project, params[:from], params[:to]) + + @commits = result[:commits] + @commit = result[:commit] + @diffs = result[:diffs] + @refs_are_same = result[:same] + @line_notes = [] + + @commits = CommitDecorator.decorate(@commits) + end +end diff --git a/app/views/compare/_head.html.haml b/app/views/compare/_head.html.haml new file mode 100644 index 00000000..a8111a72 --- /dev/null +++ b/app/views/compare/_head.html.haml @@ -0,0 +1,23 @@ +%ul.nav.nav-tabs + %li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'} + %li{class: "#{'active' if current_page?(project_commits_path(@project)) }"} + = link_to project_commits_path(@project) do + Commits + %li{class: "#{'active' if current_page?(compare_project_commits_path(@project)) }"} + = link_to compare_project_commits_path(@project) do + Compare + %li{class: "#{branches_tab_class}"} + = link_to project_repository_path(@project) do + Branches + %span.badge= @project.repo.branch_count + + %li{class: "#{'active' if current_page?(tags_project_repository_path(@project)) }"} + = link_to tags_project_repository_path(@project) do + Tags + %span.badge= @project.repo.tag_count + + - if current_page?(project_commits_path(@project)) && current_user.private_token + %li.right + %span.rss-icon + = link_to project_commits_path(@project, :atom, { private_token: current_user.private_token, ref: @ref }), title: "Feed" do + = image_tag "rss_ui.png", title: "feed" diff --git a/app/views/commits/compare.html.haml b/app/views/compare/show.html.haml similarity index 100% rename from app/views/commits/compare.html.haml rename to app/views/compare/show.html.haml diff --git a/config/routes.rb b/config/routes.rb index af7b9bd4..708dd7d5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -162,10 +162,6 @@ Gitlab::Application.routes.draw do resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} resources :commits, only: [:index, :show] do - collection do - get :compare - end - member do get :patch end @@ -194,6 +190,7 @@ Gitlab::Application.routes.draw do resources :blob, only: [:show], constraints: {id: /.+/} # resources :raw, only: [:show], constraints: {id: /.+/} resources :tree, only: [:show], constraints: {id: /.+/} + match "/compare/:from...:to" => "compare#show", as: "compare", constraints: {from: /.+/, to: /.+/} end root to: "dashboard#index" diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 04164d5d..2939f2fc 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -289,16 +289,11 @@ describe CommitController, "routing" do end end -# compare_project_commits GET /:project_id/commits/compare(.:format) commits#compare # patch_project_commit GET /:project_id/commits/:id/patch(.:format) commits#patch # project_commits GET /:project_id/commits(.:format) commits#index # POST /:project_id/commits(.:format) commits#create # project_commit GET /:project_id/commits/:id(.:format) commits#show describe CommitsController, "routing" do - it "to #compare" do - get("/gitlabhq/commits/compare").should route_to('commits#compare', project_id: 'gitlabhq') - end - it "to #patch" do get("/gitlabhq/commits/1/patch").should route_to('commits#patch', project_id: 'gitlabhq', id: '1') end @@ -407,6 +402,13 @@ describe TreeController, "routing" do end end +describe CompareController, "routing" do + it "to #show" do + get("/gitlabhq/compare/master...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'master', to: 'stable') + get("/gitlabhq/compare/issue/1234...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'issue/1234', to: 'stable') + end +end + # TODO: Pending # # /:project_id/blame/*path From 3574826920eb958c5e59e86bb79b0773c187abfb Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 20 Sep 2012 15:32:00 -0400 Subject: [PATCH 051/288] Use Commits#show instead of Commits#index Takes tree-ish + path as ID --- app/controllers/commits_controller.rb | 36 +++---------------- .../{index.atom.builder => show.atom.builder} | 0 .../{index.html.haml => show.html.haml} | 0 .../commits/{index.js.haml => show.js.haml} | 0 app/views/layouts/_project_menu.html.haml | 2 +- config/routes.rb | 26 +++++++------- 6 files changed, 19 insertions(+), 45 deletions(-) rename app/views/commits/{index.atom.builder => show.atom.builder} (100%) rename app/views/commits/{index.html.haml => show.html.haml} (100%) rename app/views/commits/{index.js.haml => show.js.haml} (100%) diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index b508d287..ba6c6c24 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -4,18 +4,19 @@ class CommitsController < ApplicationController before_filter :project layout "project" + include ExtractsPath + # Authorize before_filter :add_project_abilities before_filter :authorize_read_project! before_filter :authorize_code_access! before_filter :require_non_empty_project - before_filter :load_refs, only: :index # load @branch, @tag & @ref - def index - @repo = project.repo + def show + @repo = @project.repo @limit, @offset = (params[:limit] || 40), (params[:offset] || 0) - @commits = @project.commits(@ref, params[:path], @limit, @offset) + @commits = @project.commits(@ref, @path, @limit, @offset) @commits = CommitDecorator.decorate(@commits) respond_to do |format| @@ -25,26 +26,6 @@ class CommitsController < ApplicationController end end - # def show - # result = CommitLoad.new(project, current_user, params).execute - - # @commit = result[:commit] - - # if @commit - # @suppress_diff = result[:suppress_diff] - # @note = result[:note] - # @line_notes = result[:line_notes] - # @notes_count = result[:notes_count] - # @comments_allowed = true - # else - # return git_not_found! - # end - - # if result[:status] == :huge_commit - # render "huge_commit" and return - # end - # end - def patch @commit = project.commit(params[:id]) @@ -55,11 +36,4 @@ class CommitsController < ApplicationController filename: "#{@commit.id}.patch" ) end - - protected - - def load_refs - @ref ||= params[:ref].presence || params[:branch].presence || params[:tag].presence - @ref ||= @ref || @project.try(:default_branch) || 'master' - end end diff --git a/app/views/commits/index.atom.builder b/app/views/commits/show.atom.builder similarity index 100% rename from app/views/commits/index.atom.builder rename to app/views/commits/show.atom.builder diff --git a/app/views/commits/index.html.haml b/app/views/commits/show.html.haml similarity index 100% rename from app/views/commits/index.html.haml rename to app/views/commits/show.html.haml diff --git a/app/views/commits/index.js.haml b/app/views/commits/show.js.haml similarity index 100% rename from app/views/commits/index.js.haml rename to app/views/commits/show.js.haml diff --git a/app/views/layouts/_project_menu.html.haml b/app/views/layouts/_project_menu.html.haml index 11e632b9..a46d59a3 100644 --- a/app/views/layouts/_project_menu.html.haml +++ b/app/views/layouts/_project_menu.html.haml @@ -8,7 +8,7 @@ = link_to project_tree_path(@project, @project.root_ref) do Files %li{class: commit_tab_class} - = link_to "Commits", project_commits_path(@project) + = link_to "Commits", project_history_path(@project, @project.root_ref) %li{class: tab_class(:network)} = link_to "Network", graph_project_path(@project) diff --git a/config/routes.rb b/config/routes.rb index 708dd7d5..01889bb2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -159,13 +159,20 @@ Gitlab::Application.routes.draw do end end - resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} + # XXX: WIP + resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} + resources :commits, only: [:show], constraints: {id: /.+/}, as: 'history' + resources :blame, only: [:show], constraints: {id: /.+/} + resources :blob, only: [:show], constraints: {id: /.+/} + # resources :raw, only: [:show], constraints: {id: /.+/} + resources :tree, only: [:show], constraints: {id: /.+/} + match "/compare/:from...:to" => "compare#show", as: "compare", constraints: {from: /.+/, to: /.+/} - resources :commits, only: [:index, :show] do - member do - get :patch - end - end + # resources :commits, only: [:show], as: 'history' do + # member do + # get :patch + # end + # end resources :team, controller: 'team_members', only: [:index] resources :team_members @@ -184,13 +191,6 @@ Gitlab::Application.routes.draw do post :preview end end - - # XXX: WIP - resources :blame, only: [:show], constraints: {id: /.+/} - resources :blob, only: [:show], constraints: {id: /.+/} - # resources :raw, only: [:show], constraints: {id: /.+/} - resources :tree, only: [:show], constraints: {id: /.+/} - match "/compare/:from...:to" => "compare#show", as: "compare", constraints: {from: /.+/, to: /.+/} end root to: "dashboard#index" From 835be5b1bf25fc0509ef1b1f7f7f2e3a344ff231 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 18:20:52 -0400 Subject: [PATCH 052/288] ExtractPaths - Only call assign_ref_vars on show action --- lib/extracts_path.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb index 6648ffdc..f36dae52 100644 --- a/lib/extracts_path.rb +++ b/lib/extracts_path.rb @@ -8,7 +8,7 @@ module ExtractsPath included do if respond_to?(:before_filter) - before_filter :assign_ref_vars + before_filter :assign_ref_vars, only: [:show] end end From f1c6bd8df3225d33af4d3d032cc98be86317b348 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 18:21:04 -0400 Subject: [PATCH 053/288] Factories - Format project path and code --- spec/factories.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/factories.rb b/spec/factories.rb index 92790a3f..e11e6d07 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -42,8 +42,8 @@ FactoryGirl.define do factory :project do sequence(:name) { |n| "project#{n}" } - path { name } - code { name } + path { name.downcase.gsub(/\s/, '_') } + code { name.downcase.gsub(/\s/, '_') } owner end From 9d394250a8055f31d81e5538cb77f19ea6d0d79b Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 18:45:13 -0400 Subject: [PATCH 054/288] Add an inflector to mark "commits" as uncountable --- config/initializers/inflections.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 9e8b0131..5d46ece1 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -8,3 +8,24 @@ # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end + +# Mark "commits" as uncountable. +# +# Without this change, the routes +# +# resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} +# resources :commits, only: [:show], constraints: {id: /.+/} +# +# would generate identical route helper methods (`project_commit_path`), resulting +# in one of them not getting a helper method at all. +# +# After this change, the helper methods are: +# +# project_commit_path(@project, @project.commit) +# # => "/gitlabhq/commit/bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a +# +# project_commits_path(@project, 'stable/README.md') +# # => "/gitlabhq/commits/stable/README.md" +ActiveSupport::Inflector.inflections do |inflect| + inflect.uncountable %w(commits) +end From c058e3903e01b950d19fe8ce86702f24083c8395 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 18:45:30 -0400 Subject: [PATCH 055/288] Finalize new routes --- config/routes.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 01889bb2..bc29314e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -161,31 +161,25 @@ Gitlab::Application.routes.draw do # XXX: WIP resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} - resources :commits, only: [:show], constraints: {id: /.+/}, as: 'history' + resources :commits, only: [:show], constraints: {id: /.+/} + resources :compare, only: [:index] resources :blame, only: [:show], constraints: {id: /.+/} resources :blob, only: [:show], constraints: {id: /.+/} - # resources :raw, only: [:show], constraints: {id: /.+/} - resources :tree, only: [:show], constraints: {id: /.+/} + resources :tree, only: [:show], constraints: {id: /.+/} match "/compare/:from...:to" => "compare#show", as: "compare", constraints: {from: /.+/, to: /.+/} - # resources :commits, only: [:show], as: 'history' do - # member do - # get :patch - # end - # end - resources :team, controller: 'team_members', only: [:index] resources :team_members resources :milestones resources :labels, only: [:index] resources :issues do - collection do post :sort post :bulk_update get :search end end + resources :notes, only: [:index, :create, :destroy] do collection do post :preview From 99d391332fa9a6c11e93bd19295425167661b972 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 18:46:19 -0400 Subject: [PATCH 056/288] Add a "patch" MIME type, and render it like a normal view in Commit#show --- app/controllers/commit_controller.rb | 25 ++++++++++++++----------- app/controllers/commits_controller.rb | 11 ----------- app/views/commit/show.patch.erb | 1 + config/initializers/mime_types.rb | 2 ++ 4 files changed, 17 insertions(+), 22 deletions(-) create mode 100644 app/views/commit/show.patch.erb diff --git a/app/controllers/commit_controller.rb b/app/controllers/commit_controller.rb index 73a55614..de0d5b2e 100644 --- a/app/controllers/commit_controller.rb +++ b/app/controllers/commit_controller.rb @@ -15,19 +15,22 @@ class CommitController < ApplicationController result = CommitLoad.new(project, current_user, params).execute @commit = result[:commit] + git_not_found! unless @commit - if @commit - @suppress_diff = result[:suppress_diff] - @note = result[:note] - @line_notes = result[:line_notes] - @notes_count = result[:notes_count] - @comments_allowed = true - else - return git_not_found! - end + @suppress_diff = result[:suppress_diff] + @note = result[:note] + @line_notes = result[:line_notes] + @notes_count = result[:notes_count] + @comments_allowed = true - if result[:status] == :huge_commit - render "huge_commit" and return + respond_to do |format| + format.html do + if result[:status] == :huge_commit + render "huge_commit" and return + end + end + + format.patch end end end diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index ba6c6c24..bd67ee88 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -25,15 +25,4 @@ class CommitsController < ApplicationController format.atom { render layout: false } end end - - def patch - @commit = project.commit(params[:id]) - - send_data( - @commit.to_patch, - type: "text/plain", - disposition: 'attachment', - filename: "#{@commit.id}.patch" - ) - end end diff --git a/app/views/commit/show.patch.erb b/app/views/commit/show.patch.erb new file mode 100644 index 00000000..ce1c3d02 --- /dev/null +++ b/app/views/commit/show.patch.erb @@ -0,0 +1 @@ +<%= @commit.to_patch %> diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 72aca7e4..3549b836 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -3,3 +3,5 @@ # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone + +Mime::Type.register_alias 'text/plain', :patch From 1048917232992671b0a01f4c87ed00edfff633e8 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 18:50:02 -0400 Subject: [PATCH 057/288] Update usages of project_commit[s] route helpers --- app/controllers/refs_controller.rb | 2 +- app/decorators/event_decorator.rb | 2 +- app/decorators/tree_decorator.rb | 2 +- app/views/commits/_commit_box.html.haml | 2 +- app/views/commits/_diffs.html.haml | 2 +- app/views/layouts/_head.html.haml | 4 ++-- app/views/layouts/_project_menu.html.haml | 2 +- features/steps/shared/paths.rb | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index 5e36be30..b260be0a 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -19,7 +19,7 @@ class RefsController < ApplicationController new_path = if params[:destination] == "tree" project_tree_path(@project, @ref) else - project_commits_path(@project, ref: @ref) + project_commits_path(@project, @ref) end redirect_to new_path diff --git a/app/decorators/event_decorator.rb b/app/decorators/event_decorator.rb index ce0aaa03..312ac651 100644 --- a/app/decorators/event_decorator.rb +++ b/app/decorators/event_decorator.rb @@ -21,7 +21,7 @@ class EventDecorator < ApplicationDecorator elsif self.merge_request? h.project_merge_request_url(self.project, self.merge_request) elsif self.push? - h.project_commits_url(self.project, ref: self.ref_name) + h.project_commits_url(self.project, self.ref_name) end end end diff --git a/app/decorators/tree_decorator.rb b/app/decorators/tree_decorator.rb index 05f029d0..97981785 100644 --- a/app/decorators/tree_decorator.rb +++ b/app/decorators/tree_decorator.rb @@ -30,7 +30,7 @@ class TreeDecorator < ApplicationDecorator end def history_path - h.project_commits_path(project, path: path, ref: ref) + h.project_commits_path(project, h.tree_join(ref, path)) end def mb_size diff --git a/app/views/commits/_commit_box.html.haml b/app/views/commits/_commit_box.html.haml index 3daf63f4..b8151b56 100644 --- a/app/views/commits/_commit_box.html.haml +++ b/app/views/commits/_commit_box.html.haml @@ -5,7 +5,7 @@ %span.btn.disabled.grouped %i.icon-comment = @notes_count - = link_to patch_project_commit_path(@project, @commit.id), class: "btn small grouped" do + = link_to project_commit_path(@project, @commit, format: :patch), class: "btn small grouped" do %i.icon-download-alt Get Patch = link_to project_tree_path(@project, @commit), class: "browse-button primary grouped" do diff --git a/app/views/commits/_diffs.html.haml b/app/views/commits/_diffs.html.haml index 301cd554..026fe27e 100644 --- a/app/views/commits/_diffs.html.haml +++ b/app/views/commits/_diffs.html.haml @@ -5,7 +5,7 @@ %p To prevent performance issue we rejected diff information. %p But if you still want to see diff - = link_to "click this link", project_commit_path(@project, @commit.id, force_show_diff: true), class: "dark" + = link_to "click this link", project_commit_path(@project, @commit, force_show_diff: true), class: "dark" %p.cgray Showing #{pluralize(diffs.count, "changed file")} diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 06da82d3..1674be27 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -10,8 +10,8 @@ - if controller_name == 'projects' && action_name == 'index' = auto_discovery_link_tag :atom, projects_url(:atom, private_token: current_user.private_token), title: "Dashboard feed" - if @project && !@project.new_record? - - if current_page?(project_tree_path(@project, @project.root_ref)) || current_page?(project_commits_path(@project)) - = auto_discovery_link_tag(:atom, project_commits_url(@project, :atom, ref: @ref, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}") + - if current_page?(project_tree_path(@project, @ref)) || current_page?(project_commits_path(@project, @ref)) + = auto_discovery_link_tag(:atom, project_commits_url(@project, @ref, format: :atom, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}") - if request.path == project_issues_path(@project) = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues") = csrf_meta_tags diff --git a/app/views/layouts/_project_menu.html.haml b/app/views/layouts/_project_menu.html.haml index a46d59a3..13a4d037 100644 --- a/app/views/layouts/_project_menu.html.haml +++ b/app/views/layouts/_project_menu.html.haml @@ -8,7 +8,7 @@ = link_to project_tree_path(@project, @project.root_ref) do Files %li{class: commit_tab_class} - = link_to "Commits", project_history_path(@project, @project.root_ref) + = link_to "Commits", project_commits_path(@project, @project.root_ref) %li{class: tab_class(:network)} = link_to "Network", graph_project_path(@project) diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 1839bc81..e1e1a718 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -47,7 +47,7 @@ module SharedPaths end Given 'I visit project commits page' do - visit project_commits_path(@project) + visit project_commits_path(@project, @project.root_ref) end Given 'I visit project source page' do From 33126227af662a454538d5a64762d19165f3c65d Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 19:16:46 -0400 Subject: [PATCH 058/288] Remove check_token_auth filter Because of the way ExtractPaths works, `params[:format]` wouldn't necessarily be available at the time this filter was running, and so it would erroneously redirect to `new_user_session_path` --- app/controllers/application_controller.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a3eb3e3e..f5d978a7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,7 +2,6 @@ class ApplicationController < ActionController::Base before_filter :authenticate_user! before_filter :reject_blocked! before_filter :set_current_user_for_mailer - before_filter :check_token_auth before_filter :set_current_user_for_observers before_filter :dev_tools if Rails.env == 'development' @@ -26,13 +25,6 @@ class ApplicationController < ActionController::Base protected - def check_token_auth - # Redirect to login page if not atom feed - if params[:private_token].present? && params[:format] != 'atom' - redirect_to new_user_session_path - end - end - def reject_blocked! if current_user && current_user.blocked sign_out current_user From 95f0a4114139d49b3979d6f0e53baa53193a624a Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 19:17:54 -0400 Subject: [PATCH 059/288] Fix Refs#switch --- app/controllers/refs_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index b260be0a..ff143f3f 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -13,9 +13,9 @@ class RefsController < ApplicationController layout "project" - def switch - respond_to do |format| - format.html do + def switch + respond_to do |format| + format.html do new_path = if params[:destination] == "tree" project_tree_path(@project, @ref) else @@ -69,6 +69,6 @@ class RefsController < ApplicationController end def ref - @ref = params[:id] + @ref = params[:ref] end end From 3ad931ca9211d2ca0f345f97db00193ee5533dfd Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 19:22:44 -0400 Subject: [PATCH 060/288] Add current_controller? helper method Simplifies some of the "active tab" checks we're doing --- app/helpers/application_helper.rb | 11 +++++++++++ spec/helpers/application_helper_spec.rb | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d90fb32f..505f6067 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,6 +1,17 @@ require 'digest/md5' module ApplicationHelper + # Check if a particular controller is the current one + # + # Examples + # + # # On TreeController + # current_controller?(:tree) # => true + # current_controller?(:commits) # => false + def current_controller?(name) + controller.controller_name == name.to_s.downcase + end + def gravatar_icon(user_email = '', size = 40) if Gitlab.config.disable_gravatar? || user_email.blank? 'no_avatar.png' diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 9a2df314..10250c93 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,6 +1,20 @@ require 'spec_helper' describe ApplicationHelper do + describe 'current_controller?' do + before do + controller.stub!(:controller_name).and_return('foo') + end + + it "returns true when controller matches argument" do + current_controller?(:foo).should be_true + end + + it "returns false when controller does not match argument" do + current_controller?(:bar).should_not be_true + end + end + describe "gravatar_icon" do let(:user_email) { 'user@email.com' } From 545dc7e47d627a5ba4b4219880801f26fbb77f4d Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 19:25:14 -0400 Subject: [PATCH 061/288] Fix atom feed links --- app/views/commits/_head.html.haml | 2 +- app/views/commits/show.atom.builder | 4 ++-- app/views/compare/_head.html.haml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/commits/_head.html.haml b/app/views/commits/_head.html.haml index a8111a72..cdee391f 100644 --- a/app/views/commits/_head.html.haml +++ b/app/views/commits/_head.html.haml @@ -19,5 +19,5 @@ - if current_page?(project_commits_path(@project)) && current_user.private_token %li.right %span.rss-icon - = link_to project_commits_path(@project, :atom, { private_token: current_user.private_token, ref: @ref }), title: "Feed" do + = link_to project_commits_path(@project, @ref, {format: :atom, private_token: current_user.private_token}), title: "Feed" do = image_tag "rss_ui.png", title: "feed" diff --git a/app/views/commits/show.atom.builder b/app/views/commits/show.atom.builder index cca70456..46f9838e 100644 --- a/app/views/commits/show.atom.builder +++ b/app/views/commits/show.atom.builder @@ -1,8 +1,8 @@ xml.instruct! xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do xml.title "Recent commits to #{@project.name}:#{@ref}" - xml.link :href => project_commits_url(@project, :atom, :ref => @ref), :rel => "self", :type => "application/atom+xml" - xml.link :href => project_commits_url(@project), :rel => "alternate", :type => "text/html" + xml.link :href => project_commits_url(@project, @ref, format: :atom), :rel => "self", :type => "application/atom+xml" + xml.link :href => project_commits_url(@project, @ref), :rel => "alternate", :type => "text/html" xml.id project_commits_url(@project) xml.updated @commits.first.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") if @commits.any? diff --git a/app/views/compare/_head.html.haml b/app/views/compare/_head.html.haml index a8111a72..cdee391f 100644 --- a/app/views/compare/_head.html.haml +++ b/app/views/compare/_head.html.haml @@ -19,5 +19,5 @@ - if current_page?(project_commits_path(@project)) && current_user.private_token %li.right %span.rss-icon - = link_to project_commits_path(@project, :atom, { private_token: current_user.private_token, ref: @ref }), title: "Feed" do + = link_to project_commits_path(@project, @ref, {format: :atom, private_token: current_user.private_token}), title: "Feed" do = image_tag "rss_ui.png", title: "feed" From f814da38bf3d86b8ff045ff585c75af4d6755184 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 20:01:51 -0400 Subject: [PATCH 062/288] Limit commit history to 5 in Spinach Speeds things up a bit --- features/steps/shared/paths.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index e1e1a718..fc23a798 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -47,7 +47,11 @@ module SharedPaths end Given 'I visit project commits page' do - visit project_commits_path(@project, @project.root_ref) + visit project_commits_path(@project, @project.root_ref, {limit: 5}) + end + + Given 'I visit project commits page for stable branch' do + visit project_commits_path(@project, 'stable', {limit: 5}) end Given 'I visit project source page' do From cada511f8b88671bb8a99600ed314c3beb5a36f4 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 20:11:57 -0400 Subject: [PATCH 063/288] Add features for checking the "Active Tab" across various pages --- features/admin/active_tab.feature | 33 ++++ features/dashboard/active_tab.feature | 28 ++++ features/profile/active_tab.feature | 28 ++++ features/project/active_tab.feature | 147 ++++++++++++++++++ features/steps/admin/admin_active_tab.rb | 29 ++++ .../steps/dashboard/dashboard_active_tab.rb | 25 +++ features/steps/profile/profile_active_tab.rb | 25 +++ features/steps/project/project_active_tab.rb | 146 +++++++++++++++++ features/steps/shared/active_tab.rb | 11 ++ features/steps/shared/authentication.rb | 4 + features/steps/shared/paths.rb | 70 +++++++-- 11 files changed, 537 insertions(+), 9 deletions(-) create mode 100644 features/admin/active_tab.feature create mode 100644 features/dashboard/active_tab.feature create mode 100644 features/profile/active_tab.feature create mode 100644 features/project/active_tab.feature create mode 100644 features/steps/admin/admin_active_tab.rb create mode 100644 features/steps/dashboard/dashboard_active_tab.rb create mode 100644 features/steps/profile/profile_active_tab.rb create mode 100644 features/steps/project/project_active_tab.rb create mode 100644 features/steps/shared/active_tab.rb diff --git a/features/admin/active_tab.feature b/features/admin/active_tab.feature new file mode 100644 index 00000000..fce85ce9 --- /dev/null +++ b/features/admin/active_tab.feature @@ -0,0 +1,33 @@ +Feature: Admin active tab + Background: + Given I sign in as an admin + + Scenario: On Admin Home + Given I visit admin page + Then the active main tab should be Home + And no other main tabs should be active + + Scenario: On Admin Projects + Given I visit admin projects page + Then the active main tab should be Projects + And no other main tabs should be active + + Scenario: On Admin Users + Given I visit admin users page + Then the active main tab should be Users + And no other main tabs should be active + + Scenario: On Admin Logs + Given I visit admin logs page + Then the active main tab should be Logs + And no other main tabs should be active + + Scenario: On Admin Hooks + Given I visit admin hooks page + Then the active main tab should be Hooks + And no other main tabs should be active + + Scenario: On Admin Resque + Given I visit admin Resque page + Then the active main tab should be Resque + And no other main tabs should be active diff --git a/features/dashboard/active_tab.feature b/features/dashboard/active_tab.feature new file mode 100644 index 00000000..6715ea26 --- /dev/null +++ b/features/dashboard/active_tab.feature @@ -0,0 +1,28 @@ +Feature: Dashboard active tab + Background: + Given I sign in as a user + + Scenario: On Dashboard Home + Given I visit dashboard page + Then the active main tab should be Home + And no other main tabs should be active + + Scenario: On Dashboard Issues + Given I visit dashboard issues page + Then the active main tab should be Issues + And no other main tabs should be active + + Scenario: On Dashboard Merge Requests + Given I visit dashboard merge requests page + Then the active main tab should be Merge Requests + And no other main tabs should be active + + Scenario: On Dashboard Search + Given I visit dashboard search page + Then the active main tab should be Search + And no other main tabs should be active + + Scenario: On Dashboard Help + Given I visit dashboard help page + Then the active main tab should be Help + And no other main tabs should be active diff --git a/features/profile/active_tab.feature b/features/profile/active_tab.feature new file mode 100644 index 00000000..475641a3 --- /dev/null +++ b/features/profile/active_tab.feature @@ -0,0 +1,28 @@ +Feature: Profile active tab + Background: + Given I sign in as a user + + Scenario: On Profile Home + Given I visit profile page + Then the active main tab should be Home + And no other main tabs should be active + + Scenario: On Profile Account + Given I visit profile account page + Then the active main tab should be Account + And no other main tabs should be active + + Scenario: On Profile SSH Keys + Given I visit profile SSH keys page + Then the active main tab should be SSH Keys + And no other main tabs should be active + + Scenario: On Profile Design + Given I visit profile design page + Then the active main tab should be Design + And no other main tabs should be active + + Scenario: On Profile History + Given I visit profile history page + Then the active main tab should be History + And no other main tabs should be active diff --git a/features/project/active_tab.feature b/features/project/active_tab.feature new file mode 100644 index 00000000..2d3e41d3 --- /dev/null +++ b/features/project/active_tab.feature @@ -0,0 +1,147 @@ +Feature: Project active tab + Background: + Given I sign in as a user + And I own a project + + # Main Tabs + + Scenario: On Project Home + Given I visit my project's home page + Then the active main tab should be Home + And no other main tabs should be active + + Scenario: On Project Files + Given I visit my project's files page + Then the active main tab should be Files + And no other main tabs should be active + + Scenario: On Project Commits + Given I visit my project's commits page + Then the active main tab should be Commits + And no other main tabs should be active + + Scenario: On Project Network + Given I visit my project's network page + Then the active main tab should be Network + And no other main tabs should be active + + Scenario: On Project Issues + Given I visit my project's issues page + Then the active main tab should be Issues + And no other main tabs should be active + + Scenario: On Project Merge Requests + Given I visit my project's merge requests page + Then the active main tab should be Merge Requests + And no other main tabs should be active + + Scenario: On Project Wall + Given I visit my project's wall page + Then the active main tab should be Wall + And no other main tabs should be active + + Scenario: On Project Wiki + Given I visit my project's wiki page + Then the active main tab should be Wiki + And no other main tabs should be active + + # Sub Tabs: Home + + Scenario: On Project Home/Show + Given I visit my project's home page + Then the active sub tab should be Show + And no other sub tabs should be active + And the active main tab should be Home + + Scenario: On Project Home/Team + Given I visit my project's home page + And I click the "Team" tab + Then the active sub tab should be Team + And no other sub tabs should be active + And the active main tab should be Home + + Scenario: On Project Home/Attachments + Given I visit my project's home page + And I click the "Attachments" tab + Then the active sub tab should be Attachments + And no other sub tabs should be active + And the active main tab should be Home + + Scenario: On Project Home/Snippets + Given I visit my project's home page + And I click the "Snippets" tab + Then the active sub tab should be Snippets + And no other sub tabs should be active + And the active main tab should be Home + + Scenario: On Project Home/Edit + Given I visit my project's home page + And I click the "Edit" tab + Then the active sub tab should be Edit + And no other sub tabs should be active + And the active main tab should be Home + + Scenario: On Project Home/Hooks + Given I visit my project's home page + And I click the "Hooks" tab + Then the active sub tab should be Hooks + And no other sub tabs should be active + And the active main tab should be Home + + Scenario: On Project Home/Deploy Keys + Given I visit my project's home page + And I click the "Deploy Keys" tab + Then the active sub tab should be Deploy Keys + And no other sub tabs should be active + And the active main tab should be Home + + # Sub Tabs: Commits + + Scenario: On Project Commits/Commits + Given I visit my project's commits page + Then the active sub tab should be Commits + And no other sub tabs should be active + And the active main tab should be Commits + + Scenario: On Project Commits/Compare + Given I visit my project's commits page + And I click the "Compare" tab + Then the active sub tab should be Compare + And no other sub tabs should be active + And the active main tab should be Commits + + Scenario: On Project Commits/Branches + Given I visit my project's commits page + And I click the "Branches" tab + Then the active sub tab should be Branches + And no other sub tabs should be active + And the active main tab should be Commits + + Scenario: On Project Commits/Tags + Given I visit my project's commits page + And I click the "Tags" tab + Then the active sub tab should be Tags + And no other sub tabs should be active + And the active main tab should be Commits + + # Sub Tabs: Issues + + Scenario: On Project Issues/Browse + Given I visit my project's issues page + Then the active sub tab should be Browse Issues + And no other sub tabs should be active + And the active main tab should be Issues + + Scenario: On Project Issues/Milestones + Given I visit my project's issues page + And I click the "Milestones" tab + Then the active sub tab should be Milestones + And no other sub tabs should be active + And the active main tab should be Issues + + Scenario: On Project Issues/Labels + Given I visit my project's issues page + And I click the "Labels" tab + Then the active sub tab should be Labels + And no other sub tabs should be active + And the active main tab should be Issues diff --git a/features/steps/admin/admin_active_tab.rb b/features/steps/admin/admin_active_tab.rb new file mode 100644 index 00000000..29290892 --- /dev/null +++ b/features/steps/admin/admin_active_tab.rb @@ -0,0 +1,29 @@ +class AdminActiveTab < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedActiveTab + + Then 'the active main tab should be Home' do + ensure_active_main_tab('Stats') + end + + Then 'the active main tab should be Projects' do + ensure_active_main_tab('Projects') + end + + Then 'the active main tab should be Users' do + ensure_active_main_tab('Users') + end + + Then 'the active main tab should be Logs' do + ensure_active_main_tab('Logs') + end + + Then 'the active main tab should be Hooks' do + ensure_active_main_tab('Hooks') + end + + Then 'the active main tab should be Resque' do + ensure_active_main_tab('Resque') + end +end diff --git a/features/steps/dashboard/dashboard_active_tab.rb b/features/steps/dashboard/dashboard_active_tab.rb new file mode 100644 index 00000000..41ecc48c --- /dev/null +++ b/features/steps/dashboard/dashboard_active_tab.rb @@ -0,0 +1,25 @@ +class DashboardActiveTab < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedActiveTab + + Then 'the active main tab should be Home' do + ensure_active_main_tab('Home') + end + + Then 'the active main tab should be Issues' do + ensure_active_main_tab('Issues') + end + + Then 'the active main tab should be Merge Requests' do + ensure_active_main_tab('Merge Requests') + end + + Then 'the active main tab should be Search' do + ensure_active_main_tab('Search') + end + + Then 'the active main tab should be Help' do + ensure_active_main_tab('Help') + end +end diff --git a/features/steps/profile/profile_active_tab.rb b/features/steps/profile/profile_active_tab.rb new file mode 100644 index 00000000..1924a6fa --- /dev/null +++ b/features/steps/profile/profile_active_tab.rb @@ -0,0 +1,25 @@ +class ProfileActiveTab < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedActiveTab + + Then 'the active main tab should be Home' do + ensure_active_main_tab('Profile') + end + + Then 'the active main tab should be Account' do + ensure_active_main_tab('Account') + end + + Then 'the active main tab should be SSH Keys' do + ensure_active_main_tab('SSH Keys') + end + + Then 'the active main tab should be Design' do + ensure_active_main_tab('Design') + end + + Then 'the active main tab should be History' do + ensure_active_main_tab('History') + end +end diff --git a/features/steps/project/project_active_tab.rb b/features/steps/project/project_active_tab.rb new file mode 100644 index 00000000..a5c80353 --- /dev/null +++ b/features/steps/project/project_active_tab.rb @@ -0,0 +1,146 @@ +class ProjectActiveTab < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedProject + include SharedActiveTab + + # Main Tabs + + Then 'the active main tab should be Home' do + ensure_active_main_tab(@project.name) + end + + Then 'the active main tab should be Files' do + ensure_active_main_tab('Files') + end + + Then 'the active main tab should be Commits' do + ensure_active_main_tab('Commits') + end + + Then 'the active main tab should be Network' do + ensure_active_main_tab('Network') + end + + Then 'the active main tab should be Issues' do + ensure_active_main_tab('Issues') + end + + Then 'the active main tab should be Merge Requests' do + ensure_active_main_tab('Merge Requests') + end + + Then 'the active main tab should be Wall' do + ensure_active_main_tab('Wall') + end + + Then 'the active main tab should be Wiki' do + ensure_active_main_tab('Wiki') + end + + # Sub Tabs: Home + + Given 'I click the "Team" tab' do + click_link('Team') + end + + Given 'I click the "Attachments" tab' do + click_link('Attachments') + end + + Given 'I click the "Snippets" tab' do + click_link('Snippets') + end + + Given 'I click the "Edit" tab' do + click_link('Edit') + end + + Given 'I click the "Hooks" tab' do + click_link('Hooks') + end + + Given 'I click the "Deploy Keys" tab' do + click_link('Deploy Keys') + end + + Then 'the active sub tab should be Show' do + ensure_active_sub_tab('Show') + end + + Then 'the active sub tab should be Team' do + ensure_active_sub_tab('Team') + end + + Then 'the active sub tab should be Attachments' do + ensure_active_sub_tab('Attachments') + end + + Then 'the active sub tab should be Snippets' do + ensure_active_sub_tab('Snippets') + end + + Then 'the active sub tab should be Edit' do + ensure_active_sub_tab('Edit') + end + + Then 'the active sub tab should be Hooks' do + ensure_active_sub_tab('Hooks') + end + + Then 'the active sub tab should be Deploy Keys' do + ensure_active_sub_tab('Deploy Keys') + end + + # Sub Tabs: Commits + + Given 'I click the "Compare" tab' do + click_link('Compare') + end + + Given 'I click the "Branches" tab' do + click_link('Branches') + end + + Given 'I click the "Tags" tab' do + click_link('Tags') + end + + Then 'the active sub tab should be Commits' do + ensure_active_sub_tab('Commits') + end + + Then 'the active sub tab should be Compare' do + ensure_active_sub_tab('Compare') + end + + Then 'the active sub tab should be Branches' do + ensure_active_sub_tab('Branches') + end + + Then 'the active sub tab should be Tags' do + ensure_active_sub_tab('Tags') + end + + # Sub Tabs: Issues + + Given 'I click the "Milestones" tab' do + click_link('Milestones') + end + + Given 'I click the "Labels" tab' do + click_link('Labels') + end + + Then 'the active sub tab should be Browse Issues' do + ensure_active_sub_tab('Browse Issues') + end + + Then 'the active sub tab should be Milestones' do + ensure_active_sub_tab('Milestones') + end + + Then 'the active sub tab should be Labels' do + ensure_active_sub_tab('Labels') + end +end diff --git a/features/steps/shared/active_tab.rb b/features/steps/shared/active_tab.rb new file mode 100644 index 00000000..33ac5cf5 --- /dev/null +++ b/features/steps/shared/active_tab.rb @@ -0,0 +1,11 @@ +module SharedActiveTab + include Spinach::DSL + + def ensure_active_main_tab(content) + page.find('ul.main_menu li.current').should have_content(content) + end + + And 'no other main tabs should be active' do + page.should have_selector('ul.main_menu li.current', count: 1) + end +end diff --git a/features/steps/shared/authentication.rb b/features/steps/shared/authentication.rb index 77d9839f..2add9161 100644 --- a/features/steps/shared/authentication.rb +++ b/features/steps/shared/authentication.rb @@ -7,4 +7,8 @@ module SharedAuthentication Given 'I sign in as a user' do login_as :user end + + Given 'I sign in as an admin' do + login_as :admin + end end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index fc23a798..bb35b8b0 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -1,22 +1,34 @@ module SharedPaths include Spinach::DSL - And 'I visit dashboard search page' do - visit search_path + # ---------------------------------------- + # Dashboard + # ---------------------------------------- + + Given 'I visit dashboard page' do + visit dashboard_path end - And 'I visit dashboard merge requests page' do - visit dashboard_merge_requests_path - end - - And 'I visit dashboard issues page' do + Given 'I visit dashboard issues page' do visit dashboard_issues_path end - When 'I visit dashboard page' do - visit dashboard_path + Given 'I visit dashboard merge requests page' do + visit dashboard_merge_requests_path end + Given 'I visit dashboard search page' do + visit search_path + end + + Given 'I visit dashboard help page' do + visit help_path + end + + # ---------------------------------------- + # Profile + # ---------------------------------------- + Given 'I visit profile page' do visit profile_path end @@ -25,10 +37,50 @@ module SharedPaths visit profile_account_path end + Given 'I visit profile SSH keys page' do + visit keys_path + end + + Given 'I visit profile design page' do + visit profile_design_path + end + + Given 'I visit profile history page' do + visit profile_history_path + end + Given 'I visit profile token page' do visit profile_token_path end + # ---------------------------------------- + # Admin + # ---------------------------------------- + + Given 'I visit admin page' do + visit admin_root_path + end + + Given 'I visit admin projects page' do + visit admin_projects_path + end + + Given 'I visit admin users page' do + visit admin_users_path + end + + Given 'I visit admin logs page' do + visit admin_logs_path + end + + Given 'I visit admin hooks page' do + visit admin_hooks_path + end + + Given 'I visit admin Resque page' do + visit admin_resque_path + end + When 'I visit new project page' do visit new_project_path end From 60ac6a28a2f198427c2d1ad68421aee484e14028 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 21:18:00 -0400 Subject: [PATCH 064/288] Allow current_controller? helper to take an Array of options --- app/helpers/application_helper.rb | 11 +++++++---- spec/helpers/application_helper_spec.rb | 5 +++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 505f6067..d916d887 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,13 +3,16 @@ module ApplicationHelper # Check if a particular controller is the current one # + # args - One or more controller names to check + # # Examples # # # On TreeController - # current_controller?(:tree) # => true - # current_controller?(:commits) # => false - def current_controller?(name) - controller.controller_name == name.to_s.downcase + # current_controller?(:tree) # => true + # current_controller?(:commits) # => false + # current_controller?(:commits, :tree) # => true + def current_controller?(*args) + args.any? { |v| v.to_s.downcase == controller.controller_name } end def gravatar_icon(user_email = '', size = 40) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 10250c93..fb711dd8 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -13,6 +13,11 @@ describe ApplicationHelper do it "returns false when controller does not match argument" do current_controller?(:bar).should_not be_true end + + it "should take any number of arguments" do + current_controller?(:baz, :bar).should_not be_true + current_controller?(:baz, :bar, :foo).should be_true + end end describe "gravatar_icon" do From adcc6a0b0e08158353627a8a900971aca07429bd Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 21:18:39 -0400 Subject: [PATCH 065/288] Move tab_class helper to TabHelper --- app/helpers/application_helper.rb | 39 ------------------------------- app/helpers/tab_helper.rb | 39 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d916d887..f874851a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -99,45 +99,6 @@ module ApplicationHelper event.project.merge_requests_enabled end - def tab_class(tab_key) - active = case tab_key - - # Project Area - when :wall; wall_tab? - when :wiki; controller.controller_name == "wikis" - when :issues; issues_tab? - when :network; current_page?(controller: "projects", action: "graph", id: @project) - when :merge_requests; controller.controller_name == "merge_requests" - - # Dashboard Area - when :help; controller.controller_name == "help" - when :search; current_page?(search_path) - when :dash_issues; current_page?(dashboard_issues_path) - when :dash_mr; current_page?(dashboard_merge_requests_path) - when :root; current_page?(dashboard_path) || current_page?(root_path) - - # Profile Area - when :profile; current_page?(controller: "profile", action: :show) - when :history; current_page?(controller: "profile", action: :history) - when :account; current_page?(controller: "profile", action: :account) - when :token; current_page?(controller: "profile", action: :token) - when :design; current_page?(controller: "profile", action: :design) - when :ssh_keys; controller.controller_name == "keys" - - # Admin Area - when :admin_root; controller.controller_name == "dashboard" - when :admin_users; controller.controller_name == 'users' - when :admin_projects; controller.controller_name == "projects" - when :admin_hooks; controller.controller_name == 'hooks' - when :admin_resque; controller.controller_name == 'resque' - when :admin_logs; controller.controller_name == 'logs' - - else - false - end - active ? "current" : nil - end - def hexdigest(string) Digest::SHA1.hexdigest string end diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index b5d7ccb7..4cc97b11 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -1,4 +1,43 @@ module TabHelper + def tab_class(tab_key) + active = case tab_key + + # Project Area + when :wall; wall_tab? + when :wiki; controller.controller_name == "wikis" + when :issues; issues_tab? + when :network; current_page?(controller: "projects", action: "graph", id: @project) + when :merge_requests; controller.controller_name == "merge_requests" + + # Dashboard Area + when :help; controller.controller_name == "help" + when :search; current_page?(search_path) + when :dash_issues; current_page?(dashboard_issues_path) + when :dash_mr; current_page?(dashboard_merge_requests_path) + when :root; current_page?(dashboard_path) || current_page?(root_path) + + # Profile Area + when :profile; current_page?(controller: "profile", action: :show) + when :history; current_page?(controller: "profile", action: :history) + when :account; current_page?(controller: "profile", action: :account) + when :token; current_page?(controller: "profile", action: :token) + when :design; current_page?(controller: "profile", action: :design) + when :ssh_keys; controller.controller_name == "keys" + + # Admin Area + when :admin_root; controller.controller_name == "dashboard" + when :admin_users; controller.controller_name == 'users' + when :admin_projects; controller.controller_name == "projects" + when :admin_hooks; controller.controller_name == 'hooks' + when :admin_resque; controller.controller_name == 'resque' + when :admin_logs; controller.controller_name == 'logs' + + else + false + end + active ? "current" : nil + end + def issues_tab? controller.controller_name == "issues" || controller.controller_name == "milestones" end From 51c1e499006df02ff3dfc2a781457a01cc77550f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 22:07:41 -0400 Subject: [PATCH 066/288] Change active tab and nav class to "active" The main nav used active, the sub nav used current. This normalizes it. --- app/assets/stylesheets/sections/nav.scss | 2 +- app/helpers/tab_helper.rb | 17 ++++------------- app/views/layouts/_project_menu.html.haml | 8 +++----- features/steps/shared/active_tab.rb | 12 ++++++++++-- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/app/assets/stylesheets/sections/nav.scss b/app/assets/stylesheets/sections/nav.scss index 2d902918..98bc7275 100644 --- a/app/assets/stylesheets/sections/nav.scss +++ b/app/assets/stylesheets/sections/nav.scss @@ -53,7 +53,7 @@ ul.main_menu { border-left: 0; } - &.current { + &.active { background-color:#D5D5D5; border-right: 1px solid #BBB; border-left: 1px solid #BBB; diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index 4cc97b11..9491e277 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -5,7 +5,6 @@ module TabHelper # Project Area when :wall; wall_tab? when :wiki; controller.controller_name == "wikis" - when :issues; issues_tab? when :network; current_page?(controller: "projects", action: "graph", id: @project) when :merge_requests; controller.controller_name == "merge_requests" @@ -35,11 +34,7 @@ module TabHelper else false end - active ? "current" : nil - end - - def issues_tab? - controller.controller_name == "issues" || controller.controller_name == "milestones" + active ? "active" : nil end def wall_tab? @@ -48,21 +43,17 @@ module TabHelper def project_tab_class [:show, :files, :edit, :update].each do |action| - return "current" if current_page?(controller: "projects", action: action, id: @project) + return "active" if current_page?(controller: "projects", action: action, id: @project) end if ['snippets', 'hooks', 'deploy_keys', 'team_members'].include? controller.controller_name - "current" + "active" end end - def tree_tab_class - controller.controller_name == "refs" ? "current" : nil - end - def commit_tab_class if ['commits', 'repositories', 'protected_branches'].include? controller.controller_name - "current" + "active" end end diff --git a/app/views/layouts/_project_menu.html.haml b/app/views/layouts/_project_menu.html.haml index 13a4d037..e2575646 100644 --- a/app/views/layouts/_project_menu.html.haml +++ b/app/views/layouts/_project_menu.html.haml @@ -4,17 +4,15 @@ - if @project.repo_exists? - if can? current_user, :download_code, @project - %li{class: tree_tab_class} - = link_to project_tree_path(@project, @project.root_ref) do - Files + %li{class: current_controller?(:tree, :blob, :blame) ? 'active' : ''} + = link_to 'Files', project_tree_path(@project, @project.root_ref) %li{class: commit_tab_class} = link_to "Commits", project_commits_path(@project, @project.root_ref) - %li{class: tab_class(:network)} = link_to "Network", graph_project_path(@project) - if @project.issues_enabled - %li{class: tab_class(:issues)} + %li{class: current_controller?(:issues, :milestones, :labels) ? 'active' : ''} = link_to project_issues_filter_path(@project) do Issues %span.count.issue_counter= @project.issues.opened.count diff --git a/features/steps/shared/active_tab.rb b/features/steps/shared/active_tab.rb index 33ac5cf5..884f2d5f 100644 --- a/features/steps/shared/active_tab.rb +++ b/features/steps/shared/active_tab.rb @@ -2,10 +2,18 @@ module SharedActiveTab include Spinach::DSL def ensure_active_main_tab(content) - page.find('ul.main_menu li.current').should have_content(content) + page.find('ul.main_menu li.active').should have_content(content) + end + + def ensure_active_sub_tab(content) + page.find('div.content ul.nav-tabs li.active').should have_content(content) end And 'no other main tabs should be active' do - page.should have_selector('ul.main_menu li.current', count: 1) + page.should have_selector('ul.main_menu li.active', count: 1) + end + + And 'no other sub tabs should be active' do + page.should have_selector('div.content ul.nav-tabs li.active', count: 1) end end From 6b90f36f5b6ee36dede7cc33c9364ddd34e5ba6b Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 22:32:54 -0400 Subject: [PATCH 067/288] Updates to routing specs --- spec/routing/project_routing_spec.rb | 57 ++++++---------------------- 1 file changed, 11 insertions(+), 46 deletions(-) diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 2939f2fc..652a75a4 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -285,6 +285,7 @@ end describe CommitController, "routing" do it "to #show" do get("/gitlabhq/commit/4246fb").should route_to('commit#show', project_id: 'gitlabhq', id: '4246fb') + get("/gitlabhq/commit/4246fb.patch").should route_to('commit#show', project_id: 'gitlabhq', id: '4246fb', format: 'patch') get("/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5").should route_to('commit#show', project_id: 'gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5') end end @@ -294,16 +295,8 @@ end # POST /:project_id/commits(.:format) commits#create # project_commit GET /:project_id/commits/:id(.:format) commits#show describe CommitsController, "routing" do - it "to #patch" do - get("/gitlabhq/commits/1/patch").should route_to('commits#patch', project_id: 'gitlabhq', id: '1') - end - - it "does something with atom feeds" do - get("/gitlabhq/commits/master.atom").should route_to('commits#show', project_id: 'gitlabhq', id: 'master.atom') - end - it_behaves_like "RESTful project resources" do - let(:actions) { [:index, :show] } + let(:actions) { [:show] } let(:controller) { 'commits' } end end @@ -384,64 +377,36 @@ describe NotesController, "routing" do end end +# project_blame GET /:project_id/blame/:id(.:format) blame#show {:id=>/.+/, :project_id=>/[^\/]+/} describe BlameController, "routing" do it "to #show" do get("/gitlabhq/blame/master/app/models/project.rb").should route_to('blame#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') end end +# project_blob GET /:project_id/blob/:id(.:format) blob#show {:id=>/.+/, :project_id=>/[^\/]+/} describe BlobController, "routing" do it "to #show" do get("/gitlabhq/blob/master/app/models/project.rb").should route_to('blob#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') end end +# project_tree GET /:project_id/tree/:id(.:format) tree#show {:id=>/.+/, :project_id=>/[^\/]+/} describe TreeController, "routing" do it "to #show" do get("/gitlabhq/tree/master/app/models/project.rb").should route_to('tree#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') end end +# project_compare_index GET /:project_id/compare(.:format) compare#index {:id=>/[^\/]+/, :project_id=>/[^\/]+/} +# project_compare /:project_id/compare/:from...:to(.:format) compare#show {:from=>/.+/, :to=>/.+/, :id=>/[^\/]+/, :project_id=>/[^\/]+/} describe CompareController, "routing" do + it "to #index" do + get("/gitlabhq/compare").should route_to('compare#index', project_id: 'gitlabhq') + end + it "to #show" do get("/gitlabhq/compare/master...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'master', to: 'stable') get("/gitlabhq/compare/issue/1234...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'issue/1234', to: 'stable') end end - -# TODO: Pending -# -# /:project_id/blame/*path -# /gitlabhq/blame/master/app/contexts/base_context.rb -# /gitlabhq/blame/test/branch/name/app/contexts/base_context.rb -# -# /:project_id/blob/*path -# /gitlabhq/blob/master/app/contexts/base_context.rb -# /gitlabhq/blob/test/branch/name/app/contexts/base_context.rb -# -# /:project_id/commit/:id -# /gitlabhq/commit/caef9ed1121a16ca0cc78715695daaa974271bfd -# -# /:project_id/commits -# -# /:project_id/commits/*path -# /gitlabhq/commits/master/app/contexts/base_context.rb -# /gitlabhq/commits/test/branch/name/app/contexts/base_context.rb -# /gitlabhq/commits/master.atom -# -# /:project_id/raw/*path -# /gitlabhq/raw/master/app/contexts/base_context.rb -# /gitlabhq/raw/test/branch/name/app/contexts/base_context.rb -# -# /:project_id/tree/*path -# /gitlabhq/tree/master/app -# /gitlabhq/tree/test/branch/name/app -describe "pending routing" do - before { pending } - - describe "/:project_id/raw/:id" do - it "routes to a ref with a path" do - get("/gitlabhq/raw/master/app/models/project.rb").should route_to('raw#show', project_id: 'gitlabhq', id: 'master/app/models/project.rb') - end - end -end From 4252ea90c0ab757fce538af1f03ce5f6d48f7814 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 22:34:29 -0400 Subject: [PATCH 068/288] Add feature steps for a generic, non-"Shop" project This group is better for features that only deal with one project. --- features/steps/shared/paths.rb | 48 ++++++++++++++++++++++++++++++-- features/steps/shared/project.rb | 7 +++++ features/support/env.rb | 2 ++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index bb35b8b0..a1a8efd6 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -1,6 +1,10 @@ module SharedPaths include Spinach::DSL + When 'I visit new project page' do + visit new_project_path + end + # ---------------------------------------- # Dashboard # ---------------------------------------- @@ -81,10 +85,50 @@ module SharedPaths visit admin_resque_path end - When 'I visit new project page' do - visit new_project_path + # ---------------------------------------- + # Generic Project + # ---------------------------------------- + + Given "I visit my project's home page" do + visit project_path(@project) end + Given "I visit my project's files page" do + visit project_tree_path(@project, @project.root_ref) + end + + Given "I visit my project's commits page" do + visit project_commits_path(@project, @project.root_ref, {limit: 5}) + end + + Given "I visit my project's network page" do + # Stub out find_all to speed this up (10 commits vs. 650) + commits = Grit::Commit.find_all(@project.repo, nil, {max_count: 10}) + Grit::Commit.stub(:find_all).and_return(commits) + + visit graph_project_path(@project) + end + + Given "I visit my project's issues page" do + visit project_issues_path(@project) + end + + Given "I visit my project's merge requests page" do + visit project_merge_requests_path(@project) + end + + Given "I visit my project's wall page" do + visit wall_project_path(@project) + end + + Given "I visit my project's wiki page" do + visit project_wiki_path(@project, :index) + end + + # ---------------------------------------- + # "Shop" Project + # ---------------------------------------- + And 'I visit project "Shop" page' do project = Project.find_by_name("Shop") visit project_path(project) diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index 9b64ca59..0f93d675 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -1,6 +1,13 @@ module SharedProject include Spinach::DSL + # Create a project without caring about what it's called + And "I own a project" do + @project = create(:project) + @project.add_access(@user, :admin) + end + + # Create a specific project called "Shop" And 'I own project "Shop"' do @project = Factory :project, :name => "Shop" @project.add_access(@user, :admin) diff --git a/features/support/env.rb b/features/support/env.rb index 9c6cef07..6d49c25a 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -23,5 +23,7 @@ Spinach.hooks.after_scenario { DatabaseCleaner.clean } Spinach.hooks.before_run do RSpec::Mocks::setup self + include FactoryGirl::Syntax::Methods + stub_gitolite! end From 8fe63dab52f6e72aaab1141f2af5d72b012064b7 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 22:41:25 -0400 Subject: [PATCH 069/288] Use current_controller? in layouts/_head partial --- app/views/layouts/_head.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 1674be27..c130c565 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -10,8 +10,8 @@ - if controller_name == 'projects' && action_name == 'index' = auto_discovery_link_tag :atom, projects_url(:atom, private_token: current_user.private_token), title: "Dashboard feed" - if @project && !@project.new_record? - - if current_page?(project_tree_path(@project, @ref)) || current_page?(project_commits_path(@project, @ref)) + - if current_controller?(:tree, :commit, :commits) = auto_discovery_link_tag(:atom, project_commits_url(@project, @ref, format: :atom, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}") - - if request.path == project_issues_path(@project) + - if current_controller?(:issues) = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues") = csrf_meta_tags From 6cb626ef516a230b2af4e15145488d4c57cd048c Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 23:10:50 -0400 Subject: [PATCH 070/288] Add Compare#index and Compare#create actions Create just redirects to our specially-formatted #show action --- app/controllers/compare_controller.rb | 7 +++++++ config/routes.rb | 2 +- spec/routing/project_routing_spec.rb | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/controllers/compare_controller.rb b/app/controllers/compare_controller.rb index 1124fd0c..62f968fd 100644 --- a/app/controllers/compare_controller.rb +++ b/app/controllers/compare_controller.rb @@ -8,6 +8,9 @@ class CompareController < ApplicationController before_filter :authorize_code_access! before_filter :require_non_empty_project + def index + end + def show result = Commit.compare(project, params[:from], params[:to]) @@ -19,4 +22,8 @@ class CompareController < ApplicationController @commits = CommitDecorator.decorate(@commits) end + + def create + redirect_to project_compare_path(@project, params[:from], params[:to]) + end end diff --git a/config/routes.rb b/config/routes.rb index bc29314e..decf860b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -162,7 +162,7 @@ Gitlab::Application.routes.draw do # XXX: WIP resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} resources :commits, only: [:show], constraints: {id: /.+/} - resources :compare, only: [:index] + resources :compare, only: [:index, :create] resources :blame, only: [:show], constraints: {id: /.+/} resources :blob, only: [:show], constraints: {id: /.+/} resources :tree, only: [:show], constraints: {id: /.+/} diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 652a75a4..dc687d2a 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -399,12 +399,17 @@ describe TreeController, "routing" do end # project_compare_index GET /:project_id/compare(.:format) compare#index {:id=>/[^\/]+/, :project_id=>/[^\/]+/} +# POST /:project_id/compare(.:format) compare#create {:id=>/[^\/]+/, :project_id=>/[^\/]+/} # project_compare /:project_id/compare/:from...:to(.:format) compare#show {:from=>/.+/, :to=>/.+/, :id=>/[^\/]+/, :project_id=>/[^\/]+/} describe CompareController, "routing" do it "to #index" do get("/gitlabhq/compare").should route_to('compare#index', project_id: 'gitlabhq') end + it "to #compare" do + post("/gitlabhq/compare").should route_to('compare#create', project_id: 'gitlabhq') + end + it "to #show" do get("/gitlabhq/compare/master...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'master', to: 'stable') get("/gitlabhq/compare/issue/1234...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'issue/1234', to: 'stable') From b462a133879ca2a202f18f18d8e78a3ffed05c24 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 23:13:19 -0400 Subject: [PATCH 071/288] Compare views and cleanup - Remove compare/_head and just use commits/_head since they're identical - Add index view; extract the form into a partial --- app/views/commits/_head.html.haml | 4 +-- app/views/compare/_form.html.haml | 32 ++++++++++++++++++++ app/views/compare/_head.html.haml | 23 --------------- app/views/compare/index.html.haml | 7 +++++ app/views/compare/show.html.haml | 41 ++------------------------ app/views/events/_event_push.html.haml | 2 +- features/steps/shared/paths.rb | 2 +- 7 files changed, 45 insertions(+), 66 deletions(-) create mode 100644 app/views/compare/_form.html.haml delete mode 100644 app/views/compare/_head.html.haml create mode 100644 app/views/compare/index.html.haml diff --git a/app/views/commits/_head.html.haml b/app/views/commits/_head.html.haml index cdee391f..86a65f87 100644 --- a/app/views/commits/_head.html.haml +++ b/app/views/commits/_head.html.haml @@ -3,8 +3,8 @@ %li{class: "#{'active' if current_page?(project_commits_path(@project)) }"} = link_to project_commits_path(@project) do Commits - %li{class: "#{'active' if current_page?(compare_project_commits_path(@project)) }"} - = link_to compare_project_commits_path(@project) do + %li{class: "#{'active' if current_controller?(:compare)}"} + = link_to project_compare_index_path(@project) do Compare %li{class: "#{branches_tab_class}"} = link_to project_repository_path(@project) do diff --git a/app/views/compare/_form.html.haml b/app/views/compare/_form.html.haml new file mode 100644 index 00000000..07f1c818 --- /dev/null +++ b/app/views/compare/_form.html.haml @@ -0,0 +1,32 @@ +%div + %p.slead + Fill input field with commit id like + %code.label_branch 4eedf23 + or branch/tag name like + %code.label_branch master + and press compare button for commits list, code diff. + + %br + + = form_tag project_compare_index_path(@project), method: :post do + .clearfix + = text_field_tag :from, params[:from], placeholder: "master", class: "xlarge" + = "..." + = text_field_tag :to, params[:to], placeholder: "aa8b4ef", class: "xlarge" + - if @refs_are_same + .alert + %span Refs are the same + .actions + = submit_tag "Compare", class: "btn primary wide commits-compare-btn" + +:javascript + $(function() { + var availableTags = #{@project.ref_names.to_json}; + + $("#from, #to").autocomplete({ + source: availableTags, + minLength: 1 + }); + + disableButtonIfEmptyField('#to', '.commits-compare-btn'); + }); diff --git a/app/views/compare/_head.html.haml b/app/views/compare/_head.html.haml deleted file mode 100644 index cdee391f..00000000 --- a/app/views/compare/_head.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -%ul.nav.nav-tabs - %li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'} - %li{class: "#{'active' if current_page?(project_commits_path(@project)) }"} - = link_to project_commits_path(@project) do - Commits - %li{class: "#{'active' if current_page?(compare_project_commits_path(@project)) }"} - = link_to compare_project_commits_path(@project) do - Compare - %li{class: "#{branches_tab_class}"} - = link_to project_repository_path(@project) do - Branches - %span.badge= @project.repo.branch_count - - %li{class: "#{'active' if current_page?(tags_project_repository_path(@project)) }"} - = link_to tags_project_repository_path(@project) do - Tags - %span.badge= @project.repo.tag_count - - - if current_page?(project_commits_path(@project)) && current_user.private_token - %li.right - %span.rss-icon - = link_to project_commits_path(@project, @ref, {format: :atom, private_token: current_user.private_token}), title: "Feed" do - = image_tag "rss_ui.png", title: "feed" diff --git a/app/views/compare/index.html.haml b/app/views/compare/index.html.haml new file mode 100644 index 00000000..6c9a5fd8 --- /dev/null +++ b/app/views/compare/index.html.haml @@ -0,0 +1,7 @@ += render "commits/head" + +%h3.page_title + Compare View +%hr + += render "form" diff --git a/app/views/compare/show.html.haml b/app/views/compare/show.html.haml index db15ba53..528c8b44 100644 --- a/app/views/compare/show.html.haml +++ b/app/views/compare/show.html.haml @@ -1,29 +1,10 @@ -= render "head" += render "commits/head" %h3.page_title Compare View %hr -%div - %p.slead - Fill input field with commit id like - %code.label_branch 4eedf23 - or branch/tag name like - %code.label_branch master - and press compare button for commits list, code diff. - - %br - - = form_tag compare_project_commits_path(@project), method: :get do - .clearfix - = text_field_tag :from, params[:from], placeholder: "master", class: "xlarge" - = "..." - = text_field_tag :to, params[:to], placeholder: "aa8b4ef", class: "xlarge" - - if @refs_are_same - .alert - %span Refs are the same - .actions - = submit_tag "Compare", class: "btn primary wide commits-compare-btn" += render "form" - if @commits.present? %div.ui-box @@ -33,21 +14,3 @@ - unless @diffs.empty? %h4 Diff = render "commits/diffs", diffs: @diffs - -:javascript - $(function() { - var availableTags = #{@project.ref_names.to_json}; - - $("#from").autocomplete({ - source: availableTags, - minLength: 1 - }); - - $("#to").autocomplete({ - source: availableTags, - minLength: 1 - }); - - disableButtonIfEmptyField('#to', '.commits-compare-btn'); - }); - diff --git a/app/views/events/_event_push.html.haml b/app/views/events/_event_push.html.haml index c0be9cf5..19ac9263 100644 --- a/app/views/events/_event_push.html.haml +++ b/app/views/events/_event_push.html.haml @@ -21,6 +21,6 @@ %li.commits-stat - if event.commits_count > 2 %span ... and #{event.commits_count - 2} more commits. - = link_to compare_project_commits_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do + = link_to project_compare_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do %strong Compare → #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]} .clearfix diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index a1a8efd6..8efedfa1 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -139,7 +139,7 @@ module SharedPaths end Given 'I visit compare refs page' do - visit compare_project_commits_path(@project) + visit project_compare_index_path(@project) end Given 'I visit project commits page' do From 86a7864dc78ed9168df889a5994ee7ef80a29476 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 23:33:42 -0400 Subject: [PATCH 072/288] Fix various links --- app/views/blame/show.html.haml | 2 +- app/views/events/_event_last_push.html.haml | 2 +- app/views/events/_event_push.html.haml | 2 +- app/views/layouts/_head.html.haml | 2 +- app/views/protected_branches/index.html.haml | 2 +- app/views/repositories/_branch.html.haml | 2 +- app/views/repositories/_feed.html.haml | 2 +- app/views/repositories/tags.html.haml | 2 +- app/views/tree/_tree_file.html.haml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/blame/show.html.haml b/app/views/blame/show.html.haml index 12b4e668..8f82b00f 100644 --- a/app/views/blame/show.html.haml +++ b/app/views/blame/show.html.haml @@ -19,7 +19,7 @@ %small blame %span.options = link_to "raw", project_blob_path(@project, @id), class: "btn very_small", target: "_blank" - = link_to "history", project_commits_path(@project, path: params[:path], ref: @ref), class: "btn very_small" + = link_to "history", project_commits_path(@project, @id), class: "btn very_small" = link_to "source", project_tree_path(@project, @id), class: "btn very_small" .file_content.blame %table diff --git a/app/views/events/_event_last_push.html.haml b/app/views/events/_event_last_push.html.haml index 81b9994c..d70be70c 100644 --- a/app/views/events/_event_last_push.html.haml +++ b/app/views/events/_event_last_push.html.haml @@ -4,7 +4,7 @@ = image_tag gravatar_icon(event.author_email), class: "avatar" %span You pushed to = event.ref_type - = link_to project_commits_path(event.project, ref: event.ref_name) do + = link_to project_commits_path(event.project, event.ref_name) do %strong= truncate(event.ref_name, length: 28) at %strong= link_to event.project.name, event.project diff --git a/app/views/events/_event_push.html.haml b/app/views/events/_event_push.html.haml index 19ac9263..9b7f10d9 100644 --- a/app/views/events/_event_push.html.haml +++ b/app/views/events/_event_push.html.haml @@ -5,7 +5,7 @@ .event-title %strong.author_name #{event.author_name} %span.event_label.pushed #{event.push_action_name} #{event.ref_type} - = link_to project_commits_path(event.project, ref: event.ref_name) do + = link_to project_commits_path(event.project, event.ref_name) do %strong= event.ref_name at %strong= link_to event.project.name, event.project diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index c130c565..25fe9d80 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -10,7 +10,7 @@ - if controller_name == 'projects' && action_name == 'index' = auto_discovery_link_tag :atom, projects_url(:atom, private_token: current_user.private_token), title: "Dashboard feed" - if @project && !@project.new_record? - - if current_controller?(:tree, :commit, :commits) + - if current_controller?(:tree, :commits) = auto_discovery_link_tag(:atom, project_commits_url(@project, @ref, format: :atom, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}") - if current_controller?(:issues) = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues") diff --git a/app/views/protected_branches/index.html.haml b/app/views/protected_branches/index.html.haml index 43884de1..50a81712 100644 --- a/app/views/protected_branches/index.html.haml +++ b/app/views/protected_branches/index.html.haml @@ -34,7 +34,7 @@ - @branches.each do |branch| %tr %td - = link_to project_commits_path(@project, ref: branch.name) do + = link_to project_commits_path(@project, branch.name) do %strong= branch.name - if branch.name == @project.root_ref %span.label default diff --git a/app/views/repositories/_branch.html.haml b/app/views/repositories/_branch.html.haml index 80028a82..3c1fe47c 100644 --- a/app/views/repositories/_branch.html.haml +++ b/app/views/repositories/_branch.html.haml @@ -2,7 +2,7 @@ - commit = CommitDecorator.decorate(commit) %tr %td - = link_to project_commits_path(@project, ref: branch.name) do + = link_to project_commits_path(@project, branch.name) do %strong= truncate(branch.name, length: 60) - if branch.name == @project.root_ref %span.label default diff --git a/app/views/repositories/_feed.html.haml b/app/views/repositories/_feed.html.haml index 0c13551d..496328ba 100644 --- a/app/views/repositories/_feed.html.haml +++ b/app/views/repositories/_feed.html.haml @@ -2,7 +2,7 @@ - commit = CommitDecorator.new(commit) %tr %td - = link_to project_commits_path(@project, ref: commit.head.name) do + = link_to project_commits_path(@project, commit.head.name) do %strong = commit.head.name - if commit.head.name == @project.root_ref diff --git a/app/views/repositories/tags.html.haml b/app/views/repositories/tags.html.haml index a4114586..38cc3aca 100644 --- a/app/views/repositories/tags.html.haml +++ b/app/views/repositories/tags.html.haml @@ -12,7 +12,7 @@ - commit = CommitDecorator.decorate(commit) %tr %td - %strong= link_to tag.name, project_commits_path(@project, ref: tag.name), class: "" + %strong= link_to tag.name, project_commits_path(@project, tag.name), class: "" %td = link_to project_commit_path(@project, commit.id) do %code= commit.short_id diff --git a/app/views/tree/_tree_file.html.haml b/app/views/tree/_tree_file.html.haml index b4c4566b..93f7be28 100644 --- a/app/views/tree/_tree_file.html.haml +++ b/app/views/tree/_tree_file.html.haml @@ -6,7 +6,7 @@ %small #{file.mode} %span.options = link_to "raw", project_blob_path(@project, @id), class: "btn very_small", target: "_blank" - = link_to "history", project_commits_path(@project, path: @path, ref: @ref), class: "btn very_small" + = link_to "history", project_commits_path(@project, @id), class: "btn very_small" = link_to "blame", project_blame_path(@project, @id), class: "btn very_small" - if file.text? - if gitlab_markdown?(name) From b62d6a1fe28ad040e96fd88604131f357e5e6e9e Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 23:34:26 -0400 Subject: [PATCH 073/288] Remove commit_tab_class helper --- app/helpers/tab_helper.rb | 6 ------ app/views/layouts/_project_menu.html.haml | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index 9491e277..c26e3467 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -51,12 +51,6 @@ module TabHelper end end - def commit_tab_class - if ['commits', 'repositories', 'protected_branches'].include? controller.controller_name - "active" - end - end - def branches_tab_class if current_page?(branches_project_repository_path(@project)) || controller.controller_name == "protected_branches" || diff --git a/app/views/layouts/_project_menu.html.haml b/app/views/layouts/_project_menu.html.haml index e2575646..5a662a45 100644 --- a/app/views/layouts/_project_menu.html.haml +++ b/app/views/layouts/_project_menu.html.haml @@ -6,7 +6,7 @@ - if can? current_user, :download_code, @project %li{class: current_controller?(:tree, :blob, :blame) ? 'active' : ''} = link_to 'Files', project_tree_path(@project, @project.root_ref) - %li{class: commit_tab_class} + %li{class: current_controller?(:commit, :commits, :compare, :repositories, :protected_branches) ? 'active' : ''} = link_to "Commits", project_commits_path(@project, @project.root_ref) %li{class: tab_class(:network)} = link_to "Network", graph_project_path(@project) From b6d6663e0e793b2a47f8a25215334f77e2b80baf Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 23:34:52 -0400 Subject: [PATCH 074/288] Fix the remaining actions in RefsController --- app/controllers/refs_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index ff143f3f..6ae816ec 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -69,6 +69,6 @@ class RefsController < ApplicationController end def ref - @ref = params[:ref] + @ref = params[:id] || params[:ref] end end From 0887dda8e4eba68004e087e12302f3dbf2688790 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 23:39:28 -0400 Subject: [PATCH 075/288] Use current ref for Files and Commits if available Closes #1452 --- app/views/layouts/_project_menu.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/_project_menu.html.haml b/app/views/layouts/_project_menu.html.haml index 5a662a45..d69f9a0b 100644 --- a/app/views/layouts/_project_menu.html.haml +++ b/app/views/layouts/_project_menu.html.haml @@ -5,9 +5,9 @@ - if @project.repo_exists? - if can? current_user, :download_code, @project %li{class: current_controller?(:tree, :blob, :blame) ? 'active' : ''} - = link_to 'Files', project_tree_path(@project, @project.root_ref) + = link_to 'Files', project_tree_path(@project, @ref || @project.root_ref) %li{class: current_controller?(:commit, :commits, :compare, :repositories, :protected_branches) ? 'active' : ''} - = link_to "Commits", project_commits_path(@project, @project.root_ref) + = link_to "Commits", project_commits_path(@project, @ref || @project.root_ref) %li{class: tab_class(:network)} = link_to "Network", graph_project_path(@project) From 275db3c522200b68673c4ea6a16046b3582cda2f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 23:39:50 -0400 Subject: [PATCH 076/288] Fix paths in commits/_head --- app/views/commits/_head.html.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/commits/_head.html.haml b/app/views/commits/_head.html.haml index 86a65f87..edaf8b86 100644 --- a/app/views/commits/_head.html.haml +++ b/app/views/commits/_head.html.haml @@ -1,7 +1,7 @@ %ul.nav.nav-tabs %li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'} - %li{class: "#{'active' if current_page?(project_commits_path(@project)) }"} - = link_to project_commits_path(@project) do + %li{class: "#{'active' if current_controller?(:commit, :commits)}"} + = link_to project_commits_path(@project, @project.root_ref) do Commits %li{class: "#{'active' if current_controller?(:compare)}"} = link_to project_compare_index_path(@project) do @@ -16,7 +16,7 @@ Tags %span.badge= @project.repo.tag_count - - if current_page?(project_commits_path(@project)) && current_user.private_token + - if current_controller?(:commits) && current_user.private_token %li.right %span.rss-icon = link_to project_commits_path(@project, @ref, {format: :atom, private_token: current_user.private_token}), title: "Feed" do From 1799cf3b49dbe243e21f13d51496be7d60d1a73f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 23:40:04 -0400 Subject: [PATCH 077/288] Add CommitsController spec to make sure atom feeds work --- spec/controllers/commits_controller_spec.rb | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 spec/controllers/commits_controller_spec.rb diff --git a/spec/controllers/commits_controller_spec.rb b/spec/controllers/commits_controller_spec.rb new file mode 100644 index 00000000..bf335634 --- /dev/null +++ b/spec/controllers/commits_controller_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +describe CommitsController do + let(:project) { create(:project) } + let(:user) { create(:user) } + + before do + sign_in(user) + + project.add_access(user, :read, :admin) + end + + describe "GET show" do + context "as atom feed" do + it "should render as atom" do + get :show, project_id: project.code, id: "master.atom" + response.should be_success + response.content_type.should == 'application/atom+xml' + end + end + end +end From e9bd45060e3c5198124b4cdad08a7a26f5e0408a Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 23:56:27 -0400 Subject: [PATCH 078/288] Fix logs not showing in Tree for the root path --- app/controllers/refs_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index 6ae816ec..e92f4527 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -55,7 +55,7 @@ class RefsController < ApplicationController @commit = CommitDecorator.decorate(@commit) @tree = Tree.new(@commit.tree, project, @ref, params[:path]) @tree = TreeDecorator.new(@tree) - @hex_path = Digest::SHA1.hexdigest(params[:path] || "/") + @hex_path = Digest::SHA1.hexdigest(params[:path] || "") if params[:path] @history_path = project_tree_path(@project, File.join(@ref, params[:path])) From 9f0e80591ab1f3c4967575574fed37754ef2403b Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 13:21:38 -0400 Subject: [PATCH 079/288] Fix Repository role spec --- app/roles/repository.rb | 3 +++ spec/roles/repository_spec.rb | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/roles/repository.rb b/app/roles/repository.rb index 7118f156..191a6d70 100644 --- a/app/roles/repository.rb +++ b/app/roles/repository.rb @@ -45,14 +45,17 @@ module Repository File.exists?(hook_file) end + # Returns an Array of branch names def branches repo.branches.collect(&:name).sort end + # Returns an Array of tag names def tags repo.tags.collect(&:name).sort.reverse end + # Returns an Array of branch and tag names def ref_names [branches + tags].flatten end diff --git a/spec/roles/repository_spec.rb b/spec/roles/repository_spec.rb index 0fda57a3..c4e0e9de 100644 --- a/spec/roles/repository_spec.rb +++ b/spec/roles/repository_spec.rb @@ -21,27 +21,27 @@ describe Project, "Repository" do end describe "#discover_default_branch" do - let(:master) { double(name: 'master') } - let(:stable) { double(name: 'stable') } + let(:master) { 'master' } + let(:stable) { 'stable' } it "returns 'master' when master exists" do - project.should_receive(:heads).and_return([stable, master]) + project.should_receive(:branches).at_least(:once).and_return([stable, master]) project.discover_default_branch.should == 'master' end it "returns non-master when master exists but default branch is set to something else" do project.default_branch = 'stable' - project.should_receive(:heads).and_return([stable, master]) + project.should_receive(:branches).at_least(:once).and_return([stable, master]) project.discover_default_branch.should == 'stable' end it "returns a non-master branch when only one exists" do - project.should_receive(:heads).and_return([stable]) + project.should_receive(:branches).at_least(:once).and_return([stable]) project.discover_default_branch.should == 'stable' end it "returns nil when no branch exists" do - project.should_receive(:heads).and_return([]) + project.should_receive(:branches).at_least(:once).and_return([]) project.discover_default_branch.should be_nil end end From cf237f1d32c15e1e9fa128fc9e089a7857495f51 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 13:21:55 -0400 Subject: [PATCH 080/288] Fix GFM request spec --- spec/requests/gitlab_flavored_markdown_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/requests/gitlab_flavored_markdown_spec.rb b/spec/requests/gitlab_flavored_markdown_spec.rb index 2e5d4209..bb00d945 100644 --- a/spec/requests/gitlab_flavored_markdown_spec.rb +++ b/spec/requests/gitlab_flavored_markdown_spec.rb @@ -43,7 +43,7 @@ describe "Gitlab Flavored Markdown" do describe "for commits" do it "should render title in commits#index" do - visit project_commits_path(project, ref: @branch_name) + visit project_commits_path(project, @branch_name) page.should have_link("##{issue.id}") end @@ -69,7 +69,7 @@ describe "Gitlab Flavored Markdown" do end it "should render title in refs#blame" do - visit blame_file_project_ref_path(project, File.join(@branch_name, @test_file)) + visit project_blame_path(project, File.join(@branch_name, @test_file)) within(".blame_commit") do page.should have_link("##{issue.id}") From 67fd7432943657f29d3d417445d54bc7c6d46946 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 13:22:30 -0400 Subject: [PATCH 081/288] Clean up project access spec --- spec/requests/security/project_access_spec.rb | 170 ++++++++++-------- 1 file changed, 92 insertions(+), 78 deletions(-) diff --git a/spec/requests/security/project_access_spec.rb b/spec/requests/security/project_access_spec.rb index 9b07df6c..5f26b781 100644 --- a/spec/requests/security/project_access_spec.rb +++ b/spec/requests/security/project_access_spec.rb @@ -14,204 +14,218 @@ describe "Application access" do end describe "Project" do + let(:project) { create(:project) } + + let(:master) { create(:user) } + let(:guest) { create(:user) } + let(:reporter) { create(:user) } + before do - @project = Factory :project - @u1 = Factory :user - @u2 = Factory :user - @u3 = Factory :user # full access - @project.users_projects.create(user: @u1, project_access: UsersProject::MASTER) + project.users_projects.create(user: master, project_access: UsersProject::MASTER) + # readonly - @project.users_projects.create(user: @u3, project_access: UsersProject::REPORTER) + project.users_projects.create(user: reporter, project_access: UsersProject::REPORTER) end describe "GET /project_code" do - subject { project_path(@project) } + subject { project_path(project) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end - describe "GET /project_code/master/tree" do - subject { project_tree_path(@project, @project.root_ref) } + describe "GET /project_code/tree/master" do + subject { project_tree_path(project, project.root_ref) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end - describe "GET /project_code/commits" do - subject { project_commits_path(@project) } + describe "GET /project_code/commits/master" do + subject { project_commits_path(project, project.root_ref) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end - describe "GET /project_code/commit" do - subject { project_commit_path(@project, @project.commit.id) } + describe "GET /project_code/commit/:sha" do + subject { project_commit_path(project, project.commit) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } + it { should be_denied_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /project_code/compare" do + subject { project_compare_index_path(project) } + + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_denied_for :admin } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end describe "GET /project_code/team" do - subject { project_team_index_path(@project) } + subject { project_team_index_path(project) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end describe "GET /project_code/wall" do - subject { wall_project_path(@project) } + subject { wall_project_path(project) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end describe "GET /project_code/blob" do before do - commit = @project.commit + commit = project.commit path = commit.tree.contents.select { |i| i.is_a?(Grit::Blob)}.first.name - @blob_path = project_blob_path(@project, File.join(commit.id, path)) + @blob_path = project_blob_path(project, File.join(commit.id, path)) end - it { @blob_path.should be_allowed_for @u1 } - it { @blob_path.should be_allowed_for @u3 } + it { @blob_path.should be_allowed_for master } + it { @blob_path.should be_allowed_for reporter } it { @blob_path.should be_denied_for :admin } - it { @blob_path.should be_denied_for @u2 } + it { @blob_path.should be_denied_for guest } it { @blob_path.should be_denied_for :user } it { @blob_path.should be_denied_for :visitor } end describe "GET /project_code/edit" do - subject { edit_project_path(@project) } + subject { edit_project_path(project) } - it { should be_allowed_for @u1 } - it { should be_denied_for @u3 } + it { should be_allowed_for master } + it { should be_denied_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end describe "GET /project_code/deploy_keys" do - subject { project_deploy_keys_path(@project) } + subject { project_deploy_keys_path(project) } - it { should be_allowed_for @u1 } - it { should be_denied_for @u3 } + it { should be_allowed_for master } + it { should be_denied_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end describe "GET /project_code/issues" do - subject { project_issues_path(@project) } + subject { project_issues_path(project) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end describe "GET /project_code/snippets" do - subject { project_snippets_path(@project) } + subject { project_snippets_path(project) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end describe "GET /project_code/merge_requests" do - subject { project_merge_requests_path(@project) } + subject { project_merge_requests_path(project) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end describe "GET /project_code/repository" do - subject { project_repository_path(@project) } + subject { project_repository_path(project) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end describe "GET /project_code/repository/branches" do - subject { branches_project_repository_path(@project) } + subject { branches_project_repository_path(project) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end describe "GET /project_code/repository/tags" do - subject { tags_project_repository_path(@project) } + subject { tags_project_repository_path(project) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end describe "GET /project_code/hooks" do - subject { project_hooks_path(@project) } + subject { project_hooks_path(project) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end describe "GET /project_code/files" do - subject { files_project_path(@project) } + subject { files_project_path(project) } - it { should be_allowed_for @u1 } - it { should be_allowed_for @u3 } + it { should be_allowed_for master } + it { should be_allowed_for reporter } it { should be_denied_for :admin } - it { should be_denied_for @u2 } + it { should be_denied_for guest } it { should be_denied_for :user } it { should be_denied_for :visitor } end From 5cea3e576dfc2a0d01a44b647bbd1c14a202d9e3 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 13:23:19 -0400 Subject: [PATCH 082/288] Remove atom Dashboard spec that no longer applies --- spec/requests/atom/dashboard_spec.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/spec/requests/atom/dashboard_spec.rb b/spec/requests/atom/dashboard_spec.rb index 9459dd01..c160d24a 100644 --- a/spec/requests/atom/dashboard_spec.rb +++ b/spec/requests/atom/dashboard_spec.rb @@ -10,12 +10,5 @@ describe "Dashboard Feed" do page.body.should have_selector("feed title") end end - - context "projects page via private token" do - it "should redirect to login page" do - visit dashboard_path(private_token: user.private_token) - current_path.should == new_user_session_path - end - end end end From 2df3b310f9727956c3ce84322928f3360616f5ad Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 13:34:51 -0400 Subject: [PATCH 083/288] Rename branches and tags Repo methods to branch_names and tag_names --- app/roles/repository.rb | 14 +++++++------- spec/roles/repository_spec.rb | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/roles/repository.rb b/app/roles/repository.rb index 191a6d70..e7e57b0e 100644 --- a/app/roles/repository.rb +++ b/app/roles/repository.rb @@ -46,18 +46,18 @@ module Repository end # Returns an Array of branch names - def branches + def branch_names repo.branches.collect(&:name).sort end # Returns an Array of tag names - def tags + def tag_names repo.tags.collect(&:name).sort.reverse end # Returns an Array of branch and tag names def ref_names - [branches + tags].flatten + [branch_names + tag_names].flatten end def repo @@ -112,12 +112,12 @@ module Repository # - If two or more branches are present, returns the one that has a name # matching root_ref (default_branch or 'master' if default_branch is nil) def discover_default_branch - if branches.length == 0 + if branch_names.length == 0 nil - elsif branches.length == 1 - branches.first + elsif branch_names.length == 1 + branch_names.first else - branches.select { |v| v == root_ref }.first + branch_names.select { |v| v == root_ref }.first end end diff --git a/spec/roles/repository_spec.rb b/spec/roles/repository_spec.rb index c4e0e9de..3507585a 100644 --- a/spec/roles/repository_spec.rb +++ b/spec/roles/repository_spec.rb @@ -25,23 +25,23 @@ describe Project, "Repository" do let(:stable) { 'stable' } it "returns 'master' when master exists" do - project.should_receive(:branches).at_least(:once).and_return([stable, master]) + project.should_receive(:branch_names).at_least(:once).and_return([stable, master]) project.discover_default_branch.should == 'master' end it "returns non-master when master exists but default branch is set to something else" do project.default_branch = 'stable' - project.should_receive(:branches).at_least(:once).and_return([stable, master]) + project.should_receive(:branch_names).at_least(:once).and_return([stable, master]) project.discover_default_branch.should == 'stable' end it "returns a non-master branch when only one exists" do - project.should_receive(:branches).at_least(:once).and_return([stable]) + project.should_receive(:branch_names).at_least(:once).and_return([stable]) project.discover_default_branch.should == 'stable' end it "returns nil when no branch exists" do - project.should_receive(:branches).at_least(:once).and_return([]) + project.should_receive(:branch_names).at_least(:once).and_return([]) project.discover_default_branch.should be_nil end end From f8c02f6e39d0a1f752583cc1942bb5e4c53df9c1 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 13:38:14 -0400 Subject: [PATCH 084/288] Add branches and tags Repo methods Simplifies the actions in RepositoriesController --- app/controllers/repositories_controller.rb | 4 ++-- app/roles/repository.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 583edf8e..614582fa 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -14,11 +14,11 @@ class RepositoriesController < ApplicationController end def branches - @branches = @project.repo.heads.sort_by(&:name) + @branches = @project.branches end def tags - @tags = @project.repo.tags.sort_by(&:name).reverse + @tags = @project.tags end def archive diff --git a/app/roles/repository.rb b/app/roles/repository.rb index e7e57b0e..1f44481e 100644 --- a/app/roles/repository.rb +++ b/app/roles/repository.rb @@ -50,11 +50,21 @@ module Repository repo.branches.collect(&:name).sort end + # Returns an Array of Branches + def branches + repo.branches.sort_by(&:name) + end + # Returns an Array of tag names def tag_names repo.tags.collect(&:name).sort.reverse end + # Returns an Array of Tags + def tags + repo.tags.sort_by(&:name).reverse + end + # Returns an Array of branch and tag names def ref_names [branch_names + tag_names].flatten From 7df25e77ac3cfd279a1b1937e45446574d932a3d Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 13:43:42 -0400 Subject: [PATCH 085/288] Speed up request specs a bit --- spec/requests/gitlab_flavored_markdown_spec.rb | 4 +--- spec/requests/security/project_access_spec.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/spec/requests/gitlab_flavored_markdown_spec.rb b/spec/requests/gitlab_flavored_markdown_spec.rb index bb00d945..106f6451 100644 --- a/spec/requests/gitlab_flavored_markdown_spec.rb +++ b/spec/requests/gitlab_flavored_markdown_spec.rb @@ -40,10 +40,9 @@ describe "Gitlab Flavored Markdown" do project.add_access(@user, :read, :write) end - describe "for commits" do it "should render title in commits#index" do - visit project_commits_path(project, @branch_name) + visit project_commits_path(project, @branch_name, limit: 1) page.should have_link("##{issue.id}") end @@ -89,7 +88,6 @@ describe "Gitlab Flavored Markdown" do end end - describe "for issues" do before do @other_issue = Factory :issue, diff --git a/spec/requests/security/project_access_spec.rb b/spec/requests/security/project_access_spec.rb index 5f26b781..060a276b 100644 --- a/spec/requests/security/project_access_spec.rb +++ b/spec/requests/security/project_access_spec.rb @@ -51,7 +51,7 @@ describe "Application access" do end describe "GET /project_code/commits/master" do - subject { project_commits_path(project, project.root_ref) } + subject { project_commits_path(project, project.root_ref, limit: 1) } it { should be_allowed_for master } it { should be_allowed_for reporter } @@ -189,6 +189,11 @@ describe "Application access" do describe "GET /project_code/repository/branches" do subject { branches_project_repository_path(project) } + before do + # Speed increase + Project.any_instance.stub(:branches).and_return([]) + end + it { should be_allowed_for master } it { should be_allowed_for reporter } it { should be_denied_for :admin } @@ -200,6 +205,11 @@ describe "Application access" do describe "GET /project_code/repository/tags" do subject { tags_project_repository_path(project) } + before do + # Speed increase + Project.any_instance.stub(:tags).and_return([]) + end + it { should be_allowed_for master } it { should be_allowed_for reporter } it { should be_denied_for :admin } From 82c3f6260366147803d5f63d575231f77c7e73ce Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 13:58:50 -0400 Subject: [PATCH 086/288] Speed up Compare feature step --- features/project/commits/commits.feature | 6 +++--- features/steps/project/project_browse_commits.rb | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/features/project/commits/commits.feature b/features/project/commits/commits.feature index 53de6e6a..df795ef7 100644 --- a/features/project/commits/commits.feature +++ b/features/project/commits/commits.feature @@ -1,8 +1,8 @@ Feature: Project Browse commits Background: Given I sign in as a user - And I own project "Shop" - Given I visit project commits page + And I own a project + And I visit my project's commits page Scenario: I browse commits list for master branch Then I see project commits @@ -18,4 +18,4 @@ Feature: Project Browse commits Scenario: I compare refs Given I visit compare refs page And I fill compare fields with refs - And I see compared refs + Then I see compared refs diff --git a/features/steps/project/project_browse_commits.rb b/features/steps/project/project_browse_commits.rb index 01479987..cb5cabe9 100644 --- a/features/steps/project/project_browse_commits.rb +++ b/features/steps/project/project_browse_commits.rb @@ -4,8 +4,6 @@ class ProjectBrowseCommits < Spinach::FeatureSteps include SharedPaths Then 'I see project commits' do - current_path.should == project_commits_path(@project) - commit = @project.commit page.should have_content(@project.name) page.should have_content(commit.message) @@ -34,14 +32,14 @@ class ProjectBrowseCommits < Spinach::FeatureSteps end And 'I fill compare fields with refs' do - fill_in "from", :with => "master" - fill_in "to", :with => "stable" + fill_in "from", with: "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" + fill_in "to", with: "8716fc78f3c65bbf7bcf7b574febd583bc5d2812" click_button "Compare" end - And 'I see compared refs' do - page.should have_content "Commits (27)" + Then 'I see compared refs' do page.should have_content "Compare View" - page.should have_content "Showing 73 changed files" + page.should have_content "Commits (1)" + page.should have_content "Showing 2 changed files" end end From afc4a75499b6678a643e6b62f703f8e7e1eb0f0a Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 14:52:01 -0400 Subject: [PATCH 087/288] Use Rails.root.join where appropriate --- app/controllers/application_controller.rb | 2 +- app/models/merge_request.rb | 2 +- app/roles/repository.rb | 2 +- config/initializers/1_settings.rb | 2 +- db/fixtures/test/001_repo.rb | 4 ++-- lib/gitlab/backend/gitolite_config.rb | 4 ++-- lib/gitlab/logger.rb | 2 +- lib/gitlab/merge.rb | 4 ++-- lib/gitlab/satellite.rb | 6 +++--- spec/models/project_spec.rb | 2 +- spec/support/stubbed_repository.rb | 4 ++-- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f5d978a7..334135c8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -105,7 +105,7 @@ class ApplicationController < ActionController::Base end def render_404 - render file: File.join(Rails.root, "public", "404"), layout: false, status: "404" + render file: Rails.root.join("public", "404"), layout: false, status: "404" end def require_non_empty_project diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index bb7b53fa..717fe296 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -1,4 +1,4 @@ -require File.join(Rails.root, "app/models/commit") +require Rails.root.join("app/models/commit") class MergeRequest < ActiveRecord::Base include IssueCommonality diff --git a/app/roles/repository.rb b/app/roles/repository.rb index 1f44481e..35093a2f 100644 --- a/app/roles/repository.rb +++ b/app/roles/repository.rb @@ -155,7 +155,7 @@ module Repository # Build file path file_name = self.code + "-" + commit.id.to_s + ".tar.gz" - storage_path = File.join(Rails.root, "tmp", "repositories", self.code) + storage_path = Rails.root.join("tmp", "repositories", self.code) file_path = File.join(storage_path, file_name) # Put files into a directory before archiving diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 7a7ca43f..276707a7 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -112,7 +112,7 @@ class Settings < Settingslogic def backup_path t = app['backup_path'] || "backups/" - t = /^\//.match(t) ? t : File.join(Rails.root + t) + t = /^\//.match(t) ? t : Rails.root .join(t) t end diff --git a/db/fixtures/test/001_repo.rb b/db/fixtures/test/001_repo.rb index 67d4e7bf..18fc37cd 100644 --- a/db/fixtures/test/001_repo.rb +++ b/db/fixtures/test/001_repo.rb @@ -3,13 +3,13 @@ require 'fileutils' print "Unpacking seed repository..." SEED_REPO = 'seed_project.tar.gz' -REPO_PATH = File.join(Rails.root, 'tmp', 'repositories') +REPO_PATH = Rails.root.join('tmp', 'repositories') # Make whatever directories we need to make FileUtils.mkdir_p(REPO_PATH) # Copy the archive to the repo path -FileUtils.cp(File.join(Rails.root, 'spec', SEED_REPO), REPO_PATH) +FileUtils.cp(Rails.root.join('spec', SEED_REPO), REPO_PATH) # chdir to the repo path FileUtils.cd(REPO_PATH) do diff --git a/lib/gitlab/backend/gitolite_config.rb b/lib/gitlab/backend/gitolite_config.rb index f51e8efc..ffe15fb1 100644 --- a/lib/gitlab/backend/gitolite_config.rb +++ b/lib/gitlab/backend/gitolite_config.rb @@ -10,7 +10,7 @@ module Gitlab attr_reader :config_tmp_dir, :ga_repo, :conf def config_tmp_dir - @config_tmp_dir ||= File.join(Rails.root, 'tmp',"gitlabhq-gitolite-#{Time.now.to_i}") + @config_tmp_dir ||= Rails.root.join('tmp',"gitlabhq-gitolite-#{Time.now.to_i}") end def ga_repo @@ -19,7 +19,7 @@ module Gitlab def apply Timeout::timeout(30) do - File.open(File.join(Rails.root, 'tmp', "gitlabhq-gitolite.lock"), "w+") do |f| + File.open(Rails.root.join('tmp', "gitlabhq-gitolite.lock"), "w+") do |f| begin # Set exclusive lock # to prevent race condition diff --git a/lib/gitlab/logger.rb b/lib/gitlab/logger.rb index 9405163d..cf9a4c4a 100644 --- a/lib/gitlab/logger.rb +++ b/lib/gitlab/logger.rb @@ -15,7 +15,7 @@ module Gitlab end def self.build - new(File.join(Rails.root, "log", file_name)) + new(Rails.root.join("log", file_name)) end end end diff --git a/lib/gitlab/merge.rb b/lib/gitlab/merge.rb index 18013574..de8e737a 100644 --- a/lib/gitlab/merge.rb +++ b/lib/gitlab/merge.rb @@ -28,7 +28,7 @@ module Gitlab def process Grit::Git.with_timeout(30.seconds) do - lock_file = File.join(Rails.root, "tmp", "merge_repo_#{project.path}.lock") + lock_file = Rails.root.join("tmp", "merge_repo_#{project.path}.lock") File.open(lock_file, "w+") do |f| f.flock(File::LOCK_EX) @@ -36,7 +36,7 @@ module Gitlab unless project.satellite.exists? raise "You should run: rake gitlab:app:enable_automerge" end - + project.satellite.clear Dir.chdir(project.satellite.path) do diff --git a/lib/gitlab/satellite.rb b/lib/gitlab/satellite.rb index 4bcbfe8d..9d8dfb8e 100644 --- a/lib/gitlab/satellite.rb +++ b/lib/gitlab/satellite.rb @@ -1,6 +1,6 @@ module Gitlab class Satellite - + PARKING_BRANCH = "__parking_branch" attr_accessor :project @@ -14,7 +14,7 @@ module Gitlab end def path - File.join(Rails.root, "tmp", "repo_satellites", project.path) + Rails.root.join("tmp", "repo_satellites", project.path) end def exists? @@ -36,6 +36,6 @@ module Gitlab end end end - + end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index c313b58e..bb975a93 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -125,7 +125,7 @@ describe Project do it "should return path to repo" do project = Project.new(path: "somewhere") - project.path_to_repo.should == File.join(Rails.root, "tmp", "repositories", "somewhere") + project.path_to_repo.should == Rails.root.join("tmp", "repositories", "somewhere") end it "returns the full web URL for this repo" do diff --git a/spec/support/stubbed_repository.rb b/spec/support/stubbed_repository.rb index 90491e43..5bf3ea46 100644 --- a/spec/support/stubbed_repository.rb +++ b/spec/support/stubbed_repository.rb @@ -5,11 +5,11 @@ module StubbedRepository if new_record? || path == 'newproject' # There are a couple Project specs and features that expect the Project's # path to be in the returned path, so let's patronize them. - File.join(Rails.root, 'tmp', 'repositories', path) + Rails.root.join('tmp', 'repositories', path) else # For everything else, just give it the path to one of our real seeded # repos. - File.join(Rails.root, 'tmp', 'repositories', 'gitlabhq') + Rails.root.join('tmp', 'repositories', 'gitlabhq') end end From aa0c4b77b60acfc85d99e9eacaff25e34b136529 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 15:06:07 -0400 Subject: [PATCH 088/288] Add current_action? helper --- app/helpers/application_helper.rb | 15 +++++++++++++++ spec/helpers/application_helper_spec.rb | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f874851a..185e7d84 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,4 +1,5 @@ require 'digest/md5' + module ApplicationHelper # Check if a particular controller is the current one @@ -15,6 +16,20 @@ module ApplicationHelper args.any? { |v| v.to_s.downcase == controller.controller_name } end + # Check if a partcular action is the current one + # + # args - One or more action names to check + # + # Examples + # + # # On Projects#new + # current_action?(:new) # => true + # current_action?(:create) # => false + # current_action?(:new, :create) # => true + def current_action?(*args) + args.any? { |v| v.to_s.downcase == action_name } + end + def gravatar_icon(user_email = '', size = 40) if Gitlab.config.disable_gravatar? || user_email.blank? 'no_avatar.png' diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index fb711dd8..a94d5505 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -20,6 +20,25 @@ describe ApplicationHelper do end end + describe 'current_action?' do + before do + stub!(:action_name).and_return('foo') + end + + it "returns true when action matches argument" do + current_action?(:foo).should be_true + end + + it "returns false when action does not match argument" do + current_action?(:bar).should_not be_true + end + + it "should take any number of arguments" do + current_action?(:baz, :bar).should_not be_true + current_action?(:baz, :bar, :foo).should be_true + end + end + describe "gravatar_icon" do let(:user_email) { 'user@email.com' } From f064c84019f7414cb9cfa9e49fb735dba7f495df Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 16:13:23 -0400 Subject: [PATCH 089/288] Add nav_link helper to TabHelper --- app/helpers/tab_helper.rb | 68 +++++++++++++++++++++++++++++++++ spec/helpers/tab_helper_spec.rb | 44 +++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 spec/helpers/tab_helper_spec.rb diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index c26e3467..abd724b9 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -1,4 +1,72 @@ module TabHelper + # Navigation link helper + # + # Returns an `li` element with an 'active' class if the supplied + # controller(s) and/or action(s) currently active. The contents of the + # element is the value passed to the block. + # + # options - The options hash used to determine if the element is "active" (default: {}) + # :controller - One or more controller names to check (optional). + # :action - One or more action names to check (optional). + # :path - A shorthand path, such as 'dashboard#index', to check (optional). + # :html_options - Extra options to be passed to the list element (optional). + # block - An optional block that will become the contents of the returned + # `li` element. + # + # When both :controller and :action are specified, BOTH must match in order + # to be marked as active. When only one is given, either can match. + # + # Examples + # + # # Assuming we're on TreeController#show + # + # # Controller matches, but action doesn't + # nav_link(controller: [:tree, :refs], action: :edit) { "Hello" } + # # => '
  • Hello
  • ' + # + # # Controller matches + # nav_link(controller: [:tree, :refs]) { "Hello" } + # # => '
  • Hello
  • ' + # + # # Shorthand path + # nav_link(path: 'tree#show') { "Hello" } + # # => '
  • Hello
  • ' + # + # # Supplying custom options for the list element + # nav_link(controller: :tree, html_options: {class: 'home'}) { "Hello" } + # # => '
  • Hello
  • ' + # + # Returns a list item element String + def nav_link(options = {}, &block) + if path = options.delete(:path) + c, a, _ = path.split('#') + else + c = options.delete(:controller) + a = options.delete(:action) + end + + if c && a + # When given both options, make sure BOTH are active + klass = current_controller?(*c) && current_action?(*a) ? 'active' : '' + else + # Otherwise check EITHER option + klass = current_controller?(*c) || current_action?(*a) ? 'active' : '' + end + + # Add our custom class into the html_options, which may or may not exist + # and which may or may not already have a :class key + o = options.delete(:html_options) || {} + o[:class] ||= '' + o[:class] += ' ' + klass + o[:class].strip! + + if block_given? + content_tag(:li, capture(&block), o) + else + content_tag(:li, nil, o) + end + end + def tab_class(tab_key) active = case tab_key diff --git a/spec/helpers/tab_helper_spec.rb b/spec/helpers/tab_helper_spec.rb new file mode 100644 index 00000000..ef8e4cf6 --- /dev/null +++ b/spec/helpers/tab_helper_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' + +describe TabHelper do + include ApplicationHelper + + describe 'nav_link' do + before do + controller.stub!(:controller_name).and_return('foo') + stub!(:action_name).and_return('foo') + end + + it "captures block output" do + nav_link { "Testing Blocks" }.should match(/Testing Blocks/) + end + + it "performs checks on the current controller" do + nav_link(controller: :foo).should match(/
  • /) + nav_link(controller: :bar).should_not match(/active/) + nav_link(controller: [:foo, :bar]).should match(/active/) + end + + it "performs checks on the current action" do + nav_link(action: :foo).should match(/
  • /) + nav_link(action: :bar).should_not match(/active/) + nav_link(action: [:foo, :bar]).should match(/active/) + end + + it "performs checks on both controller and action when both are present" do + nav_link(controller: :bar, action: :foo).should_not match(/active/) + nav_link(controller: :foo, action: :bar).should_not match(/active/) + nav_link(controller: :foo, action: :foo).should match(/active/) + end + + it "accepts a path shorthand" do + nav_link(path: 'foo#bar').should_not match(/active/) + nav_link(path: 'foo#foo').should match(/active/) + end + + it "passes extra html options to the list element" do + nav_link(action: :foo, html_options: {class: 'home'}).should match(/
  • /) + nav_link(html_options: {class: 'active'}).should match(/
  • /) + end + end +end From 36f68140d1fcd89ed6bd92ac69cf13c566db63d5 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 16:14:17 -0400 Subject: [PATCH 090/288] Replace various "active tab" checks with nav_link Also remove now-unused tab_class helper --- app/helpers/tab_helper.rb | 44 +------------------ app/views/blame/_head.html.haml | 5 +-- app/views/commits/_head.html.haml | 16 +++---- app/views/issues/_head.html.haml | 15 +++---- app/views/layouts/_app_menu.html.haml | 10 ++--- app/views/layouts/_project_menu.html.haml | 22 +++++----- app/views/layouts/admin.html.haml | 12 ++--- app/views/layouts/profile.html.haml | 18 +++----- app/views/projects/_project_head.html.haml | 20 ++++----- .../repositories/_branches_head.html.haml | 15 +++---- app/views/tree/_head.html.haml | 5 +-- 11 files changed, 61 insertions(+), 121 deletions(-) diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index abd724b9..c76c1b6f 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -67,48 +67,6 @@ module TabHelper end end - def tab_class(tab_key) - active = case tab_key - - # Project Area - when :wall; wall_tab? - when :wiki; controller.controller_name == "wikis" - when :network; current_page?(controller: "projects", action: "graph", id: @project) - when :merge_requests; controller.controller_name == "merge_requests" - - # Dashboard Area - when :help; controller.controller_name == "help" - when :search; current_page?(search_path) - when :dash_issues; current_page?(dashboard_issues_path) - when :dash_mr; current_page?(dashboard_merge_requests_path) - when :root; current_page?(dashboard_path) || current_page?(root_path) - - # Profile Area - when :profile; current_page?(controller: "profile", action: :show) - when :history; current_page?(controller: "profile", action: :history) - when :account; current_page?(controller: "profile", action: :account) - when :token; current_page?(controller: "profile", action: :token) - when :design; current_page?(controller: "profile", action: :design) - when :ssh_keys; controller.controller_name == "keys" - - # Admin Area - when :admin_root; controller.controller_name == "dashboard" - when :admin_users; controller.controller_name == 'users' - when :admin_projects; controller.controller_name == "projects" - when :admin_hooks; controller.controller_name == 'hooks' - when :admin_resque; controller.controller_name == 'resque' - when :admin_logs; controller.controller_name == 'logs' - - else - false - end - active ? "active" : nil - end - - def wall_tab? - current_page?(controller: "projects", action: "wall", id: @project) - end - def project_tab_class [:show, :files, :edit, :update].each do |action| return "active" if current_page?(controller: "projects", action: action, id: @project) @@ -121,7 +79,7 @@ module TabHelper def branches_tab_class if current_page?(branches_project_repository_path(@project)) || - controller.controller_name == "protected_branches" || + current_controller?(:protected_branches) || current_page?(project_repository_path(@project)) 'active' end diff --git a/app/views/blame/_head.html.haml b/app/views/blame/_head.html.haml index 2a6052a1..3b027bda 100644 --- a/app/views/blame/_head.html.haml +++ b/app/views/blame/_head.html.haml @@ -1,9 +1,8 @@ %ul.nav.nav-tabs %li = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]} - %li{class: "#{'active' if (controller.controller_name == "refs") }"} - = link_to project_tree_path(@project, @ref) do - Source + = nav_link(controller: :refs) do + = link_to 'Source', project_tree_path(@project, @ref) %li.right .input-prepend.project_clone_holder %button{class: "btn small active", :"data-clone" => @project.ssh_url_to_repo} SSH diff --git a/app/views/commits/_head.html.haml b/app/views/commits/_head.html.haml index edaf8b86..26ae32ed 100644 --- a/app/views/commits/_head.html.haml +++ b/app/views/commits/_head.html.haml @@ -1,17 +1,17 @@ %ul.nav.nav-tabs %li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'} - %li{class: "#{'active' if current_controller?(:commit, :commits)}"} - = link_to project_commits_path(@project, @project.root_ref) do - Commits - %li{class: "#{'active' if current_controller?(:compare)}"} - = link_to project_compare_index_path(@project) do - Compare - %li{class: "#{branches_tab_class}"} + + = nav_link(controller: [:commit, :commits]) do + = link_to 'Commits', project_commits_path(@project, @project.root_ref) + = nav_link(controller: :compare) do + = link_to 'Compare', project_compare_index_path(@project) + + = nav_link(html_options: {class: branches_tab_class}) do = link_to project_repository_path(@project) do Branches %span.badge= @project.repo.branch_count - %li{class: "#{'active' if current_page?(tags_project_repository_path(@project)) }"} + = nav_link(controller: :repositories, action: :tags) do = link_to tags_project_repository_path(@project) do Tags %span.badge= @project.repo.tag_count diff --git a/app/views/issues/_head.html.haml b/app/views/issues/_head.html.haml index 8ebe3e05..4294503c 100644 --- a/app/views/issues/_head.html.haml +++ b/app/views/issues/_head.html.haml @@ -1,13 +1,10 @@ %ul.nav.nav-tabs - %li{class: "#{'active' if current_page?(project_issues_path(@project))}"} - = link_to project_issues_path(@project), class: "tab" do - Browse Issues - %li{class: "#{'active' if current_page?(project_milestones_path(@project))}"} - = link_to project_milestones_path(@project), class: "tab" do - Milestones - %li{class: "#{'active' if current_page?(project_labels_path(@project))}"} - = link_to project_labels_path(@project), class: "tab" do - Labels + = nav_link(controller: :issues) do + = link_to 'Browse Issues', project_issues_path(@project), class: "tab" + = nav_link(controller: :milestones) do + = link_to 'Milestones', project_milestones_path(@project), class: "tab" + = nav_link(controller: :labels) do + = link_to 'Labels', project_labels_path(@project), class: "tab" %li.right %span.rss-icon = link_to project_issues_path(@project, :atom, { private_token: current_user.private_token }) do diff --git a/app/views/layouts/_app_menu.html.haml b/app/views/layouts/_app_menu.html.haml index 02531489..8fac1b39 100644 --- a/app/views/layouts/_app_menu.html.haml +++ b/app/views/layouts/_app_menu.html.haml @@ -1,19 +1,19 @@ %ul.main_menu - %li.home{class: tab_class(:root)} + = nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do = link_to "Home", root_path, title: "Home" - %li{class: tab_class(:dash_issues)} + = nav_link(path: 'dashboard#issues') do = link_to dashboard_issues_path do Issues %span.count= current_user.assigned_issues.opened.count - %li{class: tab_class(:dash_mr)} + = nav_link(path: 'dashboard#merge_requests') do = link_to dashboard_merge_requests_path do Merge Requests %span.count= current_user.cared_merge_requests.count - %li{class: tab_class(:search)} + = nav_link(path: 'search#show') do = link_to "Search", search_path - %li{class: tab_class(:help)} + = nav_link(path: 'help#index') do = link_to "Help", help_path diff --git a/app/views/layouts/_project_menu.html.haml b/app/views/layouts/_project_menu.html.haml index d69f9a0b..72c39619 100644 --- a/app/views/layouts/_project_menu.html.haml +++ b/app/views/layouts/_project_menu.html.haml @@ -1,35 +1,33 @@ %ul.main_menu - %li.home{class: project_tab_class} + = nav_link(html_options: {class: "home #{project_tab_class}"}) do = link_to @project.code, project_path(@project), title: "Project" - if @project.repo_exists? - if can? current_user, :download_code, @project - %li{class: current_controller?(:tree, :blob, :blame) ? 'active' : ''} + = nav_link(controller: %w(tree blob blame)) do = link_to 'Files', project_tree_path(@project, @ref || @project.root_ref) - %li{class: current_controller?(:commit, :commits, :compare, :repositories, :protected_branches) ? 'active' : ''} + = nav_link(controller: %w(commit commits compare repositories protected_branches)) do = link_to "Commits", project_commits_path(@project, @ref || @project.root_ref) - %li{class: tab_class(:network)} + = nav_link(path: 'projects#graph') do = link_to "Network", graph_project_path(@project) - if @project.issues_enabled - %li{class: current_controller?(:issues, :milestones, :labels) ? 'active' : ''} + = nav_link(controller: %w(issues milestones labels)) do = link_to project_issues_filter_path(@project) do Issues %span.count.issue_counter= @project.issues.opened.count - if @project.repo_exists? - if @project.merge_requests_enabled - %li{class: tab_class(:merge_requests)} + = nav_link(controller: :merge_requests) do = link_to project_merge_requests_path(@project) do Merge Requests %span.count.merge_counter= @project.merge_requests.opened.count - if @project.wall_enabled - %li{class: tab_class(:wall)} - = link_to wall_project_path(@project) do - Wall + = nav_link(path: 'projects#wall') do + = link_to 'Wall', wall_project_path(@project) - if @project.wiki_enabled - %li{class: tab_class(:wiki)} - = link_to project_wiki_path(@project, :index) do - Wiki + = nav_link(controller: :wikis) do + = link_to 'Wiki', project_wiki_path(@project, :index) diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 6af0f641..dbb6939d 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -6,17 +6,17 @@ = render "layouts/head_panel", title: "Admin area" .container %ul.main_menu - %li.home{class: tab_class(:admin_root)} + = nav_link(controller: :dashboard, html_options: {class: 'home'}) do = link_to "Stats", admin_root_path - %li{class: tab_class(:admin_projects)} + = nav_link(controller: :projects) do = link_to "Projects", admin_projects_path - %li{class: tab_class(:admin_users)} + = nav_link(controller: :users) do = link_to "Users", admin_users_path - %li{class: tab_class(:admin_logs)} + = nav_link(controller: :logs) do = link_to "Logs", admin_logs_path - %li{class: tab_class(:admin_hooks)} + = nav_link(controller: :hooks) do = link_to "Hooks", admin_hooks_path - %li{class: tab_class(:admin_resque)} + = nav_link(controller: :resque) do = link_to "Resque", admin_resque_path .content= yield diff --git a/app/views/layouts/profile.html.haml b/app/views/layouts/profile.html.haml index 62c8db5b..7a54bb7c 100644 --- a/app/views/layouts/profile.html.haml +++ b/app/views/layouts/profile.html.haml @@ -6,23 +6,17 @@ = render "layouts/head_panel", title: "Profile" .container %ul.main_menu - %li.home{class: tab_class(:profile)} + = nav_link(path: 'profile#show', html_options: {class: 'home'}) do = link_to "Profile", profile_path - - %li{class: tab_class(:account)} + = nav_link(path: 'profile#account') do = link_to "Account", profile_account_path - - %li{class: tab_class(:ssh_keys)} + = nav_link(controller: :keys) do = link_to keys_path do SSH Keys %span.count= current_user.keys.count - - %li{class: tab_class(:design)} + = nav_link(path: 'profile#design') do = link_to "Design", profile_design_path - - %li{class: tab_class(:history)} + = nav_link(path: 'profile#history') do = link_to "History", profile_history_path - - .content - = yield + .content= yield diff --git a/app/views/projects/_project_head.html.haml b/app/views/projects/_project_head.html.haml index 4f38bef8..47a79073 100644 --- a/app/views/projects/_project_head.html.haml +++ b/app/views/projects/_project_head.html.haml @@ -1,29 +1,27 @@ %ul.nav.nav-tabs - %li{ class: "#{'active' if current_page?(project_path(@project)) }" } + = nav_link(path: 'projects#show') do = link_to project_path(@project), class: "activities-tab tab" do %i.icon-home Show - %li{ class: " #{'active' if (controller.controller_name == "team_members") || current_page?(project_team_index_path(@project)) }" } + = nav_link(controller: :team_members) do = link_to project_team_index_path(@project), class: "team-tab tab" do %i.icon-user Team - %li{ class: "#{'active' if current_page?(files_project_path(@project)) }" } - = link_to files_project_path(@project), class: "files-tab tab " do - Attachments - %li{ class: " #{'active' if (controller.controller_name == "snippets") }" } - = link_to project_snippets_path(@project), class: "snippets-tab tab" do - Snippets + = nav_link(path: 'projects#files') do + = link_to 'Attachments', files_project_path(@project), class: "files-tab tab" + = nav_link(controller: :snippets) do + = link_to 'Snippets', project_snippets_path(@project), class: "snippets-tab tab" - if can? current_user, :admin_project, @project - %li.right{class: "#{'active' if controller.controller_name == "deploy_keys"}"} + = nav_link(controller: :deploy_keys, html_options: {class: 'right'}) do = link_to project_deploy_keys_path(@project) do %span Deploy Keys - %li.right{class: "#{'active' if controller.controller_name == "hooks" }"} + = nav_link(controller: :hooks, html_options: {class: 'right'}) do = link_to project_hooks_path(@project) do %span Hooks - %li.right{ class: "#{'active' if current_page?(edit_project_path(@project)) }" } + = nav_link(path: 'projects#edit', html_options: {class: 'right'}) do = link_to edit_project_path(@project), class: "stat-tab tab " do %i.icon-edit Edit diff --git a/app/views/repositories/_branches_head.html.haml b/app/views/repositories/_branches_head.html.haml index 6afff627..25a988cf 100644 --- a/app/views/repositories/_branches_head.html.haml +++ b/app/views/repositories/_branches_head.html.haml @@ -1,11 +1,8 @@ = render "commits/head" %ul.nav.nav-pills - %li{class: ("active" if current_page?(project_repository_path(@project)))} - = link_to project_repository_path(@project) do - Recent - %li{class: ("active" if current_page?(project_protected_branches_path(@project)))} - = link_to project_protected_branches_path(@project) do - Protected - %li{class: ("active" if current_page?(branches_project_repository_path(@project)))} - = link_to branches_project_repository_path(@project) do - All + = nav_link(path: 'repositories#show') do + = link_to 'Recent', project_repository_path(@project) + = nav_link(path: 'protected_branches#index') do + = link_to 'Protected', project_protected_branches_path(@project) + = nav_link(path: 'repositories#branches') do + = link_to 'All', branches_project_repository_path(@project) diff --git a/app/views/tree/_head.html.haml b/app/views/tree/_head.html.haml index c7ebbf88..f1b3f63f 100644 --- a/app/views/tree/_head.html.haml +++ b/app/views/tree/_head.html.haml @@ -1,9 +1,8 @@ %ul.nav.nav-tabs %li = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: @path} - %li{class: "#{'active' if (controller.controller_name == "tree") }"} - = link_to project_tree_path(@project, @ref) do - Source + = nav_link(controller: :tree) do + = link_to 'Source', project_tree_path(@project, @ref) %li.right .input-prepend.project_clone_holder %button{class: "btn small active", :"data-clone" => @project.ssh_url_to_repo} SSH From 8432c9c176d9a5e646fe007a9cd333b31197abeb Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 16:45:00 -0400 Subject: [PATCH 091/288] Routes are now final --- config/routes.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index decf860b..21521a97 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -159,7 +159,6 @@ Gitlab::Application.routes.draw do end end - # XXX: WIP resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} resources :commits, only: [:show], constraints: {id: /.+/} resources :compare, only: [:index, :create] From d8f7748dea5d43a16babd15dd02dcbc76220da5a Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 26 Sep 2012 17:00:52 -0400 Subject: [PATCH 092/288] Remove app_menu and project_menu partials Now it's consistent across layouts where their main menus are. --- app/views/layouts/_app_menu.html.haml | 19 ------------ app/views/layouts/_project_menu.html.haml | 33 --------------------- app/views/layouts/application.html.haml | 20 +++++++++++-- app/views/layouts/project.html.haml | 36 +++++++++++++++++++++-- 4 files changed, 50 insertions(+), 58 deletions(-) delete mode 100644 app/views/layouts/_app_menu.html.haml delete mode 100644 app/views/layouts/_project_menu.html.haml diff --git a/app/views/layouts/_app_menu.html.haml b/app/views/layouts/_app_menu.html.haml deleted file mode 100644 index 8fac1b39..00000000 --- a/app/views/layouts/_app_menu.html.haml +++ /dev/null @@ -1,19 +0,0 @@ -%ul.main_menu - = nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do - = link_to "Home", root_path, title: "Home" - - = nav_link(path: 'dashboard#issues') do - = link_to dashboard_issues_path do - Issues - %span.count= current_user.assigned_issues.opened.count - - = nav_link(path: 'dashboard#merge_requests') do - = link_to dashboard_merge_requests_path do - Merge Requests - %span.count= current_user.cared_merge_requests.count - - = nav_link(path: 'search#show') do - = link_to "Search", search_path - - = nav_link(path: 'help#index') do - = link_to "Help", help_path diff --git a/app/views/layouts/_project_menu.html.haml b/app/views/layouts/_project_menu.html.haml deleted file mode 100644 index 72c39619..00000000 --- a/app/views/layouts/_project_menu.html.haml +++ /dev/null @@ -1,33 +0,0 @@ -%ul.main_menu - = nav_link(html_options: {class: "home #{project_tab_class}"}) do - = link_to @project.code, project_path(@project), title: "Project" - - - if @project.repo_exists? - - if can? current_user, :download_code, @project - = nav_link(controller: %w(tree blob blame)) do - = link_to 'Files', project_tree_path(@project, @ref || @project.root_ref) - = nav_link(controller: %w(commit commits compare repositories protected_branches)) do - = link_to "Commits", project_commits_path(@project, @ref || @project.root_ref) - = nav_link(path: 'projects#graph') do - = link_to "Network", graph_project_path(@project) - - - if @project.issues_enabled - = nav_link(controller: %w(issues milestones labels)) do - = link_to project_issues_filter_path(@project) do - Issues - %span.count.issue_counter= @project.issues.opened.count - - - if @project.repo_exists? - - if @project.merge_requests_enabled - = nav_link(controller: :merge_requests) do - = link_to project_merge_requests_path(@project) do - Merge Requests - %span.count.merge_counter= @project.merge_requests.opened.count - - - if @project.wall_enabled - = nav_link(path: 'projects#wall') do - = link_to 'Wall', wall_project_path(@project) - - - if @project.wiki_enabled - = nav_link(controller: :wikis) do - = link_to 'Wiki', project_wiki_path(@project, :index) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index dda10d5d..40f4f88c 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -5,6 +5,20 @@ = render "layouts/flash" = render "layouts/head_panel", title: "Dashboard" .container - = render partial: "layouts/app_menu" - .content - = yield + %ul.main_menu + = nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do + = link_to "Home", root_path, title: "Home" + = nav_link(path: 'dashboard#issues') do + = link_to dashboard_issues_path do + Issues + %span.count= current_user.assigned_issues.opened.count + = nav_link(path: 'dashboard#merge_requests') do + = link_to dashboard_merge_requests_path do + Merge Requests + %span.count= current_user.cared_merge_requests.count + = nav_link(path: 'search#show') do + = link_to "Search", search_path + = nav_link(path: 'help#index') do + = link_to "Help", help_path + + .content= yield diff --git a/app/views/layouts/project.html.haml b/app/views/layouts/project.html.haml index 56a947d2..b1dbe41c 100644 --- a/app/views/layouts/project.html.haml +++ b/app/views/layouts/project.html.haml @@ -5,7 +5,37 @@ = render "layouts/flash" = render "layouts/head_panel", title: @project.name .container - = render partial: "layouts/project_menu" - .content - = yield + %ul.main_menu + = nav_link(html_options: {class: "home #{project_tab_class}"}) do + = link_to @project.code, project_path(@project), title: "Project" + - if @project.repo_exists? + - if can? current_user, :download_code, @project + = nav_link(controller: %w(tree blob blame)) do + = link_to 'Files', project_tree_path(@project, @ref || @project.root_ref) + = nav_link(controller: %w(commit commits compare repositories protected_branches)) do + = link_to "Commits", project_commits_path(@project, @ref || @project.root_ref) + = nav_link(path: 'projects#graph') do + = link_to "Network", graph_project_path(@project) + + - if @project.issues_enabled + = nav_link(controller: %w(issues milestones labels)) do + = link_to project_issues_filter_path(@project) do + Issues + %span.count.issue_counter= @project.issues.opened.count + + - if @project.repo_exists? && @project.merge_requests_enabled + = nav_link(controller: :merge_requests) do + = link_to project_merge_requests_path(@project) do + Merge Requests + %span.count.merge_counter= @project.merge_requests.opened.count + + - if @project.wall_enabled + = nav_link(path: 'projects#wall') do + = link_to 'Wall', wall_project_path(@project) + + - if @project.wiki_enabled + = nav_link(controller: :wikis) do + = link_to 'Wiki', project_wiki_path(@project, :index) + + .content= yield From beb324c1c6518f4ad20039b4122ef6d59ba430c2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 27 Sep 2012 09:49:00 +0300 Subject: [PATCH 093/288] Fixed updir method. Fixed breadcrumbs for commits --- app/decorators/tree_decorator.rb | 8 ++++---- app/views/commits/show.html.haml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/decorators/tree_decorator.rb b/app/decorators/tree_decorator.rb index 97981785..38236c2c 100644 --- a/app/decorators/tree_decorator.rb +++ b/app/decorators/tree_decorator.rb @@ -6,7 +6,7 @@ class TreeDecorator < ApplicationDecorator part_path = "" parts = path.split("\/") - #parts = parts[0...-1] if is_blob? + #parts = parts[0...-1] if is_blob? yield(h.link_to("..", "#", remote: :true)) if parts.count > max_links @@ -21,7 +21,7 @@ class TreeDecorator < ApplicationDecorator end def up_dir? - !!path + path.present? end def up_dir_path @@ -36,8 +36,8 @@ class TreeDecorator < ApplicationDecorator def mb_size size = (tree.size / 1024) if size < 1024 - "#{size} KB" - else + "#{size} KB" + else "#{size/1024} MB" end end diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml index 11ffdb6a..a4f16465 100644 --- a/app/views/commits/show.html.haml +++ b/app/views/commits/show.html.haml @@ -1,6 +1,6 @@ = render "head" -- if params[:path] +- if @path %ul.breadcrumb %li %span.arrow @@ -9,7 +9,7 @@ %span.divider \/ %li - %a{href: "#"}= params[:path].split("/").join(" / ") + %a{href: "#"}= @path.split("/").join(" / ") %div{id: dom_id(@project)} #commits_list= render "commits" From 2c8d3c33ff64ac6af5daf125a2f9ef917e55bcfc Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 27 Sep 2012 09:53:42 +0300 Subject: [PATCH 094/288] Fixed ref switcher --- app/helpers/application_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 185e7d84..911b46c9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -60,8 +60,8 @@ module ApplicationHelper def grouped_options_refs(destination = :tree) options = [ - ["Branch", @project.repo.heads.map(&:name) ], - [ "Tag", @project.tags ] + ["Branch", @project.branch_names ], + [ "Tag", @project.tag_names ] ] # If reference is commit id - From a8870e87e4cc8ce441032dc6aa3dfa6e1812090e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 27 Sep 2012 11:58:41 +0300 Subject: [PATCH 095/288] Fix blame markup & breadcrubs for commits --- app/assets/stylesheets/gitlab_bootstrap/files.scss | 12 ++++++++++++ app/views/commits/show.html.haml | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/gitlab_bootstrap/files.scss b/app/assets/stylesheets/gitlab_bootstrap/files.scss index d39fdb27..cbc58d22 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/files.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/files.scss @@ -68,10 +68,22 @@ * Blame file */ &.blame { + table { + border:none; + box-shadow:none; + margin:0; + } tr { border-bottom: 1px solid #eee; } td { + &:first-child { + border-left:none; + } + &:last-child { + border-right:none; + } + background:#fff; padding:5px; } .author, diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml index a4f16465..ac063638 100644 --- a/app/views/commits/show.html.haml +++ b/app/views/commits/show.html.haml @@ -1,6 +1,6 @@ = render "head" -- if @path +- if @path.present? %ul.breadcrumb %li %span.arrow From 2a4359a572c123d117988487f9bb29f4ae176ceb Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 26 Sep 2012 22:36:31 -0700 Subject: [PATCH 096/288] annotate models --- app/models/event.rb | 10 +++++----- app/models/issue.rb | 15 +++++++-------- app/models/key.rb | 6 +++--- app/models/merge_request.rb | 14 +++++++------- app/models/milestone.rb | 6 +++--- app/models/note.rb | 6 +++--- app/models/project.rb | 14 +++++++------- app/models/project_hook.rb | 12 ++++++++++++ app/models/protected_branch.rb | 4 ++-- app/models/snippet.rb | 6 +++--- app/models/system_hook.rb | 12 ++++++++++++ app/models/user.rb | 19 ++++++++++++------- app/models/users_project.rb | 8 ++++---- app/models/web_hook.rb | 5 +++-- app/models/wiki.rb | 6 +++--- 15 files changed, 86 insertions(+), 57 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 76e428ad..e77afb98 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -144,15 +144,15 @@ end # # Table name: events # -# id :integer(4) not null, primary key +# id :integer not null, primary key # target_type :string(255) -# target_id :integer(4) +# target_id :integer # title :string(255) # data :text -# project_id :integer(4) +# project_id :integer # created_at :datetime not null # updated_at :datetime not null -# action :integer(4) -# author_id :integer(4) +# action :integer +# author_id :integer # diff --git a/app/models/issue.rb b/app/models/issue.rb index e1181b97..5e7616d6 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -36,18 +36,17 @@ end # # Table name: issues # -# id :integer(4) not null, primary key +# id :integer not null, primary key # title :string(255) -# assignee_id :integer(4) -# author_id :integer(4) -# project_id :integer(4) +# assignee_id :integer +# author_id :integer +# project_id :integer # created_at :datetime not null # updated_at :datetime not null -# closed :boolean(1) default(FALSE), not null -# position :integer(4) default(0) -# critical :boolean(1) default(FALSE), not null +# closed :boolean default(FALSE), not null +# position :integer default(0) # branch_name :string(255) # description :text -# milestone_id :integer(4) +# milestone_id :integer # diff --git a/app/models/key.rb b/app/models/key.rb index e23447e6..eadfcd85 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -61,13 +61,13 @@ end # # Table name: keys # -# id :integer(4) not null, primary key -# user_id :integer(4) +# id :integer not null, primary key +# user_id :integer # created_at :datetime not null # updated_at :datetime not null # key :text # title :string(255) # identifier :string(255) -# project_id :integer(4) +# project_id :integer # diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 717fe296..1e73276e 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -191,19 +191,19 @@ end # # Table name: merge_requests # -# id :integer(4) not null, primary key +# id :integer not null, primary key # target_branch :string(255) not null # source_branch :string(255) not null -# project_id :integer(4) not null -# author_id :integer(4) -# assignee_id :integer(4) +# project_id :integer not null +# author_id :integer +# assignee_id :integer # title :string(255) -# closed :boolean(1) default(FALSE), not null +# closed :boolean default(FALSE), not null # created_at :datetime not null # updated_at :datetime not null # st_commits :text(2147483647 # st_diffs :text(2147483647 -# merged :boolean(1) default(FALSE), not null -# state :integer(4) default(1), not null +# merged :boolean default(FALSE), not null +# state :integer default(1), not null # diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 65fa461f..9014647c 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -2,12 +2,12 @@ # # Table name: milestones # -# id :integer(4) not null, primary key +# id :integer not null, primary key # title :string(255) not null -# project_id :integer(4) not null +# project_id :integer not null # description :text # due_date :date -# closed :boolean(1) default(FALSE), not null +# closed :boolean default(FALSE), not null # created_at :datetime not null # updated_at :datetime not null # diff --git a/app/models/note.rb b/app/models/note.rb index 9ac77ef7..84913970 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -118,14 +118,14 @@ end # # Table name: notes # -# id :integer(4) not null, primary key +# id :integer not null, primary key # note :text # noteable_id :string(255) # noteable_type :string(255) -# author_id :integer(4) +# author_id :integer # created_at :datetime not null # updated_at :datetime not null -# project_id :integer(4) +# project_id :integer # attachment :string(255) # line_code :string(255) # diff --git a/app/models/project.rb b/app/models/project.rb index 7470bd95..39e2bb25 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -182,19 +182,19 @@ end # # Table name: projects # -# id :integer(4) not null, primary key +# id :integer not null, primary key # name :string(255) # path :string(255) # description :text # created_at :datetime not null # updated_at :datetime not null -# private_flag :boolean(1) default(TRUE), not null +# private_flag :boolean default(TRUE), not null # code :string(255) -# owner_id :integer(4) +# owner_id :integer # default_branch :string(255) -# issues_enabled :boolean(1) default(TRUE), not null -# wall_enabled :boolean(1) default(TRUE), not null -# merge_requests_enabled :boolean(1) default(TRUE), not null -# wiki_enabled :boolean(1) default(TRUE), not null +# issues_enabled :boolean default(TRUE), not null +# wall_enabled :boolean default(TRUE), not null +# merge_requests_enabled :boolean default(TRUE), not null +# wiki_enabled :boolean default(TRUE), not null # diff --git a/app/models/project_hook.rb b/app/models/project_hook.rb index 06388aae..e7a05d57 100644 --- a/app/models/project_hook.rb +++ b/app/models/project_hook.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: web_hooks +# +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# type :string(255) default("ProjectHook") +# + class ProjectHook < WebHook belongs_to :project end diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index 4ea083c1..42182864 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -22,8 +22,8 @@ end # # Table name: protected_branches # -# id :integer(4) not null, primary key -# project_id :integer(4) not null +# id :integer not null, primary key +# project_id :integer not null # name :string(255) not null # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/snippet.rb b/app/models/snippet.rb index bfd28684..10e37645 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -63,11 +63,11 @@ end # # Table name: snippets # -# id :integer(4) not null, primary key +# id :integer not null, primary key # title :string(255) # content :text -# author_id :integer(4) not null -# project_id :integer(4) not null +# author_id :integer not null +# project_id :integer not null # created_at :datetime not null # updated_at :datetime not null # file_name :string(255) diff --git a/app/models/system_hook.rb b/app/models/system_hook.rb index 8517d43a..89c69fce 100644 --- a/app/models/system_hook.rb +++ b/app/models/system_hook.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: web_hooks +# +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# type :string(255) default("ProjectHook") +# + class SystemHook < WebHook def async_execute(data) diff --git a/app/models/user.rb b/app/models/user.rb index a8626cc1..f33f01fd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -111,13 +111,13 @@ end # # Table name: users # -# id :integer(4) not null, primary key +# id :integer not null, primary key # email :string(255) default(""), not null # encrypted_password :string(128) default(""), not null # reset_password_token :string(255) # reset_password_sent_at :datetime # remember_created_at :datetime -# sign_in_count :integer(4) default(0) +# sign_in_count :integer default(0) # current_sign_in_at :datetime # last_sign_in_at :datetime # current_sign_in_ip :string(255) @@ -125,14 +125,19 @@ end # created_at :datetime not null # updated_at :datetime not null # name :string(255) -# admin :boolean(1) default(FALSE), not null -# projects_limit :integer(4) default(10) +# admin :boolean default(FALSE), not null +# projects_limit :integer default(10) # skype :string(255) default(""), not null # linkedin :string(255) default(""), not null # twitter :string(255) default(""), not null # authentication_token :string(255) -# dark_scheme :boolean(1) default(FALSE), not null -# theme_id :integer(4) default(1), not null +# dark_scheme :boolean default(FALSE), not null +# theme_id :integer default(1), not null # bio :string(255) -# blocked :boolean(1) default(FALSE), not null +# blocked :boolean default(FALSE), not null +# failed_attempts :integer default(0) +# locked_at :datetime +# extern_uid :string(255) +# provider :string(255) # + diff --git a/app/models/users_project.rb b/app/models/users_project.rb index c42cc865..171bf2bb 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -92,11 +92,11 @@ end # # Table name: users_projects # -# id :integer(4) not null, primary key -# user_id :integer(4) not null -# project_id :integer(4) not null +# id :integer not null, primary key +# user_id :integer not null +# project_id :integer not null # created_at :datetime not null # updated_at :datetime not null -# project_access :integer(4) default(0), not null +# project_access :integer default(0), not null # diff --git a/app/models/web_hook.rb b/app/models/web_hook.rb index 5d826d2f..b2e481e6 100644 --- a/app/models/web_hook.rb +++ b/app/models/web_hook.rb @@ -30,10 +30,11 @@ end # # Table name: web_hooks # -# id :integer(4) not null, primary key +# id :integer not null, primary key # url :string(255) -# project_id :integer(4) +# project_id :integer # created_at :datetime not null # updated_at :datetime not null +# type :string(255) default("ProjectHook") # diff --git a/app/models/wiki.rb b/app/models/wiki.rb index b053f5ad..a81a151b 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -36,13 +36,13 @@ end # # Table name: wikis # -# id :integer(4) not null, primary key +# id :integer not null, primary key # title :string(255) # content :text -# project_id :integer(4) +# project_id :integer # created_at :datetime not null # updated_at :datetime not null # slug :string(255) -# user_id :integer(4) +# user_id :integer # From 841e4fbd08d2d642c127506001a76a973ea3d536 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 26 Sep 2012 23:20:36 -0700 Subject: [PATCH 097/288] cosmetical cleanup of models --- app/models/ability.rb | 1 - app/models/commit.rb | 22 +++--------- app/models/event.rb | 11 +++--- app/models/issue.rb | 5 ++- app/models/key.rb | 16 ++++----- app/models/merge_request.rb | 5 ++- app/models/milestone.rb | 31 ++++++++-------- app/models/note.rb | 40 +++++++-------------- app/models/project.rb | 44 ++++++----------------- app/models/project_hook.rb | 8 ++--- app/models/protected_branch.rb | 5 ++- app/models/snippet.rb | 25 ++++--------- app/models/system_hook.rb | 26 +++++++------- app/models/tree.rb | 12 ++----- app/models/user.rb | 65 +++++++++------------------------- app/models/users_project.rb | 2 +- app/models/web_hook.rb | 14 +++----- app/models/wiki.rb | 2 +- 18 files changed, 108 insertions(+), 226 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index d65695a2..20ded59b 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -52,7 +52,6 @@ class Ability :admin_wiki ] if project.master_access_for?(user) || project.owner == user - rules.flatten end diff --git a/app/models/commit.rb b/app/models/commit.rb index 73583e9e..aba21762 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -4,24 +4,11 @@ class Commit include StaticModel extend ActiveModel::Naming - attr_accessor :commit - attr_accessor :head - attr_accessor :refs + attr_accessor :commit, :head, :refs - delegate :message, - :authored_date, - :committed_date, - :parents, - :sha, - :date, - :committer, - :author, - :message, - :diffs, - :tree, - :id, - :to_patch, - to: :commit + delegate :message, :authored_date, :committed_date, :parents, :sha, + :date, :committer, :author, :message, :diffs, :tree, :id, + :to_patch, to: :commit class << self def find_or_first(repo, commit_id = nil, root_ref) @@ -30,6 +17,7 @@ class Commit else repo.commits(root_ref).first end + Commit.new(commit) if commit end diff --git a/app/models/event.rb b/app/models/event.rb index e77afb98..43131ad6 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -16,6 +16,10 @@ class Event < ActiveRecord::Base Joined = 8 # User joined project Left = 9 # User left project + delegate :name, :email, to: :author, prefix: true, allow_nil: true + delegate :title, to: :issue, prefix: true, allow_nil: true + delegate :title, to: :merge_request, prefix: true, allow_nil: true + belongs_to :project belongs_to :target, polymorphic: true @@ -134,12 +138,8 @@ class Event < ActiveRecord::Base "opened" end end - - - delegate :name, :email, to: :author, prefix: true, allow_nil: true - delegate :title, to: :issue, prefix: true, allow_nil: true - delegate :title, to: :merge_request, prefix: true, allow_nil: true end + # == Schema Information # # Table name: events @@ -155,4 +155,3 @@ end # action :integer # author_id :integer # - diff --git a/app/models/issue.rb b/app/models/issue.rb index 5e7616d6..9acee1e5 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -9,8 +9,7 @@ class Issue < ActiveRecord::Base belongs_to :milestone - validates :description, - length: { within: 0..2000 } + validates :description, length: { within: 0..2000 } def self.open_for(user) opened.assigned(user) @@ -32,6 +31,7 @@ class Issue < ActiveRecord::Base closed_changed? && !closed end end + # == Schema Information # # Table name: issues @@ -49,4 +49,3 @@ end # description :text # milestone_id :integer # - diff --git a/app/models/key.rb b/app/models/key.rb index eadfcd85..3ef21811 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -6,14 +6,10 @@ class Key < ActiveRecord::Base attr_accessible :key, :title - validates :title, - presence: true, - length: { within: 0..255 } - - validates :key, - presence: true, - format: { :with => /ssh-.{3} / }, - length: { within: 0..5000 } + validates :title, presence: true, length: { within: 0..255 } + validates :key, presence: true, + length: { within: 0..5000 }, + format: { :with => /ssh-.{3} / } before_save :set_identifier before_validation :strip_white_space @@ -34,7 +30,7 @@ class Key < ActiveRecord::Base def set_identifier if is_deploy_key - self.identifier = "deploy_" + Digest::MD5.hexdigest(key) + self.identifier = "deploy_#{Digest::MD5.hexdigest(key)}" else self.identifier = "#{user.identifier}_#{Time.now.to_i}" end @@ -57,6 +53,7 @@ class Key < ActiveRecord::Base Key.where(identifier: identifier).count == 0 end end + # == Schema Information # # Table name: keys @@ -70,4 +67,3 @@ end # identifier :string(255) # project_id :integer # - diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 1e73276e..8428c7c4 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -18,8 +18,7 @@ class MergeRequest < ActiveRecord::Base attr_accessor :should_remove_source_branch - validates_presence_of :source_branch - validates_presence_of :target_branch + validates_presence_of :source_branch, :target_branch validate :validate_branches def self.find_all_by_branch(branch_name) @@ -187,6 +186,7 @@ class MergeRequest < ActiveRecord::Base patch_path end end + # == Schema Information # # Table name: merge_requests @@ -206,4 +206,3 @@ end # merged :boolean default(FALSE), not null # state :integer default(1), not null # - diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 9014647c..da54ac40 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -1,25 +1,10 @@ -# == Schema Information -# -# Table name: milestones -# -# id :integer not null, primary key -# title :string(255) not null -# project_id :integer not null -# description :text -# due_date :date -# closed :boolean default(FALSE), not null -# created_at :datetime not null -# updated_at :datetime not null -# - class Milestone < ActiveRecord::Base attr_accessible :title, :description, :due_date, :closed belongs_to :project has_many :issues - validates_presence_of :project_id - validates_presence_of :title + validates_presence_of :title, :project_id def self.active where("due_date > ? OR due_date IS NULL", Date.today) @@ -39,3 +24,17 @@ class Milestone < ActiveRecord::Base "expires at #{due_date.stamp("Aug 21, 2011")}" if due_date end end + +# == Schema Information +# +# Table name: milestones +# +# id :integer not null, primary key +# title :string(255) not null +# project_id :integer not null +# description :text +# due_date :date +# closed :boolean default(FALSE), not null +# created_at :datetime not null +# updated_at :datetime not null +# diff --git a/app/models/note.rb b/app/models/note.rb index 84913970..23ced536 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -2,39 +2,26 @@ require 'carrierwave/orm/activerecord' require 'file_size_validator' class Note < ActiveRecord::Base + mount_uploader :attachment, AttachmentUploader attr_accessible :note, :noteable, :noteable_id, :noteable_type, :project_id, :attachment, :line_code belongs_to :project belongs_to :noteable, polymorphic: true - belongs_to :author, - class_name: "User" + belongs_to :author, class_name: "User" - delegate :name, - to: :project, - prefix: true - - delegate :name, - :email, - to: :author, - prefix: true + delegate :name, to: :project, prefix: true + delegate :name, :email, to: :author, prefix: true attr_accessor :notify attr_accessor :notify_author validates_presence_of :project - validates :note, - presence: true, - length: { within: 0..5000 } - - validates :attachment, - file_size: { - maximum: 10.megabytes.to_i - } + validates :note, presence: true, length: { within: 0..5000 } + validates :attachment, file_size: { maximum: 10.megabytes.to_i } scope :common, where(noteable_id: nil) - scope :today, where("created_at >= :date", date: Date.today) scope :last_week, where("created_at >= :date", date: (Date.today - 7.days)) scope :since, lambda { |day| where("created_at >= :date", date: (day)) } @@ -42,14 +29,13 @@ class Note < ActiveRecord::Base scope :inc_author_project, includes(:project, :author) scope :inc_author, includes(:author) - mount_uploader :attachment, AttachmentUploader - def self.create_status_change_note(noteable, author, status) - create({ noteable: noteable, - project: noteable.project, - author: author, - note: "_Status changed to #{status}_" }, - without_protection: true) + create({ + noteable: noteable, + project: noteable.project, + author: author, + note: "_Status changed to #{status}_" + }, without_protection: true) end def notify @@ -114,6 +100,7 @@ class Note < ActiveRecord::Base note.start_with?('-1') || note.start_with?(':-1:') end end + # == Schema Information # # Table name: notes @@ -129,4 +116,3 @@ end # attachment :string(255) # line_code :string(255) # - diff --git a/app/models/project.rb b/app/models/project.rb index 39e2bb25..0652d187 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -8,10 +8,9 @@ class Project < ActiveRecord::Base attr_accessible :name, :path, :description, :code, :default_branch, :issues_enabled, :wall_enabled, :merge_requests_enabled, :wiki_enabled + attr_accessor :error_code - # # Relations - # belongs_to :owner, class_name: "User" has_many :users, through: :users_projects has_many :events, dependent: :destroy @@ -26,11 +25,7 @@ class Project < ActiveRecord::Base has_many :wikis, dependent: :destroy has_many :protected_branches, dependent: :destroy - attr_accessor :error_code - - # # Scopes - # scope :public_only, where(private_flag: false) scope :without_user, lambda { |user| where("id not in (:ids)", ids: user.projects.map(&:id) ) } @@ -47,7 +42,6 @@ class Project < ActiveRecord::Base Project.transaction do project.owner = user - project.save! # Add user as project master @@ -76,36 +70,19 @@ class Project < ActiveRecord::Base id && valid? end - # # Validations - # - validates :name, - uniqueness: true, - presence: true, - length: { within: 0..255 } - - validates :path, - uniqueness: true, - presence: true, - format: { with: /^[a-zA-Z][a-zA-Z0-9_\-\.]*$/, - message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }, - length: { within: 0..255 } - - validates :description, - length: { within: 0..2000 } - - validates :code, - presence: true, - uniqueness: true, - format: { with: /^[a-zA-Z][a-zA-Z0-9_\-\.]*$/, - message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }, - length: { within: 1..255 } - validates :owner, presence: true + validates :description, length: { within: 0..2000 } + validates :name, uniqueness: true, presence: true, length: { within: 0..255 } + validates :path, uniqueness: true, presence: true, length: { within: 0..255 }, + format: { with: /^[a-zA-Z][a-zA-Z0-9_\-\.]*$/, + message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } + validates :code, presence: true, uniqueness: true, length: { within: 1..255 }, + format: { with: /^[a-zA-Z][a-zA-Z0-9_\-\.]*$/, + message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } validates :issues_enabled, :wall_enabled, :merge_requests_enabled, :wiki_enabled, inclusion: { in: [true, false] } - validate :check_limit - validate :repo_name + validate :check_limit, :repo_name def check_limit unless owner.can_create_project? @@ -197,4 +174,3 @@ end # merge_requests_enabled :boolean default(TRUE), not null # wiki_enabled :boolean default(TRUE), not null # - diff --git a/app/models/project_hook.rb b/app/models/project_hook.rb index e7a05d57..5a59ebe9 100644 --- a/app/models/project_hook.rb +++ b/app/models/project_hook.rb @@ -1,3 +1,7 @@ +class ProjectHook < WebHook + belongs_to :project +end + # == Schema Information # # Table name: web_hooks @@ -9,7 +13,3 @@ # updated_at :datetime not null # type :string(255) default("ProjectHook") # - -class ProjectHook < WebHook - belongs_to :project -end diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index 42182864..c9e88d6b 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -4,8 +4,7 @@ class ProtectedBranch < ActiveRecord::Base attr_accessible :name belongs_to :project - validates_presence_of :project_id - validates_presence_of :name + validates_presence_of :name, :project_id after_save :update_repository after_destroy :update_repository @@ -18,6 +17,7 @@ class ProtectedBranch < ActiveRecord::Base project.commit(self.name) end end + # == Schema Information # # Table name: protected_branches @@ -28,4 +28,3 @@ end # created_at :datetime not null # updated_at :datetime not null # - diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 10e37645..b37d6bef 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -7,25 +7,12 @@ class Snippet < ActiveRecord::Base belongs_to :author, class_name: "User" has_many :notes, as: :noteable, dependent: :destroy - delegate :name, - :email, - to: :author, - prefix: true + delegate :name, :email, to: :author, prefix: true - validates_presence_of :project_id - validates_presence_of :author_id - - validates :title, - presence: true, - length: { within: 0..255 } - - validates :file_name, - presence: true, - length: { within: 0..255 } - - validates :content, - presence: true, - length: { within: 0..10000 } + validates_presence_of :author_id, :project_id + validates :title, presence: true, length: { within: 0..255 } + validates :file_name, presence: true, length: { within: 0..255 } + validates :content, presence: true, length: { within: 0..10000 } scope :fresh, order("created_at DESC") scope :non_expired, where(["expires_at IS NULL OR expires_at > ?", Time.current]) @@ -59,6 +46,7 @@ class Snippet < ActiveRecord::Base expires_at && expires_at < Time.current end end + # == Schema Information # # Table name: snippets @@ -73,4 +61,3 @@ end # file_name :string(255) # expires_at :datetime # - diff --git a/app/models/system_hook.rb b/app/models/system_hook.rb index 89c69fce..376f336d 100644 --- a/app/models/system_hook.rb +++ b/app/models/system_hook.rb @@ -1,3 +1,15 @@ +class SystemHook < WebHook + def async_execute(data) + Resque.enqueue(SystemHookWorker, id, data) + end + + def self.all_hooks_fire(data) + SystemHook.all.each do |sh| + sh.async_execute data + end + end +end + # == Schema Information # # Table name: web_hooks @@ -9,17 +21,3 @@ # updated_at :datetime not null # type :string(255) default("ProjectHook") # - -class SystemHook < WebHook - - def async_execute(data) - Resque.enqueue(SystemHookWorker, id, data) - end - - def self.all_hooks_fire(data) - SystemHook.all.each do |sh| - sh.async_execute data - end - end - -end diff --git a/app/models/tree.rb b/app/models/tree.rb index 88e8f2f4..e4297a71 100644 --- a/app/models/tree.rb +++ b/app/models/tree.rb @@ -2,16 +2,8 @@ class Tree include Linguist::BlobHelper attr_accessor :path, :tree, :project, :ref - delegate :contents, - :basename, - :name, - :data, - :mime_type, - :mode, - :size, - :text?, - :colorize, - to: :tree + delegate :contents, :basename, :name, :data, :mime_type, + :mode, :size, :text?, :colorize, to: :tree def initialize(raw_tree, project, ref = nil, path = nil) @project, @ref, @path = project, ref, path diff --git a/app/models/user.rb b/app/models/user.rb index f33f01fd..bed568ef 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,64 +1,31 @@ class User < ActiveRecord::Base - include Account devise :database_authenticatable, :token_authenticatable, :lockable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable - attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, - :name, :skype, :linkedin, :twitter, :dark_scheme, - :theme_id, :force_random_password, :extern_uid, :provider, :as => [:default, :admin] + attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, + :skype, :linkedin, :twitter, :dark_scheme, :theme_id, :force_random_password, + :extern_uid, :provider, :as => [:default, :admin] attr_accessible :projects_limit, :as => :admin attr_accessor :force_random_password - has_many :users_projects, dependent: :destroy - has_many :projects, through: :users_projects - has_many :my_own_projects, class_name: "Project", foreign_key: :owner_id has_many :keys, dependent: :destroy - - has_many :events, - class_name: "Event", - foreign_key: :author_id, - dependent: :destroy - - has_many :recent_events, - class_name: "Event", - foreign_key: :author_id, - order: "id DESC" - - has_many :issues, - foreign_key: :author_id, - dependent: :destroy - - has_many :notes, - foreign_key: :author_id, - dependent: :destroy - - has_many :assigned_issues, - class_name: "Issue", - foreign_key: :assignee_id, - dependent: :destroy - - has_many :merge_requests, - foreign_key: :author_id, - dependent: :destroy - - has_many :assigned_merge_requests, - class_name: "MergeRequest", - foreign_key: :assignee_id, - dependent: :destroy - - validates :projects_limit, - presence: true, - numericality: {greater_than_or_equal_to: 0} + has_many :projects, through: :users_projects + has_many :users_projects, dependent: :destroy + has_many :issues, foreign_key: :author_id, dependent: :destroy + has_many :notes, foreign_key: :author_id, dependent: :destroy + has_many :merge_requests, foreign_key: :author_id, dependent: :destroy + has_many :my_own_projects, class_name: "Project", foreign_key: :owner_id + has_many :events, class_name: "Event", foreign_key: :author_id, dependent: :destroy + has_many :recent_events, class_name: "Event", foreign_key: :author_id, order: "id DESC" + has_many :assigned_issues, class_name: "Issue", foreign_key: :assignee_id, dependent: :destroy + has_many :assigned_merge_requests, class_name: "MergeRequest", foreign_key: :assignee_id, dependent: :destroy validates :bio, length: { within: 0..255 } - validates :extern_uid, :allow_blank => true, :uniqueness => {:scope => :provider} - - before_save :ensure_authentication_token - alias_attribute :private_token, :authentication_token + validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0} scope :not_in_project, lambda { |project| where("id not in (:ids)", ids: project.users.map(&:id) ) } scope :admins, where(admin: true) @@ -66,6 +33,8 @@ class User < ActiveRecord::Base scope :active, where(blocked: false) before_validation :generate_password, on: :create + before_save :ensure_authentication_token + alias_attribute :private_token, :authentication_token def generate_password if self.force_random_password @@ -107,6 +76,7 @@ class User < ActiveRecord::Base where("name like :query or email like :query", query: "%#{query}%") end end + # == Schema Information # # Table name: users @@ -140,4 +110,3 @@ end # extern_uid :string(255) # provider :string(255) # - diff --git a/app/models/users_project.rb b/app/models/users_project.rb index 171bf2bb..510b90cb 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -88,6 +88,7 @@ class UsersProject < ActiveRecord::Base self.class.access_roles.invert[self.project_access] end end + # == Schema Information # # Table name: users_projects @@ -99,4 +100,3 @@ end # updated_at :datetime not null # project_access :integer default(0), not null # - diff --git a/app/models/web_hook.rb b/app/models/web_hook.rb index b2e481e6..edfab886 100644 --- a/app/models/web_hook.rb +++ b/app/models/web_hook.rb @@ -6,26 +6,23 @@ class WebHook < ActiveRecord::Base # HTTParty timeout default_timeout 10 - validates :url, - presence: true, - format: { - with: URI::regexp(%w(http https)), - message: "should be a valid url" } + validates :url, presence: true, + format: { with: URI::regexp(%w(http https)), message: "should be a valid url" } def execute(data) parsed_url = URI.parse(url) if parsed_url.userinfo.blank? WebHook.post(url, body: data.to_json, headers: { "Content-Type" => "application/json" }) else - post_url = url.gsub(parsed_url.userinfo+"@", "") + post_url = url.gsub("#{parsed_url.userinfo}@", "") WebHook.post(post_url, body: data.to_json, - headers: { "Content-Type" => "application/json" }, + headers: {"Content-Type" => "application/json"}, basic_auth: {username: parsed_url.user, password: parsed_url.password}) end end - end + # == Schema Information # # Table name: web_hooks @@ -37,4 +34,3 @@ end # updated_at :datetime not null # type :string(255) default("ProjectHook") # - diff --git a/app/models/wiki.rb b/app/models/wiki.rb index a81a151b..c87ac89e 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -32,6 +32,7 @@ class Wiki < ActiveRecord::Base end end end + # == Schema Information # # Table name: wikis @@ -45,4 +46,3 @@ end # slug :string(255) # user_id :integer # - From c7a1779b2215b1815d43c5635e026afeed8da7f4 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 26 Sep 2012 23:28:10 -0700 Subject: [PATCH 098/288] .map -> .pluck --- app/models/milestone.rb | 2 +- app/models/project.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/milestone.rb b/app/models/milestone.rb index da54ac40..a8619954 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -11,7 +11,7 @@ class Milestone < ActiveRecord::Base end def participants - User.where(id: issues.map(&:assignee_id)) + User.where(id: issues.pluck(:assignee_id)) end def percent_complete diff --git a/app/models/project.rb b/app/models/project.rb index 0652d187..5c82b700 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -147,7 +147,7 @@ class Project < ActiveRecord::Base end def wiki_notes - Note.where(noteable_id: wikis.map(&:id), noteable_type: 'Wiki', project_id: self.id) + Note.where(noteable_id: wikis.pluck(:id), noteable_type: 'Wiki', project_id: self.id) end def project_id From 2088d2eba86878dafaa69e8b908a0db2730451b4 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 26 Sep 2012 23:32:04 -0700 Subject: [PATCH 099/288] replace ^ and $ anchors in regexp with \A and \z respectively http://guides.rubyonrails.org/security.html#regular-expressions --- app/models/project.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 5c82b700..9b13de62 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -75,10 +75,10 @@ class Project < ActiveRecord::Base validates :description, length: { within: 0..2000 } validates :name, uniqueness: true, presence: true, length: { within: 0..255 } validates :path, uniqueness: true, presence: true, length: { within: 0..255 }, - format: { with: /^[a-zA-Z][a-zA-Z0-9_\-\.]*$/, + format: { with: /\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/, message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } validates :code, presence: true, uniqueness: true, length: { within: 1..255 }, - format: { with: /^[a-zA-Z][a-zA-Z0-9_\-\.]*$/, + format: { with: /\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/, message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } validates :issues_enabled, :wall_enabled, :merge_requests_enabled, :wiki_enabled, inclusion: { in: [true, false] } From a030e4b6645263ae409b37b569eff2600eb98aa8 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Wed, 26 Sep 2012 23:36:55 -0700 Subject: [PATCH 100/288] cleanup database.yml files --- config/database.yml.example | 8 ++------ config/database.yml.mysql | 8 ++------ config/database.yml.sqlite | 8 +------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/config/database.yml.example b/config/database.yml.example index 5b5c3f0b..c5a2b8d6 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -9,12 +9,11 @@ production: pool: 5 username: root password: "secure password" + # host: localhost # socket: /tmp/mysql.sock - -# -# Development specific # +# Development specific # development: adapter: mysql2 @@ -38,6 +37,3 @@ test: &test username: root password: "secure password" # socket: /tmp/mysql.sock - -cucumber: - <<: *test diff --git a/config/database.yml.mysql b/config/database.yml.mysql index 99cd7eaa..436bea77 100644 --- a/config/database.yml.mysql +++ b/config/database.yml.mysql @@ -9,12 +9,11 @@ production: pool: 5 username: root password: "secure password" + # host: localhost # socket: /tmp/mysql.sock - -# -# Development specific # +# Development specific # development: adapter: mysql2 @@ -38,6 +37,3 @@ test: &test username: root password: # socket: /tmp/mysql.sock - -cucumber: - <<: *test diff --git a/config/database.yml.sqlite b/config/database.yml.sqlite index 077a17ba..591448f6 100644 --- a/config/database.yml.sqlite +++ b/config/database.yml.sqlite @@ -12,12 +12,9 @@ production: pool: 5 timeout: 5000 - -# +# # Development specific # -# -# development: adapter: sqlite3 database: db/development.sqlite3 @@ -32,6 +29,3 @@ test: &test database: db/test.sqlite3 pool: 5 timeout: 5000 - -cucumber: - <<: *test From 933c5e414600d5e0170213db574ba6431c1444e4 Mon Sep 17 00:00:00 2001 From: Cyril Date: Thu, 27 Sep 2012 13:44:53 +0200 Subject: [PATCH 101/288] update new controllers --- app/controllers/blame_controller.rb | 7 +------ app/controllers/blob_controller.rb | 7 +------ app/controllers/commit_controller.rb | 6 +----- app/controllers/compare_controller.rb | 6 +----- app/controllers/tree_controller.rb | 7 +------ 5 files changed, 5 insertions(+), 28 deletions(-) diff --git a/app/controllers/blame_controller.rb b/app/controllers/blame_controller.rb index dd0837ea..e3fb69b5 100644 --- a/app/controllers/blame_controller.rb +++ b/app/controllers/blame_controller.rb @@ -1,13 +1,8 @@ # Controller for viewing a file's blame -class BlameController < ApplicationController +class BlameController < ProjectController include ExtractsPath - layout "project" - - before_filter :project - # Authorize - before_filter :add_project_abilities before_filter :authorize_read_project! before_filter :authorize_code_access! before_filter :require_non_empty_project diff --git a/app/controllers/blob_controller.rb b/app/controllers/blob_controller.rb index 33387842..30c704f2 100644 --- a/app/controllers/blob_controller.rb +++ b/app/controllers/blob_controller.rb @@ -1,14 +1,9 @@ # Controller for viewing a file's blame -class BlobController < ApplicationController +class BlobController < ProjectController include ExtractsPath include Gitlab::Encode - layout "project" - - before_filter :project - # Authorize - before_filter :add_project_abilities before_filter :authorize_read_project! before_filter :authorize_code_access! before_filter :require_non_empty_project diff --git a/app/controllers/commit_controller.rb b/app/controllers/commit_controller.rb index de0d5b2e..3e1595f1 100644 --- a/app/controllers/commit_controller.rb +++ b/app/controllers/commit_controller.rb @@ -1,12 +1,8 @@ # Controller for a specific Commit # # Not to be confused with CommitsController, plural. -class CommitController < ApplicationController - before_filter :project - layout "project" - +class CommitController < ProjectController # Authorize - before_filter :add_project_abilities before_filter :authorize_read_project! before_filter :authorize_code_access! before_filter :require_non_empty_project diff --git a/app/controllers/compare_controller.rb b/app/controllers/compare_controller.rb index 62f968fd..96c5c7e1 100644 --- a/app/controllers/compare_controller.rb +++ b/app/controllers/compare_controller.rb @@ -1,9 +1,5 @@ -class CompareController < ApplicationController - before_filter :project - layout "project" - +class CompareController < ProjectController # Authorize - before_filter :add_project_abilities before_filter :authorize_read_project! before_filter :authorize_code_access! before_filter :require_non_empty_project diff --git a/app/controllers/tree_controller.rb b/app/controllers/tree_controller.rb index e6313783..4d5c409d 100644 --- a/app/controllers/tree_controller.rb +++ b/app/controllers/tree_controller.rb @@ -1,13 +1,8 @@ # Controller for viewing a repository's file structure -class TreeController < ApplicationController +class TreeController < ProjectController include ExtractsPath - layout "project" - - before_filter :project - # Authorize - before_filter :add_project_abilities before_filter :authorize_read_project! before_filter :authorize_code_access! before_filter :require_non_empty_project From 80bfd6a50b409fc86446f40a84cbc2c90e13a304 Mon Sep 17 00:00:00 2001 From: randx Date: Thu, 27 Sep 2012 17:00:13 +0300 Subject: [PATCH 102/288] gitolite-client fork replaced with origin gem --- Gemfile | 4 +++- Gemfile.lock | 19 ++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 8e2bdb9c..c9ca52f6 100644 --- a/Gemfile +++ b/Gemfile @@ -23,13 +23,15 @@ gem 'omniauth-github' # GITLAB patched libs gem "grit", :git => "https://github.com/gitlabhq/grit.git", :ref => "7f35cb98ff17d534a07e3ce6ec3d580f67402837" -gem "gitolite", :git => "https://github.com/gitlabhq/gitolite-client.git", :ref => "9b715ca8bab6529f6c92204a25f84d12f25a6eb0" gem "pygments.rb", :git => "https://github.com/gitlabhq/pygments.rb.git", :ref => "2cada028da5054616634a1d9ca6941b65b3ce188" gem "omniauth-ldap", :git => "https://github.com/gitlabhq/omniauth-ldap.git", :ref => "f038dd852d7bd473a557e385d5d7c2fd5dc1dc2e" gem 'yaml_db', :git => "https://github.com/gitlabhq/yaml_db.git" gem 'grack', :git => "https://github.com/gitlabhq/grack.git" gem "linguist", "~> 1.0.0", :git => "https://github.com/gitlabhq/linguist.git" +# Gitolite client (for work with gitolite-admin repo) +gem "gitolite", '1.1.0' + # API gem "grape", "~> 0.2.1" diff --git a/Gemfile.lock b/Gemfile.lock index f9a0128f..f4d8e386 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,15 +4,6 @@ GIT specs: annotate (2.4.1.beta1) -GIT - remote: https://github.com/gitlabhq/gitolite-client.git - revision: 9b715ca8bab6529f6c92204a25f84d12f25a6eb0 - ref: 9b715ca8bab6529f6c92204a25f84d12f25a6eb0 - specs: - gitolite (0.0.4.alpha) - grit (>= 2.4.1) - hashery (~> 1.4.0) - GIT remote: https://github.com/gitlabhq/grack.git revision: ba46f3b0845c6a09d488ae6abdce6ede37e227e8 @@ -168,12 +159,17 @@ GEM git (1.2.5) github-markup (0.7.4) gitlab_meta (2.9) + gitolite (1.1.0) + gratr19 (~> 0.4.4.1) + grit (~> 2.5.0) + hashery (~> 1.5.0) grape (0.2.1) hashie (~> 1.2) multi_json multi_xml rack rack-mount + gratr19 (0.4.4.1) growl (1.0.3) guard (1.3.2) listen (>= 0.4.2) @@ -189,7 +185,8 @@ GEM activesupport (~> 3.0) haml (~> 3.0) railties (~> 3.0) - hashery (1.4.0) + hashery (1.5.0) + blankslate hashie (1.2.0) headless (0.3.1) hike (1.2.1) @@ -432,7 +429,7 @@ DEPENDENCIES git github-markup (~> 0.7.4) gitlab_meta (= 2.9) - gitolite! + gitolite (= 1.1.0) grack! grape (~> 0.2.1) grit! From afecb250a42222aa3ac9b373897582da27e2e49e Mon Sep 17 00:00:00 2001 From: randx Date: Thu, 27 Sep 2012 17:13:26 +0300 Subject: [PATCH 103/288] Dont show compare link if only one commit in push --- app/views/events/_event_push.html.haml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/views/events/_event_push.html.haml b/app/views/events/_event_push.html.haml index 9b7f10d9..b5273b54 100644 --- a/app/views/events/_event_push.html.haml +++ b/app/views/events/_event_push.html.haml @@ -18,9 +18,10 @@ - few_commits.each do |commit| = render "events/commit", commit: commit, project: project - %li.commits-stat - - if event.commits_count > 2 - %span ... and #{event.commits_count - 2} more commits. - = link_to project_compare_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do - %strong Compare → #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]} + - if event.commits_count > 1 + %li.commits-stat + - if event.commits_count > 2 + %span ... and #{event.commits_count - 2} more commits. + = link_to project_compare_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do + %strong Compare → #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]} .clearfix From 308dfc36b881443dc146b3f9b777c7f7f6475c90 Mon Sep 17 00:00:00 2001 From: randx Date: Thu, 27 Sep 2012 19:38:52 +0300 Subject: [PATCH 104/288] Fix back button for tree navigation --- app/views/tree/_tree.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/tree/_tree.html.haml b/app/views/tree/_tree.html.haml index 439b4ec2..cdd67929 100644 --- a/app/views/tree/_tree.html.haml +++ b/app/views/tree/_tree.html.haml @@ -61,7 +61,7 @@ ajaxGet('#{@logs_path}'); }); -- if params[:path] && request.xhr? +- if @path.present? && request.xhr? :javascript $(window).unbind('popstate'); $(window).bind('popstate', function() { From 1502be325db6e31558106d7b8dcfd30e99917cc9 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 27 Sep 2012 13:12:11 -0400 Subject: [PATCH 105/288] Minor doc fix --- app/helpers/tab_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index c76c1b6f..740700c3 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -2,7 +2,7 @@ module TabHelper # Navigation link helper # # Returns an `li` element with an 'active' class if the supplied - # controller(s) and/or action(s) currently active. The contents of the + # controller(s) and/or action(s) are currently active. The content of the # element is the value passed to the block. # # options - The options hash used to determine if the element is "active" (default: {}) From be18397d82ca16fefed7287c8078a9b41bf37c95 Mon Sep 17 00:00:00 2001 From: Cyril Date: Thu, 27 Sep 2012 20:59:42 +0200 Subject: [PATCH 106/288] rename ProjectController to ProjectResourceController --- app/controllers/blame_controller.rb | 2 +- app/controllers/blob_controller.rb | 2 +- app/controllers/commit_controller.rb | 2 +- app/controllers/commits_controller.rb | 2 +- app/controllers/compare_controller.rb | 2 +- app/controllers/deploy_keys_controller.rb | 2 +- app/controllers/hooks_controller.rb | 2 +- app/controllers/issues_controller.rb | 2 +- app/controllers/labels_controller.rb | 2 +- app/controllers/merge_requests_controller.rb | 2 +- app/controllers/milestones_controller.rb | 2 +- app/controllers/notes_controller.rb | 2 +- .../{project_controller.rb => project_resource_controller.rb} | 2 +- app/controllers/projects_controller.rb | 2 +- app/controllers/protected_branches_controller.rb | 2 +- app/controllers/refs_controller.rb | 2 +- app/controllers/repositories_controller.rb | 2 +- app/controllers/snippets_controller.rb | 2 +- app/controllers/team_members_controller.rb | 2 +- app/controllers/tree_controller.rb | 2 +- app/controllers/wikis_controller.rb | 2 +- .../layouts/{project.html.haml => project_resource.html.haml} | 0 22 files changed, 21 insertions(+), 21 deletions(-) rename app/controllers/{project_controller.rb => project_resource_controller.rb} (59%) rename app/views/layouts/{project.html.haml => project_resource.html.haml} (100%) diff --git a/app/controllers/blame_controller.rb b/app/controllers/blame_controller.rb index e3fb69b5..37d7245c 100644 --- a/app/controllers/blame_controller.rb +++ b/app/controllers/blame_controller.rb @@ -1,5 +1,5 @@ # Controller for viewing a file's blame -class BlameController < ProjectController +class BlameController < ProjectResourceController include ExtractsPath # Authorize diff --git a/app/controllers/blob_controller.rb b/app/controllers/blob_controller.rb index 30c704f2..30069d19 100644 --- a/app/controllers/blob_controller.rb +++ b/app/controllers/blob_controller.rb @@ -1,5 +1,5 @@ # Controller for viewing a file's blame -class BlobController < ProjectController +class BlobController < ProjectResourceController include ExtractsPath include Gitlab::Encode diff --git a/app/controllers/commit_controller.rb b/app/controllers/commit_controller.rb index 3e1595f1..25a1f0fe 100644 --- a/app/controllers/commit_controller.rb +++ b/app/controllers/commit_controller.rb @@ -1,7 +1,7 @@ # Controller for a specific Commit # # Not to be confused with CommitsController, plural. -class CommitController < ProjectController +class CommitController < ProjectResourceController # Authorize before_filter :authorize_read_project! before_filter :authorize_code_access! diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index 81a9e90d..3b8ebdb5 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -1,6 +1,6 @@ require "base64" -class CommitsController < ProjectController +class CommitsController < ProjectResourceController include ExtractsPath # Authorize diff --git a/app/controllers/compare_controller.rb b/app/controllers/compare_controller.rb index 96c5c7e1..ae20f9c0 100644 --- a/app/controllers/compare_controller.rb +++ b/app/controllers/compare_controller.rb @@ -1,4 +1,4 @@ -class CompareController < ProjectController +class CompareController < ProjectResourceController # Authorize before_filter :authorize_read_project! before_filter :authorize_code_access! diff --git a/app/controllers/deploy_keys_controller.rb b/app/controllers/deploy_keys_controller.rb index 29f924e8..a89ebbcb 100644 --- a/app/controllers/deploy_keys_controller.rb +++ b/app/controllers/deploy_keys_controller.rb @@ -1,4 +1,4 @@ -class DeployKeysController < ProjectController +class DeployKeysController < ProjectResourceController respond_to :html # Authorize diff --git a/app/controllers/hooks_controller.rb b/app/controllers/hooks_controller.rb index 23b81194..b7d25e36 100644 --- a/app/controllers/hooks_controller.rb +++ b/app/controllers/hooks_controller.rb @@ -1,4 +1,4 @@ -class HooksController < ProjectController +class HooksController < ProjectResourceController # Authorize before_filter :authorize_read_project! before_filter :authorize_admin_project!, only: [:new, :create, :destroy] diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 114a6a19..82ae5b37 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -1,4 +1,4 @@ -class IssuesController < ProjectController +class IssuesController < ProjectResourceController before_filter :module_enabled before_filter :issue, only: [:edit, :update, :destroy, :show] helper_method :issues_filter diff --git a/app/controllers/labels_controller.rb b/app/controllers/labels_controller.rb index 203bff56..3cbbb869 100644 --- a/app/controllers/labels_controller.rb +++ b/app/controllers/labels_controller.rb @@ -1,4 +1,4 @@ -class LabelsController < ProjectController +class LabelsController < ProjectResourceController before_filter :module_enabled # Allow read any issue diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index db6e48d5..f8d84263 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -1,4 +1,4 @@ -class MergeRequestsController < ProjectController +class MergeRequestsController < ProjectResourceController before_filter :module_enabled before_filter :merge_request, only: [:edit, :update, :destroy, :show, :commits, :diffs, :automerge, :automerge_check, :raw] before_filter :validates_merge_request, only: [:show, :diffs, :raw] diff --git a/app/controllers/milestones_controller.rb b/app/controllers/milestones_controller.rb index 19baf531..68479a26 100644 --- a/app/controllers/milestones_controller.rb +++ b/app/controllers/milestones_controller.rb @@ -1,4 +1,4 @@ -class MilestonesController < ProjectController +class MilestonesController < ProjectResourceController before_filter :module_enabled before_filter :milestone, only: [:edit, :update, :destroy, :show] diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 138d5170..7f5f5cd2 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -1,4 +1,4 @@ -class NotesController < ProjectController +class NotesController < ProjectResourceController # Authorize before_filter :authorize_read_note! before_filter :authorize_write_note!, only: [:create] diff --git a/app/controllers/project_controller.rb b/app/controllers/project_resource_controller.rb similarity index 59% rename from app/controllers/project_controller.rb rename to app/controllers/project_resource_controller.rb index de4f317a..d297bba6 100644 --- a/app/controllers/project_controller.rb +++ b/app/controllers/project_resource_controller.rb @@ -1,4 +1,4 @@ -class ProjectController < ApplicationController +class ProjectResourceController < ApplicationController before_filter :project # Authorize before_filter :add_project_abilities diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 81c267a8..13b264a4 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,6 +1,6 @@ require Rails.root.join('lib', 'gitlab', 'graph_commit') -class ProjectsController < ProjectController +class ProjectsController < ProjectResourceController skip_before_filter :project, only: [:new, :create] # Authorize diff --git a/app/controllers/protected_branches_controller.rb b/app/controllers/protected_branches_controller.rb index e91c78bd..fd2734ef 100644 --- a/app/controllers/protected_branches_controller.rb +++ b/app/controllers/protected_branches_controller.rb @@ -1,4 +1,4 @@ -class ProtectedBranchesController < ProjectController +class ProtectedBranchesController < ProjectResourceController # Authorize before_filter :authorize_read_project! before_filter :require_non_empty_project diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index 9c585c93..d3fc816b 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -1,4 +1,4 @@ -class RefsController < ProjectController +class RefsController < ProjectResourceController include Gitlab::Encode # Authorize diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index ef72e2e9..18b240e4 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -1,4 +1,4 @@ -class RepositoriesController < ProjectController +class RepositoriesController < ProjectResourceController # Authorize before_filter :authorize_read_project! before_filter :authorize_code_access! diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 03e5cc73..7324a459 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -1,4 +1,4 @@ -class SnippetsController < ProjectController +class SnippetsController < ProjectResourceController before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw] # Allow read any snippet diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb index 8261acfe..d0b699f6 100644 --- a/app/controllers/team_members_controller.rb +++ b/app/controllers/team_members_controller.rb @@ -1,4 +1,4 @@ -class TeamMembersController < ProjectController +class TeamMembersController < ProjectResourceController # Authorize before_filter :authorize_read_project! before_filter :authorize_admin_project!, except: [:index, :show] diff --git a/app/controllers/tree_controller.rb b/app/controllers/tree_controller.rb index 4d5c409d..2e4ff7d3 100644 --- a/app/controllers/tree_controller.rb +++ b/app/controllers/tree_controller.rb @@ -1,5 +1,5 @@ # Controller for viewing a repository's file structure -class TreeController < ProjectController +class TreeController < ProjectResourceController include ExtractsPath # Authorize diff --git a/app/controllers/wikis_controller.rb b/app/controllers/wikis_controller.rb index f13d0724..a93afe11 100644 --- a/app/controllers/wikis_controller.rb +++ b/app/controllers/wikis_controller.rb @@ -1,4 +1,4 @@ -class WikisController < ProjectController +class WikisController < ProjectResourceController before_filter :authorize_read_wiki! before_filter :authorize_write_wiki!, only: [:edit, :create, :history] before_filter :authorize_admin_wiki!, only: :destroy diff --git a/app/views/layouts/project.html.haml b/app/views/layouts/project_resource.html.haml similarity index 100% rename from app/views/layouts/project.html.haml rename to app/views/layouts/project_resource.html.haml From 9cabe04368024f44881e4269a008156f1629ab86 Mon Sep 17 00:00:00 2001 From: randx Date: Thu, 27 Sep 2012 23:23:11 +0300 Subject: [PATCH 107/288] tests for: Profile -> History --- app/models/event.rb | 1 + features/profile/profile.feature | 5 +++++ features/steps/profile/profile.rb | 8 ++++++++ features/steps/shared/authentication.rb | 4 ++++ spec/factories.rb | 6 ++++++ 5 files changed, 24 insertions(+) diff --git a/app/models/event.rb b/app/models/event.rb index 43131ad6..535e778d 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -20,6 +20,7 @@ class Event < ActiveRecord::Base delegate :title, to: :issue, prefix: true, allow_nil: true delegate :title, to: :merge_request, prefix: true, allow_nil: true + belongs_to :author, class_name: "User" belongs_to :project belongs_to :target, polymorphic: true diff --git a/features/profile/profile.feature b/features/profile/profile.feature index 134cabb5..d07a6db1 100644 --- a/features/profile/profile.feature +++ b/features/profile/profile.feature @@ -20,3 +20,8 @@ Feature: Profile Given I visit profile account page Then I reset my token And I should see new token + + Scenario: I visit history tab + Given I have activity + When I visit profile history page + Then I should see my activity diff --git a/features/steps/profile/profile.rb b/features/steps/profile/profile.rb index d3261a16..605936ba 100644 --- a/features/steps/profile/profile.rb +++ b/features/steps/profile/profile.rb @@ -41,4 +41,12 @@ class Profile < Spinach::FeatureSteps find("#token").value.should_not == @old_token find("#token").value.should == @user.reload.private_token end + + Given 'I have activity' do + Factory :closed_issue_event, author: current_user + end + + Then 'I should see my activity' do + page.should have_content "#{current_user.name} closed issue" + end end diff --git a/features/steps/shared/authentication.rb b/features/steps/shared/authentication.rb index 2add9161..8c501bbc 100644 --- a/features/steps/shared/authentication.rb +++ b/features/steps/shared/authentication.rb @@ -11,4 +11,8 @@ module SharedAuthentication Given 'I sign in as an admin' do login_as :admin end + + def current_user + @user || User.first + end end diff --git a/spec/factories.rb b/spec/factories.rb index e11e6d07..760465aa 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -78,6 +78,12 @@ FactoryGirl.define do end factory :event do + factory :closed_issue_event do + project + action Event::Closed + target factory: :closed_issue + author factory: :user + end end factory :key do From db69836319ebf716b31f52e818605df0816790e0 Mon Sep 17 00:00:00 2001 From: randx Date: Thu, 27 Sep 2012 23:52:08 +0300 Subject: [PATCH 108/288] Move ProjectHooks from spec/requests to spinach --- features/project/hooks.feature | 21 ++++++++++++ features/steps/project/project_hooks.rb | 36 +++++++++++++++++++++ features/steps/shared/paths.rb | 4 +++ features/steps/shared/project.rb | 4 +++ spec/requests/hooks_spec.rb | 43 ------------------------- 5 files changed, 65 insertions(+), 43 deletions(-) create mode 100644 features/project/hooks.feature create mode 100644 features/steps/project/project_hooks.rb delete mode 100644 spec/requests/hooks_spec.rb diff --git a/features/project/hooks.feature b/features/project/hooks.feature new file mode 100644 index 00000000..b158e07a --- /dev/null +++ b/features/project/hooks.feature @@ -0,0 +1,21 @@ +Feature: Project Hooks + Background: + Given I sign in as a user + And I own project "Shop" + + Scenario: I should see hook list + Given project has hook + When I visit project hooks page + Then I should see project hook + + Scenario: I add new hook + Given I visit project hooks page + When I submit new hook + Then I should see newly created hook + + Scenario: I test hook + Given project has hook + And I visit project hooks page + When I click test hook button + Then hook should be triggered + diff --git a/features/steps/project/project_hooks.rb b/features/steps/project/project_hooks.rb new file mode 100644 index 00000000..1786fe5b --- /dev/null +++ b/features/steps/project/project_hooks.rb @@ -0,0 +1,36 @@ +class ProjectHooks < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + include RSpec::Matchers + include RSpec::Mocks::ExampleMethods + + Given 'project has hook' do + @hook = Factory :project_hook, project: current_project + end + + Then 'I should see project hook' do + page.should have_content @hook.url + end + + When 'I submit new hook' do + @url = Faker::Internet.uri("http") + fill_in "hook_url", with: @url + expect { click_button "Add Web Hook" }.to change(ProjectHook, :count).by(1) + end + + Then 'I should see newly created hook' do + page.current_path.should == project_hooks_path(current_project) + page.should have_content(@url) + end + + When 'I click test hook button' do + test_hook_context = double(execute: true) + TestHookContext.should_receive(:new).and_return(test_hook_context) + click_link 'Test Hook' + end + + Then 'hook should be triggered' do + page.current_path.should == project_hooks_path(current_project) + end +end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 8efedfa1..eda5ab94 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -125,6 +125,10 @@ module SharedPaths visit project_wiki_path(@project, :index) end + When 'I visit project hooks page' do + visit project_hooks_path(@project) + end + # ---------------------------------------- # "Shop" Project # ---------------------------------------- diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index 0f93d675..ae871d63 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -12,4 +12,8 @@ module SharedProject @project = Factory :project, :name => "Shop" @project.add_access(@user, :admin) end + + def current_project + @project ||= Project.first + end end diff --git a/spec/requests/hooks_spec.rb b/spec/requests/hooks_spec.rb deleted file mode 100644 index 7cfe7cfe..00000000 --- a/spec/requests/hooks_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'spec_helper' - -describe "Hooks" do - before do - login_as :user - @project = Factory :project - @project.add_access(@user, :read, :admin) - end - - describe "GET index" do - it "should be available" do - @hook = Factory :project_hook, project: @project - visit project_hooks_path(@project) - page.should have_content "Hooks" - page.should have_content @hook.url - end - end - - describe "New Hook" do - before do - @url = Faker::Internet.uri("http") - visit project_hooks_path(@project) - fill_in "hook_url", with: @url - expect { click_button "Add Web Hook" }.to change(ProjectHook, :count).by(1) - end - - it "should open new team member popup" do - page.current_path.should == project_hooks_path(@project) - page.should have_content(@url) - end - end - - describe "Test" do - before do - @hook = Factory :project_hook, project: @project - stub_request(:post, @hook.url) - visit project_hooks_path(@project) - click_link "Test Hook" - end - - it { page.current_path.should == project_hooks_path(@project) } - end -end From 7ded8584a57f6f29a704144ae0db21adf8bd0920 Mon Sep 17 00:00:00 2001 From: randx Date: Thu, 27 Sep 2012 23:59:41 +0300 Subject: [PATCH 109/288] blue hover --- app/assets/stylesheets/main.scss | 2 +- app/assets/stylesheets/sections/tree.scss | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index 14b289c0..8f0db82d 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -5,7 +5,7 @@ $link_color:#3A89A3; $blue_link: #2fa0bb; $style_color: #474d57; -$hover: #fdf5d9; +$hover: #D9EDF7; /** GitLab Fonts **/ @font-face { font-family: Korolev; src: url('korolev-medium-compressed.otf'); } diff --git a/app/assets/stylesheets/sections/tree.scss b/app/assets/stylesheets/sections/tree.scss index 07568706..5b2bb799 100644 --- a/app/assets/stylesheets/sections/tree.scss +++ b/app/assets/stylesheets/sections/tree.scss @@ -31,8 +31,8 @@ &:hover { td { background: $hover; - border-top:1px solid #FEA; - border-bottom:1px solid #FEA; + border-top:1px solid #ADF; + border-bottom:1px solid #ADF; } cursor:pointer; } From 1fe45898d7871512bb25b5c314301221420c560b Mon Sep 17 00:00:00 2001 From: Vincent Bonmalais Date: Fri, 28 Sep 2012 14:42:31 +1000 Subject: [PATCH 110/288] Fix deletion of tmp/gitlabhq-gitolite* folders in a NFS environment. When working inside of a Vagrant box with NFS enabled, the deletion of a repository in tmp/ doesn't work every time. It is related to NFS inability to delete a folder if it's still used by a resource (e.g. `rm -rf ./folder` would leave the folder and a .nfs* file in it). In this case it's the temporary repository which can't be deleted because `ga_repo` is still using it. De-allocating ga_repo is not possible (thanks Ruby), but deleting the folder it points to in the first place fixes the issue. Reference: http://stackoverflow.com/questions/11228079/python-remove-directory-error-file-exists --- lib/gitlab/backend/gitolite_config.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/gitlab/backend/gitolite_config.rb b/lib/gitlab/backend/gitolite_config.rb index ffe15fb1..ed366f61 100644 --- a/lib/gitlab/backend/gitolite_config.rb +++ b/lib/gitlab/backend/gitolite_config.rb @@ -40,18 +40,22 @@ module Gitlab # Save changes in # gitolite-admin repo - # before pusht it + # before push it ga_repo.save # Push gitolite-admin repo # to apply all changes push(config_tmp_dir) - - # Remove tmp dir - # wiith gitolite-admin - FileUtils.rm_rf(config_tmp_dir) ensure - # unlock so other task cann access + # Remove tmp dir + # removing the gitolite folder first is important to avoid + # NFS issues. + FileUtils.rm_rf(File.join(config_tmp_dir, 'gitolite')) + + # Remove parent tmp dir + FileUtils.rm_rf(config_tmp_dir) + + # Unlock so other task can access # gitolite configuration f.flock(File::LOCK_UN) end From a79eb8428946152021b6f3a25398c49f2e9e7099 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 28 Sep 2012 16:05:54 +0300 Subject: [PATCH 111/288] commit show page styled a bit --- app/assets/stylesheets/sections/commits.scss | 18 ++++++++++++++++++ app/views/commits/_commit_box.html.haml | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/sections/commits.scss b/app/assets/stylesheets/sections/commits.scss index 33b05135..711f603f 100644 --- a/app/assets/stylesheets/sections/commits.scss +++ b/app/assets/stylesheets/sections/commits.scss @@ -47,6 +47,14 @@ padding-left: 32px; } + .author, + .committer { + font-size:14px; + line-height:22px; + text-shadow:0 1px 1px #fff; + color:#777; + } + .avatar { margin-right: 10px; } @@ -227,3 +235,13 @@ } } } + +.label_commit { + @include round-borders-all(4px); + padding:2px 4px; + border:none; + font-size:13px; + background: #474D57; + color:#fff; + font-family: 'Menlo', 'Liberation Mono', 'Consolas', 'Courier New', 'andale mono','lucida console',monospace; +} diff --git a/app/views/commits/_commit_box.html.haml b/app/views/commits/_commit_box.html.haml index b8151b56..ece0df22 100644 --- a/app/views/commits/_commit_box.html.haml +++ b/app/views/commits/_commit_box.html.haml @@ -17,7 +17,7 @@ = gfm escape_once(@commit.description) .commit-info .row - .span4 + .span5 = image_tag gravatar_icon(@commit.author_email, 40), class: "avatar" .author %strong= @commit.author_name @@ -31,10 +31,10 @@ committed %time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")} #{time_ago_in_words(@commit.committed_date)} ago - .span7.right + .span6.right .sha-block %span.cgray commit - %code= @commit.id + %code.label_commit= @commit.id .sha-block %span.cgray= pluralize(@commit.parents.count, "parent") - @commit.parents.each do |parent| From b17bbb238db328b77d8a39479f8a500e54a4bebf Mon Sep 17 00:00:00 2001 From: Thom Wiggers Date: Sat, 29 Sep 2012 02:36:06 +0300 Subject: [PATCH 112/288] fixed some grammar stuff Fixed a few things (wont -> won't, "a code") --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9041530d..4b87ac4c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,12 +7,12 @@ If you want to contribute to GitLab, follow this process: 3. Code 4. Create a pull request -We only accept pull requests if: +We will only accept pull requests if: * Your code has proper tests and all tests pass * Your code can be merged w/o problems -* It wont broke existing functionality -* Its a quality code +* It won't break existing functionality +* It's quality code * We like it :) ## [You may need a developer VM](https://github.com/gitlabhq/developer-vm) From 236fd1e63bf0fbb4f7880ee3bc975ac89f4d3e99 Mon Sep 17 00:00:00 2001 From: Cyril Date: Sat, 29 Sep 2012 13:01:13 +0200 Subject: [PATCH 113/288] all devise controller use devise layout --- .../layouts/{devise_layout.html.haml => devise.html.haml} | 0 config/application.rb | 4 ---- 2 files changed, 4 deletions(-) rename app/views/layouts/{devise_layout.html.haml => devise.html.haml} (100%) diff --git a/app/views/layouts/devise_layout.html.haml b/app/views/layouts/devise.html.haml similarity index 100% rename from app/views/layouts/devise_layout.html.haml rename to app/views/layouts/devise.html.haml diff --git a/config/application.rb b/config/application.rb index fd0dd019..27de3fa2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -53,9 +53,5 @@ module Gitlab # Add fonts config.assets.paths << "#{Rails.root}/app/assets/fonts" - - config.to_prepare do - Devise::SessionsController.layout 'devise_layout' - end end end From c2303737bacb1053dfbf87bc1a3c4639a52f36f9 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sun, 30 Sep 2012 00:53:04 +0200 Subject: [PATCH 114/288] Fix double ref_type in push event when removing branch or tag --- app/roles/push_event.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/roles/push_event.rb b/app/roles/push_event.rb index a607f212..0b8793e5 100644 --- a/app/roles/push_event.rb +++ b/app/roles/push_event.rb @@ -70,7 +70,7 @@ module PushEvent if new_ref? "pushed new" elsif rm_ref? - "removed #{ref_type}" + "removed" else "pushed to" end From 6135eeaa3e635f53d48297281ed0466622b77161 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sun, 30 Sep 2012 00:53:21 +0200 Subject: [PATCH 115/288] Don't link to removed ref --- app/views/events/_event_push.html.haml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/events/_event_push.html.haml b/app/views/events/_event_push.html.haml index b5273b54..e9a2e95f 100644 --- a/app/views/events/_event_push.html.haml +++ b/app/views/events/_event_push.html.haml @@ -5,8 +5,11 @@ .event-title %strong.author_name #{event.author_name} %span.event_label.pushed #{event.push_action_name} #{event.ref_type} - = link_to project_commits_path(event.project, event.ref_name) do + - if event.rm_ref? %strong= event.ref_name + - else + = link_to project_commits_path(event.project, event.ref_name) do + %strong= event.ref_name at %strong= link_to event.project.name, event.project From f5a62835bb43a3cae325337b84813225b67e7651 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sun, 30 Sep 2012 12:07:45 +0200 Subject: [PATCH 116/288] Fix completion for per line forms --- app/views/notes/_common_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/notes/_common_form.html.haml b/app/views/notes/_common_form.html.haml index 626a448c..adaad9ec 100644 --- a/app/views/notes/_common_form.html.haml +++ b/app/views/notes/_common_form.html.haml @@ -41,7 +41,7 @@ $(function(){ var names = #{@project.users.pluck(:name)}, emoji = ['+1', '-1']; var emoji = $.map(emoji, function(value, i) {return {key:value + ':', name:value}}); - $('#note_note'). + $('#note_note, .per_line_form .line-note-text'). atWho('@', { data: names }). atWho(':', { data: emoji, From 2022ae69df130542fe2a6ffe51c106e2942c884d Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sun, 30 Sep 2012 15:04:43 +0200 Subject: [PATCH 117/288] Clarify deletion messages --- app/models/event.rb | 2 +- app/roles/push_event.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 535e778d..de493cdb 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -54,7 +54,7 @@ class Event < ActiveRecord::Base if project project.name else - "(deleted)" + "(deleted project)" end end diff --git a/app/roles/push_event.rb b/app/roles/push_event.rb index 0b8793e5..40549f56 100644 --- a/app/roles/push_event.rb +++ b/app/roles/push_event.rb @@ -70,7 +70,7 @@ module PushEvent if new_ref? "pushed new" elsif rm_ref? - "removed" + "deleted" else "pushed to" end From 433387be358c4307e25f59c8afeb17b4514b35cc Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Mon, 1 Oct 2012 15:33:25 +0300 Subject: [PATCH 118/288] remove unnecessary step from install guide --- doc/installation.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/installation.md b/doc/installation.md index 865cde3c..ccbbd2e8 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -112,7 +112,6 @@ Generate key: Clone GitLab's fork of the Gitolite source code: - cd /home/git sudo -H -u git git clone -b gl-v304 https://github.com/gitlabhq/gitolite.git /home/git/gitolite Setup: From 663dd6fad6e0a992f7ba1ccff4e58de84463abe6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 1 Oct 2012 16:39:19 +0300 Subject: [PATCH 119/288] Refactored events output. Added links to authors of events --- app/assets/stylesheets/sections/events.scss | 9 -------- app/helpers/events_helper.rb | 22 +++++++++++++++++++ app/helpers/issues_helper.rb | 2 +- app/helpers/projects_helper.rb | 4 ++++ app/models/event.rb | 4 ++++ app/views/events/_event.html.haml | 13 +++-------- app/views/events/_event_common.html.haml | 8 +++++++ app/views/events/_event_issue.html.haml | 8 ------- .../_event_membership_changed.html.haml | 9 -------- .../events/_event_merge_request.html.haml | 16 -------------- app/views/events/_event_push.html.haml | 2 +- 11 files changed, 43 insertions(+), 54 deletions(-) create mode 100644 app/helpers/events_helper.rb create mode 100644 app/views/events/_event_common.html.haml delete mode 100644 app/views/events/_event_issue.html.haml delete mode 100644 app/views/events/_event_membership_changed.html.haml delete mode 100644 app/views/events/_event_merge_request.html.haml diff --git a/app/assets/stylesheets/sections/events.scss b/app/assets/stylesheets/sections/events.scss index 5cd3fb7d..b7a482fd 100644 --- a/app/assets/stylesheets/sections/events.scss +++ b/app/assets/stylesheets/sections/events.scss @@ -5,32 +5,23 @@ .event_label { &.pushed { padding:0 2px; - @extend .alert; - @extend .alert-info; } &.opened { padding:0 2px; - @extend .alert; - @extend .alert-success; } &.closed { padding:0 2px; - @extend .alert; - @extend .alert-error; } &.merged { padding:0 2px; - @extend .alert; - @extend .alert-success; } &.left, &.joined { padding:0 2px; - @extend .alert; float:none; } } diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb new file mode 100644 index 00000000..9ad438dc --- /dev/null +++ b/app/helpers/events_helper.rb @@ -0,0 +1,22 @@ +module EventsHelper + def link_to_author(event) + project = event.project + tm = project.team_member_by_id(event.author_id) + + if tm + link_to event.author_name, project_team_member_path(project, tm) + else + event.author_name + end + end + + def event_action_name(event) + target = if event.target_type + event.target_type.titleize.downcase + else + 'project' + end + + [event.action_name, target].join(" ") + end +end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index d4d6c2d4..9b537187 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -33,7 +33,7 @@ module IssuesHelper classes end - def issue_tags + def issue_tags @project.issues.tag_counts_on(:labels).map(&:name) end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index c7dc54ee..468ace15 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -6,5 +6,9 @@ module ProjectsHelper def remove_from_team_message(project, member) "You are going to remove #{member.user_name} from #{project.name}. Are you sure?" end + + def link_to_project project + link_to project.name, project + end end diff --git a/app/models/event.rb b/app/models/event.rb index 535e778d..40f584dd 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -58,6 +58,10 @@ class Event < ActiveRecord::Base end end + def target_title + target.try :title + end + def push? action == self.class::Pushed && valid_push? end diff --git a/app/views/events/_event.html.haml b/app/views/events/_event.html.haml index 716a214b..cdc24204 100644 --- a/app/views/events/_event.html.haml +++ b/app/views/events/_event.html.haml @@ -1,16 +1,9 @@ - if event.allowed? %div.event-item - - if event.issue? - = render "events/event_issue", event: event - - - elsif event.merge_request? - = render "events/event_merge_request", event: event - - - elsif event.push? + - if event.push? = render "events/event_push", event: event - - - elsif event.membership_changed? - = render "events/event_membership_changed", event: event + - else + = render "events/event_common", event: event %span.cgray.right = time_ago_in_words(event.created_at) diff --git a/app/views/events/_event_common.html.haml b/app/views/events/_event_common.html.haml new file mode 100644 index 00000000..0f9a86e9 --- /dev/null +++ b/app/views/events/_event_common.html.haml @@ -0,0 +1,8 @@ += image_tag gravatar_icon(event.author_email), class: "avatar" +.event-title + %span.author_name= link_to_author event + %span.event_label{class: event.action_name}= event_action_name(event) + = link_to [event.project, event.target] do + %strong= truncate event.target_title + at + = link_to_project event.project diff --git a/app/views/events/_event_issue.html.haml b/app/views/events/_event_issue.html.haml deleted file mode 100644 index 60e82c4d..00000000 --- a/app/views/events/_event_issue.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -= image_tag gravatar_icon(event.author_email), class: "avatar" -.event-title - %strong.author_name #{event.author_name} - %span.event_label{class: event.action_name} #{event.action_name} issue - = link_to project_issue_path(event.project, event.issue) do - %strong= truncate event.issue_title - at - %strong= link_to event.project.name, event.project diff --git a/app/views/events/_event_membership_changed.html.haml b/app/views/events/_event_membership_changed.html.haml deleted file mode 100644 index e89065b9..00000000 --- a/app/views/events/_event_membership_changed.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -= image_tag gravatar_icon(event.author_email), class: "avatar" -.event-title - %strong.author_name #{event.author_name} - %span.event_label{class: event.action_name} #{event.action_name} project - %strong= link_to event.project_name, event.project - %span.cgray - = time_ago_in_words(event.created_at) - ago. - diff --git a/app/views/events/_event_merge_request.html.haml b/app/views/events/_event_merge_request.html.haml deleted file mode 100644 index 655337f3..00000000 --- a/app/views/events/_event_merge_request.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -- if event.action_name == "merged" - .event_icon= image_tag "event_mr_merged.png" -= image_tag gravatar_icon(event.author_email), class: "avatar" -.event-title - %strong.author_name #{event.author_name} - %span.event_label{class: event.action_name} #{event.action_name} merge request - = link_to project_merge_request_path(event.project, event.merge_request) do - %strong= truncate event.merge_request_title - at - %strong= link_to event.project.name, event.project -.event-body - .event-info - %span= event.merge_request.source_branch - → - %span= event.merge_request.target_branch - diff --git a/app/views/events/_event_push.html.haml b/app/views/events/_event_push.html.haml index b5273b54..caf1b2c5 100644 --- a/app/views/events/_event_push.html.haml +++ b/app/views/events/_event_push.html.haml @@ -3,7 +3,7 @@ = image_tag gravatar_icon(event.author_email), class: "avatar" .event-title - %strong.author_name #{event.author_name} + %span.author_name= link_to_author event %span.event_label.pushed #{event.push_action_name} #{event.ref_type} = link_to project_commits_path(event.project, event.ref_name) do %strong= event.ref_name From 69751aac32f505a87a40af638dbf14f69f85315e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 1 Oct 2012 16:58:13 +0300 Subject: [PATCH 120/288] Refactoring event views --- app/helpers/events_helper.rb | 14 ++++++++++ app/views/events/_event.html.haml | 12 ++++++--- app/views/events/_event_push.html.haml | 27 ------------------- .../_common.html.haml} | 1 - app/views/events/event/_push.html.haml | 22 +++++++++++++++ 5 files changed, 44 insertions(+), 32 deletions(-) delete mode 100644 app/views/events/_event_push.html.haml rename app/views/events/{_event_common.html.haml => event/_common.html.haml} (80%) create mode 100644 app/views/events/event/_push.html.haml diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 9ad438dc..2c466aba 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -19,4 +19,18 @@ module EventsHelper [event.action_name, target].join(" ") end + + def event_image event + event_image_path = if event.push? + "event_push.png" + elsif event.merged? + "event_mr_merged.png" + end + + return nil unless event_image_path + + content_tag :div, class: 'event_icon' do + image_tag event_image_path + end + end end diff --git a/app/views/events/_event.html.haml b/app/views/events/_event.html.haml index cdc24204..0d91a67a 100644 --- a/app/views/events/_event.html.haml +++ b/app/views/events/_event.html.haml @@ -1,10 +1,14 @@ - if event.allowed? %div.event-item - - if event.push? - = render "events/event_push", event: event - - else - = render "events/event_common", event: event + = event_image(event) + = image_tag gravatar_icon(event.author_email), class: "avatar" + - if event.push? + = render "events/event/push", event: event + - else + = render "events/event/common", event: event + + .clearfix %span.cgray.right = time_ago_in_words(event.created_at) ago. diff --git a/app/views/events/_event_push.html.haml b/app/views/events/_event_push.html.haml deleted file mode 100644 index caf1b2c5..00000000 --- a/app/views/events/_event_push.html.haml +++ /dev/null @@ -1,27 +0,0 @@ -%div - .event_icon= image_tag "event_push.png" - = image_tag gravatar_icon(event.author_email), class: "avatar" - - .event-title - %span.author_name= link_to_author event - %span.event_label.pushed #{event.push_action_name} #{event.ref_type} - = link_to project_commits_path(event.project, event.ref_name) do - %strong= event.ref_name - at - %strong= link_to event.project.name, event.project - - - if event.push_with_commits? - - project = event.project - .event-body - %ul.unstyled.event_commits - - few_commits = event.commits[0...2] - - few_commits.each do |commit| - = render "events/commit", commit: commit, project: project - - - if event.commits_count > 1 - %li.commits-stat - - if event.commits_count > 2 - %span ... and #{event.commits_count - 2} more commits. - = link_to project_compare_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do - %strong Compare → #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]} - .clearfix diff --git a/app/views/events/_event_common.html.haml b/app/views/events/event/_common.html.haml similarity index 80% rename from app/views/events/_event_common.html.haml rename to app/views/events/event/_common.html.haml index 0f9a86e9..ffcaa81a 100644 --- a/app/views/events/_event_common.html.haml +++ b/app/views/events/event/_common.html.haml @@ -1,4 +1,3 @@ -= image_tag gravatar_icon(event.author_email), class: "avatar" .event-title %span.author_name= link_to_author event %span.event_label{class: event.action_name}= event_action_name(event) diff --git a/app/views/events/event/_push.html.haml b/app/views/events/event/_push.html.haml new file mode 100644 index 00000000..e0c0b614 --- /dev/null +++ b/app/views/events/event/_push.html.haml @@ -0,0 +1,22 @@ +.event-title + %span.author_name= link_to_author event + %span.event_label.pushed #{event.push_action_name} #{event.ref_type} + = link_to project_commits_path(event.project, event.ref_name) do + %strong= event.ref_name + at + %strong= link_to event.project.name, event.project + +- if event.push_with_commits? + - project = event.project + .event-body + %ul.unstyled.event_commits + - few_commits = event.commits[0...2] + - few_commits.each do |commit| + = render "events/commit", commit: commit, project: project + + - if event.commits_count > 1 + %li.commits-stat + - if event.commits_count > 2 + %span ... and #{event.commits_count - 2} more commits. + = link_to project_compare_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do + %strong Compare → #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]} From b82cb2630c2b2b3fbbda542602eb9383a520778a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 2 Oct 2012 10:26:24 +0300 Subject: [PATCH 121/288] Use class instead id for css styles --- .../stylesheets/gitlab_bootstrap/lists.scss | 5 +++- app/assets/stylesheets/sections/tree.scss | 23 ++++--------------- app/views/tree/_tree.html.haml | 4 ++-- app/views/tree/show.html.haml | 3 ++- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/app/assets/stylesheets/gitlab_bootstrap/lists.scss b/app/assets/stylesheets/gitlab_bootstrap/lists.scss index 5585c35c..a5d6bd0a 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/lists.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/lists.scss @@ -13,7 +13,10 @@ ul { border-bottom: 1px solid rgba(0, 0, 0, 0.05); &.smoke { background-color:#f5f5f5; } - &:hover { background:$hover; } + &:hover { + background:$hover; + border-bottom:1px solid #ADF; + } &:last-child { border:none } .author { color: #999; } diff --git a/app/assets/stylesheets/sections/tree.scss b/app/assets/stylesheets/sections/tree.scss index 5b2bb799..cd31b6a3 100644 --- a/app/assets/stylesheets/sections/tree.scss +++ b/app/assets/stylesheets/sections/tree.scss @@ -1,21 +1,8 @@ -#tree-holder { - #tree-content-holder { +.tree-holder { + .tree-content-holder { float:left; width:100%; } - #tree-readme-holder { - float:left; - width:100%; - .readme { - border:1px solid #ccc; - padding:12px; - background: #F7F7F7; - - pre { - overflow: auto; - } - } - } .tree_progress { display:none; @@ -25,7 +12,7 @@ } } - #tree-slider { + .tree-table { @include border-radius(0); .tree-item { &:hover { @@ -55,8 +42,7 @@ } } - - #tree-slider { + .tree-table { td { background:#fafafa; } @@ -72,5 +58,4 @@ text-decoration: underline; } } - } diff --git a/app/views/tree/_tree.html.haml b/app/views/tree/_tree.html.haml index cdd67929..3e805d57 100644 --- a/app/views/tree/_tree.html.haml +++ b/app/views/tree/_tree.html.haml @@ -8,12 +8,12 @@ %li= link .clear %div.tree_progress -#tree-content-holder +%div#tree-content-holder.tree-content-holder - if tree.is_blob? = render partial: "tree/tree_file", locals: { name: tree.name, content: tree.data, file: tree } - else - contents = tree.contents - %table#tree-slider{class: "table_#{@hex_path}" } + %table#tree-slider{class: "table_#{@hex_path} tree-table" } %thead %th Name %th Last Update diff --git a/app/views/tree/show.html.haml b/app/views/tree/show.html.haml index d95f90e0..591818ce 100644 --- a/app/views/tree/show.html.haml +++ b/app/views/tree/show.html.haml @@ -1,5 +1,6 @@ = render "head" -#tree-holder= render partial: "tree", locals: {commit: @commit, tree: @tree} +%div#tree-holder.tree-holder + = render "tree", commit: @commit, tree: @tree :javascript $(function() { From 025d5e68c879dfbeafd5eec00946e4707abf0900 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Tue, 2 Oct 2012 15:27:21 +0600 Subject: [PATCH 122/288] fix build --- features/steps/dashboard/dashboard.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/features/steps/dashboard/dashboard.rb b/features/steps/dashboard/dashboard.rb index 154b97e3..2bbbe55e 100644 --- a/features/steps/dashboard/dashboard.rb +++ b/features/steps/dashboard/dashboard.rb @@ -41,8 +41,8 @@ class Dashboard < Spinach::FeatureSteps ) end - Then 'I should see "John Doe joined project Shop" event' do - page.should have_content "John Doe joined project Shop" + Then 'I should see "John Doe joined project at Shop" event' do + page.should have_content "John Doe joined project at Shop" end And 'user with name "John Doe" left project "Shop"' do @@ -55,8 +55,8 @@ class Dashboard < Spinach::FeatureSteps ) end - Then 'I should see "John Doe left project Shop" event' do - page.should have_content "John Doe left project Shop" + Then 'I should see "John Doe left project at Shop" event' do + page.should have_content "John Doe left project at Shop" end And 'I own project "Shop"' do From 0187ae4e8689f0fc2fd399b65973792395534853 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Tue, 2 Oct 2012 15:32:59 +0600 Subject: [PATCH 123/288] actually fix the build --- features/dashboard/dashboard.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/dashboard/dashboard.feature b/features/dashboard/dashboard.feature index 9756bc7f..40217a7d 100644 --- a/features/dashboard/dashboard.feature +++ b/features/dashboard/dashboard.feature @@ -18,10 +18,10 @@ Feature: Dashboard Scenario: I should see User joined Project event Given user with name "John Doe" joined project "Shop" When I visit dashboard page - Then I should see "John Doe joined project Shop" event + Then I should see "John Doe joined project at Shop" event Scenario: I should see User left Project event Given user with name "John Doe" joined project "Shop" And user with name "John Doe" left project "Shop" When I visit dashboard page - Then I should see "John Doe left project Shop" event + Then I should see "John Doe left project at Shop" event From 825081174aa70b5cbfe5947ebf268f14702b6211 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Tue, 2 Oct 2012 12:46:01 +0300 Subject: [PATCH 124/288] #1585 Api for user creation: base implementation --- lib/api/helpers.rb | 4 ++++ lib/api/users.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 14390545..da1d2bd0 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -22,6 +22,10 @@ module Gitlab unauthorized! unless current_user end + def authenticated_as_admin! + forbidden! unless current_user.is_admin? + end + def authorize! action, subject unless abilities.allowed?(current_user, action, subject) forbidden! diff --git a/lib/api/users.rb b/lib/api/users.rb index 0ca8fb2a..8ce7c300 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -23,6 +23,30 @@ module Gitlab @user = User.find(params[:id]) present @user, with: Entities::User end + + # Create user. Available only for admin + # + # Parameters: + # email (required) - Email + # name (required) - Name + # password (required) - Password + # password_confirmation (required) - Password confirmation + # skype - Skype ID + # linkedin (required) - Linkedin + # twitter - Twitter account + # projects_limit - Limit projects wich user can create + # Example Request: + # POST /users + post do + authenticated_as_admin! + attrs = attributes_for_keys [:email, :name, :password, :password_confirmation, :skype, :linkedin, :twitter, :projects_limit] + user = User.new attrs + if user.save + present user, with: Entities::User + else + not_found! + end + end end resource :user do @@ -78,6 +102,8 @@ module Gitlab key = current_user.keys.find params[:id] key.delete end + + end end end From 705e9f402ed4601e502e51b46a181e3701490321 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Tue, 2 Oct 2012 12:52:13 +0300 Subject: [PATCH 125/288] #1585 Api for user creation: create help --- doc/api/users.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/api/users.md b/doc/api/users.md index 4f806b14..0e065fc9 100644 --- a/doc/api/users.md +++ b/doc/api/users.md @@ -65,6 +65,27 @@ Parameters: } ``` +## User creation +Create user. Available only for admin + +``` +POST /users +``` + +Parameters: ++ `email` (required) - Email ++ `name` (required) - Name ++ `password` (required) - Password ++ `password_confirmation` (required) - Password confirmation ++ `skype` - Skype ID ++ `linkedin` (required) - Linkedin ++ `twitter` - Twitter account ++ `projects_limit` - Limit projects wich user can create + + +Will return created user with status `201 Created` on success, or `404 Not +found` on fail. + ## Current user Get currently authenticated user. From bda0a75581d29cd0afb74a8a34ca69e75ab1c352 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Tue, 2 Oct 2012 13:59:22 +0300 Subject: [PATCH 126/288] #1585 Api for user creation: rspec --- spec/requests/api/users_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 243f70f5..e3049e09 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -4,6 +4,7 @@ describe Gitlab::API do include ApiHelpers let(:user) { Factory :user } + let(:admin) {Factory :admin} let(:key) { Factory :key, user: user } describe "GET /users" do @@ -32,6 +33,26 @@ describe Gitlab::API do end end + describe "POST /users" do + before{ admin } + + it "should not create invalid user" do + post api("/users", admin), { email: "invalid email" } + response.status.should == 404 + end + + it "should create user" do + expect{ + post api("/users", admin), Factory.attributes(:user) + }.to change{User.count}.by(1) + end + + it "shouldn't available for non admin users" do + post api("/users", user), Factory.attributes(:user) + response.status.should == 403 + end + end + describe "GET /user" do it "should return current user" do get api("/user", user) From c4883ca225d1f4934cec737769fe22588b2bc8a8 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Tue, 2 Oct 2012 16:29:03 +0300 Subject: [PATCH 127/288] Update linguist and pygments #1602 --- Gemfile | 8 +++-- Gemfile.lock | 34 +++++++-------------- spec/helpers/gitlab_markdown_helper_spec.rb | 4 +-- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/Gemfile b/Gemfile index c9ca52f6..042fbc4d 100644 --- a/Gemfile +++ b/Gemfile @@ -23,15 +23,19 @@ gem 'omniauth-github' # GITLAB patched libs gem "grit", :git => "https://github.com/gitlabhq/grit.git", :ref => "7f35cb98ff17d534a07e3ce6ec3d580f67402837" -gem "pygments.rb", :git => "https://github.com/gitlabhq/pygments.rb.git", :ref => "2cada028da5054616634a1d9ca6941b65b3ce188" gem "omniauth-ldap", :git => "https://github.com/gitlabhq/omniauth-ldap.git", :ref => "f038dd852d7bd473a557e385d5d7c2fd5dc1dc2e" gem 'yaml_db', :git => "https://github.com/gitlabhq/yaml_db.git" gem 'grack', :git => "https://github.com/gitlabhq/grack.git" -gem "linguist", "~> 1.0.0", :git => "https://github.com/gitlabhq/linguist.git" # Gitolite client (for work with gitolite-admin repo) gem "gitolite", '1.1.0' +# Syntax highlighter +gem "pygments.rb", "0.3.1" + +# Language detection +gem "github-linguist", "~> 2.3.4" , :require => "linguist" + # API gem "grape", "~> 0.2.1" diff --git a/Gemfile.lock b/Gemfile.lock index f4d8e386..3c3bea9d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -21,16 +21,6 @@ GIT mime-types (~> 1.15) posix-spawn (~> 0.3.6) -GIT - remote: https://github.com/gitlabhq/linguist.git - revision: c3d6fc5af8cf9d67afa572bba363bf0db256a900 - specs: - linguist (1.0.0) - charlock_holmes (~> 0.6.6) - escape_utils (~> 0.2.3) - mime-types (~> 1.18) - pygments.rb (~> 0.2.11) - GIT remote: https://github.com/gitlabhq/omniauth-ldap.git revision: f038dd852d7bd473a557e385d5d7c2fd5dc1dc2e @@ -42,14 +32,6 @@ GIT pyu-ruby-sasl (~> 0.0.3.1) rubyntlm (~> 0.1.1) -GIT - remote: https://github.com/gitlabhq/pygments.rb.git - revision: 2cada028da5054616634a1d9ca6941b65b3ce188 - ref: 2cada028da5054616634a1d9ca6941b65b3ce188 - specs: - pygments.rb (0.2.13) - rubypython (~> 0.6.1) - GIT remote: https://github.com/gitlabhq/yaml_db.git revision: 98e9a5dca43e3fedd3268c76a73af40d1bdf1dfd @@ -157,6 +139,11 @@ GEM thor (>= 0.13.6) gherkin-ruby (0.2.1) git (1.2.5) + github-linguist (2.3.4) + charlock_holmes (~> 0.6.6) + escape_utils (~> 0.2.3) + mime-types (~> 1.19) + pygments.rb (>= 0.2.13) github-markup (0.7.4) gitlab_meta (2.9) gitolite (1.1.0) @@ -264,6 +251,9 @@ GEM coderay (~> 1.0.5) method_source (~> 0.7.1) slop (>= 2.4.4, < 3) + pygments.rb (0.3.1) + posix-spawn (~> 0.3.6) + yajl-ruby (~> 1.1.0) pyu-ruby-sasl (0.0.3.3) rack (1.4.1) rack-cache (1.2) @@ -330,9 +320,6 @@ GEM railties (>= 3.0) rspec (~> 2.10.0) rubyntlm (0.1.1) - rubypython (0.6.2) - blankslate (>= 2.1.2.3) - ffi (~> 1.0.7) rubyzip (0.9.8) sass (3.1.19) sass-rails (3.2.5) @@ -403,6 +390,7 @@ GEM crack (>= 0.1.7) xpath (0.1.4) nokogiri (~> 1.3) + yajl-ruby (1.1.0) PLATFORMS ruby @@ -427,6 +415,7 @@ DEPENDENCIES ffaker foreman git + github-linguist (~> 2.3.4) github-markup (~> 0.7.4) gitlab_meta (= 2.9) gitolite (= 1.1.0) @@ -445,7 +434,6 @@ DEPENDENCIES kaminari launchy letter_opener - linguist (~> 1.0.0)! modernizr (= 2.5.3) mysql2 omniauth @@ -454,7 +442,7 @@ DEPENDENCIES omniauth-ldap! omniauth-twitter pry - pygments.rb! + pygments.rb (= 0.3.1) rack-mini-profiler rails (= 3.2.8) raphael-rails (= 1.5.2) diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb index a6708a7a..ec830e40 100644 --- a/spec/helpers/gitlab_markdown_helper_spec.rb +++ b/spec/helpers/gitlab_markdown_helper_spec.rb @@ -329,9 +329,9 @@ describe GitlabMarkdownHelper do end it "should leave code blocks untouched" do - markdown("\n some code from $#{snippet.id}\n here too\n").should == "
    some code from $#{snippet.id}\nhere too\n
    \n
    \n" + markdown("\n some code from $#{snippet.id}\n here too\n").should == "
    some code from $#{snippet.id}\nhere too\n
    " - markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should == "
    some code from $#{snippet.id}\nhere too\n
    \n
    \n" + markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should == "
    some code from $#{snippet.id}\nhere too\n
    " end it "should leave inline code untouched" do From d104df49e743a52b42c63a4ccca6be67bdf775d7 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Tue, 2 Oct 2012 16:34:20 +0300 Subject: [PATCH 128/288] fix TYPO --- doc/api/users.md | 4 ++-- lib/api/users.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/users.md b/doc/api/users.md index 0e065fc9..63271ee8 100644 --- a/doc/api/users.md +++ b/doc/api/users.md @@ -78,9 +78,9 @@ Parameters: + `password` (required) - Password + `password_confirmation` (required) - Password confirmation + `skype` - Skype ID -+ `linkedin` (required) - Linkedin ++ `linkedin` - Linkedin + `twitter` - Twitter account -+ `projects_limit` - Limit projects wich user can create ++ `projects_limit` - Limit projects wich user can create Will return created user with status `201 Created` on success, or `404 Not diff --git a/lib/api/users.rb b/lib/api/users.rb index 8ce7c300..7f548aaa 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -32,7 +32,7 @@ module Gitlab # password (required) - Password # password_confirmation (required) - Password confirmation # skype - Skype ID - # linkedin (required) - Linkedin + # linkedin - Linkedin # twitter - Twitter account # projects_limit - Limit projects wich user can create # Example Request: From e9c356092bfa1545f4df35f11fb54dc121f825b2 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Tue, 2 Oct 2012 18:02:21 +0300 Subject: [PATCH 129/288] #1606 API private token via the header --- lib/api/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index da1d2bd0..78d93b65 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -1,7 +1,7 @@ module Gitlab module APIHelpers def current_user - @current_user ||= User.find_by_authentication_token(params[:private_token]) + @current_user ||= User.find_by_authentication_token(params[:private_token] || header[:private_token]) end def user_project From 2e1c3c52bc43d08bc01cf3ba5fba377b3236223b Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Tue, 2 Oct 2012 18:08:04 +0300 Subject: [PATCH 130/288] #1606 Fixes --- lib/api/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 78d93b65..e9fec8b3 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -1,7 +1,7 @@ module Gitlab module APIHelpers def current_user - @current_user ||= User.find_by_authentication_token(params[:private_token] || header[:private_token]) + @current_user ||= User.find_by_authentication_token(params[:private_token] || header["private_token"]) end def user_project From fa3ae24ca7a11f3d87c8838cf05a95dfecfa4c5c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 2 Oct 2012 18:17:12 +0300 Subject: [PATCH 131/288] Group entity. Group has many projects --- app/models/group.rb | 22 +++++++++++++++++++ app/models/project.rb | 3 +++ db/migrate/20121002150926_create_groups.rb | 11 ++++++++++ .../20121002151033_add_group_id_to_project.rb | 5 +++++ db/schema.rb | 11 +++++++++- spec/factories/groups.rb | 21 ++++++++++++++++++ spec/models/group_spec.rb | 22 +++++++++++++++++++ spec/models/project_spec.rb | 22 +++++++++++++++++++ 8 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 app/models/group.rb create mode 100644 db/migrate/20121002150926_create_groups.rb create mode 100644 db/migrate/20121002151033_add_group_id_to_project.rb create mode 100644 spec/factories/groups.rb create mode 100644 spec/models/group_spec.rb diff --git a/app/models/group.rb b/app/models/group.rb new file mode 100644 index 00000000..f18b7d57 --- /dev/null +++ b/app/models/group.rb @@ -0,0 +1,22 @@ +# == Schema Information +# +# Table name: groups +# +# id :integer not null, primary key +# name :string(255) not null +# code :string(255) not null +# owner_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# + +class Group < ActiveRecord::Base + attr_accessible :code, :name, :owner_id + + has_many :projects + belongs_to :owner, class_name: "User" + + validates :name, presence: true, uniqueness: true + validates :code, presence: true, uniqueness: true + validates :owner_id, presence: true +end diff --git a/app/models/project.rb b/app/models/project.rb index 9b13de62..9d2b99e5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -11,6 +11,7 @@ class Project < ActiveRecord::Base attr_accessor :error_code # Relations + belongs_to :group belongs_to :owner, class_name: "User" has_many :users, through: :users_projects has_many :events, dependent: :destroy @@ -173,4 +174,6 @@ end # wall_enabled :boolean default(TRUE), not null # merge_requests_enabled :boolean default(TRUE), not null # wiki_enabled :boolean default(TRUE), not null +# group_id :integer # + diff --git a/db/migrate/20121002150926_create_groups.rb b/db/migrate/20121002150926_create_groups.rb new file mode 100644 index 00000000..ac178294 --- /dev/null +++ b/db/migrate/20121002150926_create_groups.rb @@ -0,0 +1,11 @@ +class CreateGroups < ActiveRecord::Migration + def change + create_table :groups do |t| + t.string :name, null: false + t.string :code, null: false + t.integer :owner_id, null: false + + t.timestamps + end + end +end diff --git a/db/migrate/20121002151033_add_group_id_to_project.rb b/db/migrate/20121002151033_add_group_id_to_project.rb new file mode 100644 index 00000000..683fbfec --- /dev/null +++ b/db/migrate/20121002151033_add_group_id_to_project.rb @@ -0,0 +1,5 @@ +class AddGroupIdToProject < ActiveRecord::Migration + def change + add_column :projects, :group_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 00bb5523..ec4729c0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120905043334) do +ActiveRecord::Schema.define(:version => 20121002151033) do create_table "events", :force => true do |t| t.string "target_type" @@ -25,6 +25,14 @@ ActiveRecord::Schema.define(:version => 20120905043334) do t.integer "author_id" end + create_table "groups", :force => true do |t| + t.string "name", :null => false + t.string "code", :null => false + t.integer "owner_id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "issues", :force => true do |t| t.string "title" t.integer "assignee_id" @@ -108,6 +116,7 @@ ActiveRecord::Schema.define(:version => 20120905043334) do t.boolean "wall_enabled", :default => true, :null => false t.boolean "merge_requests_enabled", :default => true, :null => false t.boolean "wiki_enabled", :default => true, :null => false + t.integer "group_id" end create_table "protected_branches", :force => true do |t| diff --git a/spec/factories/groups.rb b/spec/factories/groups.rb new file mode 100644 index 00000000..d583b186 --- /dev/null +++ b/spec/factories/groups.rb @@ -0,0 +1,21 @@ +# == Schema Information +# +# Table name: groups +# +# id :integer not null, primary key +# name :string(255) not null +# code :string(255) not null +# owner_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# + +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :group do + name "MyString" + code "MyString" + owner_id 1 + end +end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb new file mode 100644 index 00000000..eea196fd --- /dev/null +++ b/spec/models/group_spec.rb @@ -0,0 +1,22 @@ +# == Schema Information +# +# Table name: groups +# +# id :integer not null, primary key +# name :string(255) not null +# code :string(255) not null +# owner_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# + +require 'spec_helper' + +describe Group do + it { should have_many :projects } + it { should validate_presence_of :name } + it { should validate_uniqueness_of(:name) } + it { should validate_presence_of :code } + it { should validate_uniqueness_of(:code) } + it { should validate_presence_of :owner_id } +end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index bb975a93..b7d846e8 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1,7 +1,29 @@ +# == Schema Information +# +# Table name: projects +# +# id :integer not null, primary key +# name :string(255) +# path :string(255) +# description :text +# created_at :datetime not null +# updated_at :datetime not null +# private_flag :boolean default(TRUE), not null +# code :string(255) +# owner_id :integer +# default_branch :string(255) +# issues_enabled :boolean default(TRUE), not null +# wall_enabled :boolean default(TRUE), not null +# merge_requests_enabled :boolean default(TRUE), not null +# wiki_enabled :boolean default(TRUE), not null +# group_id :integer +# + require 'spec_helper' describe Project do describe "Associations" do + it { should belong_to(:group) } it { should belong_to(:owner).class_name('User') } it { should have_many(:users) } it { should have_many(:events).dependent(:destroy) } From d683ce5c10ee84d9fde153329d08425c7e99941f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 2 Oct 2012 18:20:46 +0300 Subject: [PATCH 132/288] refactored factory + fixed tests --- spec/factories.rb | 6 ++++++ spec/factories/groups.rb | 21 --------------------- spec/models/group_spec.rb | 2 ++ 3 files changed, 8 insertions(+), 21 deletions(-) delete mode 100644 spec/factories/groups.rb diff --git a/spec/factories.rb b/spec/factories.rb index 760465aa..82d73fec 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -47,6 +47,12 @@ FactoryGirl.define do owner end + factory :group do + sequence(:name) { |n| "group#{n}" } + code { name.downcase.gsub(/\s/, '_') } + owner + end + factory :users_project do user project diff --git a/spec/factories/groups.rb b/spec/factories/groups.rb deleted file mode 100644 index d583b186..00000000 --- a/spec/factories/groups.rb +++ /dev/null @@ -1,21 +0,0 @@ -# == Schema Information -# -# Table name: groups -# -# id :integer not null, primary key -# name :string(255) not null -# code :string(255) not null -# owner_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null -# - -# Read about factories at https://github.com/thoughtbot/factory_girl - -FactoryGirl.define do - factory :group do - name "MyString" - code "MyString" - owner_id 1 - end -end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index eea196fd..fd7db4b2 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -13,6 +13,8 @@ require 'spec_helper' describe Group do + let!(:group) { create(:group) } + it { should have_many :projects } it { should validate_presence_of :name } it { should validate_uniqueness_of(:name) } From e7608cd6f955c488844f30069af8ca71cb2677c4 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Tue, 2 Oct 2012 18:43:35 +0300 Subject: [PATCH 133/288] API: private token via header --- lib/api/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index e9fec8b3..a339ec4a 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -1,7 +1,7 @@ module Gitlab module APIHelpers def current_user - @current_user ||= User.find_by_authentication_token(params[:private_token] || header["private_token"]) + @current_user ||= User.find_by_authentication_token(params[:private_token] || env["HTTP_PRIVATE_TOKEN"]) end def user_project From dc53a4f73229c879e6fc4ce6a37c57520bb5288d Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Tue, 2 Oct 2012 18:52:19 +0300 Subject: [PATCH 134/288] API: fix documentation --- doc/api/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/README.md b/doc/api/README.md index 36a36f8f..19b7ff20 100644 --- a/doc/api/README.md +++ b/doc/api/README.md @@ -1,6 +1,6 @@ # GitLab API -All API requests require authentication. You need to pass a `private_token` parameter to authenticate. You can find or reset your private token in your profile. +All API requests require authentication. You need to pass a `private_token` parameter by url or header. You can find or reset your private token in your profile. If no, or an invalid, `private_token` is provided then an error message will be returned with status code 401: From d6363e935933551b7f9edb4063d0b0fbcea3c824 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 2 Oct 2012 19:01:40 +0300 Subject: [PATCH 135/288] Admin Group scaffold -> new, show, index --- app/controllers/admin/groups_controller.rb | 66 ++++++++++++++++++++++ app/models/group.rb | 6 ++ app/models/project.rb | 5 +- app/views/admin/groups/_form.html.haml | 19 +++++++ app/views/admin/groups/index.html.haml | 24 ++++++++ app/views/admin/groups/new.html.haml | 3 + app/views/admin/groups/show.html.haml | 48 ++++++++++++++++ config/routes.rb | 5 ++ 8 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/groups_controller.rb create mode 100644 app/views/admin/groups/_form.html.haml create mode 100644 app/views/admin/groups/index.html.haml create mode 100644 app/views/admin/groups/new.html.haml create mode 100644 app/views/admin/groups/show.html.haml diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb new file mode 100644 index 00000000..612abf8c --- /dev/null +++ b/app/controllers/admin/groups_controller.rb @@ -0,0 +1,66 @@ +class Admin::GroupsController < AdminController + before_filter :group, only: [:edit, :show, :update, :destroy, :project_update] + + def index + @groups = Group.scoped + @groups = @groups.search(params[:name]) if params[:name].present? + @groups = @groups.page(params[:page]).per(20) + end + + def show + @projects = Project.scoped + @projects = @projects.not_in_group(@group) if @group.projects.present? + @projects = @projects.all + end + + def new + @group = Group.new + end + + def edit + end + + def create + @group = Group.new(params[:group]) + @group.owner = current_user + + if @group.save + redirect_to [:admin, @group], notice: 'Group was successfully created.' + else + render action: "new" + end + end + + def update + owner_id = params[:group].delete(:owner_id) + + if owner_id + @group.owner = User.find(owner_id) + end + + if @group.update_attributes(params[:group]) + redirect_to [:admin, @group], notice: 'Group was successfully updated.' + else + render action: "edit" + end + end + + def project_update + project_ids = params[:project_ids] + Project.where(id: project_ids).update_all(group_id: @group.id) + + redirect_to :back, notice: 'Group was successfully updated.' + end + + def destroy + @group.destroy + + redirect_to groups_url, notice: 'Group was successfully deleted.' + end + + private + + def group + @group = Group.find_by_code(params[:id]) + end +end diff --git a/app/models/group.rb b/app/models/group.rb index f18b7d57..43283066 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -19,4 +19,10 @@ class Group < ActiveRecord::Base validates :name, presence: true, uniqueness: true validates :code, presence: true, uniqueness: true validates :owner_id, presence: true + + delegate :name, to: :owner, allow_nil: true, prefix: true + + def to_param + code + end end diff --git a/app/models/project.rb b/app/models/project.rb index 9d2b99e5..f525f292 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -26,9 +26,12 @@ class Project < ActiveRecord::Base has_many :wikis, dependent: :destroy has_many :protected_branches, dependent: :destroy + delegate :name, to: :owner, allow_nil: true, prefix: true + # Scopes scope :public_only, where(private_flag: false) - scope :without_user, lambda { |user| where("id not in (:ids)", ids: user.projects.map(&:id) ) } + scope :without_user, ->(user) { where("id not in (:ids)", ids: user.projects.map(&:id) ) } + scope :not_in_group, ->(group) { where("id not in (:ids)", ids: group.project_ids ) } def self.active joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC") diff --git a/app/views/admin/groups/_form.html.haml b/app/views/admin/groups/_form.html.haml new file mode 100644 index 00000000..a1ba9406 --- /dev/null +++ b/app/views/admin/groups/_form.html.haml @@ -0,0 +1,19 @@ += form_for [:admin, @group] do |f| + - if @group.errors.any? + .alert-message.block-message.error + %span= @group.errors.full_messages.first + .clearfix.group_name_holder + = f.label :name do + Group name is + .input + = f.text_field :name, placeholder: "Example Group", class: "xxlarge" + .clearfix + = f.label :code do + URL + .input + .input-prepend + %span.add-on= web_app_url + = f.text_field :code, placeholder: "example" + + .form-actions + = f.submit 'Create group', class: "btn primary" diff --git a/app/views/admin/groups/index.html.haml b/app/views/admin/groups/index.html.haml new file mode 100644 index 00000000..b90efc83 --- /dev/null +++ b/app/views/admin/groups/index.html.haml @@ -0,0 +1,24 @@ +%h3.page_title + Groups + = link_to 'New Group', new_admin_group_path, class: "btn small right" +%br += form_tag admin_groups_path, method: :get, class: 'form-inline' do + = text_field_tag :name, params[:name], class: "xlarge" + = submit_tag "Search", class: "btn submit primary" + +%table + %thead + %th Name + %th Path + %th Projects + %th Edit + %th.cred Danger Zone! + + - @groups.each do |group| + %tr + %td= link_to group.name, [:admin, group] + %td= group.path + %td= group.projects.count + %td= link_to 'Edit', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: "btn small" + %td.bgred= link_to 'Destroy', [:admin, group], confirm: "REMOVE #{group.name}? Are you sure?", method: :delete, class: "btn small danger" += paginate @groups, theme: "admin" diff --git a/app/views/admin/groups/new.html.haml b/app/views/admin/groups/new.html.haml new file mode 100644 index 00000000..d6b6ea15 --- /dev/null +++ b/app/views/admin/groups/new.html.haml @@ -0,0 +1,3 @@ +%h3.page_title New Group +%br += render 'form' diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml new file mode 100644 index 00000000..5d348eec --- /dev/null +++ b/app/views/admin/groups/show.html.haml @@ -0,0 +1,48 @@ +%h3.page_title + Group: #{@group.name} + = link_to edit_admin_group_path(@group), class: "btn right" do + %i.icon-edit + Edit + +%br +%table.zebra-striped + %thead + %tr + %th Group + %th + %tr + %td + %b + Name: + %td + = @group.name + %tr + %td + %b + Code: + %td + = @group.code + %tr + %td + %b + Owner: + %td + = @group.owner_name +.ui-box + %h5 + Projects + %small + (#{@group.projects.count}) + %ul.unstyled + - @group.projects.each do |project| + %li.wll + %strong + = link_to project.name, [:admin, project] + +%br +%h3 Add new project +%br += form_tag project_update_admin_group_path(@group), class: "bulk_import", method: :put do + = select_tag :project_ids, options_from_collection_for_select(@projects , :id, :name), multiple: true, data: {placeholder: 'Select projects'}, class: 'chosen span5' + .form-actions + = submit_tag 'Add', class: "btn primary" diff --git a/config/routes.rb b/config/routes.rb index 21521a97..2b923379 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -43,6 +43,11 @@ Gitlab::Application.routes.draw do put :unblock end end + resources :groups, constraints: { id: /[^\/]+/ } do + member do + put :project_update + end + end resources :projects, constraints: { id: /[^\/]+/ } do member do get :team From f9eda9b33a72cae91e51c5733fdf2c0d7b37d149 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 2 Oct 2012 19:37:53 +0300 Subject: [PATCH 136/288] Group filtering on dashboard --- app/controllers/dashboard_controller.rb | 20 ++++++++++++++++++-- app/views/admin/groups/index.html.haml | 4 ++-- app/views/dashboard/_groups.html.haml | 15 +++++++++++++++ app/views/dashboard/_projects.html.haml | 21 +++++++++++++++++++++ app/views/dashboard/index.html.haml | 25 +++---------------------- app/views/layouts/group.html.haml | 24 ++++++++++++++++++++++++ 6 files changed, 83 insertions(+), 26 deletions(-) create mode 100644 app/views/dashboard/_groups.html.haml create mode 100644 app/views/dashboard/_projects.html.haml create mode 100644 app/views/layouts/group.html.haml diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 7696e97a..75cf726d 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -2,12 +2,22 @@ class DashboardController < ApplicationController respond_to :html def index - @projects = current_user.projects_with_events.page(params[:page]).per(40) + @groups = Group.where(id: current_user.projects.pluck(:group_id)) + + @projects = current_user.projects_with_events + + if params[:group].present? + @group = Group.find_by_code(params[:group]) + @projects = @projects.where(group_id: @group.id) + end + + @projects = @projects.page(params[:page]).per(40) + @events = Event.recent_for_user(current_user).limit(20).offset(params[:offset] || 0) @last_push = current_user.recent_push respond_to do |format| - format.html + format.html { render 'index', layout: determine_layout } format.js format.atom { render layout: false } end @@ -31,4 +41,10 @@ class DashboardController < ApplicationController format.atom { render layout: false } end end + + protected + + def determine_layout + @group ? 'group' : 'application' + end end diff --git a/app/views/admin/groups/index.html.haml b/app/views/admin/groups/index.html.haml index b90efc83..6952c4c9 100644 --- a/app/views/admin/groups/index.html.haml +++ b/app/views/admin/groups/index.html.haml @@ -9,7 +9,7 @@ %table %thead %th Name - %th Path + %th Code %th Projects %th Edit %th.cred Danger Zone! @@ -17,7 +17,7 @@ - @groups.each do |group| %tr %td= link_to group.name, [:admin, group] - %td= group.path + %td= group.code %td= group.projects.count %td= link_to 'Edit', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: "btn small" %td.bgred= link_to 'Destroy', [:admin, group], confirm: "REMOVE #{group.name}? Are you sure?", method: :delete, class: "btn small danger" diff --git a/app/views/dashboard/_groups.html.haml b/app/views/dashboard/_groups.html.haml new file mode 100644 index 00000000..b46f675f --- /dev/null +++ b/app/views/dashboard/_groups.html.haml @@ -0,0 +1,15 @@ +.projects_box + %h5 + Groups + %small + (#{groups.count}) + %ul.unstyled + - groups.each do |group| + %li.wll + = link_to dashboard_path(group: group), class: dom_class(group) do + %strong.group_name= truncate(group.name, length: 25) + %span.arrow + → + %span.last_activity + %strong Projects: + %span= group.projects.count diff --git a/app/views/dashboard/_projects.html.haml b/app/views/dashboard/_projects.html.haml new file mode 100644 index 00000000..00f19ccd --- /dev/null +++ b/app/views/dashboard/_projects.html.haml @@ -0,0 +1,21 @@ +.projects_box + %h5 + Projects + %small + (#{projects.total_count}) + - if current_user.can_create_project? + %span.right + = link_to new_project_path, class: "btn very_small info" do + %i.icon-plus + New Project + %ul.unstyled + - projects.each do |project| + %li.wll + = link_to project_path(project), class: dom_class(project) do + %strong.project_name= truncate(project.name, length: 25) + %span.arrow + → + %span.last_activity + %strong Last activity: + %span= project_last_activity(project) + .bottom= paginate projects, theme: "gitlab" diff --git a/app/views/dashboard/index.html.haml b/app/views/dashboard/index.html.haml index 791c18e3..aa53ebfd 100644 --- a/app/views/dashboard/index.html.haml +++ b/app/views/dashboard/index.html.haml @@ -9,28 +9,9 @@ .loading.hide .side = render "events/event_last_push", event: @last_push - .projects_box - %h5 - Projects - %small - (#{@projects.total_count}) - - if current_user.can_create_project? - %span.right - = link_to new_project_path, class: "btn very_small info" do - %i.icon-plus - New Project - %ul.unstyled - - @projects.each do |project| - %li.wll - = link_to project_path(project), class: dom_class(project) do - %strong.project_name= truncate(project.name, length: 25) - %span.arrow - → - %span.last_activity - %strong Last activity: - %span= project_last_activity(project) - .bottom= paginate @projects, theme: "gitlab" - + - unless @group + = render "groups", groups: @groups + = render "projects", projects: @projects %div %span.rss-icon = link_to dashboard_path(:atom, { private_token: current_user.private_token }) do diff --git a/app/views/layouts/group.html.haml b/app/views/layouts/group.html.haml new file mode 100644 index 00000000..810c296e --- /dev/null +++ b/app/views/layouts/group.html.haml @@ -0,0 +1,24 @@ +!!! 5 +%html{ lang: "en"} + = render "layouts/head" + %body{class: "#{app_theme} application"} + = render "layouts/flash" + = render "layouts/head_panel", title: "#{@group.name}:Dashboard" + .container + %ul.main_menu + = nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do + = link_to "Home", root_path, title: "Home" + = nav_link(path: 'dashboard#issues') do + = link_to dashboard_issues_path(group: @group) do + Issues + %span.count= current_user.assigned_issues.opened.count + = nav_link(path: 'dashboard#merge_requests') do + = link_to dashboard_merge_requests_path(group: @group) do + Merge Requests + %span.count= current_user.cared_merge_requests.count + = nav_link(path: 'search#show') do + = link_to "People", "#" + = nav_link(path: 'help#index') do + = link_to "Help", help_path + + .content= yield From 1b6a3dfec9bdadb8c607bf57e4b6699c4ab3a80b Mon Sep 17 00:00:00 2001 From: randx Date: Tue, 2 Oct 2012 20:42:15 +0300 Subject: [PATCH 137/288] Move all stuff to groups controller --- app/assets/stylesheets/sections/projects.scss | 2 + app/controllers/dashboard_controller.rb | 15 +--- app/controllers/groups_controller.rb | 69 +++++++++++++++++ app/views/dashboard/_groups.html.haml | 2 +- app/views/dashboard/index.html.haml | 2 +- app/views/groups/_projects.html.haml | 20 +++++ app/views/groups/issues.atom.builder | 24 ++++++ app/views/groups/issues.html.haml | 19 +++++ app/views/groups/merge_requests.html.haml | 18 +++++ app/views/groups/people.html.haml | 12 +++ app/views/groups/search.html.haml | 75 +++++++++++++++++++ app/views/groups/show.atom.builder | 29 +++++++ app/views/groups/show.html.haml | 42 +++++++++++ app/views/groups/show.js.haml | 2 + app/views/layouts/group.html.haml | 22 +++--- config/routes.rb | 13 ++++ 16 files changed, 339 insertions(+), 27 deletions(-) create mode 100644 app/controllers/groups_controller.rb create mode 100644 app/views/groups/_projects.html.haml create mode 100644 app/views/groups/issues.atom.builder create mode 100644 app/views/groups/issues.html.haml create mode 100644 app/views/groups/merge_requests.html.haml create mode 100644 app/views/groups/people.html.haml create mode 100644 app/views/groups/search.html.haml create mode 100644 app/views/groups/show.atom.builder create mode 100644 app/views/groups/show.html.haml create mode 100644 app/views/groups/show.js.haml diff --git a/app/assets/stylesheets/sections/projects.scss b/app/assets/stylesheets/sections/projects.scss index a29504ec..53a7c2bc 100644 --- a/app/assets/stylesheets/sections/projects.scss +++ b/app/assets/stylesheets/sections/projects.scss @@ -13,6 +13,8 @@ font-size:16px; text-shadow: 0 1px 1px #fff; padding: 2px 10px; + line-height:32px; + font-size:14px; } ul { li { diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 75cf726d..1f142dae 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -3,21 +3,14 @@ class DashboardController < ApplicationController def index @groups = Group.where(id: current_user.projects.pluck(:group_id)) - @projects = current_user.projects_with_events - - if params[:group].present? - @group = Group.find_by_code(params[:group]) - @projects = @projects.where(group_id: @group.id) - end - @projects = @projects.page(params[:page]).per(40) @events = Event.recent_for_user(current_user).limit(20).offset(params[:offset] || 0) @last_push = current_user.recent_push respond_to do |format| - format.html { render 'index', layout: determine_layout } + format.html format.js format.atom { render layout: false } end @@ -41,10 +34,4 @@ class DashboardController < ApplicationController format.atom { render layout: false } end end - - protected - - def determine_layout - @group ? 'group' : 'application' - end end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb new file mode 100644 index 00000000..486b0bee --- /dev/null +++ b/app/controllers/groups_controller.rb @@ -0,0 +1,69 @@ +class GroupsController < ApplicationController + respond_to :html + layout 'group' + + before_filter :group + before_filter :projects + + def show + @events = Event.where(project_id: project_ids). + order('id DESC'). + limit(20).offset(params[:offset] || 0) + + @last_push = current_user.recent_push + + respond_to do |format| + format.html + format.js + format.atom { render layout: false } + end + end + + # Get authored or assigned open merge requests + def merge_requests + @merge_requests = current_user.cared_merge_requests.order("created_at DESC").page(params[:page]).per(20) + end + + # Get only assigned issues + def issues + @user = current_user + @issues = current_user.assigned_issues.opened.order("created_at DESC").page(params[:page]).per(20) + @issues = @issues.includes(:author, :project) + + respond_to do |format| + format.html + format.atom { render layout: false } + end + end + + def search + query = params[:search] + + @merge_requests = [] + @issues = [] + + if query.present? + @projects = @projects.search(query).limit(10) + @merge_requests = MergeRequest.where(project_id: project_ids).search(query).limit(10) + @issues = Issue.where(project_id: project_ids).search(query).limit(10) + end + end + + def people + @users = group.projects.map(&:users).flatten.uniq + end + + protected + + def group + @group ||= Group.find_by_code(params[:id]) + end + + def projects + @projects ||= current_user.projects_with_events.where(group_id: @group.id) + end + + def project_ids + projects.map(&:id) + end +end diff --git a/app/views/dashboard/_groups.html.haml b/app/views/dashboard/_groups.html.haml index b46f675f..5180bfa0 100644 --- a/app/views/dashboard/_groups.html.haml +++ b/app/views/dashboard/_groups.html.haml @@ -6,7 +6,7 @@ %ul.unstyled - groups.each do |group| %li.wll - = link_to dashboard_path(group: group), class: dom_class(group) do + = link_to group_path(id: group.code), class: dom_class(group) do %strong.group_name= truncate(group.name, length: 25) %span.arrow → diff --git a/app/views/dashboard/index.html.haml b/app/views/dashboard/index.html.haml index aa53ebfd..dc520a22 100644 --- a/app/views/dashboard/index.html.haml +++ b/app/views/dashboard/index.html.haml @@ -9,7 +9,7 @@ .loading.hide .side = render "events/event_last_push", event: @last_push - - unless @group + - if @groups.present? = render "groups", groups: @groups = render "projects", projects: @projects %div diff --git a/app/views/groups/_projects.html.haml b/app/views/groups/_projects.html.haml new file mode 100644 index 00000000..35433057 --- /dev/null +++ b/app/views/groups/_projects.html.haml @@ -0,0 +1,20 @@ +.projects_box + %h5 + Projects + %small + (#{projects.count}) + - if current_user.can_create_project? + %span.right + = link_to new_project_path, class: "btn very_small info" do + %i.icon-plus + New Project + %ul.unstyled + - projects.each do |project| + %li.wll + = link_to project_path(project), class: dom_class(project) do + %strong.project_name= truncate(project.name, length: 25) + %span.arrow + → + %span.last_activity + %strong Last activity: + %span= project_last_activity(project) diff --git a/app/views/groups/issues.atom.builder b/app/views/groups/issues.atom.builder new file mode 100644 index 00000000..5bd07bcd --- /dev/null +++ b/app/views/groups/issues.atom.builder @@ -0,0 +1,24 @@ +xml.instruct! +xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do + xml.title "#{@user.name} issues" + xml.link :href => dashboard_issues_url(:atom, :private_token => @user.private_token), :rel => "self", :type => "application/atom+xml" + xml.link :href => dashboard_issues_url(:private_token => @user.private_token), :rel => "alternate", :type => "text/html" + xml.id dashboard_issues_url(:private_token => @user.private_token) + xml.updated @issues.first.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") if @issues.any? + + @issues.each do |issue| + xml.entry do + xml.id project_issue_url(issue.project, issue) + xml.link :href => project_issue_url(issue.project, issue) + xml.title truncate(issue.title, :length => 80) + xml.updated issue.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") + xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(issue.author_email) + xml.author do |author| + xml.name issue.author_name + xml.email issue.author_email + end + xml.summary issue.title + end + end +end + diff --git a/app/views/groups/issues.html.haml b/app/views/groups/issues.html.haml new file mode 100644 index 00000000..cc488d57 --- /dev/null +++ b/app/views/groups/issues.html.haml @@ -0,0 +1,19 @@ +%h3.page_title + Issues + %small (assigned to you) + %small.right #{@issues.total_count} issues + +%br +.clearfix +- if @issues.any? + - @issues.group_by(&:project).each do |group| + %div.ui-box + - @project = group[0] + %h5= @project.name + %ul.unstyled.issues_table + - group[1].each do |issue| + = render(partial: 'issues/show', locals: {issue: issue}) + %hr + = paginate @issues, theme: "gitlab" +- else + %h3.nothing_here_message Nothing to show here diff --git a/app/views/groups/merge_requests.html.haml b/app/views/groups/merge_requests.html.haml new file mode 100644 index 00000000..23a7e722 --- /dev/null +++ b/app/views/groups/merge_requests.html.haml @@ -0,0 +1,18 @@ +%h3.page_title + Merge Requests + %small (authored by or assigned to you) + %small.right #{@merge_requests.total_count} merge requests + +%br +- if @merge_requests.any? + - @merge_requests.group_by(&:project).each do |group| + %ul.unstyled.ui-box + - @project = group[0] + %h5= @project.name + - group[1].each do |merge_request| + = render(partial: 'merge_requests/merge_request', locals: {merge_request: merge_request}) + %hr + = paginate @merge_requests, theme: "gitlab" + +- else + %h3.nothing_here_message Nothing to show here diff --git a/app/views/groups/people.html.haml b/app/views/groups/people.html.haml new file mode 100644 index 00000000..4c1865a2 --- /dev/null +++ b/app/views/groups/people.html.haml @@ -0,0 +1,12 @@ +.ui-box + %h5 + People + %small + (#{@users.count}) + %ul.unstyled + - @users.each do |user| + %li.wll + = image_tag gravatar_icon(user.email, 16), class: "avatar s16" + %strong= user.name + %span.cgray= user.email + diff --git a/app/views/groups/search.html.haml b/app/views/groups/search.html.haml new file mode 100644 index 00000000..6ca5630f --- /dev/null +++ b/app/views/groups/search.html.haml @@ -0,0 +1,75 @@ += form_tag search_group_path(@group), method: :get, class: 'form-inline' do |f| + .padded + = label_tag :search do + %strong Looking for + .input + = search_field_tag :search, params[:search], placeholder: "issue 143", class: "input-xxlarge search-text-input", id: "dashboard_search" + = submit_tag 'Search', class: "btn primary wide" +- if params[:search].present? + %br + %h3 + Search results + %small (#{@projects.count + @merge_requests.count + @issues.count}) + %hr + .search_results + .row + .span6 + %table + %thead + %tr + %th Projects + %tbody + - @projects.each do |project| + %tr + %td + = link_to project do + %strong.term= project.name + %small.cgray + last activity at + = project.last_activity_date.stamp("Aug 25, 2011") + - if @projects.blank? + %tr + %td + %h4.nothing_here_message No Projects + %br + %table + %thead + %tr + %th Merge Requests + %tbody + - @merge_requests.each do |merge_request| + %tr + %td + = link_to [merge_request.project, merge_request] do + %span.badge.badge-info ##{merge_request.id} + – + %strong.term= truncate merge_request.title, length: 50 + %strong.right + %span.label= merge_request.project.name + - if @merge_requests.blank? + %tr + %td + %h4.nothing_here_message No Merge Requests + .span6 + %table + %thead + %tr + %th Issues + %tbody + - @issues.each do |issue| + %tr + %td + = link_to [issue.project, issue] do + %span.badge.badge-info ##{issue.id} + – + %strong.term= truncate issue.title, length: 40 + %strong.right + %span.label= issue.project.name + - if @issues.blank? + %tr + %td + %h4.nothing_here_message No Issues + :javascript + $(function() { + $(".search_results .term").highlight("#{params[:search]}"); + }) diff --git a/app/views/groups/show.atom.builder b/app/views/groups/show.atom.builder new file mode 100644 index 00000000..fa3bfade --- /dev/null +++ b/app/views/groups/show.atom.builder @@ -0,0 +1,29 @@ +xml.instruct! +xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do + xml.title "Dashboard feed#{" - #{current_user.name}" if current_user.name.present?}" + xml.link :href => projects_url(:atom), :rel => "self", :type => "application/atom+xml" + xml.link :href => projects_url, :rel => "alternate", :type => "text/html" + xml.id projects_url + xml.updated @events.maximum(:updated_at).strftime("%Y-%m-%dT%H:%M:%SZ") if @events.any? + + @events.each do |event| + if event.allowed? + event = EventDecorator.decorate(event) + xml.entry do + event_link = event.feed_url + event_title = event.feed_title + + xml.id "tag:#{request.host},#{event.created_at.strftime("%Y-%m-%d")}:#{event.id}" + xml.link :href => event_link + xml.title truncate(event_title, :length => 80) + xml.updated event.created_at.strftime("%Y-%m-%dT%H:%M:%SZ") + xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(event.author_email) + xml.author do |author| + xml.name event.author_name + xml.email event.author_email + end + xml.summary event_title + end + end + end +end diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml new file mode 100644 index 00000000..7552128e --- /dev/null +++ b/app/views/groups/show.html.haml @@ -0,0 +1,42 @@ +- if @projects.any? + .projects + .activities.span8 + = render 'shared/no_ssh' + - if @events.any? + .content_list= render @events + - else + %h4.nothing_here_message Projects activity will be displayed here + .loading.hide + .side + = render "events/event_last_push", event: @last_push + = render "projects", projects: @projects + %div + %span.rss-icon + = link_to dashboard_path(:atom, { private_token: current_user.private_token }) do + = image_tag "rss_ui.png", title: "feed" + %strong News Feed + + %hr + .gitlab-promo + = link_to "Homepage", "http://gitlabhq.com" + = link_to "Blog", "http://blog.gitlabhq.com" + = link_to "@gitlabhq", "https://twitter.com/gitlabhq" + + +- else + %h3.nothing_here_message There are no projects you have access to. + %br + %h4.nothing_here_message + - if current_user.can_create_project? + You can create up to + = current_user.projects_limit + projects. Click on button below to add a new one + .link_holder + = link_to new_project_path, class: "btn primary" do + New Project » + - else + If you will be added to project - it will be displayed here + + +:javascript + $(function(){ Pager.init(20); }); diff --git a/app/views/groups/show.js.haml b/app/views/groups/show.js.haml new file mode 100644 index 00000000..7e5a148e --- /dev/null +++ b/app/views/groups/show.js.haml @@ -0,0 +1,2 @@ +:plain + Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}"); diff --git a/app/views/layouts/group.html.haml b/app/views/layouts/group.html.haml index 810c296e..e4277eff 100644 --- a/app/views/layouts/group.html.haml +++ b/app/views/layouts/group.html.haml @@ -3,22 +3,22 @@ = render "layouts/head" %body{class: "#{app_theme} application"} = render "layouts/flash" - = render "layouts/head_panel", title: "#{@group.name}:Dashboard" + = render "layouts/head_panel", title: "#{@group.name}" .container %ul.main_menu - = nav_link(path: 'dashboard#index', html_options: {class: 'home'}) do - = link_to "Home", root_path, title: "Home" - = nav_link(path: 'dashboard#issues') do - = link_to dashboard_issues_path(group: @group) do + = nav_link(path: 'groups#show', html_options: {class: 'home'}) do + = link_to "Home", group_path(@group), title: "Home" + = nav_link(path: 'groups#issues') do + = link_to issues_group_path(@group) do Issues %span.count= current_user.assigned_issues.opened.count - = nav_link(path: 'dashboard#merge_requests') do - = link_to dashboard_merge_requests_path(group: @group) do + = nav_link(path: 'groups#merge_requests') do + = link_to merge_requests_group_path(@group) do Merge Requests %span.count= current_user.cared_merge_requests.count - = nav_link(path: 'search#show') do - = link_to "People", "#" - = nav_link(path: 'help#index') do - = link_to "Help", help_path + = nav_link(path: 'groups#search') do + = link_to "Search", search_group_path(@group) + = nav_link(path: 'groups#people') do + = link_to "People", people_group_path(@group) .content= yield diff --git a/config/routes.rb b/config/routes.rb index 2b923379..f6bebc6b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -86,6 +86,19 @@ Gitlab::Application.routes.draw do get "dashboard/issues" => "dashboard#issues" get "dashboard/merge_requests" => "dashboard#merge_requests" + + # + # Groups Area + # + resources :groups, constraints: { id: /[^\/]+/ }, only: [:show] do + member do + get :issues + get :merge_requests + get :search + get :people + end + end + resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create] devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks } From 010ac2b17f1e4bd0e104a90fd8bfc8c7bcb67ac8 Mon Sep 17 00:00:00 2001 From: randx Date: Tue, 2 Oct 2012 22:08:30 +0300 Subject: [PATCH 138/288] Added back link. cleanup group show page --- app/views/groups/show.html.haml | 60 +++++++++++++-------------------- 1 file changed, 23 insertions(+), 37 deletions(-) diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index 7552128e..074288a9 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -1,42 +1,28 @@ -- if @projects.any? - .projects - .activities.span8 - = render 'shared/no_ssh' - - if @events.any? - .content_list= render @events - - else - %h4.nothing_here_message Projects activity will be displayed here - .loading.hide - .side - = render "events/event_last_push", event: @last_push - = render "projects", projects: @projects - %div - %span.rss-icon - = link_to dashboard_path(:atom, { private_token: current_user.private_token }) do - = image_tag "rss_ui.png", title: "feed" - %strong News Feed - - %hr - .gitlab-promo - = link_to "Homepage", "http://gitlabhq.com" - = link_to "Blog", "http://blog.gitlabhq.com" - = link_to "@gitlabhq", "https://twitter.com/gitlabhq" - - -- else - %h3.nothing_here_message There are no projects you have access to. - %br - %h4.nothing_here_message - - if current_user.can_create_project? - You can create up to - = current_user.projects_limit - projects. Click on button below to add a new one - .link_holder - = link_to new_project_path, class: "btn primary" do - New Project » +.projects + .activities.span8 + .back_link + = link_to dashboard_path do + ← To dashboard + = render 'shared/no_ssh' + - if @events.any? + .content_list= render @events - else - If you will be added to project - it will be displayed here + %h4.nothing_here_message Projects activity will be displayed here + .loading.hide + .side + = render "events/event_last_push", event: @last_push + = render "projects", projects: @projects + %div + %span.rss-icon + = link_to dashboard_path(:atom, { private_token: current_user.private_token }) do + = image_tag "rss_ui.png", title: "feed" + %strong News Feed + %hr + .gitlab-promo + = link_to "Homepage", "http://gitlabhq.com" + = link_to "Blog", "http://blog.gitlabhq.com" + = link_to "@gitlabhq", "https://twitter.com/gitlabhq" :javascript $(function(){ Pager.init(20); }); From 38ca52f33b6a6824268f3dc92cf5ca13ad737c20 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 2 Oct 2012 18:42:39 -0400 Subject: [PATCH 139/288] Use branches.length and tags.length instead of [whatever]_count --- app/views/commits/_head.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/commits/_head.html.haml b/app/views/commits/_head.html.haml index 26ae32ed..c001c2f7 100644 --- a/app/views/commits/_head.html.haml +++ b/app/views/commits/_head.html.haml @@ -9,12 +9,12 @@ = nav_link(html_options: {class: branches_tab_class}) do = link_to project_repository_path(@project) do Branches - %span.badge= @project.repo.branch_count + %span.badge= @project.branches.length = nav_link(controller: :repositories, action: :tags) do = link_to tags_project_repository_path(@project) do Tags - %span.badge= @project.repo.tag_count + %span.badge= @project.tags.length - if current_controller?(:commits) && current_user.private_token %li.right From 5e3be9cda0e23e2c62a3e3b08791357ce572d998 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 2 Oct 2012 18:57:13 -0400 Subject: [PATCH 140/288] Cache the value of safe_message Also, just for extra paranoia, only call safe_message once in the decorator methods Adds specs to make sure it still works --- app/decorators/commit_decorator.rb | 22 ++++++++++-------- app/models/commit.rb | 2 +- spec/models/commit_spec.rb | 37 ++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 spec/models/commit_spec.rb diff --git a/app/decorators/commit_decorator.rb b/app/decorators/commit_decorator.rb index c85f7400..777580a6 100644 --- a/app/decorators/commit_decorator.rb +++ b/app/decorators/commit_decorator.rb @@ -16,13 +16,15 @@ class CommitDecorator < ApplicationDecorator # In case this first line is longer than 80 characters, it is cut off # after 70 characters and ellipses (`&hellp;`) are appended. def title - return no_commit_message if safe_message.blank? + title = safe_message - title_end = safe_message.index(/\n/) - if (!title_end && safe_message.length > 80) || (title_end && title_end > 80) - safe_message[0..69] << "…".html_safe + return no_commit_message if title.blank? + + title_end = title.index(/\n/) + if (!title_end && title.length > 80) || (title_end && title_end > 80) + title[0..69] << "…".html_safe else - safe_message.split(/\n/, 2).first + title.split(/\n/, 2).first end end @@ -30,11 +32,13 @@ class CommitDecorator < ApplicationDecorator # # cut off, ellipses (`&hellp;`) are prepended to the commit message. def description - title_end = safe_message.index(/\n/) - if (!title_end && safe_message.length > 80) || (title_end && title_end > 80) - "…".html_safe << safe_message[70..-1] + description = safe_message + + title_end = description.index(/\n/) + if (!title_end && description.length > 80) || (title_end && title_end > 80) + "…".html_safe << description[70..-1] else - safe_message.split(/\n/, 2)[1].try(:chomp) + description.split(/\n/, 2)[1].try(:chomp) end end diff --git a/app/models/commit.rb b/app/models/commit.rb index aba21762..a070e830 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -107,7 +107,7 @@ class Commit end def safe_message - utf8 message + @safe_message ||= utf8 message end def created_at diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb new file mode 100644 index 00000000..e4bc1936 --- /dev/null +++ b/spec/models/commit_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe Commit do + let(:commit) { create(:project).commit } + + describe CommitDecorator do + let(:decorator) { CommitDecorator.new(commit) } + + describe '#title' do + it "returns no_commit_message when safe_message is blank" do + decorator.stub(:safe_message).and_return('') + decorator.title.should == "--no commit message" + end + + it "truncates a message without a newline at 70 characters" do + message = commit.safe_message * 10 + + decorator.stub(:safe_message).and_return(message) + decorator.title.should == "#{message[0..69]}…" + end + + it "truncates a message with a newline before 80 characters at the newline" do + message = commit.safe_message.split(" ").first + + decorator.stub(:safe_message).and_return(message + "\n" + message) + decorator.title.should == message + end + + it "truncates a message with a newline after 80 characters at 70 characters" do + message = (commit.safe_message * 10) + "\n" + + decorator.stub(:safe_message).and_return(message) + decorator.title.should == "#{message[0..69]}…" + end + end + end +end From 224fb5770ce71061861f5c2bddb01924d668a841 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 3 Oct 2012 12:49:43 +0300 Subject: [PATCH 141/288] Added ability to manage groups from admin --- app/controllers/admin/groups_controller.rb | 8 ++++++++ app/views/admin/groups/_form.html.haml | 2 +- app/views/admin/groups/edit.html.haml | 3 +++ app/views/admin/groups/index.html.haml | 1 + app/views/admin/groups/show.html.haml | 4 ++++ app/views/admin/projects/index.html.haml | 1 + app/views/admin/projects/show.html.haml | 1 + app/views/admin/shared/_projects_head.html.haml | 5 +++++ app/views/groups/_projects.html.haml | 5 ----- app/views/layouts/admin.html.haml | 2 +- config/routes.rb | 1 + 11 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 app/views/admin/groups/edit.html.haml create mode 100644 app/views/admin/shared/_projects_head.html.haml diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 612abf8c..49082e1d 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -52,6 +52,14 @@ class Admin::GroupsController < AdminController redirect_to :back, notice: 'Group was successfully updated.' end + def remove_project + @project = Project.find(params[:project_id]) + @project.group_id = nil + @project.save + + redirect_to :back, notice: 'Group was successfully updated.' + end + def destroy @group.destroy diff --git a/app/views/admin/groups/_form.html.haml b/app/views/admin/groups/_form.html.haml index a1ba9406..46c59563 100644 --- a/app/views/admin/groups/_form.html.haml +++ b/app/views/admin/groups/_form.html.haml @@ -16,4 +16,4 @@ = f.text_field :code, placeholder: "example" .form-actions - = f.submit 'Create group', class: "btn primary" + = f.submit 'Save group', class: "btn save-btn" diff --git a/app/views/admin/groups/edit.html.haml b/app/views/admin/groups/edit.html.haml new file mode 100644 index 00000000..9904122c --- /dev/null +++ b/app/views/admin/groups/edit.html.haml @@ -0,0 +1,3 @@ +%h3.page_title Edit Group +%br += render 'form' diff --git a/app/views/admin/groups/index.html.haml b/app/views/admin/groups/index.html.haml index 6952c4c9..25efc9ee 100644 --- a/app/views/admin/groups/index.html.haml +++ b/app/views/admin/groups/index.html.haml @@ -1,3 +1,4 @@ += render 'admin/shared/projects_head' %h3.page_title Groups = link_to 'New Group', new_admin_group_path, class: "btn small right" diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index 5d348eec..309a10e5 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -1,3 +1,4 @@ += render 'admin/shared/projects_head' %h3.page_title Group: #{@group.name} = link_to edit_admin_group_path(@group), class: "btn right" do @@ -38,6 +39,9 @@ %li.wll %strong = link_to project.name, [:admin, project] + .right + = link_to 'Remove from group', remove_project_admin_group_path(@group, project_id: project.id), confirm: 'Are you sure?', method: :delete, class: "btn danger small" + .clearfix %br %h3 Add new project diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml index bd38ae72..13b0b44a 100644 --- a/app/views/admin/projects/index.html.haml +++ b/app/views/admin/projects/index.html.haml @@ -1,3 +1,4 @@ += render 'admin/shared/projects_head' %h3.page_title Projects = link_to 'New Project', new_admin_project_path, class: "btn small right" diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index ede48ea2..f16a0211 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -1,3 +1,4 @@ += render 'admin/shared/projects_head' %h3.page_title Project: #{@admin_project.name} = link_to edit_admin_project_path(@admin_project), class: "btn right" do diff --git a/app/views/admin/shared/_projects_head.html.haml b/app/views/admin/shared/_projects_head.html.haml new file mode 100644 index 00000000..3f5c34c5 --- /dev/null +++ b/app/views/admin/shared/_projects_head.html.haml @@ -0,0 +1,5 @@ +%ul.nav.nav-tabs + = nav_link(controller: :projects) do + = link_to 'Projects', admin_projects_path, class: "tab" + = nav_link(controller: :groups) do + = link_to 'Groups', admin_groups_path, class: "tab" diff --git a/app/views/groups/_projects.html.haml b/app/views/groups/_projects.html.haml index 35433057..b565dad3 100644 --- a/app/views/groups/_projects.html.haml +++ b/app/views/groups/_projects.html.haml @@ -3,11 +3,6 @@ Projects %small (#{projects.count}) - - if current_user.can_create_project? - %span.right - = link_to new_project_path, class: "btn very_small info" do - %i.icon-plus - New Project %ul.unstyled - projects.each do |project| %li.wll diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index dbb6939d..582f86ba 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -8,7 +8,7 @@ %ul.main_menu = nav_link(controller: :dashboard, html_options: {class: 'home'}) do = link_to "Stats", admin_root_path - = nav_link(controller: :projects) do + = nav_link(controller: [:projects, :groups]) do = link_to "Projects", admin_projects_path = nav_link(controller: :users) do = link_to "Users", admin_users_path diff --git a/config/routes.rb b/config/routes.rb index f6bebc6b..060fbf16 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -46,6 +46,7 @@ Gitlab::Application.routes.draw do resources :groups, constraints: { id: /[^\/]+/ } do member do put :project_update + delete :remove_project end end resources :projects, constraints: { id: /[^\/]+/ } do From dc22dd8aded81f10b8b9fc06f8c423043aa01d0a Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Wed, 3 Oct 2012 13:33:31 +0300 Subject: [PATCH 142/288] Factories spec refactoring after #1616 --- spec/factories_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/factories_spec.rb b/spec/factories_spec.rb index caf9ac9a..5ee73546 100644 --- a/spec/factories_spec.rb +++ b/spec/factories_spec.rb @@ -1,7 +1,9 @@ require 'spec_helper' +INVALID_FACTORIES = [:key_with_a_space_in_the_middle] + FactoryGirl.factories.map(&:name).each do |factory_name| - next if :key_with_a_space_in_the_middle == factory_name + next if INVALID_FACTORIES.include?(factory_name) describe "#{factory_name} factory" do it 'should be valid' do build(factory_name).should be_valid From 8b76e30656954c2dd95121fff46c4bc6cc81bb74 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 3 Oct 2012 13:42:17 +0300 Subject: [PATCH 143/288] Spianch test for group dashboard --- app/models/group.rb | 4 ++++ app/views/groups/show.html.haml | 8 ++++--- app/views/snippets/show.html.haml | 23 +++++++++++--------- features/dashboard/dashboard.feature | 5 +++++ features/group/group.feature | 9 ++++++++ features/steps/group/group.rb | 32 ++++++++++++++++++++++++++++ 6 files changed, 68 insertions(+), 13 deletions(-) create mode 100644 features/group/group.feature create mode 100644 features/steps/group/group.rb diff --git a/app/models/group.rb b/app/models/group.rb index 43283066..1bb805e8 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -22,6 +22,10 @@ class Group < ActiveRecord::Base delegate :name, to: :owner, allow_nil: true, prefix: true + def self.search query + where("name like :query or code like :query", query: "%#{query}%") + end + def to_param code end diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index 074288a9..cd86a01f 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -1,8 +1,10 @@ .projects .activities.span8 - .back_link - = link_to dashboard_path do - ← To dashboard + = link_to dashboard_path, class: 'btn very_small' do + ← To dashboard +   + %span.cgray Events and projects are filtered in scope of group + %hr = render 'shared/no_ssh' - if @events.any? .content_list= render @events diff --git a/app/views/snippets/show.html.haml b/app/views/snippets/show.html.haml index 4188a9f1..1b8701e9 100644 --- a/app/views/snippets/show.html.haml +++ b/app/views/snippets/show.html.haml @@ -7,14 +7,17 @@ = link_to "Edit", edit_project_snippet_path(@project, @snippet), class: "btn small right" %br -.file_holder - .file_title - %i.icon-file - %strong= @snippet.file_name - %span.options - = link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn very_small", target: "_blank" - .file_content.code - %div{class: current_user.dark_scheme ? "black" : ""} - = raw @snippet.colorize(options: { linenos: 'True'}) +%div + .file_holder + .file_title + %i.icon-file + %strong= @snippet.file_name + %span.options + = link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn very_small", target: "_blank" + .file_content.code + %div{class: current_user.dark_scheme ? "black" : ""} + = raw @snippet.colorize(options: { linenos: 'True'}) -= render "notes/notes_with_form", tid: @snippet.id, tt: "snippet" + +%div + = render "notes/notes_with_form", tid: @snippet.id, tt: "snippet" diff --git a/features/dashboard/dashboard.feature b/features/dashboard/dashboard.feature index 40217a7d..24296f46 100644 --- a/features/dashboard/dashboard.feature +++ b/features/dashboard/dashboard.feature @@ -10,6 +10,11 @@ Feature: Dashboard Then I should see "Shop" project link Then I should see project "Shop" activity feed + Scenario: I should see groups list + Given I have group with projects + And I visit dashboard page + Then I should see groups list + Scenario: I should see last push widget Then I should see last push widget And I click "Create Merge Request" link diff --git a/features/group/group.feature b/features/group/group.feature new file mode 100644 index 00000000..dbddb92c --- /dev/null +++ b/features/group/group.feature @@ -0,0 +1,9 @@ +Feature: Groups + Background: + Given I sign in as a user + And I have group with projects + + Scenario: I should see group dashboard list + When I visit group page + Then I should see projects list + And I should see projects activity feed diff --git a/features/steps/group/group.rb b/features/steps/group/group.rb new file mode 100644 index 00000000..798c62c3 --- /dev/null +++ b/features/steps/group/group.rb @@ -0,0 +1,32 @@ +class Groups < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + + When 'I visit group page' do + visit group_path(current_group) + end + + Then 'I should see projects list' do + current_user.projects.each do |project| + page.should have_link project.name + end + end + + And 'I have group with projects' do + @group = Factory :group + @project = Factory :project, group: @group + @event = Factory :closed_issue_event, project: @project + + @project.add_access current_user, :admin + end + + And 'I should see projects activity feed' do + page.should have_content 'closed issue' + end + + protected + + def current_group + @group ||= Group.first + end +end From ce1b79afa9faa8ffaae7392f9e48273c230753c4 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 3 Oct 2012 14:26:37 +0300 Subject: [PATCH 144/288] SQL Fixes --- app/controllers/groups_controller.rb | 2 +- app/models/group.rb | 6 +++++- app/models/project.rb | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 486b0bee..4a05434c 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -50,7 +50,7 @@ class GroupsController < ApplicationController end def people - @users = group.projects.map(&:users).flatten.uniq + @users = group.users end protected diff --git a/app/models/group.rb b/app/models/group.rb index 1bb805e8..628d0009 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -23,10 +23,14 @@ class Group < ActiveRecord::Base delegate :name, to: :owner, allow_nil: true, prefix: true def self.search query - where("name like :query or code like :query", query: "%#{query}%") + where("name like :query OR code like :query", query: "%#{query}%") end def to_param code end + + def users + User.joins(:users_projects).where('users_projects.project_id' => project_ids).uniq + end end diff --git a/app/models/project.rb b/app/models/project.rb index f525f292..c00bb456 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -30,15 +30,15 @@ class Project < ActiveRecord::Base # Scopes scope :public_only, where(private_flag: false) - scope :without_user, ->(user) { where("id not in (:ids)", ids: user.projects.map(&:id) ) } - scope :not_in_group, ->(group) { where("id not in (:ids)", ids: group.project_ids ) } + scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) } + scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) } def self.active joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC") end def self.search query - where("name like :query or code like :query or path like :query", query: "%#{query}%") + where("name like :query OR code like :query OR path like :query", query: "%#{query}%") end def self.create_by_user(params, user) From c8412bc9edbbed7a38cc4880f0d8cbb9091eb1d9 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 3 Oct 2012 15:02:02 +0300 Subject: [PATCH 145/288] Dont change params hash. Use dup instead --- app/controllers/admin/groups_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 49082e1d..bfde6548 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -32,13 +32,14 @@ class Admin::GroupsController < AdminController end def update - owner_id = params[:group].delete(:owner_id) + group_params = params[:group].dup + owner_id =group_params.delete(:owner_id) if owner_id @group.owner = User.find(owner_id) end - if @group.update_attributes(params[:group]) + if @group.update_attributes(group_params) redirect_to [:admin, @group], notice: 'Group was successfully updated.' else render action: "edit" From 2985697af788c33b3d5b4731ec60e9b5055f97b5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 3 Oct 2012 15:56:41 +0300 Subject: [PATCH 146/288] Real fix for removing keys. Closes PR #1616 --- lib/gitlab/backend/gitolite_config.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/gitlab/backend/gitolite_config.rb b/lib/gitlab/backend/gitolite_config.rb index ed366f61..fcf43fa2 100644 --- a/lib/gitlab/backend/gitolite_config.rb +++ b/lib/gitlab/backend/gitolite_config.rb @@ -96,8 +96,9 @@ module Gitlab end def rm_key(user) - File.unlink(File.join(config_tmp_dir, 'gitolite/keydir',"#{user}.pub")) - `cd #{File.join(config_tmp_dir,'gitolite')} ; git rm keydir/#{user}.pub` + key_path = File.join(config_tmp_dir, 'gitolite/keydir', "#{user}.pub") + ga_key = ::Gitolite::SSHKey.from_file(key_path) + ga_repo.rm_key(ga_key) end # update or create From 4f7bd583076076f6c5dcd4e6ec35a014ce5285eb Mon Sep 17 00:00:00 2001 From: randx Date: Wed, 3 Oct 2012 19:51:14 +0300 Subject: [PATCH 147/288] Bigger fonts for groups box --- app/assets/stylesheets/sections/projects.scss | 5 +++++ app/views/dashboard/_groups.html.haml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/sections/projects.scss b/app/assets/stylesheets/sections/projects.scss index 53a7c2bc..b1f20a3e 100644 --- a/app/assets/stylesheets/sections/projects.scss +++ b/app/assets/stylesheets/sections/projects.scss @@ -7,6 +7,7 @@ @extend .span4; @extend .right; + .groups_box, .projects_box { h5 { color:$style_color; @@ -21,6 +22,10 @@ padding:0; a { display:block; + .group_name { + font-size:14px; + line-height:18px; + } .project_name { color:#4fa2bd; font-size:14px; diff --git a/app/views/dashboard/_groups.html.haml b/app/views/dashboard/_groups.html.haml index 5180bfa0..146a49e6 100644 --- a/app/views/dashboard/_groups.html.haml +++ b/app/views/dashboard/_groups.html.haml @@ -1,4 +1,4 @@ -.projects_box +.groups_box %h5 Groups %small From c626ec3746f0346a4a90ebf6a0860583b79dd250 Mon Sep 17 00:00:00 2001 From: randx Date: Wed, 3 Oct 2012 23:46:55 +0300 Subject: [PATCH 148/288] Implement pending dashboard step --- features/steps/dashboard/dashboard.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/features/steps/dashboard/dashboard.rb b/features/steps/dashboard/dashboard.rb index 2bbbe55e..a9416f73 100644 --- a/features/steps/dashboard/dashboard.rb +++ b/features/steps/dashboard/dashboard.rb @@ -64,6 +64,14 @@ class Dashboard < Spinach::FeatureSteps @project.add_access(@user, :admin) end + And 'I have group with projects' do + @group = Factory :group + @project = Factory :project, group: @group + @event = Factory :closed_issue_event, project: @project + + @project.add_access current_user, :admin + end + And 'project "Shop" has push event' do @project = Project.find_by_name("Shop") @@ -89,4 +97,10 @@ class Dashboard < Spinach::FeatureSteps :author_id => @user.id ) end + + Then 'I should see groups list' do + Group.all.each do |group| + page.should have_link group.name + end + end end From b5328879f5c0131721a3cd71969f7579376d8498 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 3 Oct 2012 17:01:16 -0400 Subject: [PATCH 149/288] Rename tree.js to tree.js.coffee --- app/assets/javascripts/tree.js | 30 --------------------------- app/assets/javascripts/tree.js.coffee | 20 ++++++++++++++++++ 2 files changed, 20 insertions(+), 30 deletions(-) delete mode 100644 app/assets/javascripts/tree.js create mode 100644 app/assets/javascripts/tree.js.coffee diff --git a/app/assets/javascripts/tree.js b/app/assets/javascripts/tree.js deleted file mode 100644 index 1c62751a..00000000 --- a/app/assets/javascripts/tree.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Tree slider for code browse - * - */ -var Tree = { - init: - function() { - $('#tree-slider .tree-item-file-name a, .breadcrumb li > a').live("click", function() { - $("#tree-content-holder").hide("slide", { direction: "left" }, 150) - }) - - $('.project-refs-form').live({ - "ajax:beforeSend": function() { - $("#tree-content-holder").hide("slide", { direction: "left" }, 150); - } - }) - - $("#tree-slider .tree-item").live('click', function(e){ - if(e.target.nodeName != "A") { - link = $(this).find(".tree-item-file-name a"); - link.trigger("click"); - } - }); - - $('#tree-slider .tree-item-file-name a, .breadcrumb a, .project-refs-form').live({ - "ajax:beforeSend": function() { $('.tree_progress').addClass("loading"); }, - "ajax:complete": function() { $('.tree_progress').removeClass("loading"); } - }); - } -} diff --git a/app/assets/javascripts/tree.js.coffee b/app/assets/javascripts/tree.js.coffee new file mode 100644 index 00000000..200f1e06 --- /dev/null +++ b/app/assets/javascripts/tree.js.coffee @@ -0,0 +1,20 @@ +# Code browser tree slider + +$ -> + if $('#tree-slider').length > 0 + # Show the "Loading commit data" for only the first element + $('span.log_loading:first').removeClass('hide') + + $('#tree-slider .tree-item-file-name a, .breadcrumb li > a').live "click", -> + $("#tree-content-holder").hide("slide", { direction: "left" }, 150) + + $('.project-refs-form').live + "ajax:beforeSend": -> $("#tree-content-holder").hide("slide", { direction: "left" }, 150) + + # Make the entire tree-item row clickable, but not if clicking another link (like a commit message) + $("#tree-slider .tree-item").live 'click', (e) -> + $('.tree-item-file-name a', this).trigger('click') if (e.target.nodeName != "A") + + $('#tree-slider .tree-item-file-name a, .breadcrumb a, .project-refs-form').live + "ajax:beforeSend": -> $('.tree_progress').addClass("loading") + "ajax:complete": -> $('.tree_progress').removeClass("loading") From 96b4acf5e7e1d73e06b84efd31f1bc433bd79a1c Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 3 Oct 2012 18:28:50 -0400 Subject: [PATCH 150/288] Remove locals from tree/tree_file and just use "object" instead --- app/views/tree/_tree.html.haml | 4 +++- app/views/tree/_tree_file.html.haml | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/views/tree/_tree.html.haml b/app/views/tree/_tree.html.haml index 3e805d57..c25907fb 100644 --- a/app/views/tree/_tree.html.haml +++ b/app/views/tree/_tree.html.haml @@ -6,11 +6,13 @@ - tree.breadcrumbs(6) do |link| \/ %li= link + .clear %div.tree_progress + %div#tree-content-holder.tree-content-holder - if tree.is_blob? - = render partial: "tree/tree_file", locals: { name: tree.name, content: tree.data, file: tree } + = render partial: "tree/tree_file", object: tree - else - contents = tree.contents %table#tree-slider{class: "table_#{@hex_path} tree-table" } diff --git a/app/views/tree/_tree_file.html.haml b/app/views/tree/_tree_file.html.haml index 93f7be28..82aaed24 100644 --- a/app/views/tree/_tree_file.html.haml +++ b/app/views/tree/_tree_file.html.haml @@ -2,32 +2,32 @@ .file_title %i.icon-file %span.file_name - = name.force_encoding('utf-8') - %small #{file.mode} + = tree_file.name.force_encoding('utf-8') + %small #{tree_file.mode} %span.options = link_to "raw", project_blob_path(@project, @id), class: "btn very_small", target: "_blank" = link_to "history", project_commits_path(@project, @id), class: "btn very_small" = link_to "blame", project_blame_path(@project, @id), class: "btn very_small" - - if file.text? - - if gitlab_markdown?(name) + - if tree_file.text? + - if gitlab_markdown?(tree_file.name) .file_content.wiki = preserve do - = markdown(file.data) - - elsif markup?(name) + = markdown(tree_file.data) + - elsif markup?(tree_file.name) .file_content.wiki - = raw GitHub::Markup.render(name, file.data) + = raw GitHub::Markup.render(tree_file.name, tree_file.data) - else .file_content.code - - unless file.empty? + - unless tree_file.empty? %div{class: current_user.dark_scheme ? "black" : "white"} = preserve do - = raw file.colorize(options: { linenos: 'True'}) + = raw tree_file.colorize(options: { linenos: 'True'}) - else %h4.nothing_here_message Empty file - - elsif file.image? + - elsif tree_file.image? .file_content.image_file - %img{ src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} + %img{ src: "data:#{tree_file.mime_type};base64,#{Base64.encode64(tree_file.data)}"} - else .file_content.blob_file @@ -37,4 +37,4 @@ %br = image_tag "download.png", width: 64 %h3 - Download (#{file.mb_size}) + Download (#{tree_file.mb_size}) From 37c3474f683be3deac8ba1e90183029d2f49bcdc Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 3 Oct 2012 18:29:15 -0400 Subject: [PATCH 151/288] Tree.init() JS is no longer required --- app/views/tree/show.html.haml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/views/tree/show.html.haml b/app/views/tree/show.html.haml index 591818ce..a4034f22 100644 --- a/app/views/tree/show.html.haml +++ b/app/views/tree/show.html.haml @@ -1,8 +1,3 @@ = render "head" %div#tree-holder.tree-holder - = render "tree", commit: @commit, tree: @tree - -:javascript - $(function() { - Tree.init(); - }); + = render "tree", tree: @tree From a8fad4ff9c1ae5adbe55989a44dad56a6a9b56e6 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 3 Oct 2012 18:30:27 -0400 Subject: [PATCH 152/288] Remove locals from tree/submodule_item, use "object" instead --- app/views/tree/_submodule_item.html.haml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/views/tree/_submodule_item.html.haml b/app/views/tree/_submodule_item.html.haml index 6b9f5877..cfb0256c 100644 --- a/app/views/tree/_submodule_item.html.haml +++ b/app/views/tree/_submodule_item.html.haml @@ -1,13 +1,11 @@ -- url = content.url(@ref) rescue nil -- name = content.basename +- url = submodule_item.url(@ref) rescue nil +- name = submodule_item.basename - return unless url %tr{ class: "tree-item", url: url } %td.tree-item-file-name = image_tag "submodule.png" %strong= truncate(name, length: 40) %td - %code= content.id[0..10] + %code= submodule_item.id[0..10] %td = link_to truncate(url, length: 40), url - - From 388d72e6bf9c3e72113b8c16d1cc266b41870eb9 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 3 Oct 2012 18:40:56 -0400 Subject: [PATCH 153/288] Add render_tree helper; simplify (speed up) tree_icon --- app/assets/javascripts/tree.js.coffee | 1 + app/decorators/tree_decorator.rb | 4 +-- app/helpers/tree_helper.rb | 47 +++++++++++++++++---------- app/views/tree/_tree.html.haml | 17 +++------- app/views/tree/_tree_item.html.haml | 14 ++++---- app/views/tree/show.js.haml | 2 +- 6 files changed, 44 insertions(+), 41 deletions(-) diff --git a/app/assets/javascripts/tree.js.coffee b/app/assets/javascripts/tree.js.coffee index 200f1e06..83cc08dc 100644 --- a/app/assets/javascripts/tree.js.coffee +++ b/app/assets/javascripts/tree.js.coffee @@ -15,6 +15,7 @@ $ -> $("#tree-slider .tree-item").live 'click', (e) -> $('.tree-item-file-name a', this).trigger('click') if (e.target.nodeName != "A") + # Show/Hide the loading spinner $('#tree-slider .tree-item-file-name a, .breadcrumb a, .project-refs-form').live "ajax:beforeSend": -> $('.tree_progress').addClass("loading") "ajax:complete": -> $('.tree_progress').removeClass("loading") diff --git a/app/decorators/tree_decorator.rb b/app/decorators/tree_decorator.rb index 38236c2c..754868f5 100644 --- a/app/decorators/tree_decorator.rb +++ b/app/decorators/tree_decorator.rb @@ -8,14 +8,14 @@ class TreeDecorator < ApplicationDecorator #parts = parts[0...-1] if is_blob? - yield(h.link_to("..", "#", remote: :true)) if parts.count > max_links + yield(h.link_to("..", "#", remote: true)) if parts.count > max_links parts.each do |part| part_path = File.join(part_path, part) unless part_path.empty? part_path = part if part_path.empty? next unless parts.last(2).include?(part) if parts.count > max_links - yield(h.link_to(h.truncate(part, length: 40), h.project_tree_path(project, h.tree_join(ref, part_path)), remote: :true)) + yield(h.link_to(h.truncate(part, length: 40), h.project_tree_path(project, h.tree_join(ref, part_path)), remote: true)) end end end diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index 81a16989..65c23799 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -1,31 +1,42 @@ module TreeHelper - def tree_icon(content) - if content.is_a?(Grit::Blob) - if content.text? - image_tag "file_txt.png" - elsif content.image? - image_tag "file_img.png" + # Sorts a repository's tree so that folders are before files and renders + # their corresponding partials + # + # contents - A Grit::Tree object for the current tree + def render_tree(contents) + # Render Folders before Files/Submodules + folders, files = contents.partition { |v| v.kind_of?(Grit::Tree) } + + tree = "" + + # Render folders if we have any + tree += render partial: 'tree/tree_item', collection: folders, locals: {type: 'folder'} if folders.present? + + files.each do |f| + if f.respond_to?(:url) + # Object is a Submodule + tree += render partial: 'tree/submodule_item', object: f else - image_tag "file_bin.png" + # Object is a Blob + tree += render partial: 'tree/tree_item', object: f, locals: {type: 'file'} end - else - image_tag "file_dir.png" end + + tree.html_safe + end + + # Return an image icon depending on the file type + # + # type - String type of the tree item; either 'folder' or 'file' + def tree_icon(type) + image = type == 'folder' ? 'file_dir.png' : 'file_txt.png' + image_tag(image, size: '16x16') end def tree_hex_class(content) "file_#{hexdigest(content.name)}" end - def tree_full_path(content) - content.name.force_encoding('utf-8') - if params[:path] - File.join(params[:path], content.name) - else - content.name - end - end - # Public: Determines if a given filename is compatible with GitHub::Markup. # # filename - Filename string to check diff --git a/app/views/tree/_tree.html.haml b/app/views/tree/_tree.html.haml index c25907fb..920a70b5 100644 --- a/app/views/tree/_tree.html.haml +++ b/app/views/tree/_tree.html.haml @@ -14,7 +14,6 @@ - if tree.is_blob? = render partial: "tree/tree_file", object: tree - else - - contents = tree.contents %table#tree-slider{class: "table_#{@hex_path} tree-table" } %thead %th Name @@ -24,22 +23,16 @@ = link_to "History", tree.history_path, class: "right" - if tree.up_dir? - %tr{ class: "tree-item", url: tree.up_dir_path } + %tr.tree-item %td.tree-item-file-name - = image_tag "file_empty.png" - = link_to "..", tree.up_dir_path, remote: :true + = image_tag "file_empty.png", size: '16x16' + = link_to "..", tree.up_dir_path, remote: true %td %td - - index = 0 - - contents.select{ |i| i.is_a?(Grit::Tree)}.each do |content| - = render partial: "tree/tree_item", locals: { content: content, index: (index += 1) } - - contents.select{ |i| i.is_a?(Grit::Blob)}.each do |content| - = render partial: "tree/tree_item", locals: { content: content, index: (index += 1) } - - contents.select{ |i| i.is_a?(Grit::Submodule)}.each do |content| - = render partial: "tree/submodule_item", locals: { content: content, index: (index += 1) } + = render_tree(tree.contents) - - if content = contents.select{ |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i }.first + - if content = tree.contents.find { |c| c.is_a?(Grit::Blob) and c.name =~ /^readme/i } .file_holder#README .file_title %i.icon-file diff --git a/app/views/tree/_tree_item.html.haml b/app/views/tree/_tree_item.html.haml index 226c380f..87311e19 100644 --- a/app/views/tree/_tree_item.html.haml +++ b/app/views/tree/_tree_item.html.haml @@ -1,11 +1,9 @@ -- file = tree_full_path(content) -%tr{ class: "tree-item #{tree_hex_class(content)}", url: project_tree_path(@project, tree_join(@id, file)) } +%tr{ class: "tree-item #{tree_hex_class(tree_item)}" } %td.tree-item-file-name - = tree_icon(content) - %strong= link_to truncate(content.name, length: 40), project_tree_path(@project, tree_join(@id || @commit.id, file)), remote: :true + = tree_icon(type) + %strong= link_to truncate(tree_item.name, length: 40), project_tree_path(@project, tree_join(@id || @commit.id, tree_item.name)), remote: true %td.tree_time_ago.cgray - - if index == 1 - %span.log_loading - Loading commit data.. - = image_tag "ajax_loader_tree.gif", width: 14 + %span.log_loading.hide + Loading commit data... + = image_tag "ajax_loader_tree.gif", width: 14 %td.tree_commit diff --git a/app/views/tree/show.js.haml b/app/views/tree/show.js.haml index 174e3e03..fadd5e22 100644 --- a/app/views/tree/show.js.haml +++ b/app/views/tree/show.js.haml @@ -1,6 +1,6 @@ :plain // Load Files list - $("#tree-holder").html("#{escape_javascript(render(partial: "tree", locals: {commit: @commit, tree: @tree}))}"); + $("#tree-holder").html("#{escape_javascript(render(partial: "tree", locals: {tree: @tree}))}"); $("#tree-content-holder").show("slide", { direction: "right" }, 150); $('.project-refs-form #path').val("#{@path}"); From 187e192cdf4470fa07a62aa0720c586b6dde2bde Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 3 Oct 2012 19:11:39 -0400 Subject: [PATCH 154/288] Use official Grit 2.5.0 --- Gemfile | 2 +- Gemfile.lock | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index 042fbc4d..d0701732 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,7 @@ gem 'omniauth-twitter' gem 'omniauth-github' # GITLAB patched libs -gem "grit", :git => "https://github.com/gitlabhq/grit.git", :ref => "7f35cb98ff17d534a07e3ce6ec3d580f67402837" +gem "grit", '2.5.0' gem "omniauth-ldap", :git => "https://github.com/gitlabhq/omniauth-ldap.git", :ref => "f038dd852d7bd473a557e385d5d7c2fd5dc1dc2e" gem 'yaml_db', :git => "https://github.com/gitlabhq/yaml_db.git" gem 'grack', :git => "https://github.com/gitlabhq/grack.git" diff --git a/Gemfile.lock b/Gemfile.lock index 3c3bea9d..b54773ed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,16 +11,6 @@ GIT grack (1.0.0) rack (~> 1.4.1) -GIT - remote: https://github.com/gitlabhq/grit.git - revision: 7f35cb98ff17d534a07e3ce6ec3d580f67402837 - ref: 7f35cb98ff17d534a07e3ce6ec3d580f67402837 - specs: - grit (2.5.0) - diff-lcs (~> 1.1) - mime-types (~> 1.15) - posix-spawn (~> 0.3.6) - GIT remote: https://github.com/gitlabhq/omniauth-ldap.git revision: f038dd852d7bd473a557e385d5d7c2fd5dc1dc2e @@ -157,6 +147,10 @@ GEM rack rack-mount gratr19 (0.4.4.1) + grit (2.5.0) + diff-lcs (~> 1.1) + mime-types (~> 1.15) + posix-spawn (~> 0.3.6) growl (1.0.3) guard (1.3.2) listen (>= 0.4.2) @@ -421,7 +415,7 @@ DEPENDENCIES gitolite (= 1.1.0) grack! grape (~> 0.2.1) - grit! + grit (= 2.5.0) growl guard-rspec guard-spinach From d88332709cfa42d7f1ccd9ab6bc7622b970ef9de Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 4 Oct 2012 10:51:35 +0300 Subject: [PATCH 155/288] Fixed group issues/mr. Also speedup project list of admin area --- app/controllers/groups_controller.rb | 6 ++++-- app/roles/issue_commonality.rb | 1 + app/views/admin/projects/index.html.haml | 2 -- app/views/admin/projects/show.html.haml | 9 +++++++++ app/views/layouts/group.html.haml | 4 ++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 4a05434c..c76e5c4c 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -21,13 +21,15 @@ class GroupsController < ApplicationController # Get authored or assigned open merge requests def merge_requests - @merge_requests = current_user.cared_merge_requests.order("created_at DESC").page(params[:page]).per(20) + @merge_requests = current_user.cared_merge_requests + @merge_requests = @merge_requests.of_group(@group).order("created_at DESC").page(params[:page]).per(20) end # Get only assigned issues def issues @user = current_user - @issues = current_user.assigned_issues.opened.order("created_at DESC").page(params[:page]).per(20) + @issues = current_user.assigned_issues.opened + @issues = @issues.of_group(@group).order("created_at DESC").page(params[:page]).per(20) @issues = @issues.includes(:author, :project) respond_to do |format| diff --git a/app/roles/issue_commonality.rb b/app/roles/issue_commonality.rb index 55b46ec0..ab6f89ff 100644 --- a/app/roles/issue_commonality.rb +++ b/app/roles/issue_commonality.rb @@ -18,6 +18,7 @@ module IssueCommonality scope :opened, where(closed: false) scope :closed, where(closed: true) + scope :of_group, ->(group) { where(project_id: group.project_ids) } scope :assigned, lambda { |u| where(assignee_id: u.id)} delegate :name, diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml index 13b0b44a..3335fce0 100644 --- a/app/views/admin/projects/index.html.haml +++ b/app/views/admin/projects/index.html.haml @@ -12,7 +12,6 @@ %th Name %th Path %th Team Members - %th Post Receive %th Last Commit %th Edit %th.cred Danger Zone! @@ -22,7 +21,6 @@ %td= link_to project.name, [:admin, project] %td= project.path %td= project.users_projects.count - %td= check_box_tag :post_receive_file, 1, project.has_post_receive_file?, disabled: true %td= last_commit(project) %td= link_to 'Edit', edit_admin_project_path(project), id: "edit_#{dom_id(project)}", class: "btn small" %td.bgred= link_to 'Destroy', [:admin, project], confirm: "REMOVE #{project.name}? Are you sure?", method: :delete, class: "btn small danger" diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index f16a0211..f85b6e4b 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -5,6 +5,15 @@ %i.icon-edit Edit +- if !@admin_project.has_post_receive_file? && @admin_project.commit + %br + .alert.alert-error + %span + %strong Important! + Project has commits but missing post-receive file. + %br + If you exported project manually - copy post-receive hook to bare repository + %br %table.zebra-striped %thead diff --git a/app/views/layouts/group.html.haml b/app/views/layouts/group.html.haml index e4277eff..985200e2 100644 --- a/app/views/layouts/group.html.haml +++ b/app/views/layouts/group.html.haml @@ -11,11 +11,11 @@ = nav_link(path: 'groups#issues') do = link_to issues_group_path(@group) do Issues - %span.count= current_user.assigned_issues.opened.count + %span.count= current_user.assigned_issues.opened.of_group(@group).count = nav_link(path: 'groups#merge_requests') do = link_to merge_requests_group_path(@group) do Merge Requests - %span.count= current_user.cared_merge_requests.count + %span.count= current_user.cared_merge_requests.of_group(@group).count = nav_link(path: 'groups#search') do = link_to "Search", search_group_path(@group) = nav_link(path: 'groups#people') do From 987e351de7fb6c98094a1c099c717dacb3f1416e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Leutgo=CC=88b?= Date: Thu, 4 Oct 2012 10:06:17 +0200 Subject: [PATCH 156/288] Escape html entities in commit messages --- app/views/events/_event_push.atom.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/events/_event_push.atom.haml b/app/views/events/_event_push.atom.haml index 340275a5..d09e6e03 100644 --- a/app/views/events/_event_push.atom.haml +++ b/app/views/events/_event_push.atom.haml @@ -6,7 +6,7 @@ %i at = commit.committed_date.strftime("%Y-%m-%d %H:%M:%S") - %blockquote= simple_format commit.safe_message + %blockquote= simple_format(escape_once(commit.safe_message)) - if event.commits_count > 15 %p %i From bd5334abc28ddc17b18df25cfe2fee1240d132a6 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Thu, 4 Oct 2012 13:28:58 +0300 Subject: [PATCH 157/288] fix inline diff --- lib/gitlab/inline_diff.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/gitlab/inline_diff.rb b/lib/gitlab/inline_diff.rb index 0f289a61..7a0a3214 100644 --- a/lib/gitlab/inline_diff.rb +++ b/lib/gitlab/inline_diff.rb @@ -21,14 +21,13 @@ module Gitlab end end first_token = first_line[0..first_the_same_symbols][1..-1] - diff_arr[index+1].sub!(first_token, first_token + START) diff_arr[index+2].sub!(first_token, first_token + START) - last_the_same_symbols = 0 (1..max_length + 1).each do |i| last_the_same_symbols = -i - if first_line[-i] != second_line[-i] + shortest_line = second_line.size > first_line.size ? first_line : second_line + if ( first_line[-i] != second_line[-i] ) || "#{first_token}#{START}".size == shortest_line[1..-i].size break end end From 76c4e831932bff2273c38abe1ff37cdb79164c90 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Thu, 4 Oct 2012 13:40:40 +0300 Subject: [PATCH 158/288] Minore code-style fixes --- app/models/group.rb | 2 +- app/models/project.rb | 4 ++-- app/models/user.rb | 2 +- app/roles/issue_commonality.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/group.rb b/app/models/group.rb index 628d0009..780d5fdd 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -23,7 +23,7 @@ class Group < ActiveRecord::Base delegate :name, to: :owner, allow_nil: true, prefix: true def self.search query - where("name like :query OR code like :query", query: "%#{query}%") + where("name LIKE :query OR code LIKE :query", query: "%#{query}%") end def to_param diff --git a/app/models/project.rb b/app/models/project.rb index c00bb456..982b7463 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -38,7 +38,7 @@ class Project < ActiveRecord::Base end def self.search query - where("name like :query OR code like :query OR path like :query", query: "%#{query}%") + where("name LIKE :query OR code LIKE :query OR path LIKE :query", query: "%#{query}%") end def self.create_by_user(params, user) @@ -127,7 +127,7 @@ class Project < ActiveRecord::Base end def commit_line_notes(commit) - notes.where(noteable_id: commit.id, noteable_type: "Commit").where("line_code is not null") + notes.where(noteable_id: commit.id, noteable_type: "Commit").where("line_code IS NOT NULL") end def public? diff --git a/app/models/user.rb b/app/models/user.rb index bed568ef..cf12fd60 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -73,7 +73,7 @@ class User < ActiveRecord::Base end def self.search query - where("name like :query or email like :query", query: "%#{query}%") + where("name LIKE :query OR email LIKE :query", query: "%#{query}%") end end diff --git a/app/roles/issue_commonality.rb b/app/roles/issue_commonality.rb index ab6f89ff..304f08fd 100644 --- a/app/roles/issue_commonality.rb +++ b/app/roles/issue_commonality.rb @@ -19,7 +19,7 @@ module IssueCommonality scope :opened, where(closed: false) scope :closed, where(closed: true) scope :of_group, ->(group) { where(project_id: group.project_ids) } - scope :assigned, lambda { |u| where(assignee_id: u.id)} + scope :assigned, ->(u) { where(assignee_id: u.id)} delegate :name, :email, From c6c01e1040a45f2cd3400a5847a58b7bf9b8c5c6 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Thu, 4 Oct 2012 13:48:20 +0300 Subject: [PATCH 159/288] ruby version changed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 122cd984..a8f8c0bb 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ GitLab is a free project and repository management application ## Requirements * Ubuntu/Debian -* ruby 1.9.2+ +* ruby 1.9.3+ * mysql or sqlite * git * gitolite From 73d5e51a2df5757d2eaf4ca9b54d05b48da8e15f Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Thu, 4 Oct 2012 13:55:29 +0300 Subject: [PATCH 160/288] added trace to travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bb4c4a79..2aa468fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,4 +18,4 @@ before_script: - "bundle exec rake db:migrate RAILS_ENV=test" - "bundle exec rake db:seed_fu RAILS_ENV=test" - "sh -e /etc/init.d/xvfb start" -script: "bundle exec rake travis" +script: "bundle exec rake travis --trace" From e25ddca0c462522703af93822863023f4a754390 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Thu, 4 Oct 2012 19:31:31 +0300 Subject: [PATCH 161/288] Fix bug with branches whose name contains slash --- lib/extracts_path.rb | 14 +++++++------- spec/lib/extracts_path_spec.rb | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb index f36dae52..020ff5cd 100644 --- a/lib/extracts_path.rb +++ b/lib/extracts_path.rb @@ -56,22 +56,22 @@ module ExtractsPath # Append a trailing slash if we only get a ref and no file path id = input - id += '/' unless id.include?('/') - + id += '/' unless id.ends_with?('/') + valid_refs = @project.branches + @project.tags - valid_refs.select! { |v| id.start_with?("#{v}/") } - + valid_refs.select! { |v| id.start_with?("#{v.name}/") } + if valid_refs.length != 1 # No exact ref match, so just try our best pair = id.match(/([^\/]+)(.*)/).captures else # Partition the string into the ref and the path, ignoring the empty first value - pair = id.partition(valid_refs.first)[1..-1] + pair = id.partition(valid_refs.first.name)[1..-1] end end - # Remove leading slash from path - pair[1].gsub!(/^\//, '') + # Remove ending slashes from path + pair[1].gsub!(/^\/|\/$/, '') pair end diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index 8876373d..3ee729c9 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -7,8 +7,8 @@ describe ExtractsPath do before do @project = project - project.stub(:branches).and_return(['master', 'foo/bar/baz']) - project.stub(:tags).and_return(['v1.0.0', 'v2.0.0']) + project.stub(:branches).and_return([stub(name: 'master'), stub(name: 'foo/bar/baz')]) + project.stub(:tags).and_return([stub(name: 'master'), stub(name: 'master')]) end describe '#extract_ref' do From 3606a1488952008426b1be870e62804b22fe8a61 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 4 Oct 2012 14:13:52 -0400 Subject: [PATCH 162/288] ExtractsPath: Use ref_names instead of branches+tags --- lib/extracts_path.rb | 10 +++++----- spec/lib/extracts_path_spec.rb | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb index 020ff5cd..b60dfd03 100644 --- a/lib/extracts_path.rb +++ b/lib/extracts_path.rb @@ -57,16 +57,16 @@ module ExtractsPath # Append a trailing slash if we only get a ref and no file path id = input id += '/' unless id.ends_with?('/') - - valid_refs = @project.branches + @project.tags - valid_refs.select! { |v| id.start_with?("#{v.name}/") } - + + valid_refs = @project.ref_names + valid_refs.select! { |v| id.start_with?("#{v}/") } + if valid_refs.length != 1 # No exact ref match, so just try our best pair = id.match(/([^\/]+)(.*)/).captures else # Partition the string into the ref and the path, ignoring the empty first value - pair = id.partition(valid_refs.first.name)[1..-1] + pair = id.partition(valid_refs.first)[1..-1] end end diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index 3ee729c9..cf422017 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -7,8 +7,7 @@ describe ExtractsPath do before do @project = project - project.stub(:branches).and_return([stub(name: 'master'), stub(name: 'foo/bar/baz')]) - project.stub(:tags).and_return([stub(name: 'master'), stub(name: 'master')]) + project.stub(:ref_names).and_return(['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0']) end describe '#extract_ref' do From 332fc328a394ec1e6110af872d5cb51c920a4306 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 4 Oct 2012 14:19:17 -0400 Subject: [PATCH 163/288] Revert "Use official Grit 2.5.0" This reverts commit 187e192cdf4470fa07a62aa0720c586b6dde2bde. [ci skip] --- Gemfile | 2 +- Gemfile.lock | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index d0701732..042fbc4d 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,7 @@ gem 'omniauth-twitter' gem 'omniauth-github' # GITLAB patched libs -gem "grit", '2.5.0' +gem "grit", :git => "https://github.com/gitlabhq/grit.git", :ref => "7f35cb98ff17d534a07e3ce6ec3d580f67402837" gem "omniauth-ldap", :git => "https://github.com/gitlabhq/omniauth-ldap.git", :ref => "f038dd852d7bd473a557e385d5d7c2fd5dc1dc2e" gem 'yaml_db', :git => "https://github.com/gitlabhq/yaml_db.git" gem 'grack', :git => "https://github.com/gitlabhq/grack.git" diff --git a/Gemfile.lock b/Gemfile.lock index b54773ed..3c3bea9d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,6 +11,16 @@ GIT grack (1.0.0) rack (~> 1.4.1) +GIT + remote: https://github.com/gitlabhq/grit.git + revision: 7f35cb98ff17d534a07e3ce6ec3d580f67402837 + ref: 7f35cb98ff17d534a07e3ce6ec3d580f67402837 + specs: + grit (2.5.0) + diff-lcs (~> 1.1) + mime-types (~> 1.15) + posix-spawn (~> 0.3.6) + GIT remote: https://github.com/gitlabhq/omniauth-ldap.git revision: f038dd852d7bd473a557e385d5d7c2fd5dc1dc2e @@ -147,10 +157,6 @@ GEM rack rack-mount gratr19 (0.4.4.1) - grit (2.5.0) - diff-lcs (~> 1.1) - mime-types (~> 1.15) - posix-spawn (~> 0.3.6) growl (1.0.3) guard (1.3.2) listen (>= 0.4.2) @@ -415,7 +421,7 @@ DEPENDENCIES gitolite (= 1.1.0) grack! grape (~> 0.2.1) - grit (= 2.5.0) + grit! growl guard-rspec guard-spinach From 58dad2b95463ae0bb0fd21258804f32352f0a6b5 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 4 Oct 2012 14:30:31 -0400 Subject: [PATCH 164/288] Remove leftover ref_extractor_spec file Apparently it didn't get removed after the rename to ExtractsPath. --- spec/lib/ref_extractor_spec.rb | 58 ---------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 spec/lib/ref_extractor_spec.rb diff --git a/spec/lib/ref_extractor_spec.rb b/spec/lib/ref_extractor_spec.rb deleted file mode 100644 index 8876373d..00000000 --- a/spec/lib/ref_extractor_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'spec_helper' - -describe ExtractsPath do - include ExtractsPath - - let(:project) { double('project') } - - before do - @project = project - project.stub(:branches).and_return(['master', 'foo/bar/baz']) - project.stub(:tags).and_return(['v1.0.0', 'v2.0.0']) - end - - describe '#extract_ref' do - it "returns an empty pair when no @project is set" do - @project = nil - extract_ref('master/CHANGELOG').should == ['', ''] - end - - context "without a path" do - it "extracts a valid branch" do - extract_ref('master').should == ['master', ''] - end - - it "extracts a valid tag" do - extract_ref('v2.0.0').should == ['v2.0.0', ''] - end - - it "extracts a valid commit ref without a path" do - extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062').should == - ['f4b14494ef6abf3d144c28e4af0c20143383e062', ''] - end - - it "falls back to a primitive split for an invalid ref" do - extract_ref('stable').should == ['stable', ''] - end - end - - context "with a path" do - it "extracts a valid branch" do - extract_ref('foo/bar/baz/CHANGELOG').should == ['foo/bar/baz', 'CHANGELOG'] - end - - it "extracts a valid tag" do - extract_ref('v2.0.0/CHANGELOG').should == ['v2.0.0', 'CHANGELOG'] - end - - it "extracts a valid commit SHA" do - extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG').should == - ['f4b14494ef6abf3d144c28e4af0c20143383e062', 'CHANGELOG'] - end - - it "falls back to a primitive split for an invalid ref" do - extract_ref('stable/CHANGELOG').should == ['stable', 'CHANGELOG'] - end - end - end -end From 74213534bc324886451c3f858409fc0d33eecc8c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 5 Oct 2012 17:01:44 +0300 Subject: [PATCH 165/288] Fix tests --- spec/requests/admin/admin_projects_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/requests/admin/admin_projects_spec.rb b/spec/requests/admin/admin_projects_spec.rb index 2edfb592..61e66eec 100644 --- a/spec/requests/admin/admin_projects_spec.rb +++ b/spec/requests/admin/admin_projects_spec.rb @@ -87,7 +87,7 @@ describe "Admin::Projects" do visit new_admin_project_path fill_in 'project_name', with: 'NewProject' fill_in 'project_code', with: 'NPR' - fill_in 'project_path', with: 'newproject' + fill_in 'project_path', with: 'gitlabhq_1' expect { click_button "Create project" }.to change { Project.count }.by(1) @project = Project.last end @@ -102,13 +102,13 @@ describe "Admin::Projects" do end end - describe "Add new team member" do - before do + describe "Add new team member" do + before do @new_user = Factory :user visit admin_project_path(@project) end - it "should create new user" do + it "should create new user" do select @new_user.name, from: "user_ids" expect { click_button "Add" }.to change { UsersProject.count }.by(1) page.should have_content @new_user.name From 9e4f3147a0f4b352ba243a03f76daade3dcee056 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Fri, 5 Oct 2012 05:22:01 -0700 Subject: [PATCH 166/288] specify HTTP verbs for match in routes --- config/routes.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 060fbf16..54b298c9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -184,7 +184,8 @@ Gitlab::Application.routes.draw do resources :blame, only: [:show], constraints: {id: /.+/} resources :blob, only: [:show], constraints: {id: /.+/} resources :tree, only: [:show], constraints: {id: /.+/} - match "/compare/:from...:to" => "compare#show", as: "compare", constraints: {from: /.+/, to: /.+/} + match "/compare/:from...:to" => "compare#show", as: "compare", + :via => [:get, :post], constraints: {from: /.+/, to: /.+/} resources :team, controller: 'team_members', only: [:index] resources :team_members From 317c928198aac43d4e00d1645318a373a33974cf Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Fri, 5 Oct 2012 07:13:21 -0700 Subject: [PATCH 167/288] improve emoji checking performance --- config/initializers/emoji.rb | 4 ++++ lib/gitlab/markdown.rb | 2 +- {app => vendor}/assets/images/emoji/+1.png | Bin {app => vendor}/assets/images/emoji/-1.png | Bin {app => vendor}/assets/images/emoji/100.png | Bin {app => vendor}/assets/images/emoji/109.png | Bin {app => vendor}/assets/images/emoji/1234.png | Bin {app => vendor}/assets/images/emoji/8ball.png | Bin {app => vendor}/assets/images/emoji/a.png | Bin {app => vendor}/assets/images/emoji/ab.png | Bin {app => vendor}/assets/images/emoji/abc.png | Bin {app => vendor}/assets/images/emoji/abcd.png | Bin {app => vendor}/assets/images/emoji/accept.png | Bin .../assets/images/emoji/aerial_tramway.png | Bin {app => vendor}/assets/images/emoji/airplane.png | Bin {app => vendor}/assets/images/emoji/alarm_clock.png | Bin {app => vendor}/assets/images/emoji/alien.png | Bin {app => vendor}/assets/images/emoji/ambulance.png | Bin {app => vendor}/assets/images/emoji/anchor.png | Bin {app => vendor}/assets/images/emoji/angel.png | Bin {app => vendor}/assets/images/emoji/anger.png | Bin {app => vendor}/assets/images/emoji/angry.png | Bin {app => vendor}/assets/images/emoji/ant.png | Bin {app => vendor}/assets/images/emoji/apple.png | Bin {app => vendor}/assets/images/emoji/aquarius.png | Bin {app => vendor}/assets/images/emoji/aries.png | Bin .../assets/images/emoji/arrow_backward.png | Bin .../assets/images/emoji/arrow_double_down.png | Bin .../assets/images/emoji/arrow_double_up.png | Bin {app => vendor}/assets/images/emoji/arrow_down.png | Bin .../assets/images/emoji/arrow_down_small.png | Bin .../assets/images/emoji/arrow_forward.png | Bin .../assets/images/emoji/arrow_heading_down.png | Bin .../assets/images/emoji/arrow_heading_up.png | Bin {app => vendor}/assets/images/emoji/arrow_left.png | Bin .../assets/images/emoji/arrow_lower_left.png | Bin .../assets/images/emoji/arrow_lower_right.png | Bin {app => vendor}/assets/images/emoji/arrow_right.png | Bin .../assets/images/emoji/arrow_right_hook.png | Bin {app => vendor}/assets/images/emoji/arrow_up.png | Bin .../assets/images/emoji/arrow_up_down.png | Bin .../assets/images/emoji/arrow_up_small.png | Bin .../assets/images/emoji/arrow_upper_left.png | Bin .../assets/images/emoji/arrow_upper_right.png | Bin .../assets/images/emoji/arrows_clockwise.png | Bin .../assets/images/emoji/arrows_counterclockwise.png | Bin {app => vendor}/assets/images/emoji/art.png | Bin .../assets/images/emoji/articulated_lorry.png | Bin {app => vendor}/assets/images/emoji/astonished.png | Bin {app => vendor}/assets/images/emoji/atm.png | Bin {app => vendor}/assets/images/emoji/b.png | Bin {app => vendor}/assets/images/emoji/baby.png | Bin {app => vendor}/assets/images/emoji/baby_bottle.png | Bin {app => vendor}/assets/images/emoji/baby_chick.png | Bin {app => vendor}/assets/images/emoji/baby_symbol.png | Bin .../assets/images/emoji/baggage_claim.png | Bin {app => vendor}/assets/images/emoji/balloon.png | Bin .../assets/images/emoji/ballot_box_with_check.png | Bin {app => vendor}/assets/images/emoji/bamboo.png | Bin {app => vendor}/assets/images/emoji/banana.png | Bin {app => vendor}/assets/images/emoji/bangbang.png | Bin {app => vendor}/assets/images/emoji/bank.png | Bin {app => vendor}/assets/images/emoji/bar_chart.png | Bin {app => vendor}/assets/images/emoji/barber.png | Bin {app => vendor}/assets/images/emoji/baseball.png | Bin {app => vendor}/assets/images/emoji/basketball.png | Bin {app => vendor}/assets/images/emoji/bath.png | Bin {app => vendor}/assets/images/emoji/bathtub.png | Bin {app => vendor}/assets/images/emoji/battery.png | Bin {app => vendor}/assets/images/emoji/bear.png | Bin {app => vendor}/assets/images/emoji/beer.png | Bin {app => vendor}/assets/images/emoji/beers.png | Bin {app => vendor}/assets/images/emoji/beetle.png | Bin {app => vendor}/assets/images/emoji/beginner.png | Bin {app => vendor}/assets/images/emoji/bell.png | Bin {app => vendor}/assets/images/emoji/bento.png | Bin {app => vendor}/assets/images/emoji/bicyclist.png | Bin {app => vendor}/assets/images/emoji/bike.png | Bin {app => vendor}/assets/images/emoji/bikini.png | Bin {app => vendor}/assets/images/emoji/bird.png | Bin {app => vendor}/assets/images/emoji/birthday.png | Bin .../assets/images/emoji/black_circle.png | Bin {app => vendor}/assets/images/emoji/black_joker.png | Bin {app => vendor}/assets/images/emoji/black_nib.png | Bin .../assets/images/emoji/black_square.png | Bin {app => vendor}/assets/images/emoji/blossom.png | Bin {app => vendor}/assets/images/emoji/blowfish.png | Bin {app => vendor}/assets/images/emoji/blue_book.png | Bin {app => vendor}/assets/images/emoji/blue_car.png | Bin {app => vendor}/assets/images/emoji/blue_heart.png | Bin {app => vendor}/assets/images/emoji/blush.png | Bin {app => vendor}/assets/images/emoji/boar.png | Bin {app => vendor}/assets/images/emoji/boat.png | Bin {app => vendor}/assets/images/emoji/bomb.png | Bin {app => vendor}/assets/images/emoji/book.png | Bin {app => vendor}/assets/images/emoji/bookmark.png | Bin .../assets/images/emoji/bookmark_tabs.png | Bin {app => vendor}/assets/images/emoji/books.png | Bin {app => vendor}/assets/images/emoji/boot.png | Bin {app => vendor}/assets/images/emoji/bouquet.png | Bin {app => vendor}/assets/images/emoji/bow.png | Bin {app => vendor}/assets/images/emoji/bowling.png | Bin {app => vendor}/assets/images/emoji/bowtie.png | Bin {app => vendor}/assets/images/emoji/boy.png | Bin {app => vendor}/assets/images/emoji/bread.png | Bin .../assets/images/emoji/bride_with_veil.png | Bin .../assets/images/emoji/bridge_at_night.png | Bin {app => vendor}/assets/images/emoji/briefcase.png | Bin .../assets/images/emoji/broken_heart.png | Bin {app => vendor}/assets/images/emoji/bug.png | Bin {app => vendor}/assets/images/emoji/bulb.png | Bin .../assets/images/emoji/bullettrain_front.png | Bin .../assets/images/emoji/bullettrain_side.png | Bin {app => vendor}/assets/images/emoji/bus.png | Bin {app => vendor}/assets/images/emoji/busstop.png | Bin .../assets/images/emoji/bust_in_silhouette.png | Bin .../assets/images/emoji/busts_in_silhouette.png | Bin {app => vendor}/assets/images/emoji/cactus.png | Bin {app => vendor}/assets/images/emoji/cake.png | Bin {app => vendor}/assets/images/emoji/calendar.png | Bin {app => vendor}/assets/images/emoji/calling.png | Bin {app => vendor}/assets/images/emoji/camel.png | Bin {app => vendor}/assets/images/emoji/camera.png | Bin {app => vendor}/assets/images/emoji/cancer.png | Bin {app => vendor}/assets/images/emoji/candy.png | Bin .../assets/images/emoji/capital_abcd.png | Bin {app => vendor}/assets/images/emoji/capricorn.png | Bin {app => vendor}/assets/images/emoji/car.png | Bin {app => vendor}/assets/images/emoji/card_index.png | Bin .../assets/images/emoji/carousel_horse.png | Bin {app => vendor}/assets/images/emoji/cat.png | Bin {app => vendor}/assets/images/emoji/cat2.png | Bin {app => vendor}/assets/images/emoji/cd.png | Bin {app => vendor}/assets/images/emoji/chart.png | Bin .../images/emoji/chart_with_downwards_trend.png | Bin .../images/emoji/chart_with_upwards_trend.png | Bin .../assets/images/emoji/checkered_flag.png | Bin {app => vendor}/assets/images/emoji/cherries.png | Bin .../assets/images/emoji/cherry_blossom.png | Bin {app => vendor}/assets/images/emoji/chestnut.png | Bin {app => vendor}/assets/images/emoji/chicken.png | Bin .../assets/images/emoji/children_crossing.png | Bin .../assets/images/emoji/chocolate_bar.png | Bin .../assets/images/emoji/christmas_tree.png | Bin {app => vendor}/assets/images/emoji/church.png | Bin {app => vendor}/assets/images/emoji/cinema.png | Bin {app => vendor}/assets/images/emoji/circus_tent.png | Bin .../assets/images/emoji/city_sunrise.png | Bin {app => vendor}/assets/images/emoji/city_sunset.png | Bin {app => vendor}/assets/images/emoji/cl.png | Bin {app => vendor}/assets/images/emoji/clap.png | Bin {app => vendor}/assets/images/emoji/clapper.png | Bin {app => vendor}/assets/images/emoji/clipboard.png | Bin {app => vendor}/assets/images/emoji/clock1.png | Bin {app => vendor}/assets/images/emoji/clock10.png | Bin {app => vendor}/assets/images/emoji/clock1030.png | Bin {app => vendor}/assets/images/emoji/clock11.png | Bin {app => vendor}/assets/images/emoji/clock1130.png | Bin {app => vendor}/assets/images/emoji/clock12.png | Bin {app => vendor}/assets/images/emoji/clock1230.png | Bin {app => vendor}/assets/images/emoji/clock130.png | Bin {app => vendor}/assets/images/emoji/clock2.png | Bin {app => vendor}/assets/images/emoji/clock230.png | Bin {app => vendor}/assets/images/emoji/clock3.png | Bin {app => vendor}/assets/images/emoji/clock330.png | Bin {app => vendor}/assets/images/emoji/clock4.png | Bin {app => vendor}/assets/images/emoji/clock430.png | Bin {app => vendor}/assets/images/emoji/clock5.png | Bin {app => vendor}/assets/images/emoji/clock530.png | Bin {app => vendor}/assets/images/emoji/clock6.png | Bin {app => vendor}/assets/images/emoji/clock630.png | Bin {app => vendor}/assets/images/emoji/clock7.png | Bin {app => vendor}/assets/images/emoji/clock730.png | Bin {app => vendor}/assets/images/emoji/clock8.png | Bin {app => vendor}/assets/images/emoji/clock830.png | Bin {app => vendor}/assets/images/emoji/clock9.png | Bin {app => vendor}/assets/images/emoji/clock930.png | Bin {app => vendor}/assets/images/emoji/closed_book.png | Bin .../assets/images/emoji/closed_lock_with_key.png | Bin .../assets/images/emoji/closed_umbrella.png | Bin {app => vendor}/assets/images/emoji/cloud.png | Bin {app => vendor}/assets/images/emoji/clubs.png | Bin {app => vendor}/assets/images/emoji/cn.png | Bin {app => vendor}/assets/images/emoji/cocktail.png | Bin {app => vendor}/assets/images/emoji/coffee.png | Bin {app => vendor}/assets/images/emoji/cold_sweat.png | Bin {app => vendor}/assets/images/emoji/collision.png | Bin {app => vendor}/assets/images/emoji/computer.png | Bin .../assets/images/emoji/confetti_ball.png | Bin {app => vendor}/assets/images/emoji/confounded.png | Bin .../assets/images/emoji/congratulations.png | Bin .../assets/images/emoji/construction.png | Bin .../assets/images/emoji/construction_worker.png | Bin .../assets/images/emoji/convenience_store.png | Bin {app => vendor}/assets/images/emoji/cookie.png | Bin {app => vendor}/assets/images/emoji/cool.png | Bin {app => vendor}/assets/images/emoji/cop.png | Bin {app => vendor}/assets/images/emoji/copyright.png | Bin {app => vendor}/assets/images/emoji/corn.png | Bin {app => vendor}/assets/images/emoji/couple.png | Bin .../assets/images/emoji/couple_with_heart.png | Bin {app => vendor}/assets/images/emoji/couplekiss.png | Bin {app => vendor}/assets/images/emoji/cow.png | Bin {app => vendor}/assets/images/emoji/cow2.png | Bin {app => vendor}/assets/images/emoji/credit_card.png | Bin {app => vendor}/assets/images/emoji/crocodile.png | Bin .../assets/images/emoji/crossed_flags.png | Bin {app => vendor}/assets/images/emoji/crown.png | Bin {app => vendor}/assets/images/emoji/cry.png | Bin .../assets/images/emoji/crying_cat_face.png | Bin .../assets/images/emoji/crystal_ball.png | Bin {app => vendor}/assets/images/emoji/cupid.png | Bin {app => vendor}/assets/images/emoji/curly_loop.png | Bin .../assets/images/emoji/currency_exchange.png | Bin {app => vendor}/assets/images/emoji/curry.png | Bin {app => vendor}/assets/images/emoji/custard.png | Bin {app => vendor}/assets/images/emoji/customs.png | Bin {app => vendor}/assets/images/emoji/cyclone.png | Bin {app => vendor}/assets/images/emoji/dancer.png | Bin {app => vendor}/assets/images/emoji/dancers.png | Bin {app => vendor}/assets/images/emoji/dango.png | Bin {app => vendor}/assets/images/emoji/dart.png | Bin {app => vendor}/assets/images/emoji/dash.png | Bin {app => vendor}/assets/images/emoji/date.png | Bin {app => vendor}/assets/images/emoji/de.png | Bin .../assets/images/emoji/deciduous_tree.png | Bin .../assets/images/emoji/department_store.png | Bin .../emoji/diamond_shape_with_a_dot_inside.png | Bin {app => vendor}/assets/images/emoji/diamonds.png | Bin .../assets/images/emoji/disappointed.png | Bin {app => vendor}/assets/images/emoji/dizzy.png | Bin {app => vendor}/assets/images/emoji/dizzy_face.png | Bin .../assets/images/emoji/do_not_litter.png | Bin {app => vendor}/assets/images/emoji/dog.png | Bin {app => vendor}/assets/images/emoji/dog2.png | Bin {app => vendor}/assets/images/emoji/dollar.png | Bin {app => vendor}/assets/images/emoji/dolls.png | Bin {app => vendor}/assets/images/emoji/dolphin.png | Bin {app => vendor}/assets/images/emoji/door.png | Bin {app => vendor}/assets/images/emoji/doughnut.png | Bin {app => vendor}/assets/images/emoji/dragon.png | Bin {app => vendor}/assets/images/emoji/dragon_face.png | Bin {app => vendor}/assets/images/emoji/dress.png | Bin .../assets/images/emoji/dromedary_camel.png | Bin {app => vendor}/assets/images/emoji/droplet.png | Bin {app => vendor}/assets/images/emoji/dvd.png | Bin {app => vendor}/assets/images/emoji/e-mail.png | Bin {app => vendor}/assets/images/emoji/ear.png | Bin {app => vendor}/assets/images/emoji/ear_of_rice.png | Bin .../assets/images/emoji/earth_africa.png | Bin .../assets/images/emoji/earth_americas.png | Bin {app => vendor}/assets/images/emoji/earth_asia.png | Bin {app => vendor}/assets/images/emoji/egg.png | Bin {app => vendor}/assets/images/emoji/eggplant.png | Bin {app => vendor}/assets/images/emoji/eight.png | Bin .../images/emoji/eight_pointed_black_star.png | Bin .../assets/images/emoji/eight_spoked_asterisk.png | Bin .../assets/images/emoji/electric_plug.png | Bin {app => vendor}/assets/images/emoji/elephant.png | Bin {app => vendor}/assets/images/emoji/email.png | Bin {app => vendor}/assets/images/emoji/end.png | Bin {app => vendor}/assets/images/emoji/envelope.png | Bin {app => vendor}/assets/images/emoji/es.png | Bin {app => vendor}/assets/images/emoji/euro.png | Bin .../assets/images/emoji/european_castle.png | Bin .../assets/images/emoji/european_post_office.png | Bin .../assets/images/emoji/evergreen_tree.png | Bin {app => vendor}/assets/images/emoji/exclamation.png | Bin {app => vendor}/assets/images/emoji/eyeglasses.png | Bin {app => vendor}/assets/images/emoji/eyes.png | Bin {app => vendor}/assets/images/emoji/facepunch.png | Bin {app => vendor}/assets/images/emoji/factory.png | Bin {app => vendor}/assets/images/emoji/fallen_leaf.png | Bin {app => vendor}/assets/images/emoji/family.png | Bin .../assets/images/emoji/fast_forward.png | Bin {app => vendor}/assets/images/emoji/fax.png | Bin {app => vendor}/assets/images/emoji/fearful.png | Bin {app => vendor}/assets/images/emoji/feelsgood.png | Bin {app => vendor}/assets/images/emoji/feet.png | Bin .../assets/images/emoji/ferris_wheel.png | Bin {app => vendor}/assets/images/emoji/file_folder.png | Bin {app => vendor}/assets/images/emoji/finnadie.png | Bin {app => vendor}/assets/images/emoji/fire.png | Bin {app => vendor}/assets/images/emoji/fire_engine.png | Bin {app => vendor}/assets/images/emoji/fireworks.png | Bin .../assets/images/emoji/first_quarter_moon.png | Bin .../images/emoji/first_quarter_moon_with_face.png | Bin {app => vendor}/assets/images/emoji/fish.png | Bin {app => vendor}/assets/images/emoji/fish_cake.png | Bin .../assets/images/emoji/fishing_pole_and_fish.png | Bin {app => vendor}/assets/images/emoji/fist.png | Bin {app => vendor}/assets/images/emoji/five.png | Bin {app => vendor}/assets/images/emoji/flags.png | Bin {app => vendor}/assets/images/emoji/flashlight.png | Bin {app => vendor}/assets/images/emoji/floppy_disk.png | Bin .../assets/images/emoji/flower_playing_cards.png | Bin {app => vendor}/assets/images/emoji/flushed.png | Bin {app => vendor}/assets/images/emoji/foggy.png | Bin {app => vendor}/assets/images/emoji/football.png | Bin .../assets/images/emoji/fork_and_knife.png | Bin {app => vendor}/assets/images/emoji/fountain.png | Bin {app => vendor}/assets/images/emoji/four.png | Bin .../assets/images/emoji/four_leaf_clover.png | Bin {app => vendor}/assets/images/emoji/fr.png | Bin {app => vendor}/assets/images/emoji/free.png | Bin .../assets/images/emoji/fried_shrimp.png | Bin {app => vendor}/assets/images/emoji/fries.png | Bin {app => vendor}/assets/images/emoji/frog.png | Bin {app => vendor}/assets/images/emoji/fuelpump.png | Bin {app => vendor}/assets/images/emoji/full_moon.png | Bin .../assets/images/emoji/full_moon_with_face.png | Bin {app => vendor}/assets/images/emoji/game_die.png | Bin {app => vendor}/assets/images/emoji/gb.png | Bin {app => vendor}/assets/images/emoji/gem.png | Bin {app => vendor}/assets/images/emoji/gemini.png | Bin {app => vendor}/assets/images/emoji/ghost.png | Bin {app => vendor}/assets/images/emoji/gift.png | Bin {app => vendor}/assets/images/emoji/gift_heart.png | Bin {app => vendor}/assets/images/emoji/girl.png | Bin .../assets/images/emoji/globe_with_meridians.png | Bin {app => vendor}/assets/images/emoji/goat.png | Bin {app => vendor}/assets/images/emoji/goberserk.png | Bin {app => vendor}/assets/images/emoji/godmode.png | Bin {app => vendor}/assets/images/emoji/golf.png | Bin {app => vendor}/assets/images/emoji/grapes.png | Bin {app => vendor}/assets/images/emoji/green_apple.png | Bin {app => vendor}/assets/images/emoji/green_book.png | Bin {app => vendor}/assets/images/emoji/green_heart.png | Bin .../assets/images/emoji/grey_exclamation.png | Bin .../assets/images/emoji/grey_question.png | Bin {app => vendor}/assets/images/emoji/grin.png | Bin {app => vendor}/assets/images/emoji/guardsman.png | Bin {app => vendor}/assets/images/emoji/guitar.png | Bin {app => vendor}/assets/images/emoji/gun.png | Bin {app => vendor}/assets/images/emoji/haircut.png | Bin {app => vendor}/assets/images/emoji/hamburger.png | Bin {app => vendor}/assets/images/emoji/hammer.png | Bin {app => vendor}/assets/images/emoji/hamster.png | Bin {app => vendor}/assets/images/emoji/hand.png | Bin {app => vendor}/assets/images/emoji/handbag.png | Bin {app => vendor}/assets/images/emoji/hankey.png | Bin {app => vendor}/assets/images/emoji/hash.png | Bin .../assets/images/emoji/hatched_chick.png | Bin .../assets/images/emoji/hatching_chick.png | Bin {app => vendor}/assets/images/emoji/headphones.png | Bin .../assets/images/emoji/hear_no_evil.png | Bin {app => vendor}/assets/images/emoji/heart.png | Bin .../assets/images/emoji/heart_decoration.png | Bin {app => vendor}/assets/images/emoji/heart_eyes.png | Bin .../assets/images/emoji/heart_eyes_cat.png | Bin {app => vendor}/assets/images/emoji/heartbeat.png | Bin {app => vendor}/assets/images/emoji/heartpulse.png | Bin {app => vendor}/assets/images/emoji/hearts.png | Bin .../assets/images/emoji/heavy_check_mark.png | Bin .../assets/images/emoji/heavy_division_sign.png | Bin .../assets/images/emoji/heavy_dollar_sign.png | Bin .../assets/images/emoji/heavy_exclamation_mark.png | Bin .../assets/images/emoji/heavy_minus_sign.png | Bin .../assets/images/emoji/heavy_multiplication_x.png | Bin .../assets/images/emoji/heavy_plus_sign.png | Bin {app => vendor}/assets/images/emoji/helicopter.png | Bin {app => vendor}/assets/images/emoji/herb.png | Bin {app => vendor}/assets/images/emoji/hibiscus.png | Bin .../assets/images/emoji/high_brightness.png | Bin {app => vendor}/assets/images/emoji/high_heel.png | Bin {app => vendor}/assets/images/emoji/hocho.png | Bin {app => vendor}/assets/images/emoji/honey_pot.png | Bin {app => vendor}/assets/images/emoji/honeybee.png | Bin {app => vendor}/assets/images/emoji/horse.png | Bin .../assets/images/emoji/horse_racing.png | Bin {app => vendor}/assets/images/emoji/hospital.png | Bin {app => vendor}/assets/images/emoji/hotel.png | Bin {app => vendor}/assets/images/emoji/hotsprings.png | Bin {app => vendor}/assets/images/emoji/hourglass.png | Bin {app => vendor}/assets/images/emoji/house.png | Bin {app => vendor}/assets/images/emoji/hurtrealbad.png | Bin {app => vendor}/assets/images/emoji/ice_cream.png | Bin {app => vendor}/assets/images/emoji/icecream.png | Bin {app => vendor}/assets/images/emoji/id.png | Bin .../assets/images/emoji/ideograph_advantage.png | Bin {app => vendor}/assets/images/emoji/imp.png | Bin {app => vendor}/assets/images/emoji/inbox_tray.png | Bin .../assets/images/emoji/incoming_envelope.png | Bin .../assets/images/emoji/information_desk_person.png | Bin .../assets/images/emoji/information_source.png | Bin {app => vendor}/assets/images/emoji/innocent.png | Bin {app => vendor}/assets/images/emoji/interrobang.png | Bin {app => vendor}/assets/images/emoji/iphone.png | Bin {app => vendor}/assets/images/emoji/it.png | Bin .../assets/images/emoji/izakaya_lantern.png | Bin .../assets/images/emoji/jack_o_lantern.png | Bin {app => vendor}/assets/images/emoji/japan.png | Bin .../assets/images/emoji/japanese_castle.png | Bin .../assets/images/emoji/japanese_goblin.png | Bin .../assets/images/emoji/japanese_ogre.png | Bin {app => vendor}/assets/images/emoji/jeans.png | Bin {app => vendor}/assets/images/emoji/joy.png | Bin {app => vendor}/assets/images/emoji/joy_cat.png | Bin {app => vendor}/assets/images/emoji/jp.png | Bin {app => vendor}/assets/images/emoji/key.png | Bin {app => vendor}/assets/images/emoji/keycap_ten.png | Bin {app => vendor}/assets/images/emoji/kimono.png | Bin {app => vendor}/assets/images/emoji/kiss.png | Bin {app => vendor}/assets/images/emoji/kissing_cat.png | Bin .../assets/images/emoji/kissing_face.png | Bin .../assets/images/emoji/kissing_heart.png | Bin {app => vendor}/assets/images/emoji/koala.png | Bin {app => vendor}/assets/images/emoji/koko.png | Bin {app => vendor}/assets/images/emoji/kr.png | Bin .../assets/images/emoji/large_blue_circle.png | Bin .../assets/images/emoji/large_blue_diamond.png | Bin .../assets/images/emoji/large_orange_diamond.png | Bin .../assets/images/emoji/last_quarter_moon.png | Bin .../images/emoji/last_quarter_moon_with_face.png | Bin {app => vendor}/assets/images/emoji/laughing.png | Bin {app => vendor}/assets/images/emoji/leaves.png | Bin {app => vendor}/assets/images/emoji/ledger.png | Bin .../assets/images/emoji/left_luggage.png | Bin .../assets/images/emoji/left_right_arrow.png | Bin .../images/emoji/leftwards_arrow_with_hook.png | Bin {app => vendor}/assets/images/emoji/lemon.png | Bin {app => vendor}/assets/images/emoji/leo.png | Bin {app => vendor}/assets/images/emoji/leopard.png | Bin {app => vendor}/assets/images/emoji/libra.png | Bin {app => vendor}/assets/images/emoji/light_rail.png | Bin {app => vendor}/assets/images/emoji/link.png | Bin {app => vendor}/assets/images/emoji/lips.png | Bin {app => vendor}/assets/images/emoji/lipstick.png | Bin {app => vendor}/assets/images/emoji/lock.png | Bin .../assets/images/emoji/lock_with_ink_pen.png | Bin {app => vendor}/assets/images/emoji/lollipop.png | Bin {app => vendor}/assets/images/emoji/loop.png | Bin {app => vendor}/assets/images/emoji/loudspeaker.png | Bin {app => vendor}/assets/images/emoji/love_hotel.png | Bin {app => vendor}/assets/images/emoji/love_letter.png | Bin .../assets/images/emoji/low_brightness.png | Bin {app => vendor}/assets/images/emoji/m.png | Bin {app => vendor}/assets/images/emoji/mag.png | Bin {app => vendor}/assets/images/emoji/mag_right.png | Bin {app => vendor}/assets/images/emoji/mahjong.png | Bin {app => vendor}/assets/images/emoji/mailbox.png | Bin .../assets/images/emoji/mailbox_closed.png | Bin .../assets/images/emoji/mailbox_with_mail.png | Bin .../assets/images/emoji/mailbox_with_no_mail.png | Bin {app => vendor}/assets/images/emoji/man.png | Bin .../assets/images/emoji/man_with_gua_pi_mao.png | Bin .../assets/images/emoji/man_with_turban.png | Bin {app => vendor}/assets/images/emoji/mans_shoe.png | Bin {app => vendor}/assets/images/emoji/maple_leaf.png | Bin {app => vendor}/assets/images/emoji/mask.png | Bin {app => vendor}/assets/images/emoji/massage.png | Bin .../assets/images/emoji/meat_on_bone.png | Bin {app => vendor}/assets/images/emoji/mega.png | Bin {app => vendor}/assets/images/emoji/melon.png | Bin {app => vendor}/assets/images/emoji/memo.png | Bin {app => vendor}/assets/images/emoji/mens.png | Bin {app => vendor}/assets/images/emoji/metal.png | Bin {app => vendor}/assets/images/emoji/metro.png | Bin {app => vendor}/assets/images/emoji/microphone.png | Bin {app => vendor}/assets/images/emoji/microscope.png | Bin {app => vendor}/assets/images/emoji/milky_way.png | Bin {app => vendor}/assets/images/emoji/minibus.png | Bin {app => vendor}/assets/images/emoji/minidisc.png | Bin .../assets/images/emoji/mobile_phone_off.png | Bin .../assets/images/emoji/money_with_wings.png | Bin {app => vendor}/assets/images/emoji/moneybag.png | Bin {app => vendor}/assets/images/emoji/monkey.png | Bin {app => vendor}/assets/images/emoji/monkey_face.png | Bin {app => vendor}/assets/images/emoji/monorail.png | Bin {app => vendor}/assets/images/emoji/moon.png | Bin .../assets/images/emoji/mortar_board.png | Bin {app => vendor}/assets/images/emoji/mount_fuji.png | Bin .../assets/images/emoji/mountain_bicyclist.png | Bin .../assets/images/emoji/mountain_cableway.png | Bin .../assets/images/emoji/mountain_railway.png | Bin {app => vendor}/assets/images/emoji/mouse.png | Bin {app => vendor}/assets/images/emoji/mouse2.png | Bin .../assets/images/emoji/movie_camera.png | Bin {app => vendor}/assets/images/emoji/moyai.png | Bin {app => vendor}/assets/images/emoji/muscle.png | Bin {app => vendor}/assets/images/emoji/mushroom.png | Bin .../assets/images/emoji/musical_keyboard.png | Bin .../assets/images/emoji/musical_note.png | Bin .../assets/images/emoji/musical_score.png | Bin {app => vendor}/assets/images/emoji/mute.png | Bin {app => vendor}/assets/images/emoji/nail_care.png | Bin {app => vendor}/assets/images/emoji/name_badge.png | Bin {app => vendor}/assets/images/emoji/neckbeard.png | Bin {app => vendor}/assets/images/emoji/necktie.png | Bin .../images/emoji/negative_squared_cross_mark.png | Bin .../assets/images/emoji/neutral_face.png | Bin {app => vendor}/assets/images/emoji/new.png | Bin {app => vendor}/assets/images/emoji/new_moon.png | Bin .../assets/images/emoji/new_moon_with_face.png | Bin {app => vendor}/assets/images/emoji/newspaper.png | Bin {app => vendor}/assets/images/emoji/ng.png | Bin {app => vendor}/assets/images/emoji/nine.png | Bin {app => vendor}/assets/images/emoji/no_bell.png | Bin {app => vendor}/assets/images/emoji/no_bicycles.png | Bin {app => vendor}/assets/images/emoji/no_entry.png | Bin .../assets/images/emoji/no_entry_sign.png | Bin {app => vendor}/assets/images/emoji/no_good.png | Bin .../assets/images/emoji/no_mobile_phones.png | Bin {app => vendor}/assets/images/emoji/no_mouth.png | Bin .../assets/images/emoji/no_pedestrians.png | Bin {app => vendor}/assets/images/emoji/no_smoking.png | Bin .../assets/images/emoji/non-potable_water.png | Bin {app => vendor}/assets/images/emoji/nose.png | Bin {app => vendor}/assets/images/emoji/notebook.png | Bin .../images/emoji/notebook_with_decorative_cover.png | Bin {app => vendor}/assets/images/emoji/notes.png | Bin .../assets/images/emoji/nut_and_bolt.png | Bin {app => vendor}/assets/images/emoji/o.png | Bin {app => vendor}/assets/images/emoji/o2.png | Bin {app => vendor}/assets/images/emoji/ocean.png | Bin {app => vendor}/assets/images/emoji/octocat.png | Bin {app => vendor}/assets/images/emoji/octopus.png | Bin {app => vendor}/assets/images/emoji/oden.png | Bin {app => vendor}/assets/images/emoji/office.png | Bin {app => vendor}/assets/images/emoji/ok.png | Bin {app => vendor}/assets/images/emoji/ok_hand.png | Bin {app => vendor}/assets/images/emoji/ok_woman.png | Bin {app => vendor}/assets/images/emoji/older_man.png | Bin {app => vendor}/assets/images/emoji/older_woman.png | Bin {app => vendor}/assets/images/emoji/on.png | Bin .../assets/images/emoji/oncoming_automobile.png | Bin .../assets/images/emoji/oncoming_bus.png | Bin .../assets/images/emoji/oncoming_police_car.png | Bin .../assets/images/emoji/oncoming_taxi.png | Bin {app => vendor}/assets/images/emoji/one.png | Bin .../assets/images/emoji/open_file_folder.png | Bin {app => vendor}/assets/images/emoji/open_hands.png | Bin {app => vendor}/assets/images/emoji/ophiuchus.png | Bin {app => vendor}/assets/images/emoji/orange_book.png | Bin {app => vendor}/assets/images/emoji/outbox_tray.png | Bin {app => vendor}/assets/images/emoji/ox.png | Bin .../assets/images/emoji/page_facing_up.png | Bin .../assets/images/emoji/page_with_curl.png | Bin {app => vendor}/assets/images/emoji/pager.png | Bin {app => vendor}/assets/images/emoji/palm_tree.png | Bin {app => vendor}/assets/images/emoji/panda_face.png | Bin {app => vendor}/assets/images/emoji/paperclip.png | Bin {app => vendor}/assets/images/emoji/parking.png | Bin .../assets/images/emoji/part_alternation_mark.png | Bin .../assets/images/emoji/partly_sunny.png | Bin .../assets/images/emoji/passport_control.png | Bin {app => vendor}/assets/images/emoji/paw_prints.png | Bin {app => vendor}/assets/images/emoji/peach.png | Bin {app => vendor}/assets/images/emoji/pear.png | Bin {app => vendor}/assets/images/emoji/pencil.png | Bin {app => vendor}/assets/images/emoji/pencil2.png | Bin {app => vendor}/assets/images/emoji/penguin.png | Bin {app => vendor}/assets/images/emoji/pensive.png | Bin .../assets/images/emoji/performing_arts.png | Bin {app => vendor}/assets/images/emoji/persevere.png | Bin .../assets/images/emoji/person_frowning.png | Bin .../assets/images/emoji/person_with_blond_hair.png | Bin .../images/emoji/person_with_pouting_face.png | Bin {app => vendor}/assets/images/emoji/phone.png | Bin {app => vendor}/assets/images/emoji/pig.png | Bin {app => vendor}/assets/images/emoji/pig2.png | Bin {app => vendor}/assets/images/emoji/pig_nose.png | Bin {app => vendor}/assets/images/emoji/pill.png | Bin {app => vendor}/assets/images/emoji/pineapple.png | Bin {app => vendor}/assets/images/emoji/pisces.png | Bin {app => vendor}/assets/images/emoji/pizza.png | Bin {app => vendor}/assets/images/emoji/plus1.png | Bin {app => vendor}/assets/images/emoji/point_down.png | Bin {app => vendor}/assets/images/emoji/point_left.png | Bin {app => vendor}/assets/images/emoji/point_right.png | Bin {app => vendor}/assets/images/emoji/point_up.png | Bin {app => vendor}/assets/images/emoji/point_up_2.png | Bin {app => vendor}/assets/images/emoji/police_car.png | Bin {app => vendor}/assets/images/emoji/poodle.png | Bin {app => vendor}/assets/images/emoji/poop.png | Bin {app => vendor}/assets/images/emoji/post_office.png | Bin {app => vendor}/assets/images/emoji/postal_horn.png | Bin {app => vendor}/assets/images/emoji/postbox.png | Bin .../assets/images/emoji/potable_water.png | Bin {app => vendor}/assets/images/emoji/pouch.png | Bin {app => vendor}/assets/images/emoji/poultry_leg.png | Bin {app => vendor}/assets/images/emoji/pound.png | Bin {app => vendor}/assets/images/emoji/pouting_cat.png | Bin {app => vendor}/assets/images/emoji/pray.png | Bin {app => vendor}/assets/images/emoji/princess.png | Bin {app => vendor}/assets/images/emoji/punch.png | Bin .../assets/images/emoji/purple_heart.png | Bin {app => vendor}/assets/images/emoji/purse.png | Bin {app => vendor}/assets/images/emoji/pushpin.png | Bin .../assets/images/emoji/put_litter_in_its_place.png | Bin {app => vendor}/assets/images/emoji/question.png | Bin {app => vendor}/assets/images/emoji/rabbit.png | Bin {app => vendor}/assets/images/emoji/rabbit2.png | Bin {app => vendor}/assets/images/emoji/racehorse.png | Bin {app => vendor}/assets/images/emoji/radio.png | Bin .../assets/images/emoji/radio_button.png | Bin {app => vendor}/assets/images/emoji/rage.png | Bin {app => vendor}/assets/images/emoji/rage1.png | Bin {app => vendor}/assets/images/emoji/rage2.png | Bin {app => vendor}/assets/images/emoji/rage3.png | Bin {app => vendor}/assets/images/emoji/rage4.png | Bin {app => vendor}/assets/images/emoji/railway_car.png | Bin {app => vendor}/assets/images/emoji/rainbow.png | Bin {app => vendor}/assets/images/emoji/raised_hand.png | Bin .../assets/images/emoji/raised_hands.png | Bin {app => vendor}/assets/images/emoji/ram.png | Bin {app => vendor}/assets/images/emoji/ramen.png | Bin {app => vendor}/assets/images/emoji/rat.png | Bin {app => vendor}/assets/images/emoji/recycle.png | Bin {app => vendor}/assets/images/emoji/red_car.png | Bin {app => vendor}/assets/images/emoji/red_circle.png | Bin {app => vendor}/assets/images/emoji/registered.png | Bin {app => vendor}/assets/images/emoji/relaxed.png | Bin {app => vendor}/assets/images/emoji/relieved.png | Bin {app => vendor}/assets/images/emoji/repeat.png | Bin {app => vendor}/assets/images/emoji/repeat_one.png | Bin {app => vendor}/assets/images/emoji/restroom.png | Bin .../assets/images/emoji/revolving_hearts.png | Bin {app => vendor}/assets/images/emoji/rewind.png | Bin {app => vendor}/assets/images/emoji/ribbon.png | Bin {app => vendor}/assets/images/emoji/rice.png | Bin {app => vendor}/assets/images/emoji/rice_ball.png | Bin .../assets/images/emoji/rice_cracker.png | Bin {app => vendor}/assets/images/emoji/rice_scene.png | Bin {app => vendor}/assets/images/emoji/ring.png | Bin {app => vendor}/assets/images/emoji/rocket.png | Bin .../assets/images/emoji/roller_coaster.png | Bin {app => vendor}/assets/images/emoji/rooster.png | Bin {app => vendor}/assets/images/emoji/rose.png | Bin .../assets/images/emoji/rotating_light.png | Bin .../assets/images/emoji/round_pushpin.png | Bin {app => vendor}/assets/images/emoji/rowboat.png | Bin {app => vendor}/assets/images/emoji/ru.png | Bin .../assets/images/emoji/rugby_football.png | Bin {app => vendor}/assets/images/emoji/runner.png | Bin {app => vendor}/assets/images/emoji/running.png | Bin .../assets/images/emoji/running_shirt_with_sash.png | Bin {app => vendor}/assets/images/emoji/sa.png | Bin {app => vendor}/assets/images/emoji/sagittarius.png | Bin {app => vendor}/assets/images/emoji/sailboat.png | Bin {app => vendor}/assets/images/emoji/sake.png | Bin {app => vendor}/assets/images/emoji/sandal.png | Bin {app => vendor}/assets/images/emoji/santa.png | Bin {app => vendor}/assets/images/emoji/satellite.png | Bin {app => vendor}/assets/images/emoji/satisfied.png | Bin {app => vendor}/assets/images/emoji/saxophone.png | Bin {app => vendor}/assets/images/emoji/school.png | Bin .../assets/images/emoji/school_satchel.png | Bin {app => vendor}/assets/images/emoji/scissors.png | Bin {app => vendor}/assets/images/emoji/scorpius.png | Bin {app => vendor}/assets/images/emoji/scream.png | Bin {app => vendor}/assets/images/emoji/scream_cat.png | Bin {app => vendor}/assets/images/emoji/scroll.png | Bin {app => vendor}/assets/images/emoji/seat.png | Bin {app => vendor}/assets/images/emoji/secret.png | Bin {app => vendor}/assets/images/emoji/see_no_evil.png | Bin {app => vendor}/assets/images/emoji/seedling.png | Bin {app => vendor}/assets/images/emoji/seven.png | Bin {app => vendor}/assets/images/emoji/shaved_ice.png | Bin {app => vendor}/assets/images/emoji/sheep.png | Bin {app => vendor}/assets/images/emoji/shell.png | Bin {app => vendor}/assets/images/emoji/ship.png | Bin {app => vendor}/assets/images/emoji/shipit.png | Bin {app => vendor}/assets/images/emoji/shirt.png | Bin {app => vendor}/assets/images/emoji/shit.png | Bin {app => vendor}/assets/images/emoji/shoe.png | Bin {app => vendor}/assets/images/emoji/shower.png | Bin .../assets/images/emoji/signal_strength.png | Bin {app => vendor}/assets/images/emoji/six.png | Bin .../assets/images/emoji/six_pointed_star.png | Bin {app => vendor}/assets/images/emoji/ski.png | Bin {app => vendor}/assets/images/emoji/skull.png | Bin {app => vendor}/assets/images/emoji/sleepy.png | Bin .../assets/images/emoji/slot_machine.png | Bin .../assets/images/emoji/small_blue_diamond.png | Bin .../assets/images/emoji/small_orange_diamond.png | Bin .../assets/images/emoji/small_red_triangle.png | Bin .../assets/images/emoji/small_red_triangle_down.png | Bin {app => vendor}/assets/images/emoji/smile.png | Bin {app => vendor}/assets/images/emoji/smile_cat.png | Bin {app => vendor}/assets/images/emoji/smiley.png | Bin {app => vendor}/assets/images/emoji/smiley_cat.png | Bin {app => vendor}/assets/images/emoji/smiling_imp.png | Bin {app => vendor}/assets/images/emoji/smirk.png | Bin {app => vendor}/assets/images/emoji/smirk_cat.png | Bin {app => vendor}/assets/images/emoji/smoking.png | Bin {app => vendor}/assets/images/emoji/snail.png | Bin {app => vendor}/assets/images/emoji/snake.png | Bin {app => vendor}/assets/images/emoji/snowboarder.png | Bin {app => vendor}/assets/images/emoji/snowflake.png | Bin {app => vendor}/assets/images/emoji/snowman.png | Bin {app => vendor}/assets/images/emoji/sob.png | Bin {app => vendor}/assets/images/emoji/soccer.png | Bin {app => vendor}/assets/images/emoji/soon.png | Bin {app => vendor}/assets/images/emoji/sos.png | Bin {app => vendor}/assets/images/emoji/sound.png | Bin .../assets/images/emoji/space_invader.png | Bin {app => vendor}/assets/images/emoji/spades.png | Bin {app => vendor}/assets/images/emoji/spaghetti.png | Bin {app => vendor}/assets/images/emoji/sparkler.png | Bin {app => vendor}/assets/images/emoji/sparkles.png | Bin .../assets/images/emoji/speak_no_evil.png | Bin {app => vendor}/assets/images/emoji/speaker.png | Bin .../assets/images/emoji/speech_balloon.png | Bin {app => vendor}/assets/images/emoji/speedboat.png | Bin {app => vendor}/assets/images/emoji/squirrel.png | Bin {app => vendor}/assets/images/emoji/star.png | Bin {app => vendor}/assets/images/emoji/star2.png | Bin {app => vendor}/assets/images/emoji/stars.png | Bin {app => vendor}/assets/images/emoji/station.png | Bin .../assets/images/emoji/statue_of_liberty.png | Bin .../assets/images/emoji/steam_locomotive.png | Bin {app => vendor}/assets/images/emoji/stew.png | Bin .../assets/images/emoji/straight_ruler.png | Bin {app => vendor}/assets/images/emoji/strawberry.png | Bin .../assets/images/emoji/sun_with_face.png | Bin {app => vendor}/assets/images/emoji/sunflower.png | Bin {app => vendor}/assets/images/emoji/sunglasses.png | Bin {app => vendor}/assets/images/emoji/sunny.png | Bin {app => vendor}/assets/images/emoji/sunrise.png | Bin .../assets/images/emoji/sunrise_over_mountains.png | Bin {app => vendor}/assets/images/emoji/surfer.png | Bin {app => vendor}/assets/images/emoji/sushi.png | Bin {app => vendor}/assets/images/emoji/suspect.png | Bin .../assets/images/emoji/suspension_railway.png | Bin {app => vendor}/assets/images/emoji/sweat.png | Bin {app => vendor}/assets/images/emoji/sweat_drops.png | Bin {app => vendor}/assets/images/emoji/sweat_smile.png | Bin .../assets/images/emoji/sweet_potato.png | Bin {app => vendor}/assets/images/emoji/swimmer.png | Bin {app => vendor}/assets/images/emoji/symbols.png | Bin {app => vendor}/assets/images/emoji/syringe.png | Bin {app => vendor}/assets/images/emoji/tada.png | Bin .../assets/images/emoji/tanabata_tree.png | Bin {app => vendor}/assets/images/emoji/tangerine.png | Bin {app => vendor}/assets/images/emoji/taurus.png | Bin {app => vendor}/assets/images/emoji/taxi.png | Bin {app => vendor}/assets/images/emoji/tea.png | Bin {app => vendor}/assets/images/emoji/telephone.png | Bin .../assets/images/emoji/telephone_receiver.png | Bin {app => vendor}/assets/images/emoji/telescope.png | Bin {app => vendor}/assets/images/emoji/tennis.png | Bin {app => vendor}/assets/images/emoji/tent.png | Bin .../assets/images/emoji/thought_balloon.png | Bin {app => vendor}/assets/images/emoji/three.png | Bin {app => vendor}/assets/images/emoji/thumbsdown.png | Bin {app => vendor}/assets/images/emoji/thumbsup.png | Bin {app => vendor}/assets/images/emoji/ticket.png | Bin {app => vendor}/assets/images/emoji/tiger.png | Bin {app => vendor}/assets/images/emoji/tiger2.png | Bin {app => vendor}/assets/images/emoji/tired_face.png | Bin {app => vendor}/assets/images/emoji/tm.png | Bin {app => vendor}/assets/images/emoji/toilet.png | Bin {app => vendor}/assets/images/emoji/tokyo_tower.png | Bin {app => vendor}/assets/images/emoji/tomato.png | Bin {app => vendor}/assets/images/emoji/tongue.png | Bin {app => vendor}/assets/images/emoji/tongue2.png | Bin {app => vendor}/assets/images/emoji/top.png | Bin {app => vendor}/assets/images/emoji/tophat.png | Bin {app => vendor}/assets/images/emoji/tractor.png | Bin .../assets/images/emoji/traffic_light.png | Bin {app => vendor}/assets/images/emoji/train.png | Bin {app => vendor}/assets/images/emoji/train2.png | Bin {app => vendor}/assets/images/emoji/tram.png | Bin .../assets/images/emoji/triangular_flag_on_post.png | Bin .../assets/images/emoji/triangular_ruler.png | Bin {app => vendor}/assets/images/emoji/trident.png | Bin {app => vendor}/assets/images/emoji/triumph.png | Bin {app => vendor}/assets/images/emoji/trolleybus.png | Bin {app => vendor}/assets/images/emoji/trollface.png | Bin {app => vendor}/assets/images/emoji/trophy.png | Bin .../assets/images/emoji/tropical_drink.png | Bin .../assets/images/emoji/tropical_fish.png | Bin {app => vendor}/assets/images/emoji/truck.png | Bin {app => vendor}/assets/images/emoji/trumpet.png | Bin {app => vendor}/assets/images/emoji/tshirt.png | Bin {app => vendor}/assets/images/emoji/tulip.png | Bin {app => vendor}/assets/images/emoji/turtle.png | Bin {app => vendor}/assets/images/emoji/tv.png | Bin .../images/emoji/twisted_rightwards_arrows.png | Bin {app => vendor}/assets/images/emoji/two.png | Bin {app => vendor}/assets/images/emoji/two_hearts.png | Bin .../assets/images/emoji/two_men_holding_hands.png | Bin .../assets/images/emoji/two_women_holding_hands.png | Bin {app => vendor}/assets/images/emoji/u5272.png | Bin {app => vendor}/assets/images/emoji/u5408.png | Bin {app => vendor}/assets/images/emoji/u55b6.png | Bin {app => vendor}/assets/images/emoji/u6307.png | Bin {app => vendor}/assets/images/emoji/u6708.png | Bin {app => vendor}/assets/images/emoji/u6709.png | Bin {app => vendor}/assets/images/emoji/u6e80.png | Bin {app => vendor}/assets/images/emoji/u7121.png | Bin {app => vendor}/assets/images/emoji/u7533.png | Bin {app => vendor}/assets/images/emoji/u7981.png | Bin {app => vendor}/assets/images/emoji/u7a7a.png | Bin {app => vendor}/assets/images/emoji/uk.png | Bin {app => vendor}/assets/images/emoji/umbrella.png | Bin {app => vendor}/assets/images/emoji/unamused.png | Bin {app => vendor}/assets/images/emoji/underage.png | Bin {app => vendor}/assets/images/emoji/unlock.png | Bin {app => vendor}/assets/images/emoji/up.png | Bin {app => vendor}/assets/images/emoji/us.png | Bin {app => vendor}/assets/images/emoji/v.png | Bin .../assets/images/emoji/vertical_traffic_light.png | Bin {app => vendor}/assets/images/emoji/vhs.png | Bin .../assets/images/emoji/vibration_mode.png | Bin .../assets/images/emoji/video_camera.png | Bin {app => vendor}/assets/images/emoji/video_game.png | Bin {app => vendor}/assets/images/emoji/violin.png | Bin {app => vendor}/assets/images/emoji/virgo.png | Bin {app => vendor}/assets/images/emoji/volcano.png | Bin {app => vendor}/assets/images/emoji/vs.png | Bin {app => vendor}/assets/images/emoji/walking.png | Bin .../assets/images/emoji/waning_crescent_moon.png | Bin .../assets/images/emoji/waning_gibbous_moon.png | Bin {app => vendor}/assets/images/emoji/warning.png | Bin {app => vendor}/assets/images/emoji/watch.png | Bin .../assets/images/emoji/water_buffalo.png | Bin {app => vendor}/assets/images/emoji/watermelon.png | Bin {app => vendor}/assets/images/emoji/wave.png | Bin {app => vendor}/assets/images/emoji/wavy_dash.png | Bin .../assets/images/emoji/waxing_crescent_moon.png | Bin .../assets/images/emoji/waxing_gibbous_moon.png | Bin {app => vendor}/assets/images/emoji/wc.png | Bin {app => vendor}/assets/images/emoji/weary.png | Bin {app => vendor}/assets/images/emoji/wedding.png | Bin {app => vendor}/assets/images/emoji/whale.png | Bin {app => vendor}/assets/images/emoji/whale2.png | Bin {app => vendor}/assets/images/emoji/wheelchair.png | Bin .../assets/images/emoji/white_circle.png | Bin .../assets/images/emoji/white_flower.png | Bin .../assets/images/emoji/white_square.png | Bin {app => vendor}/assets/images/emoji/wind_chime.png | Bin {app => vendor}/assets/images/emoji/wine_glass.png | Bin {app => vendor}/assets/images/emoji/wink.png | Bin {app => vendor}/assets/images/emoji/wink2.png | Bin {app => vendor}/assets/images/emoji/wolf.png | Bin {app => vendor}/assets/images/emoji/woman.png | Bin .../assets/images/emoji/womans_clothes.png | Bin {app => vendor}/assets/images/emoji/womans_hat.png | Bin {app => vendor}/assets/images/emoji/womens.png | Bin {app => vendor}/assets/images/emoji/wrench.png | Bin {app => vendor}/assets/images/emoji/x.png | Bin .../assets/images/emoji/yellow_heart.png | Bin {app => vendor}/assets/images/emoji/yen.png | Bin {app => vendor}/assets/images/emoji/yum.png | Bin {app => vendor}/assets/images/emoji/zap.png | Bin {app => vendor}/assets/images/emoji/zero.png | Bin {app => vendor}/assets/images/emoji/zzz.png | Bin 849 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 config/initializers/emoji.rb rename {app => vendor}/assets/images/emoji/+1.png (100%) rename {app => vendor}/assets/images/emoji/-1.png (100%) rename {app => vendor}/assets/images/emoji/100.png (100%) rename {app => vendor}/assets/images/emoji/109.png (100%) rename {app => vendor}/assets/images/emoji/1234.png (100%) rename {app => vendor}/assets/images/emoji/8ball.png (100%) rename {app => vendor}/assets/images/emoji/a.png (100%) rename {app => vendor}/assets/images/emoji/ab.png (100%) rename {app => vendor}/assets/images/emoji/abc.png (100%) rename {app => vendor}/assets/images/emoji/abcd.png (100%) rename {app => vendor}/assets/images/emoji/accept.png (100%) rename {app => vendor}/assets/images/emoji/aerial_tramway.png (100%) rename {app => vendor}/assets/images/emoji/airplane.png (100%) rename {app => vendor}/assets/images/emoji/alarm_clock.png (100%) rename {app => vendor}/assets/images/emoji/alien.png (100%) rename {app => vendor}/assets/images/emoji/ambulance.png (100%) rename {app => vendor}/assets/images/emoji/anchor.png (100%) rename {app => vendor}/assets/images/emoji/angel.png (100%) rename {app => vendor}/assets/images/emoji/anger.png (100%) rename {app => vendor}/assets/images/emoji/angry.png (100%) rename {app => vendor}/assets/images/emoji/ant.png (100%) rename {app => vendor}/assets/images/emoji/apple.png (100%) rename {app => vendor}/assets/images/emoji/aquarius.png (100%) rename {app => vendor}/assets/images/emoji/aries.png (100%) rename {app => vendor}/assets/images/emoji/arrow_backward.png (100%) rename {app => vendor}/assets/images/emoji/arrow_double_down.png (100%) rename {app => vendor}/assets/images/emoji/arrow_double_up.png (100%) rename {app => vendor}/assets/images/emoji/arrow_down.png (100%) rename {app => vendor}/assets/images/emoji/arrow_down_small.png (100%) rename {app => vendor}/assets/images/emoji/arrow_forward.png (100%) rename {app => vendor}/assets/images/emoji/arrow_heading_down.png (100%) rename {app => vendor}/assets/images/emoji/arrow_heading_up.png (100%) rename {app => vendor}/assets/images/emoji/arrow_left.png (100%) rename {app => vendor}/assets/images/emoji/arrow_lower_left.png (100%) rename {app => vendor}/assets/images/emoji/arrow_lower_right.png (100%) rename {app => vendor}/assets/images/emoji/arrow_right.png (100%) rename {app => vendor}/assets/images/emoji/arrow_right_hook.png (100%) rename {app => vendor}/assets/images/emoji/arrow_up.png (100%) rename {app => vendor}/assets/images/emoji/arrow_up_down.png (100%) rename {app => vendor}/assets/images/emoji/arrow_up_small.png (100%) rename {app => vendor}/assets/images/emoji/arrow_upper_left.png (100%) rename {app => vendor}/assets/images/emoji/arrow_upper_right.png (100%) rename {app => vendor}/assets/images/emoji/arrows_clockwise.png (100%) rename {app => vendor}/assets/images/emoji/arrows_counterclockwise.png (100%) rename {app => vendor}/assets/images/emoji/art.png (100%) rename {app => vendor}/assets/images/emoji/articulated_lorry.png (100%) rename {app => vendor}/assets/images/emoji/astonished.png (100%) rename {app => vendor}/assets/images/emoji/atm.png (100%) rename {app => vendor}/assets/images/emoji/b.png (100%) rename {app => vendor}/assets/images/emoji/baby.png (100%) rename {app => vendor}/assets/images/emoji/baby_bottle.png (100%) rename {app => vendor}/assets/images/emoji/baby_chick.png (100%) rename {app => vendor}/assets/images/emoji/baby_symbol.png (100%) rename {app => vendor}/assets/images/emoji/baggage_claim.png (100%) rename {app => vendor}/assets/images/emoji/balloon.png (100%) rename {app => vendor}/assets/images/emoji/ballot_box_with_check.png (100%) rename {app => vendor}/assets/images/emoji/bamboo.png (100%) rename {app => vendor}/assets/images/emoji/banana.png (100%) rename {app => vendor}/assets/images/emoji/bangbang.png (100%) rename {app => vendor}/assets/images/emoji/bank.png (100%) rename {app => vendor}/assets/images/emoji/bar_chart.png (100%) rename {app => vendor}/assets/images/emoji/barber.png (100%) rename {app => vendor}/assets/images/emoji/baseball.png (100%) rename {app => vendor}/assets/images/emoji/basketball.png (100%) rename {app => vendor}/assets/images/emoji/bath.png (100%) rename {app => vendor}/assets/images/emoji/bathtub.png (100%) rename {app => vendor}/assets/images/emoji/battery.png (100%) rename {app => vendor}/assets/images/emoji/bear.png (100%) rename {app => vendor}/assets/images/emoji/beer.png (100%) rename {app => vendor}/assets/images/emoji/beers.png (100%) rename {app => vendor}/assets/images/emoji/beetle.png (100%) rename {app => vendor}/assets/images/emoji/beginner.png (100%) rename {app => vendor}/assets/images/emoji/bell.png (100%) rename {app => vendor}/assets/images/emoji/bento.png (100%) rename {app => vendor}/assets/images/emoji/bicyclist.png (100%) rename {app => vendor}/assets/images/emoji/bike.png (100%) rename {app => vendor}/assets/images/emoji/bikini.png (100%) rename {app => vendor}/assets/images/emoji/bird.png (100%) rename {app => vendor}/assets/images/emoji/birthday.png (100%) rename {app => vendor}/assets/images/emoji/black_circle.png (100%) rename {app => vendor}/assets/images/emoji/black_joker.png (100%) rename {app => vendor}/assets/images/emoji/black_nib.png (100%) rename {app => vendor}/assets/images/emoji/black_square.png (100%) rename {app => vendor}/assets/images/emoji/blossom.png (100%) rename {app => vendor}/assets/images/emoji/blowfish.png (100%) rename {app => vendor}/assets/images/emoji/blue_book.png (100%) rename {app => vendor}/assets/images/emoji/blue_car.png (100%) rename {app => vendor}/assets/images/emoji/blue_heart.png (100%) rename {app => vendor}/assets/images/emoji/blush.png (100%) rename {app => vendor}/assets/images/emoji/boar.png (100%) rename {app => vendor}/assets/images/emoji/boat.png (100%) rename {app => vendor}/assets/images/emoji/bomb.png (100%) rename {app => vendor}/assets/images/emoji/book.png (100%) rename {app => vendor}/assets/images/emoji/bookmark.png (100%) rename {app => vendor}/assets/images/emoji/bookmark_tabs.png (100%) rename {app => vendor}/assets/images/emoji/books.png (100%) rename {app => vendor}/assets/images/emoji/boot.png (100%) rename {app => vendor}/assets/images/emoji/bouquet.png (100%) rename {app => vendor}/assets/images/emoji/bow.png (100%) rename {app => vendor}/assets/images/emoji/bowling.png (100%) rename {app => vendor}/assets/images/emoji/bowtie.png (100%) rename {app => vendor}/assets/images/emoji/boy.png (100%) rename {app => vendor}/assets/images/emoji/bread.png (100%) rename {app => vendor}/assets/images/emoji/bride_with_veil.png (100%) rename {app => vendor}/assets/images/emoji/bridge_at_night.png (100%) rename {app => vendor}/assets/images/emoji/briefcase.png (100%) rename {app => vendor}/assets/images/emoji/broken_heart.png (100%) rename {app => vendor}/assets/images/emoji/bug.png (100%) rename {app => vendor}/assets/images/emoji/bulb.png (100%) rename {app => vendor}/assets/images/emoji/bullettrain_front.png (100%) rename {app => vendor}/assets/images/emoji/bullettrain_side.png (100%) rename {app => vendor}/assets/images/emoji/bus.png (100%) rename {app => vendor}/assets/images/emoji/busstop.png (100%) rename {app => vendor}/assets/images/emoji/bust_in_silhouette.png (100%) rename {app => vendor}/assets/images/emoji/busts_in_silhouette.png (100%) rename {app => vendor}/assets/images/emoji/cactus.png (100%) rename {app => vendor}/assets/images/emoji/cake.png (100%) rename {app => vendor}/assets/images/emoji/calendar.png (100%) rename {app => vendor}/assets/images/emoji/calling.png (100%) rename {app => vendor}/assets/images/emoji/camel.png (100%) rename {app => vendor}/assets/images/emoji/camera.png (100%) rename {app => vendor}/assets/images/emoji/cancer.png (100%) rename {app => vendor}/assets/images/emoji/candy.png (100%) rename {app => vendor}/assets/images/emoji/capital_abcd.png (100%) rename {app => vendor}/assets/images/emoji/capricorn.png (100%) rename {app => vendor}/assets/images/emoji/car.png (100%) rename {app => vendor}/assets/images/emoji/card_index.png (100%) rename {app => vendor}/assets/images/emoji/carousel_horse.png (100%) rename {app => vendor}/assets/images/emoji/cat.png (100%) rename {app => vendor}/assets/images/emoji/cat2.png (100%) rename {app => vendor}/assets/images/emoji/cd.png (100%) rename {app => vendor}/assets/images/emoji/chart.png (100%) rename {app => vendor}/assets/images/emoji/chart_with_downwards_trend.png (100%) rename {app => vendor}/assets/images/emoji/chart_with_upwards_trend.png (100%) rename {app => vendor}/assets/images/emoji/checkered_flag.png (100%) rename {app => vendor}/assets/images/emoji/cherries.png (100%) rename {app => vendor}/assets/images/emoji/cherry_blossom.png (100%) rename {app => vendor}/assets/images/emoji/chestnut.png (100%) rename {app => vendor}/assets/images/emoji/chicken.png (100%) rename {app => vendor}/assets/images/emoji/children_crossing.png (100%) rename {app => vendor}/assets/images/emoji/chocolate_bar.png (100%) rename {app => vendor}/assets/images/emoji/christmas_tree.png (100%) rename {app => vendor}/assets/images/emoji/church.png (100%) rename {app => vendor}/assets/images/emoji/cinema.png (100%) rename {app => vendor}/assets/images/emoji/circus_tent.png (100%) rename {app => vendor}/assets/images/emoji/city_sunrise.png (100%) rename {app => vendor}/assets/images/emoji/city_sunset.png (100%) rename {app => vendor}/assets/images/emoji/cl.png (100%) rename {app => vendor}/assets/images/emoji/clap.png (100%) rename {app => vendor}/assets/images/emoji/clapper.png (100%) rename {app => vendor}/assets/images/emoji/clipboard.png (100%) rename {app => vendor}/assets/images/emoji/clock1.png (100%) rename {app => vendor}/assets/images/emoji/clock10.png (100%) rename {app => vendor}/assets/images/emoji/clock1030.png (100%) rename {app => vendor}/assets/images/emoji/clock11.png (100%) rename {app => vendor}/assets/images/emoji/clock1130.png (100%) rename {app => vendor}/assets/images/emoji/clock12.png (100%) rename {app => vendor}/assets/images/emoji/clock1230.png (100%) rename {app => vendor}/assets/images/emoji/clock130.png (100%) rename {app => vendor}/assets/images/emoji/clock2.png (100%) rename {app => vendor}/assets/images/emoji/clock230.png (100%) rename {app => vendor}/assets/images/emoji/clock3.png (100%) rename {app => vendor}/assets/images/emoji/clock330.png (100%) rename {app => vendor}/assets/images/emoji/clock4.png (100%) rename {app => vendor}/assets/images/emoji/clock430.png (100%) rename {app => vendor}/assets/images/emoji/clock5.png (100%) rename {app => vendor}/assets/images/emoji/clock530.png (100%) rename {app => vendor}/assets/images/emoji/clock6.png (100%) rename {app => vendor}/assets/images/emoji/clock630.png (100%) rename {app => vendor}/assets/images/emoji/clock7.png (100%) rename {app => vendor}/assets/images/emoji/clock730.png (100%) rename {app => vendor}/assets/images/emoji/clock8.png (100%) rename {app => vendor}/assets/images/emoji/clock830.png (100%) rename {app => vendor}/assets/images/emoji/clock9.png (100%) rename {app => vendor}/assets/images/emoji/clock930.png (100%) rename {app => vendor}/assets/images/emoji/closed_book.png (100%) rename {app => vendor}/assets/images/emoji/closed_lock_with_key.png (100%) rename {app => vendor}/assets/images/emoji/closed_umbrella.png (100%) rename {app => vendor}/assets/images/emoji/cloud.png (100%) rename {app => vendor}/assets/images/emoji/clubs.png (100%) rename {app => vendor}/assets/images/emoji/cn.png (100%) rename {app => vendor}/assets/images/emoji/cocktail.png (100%) rename {app => vendor}/assets/images/emoji/coffee.png (100%) rename {app => vendor}/assets/images/emoji/cold_sweat.png (100%) rename {app => vendor}/assets/images/emoji/collision.png (100%) rename {app => vendor}/assets/images/emoji/computer.png (100%) rename {app => vendor}/assets/images/emoji/confetti_ball.png (100%) rename {app => vendor}/assets/images/emoji/confounded.png (100%) rename {app => vendor}/assets/images/emoji/congratulations.png (100%) rename {app => vendor}/assets/images/emoji/construction.png (100%) rename {app => vendor}/assets/images/emoji/construction_worker.png (100%) rename {app => vendor}/assets/images/emoji/convenience_store.png (100%) rename {app => vendor}/assets/images/emoji/cookie.png (100%) rename {app => vendor}/assets/images/emoji/cool.png (100%) rename {app => vendor}/assets/images/emoji/cop.png (100%) rename {app => vendor}/assets/images/emoji/copyright.png (100%) rename {app => vendor}/assets/images/emoji/corn.png (100%) rename {app => vendor}/assets/images/emoji/couple.png (100%) rename {app => vendor}/assets/images/emoji/couple_with_heart.png (100%) rename {app => vendor}/assets/images/emoji/couplekiss.png (100%) rename {app => vendor}/assets/images/emoji/cow.png (100%) rename {app => vendor}/assets/images/emoji/cow2.png (100%) rename {app => vendor}/assets/images/emoji/credit_card.png (100%) rename {app => vendor}/assets/images/emoji/crocodile.png (100%) rename {app => vendor}/assets/images/emoji/crossed_flags.png (100%) rename {app => vendor}/assets/images/emoji/crown.png (100%) rename {app => vendor}/assets/images/emoji/cry.png (100%) rename {app => vendor}/assets/images/emoji/crying_cat_face.png (100%) rename {app => vendor}/assets/images/emoji/crystal_ball.png (100%) rename {app => vendor}/assets/images/emoji/cupid.png (100%) rename {app => vendor}/assets/images/emoji/curly_loop.png (100%) rename {app => vendor}/assets/images/emoji/currency_exchange.png (100%) rename {app => vendor}/assets/images/emoji/curry.png (100%) rename {app => vendor}/assets/images/emoji/custard.png (100%) rename {app => vendor}/assets/images/emoji/customs.png (100%) rename {app => vendor}/assets/images/emoji/cyclone.png (100%) rename {app => vendor}/assets/images/emoji/dancer.png (100%) rename {app => vendor}/assets/images/emoji/dancers.png (100%) rename {app => vendor}/assets/images/emoji/dango.png (100%) rename {app => vendor}/assets/images/emoji/dart.png (100%) rename {app => vendor}/assets/images/emoji/dash.png (100%) rename {app => vendor}/assets/images/emoji/date.png (100%) rename {app => vendor}/assets/images/emoji/de.png (100%) rename {app => vendor}/assets/images/emoji/deciduous_tree.png (100%) rename {app => vendor}/assets/images/emoji/department_store.png (100%) rename {app => vendor}/assets/images/emoji/diamond_shape_with_a_dot_inside.png (100%) rename {app => vendor}/assets/images/emoji/diamonds.png (100%) rename {app => vendor}/assets/images/emoji/disappointed.png (100%) rename {app => vendor}/assets/images/emoji/dizzy.png (100%) rename {app => vendor}/assets/images/emoji/dizzy_face.png (100%) rename {app => vendor}/assets/images/emoji/do_not_litter.png (100%) rename {app => vendor}/assets/images/emoji/dog.png (100%) rename {app => vendor}/assets/images/emoji/dog2.png (100%) rename {app => vendor}/assets/images/emoji/dollar.png (100%) rename {app => vendor}/assets/images/emoji/dolls.png (100%) rename {app => vendor}/assets/images/emoji/dolphin.png (100%) rename {app => vendor}/assets/images/emoji/door.png (100%) rename {app => vendor}/assets/images/emoji/doughnut.png (100%) rename {app => vendor}/assets/images/emoji/dragon.png (100%) rename {app => vendor}/assets/images/emoji/dragon_face.png (100%) rename {app => vendor}/assets/images/emoji/dress.png (100%) rename {app => vendor}/assets/images/emoji/dromedary_camel.png (100%) rename {app => vendor}/assets/images/emoji/droplet.png (100%) rename {app => vendor}/assets/images/emoji/dvd.png (100%) rename {app => vendor}/assets/images/emoji/e-mail.png (100%) rename {app => vendor}/assets/images/emoji/ear.png (100%) rename {app => vendor}/assets/images/emoji/ear_of_rice.png (100%) rename {app => vendor}/assets/images/emoji/earth_africa.png (100%) rename {app => vendor}/assets/images/emoji/earth_americas.png (100%) rename {app => vendor}/assets/images/emoji/earth_asia.png (100%) rename {app => vendor}/assets/images/emoji/egg.png (100%) rename {app => vendor}/assets/images/emoji/eggplant.png (100%) rename {app => vendor}/assets/images/emoji/eight.png (100%) rename {app => vendor}/assets/images/emoji/eight_pointed_black_star.png (100%) rename {app => vendor}/assets/images/emoji/eight_spoked_asterisk.png (100%) rename {app => vendor}/assets/images/emoji/electric_plug.png (100%) rename {app => vendor}/assets/images/emoji/elephant.png (100%) rename {app => vendor}/assets/images/emoji/email.png (100%) rename {app => vendor}/assets/images/emoji/end.png (100%) rename {app => vendor}/assets/images/emoji/envelope.png (100%) rename {app => vendor}/assets/images/emoji/es.png (100%) rename {app => vendor}/assets/images/emoji/euro.png (100%) rename {app => vendor}/assets/images/emoji/european_castle.png (100%) rename {app => vendor}/assets/images/emoji/european_post_office.png (100%) rename {app => vendor}/assets/images/emoji/evergreen_tree.png (100%) rename {app => vendor}/assets/images/emoji/exclamation.png (100%) rename {app => vendor}/assets/images/emoji/eyeglasses.png (100%) rename {app => vendor}/assets/images/emoji/eyes.png (100%) rename {app => vendor}/assets/images/emoji/facepunch.png (100%) rename {app => vendor}/assets/images/emoji/factory.png (100%) rename {app => vendor}/assets/images/emoji/fallen_leaf.png (100%) rename {app => vendor}/assets/images/emoji/family.png (100%) rename {app => vendor}/assets/images/emoji/fast_forward.png (100%) rename {app => vendor}/assets/images/emoji/fax.png (100%) rename {app => vendor}/assets/images/emoji/fearful.png (100%) rename {app => vendor}/assets/images/emoji/feelsgood.png (100%) rename {app => vendor}/assets/images/emoji/feet.png (100%) rename {app => vendor}/assets/images/emoji/ferris_wheel.png (100%) rename {app => vendor}/assets/images/emoji/file_folder.png (100%) rename {app => vendor}/assets/images/emoji/finnadie.png (100%) rename {app => vendor}/assets/images/emoji/fire.png (100%) rename {app => vendor}/assets/images/emoji/fire_engine.png (100%) rename {app => vendor}/assets/images/emoji/fireworks.png (100%) rename {app => vendor}/assets/images/emoji/first_quarter_moon.png (100%) rename {app => vendor}/assets/images/emoji/first_quarter_moon_with_face.png (100%) rename {app => vendor}/assets/images/emoji/fish.png (100%) rename {app => vendor}/assets/images/emoji/fish_cake.png (100%) rename {app => vendor}/assets/images/emoji/fishing_pole_and_fish.png (100%) rename {app => vendor}/assets/images/emoji/fist.png (100%) rename {app => vendor}/assets/images/emoji/five.png (100%) rename {app => vendor}/assets/images/emoji/flags.png (100%) rename {app => vendor}/assets/images/emoji/flashlight.png (100%) rename {app => vendor}/assets/images/emoji/floppy_disk.png (100%) rename {app => vendor}/assets/images/emoji/flower_playing_cards.png (100%) rename {app => vendor}/assets/images/emoji/flushed.png (100%) rename {app => vendor}/assets/images/emoji/foggy.png (100%) rename {app => vendor}/assets/images/emoji/football.png (100%) rename {app => vendor}/assets/images/emoji/fork_and_knife.png (100%) rename {app => vendor}/assets/images/emoji/fountain.png (100%) rename {app => vendor}/assets/images/emoji/four.png (100%) rename {app => vendor}/assets/images/emoji/four_leaf_clover.png (100%) rename {app => vendor}/assets/images/emoji/fr.png (100%) rename {app => vendor}/assets/images/emoji/free.png (100%) rename {app => vendor}/assets/images/emoji/fried_shrimp.png (100%) rename {app => vendor}/assets/images/emoji/fries.png (100%) rename {app => vendor}/assets/images/emoji/frog.png (100%) rename {app => vendor}/assets/images/emoji/fuelpump.png (100%) rename {app => vendor}/assets/images/emoji/full_moon.png (100%) rename {app => vendor}/assets/images/emoji/full_moon_with_face.png (100%) rename {app => vendor}/assets/images/emoji/game_die.png (100%) rename {app => vendor}/assets/images/emoji/gb.png (100%) rename {app => vendor}/assets/images/emoji/gem.png (100%) rename {app => vendor}/assets/images/emoji/gemini.png (100%) rename {app => vendor}/assets/images/emoji/ghost.png (100%) rename {app => vendor}/assets/images/emoji/gift.png (100%) rename {app => vendor}/assets/images/emoji/gift_heart.png (100%) rename {app => vendor}/assets/images/emoji/girl.png (100%) rename {app => vendor}/assets/images/emoji/globe_with_meridians.png (100%) rename {app => vendor}/assets/images/emoji/goat.png (100%) rename {app => vendor}/assets/images/emoji/goberserk.png (100%) rename {app => vendor}/assets/images/emoji/godmode.png (100%) rename {app => vendor}/assets/images/emoji/golf.png (100%) rename {app => vendor}/assets/images/emoji/grapes.png (100%) rename {app => vendor}/assets/images/emoji/green_apple.png (100%) rename {app => vendor}/assets/images/emoji/green_book.png (100%) rename {app => vendor}/assets/images/emoji/green_heart.png (100%) rename {app => vendor}/assets/images/emoji/grey_exclamation.png (100%) rename {app => vendor}/assets/images/emoji/grey_question.png (100%) rename {app => vendor}/assets/images/emoji/grin.png (100%) rename {app => vendor}/assets/images/emoji/guardsman.png (100%) rename {app => vendor}/assets/images/emoji/guitar.png (100%) rename {app => vendor}/assets/images/emoji/gun.png (100%) rename {app => vendor}/assets/images/emoji/haircut.png (100%) rename {app => vendor}/assets/images/emoji/hamburger.png (100%) rename {app => vendor}/assets/images/emoji/hammer.png (100%) rename {app => vendor}/assets/images/emoji/hamster.png (100%) rename {app => vendor}/assets/images/emoji/hand.png (100%) rename {app => vendor}/assets/images/emoji/handbag.png (100%) rename {app => vendor}/assets/images/emoji/hankey.png (100%) rename {app => vendor}/assets/images/emoji/hash.png (100%) rename {app => vendor}/assets/images/emoji/hatched_chick.png (100%) rename {app => vendor}/assets/images/emoji/hatching_chick.png (100%) rename {app => vendor}/assets/images/emoji/headphones.png (100%) rename {app => vendor}/assets/images/emoji/hear_no_evil.png (100%) rename {app => vendor}/assets/images/emoji/heart.png (100%) rename {app => vendor}/assets/images/emoji/heart_decoration.png (100%) rename {app => vendor}/assets/images/emoji/heart_eyes.png (100%) rename {app => vendor}/assets/images/emoji/heart_eyes_cat.png (100%) rename {app => vendor}/assets/images/emoji/heartbeat.png (100%) rename {app => vendor}/assets/images/emoji/heartpulse.png (100%) rename {app => vendor}/assets/images/emoji/hearts.png (100%) rename {app => vendor}/assets/images/emoji/heavy_check_mark.png (100%) rename {app => vendor}/assets/images/emoji/heavy_division_sign.png (100%) rename {app => vendor}/assets/images/emoji/heavy_dollar_sign.png (100%) rename {app => vendor}/assets/images/emoji/heavy_exclamation_mark.png (100%) rename {app => vendor}/assets/images/emoji/heavy_minus_sign.png (100%) rename {app => vendor}/assets/images/emoji/heavy_multiplication_x.png (100%) rename {app => vendor}/assets/images/emoji/heavy_plus_sign.png (100%) rename {app => vendor}/assets/images/emoji/helicopter.png (100%) rename {app => vendor}/assets/images/emoji/herb.png (100%) rename {app => vendor}/assets/images/emoji/hibiscus.png (100%) rename {app => vendor}/assets/images/emoji/high_brightness.png (100%) rename {app => vendor}/assets/images/emoji/high_heel.png (100%) rename {app => vendor}/assets/images/emoji/hocho.png (100%) rename {app => vendor}/assets/images/emoji/honey_pot.png (100%) rename {app => vendor}/assets/images/emoji/honeybee.png (100%) rename {app => vendor}/assets/images/emoji/horse.png (100%) rename {app => vendor}/assets/images/emoji/horse_racing.png (100%) rename {app => vendor}/assets/images/emoji/hospital.png (100%) rename {app => vendor}/assets/images/emoji/hotel.png (100%) rename {app => vendor}/assets/images/emoji/hotsprings.png (100%) rename {app => vendor}/assets/images/emoji/hourglass.png (100%) rename {app => vendor}/assets/images/emoji/house.png (100%) rename {app => vendor}/assets/images/emoji/hurtrealbad.png (100%) rename {app => vendor}/assets/images/emoji/ice_cream.png (100%) rename {app => vendor}/assets/images/emoji/icecream.png (100%) rename {app => vendor}/assets/images/emoji/id.png (100%) rename {app => vendor}/assets/images/emoji/ideograph_advantage.png (100%) rename {app => vendor}/assets/images/emoji/imp.png (100%) rename {app => vendor}/assets/images/emoji/inbox_tray.png (100%) rename {app => vendor}/assets/images/emoji/incoming_envelope.png (100%) rename {app => vendor}/assets/images/emoji/information_desk_person.png (100%) rename {app => vendor}/assets/images/emoji/information_source.png (100%) rename {app => vendor}/assets/images/emoji/innocent.png (100%) rename {app => vendor}/assets/images/emoji/interrobang.png (100%) rename {app => vendor}/assets/images/emoji/iphone.png (100%) rename {app => vendor}/assets/images/emoji/it.png (100%) rename {app => vendor}/assets/images/emoji/izakaya_lantern.png (100%) rename {app => vendor}/assets/images/emoji/jack_o_lantern.png (100%) rename {app => vendor}/assets/images/emoji/japan.png (100%) rename {app => vendor}/assets/images/emoji/japanese_castle.png (100%) rename {app => vendor}/assets/images/emoji/japanese_goblin.png (100%) rename {app => vendor}/assets/images/emoji/japanese_ogre.png (100%) rename {app => vendor}/assets/images/emoji/jeans.png (100%) rename {app => vendor}/assets/images/emoji/joy.png (100%) rename {app => vendor}/assets/images/emoji/joy_cat.png (100%) rename {app => vendor}/assets/images/emoji/jp.png (100%) rename {app => vendor}/assets/images/emoji/key.png (100%) rename {app => vendor}/assets/images/emoji/keycap_ten.png (100%) rename {app => vendor}/assets/images/emoji/kimono.png (100%) rename {app => vendor}/assets/images/emoji/kiss.png (100%) rename {app => vendor}/assets/images/emoji/kissing_cat.png (100%) rename {app => vendor}/assets/images/emoji/kissing_face.png (100%) rename {app => vendor}/assets/images/emoji/kissing_heart.png (100%) rename {app => vendor}/assets/images/emoji/koala.png (100%) rename {app => vendor}/assets/images/emoji/koko.png (100%) rename {app => vendor}/assets/images/emoji/kr.png (100%) rename {app => vendor}/assets/images/emoji/large_blue_circle.png (100%) rename {app => vendor}/assets/images/emoji/large_blue_diamond.png (100%) rename {app => vendor}/assets/images/emoji/large_orange_diamond.png (100%) rename {app => vendor}/assets/images/emoji/last_quarter_moon.png (100%) rename {app => vendor}/assets/images/emoji/last_quarter_moon_with_face.png (100%) rename {app => vendor}/assets/images/emoji/laughing.png (100%) rename {app => vendor}/assets/images/emoji/leaves.png (100%) rename {app => vendor}/assets/images/emoji/ledger.png (100%) rename {app => vendor}/assets/images/emoji/left_luggage.png (100%) rename {app => vendor}/assets/images/emoji/left_right_arrow.png (100%) rename {app => vendor}/assets/images/emoji/leftwards_arrow_with_hook.png (100%) rename {app => vendor}/assets/images/emoji/lemon.png (100%) rename {app => vendor}/assets/images/emoji/leo.png (100%) rename {app => vendor}/assets/images/emoji/leopard.png (100%) rename {app => vendor}/assets/images/emoji/libra.png (100%) rename {app => vendor}/assets/images/emoji/light_rail.png (100%) rename {app => vendor}/assets/images/emoji/link.png (100%) rename {app => vendor}/assets/images/emoji/lips.png (100%) rename {app => vendor}/assets/images/emoji/lipstick.png (100%) rename {app => vendor}/assets/images/emoji/lock.png (100%) rename {app => vendor}/assets/images/emoji/lock_with_ink_pen.png (100%) rename {app => vendor}/assets/images/emoji/lollipop.png (100%) rename {app => vendor}/assets/images/emoji/loop.png (100%) rename {app => vendor}/assets/images/emoji/loudspeaker.png (100%) rename {app => vendor}/assets/images/emoji/love_hotel.png (100%) rename {app => vendor}/assets/images/emoji/love_letter.png (100%) rename {app => vendor}/assets/images/emoji/low_brightness.png (100%) rename {app => vendor}/assets/images/emoji/m.png (100%) rename {app => vendor}/assets/images/emoji/mag.png (100%) rename {app => vendor}/assets/images/emoji/mag_right.png (100%) rename {app => vendor}/assets/images/emoji/mahjong.png (100%) rename {app => vendor}/assets/images/emoji/mailbox.png (100%) rename {app => vendor}/assets/images/emoji/mailbox_closed.png (100%) rename {app => vendor}/assets/images/emoji/mailbox_with_mail.png (100%) rename {app => vendor}/assets/images/emoji/mailbox_with_no_mail.png (100%) rename {app => vendor}/assets/images/emoji/man.png (100%) rename {app => vendor}/assets/images/emoji/man_with_gua_pi_mao.png (100%) rename {app => vendor}/assets/images/emoji/man_with_turban.png (100%) rename {app => vendor}/assets/images/emoji/mans_shoe.png (100%) rename {app => vendor}/assets/images/emoji/maple_leaf.png (100%) rename {app => vendor}/assets/images/emoji/mask.png (100%) rename {app => vendor}/assets/images/emoji/massage.png (100%) rename {app => vendor}/assets/images/emoji/meat_on_bone.png (100%) rename {app => vendor}/assets/images/emoji/mega.png (100%) rename {app => vendor}/assets/images/emoji/melon.png (100%) rename {app => vendor}/assets/images/emoji/memo.png (100%) rename {app => vendor}/assets/images/emoji/mens.png (100%) rename {app => vendor}/assets/images/emoji/metal.png (100%) rename {app => vendor}/assets/images/emoji/metro.png (100%) rename {app => vendor}/assets/images/emoji/microphone.png (100%) rename {app => vendor}/assets/images/emoji/microscope.png (100%) rename {app => vendor}/assets/images/emoji/milky_way.png (100%) rename {app => vendor}/assets/images/emoji/minibus.png (100%) rename {app => vendor}/assets/images/emoji/minidisc.png (100%) rename {app => vendor}/assets/images/emoji/mobile_phone_off.png (100%) rename {app => vendor}/assets/images/emoji/money_with_wings.png (100%) rename {app => vendor}/assets/images/emoji/moneybag.png (100%) rename {app => vendor}/assets/images/emoji/monkey.png (100%) rename {app => vendor}/assets/images/emoji/monkey_face.png (100%) rename {app => vendor}/assets/images/emoji/monorail.png (100%) rename {app => vendor}/assets/images/emoji/moon.png (100%) rename {app => vendor}/assets/images/emoji/mortar_board.png (100%) rename {app => vendor}/assets/images/emoji/mount_fuji.png (100%) rename {app => vendor}/assets/images/emoji/mountain_bicyclist.png (100%) rename {app => vendor}/assets/images/emoji/mountain_cableway.png (100%) rename {app => vendor}/assets/images/emoji/mountain_railway.png (100%) rename {app => vendor}/assets/images/emoji/mouse.png (100%) rename {app => vendor}/assets/images/emoji/mouse2.png (100%) rename {app => vendor}/assets/images/emoji/movie_camera.png (100%) rename {app => vendor}/assets/images/emoji/moyai.png (100%) rename {app => vendor}/assets/images/emoji/muscle.png (100%) rename {app => vendor}/assets/images/emoji/mushroom.png (100%) rename {app => vendor}/assets/images/emoji/musical_keyboard.png (100%) rename {app => vendor}/assets/images/emoji/musical_note.png (100%) rename {app => vendor}/assets/images/emoji/musical_score.png (100%) rename {app => vendor}/assets/images/emoji/mute.png (100%) rename {app => vendor}/assets/images/emoji/nail_care.png (100%) rename {app => vendor}/assets/images/emoji/name_badge.png (100%) rename {app => vendor}/assets/images/emoji/neckbeard.png (100%) rename {app => vendor}/assets/images/emoji/necktie.png (100%) rename {app => vendor}/assets/images/emoji/negative_squared_cross_mark.png (100%) rename {app => vendor}/assets/images/emoji/neutral_face.png (100%) rename {app => vendor}/assets/images/emoji/new.png (100%) rename {app => vendor}/assets/images/emoji/new_moon.png (100%) rename {app => vendor}/assets/images/emoji/new_moon_with_face.png (100%) rename {app => vendor}/assets/images/emoji/newspaper.png (100%) rename {app => vendor}/assets/images/emoji/ng.png (100%) rename {app => vendor}/assets/images/emoji/nine.png (100%) rename {app => vendor}/assets/images/emoji/no_bell.png (100%) rename {app => vendor}/assets/images/emoji/no_bicycles.png (100%) rename {app => vendor}/assets/images/emoji/no_entry.png (100%) rename {app => vendor}/assets/images/emoji/no_entry_sign.png (100%) rename {app => vendor}/assets/images/emoji/no_good.png (100%) rename {app => vendor}/assets/images/emoji/no_mobile_phones.png (100%) rename {app => vendor}/assets/images/emoji/no_mouth.png (100%) rename {app => vendor}/assets/images/emoji/no_pedestrians.png (100%) rename {app => vendor}/assets/images/emoji/no_smoking.png (100%) rename {app => vendor}/assets/images/emoji/non-potable_water.png (100%) rename {app => vendor}/assets/images/emoji/nose.png (100%) rename {app => vendor}/assets/images/emoji/notebook.png (100%) rename {app => vendor}/assets/images/emoji/notebook_with_decorative_cover.png (100%) rename {app => vendor}/assets/images/emoji/notes.png (100%) rename {app => vendor}/assets/images/emoji/nut_and_bolt.png (100%) rename {app => vendor}/assets/images/emoji/o.png (100%) rename {app => vendor}/assets/images/emoji/o2.png (100%) rename {app => vendor}/assets/images/emoji/ocean.png (100%) rename {app => vendor}/assets/images/emoji/octocat.png (100%) rename {app => vendor}/assets/images/emoji/octopus.png (100%) rename {app => vendor}/assets/images/emoji/oden.png (100%) rename {app => vendor}/assets/images/emoji/office.png (100%) rename {app => vendor}/assets/images/emoji/ok.png (100%) rename {app => vendor}/assets/images/emoji/ok_hand.png (100%) rename {app => vendor}/assets/images/emoji/ok_woman.png (100%) rename {app => vendor}/assets/images/emoji/older_man.png (100%) rename {app => vendor}/assets/images/emoji/older_woman.png (100%) rename {app => vendor}/assets/images/emoji/on.png (100%) rename {app => vendor}/assets/images/emoji/oncoming_automobile.png (100%) rename {app => vendor}/assets/images/emoji/oncoming_bus.png (100%) rename {app => vendor}/assets/images/emoji/oncoming_police_car.png (100%) rename {app => vendor}/assets/images/emoji/oncoming_taxi.png (100%) rename {app => vendor}/assets/images/emoji/one.png (100%) rename {app => vendor}/assets/images/emoji/open_file_folder.png (100%) rename {app => vendor}/assets/images/emoji/open_hands.png (100%) rename {app => vendor}/assets/images/emoji/ophiuchus.png (100%) rename {app => vendor}/assets/images/emoji/orange_book.png (100%) rename {app => vendor}/assets/images/emoji/outbox_tray.png (100%) rename {app => vendor}/assets/images/emoji/ox.png (100%) rename {app => vendor}/assets/images/emoji/page_facing_up.png (100%) rename {app => vendor}/assets/images/emoji/page_with_curl.png (100%) rename {app => vendor}/assets/images/emoji/pager.png (100%) rename {app => vendor}/assets/images/emoji/palm_tree.png (100%) rename {app => vendor}/assets/images/emoji/panda_face.png (100%) rename {app => vendor}/assets/images/emoji/paperclip.png (100%) rename {app => vendor}/assets/images/emoji/parking.png (100%) rename {app => vendor}/assets/images/emoji/part_alternation_mark.png (100%) rename {app => vendor}/assets/images/emoji/partly_sunny.png (100%) rename {app => vendor}/assets/images/emoji/passport_control.png (100%) rename {app => vendor}/assets/images/emoji/paw_prints.png (100%) rename {app => vendor}/assets/images/emoji/peach.png (100%) rename {app => vendor}/assets/images/emoji/pear.png (100%) rename {app => vendor}/assets/images/emoji/pencil.png (100%) rename {app => vendor}/assets/images/emoji/pencil2.png (100%) rename {app => vendor}/assets/images/emoji/penguin.png (100%) rename {app => vendor}/assets/images/emoji/pensive.png (100%) rename {app => vendor}/assets/images/emoji/performing_arts.png (100%) rename {app => vendor}/assets/images/emoji/persevere.png (100%) rename {app => vendor}/assets/images/emoji/person_frowning.png (100%) rename {app => vendor}/assets/images/emoji/person_with_blond_hair.png (100%) rename {app => vendor}/assets/images/emoji/person_with_pouting_face.png (100%) rename {app => vendor}/assets/images/emoji/phone.png (100%) rename {app => vendor}/assets/images/emoji/pig.png (100%) rename {app => vendor}/assets/images/emoji/pig2.png (100%) rename {app => vendor}/assets/images/emoji/pig_nose.png (100%) rename {app => vendor}/assets/images/emoji/pill.png (100%) rename {app => vendor}/assets/images/emoji/pineapple.png (100%) rename {app => vendor}/assets/images/emoji/pisces.png (100%) rename {app => vendor}/assets/images/emoji/pizza.png (100%) rename {app => vendor}/assets/images/emoji/plus1.png (100%) rename {app => vendor}/assets/images/emoji/point_down.png (100%) rename {app => vendor}/assets/images/emoji/point_left.png (100%) rename {app => vendor}/assets/images/emoji/point_right.png (100%) rename {app => vendor}/assets/images/emoji/point_up.png (100%) rename {app => vendor}/assets/images/emoji/point_up_2.png (100%) rename {app => vendor}/assets/images/emoji/police_car.png (100%) rename {app => vendor}/assets/images/emoji/poodle.png (100%) rename {app => vendor}/assets/images/emoji/poop.png (100%) rename {app => vendor}/assets/images/emoji/post_office.png (100%) rename {app => vendor}/assets/images/emoji/postal_horn.png (100%) rename {app => vendor}/assets/images/emoji/postbox.png (100%) rename {app => vendor}/assets/images/emoji/potable_water.png (100%) rename {app => vendor}/assets/images/emoji/pouch.png (100%) rename {app => vendor}/assets/images/emoji/poultry_leg.png (100%) rename {app => vendor}/assets/images/emoji/pound.png (100%) rename {app => vendor}/assets/images/emoji/pouting_cat.png (100%) rename {app => vendor}/assets/images/emoji/pray.png (100%) rename {app => vendor}/assets/images/emoji/princess.png (100%) rename {app => vendor}/assets/images/emoji/punch.png (100%) rename {app => vendor}/assets/images/emoji/purple_heart.png (100%) rename {app => vendor}/assets/images/emoji/purse.png (100%) rename {app => vendor}/assets/images/emoji/pushpin.png (100%) rename {app => vendor}/assets/images/emoji/put_litter_in_its_place.png (100%) rename {app => vendor}/assets/images/emoji/question.png (100%) rename {app => vendor}/assets/images/emoji/rabbit.png (100%) rename {app => vendor}/assets/images/emoji/rabbit2.png (100%) rename {app => vendor}/assets/images/emoji/racehorse.png (100%) rename {app => vendor}/assets/images/emoji/radio.png (100%) rename {app => vendor}/assets/images/emoji/radio_button.png (100%) rename {app => vendor}/assets/images/emoji/rage.png (100%) rename {app => vendor}/assets/images/emoji/rage1.png (100%) rename {app => vendor}/assets/images/emoji/rage2.png (100%) rename {app => vendor}/assets/images/emoji/rage3.png (100%) rename {app => vendor}/assets/images/emoji/rage4.png (100%) rename {app => vendor}/assets/images/emoji/railway_car.png (100%) rename {app => vendor}/assets/images/emoji/rainbow.png (100%) rename {app => vendor}/assets/images/emoji/raised_hand.png (100%) rename {app => vendor}/assets/images/emoji/raised_hands.png (100%) rename {app => vendor}/assets/images/emoji/ram.png (100%) rename {app => vendor}/assets/images/emoji/ramen.png (100%) rename {app => vendor}/assets/images/emoji/rat.png (100%) rename {app => vendor}/assets/images/emoji/recycle.png (100%) rename {app => vendor}/assets/images/emoji/red_car.png (100%) rename {app => vendor}/assets/images/emoji/red_circle.png (100%) rename {app => vendor}/assets/images/emoji/registered.png (100%) rename {app => vendor}/assets/images/emoji/relaxed.png (100%) rename {app => vendor}/assets/images/emoji/relieved.png (100%) rename {app => vendor}/assets/images/emoji/repeat.png (100%) rename {app => vendor}/assets/images/emoji/repeat_one.png (100%) rename {app => vendor}/assets/images/emoji/restroom.png (100%) rename {app => vendor}/assets/images/emoji/revolving_hearts.png (100%) rename {app => vendor}/assets/images/emoji/rewind.png (100%) rename {app => vendor}/assets/images/emoji/ribbon.png (100%) rename {app => vendor}/assets/images/emoji/rice.png (100%) rename {app => vendor}/assets/images/emoji/rice_ball.png (100%) rename {app => vendor}/assets/images/emoji/rice_cracker.png (100%) rename {app => vendor}/assets/images/emoji/rice_scene.png (100%) rename {app => vendor}/assets/images/emoji/ring.png (100%) rename {app => vendor}/assets/images/emoji/rocket.png (100%) rename {app => vendor}/assets/images/emoji/roller_coaster.png (100%) rename {app => vendor}/assets/images/emoji/rooster.png (100%) rename {app => vendor}/assets/images/emoji/rose.png (100%) rename {app => vendor}/assets/images/emoji/rotating_light.png (100%) rename {app => vendor}/assets/images/emoji/round_pushpin.png (100%) rename {app => vendor}/assets/images/emoji/rowboat.png (100%) rename {app => vendor}/assets/images/emoji/ru.png (100%) rename {app => vendor}/assets/images/emoji/rugby_football.png (100%) rename {app => vendor}/assets/images/emoji/runner.png (100%) rename {app => vendor}/assets/images/emoji/running.png (100%) rename {app => vendor}/assets/images/emoji/running_shirt_with_sash.png (100%) rename {app => vendor}/assets/images/emoji/sa.png (100%) rename {app => vendor}/assets/images/emoji/sagittarius.png (100%) rename {app => vendor}/assets/images/emoji/sailboat.png (100%) rename {app => vendor}/assets/images/emoji/sake.png (100%) rename {app => vendor}/assets/images/emoji/sandal.png (100%) rename {app => vendor}/assets/images/emoji/santa.png (100%) rename {app => vendor}/assets/images/emoji/satellite.png (100%) rename {app => vendor}/assets/images/emoji/satisfied.png (100%) rename {app => vendor}/assets/images/emoji/saxophone.png (100%) rename {app => vendor}/assets/images/emoji/school.png (100%) rename {app => vendor}/assets/images/emoji/school_satchel.png (100%) rename {app => vendor}/assets/images/emoji/scissors.png (100%) rename {app => vendor}/assets/images/emoji/scorpius.png (100%) rename {app => vendor}/assets/images/emoji/scream.png (100%) rename {app => vendor}/assets/images/emoji/scream_cat.png (100%) rename {app => vendor}/assets/images/emoji/scroll.png (100%) rename {app => vendor}/assets/images/emoji/seat.png (100%) rename {app => vendor}/assets/images/emoji/secret.png (100%) rename {app => vendor}/assets/images/emoji/see_no_evil.png (100%) rename {app => vendor}/assets/images/emoji/seedling.png (100%) rename {app => vendor}/assets/images/emoji/seven.png (100%) rename {app => vendor}/assets/images/emoji/shaved_ice.png (100%) rename {app => vendor}/assets/images/emoji/sheep.png (100%) rename {app => vendor}/assets/images/emoji/shell.png (100%) rename {app => vendor}/assets/images/emoji/ship.png (100%) rename {app => vendor}/assets/images/emoji/shipit.png (100%) rename {app => vendor}/assets/images/emoji/shirt.png (100%) rename {app => vendor}/assets/images/emoji/shit.png (100%) rename {app => vendor}/assets/images/emoji/shoe.png (100%) rename {app => vendor}/assets/images/emoji/shower.png (100%) rename {app => vendor}/assets/images/emoji/signal_strength.png (100%) rename {app => vendor}/assets/images/emoji/six.png (100%) rename {app => vendor}/assets/images/emoji/six_pointed_star.png (100%) rename {app => vendor}/assets/images/emoji/ski.png (100%) rename {app => vendor}/assets/images/emoji/skull.png (100%) rename {app => vendor}/assets/images/emoji/sleepy.png (100%) rename {app => vendor}/assets/images/emoji/slot_machine.png (100%) rename {app => vendor}/assets/images/emoji/small_blue_diamond.png (100%) rename {app => vendor}/assets/images/emoji/small_orange_diamond.png (100%) rename {app => vendor}/assets/images/emoji/small_red_triangle.png (100%) rename {app => vendor}/assets/images/emoji/small_red_triangle_down.png (100%) rename {app => vendor}/assets/images/emoji/smile.png (100%) rename {app => vendor}/assets/images/emoji/smile_cat.png (100%) rename {app => vendor}/assets/images/emoji/smiley.png (100%) rename {app => vendor}/assets/images/emoji/smiley_cat.png (100%) rename {app => vendor}/assets/images/emoji/smiling_imp.png (100%) rename {app => vendor}/assets/images/emoji/smirk.png (100%) rename {app => vendor}/assets/images/emoji/smirk_cat.png (100%) rename {app => vendor}/assets/images/emoji/smoking.png (100%) rename {app => vendor}/assets/images/emoji/snail.png (100%) rename {app => vendor}/assets/images/emoji/snake.png (100%) rename {app => vendor}/assets/images/emoji/snowboarder.png (100%) rename {app => vendor}/assets/images/emoji/snowflake.png (100%) rename {app => vendor}/assets/images/emoji/snowman.png (100%) rename {app => vendor}/assets/images/emoji/sob.png (100%) rename {app => vendor}/assets/images/emoji/soccer.png (100%) rename {app => vendor}/assets/images/emoji/soon.png (100%) rename {app => vendor}/assets/images/emoji/sos.png (100%) rename {app => vendor}/assets/images/emoji/sound.png (100%) rename {app => vendor}/assets/images/emoji/space_invader.png (100%) rename {app => vendor}/assets/images/emoji/spades.png (100%) rename {app => vendor}/assets/images/emoji/spaghetti.png (100%) rename {app => vendor}/assets/images/emoji/sparkler.png (100%) rename {app => vendor}/assets/images/emoji/sparkles.png (100%) rename {app => vendor}/assets/images/emoji/speak_no_evil.png (100%) rename {app => vendor}/assets/images/emoji/speaker.png (100%) rename {app => vendor}/assets/images/emoji/speech_balloon.png (100%) rename {app => vendor}/assets/images/emoji/speedboat.png (100%) rename {app => vendor}/assets/images/emoji/squirrel.png (100%) rename {app => vendor}/assets/images/emoji/star.png (100%) rename {app => vendor}/assets/images/emoji/star2.png (100%) rename {app => vendor}/assets/images/emoji/stars.png (100%) rename {app => vendor}/assets/images/emoji/station.png (100%) rename {app => vendor}/assets/images/emoji/statue_of_liberty.png (100%) rename {app => vendor}/assets/images/emoji/steam_locomotive.png (100%) rename {app => vendor}/assets/images/emoji/stew.png (100%) rename {app => vendor}/assets/images/emoji/straight_ruler.png (100%) rename {app => vendor}/assets/images/emoji/strawberry.png (100%) rename {app => vendor}/assets/images/emoji/sun_with_face.png (100%) rename {app => vendor}/assets/images/emoji/sunflower.png (100%) rename {app => vendor}/assets/images/emoji/sunglasses.png (100%) rename {app => vendor}/assets/images/emoji/sunny.png (100%) rename {app => vendor}/assets/images/emoji/sunrise.png (100%) rename {app => vendor}/assets/images/emoji/sunrise_over_mountains.png (100%) rename {app => vendor}/assets/images/emoji/surfer.png (100%) rename {app => vendor}/assets/images/emoji/sushi.png (100%) rename {app => vendor}/assets/images/emoji/suspect.png (100%) rename {app => vendor}/assets/images/emoji/suspension_railway.png (100%) rename {app => vendor}/assets/images/emoji/sweat.png (100%) rename {app => vendor}/assets/images/emoji/sweat_drops.png (100%) rename {app => vendor}/assets/images/emoji/sweat_smile.png (100%) rename {app => vendor}/assets/images/emoji/sweet_potato.png (100%) rename {app => vendor}/assets/images/emoji/swimmer.png (100%) rename {app => vendor}/assets/images/emoji/symbols.png (100%) rename {app => vendor}/assets/images/emoji/syringe.png (100%) rename {app => vendor}/assets/images/emoji/tada.png (100%) rename {app => vendor}/assets/images/emoji/tanabata_tree.png (100%) rename {app => vendor}/assets/images/emoji/tangerine.png (100%) rename {app => vendor}/assets/images/emoji/taurus.png (100%) rename {app => vendor}/assets/images/emoji/taxi.png (100%) rename {app => vendor}/assets/images/emoji/tea.png (100%) rename {app => vendor}/assets/images/emoji/telephone.png (100%) rename {app => vendor}/assets/images/emoji/telephone_receiver.png (100%) rename {app => vendor}/assets/images/emoji/telescope.png (100%) rename {app => vendor}/assets/images/emoji/tennis.png (100%) rename {app => vendor}/assets/images/emoji/tent.png (100%) rename {app => vendor}/assets/images/emoji/thought_balloon.png (100%) rename {app => vendor}/assets/images/emoji/three.png (100%) rename {app => vendor}/assets/images/emoji/thumbsdown.png (100%) rename {app => vendor}/assets/images/emoji/thumbsup.png (100%) rename {app => vendor}/assets/images/emoji/ticket.png (100%) rename {app => vendor}/assets/images/emoji/tiger.png (100%) rename {app => vendor}/assets/images/emoji/tiger2.png (100%) rename {app => vendor}/assets/images/emoji/tired_face.png (100%) rename {app => vendor}/assets/images/emoji/tm.png (100%) rename {app => vendor}/assets/images/emoji/toilet.png (100%) rename {app => vendor}/assets/images/emoji/tokyo_tower.png (100%) rename {app => vendor}/assets/images/emoji/tomato.png (100%) rename {app => vendor}/assets/images/emoji/tongue.png (100%) rename {app => vendor}/assets/images/emoji/tongue2.png (100%) rename {app => vendor}/assets/images/emoji/top.png (100%) rename {app => vendor}/assets/images/emoji/tophat.png (100%) rename {app => vendor}/assets/images/emoji/tractor.png (100%) rename {app => vendor}/assets/images/emoji/traffic_light.png (100%) rename {app => vendor}/assets/images/emoji/train.png (100%) rename {app => vendor}/assets/images/emoji/train2.png (100%) rename {app => vendor}/assets/images/emoji/tram.png (100%) rename {app => vendor}/assets/images/emoji/triangular_flag_on_post.png (100%) rename {app => vendor}/assets/images/emoji/triangular_ruler.png (100%) rename {app => vendor}/assets/images/emoji/trident.png (100%) rename {app => vendor}/assets/images/emoji/triumph.png (100%) rename {app => vendor}/assets/images/emoji/trolleybus.png (100%) rename {app => vendor}/assets/images/emoji/trollface.png (100%) rename {app => vendor}/assets/images/emoji/trophy.png (100%) rename {app => vendor}/assets/images/emoji/tropical_drink.png (100%) rename {app => vendor}/assets/images/emoji/tropical_fish.png (100%) rename {app => vendor}/assets/images/emoji/truck.png (100%) rename {app => vendor}/assets/images/emoji/trumpet.png (100%) rename {app => vendor}/assets/images/emoji/tshirt.png (100%) rename {app => vendor}/assets/images/emoji/tulip.png (100%) rename {app => vendor}/assets/images/emoji/turtle.png (100%) rename {app => vendor}/assets/images/emoji/tv.png (100%) rename {app => vendor}/assets/images/emoji/twisted_rightwards_arrows.png (100%) rename {app => vendor}/assets/images/emoji/two.png (100%) rename {app => vendor}/assets/images/emoji/two_hearts.png (100%) rename {app => vendor}/assets/images/emoji/two_men_holding_hands.png (100%) rename {app => vendor}/assets/images/emoji/two_women_holding_hands.png (100%) rename {app => vendor}/assets/images/emoji/u5272.png (100%) rename {app => vendor}/assets/images/emoji/u5408.png (100%) rename {app => vendor}/assets/images/emoji/u55b6.png (100%) rename {app => vendor}/assets/images/emoji/u6307.png (100%) rename {app => vendor}/assets/images/emoji/u6708.png (100%) rename {app => vendor}/assets/images/emoji/u6709.png (100%) rename {app => vendor}/assets/images/emoji/u6e80.png (100%) rename {app => vendor}/assets/images/emoji/u7121.png (100%) rename {app => vendor}/assets/images/emoji/u7533.png (100%) rename {app => vendor}/assets/images/emoji/u7981.png (100%) rename {app => vendor}/assets/images/emoji/u7a7a.png (100%) rename {app => vendor}/assets/images/emoji/uk.png (100%) rename {app => vendor}/assets/images/emoji/umbrella.png (100%) rename {app => vendor}/assets/images/emoji/unamused.png (100%) rename {app => vendor}/assets/images/emoji/underage.png (100%) rename {app => vendor}/assets/images/emoji/unlock.png (100%) rename {app => vendor}/assets/images/emoji/up.png (100%) rename {app => vendor}/assets/images/emoji/us.png (100%) rename {app => vendor}/assets/images/emoji/v.png (100%) rename {app => vendor}/assets/images/emoji/vertical_traffic_light.png (100%) rename {app => vendor}/assets/images/emoji/vhs.png (100%) rename {app => vendor}/assets/images/emoji/vibration_mode.png (100%) rename {app => vendor}/assets/images/emoji/video_camera.png (100%) rename {app => vendor}/assets/images/emoji/video_game.png (100%) rename {app => vendor}/assets/images/emoji/violin.png (100%) rename {app => vendor}/assets/images/emoji/virgo.png (100%) rename {app => vendor}/assets/images/emoji/volcano.png (100%) rename {app => vendor}/assets/images/emoji/vs.png (100%) rename {app => vendor}/assets/images/emoji/walking.png (100%) rename {app => vendor}/assets/images/emoji/waning_crescent_moon.png (100%) rename {app => vendor}/assets/images/emoji/waning_gibbous_moon.png (100%) rename {app => vendor}/assets/images/emoji/warning.png (100%) rename {app => vendor}/assets/images/emoji/watch.png (100%) rename {app => vendor}/assets/images/emoji/water_buffalo.png (100%) rename {app => vendor}/assets/images/emoji/watermelon.png (100%) rename {app => vendor}/assets/images/emoji/wave.png (100%) rename {app => vendor}/assets/images/emoji/wavy_dash.png (100%) rename {app => vendor}/assets/images/emoji/waxing_crescent_moon.png (100%) rename {app => vendor}/assets/images/emoji/waxing_gibbous_moon.png (100%) rename {app => vendor}/assets/images/emoji/wc.png (100%) rename {app => vendor}/assets/images/emoji/weary.png (100%) rename {app => vendor}/assets/images/emoji/wedding.png (100%) rename {app => vendor}/assets/images/emoji/whale.png (100%) rename {app => vendor}/assets/images/emoji/whale2.png (100%) rename {app => vendor}/assets/images/emoji/wheelchair.png (100%) rename {app => vendor}/assets/images/emoji/white_circle.png (100%) rename {app => vendor}/assets/images/emoji/white_flower.png (100%) rename {app => vendor}/assets/images/emoji/white_square.png (100%) rename {app => vendor}/assets/images/emoji/wind_chime.png (100%) rename {app => vendor}/assets/images/emoji/wine_glass.png (100%) rename {app => vendor}/assets/images/emoji/wink.png (100%) rename {app => vendor}/assets/images/emoji/wink2.png (100%) rename {app => vendor}/assets/images/emoji/wolf.png (100%) rename {app => vendor}/assets/images/emoji/woman.png (100%) rename {app => vendor}/assets/images/emoji/womans_clothes.png (100%) rename {app => vendor}/assets/images/emoji/womans_hat.png (100%) rename {app => vendor}/assets/images/emoji/womens.png (100%) rename {app => vendor}/assets/images/emoji/wrench.png (100%) rename {app => vendor}/assets/images/emoji/x.png (100%) rename {app => vendor}/assets/images/emoji/yellow_heart.png (100%) rename {app => vendor}/assets/images/emoji/yen.png (100%) rename {app => vendor}/assets/images/emoji/yum.png (100%) rename {app => vendor}/assets/images/emoji/zap.png (100%) rename {app => vendor}/assets/images/emoji/zero.png (100%) rename {app => vendor}/assets/images/emoji/zzz.png (100%) diff --git a/config/initializers/emoji.rb b/config/initializers/emoji.rb new file mode 100644 index 00000000..dbd2a4e2 --- /dev/null +++ b/config/initializers/emoji.rb @@ -0,0 +1,4 @@ +module Emoji + path = "#{Rails.root}/vendor/assets/images/emoji" + NAMES = Dir["#{path}/*.png"].sort.map {|f| File.basename(f, '.png')} +end diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 9eb35b84..ba993abf 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -128,7 +128,7 @@ module Gitlab # # Returns boolean def valid_emoji?(emoji) - File.exists?(Rails.root.join('app', 'assets', 'images', 'emoji', "#{emoji}.png")) + Emoji::NAMES.include? emoji end # Private: Dispatches to a dedicated processing method based on reference diff --git a/app/assets/images/emoji/+1.png b/vendor/assets/images/emoji/+1.png similarity index 100% rename from app/assets/images/emoji/+1.png rename to vendor/assets/images/emoji/+1.png diff --git a/app/assets/images/emoji/-1.png b/vendor/assets/images/emoji/-1.png similarity index 100% rename from app/assets/images/emoji/-1.png rename to vendor/assets/images/emoji/-1.png diff --git a/app/assets/images/emoji/100.png b/vendor/assets/images/emoji/100.png similarity index 100% rename from app/assets/images/emoji/100.png rename to vendor/assets/images/emoji/100.png diff --git a/app/assets/images/emoji/109.png b/vendor/assets/images/emoji/109.png similarity index 100% rename from app/assets/images/emoji/109.png rename to vendor/assets/images/emoji/109.png diff --git a/app/assets/images/emoji/1234.png b/vendor/assets/images/emoji/1234.png similarity index 100% rename from app/assets/images/emoji/1234.png rename to vendor/assets/images/emoji/1234.png diff --git a/app/assets/images/emoji/8ball.png b/vendor/assets/images/emoji/8ball.png similarity index 100% rename from app/assets/images/emoji/8ball.png rename to vendor/assets/images/emoji/8ball.png diff --git a/app/assets/images/emoji/a.png b/vendor/assets/images/emoji/a.png similarity index 100% rename from app/assets/images/emoji/a.png rename to vendor/assets/images/emoji/a.png diff --git a/app/assets/images/emoji/ab.png b/vendor/assets/images/emoji/ab.png similarity index 100% rename from app/assets/images/emoji/ab.png rename to vendor/assets/images/emoji/ab.png diff --git a/app/assets/images/emoji/abc.png b/vendor/assets/images/emoji/abc.png similarity index 100% rename from app/assets/images/emoji/abc.png rename to vendor/assets/images/emoji/abc.png diff --git a/app/assets/images/emoji/abcd.png b/vendor/assets/images/emoji/abcd.png similarity index 100% rename from app/assets/images/emoji/abcd.png rename to vendor/assets/images/emoji/abcd.png diff --git a/app/assets/images/emoji/accept.png b/vendor/assets/images/emoji/accept.png similarity index 100% rename from app/assets/images/emoji/accept.png rename to vendor/assets/images/emoji/accept.png diff --git a/app/assets/images/emoji/aerial_tramway.png b/vendor/assets/images/emoji/aerial_tramway.png similarity index 100% rename from app/assets/images/emoji/aerial_tramway.png rename to vendor/assets/images/emoji/aerial_tramway.png diff --git a/app/assets/images/emoji/airplane.png b/vendor/assets/images/emoji/airplane.png similarity index 100% rename from app/assets/images/emoji/airplane.png rename to vendor/assets/images/emoji/airplane.png diff --git a/app/assets/images/emoji/alarm_clock.png b/vendor/assets/images/emoji/alarm_clock.png similarity index 100% rename from app/assets/images/emoji/alarm_clock.png rename to vendor/assets/images/emoji/alarm_clock.png diff --git a/app/assets/images/emoji/alien.png b/vendor/assets/images/emoji/alien.png similarity index 100% rename from app/assets/images/emoji/alien.png rename to vendor/assets/images/emoji/alien.png diff --git a/app/assets/images/emoji/ambulance.png b/vendor/assets/images/emoji/ambulance.png similarity index 100% rename from app/assets/images/emoji/ambulance.png rename to vendor/assets/images/emoji/ambulance.png diff --git a/app/assets/images/emoji/anchor.png b/vendor/assets/images/emoji/anchor.png similarity index 100% rename from app/assets/images/emoji/anchor.png rename to vendor/assets/images/emoji/anchor.png diff --git a/app/assets/images/emoji/angel.png b/vendor/assets/images/emoji/angel.png similarity index 100% rename from app/assets/images/emoji/angel.png rename to vendor/assets/images/emoji/angel.png diff --git a/app/assets/images/emoji/anger.png b/vendor/assets/images/emoji/anger.png similarity index 100% rename from app/assets/images/emoji/anger.png rename to vendor/assets/images/emoji/anger.png diff --git a/app/assets/images/emoji/angry.png b/vendor/assets/images/emoji/angry.png similarity index 100% rename from app/assets/images/emoji/angry.png rename to vendor/assets/images/emoji/angry.png diff --git a/app/assets/images/emoji/ant.png b/vendor/assets/images/emoji/ant.png similarity index 100% rename from app/assets/images/emoji/ant.png rename to vendor/assets/images/emoji/ant.png diff --git a/app/assets/images/emoji/apple.png b/vendor/assets/images/emoji/apple.png similarity index 100% rename from app/assets/images/emoji/apple.png rename to vendor/assets/images/emoji/apple.png diff --git a/app/assets/images/emoji/aquarius.png b/vendor/assets/images/emoji/aquarius.png similarity index 100% rename from app/assets/images/emoji/aquarius.png rename to vendor/assets/images/emoji/aquarius.png diff --git a/app/assets/images/emoji/aries.png b/vendor/assets/images/emoji/aries.png similarity index 100% rename from app/assets/images/emoji/aries.png rename to vendor/assets/images/emoji/aries.png diff --git a/app/assets/images/emoji/arrow_backward.png b/vendor/assets/images/emoji/arrow_backward.png similarity index 100% rename from app/assets/images/emoji/arrow_backward.png rename to vendor/assets/images/emoji/arrow_backward.png diff --git a/app/assets/images/emoji/arrow_double_down.png b/vendor/assets/images/emoji/arrow_double_down.png similarity index 100% rename from app/assets/images/emoji/arrow_double_down.png rename to vendor/assets/images/emoji/arrow_double_down.png diff --git a/app/assets/images/emoji/arrow_double_up.png b/vendor/assets/images/emoji/arrow_double_up.png similarity index 100% rename from app/assets/images/emoji/arrow_double_up.png rename to vendor/assets/images/emoji/arrow_double_up.png diff --git a/app/assets/images/emoji/arrow_down.png b/vendor/assets/images/emoji/arrow_down.png similarity index 100% rename from app/assets/images/emoji/arrow_down.png rename to vendor/assets/images/emoji/arrow_down.png diff --git a/app/assets/images/emoji/arrow_down_small.png b/vendor/assets/images/emoji/arrow_down_small.png similarity index 100% rename from app/assets/images/emoji/arrow_down_small.png rename to vendor/assets/images/emoji/arrow_down_small.png diff --git a/app/assets/images/emoji/arrow_forward.png b/vendor/assets/images/emoji/arrow_forward.png similarity index 100% rename from app/assets/images/emoji/arrow_forward.png rename to vendor/assets/images/emoji/arrow_forward.png diff --git a/app/assets/images/emoji/arrow_heading_down.png b/vendor/assets/images/emoji/arrow_heading_down.png similarity index 100% rename from app/assets/images/emoji/arrow_heading_down.png rename to vendor/assets/images/emoji/arrow_heading_down.png diff --git a/app/assets/images/emoji/arrow_heading_up.png b/vendor/assets/images/emoji/arrow_heading_up.png similarity index 100% rename from app/assets/images/emoji/arrow_heading_up.png rename to vendor/assets/images/emoji/arrow_heading_up.png diff --git a/app/assets/images/emoji/arrow_left.png b/vendor/assets/images/emoji/arrow_left.png similarity index 100% rename from app/assets/images/emoji/arrow_left.png rename to vendor/assets/images/emoji/arrow_left.png diff --git a/app/assets/images/emoji/arrow_lower_left.png b/vendor/assets/images/emoji/arrow_lower_left.png similarity index 100% rename from app/assets/images/emoji/arrow_lower_left.png rename to vendor/assets/images/emoji/arrow_lower_left.png diff --git a/app/assets/images/emoji/arrow_lower_right.png b/vendor/assets/images/emoji/arrow_lower_right.png similarity index 100% rename from app/assets/images/emoji/arrow_lower_right.png rename to vendor/assets/images/emoji/arrow_lower_right.png diff --git a/app/assets/images/emoji/arrow_right.png b/vendor/assets/images/emoji/arrow_right.png similarity index 100% rename from app/assets/images/emoji/arrow_right.png rename to vendor/assets/images/emoji/arrow_right.png diff --git a/app/assets/images/emoji/arrow_right_hook.png b/vendor/assets/images/emoji/arrow_right_hook.png similarity index 100% rename from app/assets/images/emoji/arrow_right_hook.png rename to vendor/assets/images/emoji/arrow_right_hook.png diff --git a/app/assets/images/emoji/arrow_up.png b/vendor/assets/images/emoji/arrow_up.png similarity index 100% rename from app/assets/images/emoji/arrow_up.png rename to vendor/assets/images/emoji/arrow_up.png diff --git a/app/assets/images/emoji/arrow_up_down.png b/vendor/assets/images/emoji/arrow_up_down.png similarity index 100% rename from app/assets/images/emoji/arrow_up_down.png rename to vendor/assets/images/emoji/arrow_up_down.png diff --git a/app/assets/images/emoji/arrow_up_small.png b/vendor/assets/images/emoji/arrow_up_small.png similarity index 100% rename from app/assets/images/emoji/arrow_up_small.png rename to vendor/assets/images/emoji/arrow_up_small.png diff --git a/app/assets/images/emoji/arrow_upper_left.png b/vendor/assets/images/emoji/arrow_upper_left.png similarity index 100% rename from app/assets/images/emoji/arrow_upper_left.png rename to vendor/assets/images/emoji/arrow_upper_left.png diff --git a/app/assets/images/emoji/arrow_upper_right.png b/vendor/assets/images/emoji/arrow_upper_right.png similarity index 100% rename from app/assets/images/emoji/arrow_upper_right.png rename to vendor/assets/images/emoji/arrow_upper_right.png diff --git a/app/assets/images/emoji/arrows_clockwise.png b/vendor/assets/images/emoji/arrows_clockwise.png similarity index 100% rename from app/assets/images/emoji/arrows_clockwise.png rename to vendor/assets/images/emoji/arrows_clockwise.png diff --git a/app/assets/images/emoji/arrows_counterclockwise.png b/vendor/assets/images/emoji/arrows_counterclockwise.png similarity index 100% rename from app/assets/images/emoji/arrows_counterclockwise.png rename to vendor/assets/images/emoji/arrows_counterclockwise.png diff --git a/app/assets/images/emoji/art.png b/vendor/assets/images/emoji/art.png similarity index 100% rename from app/assets/images/emoji/art.png rename to vendor/assets/images/emoji/art.png diff --git a/app/assets/images/emoji/articulated_lorry.png b/vendor/assets/images/emoji/articulated_lorry.png similarity index 100% rename from app/assets/images/emoji/articulated_lorry.png rename to vendor/assets/images/emoji/articulated_lorry.png diff --git a/app/assets/images/emoji/astonished.png b/vendor/assets/images/emoji/astonished.png similarity index 100% rename from app/assets/images/emoji/astonished.png rename to vendor/assets/images/emoji/astonished.png diff --git a/app/assets/images/emoji/atm.png b/vendor/assets/images/emoji/atm.png similarity index 100% rename from app/assets/images/emoji/atm.png rename to vendor/assets/images/emoji/atm.png diff --git a/app/assets/images/emoji/b.png b/vendor/assets/images/emoji/b.png similarity index 100% rename from app/assets/images/emoji/b.png rename to vendor/assets/images/emoji/b.png diff --git a/app/assets/images/emoji/baby.png b/vendor/assets/images/emoji/baby.png similarity index 100% rename from app/assets/images/emoji/baby.png rename to vendor/assets/images/emoji/baby.png diff --git a/app/assets/images/emoji/baby_bottle.png b/vendor/assets/images/emoji/baby_bottle.png similarity index 100% rename from app/assets/images/emoji/baby_bottle.png rename to vendor/assets/images/emoji/baby_bottle.png diff --git a/app/assets/images/emoji/baby_chick.png b/vendor/assets/images/emoji/baby_chick.png similarity index 100% rename from app/assets/images/emoji/baby_chick.png rename to vendor/assets/images/emoji/baby_chick.png diff --git a/app/assets/images/emoji/baby_symbol.png b/vendor/assets/images/emoji/baby_symbol.png similarity index 100% rename from app/assets/images/emoji/baby_symbol.png rename to vendor/assets/images/emoji/baby_symbol.png diff --git a/app/assets/images/emoji/baggage_claim.png b/vendor/assets/images/emoji/baggage_claim.png similarity index 100% rename from app/assets/images/emoji/baggage_claim.png rename to vendor/assets/images/emoji/baggage_claim.png diff --git a/app/assets/images/emoji/balloon.png b/vendor/assets/images/emoji/balloon.png similarity index 100% rename from app/assets/images/emoji/balloon.png rename to vendor/assets/images/emoji/balloon.png diff --git a/app/assets/images/emoji/ballot_box_with_check.png b/vendor/assets/images/emoji/ballot_box_with_check.png similarity index 100% rename from app/assets/images/emoji/ballot_box_with_check.png rename to vendor/assets/images/emoji/ballot_box_with_check.png diff --git a/app/assets/images/emoji/bamboo.png b/vendor/assets/images/emoji/bamboo.png similarity index 100% rename from app/assets/images/emoji/bamboo.png rename to vendor/assets/images/emoji/bamboo.png diff --git a/app/assets/images/emoji/banana.png b/vendor/assets/images/emoji/banana.png similarity index 100% rename from app/assets/images/emoji/banana.png rename to vendor/assets/images/emoji/banana.png diff --git a/app/assets/images/emoji/bangbang.png b/vendor/assets/images/emoji/bangbang.png similarity index 100% rename from app/assets/images/emoji/bangbang.png rename to vendor/assets/images/emoji/bangbang.png diff --git a/app/assets/images/emoji/bank.png b/vendor/assets/images/emoji/bank.png similarity index 100% rename from app/assets/images/emoji/bank.png rename to vendor/assets/images/emoji/bank.png diff --git a/app/assets/images/emoji/bar_chart.png b/vendor/assets/images/emoji/bar_chart.png similarity index 100% rename from app/assets/images/emoji/bar_chart.png rename to vendor/assets/images/emoji/bar_chart.png diff --git a/app/assets/images/emoji/barber.png b/vendor/assets/images/emoji/barber.png similarity index 100% rename from app/assets/images/emoji/barber.png rename to vendor/assets/images/emoji/barber.png diff --git a/app/assets/images/emoji/baseball.png b/vendor/assets/images/emoji/baseball.png similarity index 100% rename from app/assets/images/emoji/baseball.png rename to vendor/assets/images/emoji/baseball.png diff --git a/app/assets/images/emoji/basketball.png b/vendor/assets/images/emoji/basketball.png similarity index 100% rename from app/assets/images/emoji/basketball.png rename to vendor/assets/images/emoji/basketball.png diff --git a/app/assets/images/emoji/bath.png b/vendor/assets/images/emoji/bath.png similarity index 100% rename from app/assets/images/emoji/bath.png rename to vendor/assets/images/emoji/bath.png diff --git a/app/assets/images/emoji/bathtub.png b/vendor/assets/images/emoji/bathtub.png similarity index 100% rename from app/assets/images/emoji/bathtub.png rename to vendor/assets/images/emoji/bathtub.png diff --git a/app/assets/images/emoji/battery.png b/vendor/assets/images/emoji/battery.png similarity index 100% rename from app/assets/images/emoji/battery.png rename to vendor/assets/images/emoji/battery.png diff --git a/app/assets/images/emoji/bear.png b/vendor/assets/images/emoji/bear.png similarity index 100% rename from app/assets/images/emoji/bear.png rename to vendor/assets/images/emoji/bear.png diff --git a/app/assets/images/emoji/beer.png b/vendor/assets/images/emoji/beer.png similarity index 100% rename from app/assets/images/emoji/beer.png rename to vendor/assets/images/emoji/beer.png diff --git a/app/assets/images/emoji/beers.png b/vendor/assets/images/emoji/beers.png similarity index 100% rename from app/assets/images/emoji/beers.png rename to vendor/assets/images/emoji/beers.png diff --git a/app/assets/images/emoji/beetle.png b/vendor/assets/images/emoji/beetle.png similarity index 100% rename from app/assets/images/emoji/beetle.png rename to vendor/assets/images/emoji/beetle.png diff --git a/app/assets/images/emoji/beginner.png b/vendor/assets/images/emoji/beginner.png similarity index 100% rename from app/assets/images/emoji/beginner.png rename to vendor/assets/images/emoji/beginner.png diff --git a/app/assets/images/emoji/bell.png b/vendor/assets/images/emoji/bell.png similarity index 100% rename from app/assets/images/emoji/bell.png rename to vendor/assets/images/emoji/bell.png diff --git a/app/assets/images/emoji/bento.png b/vendor/assets/images/emoji/bento.png similarity index 100% rename from app/assets/images/emoji/bento.png rename to vendor/assets/images/emoji/bento.png diff --git a/app/assets/images/emoji/bicyclist.png b/vendor/assets/images/emoji/bicyclist.png similarity index 100% rename from app/assets/images/emoji/bicyclist.png rename to vendor/assets/images/emoji/bicyclist.png diff --git a/app/assets/images/emoji/bike.png b/vendor/assets/images/emoji/bike.png similarity index 100% rename from app/assets/images/emoji/bike.png rename to vendor/assets/images/emoji/bike.png diff --git a/app/assets/images/emoji/bikini.png b/vendor/assets/images/emoji/bikini.png similarity index 100% rename from app/assets/images/emoji/bikini.png rename to vendor/assets/images/emoji/bikini.png diff --git a/app/assets/images/emoji/bird.png b/vendor/assets/images/emoji/bird.png similarity index 100% rename from app/assets/images/emoji/bird.png rename to vendor/assets/images/emoji/bird.png diff --git a/app/assets/images/emoji/birthday.png b/vendor/assets/images/emoji/birthday.png similarity index 100% rename from app/assets/images/emoji/birthday.png rename to vendor/assets/images/emoji/birthday.png diff --git a/app/assets/images/emoji/black_circle.png b/vendor/assets/images/emoji/black_circle.png similarity index 100% rename from app/assets/images/emoji/black_circle.png rename to vendor/assets/images/emoji/black_circle.png diff --git a/app/assets/images/emoji/black_joker.png b/vendor/assets/images/emoji/black_joker.png similarity index 100% rename from app/assets/images/emoji/black_joker.png rename to vendor/assets/images/emoji/black_joker.png diff --git a/app/assets/images/emoji/black_nib.png b/vendor/assets/images/emoji/black_nib.png similarity index 100% rename from app/assets/images/emoji/black_nib.png rename to vendor/assets/images/emoji/black_nib.png diff --git a/app/assets/images/emoji/black_square.png b/vendor/assets/images/emoji/black_square.png similarity index 100% rename from app/assets/images/emoji/black_square.png rename to vendor/assets/images/emoji/black_square.png diff --git a/app/assets/images/emoji/blossom.png b/vendor/assets/images/emoji/blossom.png similarity index 100% rename from app/assets/images/emoji/blossom.png rename to vendor/assets/images/emoji/blossom.png diff --git a/app/assets/images/emoji/blowfish.png b/vendor/assets/images/emoji/blowfish.png similarity index 100% rename from app/assets/images/emoji/blowfish.png rename to vendor/assets/images/emoji/blowfish.png diff --git a/app/assets/images/emoji/blue_book.png b/vendor/assets/images/emoji/blue_book.png similarity index 100% rename from app/assets/images/emoji/blue_book.png rename to vendor/assets/images/emoji/blue_book.png diff --git a/app/assets/images/emoji/blue_car.png b/vendor/assets/images/emoji/blue_car.png similarity index 100% rename from app/assets/images/emoji/blue_car.png rename to vendor/assets/images/emoji/blue_car.png diff --git a/app/assets/images/emoji/blue_heart.png b/vendor/assets/images/emoji/blue_heart.png similarity index 100% rename from app/assets/images/emoji/blue_heart.png rename to vendor/assets/images/emoji/blue_heart.png diff --git a/app/assets/images/emoji/blush.png b/vendor/assets/images/emoji/blush.png similarity index 100% rename from app/assets/images/emoji/blush.png rename to vendor/assets/images/emoji/blush.png diff --git a/app/assets/images/emoji/boar.png b/vendor/assets/images/emoji/boar.png similarity index 100% rename from app/assets/images/emoji/boar.png rename to vendor/assets/images/emoji/boar.png diff --git a/app/assets/images/emoji/boat.png b/vendor/assets/images/emoji/boat.png similarity index 100% rename from app/assets/images/emoji/boat.png rename to vendor/assets/images/emoji/boat.png diff --git a/app/assets/images/emoji/bomb.png b/vendor/assets/images/emoji/bomb.png similarity index 100% rename from app/assets/images/emoji/bomb.png rename to vendor/assets/images/emoji/bomb.png diff --git a/app/assets/images/emoji/book.png b/vendor/assets/images/emoji/book.png similarity index 100% rename from app/assets/images/emoji/book.png rename to vendor/assets/images/emoji/book.png diff --git a/app/assets/images/emoji/bookmark.png b/vendor/assets/images/emoji/bookmark.png similarity index 100% rename from app/assets/images/emoji/bookmark.png rename to vendor/assets/images/emoji/bookmark.png diff --git a/app/assets/images/emoji/bookmark_tabs.png b/vendor/assets/images/emoji/bookmark_tabs.png similarity index 100% rename from app/assets/images/emoji/bookmark_tabs.png rename to vendor/assets/images/emoji/bookmark_tabs.png diff --git a/app/assets/images/emoji/books.png b/vendor/assets/images/emoji/books.png similarity index 100% rename from app/assets/images/emoji/books.png rename to vendor/assets/images/emoji/books.png diff --git a/app/assets/images/emoji/boot.png b/vendor/assets/images/emoji/boot.png similarity index 100% rename from app/assets/images/emoji/boot.png rename to vendor/assets/images/emoji/boot.png diff --git a/app/assets/images/emoji/bouquet.png b/vendor/assets/images/emoji/bouquet.png similarity index 100% rename from app/assets/images/emoji/bouquet.png rename to vendor/assets/images/emoji/bouquet.png diff --git a/app/assets/images/emoji/bow.png b/vendor/assets/images/emoji/bow.png similarity index 100% rename from app/assets/images/emoji/bow.png rename to vendor/assets/images/emoji/bow.png diff --git a/app/assets/images/emoji/bowling.png b/vendor/assets/images/emoji/bowling.png similarity index 100% rename from app/assets/images/emoji/bowling.png rename to vendor/assets/images/emoji/bowling.png diff --git a/app/assets/images/emoji/bowtie.png b/vendor/assets/images/emoji/bowtie.png similarity index 100% rename from app/assets/images/emoji/bowtie.png rename to vendor/assets/images/emoji/bowtie.png diff --git a/app/assets/images/emoji/boy.png b/vendor/assets/images/emoji/boy.png similarity index 100% rename from app/assets/images/emoji/boy.png rename to vendor/assets/images/emoji/boy.png diff --git a/app/assets/images/emoji/bread.png b/vendor/assets/images/emoji/bread.png similarity index 100% rename from app/assets/images/emoji/bread.png rename to vendor/assets/images/emoji/bread.png diff --git a/app/assets/images/emoji/bride_with_veil.png b/vendor/assets/images/emoji/bride_with_veil.png similarity index 100% rename from app/assets/images/emoji/bride_with_veil.png rename to vendor/assets/images/emoji/bride_with_veil.png diff --git a/app/assets/images/emoji/bridge_at_night.png b/vendor/assets/images/emoji/bridge_at_night.png similarity index 100% rename from app/assets/images/emoji/bridge_at_night.png rename to vendor/assets/images/emoji/bridge_at_night.png diff --git a/app/assets/images/emoji/briefcase.png b/vendor/assets/images/emoji/briefcase.png similarity index 100% rename from app/assets/images/emoji/briefcase.png rename to vendor/assets/images/emoji/briefcase.png diff --git a/app/assets/images/emoji/broken_heart.png b/vendor/assets/images/emoji/broken_heart.png similarity index 100% rename from app/assets/images/emoji/broken_heart.png rename to vendor/assets/images/emoji/broken_heart.png diff --git a/app/assets/images/emoji/bug.png b/vendor/assets/images/emoji/bug.png similarity index 100% rename from app/assets/images/emoji/bug.png rename to vendor/assets/images/emoji/bug.png diff --git a/app/assets/images/emoji/bulb.png b/vendor/assets/images/emoji/bulb.png similarity index 100% rename from app/assets/images/emoji/bulb.png rename to vendor/assets/images/emoji/bulb.png diff --git a/app/assets/images/emoji/bullettrain_front.png b/vendor/assets/images/emoji/bullettrain_front.png similarity index 100% rename from app/assets/images/emoji/bullettrain_front.png rename to vendor/assets/images/emoji/bullettrain_front.png diff --git a/app/assets/images/emoji/bullettrain_side.png b/vendor/assets/images/emoji/bullettrain_side.png similarity index 100% rename from app/assets/images/emoji/bullettrain_side.png rename to vendor/assets/images/emoji/bullettrain_side.png diff --git a/app/assets/images/emoji/bus.png b/vendor/assets/images/emoji/bus.png similarity index 100% rename from app/assets/images/emoji/bus.png rename to vendor/assets/images/emoji/bus.png diff --git a/app/assets/images/emoji/busstop.png b/vendor/assets/images/emoji/busstop.png similarity index 100% rename from app/assets/images/emoji/busstop.png rename to vendor/assets/images/emoji/busstop.png diff --git a/app/assets/images/emoji/bust_in_silhouette.png b/vendor/assets/images/emoji/bust_in_silhouette.png similarity index 100% rename from app/assets/images/emoji/bust_in_silhouette.png rename to vendor/assets/images/emoji/bust_in_silhouette.png diff --git a/app/assets/images/emoji/busts_in_silhouette.png b/vendor/assets/images/emoji/busts_in_silhouette.png similarity index 100% rename from app/assets/images/emoji/busts_in_silhouette.png rename to vendor/assets/images/emoji/busts_in_silhouette.png diff --git a/app/assets/images/emoji/cactus.png b/vendor/assets/images/emoji/cactus.png similarity index 100% rename from app/assets/images/emoji/cactus.png rename to vendor/assets/images/emoji/cactus.png diff --git a/app/assets/images/emoji/cake.png b/vendor/assets/images/emoji/cake.png similarity index 100% rename from app/assets/images/emoji/cake.png rename to vendor/assets/images/emoji/cake.png diff --git a/app/assets/images/emoji/calendar.png b/vendor/assets/images/emoji/calendar.png similarity index 100% rename from app/assets/images/emoji/calendar.png rename to vendor/assets/images/emoji/calendar.png diff --git a/app/assets/images/emoji/calling.png b/vendor/assets/images/emoji/calling.png similarity index 100% rename from app/assets/images/emoji/calling.png rename to vendor/assets/images/emoji/calling.png diff --git a/app/assets/images/emoji/camel.png b/vendor/assets/images/emoji/camel.png similarity index 100% rename from app/assets/images/emoji/camel.png rename to vendor/assets/images/emoji/camel.png diff --git a/app/assets/images/emoji/camera.png b/vendor/assets/images/emoji/camera.png similarity index 100% rename from app/assets/images/emoji/camera.png rename to vendor/assets/images/emoji/camera.png diff --git a/app/assets/images/emoji/cancer.png b/vendor/assets/images/emoji/cancer.png similarity index 100% rename from app/assets/images/emoji/cancer.png rename to vendor/assets/images/emoji/cancer.png diff --git a/app/assets/images/emoji/candy.png b/vendor/assets/images/emoji/candy.png similarity index 100% rename from app/assets/images/emoji/candy.png rename to vendor/assets/images/emoji/candy.png diff --git a/app/assets/images/emoji/capital_abcd.png b/vendor/assets/images/emoji/capital_abcd.png similarity index 100% rename from app/assets/images/emoji/capital_abcd.png rename to vendor/assets/images/emoji/capital_abcd.png diff --git a/app/assets/images/emoji/capricorn.png b/vendor/assets/images/emoji/capricorn.png similarity index 100% rename from app/assets/images/emoji/capricorn.png rename to vendor/assets/images/emoji/capricorn.png diff --git a/app/assets/images/emoji/car.png b/vendor/assets/images/emoji/car.png similarity index 100% rename from app/assets/images/emoji/car.png rename to vendor/assets/images/emoji/car.png diff --git a/app/assets/images/emoji/card_index.png b/vendor/assets/images/emoji/card_index.png similarity index 100% rename from app/assets/images/emoji/card_index.png rename to vendor/assets/images/emoji/card_index.png diff --git a/app/assets/images/emoji/carousel_horse.png b/vendor/assets/images/emoji/carousel_horse.png similarity index 100% rename from app/assets/images/emoji/carousel_horse.png rename to vendor/assets/images/emoji/carousel_horse.png diff --git a/app/assets/images/emoji/cat.png b/vendor/assets/images/emoji/cat.png similarity index 100% rename from app/assets/images/emoji/cat.png rename to vendor/assets/images/emoji/cat.png diff --git a/app/assets/images/emoji/cat2.png b/vendor/assets/images/emoji/cat2.png similarity index 100% rename from app/assets/images/emoji/cat2.png rename to vendor/assets/images/emoji/cat2.png diff --git a/app/assets/images/emoji/cd.png b/vendor/assets/images/emoji/cd.png similarity index 100% rename from app/assets/images/emoji/cd.png rename to vendor/assets/images/emoji/cd.png diff --git a/app/assets/images/emoji/chart.png b/vendor/assets/images/emoji/chart.png similarity index 100% rename from app/assets/images/emoji/chart.png rename to vendor/assets/images/emoji/chart.png diff --git a/app/assets/images/emoji/chart_with_downwards_trend.png b/vendor/assets/images/emoji/chart_with_downwards_trend.png similarity index 100% rename from app/assets/images/emoji/chart_with_downwards_trend.png rename to vendor/assets/images/emoji/chart_with_downwards_trend.png diff --git a/app/assets/images/emoji/chart_with_upwards_trend.png b/vendor/assets/images/emoji/chart_with_upwards_trend.png similarity index 100% rename from app/assets/images/emoji/chart_with_upwards_trend.png rename to vendor/assets/images/emoji/chart_with_upwards_trend.png diff --git a/app/assets/images/emoji/checkered_flag.png b/vendor/assets/images/emoji/checkered_flag.png similarity index 100% rename from app/assets/images/emoji/checkered_flag.png rename to vendor/assets/images/emoji/checkered_flag.png diff --git a/app/assets/images/emoji/cherries.png b/vendor/assets/images/emoji/cherries.png similarity index 100% rename from app/assets/images/emoji/cherries.png rename to vendor/assets/images/emoji/cherries.png diff --git a/app/assets/images/emoji/cherry_blossom.png b/vendor/assets/images/emoji/cherry_blossom.png similarity index 100% rename from app/assets/images/emoji/cherry_blossom.png rename to vendor/assets/images/emoji/cherry_blossom.png diff --git a/app/assets/images/emoji/chestnut.png b/vendor/assets/images/emoji/chestnut.png similarity index 100% rename from app/assets/images/emoji/chestnut.png rename to vendor/assets/images/emoji/chestnut.png diff --git a/app/assets/images/emoji/chicken.png b/vendor/assets/images/emoji/chicken.png similarity index 100% rename from app/assets/images/emoji/chicken.png rename to vendor/assets/images/emoji/chicken.png diff --git a/app/assets/images/emoji/children_crossing.png b/vendor/assets/images/emoji/children_crossing.png similarity index 100% rename from app/assets/images/emoji/children_crossing.png rename to vendor/assets/images/emoji/children_crossing.png diff --git a/app/assets/images/emoji/chocolate_bar.png b/vendor/assets/images/emoji/chocolate_bar.png similarity index 100% rename from app/assets/images/emoji/chocolate_bar.png rename to vendor/assets/images/emoji/chocolate_bar.png diff --git a/app/assets/images/emoji/christmas_tree.png b/vendor/assets/images/emoji/christmas_tree.png similarity index 100% rename from app/assets/images/emoji/christmas_tree.png rename to vendor/assets/images/emoji/christmas_tree.png diff --git a/app/assets/images/emoji/church.png b/vendor/assets/images/emoji/church.png similarity index 100% rename from app/assets/images/emoji/church.png rename to vendor/assets/images/emoji/church.png diff --git a/app/assets/images/emoji/cinema.png b/vendor/assets/images/emoji/cinema.png similarity index 100% rename from app/assets/images/emoji/cinema.png rename to vendor/assets/images/emoji/cinema.png diff --git a/app/assets/images/emoji/circus_tent.png b/vendor/assets/images/emoji/circus_tent.png similarity index 100% rename from app/assets/images/emoji/circus_tent.png rename to vendor/assets/images/emoji/circus_tent.png diff --git a/app/assets/images/emoji/city_sunrise.png b/vendor/assets/images/emoji/city_sunrise.png similarity index 100% rename from app/assets/images/emoji/city_sunrise.png rename to vendor/assets/images/emoji/city_sunrise.png diff --git a/app/assets/images/emoji/city_sunset.png b/vendor/assets/images/emoji/city_sunset.png similarity index 100% rename from app/assets/images/emoji/city_sunset.png rename to vendor/assets/images/emoji/city_sunset.png diff --git a/app/assets/images/emoji/cl.png b/vendor/assets/images/emoji/cl.png similarity index 100% rename from app/assets/images/emoji/cl.png rename to vendor/assets/images/emoji/cl.png diff --git a/app/assets/images/emoji/clap.png b/vendor/assets/images/emoji/clap.png similarity index 100% rename from app/assets/images/emoji/clap.png rename to vendor/assets/images/emoji/clap.png diff --git a/app/assets/images/emoji/clapper.png b/vendor/assets/images/emoji/clapper.png similarity index 100% rename from app/assets/images/emoji/clapper.png rename to vendor/assets/images/emoji/clapper.png diff --git a/app/assets/images/emoji/clipboard.png b/vendor/assets/images/emoji/clipboard.png similarity index 100% rename from app/assets/images/emoji/clipboard.png rename to vendor/assets/images/emoji/clipboard.png diff --git a/app/assets/images/emoji/clock1.png b/vendor/assets/images/emoji/clock1.png similarity index 100% rename from app/assets/images/emoji/clock1.png rename to vendor/assets/images/emoji/clock1.png diff --git a/app/assets/images/emoji/clock10.png b/vendor/assets/images/emoji/clock10.png similarity index 100% rename from app/assets/images/emoji/clock10.png rename to vendor/assets/images/emoji/clock10.png diff --git a/app/assets/images/emoji/clock1030.png b/vendor/assets/images/emoji/clock1030.png similarity index 100% rename from app/assets/images/emoji/clock1030.png rename to vendor/assets/images/emoji/clock1030.png diff --git a/app/assets/images/emoji/clock11.png b/vendor/assets/images/emoji/clock11.png similarity index 100% rename from app/assets/images/emoji/clock11.png rename to vendor/assets/images/emoji/clock11.png diff --git a/app/assets/images/emoji/clock1130.png b/vendor/assets/images/emoji/clock1130.png similarity index 100% rename from app/assets/images/emoji/clock1130.png rename to vendor/assets/images/emoji/clock1130.png diff --git a/app/assets/images/emoji/clock12.png b/vendor/assets/images/emoji/clock12.png similarity index 100% rename from app/assets/images/emoji/clock12.png rename to vendor/assets/images/emoji/clock12.png diff --git a/app/assets/images/emoji/clock1230.png b/vendor/assets/images/emoji/clock1230.png similarity index 100% rename from app/assets/images/emoji/clock1230.png rename to vendor/assets/images/emoji/clock1230.png diff --git a/app/assets/images/emoji/clock130.png b/vendor/assets/images/emoji/clock130.png similarity index 100% rename from app/assets/images/emoji/clock130.png rename to vendor/assets/images/emoji/clock130.png diff --git a/app/assets/images/emoji/clock2.png b/vendor/assets/images/emoji/clock2.png similarity index 100% rename from app/assets/images/emoji/clock2.png rename to vendor/assets/images/emoji/clock2.png diff --git a/app/assets/images/emoji/clock230.png b/vendor/assets/images/emoji/clock230.png similarity index 100% rename from app/assets/images/emoji/clock230.png rename to vendor/assets/images/emoji/clock230.png diff --git a/app/assets/images/emoji/clock3.png b/vendor/assets/images/emoji/clock3.png similarity index 100% rename from app/assets/images/emoji/clock3.png rename to vendor/assets/images/emoji/clock3.png diff --git a/app/assets/images/emoji/clock330.png b/vendor/assets/images/emoji/clock330.png similarity index 100% rename from app/assets/images/emoji/clock330.png rename to vendor/assets/images/emoji/clock330.png diff --git a/app/assets/images/emoji/clock4.png b/vendor/assets/images/emoji/clock4.png similarity index 100% rename from app/assets/images/emoji/clock4.png rename to vendor/assets/images/emoji/clock4.png diff --git a/app/assets/images/emoji/clock430.png b/vendor/assets/images/emoji/clock430.png similarity index 100% rename from app/assets/images/emoji/clock430.png rename to vendor/assets/images/emoji/clock430.png diff --git a/app/assets/images/emoji/clock5.png b/vendor/assets/images/emoji/clock5.png similarity index 100% rename from app/assets/images/emoji/clock5.png rename to vendor/assets/images/emoji/clock5.png diff --git a/app/assets/images/emoji/clock530.png b/vendor/assets/images/emoji/clock530.png similarity index 100% rename from app/assets/images/emoji/clock530.png rename to vendor/assets/images/emoji/clock530.png diff --git a/app/assets/images/emoji/clock6.png b/vendor/assets/images/emoji/clock6.png similarity index 100% rename from app/assets/images/emoji/clock6.png rename to vendor/assets/images/emoji/clock6.png diff --git a/app/assets/images/emoji/clock630.png b/vendor/assets/images/emoji/clock630.png similarity index 100% rename from app/assets/images/emoji/clock630.png rename to vendor/assets/images/emoji/clock630.png diff --git a/app/assets/images/emoji/clock7.png b/vendor/assets/images/emoji/clock7.png similarity index 100% rename from app/assets/images/emoji/clock7.png rename to vendor/assets/images/emoji/clock7.png diff --git a/app/assets/images/emoji/clock730.png b/vendor/assets/images/emoji/clock730.png similarity index 100% rename from app/assets/images/emoji/clock730.png rename to vendor/assets/images/emoji/clock730.png diff --git a/app/assets/images/emoji/clock8.png b/vendor/assets/images/emoji/clock8.png similarity index 100% rename from app/assets/images/emoji/clock8.png rename to vendor/assets/images/emoji/clock8.png diff --git a/app/assets/images/emoji/clock830.png b/vendor/assets/images/emoji/clock830.png similarity index 100% rename from app/assets/images/emoji/clock830.png rename to vendor/assets/images/emoji/clock830.png diff --git a/app/assets/images/emoji/clock9.png b/vendor/assets/images/emoji/clock9.png similarity index 100% rename from app/assets/images/emoji/clock9.png rename to vendor/assets/images/emoji/clock9.png diff --git a/app/assets/images/emoji/clock930.png b/vendor/assets/images/emoji/clock930.png similarity index 100% rename from app/assets/images/emoji/clock930.png rename to vendor/assets/images/emoji/clock930.png diff --git a/app/assets/images/emoji/closed_book.png b/vendor/assets/images/emoji/closed_book.png similarity index 100% rename from app/assets/images/emoji/closed_book.png rename to vendor/assets/images/emoji/closed_book.png diff --git a/app/assets/images/emoji/closed_lock_with_key.png b/vendor/assets/images/emoji/closed_lock_with_key.png similarity index 100% rename from app/assets/images/emoji/closed_lock_with_key.png rename to vendor/assets/images/emoji/closed_lock_with_key.png diff --git a/app/assets/images/emoji/closed_umbrella.png b/vendor/assets/images/emoji/closed_umbrella.png similarity index 100% rename from app/assets/images/emoji/closed_umbrella.png rename to vendor/assets/images/emoji/closed_umbrella.png diff --git a/app/assets/images/emoji/cloud.png b/vendor/assets/images/emoji/cloud.png similarity index 100% rename from app/assets/images/emoji/cloud.png rename to vendor/assets/images/emoji/cloud.png diff --git a/app/assets/images/emoji/clubs.png b/vendor/assets/images/emoji/clubs.png similarity index 100% rename from app/assets/images/emoji/clubs.png rename to vendor/assets/images/emoji/clubs.png diff --git a/app/assets/images/emoji/cn.png b/vendor/assets/images/emoji/cn.png similarity index 100% rename from app/assets/images/emoji/cn.png rename to vendor/assets/images/emoji/cn.png diff --git a/app/assets/images/emoji/cocktail.png b/vendor/assets/images/emoji/cocktail.png similarity index 100% rename from app/assets/images/emoji/cocktail.png rename to vendor/assets/images/emoji/cocktail.png diff --git a/app/assets/images/emoji/coffee.png b/vendor/assets/images/emoji/coffee.png similarity index 100% rename from app/assets/images/emoji/coffee.png rename to vendor/assets/images/emoji/coffee.png diff --git a/app/assets/images/emoji/cold_sweat.png b/vendor/assets/images/emoji/cold_sweat.png similarity index 100% rename from app/assets/images/emoji/cold_sweat.png rename to vendor/assets/images/emoji/cold_sweat.png diff --git a/app/assets/images/emoji/collision.png b/vendor/assets/images/emoji/collision.png similarity index 100% rename from app/assets/images/emoji/collision.png rename to vendor/assets/images/emoji/collision.png diff --git a/app/assets/images/emoji/computer.png b/vendor/assets/images/emoji/computer.png similarity index 100% rename from app/assets/images/emoji/computer.png rename to vendor/assets/images/emoji/computer.png diff --git a/app/assets/images/emoji/confetti_ball.png b/vendor/assets/images/emoji/confetti_ball.png similarity index 100% rename from app/assets/images/emoji/confetti_ball.png rename to vendor/assets/images/emoji/confetti_ball.png diff --git a/app/assets/images/emoji/confounded.png b/vendor/assets/images/emoji/confounded.png similarity index 100% rename from app/assets/images/emoji/confounded.png rename to vendor/assets/images/emoji/confounded.png diff --git a/app/assets/images/emoji/congratulations.png b/vendor/assets/images/emoji/congratulations.png similarity index 100% rename from app/assets/images/emoji/congratulations.png rename to vendor/assets/images/emoji/congratulations.png diff --git a/app/assets/images/emoji/construction.png b/vendor/assets/images/emoji/construction.png similarity index 100% rename from app/assets/images/emoji/construction.png rename to vendor/assets/images/emoji/construction.png diff --git a/app/assets/images/emoji/construction_worker.png b/vendor/assets/images/emoji/construction_worker.png similarity index 100% rename from app/assets/images/emoji/construction_worker.png rename to vendor/assets/images/emoji/construction_worker.png diff --git a/app/assets/images/emoji/convenience_store.png b/vendor/assets/images/emoji/convenience_store.png similarity index 100% rename from app/assets/images/emoji/convenience_store.png rename to vendor/assets/images/emoji/convenience_store.png diff --git a/app/assets/images/emoji/cookie.png b/vendor/assets/images/emoji/cookie.png similarity index 100% rename from app/assets/images/emoji/cookie.png rename to vendor/assets/images/emoji/cookie.png diff --git a/app/assets/images/emoji/cool.png b/vendor/assets/images/emoji/cool.png similarity index 100% rename from app/assets/images/emoji/cool.png rename to vendor/assets/images/emoji/cool.png diff --git a/app/assets/images/emoji/cop.png b/vendor/assets/images/emoji/cop.png similarity index 100% rename from app/assets/images/emoji/cop.png rename to vendor/assets/images/emoji/cop.png diff --git a/app/assets/images/emoji/copyright.png b/vendor/assets/images/emoji/copyright.png similarity index 100% rename from app/assets/images/emoji/copyright.png rename to vendor/assets/images/emoji/copyright.png diff --git a/app/assets/images/emoji/corn.png b/vendor/assets/images/emoji/corn.png similarity index 100% rename from app/assets/images/emoji/corn.png rename to vendor/assets/images/emoji/corn.png diff --git a/app/assets/images/emoji/couple.png b/vendor/assets/images/emoji/couple.png similarity index 100% rename from app/assets/images/emoji/couple.png rename to vendor/assets/images/emoji/couple.png diff --git a/app/assets/images/emoji/couple_with_heart.png b/vendor/assets/images/emoji/couple_with_heart.png similarity index 100% rename from app/assets/images/emoji/couple_with_heart.png rename to vendor/assets/images/emoji/couple_with_heart.png diff --git a/app/assets/images/emoji/couplekiss.png b/vendor/assets/images/emoji/couplekiss.png similarity index 100% rename from app/assets/images/emoji/couplekiss.png rename to vendor/assets/images/emoji/couplekiss.png diff --git a/app/assets/images/emoji/cow.png b/vendor/assets/images/emoji/cow.png similarity index 100% rename from app/assets/images/emoji/cow.png rename to vendor/assets/images/emoji/cow.png diff --git a/app/assets/images/emoji/cow2.png b/vendor/assets/images/emoji/cow2.png similarity index 100% rename from app/assets/images/emoji/cow2.png rename to vendor/assets/images/emoji/cow2.png diff --git a/app/assets/images/emoji/credit_card.png b/vendor/assets/images/emoji/credit_card.png similarity index 100% rename from app/assets/images/emoji/credit_card.png rename to vendor/assets/images/emoji/credit_card.png diff --git a/app/assets/images/emoji/crocodile.png b/vendor/assets/images/emoji/crocodile.png similarity index 100% rename from app/assets/images/emoji/crocodile.png rename to vendor/assets/images/emoji/crocodile.png diff --git a/app/assets/images/emoji/crossed_flags.png b/vendor/assets/images/emoji/crossed_flags.png similarity index 100% rename from app/assets/images/emoji/crossed_flags.png rename to vendor/assets/images/emoji/crossed_flags.png diff --git a/app/assets/images/emoji/crown.png b/vendor/assets/images/emoji/crown.png similarity index 100% rename from app/assets/images/emoji/crown.png rename to vendor/assets/images/emoji/crown.png diff --git a/app/assets/images/emoji/cry.png b/vendor/assets/images/emoji/cry.png similarity index 100% rename from app/assets/images/emoji/cry.png rename to vendor/assets/images/emoji/cry.png diff --git a/app/assets/images/emoji/crying_cat_face.png b/vendor/assets/images/emoji/crying_cat_face.png similarity index 100% rename from app/assets/images/emoji/crying_cat_face.png rename to vendor/assets/images/emoji/crying_cat_face.png diff --git a/app/assets/images/emoji/crystal_ball.png b/vendor/assets/images/emoji/crystal_ball.png similarity index 100% rename from app/assets/images/emoji/crystal_ball.png rename to vendor/assets/images/emoji/crystal_ball.png diff --git a/app/assets/images/emoji/cupid.png b/vendor/assets/images/emoji/cupid.png similarity index 100% rename from app/assets/images/emoji/cupid.png rename to vendor/assets/images/emoji/cupid.png diff --git a/app/assets/images/emoji/curly_loop.png b/vendor/assets/images/emoji/curly_loop.png similarity index 100% rename from app/assets/images/emoji/curly_loop.png rename to vendor/assets/images/emoji/curly_loop.png diff --git a/app/assets/images/emoji/currency_exchange.png b/vendor/assets/images/emoji/currency_exchange.png similarity index 100% rename from app/assets/images/emoji/currency_exchange.png rename to vendor/assets/images/emoji/currency_exchange.png diff --git a/app/assets/images/emoji/curry.png b/vendor/assets/images/emoji/curry.png similarity index 100% rename from app/assets/images/emoji/curry.png rename to vendor/assets/images/emoji/curry.png diff --git a/app/assets/images/emoji/custard.png b/vendor/assets/images/emoji/custard.png similarity index 100% rename from app/assets/images/emoji/custard.png rename to vendor/assets/images/emoji/custard.png diff --git a/app/assets/images/emoji/customs.png b/vendor/assets/images/emoji/customs.png similarity index 100% rename from app/assets/images/emoji/customs.png rename to vendor/assets/images/emoji/customs.png diff --git a/app/assets/images/emoji/cyclone.png b/vendor/assets/images/emoji/cyclone.png similarity index 100% rename from app/assets/images/emoji/cyclone.png rename to vendor/assets/images/emoji/cyclone.png diff --git a/app/assets/images/emoji/dancer.png b/vendor/assets/images/emoji/dancer.png similarity index 100% rename from app/assets/images/emoji/dancer.png rename to vendor/assets/images/emoji/dancer.png diff --git a/app/assets/images/emoji/dancers.png b/vendor/assets/images/emoji/dancers.png similarity index 100% rename from app/assets/images/emoji/dancers.png rename to vendor/assets/images/emoji/dancers.png diff --git a/app/assets/images/emoji/dango.png b/vendor/assets/images/emoji/dango.png similarity index 100% rename from app/assets/images/emoji/dango.png rename to vendor/assets/images/emoji/dango.png diff --git a/app/assets/images/emoji/dart.png b/vendor/assets/images/emoji/dart.png similarity index 100% rename from app/assets/images/emoji/dart.png rename to vendor/assets/images/emoji/dart.png diff --git a/app/assets/images/emoji/dash.png b/vendor/assets/images/emoji/dash.png similarity index 100% rename from app/assets/images/emoji/dash.png rename to vendor/assets/images/emoji/dash.png diff --git a/app/assets/images/emoji/date.png b/vendor/assets/images/emoji/date.png similarity index 100% rename from app/assets/images/emoji/date.png rename to vendor/assets/images/emoji/date.png diff --git a/app/assets/images/emoji/de.png b/vendor/assets/images/emoji/de.png similarity index 100% rename from app/assets/images/emoji/de.png rename to vendor/assets/images/emoji/de.png diff --git a/app/assets/images/emoji/deciduous_tree.png b/vendor/assets/images/emoji/deciduous_tree.png similarity index 100% rename from app/assets/images/emoji/deciduous_tree.png rename to vendor/assets/images/emoji/deciduous_tree.png diff --git a/app/assets/images/emoji/department_store.png b/vendor/assets/images/emoji/department_store.png similarity index 100% rename from app/assets/images/emoji/department_store.png rename to vendor/assets/images/emoji/department_store.png diff --git a/app/assets/images/emoji/diamond_shape_with_a_dot_inside.png b/vendor/assets/images/emoji/diamond_shape_with_a_dot_inside.png similarity index 100% rename from app/assets/images/emoji/diamond_shape_with_a_dot_inside.png rename to vendor/assets/images/emoji/diamond_shape_with_a_dot_inside.png diff --git a/app/assets/images/emoji/diamonds.png b/vendor/assets/images/emoji/diamonds.png similarity index 100% rename from app/assets/images/emoji/diamonds.png rename to vendor/assets/images/emoji/diamonds.png diff --git a/app/assets/images/emoji/disappointed.png b/vendor/assets/images/emoji/disappointed.png similarity index 100% rename from app/assets/images/emoji/disappointed.png rename to vendor/assets/images/emoji/disappointed.png diff --git a/app/assets/images/emoji/dizzy.png b/vendor/assets/images/emoji/dizzy.png similarity index 100% rename from app/assets/images/emoji/dizzy.png rename to vendor/assets/images/emoji/dizzy.png diff --git a/app/assets/images/emoji/dizzy_face.png b/vendor/assets/images/emoji/dizzy_face.png similarity index 100% rename from app/assets/images/emoji/dizzy_face.png rename to vendor/assets/images/emoji/dizzy_face.png diff --git a/app/assets/images/emoji/do_not_litter.png b/vendor/assets/images/emoji/do_not_litter.png similarity index 100% rename from app/assets/images/emoji/do_not_litter.png rename to vendor/assets/images/emoji/do_not_litter.png diff --git a/app/assets/images/emoji/dog.png b/vendor/assets/images/emoji/dog.png similarity index 100% rename from app/assets/images/emoji/dog.png rename to vendor/assets/images/emoji/dog.png diff --git a/app/assets/images/emoji/dog2.png b/vendor/assets/images/emoji/dog2.png similarity index 100% rename from app/assets/images/emoji/dog2.png rename to vendor/assets/images/emoji/dog2.png diff --git a/app/assets/images/emoji/dollar.png b/vendor/assets/images/emoji/dollar.png similarity index 100% rename from app/assets/images/emoji/dollar.png rename to vendor/assets/images/emoji/dollar.png diff --git a/app/assets/images/emoji/dolls.png b/vendor/assets/images/emoji/dolls.png similarity index 100% rename from app/assets/images/emoji/dolls.png rename to vendor/assets/images/emoji/dolls.png diff --git a/app/assets/images/emoji/dolphin.png b/vendor/assets/images/emoji/dolphin.png similarity index 100% rename from app/assets/images/emoji/dolphin.png rename to vendor/assets/images/emoji/dolphin.png diff --git a/app/assets/images/emoji/door.png b/vendor/assets/images/emoji/door.png similarity index 100% rename from app/assets/images/emoji/door.png rename to vendor/assets/images/emoji/door.png diff --git a/app/assets/images/emoji/doughnut.png b/vendor/assets/images/emoji/doughnut.png similarity index 100% rename from app/assets/images/emoji/doughnut.png rename to vendor/assets/images/emoji/doughnut.png diff --git a/app/assets/images/emoji/dragon.png b/vendor/assets/images/emoji/dragon.png similarity index 100% rename from app/assets/images/emoji/dragon.png rename to vendor/assets/images/emoji/dragon.png diff --git a/app/assets/images/emoji/dragon_face.png b/vendor/assets/images/emoji/dragon_face.png similarity index 100% rename from app/assets/images/emoji/dragon_face.png rename to vendor/assets/images/emoji/dragon_face.png diff --git a/app/assets/images/emoji/dress.png b/vendor/assets/images/emoji/dress.png similarity index 100% rename from app/assets/images/emoji/dress.png rename to vendor/assets/images/emoji/dress.png diff --git a/app/assets/images/emoji/dromedary_camel.png b/vendor/assets/images/emoji/dromedary_camel.png similarity index 100% rename from app/assets/images/emoji/dromedary_camel.png rename to vendor/assets/images/emoji/dromedary_camel.png diff --git a/app/assets/images/emoji/droplet.png b/vendor/assets/images/emoji/droplet.png similarity index 100% rename from app/assets/images/emoji/droplet.png rename to vendor/assets/images/emoji/droplet.png diff --git a/app/assets/images/emoji/dvd.png b/vendor/assets/images/emoji/dvd.png similarity index 100% rename from app/assets/images/emoji/dvd.png rename to vendor/assets/images/emoji/dvd.png diff --git a/app/assets/images/emoji/e-mail.png b/vendor/assets/images/emoji/e-mail.png similarity index 100% rename from app/assets/images/emoji/e-mail.png rename to vendor/assets/images/emoji/e-mail.png diff --git a/app/assets/images/emoji/ear.png b/vendor/assets/images/emoji/ear.png similarity index 100% rename from app/assets/images/emoji/ear.png rename to vendor/assets/images/emoji/ear.png diff --git a/app/assets/images/emoji/ear_of_rice.png b/vendor/assets/images/emoji/ear_of_rice.png similarity index 100% rename from app/assets/images/emoji/ear_of_rice.png rename to vendor/assets/images/emoji/ear_of_rice.png diff --git a/app/assets/images/emoji/earth_africa.png b/vendor/assets/images/emoji/earth_africa.png similarity index 100% rename from app/assets/images/emoji/earth_africa.png rename to vendor/assets/images/emoji/earth_africa.png diff --git a/app/assets/images/emoji/earth_americas.png b/vendor/assets/images/emoji/earth_americas.png similarity index 100% rename from app/assets/images/emoji/earth_americas.png rename to vendor/assets/images/emoji/earth_americas.png diff --git a/app/assets/images/emoji/earth_asia.png b/vendor/assets/images/emoji/earth_asia.png similarity index 100% rename from app/assets/images/emoji/earth_asia.png rename to vendor/assets/images/emoji/earth_asia.png diff --git a/app/assets/images/emoji/egg.png b/vendor/assets/images/emoji/egg.png similarity index 100% rename from app/assets/images/emoji/egg.png rename to vendor/assets/images/emoji/egg.png diff --git a/app/assets/images/emoji/eggplant.png b/vendor/assets/images/emoji/eggplant.png similarity index 100% rename from app/assets/images/emoji/eggplant.png rename to vendor/assets/images/emoji/eggplant.png diff --git a/app/assets/images/emoji/eight.png b/vendor/assets/images/emoji/eight.png similarity index 100% rename from app/assets/images/emoji/eight.png rename to vendor/assets/images/emoji/eight.png diff --git a/app/assets/images/emoji/eight_pointed_black_star.png b/vendor/assets/images/emoji/eight_pointed_black_star.png similarity index 100% rename from app/assets/images/emoji/eight_pointed_black_star.png rename to vendor/assets/images/emoji/eight_pointed_black_star.png diff --git a/app/assets/images/emoji/eight_spoked_asterisk.png b/vendor/assets/images/emoji/eight_spoked_asterisk.png similarity index 100% rename from app/assets/images/emoji/eight_spoked_asterisk.png rename to vendor/assets/images/emoji/eight_spoked_asterisk.png diff --git a/app/assets/images/emoji/electric_plug.png b/vendor/assets/images/emoji/electric_plug.png similarity index 100% rename from app/assets/images/emoji/electric_plug.png rename to vendor/assets/images/emoji/electric_plug.png diff --git a/app/assets/images/emoji/elephant.png b/vendor/assets/images/emoji/elephant.png similarity index 100% rename from app/assets/images/emoji/elephant.png rename to vendor/assets/images/emoji/elephant.png diff --git a/app/assets/images/emoji/email.png b/vendor/assets/images/emoji/email.png similarity index 100% rename from app/assets/images/emoji/email.png rename to vendor/assets/images/emoji/email.png diff --git a/app/assets/images/emoji/end.png b/vendor/assets/images/emoji/end.png similarity index 100% rename from app/assets/images/emoji/end.png rename to vendor/assets/images/emoji/end.png diff --git a/app/assets/images/emoji/envelope.png b/vendor/assets/images/emoji/envelope.png similarity index 100% rename from app/assets/images/emoji/envelope.png rename to vendor/assets/images/emoji/envelope.png diff --git a/app/assets/images/emoji/es.png b/vendor/assets/images/emoji/es.png similarity index 100% rename from app/assets/images/emoji/es.png rename to vendor/assets/images/emoji/es.png diff --git a/app/assets/images/emoji/euro.png b/vendor/assets/images/emoji/euro.png similarity index 100% rename from app/assets/images/emoji/euro.png rename to vendor/assets/images/emoji/euro.png diff --git a/app/assets/images/emoji/european_castle.png b/vendor/assets/images/emoji/european_castle.png similarity index 100% rename from app/assets/images/emoji/european_castle.png rename to vendor/assets/images/emoji/european_castle.png diff --git a/app/assets/images/emoji/european_post_office.png b/vendor/assets/images/emoji/european_post_office.png similarity index 100% rename from app/assets/images/emoji/european_post_office.png rename to vendor/assets/images/emoji/european_post_office.png diff --git a/app/assets/images/emoji/evergreen_tree.png b/vendor/assets/images/emoji/evergreen_tree.png similarity index 100% rename from app/assets/images/emoji/evergreen_tree.png rename to vendor/assets/images/emoji/evergreen_tree.png diff --git a/app/assets/images/emoji/exclamation.png b/vendor/assets/images/emoji/exclamation.png similarity index 100% rename from app/assets/images/emoji/exclamation.png rename to vendor/assets/images/emoji/exclamation.png diff --git a/app/assets/images/emoji/eyeglasses.png b/vendor/assets/images/emoji/eyeglasses.png similarity index 100% rename from app/assets/images/emoji/eyeglasses.png rename to vendor/assets/images/emoji/eyeglasses.png diff --git a/app/assets/images/emoji/eyes.png b/vendor/assets/images/emoji/eyes.png similarity index 100% rename from app/assets/images/emoji/eyes.png rename to vendor/assets/images/emoji/eyes.png diff --git a/app/assets/images/emoji/facepunch.png b/vendor/assets/images/emoji/facepunch.png similarity index 100% rename from app/assets/images/emoji/facepunch.png rename to vendor/assets/images/emoji/facepunch.png diff --git a/app/assets/images/emoji/factory.png b/vendor/assets/images/emoji/factory.png similarity index 100% rename from app/assets/images/emoji/factory.png rename to vendor/assets/images/emoji/factory.png diff --git a/app/assets/images/emoji/fallen_leaf.png b/vendor/assets/images/emoji/fallen_leaf.png similarity index 100% rename from app/assets/images/emoji/fallen_leaf.png rename to vendor/assets/images/emoji/fallen_leaf.png diff --git a/app/assets/images/emoji/family.png b/vendor/assets/images/emoji/family.png similarity index 100% rename from app/assets/images/emoji/family.png rename to vendor/assets/images/emoji/family.png diff --git a/app/assets/images/emoji/fast_forward.png b/vendor/assets/images/emoji/fast_forward.png similarity index 100% rename from app/assets/images/emoji/fast_forward.png rename to vendor/assets/images/emoji/fast_forward.png diff --git a/app/assets/images/emoji/fax.png b/vendor/assets/images/emoji/fax.png similarity index 100% rename from app/assets/images/emoji/fax.png rename to vendor/assets/images/emoji/fax.png diff --git a/app/assets/images/emoji/fearful.png b/vendor/assets/images/emoji/fearful.png similarity index 100% rename from app/assets/images/emoji/fearful.png rename to vendor/assets/images/emoji/fearful.png diff --git a/app/assets/images/emoji/feelsgood.png b/vendor/assets/images/emoji/feelsgood.png similarity index 100% rename from app/assets/images/emoji/feelsgood.png rename to vendor/assets/images/emoji/feelsgood.png diff --git a/app/assets/images/emoji/feet.png b/vendor/assets/images/emoji/feet.png similarity index 100% rename from app/assets/images/emoji/feet.png rename to vendor/assets/images/emoji/feet.png diff --git a/app/assets/images/emoji/ferris_wheel.png b/vendor/assets/images/emoji/ferris_wheel.png similarity index 100% rename from app/assets/images/emoji/ferris_wheel.png rename to vendor/assets/images/emoji/ferris_wheel.png diff --git a/app/assets/images/emoji/file_folder.png b/vendor/assets/images/emoji/file_folder.png similarity index 100% rename from app/assets/images/emoji/file_folder.png rename to vendor/assets/images/emoji/file_folder.png diff --git a/app/assets/images/emoji/finnadie.png b/vendor/assets/images/emoji/finnadie.png similarity index 100% rename from app/assets/images/emoji/finnadie.png rename to vendor/assets/images/emoji/finnadie.png diff --git a/app/assets/images/emoji/fire.png b/vendor/assets/images/emoji/fire.png similarity index 100% rename from app/assets/images/emoji/fire.png rename to vendor/assets/images/emoji/fire.png diff --git a/app/assets/images/emoji/fire_engine.png b/vendor/assets/images/emoji/fire_engine.png similarity index 100% rename from app/assets/images/emoji/fire_engine.png rename to vendor/assets/images/emoji/fire_engine.png diff --git a/app/assets/images/emoji/fireworks.png b/vendor/assets/images/emoji/fireworks.png similarity index 100% rename from app/assets/images/emoji/fireworks.png rename to vendor/assets/images/emoji/fireworks.png diff --git a/app/assets/images/emoji/first_quarter_moon.png b/vendor/assets/images/emoji/first_quarter_moon.png similarity index 100% rename from app/assets/images/emoji/first_quarter_moon.png rename to vendor/assets/images/emoji/first_quarter_moon.png diff --git a/app/assets/images/emoji/first_quarter_moon_with_face.png b/vendor/assets/images/emoji/first_quarter_moon_with_face.png similarity index 100% rename from app/assets/images/emoji/first_quarter_moon_with_face.png rename to vendor/assets/images/emoji/first_quarter_moon_with_face.png diff --git a/app/assets/images/emoji/fish.png b/vendor/assets/images/emoji/fish.png similarity index 100% rename from app/assets/images/emoji/fish.png rename to vendor/assets/images/emoji/fish.png diff --git a/app/assets/images/emoji/fish_cake.png b/vendor/assets/images/emoji/fish_cake.png similarity index 100% rename from app/assets/images/emoji/fish_cake.png rename to vendor/assets/images/emoji/fish_cake.png diff --git a/app/assets/images/emoji/fishing_pole_and_fish.png b/vendor/assets/images/emoji/fishing_pole_and_fish.png similarity index 100% rename from app/assets/images/emoji/fishing_pole_and_fish.png rename to vendor/assets/images/emoji/fishing_pole_and_fish.png diff --git a/app/assets/images/emoji/fist.png b/vendor/assets/images/emoji/fist.png similarity index 100% rename from app/assets/images/emoji/fist.png rename to vendor/assets/images/emoji/fist.png diff --git a/app/assets/images/emoji/five.png b/vendor/assets/images/emoji/five.png similarity index 100% rename from app/assets/images/emoji/five.png rename to vendor/assets/images/emoji/five.png diff --git a/app/assets/images/emoji/flags.png b/vendor/assets/images/emoji/flags.png similarity index 100% rename from app/assets/images/emoji/flags.png rename to vendor/assets/images/emoji/flags.png diff --git a/app/assets/images/emoji/flashlight.png b/vendor/assets/images/emoji/flashlight.png similarity index 100% rename from app/assets/images/emoji/flashlight.png rename to vendor/assets/images/emoji/flashlight.png diff --git a/app/assets/images/emoji/floppy_disk.png b/vendor/assets/images/emoji/floppy_disk.png similarity index 100% rename from app/assets/images/emoji/floppy_disk.png rename to vendor/assets/images/emoji/floppy_disk.png diff --git a/app/assets/images/emoji/flower_playing_cards.png b/vendor/assets/images/emoji/flower_playing_cards.png similarity index 100% rename from app/assets/images/emoji/flower_playing_cards.png rename to vendor/assets/images/emoji/flower_playing_cards.png diff --git a/app/assets/images/emoji/flushed.png b/vendor/assets/images/emoji/flushed.png similarity index 100% rename from app/assets/images/emoji/flushed.png rename to vendor/assets/images/emoji/flushed.png diff --git a/app/assets/images/emoji/foggy.png b/vendor/assets/images/emoji/foggy.png similarity index 100% rename from app/assets/images/emoji/foggy.png rename to vendor/assets/images/emoji/foggy.png diff --git a/app/assets/images/emoji/football.png b/vendor/assets/images/emoji/football.png similarity index 100% rename from app/assets/images/emoji/football.png rename to vendor/assets/images/emoji/football.png diff --git a/app/assets/images/emoji/fork_and_knife.png b/vendor/assets/images/emoji/fork_and_knife.png similarity index 100% rename from app/assets/images/emoji/fork_and_knife.png rename to vendor/assets/images/emoji/fork_and_knife.png diff --git a/app/assets/images/emoji/fountain.png b/vendor/assets/images/emoji/fountain.png similarity index 100% rename from app/assets/images/emoji/fountain.png rename to vendor/assets/images/emoji/fountain.png diff --git a/app/assets/images/emoji/four.png b/vendor/assets/images/emoji/four.png similarity index 100% rename from app/assets/images/emoji/four.png rename to vendor/assets/images/emoji/four.png diff --git a/app/assets/images/emoji/four_leaf_clover.png b/vendor/assets/images/emoji/four_leaf_clover.png similarity index 100% rename from app/assets/images/emoji/four_leaf_clover.png rename to vendor/assets/images/emoji/four_leaf_clover.png diff --git a/app/assets/images/emoji/fr.png b/vendor/assets/images/emoji/fr.png similarity index 100% rename from app/assets/images/emoji/fr.png rename to vendor/assets/images/emoji/fr.png diff --git a/app/assets/images/emoji/free.png b/vendor/assets/images/emoji/free.png similarity index 100% rename from app/assets/images/emoji/free.png rename to vendor/assets/images/emoji/free.png diff --git a/app/assets/images/emoji/fried_shrimp.png b/vendor/assets/images/emoji/fried_shrimp.png similarity index 100% rename from app/assets/images/emoji/fried_shrimp.png rename to vendor/assets/images/emoji/fried_shrimp.png diff --git a/app/assets/images/emoji/fries.png b/vendor/assets/images/emoji/fries.png similarity index 100% rename from app/assets/images/emoji/fries.png rename to vendor/assets/images/emoji/fries.png diff --git a/app/assets/images/emoji/frog.png b/vendor/assets/images/emoji/frog.png similarity index 100% rename from app/assets/images/emoji/frog.png rename to vendor/assets/images/emoji/frog.png diff --git a/app/assets/images/emoji/fuelpump.png b/vendor/assets/images/emoji/fuelpump.png similarity index 100% rename from app/assets/images/emoji/fuelpump.png rename to vendor/assets/images/emoji/fuelpump.png diff --git a/app/assets/images/emoji/full_moon.png b/vendor/assets/images/emoji/full_moon.png similarity index 100% rename from app/assets/images/emoji/full_moon.png rename to vendor/assets/images/emoji/full_moon.png diff --git a/app/assets/images/emoji/full_moon_with_face.png b/vendor/assets/images/emoji/full_moon_with_face.png similarity index 100% rename from app/assets/images/emoji/full_moon_with_face.png rename to vendor/assets/images/emoji/full_moon_with_face.png diff --git a/app/assets/images/emoji/game_die.png b/vendor/assets/images/emoji/game_die.png similarity index 100% rename from app/assets/images/emoji/game_die.png rename to vendor/assets/images/emoji/game_die.png diff --git a/app/assets/images/emoji/gb.png b/vendor/assets/images/emoji/gb.png similarity index 100% rename from app/assets/images/emoji/gb.png rename to vendor/assets/images/emoji/gb.png diff --git a/app/assets/images/emoji/gem.png b/vendor/assets/images/emoji/gem.png similarity index 100% rename from app/assets/images/emoji/gem.png rename to vendor/assets/images/emoji/gem.png diff --git a/app/assets/images/emoji/gemini.png b/vendor/assets/images/emoji/gemini.png similarity index 100% rename from app/assets/images/emoji/gemini.png rename to vendor/assets/images/emoji/gemini.png diff --git a/app/assets/images/emoji/ghost.png b/vendor/assets/images/emoji/ghost.png similarity index 100% rename from app/assets/images/emoji/ghost.png rename to vendor/assets/images/emoji/ghost.png diff --git a/app/assets/images/emoji/gift.png b/vendor/assets/images/emoji/gift.png similarity index 100% rename from app/assets/images/emoji/gift.png rename to vendor/assets/images/emoji/gift.png diff --git a/app/assets/images/emoji/gift_heart.png b/vendor/assets/images/emoji/gift_heart.png similarity index 100% rename from app/assets/images/emoji/gift_heart.png rename to vendor/assets/images/emoji/gift_heart.png diff --git a/app/assets/images/emoji/girl.png b/vendor/assets/images/emoji/girl.png similarity index 100% rename from app/assets/images/emoji/girl.png rename to vendor/assets/images/emoji/girl.png diff --git a/app/assets/images/emoji/globe_with_meridians.png b/vendor/assets/images/emoji/globe_with_meridians.png similarity index 100% rename from app/assets/images/emoji/globe_with_meridians.png rename to vendor/assets/images/emoji/globe_with_meridians.png diff --git a/app/assets/images/emoji/goat.png b/vendor/assets/images/emoji/goat.png similarity index 100% rename from app/assets/images/emoji/goat.png rename to vendor/assets/images/emoji/goat.png diff --git a/app/assets/images/emoji/goberserk.png b/vendor/assets/images/emoji/goberserk.png similarity index 100% rename from app/assets/images/emoji/goberserk.png rename to vendor/assets/images/emoji/goberserk.png diff --git a/app/assets/images/emoji/godmode.png b/vendor/assets/images/emoji/godmode.png similarity index 100% rename from app/assets/images/emoji/godmode.png rename to vendor/assets/images/emoji/godmode.png diff --git a/app/assets/images/emoji/golf.png b/vendor/assets/images/emoji/golf.png similarity index 100% rename from app/assets/images/emoji/golf.png rename to vendor/assets/images/emoji/golf.png diff --git a/app/assets/images/emoji/grapes.png b/vendor/assets/images/emoji/grapes.png similarity index 100% rename from app/assets/images/emoji/grapes.png rename to vendor/assets/images/emoji/grapes.png diff --git a/app/assets/images/emoji/green_apple.png b/vendor/assets/images/emoji/green_apple.png similarity index 100% rename from app/assets/images/emoji/green_apple.png rename to vendor/assets/images/emoji/green_apple.png diff --git a/app/assets/images/emoji/green_book.png b/vendor/assets/images/emoji/green_book.png similarity index 100% rename from app/assets/images/emoji/green_book.png rename to vendor/assets/images/emoji/green_book.png diff --git a/app/assets/images/emoji/green_heart.png b/vendor/assets/images/emoji/green_heart.png similarity index 100% rename from app/assets/images/emoji/green_heart.png rename to vendor/assets/images/emoji/green_heart.png diff --git a/app/assets/images/emoji/grey_exclamation.png b/vendor/assets/images/emoji/grey_exclamation.png similarity index 100% rename from app/assets/images/emoji/grey_exclamation.png rename to vendor/assets/images/emoji/grey_exclamation.png diff --git a/app/assets/images/emoji/grey_question.png b/vendor/assets/images/emoji/grey_question.png similarity index 100% rename from app/assets/images/emoji/grey_question.png rename to vendor/assets/images/emoji/grey_question.png diff --git a/app/assets/images/emoji/grin.png b/vendor/assets/images/emoji/grin.png similarity index 100% rename from app/assets/images/emoji/grin.png rename to vendor/assets/images/emoji/grin.png diff --git a/app/assets/images/emoji/guardsman.png b/vendor/assets/images/emoji/guardsman.png similarity index 100% rename from app/assets/images/emoji/guardsman.png rename to vendor/assets/images/emoji/guardsman.png diff --git a/app/assets/images/emoji/guitar.png b/vendor/assets/images/emoji/guitar.png similarity index 100% rename from app/assets/images/emoji/guitar.png rename to vendor/assets/images/emoji/guitar.png diff --git a/app/assets/images/emoji/gun.png b/vendor/assets/images/emoji/gun.png similarity index 100% rename from app/assets/images/emoji/gun.png rename to vendor/assets/images/emoji/gun.png diff --git a/app/assets/images/emoji/haircut.png b/vendor/assets/images/emoji/haircut.png similarity index 100% rename from app/assets/images/emoji/haircut.png rename to vendor/assets/images/emoji/haircut.png diff --git a/app/assets/images/emoji/hamburger.png b/vendor/assets/images/emoji/hamburger.png similarity index 100% rename from app/assets/images/emoji/hamburger.png rename to vendor/assets/images/emoji/hamburger.png diff --git a/app/assets/images/emoji/hammer.png b/vendor/assets/images/emoji/hammer.png similarity index 100% rename from app/assets/images/emoji/hammer.png rename to vendor/assets/images/emoji/hammer.png diff --git a/app/assets/images/emoji/hamster.png b/vendor/assets/images/emoji/hamster.png similarity index 100% rename from app/assets/images/emoji/hamster.png rename to vendor/assets/images/emoji/hamster.png diff --git a/app/assets/images/emoji/hand.png b/vendor/assets/images/emoji/hand.png similarity index 100% rename from app/assets/images/emoji/hand.png rename to vendor/assets/images/emoji/hand.png diff --git a/app/assets/images/emoji/handbag.png b/vendor/assets/images/emoji/handbag.png similarity index 100% rename from app/assets/images/emoji/handbag.png rename to vendor/assets/images/emoji/handbag.png diff --git a/app/assets/images/emoji/hankey.png b/vendor/assets/images/emoji/hankey.png similarity index 100% rename from app/assets/images/emoji/hankey.png rename to vendor/assets/images/emoji/hankey.png diff --git a/app/assets/images/emoji/hash.png b/vendor/assets/images/emoji/hash.png similarity index 100% rename from app/assets/images/emoji/hash.png rename to vendor/assets/images/emoji/hash.png diff --git a/app/assets/images/emoji/hatched_chick.png b/vendor/assets/images/emoji/hatched_chick.png similarity index 100% rename from app/assets/images/emoji/hatched_chick.png rename to vendor/assets/images/emoji/hatched_chick.png diff --git a/app/assets/images/emoji/hatching_chick.png b/vendor/assets/images/emoji/hatching_chick.png similarity index 100% rename from app/assets/images/emoji/hatching_chick.png rename to vendor/assets/images/emoji/hatching_chick.png diff --git a/app/assets/images/emoji/headphones.png b/vendor/assets/images/emoji/headphones.png similarity index 100% rename from app/assets/images/emoji/headphones.png rename to vendor/assets/images/emoji/headphones.png diff --git a/app/assets/images/emoji/hear_no_evil.png b/vendor/assets/images/emoji/hear_no_evil.png similarity index 100% rename from app/assets/images/emoji/hear_no_evil.png rename to vendor/assets/images/emoji/hear_no_evil.png diff --git a/app/assets/images/emoji/heart.png b/vendor/assets/images/emoji/heart.png similarity index 100% rename from app/assets/images/emoji/heart.png rename to vendor/assets/images/emoji/heart.png diff --git a/app/assets/images/emoji/heart_decoration.png b/vendor/assets/images/emoji/heart_decoration.png similarity index 100% rename from app/assets/images/emoji/heart_decoration.png rename to vendor/assets/images/emoji/heart_decoration.png diff --git a/app/assets/images/emoji/heart_eyes.png b/vendor/assets/images/emoji/heart_eyes.png similarity index 100% rename from app/assets/images/emoji/heart_eyes.png rename to vendor/assets/images/emoji/heart_eyes.png diff --git a/app/assets/images/emoji/heart_eyes_cat.png b/vendor/assets/images/emoji/heart_eyes_cat.png similarity index 100% rename from app/assets/images/emoji/heart_eyes_cat.png rename to vendor/assets/images/emoji/heart_eyes_cat.png diff --git a/app/assets/images/emoji/heartbeat.png b/vendor/assets/images/emoji/heartbeat.png similarity index 100% rename from app/assets/images/emoji/heartbeat.png rename to vendor/assets/images/emoji/heartbeat.png diff --git a/app/assets/images/emoji/heartpulse.png b/vendor/assets/images/emoji/heartpulse.png similarity index 100% rename from app/assets/images/emoji/heartpulse.png rename to vendor/assets/images/emoji/heartpulse.png diff --git a/app/assets/images/emoji/hearts.png b/vendor/assets/images/emoji/hearts.png similarity index 100% rename from app/assets/images/emoji/hearts.png rename to vendor/assets/images/emoji/hearts.png diff --git a/app/assets/images/emoji/heavy_check_mark.png b/vendor/assets/images/emoji/heavy_check_mark.png similarity index 100% rename from app/assets/images/emoji/heavy_check_mark.png rename to vendor/assets/images/emoji/heavy_check_mark.png diff --git a/app/assets/images/emoji/heavy_division_sign.png b/vendor/assets/images/emoji/heavy_division_sign.png similarity index 100% rename from app/assets/images/emoji/heavy_division_sign.png rename to vendor/assets/images/emoji/heavy_division_sign.png diff --git a/app/assets/images/emoji/heavy_dollar_sign.png b/vendor/assets/images/emoji/heavy_dollar_sign.png similarity index 100% rename from app/assets/images/emoji/heavy_dollar_sign.png rename to vendor/assets/images/emoji/heavy_dollar_sign.png diff --git a/app/assets/images/emoji/heavy_exclamation_mark.png b/vendor/assets/images/emoji/heavy_exclamation_mark.png similarity index 100% rename from app/assets/images/emoji/heavy_exclamation_mark.png rename to vendor/assets/images/emoji/heavy_exclamation_mark.png diff --git a/app/assets/images/emoji/heavy_minus_sign.png b/vendor/assets/images/emoji/heavy_minus_sign.png similarity index 100% rename from app/assets/images/emoji/heavy_minus_sign.png rename to vendor/assets/images/emoji/heavy_minus_sign.png diff --git a/app/assets/images/emoji/heavy_multiplication_x.png b/vendor/assets/images/emoji/heavy_multiplication_x.png similarity index 100% rename from app/assets/images/emoji/heavy_multiplication_x.png rename to vendor/assets/images/emoji/heavy_multiplication_x.png diff --git a/app/assets/images/emoji/heavy_plus_sign.png b/vendor/assets/images/emoji/heavy_plus_sign.png similarity index 100% rename from app/assets/images/emoji/heavy_plus_sign.png rename to vendor/assets/images/emoji/heavy_plus_sign.png diff --git a/app/assets/images/emoji/helicopter.png b/vendor/assets/images/emoji/helicopter.png similarity index 100% rename from app/assets/images/emoji/helicopter.png rename to vendor/assets/images/emoji/helicopter.png diff --git a/app/assets/images/emoji/herb.png b/vendor/assets/images/emoji/herb.png similarity index 100% rename from app/assets/images/emoji/herb.png rename to vendor/assets/images/emoji/herb.png diff --git a/app/assets/images/emoji/hibiscus.png b/vendor/assets/images/emoji/hibiscus.png similarity index 100% rename from app/assets/images/emoji/hibiscus.png rename to vendor/assets/images/emoji/hibiscus.png diff --git a/app/assets/images/emoji/high_brightness.png b/vendor/assets/images/emoji/high_brightness.png similarity index 100% rename from app/assets/images/emoji/high_brightness.png rename to vendor/assets/images/emoji/high_brightness.png diff --git a/app/assets/images/emoji/high_heel.png b/vendor/assets/images/emoji/high_heel.png similarity index 100% rename from app/assets/images/emoji/high_heel.png rename to vendor/assets/images/emoji/high_heel.png diff --git a/app/assets/images/emoji/hocho.png b/vendor/assets/images/emoji/hocho.png similarity index 100% rename from app/assets/images/emoji/hocho.png rename to vendor/assets/images/emoji/hocho.png diff --git a/app/assets/images/emoji/honey_pot.png b/vendor/assets/images/emoji/honey_pot.png similarity index 100% rename from app/assets/images/emoji/honey_pot.png rename to vendor/assets/images/emoji/honey_pot.png diff --git a/app/assets/images/emoji/honeybee.png b/vendor/assets/images/emoji/honeybee.png similarity index 100% rename from app/assets/images/emoji/honeybee.png rename to vendor/assets/images/emoji/honeybee.png diff --git a/app/assets/images/emoji/horse.png b/vendor/assets/images/emoji/horse.png similarity index 100% rename from app/assets/images/emoji/horse.png rename to vendor/assets/images/emoji/horse.png diff --git a/app/assets/images/emoji/horse_racing.png b/vendor/assets/images/emoji/horse_racing.png similarity index 100% rename from app/assets/images/emoji/horse_racing.png rename to vendor/assets/images/emoji/horse_racing.png diff --git a/app/assets/images/emoji/hospital.png b/vendor/assets/images/emoji/hospital.png similarity index 100% rename from app/assets/images/emoji/hospital.png rename to vendor/assets/images/emoji/hospital.png diff --git a/app/assets/images/emoji/hotel.png b/vendor/assets/images/emoji/hotel.png similarity index 100% rename from app/assets/images/emoji/hotel.png rename to vendor/assets/images/emoji/hotel.png diff --git a/app/assets/images/emoji/hotsprings.png b/vendor/assets/images/emoji/hotsprings.png similarity index 100% rename from app/assets/images/emoji/hotsprings.png rename to vendor/assets/images/emoji/hotsprings.png diff --git a/app/assets/images/emoji/hourglass.png b/vendor/assets/images/emoji/hourglass.png similarity index 100% rename from app/assets/images/emoji/hourglass.png rename to vendor/assets/images/emoji/hourglass.png diff --git a/app/assets/images/emoji/house.png b/vendor/assets/images/emoji/house.png similarity index 100% rename from app/assets/images/emoji/house.png rename to vendor/assets/images/emoji/house.png diff --git a/app/assets/images/emoji/hurtrealbad.png b/vendor/assets/images/emoji/hurtrealbad.png similarity index 100% rename from app/assets/images/emoji/hurtrealbad.png rename to vendor/assets/images/emoji/hurtrealbad.png diff --git a/app/assets/images/emoji/ice_cream.png b/vendor/assets/images/emoji/ice_cream.png similarity index 100% rename from app/assets/images/emoji/ice_cream.png rename to vendor/assets/images/emoji/ice_cream.png diff --git a/app/assets/images/emoji/icecream.png b/vendor/assets/images/emoji/icecream.png similarity index 100% rename from app/assets/images/emoji/icecream.png rename to vendor/assets/images/emoji/icecream.png diff --git a/app/assets/images/emoji/id.png b/vendor/assets/images/emoji/id.png similarity index 100% rename from app/assets/images/emoji/id.png rename to vendor/assets/images/emoji/id.png diff --git a/app/assets/images/emoji/ideograph_advantage.png b/vendor/assets/images/emoji/ideograph_advantage.png similarity index 100% rename from app/assets/images/emoji/ideograph_advantage.png rename to vendor/assets/images/emoji/ideograph_advantage.png diff --git a/app/assets/images/emoji/imp.png b/vendor/assets/images/emoji/imp.png similarity index 100% rename from app/assets/images/emoji/imp.png rename to vendor/assets/images/emoji/imp.png diff --git a/app/assets/images/emoji/inbox_tray.png b/vendor/assets/images/emoji/inbox_tray.png similarity index 100% rename from app/assets/images/emoji/inbox_tray.png rename to vendor/assets/images/emoji/inbox_tray.png diff --git a/app/assets/images/emoji/incoming_envelope.png b/vendor/assets/images/emoji/incoming_envelope.png similarity index 100% rename from app/assets/images/emoji/incoming_envelope.png rename to vendor/assets/images/emoji/incoming_envelope.png diff --git a/app/assets/images/emoji/information_desk_person.png b/vendor/assets/images/emoji/information_desk_person.png similarity index 100% rename from app/assets/images/emoji/information_desk_person.png rename to vendor/assets/images/emoji/information_desk_person.png diff --git a/app/assets/images/emoji/information_source.png b/vendor/assets/images/emoji/information_source.png similarity index 100% rename from app/assets/images/emoji/information_source.png rename to vendor/assets/images/emoji/information_source.png diff --git a/app/assets/images/emoji/innocent.png b/vendor/assets/images/emoji/innocent.png similarity index 100% rename from app/assets/images/emoji/innocent.png rename to vendor/assets/images/emoji/innocent.png diff --git a/app/assets/images/emoji/interrobang.png b/vendor/assets/images/emoji/interrobang.png similarity index 100% rename from app/assets/images/emoji/interrobang.png rename to vendor/assets/images/emoji/interrobang.png diff --git a/app/assets/images/emoji/iphone.png b/vendor/assets/images/emoji/iphone.png similarity index 100% rename from app/assets/images/emoji/iphone.png rename to vendor/assets/images/emoji/iphone.png diff --git a/app/assets/images/emoji/it.png b/vendor/assets/images/emoji/it.png similarity index 100% rename from app/assets/images/emoji/it.png rename to vendor/assets/images/emoji/it.png diff --git a/app/assets/images/emoji/izakaya_lantern.png b/vendor/assets/images/emoji/izakaya_lantern.png similarity index 100% rename from app/assets/images/emoji/izakaya_lantern.png rename to vendor/assets/images/emoji/izakaya_lantern.png diff --git a/app/assets/images/emoji/jack_o_lantern.png b/vendor/assets/images/emoji/jack_o_lantern.png similarity index 100% rename from app/assets/images/emoji/jack_o_lantern.png rename to vendor/assets/images/emoji/jack_o_lantern.png diff --git a/app/assets/images/emoji/japan.png b/vendor/assets/images/emoji/japan.png similarity index 100% rename from app/assets/images/emoji/japan.png rename to vendor/assets/images/emoji/japan.png diff --git a/app/assets/images/emoji/japanese_castle.png b/vendor/assets/images/emoji/japanese_castle.png similarity index 100% rename from app/assets/images/emoji/japanese_castle.png rename to vendor/assets/images/emoji/japanese_castle.png diff --git a/app/assets/images/emoji/japanese_goblin.png b/vendor/assets/images/emoji/japanese_goblin.png similarity index 100% rename from app/assets/images/emoji/japanese_goblin.png rename to vendor/assets/images/emoji/japanese_goblin.png diff --git a/app/assets/images/emoji/japanese_ogre.png b/vendor/assets/images/emoji/japanese_ogre.png similarity index 100% rename from app/assets/images/emoji/japanese_ogre.png rename to vendor/assets/images/emoji/japanese_ogre.png diff --git a/app/assets/images/emoji/jeans.png b/vendor/assets/images/emoji/jeans.png similarity index 100% rename from app/assets/images/emoji/jeans.png rename to vendor/assets/images/emoji/jeans.png diff --git a/app/assets/images/emoji/joy.png b/vendor/assets/images/emoji/joy.png similarity index 100% rename from app/assets/images/emoji/joy.png rename to vendor/assets/images/emoji/joy.png diff --git a/app/assets/images/emoji/joy_cat.png b/vendor/assets/images/emoji/joy_cat.png similarity index 100% rename from app/assets/images/emoji/joy_cat.png rename to vendor/assets/images/emoji/joy_cat.png diff --git a/app/assets/images/emoji/jp.png b/vendor/assets/images/emoji/jp.png similarity index 100% rename from app/assets/images/emoji/jp.png rename to vendor/assets/images/emoji/jp.png diff --git a/app/assets/images/emoji/key.png b/vendor/assets/images/emoji/key.png similarity index 100% rename from app/assets/images/emoji/key.png rename to vendor/assets/images/emoji/key.png diff --git a/app/assets/images/emoji/keycap_ten.png b/vendor/assets/images/emoji/keycap_ten.png similarity index 100% rename from app/assets/images/emoji/keycap_ten.png rename to vendor/assets/images/emoji/keycap_ten.png diff --git a/app/assets/images/emoji/kimono.png b/vendor/assets/images/emoji/kimono.png similarity index 100% rename from app/assets/images/emoji/kimono.png rename to vendor/assets/images/emoji/kimono.png diff --git a/app/assets/images/emoji/kiss.png b/vendor/assets/images/emoji/kiss.png similarity index 100% rename from app/assets/images/emoji/kiss.png rename to vendor/assets/images/emoji/kiss.png diff --git a/app/assets/images/emoji/kissing_cat.png b/vendor/assets/images/emoji/kissing_cat.png similarity index 100% rename from app/assets/images/emoji/kissing_cat.png rename to vendor/assets/images/emoji/kissing_cat.png diff --git a/app/assets/images/emoji/kissing_face.png b/vendor/assets/images/emoji/kissing_face.png similarity index 100% rename from app/assets/images/emoji/kissing_face.png rename to vendor/assets/images/emoji/kissing_face.png diff --git a/app/assets/images/emoji/kissing_heart.png b/vendor/assets/images/emoji/kissing_heart.png similarity index 100% rename from app/assets/images/emoji/kissing_heart.png rename to vendor/assets/images/emoji/kissing_heart.png diff --git a/app/assets/images/emoji/koala.png b/vendor/assets/images/emoji/koala.png similarity index 100% rename from app/assets/images/emoji/koala.png rename to vendor/assets/images/emoji/koala.png diff --git a/app/assets/images/emoji/koko.png b/vendor/assets/images/emoji/koko.png similarity index 100% rename from app/assets/images/emoji/koko.png rename to vendor/assets/images/emoji/koko.png diff --git a/app/assets/images/emoji/kr.png b/vendor/assets/images/emoji/kr.png similarity index 100% rename from app/assets/images/emoji/kr.png rename to vendor/assets/images/emoji/kr.png diff --git a/app/assets/images/emoji/large_blue_circle.png b/vendor/assets/images/emoji/large_blue_circle.png similarity index 100% rename from app/assets/images/emoji/large_blue_circle.png rename to vendor/assets/images/emoji/large_blue_circle.png diff --git a/app/assets/images/emoji/large_blue_diamond.png b/vendor/assets/images/emoji/large_blue_diamond.png similarity index 100% rename from app/assets/images/emoji/large_blue_diamond.png rename to vendor/assets/images/emoji/large_blue_diamond.png diff --git a/app/assets/images/emoji/large_orange_diamond.png b/vendor/assets/images/emoji/large_orange_diamond.png similarity index 100% rename from app/assets/images/emoji/large_orange_diamond.png rename to vendor/assets/images/emoji/large_orange_diamond.png diff --git a/app/assets/images/emoji/last_quarter_moon.png b/vendor/assets/images/emoji/last_quarter_moon.png similarity index 100% rename from app/assets/images/emoji/last_quarter_moon.png rename to vendor/assets/images/emoji/last_quarter_moon.png diff --git a/app/assets/images/emoji/last_quarter_moon_with_face.png b/vendor/assets/images/emoji/last_quarter_moon_with_face.png similarity index 100% rename from app/assets/images/emoji/last_quarter_moon_with_face.png rename to vendor/assets/images/emoji/last_quarter_moon_with_face.png diff --git a/app/assets/images/emoji/laughing.png b/vendor/assets/images/emoji/laughing.png similarity index 100% rename from app/assets/images/emoji/laughing.png rename to vendor/assets/images/emoji/laughing.png diff --git a/app/assets/images/emoji/leaves.png b/vendor/assets/images/emoji/leaves.png similarity index 100% rename from app/assets/images/emoji/leaves.png rename to vendor/assets/images/emoji/leaves.png diff --git a/app/assets/images/emoji/ledger.png b/vendor/assets/images/emoji/ledger.png similarity index 100% rename from app/assets/images/emoji/ledger.png rename to vendor/assets/images/emoji/ledger.png diff --git a/app/assets/images/emoji/left_luggage.png b/vendor/assets/images/emoji/left_luggage.png similarity index 100% rename from app/assets/images/emoji/left_luggage.png rename to vendor/assets/images/emoji/left_luggage.png diff --git a/app/assets/images/emoji/left_right_arrow.png b/vendor/assets/images/emoji/left_right_arrow.png similarity index 100% rename from app/assets/images/emoji/left_right_arrow.png rename to vendor/assets/images/emoji/left_right_arrow.png diff --git a/app/assets/images/emoji/leftwards_arrow_with_hook.png b/vendor/assets/images/emoji/leftwards_arrow_with_hook.png similarity index 100% rename from app/assets/images/emoji/leftwards_arrow_with_hook.png rename to vendor/assets/images/emoji/leftwards_arrow_with_hook.png diff --git a/app/assets/images/emoji/lemon.png b/vendor/assets/images/emoji/lemon.png similarity index 100% rename from app/assets/images/emoji/lemon.png rename to vendor/assets/images/emoji/lemon.png diff --git a/app/assets/images/emoji/leo.png b/vendor/assets/images/emoji/leo.png similarity index 100% rename from app/assets/images/emoji/leo.png rename to vendor/assets/images/emoji/leo.png diff --git a/app/assets/images/emoji/leopard.png b/vendor/assets/images/emoji/leopard.png similarity index 100% rename from app/assets/images/emoji/leopard.png rename to vendor/assets/images/emoji/leopard.png diff --git a/app/assets/images/emoji/libra.png b/vendor/assets/images/emoji/libra.png similarity index 100% rename from app/assets/images/emoji/libra.png rename to vendor/assets/images/emoji/libra.png diff --git a/app/assets/images/emoji/light_rail.png b/vendor/assets/images/emoji/light_rail.png similarity index 100% rename from app/assets/images/emoji/light_rail.png rename to vendor/assets/images/emoji/light_rail.png diff --git a/app/assets/images/emoji/link.png b/vendor/assets/images/emoji/link.png similarity index 100% rename from app/assets/images/emoji/link.png rename to vendor/assets/images/emoji/link.png diff --git a/app/assets/images/emoji/lips.png b/vendor/assets/images/emoji/lips.png similarity index 100% rename from app/assets/images/emoji/lips.png rename to vendor/assets/images/emoji/lips.png diff --git a/app/assets/images/emoji/lipstick.png b/vendor/assets/images/emoji/lipstick.png similarity index 100% rename from app/assets/images/emoji/lipstick.png rename to vendor/assets/images/emoji/lipstick.png diff --git a/app/assets/images/emoji/lock.png b/vendor/assets/images/emoji/lock.png similarity index 100% rename from app/assets/images/emoji/lock.png rename to vendor/assets/images/emoji/lock.png diff --git a/app/assets/images/emoji/lock_with_ink_pen.png b/vendor/assets/images/emoji/lock_with_ink_pen.png similarity index 100% rename from app/assets/images/emoji/lock_with_ink_pen.png rename to vendor/assets/images/emoji/lock_with_ink_pen.png diff --git a/app/assets/images/emoji/lollipop.png b/vendor/assets/images/emoji/lollipop.png similarity index 100% rename from app/assets/images/emoji/lollipop.png rename to vendor/assets/images/emoji/lollipop.png diff --git a/app/assets/images/emoji/loop.png b/vendor/assets/images/emoji/loop.png similarity index 100% rename from app/assets/images/emoji/loop.png rename to vendor/assets/images/emoji/loop.png diff --git a/app/assets/images/emoji/loudspeaker.png b/vendor/assets/images/emoji/loudspeaker.png similarity index 100% rename from app/assets/images/emoji/loudspeaker.png rename to vendor/assets/images/emoji/loudspeaker.png diff --git a/app/assets/images/emoji/love_hotel.png b/vendor/assets/images/emoji/love_hotel.png similarity index 100% rename from app/assets/images/emoji/love_hotel.png rename to vendor/assets/images/emoji/love_hotel.png diff --git a/app/assets/images/emoji/love_letter.png b/vendor/assets/images/emoji/love_letter.png similarity index 100% rename from app/assets/images/emoji/love_letter.png rename to vendor/assets/images/emoji/love_letter.png diff --git a/app/assets/images/emoji/low_brightness.png b/vendor/assets/images/emoji/low_brightness.png similarity index 100% rename from app/assets/images/emoji/low_brightness.png rename to vendor/assets/images/emoji/low_brightness.png diff --git a/app/assets/images/emoji/m.png b/vendor/assets/images/emoji/m.png similarity index 100% rename from app/assets/images/emoji/m.png rename to vendor/assets/images/emoji/m.png diff --git a/app/assets/images/emoji/mag.png b/vendor/assets/images/emoji/mag.png similarity index 100% rename from app/assets/images/emoji/mag.png rename to vendor/assets/images/emoji/mag.png diff --git a/app/assets/images/emoji/mag_right.png b/vendor/assets/images/emoji/mag_right.png similarity index 100% rename from app/assets/images/emoji/mag_right.png rename to vendor/assets/images/emoji/mag_right.png diff --git a/app/assets/images/emoji/mahjong.png b/vendor/assets/images/emoji/mahjong.png similarity index 100% rename from app/assets/images/emoji/mahjong.png rename to vendor/assets/images/emoji/mahjong.png diff --git a/app/assets/images/emoji/mailbox.png b/vendor/assets/images/emoji/mailbox.png similarity index 100% rename from app/assets/images/emoji/mailbox.png rename to vendor/assets/images/emoji/mailbox.png diff --git a/app/assets/images/emoji/mailbox_closed.png b/vendor/assets/images/emoji/mailbox_closed.png similarity index 100% rename from app/assets/images/emoji/mailbox_closed.png rename to vendor/assets/images/emoji/mailbox_closed.png diff --git a/app/assets/images/emoji/mailbox_with_mail.png b/vendor/assets/images/emoji/mailbox_with_mail.png similarity index 100% rename from app/assets/images/emoji/mailbox_with_mail.png rename to vendor/assets/images/emoji/mailbox_with_mail.png diff --git a/app/assets/images/emoji/mailbox_with_no_mail.png b/vendor/assets/images/emoji/mailbox_with_no_mail.png similarity index 100% rename from app/assets/images/emoji/mailbox_with_no_mail.png rename to vendor/assets/images/emoji/mailbox_with_no_mail.png diff --git a/app/assets/images/emoji/man.png b/vendor/assets/images/emoji/man.png similarity index 100% rename from app/assets/images/emoji/man.png rename to vendor/assets/images/emoji/man.png diff --git a/app/assets/images/emoji/man_with_gua_pi_mao.png b/vendor/assets/images/emoji/man_with_gua_pi_mao.png similarity index 100% rename from app/assets/images/emoji/man_with_gua_pi_mao.png rename to vendor/assets/images/emoji/man_with_gua_pi_mao.png diff --git a/app/assets/images/emoji/man_with_turban.png b/vendor/assets/images/emoji/man_with_turban.png similarity index 100% rename from app/assets/images/emoji/man_with_turban.png rename to vendor/assets/images/emoji/man_with_turban.png diff --git a/app/assets/images/emoji/mans_shoe.png b/vendor/assets/images/emoji/mans_shoe.png similarity index 100% rename from app/assets/images/emoji/mans_shoe.png rename to vendor/assets/images/emoji/mans_shoe.png diff --git a/app/assets/images/emoji/maple_leaf.png b/vendor/assets/images/emoji/maple_leaf.png similarity index 100% rename from app/assets/images/emoji/maple_leaf.png rename to vendor/assets/images/emoji/maple_leaf.png diff --git a/app/assets/images/emoji/mask.png b/vendor/assets/images/emoji/mask.png similarity index 100% rename from app/assets/images/emoji/mask.png rename to vendor/assets/images/emoji/mask.png diff --git a/app/assets/images/emoji/massage.png b/vendor/assets/images/emoji/massage.png similarity index 100% rename from app/assets/images/emoji/massage.png rename to vendor/assets/images/emoji/massage.png diff --git a/app/assets/images/emoji/meat_on_bone.png b/vendor/assets/images/emoji/meat_on_bone.png similarity index 100% rename from app/assets/images/emoji/meat_on_bone.png rename to vendor/assets/images/emoji/meat_on_bone.png diff --git a/app/assets/images/emoji/mega.png b/vendor/assets/images/emoji/mega.png similarity index 100% rename from app/assets/images/emoji/mega.png rename to vendor/assets/images/emoji/mega.png diff --git a/app/assets/images/emoji/melon.png b/vendor/assets/images/emoji/melon.png similarity index 100% rename from app/assets/images/emoji/melon.png rename to vendor/assets/images/emoji/melon.png diff --git a/app/assets/images/emoji/memo.png b/vendor/assets/images/emoji/memo.png similarity index 100% rename from app/assets/images/emoji/memo.png rename to vendor/assets/images/emoji/memo.png diff --git a/app/assets/images/emoji/mens.png b/vendor/assets/images/emoji/mens.png similarity index 100% rename from app/assets/images/emoji/mens.png rename to vendor/assets/images/emoji/mens.png diff --git a/app/assets/images/emoji/metal.png b/vendor/assets/images/emoji/metal.png similarity index 100% rename from app/assets/images/emoji/metal.png rename to vendor/assets/images/emoji/metal.png diff --git a/app/assets/images/emoji/metro.png b/vendor/assets/images/emoji/metro.png similarity index 100% rename from app/assets/images/emoji/metro.png rename to vendor/assets/images/emoji/metro.png diff --git a/app/assets/images/emoji/microphone.png b/vendor/assets/images/emoji/microphone.png similarity index 100% rename from app/assets/images/emoji/microphone.png rename to vendor/assets/images/emoji/microphone.png diff --git a/app/assets/images/emoji/microscope.png b/vendor/assets/images/emoji/microscope.png similarity index 100% rename from app/assets/images/emoji/microscope.png rename to vendor/assets/images/emoji/microscope.png diff --git a/app/assets/images/emoji/milky_way.png b/vendor/assets/images/emoji/milky_way.png similarity index 100% rename from app/assets/images/emoji/milky_way.png rename to vendor/assets/images/emoji/milky_way.png diff --git a/app/assets/images/emoji/minibus.png b/vendor/assets/images/emoji/minibus.png similarity index 100% rename from app/assets/images/emoji/minibus.png rename to vendor/assets/images/emoji/minibus.png diff --git a/app/assets/images/emoji/minidisc.png b/vendor/assets/images/emoji/minidisc.png similarity index 100% rename from app/assets/images/emoji/minidisc.png rename to vendor/assets/images/emoji/minidisc.png diff --git a/app/assets/images/emoji/mobile_phone_off.png b/vendor/assets/images/emoji/mobile_phone_off.png similarity index 100% rename from app/assets/images/emoji/mobile_phone_off.png rename to vendor/assets/images/emoji/mobile_phone_off.png diff --git a/app/assets/images/emoji/money_with_wings.png b/vendor/assets/images/emoji/money_with_wings.png similarity index 100% rename from app/assets/images/emoji/money_with_wings.png rename to vendor/assets/images/emoji/money_with_wings.png diff --git a/app/assets/images/emoji/moneybag.png b/vendor/assets/images/emoji/moneybag.png similarity index 100% rename from app/assets/images/emoji/moneybag.png rename to vendor/assets/images/emoji/moneybag.png diff --git a/app/assets/images/emoji/monkey.png b/vendor/assets/images/emoji/monkey.png similarity index 100% rename from app/assets/images/emoji/monkey.png rename to vendor/assets/images/emoji/monkey.png diff --git a/app/assets/images/emoji/monkey_face.png b/vendor/assets/images/emoji/monkey_face.png similarity index 100% rename from app/assets/images/emoji/monkey_face.png rename to vendor/assets/images/emoji/monkey_face.png diff --git a/app/assets/images/emoji/monorail.png b/vendor/assets/images/emoji/monorail.png similarity index 100% rename from app/assets/images/emoji/monorail.png rename to vendor/assets/images/emoji/monorail.png diff --git a/app/assets/images/emoji/moon.png b/vendor/assets/images/emoji/moon.png similarity index 100% rename from app/assets/images/emoji/moon.png rename to vendor/assets/images/emoji/moon.png diff --git a/app/assets/images/emoji/mortar_board.png b/vendor/assets/images/emoji/mortar_board.png similarity index 100% rename from app/assets/images/emoji/mortar_board.png rename to vendor/assets/images/emoji/mortar_board.png diff --git a/app/assets/images/emoji/mount_fuji.png b/vendor/assets/images/emoji/mount_fuji.png similarity index 100% rename from app/assets/images/emoji/mount_fuji.png rename to vendor/assets/images/emoji/mount_fuji.png diff --git a/app/assets/images/emoji/mountain_bicyclist.png b/vendor/assets/images/emoji/mountain_bicyclist.png similarity index 100% rename from app/assets/images/emoji/mountain_bicyclist.png rename to vendor/assets/images/emoji/mountain_bicyclist.png diff --git a/app/assets/images/emoji/mountain_cableway.png b/vendor/assets/images/emoji/mountain_cableway.png similarity index 100% rename from app/assets/images/emoji/mountain_cableway.png rename to vendor/assets/images/emoji/mountain_cableway.png diff --git a/app/assets/images/emoji/mountain_railway.png b/vendor/assets/images/emoji/mountain_railway.png similarity index 100% rename from app/assets/images/emoji/mountain_railway.png rename to vendor/assets/images/emoji/mountain_railway.png diff --git a/app/assets/images/emoji/mouse.png b/vendor/assets/images/emoji/mouse.png similarity index 100% rename from app/assets/images/emoji/mouse.png rename to vendor/assets/images/emoji/mouse.png diff --git a/app/assets/images/emoji/mouse2.png b/vendor/assets/images/emoji/mouse2.png similarity index 100% rename from app/assets/images/emoji/mouse2.png rename to vendor/assets/images/emoji/mouse2.png diff --git a/app/assets/images/emoji/movie_camera.png b/vendor/assets/images/emoji/movie_camera.png similarity index 100% rename from app/assets/images/emoji/movie_camera.png rename to vendor/assets/images/emoji/movie_camera.png diff --git a/app/assets/images/emoji/moyai.png b/vendor/assets/images/emoji/moyai.png similarity index 100% rename from app/assets/images/emoji/moyai.png rename to vendor/assets/images/emoji/moyai.png diff --git a/app/assets/images/emoji/muscle.png b/vendor/assets/images/emoji/muscle.png similarity index 100% rename from app/assets/images/emoji/muscle.png rename to vendor/assets/images/emoji/muscle.png diff --git a/app/assets/images/emoji/mushroom.png b/vendor/assets/images/emoji/mushroom.png similarity index 100% rename from app/assets/images/emoji/mushroom.png rename to vendor/assets/images/emoji/mushroom.png diff --git a/app/assets/images/emoji/musical_keyboard.png b/vendor/assets/images/emoji/musical_keyboard.png similarity index 100% rename from app/assets/images/emoji/musical_keyboard.png rename to vendor/assets/images/emoji/musical_keyboard.png diff --git a/app/assets/images/emoji/musical_note.png b/vendor/assets/images/emoji/musical_note.png similarity index 100% rename from app/assets/images/emoji/musical_note.png rename to vendor/assets/images/emoji/musical_note.png diff --git a/app/assets/images/emoji/musical_score.png b/vendor/assets/images/emoji/musical_score.png similarity index 100% rename from app/assets/images/emoji/musical_score.png rename to vendor/assets/images/emoji/musical_score.png diff --git a/app/assets/images/emoji/mute.png b/vendor/assets/images/emoji/mute.png similarity index 100% rename from app/assets/images/emoji/mute.png rename to vendor/assets/images/emoji/mute.png diff --git a/app/assets/images/emoji/nail_care.png b/vendor/assets/images/emoji/nail_care.png similarity index 100% rename from app/assets/images/emoji/nail_care.png rename to vendor/assets/images/emoji/nail_care.png diff --git a/app/assets/images/emoji/name_badge.png b/vendor/assets/images/emoji/name_badge.png similarity index 100% rename from app/assets/images/emoji/name_badge.png rename to vendor/assets/images/emoji/name_badge.png diff --git a/app/assets/images/emoji/neckbeard.png b/vendor/assets/images/emoji/neckbeard.png similarity index 100% rename from app/assets/images/emoji/neckbeard.png rename to vendor/assets/images/emoji/neckbeard.png diff --git a/app/assets/images/emoji/necktie.png b/vendor/assets/images/emoji/necktie.png similarity index 100% rename from app/assets/images/emoji/necktie.png rename to vendor/assets/images/emoji/necktie.png diff --git a/app/assets/images/emoji/negative_squared_cross_mark.png b/vendor/assets/images/emoji/negative_squared_cross_mark.png similarity index 100% rename from app/assets/images/emoji/negative_squared_cross_mark.png rename to vendor/assets/images/emoji/negative_squared_cross_mark.png diff --git a/app/assets/images/emoji/neutral_face.png b/vendor/assets/images/emoji/neutral_face.png similarity index 100% rename from app/assets/images/emoji/neutral_face.png rename to vendor/assets/images/emoji/neutral_face.png diff --git a/app/assets/images/emoji/new.png b/vendor/assets/images/emoji/new.png similarity index 100% rename from app/assets/images/emoji/new.png rename to vendor/assets/images/emoji/new.png diff --git a/app/assets/images/emoji/new_moon.png b/vendor/assets/images/emoji/new_moon.png similarity index 100% rename from app/assets/images/emoji/new_moon.png rename to vendor/assets/images/emoji/new_moon.png diff --git a/app/assets/images/emoji/new_moon_with_face.png b/vendor/assets/images/emoji/new_moon_with_face.png similarity index 100% rename from app/assets/images/emoji/new_moon_with_face.png rename to vendor/assets/images/emoji/new_moon_with_face.png diff --git a/app/assets/images/emoji/newspaper.png b/vendor/assets/images/emoji/newspaper.png similarity index 100% rename from app/assets/images/emoji/newspaper.png rename to vendor/assets/images/emoji/newspaper.png diff --git a/app/assets/images/emoji/ng.png b/vendor/assets/images/emoji/ng.png similarity index 100% rename from app/assets/images/emoji/ng.png rename to vendor/assets/images/emoji/ng.png diff --git a/app/assets/images/emoji/nine.png b/vendor/assets/images/emoji/nine.png similarity index 100% rename from app/assets/images/emoji/nine.png rename to vendor/assets/images/emoji/nine.png diff --git a/app/assets/images/emoji/no_bell.png b/vendor/assets/images/emoji/no_bell.png similarity index 100% rename from app/assets/images/emoji/no_bell.png rename to vendor/assets/images/emoji/no_bell.png diff --git a/app/assets/images/emoji/no_bicycles.png b/vendor/assets/images/emoji/no_bicycles.png similarity index 100% rename from app/assets/images/emoji/no_bicycles.png rename to vendor/assets/images/emoji/no_bicycles.png diff --git a/app/assets/images/emoji/no_entry.png b/vendor/assets/images/emoji/no_entry.png similarity index 100% rename from app/assets/images/emoji/no_entry.png rename to vendor/assets/images/emoji/no_entry.png diff --git a/app/assets/images/emoji/no_entry_sign.png b/vendor/assets/images/emoji/no_entry_sign.png similarity index 100% rename from app/assets/images/emoji/no_entry_sign.png rename to vendor/assets/images/emoji/no_entry_sign.png diff --git a/app/assets/images/emoji/no_good.png b/vendor/assets/images/emoji/no_good.png similarity index 100% rename from app/assets/images/emoji/no_good.png rename to vendor/assets/images/emoji/no_good.png diff --git a/app/assets/images/emoji/no_mobile_phones.png b/vendor/assets/images/emoji/no_mobile_phones.png similarity index 100% rename from app/assets/images/emoji/no_mobile_phones.png rename to vendor/assets/images/emoji/no_mobile_phones.png diff --git a/app/assets/images/emoji/no_mouth.png b/vendor/assets/images/emoji/no_mouth.png similarity index 100% rename from app/assets/images/emoji/no_mouth.png rename to vendor/assets/images/emoji/no_mouth.png diff --git a/app/assets/images/emoji/no_pedestrians.png b/vendor/assets/images/emoji/no_pedestrians.png similarity index 100% rename from app/assets/images/emoji/no_pedestrians.png rename to vendor/assets/images/emoji/no_pedestrians.png diff --git a/app/assets/images/emoji/no_smoking.png b/vendor/assets/images/emoji/no_smoking.png similarity index 100% rename from app/assets/images/emoji/no_smoking.png rename to vendor/assets/images/emoji/no_smoking.png diff --git a/app/assets/images/emoji/non-potable_water.png b/vendor/assets/images/emoji/non-potable_water.png similarity index 100% rename from app/assets/images/emoji/non-potable_water.png rename to vendor/assets/images/emoji/non-potable_water.png diff --git a/app/assets/images/emoji/nose.png b/vendor/assets/images/emoji/nose.png similarity index 100% rename from app/assets/images/emoji/nose.png rename to vendor/assets/images/emoji/nose.png diff --git a/app/assets/images/emoji/notebook.png b/vendor/assets/images/emoji/notebook.png similarity index 100% rename from app/assets/images/emoji/notebook.png rename to vendor/assets/images/emoji/notebook.png diff --git a/app/assets/images/emoji/notebook_with_decorative_cover.png b/vendor/assets/images/emoji/notebook_with_decorative_cover.png similarity index 100% rename from app/assets/images/emoji/notebook_with_decorative_cover.png rename to vendor/assets/images/emoji/notebook_with_decorative_cover.png diff --git a/app/assets/images/emoji/notes.png b/vendor/assets/images/emoji/notes.png similarity index 100% rename from app/assets/images/emoji/notes.png rename to vendor/assets/images/emoji/notes.png diff --git a/app/assets/images/emoji/nut_and_bolt.png b/vendor/assets/images/emoji/nut_and_bolt.png similarity index 100% rename from app/assets/images/emoji/nut_and_bolt.png rename to vendor/assets/images/emoji/nut_and_bolt.png diff --git a/app/assets/images/emoji/o.png b/vendor/assets/images/emoji/o.png similarity index 100% rename from app/assets/images/emoji/o.png rename to vendor/assets/images/emoji/o.png diff --git a/app/assets/images/emoji/o2.png b/vendor/assets/images/emoji/o2.png similarity index 100% rename from app/assets/images/emoji/o2.png rename to vendor/assets/images/emoji/o2.png diff --git a/app/assets/images/emoji/ocean.png b/vendor/assets/images/emoji/ocean.png similarity index 100% rename from app/assets/images/emoji/ocean.png rename to vendor/assets/images/emoji/ocean.png diff --git a/app/assets/images/emoji/octocat.png b/vendor/assets/images/emoji/octocat.png similarity index 100% rename from app/assets/images/emoji/octocat.png rename to vendor/assets/images/emoji/octocat.png diff --git a/app/assets/images/emoji/octopus.png b/vendor/assets/images/emoji/octopus.png similarity index 100% rename from app/assets/images/emoji/octopus.png rename to vendor/assets/images/emoji/octopus.png diff --git a/app/assets/images/emoji/oden.png b/vendor/assets/images/emoji/oden.png similarity index 100% rename from app/assets/images/emoji/oden.png rename to vendor/assets/images/emoji/oden.png diff --git a/app/assets/images/emoji/office.png b/vendor/assets/images/emoji/office.png similarity index 100% rename from app/assets/images/emoji/office.png rename to vendor/assets/images/emoji/office.png diff --git a/app/assets/images/emoji/ok.png b/vendor/assets/images/emoji/ok.png similarity index 100% rename from app/assets/images/emoji/ok.png rename to vendor/assets/images/emoji/ok.png diff --git a/app/assets/images/emoji/ok_hand.png b/vendor/assets/images/emoji/ok_hand.png similarity index 100% rename from app/assets/images/emoji/ok_hand.png rename to vendor/assets/images/emoji/ok_hand.png diff --git a/app/assets/images/emoji/ok_woman.png b/vendor/assets/images/emoji/ok_woman.png similarity index 100% rename from app/assets/images/emoji/ok_woman.png rename to vendor/assets/images/emoji/ok_woman.png diff --git a/app/assets/images/emoji/older_man.png b/vendor/assets/images/emoji/older_man.png similarity index 100% rename from app/assets/images/emoji/older_man.png rename to vendor/assets/images/emoji/older_man.png diff --git a/app/assets/images/emoji/older_woman.png b/vendor/assets/images/emoji/older_woman.png similarity index 100% rename from app/assets/images/emoji/older_woman.png rename to vendor/assets/images/emoji/older_woman.png diff --git a/app/assets/images/emoji/on.png b/vendor/assets/images/emoji/on.png similarity index 100% rename from app/assets/images/emoji/on.png rename to vendor/assets/images/emoji/on.png diff --git a/app/assets/images/emoji/oncoming_automobile.png b/vendor/assets/images/emoji/oncoming_automobile.png similarity index 100% rename from app/assets/images/emoji/oncoming_automobile.png rename to vendor/assets/images/emoji/oncoming_automobile.png diff --git a/app/assets/images/emoji/oncoming_bus.png b/vendor/assets/images/emoji/oncoming_bus.png similarity index 100% rename from app/assets/images/emoji/oncoming_bus.png rename to vendor/assets/images/emoji/oncoming_bus.png diff --git a/app/assets/images/emoji/oncoming_police_car.png b/vendor/assets/images/emoji/oncoming_police_car.png similarity index 100% rename from app/assets/images/emoji/oncoming_police_car.png rename to vendor/assets/images/emoji/oncoming_police_car.png diff --git a/app/assets/images/emoji/oncoming_taxi.png b/vendor/assets/images/emoji/oncoming_taxi.png similarity index 100% rename from app/assets/images/emoji/oncoming_taxi.png rename to vendor/assets/images/emoji/oncoming_taxi.png diff --git a/app/assets/images/emoji/one.png b/vendor/assets/images/emoji/one.png similarity index 100% rename from app/assets/images/emoji/one.png rename to vendor/assets/images/emoji/one.png diff --git a/app/assets/images/emoji/open_file_folder.png b/vendor/assets/images/emoji/open_file_folder.png similarity index 100% rename from app/assets/images/emoji/open_file_folder.png rename to vendor/assets/images/emoji/open_file_folder.png diff --git a/app/assets/images/emoji/open_hands.png b/vendor/assets/images/emoji/open_hands.png similarity index 100% rename from app/assets/images/emoji/open_hands.png rename to vendor/assets/images/emoji/open_hands.png diff --git a/app/assets/images/emoji/ophiuchus.png b/vendor/assets/images/emoji/ophiuchus.png similarity index 100% rename from app/assets/images/emoji/ophiuchus.png rename to vendor/assets/images/emoji/ophiuchus.png diff --git a/app/assets/images/emoji/orange_book.png b/vendor/assets/images/emoji/orange_book.png similarity index 100% rename from app/assets/images/emoji/orange_book.png rename to vendor/assets/images/emoji/orange_book.png diff --git a/app/assets/images/emoji/outbox_tray.png b/vendor/assets/images/emoji/outbox_tray.png similarity index 100% rename from app/assets/images/emoji/outbox_tray.png rename to vendor/assets/images/emoji/outbox_tray.png diff --git a/app/assets/images/emoji/ox.png b/vendor/assets/images/emoji/ox.png similarity index 100% rename from app/assets/images/emoji/ox.png rename to vendor/assets/images/emoji/ox.png diff --git a/app/assets/images/emoji/page_facing_up.png b/vendor/assets/images/emoji/page_facing_up.png similarity index 100% rename from app/assets/images/emoji/page_facing_up.png rename to vendor/assets/images/emoji/page_facing_up.png diff --git a/app/assets/images/emoji/page_with_curl.png b/vendor/assets/images/emoji/page_with_curl.png similarity index 100% rename from app/assets/images/emoji/page_with_curl.png rename to vendor/assets/images/emoji/page_with_curl.png diff --git a/app/assets/images/emoji/pager.png b/vendor/assets/images/emoji/pager.png similarity index 100% rename from app/assets/images/emoji/pager.png rename to vendor/assets/images/emoji/pager.png diff --git a/app/assets/images/emoji/palm_tree.png b/vendor/assets/images/emoji/palm_tree.png similarity index 100% rename from app/assets/images/emoji/palm_tree.png rename to vendor/assets/images/emoji/palm_tree.png diff --git a/app/assets/images/emoji/panda_face.png b/vendor/assets/images/emoji/panda_face.png similarity index 100% rename from app/assets/images/emoji/panda_face.png rename to vendor/assets/images/emoji/panda_face.png diff --git a/app/assets/images/emoji/paperclip.png b/vendor/assets/images/emoji/paperclip.png similarity index 100% rename from app/assets/images/emoji/paperclip.png rename to vendor/assets/images/emoji/paperclip.png diff --git a/app/assets/images/emoji/parking.png b/vendor/assets/images/emoji/parking.png similarity index 100% rename from app/assets/images/emoji/parking.png rename to vendor/assets/images/emoji/parking.png diff --git a/app/assets/images/emoji/part_alternation_mark.png b/vendor/assets/images/emoji/part_alternation_mark.png similarity index 100% rename from app/assets/images/emoji/part_alternation_mark.png rename to vendor/assets/images/emoji/part_alternation_mark.png diff --git a/app/assets/images/emoji/partly_sunny.png b/vendor/assets/images/emoji/partly_sunny.png similarity index 100% rename from app/assets/images/emoji/partly_sunny.png rename to vendor/assets/images/emoji/partly_sunny.png diff --git a/app/assets/images/emoji/passport_control.png b/vendor/assets/images/emoji/passport_control.png similarity index 100% rename from app/assets/images/emoji/passport_control.png rename to vendor/assets/images/emoji/passport_control.png diff --git a/app/assets/images/emoji/paw_prints.png b/vendor/assets/images/emoji/paw_prints.png similarity index 100% rename from app/assets/images/emoji/paw_prints.png rename to vendor/assets/images/emoji/paw_prints.png diff --git a/app/assets/images/emoji/peach.png b/vendor/assets/images/emoji/peach.png similarity index 100% rename from app/assets/images/emoji/peach.png rename to vendor/assets/images/emoji/peach.png diff --git a/app/assets/images/emoji/pear.png b/vendor/assets/images/emoji/pear.png similarity index 100% rename from app/assets/images/emoji/pear.png rename to vendor/assets/images/emoji/pear.png diff --git a/app/assets/images/emoji/pencil.png b/vendor/assets/images/emoji/pencil.png similarity index 100% rename from app/assets/images/emoji/pencil.png rename to vendor/assets/images/emoji/pencil.png diff --git a/app/assets/images/emoji/pencil2.png b/vendor/assets/images/emoji/pencil2.png similarity index 100% rename from app/assets/images/emoji/pencil2.png rename to vendor/assets/images/emoji/pencil2.png diff --git a/app/assets/images/emoji/penguin.png b/vendor/assets/images/emoji/penguin.png similarity index 100% rename from app/assets/images/emoji/penguin.png rename to vendor/assets/images/emoji/penguin.png diff --git a/app/assets/images/emoji/pensive.png b/vendor/assets/images/emoji/pensive.png similarity index 100% rename from app/assets/images/emoji/pensive.png rename to vendor/assets/images/emoji/pensive.png diff --git a/app/assets/images/emoji/performing_arts.png b/vendor/assets/images/emoji/performing_arts.png similarity index 100% rename from app/assets/images/emoji/performing_arts.png rename to vendor/assets/images/emoji/performing_arts.png diff --git a/app/assets/images/emoji/persevere.png b/vendor/assets/images/emoji/persevere.png similarity index 100% rename from app/assets/images/emoji/persevere.png rename to vendor/assets/images/emoji/persevere.png diff --git a/app/assets/images/emoji/person_frowning.png b/vendor/assets/images/emoji/person_frowning.png similarity index 100% rename from app/assets/images/emoji/person_frowning.png rename to vendor/assets/images/emoji/person_frowning.png diff --git a/app/assets/images/emoji/person_with_blond_hair.png b/vendor/assets/images/emoji/person_with_blond_hair.png similarity index 100% rename from app/assets/images/emoji/person_with_blond_hair.png rename to vendor/assets/images/emoji/person_with_blond_hair.png diff --git a/app/assets/images/emoji/person_with_pouting_face.png b/vendor/assets/images/emoji/person_with_pouting_face.png similarity index 100% rename from app/assets/images/emoji/person_with_pouting_face.png rename to vendor/assets/images/emoji/person_with_pouting_face.png diff --git a/app/assets/images/emoji/phone.png b/vendor/assets/images/emoji/phone.png similarity index 100% rename from app/assets/images/emoji/phone.png rename to vendor/assets/images/emoji/phone.png diff --git a/app/assets/images/emoji/pig.png b/vendor/assets/images/emoji/pig.png similarity index 100% rename from app/assets/images/emoji/pig.png rename to vendor/assets/images/emoji/pig.png diff --git a/app/assets/images/emoji/pig2.png b/vendor/assets/images/emoji/pig2.png similarity index 100% rename from app/assets/images/emoji/pig2.png rename to vendor/assets/images/emoji/pig2.png diff --git a/app/assets/images/emoji/pig_nose.png b/vendor/assets/images/emoji/pig_nose.png similarity index 100% rename from app/assets/images/emoji/pig_nose.png rename to vendor/assets/images/emoji/pig_nose.png diff --git a/app/assets/images/emoji/pill.png b/vendor/assets/images/emoji/pill.png similarity index 100% rename from app/assets/images/emoji/pill.png rename to vendor/assets/images/emoji/pill.png diff --git a/app/assets/images/emoji/pineapple.png b/vendor/assets/images/emoji/pineapple.png similarity index 100% rename from app/assets/images/emoji/pineapple.png rename to vendor/assets/images/emoji/pineapple.png diff --git a/app/assets/images/emoji/pisces.png b/vendor/assets/images/emoji/pisces.png similarity index 100% rename from app/assets/images/emoji/pisces.png rename to vendor/assets/images/emoji/pisces.png diff --git a/app/assets/images/emoji/pizza.png b/vendor/assets/images/emoji/pizza.png similarity index 100% rename from app/assets/images/emoji/pizza.png rename to vendor/assets/images/emoji/pizza.png diff --git a/app/assets/images/emoji/plus1.png b/vendor/assets/images/emoji/plus1.png similarity index 100% rename from app/assets/images/emoji/plus1.png rename to vendor/assets/images/emoji/plus1.png diff --git a/app/assets/images/emoji/point_down.png b/vendor/assets/images/emoji/point_down.png similarity index 100% rename from app/assets/images/emoji/point_down.png rename to vendor/assets/images/emoji/point_down.png diff --git a/app/assets/images/emoji/point_left.png b/vendor/assets/images/emoji/point_left.png similarity index 100% rename from app/assets/images/emoji/point_left.png rename to vendor/assets/images/emoji/point_left.png diff --git a/app/assets/images/emoji/point_right.png b/vendor/assets/images/emoji/point_right.png similarity index 100% rename from app/assets/images/emoji/point_right.png rename to vendor/assets/images/emoji/point_right.png diff --git a/app/assets/images/emoji/point_up.png b/vendor/assets/images/emoji/point_up.png similarity index 100% rename from app/assets/images/emoji/point_up.png rename to vendor/assets/images/emoji/point_up.png diff --git a/app/assets/images/emoji/point_up_2.png b/vendor/assets/images/emoji/point_up_2.png similarity index 100% rename from app/assets/images/emoji/point_up_2.png rename to vendor/assets/images/emoji/point_up_2.png diff --git a/app/assets/images/emoji/police_car.png b/vendor/assets/images/emoji/police_car.png similarity index 100% rename from app/assets/images/emoji/police_car.png rename to vendor/assets/images/emoji/police_car.png diff --git a/app/assets/images/emoji/poodle.png b/vendor/assets/images/emoji/poodle.png similarity index 100% rename from app/assets/images/emoji/poodle.png rename to vendor/assets/images/emoji/poodle.png diff --git a/app/assets/images/emoji/poop.png b/vendor/assets/images/emoji/poop.png similarity index 100% rename from app/assets/images/emoji/poop.png rename to vendor/assets/images/emoji/poop.png diff --git a/app/assets/images/emoji/post_office.png b/vendor/assets/images/emoji/post_office.png similarity index 100% rename from app/assets/images/emoji/post_office.png rename to vendor/assets/images/emoji/post_office.png diff --git a/app/assets/images/emoji/postal_horn.png b/vendor/assets/images/emoji/postal_horn.png similarity index 100% rename from app/assets/images/emoji/postal_horn.png rename to vendor/assets/images/emoji/postal_horn.png diff --git a/app/assets/images/emoji/postbox.png b/vendor/assets/images/emoji/postbox.png similarity index 100% rename from app/assets/images/emoji/postbox.png rename to vendor/assets/images/emoji/postbox.png diff --git a/app/assets/images/emoji/potable_water.png b/vendor/assets/images/emoji/potable_water.png similarity index 100% rename from app/assets/images/emoji/potable_water.png rename to vendor/assets/images/emoji/potable_water.png diff --git a/app/assets/images/emoji/pouch.png b/vendor/assets/images/emoji/pouch.png similarity index 100% rename from app/assets/images/emoji/pouch.png rename to vendor/assets/images/emoji/pouch.png diff --git a/app/assets/images/emoji/poultry_leg.png b/vendor/assets/images/emoji/poultry_leg.png similarity index 100% rename from app/assets/images/emoji/poultry_leg.png rename to vendor/assets/images/emoji/poultry_leg.png diff --git a/app/assets/images/emoji/pound.png b/vendor/assets/images/emoji/pound.png similarity index 100% rename from app/assets/images/emoji/pound.png rename to vendor/assets/images/emoji/pound.png diff --git a/app/assets/images/emoji/pouting_cat.png b/vendor/assets/images/emoji/pouting_cat.png similarity index 100% rename from app/assets/images/emoji/pouting_cat.png rename to vendor/assets/images/emoji/pouting_cat.png diff --git a/app/assets/images/emoji/pray.png b/vendor/assets/images/emoji/pray.png similarity index 100% rename from app/assets/images/emoji/pray.png rename to vendor/assets/images/emoji/pray.png diff --git a/app/assets/images/emoji/princess.png b/vendor/assets/images/emoji/princess.png similarity index 100% rename from app/assets/images/emoji/princess.png rename to vendor/assets/images/emoji/princess.png diff --git a/app/assets/images/emoji/punch.png b/vendor/assets/images/emoji/punch.png similarity index 100% rename from app/assets/images/emoji/punch.png rename to vendor/assets/images/emoji/punch.png diff --git a/app/assets/images/emoji/purple_heart.png b/vendor/assets/images/emoji/purple_heart.png similarity index 100% rename from app/assets/images/emoji/purple_heart.png rename to vendor/assets/images/emoji/purple_heart.png diff --git a/app/assets/images/emoji/purse.png b/vendor/assets/images/emoji/purse.png similarity index 100% rename from app/assets/images/emoji/purse.png rename to vendor/assets/images/emoji/purse.png diff --git a/app/assets/images/emoji/pushpin.png b/vendor/assets/images/emoji/pushpin.png similarity index 100% rename from app/assets/images/emoji/pushpin.png rename to vendor/assets/images/emoji/pushpin.png diff --git a/app/assets/images/emoji/put_litter_in_its_place.png b/vendor/assets/images/emoji/put_litter_in_its_place.png similarity index 100% rename from app/assets/images/emoji/put_litter_in_its_place.png rename to vendor/assets/images/emoji/put_litter_in_its_place.png diff --git a/app/assets/images/emoji/question.png b/vendor/assets/images/emoji/question.png similarity index 100% rename from app/assets/images/emoji/question.png rename to vendor/assets/images/emoji/question.png diff --git a/app/assets/images/emoji/rabbit.png b/vendor/assets/images/emoji/rabbit.png similarity index 100% rename from app/assets/images/emoji/rabbit.png rename to vendor/assets/images/emoji/rabbit.png diff --git a/app/assets/images/emoji/rabbit2.png b/vendor/assets/images/emoji/rabbit2.png similarity index 100% rename from app/assets/images/emoji/rabbit2.png rename to vendor/assets/images/emoji/rabbit2.png diff --git a/app/assets/images/emoji/racehorse.png b/vendor/assets/images/emoji/racehorse.png similarity index 100% rename from app/assets/images/emoji/racehorse.png rename to vendor/assets/images/emoji/racehorse.png diff --git a/app/assets/images/emoji/radio.png b/vendor/assets/images/emoji/radio.png similarity index 100% rename from app/assets/images/emoji/radio.png rename to vendor/assets/images/emoji/radio.png diff --git a/app/assets/images/emoji/radio_button.png b/vendor/assets/images/emoji/radio_button.png similarity index 100% rename from app/assets/images/emoji/radio_button.png rename to vendor/assets/images/emoji/radio_button.png diff --git a/app/assets/images/emoji/rage.png b/vendor/assets/images/emoji/rage.png similarity index 100% rename from app/assets/images/emoji/rage.png rename to vendor/assets/images/emoji/rage.png diff --git a/app/assets/images/emoji/rage1.png b/vendor/assets/images/emoji/rage1.png similarity index 100% rename from app/assets/images/emoji/rage1.png rename to vendor/assets/images/emoji/rage1.png diff --git a/app/assets/images/emoji/rage2.png b/vendor/assets/images/emoji/rage2.png similarity index 100% rename from app/assets/images/emoji/rage2.png rename to vendor/assets/images/emoji/rage2.png diff --git a/app/assets/images/emoji/rage3.png b/vendor/assets/images/emoji/rage3.png similarity index 100% rename from app/assets/images/emoji/rage3.png rename to vendor/assets/images/emoji/rage3.png diff --git a/app/assets/images/emoji/rage4.png b/vendor/assets/images/emoji/rage4.png similarity index 100% rename from app/assets/images/emoji/rage4.png rename to vendor/assets/images/emoji/rage4.png diff --git a/app/assets/images/emoji/railway_car.png b/vendor/assets/images/emoji/railway_car.png similarity index 100% rename from app/assets/images/emoji/railway_car.png rename to vendor/assets/images/emoji/railway_car.png diff --git a/app/assets/images/emoji/rainbow.png b/vendor/assets/images/emoji/rainbow.png similarity index 100% rename from app/assets/images/emoji/rainbow.png rename to vendor/assets/images/emoji/rainbow.png diff --git a/app/assets/images/emoji/raised_hand.png b/vendor/assets/images/emoji/raised_hand.png similarity index 100% rename from app/assets/images/emoji/raised_hand.png rename to vendor/assets/images/emoji/raised_hand.png diff --git a/app/assets/images/emoji/raised_hands.png b/vendor/assets/images/emoji/raised_hands.png similarity index 100% rename from app/assets/images/emoji/raised_hands.png rename to vendor/assets/images/emoji/raised_hands.png diff --git a/app/assets/images/emoji/ram.png b/vendor/assets/images/emoji/ram.png similarity index 100% rename from app/assets/images/emoji/ram.png rename to vendor/assets/images/emoji/ram.png diff --git a/app/assets/images/emoji/ramen.png b/vendor/assets/images/emoji/ramen.png similarity index 100% rename from app/assets/images/emoji/ramen.png rename to vendor/assets/images/emoji/ramen.png diff --git a/app/assets/images/emoji/rat.png b/vendor/assets/images/emoji/rat.png similarity index 100% rename from app/assets/images/emoji/rat.png rename to vendor/assets/images/emoji/rat.png diff --git a/app/assets/images/emoji/recycle.png b/vendor/assets/images/emoji/recycle.png similarity index 100% rename from app/assets/images/emoji/recycle.png rename to vendor/assets/images/emoji/recycle.png diff --git a/app/assets/images/emoji/red_car.png b/vendor/assets/images/emoji/red_car.png similarity index 100% rename from app/assets/images/emoji/red_car.png rename to vendor/assets/images/emoji/red_car.png diff --git a/app/assets/images/emoji/red_circle.png b/vendor/assets/images/emoji/red_circle.png similarity index 100% rename from app/assets/images/emoji/red_circle.png rename to vendor/assets/images/emoji/red_circle.png diff --git a/app/assets/images/emoji/registered.png b/vendor/assets/images/emoji/registered.png similarity index 100% rename from app/assets/images/emoji/registered.png rename to vendor/assets/images/emoji/registered.png diff --git a/app/assets/images/emoji/relaxed.png b/vendor/assets/images/emoji/relaxed.png similarity index 100% rename from app/assets/images/emoji/relaxed.png rename to vendor/assets/images/emoji/relaxed.png diff --git a/app/assets/images/emoji/relieved.png b/vendor/assets/images/emoji/relieved.png similarity index 100% rename from app/assets/images/emoji/relieved.png rename to vendor/assets/images/emoji/relieved.png diff --git a/app/assets/images/emoji/repeat.png b/vendor/assets/images/emoji/repeat.png similarity index 100% rename from app/assets/images/emoji/repeat.png rename to vendor/assets/images/emoji/repeat.png diff --git a/app/assets/images/emoji/repeat_one.png b/vendor/assets/images/emoji/repeat_one.png similarity index 100% rename from app/assets/images/emoji/repeat_one.png rename to vendor/assets/images/emoji/repeat_one.png diff --git a/app/assets/images/emoji/restroom.png b/vendor/assets/images/emoji/restroom.png similarity index 100% rename from app/assets/images/emoji/restroom.png rename to vendor/assets/images/emoji/restroom.png diff --git a/app/assets/images/emoji/revolving_hearts.png b/vendor/assets/images/emoji/revolving_hearts.png similarity index 100% rename from app/assets/images/emoji/revolving_hearts.png rename to vendor/assets/images/emoji/revolving_hearts.png diff --git a/app/assets/images/emoji/rewind.png b/vendor/assets/images/emoji/rewind.png similarity index 100% rename from app/assets/images/emoji/rewind.png rename to vendor/assets/images/emoji/rewind.png diff --git a/app/assets/images/emoji/ribbon.png b/vendor/assets/images/emoji/ribbon.png similarity index 100% rename from app/assets/images/emoji/ribbon.png rename to vendor/assets/images/emoji/ribbon.png diff --git a/app/assets/images/emoji/rice.png b/vendor/assets/images/emoji/rice.png similarity index 100% rename from app/assets/images/emoji/rice.png rename to vendor/assets/images/emoji/rice.png diff --git a/app/assets/images/emoji/rice_ball.png b/vendor/assets/images/emoji/rice_ball.png similarity index 100% rename from app/assets/images/emoji/rice_ball.png rename to vendor/assets/images/emoji/rice_ball.png diff --git a/app/assets/images/emoji/rice_cracker.png b/vendor/assets/images/emoji/rice_cracker.png similarity index 100% rename from app/assets/images/emoji/rice_cracker.png rename to vendor/assets/images/emoji/rice_cracker.png diff --git a/app/assets/images/emoji/rice_scene.png b/vendor/assets/images/emoji/rice_scene.png similarity index 100% rename from app/assets/images/emoji/rice_scene.png rename to vendor/assets/images/emoji/rice_scene.png diff --git a/app/assets/images/emoji/ring.png b/vendor/assets/images/emoji/ring.png similarity index 100% rename from app/assets/images/emoji/ring.png rename to vendor/assets/images/emoji/ring.png diff --git a/app/assets/images/emoji/rocket.png b/vendor/assets/images/emoji/rocket.png similarity index 100% rename from app/assets/images/emoji/rocket.png rename to vendor/assets/images/emoji/rocket.png diff --git a/app/assets/images/emoji/roller_coaster.png b/vendor/assets/images/emoji/roller_coaster.png similarity index 100% rename from app/assets/images/emoji/roller_coaster.png rename to vendor/assets/images/emoji/roller_coaster.png diff --git a/app/assets/images/emoji/rooster.png b/vendor/assets/images/emoji/rooster.png similarity index 100% rename from app/assets/images/emoji/rooster.png rename to vendor/assets/images/emoji/rooster.png diff --git a/app/assets/images/emoji/rose.png b/vendor/assets/images/emoji/rose.png similarity index 100% rename from app/assets/images/emoji/rose.png rename to vendor/assets/images/emoji/rose.png diff --git a/app/assets/images/emoji/rotating_light.png b/vendor/assets/images/emoji/rotating_light.png similarity index 100% rename from app/assets/images/emoji/rotating_light.png rename to vendor/assets/images/emoji/rotating_light.png diff --git a/app/assets/images/emoji/round_pushpin.png b/vendor/assets/images/emoji/round_pushpin.png similarity index 100% rename from app/assets/images/emoji/round_pushpin.png rename to vendor/assets/images/emoji/round_pushpin.png diff --git a/app/assets/images/emoji/rowboat.png b/vendor/assets/images/emoji/rowboat.png similarity index 100% rename from app/assets/images/emoji/rowboat.png rename to vendor/assets/images/emoji/rowboat.png diff --git a/app/assets/images/emoji/ru.png b/vendor/assets/images/emoji/ru.png similarity index 100% rename from app/assets/images/emoji/ru.png rename to vendor/assets/images/emoji/ru.png diff --git a/app/assets/images/emoji/rugby_football.png b/vendor/assets/images/emoji/rugby_football.png similarity index 100% rename from app/assets/images/emoji/rugby_football.png rename to vendor/assets/images/emoji/rugby_football.png diff --git a/app/assets/images/emoji/runner.png b/vendor/assets/images/emoji/runner.png similarity index 100% rename from app/assets/images/emoji/runner.png rename to vendor/assets/images/emoji/runner.png diff --git a/app/assets/images/emoji/running.png b/vendor/assets/images/emoji/running.png similarity index 100% rename from app/assets/images/emoji/running.png rename to vendor/assets/images/emoji/running.png diff --git a/app/assets/images/emoji/running_shirt_with_sash.png b/vendor/assets/images/emoji/running_shirt_with_sash.png similarity index 100% rename from app/assets/images/emoji/running_shirt_with_sash.png rename to vendor/assets/images/emoji/running_shirt_with_sash.png diff --git a/app/assets/images/emoji/sa.png b/vendor/assets/images/emoji/sa.png similarity index 100% rename from app/assets/images/emoji/sa.png rename to vendor/assets/images/emoji/sa.png diff --git a/app/assets/images/emoji/sagittarius.png b/vendor/assets/images/emoji/sagittarius.png similarity index 100% rename from app/assets/images/emoji/sagittarius.png rename to vendor/assets/images/emoji/sagittarius.png diff --git a/app/assets/images/emoji/sailboat.png b/vendor/assets/images/emoji/sailboat.png similarity index 100% rename from app/assets/images/emoji/sailboat.png rename to vendor/assets/images/emoji/sailboat.png diff --git a/app/assets/images/emoji/sake.png b/vendor/assets/images/emoji/sake.png similarity index 100% rename from app/assets/images/emoji/sake.png rename to vendor/assets/images/emoji/sake.png diff --git a/app/assets/images/emoji/sandal.png b/vendor/assets/images/emoji/sandal.png similarity index 100% rename from app/assets/images/emoji/sandal.png rename to vendor/assets/images/emoji/sandal.png diff --git a/app/assets/images/emoji/santa.png b/vendor/assets/images/emoji/santa.png similarity index 100% rename from app/assets/images/emoji/santa.png rename to vendor/assets/images/emoji/santa.png diff --git a/app/assets/images/emoji/satellite.png b/vendor/assets/images/emoji/satellite.png similarity index 100% rename from app/assets/images/emoji/satellite.png rename to vendor/assets/images/emoji/satellite.png diff --git a/app/assets/images/emoji/satisfied.png b/vendor/assets/images/emoji/satisfied.png similarity index 100% rename from app/assets/images/emoji/satisfied.png rename to vendor/assets/images/emoji/satisfied.png diff --git a/app/assets/images/emoji/saxophone.png b/vendor/assets/images/emoji/saxophone.png similarity index 100% rename from app/assets/images/emoji/saxophone.png rename to vendor/assets/images/emoji/saxophone.png diff --git a/app/assets/images/emoji/school.png b/vendor/assets/images/emoji/school.png similarity index 100% rename from app/assets/images/emoji/school.png rename to vendor/assets/images/emoji/school.png diff --git a/app/assets/images/emoji/school_satchel.png b/vendor/assets/images/emoji/school_satchel.png similarity index 100% rename from app/assets/images/emoji/school_satchel.png rename to vendor/assets/images/emoji/school_satchel.png diff --git a/app/assets/images/emoji/scissors.png b/vendor/assets/images/emoji/scissors.png similarity index 100% rename from app/assets/images/emoji/scissors.png rename to vendor/assets/images/emoji/scissors.png diff --git a/app/assets/images/emoji/scorpius.png b/vendor/assets/images/emoji/scorpius.png similarity index 100% rename from app/assets/images/emoji/scorpius.png rename to vendor/assets/images/emoji/scorpius.png diff --git a/app/assets/images/emoji/scream.png b/vendor/assets/images/emoji/scream.png similarity index 100% rename from app/assets/images/emoji/scream.png rename to vendor/assets/images/emoji/scream.png diff --git a/app/assets/images/emoji/scream_cat.png b/vendor/assets/images/emoji/scream_cat.png similarity index 100% rename from app/assets/images/emoji/scream_cat.png rename to vendor/assets/images/emoji/scream_cat.png diff --git a/app/assets/images/emoji/scroll.png b/vendor/assets/images/emoji/scroll.png similarity index 100% rename from app/assets/images/emoji/scroll.png rename to vendor/assets/images/emoji/scroll.png diff --git a/app/assets/images/emoji/seat.png b/vendor/assets/images/emoji/seat.png similarity index 100% rename from app/assets/images/emoji/seat.png rename to vendor/assets/images/emoji/seat.png diff --git a/app/assets/images/emoji/secret.png b/vendor/assets/images/emoji/secret.png similarity index 100% rename from app/assets/images/emoji/secret.png rename to vendor/assets/images/emoji/secret.png diff --git a/app/assets/images/emoji/see_no_evil.png b/vendor/assets/images/emoji/see_no_evil.png similarity index 100% rename from app/assets/images/emoji/see_no_evil.png rename to vendor/assets/images/emoji/see_no_evil.png diff --git a/app/assets/images/emoji/seedling.png b/vendor/assets/images/emoji/seedling.png similarity index 100% rename from app/assets/images/emoji/seedling.png rename to vendor/assets/images/emoji/seedling.png diff --git a/app/assets/images/emoji/seven.png b/vendor/assets/images/emoji/seven.png similarity index 100% rename from app/assets/images/emoji/seven.png rename to vendor/assets/images/emoji/seven.png diff --git a/app/assets/images/emoji/shaved_ice.png b/vendor/assets/images/emoji/shaved_ice.png similarity index 100% rename from app/assets/images/emoji/shaved_ice.png rename to vendor/assets/images/emoji/shaved_ice.png diff --git a/app/assets/images/emoji/sheep.png b/vendor/assets/images/emoji/sheep.png similarity index 100% rename from app/assets/images/emoji/sheep.png rename to vendor/assets/images/emoji/sheep.png diff --git a/app/assets/images/emoji/shell.png b/vendor/assets/images/emoji/shell.png similarity index 100% rename from app/assets/images/emoji/shell.png rename to vendor/assets/images/emoji/shell.png diff --git a/app/assets/images/emoji/ship.png b/vendor/assets/images/emoji/ship.png similarity index 100% rename from app/assets/images/emoji/ship.png rename to vendor/assets/images/emoji/ship.png diff --git a/app/assets/images/emoji/shipit.png b/vendor/assets/images/emoji/shipit.png similarity index 100% rename from app/assets/images/emoji/shipit.png rename to vendor/assets/images/emoji/shipit.png diff --git a/app/assets/images/emoji/shirt.png b/vendor/assets/images/emoji/shirt.png similarity index 100% rename from app/assets/images/emoji/shirt.png rename to vendor/assets/images/emoji/shirt.png diff --git a/app/assets/images/emoji/shit.png b/vendor/assets/images/emoji/shit.png similarity index 100% rename from app/assets/images/emoji/shit.png rename to vendor/assets/images/emoji/shit.png diff --git a/app/assets/images/emoji/shoe.png b/vendor/assets/images/emoji/shoe.png similarity index 100% rename from app/assets/images/emoji/shoe.png rename to vendor/assets/images/emoji/shoe.png diff --git a/app/assets/images/emoji/shower.png b/vendor/assets/images/emoji/shower.png similarity index 100% rename from app/assets/images/emoji/shower.png rename to vendor/assets/images/emoji/shower.png diff --git a/app/assets/images/emoji/signal_strength.png b/vendor/assets/images/emoji/signal_strength.png similarity index 100% rename from app/assets/images/emoji/signal_strength.png rename to vendor/assets/images/emoji/signal_strength.png diff --git a/app/assets/images/emoji/six.png b/vendor/assets/images/emoji/six.png similarity index 100% rename from app/assets/images/emoji/six.png rename to vendor/assets/images/emoji/six.png diff --git a/app/assets/images/emoji/six_pointed_star.png b/vendor/assets/images/emoji/six_pointed_star.png similarity index 100% rename from app/assets/images/emoji/six_pointed_star.png rename to vendor/assets/images/emoji/six_pointed_star.png diff --git a/app/assets/images/emoji/ski.png b/vendor/assets/images/emoji/ski.png similarity index 100% rename from app/assets/images/emoji/ski.png rename to vendor/assets/images/emoji/ski.png diff --git a/app/assets/images/emoji/skull.png b/vendor/assets/images/emoji/skull.png similarity index 100% rename from app/assets/images/emoji/skull.png rename to vendor/assets/images/emoji/skull.png diff --git a/app/assets/images/emoji/sleepy.png b/vendor/assets/images/emoji/sleepy.png similarity index 100% rename from app/assets/images/emoji/sleepy.png rename to vendor/assets/images/emoji/sleepy.png diff --git a/app/assets/images/emoji/slot_machine.png b/vendor/assets/images/emoji/slot_machine.png similarity index 100% rename from app/assets/images/emoji/slot_machine.png rename to vendor/assets/images/emoji/slot_machine.png diff --git a/app/assets/images/emoji/small_blue_diamond.png b/vendor/assets/images/emoji/small_blue_diamond.png similarity index 100% rename from app/assets/images/emoji/small_blue_diamond.png rename to vendor/assets/images/emoji/small_blue_diamond.png diff --git a/app/assets/images/emoji/small_orange_diamond.png b/vendor/assets/images/emoji/small_orange_diamond.png similarity index 100% rename from app/assets/images/emoji/small_orange_diamond.png rename to vendor/assets/images/emoji/small_orange_diamond.png diff --git a/app/assets/images/emoji/small_red_triangle.png b/vendor/assets/images/emoji/small_red_triangle.png similarity index 100% rename from app/assets/images/emoji/small_red_triangle.png rename to vendor/assets/images/emoji/small_red_triangle.png diff --git a/app/assets/images/emoji/small_red_triangle_down.png b/vendor/assets/images/emoji/small_red_triangle_down.png similarity index 100% rename from app/assets/images/emoji/small_red_triangle_down.png rename to vendor/assets/images/emoji/small_red_triangle_down.png diff --git a/app/assets/images/emoji/smile.png b/vendor/assets/images/emoji/smile.png similarity index 100% rename from app/assets/images/emoji/smile.png rename to vendor/assets/images/emoji/smile.png diff --git a/app/assets/images/emoji/smile_cat.png b/vendor/assets/images/emoji/smile_cat.png similarity index 100% rename from app/assets/images/emoji/smile_cat.png rename to vendor/assets/images/emoji/smile_cat.png diff --git a/app/assets/images/emoji/smiley.png b/vendor/assets/images/emoji/smiley.png similarity index 100% rename from app/assets/images/emoji/smiley.png rename to vendor/assets/images/emoji/smiley.png diff --git a/app/assets/images/emoji/smiley_cat.png b/vendor/assets/images/emoji/smiley_cat.png similarity index 100% rename from app/assets/images/emoji/smiley_cat.png rename to vendor/assets/images/emoji/smiley_cat.png diff --git a/app/assets/images/emoji/smiling_imp.png b/vendor/assets/images/emoji/smiling_imp.png similarity index 100% rename from app/assets/images/emoji/smiling_imp.png rename to vendor/assets/images/emoji/smiling_imp.png diff --git a/app/assets/images/emoji/smirk.png b/vendor/assets/images/emoji/smirk.png similarity index 100% rename from app/assets/images/emoji/smirk.png rename to vendor/assets/images/emoji/smirk.png diff --git a/app/assets/images/emoji/smirk_cat.png b/vendor/assets/images/emoji/smirk_cat.png similarity index 100% rename from app/assets/images/emoji/smirk_cat.png rename to vendor/assets/images/emoji/smirk_cat.png diff --git a/app/assets/images/emoji/smoking.png b/vendor/assets/images/emoji/smoking.png similarity index 100% rename from app/assets/images/emoji/smoking.png rename to vendor/assets/images/emoji/smoking.png diff --git a/app/assets/images/emoji/snail.png b/vendor/assets/images/emoji/snail.png similarity index 100% rename from app/assets/images/emoji/snail.png rename to vendor/assets/images/emoji/snail.png diff --git a/app/assets/images/emoji/snake.png b/vendor/assets/images/emoji/snake.png similarity index 100% rename from app/assets/images/emoji/snake.png rename to vendor/assets/images/emoji/snake.png diff --git a/app/assets/images/emoji/snowboarder.png b/vendor/assets/images/emoji/snowboarder.png similarity index 100% rename from app/assets/images/emoji/snowboarder.png rename to vendor/assets/images/emoji/snowboarder.png diff --git a/app/assets/images/emoji/snowflake.png b/vendor/assets/images/emoji/snowflake.png similarity index 100% rename from app/assets/images/emoji/snowflake.png rename to vendor/assets/images/emoji/snowflake.png diff --git a/app/assets/images/emoji/snowman.png b/vendor/assets/images/emoji/snowman.png similarity index 100% rename from app/assets/images/emoji/snowman.png rename to vendor/assets/images/emoji/snowman.png diff --git a/app/assets/images/emoji/sob.png b/vendor/assets/images/emoji/sob.png similarity index 100% rename from app/assets/images/emoji/sob.png rename to vendor/assets/images/emoji/sob.png diff --git a/app/assets/images/emoji/soccer.png b/vendor/assets/images/emoji/soccer.png similarity index 100% rename from app/assets/images/emoji/soccer.png rename to vendor/assets/images/emoji/soccer.png diff --git a/app/assets/images/emoji/soon.png b/vendor/assets/images/emoji/soon.png similarity index 100% rename from app/assets/images/emoji/soon.png rename to vendor/assets/images/emoji/soon.png diff --git a/app/assets/images/emoji/sos.png b/vendor/assets/images/emoji/sos.png similarity index 100% rename from app/assets/images/emoji/sos.png rename to vendor/assets/images/emoji/sos.png diff --git a/app/assets/images/emoji/sound.png b/vendor/assets/images/emoji/sound.png similarity index 100% rename from app/assets/images/emoji/sound.png rename to vendor/assets/images/emoji/sound.png diff --git a/app/assets/images/emoji/space_invader.png b/vendor/assets/images/emoji/space_invader.png similarity index 100% rename from app/assets/images/emoji/space_invader.png rename to vendor/assets/images/emoji/space_invader.png diff --git a/app/assets/images/emoji/spades.png b/vendor/assets/images/emoji/spades.png similarity index 100% rename from app/assets/images/emoji/spades.png rename to vendor/assets/images/emoji/spades.png diff --git a/app/assets/images/emoji/spaghetti.png b/vendor/assets/images/emoji/spaghetti.png similarity index 100% rename from app/assets/images/emoji/spaghetti.png rename to vendor/assets/images/emoji/spaghetti.png diff --git a/app/assets/images/emoji/sparkler.png b/vendor/assets/images/emoji/sparkler.png similarity index 100% rename from app/assets/images/emoji/sparkler.png rename to vendor/assets/images/emoji/sparkler.png diff --git a/app/assets/images/emoji/sparkles.png b/vendor/assets/images/emoji/sparkles.png similarity index 100% rename from app/assets/images/emoji/sparkles.png rename to vendor/assets/images/emoji/sparkles.png diff --git a/app/assets/images/emoji/speak_no_evil.png b/vendor/assets/images/emoji/speak_no_evil.png similarity index 100% rename from app/assets/images/emoji/speak_no_evil.png rename to vendor/assets/images/emoji/speak_no_evil.png diff --git a/app/assets/images/emoji/speaker.png b/vendor/assets/images/emoji/speaker.png similarity index 100% rename from app/assets/images/emoji/speaker.png rename to vendor/assets/images/emoji/speaker.png diff --git a/app/assets/images/emoji/speech_balloon.png b/vendor/assets/images/emoji/speech_balloon.png similarity index 100% rename from app/assets/images/emoji/speech_balloon.png rename to vendor/assets/images/emoji/speech_balloon.png diff --git a/app/assets/images/emoji/speedboat.png b/vendor/assets/images/emoji/speedboat.png similarity index 100% rename from app/assets/images/emoji/speedboat.png rename to vendor/assets/images/emoji/speedboat.png diff --git a/app/assets/images/emoji/squirrel.png b/vendor/assets/images/emoji/squirrel.png similarity index 100% rename from app/assets/images/emoji/squirrel.png rename to vendor/assets/images/emoji/squirrel.png diff --git a/app/assets/images/emoji/star.png b/vendor/assets/images/emoji/star.png similarity index 100% rename from app/assets/images/emoji/star.png rename to vendor/assets/images/emoji/star.png diff --git a/app/assets/images/emoji/star2.png b/vendor/assets/images/emoji/star2.png similarity index 100% rename from app/assets/images/emoji/star2.png rename to vendor/assets/images/emoji/star2.png diff --git a/app/assets/images/emoji/stars.png b/vendor/assets/images/emoji/stars.png similarity index 100% rename from app/assets/images/emoji/stars.png rename to vendor/assets/images/emoji/stars.png diff --git a/app/assets/images/emoji/station.png b/vendor/assets/images/emoji/station.png similarity index 100% rename from app/assets/images/emoji/station.png rename to vendor/assets/images/emoji/station.png diff --git a/app/assets/images/emoji/statue_of_liberty.png b/vendor/assets/images/emoji/statue_of_liberty.png similarity index 100% rename from app/assets/images/emoji/statue_of_liberty.png rename to vendor/assets/images/emoji/statue_of_liberty.png diff --git a/app/assets/images/emoji/steam_locomotive.png b/vendor/assets/images/emoji/steam_locomotive.png similarity index 100% rename from app/assets/images/emoji/steam_locomotive.png rename to vendor/assets/images/emoji/steam_locomotive.png diff --git a/app/assets/images/emoji/stew.png b/vendor/assets/images/emoji/stew.png similarity index 100% rename from app/assets/images/emoji/stew.png rename to vendor/assets/images/emoji/stew.png diff --git a/app/assets/images/emoji/straight_ruler.png b/vendor/assets/images/emoji/straight_ruler.png similarity index 100% rename from app/assets/images/emoji/straight_ruler.png rename to vendor/assets/images/emoji/straight_ruler.png diff --git a/app/assets/images/emoji/strawberry.png b/vendor/assets/images/emoji/strawberry.png similarity index 100% rename from app/assets/images/emoji/strawberry.png rename to vendor/assets/images/emoji/strawberry.png diff --git a/app/assets/images/emoji/sun_with_face.png b/vendor/assets/images/emoji/sun_with_face.png similarity index 100% rename from app/assets/images/emoji/sun_with_face.png rename to vendor/assets/images/emoji/sun_with_face.png diff --git a/app/assets/images/emoji/sunflower.png b/vendor/assets/images/emoji/sunflower.png similarity index 100% rename from app/assets/images/emoji/sunflower.png rename to vendor/assets/images/emoji/sunflower.png diff --git a/app/assets/images/emoji/sunglasses.png b/vendor/assets/images/emoji/sunglasses.png similarity index 100% rename from app/assets/images/emoji/sunglasses.png rename to vendor/assets/images/emoji/sunglasses.png diff --git a/app/assets/images/emoji/sunny.png b/vendor/assets/images/emoji/sunny.png similarity index 100% rename from app/assets/images/emoji/sunny.png rename to vendor/assets/images/emoji/sunny.png diff --git a/app/assets/images/emoji/sunrise.png b/vendor/assets/images/emoji/sunrise.png similarity index 100% rename from app/assets/images/emoji/sunrise.png rename to vendor/assets/images/emoji/sunrise.png diff --git a/app/assets/images/emoji/sunrise_over_mountains.png b/vendor/assets/images/emoji/sunrise_over_mountains.png similarity index 100% rename from app/assets/images/emoji/sunrise_over_mountains.png rename to vendor/assets/images/emoji/sunrise_over_mountains.png diff --git a/app/assets/images/emoji/surfer.png b/vendor/assets/images/emoji/surfer.png similarity index 100% rename from app/assets/images/emoji/surfer.png rename to vendor/assets/images/emoji/surfer.png diff --git a/app/assets/images/emoji/sushi.png b/vendor/assets/images/emoji/sushi.png similarity index 100% rename from app/assets/images/emoji/sushi.png rename to vendor/assets/images/emoji/sushi.png diff --git a/app/assets/images/emoji/suspect.png b/vendor/assets/images/emoji/suspect.png similarity index 100% rename from app/assets/images/emoji/suspect.png rename to vendor/assets/images/emoji/suspect.png diff --git a/app/assets/images/emoji/suspension_railway.png b/vendor/assets/images/emoji/suspension_railway.png similarity index 100% rename from app/assets/images/emoji/suspension_railway.png rename to vendor/assets/images/emoji/suspension_railway.png diff --git a/app/assets/images/emoji/sweat.png b/vendor/assets/images/emoji/sweat.png similarity index 100% rename from app/assets/images/emoji/sweat.png rename to vendor/assets/images/emoji/sweat.png diff --git a/app/assets/images/emoji/sweat_drops.png b/vendor/assets/images/emoji/sweat_drops.png similarity index 100% rename from app/assets/images/emoji/sweat_drops.png rename to vendor/assets/images/emoji/sweat_drops.png diff --git a/app/assets/images/emoji/sweat_smile.png b/vendor/assets/images/emoji/sweat_smile.png similarity index 100% rename from app/assets/images/emoji/sweat_smile.png rename to vendor/assets/images/emoji/sweat_smile.png diff --git a/app/assets/images/emoji/sweet_potato.png b/vendor/assets/images/emoji/sweet_potato.png similarity index 100% rename from app/assets/images/emoji/sweet_potato.png rename to vendor/assets/images/emoji/sweet_potato.png diff --git a/app/assets/images/emoji/swimmer.png b/vendor/assets/images/emoji/swimmer.png similarity index 100% rename from app/assets/images/emoji/swimmer.png rename to vendor/assets/images/emoji/swimmer.png diff --git a/app/assets/images/emoji/symbols.png b/vendor/assets/images/emoji/symbols.png similarity index 100% rename from app/assets/images/emoji/symbols.png rename to vendor/assets/images/emoji/symbols.png diff --git a/app/assets/images/emoji/syringe.png b/vendor/assets/images/emoji/syringe.png similarity index 100% rename from app/assets/images/emoji/syringe.png rename to vendor/assets/images/emoji/syringe.png diff --git a/app/assets/images/emoji/tada.png b/vendor/assets/images/emoji/tada.png similarity index 100% rename from app/assets/images/emoji/tada.png rename to vendor/assets/images/emoji/tada.png diff --git a/app/assets/images/emoji/tanabata_tree.png b/vendor/assets/images/emoji/tanabata_tree.png similarity index 100% rename from app/assets/images/emoji/tanabata_tree.png rename to vendor/assets/images/emoji/tanabata_tree.png diff --git a/app/assets/images/emoji/tangerine.png b/vendor/assets/images/emoji/tangerine.png similarity index 100% rename from app/assets/images/emoji/tangerine.png rename to vendor/assets/images/emoji/tangerine.png diff --git a/app/assets/images/emoji/taurus.png b/vendor/assets/images/emoji/taurus.png similarity index 100% rename from app/assets/images/emoji/taurus.png rename to vendor/assets/images/emoji/taurus.png diff --git a/app/assets/images/emoji/taxi.png b/vendor/assets/images/emoji/taxi.png similarity index 100% rename from app/assets/images/emoji/taxi.png rename to vendor/assets/images/emoji/taxi.png diff --git a/app/assets/images/emoji/tea.png b/vendor/assets/images/emoji/tea.png similarity index 100% rename from app/assets/images/emoji/tea.png rename to vendor/assets/images/emoji/tea.png diff --git a/app/assets/images/emoji/telephone.png b/vendor/assets/images/emoji/telephone.png similarity index 100% rename from app/assets/images/emoji/telephone.png rename to vendor/assets/images/emoji/telephone.png diff --git a/app/assets/images/emoji/telephone_receiver.png b/vendor/assets/images/emoji/telephone_receiver.png similarity index 100% rename from app/assets/images/emoji/telephone_receiver.png rename to vendor/assets/images/emoji/telephone_receiver.png diff --git a/app/assets/images/emoji/telescope.png b/vendor/assets/images/emoji/telescope.png similarity index 100% rename from app/assets/images/emoji/telescope.png rename to vendor/assets/images/emoji/telescope.png diff --git a/app/assets/images/emoji/tennis.png b/vendor/assets/images/emoji/tennis.png similarity index 100% rename from app/assets/images/emoji/tennis.png rename to vendor/assets/images/emoji/tennis.png diff --git a/app/assets/images/emoji/tent.png b/vendor/assets/images/emoji/tent.png similarity index 100% rename from app/assets/images/emoji/tent.png rename to vendor/assets/images/emoji/tent.png diff --git a/app/assets/images/emoji/thought_balloon.png b/vendor/assets/images/emoji/thought_balloon.png similarity index 100% rename from app/assets/images/emoji/thought_balloon.png rename to vendor/assets/images/emoji/thought_balloon.png diff --git a/app/assets/images/emoji/three.png b/vendor/assets/images/emoji/three.png similarity index 100% rename from app/assets/images/emoji/three.png rename to vendor/assets/images/emoji/three.png diff --git a/app/assets/images/emoji/thumbsdown.png b/vendor/assets/images/emoji/thumbsdown.png similarity index 100% rename from app/assets/images/emoji/thumbsdown.png rename to vendor/assets/images/emoji/thumbsdown.png diff --git a/app/assets/images/emoji/thumbsup.png b/vendor/assets/images/emoji/thumbsup.png similarity index 100% rename from app/assets/images/emoji/thumbsup.png rename to vendor/assets/images/emoji/thumbsup.png diff --git a/app/assets/images/emoji/ticket.png b/vendor/assets/images/emoji/ticket.png similarity index 100% rename from app/assets/images/emoji/ticket.png rename to vendor/assets/images/emoji/ticket.png diff --git a/app/assets/images/emoji/tiger.png b/vendor/assets/images/emoji/tiger.png similarity index 100% rename from app/assets/images/emoji/tiger.png rename to vendor/assets/images/emoji/tiger.png diff --git a/app/assets/images/emoji/tiger2.png b/vendor/assets/images/emoji/tiger2.png similarity index 100% rename from app/assets/images/emoji/tiger2.png rename to vendor/assets/images/emoji/tiger2.png diff --git a/app/assets/images/emoji/tired_face.png b/vendor/assets/images/emoji/tired_face.png similarity index 100% rename from app/assets/images/emoji/tired_face.png rename to vendor/assets/images/emoji/tired_face.png diff --git a/app/assets/images/emoji/tm.png b/vendor/assets/images/emoji/tm.png similarity index 100% rename from app/assets/images/emoji/tm.png rename to vendor/assets/images/emoji/tm.png diff --git a/app/assets/images/emoji/toilet.png b/vendor/assets/images/emoji/toilet.png similarity index 100% rename from app/assets/images/emoji/toilet.png rename to vendor/assets/images/emoji/toilet.png diff --git a/app/assets/images/emoji/tokyo_tower.png b/vendor/assets/images/emoji/tokyo_tower.png similarity index 100% rename from app/assets/images/emoji/tokyo_tower.png rename to vendor/assets/images/emoji/tokyo_tower.png diff --git a/app/assets/images/emoji/tomato.png b/vendor/assets/images/emoji/tomato.png similarity index 100% rename from app/assets/images/emoji/tomato.png rename to vendor/assets/images/emoji/tomato.png diff --git a/app/assets/images/emoji/tongue.png b/vendor/assets/images/emoji/tongue.png similarity index 100% rename from app/assets/images/emoji/tongue.png rename to vendor/assets/images/emoji/tongue.png diff --git a/app/assets/images/emoji/tongue2.png b/vendor/assets/images/emoji/tongue2.png similarity index 100% rename from app/assets/images/emoji/tongue2.png rename to vendor/assets/images/emoji/tongue2.png diff --git a/app/assets/images/emoji/top.png b/vendor/assets/images/emoji/top.png similarity index 100% rename from app/assets/images/emoji/top.png rename to vendor/assets/images/emoji/top.png diff --git a/app/assets/images/emoji/tophat.png b/vendor/assets/images/emoji/tophat.png similarity index 100% rename from app/assets/images/emoji/tophat.png rename to vendor/assets/images/emoji/tophat.png diff --git a/app/assets/images/emoji/tractor.png b/vendor/assets/images/emoji/tractor.png similarity index 100% rename from app/assets/images/emoji/tractor.png rename to vendor/assets/images/emoji/tractor.png diff --git a/app/assets/images/emoji/traffic_light.png b/vendor/assets/images/emoji/traffic_light.png similarity index 100% rename from app/assets/images/emoji/traffic_light.png rename to vendor/assets/images/emoji/traffic_light.png diff --git a/app/assets/images/emoji/train.png b/vendor/assets/images/emoji/train.png similarity index 100% rename from app/assets/images/emoji/train.png rename to vendor/assets/images/emoji/train.png diff --git a/app/assets/images/emoji/train2.png b/vendor/assets/images/emoji/train2.png similarity index 100% rename from app/assets/images/emoji/train2.png rename to vendor/assets/images/emoji/train2.png diff --git a/app/assets/images/emoji/tram.png b/vendor/assets/images/emoji/tram.png similarity index 100% rename from app/assets/images/emoji/tram.png rename to vendor/assets/images/emoji/tram.png diff --git a/app/assets/images/emoji/triangular_flag_on_post.png b/vendor/assets/images/emoji/triangular_flag_on_post.png similarity index 100% rename from app/assets/images/emoji/triangular_flag_on_post.png rename to vendor/assets/images/emoji/triangular_flag_on_post.png diff --git a/app/assets/images/emoji/triangular_ruler.png b/vendor/assets/images/emoji/triangular_ruler.png similarity index 100% rename from app/assets/images/emoji/triangular_ruler.png rename to vendor/assets/images/emoji/triangular_ruler.png diff --git a/app/assets/images/emoji/trident.png b/vendor/assets/images/emoji/trident.png similarity index 100% rename from app/assets/images/emoji/trident.png rename to vendor/assets/images/emoji/trident.png diff --git a/app/assets/images/emoji/triumph.png b/vendor/assets/images/emoji/triumph.png similarity index 100% rename from app/assets/images/emoji/triumph.png rename to vendor/assets/images/emoji/triumph.png diff --git a/app/assets/images/emoji/trolleybus.png b/vendor/assets/images/emoji/trolleybus.png similarity index 100% rename from app/assets/images/emoji/trolleybus.png rename to vendor/assets/images/emoji/trolleybus.png diff --git a/app/assets/images/emoji/trollface.png b/vendor/assets/images/emoji/trollface.png similarity index 100% rename from app/assets/images/emoji/trollface.png rename to vendor/assets/images/emoji/trollface.png diff --git a/app/assets/images/emoji/trophy.png b/vendor/assets/images/emoji/trophy.png similarity index 100% rename from app/assets/images/emoji/trophy.png rename to vendor/assets/images/emoji/trophy.png diff --git a/app/assets/images/emoji/tropical_drink.png b/vendor/assets/images/emoji/tropical_drink.png similarity index 100% rename from app/assets/images/emoji/tropical_drink.png rename to vendor/assets/images/emoji/tropical_drink.png diff --git a/app/assets/images/emoji/tropical_fish.png b/vendor/assets/images/emoji/tropical_fish.png similarity index 100% rename from app/assets/images/emoji/tropical_fish.png rename to vendor/assets/images/emoji/tropical_fish.png diff --git a/app/assets/images/emoji/truck.png b/vendor/assets/images/emoji/truck.png similarity index 100% rename from app/assets/images/emoji/truck.png rename to vendor/assets/images/emoji/truck.png diff --git a/app/assets/images/emoji/trumpet.png b/vendor/assets/images/emoji/trumpet.png similarity index 100% rename from app/assets/images/emoji/trumpet.png rename to vendor/assets/images/emoji/trumpet.png diff --git a/app/assets/images/emoji/tshirt.png b/vendor/assets/images/emoji/tshirt.png similarity index 100% rename from app/assets/images/emoji/tshirt.png rename to vendor/assets/images/emoji/tshirt.png diff --git a/app/assets/images/emoji/tulip.png b/vendor/assets/images/emoji/tulip.png similarity index 100% rename from app/assets/images/emoji/tulip.png rename to vendor/assets/images/emoji/tulip.png diff --git a/app/assets/images/emoji/turtle.png b/vendor/assets/images/emoji/turtle.png similarity index 100% rename from app/assets/images/emoji/turtle.png rename to vendor/assets/images/emoji/turtle.png diff --git a/app/assets/images/emoji/tv.png b/vendor/assets/images/emoji/tv.png similarity index 100% rename from app/assets/images/emoji/tv.png rename to vendor/assets/images/emoji/tv.png diff --git a/app/assets/images/emoji/twisted_rightwards_arrows.png b/vendor/assets/images/emoji/twisted_rightwards_arrows.png similarity index 100% rename from app/assets/images/emoji/twisted_rightwards_arrows.png rename to vendor/assets/images/emoji/twisted_rightwards_arrows.png diff --git a/app/assets/images/emoji/two.png b/vendor/assets/images/emoji/two.png similarity index 100% rename from app/assets/images/emoji/two.png rename to vendor/assets/images/emoji/two.png diff --git a/app/assets/images/emoji/two_hearts.png b/vendor/assets/images/emoji/two_hearts.png similarity index 100% rename from app/assets/images/emoji/two_hearts.png rename to vendor/assets/images/emoji/two_hearts.png diff --git a/app/assets/images/emoji/two_men_holding_hands.png b/vendor/assets/images/emoji/two_men_holding_hands.png similarity index 100% rename from app/assets/images/emoji/two_men_holding_hands.png rename to vendor/assets/images/emoji/two_men_holding_hands.png diff --git a/app/assets/images/emoji/two_women_holding_hands.png b/vendor/assets/images/emoji/two_women_holding_hands.png similarity index 100% rename from app/assets/images/emoji/two_women_holding_hands.png rename to vendor/assets/images/emoji/two_women_holding_hands.png diff --git a/app/assets/images/emoji/u5272.png b/vendor/assets/images/emoji/u5272.png similarity index 100% rename from app/assets/images/emoji/u5272.png rename to vendor/assets/images/emoji/u5272.png diff --git a/app/assets/images/emoji/u5408.png b/vendor/assets/images/emoji/u5408.png similarity index 100% rename from app/assets/images/emoji/u5408.png rename to vendor/assets/images/emoji/u5408.png diff --git a/app/assets/images/emoji/u55b6.png b/vendor/assets/images/emoji/u55b6.png similarity index 100% rename from app/assets/images/emoji/u55b6.png rename to vendor/assets/images/emoji/u55b6.png diff --git a/app/assets/images/emoji/u6307.png b/vendor/assets/images/emoji/u6307.png similarity index 100% rename from app/assets/images/emoji/u6307.png rename to vendor/assets/images/emoji/u6307.png diff --git a/app/assets/images/emoji/u6708.png b/vendor/assets/images/emoji/u6708.png similarity index 100% rename from app/assets/images/emoji/u6708.png rename to vendor/assets/images/emoji/u6708.png diff --git a/app/assets/images/emoji/u6709.png b/vendor/assets/images/emoji/u6709.png similarity index 100% rename from app/assets/images/emoji/u6709.png rename to vendor/assets/images/emoji/u6709.png diff --git a/app/assets/images/emoji/u6e80.png b/vendor/assets/images/emoji/u6e80.png similarity index 100% rename from app/assets/images/emoji/u6e80.png rename to vendor/assets/images/emoji/u6e80.png diff --git a/app/assets/images/emoji/u7121.png b/vendor/assets/images/emoji/u7121.png similarity index 100% rename from app/assets/images/emoji/u7121.png rename to vendor/assets/images/emoji/u7121.png diff --git a/app/assets/images/emoji/u7533.png b/vendor/assets/images/emoji/u7533.png similarity index 100% rename from app/assets/images/emoji/u7533.png rename to vendor/assets/images/emoji/u7533.png diff --git a/app/assets/images/emoji/u7981.png b/vendor/assets/images/emoji/u7981.png similarity index 100% rename from app/assets/images/emoji/u7981.png rename to vendor/assets/images/emoji/u7981.png diff --git a/app/assets/images/emoji/u7a7a.png b/vendor/assets/images/emoji/u7a7a.png similarity index 100% rename from app/assets/images/emoji/u7a7a.png rename to vendor/assets/images/emoji/u7a7a.png diff --git a/app/assets/images/emoji/uk.png b/vendor/assets/images/emoji/uk.png similarity index 100% rename from app/assets/images/emoji/uk.png rename to vendor/assets/images/emoji/uk.png diff --git a/app/assets/images/emoji/umbrella.png b/vendor/assets/images/emoji/umbrella.png similarity index 100% rename from app/assets/images/emoji/umbrella.png rename to vendor/assets/images/emoji/umbrella.png diff --git a/app/assets/images/emoji/unamused.png b/vendor/assets/images/emoji/unamused.png similarity index 100% rename from app/assets/images/emoji/unamused.png rename to vendor/assets/images/emoji/unamused.png diff --git a/app/assets/images/emoji/underage.png b/vendor/assets/images/emoji/underage.png similarity index 100% rename from app/assets/images/emoji/underage.png rename to vendor/assets/images/emoji/underage.png diff --git a/app/assets/images/emoji/unlock.png b/vendor/assets/images/emoji/unlock.png similarity index 100% rename from app/assets/images/emoji/unlock.png rename to vendor/assets/images/emoji/unlock.png diff --git a/app/assets/images/emoji/up.png b/vendor/assets/images/emoji/up.png similarity index 100% rename from app/assets/images/emoji/up.png rename to vendor/assets/images/emoji/up.png diff --git a/app/assets/images/emoji/us.png b/vendor/assets/images/emoji/us.png similarity index 100% rename from app/assets/images/emoji/us.png rename to vendor/assets/images/emoji/us.png diff --git a/app/assets/images/emoji/v.png b/vendor/assets/images/emoji/v.png similarity index 100% rename from app/assets/images/emoji/v.png rename to vendor/assets/images/emoji/v.png diff --git a/app/assets/images/emoji/vertical_traffic_light.png b/vendor/assets/images/emoji/vertical_traffic_light.png similarity index 100% rename from app/assets/images/emoji/vertical_traffic_light.png rename to vendor/assets/images/emoji/vertical_traffic_light.png diff --git a/app/assets/images/emoji/vhs.png b/vendor/assets/images/emoji/vhs.png similarity index 100% rename from app/assets/images/emoji/vhs.png rename to vendor/assets/images/emoji/vhs.png diff --git a/app/assets/images/emoji/vibration_mode.png b/vendor/assets/images/emoji/vibration_mode.png similarity index 100% rename from app/assets/images/emoji/vibration_mode.png rename to vendor/assets/images/emoji/vibration_mode.png diff --git a/app/assets/images/emoji/video_camera.png b/vendor/assets/images/emoji/video_camera.png similarity index 100% rename from app/assets/images/emoji/video_camera.png rename to vendor/assets/images/emoji/video_camera.png diff --git a/app/assets/images/emoji/video_game.png b/vendor/assets/images/emoji/video_game.png similarity index 100% rename from app/assets/images/emoji/video_game.png rename to vendor/assets/images/emoji/video_game.png diff --git a/app/assets/images/emoji/violin.png b/vendor/assets/images/emoji/violin.png similarity index 100% rename from app/assets/images/emoji/violin.png rename to vendor/assets/images/emoji/violin.png diff --git a/app/assets/images/emoji/virgo.png b/vendor/assets/images/emoji/virgo.png similarity index 100% rename from app/assets/images/emoji/virgo.png rename to vendor/assets/images/emoji/virgo.png diff --git a/app/assets/images/emoji/volcano.png b/vendor/assets/images/emoji/volcano.png similarity index 100% rename from app/assets/images/emoji/volcano.png rename to vendor/assets/images/emoji/volcano.png diff --git a/app/assets/images/emoji/vs.png b/vendor/assets/images/emoji/vs.png similarity index 100% rename from app/assets/images/emoji/vs.png rename to vendor/assets/images/emoji/vs.png diff --git a/app/assets/images/emoji/walking.png b/vendor/assets/images/emoji/walking.png similarity index 100% rename from app/assets/images/emoji/walking.png rename to vendor/assets/images/emoji/walking.png diff --git a/app/assets/images/emoji/waning_crescent_moon.png b/vendor/assets/images/emoji/waning_crescent_moon.png similarity index 100% rename from app/assets/images/emoji/waning_crescent_moon.png rename to vendor/assets/images/emoji/waning_crescent_moon.png diff --git a/app/assets/images/emoji/waning_gibbous_moon.png b/vendor/assets/images/emoji/waning_gibbous_moon.png similarity index 100% rename from app/assets/images/emoji/waning_gibbous_moon.png rename to vendor/assets/images/emoji/waning_gibbous_moon.png diff --git a/app/assets/images/emoji/warning.png b/vendor/assets/images/emoji/warning.png similarity index 100% rename from app/assets/images/emoji/warning.png rename to vendor/assets/images/emoji/warning.png diff --git a/app/assets/images/emoji/watch.png b/vendor/assets/images/emoji/watch.png similarity index 100% rename from app/assets/images/emoji/watch.png rename to vendor/assets/images/emoji/watch.png diff --git a/app/assets/images/emoji/water_buffalo.png b/vendor/assets/images/emoji/water_buffalo.png similarity index 100% rename from app/assets/images/emoji/water_buffalo.png rename to vendor/assets/images/emoji/water_buffalo.png diff --git a/app/assets/images/emoji/watermelon.png b/vendor/assets/images/emoji/watermelon.png similarity index 100% rename from app/assets/images/emoji/watermelon.png rename to vendor/assets/images/emoji/watermelon.png diff --git a/app/assets/images/emoji/wave.png b/vendor/assets/images/emoji/wave.png similarity index 100% rename from app/assets/images/emoji/wave.png rename to vendor/assets/images/emoji/wave.png diff --git a/app/assets/images/emoji/wavy_dash.png b/vendor/assets/images/emoji/wavy_dash.png similarity index 100% rename from app/assets/images/emoji/wavy_dash.png rename to vendor/assets/images/emoji/wavy_dash.png diff --git a/app/assets/images/emoji/waxing_crescent_moon.png b/vendor/assets/images/emoji/waxing_crescent_moon.png similarity index 100% rename from app/assets/images/emoji/waxing_crescent_moon.png rename to vendor/assets/images/emoji/waxing_crescent_moon.png diff --git a/app/assets/images/emoji/waxing_gibbous_moon.png b/vendor/assets/images/emoji/waxing_gibbous_moon.png similarity index 100% rename from app/assets/images/emoji/waxing_gibbous_moon.png rename to vendor/assets/images/emoji/waxing_gibbous_moon.png diff --git a/app/assets/images/emoji/wc.png b/vendor/assets/images/emoji/wc.png similarity index 100% rename from app/assets/images/emoji/wc.png rename to vendor/assets/images/emoji/wc.png diff --git a/app/assets/images/emoji/weary.png b/vendor/assets/images/emoji/weary.png similarity index 100% rename from app/assets/images/emoji/weary.png rename to vendor/assets/images/emoji/weary.png diff --git a/app/assets/images/emoji/wedding.png b/vendor/assets/images/emoji/wedding.png similarity index 100% rename from app/assets/images/emoji/wedding.png rename to vendor/assets/images/emoji/wedding.png diff --git a/app/assets/images/emoji/whale.png b/vendor/assets/images/emoji/whale.png similarity index 100% rename from app/assets/images/emoji/whale.png rename to vendor/assets/images/emoji/whale.png diff --git a/app/assets/images/emoji/whale2.png b/vendor/assets/images/emoji/whale2.png similarity index 100% rename from app/assets/images/emoji/whale2.png rename to vendor/assets/images/emoji/whale2.png diff --git a/app/assets/images/emoji/wheelchair.png b/vendor/assets/images/emoji/wheelchair.png similarity index 100% rename from app/assets/images/emoji/wheelchair.png rename to vendor/assets/images/emoji/wheelchair.png diff --git a/app/assets/images/emoji/white_circle.png b/vendor/assets/images/emoji/white_circle.png similarity index 100% rename from app/assets/images/emoji/white_circle.png rename to vendor/assets/images/emoji/white_circle.png diff --git a/app/assets/images/emoji/white_flower.png b/vendor/assets/images/emoji/white_flower.png similarity index 100% rename from app/assets/images/emoji/white_flower.png rename to vendor/assets/images/emoji/white_flower.png diff --git a/app/assets/images/emoji/white_square.png b/vendor/assets/images/emoji/white_square.png similarity index 100% rename from app/assets/images/emoji/white_square.png rename to vendor/assets/images/emoji/white_square.png diff --git a/app/assets/images/emoji/wind_chime.png b/vendor/assets/images/emoji/wind_chime.png similarity index 100% rename from app/assets/images/emoji/wind_chime.png rename to vendor/assets/images/emoji/wind_chime.png diff --git a/app/assets/images/emoji/wine_glass.png b/vendor/assets/images/emoji/wine_glass.png similarity index 100% rename from app/assets/images/emoji/wine_glass.png rename to vendor/assets/images/emoji/wine_glass.png diff --git a/app/assets/images/emoji/wink.png b/vendor/assets/images/emoji/wink.png similarity index 100% rename from app/assets/images/emoji/wink.png rename to vendor/assets/images/emoji/wink.png diff --git a/app/assets/images/emoji/wink2.png b/vendor/assets/images/emoji/wink2.png similarity index 100% rename from app/assets/images/emoji/wink2.png rename to vendor/assets/images/emoji/wink2.png diff --git a/app/assets/images/emoji/wolf.png b/vendor/assets/images/emoji/wolf.png similarity index 100% rename from app/assets/images/emoji/wolf.png rename to vendor/assets/images/emoji/wolf.png diff --git a/app/assets/images/emoji/woman.png b/vendor/assets/images/emoji/woman.png similarity index 100% rename from app/assets/images/emoji/woman.png rename to vendor/assets/images/emoji/woman.png diff --git a/app/assets/images/emoji/womans_clothes.png b/vendor/assets/images/emoji/womans_clothes.png similarity index 100% rename from app/assets/images/emoji/womans_clothes.png rename to vendor/assets/images/emoji/womans_clothes.png diff --git a/app/assets/images/emoji/womans_hat.png b/vendor/assets/images/emoji/womans_hat.png similarity index 100% rename from app/assets/images/emoji/womans_hat.png rename to vendor/assets/images/emoji/womans_hat.png diff --git a/app/assets/images/emoji/womens.png b/vendor/assets/images/emoji/womens.png similarity index 100% rename from app/assets/images/emoji/womens.png rename to vendor/assets/images/emoji/womens.png diff --git a/app/assets/images/emoji/wrench.png b/vendor/assets/images/emoji/wrench.png similarity index 100% rename from app/assets/images/emoji/wrench.png rename to vendor/assets/images/emoji/wrench.png diff --git a/app/assets/images/emoji/x.png b/vendor/assets/images/emoji/x.png similarity index 100% rename from app/assets/images/emoji/x.png rename to vendor/assets/images/emoji/x.png diff --git a/app/assets/images/emoji/yellow_heart.png b/vendor/assets/images/emoji/yellow_heart.png similarity index 100% rename from app/assets/images/emoji/yellow_heart.png rename to vendor/assets/images/emoji/yellow_heart.png diff --git a/app/assets/images/emoji/yen.png b/vendor/assets/images/emoji/yen.png similarity index 100% rename from app/assets/images/emoji/yen.png rename to vendor/assets/images/emoji/yen.png diff --git a/app/assets/images/emoji/yum.png b/vendor/assets/images/emoji/yum.png similarity index 100% rename from app/assets/images/emoji/yum.png rename to vendor/assets/images/emoji/yum.png diff --git a/app/assets/images/emoji/zap.png b/vendor/assets/images/emoji/zap.png similarity index 100% rename from app/assets/images/emoji/zap.png rename to vendor/assets/images/emoji/zap.png diff --git a/app/assets/images/emoji/zero.png b/vendor/assets/images/emoji/zero.png similarity index 100% rename from app/assets/images/emoji/zero.png rename to vendor/assets/images/emoji/zero.png diff --git a/app/assets/images/emoji/zzz.png b/vendor/assets/images/emoji/zzz.png similarity index 100% rename from app/assets/images/emoji/zzz.png rename to vendor/assets/images/emoji/zzz.png From 72395d7f6edc3ff2a4c01052a2ad085ab310595b Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Fri, 5 Oct 2012 07:22:21 -0700 Subject: [PATCH 168/288] no need to add fonts to assets path --- app/assets/stylesheets/main.scss | 2 +- config/application.rb | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index 8f0db82d..bff24493 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -8,7 +8,7 @@ $style_color: #474d57; $hover: #D9EDF7; /** GitLab Fonts **/ -@font-face { font-family: Korolev; src: url('korolev-medium-compressed.otf'); } +@font-face { font-family: Korolev; src: font-url('korolev-medium-compressed.otf'); } /** MIXINS **/ @mixin shade { diff --git a/config/application.rb b/config/application.rb index 27de3fa2..1189035f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -50,8 +50,5 @@ module Gitlab # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' - - # Add fonts - config.assets.paths << "#{Rails.root}/app/assets/fonts" end end From d2ea858fbf9c1a3097a2c12f3aa0e9537476ce8e Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Fri, 5 Oct 2012 07:42:23 -0700 Subject: [PATCH 169/288] move emoji module to lib --- {config/initializers => lib}/emoji.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {config/initializers => lib}/emoji.rb (100%) diff --git a/config/initializers/emoji.rb b/lib/emoji.rb similarity index 100% rename from config/initializers/emoji.rb rename to lib/emoji.rb From 82425cf358d6abb316dce04dca1567481f57c463 Mon Sep 17 00:00:00 2001 From: joseph Borremans Date: Fri, 5 Oct 2012 17:48:52 +0200 Subject: [PATCH 170/288] reversed order of progress indication for visual harmony so that text matches the progress bar --- app/views/milestones/show.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/milestones/show.html.haml b/app/views/milestones/show.html.haml index ba71ead7..8acf9ca3 100644 --- a/app/views/milestones/show.html.haml +++ b/app/views/milestones/show.html.haml @@ -28,9 +28,9 @@ %h5 Progress: %small - #{@milestone.issues.opened.count} open - – #{@milestone.issues.closed.count} closed + – + #{@milestone.issues.opened.count} open .progress.progress-success .bar{style: "width: #{@milestone.percent_complete}%;"} From 7c2e67c6604454ab03d4f760794d85036f0c098b Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Fri, 5 Oct 2012 23:46:15 -0700 Subject: [PATCH 171/288] Tiny fix to the add/edit groups form path field --- app/views/admin/groups/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/groups/_form.html.haml b/app/views/admin/groups/_form.html.haml index 46c59563..e85cce66 100644 --- a/app/views/admin/groups/_form.html.haml +++ b/app/views/admin/groups/_form.html.haml @@ -12,7 +12,7 @@ URL .input .input-prepend - %span.add-on= web_app_url + %span.add-on= web_app_url + 'groups/' = f.text_field :code, placeholder: "example" .form-actions From ed5754624e29e063334b7f935a224b08f60657da Mon Sep 17 00:00:00 2001 From: Danillo Nunes Date: Sat, 6 Oct 2012 21:36:20 -0300 Subject: [PATCH 172/288] Doc fix: Nginx init script requires sudo --- doc/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/installation.md b/doc/installation.md index ccbbd2e8..fd8a8b9b 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -284,7 +284,7 @@ a different host, you can configure its connection string in the sudo vim /etc/nginx/sites-enabled/gitlab # Restart nginx: - /etc/init.d/nginx restart + sudo /etc/init.d/nginx restart ## 3. Init script From d47e40929d7892e7469a11016f927412ed283791 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 8 Oct 2012 01:52:08 -0700 Subject: [PATCH 173/288] add API changelog --- CHANGELOG | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3fec2d86..3a283aa5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +master + - [API] allow to authorize using private token in HTTP header + - [API] add user creation + v 2.9.1 - Fixed resque custom config init @@ -9,7 +13,7 @@ v 2.9.0 - restyled projects list on dashboard - ssh keys validation to prevent gitolite crash - send notifications if changed premission in project - - scss refactoring. gitlab_bootstrap/ dir + - scss refactoring. gitlab_bootstrap/ dir - fix git push http body bigger than 112k problem - list of labels page under issues tab - API for milestones, keys @@ -113,7 +117,7 @@ v 2.1.0 v 2.0.0 - gitolite as main git host system - merge requests - - project/repo access + - project/repo access - link to commit/issue feed - design tab - improved email notifications @@ -147,7 +151,7 @@ v 1.1.0 - bugfix & code cleaning v 1.0.2 - - fixed bug with empty project + - fixed bug with empty project - added adv validation for project path & code - feature: issues can be sortable - bugfix From ad5b5d1e51abb02496458989fbff351f57f7fb29 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 8 Oct 2012 01:54:36 -0700 Subject: [PATCH 174/288] projects API should return info about deleted hook --- lib/api/projects.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/api/projects.rb b/lib/api/projects.rb index c3dc3da6..5a1b1779 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -176,7 +176,6 @@ module Gitlab authorize! :admin_project, user_project @hook = user_project.hooks.find(params[:hook_id]) @hook.destroy - nil end # Get a project repository branches From 61f12da3a5b84670a0fc8cb5dbb962a365895097 Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Mon, 8 Oct 2012 02:13:53 -0700 Subject: [PATCH 175/288] API: add project snippets listing --- CHANGELOG | 1 + doc/api/snippets.md | 10 +++++++++- lib/api/projects.rb | 10 ++++++++++ spec/requests/api/projects_spec.rb | 9 +++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 3a283aa5..1c9f3bba 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ master + - [API] add project snippets list - [API] allow to authorize using private token in HTTP header - [API] add user creation diff --git a/doc/api/snippets.md b/doc/api/snippets.md index 0cd29ce5..288fd529 100644 --- a/doc/api/snippets.md +++ b/doc/api/snippets.md @@ -1,6 +1,14 @@ ## List snippets -Not implemented. +Get a list of project snippets. + +``` +GET /projects/:id/snippets +``` + +Parameters: + ++ `id` (required) - The ID or code name of a project ## Single snippet diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 5a1b1779..0f013883 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -228,6 +228,16 @@ module Gitlab present CommitDecorator.decorate(commits), with: Entities::RepoCommit end + # Get a project snippets + # + # Parameters: + # id (required) - The ID or code name of a project + # Example Request: + # GET /projects/:id/snippets + get ":id/snippets" do + present paginate(user_project.snippets), with: Entities::ProjectSnippet + end + # Get a project snippet # # Parameters: diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 498bbad6..94c9abb3 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -220,6 +220,15 @@ describe Gitlab::API do end end + describe "GET /projects/:id/snippets" do + it "should return a project snippet" do + get api("/projects/#{project.code}/snippets", user) + response.status.should == 200 + json_response.should be_an Array + json_response.first['title'].should == snippet.title + end + end + describe "GET /projects/:id/snippets/:snippet_id" do it "should return a project snippet" do get api("/projects/#{project.code}/snippets/#{snippet.id}", user) From 927d0cc2674d21f470a29e7a10577707172f13c6 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Mon, 8 Oct 2012 12:41:25 +0200 Subject: [PATCH 176/288] Do not allow removal of a project owner user. --- app/controllers/admin/users_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index e2d61864..9219513e 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -98,6 +98,7 @@ class Admin::UsersController < AdminController def destroy @admin_user = User.find(params[:id]) + redirect_to admin_users_url, notice: 'User is a project owner, cannot be removed.' and return if @admin_user.my_own_projects.count > 0 @admin_user.destroy respond_to do |format| From bcdb168709ac03c7a7e00f440dcd47f2538894e3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 8 Oct 2012 14:17:46 +0300 Subject: [PATCH 177/288] Fix dashboard atom feed routes --- app/decorators/event_decorator.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/decorators/event_decorator.rb b/app/decorators/event_decorator.rb index b2f9c439..1b0ad0da 100644 --- a/app/decorators/event_decorator.rb +++ b/app/decorators/event_decorator.rb @@ -24,15 +24,14 @@ class EventDecorator < ApplicationDecorator elsif self.push? if self.push_with_commits? if self.commits_count > 1 - h.compare_project_commits_path(self.project, :from => self.parent_commit.id, :to => self.last_commit.id) + h.project_compare_url(self.project, :from => self.parent_commit.id, :to => self.last_commit.id) else - h.project_commit_path(self.project, :id => self.last_commit.id) + h.project_commit_url(self.project, :id => self.last_commit.id) end else - h.project_commits_url(self.project, ref: self.ref_name) + h.project_commits_url(self.project, self.ref_name) end end - end def feed_summary From a635b9da97b0e104b8ac1a846344ec8a4abd3123 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Mon, 8 Oct 2012 15:57:30 +0300 Subject: [PATCH 178/288] Revert "Do not allow removal of a project owner user." This reverts commit 927d0cc2674d21f470a29e7a10577707172f13c6. --- app/controllers/admin/users_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 55f2b248..c9586ad5 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -98,7 +98,6 @@ class Admin::UsersController < AdminController def destroy @admin_user = User.find(params[:id]) - redirect_to admin_users_url, notice: 'User is a project owner, cannot be removed.' and return if @admin_user.my_own_projects.count > 0 @admin_user.destroy respond_to do |format| From df7c52489a890ac38491682b4a3399beb7cdbc86 Mon Sep 17 00:00:00 2001 From: Andrey Kumanyaev Date: Tue, 9 Oct 2012 04:10:04 +0400 Subject: [PATCH 179/288] simple refactoring --- app/helpers/commits_helper.rb | 2 +- app/helpers/merge_requests_helper.rb | 2 +- app/models/ability.rb | 115 +++++++++++++-------------- app/models/event.rb | 19 +++-- app/models/group.rb | 28 +++---- app/models/key.rb | 13 ++- app/models/merge_request.rb | 7 +- app/models/milestone.rb | 3 +- app/models/note.rb | 16 ++-- app/models/project.rb | 102 ++++++++++++------------ app/models/protected_branch.rb | 3 +- app/models/snippet.rb | 4 +- app/models/system_hook.rb | 8 +- app/models/user.rb | 79 +++++++++--------- app/models/users_project.rb | 84 +++++++++---------- app/models/web_hook.rb | 2 +- app/models/wiki.rb | 26 +++--- app/roles/account.rb | 2 +- app/roles/authority.rb | 8 +- app/roles/issue_commonality.rb | 9 +-- app/roles/push_event.rb | 8 +- 21 files changed, 276 insertions(+), 264 deletions(-) diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 16ecfb1f..4b35b0ac 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -17,7 +17,7 @@ module CommitsHelper line_old = 1 line_new = 1 type = nil - + lines_arr = ::Gitlab::InlineDiff.processing diff_arr lines_arr.each do |line| next if line.match(/^\-\-\- \/dev\/null/) diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index 62ac5e55..16855989 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -24,7 +24,7 @@ module MergeRequestsHelper def new_mr_path_from_push_event(event) new_project_merge_request_path( event.project, - merge_request: { + merge_request: { source_branch: event.branch_name, target_branch: event.project.root_ref, title: event.branch_name.titleize diff --git a/app/models/ability.rb b/app/models/ability.rb index 20ded59b..d3180b76 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -1,61 +1,61 @@ class Ability - def self.allowed(object, subject) - case subject.class.name - when "Project" then project_abilities(object, subject) - when "Issue" then issue_abilities(object, subject) - when "Note" then note_abilities(object, subject) - when "Snippet" then snippet_abilities(object, subject) - when "MergeRequest" then merge_request_abilities(object, subject) - else [] - end - end - - def self.project_abilities(user, project) - rules = [] - - rules << [ - :read_project, - :read_wiki, - :read_issue, - :read_milestone, - :read_snippet, - :read_team_member, - :read_merge_request, - :read_note, - :write_project, - :write_issue, - :write_note - ] if project.guest_access_for?(user) - - rules << [ - :download_code, - :write_merge_request, - :write_snippet - ] if project.report_access_for?(user) - - rules << [ - :write_wiki - ] if project.dev_access_for?(user) - - rules << [ - :modify_issue, - :modify_snippet, - :modify_merge_request, - :admin_project, - :admin_issue, - :admin_milestone, - :admin_snippet, - :admin_team_member, - :admin_merge_request, - :admin_note, - :accept_mr, - :admin_wiki - ] if project.master_access_for?(user) || project.owner == user - - rules.flatten - end - class << self + def allowed(object, subject) + case subject.class.name + when "Project" then project_abilities(object, subject) + when "Issue" then issue_abilities(object, subject) + when "Note" then note_abilities(object, subject) + when "Snippet" then snippet_abilities(object, subject) + when "MergeRequest" then merge_request_abilities(object, subject) + else [] + end + end + + def project_abilities(user, project) + rules = [] + + rules << [ + :read_project, + :read_wiki, + :read_issue, + :read_milestone, + :read_snippet, + :read_team_member, + :read_merge_request, + :read_note, + :write_project, + :write_issue, + :write_note + ] if project.guest_access_for?(user) + + rules << [ + :download_code, + :write_merge_request, + :write_snippet + ] if project.report_access_for?(user) + + rules << [ + :write_wiki + ] if project.dev_access_for?(user) + + rules << [ + :modify_issue, + :modify_snippet, + :modify_merge_request, + :admin_project, + :admin_issue, + :admin_milestone, + :admin_snippet, + :admin_team_member, + :admin_merge_request, + :admin_note, + :accept_mr, + :admin_wiki + ] if project.master_access_for?(user) || project.owner == user + + rules.flatten + end + [:issue, :note, :snippet, :merge_request].each do |name| define_method "#{name}_abilities" do |user, subject| if subject.author == user @@ -72,8 +72,7 @@ class Ability :"modify_#{name}", ] else - subject.respond_to?(:project) ? - project_abilities(user, subject.project) : [] + subject.respond_to?(:project) ? project_abilities(user, subject.project) : [] end end end diff --git a/app/models/event.rb b/app/models/event.rb index 40f584dd..9f01964d 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -27,19 +27,22 @@ class Event < ActiveRecord::Base # For Hash only serialize :data + # Scopes scope :recent, order("created_at DESC") scope :code_push, where(action: Pushed) - def self.determine_action(record) - if [Issue, MergeRequest].include? record.class - Event::Created - elsif record.kind_of? Note - Event::Commented + class << self + def determine_action(record) + if [Issue, MergeRequest].include? record.class + Event::Created + elsif record.kind_of? Note + Event::Commented + end end - end - def self.recent_for_user user - where(project_id: user.projects.map(&:id)).recent + def recent_for_user user + where(project_id: user.projects.map(&:id)).recent + end end # Next events currently enabled for system diff --git a/app/models/group.rb b/app/models/group.rb index 780d5fdd..012b1285 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,15 +1,3 @@ -# == Schema Information -# -# Table name: groups -# -# id :integer not null, primary key -# name :string(255) not null -# code :string(255) not null -# owner_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null -# - class Group < ActiveRecord::Base attr_accessible :code, :name, :owner_id @@ -18,7 +6,7 @@ class Group < ActiveRecord::Base validates :name, presence: true, uniqueness: true validates :code, presence: true, uniqueness: true - validates :owner_id, presence: true + validates :owner, presence: true delegate :name, to: :owner, allow_nil: true, prefix: true @@ -31,6 +19,18 @@ class Group < ActiveRecord::Base end def users - User.joins(:users_projects).where('users_projects.project_id' => project_ids).uniq + User.joins(:users_projects).where(users_projects: {project_id: project_ids}).uniq end end + +# == Schema Information +# +# Table name: groups +# +# id :integer not null, primary key +# name :string(255) not null +# code :string(255) not null +# owner_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# diff --git a/app/models/key.rb b/app/models/key.rb index dc1f3cdb..43db0950 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -6,16 +6,15 @@ class Key < ActiveRecord::Base attr_accessible :key, :title - validates :title, presence: true, length: { within: 0..255 } - validates :key, presence: true, - length: { within: 0..5000 }, - format: { :with => /ssh-.{3} / } - - before_save :set_identifier before_validation :strip_white_space - delegate :name, :email, to: :user, prefix: true + before_save :set_identifier + + validates :title, presence: true, length: { within: 0..255 } + validates :key, presence: true, length: { within: 0..5000 }, format: { :with => /ssh-.{3} / } validate :unique_key, :fingerprintable_key + delegate :name, :email, to: :user, prefix: true + def strip_white_space self.key = self.key.strip unless self.key.blank? end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 8428c7c4..dc44d820 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -7,6 +7,8 @@ class MergeRequest < ActiveRecord::Base attr_accessible :title, :assignee_id, :closed, :target_branch, :source_branch, :author_id_of_changes + attr_accessor :should_remove_source_branch + BROKEN_DIFF = "--broken-diff" UNCHECKED = 1 @@ -16,9 +18,8 @@ class MergeRequest < ActiveRecord::Base serialize :st_commits serialize :st_diffs - attr_accessor :should_remove_source_branch - - validates_presence_of :source_branch, :target_branch + validates :source_branch, presence: true + validates :target_branch, presence: true validate :validate_branches def self.find_all_by_branch(branch_name) diff --git a/app/models/milestone.rb b/app/models/milestone.rb index a8619954..096376e3 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -4,7 +4,8 @@ class Milestone < ActiveRecord::Base belongs_to :project has_many :issues - validates_presence_of :title, :project_id + validates :title, presence: true + validates :project, presence: true def self.active where("due_date > ? OR due_date IS NULL", Date.today) diff --git a/app/models/note.rb b/app/models/note.rb index 23ced536..55b011f8 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -2,10 +2,13 @@ require 'carrierwave/orm/activerecord' require 'file_size_validator' class Note < ActiveRecord::Base - mount_uploader :attachment, AttachmentUploader + attr_accessible :note, :noteable, :noteable_id, :noteable_type, :project_id, :attachment, :line_code + attr_accessor :notify + attr_accessor :notify_author + belongs_to :project belongs_to :noteable, polymorphic: true belongs_to :author, class_name: "User" @@ -13,18 +16,17 @@ class Note < ActiveRecord::Base delegate :name, to: :project, prefix: true delegate :name, :email, to: :author, prefix: true - attr_accessor :notify - attr_accessor :notify_author - - validates_presence_of :project - + validates :project, presence: true validates :note, presence: true, length: { within: 0..5000 } validates :attachment, file_size: { maximum: 10.megabytes.to_i } + mount_uploader :attachment, AttachmentUploader + + # Scopes scope :common, where(noteable_id: nil) scope :today, where("created_at >= :date", date: Date.today) scope :last_week, where("created_at >= :date", date: (Date.today - 7.days)) - scope :since, lambda { |day| where("created_at >= :date", date: (day)) } + scope :since, ->(day) { where("created_at >= :date", date: (day)) } scope :fresh, order("created_at ASC, id ASC") scope :inc_author_project, includes(:project, :author) scope :inc_author, includes(:author) diff --git a/app/models/project.rb b/app/models/project.rb index 982b7463..f4d86887 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -28,52 +28,6 @@ class Project < ActiveRecord::Base delegate :name, to: :owner, allow_nil: true, prefix: true - # Scopes - scope :public_only, where(private_flag: false) - scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) } - scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) } - - def self.active - joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC") - end - - def self.search query - where("name LIKE :query OR code LIKE :query OR path LIKE :query", query: "%#{query}%") - end - - def self.create_by_user(params, user) - project = Project.new params - - Project.transaction do - project.owner = user - project.save! - - # Add user as project master - project.users_projects.create!(project_access: UsersProject::MASTER, user: user) - - # when project saved no team member exist so - # project repository should be updated after first user add - project.update_repository - end - - project - rescue Gitlab::Gitolite::AccessDenied => ex - project.error_code = :gitolite - project - rescue => ex - project.error_code = :db - project.errors.add(:base, "Can't save project. Please try again later") - project - end - - def git_error? - error_code == :gitolite - end - - def saved? - id && valid? - end - # Validations validates :owner, presence: true validates :description, length: { within: 0..2000 } @@ -88,6 +42,58 @@ class Project < ActiveRecord::Base :wiki_enabled, inclusion: { in: [true, false] } validate :check_limit, :repo_name + # Scopes + scope :public_only, where(private_flag: false) + scope :without_user, ->(user) { where("id NOT IN (:ids)", ids: user.projects.map(&:id) ) } + scope :not_in_group, ->(group) { where("id NOT IN (:ids)", ids: group.project_ids ) } + + class << self + def active + joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC") + end + + def search query + where("name LIKE :query OR code LIKE :query OR path LIKE :query", query: "%#{query}%") + end + + def create_by_user(params, user) + project = Project.new params + + Project.transaction do + project.owner = user + project.save! + + # Add user as project master + project.users_projects.create!(project_access: UsersProject::MASTER, user: user) + + # when project saved no team member exist so + # project repository should be updated after first user add + project.update_repository + end + + project + rescue Gitlab::Gitolite::AccessDenied => ex + project.error_code = :gitolite + project + rescue => ex + project.error_code = :db + project.errors.add(:base, "Can't save project. Please try again later") + project + end + + def access_options + UsersProject.access_roles + end + end + + def git_error? + error_code == :gitolite + end + + def saved? + id && valid? + end + def check_limit unless owner.can_create_project? errors[:base] << ("Your own projects limit is #{owner.projects_limit}! Please contact administrator to increase it") @@ -102,10 +108,6 @@ class Project < ActiveRecord::Base end end - def self.access_options - UsersProject.access_roles - end - def to_param code end diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index c9e88d6b..cd93dc1b 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -4,7 +4,8 @@ class ProtectedBranch < ActiveRecord::Base attr_accessible :name belongs_to :project - validates_presence_of :name, :project_id + validates :name, presence: true + validates :project, presence: true after_save :update_repository after_destroy :update_repository diff --git a/app/models/snippet.rb b/app/models/snippet.rb index b37d6bef..e8670cdb 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -9,11 +9,13 @@ class Snippet < ActiveRecord::Base delegate :name, :email, to: :author, prefix: true - validates_presence_of :author_id, :project_id + validates :author, presence: true + validates :project, presence: true validates :title, presence: true, length: { within: 0..255 } validates :file_name, presence: true, length: { within: 0..255 } validates :content, presence: true, length: { within: 0..10000 } + # Scopes scope :fresh, order("created_at DESC") scope :non_expired, where(["expires_at IS NULL OR expires_at > ?", Time.current]) scope :expired, where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) diff --git a/app/models/system_hook.rb b/app/models/system_hook.rb index 376f336d..8ec8374b 100644 --- a/app/models/system_hook.rb +++ b/app/models/system_hook.rb @@ -1,13 +1,13 @@ class SystemHook < WebHook - def async_execute(data) - Resque.enqueue(SystemHookWorker, id, data) - end - def self.all_hooks_fire(data) SystemHook.all.each do |sh| sh.async_execute data end end + + def async_execute(data) + Resque.enqueue(SystemHookWorker, id, data) + end end # == Schema Information diff --git a/app/models/user.rb b/app/models/user.rb index cf12fd60..da0e9a0a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -27,54 +27,57 @@ class User < ActiveRecord::Base validates :extern_uid, :allow_blank => true, :uniqueness => {:scope => :provider} validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0} - scope :not_in_project, lambda { |project| where("id not in (:ids)", ids: project.users.map(&:id) ) } + before_validation :generate_password, on: :create + before_save :ensure_authentication_token + alias_attribute :private_token, :authentication_token + + # Scopes + scope :not_in_project, ->(project) { where("id not in (:ids)", ids: project.users.map(&:id) ) } scope :admins, where(admin: true) scope :blocked, where(blocked: true) scope :active, where(blocked: false) - before_validation :generate_password, on: :create - before_save :ensure_authentication_token - alias_attribute :private_token, :authentication_token + class << self + def filter filter_name + case filter_name + when "admins"; self.admins + when "blocked"; self.blocked + when "wop"; self.without_projects + else + self.active + end + end + + def without_projects + where('id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)') + end + + def create_from_omniauth(auth, ldap = false) + gitlab_auth.create_from_omniauth(auth, ldap) + end + + def find_or_new_for_omniauth(auth) + gitlab_auth.find_or_new_for_omniauth(auth) + end + + def find_for_ldap_auth(auth, signed_in_resource = nil) + gitlab_auth.find_for_ldap_auth(auth, signed_in_resource) + end + + def gitlab_auth + Gitlab::Auth.new + end + + def search query + where("name LIKE :query or email LIKE :query", query: "%#{query}%") + end + end def generate_password if self.force_random_password self.password = self.password_confirmation = Devise.friendly_token.first(8) end end - - def self.filter filter_name - case filter_name - when "admins"; self.admins - when "blocked"; self.blocked - when "wop"; self.without_projects - else - self.active - end - end - - def self.without_projects - where('id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)') - end - - def self.create_from_omniauth(auth, ldap = false) - gitlab_auth.create_from_omniauth(auth, ldap) - end - - def self.find_or_new_for_omniauth(auth) - gitlab_auth.find_or_new_for_omniauth(auth) - end - - def self.find_for_ldap_auth(auth, signed_in_resource = nil) - gitlab_auth.find_for_ldap_auth(auth, signed_in_resource) - end - - def self.gitlab_auth - Gitlab::Auth.new - end - - def self.search query - where("name LIKE :query OR email LIKE :query", query: "%#{query}%") - end end # == Schema Information diff --git a/app/models/users_project.rb b/app/models/users_project.rb index 510b90cb..a3d5116f 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -14,62 +14,64 @@ class UsersProject < ActiveRecord::Base after_save :update_repository after_destroy :update_repository - validates_uniqueness_of :user_id, scope: [:project_id], message: "already exists in project" - validates_presence_of :user_id - validates_presence_of :project_id + validates :user, presence: true + validates :user_id, uniqueness: { :scope => [:project_id], message: "already exists in project" } + validates :project, presence: true delegate :name, :email, to: :user, prefix: true - def self.bulk_delete(project, user_ids) - UsersProject.transaction do - UsersProject.where(:user_id => user_ids, :project_id => project.id).each do |users_project| - users_project.destroy + class << self + def bulk_delete(project, user_ids) + UsersProject.transaction do + UsersProject.where(:user_id => user_ids, :project_id => project.id).each do |users_project| + users_project.destroy + end end end - end - def self.bulk_update(project, user_ids, project_access) - UsersProject.transaction do - UsersProject.where(:user_id => user_ids, :project_id => project.id).each do |users_project| - users_project.project_access = project_access - users_project.save + def bulk_update(project, user_ids, project_access) + UsersProject.transaction do + UsersProject.where(:user_id => user_ids, :project_id => project.id).each do |users_project| + users_project.project_access = project_access + users_project.save + end end end - end - def self.bulk_import(project, user_ids, project_access) - UsersProject.transaction do - user_ids.each do |user_id| - users_project = UsersProject.new( - project_access: project_access, - user_id: user_id - ) - users_project.project = project - users_project.save + def bulk_import(project, user_ids, project_access) + UsersProject.transaction do + user_ids.each do |user_id| + users_project = UsersProject.new( + project_access: project_access, + user_id: user_id + ) + users_project.project = project + users_project.save + end end end - end - def self.user_bulk_import(user, project_ids, project_access) - UsersProject.transaction do - project_ids.each do |project_id| - users_project = UsersProject.new( - project_access: project_access, - ) - users_project.project_id = project_id - users_project.user_id = user.id - users_project.save + def user_bulk_import(user, project_ids, project_access) + UsersProject.transaction do + project_ids.each do |project_id| + users_project = UsersProject.new( + project_access: project_access, + ) + users_project.project_id = project_id + users_project.user_id = user.id + users_project.save + end end end - end - def self.access_roles - { - "Guest" => GUEST, - "Reporter" => REPORTER, - "Developer" => DEVELOPER, - "Master" => MASTER - } + def access_roles + { + "Guest" => GUEST, + "Reporter" => REPORTER, + "Developer" => DEVELOPER, + "Master" => MASTER + } + end end def role_access diff --git a/app/models/web_hook.rb b/app/models/web_hook.rb index edfab886..779b3a99 100644 --- a/app/models/web_hook.rb +++ b/app/models/web_hook.rb @@ -7,7 +7,7 @@ class WebHook < ActiveRecord::Base default_timeout 10 validates :url, presence: true, - format: { with: URI::regexp(%w(http https)), message: "should be a valid url" } + format: { with: URI::regexp(%w(http https)), message: "should be a valid url" } def execute(data) parsed_url = URI.parse(url) diff --git a/app/models/wiki.rb b/app/models/wiki.rb index c87ac89e..3a431e4c 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -5,8 +5,9 @@ class Wiki < ActiveRecord::Base belongs_to :user has_many :notes, as: :noteable, dependent: :destroy - validates :content, :title, :user_id, presence: true - validates :title, length: 1..250 + validates :content, presence: true + validates :user, presence: true + validates :title, presence: true, length: 1..250 before_update :set_slug @@ -16,21 +17,20 @@ class Wiki < ActiveRecord::Base protected + def self.regenerate_from wiki + regenerated_field = [:slug, :content, :title] + + new_wiki = Wiki.new + regenerated_field.each do |field| + new_wiki.send("#{field}=", wiki.send(field)) + end + new_wiki + end + def set_slug self.slug = self.title.parameterize end - class << self - def regenerate_from wiki - regenerated_field = [:slug, :content, :title] - - new_wiki = Wiki.new - regenerated_field.each do |field| - new_wiki.send("#{field}=", wiki.send(field)) - end - new_wiki - end - end end # == Schema Information diff --git a/app/roles/account.rb b/app/roles/account.rb index b8c445a3..19465478 100644 --- a/app/roles/account.rb +++ b/app/roles/account.rb @@ -41,7 +41,7 @@ module Account # Remove user from all projects and # set blocked attribute to true def block - users_projects.all.each do |membership| + users_projects.find_each do |membership| return false unless membership.destroy end diff --git a/app/roles/authority.rb b/app/roles/authority.rb index 9d9153db..dbdd9839 100644 --- a/app/roles/authority.rb +++ b/app/roles/authority.rb @@ -2,12 +2,12 @@ module Authority # Compatible with all access rights # Should be rewrited for new access rights def add_access(user, *access) - access = if access.include?(:admin) - { project_access: UsersProject::MASTER } + access = if access.include?(:admin) + { project_access: UsersProject::MASTER } elsif access.include?(:write) - { project_access: UsersProject::DEVELOPER } + { project_access: UsersProject::DEVELOPER } else - { project_access: UsersProject::REPORTER } + { project_access: UsersProject::REPORTER } end opts = { user: user } opts.merge!(access) diff --git a/app/roles/issue_commonality.rb b/app/roles/issue_commonality.rb index 304f08fd..b21d92a3 100644 --- a/app/roles/issue_commonality.rb +++ b/app/roles/issue_commonality.rb @@ -8,12 +8,9 @@ module IssueCommonality belongs_to :assignee, class_name: "User" has_many :notes, as: :noteable, dependent: :destroy - validates_presence_of :project_id - validates_presence_of :author_id - - validates :title, - presence: true, - length: { within: 0..255 } + validates :project, presence: true + validates :author, presence: true + validates :title, presence: true, length: { within: 0..255 } validates :closed, inclusion: { in: [true, false] } scope :opened, where(closed: false) diff --git a/app/roles/push_event.rb b/app/roles/push_event.rb index a607f212..a6041f18 100644 --- a/app/roles/push_event.rb +++ b/app/roles/push_event.rb @@ -5,11 +5,11 @@ module PushEvent false end - def tag? + def tag? data[:ref]["refs/tags"] end - def branch? + def branch? data[:ref]["refs/heads"] end @@ -25,7 +25,7 @@ module PushEvent commit_to =~ /^00000/ end - def md_ref? + def md_ref? !(rm_ref? || new_ref?) end @@ -37,7 +37,7 @@ module PushEvent data[:after] end - def ref_name + def ref_name if tag? tag_name else From a4cd738686659314f0bb9fd13a80845dc2b036ab Mon Sep 17 00:00:00 2001 From: Andrey Kumanyaev Date: Tue, 9 Oct 2012 04:10:16 +0400 Subject: [PATCH 180/288] tests fix --- spec/models/group_spec.rb | 2 +- spec/models/milestone_spec.rb | 2 +- spec/models/protected_branch_spec.rb | 2 +- spec/models/snippet_spec.rb | 4 ++-- spec/models/users_project_spec.rb | 4 ++-- spec/models/wiki_spec.rb | 2 +- spec/roles/issue_commonality_spec.rb | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index fd7db4b2..5ae40658 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -20,5 +20,5 @@ describe Group do it { should validate_uniqueness_of(:name) } it { should validate_presence_of :code } it { should validate_uniqueness_of(:code) } - it { should validate_presence_of :owner_id } + it { should validate_presence_of :owner } end diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 9c11a7b1..ef50e012 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -12,7 +12,7 @@ describe Milestone do describe "Validation" do it { should validate_presence_of(:title) } - it { should validate_presence_of(:project_id) } + it { should validate_presence_of(:project) } it { should ensure_inclusion_of(:closed).in_array([true, false]) } end diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb index 4b292362..c6b09f35 100644 --- a/spec/models/protected_branch_spec.rb +++ b/spec/models/protected_branch_spec.rb @@ -10,7 +10,7 @@ describe ProtectedBranch do end describe 'Validation' do - it { should validate_presence_of(:project_id) } + it { should validate_presence_of(:project) } it { should validate_presence_of(:name) } end diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index 66c36e51..465612e0 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -13,8 +13,8 @@ describe Snippet do end describe "Validation" do - it { should validate_presence_of(:author_id) } - it { should validate_presence_of(:project_id) } + it { should validate_presence_of(:author) } + it { should validate_presence_of(:project) } it { should validate_presence_of(:title) } it { should ensure_length_of(:title).is_within(0..255) } diff --git a/spec/models/users_project_spec.rb b/spec/models/users_project_spec.rb index a13a08db..a64ff367 100644 --- a/spec/models/users_project_spec.rb +++ b/spec/models/users_project_spec.rb @@ -13,10 +13,10 @@ describe UsersProject do describe "Validation" do let!(:users_project) { create(:users_project) } - it { should validate_presence_of(:user_id) } + it { should validate_presence_of(:user) } it { should validate_uniqueness_of(:user_id).scoped_to(:project_id).with_message(/already exists/) } - it { should validate_presence_of(:project_id) } + it { should validate_presence_of(:project) } end describe "Delegate methods" do diff --git a/spec/models/wiki_spec.rb b/spec/models/wiki_spec.rb index 1e27954c..7830c821 100644 --- a/spec/models/wiki_spec.rb +++ b/spec/models/wiki_spec.rb @@ -16,6 +16,6 @@ describe Wiki do it { should validate_presence_of(:title) } it { should ensure_length_of(:title).is_within(1..250) } it { should validate_presence_of(:content) } - it { should validate_presence_of(:user_id) } + it { should validate_presence_of(:user) } end end diff --git a/spec/roles/issue_commonality_spec.rb b/spec/roles/issue_commonality_spec.rb index 77b98b46..fc4114e3 100644 --- a/spec/roles/issue_commonality_spec.rb +++ b/spec/roles/issue_commonality_spec.rb @@ -11,8 +11,8 @@ describe Issue, "IssueCommonality" do end describe "Validation" do - it { should validate_presence_of(:project_id) } - it { should validate_presence_of(:author_id) } + it { should validate_presence_of(:project) } + it { should validate_presence_of(:author) } it { should validate_presence_of(:title) } it { should ensure_length_of(:title).is_at_least(0).is_at_most(255) } end From ce1b742b1e61d8726078e0060ba52aa8b9985c1b Mon Sep 17 00:00:00 2001 From: randx Date: Tue, 9 Oct 2012 09:46:20 +0300 Subject: [PATCH 181/288] Group: new link on dashboard if admin. Fixed people count --- app/controllers/groups_controller.rb | 2 +- app/roles/account.rb | 4 ++++ app/views/dashboard/_groups.html.haml | 5 +++++ app/views/groups/people.html.haml | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index c76e5c4c..5576bc03 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -52,7 +52,7 @@ class GroupsController < ApplicationController end def people - @users = group.users + @users = group.users.all end protected diff --git a/app/roles/account.rb b/app/roles/account.rb index b8c445a3..af5b7c88 100644 --- a/app/roles/account.rb +++ b/app/roles/account.rb @@ -22,6 +22,10 @@ module Account projects_limit > my_own_projects.count end + def can_create_group? + is_admin? + end + def last_activity_project projects.first end diff --git a/app/views/dashboard/_groups.html.haml b/app/views/dashboard/_groups.html.haml index 146a49e6..7c5e9f3f 100644 --- a/app/views/dashboard/_groups.html.haml +++ b/app/views/dashboard/_groups.html.haml @@ -3,6 +3,11 @@ Groups %small (#{groups.count}) + - if current_user.can_create_group? + %span.right + = link_to new_admin_group_path, class: "btn very_small info" do + %i.icon-plus + New Group %ul.unstyled - groups.each do |group| %li.wll diff --git a/app/views/groups/people.html.haml b/app/views/groups/people.html.haml index 4c1865a2..25810808 100644 --- a/app/views/groups/people.html.haml +++ b/app/views/groups/people.html.haml @@ -2,7 +2,7 @@ %h5 People %small - (#{@users.count}) + (#{@users.size}) %ul.unstyled - @users.each do |user| %li.wll From c348284fedb487474626b3dae9be73311f8382df Mon Sep 17 00:00:00 2001 From: randx Date: Tue, 9 Oct 2012 10:01:07 +0300 Subject: [PATCH 182/288] Reduce count of projects on dashboard to 20 --- app/controllers/dashboard_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 1f142dae..ee82d0f4 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -4,7 +4,7 @@ class DashboardController < ApplicationController def index @groups = Group.where(id: current_user.projects.pluck(:group_id)) @projects = current_user.projects_with_events - @projects = @projects.page(params[:page]).per(40) + @projects = @projects.page(params[:page]).per(20) @events = Event.recent_for_user(current_user).limit(20).offset(params[:offset] || 0) @last_push = current_user.recent_push From 41e53eb98058a0082e0951aa21812b04d745414a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 9 Oct 2012 11:14:17 +0300 Subject: [PATCH 183/288] Annotated --- app/models/event.rb | 1 + app/models/group.rb | 1 + app/models/issue.rb | 1 + app/models/key.rb | 1 + app/models/merge_request.rb | 5 ++-- app/models/milestone.rb | 1 + app/models/note.rb | 1 + app/models/project_hook.rb | 1 + app/models/protected_branch.rb | 1 + app/models/snippet.rb | 1 + app/models/system_hook.rb | 1 + app/models/user.rb | 1 + app/models/users_project.rb | 1 + app/models/web_hook.rb | 1 + app/models/wiki.rb | 1 + spec/models/event_spec.rb | 16 +++++++++++++ spec/models/issue_spec.rb | 18 +++++++++++++++ spec/models/key_spec.rb | 14 ++++++++++++ spec/models/merge_request_spec.rb | 20 ++++++++++++++++ spec/models/milestone_spec.rb | 14 ++++++++++++ spec/models/note_spec.rb | 16 +++++++++++++ spec/models/protected_branch_spec.rb | 11 +++++++++ spec/models/snippet_spec.rb | 15 ++++++++++++ spec/models/system_hook_spec.rb | 12 ++++++++++ spec/models/user_spec.rb | 34 ++++++++++++++++++++++++++++ spec/models/users_project_spec.rb | 12 ++++++++++ spec/models/web_hook_spec.rb | 12 ++++++++++ spec/models/wiki_spec.rb | 14 ++++++++++++ 28 files changed, 225 insertions(+), 2 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 17cc1d58..647abdb9 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -163,3 +163,4 @@ end # action :integer # author_id :integer # + diff --git a/app/models/group.rb b/app/models/group.rb index 012b1285..ef8c7463 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -34,3 +34,4 @@ end # created_at :datetime not null # updated_at :datetime not null # + diff --git a/app/models/issue.rb b/app/models/issue.rb index 9acee1e5..5450bb49 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -49,3 +49,4 @@ end # description :text # milestone_id :integer # + diff --git a/app/models/key.rb b/app/models/key.rb index 43db0950..e4710b85 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -81,3 +81,4 @@ end # identifier :string(255) # project_id :integer # + diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index dc44d820..b6392ce8 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -202,8 +202,9 @@ end # closed :boolean default(FALSE), not null # created_at :datetime not null # updated_at :datetime not null -# st_commits :text(2147483647 -# st_diffs :text(2147483647 +# st_commits :text(4294967295 +# st_diffs :text(4294967295 # merged :boolean default(FALSE), not null # state :integer default(1), not null # + diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 096376e3..06c09431 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -39,3 +39,4 @@ end # created_at :datetime not null # updated_at :datetime not null # + diff --git a/app/models/note.rb b/app/models/note.rb index 55b011f8..65b20fe0 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -118,3 +118,4 @@ end # attachment :string(255) # line_code :string(255) # + diff --git a/app/models/project_hook.rb b/app/models/project_hook.rb index 5a59ebe9..92f6d1f0 100644 --- a/app/models/project_hook.rb +++ b/app/models/project_hook.rb @@ -13,3 +13,4 @@ end # updated_at :datetime not null # type :string(255) default("ProjectHook") # + diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index cd93dc1b..926692f1 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -29,3 +29,4 @@ end # created_at :datetime not null # updated_at :datetime not null # + diff --git a/app/models/snippet.rb b/app/models/snippet.rb index e8670cdb..3525219e 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -63,3 +63,4 @@ end # file_name :string(255) # expires_at :datetime # + diff --git a/app/models/system_hook.rb b/app/models/system_hook.rb index 8ec8374b..f56b80f4 100644 --- a/app/models/system_hook.rb +++ b/app/models/system_hook.rb @@ -21,3 +21,4 @@ end # updated_at :datetime not null # type :string(255) default("ProjectHook") # + diff --git a/app/models/user.rb b/app/models/user.rb index da0e9a0a..b0484698 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -113,3 +113,4 @@ end # extern_uid :string(255) # provider :string(255) # + diff --git a/app/models/users_project.rb b/app/models/users_project.rb index a3d5116f..e336fac3 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -102,3 +102,4 @@ end # updated_at :datetime not null # project_access :integer default(0), not null # + diff --git a/app/models/web_hook.rb b/app/models/web_hook.rb index 779b3a99..db773c55 100644 --- a/app/models/web_hook.rb +++ b/app/models/web_hook.rb @@ -34,3 +34,4 @@ end # updated_at :datetime not null # type :string(255) default("ProjectHook") # + diff --git a/app/models/wiki.rb b/app/models/wiki.rb index 3a431e4c..b1f41d63 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -46,3 +46,4 @@ end # slug :string(255) # user_id :integer # + diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 5cb68761..77b49246 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -1,3 +1,19 @@ +# == Schema Information +# +# Table name: events +# +# id :integer not null, primary key +# target_type :string(255) +# target_id :integer +# title :string(255) +# data :text +# project_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# action :integer +# author_id :integer +# + require 'spec_helper' describe Event do diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 099c4198..7c98b9ea 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -1,3 +1,21 @@ +# == Schema Information +# +# Table name: issues +# +# id :integer not null, primary key +# title :string(255) +# assignee_id :integer +# author_id :integer +# project_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# closed :boolean default(FALSE), not null +# position :integer default(0) +# branch_name :string(255) +# description :text +# milestone_id :integer +# + require 'spec_helper' describe Issue do diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 169bd890..d3231af8 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: keys +# +# id :integer not null, primary key +# user_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# key :text +# title :string(255) +# identifier :string(255) +# project_id :integer +# + require 'spec_helper' describe Key do diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index a5484924..7a1f541f 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1,3 +1,23 @@ +# == Schema Information +# +# Table name: merge_requests +# +# id :integer not null, primary key +# target_branch :string(255) not null +# source_branch :string(255) not null +# project_id :integer not null +# author_id :integer +# assignee_id :integer +# title :string(255) +# closed :boolean default(FALSE), not null +# created_at :datetime not null +# updated_at :datetime not null +# st_commits :text(4294967295 +# st_diffs :text(4294967295 +# merged :boolean default(FALSE), not null +# state :integer default(1), not null +# + require 'spec_helper' describe MergeRequest do diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index ef50e012..1aba20c6 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: milestones +# +# id :integer not null, primary key +# title :string(255) not null +# project_id :integer not null +# description :text +# due_date :date +# closed :boolean default(FALSE), not null +# created_at :datetime not null +# updated_at :datetime not null +# + require 'spec_helper' describe Milestone do diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 34493a11..8b622d5b 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -1,3 +1,19 @@ +# == Schema Information +# +# Table name: notes +# +# id :integer not null, primary key +# note :text +# noteable_id :string(255) +# noteable_type :string(255) +# author_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# project_id :integer +# attachment :string(255) +# line_code :string(255) +# + require 'spec_helper' describe Note do diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb index c6b09f35..874c4e4d 100644 --- a/spec/models/protected_branch_spec.rb +++ b/spec/models/protected_branch_spec.rb @@ -1,3 +1,14 @@ +# == Schema Information +# +# Table name: protected_branches +# +# id :integer not null, primary key +# project_id :integer not null +# name :string(255) not null +# created_at :datetime not null +# updated_at :datetime not null +# + require 'spec_helper' describe ProtectedBranch do diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index 465612e0..ada5fcdb 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -1,3 +1,18 @@ +# == Schema Information +# +# Table name: snippets +# +# id :integer not null, primary key +# title :string(255) +# content :text +# author_id :integer not null +# project_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# file_name :string(255) +# expires_at :datetime +# + require 'spec_helper' describe Snippet do diff --git a/spec/models/system_hook_spec.rb b/spec/models/system_hook_spec.rb index fe2a5836..b5d338a8 100644 --- a/spec/models/system_hook_spec.rb +++ b/spec/models/system_hook_spec.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: web_hooks +# +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# type :string(255) default("ProjectHook") +# + require "spec_helper" describe SystemHook do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b77d8878..5f41fb05 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,3 +1,37 @@ +# == Schema Information +# +# Table name: users +# +# id :integer not null, primary key +# email :string(255) default(""), not null +# encrypted_password :string(128) default(""), not null +# reset_password_token :string(255) +# reset_password_sent_at :datetime +# remember_created_at :datetime +# sign_in_count :integer default(0) +# current_sign_in_at :datetime +# last_sign_in_at :datetime +# current_sign_in_ip :string(255) +# last_sign_in_ip :string(255) +# created_at :datetime not null +# updated_at :datetime not null +# name :string(255) +# admin :boolean default(FALSE), not null +# projects_limit :integer default(10) +# skype :string(255) default(""), not null +# linkedin :string(255) default(""), not null +# twitter :string(255) default(""), not null +# authentication_token :string(255) +# dark_scheme :boolean default(FALSE), not null +# theme_id :integer default(1), not null +# bio :string(255) +# blocked :boolean default(FALSE), not null +# failed_attempts :integer default(0) +# locked_at :datetime +# extern_uid :string(255) +# provider :string(255) +# + require 'spec_helper' describe User do diff --git a/spec/models/users_project_spec.rb b/spec/models/users_project_spec.rb index a64ff367..5b6516b3 100644 --- a/spec/models/users_project_spec.rb +++ b/spec/models/users_project_spec.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: users_projects +# +# id :integer not null, primary key +# user_id :integer not null +# project_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# project_access :integer default(0), not null +# + require 'spec_helper' describe UsersProject do diff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rb index 422d67cf..d71fec81 100644 --- a/spec/models/web_hook_spec.rb +++ b/spec/models/web_hook_spec.rb @@ -1,3 +1,15 @@ +# == Schema Information +# +# Table name: web_hooks +# +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# type :string(255) default("ProjectHook") +# + require 'spec_helper' describe ProjectHook do diff --git a/spec/models/wiki_spec.rb b/spec/models/wiki_spec.rb index 7830c821..96aebd2d 100644 --- a/spec/models/wiki_spec.rb +++ b/spec/models/wiki_spec.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: wikis +# +# id :integer not null, primary key +# title :string(255) +# content :text +# project_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# slug :string(255) +# user_id :integer +# + require 'spec_helper' describe Wiki do From a54a90188b03730c998b7e5a91c85611dfe5e311 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Tue, 9 Oct 2012 14:59:58 +0300 Subject: [PATCH 184/288] remove unnecessary task --- lib/tasks/gitlab/write_hook.rake | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 lib/tasks/gitlab/write_hook.rake diff --git a/lib/tasks/gitlab/write_hook.rake b/lib/tasks/gitlab/write_hook.rake deleted file mode 100644 index ccc96aad..00000000 --- a/lib/tasks/gitlab/write_hook.rake +++ /dev/null @@ -1,21 +0,0 @@ -namespace :gitlab do - namespace :gitolite do - desc "GITLAB | Write GitLab hook for gitolite" - task :write_hooks => :environment do - gitolite_hooks_path = File.join(Gitlab.config.git_hooks_path, "common") - gitlab_hooks_path = Rails.root.join("lib", "hooks") - gitlab_hook_files = ['post-receive'] - - gitlab_hook_files.each do |file_name| - source = File.join(gitlab_hooks_path, file_name) - dest = File.join(gitolite_hooks_path, file_name) - - puts "sudo -u root cp #{source} #{dest}".yellow - `sudo -u root cp #{source} #{dest}` - - puts "sudo -u root chown git:git #{dest}".yellow - `sudo -u root chown git:git #{dest}` - end - end - end -end From bbd92e57cb5c764baf5fbdb9ccb1a1cd140eeca9 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Tue, 9 Oct 2012 14:47:42 +0200 Subject: [PATCH 185/288] Add emoji_for_completion helper --- app/helpers/notes_helper.rb | 6 ++++++ spec/helpers/notes_helper_spec.rb | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 spec/helpers/notes_helper_spec.rb diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 65389e38..9f75fc42 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -14,4 +14,10 @@ module NotesHelper "vote downvote" end end + + def emoji_for_completion + # should be an array of strings + # so to_s can be called, because it is sufficient and to_json is too slow + Emoji::NAMES + end end diff --git a/spec/helpers/notes_helper_spec.rb b/spec/helpers/notes_helper_spec.rb new file mode 100644 index 00000000..73481694 --- /dev/null +++ b/spec/helpers/notes_helper_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +describe NotesHelper do + describe "#emoji_for_completion" do + it "should be an Array of Strings" do + emoji_for_completion.should be_a(Array) + emoji_for_completion.each { |emoji| emoji.should be_a(String) } + end + end +end From 3adfbe3e81697f61775d4d08d8eacde5a13a95c4 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Tue, 9 Oct 2012 14:48:20 +0200 Subject: [PATCH 186/288] Mark inputs for notes with GFM capabilities --- app/views/notes/_common_form.html.haml | 2 +- app/views/notes/_per_line_form.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/notes/_common_form.html.haml b/app/views/notes/_common_form.html.haml index adaad9ec..260725e9 100644 --- a/app/views/notes/_common_form.html.haml +++ b/app/views/notes/_common_form.html.haml @@ -8,7 +8,7 @@ = f.hidden_field :noteable_id = f.hidden_field :noteable_type - = f.text_area :note, size: 255, class: 'note-text' + = f.text_area :note, size: 255, class: 'note-text gfm-input' #preview-note.preview_note.hide .hint .right Comments are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. diff --git a/app/views/notes/_per_line_form.html.haml b/app/views/notes/_per_line_form.html.haml index 8e31b59e..ee0cde4b 100644 --- a/app/views/notes/_per_line_form.html.haml +++ b/app/views/notes/_per_line_form.html.haml @@ -13,7 +13,7 @@ = f.hidden_field :noteable_id = f.hidden_field :noteable_type = f.hidden_field :line_code - = f.text_area :note, size: 255, class: 'line-note-text' + = f.text_area :note, size: 255, class: 'line-note-text gfm-input' .note_actions .buttons = f.submit 'Add note', class: "btn save-btn submit_note submit_inline_note", id: "submit_note" From 37e579ce10376ef16f9e9f28b81b0ca788438204 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Tue, 9 Oct 2012 14:48:35 +0200 Subject: [PATCH 187/288] Redo the auto-completion JS for notes --- app/views/notes/_common_form.html.haml | 50 +++++++++++++++++++++----- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/app/views/notes/_common_form.html.haml b/app/views/notes/_common_form.html.haml index 260725e9..4ac26d33 100644 --- a/app/views/notes/_common_form.html.haml +++ b/app/views/notes/_common_form.html.haml @@ -39,12 +39,46 @@ :javascript $(function(){ - var names = #{@project.users.pluck(:name)}, emoji = ['+1', '-1']; - var emoji = $.map(emoji, function(value, i) {return {key:value + ':', name:value}}); - $('#note_note, .per_line_form .line-note-text'). - atWho('@', { data: names }). - atWho(':', { - data: emoji, - tpl: "
  • ${name} #{escape_javascript image_tag('emoji/${name}.png', :size => '20x20')}
  • " - }); + // init auto-completion of team members + var membersUrl = "#{root_url}/api/v2/projects/#{@project.code}/members"; + var membersParams = { + private_token: "#{current_user.authentication_token}", + page: 1, + }; + var membersData = []; + $('.gfm-input').atWho('@', function(query, callback) { + (function getMoreMembers() { + $.getJSON(membersUrl, membersParams). + success(function(members) { + // pick the data we need + var newMembersData = $.map(members, function(member) { return member.name }); + + // add the new page of data to the rest + $.merge(membersData, newMembersData); + + // show the pop-up with a copy of the current data + callback(membersData.slice(0)); + + // are we past the last page? + if (newMembersData.length == 0) { + // set static data and stop callbacks + $('.gfm-input').atWho('@', { data: membersData, callback: null }); + } else { + // get next page + getMoreMembers(); + } + }); + // next request will get the next page + membersParams.page += 1; + })(); + }); + + // init auto-completion of emoji + var emoji = #{emoji_for_completion}; + // convert the list so that the items have the right format for completion + emoji = $.map(emoji, function(value) {return { key: value+':', name: value }}); + $('.gfm-input').atWho(':', { + data: emoji, + tpl: "
  • ${name} #{escape_javascript image_tag('emoji/${name}.png', :size => '20x20')}
  • " + }); }); From 63fe042d97a5430770ec50fc0e8f29c416bd2ec9 Mon Sep 17 00:00:00 2001 From: randx Date: Tue, 9 Oct 2012 20:39:06 +0300 Subject: [PATCH 188/288] project.issues_labels method --- app/controllers/labels_controller.rb | 2 +- app/models/project.rb | 4 ++++ app/roles/issue_commonality.rb | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/labels_controller.rb b/app/controllers/labels_controller.rb index 3cbbb869..999351e2 100644 --- a/app/controllers/labels_controller.rb +++ b/app/controllers/labels_controller.rb @@ -7,7 +7,7 @@ class LabelsController < ProjectResourceController respond_to :js, :html def index - @labels = @project.issues.tag_counts_on(:labels).order('count DESC') + @labels = @project.issues_labels.order('count DESC') end protected diff --git a/app/models/project.rb b/app/models/project.rb index f4d86887..3ae15f24 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -159,6 +159,10 @@ class Project < ActiveRecord::Base def project_id self.id end + + def issues_labels + issues.tag_counts_on(:labels) + end end # == Schema Information diff --git a/app/roles/issue_commonality.rb b/app/roles/issue_commonality.rb index b21d92a3..4aee916c 100644 --- a/app/roles/issue_commonality.rb +++ b/app/roles/issue_commonality.rb @@ -1,4 +1,5 @@ -# Contains common functionality shared between Issues and MergeRequests +# Contains common functionality +# shared between Issues and MergeRequests module IssueCommonality extend ActiveSupport::Concern From 679d0d6d760b850e27c13f3ce0f812b8b081df7f Mon Sep 17 00:00:00 2001 From: randx Date: Tue, 9 Oct 2012 22:09:46 +0300 Subject: [PATCH 189/288] Context refactoring. Move Issues list, Search logic to context --- ...{commit_load.rb => commit_load_context.rb} | 8 ++-- app/contexts/issues_list_context.rb | 29 +++++++++++++++ ...load.rb => merge_requests_load_context.rb} | 2 +- app/contexts/search_context.rb | 27 ++++++++++++++ app/controllers/commit_controller.rb | 2 +- app/controllers/dashboard_controller.rb | 6 +-- app/controllers/groups_controller.rb | 22 ++++------- app/controllers/issues_controller.rb | 37 ++----------------- app/controllers/merge_requests_controller.rb | 10 ++--- app/controllers/milestones_controller.rb | 2 +- app/controllers/refs_controller.rb | 6 +-- app/controllers/search_controller.rb | 14 ++----- app/helpers/issues_helper.rb | 9 +++++ app/models/event.rb | 5 +-- app/roles/issue_commonality.rb | 4 +- 15 files changed, 100 insertions(+), 83 deletions(-) rename app/contexts/{commit_load.rb => commit_load_context.rb} (89%) create mode 100644 app/contexts/issues_list_context.rb rename app/contexts/{merge_requests_load.rb => merge_requests_load_context.rb} (91%) create mode 100644 app/contexts/search_context.rb diff --git a/app/contexts/commit_load.rb b/app/contexts/commit_load_context.rb similarity index 89% rename from app/contexts/commit_load.rb rename to app/contexts/commit_load_context.rb index 81fb4925..b3548ed8 100644 --- a/app/contexts/commit_load.rb +++ b/app/contexts/commit_load_context.rb @@ -1,17 +1,17 @@ -class CommitLoad < BaseContext +class CommitLoadContext < BaseContext def execute - result = { + result = { commit: nil, suppress_diff: false, line_notes: [], notes_count: 0, - note: nil, + note: nil, status: :ok } commit = project.commit(params[:id]) - if commit + if commit commit = CommitDecorator.decorate(commit) line_notes = project.commit_line_notes(commit) diff --git a/app/contexts/issues_list_context.rb b/app/contexts/issues_list_context.rb new file mode 100644 index 00000000..9bbdfe1d --- /dev/null +++ b/app/contexts/issues_list_context.rb @@ -0,0 +1,29 @@ +class IssuesListContext < BaseContext + include IssuesHelper + + attr_accessor :issues + + def execute + @issues = case params[:f] + when issues_filter[:all] then @project.issues + when issues_filter[:closed] then @project.issues.closed + when issues_filter[:to_me] then @project.issues.opened.assigned(current_user) + else @project.issues.opened + end + + @issues = @issues.tagged_with(params[:label_name]) if params[:label_name].present? + @issues = @issues.includes(:author, :project).order("updated_at") + + # Filter by specific assignee_id (or lack thereof)? + if params[:assignee_id].present? + @issues = @issues.where(assignee_id: (params[:assignee_id] == '0' ? nil : params[:assignee_id])) + end + + # Filter by specific milestone_id (or lack thereof)? + if params[:milestone_id].present? + @issues = @issues.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id])) + end + + @issues + end +end diff --git a/app/contexts/merge_requests_load.rb b/app/contexts/merge_requests_load_context.rb similarity index 91% rename from app/contexts/merge_requests_load.rb rename to app/contexts/merge_requests_load_context.rb index e2f68e38..e7dbdd28 100644 --- a/app/contexts/merge_requests_load.rb +++ b/app/contexts/merge_requests_load_context.rb @@ -1,4 +1,4 @@ -class MergeRequestsLoad < BaseContext +class MergeRequestsLoadContext < BaseContext def execute type = params[:f] diff --git a/app/contexts/search_context.rb b/app/contexts/search_context.rb new file mode 100644 index 00000000..6e5e8c5e --- /dev/null +++ b/app/contexts/search_context.rb @@ -0,0 +1,27 @@ +class SearchContext + attr_accessor :project_ids, :params + + def initialize(project_ids, params) + @project_ids, @params = project_ids, params.dup + end + + def execute + query = params[:search] + + return result unless query.present? + + result[:projects] = Project.where(id: project_ids).search(query).limit(10) + result[:merge_requests] = MergeRequest.where(project_id: project_ids).search(query).limit(10) + result[:issues] = Issue.where(project_id: project_ids).search(query).limit(10) + result + end + + def result + @result ||= { + projects: [], + merge_requests: [], + issues: [] + } + end +end + diff --git a/app/controllers/commit_controller.rb b/app/controllers/commit_controller.rb index 25a1f0fe..97998352 100644 --- a/app/controllers/commit_controller.rb +++ b/app/controllers/commit_controller.rb @@ -8,7 +8,7 @@ class CommitController < ProjectResourceController before_filter :require_non_empty_project def show - result = CommitLoad.new(project, current_user, params).execute + result = CommitLoadContext.new(project, current_user, params).execute @commit = result[:commit] git_not_found! unless @commit diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index ee82d0f4..0ad73f32 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -6,7 +6,7 @@ class DashboardController < ApplicationController @projects = current_user.projects_with_events @projects = @projects.page(params[:page]).per(20) - @events = Event.recent_for_user(current_user).limit(20).offset(params[:offset] || 0) + @events = Event.in_projects(current_user.project_ids).limit(20).offset(params[:offset] || 0) @last_push = current_user.recent_push respond_to do |format| @@ -19,14 +19,14 @@ class DashboardController < ApplicationController # Get authored or assigned open merge requests def merge_requests @projects = current_user.projects.all - @merge_requests = current_user.cared_merge_requests.order("created_at DESC").page(params[:page]).per(20) + @merge_requests = current_user.cared_merge_requests.recent.page(params[:page]).per(20) end # Get only assigned issues def issues @projects = current_user.projects.all @user = current_user - @issues = current_user.assigned_issues.opened.order("created_at DESC").page(params[:page]).per(20) + @issues = current_user.assigned_issues.opened.recent.page(params[:page]).per(20) @issues = @issues.includes(:author, :project) respond_to do |format| diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 5576bc03..761238a9 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -6,10 +6,7 @@ class GroupsController < ApplicationController before_filter :projects def show - @events = Event.where(project_id: project_ids). - order('id DESC'). - limit(20).offset(params[:offset] || 0) - + @events = Event.in_projects(project_ids).limit(20).offset(params[:offset] || 0) @last_push = current_user.recent_push respond_to do |format| @@ -22,14 +19,14 @@ class GroupsController < ApplicationController # Get authored or assigned open merge requests def merge_requests @merge_requests = current_user.cared_merge_requests - @merge_requests = @merge_requests.of_group(@group).order("created_at DESC").page(params[:page]).per(20) + @merge_requests = @merge_requests.of_group(@group).recent.page(params[:page]).per(20) end # Get only assigned issues def issues @user = current_user @issues = current_user.assigned_issues.opened - @issues = @issues.of_group(@group).order("created_at DESC").page(params[:page]).per(20) + @issues = @issues.of_group(@group).recent.page(params[:page]).per(20) @issues = @issues.includes(:author, :project) respond_to do |format| @@ -39,16 +36,11 @@ class GroupsController < ApplicationController end def search - query = params[:search] + result = SearchContext.new(project_ids, params).execute - @merge_requests = [] - @issues = [] - - if query.present? - @projects = @projects.search(query).limit(10) - @merge_requests = MergeRequest.where(project_id: project_ids).search(query).limit(10) - @issues = Issue.where(project_id: project_ids).search(query).limit(10) - end + @projects = result[:projects] + @merge_requests = result[:merge_requests] + @issues = result[:issues] end def people diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 82ae5b37..0f28fc3a 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -1,7 +1,6 @@ class IssuesController < ProjectResourceController before_filter :module_enabled before_filter :issue, only: [:edit, :update, :destroy, :show] - helper_method :issues_filter # Allow read any issue before_filter :authorize_read_issue! @@ -19,7 +18,6 @@ class IssuesController < ProjectResourceController def index @issues = issues_filtered - @issues = @issues.page(params[:page]).per(20) respond_to do |format| @@ -54,7 +52,7 @@ class IssuesController < ProjectResourceController respond_to do |format| format.html do - if @issue.valid? + if @issue.valid? redirect_to project_issue_path(@project, @issue) else render :new @@ -69,7 +67,7 @@ class IssuesController < ProjectResourceController respond_to do |format| format.js - format.html do + format.html do if @issue.valid? redirect_to [@project, @issue] else @@ -134,35 +132,6 @@ class IssuesController < ProjectResourceController end def issues_filtered - @issues = case params[:f] - when issues_filter[:all] then @project.issues - when issues_filter[:closed] then @project.issues.closed - when issues_filter[:to_me] then @project.issues.opened.assigned(current_user) - else @project.issues.opened - end - - @issues = @issues.tagged_with(params[:label_name]) if params[:label_name].present? - @issues = @issues.includes(:author, :project).order("updated_at") - - # Filter by specific assignee_id (or lack thereof)? - if params[:assignee_id].present? - @issues = @issues.where(assignee_id: (params[:assignee_id] == '0' ? nil : params[:assignee_id])) - end - - # Filter by specific milestone_id (or lack thereof)? - if params[:milestone_id].present? - @issues = @issues.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id])) - end - - @issues - end - - def issues_filter - { - all: "all", - closed: "closed", - to_me: "assigned-to-me", - open: "open" - } + @issues = IssuesListContext.new(project, current_user, params).execute end end diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index f8d84263..8e180c9b 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -18,7 +18,7 @@ class MergeRequestsController < ProjectResourceController def index - @merge_requests = MergeRequestsLoad.new(project, current_user, params).execute + @merge_requests = MergeRequestsLoadContext.new(project, current_user, params).execute end def show @@ -55,7 +55,7 @@ class MergeRequestsController < ProjectResourceController @merge_request.reload_code redirect_to [@project, @merge_request], notice: 'Merge request was successfully created.' else - render action: "new" + render action: "new" end end @@ -70,7 +70,7 @@ class MergeRequestsController < ProjectResourceController end def automerge_check - if @merge_request.unchecked? + if @merge_request.unchecked? @merge_request.check_if_can_be_merged end render json: {state: @merge_request.human_state} @@ -125,7 +125,7 @@ class MergeRequestsController < ProjectResourceController def validates_merge_request # Show git not found page if target branch doesnt exist - return git_not_found! unless @project.repo.heads.map(&:name).include?(@merge_request.target_branch) + return git_not_found! unless @project.repo.heads.map(&:name).include?(@merge_request.target_branch) # Show git not found page if source branch doesnt exist # and there is no saved commits between source & target branch @@ -136,7 +136,7 @@ class MergeRequestsController < ProjectResourceController # Build a note object for comment form @note = @project.notes.new(noteable: @merge_request) - # Get commits from repository + # Get commits from repository # or from cache if already merged @commits = @merge_request.commits @commits = CommitDecorator.decorate(@commits) diff --git a/app/controllers/milestones_controller.rb b/app/controllers/milestones_controller.rb index 68479a26..f8fe987c 100644 --- a/app/controllers/milestones_controller.rb +++ b/app/controllers/milestones_controller.rb @@ -54,7 +54,7 @@ class MilestonesController < ProjectResourceController respond_to do |format| format.js - format.html do + format.html do if @milestone.valid? redirect_to [@project, @milestone] else diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index d3fc816b..6a1a3606 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -9,9 +9,9 @@ class RefsController < ProjectResourceController before_filter :ref before_filter :define_tree_vars, only: [:blob, :logs_tree] - def switch - respond_to do |format| - format.html do + def switch + respond_to do |format| + format.html do new_path = if params[:destination] == "tree" project_tree_path(@project, @ref) else diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 71e2d92b..1dc8507e 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,15 +1,9 @@ class SearchController < ApplicationController def show - query = params[:search] + result = SearchContext.new(current_user.project_ids, params).execute - @projects = [] - @merge_requests = [] - @issues = [] - - if query.present? - @projects = current_user.projects.search(query).limit(10) - @merge_requests = MergeRequest.where(project_id: current_user.project_ids).search(query).limit(10) - @issues = Issue.where(project_id: current_user.project_ids).search(query).limit(10) - end + @projects = result[:projects] + @merge_requests = result[:merge_requests] + @issues = result[:issues] end end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 9b537187..99ea9ef2 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -43,4 +43,13 @@ module IssuesHelper # Milestone uses :title, Issue uses :name OpenStruct.new(id: 0, title: 'Unspecified', name: 'Unassigned') end + + def issues_filter + { + all: "all", + closed: "closed", + to_me: "assigned-to-me", + open: "open" + } + end end diff --git a/app/models/event.rb b/app/models/event.rb index 647abdb9..0ea3224a 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -30,6 +30,7 @@ class Event < ActiveRecord::Base # Scopes scope :recent, order("created_at DESC") scope :code_push, where(action: Pushed) + scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent } class << self def determine_action(record) @@ -39,10 +40,6 @@ class Event < ActiveRecord::Base Event::Commented end end - - def recent_for_user user - where(project_id: user.projects.map(&:id)).recent - end end # Next events currently enabled for system diff --git a/app/roles/issue_commonality.rb b/app/roles/issue_commonality.rb index 4aee916c..3d907486 100644 --- a/app/roles/issue_commonality.rb +++ b/app/roles/issue_commonality.rb @@ -1,5 +1,4 @@ -# Contains common functionality -# shared between Issues and MergeRequests +# Contains common functionality shared between Issues and MergeRequests module IssueCommonality extend ActiveSupport::Concern @@ -18,6 +17,7 @@ module IssueCommonality scope :closed, where(closed: true) scope :of_group, ->(group) { where(project_id: group.project_ids) } scope :assigned, ->(u) { where(assignee_id: u.id)} + scope :recent, order("created_at DESC") delegate :name, :email, From 682f62fd4addb38843a9047b9ac47eb5ba94a30e Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Tue, 9 Oct 2012 23:06:33 +0200 Subject: [PATCH 190/288] Mark all GFM capable inputs --- app/views/issues/_form.html.haml | 4 ++-- app/views/merge_requests/_form.html.haml | 2 +- app/views/wikis/_form.html.haml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/issues/_form.html.haml b/app/views/issues/_form.html.haml index 813ecab2..ec3edce0 100644 --- a/app/views/issues/_form.html.haml +++ b/app/views/issues/_form.html.haml @@ -12,7 +12,7 @@ = f.label :title do %strong= "Subject *" .input - = f.text_field :title, maxlength: 255, class: "xxlarge" + = f.text_field :title, maxlength: 255, class: "xxlarge gfm-input" .issue_middle_block .issue_assignee = f.label :assignee_id do @@ -37,7 +37,7 @@ .clearfix = f.label :description, "Details" .input - = f.text_area :description, maxlength: 2000, class: "xxlarge", rows: 14 + = f.text_area :description, maxlength: 2000, class: "xxlarge gfm-input", rows: 14 %p.hint Issues are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. diff --git a/app/views/merge_requests/_form.html.haml b/app/views/merge_requests/_form.html.haml index 96692c0f..f42d74e1 100644 --- a/app/views/merge_requests/_form.html.haml +++ b/app/views/merge_requests/_form.html.haml @@ -38,7 +38,7 @@ .top_box_content = f.label :title do %strong= "Title *" - .input= f.text_field :title, class: "input-xxlarge pad", maxlength: 255, rows: 5 + .input= f.text_field :title, class: "input-xxlarge pad gfm-input", maxlength: 255, rows: 5 .middle_box_content = f.label :assignee_id do %i.icon-user diff --git a/app/views/wikis/_form.html.haml b/app/views/wikis/_form.html.haml index b05d0a78..89bbe2ea 100644 --- a/app/views/wikis/_form.html.haml +++ b/app/views/wikis/_form.html.haml @@ -21,7 +21,7 @@ .bottom_box_content = f.label :content - .input= f.text_area :content, class: 'span8' + .input= f.text_area :content, class: 'span8 gfm-input' .actions = f.submit 'Save', class: "save-btn btn" = link_to "Cancel", project_wiki_path(@project, :index), class: "btn cancel-btn" From cda5e66d7c190e852b23caca17d90df43d91d75e Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 3 Oct 2012 19:12:51 -0400 Subject: [PATCH 191/288] Use History.js for better Tree browsing Closes #1578 --- app/assets/javascripts/application.js | 1 + app/assets/javascripts/tree.js.coffee | 24 ++++++++++++++++++--- app/views/tree/_tree.html.haml | 17 ++------------- app/views/tree/_tree_item.html.haml | 2 +- vendor/assets/javascripts/jquery.history.js | 1 + 5 files changed, 26 insertions(+), 19 deletions(-) create mode 100644 vendor/assets/javascripts/jquery.history.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 02ef6cab..d582a1a1 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -10,6 +10,7 @@ //= require jquery.cookie //= require jquery.endless-scroll //= require jquery.highlight +//= require jquery.history //= require jquery.waitforimages //= require jquery.atwho //= require bootstrap diff --git a/app/assets/javascripts/tree.js.coffee b/app/assets/javascripts/tree.js.coffee index 83cc08dc..47d49abc 100644 --- a/app/assets/javascripts/tree.js.coffee +++ b/app/assets/javascripts/tree.js.coffee @@ -8,9 +8,6 @@ $ -> $('#tree-slider .tree-item-file-name a, .breadcrumb li > a').live "click", -> $("#tree-content-holder").hide("slide", { direction: "left" }, 150) - $('.project-refs-form').live - "ajax:beforeSend": -> $("#tree-content-holder").hide("slide", { direction: "left" }, 150) - # Make the entire tree-item row clickable, but not if clicking another link (like a commit message) $("#tree-slider .tree-item").live 'click', (e) -> $('.tree-item-file-name a', this).trigger('click') if (e.target.nodeName != "A") @@ -19,3 +16,24 @@ $ -> $('#tree-slider .tree-item-file-name a, .breadcrumb a, .project-refs-form').live "ajax:beforeSend": -> $('.tree_progress').addClass("loading") "ajax:complete": -> $('.tree_progress').removeClass("loading") + +# Maintain forward/back history while browsing the file tree + +((window) -> + History = window.History + $ = window.jQuery + document = window.document + + # Check to see if History.js is enabled for our Browser + unless History.enabled + return false + + $ -> + $('#tree-slider .tree-item-file-name a, .breadcrumb li > a').live 'click', (e) -> + History.pushState(null, null, $(@).attr('href')) + return false + + History.Adapter.bind window, 'statechange', -> + state = History.getState() + window.ajaxGet(state.url) +)(window) diff --git a/app/views/tree/_tree.html.haml b/app/views/tree/_tree.html.haml index 920a70b5..2937a474 100644 --- a/app/views/tree/_tree.html.haml +++ b/app/views/tree/_tree.html.haml @@ -1,7 +1,7 @@ %ul.breadcrumb %li %span.arrow - = link_to project_tree_path(@project, @ref), remote: true do + = link_to project_tree_path(@project, @ref) do = @project.name - tree.breadcrumbs(6) do |link| \/ @@ -26,7 +26,7 @@ %tr.tree-item %td.tree-item-file-name = image_tag "file_empty.png", size: '16x16' - = link_to "..", tree.up_dir_path, remote: true + = link_to "..", tree.up_dir_path %td %td @@ -44,22 +44,9 @@ - else = raw GitHub::Markup.render(content.name, content.data) -:javascript - $(function(){ - history.pushState({ path: this.path }, '', "#{@history_path}"); - }); - - unless tree.is_blob? :javascript // Load last commit log for each file in tree $(window).load(function(){ ajaxGet('#{@logs_path}'); }); - -- if @path.present? && request.xhr? - :javascript - $(window).unbind('popstate'); - $(window).bind('popstate', function() { - if(location.pathname.search("tree") != -1) { - $.ajax({type: "GET", url: location.pathname, dataType: "script"})} - else { location.href = location.pathname;}}); diff --git a/app/views/tree/_tree_item.html.haml b/app/views/tree/_tree_item.html.haml index 87311e19..e9675248 100644 --- a/app/views/tree/_tree_item.html.haml +++ b/app/views/tree/_tree_item.html.haml @@ -1,7 +1,7 @@ %tr{ class: "tree-item #{tree_hex_class(tree_item)}" } %td.tree-item-file-name = tree_icon(type) - %strong= link_to truncate(tree_item.name, length: 40), project_tree_path(@project, tree_join(@id || @commit.id, tree_item.name)), remote: true + %strong= link_to truncate(tree_item.name, length: 40), project_tree_path(@project, tree_join(@id || @commit.id, tree_item.name)) %td.tree_time_ago.cgray %span.log_loading.hide Loading commit data... diff --git a/vendor/assets/javascripts/jquery.history.js b/vendor/assets/javascripts/jquery.history.js new file mode 100644 index 00000000..8d4edcd2 --- /dev/null +++ b/vendor/assets/javascripts/jquery.history.js @@ -0,0 +1 @@ +window.JSON||(window.JSON={}),function(){function f(a){return a<10?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c")&&c[0]);return a>4?a:!1}();return a},m.isInternetExplorer=function(){var a=m.isInternetExplorer.cached=typeof m.isInternetExplorer.cached!="undefined"?m.isInternetExplorer.cached:Boolean(m.getInternetExplorerMajorVersion());return a},m.emulated={pushState:!Boolean(a.history&&a.history.pushState&&a.history.replaceState&&!/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(e.userAgent)&&!/AppleWebKit\/5([0-2]|3[0-2])/i.test(e.userAgent)),hashChange:Boolean(!("onhashchange"in a||"onhashchange"in d)||m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8)},m.enabled=!m.emulated.pushState,m.bugs={setHash:Boolean(!m.emulated.pushState&&e.vendor==="Apple Computer, Inc."&&/AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)),safariPoll:Boolean(!m.emulated.pushState&&e.vendor==="Apple Computer, Inc."&&/AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)),ieDoubleCheck:Boolean(m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8),hashEscape:Boolean(m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<7)},m.isEmptyObject=function(a){for(var b in a)return!1;return!0},m.cloneObject=function(a){var b,c;return a?(b=k.stringify(a),c=k.parse(b)):c={},c},m.getRootUrl=function(){var a=d.location.protocol+"//"+(d.location.hostname||d.location.host);if(d.location.port||!1)a+=":"+d.location.port;return a+="/",a},m.getBaseHref=function(){var a=d.getElementsByTagName("base"),b=null,c="";return a.length===1&&(b=a[0],c=b.href.replace(/[^\/]+$/,"")),c=c.replace(/\/+$/,""),c&&(c+="/"),c},m.getBaseUrl=function(){var a=m.getBaseHref()||m.getBasePageUrl()||m.getRootUrl();return a},m.getPageUrl=function(){var a=m.getState(!1,!1),b=(a||{}).url||d.location.href,c;return c=b.replace(/\/+$/,"").replace(/[^\/]+$/,function(a,b,c){return/\./.test(a)?a:a+"/"}),c},m.getBasePageUrl=function(){var a=d.location.href.replace(/[#\?].*/,"").replace(/[^\/]+$/,function(a,b,c){return/[^\/]$/.test(a)?"":a}).replace(/\/+$/,"")+"/";return a},m.getFullUrl=function(a,b){var c=a,d=a.substring(0,1);return b=typeof b=="undefined"?!0:b,/[a-z]+\:\/\//.test(a)||(d==="/"?c=m.getRootUrl()+a.replace(/^\/+/,""):d==="#"?c=m.getPageUrl().replace(/#.*/,"")+a:d==="?"?c=m.getPageUrl().replace(/[\?#].*/,"")+a:b?c=m.getBaseUrl()+a.replace(/^(\.\/)+/,""):c=m.getBasePageUrl()+a.replace(/^(\.\/)+/,"")),c.replace(/\#$/,"")},m.getShortUrl=function(a){var b=a,c=m.getBaseUrl(),d=m.getRootUrl();return m.emulated.pushState&&(b=b.replace(c,"")),b=b.replace(d,"/"),m.isTraditionalAnchor(b)&&(b="./"+b),b=b.replace(/^(\.\/)+/g,"./").replace(/\#$/,""),b},m.store={},m.idToState=m.idToState||{},m.stateToId=m.stateToId||{},m.urlToId=m.urlToId||{},m.storedStates=m.storedStates||[],m.savedStates=m.savedStates||[],m.normalizeStore=function(){m.store.idToState=m.store.idToState||{},m.store.urlToId=m.store.urlToId||{},m.store.stateToId=m.store.stateToId||{}},m.getState=function(a,b){typeof a=="undefined"&&(a=!0),typeof b=="undefined"&&(b=!0);var c=m.getLastSavedState();return!c&&b&&(c=m.createStateObject()),a&&(c=m.cloneObject(c),c.url=c.cleanUrl||c.url),c},m.getIdByState=function(a){var b=m.extractId(a.url),c;if(!b){c=m.getStateString(a);if(typeof m.stateToId[c]!="undefined")b=m.stateToId[c];else if(typeof m.store.stateToId[c]!="undefined")b=m.store.stateToId[c];else{for(;;){b=(new Date).getTime()+String(Math.random()).replace(/\D/g,"");if(typeof m.idToState[b]=="undefined"&&typeof m.store.idToState[b]=="undefined")break}m.stateToId[c]=b,m.idToState[b]=a}}return b},m.normalizeState=function(a){var b,c;if(!a||typeof a!="object")a={};if(typeof a.normalized!="undefined")return a;if(!a.data||typeof a.data!="object")a.data={};b={},b.normalized=!0,b.title=a.title||"",b.url=m.getFullUrl(m.unescapeString(a.url||d.location.href)),b.hash=m.getShortUrl(b.url),b.data=m.cloneObject(a.data),b.id=m.getIdByState(b),b.cleanUrl=b.url.replace(/\??\&_suid.*/,""),b.url=b.cleanUrl,c=!m.isEmptyObject(b.data);if(b.title||c)b.hash=m.getShortUrl(b.url).replace(/\??\&_suid.*/,""),/\?/.test(b.hash)||(b.hash+="?"),b.hash+="&_suid="+b.id;return b.hashedUrl=m.getFullUrl(b.hash),(m.emulated.pushState||m.bugs.safariPoll)&&m.hasUrlDuplicate(b)&&(b.url=b.hashedUrl),b},m.createStateObject=function(a,b,c){var d={data:a,title:b,url:c};return d=m.normalizeState(d),d},m.getStateById=function(a){a=String(a);var c=m.idToState[a]||m.store.idToState[a]||b;return c},m.getStateString=function(a){var b,c,d;return b=m.normalizeState(a),c={data:b.data,title:a.title,url:a.url},d=k.stringify(c),d},m.getStateId=function(a){var b,c;return b=m.normalizeState(a),c=b.id,c},m.getHashByState=function(a){var b,c;return b=m.normalizeState(a),c=b.hash,c},m.extractId=function(a){var b,c,d;return c=/(.*)\&_suid=([0-9]+)$/.exec(a),d=c?c[1]||a:a,b=c?String(c[2]||""):"",b||!1},m.isTraditionalAnchor=function(a){var b=!/[\/\?\.]/.test(a);return b},m.extractState=function(a,b){var c=null,d,e;return b=b||!1,d=m.extractId(a),d&&(c=m.getStateById(d)),c||(e=m.getFullUrl(a),d=m.getIdByUrl(e)||!1,d&&(c=m.getStateById(d)),!c&&b&&!m.isTraditionalAnchor(a)&&(c=m.createStateObject(null,null,e))),c},m.getIdByUrl=function(a){var c=m.urlToId[a]||m.store.urlToId[a]||b;return c},m.getLastSavedState=function(){return m.savedStates[m.savedStates.length-1]||b},m.getLastStoredState=function(){return m.storedStates[m.storedStates.length-1]||b},m.hasUrlDuplicate=function(a){var b=!1,c;return c=m.extractState(a.url),b=c&&c.id!==a.id,b},m.storeState=function(a){return m.urlToId[a.url]=a.id,m.storedStates.push(m.cloneObject(a)),a},m.isLastSavedState=function(a){var b=!1,c,d,e;return m.savedStates.length&&(c=a.id,d=m.getLastSavedState(),e=d.id,b=c===e),b},m.saveState=function(a){return m.isLastSavedState(a)?!1:(m.savedStates.push(m.cloneObject(a)),!0)},m.getStateByIndex=function(a){var b=null;return typeof a=="undefined"?b=m.savedStates[m.savedStates.length-1]:a<0?b=m.savedStates[m.savedStates.length+a]:b=m.savedStates[a],b},m.getHash=function(){var a=m.unescapeHash(d.location.hash);return a},m.unescapeString=function(b){var c=b,d;for(;;){d=a.unescape(c);if(d===c)break;c=d}return c},m.unescapeHash=function(a){var b=m.normalizeHash(a);return b=m.unescapeString(b),b},m.normalizeHash=function(a){var b=a.replace(/[^#]*#/,"").replace(/#.*/,"");return b},m.setHash=function(a,b){var c,e,f;return b!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.setHash,args:arguments,queue:b}),!1):(c=m.escapeHash(a),m.busy(!0),e=m.extractState(a,!0),e&&!m.emulated.pushState?m.pushState(e.data,e.title,e.url,!1):d.location.hash!==c&&(m.bugs.setHash?(f=m.getPageUrl(),m.pushState(null,null,f+"#"+c,!1)):d.location.hash=c),m)},m.escapeHash=function(b){var c=m.normalizeHash(b);return c=a.escape(c),m.bugs.hashEscape||(c=c.replace(/\%21/g,"!").replace(/\%26/g,"&").replace(/\%3D/g,"=").replace(/\%3F/g,"?")),c},m.getHashByUrl=function(a){var b=String(a).replace(/([^#]*)#?([^#]*)#?(.*)/,"$2");return b=m.unescapeHash(b),b},m.setTitle=function(a){var b=a.title,c;b||(c=m.getStateByIndex(0),c&&c.url===a.url&&(b=c.title||m.options.initialTitle));try{d.getElementsByTagName("title")[0].innerHTML=b.replace("<","<").replace(">",">").replace(" & "," & ")}catch(e){}return d.title=b,m},m.queues=[],m.busy=function(a){typeof a!="undefined"?m.busy.flag=a:typeof m.busy.flag=="undefined"&&(m.busy.flag=!1);if(!m.busy.flag){h(m.busy.timeout);var b=function(){var a,c,d;if(m.busy.flag)return;for(a=m.queues.length-1;a>=0;--a){c=m.queues[a];if(c.length===0)continue;d=c.shift(),m.fireQueueItem(d),m.busy.timeout=g(b,m.options.busyDelay)}};m.busy.timeout=g(b,m.options.busyDelay)}return m.busy.flag},m.busy.flag=!1,m.fireQueueItem=function(a){return a.callback.apply(a.scope||m,a.args||[])},m.pushQueue=function(a){return m.queues[a.queue||0]=m.queues[a.queue||0]||[],m.queues[a.queue||0].push(a),m},m.queue=function(a,b){return typeof a=="function"&&(a={callback:a}),typeof b!="undefined"&&(a.queue=b),m.busy()?m.pushQueue(a):m.fireQueueItem(a),m},m.clearQueue=function(){return m.busy.flag=!1,m.queues=[],m},m.stateChanged=!1,m.doubleChecker=!1,m.doubleCheckComplete=function(){return m.stateChanged=!0,m.doubleCheckClear(),m},m.doubleCheckClear=function(){return m.doubleChecker&&(h(m.doubleChecker),m.doubleChecker=!1),m},m.doubleCheck=function(a){return m.stateChanged=!1,m.doubleCheckClear(),m.bugs.ieDoubleCheck&&(m.doubleChecker=g(function(){return m.doubleCheckClear(),m.stateChanged||a(),!0},m.options.doubleCheckInterval)),m},m.safariStatePoll=function(){var b=m.extractState(d.location.href),c;if(!m.isLastSavedState(b))c=b;else return;return c||(c=m.createStateObject()),m.Adapter.trigger(a,"popstate"),m},m.back=function(a){return a!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.back,args:arguments,queue:a}),!1):(m.busy(!0),m.doubleCheck(function(){m.back(!1)}),n.go(-1),!0)},m.forward=function(a){return a!==!1&&m.busy()?(m.pushQueue({scope:m,callback:m.forward,args:arguments,queue:a}),!1):(m.busy(!0),m.doubleCheck(function(){m.forward(!1)}),n.go(1),!0)},m.go=function(a,b){var c;if(a>0)for(c=1;c<=a;++c)m.forward(b);else{if(!(a<0))throw new Error("History.go: History.go requires a positive or negative integer passed.");for(c=-1;c>=a;--c)m.back(b)}return m};if(m.emulated.pushState){var o=function(){};m.pushState=m.pushState||o,m.replaceState=m.replaceState||o}else m.onPopState=function(b,c){var e=!1,f=!1,g,h;return m.doubleCheckComplete(),g=m.getHash(),g?(h=m.extractState(g||d.location.href,!0),h?m.replaceState(h.data,h.title,h.url,!1):(m.Adapter.trigger(a,"anchorchange"),m.busy(!1)),m.expectedStateId=!1,!1):(e=m.Adapter.extractEventData("state",b,c)||!1,e?f=m.getStateById(e):m.expectedStateId?f=m.getStateById(m.expectedStateId):f=m.extractState(d.location.href),f||(f=m.createStateObject(null,null,d.location.href)),m.expectedStateId=!1,m.isLastSavedState(f)?(m.busy(!1),!1):(m.storeState(f),m.saveState(f),m.setTitle(f),m.Adapter.trigger(a,"statechange"),m.busy(!1),!0))},m.Adapter.bind(a,"popstate",m.onPopState),m.pushState=function(b,c,d,e){if(m.getHashByUrl(d)&&m.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(e!==!1&&m.busy())return m.pushQueue({scope:m,callback:m.pushState,args:arguments,queue:e}),!1;m.busy(!0);var f=m.createStateObject(b,c,d);return m.isLastSavedState(f)?m.busy(!1):(m.storeState(f),m.expectedStateId=f.id,n.pushState(f.id,f.title,f.url),m.Adapter.trigger(a,"popstate")),!0},m.replaceState=function(b,c,d,e){if(m.getHashByUrl(d)&&m.emulated.pushState)throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(e!==!1&&m.busy())return m.pushQueue({scope:m,callback:m.replaceState,args:arguments,queue:e}),!1;m.busy(!0);var f=m.createStateObject(b,c,d);return m.isLastSavedState(f)?m.busy(!1):(m.storeState(f),m.expectedStateId=f.id,n.replaceState(f.id,f.title,f.url),m.Adapter.trigger(a,"popstate")),!0};if(f){try{m.store=k.parse(f.getItem("History.store"))||{}}catch(p){m.store={}}m.normalizeStore()}else m.store={},m.normalizeStore();m.Adapter.bind(a,"beforeunload",m.clearAllIntervals),m.Adapter.bind(a,"unload",m.clearAllIntervals),m.saveState(m.storeState(m.extractState(d.location.href,!0))),f&&(m.onUnload=function(){var a,b;try{a=k.parse(f.getItem("History.store"))||{}}catch(c){a={}}a.idToState=a.idToState||{},a.urlToId=a.urlToId||{},a.stateToId=a.stateToId||{};for(b in m.idToState){if(!m.idToState.hasOwnProperty(b))continue;a.idToState[b]=m.idToState[b]}for(b in m.urlToId){if(!m.urlToId.hasOwnProperty(b))continue;a.urlToId[b]=m.urlToId[b]}for(b in m.stateToId){if(!m.stateToId.hasOwnProperty(b))continue;a.stateToId[b]=m.stateToId[b]}m.store=a,m.normalizeStore(),f.setItem("History.store",k.stringify(a))},m.intervalList.push(i(m.onUnload,m.options.storeInterval)),m.Adapter.bind(a,"beforeunload",m.onUnload),m.Adapter.bind(a,"unload",m.onUnload));if(!m.emulated.pushState){m.bugs.safariPoll&&m.intervalList.push(i(m.safariStatePoll,m.options.safariPollInterval));if(e.vendor==="Apple Computer, Inc."||(e.appCodeName||"")==="Mozilla")m.Adapter.bind(a,"hashchange",function(){m.Adapter.trigger(a,"popstate")}),m.getHash()&&m.Adapter.onDomLoad(function(){m.Adapter.trigger(a,"hashchange")})}},m.init()}(window) \ No newline at end of file From 702133c0e2ff1e9a70263ad9c01985a6279cb2db Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 9 Oct 2012 18:33:22 -0400 Subject: [PATCH 192/288] Remove unused history_path instance variable --- app/controllers/refs_controller.rb | 2 -- app/controllers/tree_controller.rb | 6 ++---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb index 6a1a3606..977ccea7 100644 --- a/app/controllers/refs_controller.rb +++ b/app/controllers/refs_controller.rb @@ -54,10 +54,8 @@ class RefsController < ProjectResourceController @hex_path = Digest::SHA1.hexdigest(params[:path] || "") if params[:path] - @history_path = project_tree_path(@project, File.join(@ref, params[:path])) @logs_path = logs_file_project_ref_path(@project, @ref, params[:path]) else - @history_path = project_tree_path(@project, @ref) @logs_path = logs_tree_project_ref_path(@project, @ref) end rescue diff --git a/app/controllers/tree_controller.rb b/app/controllers/tree_controller.rb index 2e4ff7d3..2270eede 100644 --- a/app/controllers/tree_controller.rb +++ b/app/controllers/tree_controller.rb @@ -10,10 +10,8 @@ class TreeController < ProjectResourceController before_filter :assign_ref_vars def show - @hex_path = Digest::SHA1.hexdigest(@path) - - @history_path = project_tree_path(@project, @id) - @logs_path = logs_file_project_ref_path(@project, @ref, @path) + @hex_path = Digest::SHA1.hexdigest(@path) + @logs_path = logs_file_project_ref_path(@project, @ref, @path) respond_to do |format| format.html From eb92813757d8ec14819ddbab6efae7e7cdd403e6 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Wed, 10 Oct 2012 00:53:42 +0200 Subject: [PATCH 193/288] Move emoji auto-complete helper to ApplicationHelper --- app/helpers/application_helper.rb | 6 ++++++ app/helpers/notes_helper.rb | 6 ------ spec/helpers/notes_helper_spec.rb | 10 ---------- 3 files changed, 6 insertions(+), 16 deletions(-) delete mode 100644 spec/helpers/notes_helper_spec.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 911b46c9..8c65a0fd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -98,6 +98,12 @@ module ApplicationHelper [projects, default_nav, project_nav].flatten.to_json end + def emoji_autocomplete_source + # should be an array of strings + # so to_s can be called, because it is sufficient and to_json is too slow + Emoji::NAMES.to_s + end + def ldap_enable? Devise.omniauth_providers.include?(:ldap) end diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 9f75fc42..65389e38 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -14,10 +14,4 @@ module NotesHelper "vote downvote" end end - - def emoji_for_completion - # should be an array of strings - # so to_s can be called, because it is sufficient and to_json is too slow - Emoji::NAMES - end end diff --git a/spec/helpers/notes_helper_spec.rb b/spec/helpers/notes_helper_spec.rb deleted file mode 100644 index 73481694..00000000 --- a/spec/helpers/notes_helper_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'spec_helper' - -describe NotesHelper do - describe "#emoji_for_completion" do - it "should be an Array of Strings" do - emoji_for_completion.should be_a(Array) - emoji_for_completion.each { |emoji| emoji.should be_a(String) } - end - end -end From e4aa5a5c8f9d8a4b556aeba003160017821ed9a3 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Wed, 10 Oct 2012 00:16:52 +0200 Subject: [PATCH 194/288] Extract and split GFM auto-completion setup JS * static initialization and setup moved to assets * per request initialization moved to layout partial --- .../javascripts/gfm_auto_complete.js.coffee | 57 +++++++++++++++++++ app/views/layouts/_head_panel.html.haml | 2 + .../layouts/_init_auto_complete.html.haml | 17 ++++++ app/views/notes/_common_form.html.haml | 46 --------------- 4 files changed, 76 insertions(+), 46 deletions(-) create mode 100644 app/assets/javascripts/gfm_auto_complete.js.coffee create mode 100644 app/views/layouts/_init_auto_complete.html.haml diff --git a/app/assets/javascripts/gfm_auto_complete.js.coffee b/app/assets/javascripts/gfm_auto_complete.js.coffee new file mode 100644 index 00000000..203a5b67 --- /dev/null +++ b/app/assets/javascripts/gfm_auto_complete.js.coffee @@ -0,0 +1,57 @@ + +### + Creates the variables for setting up GFM auto-completion +### +# Emoji +window.autocompleteEmojiData = []; +window.autocompleteEmojiTemplate = "
  • ${name} ${name}
  • "; + +# Team Members +window.autocompleteMembersUrl = ""; +window.autocompleteMembersParams = + private_token: "" + page: 1 +window.autocompleteMembersData = []; + + + +### + Add GFM auto-completion to all input fields, that accept GFM input. +### +window.setupGfmAutoComplete = -> + ### + Emoji + ### + $('.gfm-input').atWho ':', + data: autocompleteEmojiData, + tpl: autocompleteEmojiTemplate + + ### + Team Members + ### + $('.gfm-input').atWho '@', (query, callback) -> + (getMoreMembers = -> + $.getJSON(autocompleteMembersUrl, autocompleteMembersParams) + .success (members) -> + # pick the data we need + newMembersData = $.map members, (m) -> m.name + + # add the new page of data to the rest + $.merge autocompleteMembersData, newMembersData + + # show the pop-up with a copy of the current data + callback autocompleteMembersData[..] + + # are we past the last page? + if newMembersData.length == 0 + # set static data and stop callbacks + $('.gfm-input').atWho '@', + data: autocompleteMembersData + callback: null + else + # get next page + getMoreMembers() + + # so the next request gets the next page + autocompleteMembersParams.page += 1; + ).call(); \ No newline at end of file diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml index f5e423a5..7f89bdf0 100644 --- a/app/views/layouts/_head_panel.html.haml +++ b/app/views/layouts/_head_panel.html.haml @@ -28,6 +28,8 @@ My profile = link_to 'Logout', destroy_user_session_path, class: "logout", method: :delete += render "layouts/init_auto_complete" + :javascript $(function(){ $("#search").autocomplete({ diff --git a/app/views/layouts/_init_auto_complete.html.haml b/app/views/layouts/_init_auto_complete.html.haml new file mode 100644 index 00000000..87a74655 --- /dev/null +++ b/app/views/layouts/_init_auto_complete.html.haml @@ -0,0 +1,17 @@ +:javascript + $(function() { + autocompleteMembersUrl = "#{ "/api/v2/projects/#{@project.code}/members" if @project }"; + autocompleteMembersParams.private_token = "#{current_user.authentication_token}"; + + autocompleteEmojiData = #{raw emoji_autocomplete_source}; + // convert the list so that the items have the right format for completion + autocompleteEmojiData = $.map(autocompleteEmojiData, function(value) { + return { + name: value, + insert: value+':', + image: '#{image_path("emoji")}/'+value+'.png' + } + }); + + setupGfmAutoComplete(); + }); diff --git a/app/views/notes/_common_form.html.haml b/app/views/notes/_common_form.html.haml index 4ac26d33..a9f2907b 100644 --- a/app/views/notes/_common_form.html.haml +++ b/app/views/notes/_common_form.html.haml @@ -36,49 +36,3 @@ %a.file_upload.btn.small Upload File = f.file_field :attachment, class: "input-file" %span.hint Any file less than 10 MB - -:javascript - $(function(){ - // init auto-completion of team members - var membersUrl = "#{root_url}/api/v2/projects/#{@project.code}/members"; - var membersParams = { - private_token: "#{current_user.authentication_token}", - page: 1, - }; - var membersData = []; - $('.gfm-input').atWho('@', function(query, callback) { - (function getMoreMembers() { - $.getJSON(membersUrl, membersParams). - success(function(members) { - // pick the data we need - var newMembersData = $.map(members, function(member) { return member.name }); - - // add the new page of data to the rest - $.merge(membersData, newMembersData); - - // show the pop-up with a copy of the current data - callback(membersData.slice(0)); - - // are we past the last page? - if (newMembersData.length == 0) { - // set static data and stop callbacks - $('.gfm-input').atWho('@', { data: membersData, callback: null }); - } else { - // get next page - getMoreMembers(); - } - }); - // next request will get the next page - membersParams.page += 1; - })(); - }); - - // init auto-completion of emoji - var emoji = #{emoji_for_completion}; - // convert the list so that the items have the right format for completion - emoji = $.map(emoji, function(value) {return { key: value+':', name: value }}); - $('.gfm-input').atWho(':', { - data: emoji, - tpl: "
  • ${name} #{escape_javascript image_tag('emoji/${name}.png', :size => '20x20')}
  • " - }); - }); From 4d843d2ce1e12525637e2a578896686a4efb9a55 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Tue, 9 Oct 2012 23:54:14 +0200 Subject: [PATCH 195/288] Fix auto-completion for forms that are inserted with JS --- app/assets/javascripts/issues.js | 2 ++ app/views/notes/_create_common_note.js.haml | 1 + 2 files changed, 3 insertions(+) diff --git a/app/assets/javascripts/issues.js b/app/assets/javascripts/issues.js index 3ddc6926..c3cf364f 100644 --- a/app/assets/javascripts/issues.js +++ b/app/assets/javascripts/issues.js @@ -6,6 +6,7 @@ function switchToNewIssue(form){ $("#new_issue_dialog").show("fade", { direction: "right" }, 150); $('.top-tabs .add_new').hide(); disableButtonIfEmptyField("#issue_title", ".save-btn"); + setupGfmAutoComplete(); }); } @@ -17,6 +18,7 @@ function switchToEditIssue(form){ $("#edit_issue_dialog").show("fade", { direction: "right" }, 150); $('.add_new').hide(); disableButtonIfEmptyField("#issue_title", ".save-btn"); + setupGfmAutoComplete(); }); } diff --git a/app/views/notes/_create_common_note.js.haml b/app/views/notes/_create_common_note.js.haml index bbebc247..e7df64c4 100644 --- a/app/views/notes/_create_common_note.js.haml +++ b/app/views/notes/_create_common_note.js.haml @@ -10,4 +10,5 @@ - else :plain $(".note-form-holder").replaceWith("#{escape_javascript(render 'form')}"); + setupGfmAutoComplete(); From 77bde9a0e41e9229357983d258eaea9d7ef67017 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Thu, 4 Oct 2012 23:02:37 +0200 Subject: [PATCH 196/288] Add notes count to commits in lists. --- app/assets/stylesheets/sections/commits.scss | 5 +++++ app/views/commits/_commit.html.haml | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/app/assets/stylesheets/sections/commits.scss b/app/assets/stylesheets/sections/commits.scss index 711f603f..1da81275 100644 --- a/app/assets/stylesheets/sections/commits.scss +++ b/app/assets/stylesheets/sections/commits.scss @@ -203,6 +203,11 @@ @extend .cgray; } + .notes_count { + float:right; + margin: -6px 8px 6px; + } + code { background:#FCEEC1; color:$style_color; diff --git a/app/views/commits/_commit.html.haml b/app/views/commits/_commit.html.haml index 259e8e26..9abadc5d 100644 --- a/app/views/commits/_commit.html.haml +++ b/app/views/commits/_commit.html.haml @@ -13,3 +13,10 @@ = time_ago_in_words(commit.committed_date) ago   + + %span.notes_count + - notes = @project.commit_notes(commit) + @project.commit_line_notes(commit) + - if notes.any? + %span.btn.small.disabled.grouped + %i.icon-comment + = notes.count From 6dc8c0eac28d826a4a58bcb3cdac070f3de2a10c Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Fri, 5 Oct 2012 00:25:40 +0200 Subject: [PATCH 197/288] Make MRs also count and display its commits' notes --- app/models/merge_request.rb | 5 +++++ app/views/merge_requests/_merge_request.html.haml | 2 +- spec/models/merge_request_spec.rb | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index b6392ce8..5b3c3724 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -186,6 +186,11 @@ class MergeRequest < ActiveRecord::Base patch_path end + + def mr_and_commit_notes + commit_ids = commits.map(&:id) + Note.where("(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND noteable_id IN (:commit_ids))", mr_id: id, commit_ids: commit_ids) + end end # == Schema Information diff --git a/app/views/merge_requests/_merge_request.html.haml b/app/views/merge_requests/_merge_request.html.haml index 9d94d670..419419d2 100644 --- a/app/views/merge_requests/_merge_request.html.haml +++ b/app/views/merge_requests/_merge_request.html.haml @@ -9,7 +9,7 @@ - if merge_request.notes.any? %span.btn.small.disabled.grouped %i.icon-comment - = merge_request.notes.count + = merge_request.mr_and_commit_notes.count %span.btn.small.disabled.grouped = merge_request.source_branch → diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 7a1f541f..91d404f7 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -35,4 +35,19 @@ describe MergeRequest do it { should include_module(IssueCommonality) } it { should include_module(Votes) } end + + describe "#mr_and_commit_notes" do + let!(:merge_request) { Factory.create(:merge_request) } + + before do + merge_request.stub(:commits) { [merge_request.project.commit] } + Factory.create(:note, noteable: merge_request.commits.first) + Factory.create(:note, noteable: merge_request) + end + + it "should include notes for commits" do + merge_request.commits.should_not be_empty + merge_request.mr_and_commit_notes.count.should == 2 + end + end end From 41afd3bf16b6ceff2b0dab24ce2eeae8056a7577 Mon Sep 17 00:00:00 2001 From: Andrey Kumanyaev Date: Wed, 10 Oct 2012 03:14:58 +0400 Subject: [PATCH 198/288] add pg gem --- Gemfile | 5 +++-- Gemfile.lock | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 042fbc4d..954fb888 100644 --- a/Gemfile +++ b/Gemfile @@ -11,8 +11,9 @@ end gem "rails", "3.2.8" # Supported DBs -gem "sqlite3" -gem "mysql2" +gem "sqlite3", :group => :sqlite +gem "mysql2", :group => :mysql +gem "pg", :group => :postgres # Auth gem "devise", "~> 2.1.0" diff --git a/Gemfile.lock b/Gemfile.lock index 3c3bea9d..87fd1c90 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -245,6 +245,7 @@ GEM multi_json (~> 1.3) omniauth-oauth (~> 1.0) orm_adapter (0.3.0) + pg (0.14.0) polyglot (0.3.3) posix-spawn (0.3.6) pry (0.9.9.6) @@ -441,6 +442,7 @@ DEPENDENCIES omniauth-google-oauth2 omniauth-ldap! omniauth-twitter + pg pry pygments.rb (= 0.3.1) rack-mini-profiler From 3e1d52f4b7accb100d8a312236f8fc8005b78a69 Mon Sep 17 00:00:00 2001 From: Andrey Kumanyaev Date: Wed, 10 Oct 2012 03:15:26 +0400 Subject: [PATCH 199/288] add default postgres config --- config/database.yml.postgresql | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 config/database.yml.postgresql diff --git a/config/database.yml.postgresql b/config/database.yml.postgresql new file mode 100644 index 00000000..17b38f3d --- /dev/null +++ b/config/database.yml.postgresql @@ -0,0 +1,48 @@ +# +# PRODUCTION +# +production: + adapter: postgresql + encoding: unicode + database: gitlabhq_production + pool: 5 + username: postgres + password: + # host: localhost + # socket: /tmp/postgresql.sock + +# +# Development specific +# +development: + adapter: postgresql + encoding: unicode + database: gitlabhq_development + pool: 5 + username: postgres + password: + # socket: /tmp/postgresql.sock + +# +# Staging specific +# +staging: + adapter: postgresql + encoding: unicode + database: gitlabhq_staging + pool: 5 + username: postgres + password: + # socket: /tmp/postgresql.sock + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: &test + adapter: postgresql + encoding: unicode + database: gitlabhq_test + pool: 5 + username: postgres + password: + # socket: /tmp/postgresql.sock From 4eb7d82ae7b085049a889b8f4e7d421f05b39d07 Mon Sep 17 00:00:00 2001 From: Andrey Kumanyaev Date: Wed, 10 Oct 2012 03:31:51 +0400 Subject: [PATCH 200/288] add support use string FK with integer PK --- ...20121009205010_postgres_create_integer_cast.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 db/migrate/20121009205010_postgres_create_integer_cast.rb diff --git a/db/migrate/20121009205010_postgres_create_integer_cast.rb b/db/migrate/20121009205010_postgres_create_integer_cast.rb new file mode 100644 index 00000000..b9a97138 --- /dev/null +++ b/db/migrate/20121009205010_postgres_create_integer_cast.rb @@ -0,0 +1,15 @@ +class PostgresCreateIntegerCast < ActiveRecord::Migration + def up + execute <<-SQL + CREATE CAST (integer AS text) WITH INOUT AS IMPLICIT; + SQL + rescue ActiveRecord::StatementInvalid + end + + def down + execute <<-SQL + DROP CAST (integer AS text); + SQL + rescue ActiveRecord::StatementInvalid + end +end From 75e6eb59ecd21735c87eb53eb68d510760580b3f Mon Sep 17 00:00:00 2001 From: Andrey Kumanyaev Date: Wed, 10 Oct 2012 03:41:14 +0400 Subject: [PATCH 201/288] patch rails to ignore text limit --- config/initializers/postgresql_limit_fix.rb | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 config/initializers/postgresql_limit_fix.rb diff --git a/config/initializers/postgresql_limit_fix.rb b/config/initializers/postgresql_limit_fix.rb new file mode 100644 index 00000000..0cb3aaf4 --- /dev/null +++ b/config/initializers/postgresql_limit_fix.rb @@ -0,0 +1,26 @@ +if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) + class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter + class TableDefinition + def text(*args) + options = args.extract_options! + options.delete(:limit) + column_names = args + type = :text + column_names.each { |name| column(name, type, options) } + end + end + + def add_column_with_limit_filter(table_name, column_name, type, options = {}) + options.delete(:limit) if type == :text + add_column_without_limit_filter(table_name, column_name, type, options) + end + + def change_column_with_limit_filter(table_name, column_name, type, options = {}) + options.delete(:limit) if type == :text + change_column_without_limit_filter(table_name, column_name, type, options) + end + + alias_method_chain :add_column, :limit_filter + alias_method_chain :change_column, :limit_filter + end +end From 92ac42a27c1251304f408fdff162999d0577a340 Mon Sep 17 00:00:00 2001 From: Andrey Kumanyaev Date: Wed, 10 Oct 2012 03:41:33 +0400 Subject: [PATCH 202/288] update doc --- doc/installation.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/doc/installation.md b/doc/installation.md index fd8a8b9b..fc5ea828 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -75,6 +75,9 @@ Now install the required packages: # If you want to use MySQL: sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev + # If you want to use PostgreSQL: + sudo apt-get install -y postgresql-9.2 postgresql-server-dev-9.2 + # 2. Install Ruby wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz @@ -188,9 +191,45 @@ and ensure you have followed all of the above steps carefully. # Exit MySQL Server and copy the example config, make sure to update username/password in config/database.yml sudo -u gitlab cp config/database.yml.example config/database.yml + # Or + # PostgreSQL + # Install PostgreSQL as directed in Step #1 + + # Connect to database server + sudo -u postgres psql -d template1 + + # Add a user called gitlab. Change $password to a real password + template1=# CREATE USER gitlab WITH PASSWORD '$password'; + + # Create the GitLab production database + template1=# CREATE DATABASE IF NOT EXISTS gitlabhq_production; + + # Grant all privileges on database + template1=# GRANT ALL PRIVILEGES ON DATABASE gitlabhq_production to gitlab; + + # Quit from PostgreSQL server + template1=# \q + + # Try connect to new database + $ su - gitlab + $ psql -d gitlabhq_production -U gitlab + + # Exit PostgreSQL Server and copy the example config, make sure to update username/password in config/database.yml + sudo -u gitlab cp config/database.yml.postgres config/database.yml + + # If you need create development, test, staging or another database + # Repeate some steps with actual commands + #### Install gems - sudo -u gitlab -H bundle install --without development test --deployment + # Please, check Gemfile before run bundle install + # Select database gem, wich you will use + # or run to setup gems with mysql usage + sudo -u gitlab -H bundle install --without development test sqlite postgres --deployment + # or postgres + sudo -u gitlab -H bundle install --without development test sqlite mysql --deployment + # or sqlite + sudo -u gitlab -H bundle install --without development test mysql postgres --deployment #### Setup database From 8402bca7355c95e60b9d5cfd124a839de60cd50b Mon Sep 17 00:00:00 2001 From: Andrey Kumanyaev Date: Wed, 10 Oct 2012 03:41:44 +0400 Subject: [PATCH 203/288] travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2aa468fd..df3974fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ env: + - DB=postgresql - DB=mysql before_install: - sudo apt-get install libicu-dev -y @@ -11,6 +12,7 @@ rvm: - 1.9.3 services: - mysql + - postgresql before_script: - "cp config/database.yml.$DB config/database.yml" - "cp config/gitlab.yml.example config/gitlab.yml" From 3f72af9994554c66a51cdfb4302e48da0edd043a Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Wed, 10 Oct 2012 12:06:30 +0200 Subject: [PATCH 204/288] Make notes for merge requests include commit notes and add helpers --- app/contexts/notes/load_context.rb | 2 +- app/controllers/notes_controller.rb | 5 +++++ app/helpers/notes_helper.rb | 5 +++++ app/models/note.rb | 6 +++++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/contexts/notes/load_context.rb b/app/contexts/notes/load_context.rb index f92a7801..f3949149 100644 --- a/app/contexts/notes/load_context.rb +++ b/app/contexts/notes/load_context.rb @@ -13,7 +13,7 @@ module Notes when "issue" project.issues.find(target_id).notes.inc_author.fresh.limit(20) when "merge_request" - project.merge_requests.find(target_id).notes.inc_author.fresh.limit(20) + project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh.limit(20) when "snippet" project.snippets.find(target_id).notes.fresh when "wall" diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 7f5f5cd2..d794f368 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -7,6 +7,11 @@ class NotesController < ProjectResourceController def index notes + if params[:target_type] == "merge_request" + @mixed_targets = true + @main_target_type = params[:target_type].camelize + end + respond_with(@notes) end diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 65389e38..3e875023 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -7,6 +7,11 @@ module NotesHelper params[:loading_new].present? end + # Helps to distinguish e.g. commit notes in mr notes list + def note_for_main_target?(note) + !@mixed_targets || @main_target_type == note.noteable_type + end + def note_vote_class(note) if note.upvote? "vote upvote" diff --git a/app/models/note.rb b/app/models/note.rb index 65b20fe0..ae51e486 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -49,7 +49,7 @@ class Note < ActiveRecord::Base end def target - if noteable_type == "Commit" + if commit? project.commit(noteable_id) else noteable @@ -82,6 +82,10 @@ class Note < ActiveRecord::Base noteable_type == "Commit" end + def line_note? + line_code.present? + end + def commit_author @commit_author ||= project.users.find_by_email(target.author_email) || From fb0279f3113f58b1cbdbe04acabe874ac4d231f9 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Wed, 10 Oct 2012 12:09:45 +0200 Subject: [PATCH 205/288] Fix vote counting to only count main target notes (not mixed in ones) --- app/assets/javascripts/notes.js | 2 +- app/helpers/notes_helper.rb | 6 ------ app/views/notes/_note.html.haml | 23 ++++++++++++++--------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index e1ad1d2f..558643d5 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -230,7 +230,7 @@ var NoteList = { updateVotes: function() { var votes = $("#votes .votes"); - var notes = $("#notes-list, #new-notes-list").find(".note.vote"); + var notes = $("#notes-list, #new-notes-list").find(".note .vote"); // only update if there is a vote display if (votes.size()) { diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 3e875023..ba02ca6b 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -12,11 +12,5 @@ module NotesHelper !@mixed_targets || @main_target_type == note.noteable_type end - def note_vote_class(note) - if note.upvote? - "vote upvote" - elsif note.downvote? - "vote downvote" - end end end diff --git a/app/views/notes/_note.html.haml b/app/views/notes/_note.html.haml index 5234e55d..57946163 100644 --- a/app/views/notes/_note.html.haml +++ b/app/views/notes/_note.html.haml @@ -1,4 +1,4 @@ -%li{id: dom_id(note), class: "note #{note_vote_class(note)}"} +%li{id: dom_id(note), class: "note"} = image_tag gravatar_icon(note.author.email), class: "avatar s32" %div.note-author %strong= note.author_name @@ -6,14 +6,19 @@ %cite.cgray = time_ago_in_words(note.updated_at) ago - - if note.upvote? - %span.label.label-success - %i.icon-thumbs-up - \+1 - - if note.downvote? - %span.label.label-error - %i.icon-thumbs-down - \-1 + + -# only show vote if it's a note for the main target + - if note_for_main_target?(note) + - if note.upvote? + %span.vote.upvote.label.label-success + %i.icon-thumbs-up + \+1 + - if note.downvote? + %span.vote.downvote.label.label-error + %i.icon-thumbs-down + \-1 + + -# remove button - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) = link_to [@project, note], confirm: 'Are you sure?', method: :delete, remote: true, class: "cred delete-note btn very_small" do %i.icon-trash From 81ee69381d9e01997a204b89cdeabf9854138967 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Wed, 10 Oct 2012 12:14:48 +0200 Subject: [PATCH 206/288] Add links to the note source if the note is mixed in --- app/helpers/notes_helper.rb | 10 ++++++++++ app/views/commits/_text_file.html.haml | 2 +- app/views/notes/_note.html.haml | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index ba02ca6b..99db8b6f 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -12,5 +12,15 @@ module NotesHelper !@mixed_targets || @main_target_type == note.noteable_type end + def link_to_commit_diff_line_note(note) + return unless note.line_note? + + commit = note.target + diff_index, diff_old_line, diff_new_line = note.line_code.split('_') + + link_file = commit.diffs[diff_index.to_i].new_path + link_line = diff_new_line + + link_to "#{link_file}:L#{link_line}", project_commit_path(@project, commit, anchor: note.line_code) end end diff --git a/app/views/commits/_text_file.html.haml b/app/views/commits/_text_file.html.haml index 9f5b5345..02117386 100644 --- a/app/views/commits/_text_file.html.haml +++ b/app/views/commits/_text_file.html.haml @@ -4,7 +4,7 @@ %table{class: "#{'hide' if too_big}"} - each_diff_line(diff.diff.lines.to_a, index) do |line, type, line_code, line_new, line_old| - %tr.line_holder + %tr.line_holder{ id: line_code } - if type == "match" %td.old_line= "..." %td.new_line= "..." diff --git a/app/views/notes/_note.html.haml b/app/views/notes/_note.html.haml index 57946163..0901e4b8 100644 --- a/app/views/notes/_note.html.haml +++ b/app/views/notes/_note.html.haml @@ -7,6 +7,12 @@ = time_ago_in_words(note.updated_at) ago + - unless note_for_main_target?(note) + - if note.commit? + %span.cgray + on #{link_to note.target.short_id, project_commit_path(@project, note.target)} + = link_to_commit_diff_line_note(note) if note.line_note? + -# only show vote if it's a note for the main target - if note_for_main_target?(note) - if note.upvote? From b2f57409931ddd9bf059e992bc255da93a8192b5 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 10 Oct 2012 15:45:19 +0300 Subject: [PATCH 207/288] Updated installation docs with better db origanisation --- doc/installation.md | 98 +++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/doc/installation.md b/doc/installation.md index fc5ea828..73c11e0a 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -70,14 +70,56 @@ Now install the required packages: sudo apt-get update sudo apt-get upgrade - sudo apt-get install -y wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server git-core python-dev python-pip libyaml-dev postfix + sudo apt-get install -y wget curl gcc checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server git-core python-dev python-pip libyaml-dev postfix + + +# Database + +## SQLite + + sudo apt-get install -y sqlite3 libsqlite3-dev + +## MySQL - # If you want to use MySQL: sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev - # If you want to use PostgreSQL: + # Login to MySQL + $ mysql -u root -p + + # Create the GitLab production database + mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; + + # Create the MySQL User change $password to a real password + mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password'; + + # Grant proper permissions to the MySQL User + mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; + + +## PostgreSQL + sudo apt-get install -y postgresql-9.2 postgresql-server-dev-9.2 + # Connect to database server + sudo -u postgres psql -d template1 + + # Add a user called gitlab. Change $password to a real password + template1=# CREATE USER gitlab WITH PASSWORD '$password'; + + # Create the GitLab production database + template1=# CREATE DATABASE IF NOT EXISTS gitlabhq_production; + + # Grant all privileges on database + template1=# GRANT ALL PRIVILEGES ON DATABASE gitlabhq_production to gitlab; + + # Quit from PostgreSQL server + template1=# \q + + # Try connect to new database + $ su - gitlab + $ psql -d gitlabhq_production -U gitlab + + # 2. Install Ruby wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz @@ -172,62 +214,22 @@ and ensure you have followed all of the above steps carefully. # SQLite sudo -u gitlab cp config/database.yml.sqlite config/database.yml - # Or # Mysql - # Install MySQL as directed in Step #1 + sudo -u gitlab cp config/database.yml.mysql config/database.yml - # Login to MySQL - $ mysql -u root -p - - # Create the GitLab production database - mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; - - # Create the MySQL User change $password to a real password - mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password'; - - # Grant proper permissions to the MySQL User - mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; - - # Exit MySQL Server and copy the example config, make sure to update username/password in config/database.yml - sudo -u gitlab cp config/database.yml.example config/database.yml - - # Or # PostgreSQL - # Install PostgreSQL as directed in Step #1 - - # Connect to database server - sudo -u postgres psql -d template1 - - # Add a user called gitlab. Change $password to a real password - template1=# CREATE USER gitlab WITH PASSWORD '$password'; - - # Create the GitLab production database - template1=# CREATE DATABASE IF NOT EXISTS gitlabhq_production; - - # Grant all privileges on database - template1=# GRANT ALL PRIVILEGES ON DATABASE gitlabhq_production to gitlab; - - # Quit from PostgreSQL server - template1=# \q - - # Try connect to new database - $ su - gitlab - $ psql -d gitlabhq_production -U gitlab - - # Exit PostgreSQL Server and copy the example config, make sure to update username/password in config/database.yml sudo -u gitlab cp config/database.yml.postgres config/database.yml - # If you need create development, test, staging or another database - # Repeate some steps with actual commands + # make sure to update username/password in config/database.yml #### Install gems - # Please, check Gemfile before run bundle install - # Select database gem, wich you will use - # or run to setup gems with mysql usage + # mysql sudo -u gitlab -H bundle install --without development test sqlite postgres --deployment + # or postgres sudo -u gitlab -H bundle install --without development test sqlite mysql --deployment + # or sqlite sudo -u gitlab -H bundle install --without development test mysql postgres --deployment From 2b7fd29b1abb3ab6ca5ece7fe2b093f6672796d6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 10 Oct 2012 17:17:23 +0300 Subject: [PATCH 208/288] hardware requirements --- doc/installation.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/installation.md b/doc/installation.md index 73c11e0a..2d273836 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -22,6 +22,12 @@ You might have some luck using these, but no guarantees: GitLab does **not** run on Windows and we have no plans of making GitLab compatible. + +## Hardware: + +We recommend to use server with at least 1GB RAM for gitlab instance. + + ## This installation guide created for Debian/Ubuntu and properly tested. The installation consists of 6 steps: From ace816354fb098118539640b5d9af392da349396 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 4 Sep 2012 04:13:56 -0400 Subject: [PATCH 209/288] Add toggle to show closed issues on Milestones#show Progress on #1167 --- app/assets/javascripts/milestones.js.coffee | 7 +++++++ app/assets/stylesheets/gitlab_bootstrap/tables.scss | 5 +++++ app/controllers/milestones_controller.rb | 2 +- app/views/milestones/show.html.haml | 10 ++++++---- 4 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 app/assets/javascripts/milestones.js.coffee diff --git a/app/assets/javascripts/milestones.js.coffee b/app/assets/javascripts/milestones.js.coffee new file mode 100644 index 00000000..f24682bf --- /dev/null +++ b/app/assets/javascripts/milestones.js.coffee @@ -0,0 +1,7 @@ +$ -> + $('.milestone-issue-filter td[data-closed]').addClass('hide') + + $('.milestone-issue-filter ul.nav li a').click -> + $('.milestone-issue-filter li').toggleClass('active') + $('.milestone-issue-filter td[data-closed]').toggleClass('hide') + false diff --git a/app/assets/stylesheets/gitlab_bootstrap/tables.scss b/app/assets/stylesheets/gitlab_bootstrap/tables.scss index 29293867..b9220792 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/tables.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/tables.scss @@ -11,6 +11,11 @@ table { border-bottom: 1px solid #bbb; text-shadow: 0 1px 1px #fff; @include bg-dark-gray-gradient; + + ul.nav { + text-shadow: none; + margin: 0; + } } th, td { diff --git a/app/controllers/milestones_controller.rb b/app/controllers/milestones_controller.rb index f8fe987c..fa202cf4 100644 --- a/app/controllers/milestones_controller.rb +++ b/app/controllers/milestones_controller.rb @@ -30,7 +30,7 @@ class MilestonesController < ProjectResourceController end def show - @issues = @milestone.issues.opened.page(params[:page]).per(40) + @issues = @milestone.issues @users = @milestone.participants respond_to do |format| diff --git a/app/views/milestones/show.html.haml b/app/views/milestones/show.html.haml index d3b1c092..e2555610 100644 --- a/app/views/milestones/show.html.haml +++ b/app/views/milestones/show.html.haml @@ -45,18 +45,20 @@ .row .span6 - %table + %table.milestone-issue-filter %thead - %th Open Issues + %th + %ul.nav.nav-pills + %li.active.open= link_to('Open Issues', '#') + %li.all=link_to('All Issues', '#') - @issues.each do |issue| %tr - %td + %td{data: {closed: issue.closed}} = link_to [@project, issue] do %span.badge.badge-info ##{issue.id} – = link_to_gfm truncate(issue.title, length: 60), [@project, issue] %br - = paginate @issues, theme: "gitlab" .span6 %table From ce6e5f34d59bf6925170584a6579fb4478cd6e50 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 4 Sep 2012 04:18:30 -0400 Subject: [PATCH 210/288] Remove unused li classes from milestone issue filter --- app/views/milestones/show.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/milestones/show.html.haml b/app/views/milestones/show.html.haml index e2555610..cbc69fb7 100644 --- a/app/views/milestones/show.html.haml +++ b/app/views/milestones/show.html.haml @@ -49,8 +49,8 @@ %thead %th %ul.nav.nav-pills - %li.active.open= link_to('Open Issues', '#') - %li.all=link_to('All Issues', '#') + %li.active= link_to('Open Issues', '#') + %li=link_to('All Issues', '#') - @issues.each do |issue| %tr %td{data: {closed: issue.closed}} From 7d145adf35b53fae3a512d433f23ee911b4f5d39 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 10 Oct 2012 13:06:34 -0400 Subject: [PATCH 211/288] Move 'closed' attribute to the row instead of the cell --- app/assets/javascripts/milestones.js.coffee | 4 ++-- app/views/milestones/show.html.haml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/milestones.js.coffee b/app/assets/javascripts/milestones.js.coffee index f24682bf..13aba860 100644 --- a/app/assets/javascripts/milestones.js.coffee +++ b/app/assets/javascripts/milestones.js.coffee @@ -1,7 +1,7 @@ $ -> - $('.milestone-issue-filter td[data-closed]').addClass('hide') + $('.milestone-issue-filter tr[data-closed]').addClass('hide') $('.milestone-issue-filter ul.nav li a').click -> $('.milestone-issue-filter li').toggleClass('active') - $('.milestone-issue-filter td[data-closed]').toggleClass('hide') + $('.milestone-issue-filter tr[data-closed]').toggleClass('hide') false diff --git a/app/views/milestones/show.html.haml b/app/views/milestones/show.html.haml index cbc69fb7..c113c81f 100644 --- a/app/views/milestones/show.html.haml +++ b/app/views/milestones/show.html.haml @@ -52,8 +52,8 @@ %li.active= link_to('Open Issues', '#') %li=link_to('All Issues', '#') - @issues.each do |issue| - %tr - %td{data: {closed: issue.closed}} + %tr{data: {closed: issue.closed}} + %td = link_to [@project, issue] do %span.badge.badge-info ##{issue.id} – From bf1554f8c49d8243abadaf0078fbecf3ebdfaf93 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 10 Oct 2012 13:06:54 -0400 Subject: [PATCH 212/288] Add Feature for milestone issue filter Closes #1167 --- features/project/issues/milestones.feature | 8 +++++++ features/steps/project/project_milestones.rb | 22 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/features/project/issues/milestones.feature b/features/project/issues/milestones.feature index a57f67d6..50c090cc 100644 --- a/features/project/issues/milestones.feature +++ b/features/project/issues/milestones.feature @@ -16,3 +16,11 @@ Feature: Project Milestones Given I click link "New Milestone" And I submit new milestone "v2.3" Then I should see milestone "v2.3" + + @javascript + Scenario: Listing closed issues + Given the milestone has open and closed issues + And I click link "v2.2" + Then I should see 3 issues + When I click link "All Issues" + Then I should see 4 issues diff --git a/features/steps/project/project_milestones.rb b/features/steps/project/project_milestones.rb index 83ed6859..4d689c95 100644 --- a/features/steps/project/project_milestones.rb +++ b/features/steps/project/project_milestones.rb @@ -36,4 +36,26 @@ class ProjectMilestones < Spinach::FeatureSteps 3.times { Factory :issue, :project => project, :milestone => milestone } end + + Given 'the milestone has open and closed issues' do + project = Project.find_by_name("Shop") + milestone = project.milestones.find_by_title('v2.2') + + # 3 Open issues created above; create one closed issue + create(:closed_issue, project: project, milestone: milestone) + end + + When 'I click link "All Issues"' do + click_link 'All Issues' + end + + Then "I should see 3 issues" do + page.should have_selector('.milestone-issue-filter tbody tr', count: 4) + page.should have_selector('.milestone-issue-filter tbody tr.hide', count: 1) + end + + Then "I should see 4 issues" do + page.should have_selector('.milestone-issue-filter tbody tr', count: 4) + page.should_not have_selector('.milestone-issue-filter tbody tr.hide') + end end From 16ceae895e32c2474de04c42307d914bf9a4c304 Mon Sep 17 00:00:00 2001 From: Robb Kidd Date: Tue, 9 Oct 2012 18:25:29 -0400 Subject: [PATCH 213/288] Separate observing of Note and MergeRequests * Move is_assigned? and is_being_xx? methods to IssueCommonality This is behavior merge requests have in common with issues. Moved methods to IssueCommonality role. Put specs directly into merge_request_spec because setup differs for issues and MRs specifically in the "closed" factory to use. * Add MergeRequestObserver. Parallels IssueObserver in almost every way. Ripe for refactoring. * Rename MailerObserver to NoteObserver With merge request observing moved out of MailerObserver, all that was left was Note logic. Renamed to NoteObserver, added tests and updated application config for new observer names. Refactored NoteObserver to use the note's author and not rely on current_user. * Set current_user for MergeRequestObserver IssueObserver and MergeRequestObserver are the only observers that need a reference to the current_user that they cannot look up on the objects they are observing. --- app/controllers/application_controller.rb | 6 +- app/models/issue.rb | 16 -- app/observers/mailer_observer.rb | 80 -------- app/observers/merge_request_observer.rb | 31 +++ app/observers/note_observer.rb | 36 ++++ app/roles/issue_commonality.rb | 17 ++ config/application.rb | 10 +- spec/factories.rb | 6 + spec/models/merge_request_spec.rb | 43 ++++ spec/observers/merge_request_observer_spec.rb | 193 ++++++++++++++++++ spec/observers/note_observer_spec.rb | 109 ++++++++++ 11 files changed, 445 insertions(+), 102 deletions(-) delete mode 100644 app/observers/mailer_observer.rb create mode 100644 app/observers/merge_request_observer.rb create mode 100644 app/observers/note_observer.rb create mode 100644 spec/observers/merge_request_observer_spec.rb create mode 100644 spec/observers/note_observer_spec.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c4c99204..b597795a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,6 @@ class ApplicationController < ActionController::Base before_filter :authenticate_user! before_filter :reject_blocked! - before_filter :set_current_user_for_mailer before_filter :set_current_user_for_observers before_filter :dev_tools if Rails.env == 'development' @@ -41,11 +40,8 @@ class ApplicationController < ActionController::Base end end - def set_current_user_for_mailer - MailerObserver.current_user = current_user - end - def set_current_user_for_observers + MergeRequestObserver.current_user = current_user IssueObserver.current_user = current_user end diff --git a/app/models/issue.rb b/app/models/issue.rb index 5450bb49..3dd1c8c8 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -14,22 +14,6 @@ class Issue < ActiveRecord::Base def self.open_for(user) opened.assigned(user) end - - def is_assigned? - !!assignee_id - end - - def is_being_reassigned? - assignee_id_changed? - end - - def is_being_closed? - closed_changed? && closed - end - - def is_being_reopened? - closed_changed? && !closed - end end # == Schema Information diff --git a/app/observers/mailer_observer.rb b/app/observers/mailer_observer.rb deleted file mode 100644 index 331aaa35..00000000 --- a/app/observers/mailer_observer.rb +++ /dev/null @@ -1,80 +0,0 @@ -class MailerObserver < ActiveRecord::Observer - observe :note, :merge_request - cattr_accessor :current_user - - def after_create(model) - new_note(model) if model.kind_of?(Note) - new_merge_request(model) if model.kind_of?(MergeRequest) - end - - def after_update(model) - changed_merge_request(model) if model.kind_of?(MergeRequest) - end - - protected - - def new_note(note) - if note.notify - # Notify whole team except author of note - notify_note(note) - elsif note.notify_author - # Notify only author of resource - Notify.note_commit_email(note.commit_author.id, note.id).deliver - else - # Otherwise ignore it - nil - end - end - - def notify_note note - # reject author of note from mail list - users = note.project.users.reject { |u| u.id == current_user.id } - - users.each do |u| - case note.noteable_type - when "Commit"; Notify.note_commit_email(u.id, note.id).deliver - when "Issue"; Notify.note_issue_email(u.id, note.id).deliver - when "Wiki"; Notify.note_wiki_email(u.id, note.id).deliver - when "MergeRequest"; Notify.note_merge_request_email(u.id, note.id).deliver - when "Snippet"; true - else - Notify.note_wall_email(u.id, note.id).deliver - end - end - end - - def new_merge_request(merge_request) - if merge_request.assignee && merge_request.assignee != current_user - Notify.new_merge_request_email(merge_request.id).deliver - end - end - - def changed_merge_request(merge_request) - status_notify_and_comment merge_request, :reassigned_merge_request_email - end - - # This method used for Issues & Merge Requests - # - # It create a comment for Issue or MR if someone close/reopen. - # It also notify via email if assignee was changed - # - def status_notify_and_comment target, mail_method - # If assigne changed - notify to recipients - if target.assignee_id_changed? - recipients_ids = target.assignee_id_was, target.assignee_id - recipients_ids.delete current_user.id - - recipients_ids.each do |recipient_id| - Notify.send(mail_method, recipient_id, target.id, target.assignee_id_was).deliver - end - end - - # Create comment about status changed - if target.closed_changed? - note = Note.new(noteable: target, project: target.project) - note.author = current_user - note.note = "_Status changed to #{target.closed ? 'closed' : 'reopened'}_" - note.save() - end - end -end diff --git a/app/observers/merge_request_observer.rb b/app/observers/merge_request_observer.rb new file mode 100644 index 00000000..9090794d --- /dev/null +++ b/app/observers/merge_request_observer.rb @@ -0,0 +1,31 @@ +class MergeRequestObserver < ActiveRecord::Observer + cattr_accessor :current_user + + def after_create(merge_request) + if merge_request.assignee && merge_request.assignee != current_user + Notify.new_merge_request_email(merge_request.id).deliver + end + end + + def after_update(merge_request) + send_reassigned_email(merge_request) if merge_request.is_being_reassigned? + + status = nil + status = 'closed' if merge_request.is_being_closed? + status = 'reopened' if merge_request.is_being_reopened? + if status + Note.create_status_change_note(merge_request, current_user, status) + end + end + + protected + + def send_reassigned_email(merge_request) + recipients_ids = merge_request.assignee_id_was, merge_request.assignee_id + recipients_ids.delete current_user.id + + recipients_ids.each do |recipient_id| + Notify.reassigned_merge_request_email(recipient_id, merge_request.id, merge_request.assignee_id_was).deliver + end + end +end diff --git a/app/observers/note_observer.rb b/app/observers/note_observer.rb new file mode 100644 index 00000000..84484856 --- /dev/null +++ b/app/observers/note_observer.rb @@ -0,0 +1,36 @@ +class NoteObserver < ActiveRecord::Observer + + def after_create(note) + if note.notify + # Notify whole team except author of note + notify_team_of_new_note(note) + elsif note.notify_author + # Notify only author of resource + Notify.note_commit_email(note.commit_author.id, note.id).deliver + else + # Otherwise ignore it + nil + end + end + + protected + + def notify_team_of_new_note(note) + team_without_note_author(note).map do |u| + case note.noteable_type + when "Commit"; Notify.note_commit_email(u.id, note.id).deliver + when "Issue"; Notify.note_issue_email(u.id, note.id).deliver + when "Wiki"; Notify.note_wiki_email(u.id, note.id).deliver + when "MergeRequest"; Notify.note_merge_request_email(u.id, note.id).deliver + when "Wall"; Notify.note_wall_email(u.id, note.id).deliver + when "Snippet"; true # no notifications for snippets? + else + true + end + end + end + + def team_without_note_author(note) + note.project.users.reject { |u| u.id == note.author.id } + end +end diff --git a/app/roles/issue_commonality.rb b/app/roles/issue_commonality.rb index 3d907486..2d10bfec 100644 --- a/app/roles/issue_commonality.rb +++ b/app/roles/issue_commonality.rb @@ -46,4 +46,21 @@ module IssueCommonality def new? today? && created_at == updated_at end + + def is_assigned? + !!assignee_id + end + + def is_being_reassigned? + assignee_id_changed? + end + + def is_being_closed? + closed_changed? && closed + end + + def is_being_reopened? + closed_changed? && !closed + end + end diff --git a/config/application.rb b/config/application.rb index 1189035f..74ed330e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -23,7 +23,15 @@ module Gitlab # config.plugins = [ :exception_notification, :ssl_requirement, :all ] # Activate observers that should always be running. - config.active_record.observers = :mailer_observer, :activity_observer, :project_observer, :key_observer, :issue_observer, :user_observer, :system_hook_observer, :users_project_observer + config.active_record.observers = :activity_observer, + :issue_observer, + :key_observer, + :merge_request_observer, + :note_observer, + :project_observer, + :system_hook_observer, + :user_observer, + :users_project_observer # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. diff --git a/spec/factories.rb b/spec/factories.rb index cb3541cc..0258f892 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -76,6 +76,12 @@ FactoryGirl.define do project source_branch "master" target_branch "stable" + + trait :closed do + closed true + end + + factory :closed_merge_request, traits: [:closed] end factory :note do diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 91d404f7..be40c561 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -50,4 +50,47 @@ describe MergeRequest do merge_request.mr_and_commit_notes.count.should == 2 end end + + subject { Factory.create(:merge_request) } + + describe '#is_being_reassigned?' do + it 'returns true if the merge_request assignee has changed' do + subject.assignee = Factory(:user) + subject.is_being_reassigned?.should be_true + end + it 'returns false if the merge request assignee has not changed' do + subject.is_being_reassigned?.should be_false + end + end + + describe '#is_being_closed?' do + it 'returns true if the closed attribute has changed and is now true' do + subject.closed = true + subject.is_being_closed?.should be_true + end + it 'returns false if the closed attribute has changed and is now false' do + merge_request = Factory.create(:closed_merge_request) + merge_request.closed = false + merge_request.is_being_closed?.should be_false + end + it 'returns false if the closed attribute has not changed' do + subject.is_being_closed?.should be_false + end + end + + + describe '#is_being_reopened?' do + it 'returns true if the closed attribute has changed and is now false' do + merge_request = Factory.create(:closed_merge_request) + merge_request.closed = false + merge_request.is_being_reopened?.should be_true + end + it 'returns false if the closed attribute has changed and is now true' do + subject.closed = true + subject.is_being_reopened?.should be_false + end + it 'returns false if the closed attribute has not changed' do + subject.is_being_reopened?.should be_false + end + end end diff --git a/spec/observers/merge_request_observer_spec.rb b/spec/observers/merge_request_observer_spec.rb new file mode 100644 index 00000000..a9ba7927 --- /dev/null +++ b/spec/observers/merge_request_observer_spec.rb @@ -0,0 +1,193 @@ +require 'spec_helper' + +describe MergeRequestObserver do + let(:some_user) { double(:user, id: 1) } + let(:assignee) { double(:user, id: 2) } + let(:author) { double(:user, id: 3) } + let(:mr) { double(:merge_request, id: 42, assignee: assignee, author: author) } + + before(:each) { subject.stub(:current_user).and_return(some_user) } + + subject { MergeRequestObserver.instance } + + describe '#after_create' do + + it 'is called when a merge request is created' do + subject.should_receive(:after_create) + + MergeRequest.observers.enable :merge_request_observer do + Factory.create(:merge_request, project: Factory.create(:project)) + end + end + + it 'sends an email to the assignee' do + Notify.should_receive(:new_merge_request_email).with(mr.id). + and_return(double(deliver: true)) + + subject.after_create(mr) + end + + it 'does not send an email to the assignee if assignee created the merge request' do + subject.stub(:current_user).and_return(assignee) + Notify.should_not_receive(:new_merge_request_email) + + subject.after_create(mr) + end + end + + context '#after_update' do + before(:each) do + mr.stub(:is_being_reassigned?).and_return(false) + mr.stub(:is_being_closed?).and_return(false) + mr.stub(:is_being_reopened?).and_return(false) + end + + it 'is called when a merge request is changed' do + changed = Factory.create(:merge_request, project: Factory.create(:project)) + subject.should_receive(:after_update) + + MergeRequest.observers.enable :merge_request_observer do + changed.title = 'I changed' + changed.save + end + end + + context 'a reassigned email' do + it 'is sent if the merge request is being reassigned' do + mr.should_receive(:is_being_reassigned?).and_return(true) + subject.should_receive(:send_reassigned_email).with(mr) + + subject.after_update(mr) + end + + it 'is not sent if the merge request is not being reassigned' do + mr.should_receive(:is_being_reassigned?).and_return(false) + subject.should_not_receive(:send_reassigned_email) + + subject.after_update(mr) + end + end + + context 'a status "closed"' do + it 'note is created if the merge request is being closed' do + mr.should_receive(:is_being_closed?).and_return(true) + Note.should_receive(:create_status_change_note).with(mr, some_user, 'closed') + + subject.after_update(mr) + end + + it 'note is not created if the merge request is not being closed' do + mr.should_receive(:is_being_closed?).and_return(false) + Note.should_not_receive(:create_status_change_note).with(mr, some_user, 'closed') + + subject.after_update(mr) + end + + it 'notification is delivered if the merge request being closed' do + mr.stub(:is_being_closed?).and_return(true) + Note.should_receive(:create_status_change_note).with(mr, some_user, 'closed') + + subject.after_update(mr) + end + + it 'notification is not delivered if the merge request not being closed' do + mr.stub(:is_being_closed?).and_return(false) + Note.should_not_receive(:create_status_change_note).with(mr, some_user, 'closed') + + subject.after_update(mr) + end + + it 'notification is delivered only to author if the merge request is being closed' do + mr_without_assignee = double(:merge_request, id: 42, author: author, assignee: nil) + mr_without_assignee.stub(:is_being_reassigned?).and_return(false) + mr_without_assignee.stub(:is_being_closed?).and_return(true) + mr_without_assignee.stub(:is_being_reopened?).and_return(false) + Note.should_receive(:create_status_change_note).with(mr_without_assignee, some_user, 'closed') + + subject.after_update(mr_without_assignee) + end + end + + context 'a status "reopened"' do + it 'note is created if the merge request is being reopened' do + mr.should_receive(:is_being_reopened?).and_return(true) + Note.should_receive(:create_status_change_note).with(mr, some_user, 'reopened') + + subject.after_update(mr) + end + + it 'note is not created if the merge request is not being reopened' do + mr.should_receive(:is_being_reopened?).and_return(false) + Note.should_not_receive(:create_status_change_note).with(mr, some_user, 'reopened') + + subject.after_update(mr) + end + + it 'notification is delivered if the merge request being reopened' do + mr.stub(:is_being_reopened?).and_return(true) + Note.should_receive(:create_status_change_note).with(mr, some_user, 'reopened') + + subject.after_update(mr) + end + + it 'notification is not delivered if the merge request is not being reopened' do + mr.stub(:is_being_reopened?).and_return(false) + Note.should_not_receive(:create_status_change_note).with(mr, some_user, 'reopened') + + subject.after_update(mr) + end + + it 'notification is delivered only to author if the merge request is being reopened' do + mr_without_assignee = double(:merge_request, id: 42, author: author, assignee: nil) + mr_without_assignee.stub(:is_being_reassigned?).and_return(false) + mr_without_assignee.stub(:is_being_closed?).and_return(false) + mr_without_assignee.stub(:is_being_reopened?).and_return(true) + Note.should_receive(:create_status_change_note).with(mr_without_assignee, some_user, 'reopened') + + subject.after_update(mr_without_assignee) + end + end + end + + describe '#send_reassigned_email' do + let(:previous_assignee) { double(:user, id: 3) } + + before(:each) do + mr.stub(:assignee_id).and_return(assignee.id) + mr.stub(:assignee_id_was).and_return(previous_assignee.id) + end + + def it_sends_a_reassigned_email_to(recipient) + Notify.should_receive(:reassigned_merge_request_email).with(recipient, mr.id, previous_assignee.id). + and_return(double(deliver: true)) + end + + def it_does_not_send_a_reassigned_email_to(recipient) + Notify.should_not_receive(:reassigned_merge_request_email).with(recipient, mr.id, previous_assignee.id) + end + + it 'sends a reassigned email to the previous and current assignees' do + it_sends_a_reassigned_email_to assignee.id + it_sends_a_reassigned_email_to previous_assignee.id + + subject.send(:send_reassigned_email, mr) + end + + context 'does not send an email to the user who made the reassignment' do + it 'if the user is the assignee' do + subject.stub(:current_user).and_return(assignee) + it_sends_a_reassigned_email_to previous_assignee.id + it_does_not_send_a_reassigned_email_to assignee.id + + subject.send(:send_reassigned_email, mr) + end + it 'if the user is the previous assignee' do + subject.stub(:current_user).and_return(previous_assignee) + it_sends_a_reassigned_email_to assignee.id + it_does_not_send_a_reassigned_email_to previous_assignee.id + + subject.send(:send_reassigned_email, mr) + end + end + end +end diff --git a/spec/observers/note_observer_spec.rb b/spec/observers/note_observer_spec.rb new file mode 100644 index 00000000..fd211789 --- /dev/null +++ b/spec/observers/note_observer_spec.rb @@ -0,0 +1,109 @@ +require 'spec_helper' + +describe NoteObserver do + subject { NoteObserver.instance } + + describe '#after_create' do + let(:note) { double :note, notify: false, notify_author: false } + + it 'is called after a note is created' do + subject.should_receive :after_create + + Note.observers.enable :note_observer do + Factory.create(:note) + end + end + + it 'notifies team of new note when flagged to notify' do + note.stub(:notify).and_return(true) + subject.should_receive(:notify_team_of_new_note).with(note) + + subject.after_create(note) + end + it 'does not notify team of new note when not flagged to notify' do + subject.should_not_receive(:notify_team_of_new_note).with(note) + + subject.after_create(note) + end + it 'notifies the author of a commit when flagged to notify the author' do + note.stub(:notify_author).and_return(true) + note.stub(:id).and_return(42) + author = double :user, id: 1 + note.stub(:commit_author).and_return(author) + Notify.should_receive(:note_commit_email).and_return(double(deliver: true)) + + subject.after_create(note) + end + it 'does not notify the author of a commit when not flagged to notify the author' do + Notify.should_not_receive(:note_commit_email) + + subject.after_create(note) + end + it 'does nothing if no notify flags are set' do + subject.after_create(note).should be_nil + end + end + + + let(:team_without_author) { (1..2).map { |n| double :user, id: n } } + + describe '#notify_team_of_new_note' do + let(:note) { double :note, id: 1 } + + before :each do + subject.stub(:team_without_note_author).with(note).and_return(team_without_author) + end + + context 'notifies team of a new note on' do + it 'a commit' do + note.stub(:noteable_type).and_return('Commit') + Notify.should_receive(:note_commit_email).twice.and_return(double(deliver: true)) + + subject.send(:notify_team_of_new_note, note) + end + it 'an issue' do + note.stub(:noteable_type).and_return('Issue') + Notify.should_receive(:note_issue_email).twice.and_return(double(deliver: true)) + + subject.send(:notify_team_of_new_note, note) + end + it 'a wiki page' do + note.stub(:noteable_type).and_return('Wiki') + Notify.should_receive(:note_wiki_email).twice.and_return(double(deliver: true)) + + subject.send(:notify_team_of_new_note, note) + end + it 'a merge request' do + note.stub(:noteable_type).and_return('MergeRequest') + Notify.should_receive(:note_merge_request_email).twice.and_return(double(deliver: true)) + + subject.send(:notify_team_of_new_note, note) + end + it 'a wall' do + note.stub(:noteable_type).and_return('Wall') + Notify.should_receive(:note_wall_email).twice.and_return(double(deliver: true)) + + subject.send(:notify_team_of_new_note, note) + end + end + + it 'does nothing for a new note on a snippet' do + note.stub(:noteable_type).and_return('Snippet') + + subject.send(:notify_team_of_new_note, note).should == [true, true] + end + end + + + describe '#team_without_note_author' do + let(:author) { double :user, id: 4 } + + let(:users) { team_without_author + [author] } + let(:project) { double :project, users: users } + let(:note) { double :note, project: project, author: author } + + it 'returns the projects user without the note author included' do + subject.send(:team_without_note_author, note).should == team_without_author + end + end +end From 9168cd6a00aced5d21c36ab8e8941e6d297e2023 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Thu, 11 Oct 2012 16:55:11 +0300 Subject: [PATCH 214/288] Fix starting gitlab after reboot server --- doc/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/installation.md b/doc/installation.md index 2d273836..0a9858e9 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -342,7 +342,7 @@ Create init script in /etc/init.d/gitlab: GitLab autostart: - sudo update-rc.d gitlab defaults + sudo update-rc.d gitlab defaults 21 Now you can start/restart/stop GitLab like: From d32a5d7eef9e06629e849fb8adbab7a9d584814f Mon Sep 17 00:00:00 2001 From: Robb Kidd Date: Thu, 11 Oct 2012 11:05:13 -0400 Subject: [PATCH 215/288] Clean up indenting in new observer. --- app/observers/merge_request_observer.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/observers/merge_request_observer.rb b/app/observers/merge_request_observer.rb index 9090794d..c4040f15 100644 --- a/app/observers/merge_request_observer.rb +++ b/app/observers/merge_request_observer.rb @@ -21,11 +21,11 @@ class MergeRequestObserver < ActiveRecord::Observer protected def send_reassigned_email(merge_request) - recipients_ids = merge_request.assignee_id_was, merge_request.assignee_id - recipients_ids.delete current_user.id + recipients_ids = merge_request.assignee_id_was, merge_request.assignee_id + recipients_ids.delete current_user.id - recipients_ids.each do |recipient_id| - Notify.reassigned_merge_request_email(recipient_id, merge_request.id, merge_request.assignee_id_was).deliver - end + recipients_ids.each do |recipient_id| + Notify.reassigned_merge_request_email(recipient_id, merge_request.id, merge_request.assignee_id_was).deliver + end end end From 378fe076b6d6bf6d6808a7336a25ebeb3eca7683 Mon Sep 17 00:00:00 2001 From: Robb Kidd Date: Thu, 11 Oct 2012 13:27:58 -0400 Subject: [PATCH 216/288] Reduce complexity: replace case statement with method lookup. --- app/observers/note_observer.rb | 15 +++++---------- spec/observers/note_observer_spec.rb | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/observers/note_observer.rb b/app/observers/note_observer.rb index 84484856..3d51b9c2 100644 --- a/app/observers/note_observer.rb +++ b/app/observers/note_observer.rb @@ -16,16 +16,11 @@ class NoteObserver < ActiveRecord::Observer protected def notify_team_of_new_note(note) - team_without_note_author(note).map do |u| - case note.noteable_type - when "Commit"; Notify.note_commit_email(u.id, note.id).deliver - when "Issue"; Notify.note_issue_email(u.id, note.id).deliver - when "Wiki"; Notify.note_wiki_email(u.id, note.id).deliver - when "MergeRequest"; Notify.note_merge_request_email(u.id, note.id).deliver - when "Wall"; Notify.note_wall_email(u.id, note.id).deliver - when "Snippet"; true # no notifications for snippets? - else - true + notify_method = 'note_' + note.noteable_type.underscore + '_email' + + if Notify.respond_to? notify_method + team_without_note_author(note).map do |u| + Notify.send(notify_method.to_sym, u.id, note.id).deliver end end end diff --git a/spec/observers/note_observer_spec.rb b/spec/observers/note_observer_spec.rb index fd211789..3538cf04 100644 --- a/spec/observers/note_observer_spec.rb +++ b/spec/observers/note_observer_spec.rb @@ -90,7 +90,7 @@ describe NoteObserver do it 'does nothing for a new note on a snippet' do note.stub(:noteable_type).and_return('Snippet') - subject.send(:notify_team_of_new_note, note).should == [true, true] + subject.send(:notify_team_of_new_note, note).should be_nil end end From 64008b9ec70d299fb9514365b8853182534fc421 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Fri, 12 Oct 2012 01:02:28 +0200 Subject: [PATCH 217/288] Improve search suggestions --- app/helpers/application_helper.rb | 36 +++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8c65a0fd..d27f4de3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -76,26 +76,40 @@ module ApplicationHelper def search_autocomplete_source projects = current_user.projects.map{ |p| { label: p.name, url: project_path(p) } } + default_nav = [ - { label: "Profile", url: profile_path }, - { label: "Keys", url: keys_path }, - { label: "Dashboard", url: root_path }, - { label: "Admin", url: admin_root_path } + { label: "My Profile", url: profile_path }, + { label: "My SSH Keys", url: keys_path }, + { label: "My Dashboard", url: root_path }, + { label: "Admin Section", url: admin_root_path }, + ] + + help_nav = [ + { label: "Workflow Help", url: help_workflow_path }, + { label: "Permissions Help", url: help_permissions_path }, + { label: "Web Hooks Help", url: help_web_hooks_path }, + { label: "System Hooks Help", url: help_system_hooks_path }, + { label: "API Help", url: help_api_path }, + { label: "Markdown Help", url: help_markdown_path }, + { label: "SSH Keys Help", url: help_ssh_path }, ] project_nav = [] - if @project && !@project.new_record? project_nav = [ - { label: "#{@project.name} / Issues", url: project_issues_path(@project) }, - { label: "#{@project.name} / Wall", url: wall_project_path(@project) }, - { label: "#{@project.name} / Tree", url: project_tree_path(@project, @ref || @project.root_ref) }, - { label: "#{@project.name} / Commits", url: project_commits_path(@project, @ref || @project.root_ref) }, - { label: "#{@project.name} / Team", url: project_team_index_path(@project) } + { label: "#{@project.name} Issues", url: project_issues_path(@project) }, + { label: "#{@project.name} Commits", url: project_commits_path(@project, @ref || @project.root_ref) }, + { label: "#{@project.name} Merge Requests", url: project_merge_requests_path(@project) }, + { label: "#{@project.name} Milestones", url: project_milestones_path(@project) }, + { label: "#{@project.name} Snippets", url: project_snippets_path(@project) }, + { label: "#{@project.name} Team", url: project_team_index_path(@project) }, + { label: "#{@project.name} Tree", url: project_tree_path(@project, @ref || @project.root_ref) }, + { label: "#{@project.name} Wall", url: wall_project_path(@project) }, + { label: "#{@project.name} Wiki", url: project_wikis_path(@project) }, ] end - [projects, default_nav, project_nav].flatten.to_json + [projects, default_nav, project_nav, help_nav].flatten.to_json end def emoji_autocomplete_source From d1a18d038d12198c433a8d90a14ca6365ece33b4 Mon Sep 17 00:00:00 2001 From: jozefvaclavik Date: Fri, 12 Oct 2012 10:30:09 +0300 Subject: [PATCH 218/288] Update lib/api/projects.rb Added methods for listing one project hook and editing hooks. GET /project/:id/hooks/:hook_id PUT /project/:id/hooks/:hook_id --- lib/api/projects.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 0f013883..8f094e0c 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -147,6 +147,19 @@ module Gitlab @hooks = paginate user_project.hooks present @hooks, with: Entities::Hook end + + # Get a project hook + # + # Parameters: + # id (required) - The ID or code name of a project + # hook_id (required) - The ID of a project hook + # Example Request: + # GET /projects/:id/hooks/:hook_id + get ":id/hooks/:hook_id" do + @hook = user_project.hooks.find(params[:hook_id]) + present @hook, with: Entities::Hook + end + # Add hook to project # @@ -164,6 +177,27 @@ module Gitlab error!({'message' => '404 Not found'}, 404) end end + + # Update an existing project hook + # + # Parameters: + # id (required) - The ID or code name of a project + # hook_id (required) - The ID of a project hook + # url (required) - The hook URL + # Example Request: + # PUT /projects/:id/hooks/:hook_id + put ":id/hooks/:hook_id" do + @hook = user_project.hooks.find(params[:hook_id]) + authorize! :admin_project, user_project + + attrs = attributes_for_keys [:url] + + if @hook.update_attributes attrs + present @hook, with: Entities::Hook + else + not_found! + end + end # Delete project hook # From cfbd0b4f26224d0af9fa1366f7d83036aea2c15d Mon Sep 17 00:00:00 2001 From: jozefvaclavik Date: Fri, 12 Oct 2012 10:31:57 +0300 Subject: [PATCH 219/288] Update CHANGELOG for updated hooks API --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 1c9f3bba..f626f49d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ master + - [API] list one project hook + - [API] edit project hook - [API] add project snippets list - [API] allow to authorize using private token in HTTP header - [API] add user creation From d0000e5c189534468da41205a1d5ad61f5c26547 Mon Sep 17 00:00:00 2001 From: jozefvaclavik Date: Fri, 12 Oct 2012 10:38:15 +0300 Subject: [PATCH 220/288] Update doc/api/projects.md for hooks API Added documentation for getting project hook and editing project hook. --- doc/api/projects.md | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/doc/api/projects.md b/doc/api/projects.md index d06a41c2..fdedf904 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -196,9 +196,9 @@ Parameters: Status code `200` will be returned on success. -## Get project hooks +## List project hooks -Get hooks for project +Get list for project hooks ``` GET /projects/:id/hooks @@ -210,6 +210,21 @@ Parameters: Will return hooks with status `200 OK` on success, or `404 Not found` on fail. +## Get project hook + +Get hook for project + +``` +GET /projects/:id/hooks/:hook_id +``` + +Parameters: + ++ `id` (required) - The ID or code name of a project ++ `hook_id` (required) - The ID of a project hook + +Will return hook with status `200 OK` on success, or `404 Not found` on fail. + ## Add project hook Add hook to project @@ -225,6 +240,23 @@ Parameters: Will return status `201 Created` on success, or `404 Not found` on fail. +## Edit project hook + +Edit hook for project + +``` +PUT /projects/:id/hooks/:hook_id +``` + +Parameters: + ++ `id` (required) - The ID or code name of a project ++ `hook_id` (required) - The ID of a project hook ++ `url` (required) - The hook URL + +Will return status `201 Created` on success, or `404 Not found` on fail. + + ## Delete project hook Delete hook from project From 3f2e04254f92269240a4f0e7dbeb55e045563bc6 Mon Sep 17 00:00:00 2001 From: jozefvaclavik Date: Fri, 12 Oct 2012 11:00:59 +0300 Subject: [PATCH 221/288] Update projects_spec.rb for Hook list and edit Also (I think) I found few mistakes with snippets requests. --- spec/requests/api/projects_spec.rb | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 94c9abb3..87d981a0 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -172,7 +172,15 @@ describe Gitlab::API do end end - describe "POST /projects/:id/users" do + describe "GET /projects/:id/hooks/:hook_id" do + it "should return a project hook" do + get api("/projects/#{project.code}/hooks/#{hook.id}", user) + response.status.should == 200 + json_response['url'].should == hook.url + end + end + + describe "POST /projects/:id/hooks" do it "should add hook to project" do expect { post api("/projects/#{project.code}/hooks", user), @@ -180,6 +188,17 @@ describe Gitlab::API do }.to change {project.hooks.count}.by(1) end end + + describe "PUT /projects/:id/hooks/:hook_id" do + it "should update an existing project hook" do + put api("/projects/#{project.code}/hooks/#{hook.id}", user), + code: 'updated code' + response.status.should == 200 + json_response['url'].should == 'http://example.com' + hook.reload.content.should == 'updated code' + end + end + describe "DELETE /projects/:id/hooks" do it "should delete hook from project" do @@ -246,7 +265,7 @@ describe Gitlab::API do end end - describe "PUT /projects/:id/snippets" do + describe "PUT /projects/:id/snippets/:shippet_id" do it "should update an existing project snippet" do put api("/projects/#{project.code}/snippets/#{snippet.id}", user), code: 'updated code' From 96abbf02e3679cd883ea4ad80227f3187791da8a Mon Sep 17 00:00:00 2001 From: jozefvaclavik Date: Fri, 12 Oct 2012 11:30:39 +0300 Subject: [PATCH 222/288] Update spec/requests/api/projects_spec.rb Fixed mistake with updating project hook --- spec/requests/api/projects_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 87d981a0..51526f89 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -192,10 +192,9 @@ describe Gitlab::API do describe "PUT /projects/:id/hooks/:hook_id" do it "should update an existing project hook" do put api("/projects/#{project.code}/hooks/#{hook.id}", user), - code: 'updated code' + url: 'http://example.com' response.status.should == 200 json_response['url'].should == 'http://example.com' - hook.reload.content.should == 'updated code' end end From 19560a4b5f8087ed0cfeef285c9a03404d15ca60 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Fri, 12 Oct 2012 13:37:44 +0200 Subject: [PATCH 223/288] Fix displaying events for deleted things --- app/helpers/events_helper.rb | 2 +- app/views/events/event/_common.html.haml | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 2c466aba..0eb87caa 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -1,7 +1,7 @@ module EventsHelper def link_to_author(event) project = event.project - tm = project.team_member_by_id(event.author_id) + tm = project.team_member_by_id(event.author_id) if project if tm link_to event.author_name, project_team_member_path(project, tm) diff --git a/app/views/events/event/_common.html.haml b/app/views/events/event/_common.html.haml index ffcaa81a..dcabd1a9 100644 --- a/app/views/events/event/_common.html.haml +++ b/app/views/events/event/_common.html.haml @@ -1,7 +1,13 @@ .event-title %span.author_name= link_to_author event %span.event_label{class: event.action_name}= event_action_name(event) - = link_to [event.project, event.target] do + - if event.target + = link_to [event.project, event.target] do + %strong= truncate event.target_title + - else %strong= truncate event.target_title at - = link_to_project event.project + - if event.project + = link_to_project event.project + - else + = event.project_name From f6a8e6944984eabb21a3ce9c15d1f14eb87ee06d Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Mon, 8 Oct 2012 18:43:54 +0300 Subject: [PATCH 224/288] WebEditor: base form --- app/controllers/tree_controller.rb | 8 ++++++++ app/views/tree/_tree_file.html.haml | 1 + app/views/tree/edit.html.haml | 10 ++++++++++ config/routes.rb | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 app/views/tree/edit.html.haml diff --git a/app/controllers/tree_controller.rb b/app/controllers/tree_controller.rb index 2270eede..6224ed06 100644 --- a/app/controllers/tree_controller.rb +++ b/app/controllers/tree_controller.rb @@ -19,4 +19,12 @@ class TreeController < ProjectResourceController format.js { no_cache_headers } end end + + def edit + @last_commit = @project.commits(@ref, @path, 1).first.sha + end + + def update + last_commit = @project.commits(@ref, @path, 1).first.sha + end end diff --git a/app/views/tree/_tree_file.html.haml b/app/views/tree/_tree_file.html.haml index 82aaed24..bae43087 100644 --- a/app/views/tree/_tree_file.html.haml +++ b/app/views/tree/_tree_file.html.haml @@ -8,6 +8,7 @@ = link_to "raw", project_blob_path(@project, @id), class: "btn very_small", target: "_blank" = link_to "history", project_commits_path(@project, @id), class: "btn very_small" = link_to "blame", project_blame_path(@project, @id), class: "btn very_small" + = link_to "Edit", edit_project_tree_path(@project, @id), class: "btn very_small" - if tree_file.text? - if gitlab_markdown?(tree_file.name) .file_content.wiki diff --git a/app/views/tree/edit.html.haml b/app/views/tree/edit.html.haml new file mode 100644 index 00000000..d4571f76 --- /dev/null +++ b/app/views/tree/edit.html.haml @@ -0,0 +1,10 @@ +.file_holder + Edit file: + %span.file_name + = @tree.path.force_encoding('utf-8') + %br + = form_tag(project_tree_path(@project, @id), :method => :put) do + %textarea + = @tree.data + = hidden_field_tag 'last_commit', @last_commit + = submit_tag "Save" diff --git a/config/routes.rb b/config/routes.rb index 54b298c9..de5261d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -183,7 +183,7 @@ Gitlab::Application.routes.draw do resources :compare, only: [:index, :create] resources :blame, only: [:show], constraints: {id: /.+/} resources :blob, only: [:show], constraints: {id: /.+/} - resources :tree, only: [:show], constraints: {id: /.+/} + resources :tree, only: [:show, :edit, :update], constraints: {id: /.+/} match "/compare/:from...:to" => "compare#show", as: "compare", :via => [:get, :post], constraints: {from: /.+/, to: /.+/} From 3b5c7b6e9aead85ffaa5d669639e69989da8a5b8 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Mon, 8 Oct 2012 18:54:51 +0300 Subject: [PATCH 225/288] minor code style fixing --- app/models/merge_request.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 5b3c3724..f4644dac 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -23,7 +23,7 @@ class MergeRequest < ActiveRecord::Base validate :validate_branches def self.find_all_by_branch(branch_name) - where("source_branch like :branch or target_branch like :branch", branch: branch_name) + where("source_branch LIKE :branch OR target_branch LIKE :branch", branch: branch_name) end def human_state From 57e2b5ed1adf330f2b1684d3e8aed311087d4304 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Tue, 9 Oct 2012 20:11:49 +0300 Subject: [PATCH 226/288] WebEditor: integrated editor --- app/assets/javascripts/application.js | 1 + app/assets/stylesheets/main.scss | 6 + app/assets/stylesheets/sections/editor.scss | 14 + app/views/tree/edit.html.haml | 15 +- .../javascripts/ace-src-noconflict/ace.js | 15881 ++++ .../ace-src-noconflict/keybinding-emacs.js | 374 + .../ace-src-noconflict/keybinding-vim.js | 1679 + .../ace-src-noconflict/mode-c9search.js | 268 + .../ace-src-noconflict/mode-c_cpp.js | 759 + .../ace-src-noconflict/mode-clojure.js | 347 + .../ace-src-noconflict/mode-coffee.js | 513 + .../ace-src-noconflict/mode-coldfusion.js | 1852 + .../ace-src-noconflict/mode-csharp.js | 619 + .../ace-src-noconflict/mode-css.js | 457 + .../ace-src-noconflict/mode-diff.js | 244 + .../ace-src-noconflict/mode-glsl.js | 834 + .../ace-src-noconflict/mode-golang.js | 674 + .../ace-src-noconflict/mode-groovy.js | 1160 + .../ace-src-noconflict/mode-haxe.js | 624 + .../ace-src-noconflict/mode-html.js | 1950 + .../ace-src-noconflict/mode-jade.js | 2038 + .../ace-src-noconflict/mode-java.js | 1120 + .../ace-src-noconflict/mode-javascript.js | 990 + .../ace-src-noconflict/mode-json.js | 581 + .../ace-src-noconflict/mode-jsp.js | 1664 + .../ace-src-noconflict/mode-jsx.js | 646 + .../ace-src-noconflict/mode-latex.js | 95 + .../ace-src-noconflict/mode-less.js | 504 + .../ace-src-noconflict/mode-liquid.js | 1003 + .../ace-src-noconflict/mode-lua.js | 524 + .../ace-src-noconflict/mode-luahtml.js | 2415 + .../ace-src-noconflict/mode-luapage.js | 2480 + .../ace-src-noconflict/mode-markdown.js | 2252 + .../ace-src-noconflict/mode-ocaml.js | 452 + .../ace-src-noconflict/mode-perl.js | 419 + .../ace-src-noconflict/mode-pgsql.js | 963 + .../ace-src-noconflict/mode-php.js | 2359 + .../ace-src-noconflict/mode-powershell.js | 608 + .../ace-src-noconflict/mode-python.js | 383 + .../ace-src-noconflict/mode-ruby.js | 302 + .../ace-src-noconflict/mode-scad.js | 712 + .../ace-src-noconflict/mode-scala.js | 1151 + .../ace-src-noconflict/mode-scss.js | 530 + .../javascripts/ace-src-noconflict/mode-sh.js | 238 + .../ace-src-noconflict/mode-sql.js | 145 + .../ace-src-noconflict/mode-svg.js | 1602 + .../ace-src-noconflict/mode-tcl.js | 444 + .../ace-src-noconflict/mode-text.js | 0 .../ace-src-noconflict/mode-textile.js | 175 + .../ace-src-noconflict/mode-xml.js | 822 + .../ace-src-noconflict/mode-xquery.js | 591 + .../ace-src-noconflict/mode-yaml.js | 371 + .../ace-src-noconflict/theme-ambiance.js | 269 + .../ace-src-noconflict/theme-chrome.js | 205 + .../ace-src-noconflict/theme-clouds.js | 170 + .../theme-clouds_midnight.js | 171 + .../ace-src-noconflict/theme-cobalt.js | 182 + .../theme-crimson_editor.js | 197 + .../ace-src-noconflict/theme-dawn.js | 183 + .../ace-src-noconflict/theme-dreamweaver.js | 224 + .../ace-src-noconflict/theme-eclipse.js | 154 + .../ace-src-noconflict/theme-github.js | 175 + .../ace-src-noconflict/theme-idle_fingers.js | 171 + .../ace-src-noconflict/theme-kr_theme.js | 177 + .../ace-src-noconflict/theme-merbivore.js | 168 + .../theme-merbivore_soft.js | 169 + .../theme-mono_industrial.js | 180 + .../ace-src-noconflict/theme-monokai.js | 174 + .../theme-pastel_on_dark.js | 187 + .../theme-solarized_dark.js | 159 + .../theme-solarized_light.js | 164 + .../ace-src-noconflict/theme-textmate.js | 207 + .../ace-src-noconflict/theme-tomorrow.js | 182 + .../theme-tomorrow_night.js | 182 + .../theme-tomorrow_night_blue.js | 179 + .../theme-tomorrow_night_bright.js | 182 + .../theme-tomorrow_night_eighties.js | 178 + .../ace-src-noconflict/theme-twilight.js | 184 + .../ace-src-noconflict/theme-vibrant_ink.js | 164 + .../ace-src-noconflict/theme-xcode.js | 156 + .../ace-src-noconflict/worker-coffee.js | 7213 ++ .../ace-src-noconflict/worker-css.js | 10940 +++ .../ace-src-noconflict/worker-javascript.js | 10319 +++ .../ace-src-noconflict/worker-json.js | 2946 + .../ace-src-noconflict/worker-xquery.js | 69021 ++++++++++++++++ 85 files changed, 162379 insertions(+), 3 deletions(-) create mode 100644 app/assets/stylesheets/sections/editor.scss create mode 100644 vendor/assets/javascripts/ace-src-noconflict/ace.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/keybinding-emacs.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/keybinding-vim.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-c9search.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-c_cpp.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-clojure.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-coffee.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-coldfusion.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-csharp.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-css.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-diff.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-glsl.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-golang.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-groovy.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-haxe.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-html.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-jade.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-java.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-javascript.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-json.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-jsp.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-jsx.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-latex.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-less.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-liquid.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-lua.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-luahtml.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-luapage.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-markdown.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-ocaml.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-perl.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-pgsql.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-php.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-powershell.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-python.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-ruby.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-scad.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-scala.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-scss.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-sh.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-sql.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-svg.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-tcl.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-text.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-textile.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-xml.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-xquery.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/mode-yaml.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-ambiance.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-chrome.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-clouds.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-clouds_midnight.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-cobalt.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-crimson_editor.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-dawn.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-dreamweaver.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-eclipse.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-github.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-idle_fingers.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-kr_theme.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-merbivore.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-merbivore_soft.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-mono_industrial.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-monokai.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-pastel_on_dark.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-solarized_dark.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-solarized_light.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-textmate.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_blue.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_bright.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_eighties.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-twilight.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-vibrant_ink.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/theme-xcode.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/worker-coffee.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/worker-css.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/worker-javascript.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/worker-json.js create mode 100644 vendor/assets/javascripts/ace-src-noconflict/worker-xquery.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index d582a1a1..21554ba3 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -18,4 +18,5 @@ //= require chosen-jquery //= require raphael //= require branch-graph +//= require ace-src-noconflict/ace.js //= require_tree . diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index bff24493..f8cf8e44 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -182,3 +182,9 @@ $hover: #D9EDF7; * */ @import "highlight/dark.scss"; + +/** + * File Editor styles + * + */ +@import "sections/editor.scss"; diff --git a/app/assets/stylesheets/sections/editor.scss b/app/assets/stylesheets/sections/editor.scss new file mode 100644 index 00000000..f8e0fcac --- /dev/null +++ b/app/assets/stylesheets/sections/editor.scss @@ -0,0 +1,14 @@ +.file-editor { + + #editor{ + height: 500px; + width: 90%; + position: relative; + margin-bottom: 20px; + } + textarea{ + display: block; + width: 40%; + margin: 10px 0 10px 0; + } +} diff --git a/app/views/tree/edit.html.haml b/app/views/tree/edit.html.haml index d4571f76..f9a1e6dc 100644 --- a/app/views/tree/edit.html.haml +++ b/app/views/tree/edit.html.haml @@ -1,10 +1,19 @@ -.file_holder - Edit file: +.file-editor + .file_name + File: %span.file_name = @tree.path.force_encoding('utf-8') %br = form_tag(project_tree_path(@project, @id), :method => :put) do - %textarea + #editor = @tree.data = hidden_field_tag 'last_commit', @last_commit + = hidden_field_tag 'content' + + = text_area_tag 'text_commit' = submit_tag "Save" + +:javascript + var editor = ace.edit("editor"); + editor.setTheme("ace/theme/twilight"); + editor.getSession().setMode("ace/mode/javascript"); diff --git a/vendor/assets/javascripts/ace-src-noconflict/ace.js b/vendor/assets/javascripts/ace-src-noconflict/ace.js new file mode 100644 index 00000000..11b4bbb8 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/ace.js @@ -0,0 +1,15881 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +/** + * Define a module along with a payload + * @param module a name for the payload + * @param payload a function to call with (require, exports, module) params + */ + +(function() { + +var ACE_NAMESPACE = "ace"; + +var global = (function() { + return this; +})(); + +// take care of the case when requirejs is used and we just need to patch it a little bit +if (!ACE_NAMESPACE && typeof requirejs !== "undefined") { + + var define = global.define; + global.define = function(id, deps, callback) { + if (typeof callback !== "function") + return define.apply(this, arguments); + + return ace.define(id, deps, function(require, exports, module) { + if (deps[2] == "module") + module.packaged = true; + return callback.apply(this, arguments); + }); + }; + global.define.packaged = true; + + return; +} + + +var _define = function(module, deps, payload) { + if (typeof module !== 'string') { + if (_define.original) + _define.original.apply(window, arguments); + else { + console.error('dropping module because define wasn\'t a string.'); + console.trace(); + } + return; + } + + if (arguments.length == 2) + payload = deps; + + if (!_define.modules) + _define.modules = {}; + + _define.modules[module] = payload; +}; +var _require = function(parentId, module, callback) { + if (Object.prototype.toString.call(module) === "[object Array]") { + var params = []; + for (var i = 0, l = module.length; i < l; ++i) { + var dep = lookup(parentId, module[i]); + if (!dep && _require.original) + return _require.original.apply(window, arguments); + params.push(dep); + } + if (callback) { + callback.apply(null, params); + } + } + else if (typeof module === 'string') { + var payload = lookup(parentId, module); + if (!payload && _require.original) + return _require.original.apply(window, arguments); + + if (callback) { + callback(); + } + + return payload; + } + else { + if (_require.original) + return _require.original.apply(window, arguments); + } +}; + +var normalizeModule = function(parentId, moduleName) { + // normalize plugin requires + if (moduleName.indexOf("!") !== -1) { + var chunks = moduleName.split("!"); + return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]); + } + // normalize relative requires + if (moduleName.charAt(0) == ".") { + var base = parentId.split("/").slice(0, -1).join("/"); + moduleName = base + "/" + moduleName; + + while(moduleName.indexOf(".") !== -1 && previous != moduleName) { + var previous = moduleName; + moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); + } + } + + return moduleName; +}; +var lookup = function(parentId, moduleName) { + + moduleName = normalizeModule(parentId, moduleName); + + var module = _define.modules[moduleName]; + if (!module) { + return null; + } + + if (typeof module === 'function') { + var exports = {}; + var mod = { + id: moduleName, + uri: '', + exports: exports, + packaged: true + }; + + var req = function(module, callback) { + return _require(moduleName, module, callback); + }; + + var returnValue = module(req, exports, mod); + exports = returnValue || mod.exports; + + // cache the resulting module object for next time + _define.modules[moduleName] = exports; + return exports; + } + + return module; +}; + +function exportAce(ns) { + var require = function(module, callback) { + return _require("", module, callback); + }; + + var root = global; + if (ns) { + if (!global[ns]) + global[ns] = {}; + root = global[ns]; + } + + if (!root.define || !root.define.packaged) { + _define.original = root.define; + root.define = _define; + root.define.packaged = true; + } + + if (!root.require || !root.require.packaged) { + _require.original = root.require; + root.require = require; + root.require.packaged = true; + } +} + +exportAce(ACE_NAMESPACE); + +})(); + +/** + * class Ace + * + * The main class required to set up an Ace instance in the browser. + * + * + **/ + +ace.define('ace/ace', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/lib/dom', 'ace/lib/event', 'ace/editor', 'ace/edit_session', 'ace/undomanager', 'ace/virtual_renderer', 'ace/multi_select', 'ace/worker/worker_client', 'ace/keyboard/hash_handler', 'ace/keyboard/state_handler', 'ace/placeholder', 'ace/config', 'ace/theme/textmate'], function(require, exports, module) { + + +require("./lib/fixoldbrowsers"); + +var Dom = require("./lib/dom"); +var Event = require("./lib/event"); + +var Editor = require("./editor").Editor; +var EditSession = require("./edit_session").EditSession; +var UndoManager = require("./undomanager").UndoManager; +var Renderer = require("./virtual_renderer").VirtualRenderer; +var MultiSelect = require("./multi_select").MultiSelect; + +// The following require()s are for inclusion in the built ace file +require("./worker/worker_client"); +require("./keyboard/hash_handler"); +require("./keyboard/state_handler"); +require("./placeholder"); +exports.config = require("./config"); +exports.edit = function(el) { + if (typeof(el) == "string") { + var _id = el; + if (!(el = document.getElementById(el))) { + console.log("can't match div #" + _id); + } + } + + if (el.env && el.env.editor instanceof Editor) + return el.env.editor; + + var doc = new EditSession(Dom.getInnerText(el)); + doc.setUndoManager(new UndoManager()); + el.innerHTML = ''; + + var editor = new Editor(new Renderer(el, require("./theme/textmate"))); + new MultiSelect(editor); + editor.setSession(doc); + + var env = {}; + env.document = doc; + env.editor = editor; + editor.resize(); + Event.addListener(window, "resize", function() { + editor.resize(); + }); + el.env = env; + // Store env on editor such that it can be accessed later on from + // the returned object. + editor.env = env; + return editor; +}; + +}); +// vim:set ts=4 sts=4 sw=4 st: +// -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License +// -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project) +// -- dantman Daniel Friesen Copyright(C) 2010 XXX No License Specified +// -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License +// -- Irakli Gozalishvili Copyright (C) 2010 MIT License + +/*! + Copyright (c) 2009, 280 North Inc. http://280north.com/ + MIT License. http://github.com/280north/narwhal/blob/master/README.md +*/ + +ace.define('ace/lib/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/regexp', 'ace/lib/es5-shim'], function(require, exports, module) { + + +require("./regexp"); +require("./es5-shim"); + +}); + +ace.define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, exports, module) { + + + //--------------------------------- + // Private variables + //--------------------------------- + + var real = { + exec: RegExp.prototype.exec, + test: RegExp.prototype.test, + match: String.prototype.match, + replace: String.prototype.replace, + split: String.prototype.split + }, + compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups + compliantLastIndexIncrement = function () { + var x = /^/g; + real.test.call(x, ""); + return !x.lastIndex; + }(); + + if (compliantLastIndexIncrement && compliantExecNpcg) + return; + + //--------------------------------- + // Overriden native methods + //--------------------------------- + + // Adds named capture support (with backreferences returned as `result.name`), and fixes two + // cross-browser issues per ES3: + // - Captured values for nonparticipating capturing groups should be returned as `undefined`, + // rather than the empty string. + // - `lastIndex` should not be incremented after zero-length matches. + RegExp.prototype.exec = function (str) { + var match = real.exec.apply(this, arguments), + name, r2; + if ( typeof(str) == 'string' && match) { + // Fix browsers whose `exec` methods don't consistently return `undefined` for + // nonparticipating capturing groups + if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) { + r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", "")); + // Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed + // matching due to characters outside the match + real.replace.call(str.slice(match.index), r2, function () { + for (var i = 1; i < arguments.length - 2; i++) { + if (arguments[i] === undefined) + match[i] = undefined; + } + }); + } + // Attach named capture properties + if (this._xregexp && this._xregexp.captureNames) { + for (var i = 1; i < match.length; i++) { + name = this._xregexp.captureNames[i - 1]; + if (name) + match[name] = match[i]; + } + } + // Fix browsers that increment `lastIndex` after zero-length matches + if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index)) + this.lastIndex--; + } + return match; + }; + + // Don't override `test` if it won't change anything + if (!compliantLastIndexIncrement) { + // Fix browser bug in native method + RegExp.prototype.test = function (str) { + // Use the native `exec` to skip some processing overhead, even though the overriden + // `exec` would take care of the `lastIndex` fix + var match = real.exec.call(this, str); + // Fix browsers that increment `lastIndex` after zero-length matches + if (match && this.global && !match[0].length && (this.lastIndex > match.index)) + this.lastIndex--; + return !!match; + }; + } + + //--------------------------------- + // Private helper functions + //--------------------------------- + + function getNativeFlags (regex) { + return (regex.global ? "g" : "") + + (regex.ignoreCase ? "i" : "") + + (regex.multiline ? "m" : "") + + (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3 + (regex.sticky ? "y" : ""); + } + + function indexOf (array, item, from) { + if (Array.prototype.indexOf) // Use the native array method if available + return array.indexOf(item, from); + for (var i = from || 0; i < array.length; i++) { + if (array[i] === item) + return i; + } + return -1; + } + +}); +// vim: ts=4 sts=4 sw=4 expandtab +// -- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License +// -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project) +// -- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA +// -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License +// -- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License +// -- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License +// -- kossnocorp Sasha Koss XXX TODO License or CLA +// -- bryanforbes Bryan Forbes XXX TODO License or CLA +// -- killdream Quildreen Motta Copyright (C) 2011 MIT Licence +// -- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD License +// -- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License +// -- bbqsrc Brendan Molloy (C) 2011 Creative Commons Zero (public domain) +// -- iwyg XXX TODO License or CLA +// -- DomenicDenicola Domenic Denicola Copyright (C) 2011 MIT License +// -- xavierm02 Montillet Xavier XXX TODO License or CLA +// -- Raynos Raynos XXX TODO License or CLA +// -- samsonjs Sami Samhuri Copyright (C) 2010 MIT License +// -- rwldrn Rick Waldron Copyright (C) 2011 MIT License +// -- lexer Alexey Zakharov XXX TODO License or CLA + +/*! + Copyright (c) 2009, 280 North Inc. http://280north.com/ + MIT License. http://github.com/280north/narwhal/blob/master/README.md +*/ + +ace.define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) { + +/* + * Brings an environment as close to ECMAScript 5 compliance + * as is possible with the facilities of erstwhile engines. + * + * Annotated ES5: http://es5.github.com/ (specific links below) + * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf + * + * @module + */ + +/*whatsupdoc*/ + +// +// Function +// ======== +// + +// ES-5 15.3.4.5 +// http://es5.github.com/#x15.3.4.5 + +if (!Function.prototype.bind) { + Function.prototype.bind = function bind(that) { // .length is 1 + // 1. Let Target be the this value. + var target = this; + // 2. If IsCallable(Target) is false, throw a TypeError exception. + if (typeof target != "function") + throw new TypeError(); // TODO message + // 3. Let A be a new (possibly empty) internal list of all of the + // argument values provided after thisArg (arg1, arg2 etc), in order. + // XXX slicedArgs will stand in for "A" if used + var args = slice.call(arguments, 1); // for normal call + // 4. Let F be a new native ECMAScript object. + // 11. Set the [[Prototype]] internal property of F to the standard + // built-in Function prototype object as specified in 15.3.3.1. + // 12. Set the [[Call]] internal property of F as described in + // 15.3.4.5.1. + // 13. Set the [[Construct]] internal property of F as described in + // 15.3.4.5.2. + // 14. Set the [[HasInstance]] internal property of F as described in + // 15.3.4.5.3. + var bound = function () { + + if (this instanceof bound) { + // 15.3.4.5.2 [[Construct]] + // When the [[Construct]] internal method of a function object, + // F that was created using the bind function is called with a + // list of arguments ExtraArgs, the following steps are taken: + // 1. Let target be the value of F's [[TargetFunction]] + // internal property. + // 2. If target has no [[Construct]] internal method, a + // TypeError exception is thrown. + // 3. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Construct]] internal + // method of target providing args as the arguments. + + var F = function(){}; + F.prototype = target.prototype; + var self = new F; + + var result = target.apply( + self, + args.concat(slice.call(arguments)) + ); + if (result !== null && Object(result) === result) + return result; + return self; + + } else { + // 15.3.4.5.1 [[Call]] + // When the [[Call]] internal method of a function object, F, + // which was created using the bind function is called with a + // this value and a list of arguments ExtraArgs, the following + // steps are taken: + // 1. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 2. Let boundThis be the value of F's [[BoundThis]] internal + // property. + // 3. Let target be the value of F's [[TargetFunction]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Call]] internal method + // of target providing boundThis as the this value and + // providing args as the arguments. + + // equiv: target.call(this, ...boundArgs, ...args) + return target.apply( + that, + args.concat(slice.call(arguments)) + ); + + } + + }; + // XXX bound.length is never writable, so don't even try + // + // 15. If the [[Class]] internal property of Target is "Function", then + // a. Let L be the length property of Target minus the length of A. + // b. Set the length own property of F to either 0 or L, whichever is + // larger. + // 16. Else set the length own property of F to 0. + // 17. Set the attributes of the length own property of F to the values + // specified in 15.3.5.1. + + // TODO + // 18. Set the [[Extensible]] internal property of F to true. + + // TODO + // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3). + // 20. Call the [[DefineOwnProperty]] internal method of F with + // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]: + // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and + // false. + // 21. Call the [[DefineOwnProperty]] internal method of F with + // arguments "arguments", PropertyDescriptor {[[Get]]: thrower, + // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false}, + // and false. + + // TODO + // NOTE Function objects created using Function.prototype.bind do not + // have a prototype property or the [[Code]], [[FormalParameters]], and + // [[Scope]] internal properties. + // XXX can't delete prototype in pure-js. + + // 22. Return F. + return bound; + }; +} + +// Shortcut to an often accessed properties, in order to avoid multiple +// dereference that costs universally. +// _Please note: Shortcuts are defined after `Function.prototype.bind` as we +// us it in defining shortcuts. +var call = Function.prototype.call; +var prototypeOfArray = Array.prototype; +var prototypeOfObject = Object.prototype; +var slice = prototypeOfArray.slice; +var toString = call.bind(prototypeOfObject.toString); +var owns = call.bind(prototypeOfObject.hasOwnProperty); + +// If JS engine supports accessors creating shortcuts. +var defineGetter; +var defineSetter; +var lookupGetter; +var lookupSetter; +var supportsAccessors; +if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) { + defineGetter = call.bind(prototypeOfObject.__defineGetter__); + defineSetter = call.bind(prototypeOfObject.__defineSetter__); + lookupGetter = call.bind(prototypeOfObject.__lookupGetter__); + lookupSetter = call.bind(prototypeOfObject.__lookupSetter__); +} + +// +// Array +// ===== +// + +// ES5 15.4.3.2 +// http://es5.github.com/#x15.4.3.2 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray +if (!Array.isArray) { + Array.isArray = function isArray(obj) { + return toString(obj) == "[object Array]"; + }; +} + +// The IsCallable() check in the Array functions +// has been replaced with a strict check on the +// internal class of the object to trap cases where +// the provided function was actually a regular +// expression literal, which in V8 and +// JavaScriptCore is a typeof "function". Only in +// V8 are regular expression literals permitted as +// reduce parameters, so it is desirable in the +// general case for the shim to match the more +// strict and common behavior of rejecting regular +// expressions. + +// ES5 15.4.4.18 +// http://es5.github.com/#x15.4.4.18 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach +if (!Array.prototype.forEach) { + Array.prototype.forEach = function forEach(fun /*, thisp*/) { + var self = toObject(this), + thisp = arguments[1], + i = 0, + length = self.length >>> 0; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + while (i < length) { + if (i in self) { + // Invoke the callback function with call, passing arguments: + // context, property value, property key, thisArg object context + fun.call(thisp, self[i], i, self); + } + i++; + } + }; +} + +// ES5 15.4.4.19 +// http://es5.github.com/#x15.4.4.19 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map +if (!Array.prototype.map) { + Array.prototype.map = function map(fun /*, thisp*/) { + var self = toObject(this), + length = self.length >>> 0, + result = Array(length), + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + for (var i = 0; i < length; i++) { + if (i in self) + result[i] = fun.call(thisp, self[i], i, self); + } + return result; + }; +} + +// ES5 15.4.4.20 +// http://es5.github.com/#x15.4.4.20 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter +if (!Array.prototype.filter) { + Array.prototype.filter = function filter(fun /*, thisp */) { + var self = toObject(this), + length = self.length >>> 0, + result = [], + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + for (var i = 0; i < length; i++) { + if (i in self && fun.call(thisp, self[i], i, self)) + result.push(self[i]); + } + return result; + }; +} + +// ES5 15.4.4.16 +// http://es5.github.com/#x15.4.4.16 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every +if (!Array.prototype.every) { + Array.prototype.every = function every(fun /*, thisp */) { + var self = toObject(this), + length = self.length >>> 0, + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + for (var i = 0; i < length; i++) { + if (i in self && !fun.call(thisp, self[i], i, self)) + return false; + } + return true; + }; +} + +// ES5 15.4.4.17 +// http://es5.github.com/#x15.4.4.17 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some +if (!Array.prototype.some) { + Array.prototype.some = function some(fun /*, thisp */) { + var self = toObject(this), + length = self.length >>> 0, + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + for (var i = 0; i < length; i++) { + if (i in self && fun.call(thisp, self[i], i, self)) + return true; + } + return false; + }; +} + +// ES5 15.4.4.21 +// http://es5.github.com/#x15.4.4.21 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce +if (!Array.prototype.reduce) { + Array.prototype.reduce = function reduce(fun /*, initial*/) { + var self = toObject(this), + length = self.length >>> 0; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + // no value to return if no initial value and an empty array + if (!length && arguments.length == 1) + throw new TypeError(); // TODO message + + var i = 0; + var result; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i++]; + break; + } + + // if array contains no values, no initial value to return + if (++i >= length) + throw new TypeError(); // TODO message + } while (true); + } + + for (; i < length; i++) { + if (i in self) + result = fun.call(void 0, result, self[i], i, self); + } + + return result; + }; +} + +// ES5 15.4.4.22 +// http://es5.github.com/#x15.4.4.22 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight +if (!Array.prototype.reduceRight) { + Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) { + var self = toObject(this), + length = self.length >>> 0; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + // no value to return if no initial value, empty array + if (!length && arguments.length == 1) + throw new TypeError(); // TODO message + + var result, i = length - 1; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i--]; + break; + } + + // if array contains no values, no initial value to return + if (--i < 0) + throw new TypeError(); // TODO message + } while (true); + } + + do { + if (i in this) + result = fun.call(void 0, result, self[i], i, self); + } while (i--); + + return result; + }; +} + +// ES5 15.4.4.14 +// http://es5.github.com/#x15.4.4.14 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf +if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) { + var self = toObject(this), + length = self.length >>> 0; + + if (!length) + return -1; + + var i = 0; + if (arguments.length > 1) + i = toInteger(arguments[1]); + + // handle negative indices + i = i >= 0 ? i : Math.max(0, length + i); + for (; i < length; i++) { + if (i in self && self[i] === sought) { + return i; + } + } + return -1; + }; +} + +// ES5 15.4.4.15 +// http://es5.github.com/#x15.4.4.15 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf +if (!Array.prototype.lastIndexOf) { + Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) { + var self = toObject(this), + length = self.length >>> 0; + + if (!length) + return -1; + var i = length - 1; + if (arguments.length > 1) + i = Math.min(i, toInteger(arguments[1])); + // handle negative indices + i = i >= 0 ? i : length - Math.abs(i); + for (; i >= 0; i--) { + if (i in self && sought === self[i]) + return i; + } + return -1; + }; +} + +// +// Object +// ====== +// + +// ES5 15.2.3.2 +// http://es5.github.com/#x15.2.3.2 +if (!Object.getPrototypeOf) { + // https://github.com/kriskowal/es5-shim/issues#issue/2 + // http://ejohn.org/blog/objectgetprototypeof/ + // recommended by fschaefer on github + Object.getPrototypeOf = function getPrototypeOf(object) { + return object.__proto__ || ( + object.constructor ? + object.constructor.prototype : + prototypeOfObject + ); + }; +} + +// ES5 15.2.3.3 +// http://es5.github.com/#x15.2.3.3 +if (!Object.getOwnPropertyDescriptor) { + var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " + + "non-object: "; + Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) { + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError(ERR_NON_OBJECT + object); + // If object does not owns property return undefined immediately. + if (!owns(object, property)) + return; + + var descriptor, getter, setter; + + // If object has a property then it's for sure both `enumerable` and + // `configurable`. + descriptor = { enumerable: true, configurable: true }; + + // If JS engine supports accessor properties then property may be a + // getter or setter. + if (supportsAccessors) { + // Unfortunately `__lookupGetter__` will return a getter even + // if object has own non getter property along with a same named + // inherited getter. To avoid misbehavior we temporary remove + // `__proto__` so that `__lookupGetter__` will return getter only + // if it's owned by an object. + var prototype = object.__proto__; + object.__proto__ = prototypeOfObject; + + var getter = lookupGetter(object, property); + var setter = lookupSetter(object, property); + + // Once we have getter and setter we can put values back. + object.__proto__ = prototype; + + if (getter || setter) { + if (getter) descriptor.get = getter; + if (setter) descriptor.set = setter; + + // If it was accessor property we're done and return here + // in order to avoid adding `value` to the descriptor. + return descriptor; + } + } + + // If we got this far we know that object has an own property that is + // not an accessor so we set it as a value and return descriptor. + descriptor.value = object[property]; + return descriptor; + }; +} + +// ES5 15.2.3.4 +// http://es5.github.com/#x15.2.3.4 +if (!Object.getOwnPropertyNames) { + Object.getOwnPropertyNames = function getOwnPropertyNames(object) { + return Object.keys(object); + }; +} + +// ES5 15.2.3.5 +// http://es5.github.com/#x15.2.3.5 +if (!Object.create) { + Object.create = function create(prototype, properties) { + var object; + if (prototype === null) { + object = { "__proto__": null }; + } else { + if (typeof prototype != "object") + throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'"); + var Type = function () {}; + Type.prototype = prototype; + object = new Type(); + // IE has no built-in implementation of `Object.getPrototypeOf` + // neither `__proto__`, but this manually setting `__proto__` will + // guarantee that `Object.getPrototypeOf` will work as expected with + // objects created using `Object.create` + object.__proto__ = prototype; + } + if (properties !== void 0) + Object.defineProperties(object, properties); + return object; + }; +} + +// ES5 15.2.3.6 +// http://es5.github.com/#x15.2.3.6 + +// Patch for WebKit and IE8 standard mode +// Designed by hax +// related issue: https://github.com/kriskowal/es5-shim/issues#issue/5 +// IE8 Reference: +// http://msdn.microsoft.com/en-us/library/dd282900.aspx +// http://msdn.microsoft.com/en-us/library/dd229916.aspx +// WebKit Bugs: +// https://bugs.webkit.org/show_bug.cgi?id=36423 + +function doesDefinePropertyWork(object) { + try { + Object.defineProperty(object, "sentinel", {}); + return "sentinel" in object; + } catch (exception) { + // returns falsy + } +} + +// check whether defineProperty works if it's given. Otherwise, +// shim partially. +if (Object.defineProperty) { + var definePropertyWorksOnObject = doesDefinePropertyWork({}); + var definePropertyWorksOnDom = typeof document == "undefined" || + doesDefinePropertyWork(document.createElement("div")); + if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) { + var definePropertyFallback = Object.defineProperty; + } +} + +if (!Object.defineProperty || definePropertyFallback) { + var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: "; + var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: " + var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " + + "on this javascript engine"; + + Object.defineProperty = function defineProperty(object, property, descriptor) { + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError(ERR_NON_OBJECT_TARGET + object); + if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null) + throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor); + + // make a valiant attempt to use the real defineProperty + // for I8's DOM elements. + if (definePropertyFallback) { + try { + return definePropertyFallback.call(Object, object, property, descriptor); + } catch (exception) { + // try the shim if the real one doesn't work + } + } + + // If it's a data property. + if (owns(descriptor, "value")) { + // fail silently if "writable", "enumerable", or "configurable" + // are requested but not supported + /* + // alternate approach: + if ( // can't implement these features; allow false but not true + !(owns(descriptor, "writable") ? descriptor.writable : true) || + !(owns(descriptor, "enumerable") ? descriptor.enumerable : true) || + !(owns(descriptor, "configurable") ? descriptor.configurable : true) + ) + throw new RangeError( + "This implementation of Object.defineProperty does not " + + "support configurable, enumerable, or writable." + ); + */ + + if (supportsAccessors && (lookupGetter(object, property) || + lookupSetter(object, property))) + { + // As accessors are supported only on engines implementing + // `__proto__` we can safely override `__proto__` while defining + // a property to make sure that we don't hit an inherited + // accessor. + var prototype = object.__proto__; + object.__proto__ = prototypeOfObject; + // Deleting a property anyway since getter / setter may be + // defined on object itself. + delete object[property]; + object[property] = descriptor.value; + // Setting original `__proto__` back now. + object.__proto__ = prototype; + } else { + object[property] = descriptor.value; + } + } else { + if (!supportsAccessors) + throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED); + // If we got that far then getters and setters can be defined !! + if (owns(descriptor, "get")) + defineGetter(object, property, descriptor.get); + if (owns(descriptor, "set")) + defineSetter(object, property, descriptor.set); + } + + return object; + }; +} + +// ES5 15.2.3.7 +// http://es5.github.com/#x15.2.3.7 +if (!Object.defineProperties) { + Object.defineProperties = function defineProperties(object, properties) { + for (var property in properties) { + if (owns(properties, property)) + Object.defineProperty(object, property, properties[property]); + } + return object; + }; +} + +// ES5 15.2.3.8 +// http://es5.github.com/#x15.2.3.8 +if (!Object.seal) { + Object.seal = function seal(object) { + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; +} + +// ES5 15.2.3.9 +// http://es5.github.com/#x15.2.3.9 +if (!Object.freeze) { + Object.freeze = function freeze(object) { + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; +} + +// detect a Rhino bug and patch it +try { + Object.freeze(function () {}); +} catch (exception) { + Object.freeze = (function freeze(freezeObject) { + return function freeze(object) { + if (typeof object == "function") { + return object; + } else { + return freezeObject(object); + } + }; + })(Object.freeze); +} + +// ES5 15.2.3.10 +// http://es5.github.com/#x15.2.3.10 +if (!Object.preventExtensions) { + Object.preventExtensions = function preventExtensions(object) { + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; +} + +// ES5 15.2.3.11 +// http://es5.github.com/#x15.2.3.11 +if (!Object.isSealed) { + Object.isSealed = function isSealed(object) { + return false; + }; +} + +// ES5 15.2.3.12 +// http://es5.github.com/#x15.2.3.12 +if (!Object.isFrozen) { + Object.isFrozen = function isFrozen(object) { + return false; + }; +} + +// ES5 15.2.3.13 +// http://es5.github.com/#x15.2.3.13 +if (!Object.isExtensible) { + Object.isExtensible = function isExtensible(object) { + // 1. If Type(O) is not Object throw a TypeError exception. + if (Object(object) === object) { + throw new TypeError(); // TODO message + } + // 2. Return the Boolean value of the [[Extensible]] internal property of O. + var name = ''; + while (owns(object, name)) { + name += '?'; + } + object[name] = true; + var returnValue = owns(object, name); + delete object[name]; + return returnValue; + }; +} + +// ES5 15.2.3.14 +// http://es5.github.com/#x15.2.3.14 +if (!Object.keys) { + // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation + var hasDontEnumBug = true, + dontEnums = [ + "toString", + "toLocaleString", + "valueOf", + "hasOwnProperty", + "isPrototypeOf", + "propertyIsEnumerable", + "constructor" + ], + dontEnumsLength = dontEnums.length; + + for (var key in {"toString": null}) + hasDontEnumBug = false; + + Object.keys = function keys(object) { + + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError("Object.keys called on a non-object"); + + var keys = []; + for (var name in object) { + if (owns(object, name)) { + keys.push(name); + } + } + + if (hasDontEnumBug) { + for (var i = 0, ii = dontEnumsLength; i < ii; i++) { + var dontEnum = dontEnums[i]; + if (owns(object, dontEnum)) { + keys.push(dontEnum); + } + } + } + + return keys; + }; + +} + +// +// Date +// ==== +// + +// ES5 15.9.5.43 +// http://es5.github.com/#x15.9.5.43 +// This function returns a String value represent the instance in time +// represented by this Date object. The format of the String is the Date Time +// string format defined in 15.9.1.15. All fields are present in the String. +// The time zone is always UTC, denoted by the suffix Z. If the time value of +// this object is not a finite Number a RangeError exception is thrown. +if (!Date.prototype.toISOString || (new Date(-62198755200000).toISOString().indexOf('-000001') === -1)) { + Date.prototype.toISOString = function toISOString() { + var result, length, value, year; + if (!isFinite(this)) + throw new RangeError; + + // the date time string format is specified in 15.9.1.15. + result = [this.getUTCMonth() + 1, this.getUTCDate(), + this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()]; + year = this.getUTCFullYear(); + year = (year < 0 ? '-' : (year > 9999 ? '+' : '')) + ('00000' + Math.abs(year)).slice(0 <= year && year <= 9999 ? -4 : -6); + + length = result.length; + while (length--) { + value = result[length]; + // pad months, days, hours, minutes, and seconds to have two digits. + if (value < 10) + result[length] = "0" + value; + } + // pad milliseconds to have three digits. + return year + "-" + result.slice(0, 2).join("-") + "T" + result.slice(2).join(":") + "." + + ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"; + } +} + +// ES5 15.9.4.4 +// http://es5.github.com/#x15.9.4.4 +if (!Date.now) { + Date.now = function now() { + return new Date().getTime(); + }; +} + +// ES5 15.9.5.44 +// http://es5.github.com/#x15.9.5.44 +// This function provides a String representation of a Date object for use by +// JSON.stringify (15.12.3). +if (!Date.prototype.toJSON) { + Date.prototype.toJSON = function toJSON(key) { + // When the toJSON method is called with argument key, the following + // steps are taken: + + // 1. Let O be the result of calling ToObject, giving it the this + // value as its argument. + // 2. Let tv be ToPrimitive(O, hint Number). + // 3. If tv is a Number and is not finite, return null. + // XXX + // 4. Let toISO be the result of calling the [[Get]] internal method of + // O with argument "toISOString". + // 5. If IsCallable(toISO) is false, throw a TypeError exception. + if (typeof this.toISOString != "function") + throw new TypeError(); // TODO message + // 6. Return the result of calling the [[Call]] internal method of + // toISO with O as the this value and an empty argument list. + return this.toISOString(); + + // NOTE 1 The argument is ignored. + + // NOTE 2 The toJSON function is intentionally generic; it does not + // require that its this value be a Date object. Therefore, it can be + // transferred to other kinds of objects for use as a method. However, + // it does require that any such object have a toISOString method. An + // object is free to use the argument key to filter its + // stringification. + }; +} + +// ES5 15.9.4.2 +// http://es5.github.com/#x15.9.4.2 +// based on work shared by Daniel Friesen (dantman) +// http://gist.github.com/303249 +if (Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) { + // XXX global assignment won't work in embeddings that use + // an alternate object for the context. + Date = (function(NativeDate) { + + // Date.length === 7 + var Date = function Date(Y, M, D, h, m, s, ms) { + var length = arguments.length; + if (this instanceof NativeDate) { + var date = length == 1 && String(Y) === Y ? // isString(Y) + // We explicitly pass it through parse: + new NativeDate(Date.parse(Y)) : + // We have to manually make calls depending on argument + // length here + length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) : + length >= 6 ? new NativeDate(Y, M, D, h, m, s) : + length >= 5 ? new NativeDate(Y, M, D, h, m) : + length >= 4 ? new NativeDate(Y, M, D, h) : + length >= 3 ? new NativeDate(Y, M, D) : + length >= 2 ? new NativeDate(Y, M) : + length >= 1 ? new NativeDate(Y) : + new NativeDate(); + // Prevent mixups with unfixed Date object + date.constructor = Date; + return date; + } + return NativeDate.apply(this, arguments); + }; + + // 15.9.1.15 Date Time String Format. + var isoDateExpression = new RegExp("^" + + "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign + 6-digit extended year + "(?:-(\\d{2})" + // optional month capture + "(?:-(\\d{2})" + // optional day capture + "(?:" + // capture hours:minutes:seconds.milliseconds + "T(\\d{2})" + // hours capture + ":(\\d{2})" + // minutes capture + "(?:" + // optional :seconds.milliseconds + ":(\\d{2})" + // seconds capture + "(?:\\.(\\d{3}))?" + // milliseconds capture + ")?" + + "(?:" + // capture UTC offset component + "Z|" + // UTC capture + "(?:" + // offset specifier +/-hours:minutes + "([-+])" + // sign capture + "(\\d{2})" + // hours offset capture + ":(\\d{2})" + // minutes offset capture + ")" + + ")?)?)?)?" + + "$"); + + // Copy any custom methods a 3rd party library may have added + for (var key in NativeDate) + Date[key] = NativeDate[key]; + + // Copy "native" methods explicitly; they may be non-enumerable + Date.now = NativeDate.now; + Date.UTC = NativeDate.UTC; + Date.prototype = NativeDate.prototype; + Date.prototype.constructor = Date; + + // Upgrade Date.parse to handle simplified ISO 8601 strings + Date.parse = function parse(string) { + var match = isoDateExpression.exec(string); + if (match) { + match.shift(); // kill match[0], the full match + // parse months, days, hours, minutes, seconds, and milliseconds + for (var i = 1; i < 7; i++) { + // provide default values if necessary + match[i] = +(match[i] || (i < 3 ? 1 : 0)); + // match[1] is the month. Months are 0-11 in JavaScript + // `Date` objects, but 1-12 in ISO notation, so we + // decrement. + if (i == 1) + match[i]--; + } + + // parse the UTC offset component + var minuteOffset = +match.pop(), hourOffset = +match.pop(), sign = match.pop(); + + // compute the explicit time zone offset if specified + var offset = 0; + if (sign) { + // detect invalid offsets and return early + if (hourOffset > 23 || minuteOffset > 59) + return NaN; + + // express the provided time zone offset in minutes. The offset is + // negative for time zones west of UTC; positive otherwise. + offset = (hourOffset * 60 + minuteOffset) * 6e4 * (sign == "+" ? -1 : 1); + } + + // Date.UTC for years between 0 and 99 converts year to 1900 + year + // The Gregorian calendar has a 400-year cycle, so + // to Date.UTC(year + 400, .... ) - 12622780800000 == Date.UTC(year, ...), + // where 12622780800000 - number of milliseconds in Gregorian calendar 400 years + var year = +match[0]; + if (0 <= year && year <= 99) { + match[0] = year + 400; + return NativeDate.UTC.apply(this, match) + offset - 12622780800000; + } + + // compute a new UTC date value, accounting for the optional offset + return NativeDate.UTC.apply(this, match) + offset; + } + return NativeDate.parse.apply(this, arguments); + }; + + return Date; + })(Date); +} + +// +// String +// ====== +// + +// ES5 15.5.4.20 +// http://es5.github.com/#x15.5.4.20 +var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" + + "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" + + "\u2029\uFEFF"; +if (!String.prototype.trim || ws.trim()) { + // http://blog.stevenlevithan.com/archives/faster-trim-javascript + // http://perfectionkills.com/whitespace-deviations/ + ws = "[" + ws + "]"; + var trimBeginRegexp = new RegExp("^" + ws + ws + "*"), + trimEndRegexp = new RegExp(ws + ws + "*$"); + String.prototype.trim = function trim() { + return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, ""); + }; +} + +// +// Util +// ====== +// + +// ES5 9.4 +// http://es5.github.com/#x9.4 +// http://jsperf.com/to-integer +var toInteger = function (n) { + n = +n; + if (n !== n) // isNaN + n = 0; + else if (n !== 0 && n !== (1/0) && n !== -(1/0)) + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + return n; +}; + +var prepareString = "a"[0] != "a", + // ES5 9.9 + // http://es5.github.com/#x9.9 + toObject = function (o) { + if (o == null) { // this matches both null and undefined + throw new TypeError(); // TODO message + } + // If the implementation doesn't support by-index access of + // string characters (ex. IE < 7), split the string + if (prepareString && typeof o == "string" && o) { + return o.split(""); + } + return Object(o); + }; +}); + +ace.define('ace/lib/dom', ['require', 'exports', 'module' ], function(require, exports, module) { + + +var XHTML_NS = "http://www.w3.org/1999/xhtml"; + +exports.createElement = function(tag, ns) { + return document.createElementNS ? + document.createElementNS(ns || XHTML_NS, tag) : + document.createElement(tag); +}; + +exports.setText = function(elem, text) { + if (elem.innerText !== undefined) { + elem.innerText = text; + } + if (elem.textContent !== undefined) { + elem.textContent = text; + } +}; + +exports.hasCssClass = function(el, name) { + var classes = el.className.split(/\s+/g); + return classes.indexOf(name) !== -1; +}; +exports.addCssClass = function(el, name) { + if (!exports.hasCssClass(el, name)) { + el.className += " " + name; + } +}; +exports.removeCssClass = function(el, name) { + var classes = el.className.split(/\s+/g); + while (true) { + var index = classes.indexOf(name); + if (index == -1) { + break; + } + classes.splice(index, 1); + } + el.className = classes.join(" "); +}; + +exports.toggleCssClass = function(el, name) { + var classes = el.className.split(/\s+/g), add = true; + while (true) { + var index = classes.indexOf(name); + if (index == -1) { + break; + } + add = false; + classes.splice(index, 1); + } + if(add) + classes.push(name); + + el.className = classes.join(" "); + return add; +}; +exports.setCssClass = function(node, className, include) { + if (include) { + exports.addCssClass(node, className); + } else { + exports.removeCssClass(node, className); + } +}; + +exports.hasCssString = function(id, doc) { + var index = 0, sheets; + doc = doc || document; + + if (doc.createStyleSheet && (sheets = doc.styleSheets)) { + while (index < sheets.length) + if (sheets[index++].owningElement.id === id) return true; + } else if ((sheets = doc.getElementsByTagName("style"))) { + while (index < sheets.length) + if (sheets[index++].id === id) return true; + } + + return false; +}; + +exports.importCssString = function importCssString(cssText, id, doc) { + doc = doc || document; + // If style is already imported return immediately. + if (id && exports.hasCssString(id, doc)) + return null; + + var style; + + if (doc.createStyleSheet) { + style = doc.createStyleSheet(); + style.cssText = cssText; + if (id) + style.owningElement.id = id; + } else { + style = doc.createElementNS + ? doc.createElementNS(XHTML_NS, "style") + : doc.createElement("style"); + + style.appendChild(doc.createTextNode(cssText)); + if (id) + style.id = id; + + var head = doc.getElementsByTagName("head")[0] || doc.documentElement; + head.appendChild(style); + } +}; + +exports.importCssStylsheet = function(uri, doc) { + if (doc.createStyleSheet) { + doc.createStyleSheet(uri); + } else { + var link = exports.createElement('link'); + link.rel = 'stylesheet'; + link.href = uri; + + var head = doc.getElementsByTagName("head")[0] || doc.documentElement; + head.appendChild(link); + } +}; + +exports.getInnerWidth = function(element) { + return ( + parseInt(exports.computedStyle(element, "paddingLeft"), 10) + + parseInt(exports.computedStyle(element, "paddingRight"), 10) + + element.clientWidth + ); +}; + +exports.getInnerHeight = function(element) { + return ( + parseInt(exports.computedStyle(element, "paddingTop"), 10) + + parseInt(exports.computedStyle(element, "paddingBottom"), 10) + + element.clientHeight + ); +}; + +if (window.pageYOffset !== undefined) { + exports.getPageScrollTop = function() { + return window.pageYOffset; + }; + + exports.getPageScrollLeft = function() { + return window.pageXOffset; + }; +} +else { + exports.getPageScrollTop = function() { + return document.body.scrollTop; + }; + + exports.getPageScrollLeft = function() { + return document.body.scrollLeft; + }; +} + +if (window.getComputedStyle) + exports.computedStyle = function(element, style) { + if (style) + return (window.getComputedStyle(element, "") || {})[style] || ""; + return window.getComputedStyle(element, "") || {}; + }; +else + exports.computedStyle = function(element, style) { + if (style) + return element.currentStyle[style]; + return element.currentStyle; + }; + +exports.scrollbarWidth = function(document) { + + var inner = exports.createElement("p"); + inner.style.width = "100%"; + inner.style.minWidth = "0px"; + inner.style.height = "200px"; + + var outer = exports.createElement("div"); + var style = outer.style; + + style.position = "absolute"; + style.left = "-10000px"; + style.overflow = "hidden"; + style.width = "200px"; + style.minWidth = "0px"; + style.height = "150px"; + + outer.appendChild(inner); + + var body = document.body || document.documentElement; + body.appendChild(outer); + + var noScrollbar = inner.offsetWidth; + + style.overflow = "scroll"; + var withScrollbar = inner.offsetWidth; + + if (noScrollbar == withScrollbar) { + withScrollbar = outer.clientWidth; + } + + body.removeChild(outer); + + return noScrollbar-withScrollbar; +}; +exports.setInnerHtml = function(el, innerHtml) { + var element = el.cloneNode(false);//document.createElement("div"); + element.innerHTML = innerHtml; + el.parentNode.replaceChild(element, el); + return element; +}; + +exports.setInnerText = function(el, innerText) { + var document = el.ownerDocument; + if (document.body && "textContent" in document.body) + el.textContent = innerText; + else + el.innerText = innerText; + +}; + +exports.getInnerText = function(el) { + var document = el.ownerDocument; + if (document.body && "textContent" in document.body) + return el.textContent; + else + return el.innerText || el.textContent || ""; +}; + +exports.getParentWindow = function(document) { + return document.defaultView || document.parentWindow; +}; + +}); + +ace.define('ace/lib/event', ['require', 'exports', 'module' , 'ace/lib/keys', 'ace/lib/useragent', 'ace/lib/dom'], function(require, exports, module) { + + +var keys = require("./keys"); +var useragent = require("./useragent"); +var dom = require("./dom"); + +exports.addListener = function(elem, type, callback) { + if (elem.addEventListener) { + return elem.addEventListener(type, callback, false); + } + if (elem.attachEvent) { + var wrapper = function() { + callback(window.event); + }; + callback._wrapper = wrapper; + elem.attachEvent("on" + type, wrapper); + } +}; + +exports.removeListener = function(elem, type, callback) { + if (elem.removeEventListener) { + return elem.removeEventListener(type, callback, false); + } + if (elem.detachEvent) { + elem.detachEvent("on" + type, callback._wrapper || callback); + } +}; +exports.stopEvent = function(e) { + exports.stopPropagation(e); + exports.preventDefault(e); + return false; +}; + +exports.stopPropagation = function(e) { + if (e.stopPropagation) + e.stopPropagation(); + else + e.cancelBubble = true; +}; + +exports.preventDefault = function(e) { + if (e.preventDefault) + e.preventDefault(); + else + e.returnValue = false; +}; +exports.getButton = function(e) { + if (e.type == "dblclick") + return 0; + if (e.type == "contextmenu" || (e.ctrlKey && useragent.isMac)) + return 2; + + // DOM Event + if (e.preventDefault) { + return e.button; + } + // old IE + else { + return {1:0, 2:2, 4:1}[e.button]; + } +}; + +if (document.documentElement.setCapture) { + exports.capture = function(el, eventHandler, releaseCaptureHandler) { + var called = false; + function onReleaseCapture(e) { + eventHandler(e); + + if (!called) { + called = true; + releaseCaptureHandler(e); + } + + exports.removeListener(el, "mousemove", eventHandler); + exports.removeListener(el, "mouseup", onReleaseCapture); + exports.removeListener(el, "losecapture", onReleaseCapture); + + el.releaseCapture(); + } + + exports.addListener(el, "mousemove", eventHandler); + exports.addListener(el, "mouseup", onReleaseCapture); + exports.addListener(el, "losecapture", onReleaseCapture); + el.setCapture(); + }; +} +else { + exports.capture = function(el, eventHandler, releaseCaptureHandler) { + function onMouseUp(e) { + eventHandler && eventHandler(e); + releaseCaptureHandler && releaseCaptureHandler(e); + + document.removeEventListener("mousemove", eventHandler, true); + document.removeEventListener("mouseup", onMouseUp, true); + + e.stopPropagation(); + } + + document.addEventListener("mousemove", eventHandler, true); + document.addEventListener("mouseup", onMouseUp, true); + }; +} + +exports.addMouseWheelListener = function(el, callback) { + var factor = 8; + var listener = function(e) { + if (e.wheelDelta !== undefined) { + if (e.wheelDeltaX !== undefined) { + e.wheelX = -e.wheelDeltaX / factor; + e.wheelY = -e.wheelDeltaY / factor; + } else { + e.wheelX = 0; + e.wheelY = -e.wheelDelta / factor; + } + } + else { + if (e.axis && e.axis == e.HORIZONTAL_AXIS) { + e.wheelX = (e.detail || 0) * 5; + e.wheelY = 0; + } else { + e.wheelX = 0; + e.wheelY = (e.detail || 0) * 5; + } + } + callback(e); + }; + exports.addListener(el, "DOMMouseScroll", listener); + exports.addListener(el, "mousewheel", listener); +}; + +exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbackName) { + var clicks = 0; + var startX, startY, timer; + var eventNames = { + 2: "dblclick", + 3: "tripleclick", + 4: "quadclick" + }; + + exports.addListener(el, "mousedown", function(e) { + if (exports.getButton(e) != 0) { + clicks = 0; + } else { + var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5; + + if (!timer || isNewClick) + clicks = 0; + + clicks += 1; + + if (timer) + clearTimeout(timer) + timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600); + } + if (clicks == 1) { + startX = e.clientX; + startY = e.clientY; + } + + eventHandler[callbackName]("mousedown", e); + + if (clicks > 4) + clicks = 0; + else if (clicks > 1) + return eventHandler[callbackName](eventNames[clicks], e); + }); + + if (useragent.isOldIE) { + exports.addListener(el, "dblclick", function(e) { + clicks = 2; + if (timer) + clearTimeout(timer); + timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600); + eventHandler[callbackName]("mousedown", e); + eventHandler[callbackName](eventNames[clicks], e); + }); + } +}; + +function normalizeCommandKeys(callback, e, keyCode) { + var hashId = 0; + if ((useragent.isOpera && !("KeyboardEvent" in window)) && useragent.isMac) { + hashId = 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0) + | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0); + } else { + hashId = 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) + | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0); + } + + if (keyCode in keys.MODIFIER_KEYS) { + switch (keys.MODIFIER_KEYS[keyCode]) { + case "Alt": + hashId = 2; + break; + case "Shift": + hashId = 4; + break; + case "Ctrl": + hashId = 1; + break; + default: + hashId = 8; + break; + } + keyCode = 0; + } + + if (hashId & 8 && (keyCode == 91 || keyCode == 93)) { + keyCode = 0; + } + + // If there is no hashID and the keyCode is not a function key, then + // we don't call the callback as we don't handle a command key here + // (it's a normal key/character input). + if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) { + return false; + } + return callback(e, hashId, keyCode); +} + +exports.addCommandKeyListener = function(el, callback) { + var addListener = exports.addListener; + if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) { + // Old versions of Gecko aka. Firefox < 4.0 didn't repeat the keydown + // event if the user pressed the key for a longer time. Instead, the + // keydown event was fired once and later on only the keypress event. + // To emulate the 'right' keydown behavior, the keyCode of the initial + // keyDown event is stored and in the following keypress events the + // stores keyCode is used to emulate a keyDown event. + var lastKeyDownKeyCode = null; + addListener(el, "keydown", function(e) { + lastKeyDownKeyCode = e.keyCode; + }); + addListener(el, "keypress", function(e) { + return normalizeCommandKeys(callback, e, lastKeyDownKeyCode); + }); + } else { + var lastDown = null; + + addListener(el, "keydown", function(e) { + lastDown = e.keyIdentifier || e.keyCode; + return normalizeCommandKeys(callback, e, e.keyCode); + }); + } +}; + +if (window.postMessage && !useragent.isOldIE) { + var postMessageId = 1; + exports.nextTick = function(callback, win) { + win = win || window; + var messageName = "zero-timeout-message-" + postMessageId; + exports.addListener(win, "message", function listener(e) { + if (e.data == messageName) { + exports.stopPropagation(e); + exports.removeListener(win, "message", listener); + callback(); + } + }); + win.postMessage(messageName, "*"); + }; +} +else { + exports.nextTick = function(callback, win) { + win = win || window; + window.setTimeout(callback, 0); + }; +} + +}); + +// Most of the following code is taken from SproutCore with a few changes. + +ace.define('ace/lib/keys', ['require', 'exports', 'module' , 'ace/lib/oop'], function(require, exports, module) { + + +var oop = require("./oop"); +var Keys = (function() { + var ret = { + MODIFIER_KEYS: { + 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta' + }, + + KEY_MODS: { + "ctrl": 1, "alt": 2, "option" : 2, + "shift": 4, "meta": 8, "command": 8 + }, + + FUNCTION_KEYS : { + 8 : "Backspace", + 9 : "Tab", + 13 : "Return", + 19 : "Pause", + 27 : "Esc", + 32 : "Space", + 33 : "PageUp", + 34 : "PageDown", + 35 : "End", + 36 : "Home", + 37 : "Left", + 38 : "Up", + 39 : "Right", + 40 : "Down", + 44 : "Print", + 45 : "Insert", + 46 : "Delete", + 96 : "Numpad0", + 97 : "Numpad1", + 98 : "Numpad2", + 99 : "Numpad3", + 100: "Numpad4", + 101: "Numpad5", + 102: "Numpad6", + 103: "Numpad7", + 104: "Numpad8", + 105: "Numpad9", + 112: "F1", + 113: "F2", + 114: "F3", + 115: "F4", + 116: "F5", + 117: "F6", + 118: "F7", + 119: "F8", + 120: "F9", + 121: "F10", + 122: "F11", + 123: "F12", + 144: "Numlock", + 145: "Scrolllock" + }, + + PRINTABLE_KEYS: { + 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5', + 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a', + 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h', + 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o', + 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v', + 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.', + 188: ',', 190: '.', 191: '/', 192: '`', 219: '[', 220: '\\', + 221: ']', 222: '\'' + } + }; + + // A reverse map of FUNCTION_KEYS + for (var i in ret.FUNCTION_KEYS) { + var name = ret.FUNCTION_KEYS[i].toLowerCase(); + ret[name] = parseInt(i, 10); + } + + // Add the MODIFIER_KEYS, FUNCTION_KEYS and PRINTABLE_KEYS to the KEY + // variables as well. + oop.mixin(ret, ret.MODIFIER_KEYS); + oop.mixin(ret, ret.PRINTABLE_KEYS); + oop.mixin(ret, ret.FUNCTION_KEYS); + + // aliases + ret.enter = ret["return"]; + ret.escape = ret.esc; + ret.del = ret["delete"]; + + // workaround for firefox bug + ret[173] = '-'; + + return ret; +})(); +oop.mixin(exports, Keys); + +exports.keyCodeToString = function(keyCode) { + return (Keys[keyCode] || String.fromCharCode(keyCode)).toLowerCase(); +} + +}); + +ace.define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.inherits = (function() { + var tempCtor = function() {}; + return function(ctor, superCtor) { + tempCtor.prototype = superCtor.prototype; + ctor.super_ = superCtor.prototype; + ctor.prototype = new tempCtor(); + ctor.prototype.constructor = ctor; + }; +}()); + +exports.mixin = function(obj, mixin) { + for (var key in mixin) { + obj[key] = mixin[key]; + } +}; + +exports.implement = function(proto, mixin) { + exports.mixin(proto, mixin); +}; + +}); + +ace.define('ace/lib/useragent', ['require', 'exports', 'module' ], function(require, exports, module) { + + +var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase(); +var ua = navigator.userAgent; + +// Is the user using a browser that identifies itself as Windows +exports.isWin = (os == "win"); + +// Is the user using a browser that identifies itself as Mac OS +exports.isMac = (os == "mac"); + +// Is the user using a browser that identifies itself as Linux +exports.isLinux = (os == "linux"); + +exports.isIE = + navigator.appName == "Microsoft Internet Explorer" + && parseFloat(navigator.userAgent.match(/MSIE ([0-9]+[\.0-9]+)/)[1]); + +exports.isOldIE = exports.isIE && exports.isIE < 9; + +// Is this Firefox or related? +exports.isGecko = exports.isMozilla = window.controllers && window.navigator.product === "Gecko"; + +// oldGecko == rev < 2.0 +exports.isOldGecko = exports.isGecko && parseInt((navigator.userAgent.match(/rv\:(\d+)/)||[])[1], 10) < 4; + +// Is this Opera +exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]"; + +// Is the user using a browser that identifies itself as WebKit +exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined; + +exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined; + +exports.isAIR = ua.indexOf("AdobeAIR") >= 0; + +exports.isIPad = ua.indexOf("iPad") >= 0; + +exports.isTouchPad = ua.indexOf("TouchPad") >= 0; +exports.OS = { + LINUX: "LINUX", + MAC: "MAC", + WINDOWS: "WINDOWS" +}; +exports.getOS = function() { + if (exports.isMac) { + return exports.OS.MAC; + } else if (exports.isLinux) { + return exports.OS.LINUX; + } else { + return exports.OS.WINDOWS; + } +}; + +}); + +ace.define('ace/editor', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/useragent', 'ace/keyboard/textinput', 'ace/mouse/mouse_handler', 'ace/mouse/fold_handler', 'ace/keyboard/keybinding', 'ace/edit_session', 'ace/search', 'ace/range', 'ace/lib/event_emitter', 'ace/commands/command_manager', 'ace/commands/default_commands'], function(require, exports, module) { + + +require("./lib/fixoldbrowsers"); + +var oop = require("./lib/oop"); +var lang = require("./lib/lang"); +var useragent = require("./lib/useragent"); +var TextInput = require("./keyboard/textinput").TextInput; +var MouseHandler = require("./mouse/mouse_handler").MouseHandler; +var FoldHandler = require("./mouse/fold_handler").FoldHandler; +var KeyBinding = require("./keyboard/keybinding").KeyBinding; +var EditSession = require("./edit_session").EditSession; +var Search = require("./search").Search; +var Range = require("./range").Range; +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var CommandManager = require("./commands/command_manager").CommandManager; +var defaultCommands = require("./commands/default_commands").commands; + +/** + * new Editor(renderer, session) + * - renderer (VirtualRenderer): Associated `VirtualRenderer` that draws everything + * - session (EditSession): The `EditSession` to refer to + * + * Creates a new `Editor` object. + * + **/ +var Editor = function(renderer, session) { + var container = renderer.getContainerElement(); + this.container = container; + this.renderer = renderer; + + this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands); + this.textInput = new TextInput(renderer.getTextAreaContainer(), this); + this.renderer.textarea = this.textInput.getElement(); + this.keyBinding = new KeyBinding(this); + + // TODO detect touch event support + this.$mouseHandler = new MouseHandler(this); + new FoldHandler(this); + + this.$blockScrolling = 0; + this.$search = new Search().set({ + wrap: true + }); + + this.setSession(session || new EditSession("")); +}; + +(function(){ + + oop.implement(this, EventEmitter); + this.setKeyboardHandler = function(keyboardHandler) { + this.keyBinding.setKeyboardHandler(keyboardHandler); + }; + this.getKeyboardHandler = function() { + return this.keyBinding.getKeyboardHandler(); + }; + /** + * Editor@changeSession(e) + * - e (Object): An object with two properties, `oldSession` and `session`, that represent the old and new [[EditSession]]s. + * + * Emitted whenever the [[EditSession]] changes. + **/ + this.setSession = function(session) { + if (this.session == session) + return; + + if (this.session) { + var oldSession = this.session; + this.session.removeEventListener("change", this.$onDocumentChange); + this.session.removeEventListener("changeMode", this.$onChangeMode); + this.session.removeEventListener("tokenizerUpdate", this.$onTokenizerUpdate); + this.session.removeEventListener("changeTabSize", this.$onChangeTabSize); + this.session.removeEventListener("changeWrapLimit", this.$onChangeWrapLimit); + this.session.removeEventListener("changeWrapMode", this.$onChangeWrapMode); + this.session.removeEventListener("onChangeFold", this.$onChangeFold); + this.session.removeEventListener("changeFrontMarker", this.$onChangeFrontMarker); + this.session.removeEventListener("changeBackMarker", this.$onChangeBackMarker); + this.session.removeEventListener("changeBreakpoint", this.$onChangeBreakpoint); + this.session.removeEventListener("changeAnnotation", this.$onChangeAnnotation); + this.session.removeEventListener("changeOverwrite", this.$onCursorChange); + this.session.removeEventListener("changeScrollTop", this.$onScrollTopChange); + this.session.removeEventListener("changeLeftTop", this.$onScrollLeftChange); + + var selection = this.session.getSelection(); + selection.removeEventListener("changeCursor", this.$onCursorChange); + selection.removeEventListener("changeSelection", this.$onSelectionChange); + } + + this.session = session; + + this.$onDocumentChange = this.onDocumentChange.bind(this); + session.addEventListener("change", this.$onDocumentChange); + this.renderer.setSession(session); + + this.$onChangeMode = this.onChangeMode.bind(this); + session.addEventListener("changeMode", this.$onChangeMode); + + this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this); + session.addEventListener("tokenizerUpdate", this.$onTokenizerUpdate); + + this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer); + session.addEventListener("changeTabSize", this.$onChangeTabSize); + + this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this); + session.addEventListener("changeWrapLimit", this.$onChangeWrapLimit); + + this.$onChangeWrapMode = this.onChangeWrapMode.bind(this); + session.addEventListener("changeWrapMode", this.$onChangeWrapMode); + + this.$onChangeFold = this.onChangeFold.bind(this); + session.addEventListener("changeFold", this.$onChangeFold); + + this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this); + this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker); + + this.$onChangeBackMarker = this.onChangeBackMarker.bind(this); + this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker); + + this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this); + this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint); + + this.$onChangeAnnotation = this.onChangeAnnotation.bind(this); + this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation); + + this.$onCursorChange = this.onCursorChange.bind(this); + this.session.addEventListener("changeOverwrite", this.$onCursorChange); + + this.$onScrollTopChange = this.onScrollTopChange.bind(this); + this.session.addEventListener("changeScrollTop", this.$onScrollTopChange); + + this.$onScrollLeftChange = this.onScrollLeftChange.bind(this); + this.session.addEventListener("changeScrollLeft", this.$onScrollLeftChange); + + this.selection = session.getSelection(); + this.selection.addEventListener("changeCursor", this.$onCursorChange); + + this.$onSelectionChange = this.onSelectionChange.bind(this); + this.selection.addEventListener("changeSelection", this.$onSelectionChange); + + this.onChangeMode(); + + this.$blockScrolling += 1; + this.onCursorChange(); + this.$blockScrolling -= 1; + + this.onScrollTopChange(); + this.onScrollLeftChange(); + this.onSelectionChange(); + this.onChangeFrontMarker(); + this.onChangeBackMarker(); + this.onChangeBreakpoint(); + this.onChangeAnnotation(); + this.session.getUseWrapMode() && this.renderer.adjustWrapLimit(); + this.renderer.updateFull(); + + this._emit("changeSession", { + session: session, + oldSession: oldSession + }); + }; + this.getSession = function() { + return this.session; + }; + this.setValue = function(val, cursorPos) { + this.session.doc.setValue(val); + + if (!cursorPos) + this.selectAll(); + else if (cursorPos == 1) + this.navigateFileEnd(); + else if (cursorPos == -1) + this.navigateFileStart(); + + return val; + }; + this.getValue = function() { + return this.session.getValue(); + }; + this.getSelection = function() { + return this.selection; + }; + this.resize = function(force) { + this.renderer.onResize(force); + }; + this.setTheme = function(theme) { + this.renderer.setTheme(theme); + }; + this.getTheme = function() { + return this.renderer.getTheme(); + }; + this.setStyle = function(style) { + this.renderer.setStyle(style); + }; + this.unsetStyle = function(style) { + this.renderer.unsetStyle(style); + }; + this.setFontSize = function(size) { + this.container.style.fontSize = size; + this.renderer.updateFontSize(); + }; + this.$highlightBrackets = function() { + if (this.session.$bracketHighlight) { + this.session.removeMarker(this.session.$bracketHighlight); + this.session.$bracketHighlight = null; + } + + if (this.$highlightPending) { + return; + } + + // perform highlight async to not block the browser during navigation + var self = this; + this.$highlightPending = true; + setTimeout(function() { + self.$highlightPending = false; + + var pos = self.session.findMatchingBracket(self.getCursorPosition()); + if (pos) { + var range = new Range(pos.row, pos.column, pos.row, pos.column+1); + self.session.$bracketHighlight = self.session.addMarker(range, "ace_bracket", "text"); + } + }, 10); + }; + this.focus = function() { + // Safari needs the timeout + // iOS and Firefox need it called immediately + // to be on the save side we do both + var _self = this; + setTimeout(function() { + _self.textInput.focus(); + }); + this.textInput.focus(); + }; + this.isFocused = function() { + return this.textInput.isFocused(); + }; + this.blur = function() { + this.textInput.blur(); + }; + this.onFocus = function() { + if (this.$isFocused) + return; + this.$isFocused = true; + this.renderer.showCursor(); + this.renderer.visualizeFocus(); + this._emit("focus"); + }; + this.onBlur = function() { + if (!this.$isFocused) + return; + this.$isFocused = false; + this.renderer.hideCursor(); + this.renderer.visualizeBlur(); + this._emit("blur"); + }; + + this.$cursorChange = function() { + this.renderer.updateCursor(); + }; + this.onDocumentChange = function(e) { + var delta = e.data; + var range = delta.range; + var lastRow; + + if (range.start.row == range.end.row && delta.action != "insertLines" && delta.action != "removeLines") + lastRow = range.end.row; + else + lastRow = Infinity; + this.renderer.updateLines(range.start.row, lastRow); + + this._emit("change", e); + + // update cursor because tab characters can influence the cursor position + this.$cursorChange(); + }; + + this.onTokenizerUpdate = function(e) { + var rows = e.data; + this.renderer.updateLines(rows.first, rows.last); + }; + + + this.onScrollTopChange = function() { + this.renderer.scrollToY(this.session.getScrollTop()); + }; + + this.onScrollLeftChange = function() { + this.renderer.scrollToX(this.session.getScrollLeft()); + }; + this.onCursorChange = function() { + this.$cursorChange(); + + if (!this.$blockScrolling) { + this.renderer.scrollCursorIntoView(); + } + + this.$highlightBrackets(); + this.$updateHighlightActiveLine(); + this._emit("changeSelection"); + }; + this.$updateHighlightActiveLine = function() { + var session = this.getSession(); + + if (session.$highlightLineMarker) + session.removeMarker(session.$highlightLineMarker); + + session.$highlightLineMarker = null; + + if (this.$highlightActiveLine) { + var cursor = this.getCursorPosition(); + var foldLine = this.session.getFoldLine(cursor.row); + + if ((this.getSelectionStyle() != "line" || !this.selection.isMultiLine())) { + var range; + if (foldLine) { + range = new Range(foldLine.start.row, 0, foldLine.end.row + 1, 0); + } else { + range = new Range(cursor.row, 0, cursor.row+1, 0); + } + session.$highlightLineMarker = session.addMarker(range, "ace_active_line", "background"); + } + } + }; + + + this.onSelectionChange = function(e) { + var session = this.session; + + if (session.$selectionMarker) { + session.removeMarker(session.$selectionMarker); + } + session.$selectionMarker = null; + + if (!this.selection.isEmpty()) { + var range = this.selection.getRange(); + var style = this.getSelectionStyle(); + session.$selectionMarker = session.addMarker(range, "ace_selection", style); + } else { + this.$updateHighlightActiveLine(); + } + + var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp() + this.session.highlight(re); + + this._emit("changeSelection"); + }; + + this.$getSelectionHighLightRegexp = function() { + var session = this.session; + + var selection = this.getSelectionRange(); + if (selection.isEmpty() || selection.isMultiLine()) + return; + + var startOuter = selection.start.column - 1; + var endOuter = selection.end.column + 1; + var line = session.getLine(selection.start.row); + var lineCols = line.length; + var needle = line.substring(Math.max(startOuter, 0), + Math.min(endOuter, lineCols)); + + // Make sure the outer characters are not part of the word. + if ((startOuter >= 0 && /^[\w\d]/.test(needle)) || + (endOuter <= lineCols && /[\w\d]$/.test(needle))) + return; + + needle = line.substring(selection.start.column, selection.end.column); + if (!/^[\w\d]+$/.test(needle)) + return; + + var re = this.$search.$assembleRegExp({ + wholeWord: true, + caseSensitive: true, + needle: needle + }); + + return re; + }; + + + this.onChangeFrontMarker = function() { + this.renderer.updateFrontMarkers(); + }; + + this.onChangeBackMarker = function() { + this.renderer.updateBackMarkers(); + }; + + + this.onChangeBreakpoint = function() { + this.renderer.updateBreakpoints(); + }; + + this.onChangeAnnotation = function() { + this.renderer.setAnnotations(this.session.getAnnotations()); + }; + + + this.onChangeMode = function() { + this.renderer.updateText(); + }; + + + this.onChangeWrapLimit = function() { + this.renderer.updateFull(); + }; + + this.onChangeWrapMode = function() { + this.renderer.onResize(true); + }; + + + this.onChangeFold = function() { + // Update the active line marker as due to folding changes the current + // line range on the screen might have changed. + this.$updateHighlightActiveLine(); + // TODO: This might be too much updating. Okay for now. + this.renderer.updateFull(); + }; + /** + * Editor@copy(text) + * - text (String): The copied text + * + * Emitted when text is copied. + **/ + this.getCopyText = function() { + var text = ""; + if (!this.selection.isEmpty()) + text = this.session.getTextRange(this.getSelectionRange()); + + this._emit("copy", text); + return text; + }; + this.onCopy = function() { + this.commands.exec("copy", this); + }; + this.onCut = function() { + this.commands.exec("cut", this); + }; + /** + * Editor@paste(text) + * - text (String): The pasted text + * + * Emitted when text is pasted. + **/ + this.onPaste = function(text) { + // todo this should change when paste becomes a command + if (this.$readOnly) + return; + this._emit("paste", text); + this.insert(text); + }; + this.insert = function(text) { + var session = this.session; + var mode = session.getMode(); + + var cursor = this.getCursorPosition(); + + if (this.getBehavioursEnabled()) { + // Get a transform if the current mode wants one. + var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text); + if (transform) + text = transform.text; + } + + text = text.replace("\t", this.session.getTabString()); + + // remove selected text + if (!this.selection.isEmpty()) { + cursor = this.session.remove(this.getSelectionRange()); + this.clearSelection(); + } + else if (this.session.getOverwrite()) { + var range = new Range.fromPoints(cursor, cursor); + range.end.column += text.length; + this.session.remove(range); + } + + this.clearSelection(); + + var start = cursor.column; + var lineState = session.getState(cursor.row); + var shouldOutdent = mode.checkOutdent(lineState, session.getLine(cursor.row), text); + var line = session.getLine(cursor.row); + var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString()); + var end = session.insert(cursor, text); + + if (transform && transform.selection) { + if (transform.selection.length == 2) { // Transform relative to the current column + this.selection.setSelectionRange( + new Range(cursor.row, start + transform.selection[0], + cursor.row, start + transform.selection[1])); + } else { // Transform relative to the current row. + this.selection.setSelectionRange( + new Range(cursor.row + transform.selection[0], + transform.selection[1], + cursor.row + transform.selection[2], + transform.selection[3])); + } + } + + var lineState = session.getState(cursor.row); + + // TODO disabled multiline auto indent + // possibly doing the indent before inserting the text + // if (cursor.row !== end.row) { + if (session.getDocument().isNewLine(text)) { + this.moveCursorTo(cursor.row+1, 0); + + var size = session.getTabSize(); + var minIndent = Number.MAX_VALUE; + + for (var row = cursor.row + 1; row <= end.row; ++row) { + var indent = 0; + + line = session.getLine(row); + for (var i = 0; i < line.length; ++i) + if (line.charAt(i) == '\t') + indent += size; + else if (line.charAt(i) == ' ') + indent += 1; + else + break; + if (/[^\s]/.test(line)) + minIndent = Math.min(indent, minIndent); + } + + for (var row = cursor.row + 1; row <= end.row; ++row) { + var outdent = minIndent; + + line = session.getLine(row); + for (var i = 0; i < line.length && outdent > 0; ++i) + if (line.charAt(i) == '\t') + outdent -= size; + else if (line.charAt(i) == ' ') + outdent -= 1; + session.remove(new Range(row, 0, row, i)); + } + session.indentRows(cursor.row + 1, end.row, lineIndent); + } + if (shouldOutdent) + mode.autoOutdent(lineState, session, cursor.row); + }; + + this.onTextInput = function(text) { + this.keyBinding.onTextInput(text); + }; + + this.onCommandKey = function(e, hashId, keyCode) { + this.keyBinding.onCommandKey(e, hashId, keyCode); + }; + this.setOverwrite = function(overwrite) { + this.session.setOverwrite(overwrite); + }; + this.getOverwrite = function() { + return this.session.getOverwrite(); + }; + this.toggleOverwrite = function() { + this.session.toggleOverwrite(); + }; + this.setScrollSpeed = function(speed) { + this.$mouseHandler.setScrollSpeed(speed); + }; + this.getScrollSpeed = function() { + return this.$mouseHandler.getScrollSpeed(); + }; + this.setDragDelay = function(dragDelay) { + this.$mouseHandler.setDragDelay(dragDelay); + }; + this.getDragDelay = function() { + return this.$mouseHandler.getDragDelay(); + }; + + this.$selectionStyle = "line"; + /** + * Editor@changeSelectionStyle(data) + * - data (Object): Contains one property, `data`, which indicates the new selection style + * + * Emitted when the selection style changes, via [[Editor.setSelectionStyle]]. + * + **/ + this.setSelectionStyle = function(style) { + if (this.$selectionStyle == style) return; + + this.$selectionStyle = style; + this.onSelectionChange(); + this._emit("changeSelectionStyle", {data: style}); + }; + this.getSelectionStyle = function() { + return this.$selectionStyle; + }; + + this.$highlightActiveLine = true; + this.setHighlightActiveLine = function(shouldHighlight) { + if (this.$highlightActiveLine == shouldHighlight) + return; + + this.$highlightActiveLine = shouldHighlight; + this.$updateHighlightActiveLine(); + }; + this.getHighlightActiveLine = function() { + return this.$highlightActiveLine; + }; + + this.$highlightGutterLine = true; + this.setHighlightGutterLine = function(shouldHighlight) { + if (this.$highlightGutterLine == shouldHighlight) + return; + + this.renderer.setHighlightGutterLine(shouldHighlight); + this.$highlightGutterLine = shouldHighlight; + }; + + this.getHighlightGutterLine = function() { + return this.$highlightGutterLine; + }; + + this.$highlightSelectedWord = true; + this.setHighlightSelectedWord = function(shouldHighlight) { + if (this.$highlightSelectedWord == shouldHighlight) + return; + + this.$highlightSelectedWord = shouldHighlight; + this.$onSelectionChange(); + }; + this.getHighlightSelectedWord = function() { + return this.$highlightSelectedWord; + }; + + this.setAnimatedScroll = function(shouldAnimate){ + this.renderer.setAnimatedScroll(shouldAnimate); + }; + + this.getAnimatedScroll = function(){ + return this.renderer.getAnimatedScroll(); + }; + this.setShowInvisibles = function(showInvisibles) { + this.renderer.setShowInvisibles(showInvisibles); + }; + this.getShowInvisibles = function() { + return this.renderer.getShowInvisibles(); + }; + + this.setDisplayIndentGuides = function(display) { + this.renderer.setDisplayIndentGuides(display); + }; + + this.getDisplayIndentGuides = function() { + return this.renderer.getDisplayIndentGuides(); + }; + this.setShowPrintMargin = function(showPrintMargin) { + this.renderer.setShowPrintMargin(showPrintMargin); + }; + this.getShowPrintMargin = function() { + return this.renderer.getShowPrintMargin(); + }; + this.setPrintMarginColumn = function(showPrintMargin) { + this.renderer.setPrintMarginColumn(showPrintMargin); + }; + this.getPrintMarginColumn = function() { + return this.renderer.getPrintMarginColumn(); + }; + + this.$readOnly = false; + this.setReadOnly = function(readOnly) { + this.$readOnly = readOnly; + }; + this.getReadOnly = function() { + return this.$readOnly; + }; + + this.$modeBehaviours = true; + this.setBehavioursEnabled = function (enabled) { + this.$modeBehaviours = enabled; + }; + this.getBehavioursEnabled = function () { + return this.$modeBehaviours; + }; + this.setShowFoldWidgets = function(show) { + var gutter = this.renderer.$gutterLayer; + if (gutter.getShowFoldWidgets() == show) + return; + + this.renderer.$gutterLayer.setShowFoldWidgets(show); + this.$showFoldWidgets = show; + this.renderer.updateFull(); + }; + this.getShowFoldWidgets = function() { + return this.renderer.$gutterLayer.getShowFoldWidgets(); + }; + + this.setFadeFoldWidgets = function(show) { + this.renderer.setFadeFoldWidgets(show); + }; + + this.getFadeFoldWidgets = function() { + return this.renderer.getFadeFoldWidgets(); + }; + this.remove = function(dir) { + if (this.selection.isEmpty()){ + if (dir == "left") + this.selection.selectLeft(); + else + this.selection.selectRight(); + } + + var range = this.getSelectionRange(); + if (this.getBehavioursEnabled()) { + var session = this.session; + var state = session.getState(range.start.row); + var new_range = session.getMode().transformAction(state, 'deletion', this, session, range); + if (new_range) + range = new_range; + } + + this.session.remove(range); + this.clearSelection(); + }; + this.removeWordRight = function() { + if (this.selection.isEmpty()) + this.selection.selectWordRight(); + + this.session.remove(this.getSelectionRange()); + this.clearSelection(); + }; + this.removeWordLeft = function() { + if (this.selection.isEmpty()) + this.selection.selectWordLeft(); + + this.session.remove(this.getSelectionRange()); + this.clearSelection(); + }; + this.removeToLineStart = function() { + if (this.selection.isEmpty()) + this.selection.selectLineStart(); + + this.session.remove(this.getSelectionRange()); + this.clearSelection(); + }; + this.removeToLineEnd = function() { + if (this.selection.isEmpty()) + this.selection.selectLineEnd(); + + var range = this.getSelectionRange(); + if (range.start.column == range.end.column && range.start.row == range.end.row) { + range.end.column = 0; + range.end.row++; + } + + this.session.remove(range); + this.clearSelection(); + }; + this.splitLine = function() { + if (!this.selection.isEmpty()) { + this.session.remove(this.getSelectionRange()); + this.clearSelection(); + } + + var cursor = this.getCursorPosition(); + this.insert("\n"); + this.moveCursorToPosition(cursor); + }; + this.transposeLetters = function() { + if (!this.selection.isEmpty()) { + return; + } + + var cursor = this.getCursorPosition(); + var column = cursor.column; + if (column === 0) + return; + + var line = this.session.getLine(cursor.row); + var swap, range; + if (column < line.length) { + swap = line.charAt(column) + line.charAt(column-1); + range = new Range(cursor.row, column-1, cursor.row, column+1); + } + else { + swap = line.charAt(column-1) + line.charAt(column-2); + range = new Range(cursor.row, column-2, cursor.row, column); + } + this.session.replace(range, swap); + }; + this.toLowerCase = function() { + var originalRange = this.getSelectionRange(); + if (this.selection.isEmpty()) { + this.selection.selectWord(); + } + + var range = this.getSelectionRange(); + var text = this.session.getTextRange(range); + this.session.replace(range, text.toLowerCase()); + this.selection.setSelectionRange(originalRange); + }; + this.toUpperCase = function() { + var originalRange = this.getSelectionRange(); + if (this.selection.isEmpty()) { + this.selection.selectWord(); + } + + var range = this.getSelectionRange(); + var text = this.session.getTextRange(range); + this.session.replace(range, text.toUpperCase()); + this.selection.setSelectionRange(originalRange); + }; + this.indent = function() { + var session = this.session; + var range = this.getSelectionRange(); + + if (range.start.row < range.end.row || range.start.column < range.end.column) { + var rows = this.$getSelectedRows(); + session.indentRows(rows.first, rows.last, "\t"); + } else { + var indentString; + + if (this.session.getUseSoftTabs()) { + var size = session.getTabSize(), + position = this.getCursorPosition(), + column = session.documentToScreenColumn(position.row, position.column), + count = (size - column % size); + + indentString = lang.stringRepeat(" ", count); + } else + indentString = "\t"; + return this.insert(indentString); + } + }; + this.blockOutdent = function() { + var selection = this.session.getSelection(); + this.session.outdentRows(selection.getRange()); + }; + this.toggleCommentLines = function() { + var state = this.session.getState(this.getCursorPosition().row); + var rows = this.$getSelectedRows(); + this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last); + }; + this.removeLines = function() { + var rows = this.$getSelectedRows(); + var range; + if (rows.first === 0 || rows.last+1 < this.session.getLength()) + range = new Range(rows.first, 0, rows.last+1, 0); + else + range = new Range( + rows.first-1, this.session.getLine(rows.first-1).length, + rows.last, this.session.getLine(rows.last).length + ); + this.session.remove(range); + this.clearSelection(); + }; + + this.duplicateSelection = function() { + var sel = this.selection; + var doc = this.session; + var range = sel.getRange(); + if (range.isEmpty()) { + var row = range.start.row; + doc.duplicateLines(row, row); + } else { + var reverse = sel.isBackwards() + var point = sel.isBackwards() ? range.start : range.end; + var endPoint = doc.insert(point, doc.getTextRange(range), false); + range.start = point; + range.end = endPoint; + + sel.setSelectionRange(range, reverse) + } + }; + this.moveLinesDown = function() { + this.$moveLines(function(firstRow, lastRow) { + return this.session.moveLinesDown(firstRow, lastRow); + }); + }; + this.moveLinesUp = function() { + this.$moveLines(function(firstRow, lastRow) { + return this.session.moveLinesUp(firstRow, lastRow); + }); + }; + this.moveText = function(range, toPosition) { + if (this.$readOnly) + return null; + + return this.session.moveText(range, toPosition); + }; + this.copyLinesUp = function() { + this.$moveLines(function(firstRow, lastRow) { + this.session.duplicateLines(firstRow, lastRow); + return 0; + }); + }; + this.copyLinesDown = function() { + this.$moveLines(function(firstRow, lastRow) { + return this.session.duplicateLines(firstRow, lastRow); + }); + }; + this.$moveLines = function(mover) { + var rows = this.$getSelectedRows(); + var selection = this.selection; + if (!selection.isMultiLine()) { + var range = selection.getRange(); + var reverse = selection.isBackwards(); + } + + var linesMoved = mover.call(this, rows.first, rows.last); + + if (range) { + range.start.row += linesMoved; + range.end.row += linesMoved; + selection.setSelectionRange(range, reverse); + } + else { + selection.setSelectionAnchor(rows.last+linesMoved+1, 0); + selection.$moveSelection(function() { + selection.moveCursorTo(rows.first+linesMoved, 0); + }); + } + }; + this.$getSelectedRows = function() { + var range = this.getSelectionRange().collapseRows(); + + return { + first: range.start.row, + last: range.end.row + }; + }; + + this.onCompositionStart = function(text) { + this.renderer.showComposition(this.getCursorPosition()); + }; + + this.onCompositionUpdate = function(text) { + this.renderer.setCompositionText(text); + }; + + this.onCompositionEnd = function() { + this.renderer.hideComposition(); + }; + this.getFirstVisibleRow = function() { + return this.renderer.getFirstVisibleRow(); + }; + this.getLastVisibleRow = function() { + return this.renderer.getLastVisibleRow(); + }; + this.isRowVisible = function(row) { + return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow()); + }; + this.isRowFullyVisible = function(row) { + return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow()); + }; + this.$getVisibleRowCount = function() { + return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1; + }; + + this.$moveByPage = function(dir, select) { + var renderer = this.renderer; + var config = this.renderer.layerConfig; + var rows = dir * Math.floor(config.height / config.lineHeight); + + this.$blockScrolling++; + if (select == true) { + this.selection.$moveSelection(function(){ + this.moveCursorBy(rows, 0); + }); + } else if (select == false) { + this.selection.moveCursorBy(rows, 0); + this.selection.clearSelection(); + } + this.$blockScrolling--; + + var scrollTop = renderer.scrollTop; + + renderer.scrollBy(0, rows * config.lineHeight); + if (select != null) + renderer.scrollCursorIntoView(null, 0.5); + + renderer.animateScrolling(scrollTop); + }; + this.selectPageDown = function() { + this.$moveByPage(1, true); + }; + this.selectPageUp = function() { + this.$moveByPage(-1, true); + }; + this.gotoPageDown = function() { + this.$moveByPage(1, false); + }; + this.gotoPageUp = function() { + this.$moveByPage(-1, false); + }; + this.scrollPageDown = function() { + this.$moveByPage(1); + }; + this.scrollPageUp = function() { + this.$moveByPage(-1); + }; + this.scrollToRow = function(row) { + this.renderer.scrollToRow(row); + }; + this.scrollToLine = function(line, center, animate, callback) { + this.renderer.scrollToLine(line, center, animate, callback); + }; + this.centerSelection = function() { + var range = this.getSelectionRange(); + var pos = { + row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2), + column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2) + } + this.renderer.alignCursor(pos, 0.5); + }; + this.getCursorPosition = function() { + return this.selection.getCursor(); + }; + this.getCursorPositionScreen = function() { + return this.session.documentToScreenPosition(this.getCursorPosition()); + }; + this.getSelectionRange = function() { + return this.selection.getRange(); + }; + this.selectAll = function() { + this.$blockScrolling += 1; + this.selection.selectAll(); + this.$blockScrolling -= 1; + }; + this.clearSelection = function() { + this.selection.clearSelection(); + }; + this.moveCursorTo = function(row, column) { + this.selection.moveCursorTo(row, column); + }; + this.moveCursorToPosition = function(pos) { + this.selection.moveCursorToPosition(pos); + }; + this.jumpToMatching = function(select) { + var cursor = this.getCursorPosition(); + + var range = this.session.getBracketRange(cursor); + if (!range) { + range = this.find({ + needle: /[{}()\[\]]/g, + preventScroll:true, + start: {row: cursor.row, column: cursor.column - 1} + }); + if (!range) + return; + var pos = range.start; + if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2) + range = this.session.getBracketRange(pos); + } + + pos = range && range.cursor || pos; + if (pos) { + if (select) { + if (range && range.isEqual(this.getSelectionRange())) + this.clearSelection(); + else + this.selection.selectTo(pos.row, pos.column); + } else { + this.clearSelection(); + this.moveCursorTo(pos.row, pos.column); + } + } + }; + this.gotoLine = function(lineNumber, column, animate) { + this.selection.clearSelection(); + this.session.unfold({row: lineNumber - 1, column: column || 0}); + + this.$blockScrolling += 1; + this.moveCursorTo(lineNumber - 1, column || 0); + this.$blockScrolling -= 1; + + if (!this.isRowFullyVisible(lineNumber - 1)) + this.scrollToLine(lineNumber - 1, true, animate); + }; + this.navigateTo = function(row, column) { + this.clearSelection(); + this.moveCursorTo(row, column); + }; + this.navigateUp = function(times) { + this.selection.clearSelection(); + times = times || 1; + this.selection.moveCursorBy(-times, 0); + }; + this.navigateDown = function(times) { + this.selection.clearSelection(); + times = times || 1; + this.selection.moveCursorBy(times, 0); + }; + this.navigateLeft = function(times) { + if (!this.selection.isEmpty()) { + var selectionStart = this.getSelectionRange().start; + this.moveCursorToPosition(selectionStart); + } + else { + times = times || 1; + while (times--) { + this.selection.moveCursorLeft(); + } + } + this.clearSelection(); + }; + this.navigateRight = function(times) { + if (!this.selection.isEmpty()) { + var selectionEnd = this.getSelectionRange().end; + this.moveCursorToPosition(selectionEnd); + } + else { + times = times || 1; + while (times--) { + this.selection.moveCursorRight(); + } + } + this.clearSelection(); + }; + this.navigateLineStart = function() { + this.selection.moveCursorLineStart(); + this.clearSelection(); + }; + this.navigateLineEnd = function() { + this.selection.moveCursorLineEnd(); + this.clearSelection(); + }; + this.navigateFileEnd = function() { + var scrollTop = this.renderer.scrollTop; + this.selection.moveCursorFileEnd(); + this.clearSelection(); + this.renderer.animateScrolling(scrollTop); + }; + this.navigateFileStart = function() { + var scrollTop = this.renderer.scrollTop; + this.selection.moveCursorFileStart(); + this.clearSelection(); + this.renderer.animateScrolling(scrollTop); + }; + this.navigateWordRight = function() { + this.selection.moveCursorWordRight(); + this.clearSelection(); + }; + this.navigateWordLeft = function() { + this.selection.moveCursorWordLeft(); + this.clearSelection(); + }; + this.replace = function(replacement, options) { + if (options) + this.$search.set(options); + + var range = this.$search.find(this.session); + var replaced = 0; + if (!range) + return replaced; + + if (this.$tryReplace(range, replacement)) { + replaced = 1; + } + if (range !== null) { + this.selection.setSelectionRange(range); + this.renderer.scrollSelectionIntoView(range.start, range.end); + } + + return replaced; + }; + this.replaceAll = function(replacement, options) { + if (options) { + this.$search.set(options); + } + + var ranges = this.$search.findAll(this.session); + var replaced = 0; + if (!ranges.length) + return replaced; + + this.$blockScrolling += 1; + + var selection = this.getSelectionRange(); + this.clearSelection(); + this.selection.moveCursorTo(0, 0); + + for (var i = ranges.length - 1; i >= 0; --i) { + if(this.$tryReplace(ranges[i], replacement)) { + replaced++; + } + } + + this.selection.setSelectionRange(selection); + this.$blockScrolling -= 1; + + return replaced; + }; + + this.$tryReplace = function(range, replacement) { + var input = this.session.getTextRange(range); + replacement = this.$search.replace(input, replacement); + if (replacement !== null) { + range.end = this.session.replace(range, replacement); + return range; + } else { + return null; + } + }; + this.getLastSearchOptions = function() { + return this.$search.getOptions(); + }; + this.find = function(needle, options, animate) { + if (!options) + options = {}; + + if (typeof needle == "string" || needle instanceof RegExp) + options.needle = needle; + else if (typeof needle == "object") + oop.mixin(options, needle); + + var range = this.selection.getRange(); + if (options.needle == null) { + needle = this.session.getTextRange(range) + || this.$search.$options.needle; + if (!needle) { + range = this.session.getWordRange(range.start.row, range.start.column); + needle = this.session.getTextRange(range); + } + this.$search.set({needle: needle}); + } + + this.$search.set(options); + if (!options.start) + this.$search.set({start: range}); + + var newRange = this.$search.find(this.session); + if (options.preventScroll) + return newRange; + if (newRange) { + this.revealRange(newRange, animate); + return newRange; + } + // clear selection if nothing is found + if (options.backwards) + range.start = range.end; + else + range.end = range.start; + this.selection.setRange(range); + }; + this.findNext = function(options, animate) { + this.find({skipCurrent: true, backwards: false}, options, animate); + }; + this.findPrevious = function(options, animate) { + this.find(options, {skipCurrent: true, backwards: true}, animate); + }; + + this.revealRange = function(range, animate) { + this.$blockScrolling += 1; + this.session.unfold(range); + this.selection.setSelectionRange(range); + this.$blockScrolling -= 1; + + var scrollTop = this.renderer.scrollTop; + this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5); + if (animate != false) + this.renderer.animateScrolling(scrollTop); + }; + this.undo = function() { + this.$blockScrolling++; + this.session.getUndoManager().undo(); + this.$blockScrolling--; + this.renderer.scrollCursorIntoView(null, 0.5); + }; + this.redo = function() { + this.$blockScrolling++; + this.session.getUndoManager().redo(); + this.$blockScrolling--; + this.renderer.scrollCursorIntoView(null, 0.5); + }; + this.destroy = function() { + this.renderer.destroy(); + }; + +}).call(Editor.prototype); + + +exports.Editor = Editor; +}); + +ace.define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.stringReverse = function(string) { + return string.split("").reverse().join(""); +}; + +exports.stringRepeat = function (string, count) { + return new Array(count + 1).join(string); +}; + +var trimBeginRegexp = /^\s\s*/; +var trimEndRegexp = /\s\s*$/; + +exports.stringTrimLeft = function (string) { + return string.replace(trimBeginRegexp, ''); +}; + +exports.stringTrimRight = function (string) { + return string.replace(trimEndRegexp, ''); +}; + +exports.copyObject = function(obj) { + var copy = {}; + for (var key in obj) { + copy[key] = obj[key]; + } + return copy; +}; + +exports.copyArray = function(array){ + var copy = []; + for (var i=0, l=array.length; i 1) { + if (value.charAt(0) == PLACEHOLDER) + value = value.substr(1); + else if (value.charAt(value.length - 1) == PLACEHOLDER) + value = value.slice(0, -1); + } + + if (value && value != PLACEHOLDER) { + if (pasted) + host.onPaste(value); + else + host.onTextInput(value); + } + } + } + + copied = false; + pasted = false; + + // Safari doesn't fire copy events if no text is selected + reset(true); + } + + var onTextInput = function(e) { + if (!inCompostion) + sendText(e.data); + setTimeout(function () { + if (!inCompostion) + reset(true); + }, 0); + }; + + var onPropertyChange = function(e) { + setTimeout(function() { + if (!inCompostion) + if(text.value != "") { + sendText(); + } + }, 0); + }; + + var onCompositionStart = function(e) { + inCompostion = true; + host.onCompositionStart(); + setTimeout(onCompositionUpdate, 0); + }; + + var onCompositionUpdate = function() { + if (!inCompostion) return; + host.onCompositionUpdate(text.value); + }; + + var onCompositionEnd = function(e) { + inCompostion = false; + host.onCompositionEnd(); + }; + + var onCopy = function(e) { + copied = true; + var copyText = host.getCopyText(); + if(copyText) + text.value = copyText; + else + e.preventDefault(); + reset(); + setTimeout(function () { + sendText(); + }, 0); + }; + + var onCut = function(e) { + copied = true; + var copyText = host.getCopyText(); + if(copyText) { + text.value = copyText; + host.onCut(); + } else + e.preventDefault(); + reset(); + setTimeout(function () { + sendText(); + }, 0); + }; + + event.addCommandKeyListener(text, host.onCommandKey.bind(host)); + event.addListener(text, "input", onTextInput); + + if (useragent.isOldIE) { + var keytable = { 13:1, 27:1 }; + event.addListener(text, "keyup", function (e) { + if (inCompostion && (!text.value || keytable[e.keyCode])) + setTimeout(onCompositionEnd, 0); + if ((text.value.charCodeAt(0)|0) < 129) { + return; + } + inCompostion ? onCompositionUpdate() : onCompositionStart(); + }); + + event.addListener(text, "propertychange", function() { + if (text.value != PLACEHOLDER) + setTimeout(sendText, 0); + }); + } + + event.addListener(text, "paste", function(e) { + // Mark that the next input text comes from past. + pasted = true; + // Some browsers support the event.clipboardData API. Use this to get + // the pasted content which increases speed if pasting a lot of lines. + if (e.clipboardData && e.clipboardData.getData) { + sendText(e.clipboardData.getData("text/plain")); + e.preventDefault(); + } + else { + // If a browser doesn't support any of the things above, use the regular + // method to detect the pasted input. + onPropertyChange(); + } + }); + + if ("onbeforecopy" in text && typeof clipboardData !== "undefined") { + event.addListener(text, "beforecopy", function(e) { + if (tempStyle) + return; // without this text is copied when contextmenu is shown + var copyText = host.getCopyText(); + if (copyText) + clipboardData.setData("Text", copyText); + else + e.preventDefault(); + }); + event.addListener(parentNode, "keydown", function(e) { + if (e.ctrlKey && e.keyCode == 88) { + var copyText = host.getCopyText(); + if (copyText) { + clipboardData.setData("Text", copyText); + host.onCut(); + } + event.preventDefault(e); + } + }); + event.addListener(text, "cut", onCut); // for ie9 context menu + } + else if (useragent.isOpera && !("KeyboardEvent" in window)) { + event.addListener(parentNode, "keydown", function(e) { + if ((useragent.isMac && !e.metaKey) || !e.ctrlKey) + return; + + if ((e.keyCode == 88 || e.keyCode == 67)) { + var copyText = host.getCopyText(); + if (copyText) { + text.value = copyText; + text.select(); + if (e.keyCode == 88) + host.onCut(); + } + } + }); + } + else { + event.addListener(text, "copy", onCopy); + event.addListener(text, "cut", onCut); + } + + event.addListener(text, "compositionstart", onCompositionStart); + if (useragent.isGecko) { + event.addListener(text, "text", onCompositionUpdate); + } + if (useragent.isWebKit) { + event.addListener(text, "keyup", onCompositionUpdate); + } + event.addListener(text, "compositionend", onCompositionEnd); + + event.addListener(text, "blur", function() { + host.onBlur(); + }); + + event.addListener(text, "focus", function() { + host.onFocus(); + reset(); + }); + + this.focus = function() { + reset(); + text.focus(); + }; + + this.blur = function() { + text.blur(); + }; + + function isFocused() { + return document.activeElement === text; + } + this.isFocused = isFocused; + + this.getElement = function() { + return text; + }; + + this.onContextMenu = function(e) { + if (!tempStyle) + tempStyle = text.style.cssText; + + text.style.cssText = + "position:fixed; z-index:100000;" + + (useragent.isIE ? "background:rgba(0, 0, 0, 0.03); opacity:0.1;" : "") + //"background:rgba(250, 0, 0, 0.3); opacity:1;" + + "left:" + (e.clientX - 2) + "px; top:" + (e.clientY - 2) + "px;"; + + if (host.selection.isEmpty()) + text.value = ""; + else + reset(true); + + if (e.type != "mousedown") + return; + + if (host.renderer.$keepTextAreaAtCursor) + host.renderer.$keepTextAreaAtCursor = null; + + // on windows context menu is opened after mouseup + if (useragent.isWin && (useragent.isGecko || useragent.isIE)) + event.capture(host.container, function(e) { + text.style.left = e.clientX - 2 + "px"; + text.style.top = e.clientY - 2 + "px"; + }, onContextMenuClose); + }; + + function onContextMenuClose() { + setTimeout(function () { + if (tempStyle) { + text.style.cssText = tempStyle; + tempStyle = ''; + } + sendText(); + if (host.renderer.$keepTextAreaAtCursor == null) { + host.renderer.$keepTextAreaAtCursor = true; + host.renderer.$moveTextAreaToCursor(); + } + }, 0); + }; + this.onContextMenuClose = onContextMenuClose; + + // firefox fires contextmenu event after opening it + if (!useragent.isGecko) + event.addListener(text, "contextmenu", function(e) { + host.textInput.onContextMenu(e); + onContextMenuClose() + }); +}; + +exports.TextInput = TextInput; +}); + +ace.define('ace/mouse/mouse_handler', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/lib/useragent', 'ace/mouse/default_handlers', 'ace/mouse/default_gutter_handler', 'ace/mouse/mouse_event', 'ace/mouse/dragdrop'], function(require, exports, module) { + + +var event = require("../lib/event"); +var useragent = require("../lib/useragent"); +var DefaultHandlers = require("./default_handlers").DefaultHandlers; +var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler; +var MouseEvent = require("./mouse_event").MouseEvent; +var DragdropHandler = require("./dragdrop").DragdropHandler; + +var MouseHandler = function(editor) { + this.editor = editor; + + new DefaultHandlers(this); + new DefaultGutterHandler(this); + new DragdropHandler(this); + + event.addListener(editor.container, "mousedown", function(e) { + editor.focus(); + return event.preventDefault(e); + }); + + var mouseTarget = editor.renderer.getMouseEventTarget(); + event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click")); + event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove")); + event.addMultiMouseDownListener(mouseTarget, [300, 300, 250], this, "onMouseEvent"); + event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel")); + + var gutterEl = editor.renderer.$gutter; + event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown")); + event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick")); + event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick")); + event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove")); +}; + +(function() { + + this.$scrollSpeed = 1; + this.setScrollSpeed = function(speed) { + this.$scrollSpeed = speed; + }; + + this.getScrollSpeed = function() { + return this.$scrollSpeed; + }; + + this.onMouseEvent = function(name, e) { + this.editor._emit(name, new MouseEvent(e, this.editor)); + }; + + this.$dragDelay = 250; + this.setDragDelay = function(dragDelay) { + this.$dragDelay = dragDelay; + }; + + this.getDragDelay = function() { + return this.$dragDelay; + }; + + this.onMouseMove = function(name, e) { + // optimization, because mousemove doesn't have a default handler. + var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove; + if (!listeners || !listeners.length) + return; + + this.editor._emit(name, new MouseEvent(e, this.editor)); + }; + + this.onMouseWheel = function(name, e) { + var mouseEvent = new MouseEvent(e, this.editor); + mouseEvent.speed = this.$scrollSpeed * 2; + mouseEvent.wheelX = e.wheelX; + mouseEvent.wheelY = e.wheelY; + + this.editor._emit(name, mouseEvent); + }; + + this.setState = function(state) { + this.state = state; + }; + + this.captureMouse = function(ev, state) { + if (state) + this.setState(state); + + this.x = ev.x; + this.y = ev.y; + + // do not move textarea during selection + var renderer = this.editor.renderer; + if (renderer.$keepTextAreaAtCursor) + renderer.$keepTextAreaAtCursor = null; + + var self = this; + var onMouseMove = function(e) { + self.x = e.clientX; + self.y = e.clientY; + }; + + var onCaptureEnd = function(e) { + clearInterval(timerId); + self[self.state + "End"] && self[self.state + "End"](e); + self.$clickSelection = null; + if (renderer.$keepTextAreaAtCursor == null) { + renderer.$keepTextAreaAtCursor = true; + renderer.$moveTextAreaToCursor(); + } + }; + + var onCaptureInterval = function() { + self[self.state] && self[self.state](); + } + + if (useragent.isOldIE && ev.domEvent.type == "dblclick") { + setTimeout(function() { + onCaptureInterval(); + onCaptureEnd(ev.domEvent); + }); + return; + } + + event.capture(this.editor.container, onMouseMove, onCaptureEnd); + var timerId = setInterval(onCaptureInterval, 20); + }; +}).call(MouseHandler.prototype); + +exports.MouseHandler = MouseHandler; +}); + +ace.define('ace/mouse/default_handlers', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/useragent'], function(require, exports, module) { + + +var dom = require("../lib/dom"); +var useragent = require("../lib/useragent"); + +var DRAG_OFFSET = 5; // pixels + +function DefaultHandlers(mouseHandler) { + mouseHandler.$clickSelection = null; + + var editor = mouseHandler.editor; + editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler)); + editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler)); + editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler)); + editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler)); + editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler)); + + var exports = ["select", "startSelect", "drag", "dragEnd", "dragWait", + "dragWaitEnd", "startDrag", "focusWait"]; + + exports.forEach(function(x) { + mouseHandler[x] = this[x]; + }, this); + + mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange"); + mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange"); + + mouseHandler.$focusWaitTimout = 250; +} + +(function() { + + this.onMouseDown = function(ev) { + var inSelection = ev.inSelection(); + var pos = ev.getDocumentPosition(); + this.mousedownEvent = ev; + var editor = this.editor; + + var button = ev.getButton(); + if (button !== 0) { + var selectionRange = editor.getSelectionRange(); + var selectionEmpty = selectionRange.isEmpty(); + + if (selectionEmpty) { + editor.moveCursorToPosition(pos); + editor.selection.clearSelection(); + } + + // 2: contextmenu, 1: linux paste + editor.textInput.onContextMenu(ev.domEvent); + return; // stopping event here breaks contextmenu on ff mac + } + + // if this click caused the editor to be focused should not clear the + // selection + if (inSelection && !editor.isFocused()) { + editor.focus(); + if (this.$focusWaitTimout && !this.$clickSelection) { + this.setState("focusWait"); + this.captureMouse(ev); + return ev.preventDefault(); + } + } + + if (!inSelection || this.$clickSelection || ev.getShiftKey()) { + // Directly pick STATE_SELECT, since the user is not clicking inside + // a selection. + this.startSelect(pos); + } else if (inSelection) { + this.mousedownEvent.time = (new Date()).getTime(); + this.setState("dragWait"); + } + + this.captureMouse(ev); + return ev.preventDefault(); + }; + + this.startSelect = function(pos) { + pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y); + if (this.mousedownEvent.getShiftKey()) { + this.editor.selection.selectToPosition(pos); + } + else if (!this.$clickSelection) { + this.editor.moveCursorToPosition(pos); + this.editor.selection.clearSelection(); + } + this.setState("select"); + }; + + this.select = function() { + var anchor, editor = this.editor; + var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y); + + if (this.$clickSelection) { + var cmp = this.$clickSelection.comparePoint(cursor); + + if (cmp == -1) { + anchor = this.$clickSelection.end; + } else if (cmp == 1) { + anchor = this.$clickSelection.start; + } else { + var orientedRange = calcRangeOrientation(this.$clickSelection, cursor); + cursor = orientedRange.cursor; + anchor = orientedRange.anchor; + } + editor.selection.setSelectionAnchor(anchor.row, anchor.column); + } + editor.selection.selectToPosition(cursor); + + editor.renderer.scrollCursorIntoView(); + }; + + this.extendSelectionBy = function(unitName) { + var anchor, editor = this.editor; + var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y); + var range = editor.selection[unitName](cursor.row, cursor.column); + + if (this.$clickSelection) { + var cmpStart = this.$clickSelection.comparePoint(range.start); + var cmpEnd = this.$clickSelection.comparePoint(range.end); + + if (cmpStart == -1 && cmpEnd <= 0) { + anchor = this.$clickSelection.end; + if (range.end.row != cursor.row || range.end.column != cursor.column) + cursor = range.start; + } else if (cmpEnd == 1 && cmpStart >= 0) { + anchor = this.$clickSelection.start; + if (range.start.row != cursor.row || range.start.column != cursor.column) + cursor = range.end; + } else if (cmpStart == -1 && cmpEnd == 1) { + cursor = range.end; + anchor = range.start; + } else { + var orientedRange = calcRangeOrientation(this.$clickSelection, cursor); + cursor = orientedRange.cursor; + anchor = orientedRange.anchor; + } + editor.selection.setSelectionAnchor(anchor.row, anchor.column); + } + editor.selection.selectToPosition(cursor); + + editor.renderer.scrollCursorIntoView(); + }; + + this.startDrag = function() { + var editor = this.editor; + this.setState("drag"); + this.dragRange = editor.getSelectionRange(); + var style = editor.getSelectionStyle(); + this.dragSelectionMarker = editor.session.addMarker(this.dragRange, "ace_selection", style); + editor.clearSelection(); + dom.addCssClass(editor.container, "ace_dragging"); + if (!this.$dragKeybinding) { + this.$dragKeybinding = { + handleKeyboard: function(data, hashId, keyString, keyCode) { + if (keyString == "esc") + return {command: this.command}; + }, + command: { + exec: function(editor) { + var self = editor.$mouseHandler; + self.dragCursor = null; + self.dragEnd(); + self.startSelect(); + } + } + } + } + + editor.keyBinding.addKeyboardHandler(this.$dragKeybinding); + }; + + this.focusWait = function() { + var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y); + var time = (new Date()).getTime(); + + if (distance > DRAG_OFFSET ||time - this.mousedownEvent.time > this.$focusWaitTimout) + this.startSelect(); + }; + + this.dragWait = function(e) { + var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y); + var time = (new Date()).getTime(); + var editor = this.editor; + + if (distance > DRAG_OFFSET) { + this.startSelect(this.mousedownEvent.getDocumentPosition()); + } else if (time - this.mousedownEvent.time > editor.getDragDelay()) { + this.startDrag(); + } + }; + + this.dragWaitEnd = function(e) { + this.mousedownEvent.domEvent = e; + this.startSelect(); + }; + + this.drag = function() { + var editor = this.editor; + this.dragCursor = editor.renderer.screenToTextCoordinates(this.x, this.y); + editor.moveCursorToPosition(this.dragCursor); + editor.renderer.scrollCursorIntoView(); + }; + + this.dragEnd = function(e) { + var editor = this.editor; + var dragCursor = this.dragCursor; + var dragRange = this.dragRange; + dom.removeCssClass(editor.container, "ace_dragging"); + editor.session.removeMarker(this.dragSelectionMarker); + editor.keyBinding.removeKeyboardHandler(this.$dragKeybinding); + + if (!dragCursor) + return; + + editor.clearSelection(); + if (e && (e.ctrlKey || e.altKey)) { + var session = editor.session; + var newRange = dragRange; + newRange.end = session.insert(dragCursor, session.getTextRange(dragRange)); + newRange.start = dragCursor; + } else if (dragRange.contains(dragCursor.row, dragCursor.column)) { + return; + } else { + var newRange = editor.moveText(dragRange, dragCursor); + } + + if (!newRange) + return; + + editor.selection.setSelectionRange(newRange); + }; + + this.onDoubleClick = function(ev) { + var pos = ev.getDocumentPosition(); + var editor = this.editor; + var session = editor.session; + + var range = session.getBracketRange(pos); + if (range) { + if (range.isEmpty()) { + range.start.column--; + range.end.column++; + } + this.$clickSelection = range; + this.setState("select"); + return; + } + + this.$clickSelection = editor.selection.getWordRange(pos.row, pos.column); + this.setState("selectByWords"); + }; + + this.onTripleClick = function(ev) { + var pos = ev.getDocumentPosition(); + var editor = this.editor; + + this.setState("selectByLines"); + this.$clickSelection = editor.selection.getLineRange(pos.row); + }; + + this.onQuadClick = function(ev) { + var editor = this.editor; + + editor.selectAll(); + this.$clickSelection = editor.getSelectionRange(); + this.setState("null"); + }; + + this.onMouseWheel = function(ev) { + if (ev.getShiftKey() || ev.getAccelKey()){ + return; + } + var editor = this.editor; + var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed); + if (isScrolable) { + this.$passScrollEvent = false; + } else { + if (this.$passScrollEvent) + return; + + if (!this.$scrollStopTimeout) { + var self = this; + this.$scrollStopTimeout = setTimeout(function() { + self.$passScrollEvent = true; + self.$scrollStopTimeout = null; + }, 200); + } + } + + editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed); + return ev.preventDefault(); + }; + +}).call(DefaultHandlers.prototype); + +exports.DefaultHandlers = DefaultHandlers; + +function calcDistance(ax, ay, bx, by) { + return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2)); +} + +function calcRangeOrientation(range, cursor) { + if (range.start.row == range.end.row) + var cmp = 2 * cursor.column - range.start.column - range.end.column; + else + var cmp = 2 * cursor.row - range.start.row - range.end.row; + + if (cmp < 0) + return {cursor: range.start, anchor: range.end}; + else + return {cursor: range.end, anchor: range.start}; +} + +}); + +ace.define('ace/mouse/default_gutter_handler', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/event'], function(require, exports, module) { + +var dom = require("../lib/dom"); +var event = require("../lib/event"); + +function GutterHandler(mouseHandler) { + var editor = mouseHandler.editor; + var gutter = editor.renderer.$gutterLayer; + + mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) { + if (!editor.isFocused()) + return; + var gutterRegion = gutter.getRegion(e); + + if (gutterRegion) + return; + + var row = e.getDocumentPosition().row; + var selection = editor.session.selection; + + if (e.getShiftKey()) + selection.selectTo(row, 0); + else + mouseHandler.$clickSelection = editor.selection.getLineRange(row); + + mouseHandler.captureMouse(e, "selectByLines"); + return e.preventDefault(); + }); + + + var tooltipTimeout, mouseEvent, tooltip, tooltipAnnotation; + function createTooltip() { + tooltip = dom.createElement("div"); + tooltip.className = "ace_gutter_tooltip"; + tooltip.style.maxWidth = "500px"; + tooltip.style.display = "none"; + editor.container.appendChild(tooltip); + } + + function showTooltip() { + if (!tooltip) { + createTooltip(); + } + var row = mouseEvent.getDocumentPosition().row; + var annotation = gutter.$annotations[row]; + if (!annotation) + return hideTooltip(); + + var maxRow = editor.session.getLength(); + if (row == maxRow) { + var screenRow = editor.renderer.pixelToScreenCoordinates(0, mouseEvent.y).row; + var pos = mouseEvent.$pos; + if (screenRow > editor.session.documentToScreenRow(pos.row, pos.column)) + return hideTooltip(); + } + + if (tooltipAnnotation == annotation) + return; + tooltipAnnotation = annotation.text.join("\n"); + + tooltip.style.display = "block"; + tooltip.innerHTML = tooltipAnnotation; + editor.on("mousewheel", hideTooltip); + + moveTooltip(mouseEvent); + } + + function hideTooltip() { + if (tooltipTimeout) + tooltipTimeout = clearTimeout(tooltipTimeout); + if (tooltipAnnotation) { + tooltip.style.display = "none"; + tooltipAnnotation = null; + editor.removeEventListener("mousewheel", hideTooltip); + } + } + + function moveTooltip(e) { + var rect = editor.renderer.$gutter.getBoundingClientRect(); + tooltip.style.left = e.x - rect.left + 15 + "px"; + if (e.y + 3 * editor.renderer.lineHeight + 15 < rect.bottom) { + tooltip.style.bottom = ""; + tooltip.style.top = e.y - rect.top + 15 + "px"; + } else { + tooltip.style.top = ""; + tooltip.style.bottom = rect.bottom - e.y + 5 + "px"; + } + } + + mouseHandler.editor.setDefaultHandler("guttermousemove", function(e) { + var target = e.domEvent.target || e.domEvent.srcElement; + if (dom.hasCssClass(target, "ace_fold-widget")) + return hideTooltip(); + + if (tooltipAnnotation) + moveTooltip(e); + + mouseEvent = e; + if (tooltipTimeout) + return; + tooltipTimeout = setTimeout(function() { + tooltipTimeout = null; + if (mouseEvent) + showTooltip(); + else + hideTooltip(); + }, 50); + }); + + event.addListener(editor.renderer.$gutter, "mouseout", function(e) { + mouseEvent = null; + if (!tooltipAnnotation || tooltipTimeout) + return; + + tooltipTimeout = setTimeout(function() { + tooltipTimeout = null; + hideTooltip(); + }, 50); + }); + +} + +exports.GutterHandler = GutterHandler; + +}); + +ace.define('ace/mouse/mouse_event', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/lib/useragent'], function(require, exports, module) { + + +var event = require("../lib/event"); +var useragent = require("../lib/useragent"); +var MouseEvent = exports.MouseEvent = function(domEvent, editor) { + this.domEvent = domEvent; + this.editor = editor; + + this.x = this.clientX = domEvent.clientX; + this.y = this.clientY = domEvent.clientY; + + this.$pos = null; + this.$inSelection = null; + + this.propagationStopped = false; + this.defaultPrevented = false; +}; + +(function() { + + this.stopPropagation = function() { + event.stopPropagation(this.domEvent); + this.propagationStopped = true; + }; + + this.preventDefault = function() { + event.preventDefault(this.domEvent); + this.defaultPrevented = true; + }; + + this.stop = function() { + this.stopPropagation(); + this.preventDefault(); + }; + this.getDocumentPosition = function() { + if (this.$pos) + return this.$pos; + + this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY); + return this.$pos; + }; + this.inSelection = function() { + if (this.$inSelection !== null) + return this.$inSelection; + + var editor = this.editor; + + if (editor.getReadOnly()) { + this.$inSelection = false; + } + else { + var selectionRange = editor.getSelectionRange(); + if (selectionRange.isEmpty()) + this.$inSelection = false; + else { + var pos = this.getDocumentPosition(); + this.$inSelection = selectionRange.contains(pos.row, pos.column); + } + } + return this.$inSelection; + }; + this.getButton = function() { + return event.getButton(this.domEvent); + }; + this.getShiftKey = function() { + return this.domEvent.shiftKey; + }; + + this.getAccelKey = useragent.isMac + ? function() { return this.domEvent.metaKey; } + : function() { return this.domEvent.ctrlKey; }; + +}).call(MouseEvent.prototype); + +}); + +ace.define('ace/mouse/dragdrop', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) { + + +var event = require("../lib/event"); + +var DragdropHandler = function(mouseHandler) { + var editor = mouseHandler.editor; + var dragSelectionMarker, x, y; + var timerId, range, isBackwards; + var dragCursor, counter = 0; + + var mouseTarget = editor.container; + event.addListener(mouseTarget, "dragenter", function(e) { + counter++; + if (!dragSelectionMarker) { + range = editor.getSelectionRange(); + isBackwards = editor.selection.isBackwards(); + var style = editor.getSelectionStyle(); + dragSelectionMarker = editor.session.addMarker(range, "ace_selection", style); + editor.clearSelection(); + clearInterval(timerId); + timerId = setInterval(onDragInterval, 20); + } + return event.preventDefault(e); + }); + + event.addListener(mouseTarget, "dragover", function(e) { + x = e.clientX; + y = e.clientY; + return event.preventDefault(e); + }); + + var onDragInterval = function() { + dragCursor = editor.renderer.screenToTextCoordinates(x, y); + editor.moveCursorToPosition(dragCursor); + editor.renderer.scrollCursorIntoView(); + }; + + event.addListener(mouseTarget, "dragleave", function(e) { + counter--; + if (counter > 0) + return; + console.log(e.type, counter,e.target); + clearInterval(timerId); + editor.session.removeMarker(dragSelectionMarker); + dragSelectionMarker = null; + editor.selection.setSelectionRange(range, isBackwards); + return event.preventDefault(e); + }); + + event.addListener(mouseTarget, "drop", function(e) { + console.log(e.type, counter,e.target); + counter = 0; + clearInterval(timerId); + editor.session.removeMarker(dragSelectionMarker); + dragSelectionMarker = null; + + range.end = editor.session.insert(dragCursor, e.dataTransfer.getData('Text')); + range.start = dragCursor; + editor.focus(); + editor.selection.setSelectionRange(range); + return event.preventDefault(e); + }); + +}; + +exports.DragdropHandler = DragdropHandler; +}); + +ace.define('ace/mouse/fold_handler', ['require', 'exports', 'module' ], function(require, exports, module) { + + +function FoldHandler(editor) { + + editor.on("click", function(e) { + var position = e.getDocumentPosition(); + var session = editor.session; + + // If the user clicked on a fold, then expand it. + var fold = session.getFoldAt(position.row, position.column, 1); + if (fold) { + if (e.getAccelKey()) + session.removeFold(fold); + else + session.expandFold(fold); + + e.stop(); + } + }); + + editor.on("gutterclick", function(e) { + var gutterRegion = editor.renderer.$gutterLayer.getRegion(e); + + if (gutterRegion == "foldWidgets") { + var row = e.getDocumentPosition().row; + var session = editor.session; + if (session.foldWidgets && session.foldWidgets[row]) + editor.session.onFoldWidgetClick(row, e); + e.stop(); + } + }); +} + +exports.FoldHandler = FoldHandler; + +}); + +ace.define('ace/keyboard/keybinding', ['require', 'exports', 'module' , 'ace/lib/keys', 'ace/lib/event'], function(require, exports, module) { + + +var keyUtil = require("../lib/keys"); +var event = require("../lib/event"); + +var KeyBinding = function(editor) { + this.$editor = editor; + this.$data = { }; + this.$handlers = []; + this.setDefaultHandler(editor.commands); +}; + +(function() { + this.setDefaultHandler = function(kb) { + this.removeKeyboardHandler(this.$defaultHandler); + this.$defaultHandler = kb; + this.addKeyboardHandler(kb, 0); + this.$data = {editor: this.$editor}; + }; + + this.setKeyboardHandler = function(kb) { + if (this.$handlers[this.$handlers.length - 1] == kb) + return; + + while (this.$handlers[1]) + this.removeKeyboardHandler(this.$handlers[1]); + + this.addKeyboardHandler(kb, 1); + }; + + this.addKeyboardHandler = function(kb, pos) { + if (!kb) + return; + var i = this.$handlers.indexOf(kb); + if (i != -1) + this.$handlers.splice(i, 1); + + if (pos == undefined) + this.$handlers.push(kb); + else + this.$handlers.splice(pos, 0, kb); + + if (i == -1 && kb.attach) + kb.attach(this.$editor); + }; + + this.removeKeyboardHandler = function(kb) { + var i = this.$handlers.indexOf(kb); + if (i == -1) + return false; + this.$handlers.splice(i, 1); + kb.detach && kb.detach(this.$editor); + return true; + }; + + this.getKeyboardHandler = function() { + return this.$handlers[this.$handlers.length - 1]; + }; + + this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) { + var toExecute; + for (var i = this.$handlers.length; i--;) { + toExecute = this.$handlers[i].handleKeyboard( + this.$data, hashId, keyString, keyCode, e + ); + if (toExecute && toExecute.command) + break; + } + + if (!toExecute || !toExecute.command) + return false; + + var success = false; + var commands = this.$editor.commands; + + // allow keyboardHandler to consume keys + if (toExecute.command != "null") + success = commands.exec(toExecute.command, this.$editor, toExecute.args, e); + else + success = toExecute.passEvent != true; + + // do not stop input events to not break repeating + if (success && e && hashId != -1) + event.stopEvent(e); + + return success; + }; + + this.onCommandKey = function(e, hashId, keyCode) { + var keyString = keyUtil.keyCodeToString(keyCode); + this.$callKeyboardHandlers(hashId, keyString, keyCode, e); + }; + + this.onTextInput = function(text) { + var success = this.$callKeyboardHandlers(-1, text); + if (!success) + this.$editor.commands.exec("insertstring", this.$editor, text); + }; + +}).call(KeyBinding.prototype); + +exports.KeyBinding = KeyBinding; +}); + +ace.define('ace/edit_session', ['require', 'exports', 'module' , 'ace/config', 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/net', 'ace/lib/event_emitter', 'ace/selection', 'ace/mode/text', 'ace/range', 'ace/document', 'ace/background_tokenizer', 'ace/search_highlight', 'ace/edit_session/folding', 'ace/edit_session/bracket_match'], function(require, exports, module) { + + +var config = require("./config"); +var oop = require("./lib/oop"); +var lang = require("./lib/lang"); +var net = require("./lib/net"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var Selection = require("./selection").Selection; +var TextMode = require("./mode/text").Mode; +var Range = require("./range").Range; +var Document = require("./document").Document; +var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer; +var SearchHighlight = require("./search_highlight").SearchHighlight; + +// events +/** + * EditSession@change(e) + * - e (Object): An object containing a `delta` of information about the change. + * + * Emitted when the document changes. + **/ +/** + * EditSession@changeTabSize() + * + * Emitted when the tab size changes, via [[EditSession.setTabSize]]. + **/ +/** + * EditSession@changeOverwrite() + * + * Emitted when the ability to overwrite text changes, via [[EditSession.setOverwrite]]. + **/ +/** + * EditSession@changeBreakpoint() + * + * Emitted when the gutter changes, either by setting or removing breakpoints, or when the gutter decorations change. + **/ +/** + * EditSession@changeFrontMarker() + * + * Emitted when a front marker changes. + **/ +/** + * EditSession@changeBackMarker() + * + * Emitted when a back marker changes. + **/ +/** + * EditSession@changeAnnotation() + * + * Emitted when an annotation changes, like through [[EditSession.setAnnotations]]. + **/ +/** + * EditSession@tokenizerUpdate(e) + * - e (Object): An object containing one property, `"data"`, that contains information about the changing rows + * + * Emitted when a background tokenizer asynchronously processes new rows. + * + **/ +/** hide + * EditSession@loadMode(e) + * + * + * + **/ +/** + * EditSession@changeMode() + * + * Emitted when the current mode changes. + * + **/ +/** + * EditSession@changeWrapMode() + * + * Emitted when the wrap mode changes. + * + **/ +/** + * EditSession@changeWrapLimit() + * + * Emitted when the wrapping limit changes. + * + **/ +/** + * EditSession@changeFold(e) + * + * Emitted when a code fold is added or removed. + * + **/ + /** + * EditSession@changeScrollTop(scrollTop) + * - scrollTop (Number): The new scroll top value + * + * Emitted when the scroll top changes. + **/ +/** + * EditSession@changeScrollLeft(scrollLeft) + * - scrollLeft (Number): The new scroll left value + * + * Emitted when the scroll left changes. + **/ + + +/** + * new EditSession(text, mode) + * - text (Document | String): If `text` is a `Document`, it associates the `EditSession` with it. Otherwise, a new `Document` is created, with the initial text + * - mode (TextMode): The inital language mode to use for the document + * + * Sets up a new `EditSession` and associates it with the given `Document` and `TextMode`. + * + **/ + +var EditSession = function(text, mode) { + this.$modified = true; + this.$breakpoints = []; + this.$decorations = []; + this.$frontMarkers = {}; + this.$backMarkers = {}; + this.$markerId = 1; + this.$resetRowCache(0); + this.$wrapData = []; + this.$foldData = []; + this.$rowLengthCache = []; + this.$undoSelect = true; + this.$foldData.toString = function() { + var str = ""; + this.forEach(function(foldLine) { + str += "\n" + foldLine.toString(); + }); + return str; + } + + if (typeof text == "object" && text.getLine) { + this.setDocument(text); + } else { + this.setDocument(new Document(text)); + } + + this.selection = new Selection(this); + this.setMode(mode); +}; + + +(function() { + + oop.implement(this, EventEmitter); + this.setDocument = function(doc) { + if (this.doc) + throw new Error("Document is already set"); + + this.doc = doc; + doc.on("change", this.onChange.bind(this)); + this.on("changeFold", this.onChangeFold.bind(this)); + + if (this.bgTokenizer) { + this.bgTokenizer.setDocument(this.getDocument()); + this.bgTokenizer.start(0); + } + }; + this.getDocument = function() { + return this.doc; + }; + this.$resetRowCache = function(docRow) { + if (!docRow) { + this.$docRowCache = []; + this.$screenRowCache = []; + return; + } + + var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1; + var l = this.$docRowCache.length; + this.$docRowCache.splice(i, l); + this.$screenRowCache.splice(i, l); + + }; + + this.$getRowCacheIndex = function(cacheArray, val) { + var low = 0; + var hi = cacheArray.length - 1; + + while (low <= hi) { + var mid = (low + hi) >> 1; + var c = cacheArray[mid]; + + if (val > c) + low = mid + 1; + else if (val < c) + hi = mid - 1; + else + return mid; + } + + return low && low -1; + }; + + this.onChangeFold = function(e) { + var fold = e.data; + this.$resetRowCache(fold.start.row); + }; + + this.onChange = function(e) { + var delta = e.data; + this.$modified = true; + + this.$resetRowCache(delta.range.start.row); + + var removedFolds = this.$updateInternalDataOnChange(e); + if (!this.$fromUndo && this.$undoManager && !delta.ignore) { + this.$deltasDoc.push(delta); + if (removedFolds && removedFolds.length != 0) { + this.$deltasFold.push({ + action: "removeFolds", + folds: removedFolds + }); + } + + this.$informUndoManager.schedule(); + } + + this.bgTokenizer.$updateOnChange(delta); + this._emit("change", e); + }; + this.setValue = function(text) { + this.doc.setValue(text); + this.selection.moveCursorTo(0, 0); + this.selection.clearSelection(); + + this.$resetRowCache(0); + this.$deltas = []; + this.$deltasDoc = []; + this.$deltasFold = []; + this.getUndoManager().reset(); + }; + /** alias of: EditSession.getValue + * EditSession.toString() -> String + * + * Returns the current [[Document `Document`]] as a string. + * + **/ + this.getValue = + this.toString = function() { + return this.doc.getValue(); + }; + this.getSelection = function() { + return this.selection; + }; + this.getState = function(row) { + return this.bgTokenizer.getState(row); + }; + this.getTokens = function(row) { + return this.bgTokenizer.getTokens(row); + }; + this.getTokenAt = function(row, column) { + var tokens = this.bgTokenizer.getTokens(row); + var token, c = 0; + if (column == null) { + i = tokens.length - 1; + c = this.getLine(row).length; + } else { + for (var i = 0; i < tokens.length; i++) { + c += tokens[i].value.length; + if (c >= column) + break; + } + } + token = tokens[i]; + if (!token) + return null; + token.index = i; + token.start = c - token.value.length; + return token; + }; + + this.highlight = function(re) { + if (!this.$searchHighlight) { + var highlight = new SearchHighlight(null, "ace_selected_word", "text"); + this.$searchHighlight = this.addDynamicMarker(highlight); + } + this.$searchHighlight.setRegexp(re); + } + /** + * EditSession.setUndoManager(undoManager) + * - undoManager (UndoManager): The new undo manager + * + * Sets the undo manager. + **/ + this.setUndoManager = function(undoManager) { + this.$undoManager = undoManager; + this.$deltas = []; + this.$deltasDoc = []; + this.$deltasFold = []; + + if (this.$informUndoManager) + this.$informUndoManager.cancel(); + + if (undoManager) { + var self = this; + this.$syncInformUndoManager = function() { + self.$informUndoManager.cancel(); + + if (self.$deltasFold.length) { + self.$deltas.push({ + group: "fold", + deltas: self.$deltasFold + }); + self.$deltasFold = []; + } + + if (self.$deltasDoc.length) { + self.$deltas.push({ + group: "doc", + deltas: self.$deltasDoc + }); + self.$deltasDoc = []; + } + + if (self.$deltas.length > 0) { + undoManager.execute({ + action: "aceupdate", + args: [self.$deltas, self] + }); + } + + self.$deltas = []; + } + this.$informUndoManager = + lang.deferredCall(this.$syncInformUndoManager); + } + }; + + this.$defaultUndoManager = { + undo: function() {}, + redo: function() {}, + reset: function() {} + }; + this.getUndoManager = function() { + return this.$undoManager || this.$defaultUndoManager; + }, + + /** + * EditSession.getTabString() -> String + * + * Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by [[EditSession.getTabSize `getTabSize()`]]); otherwise it's simply `'\t'`. + **/ + this.getTabString = function() { + if (this.getUseSoftTabs()) { + return lang.stringRepeat(" ", this.getTabSize()); + } else { + return "\t"; + } + }; + + this.$useSoftTabs = true; + this.setUseSoftTabs = function(useSoftTabs) { + if (this.$useSoftTabs === useSoftTabs) return; + + this.$useSoftTabs = useSoftTabs; + }; + this.getUseSoftTabs = function() { + return this.$useSoftTabs; + }; + + this.$tabSize = 4; + this.setTabSize = function(tabSize) { + if (isNaN(tabSize) || this.$tabSize === tabSize) return; + + this.$modified = true; + this.$rowLengthCache = []; + this.$tabSize = tabSize; + this._emit("changeTabSize"); + }; + this.getTabSize = function() { + return this.$tabSize; + }; + this.isTabStop = function(position) { + return this.$useSoftTabs && (position.column % this.$tabSize == 0); + }; + + this.$overwrite = false; + this.setOverwrite = function(overwrite) { + if (this.$overwrite == overwrite) return; + + this.$overwrite = overwrite; + this._emit("changeOverwrite"); + }; + this.getOverwrite = function() { + return this.$overwrite; + }; + this.toggleOverwrite = function() { + this.setOverwrite(!this.$overwrite); + }; + this.addGutterDecoration = function(row, className) { + if (!this.$decorations[row]) + this.$decorations[row] = ""; + this.$decorations[row] += " " + className; + this._emit("changeBreakpoint", {}); + }; + this.removeGutterDecoration = function(row, className) { + this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, ""); + this._emit("changeBreakpoint", {}); + }; + this.getBreakpoints = function() { + return this.$breakpoints; + }; + this.setBreakpoints = function(rows) { + this.$breakpoints = []; + for (var i=0; i 0) + inToken = !!line.charAt(column - 1).match(this.tokenRe); + + if (!inToken) + inToken = !!line.charAt(column).match(this.tokenRe); + + if (inToken) + var re = this.tokenRe; + else if (/^\s+$/.test(line.slice(column-1, column+1))) + var re = /\s/; + else + var re = this.nonTokenRe; + + var start = column; + if (start > 0) { + do { + start--; + } + while (start >= 0 && line.charAt(start).match(re)); + start++; + } + + var end = column; + while (end < line.length && line.charAt(end).match(re)) { + end++; + } + + return new Range(row, start, row, end); + }; + this.getAWordRange = function(row, column) { + var wordRange = this.getWordRange(row, column); + var line = this.getLine(wordRange.end.row); + + while (line.charAt(wordRange.end.column).match(/[ \t]/)) { + wordRange.end.column += 1; + } + return wordRange; + }; + this.setNewLineMode = function(newLineMode) { + this.doc.setNewLineMode(newLineMode); + }; + this.getNewLineMode = function() { + return this.doc.getNewLineMode(); + }; + + this.$useWorker = true; + this.setUseWorker = function(useWorker) { + if (this.$useWorker == useWorker) + return; + + this.$useWorker = useWorker; + + this.$stopWorker(); + if (useWorker) + this.$startWorker(); + }; + this.getUseWorker = function() { + return this.$useWorker; + }; + this.onReloadTokenizer = function(e) { + var rows = e.data; + this.bgTokenizer.start(rows.first); + this._emit("tokenizerUpdate", e); + }; + + this.$modes = {}; + this._loadMode = function(mode, callback) { + if (!this.$modes["null"]) + this.$modes["null"] = this.$modes["ace/mode/text"] = new TextMode(); + + if (this.$modes[mode]) + return callback(this.$modes[mode]); + + var _self = this; + var module; + try { + module = require(mode); + } catch (e) {}; + // sometimes require returns empty object (this bug is present in requirejs 2 as well) + if (module && module.Mode) + return done(module); + + // set mode to text until loading is finished + if (!this.$mode) + this.$setModePlaceholder(); + + fetch(mode, function() { + require([mode], done); + }); + + function done(module) { + if (_self.$modes[mode]) + return callback(_self.$modes[mode]); + + _self.$modes[mode] = new module.Mode(); + _self.$modes[mode].$id = mode; + _self._emit("loadmode", { + name: mode, + mode: _self.$modes[mode] + }); + callback(_self.$modes[mode]); + } + + function fetch(name, callback) { + if (!config.get("packaged")) + return callback(); + + net.loadScript(config.moduleUrl(name, "mode"), callback); + } + }; + + this.$setModePlaceholder = function() { + this.$mode = this.$modes["null"]; + var tokenizer = this.$mode.getTokenizer(); + + if (!this.bgTokenizer) { + this.bgTokenizer = new BackgroundTokenizer(tokenizer); + var _self = this; + this.bgTokenizer.addEventListener("update", function(e) { + _self._emit("tokenizerUpdate", e); + }); + } else { + this.bgTokenizer.setTokenizer(tokenizer); + } + this.bgTokenizer.setDocument(this.getDocument()); + + this.tokenRe = this.$mode.tokenRe; + this.nonTokenRe = this.$mode.nonTokenRe; + }; + this.$mode = null; + this.$modeId = null; + this.setMode = function(mode) { + mode = mode || "null"; + // load on demand + if (typeof mode === "string") { + if (this.$modeId == mode) + return; + + this.$modeId = mode; + var _self = this; + this._loadMode(mode, function(module) { + if (_self.$modeId !== mode) + return; + + _self.setMode(module); + }); + return; + } + + if (this.$mode === mode) return; + this.$mode = mode; + this.$modeId = mode.$id; + + this.$stopWorker(); + + if (this.$useWorker) + this.$startWorker(); + + var tokenizer = mode.getTokenizer(); + + if(tokenizer.addEventListener !== undefined) { + var onReloadTokenizer = this.onReloadTokenizer.bind(this); + tokenizer.addEventListener("update", onReloadTokenizer); + } + + if (!this.bgTokenizer) { + this.bgTokenizer = new BackgroundTokenizer(tokenizer); + var _self = this; + this.bgTokenizer.addEventListener("update", function(e) { + _self._emit("tokenizerUpdate", e); + }); + } else { + this.bgTokenizer.setTokenizer(tokenizer); + } + + this.bgTokenizer.setDocument(this.getDocument()); + this.bgTokenizer.start(0); + + this.tokenRe = mode.tokenRe; + this.nonTokenRe = mode.nonTokenRe; + + this.$setFolding(mode.foldingRules); + + this._emit("changeMode"); + }; + this.$stopWorker = function() { + if (this.$worker) + this.$worker.terminate(); + + this.$worker = null; + }; + this.$startWorker = function() { + if (typeof Worker !== "undefined" && !require.noWorker) { + try { + this.$worker = this.$mode.createWorker(this); + } catch (e) { + console.log("Could not load worker"); + console.log(e); + this.$worker = null; + } + } + else + this.$worker = null; + }; + this.getMode = function() { + return this.$mode; + }; + + this.$scrollTop = 0; + this.setScrollTop = function(scrollTop) { + scrollTop = Math.round(Math.max(0, scrollTop)); + if (this.$scrollTop === scrollTop) + return; + + this.$scrollTop = scrollTop; + this._emit("changeScrollTop", scrollTop); + }; + this.getScrollTop = function() { + return this.$scrollTop; + }; + + this.$scrollLeft = 0; + this.setScrollLeft = function(scrollLeft) { + scrollLeft = Math.round(Math.max(0, scrollLeft)); + if (this.$scrollLeft === scrollLeft) + return; + + this.$scrollLeft = scrollLeft; + this._emit("changeScrollLeft", scrollLeft); + }; + this.getScrollLeft = function() { + return this.$scrollLeft; + }; + this.getScreenWidth = function() { + this.$computeWidth(); + return this.screenWidth; + }; + + this.$computeWidth = function(force) { + if (this.$modified || force) { + this.$modified = false; + + if (this.$useWrapMode) + return this.screenWidth = this.$wrapLimit; + + var lines = this.doc.getAllLines(); + var cache = this.$rowLengthCache; + var longestScreenLine = 0; + var foldIndex = 0; + var foldLine = this.$foldData[foldIndex]; + var foldStart = foldLine ? foldLine.start.row : Infinity; + var len = lines.length; + + for (var i = 0; i < len; i++) { + if (i > foldStart) { + i = foldLine.end.row + 1; + if (i >= len) + break; + foldLine = this.$foldData[foldIndex++]; + foldStart = foldLine ? foldLine.start.row : Infinity; + } + + if (cache[i] == null) + cache[i] = this.$getStringScreenWidth(lines[i])[0]; + + if (cache[i] > longestScreenLine) + longestScreenLine = cache[i]; + } + this.screenWidth = longestScreenLine; + } + }; + this.getLine = function(row) { + return this.doc.getLine(row); + }; + this.getLines = function(firstRow, lastRow) { + return this.doc.getLines(firstRow, lastRow); + }; + this.getLength = function() { + return this.doc.getLength(); + }; + this.getTextRange = function(range) { + return this.doc.getTextRange(range || this.selection.getRange()); + }; + this.insert = function(position, text) { + return this.doc.insert(position, text); + }; + this.remove = function(range) { + return this.doc.remove(range); + }; + this.undoChanges = function(deltas, dontSelect) { + if (!deltas.length) + return; + + this.$fromUndo = true; + var lastUndoRange = null; + for (var i = deltas.length - 1; i != -1; i--) { + var delta = deltas[i]; + if (delta.group == "doc") { + this.doc.revertDeltas(delta.deltas); + lastUndoRange = + this.$getUndoSelection(delta.deltas, true, lastUndoRange); + } else { + delta.deltas.forEach(function(foldDelta) { + this.addFolds(foldDelta.folds); + }, this); + } + } + this.$fromUndo = false; + lastUndoRange && + this.$undoSelect && + !dontSelect && + this.selection.setSelectionRange(lastUndoRange); + return lastUndoRange; + }; + this.redoChanges = function(deltas, dontSelect) { + if (!deltas.length) + return; + + this.$fromUndo = true; + var lastUndoRange = null; + for (var i = 0; i < deltas.length; i++) { + var delta = deltas[i]; + if (delta.group == "doc") { + this.doc.applyDeltas(delta.deltas); + lastUndoRange = + this.$getUndoSelection(delta.deltas, false, lastUndoRange); + } + } + this.$fromUndo = false; + lastUndoRange && + this.$undoSelect && + !dontSelect && + this.selection.setSelectionRange(lastUndoRange); + return lastUndoRange; + }; + this.setUndoSelect = function(enable) { + this.$undoSelect = enable; + }; + this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) { + function isInsert(delta) { + var insert = + delta.action == "insertText" || delta.action == "insertLines"; + return isUndo ? !insert : insert; + } + + var delta = deltas[0]; + var range, point; + var lastDeltaIsInsert = false; + if (isInsert(delta)) { + range = delta.range.clone(); + lastDeltaIsInsert = true; + } else { + range = Range.fromPoints(delta.range.start, delta.range.start); + lastDeltaIsInsert = false; + } + + for (var i = 1; i < deltas.length; i++) { + delta = deltas[i]; + if (isInsert(delta)) { + point = delta.range.start; + if (range.compare(point.row, point.column) == -1) { + range.setStart(delta.range.start); + } + point = delta.range.end; + if (range.compare(point.row, point.column) == 1) { + range.setEnd(delta.range.end); + } + lastDeltaIsInsert = true; + } else { + point = delta.range.start; + if (range.compare(point.row, point.column) == -1) { + range = + Range.fromPoints(delta.range.start, delta.range.start); + } + lastDeltaIsInsert = false; + } + } + + // Check if this range and the last undo range has something in common. + // If true, merge the ranges. + if (lastUndoRange != null) { + var cmp = lastUndoRange.compareRange(range); + if (cmp == 1) { + range.setStart(lastUndoRange.start); + } else if (cmp == -1) { + range.setEnd(lastUndoRange.end); + } + } + + return range; + }, + + /** related to: Document.replace + * EditSession.replace(range, text) -> Object + * - range (Range): A specified Range to replace + * - text (String): The new text to use as a replacement + * + (Object): Returns an object containing the final row and column, like this:
    + * ```{row: endRow, column: 0}```
    + * If the text and range are empty, this function returns an object containing the current `range.start` value.
    + * If the text is the exact same as what currently exists, this function returns an object containing the current `range.end` value. + * + * Replaces a range in the document with the new `text`. + * + * + * + **/ + this.replace = function(range, text) { + return this.doc.replace(range, text); + }; + this.moveText = function(fromRange, toPosition) { + var text = this.getTextRange(fromRange); + this.remove(fromRange); + + var toRow = toPosition.row; + var toColumn = toPosition.column; + + // Make sure to update the insert location, when text is removed in + // front of the chosen point of insertion. + if (!fromRange.isMultiLine() && fromRange.start.row == toRow && + fromRange.end.column < toColumn) + toColumn -= text.length; + + if (fromRange.isMultiLine() && fromRange.end.row < toRow) { + var lines = this.doc.$split(text); + toRow -= lines.length - 1; + } + + var endRow = toRow + fromRange.end.row - fromRange.start.row; + var endColumn = fromRange.isMultiLine() ? + fromRange.end.column : + toColumn + fromRange.end.column - fromRange.start.column; + + var toRange = new Range(toRow, toColumn, endRow, endColumn); + + this.insert(toRange.start, text); + + return toRange; + }; + this.indentRows = function(startRow, endRow, indentString) { + indentString = indentString.replace(/\t/g, this.getTabString()); + for (var row=startRow; row<=endRow; row++) + this.insert({row: row, column:0}, indentString); + }; + this.outdentRows = function (range) { + var rowRange = range.collapseRows(); + var deleteRange = new Range(0, 0, 0, 0); + var size = this.getTabSize(); + + for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) { + var line = this.getLine(i); + + deleteRange.start.row = i; + deleteRange.end.row = i; + for (var j = 0; j < size; ++j) + if (line.charAt(j) != ' ') + break; + if (j < size && line.charAt(j) == '\t') { + deleteRange.start.column = j; + deleteRange.end.column = j + 1; + } else { + deleteRange.start.column = 0; + deleteRange.end.column = j; + } + this.remove(deleteRange); + } + }; + this.moveLinesUp = function(firstRow, lastRow) { + if (firstRow <= 0) return 0; + + var removed = this.doc.removeLines(firstRow, lastRow); + this.doc.insertLines(firstRow - 1, removed); + return -1; + }; + this.moveLinesDown = function(firstRow, lastRow) { + if (lastRow >= this.doc.getLength()-1) return 0; + + var removed = this.doc.removeLines(firstRow, lastRow); + this.doc.insertLines(firstRow+1, removed); + return 1; + }; + this.duplicateLines = function(firstRow, lastRow) { + var firstRow = this.$clipRowToDocument(firstRow); + var lastRow = this.$clipRowToDocument(lastRow); + + var lines = this.getLines(firstRow, lastRow); + this.doc.insertLines(firstRow, lines); + + var addedRows = lastRow - firstRow + 1; + return addedRows; + }; + + + this.$clipRowToDocument = function(row) { + return Math.max(0, Math.min(row, this.doc.getLength()-1)); + }; + + this.$clipColumnToRow = function(row, column) { + if (column < 0) + return 0; + return Math.min(this.doc.getLine(row).length, column); + }; + + + this.$clipPositionToDocument = function(row, column) { + column = Math.max(0, column); + + if (row < 0) { + row = 0; + column = 0; + } else { + var len = this.doc.getLength(); + if (row >= len) { + row = len - 1; + column = this.doc.getLine(len-1).length; + } else { + column = Math.min(this.doc.getLine(row).length, column); + } + } + + return { + row: row, + column: column + }; + }; + + this.$clipRangeToDocument = function(range) { + if (range.start.row < 0) { + range.start.row = 0; + range.start.column = 0; + } else { + range.start.column = this.$clipColumnToRow( + range.start.row, + range.start.column + ); + } + + var len = this.doc.getLength() - 1; + if (range.end.row > len) { + range.end.row = len; + range.end.column = this.doc.getLine(len).length; + } else { + range.end.column = this.$clipColumnToRow( + range.end.row, + range.end.column + ); + } + return range; + }; + + // WRAPMODE + this.$wrapLimit = 80; + this.$useWrapMode = false; + this.$wrapLimitRange = { + min : null, + max : null + }; + this.setUseWrapMode = function(useWrapMode) { + if (useWrapMode != this.$useWrapMode) { + this.$useWrapMode = useWrapMode; + this.$modified = true; + this.$resetRowCache(0); + + // If wrapMode is activaed, the wrapData array has to be initialized. + if (useWrapMode) { + var len = this.getLength(); + this.$wrapData = []; + for (var i = 0; i < len; i++) { + this.$wrapData.push([]); + } + this.$updateWrapData(0, len - 1); + } + + this._emit("changeWrapMode"); + } + }; + this.getUseWrapMode = function() { + return this.$useWrapMode; + }; + + // Allow the wrap limit to move freely between min and max. Either + // parameter can be null to allow the wrap limit to be unconstrained + // in that direction. Or set both parameters to the same number to pin + // the limit to that value. + /** + * EditSession.setWrapLimitRange(min, max) + * - min (Number): The minimum wrap value (the left side wrap) + * - max (Number): The maximum wrap value (the right side wrap) + * + * Sets the boundaries of wrap. Either value can be `null` to have an unconstrained wrap, or, they can be the same number to pin the limit. If the wrap limits for `min` or `max` are different, this method also emits the `'changeWrapMode'` event. + **/ + this.setWrapLimitRange = function(min, max) { + if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) { + this.$wrapLimitRange.min = min; + this.$wrapLimitRange.max = max; + this.$modified = true; + // This will force a recalculation of the wrap limit + this._emit("changeWrapMode"); + } + }; + this.adjustWrapLimit = function(desiredLimit) { + var wrapLimit = this.$constrainWrapLimit(desiredLimit); + if (wrapLimit != this.$wrapLimit && wrapLimit > 0) { + this.$wrapLimit = wrapLimit; + this.$modified = true; + if (this.$useWrapMode) { + this.$updateWrapData(0, this.getLength() - 1); + this.$resetRowCache(0); + this._emit("changeWrapLimit"); + } + return true; + } + return false; + }; + this.$constrainWrapLimit = function(wrapLimit) { + var min = this.$wrapLimitRange.min; + if (min) + wrapLimit = Math.max(min, wrapLimit); + + var max = this.$wrapLimitRange.max; + if (max) + wrapLimit = Math.min(max, wrapLimit); + + // What would a limit of 0 even mean? + return Math.max(1, wrapLimit); + }; + this.getWrapLimit = function() { + return this.$wrapLimit; + }; + this.getWrapLimitRange = function() { + // Avoid unexpected mutation by returning a copy + return { + min : this.$wrapLimitRange.min, + max : this.$wrapLimitRange.max + }; + }; + this.$updateInternalDataOnChange = function(e) { + var useWrapMode = this.$useWrapMode; + var len; + var action = e.data.action; + var firstRow = e.data.range.start.row; + var lastRow = e.data.range.end.row; + var start = e.data.range.start; + var end = e.data.range.end; + var removedFolds = null; + + if (action.indexOf("Lines") != -1) { + if (action == "insertLines") { + lastRow = firstRow + (e.data.lines.length); + } else { + lastRow = firstRow; + } + len = e.data.lines ? e.data.lines.length : lastRow - firstRow; + } else { + len = lastRow - firstRow; + } + + if (len != 0) { + if (action.indexOf("remove") != -1) { + this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len); + + var foldLines = this.$foldData; + removedFolds = this.getFoldsInRange(e.data.range); + this.removeFolds(removedFolds); + + var foldLine = this.getFoldLine(end.row); + var idx = 0; + if (foldLine) { + foldLine.addRemoveChars(end.row, end.column, start.column - end.column); + foldLine.shiftRow(-len); + + var foldLineBefore = this.getFoldLine(firstRow); + if (foldLineBefore && foldLineBefore !== foldLine) { + foldLineBefore.merge(foldLine); + foldLine = foldLineBefore; + } + idx = foldLines.indexOf(foldLine) + 1; + } + + for (idx; idx < foldLines.length; idx++) { + var foldLine = foldLines[idx]; + if (foldLine.start.row >= end.row) { + foldLine.shiftRow(-len); + } + } + + lastRow = firstRow; + } else { + var args; + if (useWrapMode) { + args = [firstRow, 0]; + for (var i = 0; i < len; i++) args.push([]); + this.$wrapData.splice.apply(this.$wrapData, args); + } else { + args = Array(len); + args.unshift(firstRow, 0); + this.$rowLengthCache.splice.apply(this.$rowLengthCache, args); + } + + // If some new line is added inside of a foldLine, then split + // the fold line up. + var foldLines = this.$foldData; + var foldLine = this.getFoldLine(firstRow); + var idx = 0; + if (foldLine) { + var cmp = foldLine.range.compareInside(start.row, start.column) + // Inside of the foldLine range. Need to split stuff up. + if (cmp == 0) { + foldLine = foldLine.split(start.row, start.column); + foldLine.shiftRow(len); + foldLine.addRemoveChars( + lastRow, 0, end.column - start.column); + } else + // Infront of the foldLine but same row. Need to shift column. + if (cmp == -1) { + foldLine.addRemoveChars(firstRow, 0, end.column - start.column); + foldLine.shiftRow(len); + } + // Nothing to do if the insert is after the foldLine. + idx = foldLines.indexOf(foldLine) + 1; + } + + for (idx; idx < foldLines.length; idx++) { + var foldLine = foldLines[idx]; + if (foldLine.start.row >= firstRow) { + foldLine.shiftRow(len); + } + } + } + } else { + // Realign folds. E.g. if you add some new chars before a fold, the + // fold should "move" to the right. + len = Math.abs(e.data.range.start.column - e.data.range.end.column); + if (action.indexOf("remove") != -1) { + // Get all the folds in the change range and remove them. + removedFolds = this.getFoldsInRange(e.data.range); + this.removeFolds(removedFolds); + + len = -len; + } + var foldLine = this.getFoldLine(firstRow); + if (foldLine) { + foldLine.addRemoveChars(firstRow, start.column, len); + } + } + + if (useWrapMode && this.$wrapData.length != this.doc.getLength()) { + console.error("doc.getLength() and $wrapData.length have to be the same!"); + } + + if (useWrapMode) + this.$updateWrapData(firstRow, lastRow); + else + this.$updateRowLengthCache(firstRow, lastRow); + + return removedFolds; + }; + + this.$updateRowLengthCache = function(firstRow, lastRow, b) { + this.$rowLengthCache[firstRow] = null; + this.$rowLengthCache[lastRow] = null; + }; + this.$updateWrapData = function(firstRow, lastRow) { + var lines = this.doc.getAllLines(); + var tabSize = this.getTabSize(); + var wrapData = this.$wrapData; + var wrapLimit = this.$wrapLimit; + var tokens; + var foldLine; + + var row = firstRow; + lastRow = Math.min(lastRow, lines.length - 1); + while (row <= lastRow) { + foldLine = this.getFoldLine(row, foldLine); + if (!foldLine) { + tokens = this.$getDisplayTokens(lang.stringTrimRight(lines[row])); + wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize); + row ++; + } else { + tokens = []; + foldLine.walk( + function(placeholder, row, column, lastColumn) { + var walkTokens; + if (placeholder) { + walkTokens = this.$getDisplayTokens( + placeholder, tokens.length); + walkTokens[0] = PLACEHOLDER_START; + for (var i = 1; i < walkTokens.length; i++) { + walkTokens[i] = PLACEHOLDER_BODY; + } + } else { + walkTokens = this.$getDisplayTokens( + lines[row].substring(lastColumn, column), + tokens.length); + } + tokens = tokens.concat(walkTokens); + }.bind(this), + foldLine.end.row, + lines[foldLine.end.row].length + 1 + ); + // Remove spaces/tabs from the back of the token array. + while (tokens.length != 0 && tokens[tokens.length - 1] >= SPACE) + tokens.pop(); + + wrapData[foldLine.start.row] + = this.$computeWrapSplits(tokens, wrapLimit, tabSize); + row = foldLine.end.row + 1; + } + } + }; + + // "Tokens" + var CHAR = 1, + CHAR_EXT = 2, + PLACEHOLDER_START = 3, + PLACEHOLDER_BODY = 4, + PUNCTUATION = 9, + SPACE = 10, + TAB = 11, + TAB_SPACE = 12; + this.$computeWrapSplits = function(tokens, wrapLimit) { + if (tokens.length == 0) { + return []; + } + + var splits = []; + var displayLength = tokens.length; + var lastSplit = 0, lastDocSplit = 0; + + function addSplit(screenPos) { + var displayed = tokens.slice(lastSplit, screenPos); + + // The document size is the current size - the extra width for tabs + // and multipleWidth characters. + var len = displayed.length; + displayed.join(""). + // Get all the TAB_SPACEs. + replace(/12/g, function() { + len -= 1; + }). + // Get all the CHAR_EXT/multipleWidth characters. + replace(/2/g, function() { + len -= 1; + }); + + lastDocSplit += len; + splits.push(lastDocSplit); + lastSplit = screenPos; + } + + while (displayLength - lastSplit > wrapLimit) { + // This is, where the split should be. + var split = lastSplit + wrapLimit; + + // If there is a space or tab at this split position, then making + // a split is simple. + if (tokens[split] >= SPACE) { + // Include all following spaces + tabs in this split as well. + while (tokens[split] >= SPACE) { + split ++; + } + addSplit(split); + continue; + } + + // === ELSE === + // Check if split is inside of a placeholder. Placeholder are + // not splitable. Therefore, seek the beginning of the placeholder + // and try to place the split beofre the placeholder's start. + if (tokens[split] == PLACEHOLDER_START + || tokens[split] == PLACEHOLDER_BODY) + { + // Seek the start of the placeholder and do the split + // before the placeholder. By definition there always + // a PLACEHOLDER_START between split and lastSplit. + for (split; split != lastSplit - 1; split--) { + if (tokens[split] == PLACEHOLDER_START) { + // split++; << No incremental here as we want to + // have the position before the Placeholder. + break; + } + } + + // If the PLACEHOLDER_START is not the index of the + // last split, then we can do the split + if (split > lastSplit) { + addSplit(split); + continue; + } + + // If the PLACEHOLDER_START IS the index of the last + // split, then we have to place the split after the + // placeholder. So, let's seek for the end of the placeholder. + split = lastSplit + wrapLimit; + for (split; split < tokens.length; split++) { + if (tokens[split] != PLACEHOLDER_BODY) + { + break; + } + } + + // If spilt == tokens.length, then the placeholder is the last + // thing in the line and adding a new split doesn't make sense. + if (split == tokens.length) { + break; // Breaks the while-loop. + } + + // Finally, add the split... + addSplit(split); + continue; + } + + // === ELSE === + // Search for the first non space/tab/placeholder/punctuation token backwards. + var minSplit = Math.max(split - 10, lastSplit - 1); + while (split > minSplit && tokens[split] < PLACEHOLDER_START) { + split --; + } + while (split > minSplit && tokens[split] == PUNCTUATION) { + split --; + } + // If we found one, then add the split. + if (split > minSplit) { + addSplit(++split); + continue; + } + + // === ELSE === + split = lastSplit + wrapLimit; + // The split is inside of a CHAR or CHAR_EXT token and no space + // around -> force a split. + addSplit(split); + } + return splits; + }; + this.$getDisplayTokens = function(str, offset) { + var arr = []; + var tabSize; + offset = offset || 0; + + for (var i = 0; i < str.length; i++) { + var c = str.charCodeAt(i); + // Tab + if (c == 9) { + tabSize = this.getScreenTabSize(arr.length + offset); + arr.push(TAB); + for (var n = 1; n < tabSize; n++) { + arr.push(TAB_SPACE); + } + } + // Space + else if (c == 32) { + arr.push(SPACE); + } else if((c > 39 && c < 48) || (c > 57 && c < 64)) { + arr.push(PUNCTUATION); + } + // full width characters + else if (c >= 0x1100 && isFullWidth(c)) { + arr.push(CHAR, CHAR_EXT); + } else { + arr.push(CHAR); + } + } + return arr; + }; + this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) { + if (maxScreenColumn == 0) + return [0, 0]; + if (maxScreenColumn == null) + maxScreenColumn = Infinity; + screenColumn = screenColumn || 0; + + var c, column; + for (column = 0; column < str.length; column++) { + c = str.charCodeAt(column); + // tab + if (c == 9) { + screenColumn += this.getScreenTabSize(screenColumn); + } + // full width characters + else if (c >= 0x1100 && isFullWidth(c)) { + screenColumn += 2; + } else { + screenColumn += 1; + } + if (screenColumn > maxScreenColumn) { + break; + } + } + + return [screenColumn, column]; + }; + this.getRowLength = function(row) { + if (!this.$useWrapMode || !this.$wrapData[row]) { + return 1; + } else { + return this.$wrapData[row].length + 1; + } + }; + this.getScreenLastRowColumn = function(screenRow) { + var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE); + return this.documentToScreenColumn(pos.row, pos.column); + }; + this.getDocumentLastRowColumn = function(docRow, docColumn) { + var screenRow = this.documentToScreenRow(docRow, docColumn); + return this.getScreenLastRowColumn(screenRow); + }; + this.getDocumentLastRowColumnPosition = function(docRow, docColumn) { + var screenRow = this.documentToScreenRow(docRow, docColumn); + return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10); + }; + this.getRowSplitData = function(row) { + if (!this.$useWrapMode) { + return undefined; + } else { + return this.$wrapData[row]; + } + }; + this.getScreenTabSize = function(screenColumn) { + return this.$tabSize - screenColumn % this.$tabSize; + }; + this.screenToDocumentRow = function(screenRow, screenColumn) { + return this.screenToDocumentPosition(screenRow, screenColumn).row; + }; + this.screenToDocumentColumn = function(screenRow, screenColumn) { + return this.screenToDocumentPosition(screenRow, screenColumn).column; + }; + this.screenToDocumentPosition = function(screenRow, screenColumn) { + if (screenRow < 0) + return {row: 0, column: 0}; + + var line; + var docRow = 0; + var docColumn = 0; + var column; + var row = 0; + var rowLength = 0; + + var rowCache = this.$screenRowCache; + var i = this.$getRowCacheIndex(rowCache, screenRow); + if (0 < i && i < rowCache.length) { + var row = rowCache[i]; + var docRow = this.$docRowCache[i]; + var doCache = screenRow > row || (screenRow == row && i == rowCache.length - 1); + } else { + var doCache = i != 0 || !rowCache.length; + } + + var maxRow = this.getLength() - 1; + var foldLine = this.getNextFoldLine(docRow); + var foldStart = foldLine ? foldLine.start.row : Infinity; + + while (row <= screenRow) { + rowLength = this.getRowLength(docRow); + if (row + rowLength - 1 >= screenRow || docRow >= maxRow) { + break; + } else { + row += rowLength; + docRow++; + if (docRow > foldStart) { + docRow = foldLine.end.row+1; + foldLine = this.getNextFoldLine(docRow, foldLine); + foldStart = foldLine ? foldLine.start.row : Infinity; + } + } + if (doCache) { + this.$docRowCache.push(docRow); + this.$screenRowCache.push(row); + } + } + + if (foldLine && foldLine.start.row <= docRow) { + line = this.getFoldDisplayLine(foldLine); + docRow = foldLine.start.row; + } else if (row + rowLength <= screenRow || docRow > maxRow) { + // clip at the end of the document + return { + row: maxRow, + column: this.getLine(maxRow).length + } + } else { + line = this.getLine(docRow); + foldLine = null; + } + + if (this.$useWrapMode) { + var splits = this.$wrapData[docRow]; + if (splits) { + column = splits[screenRow - row]; + if(screenRow > row && splits.length) { + docColumn = splits[screenRow - row - 1] || splits[splits.length - 1]; + line = line.substring(docColumn); + } + } + } + + docColumn += this.$getStringScreenWidth(line, screenColumn)[1]; + + // We remove one character at the end so that the docColumn + // position returned is not associated to the next row on the screen. + if (this.$useWrapMode && docColumn >= column) + docColumn = column - 1; + + if (foldLine) + return foldLine.idxToPosition(docColumn); + + return {row: docRow, column: docColumn}; + }; + this.documentToScreenPosition = function(docRow, docColumn) { + // Normalize the passed in arguments. + if (typeof docColumn === "undefined") + var pos = this.$clipPositionToDocument(docRow.row, docRow.column); + else + pos = this.$clipPositionToDocument(docRow, docColumn); + + docRow = pos.row; + docColumn = pos.column; + + var screenRow = 0; + var foldStartRow = null; + var fold = null; + + // Clamp the docRow position in case it's inside of a folded block. + fold = this.getFoldAt(docRow, docColumn, 1); + if (fold) { + docRow = fold.start.row; + docColumn = fold.start.column; + } + + var rowEnd, row = 0; + + + var rowCache = this.$docRowCache; + var i = this.$getRowCacheIndex(rowCache, docRow); + if (0 < i && i < rowCache.length) { + var row = rowCache[i]; + var screenRow = this.$screenRowCache[i]; + var doCache = docRow > row || (docRow == row && i == rowCache.length - 1); + } else { + var doCache = i != 0 || !rowCache.length; + } + + var foldLine = this.getNextFoldLine(row); + var foldStart = foldLine ?foldLine.start.row :Infinity; + + while (row < docRow) { + if (row >= foldStart) { + rowEnd = foldLine.end.row + 1; + if (rowEnd > docRow) + break; + foldLine = this.getNextFoldLine(rowEnd, foldLine); + foldStart = foldLine ?foldLine.start.row :Infinity; + } + else { + rowEnd = row + 1; + } + + screenRow += this.getRowLength(row); + row = rowEnd; + + if (doCache) { + this.$docRowCache.push(row); + this.$screenRowCache.push(screenRow); + } + } + + // Calculate the text line that is displayed in docRow on the screen. + var textLine = ""; + // Check if the final row we want to reach is inside of a fold. + if (foldLine && row >= foldStart) { + textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn); + foldStartRow = foldLine.start.row; + } else { + textLine = this.getLine(docRow).substring(0, docColumn); + foldStartRow = docRow; + } + // Clamp textLine if in wrapMode. + if (this.$useWrapMode) { + var wrapRow = this.$wrapData[foldStartRow]; + var screenRowOffset = 0; + while (textLine.length >= wrapRow[screenRowOffset]) { + screenRow ++; + screenRowOffset++; + } + textLine = textLine.substring( + wrapRow[screenRowOffset - 1] || 0, textLine.length + ); + } + + return { + row: screenRow, + column: this.$getStringScreenWidth(textLine)[0] + }; + }; + this.documentToScreenColumn = function(row, docColumn) { + return this.documentToScreenPosition(row, docColumn).column; + }; + this.documentToScreenRow = function(docRow, docColumn) { + return this.documentToScreenPosition(docRow, docColumn).row; + }; + this.getScreenLength = function() { + var screenRows = 0; + var fold = null; + if (!this.$useWrapMode) { + screenRows = this.getLength(); + + // Remove the folded lines again. + var foldData = this.$foldData; + for (var i = 0; i < foldData.length; i++) { + fold = foldData[i]; + screenRows -= fold.end.row - fold.start.row; + } + } else { + var lastRow = this.$wrapData.length; + var row = 0, i = 0; + var fold = this.$foldData[i++]; + var foldStart = fold ? fold.start.row :Infinity; + + while (row < lastRow) { + screenRows += this.$wrapData[row].length + 1; + row ++; + if (row > foldStart) { + row = fold.end.row+1; + fold = this.$foldData[i++]; + foldStart = fold ?fold.start.row :Infinity; + } + } + } + + return screenRows; + } + + // For every keystroke this gets called once per char in the whole doc!! + // Wouldn't hurt to make it a bit faster for c >= 0x1100 + function isFullWidth(c) { + if (c < 0x1100) + return false; + return c >= 0x1100 && c <= 0x115F || + c >= 0x11A3 && c <= 0x11A7 || + c >= 0x11FA && c <= 0x11FF || + c >= 0x2329 && c <= 0x232A || + c >= 0x2E80 && c <= 0x2E99 || + c >= 0x2E9B && c <= 0x2EF3 || + c >= 0x2F00 && c <= 0x2FD5 || + c >= 0x2FF0 && c <= 0x2FFB || + c >= 0x3000 && c <= 0x303E || + c >= 0x3041 && c <= 0x3096 || + c >= 0x3099 && c <= 0x30FF || + c >= 0x3105 && c <= 0x312D || + c >= 0x3131 && c <= 0x318E || + c >= 0x3190 && c <= 0x31BA || + c >= 0x31C0 && c <= 0x31E3 || + c >= 0x31F0 && c <= 0x321E || + c >= 0x3220 && c <= 0x3247 || + c >= 0x3250 && c <= 0x32FE || + c >= 0x3300 && c <= 0x4DBF || + c >= 0x4E00 && c <= 0xA48C || + c >= 0xA490 && c <= 0xA4C6 || + c >= 0xA960 && c <= 0xA97C || + c >= 0xAC00 && c <= 0xD7A3 || + c >= 0xD7B0 && c <= 0xD7C6 || + c >= 0xD7CB && c <= 0xD7FB || + c >= 0xF900 && c <= 0xFAFF || + c >= 0xFE10 && c <= 0xFE19 || + c >= 0xFE30 && c <= 0xFE52 || + c >= 0xFE54 && c <= 0xFE66 || + c >= 0xFE68 && c <= 0xFE6B || + c >= 0xFF01 && c <= 0xFF60 || + c >= 0xFFE0 && c <= 0xFFE6; + }; + +}).call(EditSession.prototype); + +require("./edit_session/folding").Folding.call(EditSession.prototype); +require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype); + +exports.EditSession = EditSession; +}); + +ace.define('ace/config', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) { +"no use strict"; + +var lang = require("./lib/lang"); + +var global = (function() { + return this; +})(); + +var options = { + packaged: false, + workerPath: "", + modePath: "", + themePath: "", + suffix: ".js", + $moduleUrls: {} +}; + +exports.get = function(key) { + if (!options.hasOwnProperty(key)) + throw new Error("Unknown config key: " + key); + + return options[key]; +}; + +exports.set = function(key, value) { + if (!options.hasOwnProperty(key)) + throw new Error("Unknown config key: " + key); + + options[key] = value; +}; + +exports.all = function() { + return lang.copyObject(options); +}; + +exports.moduleUrl = function(name, component) { + if (options.$moduleUrls[name]) + return options.$moduleUrls[name]; + + var parts = name.split("/"); + component = component || parts[parts.length - 2] || ""; + var base = parts[parts.length - 1].replace(component, "").replace(/(^[\-_])|([\-_]$)/, ""); + + if (!base && parts.length > 1) + base = parts[parts.length - 2]; + return this.get(component + "Path") + "/" + component + "-" + base + this.get("suffix"); +}; + +exports.setModuleUrl = function(name, subst) { + return options.$moduleUrls[name] = subst; +}; + +exports.init = function() { + options.packaged = require.packaged || module.packaged || (global.define && define.packaged); + + if (!global.document) + return ""; + + var scriptOptions = {}; + var scriptUrl = ""; + + var scripts = document.getElementsByTagName("script"); + for (var i=0; i lead.row || (anchor.row == lead.row && anchor.column > lead.column)); + }; + this.getRange = function() { + var anchor = this.anchor; + var lead = this.lead; + + if (this.isEmpty()) + return Range.fromPoints(lead, lead); + + if (this.isBackwards()) { + return Range.fromPoints(lead, anchor); + } + else { + return Range.fromPoints(anchor, lead); + } + }; + this.clearSelection = function() { + if (!this.$isEmpty) { + this.$isEmpty = true; + this._emit("changeSelection"); + } + }; + this.selectAll = function() { + var lastRow = this.doc.getLength() - 1; + this.setSelectionAnchor(0, 0); + this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length); + }; + this.setRange = + this.setSelectionRange = function(range, reverse) { + if (reverse) { + this.setSelectionAnchor(range.end.row, range.end.column); + this.selectTo(range.start.row, range.start.column); + } else { + this.setSelectionAnchor(range.start.row, range.start.column); + this.selectTo(range.end.row, range.end.column); + } + this.$desiredColumn = null; + }; + + this.$moveSelection = function(mover) { + var lead = this.lead; + if (this.$isEmpty) + this.setSelectionAnchor(lead.row, lead.column); + + mover.call(this); + }; + this.selectTo = function(row, column) { + this.$moveSelection(function() { + this.moveCursorTo(row, column); + }); + }; + this.selectToPosition = function(pos) { + this.$moveSelection(function() { + this.moveCursorToPosition(pos); + }); + }; + this.selectUp = function() { + this.$moveSelection(this.moveCursorUp); + }; + this.selectDown = function() { + this.$moveSelection(this.moveCursorDown); + }; + this.selectRight = function() { + this.$moveSelection(this.moveCursorRight); + }; + this.selectLeft = function() { + this.$moveSelection(this.moveCursorLeft); + }; + this.selectLineStart = function() { + this.$moveSelection(this.moveCursorLineStart); + }; + this.selectLineEnd = function() { + this.$moveSelection(this.moveCursorLineEnd); + }; + this.selectFileEnd = function() { + this.$moveSelection(this.moveCursorFileEnd); + }; + this.selectFileStart = function() { + this.$moveSelection(this.moveCursorFileStart); + }; + this.selectWordRight = function() { + this.$moveSelection(this.moveCursorWordRight); + }; + this.selectWordLeft = function() { + this.$moveSelection(this.moveCursorWordLeft); + }; + this.getWordRange = function(row, column) { + if (typeof column == "undefined") { + var cursor = row || this.lead; + row = cursor.row; + column = cursor.column; + } + return this.session.getWordRange(row, column); + }; + + this.selectWord = function() { + this.setSelectionRange(this.getWordRange()); + }; + this.selectAWord = function() { + var cursor = this.getCursor(); + var range = this.session.getAWordRange(cursor.row, cursor.column); + this.setSelectionRange(range); + }; + + this.getLineRange = function(row, excludeLastChar) { + var rowStart = typeof row == "number" ? row : this.lead.row; + var rowEnd; + + var foldLine = this.session.getFoldLine(rowStart); + if (foldLine) { + rowStart = foldLine.start.row; + rowEnd = foldLine.end.row; + } else { + rowEnd = rowStart; + } + if (excludeLastChar) + return new Range(rowStart, 0, rowEnd, this.session.getLine(rowEnd).length); + else + return new Range(rowStart, 0, rowEnd + 1, 0); + }; + this.selectLine = function() { + this.setSelectionRange(this.getLineRange()); + }; + this.moveCursorUp = function() { + this.moveCursorBy(-1, 0); + }; + this.moveCursorDown = function() { + this.moveCursorBy(1, 0); + }; + this.moveCursorLeft = function() { + var cursor = this.lead.getPosition(), + fold; + + if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) { + this.moveCursorTo(fold.start.row, fold.start.column); + } else if (cursor.column == 0) { + // cursor is a line (start + if (cursor.row > 0) { + this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length); + } + } + else { + var tabSize = this.session.getTabSize(); + if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column-tabSize, cursor.column).split(" ").length-1 == tabSize) + this.moveCursorBy(0, -tabSize); + else + this.moveCursorBy(0, -1); + } + }; + this.moveCursorRight = function() { + var cursor = this.lead.getPosition(), + fold; + if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) { + this.moveCursorTo(fold.end.row, fold.end.column); + } + else if (this.lead.column == this.doc.getLine(this.lead.row).length) { + if (this.lead.row < this.doc.getLength() - 1) { + this.moveCursorTo(this.lead.row + 1, 0); + } + } + else { + var tabSize = this.session.getTabSize(); + var cursor = this.lead; + if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column, cursor.column+tabSize).split(" ").length-1 == tabSize) + this.moveCursorBy(0, tabSize); + else + this.moveCursorBy(0, 1); + } + }; + this.moveCursorLineStart = function() { + var row = this.lead.row; + var column = this.lead.column; + var screenRow = this.session.documentToScreenRow(row, column); + + // Determ the doc-position of the first character at the screen line. + var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0); + + // Determ the line + var beforeCursor = this.session.getDisplayLine( + row, null, firstColumnPosition.row, + firstColumnPosition.column + ); + + var leadingSpace = beforeCursor.match(/^\s*/); + if (leadingSpace[0].length == column) { + this.moveCursorTo( + firstColumnPosition.row, firstColumnPosition.column + ); + } + else { + this.moveCursorTo( + firstColumnPosition.row, + firstColumnPosition.column + leadingSpace[0].length + ); + } + }; + this.moveCursorLineEnd = function() { + var lead = this.lead; + var lineEnd = this.session.getDocumentLastRowColumnPosition(lead.row, lead.column); + if (this.lead.column == lineEnd.column) { + var line = this.session.getLine(lineEnd.row); + if (lineEnd.column == line.length) { + var textEnd = line.search(/\s+$/); + if (textEnd > 0) + lineEnd.column = textEnd; + } + } + + this.moveCursorTo(lineEnd.row, lineEnd.column); + }; + this.moveCursorFileEnd = function() { + var row = this.doc.getLength() - 1; + var column = this.doc.getLine(row).length; + this.moveCursorTo(row, column); + }; + this.moveCursorFileStart = function() { + this.moveCursorTo(0, 0); + }; + this.moveCursorLongWordRight = function() { + var row = this.lead.row; + var column = this.lead.column; + var line = this.doc.getLine(row); + var rightOfCursor = line.substring(column); + + var match; + this.session.nonTokenRe.lastIndex = 0; + this.session.tokenRe.lastIndex = 0; + + // skip folds + var fold = this.session.getFoldAt(row, column, 1); + if (fold) { + this.moveCursorTo(fold.end.row, fold.end.column); + return; + } + + // first skip space + if (match = this.session.nonTokenRe.exec(rightOfCursor)) { + column += this.session.nonTokenRe.lastIndex; + this.session.nonTokenRe.lastIndex = 0; + rightOfCursor = line.substring(column); + } + + // if at line end proceed with next line + if (column >= line.length) { + this.moveCursorTo(row, line.length); + this.moveCursorRight(); + if (row < this.doc.getLength() - 1) + this.moveCursorWordRight(); + return; + } + + // advance to the end of the next token + if (match = this.session.tokenRe.exec(rightOfCursor)) { + column += this.session.tokenRe.lastIndex; + this.session.tokenRe.lastIndex = 0; + } + + this.moveCursorTo(row, column); + }; + this.moveCursorLongWordLeft = function() { + var row = this.lead.row; + var column = this.lead.column; + + // skip folds + var fold; + if (fold = this.session.getFoldAt(row, column, -1)) { + this.moveCursorTo(fold.start.row, fold.start.column); + return; + } + + var str = this.session.getFoldStringAt(row, column, -1); + if (str == null) { + str = this.doc.getLine(row).substring(0, column) + } + + var leftOfCursor = lang.stringReverse(str); + var match; + this.session.nonTokenRe.lastIndex = 0; + this.session.tokenRe.lastIndex = 0; + + // skip whitespace + if (match = this.session.nonTokenRe.exec(leftOfCursor)) { + column -= this.session.nonTokenRe.lastIndex; + leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex); + this.session.nonTokenRe.lastIndex = 0; + } + + // if at begin of the line proceed in line above + if (column <= 0) { + this.moveCursorTo(row, 0); + this.moveCursorLeft(); + if (row > 0) + this.moveCursorWordLeft(); + return; + } + + // move to the begin of the word + if (match = this.session.tokenRe.exec(leftOfCursor)) { + column -= this.session.tokenRe.lastIndex; + this.session.tokenRe.lastIndex = 0; + } + + this.moveCursorTo(row, column); + }; + + this.$shortWordEndIndex = function(rightOfCursor) { + var match, index = 0, ch; + var whitespaceRe = /\s/; + var tokenRe = this.session.tokenRe; + + tokenRe.lastIndex = 0; + if (match = this.session.tokenRe.exec(rightOfCursor)) { + index = this.session.tokenRe.lastIndex; + } else { + while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch)) + index ++; + + if (index <= 1) { + tokenRe.lastIndex = 0; + while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) { + tokenRe.lastIndex = 0; + index ++; + if (whitespaceRe.test(ch)) { + if (index > 2) { + index-- + break; + } else { + while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch)) + index ++; + if (index > 2) + break + } + } + } + } + } + tokenRe.lastIndex = 0; + + return index; + }; + + this.moveCursorShortWordRight = function() { + var row = this.lead.row; + var column = this.lead.column; + var line = this.doc.getLine(row); + var rightOfCursor = line.substring(column); + + var fold = this.session.getFoldAt(row, column, 1); + if (fold) + return this.moveCursorTo(fold.end.row, fold.end.column); + + if (column == line.length) { + var l = this.doc.getLength(); + do { + row++; + rightOfCursor = this.doc.getLine(row) + } while (row < l && /^\s*$/.test(rightOfCursor)) + + if (!/^\s+/.test(rightOfCursor)) + rightOfCursor = "" + column = 0; + } + + var index = this.$shortWordEndIndex(rightOfCursor); + + this.moveCursorTo(row, column + index); + }; + + this.moveCursorShortWordLeft = function() { + var row = this.lead.row; + var column = this.lead.column; + + var fold; + if (fold = this.session.getFoldAt(row, column, -1)) + return this.moveCursorTo(fold.start.row, fold.start.column); + + var line = this.session.getLine(row).substring(0, column); + if (column == 0) { + do { + row--; + line = this.doc.getLine(row); + } while (row > 0 && /^\s*$/.test(line)) + + column = line.length; + if (!/\s+$/.test(line)) + line = "" + } + + var leftOfCursor = lang.stringReverse(line); + var index = this.$shortWordEndIndex(leftOfCursor); + + return this.moveCursorTo(row, column - index); + }; + + this.moveCursorWordRight = function() { + if (this.session.$selectLongWords) + this.moveCursorLongWordRight(); + else + this.moveCursorShortWordRight(); + }; + + this.moveCursorWordLeft = function() { + if (this.session.$selectLongWords) + this.moveCursorLongWordLeft(); + else + this.moveCursorShortWordLeft(); + }; + this.moveCursorBy = function(rows, chars) { + var screenPos = this.session.documentToScreenPosition( + this.lead.row, + this.lead.column + ); + + if (chars === 0) { + if (this.$desiredColumn) + screenPos.column = this.$desiredColumn; + else + this.$desiredColumn = screenPos.column; + } + + var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column); + + // move the cursor and update the desired column + this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0); + }; + this.moveCursorToPosition = function(position) { + this.moveCursorTo(position.row, position.column); + }; + this.moveCursorTo = function(row, column, keepDesiredColumn) { + // Ensure the row/column is not inside of a fold. + var fold = this.session.getFoldAt(row, column, 1); + if (fold) { + row = fold.start.row; + column = fold.start.column; + } + + this.$keepDesiredColumnOnChange = true; + this.lead.setPosition(row, column); + this.$keepDesiredColumnOnChange = false; + + if (!keepDesiredColumn) + this.$desiredColumn = null; + }; + this.moveCursorToScreen = function(row, column, keepDesiredColumn) { + var pos = this.session.screenToDocumentPosition(row, column); + this.moveCursorTo(pos.row, pos.column, keepDesiredColumn); + }; + + // remove listeners from document + this.detach = function() { + this.lead.detach(); + this.anchor.detach(); + this.session = this.doc = null; + } + + this.fromOrientedRange = function(range) { + this.setSelectionRange(range, range.cursor == range.start); + this.$desiredColumn = range.desiredColumn || this.$desiredColumn; + } + + this.toOrientedRange = function(range) { + var r = this.getRange(); + if (range) { + range.start.column = r.start.column; + range.start.row = r.start.row; + range.end.column = r.end.column; + range.end.row = r.end.row; + } else { + range = r; + } + + range.cursor = this.isBackwards() ? range.start : range.end; + range.desiredColumn = this.$desiredColumn; + return range; + } + +}).call(Selection.prototype); + +exports.Selection = Selection; +}); + +ace.define('ace/range', ['require', 'exports', 'module' ], function(require, exports, module) { + + +/** + * class Range + * + * This object is used in various places to indicate a region within the editor. To better visualize how this works, imagine a rectangle. Each quadrant of the rectangle is analogus to a range, as ranges contain a starting row and starting column, and an ending row, and ending column. + * + **/ + +/** + * new Range(startRow, startColumn, endRow, endColumn) + * - startRow (Number): The starting row + * - startColumn (Number): The starting column + * - endRow (Number): The ending row + * - endColumn (Number): The ending column + * + * Creates a new `Range` object with the given starting and ending row and column points. + * + **/ +var Range = function(startRow, startColumn, endRow, endColumn) { + this.start = { + row: startRow, + column: startColumn + }; + + this.end = { + row: endRow, + column: endColumn + }; +}; + +(function() { + /** + * Range.isEqual(range) -> Boolean + * - range (Range): A range to check against + * + * Returns `true` if and only if the starting row and column, and ending tow and column, are equivalent to those given by `range`. + * + **/ + this.isEqual = function(range) { + return this.start.row == range.start.row && + this.end.row == range.end.row && + this.start.column == range.start.column && + this.end.column == range.end.column + }; + this.toString = function() { + return ("Range: [" + this.start.row + "/" + this.start.column + + "] -> [" + this.end.row + "/" + this.end.column + "]"); + }; + + this.contains = function(row, column) { + return this.compare(row, column) == 0; + }; + this.compareRange = function(range) { + var cmp, + end = range.end, + start = range.start; + + cmp = this.compare(end.row, end.column); + if (cmp == 1) { + cmp = this.compare(start.row, start.column); + if (cmp == 1) { + return 2; + } else if (cmp == 0) { + return 1; + } else { + return 0; + } + } else if (cmp == -1) { + return -2; + } else { + cmp = this.compare(start.row, start.column); + if (cmp == -1) { + return -1; + } else if (cmp == 1) { + return 42; + } else { + return 0; + } + } + } + + /** related to: Range.compare + * Range.comparePoint(p) -> Number + * - p (Range): A point to compare with + * + (Number): This method returns one of the following numbers:
    + * * `0` if the two points are exactly equal
    + * * `-1` if `p.row` is less then the calling range
    + * * `1` if `p.row` is greater than the calling range
    + *
    + * If the starting row of the calling range is equal to `p.row`, and:
    + * * `p.column` is greater than or equal to the calling range's starting column, this returns `0`
    + * * Otherwise, it returns -1
    + *
    + * If the ending row of the calling range is equal to `p.row`, and:
    + * * `p.column` is less than or equal to the calling range's ending column, this returns `0`
    + * * Otherwise, it returns 1
    + * + * Checks the row and column points of `p` with the row and column points of the calling range. + * + * + * + **/ + this.comparePoint = function(p) { + return this.compare(p.row, p.column); + } + + /** related to: Range.comparePoint + * Range.containsRange(range) -> Boolean + * - range (Range): A range to compare with + * + * Checks the start and end points of `range` and compares them to the calling range. Returns `true` if the `range` is contained within the caller's range. + * + **/ + this.containsRange = function(range) { + return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0; + } + + /** + * Range.intersects(range) -> Boolean + * - range (Range): A range to compare with + * + * Returns `true` if passed in `range` intersects with the one calling this method. + * + **/ + this.intersects = function(range) { + var cmp = this.compareRange(range); + return (cmp == -1 || cmp == 0 || cmp == 1); + } + + /** + * Range.isEnd(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the caller's ending row point is the same as `row`, and if the caller's ending column is the same as `column`. + * + **/ + this.isEnd = function(row, column) { + return this.end.row == row && this.end.column == column; + } + + /** + * Range.isStart(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the caller's starting row point is the same as `row`, and if the caller's starting column is the same as `column`. + * + **/ + this.isStart = function(row, column) { + return this.start.row == row && this.start.column == column; + } + + /** + * Range.setStart(row, column) + * - row (Number): A row point to set + * - column (Number): A column point to set + * + * Sets the starting row and column for the range. + * + **/ + this.setStart = function(row, column) { + if (typeof row == "object") { + this.start.column = row.column; + this.start.row = row.row; + } else { + this.start.row = row; + this.start.column = column; + } + } + + /** + * Range.setEnd(row, column) + * - row (Number): A row point to set + * - column (Number): A column point to set + * + * Sets the starting row and column for the range. + * + **/ + this.setEnd = function(row, column) { + if (typeof row == "object") { + this.end.column = row.column; + this.end.row = row.row; + } else { + this.end.row = row; + this.end.column = column; + } + } + + /** related to: Range.compare + * Range.inside(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the `row` and `column` are within the given range. + * + **/ + this.inside = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isEnd(row, column) || this.isStart(row, column)) { + return false; + } else { + return true; + } + } + return false; + } + + /** related to: Range.compare + * Range.insideStart(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the `row` and `column` are within the given range's starting points. + * + **/ + this.insideStart = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isEnd(row, column)) { + return false; + } else { + return true; + } + } + return false; + } + + /** related to: Range.compare + * Range.insideEnd(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the `row` and `column` are within the given range's ending points. + * + **/ + this.insideEnd = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isStart(row, column)) { + return false; + } else { + return true; + } + } + return false; + } + + /** + * Range.compare(row, column) -> Number + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + (Number): This method returns one of the following numbers:
    + * * `0` if the two points are exactly equal
    + * * `-1` if `p.row` is less then the calling range
    + * * `1` if `p.row` is greater than the calling range
    + *
    + * If the starting row of the calling range is equal to `p.row`, and:
    + * * `p.column` is greater than or equal to the calling range's starting column, this returns `0`
    + * * Otherwise, it returns -1
    + *
    + * If the ending row of the calling range is equal to `p.row`, and:
    + * * `p.column` is less than or equal to the calling range's ending column, this returns `0`
    + * * Otherwise, it returns 1 + * + * Checks the row and column points with the row and column points of the calling range. + * + * + **/ + this.compare = function(row, column) { + if (!this.isMultiLine()) { + if (row === this.start.row) { + return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0); + }; + } + + if (row < this.start.row) + return -1; + + if (row > this.end.row) + return 1; + + if (this.start.row === row) + return column >= this.start.column ? 0 : -1; + + if (this.end.row === row) + return column <= this.end.column ? 0 : 1; + + return 0; + }; + this.compareStart = function(row, column) { + if (this.start.row == row && this.start.column == column) { + return -1; + } else { + return this.compare(row, column); + } + } + + /** + * Range.compareEnd(row, column) -> Number + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + (Number): This method returns one of the following numbers:
    + * * `0` if the two points are exactly equal
    + * * `-1` if `p.row` is less then the calling range
    + * * `1` if `p.row` is greater than the calling range, or if `isEnd` is `true.
    + *
    + * If the starting row of the calling range is equal to `p.row`, and:
    + * * `p.column` is greater than or equal to the calling range's starting column, this returns `0`
    + * * Otherwise, it returns -1
    + *
    + * If the ending row of the calling range is equal to `p.row`, and:
    + * * `p.column` is less than or equal to the calling range's ending column, this returns `0`
    + * * Otherwise, it returns 1 + * + * Checks the row and column points with the row and column points of the calling range. + * + * + **/ + this.compareEnd = function(row, column) { + if (this.end.row == row && this.end.column == column) { + return 1; + } else { + return this.compare(row, column); + } + } + + /** + * Range.compareInside(row, column) -> Number + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + (Number): This method returns one of the following numbers:
    + * * `1` if the ending row of the calling range is equal to `row`, and the ending column of the calling range is equal to `column`
    + * * `-1` if the starting row of the calling range is equal to `row`, and the starting column of the calling range is equal to `column`
    + *
    + * Otherwise, it returns the value after calling [[Range.compare `compare()`]]. + * + * Checks the row and column points with the row and column points of the calling range. + * + * + * + **/ + this.compareInside = function(row, column) { + if (this.end.row == row && this.end.column == column) { + return 1; + } else if (this.start.row == row && this.start.column == column) { + return -1; + } else { + return this.compare(row, column); + } + } + + /** + * Range.clipRows(firstRow, lastRow) -> Range + * - firstRow (Number): The starting row + * - lastRow (Number): The ending row + * + * Returns the part of the current `Range` that occurs within the boundaries of `firstRow` and `lastRow` as a new `Range` object. + * + **/ + this.clipRows = function(firstRow, lastRow) { + if (this.end.row > lastRow) { + var end = { + row: lastRow+1, + column: 0 + }; + } + + if (this.start.row > lastRow) { + var start = { + row: lastRow+1, + column: 0 + }; + } + + if (this.start.row < firstRow) { + var start = { + row: firstRow, + column: 0 + }; + } + + if (this.end.row < firstRow) { + var end = { + row: firstRow, + column: 0 + }; + } + return Range.fromPoints(start || this.start, end || this.end); + }; + this.extend = function(row, column) { + var cmp = this.compare(row, column); + + if (cmp == 0) + return this; + else if (cmp == -1) + var start = {row: row, column: column}; + else + var end = {row: row, column: column}; + + return Range.fromPoints(start || this.start, end || this.end); + }; + + this.isEmpty = function() { + return (this.start.row == this.end.row && this.start.column == this.end.column); + }; + this.isMultiLine = function() { + return (this.start.row !== this.end.row); + }; + this.clone = function() { + return Range.fromPoints(this.start, this.end); + }; + this.collapseRows = function() { + if (this.end.column == 0) + return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0) + else + return new Range(this.start.row, 0, this.end.row, 0) + }; + this.toScreenRange = function(session) { + var screenPosStart = + session.documentToScreenPosition(this.start); + var screenPosEnd = + session.documentToScreenPosition(this.end); + + return new Range( + screenPosStart.row, screenPosStart.column, + screenPosEnd.row, screenPosEnd.column + ); + }; + +}).call(Range.prototype); +Range.fromPoints = function(start, end) { + return new Range(start.row, start.column, end.row, end.column); +}; + +exports.Range = Range; +}); + +ace.define('ace/mode/text', ['require', 'exports', 'module' , 'ace/tokenizer', 'ace/mode/text_highlight_rules', 'ace/mode/behaviour', 'ace/unicode'], function(require, exports, module) { + + +var Tokenizer = require("../tokenizer").Tokenizer; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; +var Behaviour = require("./behaviour").Behaviour; +var unicode = require("../unicode"); + +var Mode = function() { + this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules()); + this.$behaviour = new Behaviour(); +}; + +(function() { + + this.tokenRe = new RegExp("^[" + + unicode.packages.L + + unicode.packages.Mn + unicode.packages.Mc + + unicode.packages.Nd + + unicode.packages.Pc + "\\$_]+", "g" + ); + + this.nonTokenRe = new RegExp("^(?:[^" + + unicode.packages.L + + unicode.packages.Mn + unicode.packages.Mc + + unicode.packages.Nd + + unicode.packages.Pc + "\\$_]|\s])+", "g" + ); + + this.getTokenizer = function() { + return this.$tokenizer; + }; + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + }; + + this.getNextLineIndent = function(state, line, tab) { + return ""; + }; + + this.checkOutdent = function(state, line, input) { + return false; + }; + + this.autoOutdent = function(state, doc, row) { + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + + this.createWorker = function(session) { + return null; + }; + + this.createModeDelegates = function (mapping) { + if (!this.$embeds) { + return; + } + this.$modes = {}; + for (var i = 0; i < this.$embeds.length; i++) { + if (mapping[this.$embeds[i]]) { + this.$modes[this.$embeds[i]] = new mapping[this.$embeds[i]](); + } + } + + var delegations = ['toggleCommentLines', 'getNextLineIndent', 'checkOutdent', 'autoOutdent', 'transformAction']; + + for (var i = 0; i < delegations.length; i++) { + (function(scope) { + var functionName = delegations[i]; + var defaultHandler = scope[functionName]; + scope[delegations[i]] = function() { + return this.$delegator(functionName, arguments, defaultHandler); + } + } (this)); + } + } + + this.$delegator = function(method, args, defaultHandler) { + var state = args[0]; + + for (var i = 0; i < this.$embeds.length; i++) { + if (!this.$modes[this.$embeds[i]]) continue; + + var split = state.split(this.$embeds[i]); + if (!split[0] && split[1]) { + args[0] = split[1]; + var mode = this.$modes[this.$embeds[i]]; + return mode[method].apply(mode, args); + } + } + var ret = defaultHandler.apply(this, args); + return defaultHandler ? ret : undefined; + }; + + this.transformAction = function(state, action, editor, session, param) { + if (this.$behaviour) { + var behaviours = this.$behaviour.getBehaviours(); + for (var key in behaviours) { + if (behaviours[key][action]) { + var ret = behaviours[key][action].apply(this, arguments); + if (ret) { + return ret; + } + } + } + } + } + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/tokenizer', ['require', 'exports', 'module' ], function(require, exports, module) { + + +/** + * class Tokenizer + * + * This class takes a set of highlighting rules, and creates a tokenizer out of them. For more information, see [the wiki on extending highlighters](https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode#wiki-extendingTheHighlighter). + * + **/ + +/** + * new Tokenizer(rules, flag) + * - rules (Object): The highlighting rules + * - flag (String): Any additional regular expression flags to pass (like "i" for case insensitive) + * + * Constructs a new tokenizer based on the given rules and flags. + * + **/ +var Tokenizer = function(rules, flag) { + flag = flag ? "g" + flag : "g"; + this.rules = rules; + + this.regExps = {}; + this.matchMappings = {}; + for ( var key in this.rules) { + var rule = this.rules[key]; + var state = rule; + var ruleRegExps = []; + var matchTotal = 0; + var mapping = this.matchMappings[key] = {}; + + for ( var i = 0; i < state.length; i++) { + + if (state[i].regex instanceof RegExp) + state[i].regex = state[i].regex.toString().slice(1, -1); + + // Count number of matching groups. 2 extra groups from the full match + // And the catch-all on the end (used to force a match); + var matchcount = new RegExp("(?:(" + state[i].regex + ")|(.))").exec("a").length - 2; + + // Replace any backreferences and offset appropriately. + var adjustedregex = state[i].regex.replace(/\\([0-9]+)/g, function (match, digit) { + return "\\" + (parseInt(digit, 10) + matchTotal + 1); + }); + + if (matchcount > 1 && state[i].token.length !== matchcount-1) + throw new Error("For " + state[i].regex + " the matching groups and length of the token array don't match (rule #" + i + " of state " + key + ")"); + + mapping[matchTotal] = { + rule: i, + len: matchcount + }; + matchTotal += matchcount; + + ruleRegExps.push(adjustedregex); + } + + this.regExps[key] = new RegExp("(?:(" + ruleRegExps.join(")|(") + ")|(.))", flag); + } +}; + +(function() { + + /** + * Tokenizer.getLineTokens() -> Object + * + * Returns an object containing two properties: `tokens`, which contains all the tokens; and `state`, the current state. + **/ + this.getLineTokens = function(line, startState) { + var currentState = startState || "start"; + var state = this.rules[currentState]; + var mapping = this.matchMappings[currentState]; + var re = this.regExps[currentState]; + re.lastIndex = 0; + + var match, tokens = []; + + var lastIndex = 0; + + var token = { + type: null, + value: "" + }; + + while (match = re.exec(line)) { + var type = "text"; + var rule = null; + var value = [match[0]]; + + for (var i = 0; i < match.length-2; i++) { + if (match[i + 1] === undefined) + continue; + + rule = state[mapping[i].rule]; + + if (mapping[i].len > 1) + value = match.slice(i+2, i+1+mapping[i].len); + + // compute token type + if (typeof rule.token == "function") + type = rule.token.apply(this, value); + else + type = rule.token; + + if (rule.next) { + currentState = rule.next; + state = this.rules[currentState]; + mapping = this.matchMappings[currentState]; + lastIndex = re.lastIndex; + + re = this.regExps[currentState]; + + if (re === undefined) { + throw new Error("You indicated a state of " + rule.next + " to go to, but it doesn't exist!"); + } + + re.lastIndex = lastIndex; + } + break; + } + + if (value[0]) { + if (typeof type == "string") { + value = [value.join("")]; + type = [type]; + } + for (var i = 0; i < value.length; i++) { + if (!value[i]) + continue; + + if ((!rule || rule.merge || type[i] === "text") && token.type === type[i]) { + token.value += value[i]; + } else { + if (token.type) + tokens.push(token); + + token = { + type: type[i], + value: value[i] + }; + } + } + } + + if (lastIndex == line.length) + break; + + lastIndex = re.lastIndex; + } + + if (token.type) + tokens.push(token); + + return { + tokens : tokens, + state : currentState + }; + }; + +}).call(Tokenizer.prototype); + +exports.Tokenizer = Tokenizer; +}); + +ace.define('ace/mode/text_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) { + + +var lang = require("../lib/lang"); + +var TextHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [{ + token : "empty_line", + regex : '^$' + }, { + token : "text", + regex : ".+" + }] + }; +}; + +(function() { + + this.addRules = function(rules, prefix) { + for (var key in rules) { + var state = rules[key]; + for (var i=0; i +Uses the Unicode 5.2 character database + +This package for the XRegExp Unicode plugin enables the following Unicode categories (aka properties): + +L - Letter (the top-level Letter category is included in the Unicode plugin base script) + Ll - Lowercase letter + Lu - Uppercase letter + Lt - Titlecase letter + Lm - Modifier letter + Lo - Letter without case +M - Mark + Mn - Non-spacing mark + Mc - Spacing combining mark + Me - Enclosing mark +N - Number + Nd - Decimal digit + Nl - Letter number + No - Other number +P - Punctuation + Pd - Dash punctuation + Ps - Open punctuation + Pe - Close punctuation + Pi - Initial punctuation + Pf - Final punctuation + Pc - Connector punctuation + Po - Other punctuation +S - Symbol + Sm - Math symbol + Sc - Currency symbol + Sk - Modifier symbol + So - Other symbol +Z - Separator + Zs - Space separator + Zl - Line separator + Zp - Paragraph separator +C - Other + Cc - Control + Cf - Format + Co - Private use + Cs - Surrogate + Cn - Unassigned + +Example usage: + + \p{N} + \p{Cn} +*/ + + +// will be populated by addUnicodePackage +exports.packages = {}; + +addUnicodePackage({ + L: "0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05250531-055605590561-058705D0-05EA05F0-05F20621-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280904-0939093D09500958-0961097109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510D0-10FA10FC1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209421022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2D00-2D252D30-2D652D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A65FA662-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78BA78CA7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC", + Ll: "0061-007A00AA00B500BA00DF-00F600F8-00FF01010103010501070109010B010D010F01110113011501170119011B011D011F01210123012501270129012B012D012F01310133013501370138013A013C013E014001420144014601480149014B014D014F01510153015501570159015B015D015F01610163016501670169016B016D016F0171017301750177017A017C017E-0180018301850188018C018D019201950199-019B019E01A101A301A501A801AA01AB01AD01B001B401B601B901BA01BD-01BF01C601C901CC01CE01D001D201D401D601D801DA01DC01DD01DF01E101E301E501E701E901EB01ED01EF01F001F301F501F901FB01FD01FF02010203020502070209020B020D020F02110213021502170219021B021D021F02210223022502270229022B022D022F02310233-0239023C023F0240024202470249024B024D024F-02930295-02AF037103730377037B-037D039003AC-03CE03D003D103D5-03D703D903DB03DD03DF03E103E303E503E703E903EB03ED03EF-03F303F503F803FB03FC0430-045F04610463046504670469046B046D046F04710473047504770479047B047D047F0481048B048D048F04910493049504970499049B049D049F04A104A304A504A704A904AB04AD04AF04B104B304B504B704B904BB04BD04BF04C204C404C604C804CA04CC04CE04CF04D104D304D504D704D904DB04DD04DF04E104E304E504E704E904EB04ED04EF04F104F304F504F704F904FB04FD04FF05010503050505070509050B050D050F05110513051505170519051B051D051F0521052305250561-05871D00-1D2B1D62-1D771D79-1D9A1E011E031E051E071E091E0B1E0D1E0F1E111E131E151E171E191E1B1E1D1E1F1E211E231E251E271E291E2B1E2D1E2F1E311E331E351E371E391E3B1E3D1E3F1E411E431E451E471E491E4B1E4D1E4F1E511E531E551E571E591E5B1E5D1E5F1E611E631E651E671E691E6B1E6D1E6F1E711E731E751E771E791E7B1E7D1E7F1E811E831E851E871E891E8B1E8D1E8F1E911E931E95-1E9D1E9F1EA11EA31EA51EA71EA91EAB1EAD1EAF1EB11EB31EB51EB71EB91EBB1EBD1EBF1EC11EC31EC51EC71EC91ECB1ECD1ECF1ED11ED31ED51ED71ED91EDB1EDD1EDF1EE11EE31EE51EE71EE91EEB1EED1EEF1EF11EF31EF51EF71EF91EFB1EFD1EFF-1F071F10-1F151F20-1F271F30-1F371F40-1F451F50-1F571F60-1F671F70-1F7D1F80-1F871F90-1F971FA0-1FA71FB0-1FB41FB61FB71FBE1FC2-1FC41FC61FC71FD0-1FD31FD61FD71FE0-1FE71FF2-1FF41FF61FF7210A210E210F2113212F21342139213C213D2146-2149214E21842C30-2C5E2C612C652C662C682C6A2C6C2C712C732C742C76-2C7C2C812C832C852C872C892C8B2C8D2C8F2C912C932C952C972C992C9B2C9D2C9F2CA12CA32CA52CA72CA92CAB2CAD2CAF2CB12CB32CB52CB72CB92CBB2CBD2CBF2CC12CC32CC52CC72CC92CCB2CCD2CCF2CD12CD32CD52CD72CD92CDB2CDD2CDF2CE12CE32CE42CEC2CEE2D00-2D25A641A643A645A647A649A64BA64DA64FA651A653A655A657A659A65BA65DA65FA663A665A667A669A66BA66DA681A683A685A687A689A68BA68DA68FA691A693A695A697A723A725A727A729A72BA72DA72F-A731A733A735A737A739A73BA73DA73FA741A743A745A747A749A74BA74DA74FA751A753A755A757A759A75BA75DA75FA761A763A765A767A769A76BA76DA76FA771-A778A77AA77CA77FA781A783A785A787A78CFB00-FB06FB13-FB17FF41-FF5A", + Lu: "0041-005A00C0-00D600D8-00DE01000102010401060108010A010C010E01100112011401160118011A011C011E01200122012401260128012A012C012E01300132013401360139013B013D013F0141014301450147014A014C014E01500152015401560158015A015C015E01600162016401660168016A016C016E017001720174017601780179017B017D018101820184018601870189-018B018E-0191019301940196-0198019C019D019F01A001A201A401A601A701A901AC01AE01AF01B1-01B301B501B701B801BC01C401C701CA01CD01CF01D101D301D501D701D901DB01DE01E001E201E401E601E801EA01EC01EE01F101F401F6-01F801FA01FC01FE02000202020402060208020A020C020E02100212021402160218021A021C021E02200222022402260228022A022C022E02300232023A023B023D023E02410243-02460248024A024C024E03700372037603860388-038A038C038E038F0391-03A103A3-03AB03CF03D2-03D403D803DA03DC03DE03E003E203E403E603E803EA03EC03EE03F403F703F903FA03FD-042F04600462046404660468046A046C046E04700472047404760478047A047C047E0480048A048C048E04900492049404960498049A049C049E04A004A204A404A604A804AA04AC04AE04B004B204B404B604B804BA04BC04BE04C004C104C304C504C704C904CB04CD04D004D204D404D604D804DA04DC04DE04E004E204E404E604E804EA04EC04EE04F004F204F404F604F804FA04FC04FE05000502050405060508050A050C050E05100512051405160518051A051C051E0520052205240531-055610A0-10C51E001E021E041E061E081E0A1E0C1E0E1E101E121E141E161E181E1A1E1C1E1E1E201E221E241E261E281E2A1E2C1E2E1E301E321E341E361E381E3A1E3C1E3E1E401E421E441E461E481E4A1E4C1E4E1E501E521E541E561E581E5A1E5C1E5E1E601E621E641E661E681E6A1E6C1E6E1E701E721E741E761E781E7A1E7C1E7E1E801E821E841E861E881E8A1E8C1E8E1E901E921E941E9E1EA01EA21EA41EA61EA81EAA1EAC1EAE1EB01EB21EB41EB61EB81EBA1EBC1EBE1EC01EC21EC41EC61EC81ECA1ECC1ECE1ED01ED21ED41ED61ED81EDA1EDC1EDE1EE01EE21EE41EE61EE81EEA1EEC1EEE1EF01EF21EF41EF61EF81EFA1EFC1EFE1F08-1F0F1F18-1F1D1F28-1F2F1F38-1F3F1F48-1F4D1F591F5B1F5D1F5F1F68-1F6F1FB8-1FBB1FC8-1FCB1FD8-1FDB1FE8-1FEC1FF8-1FFB21022107210B-210D2110-211221152119-211D212421262128212A-212D2130-2133213E213F214521832C00-2C2E2C602C62-2C642C672C692C6B2C6D-2C702C722C752C7E-2C802C822C842C862C882C8A2C8C2C8E2C902C922C942C962C982C9A2C9C2C9E2CA02CA22CA42CA62CA82CAA2CAC2CAE2CB02CB22CB42CB62CB82CBA2CBC2CBE2CC02CC22CC42CC62CC82CCA2CCC2CCE2CD02CD22CD42CD62CD82CDA2CDC2CDE2CE02CE22CEB2CEDA640A642A644A646A648A64AA64CA64EA650A652A654A656A658A65AA65CA65EA662A664A666A668A66AA66CA680A682A684A686A688A68AA68CA68EA690A692A694A696A722A724A726A728A72AA72CA72EA732A734A736A738A73AA73CA73EA740A742A744A746A748A74AA74CA74EA750A752A754A756A758A75AA75CA75EA760A762A764A766A768A76AA76CA76EA779A77BA77DA77EA780A782A784A786A78BFF21-FF3A", + Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC", + Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F", + Lo: "01BB01C0-01C3029405D0-05EA05F0-05F20621-063F0641-064A066E066F0671-06D306D506EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA0800-08150904-0939093D09500958-096109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E450E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10D0-10FA1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317DC1820-18421844-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C771CE9-1CEC1CEE-1CF12135-21382D30-2D652D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE3006303C3041-3096309F30A1-30FA30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A014A016-A48CA4D0-A4F7A500-A60BA610-A61FA62AA62BA66EA6A0-A6E5A7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2AA00-AA28AA40-AA42AA44-AA4BAA60-AA6FAA71-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADBAADCABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF66-FF6FFF71-FF9DFFA0-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC", + M: "0300-036F0483-04890591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DE-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0903093C093E-094E0951-0955096209630981-098309BC09BE-09C409C709C809CB-09CD09D709E209E30A01-0A030A3C0A3E-0A420A470A480A4B-0A4D0A510A700A710A750A81-0A830ABC0ABE-0AC50AC7-0AC90ACB-0ACD0AE20AE30B01-0B030B3C0B3E-0B440B470B480B4B-0B4D0B560B570B620B630B820BBE-0BC20BC6-0BC80BCA-0BCD0BD70C01-0C030C3E-0C440C46-0C480C4A-0C4D0C550C560C620C630C820C830CBC0CBE-0CC40CC6-0CC80CCA-0CCD0CD50CD60CE20CE30D020D030D3E-0D440D46-0D480D4A-0D4D0D570D620D630D820D830DCA0DCF-0DD40DD60DD8-0DDF0DF20DF30E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F3E0F3F0F71-0F840F860F870F90-0F970F99-0FBC0FC6102B-103E1056-1059105E-10601062-10641067-106D1071-10741082-108D108F109A-109D135F1712-17141732-1734175217531772177317B6-17D317DD180B-180D18A91920-192B1930-193B19B0-19C019C819C91A17-1A1B1A55-1A5E1A60-1A7C1A7F1B00-1B041B34-1B441B6B-1B731B80-1B821BA1-1BAA1C24-1C371CD0-1CD21CD4-1CE81CED1CF21DC0-1DE61DFD-1DFF20D0-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66F-A672A67CA67DA6F0A6F1A802A806A80BA823-A827A880A881A8B4-A8C4A8E0-A8F1A926-A92DA947-A953A980-A983A9B3-A9C0AA29-AA36AA43AA4CAA4DAA7BAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE3-ABEAABECABEDFB1EFE00-FE0FFE20-FE26", + Mn: "0300-036F0483-04870591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DF-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0902093C0941-0948094D0951-095509620963098109BC09C1-09C409CD09E209E30A010A020A3C0A410A420A470A480A4B-0A4D0A510A700A710A750A810A820ABC0AC1-0AC50AC70AC80ACD0AE20AE30B010B3C0B3F0B41-0B440B4D0B560B620B630B820BC00BCD0C3E-0C400C46-0C480C4A-0C4D0C550C560C620C630CBC0CBF0CC60CCC0CCD0CE20CE30D41-0D440D4D0D620D630DCA0DD2-0DD40DD60E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F71-0F7E0F80-0F840F860F870F90-0F970F99-0FBC0FC6102D-10301032-10371039103A103D103E10581059105E-10601071-1074108210851086108D109D135F1712-17141732-1734175217531772177317B7-17BD17C617C9-17D317DD180B-180D18A91920-19221927192819321939-193B1A171A181A561A58-1A5E1A601A621A65-1A6C1A73-1A7C1A7F1B00-1B031B341B36-1B3A1B3C1B421B6B-1B731B801B811BA2-1BA51BA81BA91C2C-1C331C361C371CD0-1CD21CD4-1CE01CE2-1CE81CED1DC0-1DE61DFD-1DFF20D0-20DC20E120E5-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66FA67CA67DA6F0A6F1A802A806A80BA825A826A8C4A8E0-A8F1A926-A92DA947-A951A980-A982A9B3A9B6-A9B9A9BCAA29-AA2EAA31AA32AA35AA36AA43AA4CAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE5ABE8ABEDFB1EFE00-FE0FFE20-FE26", + Mc: "0903093E-09400949-094C094E0982098309BE-09C009C709C809CB09CC09D70A030A3E-0A400A830ABE-0AC00AC90ACB0ACC0B020B030B3E0B400B470B480B4B0B4C0B570BBE0BBF0BC10BC20BC6-0BC80BCA-0BCC0BD70C01-0C030C41-0C440C820C830CBE0CC0-0CC40CC70CC80CCA0CCB0CD50CD60D020D030D3E-0D400D46-0D480D4A-0D4C0D570D820D830DCF-0DD10DD8-0DDF0DF20DF30F3E0F3F0F7F102B102C10311038103B103C105610571062-10641067-106D108310841087-108C108F109A-109C17B617BE-17C517C717C81923-19261929-192B193019311933-193819B0-19C019C819C91A19-1A1B1A551A571A611A631A641A6D-1A721B041B351B3B1B3D-1B411B431B441B821BA11BA61BA71BAA1C24-1C2B1C341C351CE11CF2A823A824A827A880A881A8B4-A8C3A952A953A983A9B4A9B5A9BAA9BBA9BD-A9C0AA2FAA30AA33AA34AA4DAA7BABE3ABE4ABE6ABE7ABE9ABEAABEC", + Me: "0488048906DE20DD-20E020E2-20E4A670-A672", + N: "0030-003900B200B300B900BC-00BE0660-066906F0-06F907C0-07C90966-096F09E6-09EF09F4-09F90A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BF20C66-0C6F0C78-0C7E0CE6-0CEF0D66-0D750E50-0E590ED0-0ED90F20-0F331040-10491090-10991369-137C16EE-16F017E0-17E917F0-17F91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C5920702074-20792080-20892150-21822185-21892460-249B24EA-24FF2776-27932CFD30073021-30293038-303A3192-31953220-32293251-325F3280-328932B1-32BFA620-A629A6E6-A6EFA830-A835A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19", + Nd: "0030-00390660-066906F0-06F907C0-07C90966-096F09E6-09EF0A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BEF0C66-0C6F0CE6-0CEF0D66-0D6F0E50-0E590ED0-0ED90F20-0F291040-10491090-109917E0-17E91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C59A620-A629A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19", + Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF", + No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835", + P: "0021-00230025-002A002C-002F003A003B003F0040005B-005D005F007B007D00A100AB00B700BB00BF037E0387055A-055F0589058A05BE05C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F3A-0F3D0F850FD0-0FD4104A-104F10FB1361-13681400166D166E169B169C16EB-16ED1735173617D4-17D617D8-17DA1800-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD32010-20272030-20432045-20512053-205E207D207E208D208E2329232A2768-277527C527C627E6-27EF2983-299829D8-29DB29FC29FD2CF9-2CFC2CFE2CFF2E00-2E2E2E302E313001-30033008-30113014-301F3030303D30A030FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFD3EFD3FFE10-FE19FE30-FE52FE54-FE61FE63FE68FE6AFE6BFF01-FF03FF05-FF0AFF0C-FF0FFF1AFF1BFF1FFF20FF3B-FF3DFF3FFF5BFF5DFF5F-FF65", + Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D", + Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62", + Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63", + Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20", + Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21", + Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F", + Po: "0021-00230025-0027002A002C002E002F003A003B003F0040005C00A100B700BF037E0387055A-055F058905C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F850FD0-0FD4104A-104F10FB1361-1368166D166E16EB-16ED1735173617D4-17D617D8-17DA1800-18051807-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD3201620172020-20272030-2038203B-203E2041-20432047-205120532055-205E2CF9-2CFC2CFE2CFF2E002E012E06-2E082E0B2E0E-2E162E182E192E1B2E1E2E1F2E2A-2E2E2E302E313001-3003303D30FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFE10-FE16FE19FE30FE45FE46FE49-FE4CFE50-FE52FE54-FE57FE5F-FE61FE68FE6AFE6BFF01-FF03FF05-FF07FF0AFF0CFF0EFF0FFF1AFF1BFF1FFF20FF3CFF61FF64FF65", + S: "0024002B003C-003E005E0060007C007E00A2-00A900AC00AE-00B100B400B600B800D700F702C2-02C502D2-02DF02E5-02EB02ED02EF-02FF03750384038503F604820606-0608060B060E060F06E906FD06FE07F609F209F309FA09FB0AF10B700BF3-0BFA0C7F0CF10CF20D790E3F0F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-139917DB194019E0-19FF1B61-1B6A1B74-1B7C1FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE20442052207A-207C208A-208C20A0-20B8210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B2140-2144214A-214D214F2190-2328232B-23E82400-24262440-244A249C-24E92500-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE27C0-27C427C7-27CA27CC27D0-27E527F0-29822999-29D729DC-29FB29FE-2B4C2B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F309B309C319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A700-A716A720A721A789A78AA828-A82BA836-A839AA77-AA79FB29FDFCFDFDFE62FE64-FE66FE69FF04FF0BFF1C-FF1EFF3EFF40FF5CFF5EFFE0-FFE6FFE8-FFEEFFFCFFFD", + Sm: "002B003C-003E007C007E00AC00B100D700F703F60606-060820442052207A-207C208A-208C2140-2144214B2190-2194219A219B21A021A321A621AE21CE21CF21D221D421F4-22FF2308-230B23202321237C239B-23B323DC-23E125B725C125F8-25FF266F27C0-27C427C7-27CA27CC27D0-27E527F0-27FF2900-29822999-29D729DC-29FB29FE-2AFF2B30-2B442B47-2B4CFB29FE62FE64-FE66FF0BFF1C-FF1EFF5CFF5EFFE2FFE9-FFEC", + Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6", + Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3", + So: "00A600A700A900AE00B000B60482060E060F06E906FD06FE07F609FA0B700BF3-0BF80BFA0C7F0CF10CF20D790F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-1399194019E0-19FF1B61-1B6A1B74-1B7C210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B214A214C214D214F2195-2199219C-219F21A121A221A421A521A7-21AD21AF-21CD21D021D121D321D5-21F32300-2307230C-231F2322-2328232B-237B237D-239A23B4-23DB23E2-23E82400-24262440-244A249C-24E92500-25B625B8-25C025C2-25F72600-266E2670-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE2800-28FF2B00-2B2F2B452B462B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A828-A82BA836A837A839AA77-AA79FDFDFFE4FFE8FFEDFFEEFFFCFFFD", + Z: "002000A01680180E2000-200A20282029202F205F3000", + Zs: "002000A01680180E2000-200A202F205F3000", + Zl: "2028", + Zp: "2029", + C: "0000-001F007F-009F00AD03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-0605061C061D0620065F06DD070E070F074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17B417B517DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF200B-200F202A-202E2060-206F20722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-F8FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFD-FF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFFBFFFEFFFF", + Cc: "0000-001F007F-009F", + Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB", + Co: "E000-F8FF", + Cs: "D800-DFFF", + Cn: "03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-05FF06040605061C061D0620065F070E074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF2065-206920722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-D7FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFDFEFEFF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFF8FFFEFFFF" +}); + +function addUnicodePackage (pack) { + var codePoint = /\w{4}/g; + for (var name in pack) + exports.packages[name] = pack[name].replace(codePoint, "\\u$&"); +}; + +}); + +ace.define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/range', 'ace/anchor'], function(require, exports, module) { + + +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var Range = require("./range").Range; +var Anchor = require("./anchor").Anchor; + + /** + * new Document([text]) + * - text (String | Array): The starting text + * + * Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty. + * + **/ + +var Document = function(text) { + this.$lines = []; + + // There has to be one line at least in the document. If you pass an empty + // string to the insert function, nothing will happen. Workaround. + if (text.length == 0) { + this.$lines = [""]; + } else if (Array.isArray(text)) { + this.insertLines(0, text); + } else { + this.insert({row: 0, column:0}, text); + } +}; + +(function() { + + oop.implement(this, EventEmitter); + this.setValue = function(text) { + var len = this.getLength(); + this.remove(new Range(0, 0, len, this.getLine(len-1).length)); + this.insert({row: 0, column:0}, text); + }; + this.getValue = function() { + return this.getAllLines().join(this.getNewLineCharacter()); + }; + this.createAnchor = function(row, column) { + return new Anchor(this, row, column); + }; + + // check for IE split bug + if ("aaa".split(/a/).length == 0) + this.$split = function(text) { + return text.replace(/\r\n|\r/g, "\n").split("\n"); + } + else + this.$split = function(text) { + return text.split(/\r\n|\r|\n/); + }; + this.$detectNewLine = function(text) { + var match = text.match(/^.*?(\r\n|\r|\n)/m); + if (match) { + this.$autoNewLine = match[1]; + } else { + this.$autoNewLine = "\n"; + } + }; + this.getNewLineCharacter = function() { + switch (this.$newLineMode) { + case "windows": + return "\r\n"; + + case "unix": + return "\n"; + + case "auto": + return this.$autoNewLine; + } + }; + + this.$autoNewLine = "\n"; + this.$newLineMode = "auto"; + this.setNewLineMode = function(newLineMode) { + if (this.$newLineMode === newLineMode) + return; + + this.$newLineMode = newLineMode; + }; + this.getNewLineMode = function() { + return this.$newLineMode; + }; + this.isNewLine = function(text) { + return (text == "\r\n" || text == "\r" || text == "\n"); + }; + this.getLine = function(row) { + return this.$lines[row] || ""; + }; + this.getLines = function(firstRow, lastRow) { + return this.$lines.slice(firstRow, lastRow + 1); + }; + this.getAllLines = function() { + return this.getLines(0, this.getLength()); + }; + this.getLength = function() { + return this.$lines.length; + }; + this.getTextRange = function(range) { + if (range.start.row == range.end.row) { + return this.$lines[range.start.row].substring(range.start.column, + range.end.column); + } + else { + var lines = this.getLines(range.start.row+1, range.end.row-1); + lines.unshift((this.$lines[range.start.row] || "").substring(range.start.column)); + lines.push((this.$lines[range.end.row] || "").substring(0, range.end.column)); + return lines.join(this.getNewLineCharacter()); + } + }; + this.$clipPosition = function(position) { + var length = this.getLength(); + if (position.row >= length) { + position.row = Math.max(0, length - 1); + position.column = this.getLine(length-1).length; + } + return position; + }; + this.insert = function(position, text) { + if (!text || text.length === 0) + return position; + + position = this.$clipPosition(position); + + // only detect new lines if the document has no line break yet + if (this.getLength() <= 1) + this.$detectNewLine(text); + + var lines = this.$split(text); + var firstLine = lines.splice(0, 1)[0]; + var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0]; + + position = this.insertInLine(position, firstLine); + if (lastLine !== null) { + position = this.insertNewLine(position); // terminate first line + position = this.insertLines(position.row, lines); + position = this.insertInLine(position, lastLine || ""); + } + return position; + }; + /** + * Document@change(e) + * - e (Object): Contains at least one property called `"action"`. `"action"` indicates the action that triggered the change. Each action also has a set of additional properties. + * + * Fires whenever the document changes. + * + * Several methods trigger different `"change"` events. Below is a list of each action type, followed by each property that's also available: + * + * * `"insertLines"` (emitted by [[Document.insertLines]]) + * * `range`: the [[Range]] of the change within the document + * * `lines`: the lines in the document that are changing + * * `"insertText"` (emitted by [[Document.insertNewLine]]) + * * `range`: the [[Range]] of the change within the document + * * `text`: the text that's being added + * * `"removeLines"` (emitted by [[Document.insertLines]]) + * * `range`: the [[Range]] of the change within the document + * * `lines`: the lines in the document that were removed + * * `nl`: the new line character (as defined by [[Document.getNewLineCharacter]]) + * * `"removeText"` (emitted by [[Document.removeInLine]] and [[Document.removeNewLine]]) + * * `range`: the [[Range]] of the change within the document + * * `text`: the text that's being removed + * + **/ + this.insertLines = function(row, lines) { + if (lines.length == 0) + return {row: row, column: 0}; + + // apply doesn't work for big arrays (smallest threshold is on safari 0xFFFF) + // to circumvent that we have to break huge inserts into smaller chunks here + if (lines.length > 0xFFFF) { + var end = this.insertLines(row, lines.slice(0xFFFF)); + lines = lines.slice(0, 0xFFFF); + } + + var args = [row, 0]; + args.push.apply(args, lines); + this.$lines.splice.apply(this.$lines, args); + + var range = new Range(row, 0, row + lines.length, 0); + var delta = { + action: "insertLines", + range: range, + lines: lines + }; + this._emit("change", { data: delta }); + return end || range.end; + }; + this.insertNewLine = function(position) { + position = this.$clipPosition(position); + var line = this.$lines[position.row] || ""; + + this.$lines[position.row] = line.substring(0, position.column); + this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length)); + + var end = { + row : position.row + 1, + column : 0 + }; + + var delta = { + action: "insertText", + range: Range.fromPoints(position, end), + text: this.getNewLineCharacter() + }; + this._emit("change", { data: delta }); + + return end; + }; + this.insertInLine = function(position, text) { + if (text.length == 0) + return position; + + var line = this.$lines[position.row] || ""; + + this.$lines[position.row] = line.substring(0, position.column) + text + + line.substring(position.column); + + var end = { + row : position.row, + column : position.column + text.length + }; + + var delta = { + action: "insertText", + range: Range.fromPoints(position, end), + text: text + }; + this._emit("change", { data: delta }); + + return end; + }; + this.remove = function(range) { + // clip to document + range.start = this.$clipPosition(range.start); + range.end = this.$clipPosition(range.end); + + if (range.isEmpty()) + return range.start; + + var firstRow = range.start.row; + var lastRow = range.end.row; + + if (range.isMultiLine()) { + var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1; + var lastFullRow = lastRow - 1; + + if (range.end.column > 0) + this.removeInLine(lastRow, 0, range.end.column); + + if (lastFullRow >= firstFullRow) + this.removeLines(firstFullRow, lastFullRow); + + if (firstFullRow != firstRow) { + this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length); + this.removeNewLine(range.start.row); + } + } + else { + this.removeInLine(firstRow, range.start.column, range.end.column); + } + return range.start; + }; + this.removeInLine = function(row, startColumn, endColumn) { + if (startColumn == endColumn) + return; + + var range = new Range(row, startColumn, row, endColumn); + var line = this.getLine(row); + var removed = line.substring(startColumn, endColumn); + var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length); + this.$lines.splice(row, 1, newLine); + + var delta = { + action: "removeText", + range: range, + text: removed + }; + this._emit("change", { data: delta }); + return range.start; + }; + this.removeLines = function(firstRow, lastRow) { + var range = new Range(firstRow, 0, lastRow + 1, 0); + var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1); + + var delta = { + action: "removeLines", + range: range, + nl: this.getNewLineCharacter(), + lines: removed + }; + this._emit("change", { data: delta }); + return removed; + }; + this.removeNewLine = function(row) { + var firstLine = this.getLine(row); + var secondLine = this.getLine(row+1); + + var range = new Range(row, firstLine.length, row+1, 0); + var line = firstLine + secondLine; + + this.$lines.splice(row, 2, line); + + var delta = { + action: "removeText", + range: range, + text: this.getNewLineCharacter() + }; + this._emit("change", { data: delta }); + }; + this.replace = function(range, text) { + if (text.length == 0 && range.isEmpty()) + return range.start; + + // Shortcut: If the text we want to insert is the same as it is already + // in the document, we don't have to replace anything. + if (text == this.getTextRange(range)) + return range.end; + + this.remove(range); + if (text) { + var end = this.insert(range.start, text); + } + else { + end = range.start; + } + + return end; + }; + this.applyDeltas = function(deltas) { + for (var i=0; i=0; i--) { + var delta = deltas[i]; + + var range = Range.fromPoints(delta.range.start, delta.range.end); + + if (delta.action == "insertLines") + this.removeLines(range.start.row, range.end.row - 1); + else if (delta.action == "insertText") + this.remove(range); + else if (delta.action == "removeLines") + this.insertLines(range.start.row, delta.lines); + else if (delta.action == "removeText") + this.insert(range.start, delta.text); + } + }; + +}).call(Document.prototype); + +exports.Document = Document; +}); + +ace.define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) { + + +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; + +/** + * new Anchor(doc, row, column) + * - doc (Document): The document to associate with the anchor + * - row (Number): The starting row position + * - column (Number): The starting column position + * + * Creates a new `Anchor` and associates it with a document. + * + **/ + +var Anchor = exports.Anchor = function(doc, row, column) { + this.document = doc; + + if (typeof column == "undefined") + this.setPosition(row.row, row.column); + else + this.setPosition(row, column); + + this.$onChange = this.onChange.bind(this); + doc.on("change", this.$onChange); +}; + +(function() { + + oop.implement(this, EventEmitter); + + this.getPosition = function() { + return this.$clipPositionToDocument(this.row, this.column); + }; + + this.getDocument = function() { + return this.document; + }; + + this.onChange = function(e) { + var delta = e.data; + var range = delta.range; + + if (range.start.row == range.end.row && range.start.row != this.row) + return; + + if (range.start.row > this.row) + return; + + if (range.start.row == this.row && range.start.column > this.column) + return; + + var row = this.row; + var column = this.column; + + if (delta.action === "insertText") { + if (range.start.row === row && range.start.column <= column) { + if (range.start.row === range.end.row) { + column += range.end.column - range.start.column; + } + else { + column -= range.start.column; + row += range.end.row - range.start.row; + } + } + else if (range.start.row !== range.end.row && range.start.row < row) { + row += range.end.row - range.start.row; + } + } else if (delta.action === "insertLines") { + if (range.start.row <= row) { + row += range.end.row - range.start.row; + } + } + else if (delta.action == "removeText") { + if (range.start.row == row && range.start.column < column) { + if (range.end.column >= column) + column = range.start.column; + else + column = Math.max(0, column - (range.end.column - range.start.column)); + + } else if (range.start.row !== range.end.row && range.start.row < row) { + if (range.end.row == row) { + column = Math.max(0, column - range.end.column) + range.start.column; + } + row -= (range.end.row - range.start.row); + } + else if (range.end.row == row) { + row -= range.end.row - range.start.row; + column = Math.max(0, column - range.end.column) + range.start.column; + } + } else if (delta.action == "removeLines") { + if (range.start.row <= row) { + if (range.end.row <= row) + row -= range.end.row - range.start.row; + else { + row = range.start.row; + column = 0; + } + } + } + + this.setPosition(row, column, true); + }; + + this.setPosition = function(row, column, noClip) { + var pos; + if (noClip) { + pos = { + row: row, + column: column + }; + } + else { + pos = this.$clipPositionToDocument(row, column); + } + + if (this.row == pos.row && this.column == pos.column) + return; + + var old = { + row: this.row, + column: this.column + }; + + this.row = pos.row; + this.column = pos.column; + this._emit("change", { + old: old, + value: pos + }); + }; + + this.detach = function() { + this.document.removeEventListener("change", this.$onChange); + }; + + this.$clipPositionToDocument = function(row, column) { + var pos = {}; + + if (row >= this.document.getLength()) { + pos.row = Math.max(0, this.document.getLength() - 1); + pos.column = this.document.getLine(pos.row).length; + } + else if (row < 0) { + pos.row = 0; + pos.column = 0; + } + else { + pos.row = row; + pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column)); + } + + if (column < 0) + pos.column = 0; + + return pos; + }; + +}).call(Anchor.prototype); + +}); + +ace.define('ace/background_tokenizer', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) { + + +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; + +// tokenizing lines longer than this makes editor very slow +var MAX_LINE_LENGTH = 5000; + +/** + * new BackgroundTokenizer(tokenizer, editor) + * - tokenizer (Tokenizer): The tokenizer to use + * - editor (Editor): The editor to associate with + * + * Creates a new `BackgroundTokenizer` object. + * + * + **/ + +var BackgroundTokenizer = function(tokenizer, editor) { + this.running = false; + this.lines = []; + this.states = []; + this.currentLine = 0; + this.tokenizer = tokenizer; + + var self = this; + + this.$worker = function() { + if (!self.running) { return; } + + var workerStart = new Date(); + var startLine = self.currentLine; + var doc = self.doc; + + var processedLines = 0; + + var len = doc.getLength(); + while (self.currentLine < len) { + self.$tokenizeRow(self.currentLine); + while (self.lines[self.currentLine]) + self.currentLine++; + + // only check every 5 lines + processedLines ++; + if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) { + self.fireUpdateEvent(startLine, self.currentLine-1); + self.running = setTimeout(self.$worker, 20); + return; + } + } + + self.running = false; + + self.fireUpdateEvent(startLine, len - 1); + }; +}; + +(function(){ + + oop.implement(this, EventEmitter); + this.setTokenizer = function(tokenizer) { + this.tokenizer = tokenizer; + this.lines = []; + this.states = []; + + this.start(0); + }; + this.setDocument = function(doc) { + this.doc = doc; + this.lines = []; + this.states = []; + + this.stop(); + }; + /** + * BackgroundTokenizer@update(e) + * - e (Object): An object containing two properties, `first` and `last`, which indicate the rows of the region being updated. + * + * Fires whenever the background tokeniziers between a range of rows are going to be updated. + * + **/ + this.fireUpdateEvent = function(firstRow, lastRow) { + var data = { + first: firstRow, + last: lastRow + }; + this._emit("update", {data: data}); + }; + this.start = function(startRow) { + this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength()); + + // remove all cached items below this line + this.lines.splice(this.currentLine, this.lines.length); + this.states.splice(this.currentLine, this.states.length); + + this.stop(); + // pretty long delay to prevent the tokenizer from interfering with the user + this.running = setTimeout(this.$worker, 700); + }; + + this.$updateOnChange = function(delta) { + var range = delta.range; + var startRow = range.start.row; + var len = range.end.row - startRow; + + if (len === 0) { + this.lines[startRow] = null; + } else if (delta.action == "removeText" || delta.action == "removeLines") { + this.lines.splice(startRow, len + 1, null); + this.states.splice(startRow, len + 1, null); + } else { + var args = Array(len + 1); + args.unshift(startRow, 1); + this.lines.splice.apply(this.lines, args); + this.states.splice.apply(this.states, args); + } + + this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength()); + + this.stop(); + // pretty long delay to prevent the tokenizer from interfering with the user + this.running = setTimeout(this.$worker, 700); + }; + this.stop = function() { + if (this.running) + clearTimeout(this.running); + this.running = false; + }; + this.getTokens = function(row) { + return this.lines[row] || this.$tokenizeRow(row); + }; + this.getState = function(row) { + if (this.currentLine == row) + this.$tokenizeRow(row); + return this.states[row] || "start"; + }; + + this.$tokenizeRow = function(row) { + var line = this.doc.getLine(row); + var state = this.states[row - 1]; + + if (line.length > MAX_LINE_LENGTH) { + var overflow = {value: line.substr(MAX_LINE_LENGTH), type: "text"}; + line = line.slice(0, MAX_LINE_LENGTH); + } + var data = this.tokenizer.getLineTokens(line, state); + if (overflow) { + data.tokens.push(overflow); + data.state = "start"; + } + + if (this.states[row] !== data.state) { + this.states[row] = data.state; + this.lines[row + 1] = null; + if (this.currentLine > row + 1) + this.currentLine = row + 1; + } else if (this.currentLine == row) { + this.currentLine = row + 1; + } + + return this.lines[row] = data.tokens; + }; + +}).call(BackgroundTokenizer.prototype); + +exports.BackgroundTokenizer = BackgroundTokenizer; +}); + +ace.define('ace/search_highlight', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/lib/oop', 'ace/range'], function(require, exports, module) { + + +var lang = require("./lib/lang"); +var oop = require("./lib/oop"); +var Range = require("./range").Range; + +var SearchHighlight = function(regExp, clazz, type) { + this.setRegexp(regExp); + this.clazz = clazz; + this.type = type || "text"; +}; + +(function() { + this.setRegexp = function(regExp) { + if (this.regExp+"" == regExp+"") + return; + this.regExp = regExp; + this.cache = []; + }; + + this.update = function(html, markerLayer, session, config) { + if (!this.regExp) + return; + var start = config.firstRow, end = config.lastRow; + + for (var i = start; i <= end; i++) { + var ranges = this.cache[i]; + if (ranges == null) { + ranges = lang.getMatchOffsets(session.getLine(i), this.regExp); + ranges = ranges.map(function(match) { + return new Range(i, match.offset, i, match.offset + match.length); + }); + this.cache[i] = ranges.length ? ranges : ""; + } + + for (var j = ranges.length; j --; ) { + markerLayer.drawSingleLineMarker( + html, ranges[j].toScreenRange(session), this.clazz, config, + null, this.type + ); + } + } + }; + +}).call(SearchHighlight.prototype); + +exports.SearchHighlight = SearchHighlight; +}); + +ace.define('ace/edit_session/folding', ['require', 'exports', 'module' , 'ace/range', 'ace/edit_session/fold_line', 'ace/edit_session/fold', 'ace/token_iterator'], function(require, exports, module) { + + +var Range = require("../range").Range; +var FoldLine = require("./fold_line").FoldLine; +var Fold = require("./fold").Fold; +var TokenIterator = require("../token_iterator").TokenIterator; + +function Folding() { + /* + * Looks up a fold at a given row/column. Possible values for side: + * -1: ignore a fold if fold.start = row/column + * +1: ignore a fold if fold.end = row/column + */ + this.getFoldAt = function(row, column, side) { + var foldLine = this.getFoldLine(row); + if (!foldLine) + return null; + + var folds = foldLine.folds; + for (var i = 0; i < folds.length; i++) { + var fold = folds[i]; + if (fold.range.contains(row, column)) { + if (side == 1 && fold.range.isEnd(row, column)) { + continue; + } else if (side == -1 && fold.range.isStart(row, column)) { + continue; + } + return fold; + } + } + }; + this.getFoldsInRange = function(range) { + range = range.clone(); + var start = range.start; + var end = range.end; + var foldLines = this.$foldData; + var foundFolds = []; + + start.column += 1; + end.column -= 1; + + for (var i = 0; i < foldLines.length; i++) { + var cmp = foldLines[i].range.compareRange(range); + if (cmp == 2) { + // Range is before foldLine. No intersection. This means, + // there might be other foldLines that intersect. + continue; + } + else if (cmp == -2) { + // Range is after foldLine. There can't be any other foldLines then, + // so let's give up. + break; + } + + var folds = foldLines[i].folds; + for (var j = 0; j < folds.length; j++) { + var fold = folds[j]; + cmp = fold.range.compareRange(range); + if (cmp == -2) { + break; + } else if (cmp == 2) { + continue; + } else + // WTF-state: Can happen due to -1/+1 to start/end column. + if (cmp == 42) { + break; + } + foundFolds.push(fold); + } + } + return foundFolds; + }; + this.getAllFolds = function() { + var folds = []; + var foldLines = this.$foldData; + + function addFold(fold) { + folds.push(fold); + if (!fold.subFolds) + return; + + for (var i = 0; i < fold.subFolds.length; i++) + addFold(fold.subFolds[i]); + } + + for (var i = 0; i < foldLines.length; i++) + for (var j = 0; j < foldLines[i].folds.length; j++) + addFold(foldLines[i].folds[j]); + + return folds; + }; + this.getFoldStringAt = function(row, column, trim, foldLine) { + foldLine = foldLine || this.getFoldLine(row); + if (!foldLine) + return null; + + var lastFold = { + end: { column: 0 } + }; + // TODO: Refactor to use getNextFoldTo function. + var str, fold; + for (var i = 0; i < foldLine.folds.length; i++) { + fold = foldLine.folds[i]; + var cmp = fold.range.compareEnd(row, column); + if (cmp == -1) { + str = this + .getLine(fold.start.row) + .substring(lastFold.end.column, fold.start.column); + break; + } + else if (cmp === 0) { + return null; + } + lastFold = fold; + } + if (!str) + str = this.getLine(fold.start.row).substring(lastFold.end.column); + + if (trim == -1) + return str.substring(0, column - lastFold.end.column); + else if (trim == 1) + return str.substring(column - lastFold.end.column); + else + return str; + }; + + this.getFoldLine = function(docRow, startFoldLine) { + var foldData = this.$foldData; + var i = 0; + if (startFoldLine) + i = foldData.indexOf(startFoldLine); + if (i == -1) + i = 0; + for (i; i < foldData.length; i++) { + var foldLine = foldData[i]; + if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) { + return foldLine; + } else if (foldLine.end.row > docRow) { + return null; + } + } + return null; + }; + + // returns the fold which starts after or contains docRow + this.getNextFoldLine = function(docRow, startFoldLine) { + var foldData = this.$foldData; + var i = 0; + if (startFoldLine) + i = foldData.indexOf(startFoldLine); + if (i == -1) + i = 0; + for (i; i < foldData.length; i++) { + var foldLine = foldData[i]; + if (foldLine.end.row >= docRow) { + return foldLine; + } + } + return null; + }; + + this.getFoldedRowCount = function(first, last) { + var foldData = this.$foldData, rowCount = last-first+1; + for (var i = 0; i < foldData.length; i++) { + var foldLine = foldData[i], + end = foldLine.end.row, + start = foldLine.start.row; + if (end >= last) { + if(start < last) { + if(start >= first) + rowCount -= last-start; + else + rowCount = 0;//in one fold + } + break; + } else if(end >= first){ + if (start >= first) //fold inside range + rowCount -= end-start; + else + rowCount -= end-first+1; + } + } + return rowCount; + }; + + this.$addFoldLine = function(foldLine) { + this.$foldData.push(foldLine); + this.$foldData.sort(function(a, b) { + return a.start.row - b.start.row; + }); + return foldLine; + }; + this.addFold = function(placeholder, range) { + var foldData = this.$foldData; + var added = false; + var fold; + + if (placeholder instanceof Fold) + fold = placeholder; + else + fold = new Fold(range, placeholder); + + this.$clipRangeToDocument(fold.range); + + var startRow = fold.start.row; + var startColumn = fold.start.column; + var endRow = fold.end.row; + var endColumn = fold.end.column; + + // --- Some checking --- + if (fold.placeholder.length < 2) + throw "Placeholder has to be at least 2 characters"; + + if (startRow == endRow && endColumn - startColumn < 2) + throw "The range has to be at least 2 characters width"; + + var startFold = this.getFoldAt(startRow, startColumn, 1); + var endFold = this.getFoldAt(endRow, endColumn, -1); + if (startFold && endFold == startFold) + return startFold.addSubFold(fold); + + if ( + (startFold && !startFold.range.isStart(startRow, startColumn)) + || (endFold && !endFold.range.isEnd(endRow, endColumn)) + ) { + throw "A fold can't intersect already existing fold" + fold.range + startFold.range; + } + + // Check if there are folds in the range we create the new fold for. + var folds = this.getFoldsInRange(fold.range); + if (folds.length > 0) { + // Remove the folds from fold data. + this.removeFolds(folds); + // Add the removed folds as subfolds on the new fold. + fold.subFolds = folds; + } + + for (var i = 0; i < foldData.length; i++) { + var foldLine = foldData[i]; + if (endRow == foldLine.start.row) { + foldLine.addFold(fold); + added = true; + break; + } + else if (startRow == foldLine.end.row) { + foldLine.addFold(fold); + added = true; + if (!fold.sameRow) { + // Check if we might have to merge two FoldLines. + var foldLineNext = foldData[i + 1]; + if (foldLineNext && foldLineNext.start.row == endRow) { + // We need to merge! + foldLine.merge(foldLineNext); + break; + } + } + break; + } + else if (endRow <= foldLine.start.row) { + break; + } + } + + if (!added) + foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold)); + + if (this.$useWrapMode) + this.$updateWrapData(foldLine.start.row, foldLine.start.row); + else + this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row); + + // Notify that fold data has changed. + this.$modified = true; + this._emit("changeFold", { data: fold }); + + return fold; + }; + + this.addFolds = function(folds) { + folds.forEach(function(fold) { + this.addFold(fold); + }, this); + }; + + this.removeFold = function(fold) { + var foldLine = fold.foldLine; + var startRow = foldLine.start.row; + var endRow = foldLine.end.row; + + var foldLines = this.$foldData; + var folds = foldLine.folds; + // Simple case where there is only one fold in the FoldLine such that + // the entire fold line can get removed directly. + if (folds.length == 1) { + foldLines.splice(foldLines.indexOf(foldLine), 1); + } else + // If the fold is the last fold of the foldLine, just remove it. + if (foldLine.range.isEnd(fold.end.row, fold.end.column)) { + folds.pop(); + foldLine.end.row = folds[folds.length - 1].end.row; + foldLine.end.column = folds[folds.length - 1].end.column; + } else + // If the fold is the first fold of the foldLine, just remove it. + if (foldLine.range.isStart(fold.start.row, fold.start.column)) { + folds.shift(); + foldLine.start.row = folds[0].start.row; + foldLine.start.column = folds[0].start.column; + } else + // We know there are more then 2 folds and the fold is not at the edge. + // This means, the fold is somewhere in between. + // + // If the fold is in one row, we just can remove it. + if (fold.sameRow) { + folds.splice(folds.indexOf(fold), 1); + } else + // The fold goes over more then one row. This means remvoing this fold + // will cause the fold line to get splitted up. newFoldLine is the second part + { + var newFoldLine = foldLine.split(fold.start.row, fold.start.column); + folds = newFoldLine.folds; + folds.shift(); + newFoldLine.start.row = folds[0].start.row; + newFoldLine.start.column = folds[0].start.column; + } + + if (this.$useWrapMode) + this.$updateWrapData(startRow, endRow); + else + this.$updateRowLengthCache(startRow, endRow); + + // Notify that fold data has changed. + this.$modified = true; + this._emit("changeFold", { data: fold }); + }; + + this.removeFolds = function(folds) { + // We need to clone the folds array passed in as it might be the folds + // array of a fold line and as we call this.removeFold(fold), folds + // are removed from folds and changes the current index. + var cloneFolds = []; + for (var i = 0; i < folds.length; i++) { + cloneFolds.push(folds[i]); + } + + cloneFolds.forEach(function(fold) { + this.removeFold(fold); + }, this); + this.$modified = true; + }; + + this.expandFold = function(fold) { + this.removeFold(fold); + fold.subFolds.forEach(function(fold) { + this.addFold(fold); + }, this); + fold.subFolds = []; + }; + + this.expandFolds = function(folds) { + folds.forEach(function(fold) { + this.expandFold(fold); + }, this); + }; + + this.unfold = function(location, expandInner) { + var range, folds; + if (location == null) + range = new Range(0, 0, this.getLength(), 0); + else if (typeof location == "number") + range = new Range(location, 0, location, this.getLine(location).length); + else if ("row" in location) + range = Range.fromPoints(location, location); + else + range = location; + + folds = this.getFoldsInRange(range); + if (expandInner) { + this.removeFolds(folds); + } else { + // TODO: might need to remove and add folds in one go instead of using + // expandFolds several times. + while (folds.length) { + this.expandFolds(folds); + folds = this.getFoldsInRange(range); + } + } + }; + this.isRowFolded = function(docRow, startFoldRow) { + return !!this.getFoldLine(docRow, startFoldRow); + }; + + this.getRowFoldEnd = function(docRow, startFoldRow) { + var foldLine = this.getFoldLine(docRow, startFoldRow); + return foldLine ? foldLine.end.row : docRow; + }; + + this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) { + if (startRow == null) { + startRow = foldLine.start.row; + startColumn = 0; + } + + if (endRow == null) { + endRow = foldLine.end.row; + endColumn = this.getLine(endRow).length; + } + + // Build the textline using the FoldLine walker. + var doc = this.doc; + var textLine = ""; + + foldLine.walk(function(placeholder, row, column, lastColumn) { + if (row < startRow) { + return; + } else if (row == startRow) { + if (column < startColumn) { + return; + } + lastColumn = Math.max(startColumn, lastColumn); + } + if (placeholder) { + textLine += placeholder; + } else { + textLine += doc.getLine(row).substring(lastColumn, column); + } + }.bind(this), endRow, endColumn); + return textLine; + }; + + this.getDisplayLine = function(row, endColumn, startRow, startColumn) { + var foldLine = this.getFoldLine(row); + + if (!foldLine) { + var line; + line = this.doc.getLine(row); + return line.substring(startColumn || 0, endColumn || line.length); + } else { + return this.getFoldDisplayLine( + foldLine, row, endColumn, startRow, startColumn); + } + }; + + this.$cloneFoldData = function() { + var fd = []; + fd = this.$foldData.map(function(foldLine) { + var folds = foldLine.folds.map(function(fold) { + return fold.clone(); + }); + return new FoldLine(fd, folds); + }); + + return fd; + }; + + this.toggleFold = function(tryToUnfold) { + var selection = this.selection; + var range = selection.getRange(); + var fold; + var bracketPos; + + if (range.isEmpty()) { + var cursor = range.start; + fold = this.getFoldAt(cursor.row, cursor.column); + + if (fold) { + this.expandFold(fold); + return; + } + else if (bracketPos = this.findMatchingBracket(cursor)) { + if (range.comparePoint(bracketPos) == 1) { + range.end = bracketPos; + } + else { + range.start = bracketPos; + range.start.column++; + range.end.column--; + } + } + else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) { + if (range.comparePoint(bracketPos) == 1) + range.end = bracketPos; + else + range.start = bracketPos; + + range.start.column++; + } + else { + range = this.getCommentFoldRange(cursor.row, cursor.column) || range; + } + } else { + var folds = this.getFoldsInRange(range); + if (tryToUnfold && folds.length) { + this.expandFolds(folds); + return; + } + else if (folds.length == 1 ) { + fold = folds[0]; + } + } + + if (!fold) + fold = this.getFoldAt(range.start.row, range.start.column); + + if (fold && fold.range.toString() == range.toString()) { + this.expandFold(fold); + return; + } + + var placeholder = "..."; + if (!range.isMultiLine()) { + placeholder = this.getTextRange(range); + if(placeholder.length < 4) + return; + placeholder = placeholder.trim().substring(0, 2) + ".."; + } + + this.addFold(placeholder, range); + }; + + this.getCommentFoldRange = function(row, column) { + var iterator = new TokenIterator(this, row, column); + var token = iterator.getCurrentToken(); + if (token && /^comment|string/.test(token.type)) { + var range = new Range(); + var re = new RegExp(token.type.replace(/\..*/, "\\.")); + do { + token = iterator.stepBackward(); + } while(token && re.test(token.type)); + + iterator.stepForward(); + range.start.row = iterator.getCurrentTokenRow(); + range.start.column = iterator.getCurrentTokenColumn() + 2; + + iterator = new TokenIterator(this, row, column); + + do { + token = iterator.stepForward(); + } while(token && re.test(token.type)); + + token = iterator.stepBackward(); + + range.end.row = iterator.getCurrentTokenRow(); + range.end.column = iterator.getCurrentTokenColumn() + token.value.length; + return range; + } + }; + + this.foldAll = function(startRow, endRow) { + var foldWidgets = this.foldWidgets; + endRow = endRow || this.getLength(); + for (var row = startRow || 0; row < endRow; row++) { + if (foldWidgets[row] == null) + foldWidgets[row] = this.getFoldWidget(row); + if (foldWidgets[row] != "start") + continue; + + var range = this.getFoldWidgetRange(row); + // sometimes range can be incompatible with existing fold + // wouldn't it be better for addFold to return null istead of throwing? + if (range && range.end.row < endRow) try { + this.addFold("...", range); + } catch(e) {} + } + }; + + this.$foldStyles = { + "manual": 1, + "markbegin": 1, + "markbeginend": 1 + }; + this.$foldStyle = "markbegin"; + this.setFoldStyle = function(style) { + if (!this.$foldStyles[style]) + throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]"); + + if (this.$foldStyle == style) + return; + + this.$foldStyle = style; + + if (style == "manual") + this.unfold(); + + // reset folding + var mode = this.$foldMode; + this.$setFolding(null); + this.$setFolding(mode); + }; + + // structured folding + this.$setFolding = function(foldMode) { + if (this.$foldMode == foldMode) + return; + + this.$foldMode = foldMode; + + this.removeListener('change', this.$updateFoldWidgets); + this._emit("changeAnnotation"); + + if (!foldMode || this.$foldStyle == "manual") { + this.foldWidgets = null; + return; + } + + this.foldWidgets = []; + this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle); + this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle); + + this.$updateFoldWidgets = this.updateFoldWidgets.bind(this); + this.on('change', this.$updateFoldWidgets); + + }; + + this.onFoldWidgetClick = function(row, e) { + var type = this.getFoldWidget(row); + var line = this.getLine(row); + var onlySubfolds = e.shiftKey; + var addSubfolds = onlySubfolds || e.ctrlKey || e.altKey || e.metaKey; + var fold; + + if (type == "end") + fold = this.getFoldAt(row, 0, -1); + else + fold = this.getFoldAt(row, line.length, 1); + + if (fold) { + if (addSubfolds) + this.removeFold(fold); + else + this.expandFold(fold); + return; + } + + var range = this.getFoldWidgetRange(row); + if (range) { + // sometimes singleline folds can be missed by the code above + if (!range.isMultiLine()) { + fold = this.getFoldAt(range.start.row, range.start.column, 1); + if (fold && range.isEqual(fold.range)) { + this.removeFold(fold); + return; + } + } + + if (!onlySubfolds) + this.addFold("...", range); + + if (addSubfolds) + this.foldAll(range.start.row + 1, range.end.row); + } else { + if (addSubfolds) + this.foldAll(row + 1, this.getLength()); + (e.target || e.srcElement).className += " invalid" + } + }; + + this.updateFoldWidgets = function(e) { + var delta = e.data; + var range = delta.range; + var firstRow = range.start.row; + var len = range.end.row - firstRow; + + if (len === 0) { + this.foldWidgets[firstRow] = null; + } else if (delta.action == "removeText" || delta.action == "removeLines") { + this.foldWidgets.splice(firstRow, len + 1, null); + } else { + var args = Array(len + 1); + args.unshift(firstRow, 1); + this.foldWidgets.splice.apply(this.foldWidgets, args); + } + }; + +} + +exports.Folding = Folding; + +}); + +ace.define('ace/edit_session/fold_line', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; +function FoldLine(foldData, folds) { + this.foldData = foldData; + if (Array.isArray(folds)) { + this.folds = folds; + } else { + folds = this.folds = [ folds ]; + } + + var last = folds[folds.length - 1] + this.range = new Range(folds[0].start.row, folds[0].start.column, + last.end.row, last.end.column); + this.start = this.range.start; + this.end = this.range.end; + + this.folds.forEach(function(fold) { + fold.setFoldLine(this); + }, this); +} + +(function() { + /* + * Note: This doesn't update wrapData! + */ + this.shiftRow = function(shift) { + this.start.row += shift; + this.end.row += shift; + this.folds.forEach(function(fold) { + fold.start.row += shift; + fold.end.row += shift; + }); + } + + this.addFold = function(fold) { + if (fold.sameRow) { + if (fold.start.row < this.startRow || fold.endRow > this.endRow) { + throw "Can't add a fold to this FoldLine as it has no connection"; + } + this.folds.push(fold); + this.folds.sort(function(a, b) { + return -a.range.compareEnd(b.start.row, b.start.column); + }); + if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) { + this.end.row = fold.end.row; + this.end.column = fold.end.column; + } else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) { + this.start.row = fold.start.row; + this.start.column = fold.start.column; + } + } else if (fold.start.row == this.end.row) { + this.folds.push(fold); + this.end.row = fold.end.row; + this.end.column = fold.end.column; + } else if (fold.end.row == this.start.row) { + this.folds.unshift(fold); + this.start.row = fold.start.row; + this.start.column = fold.start.column; + } else { + throw "Trying to add fold to FoldRow that doesn't have a matching row"; + } + fold.foldLine = this; + } + + this.containsRow = function(row) { + return row >= this.start.row && row <= this.end.row; + } + + this.walk = function(callback, endRow, endColumn) { + var lastEnd = 0, + folds = this.folds, + fold, + comp, stop, isNewRow = true; + + if (endRow == null) { + endRow = this.end.row; + endColumn = this.end.column; + } + + for (var i = 0; i < folds.length; i++) { + fold = folds[i]; + + comp = fold.range.compareStart(endRow, endColumn); + // This fold is after the endRow/Column. + if (comp == -1) { + callback(null, endRow, endColumn, lastEnd, isNewRow); + return; + } + + stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow); + stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd); + + // If the user requested to stop the walk or endRow/endColumn is + // inside of this fold (comp == 0), then end here. + if (stop || comp == 0) { + return; + } + + // Note the new lastEnd might not be on the same line. However, + // it's the callback's job to recognize this. + isNewRow = !fold.sameRow; + lastEnd = fold.end.column; + } + callback(null, endRow, endColumn, lastEnd, isNewRow); + } + + this.getNextFoldTo = function(row, column) { + var fold, cmp; + for (var i = 0; i < this.folds.length; i++) { + fold = this.folds[i]; + cmp = fold.range.compareEnd(row, column); + if (cmp == -1) { + return { + fold: fold, + kind: "after" + }; + } else if (cmp == 0) { + return { + fold: fold, + kind: "inside" + } + } + } + return null; + } + + this.addRemoveChars = function(row, column, len) { + var ret = this.getNextFoldTo(row, column), + fold, folds; + if (ret) { + fold = ret.fold; + if (ret.kind == "inside" + && fold.start.column != column + && fold.start.row != row) + { + //throwing here breaks whole editor + //TODO: properly handle this + window.console && window.console.log(row, column, fold); + } else if (fold.start.row == row) { + folds = this.folds; + var i = folds.indexOf(fold); + if (i == 0) { + this.start.column += len; + } + for (i; i < folds.length; i++) { + fold = folds[i]; + fold.start.column += len; + if (!fold.sameRow) { + return; + } + fold.end.column += len; + } + this.end.column += len; + } + } + } + + this.split = function(row, column) { + var fold = this.getNextFoldTo(row, column).fold, + folds = this.folds; + var foldData = this.foldData; + + if (!fold) { + return null; + } + var i = folds.indexOf(fold); + var foldBefore = folds[i - 1]; + this.end.row = foldBefore.end.row; + this.end.column = foldBefore.end.column; + + // Remove the folds after row/column and create a new FoldLine + // containing these removed folds. + folds = folds.splice(i, folds.length - i); + + var newFoldLine = new FoldLine(foldData, folds); + foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine); + return newFoldLine; + } + + this.merge = function(foldLineNext) { + var folds = foldLineNext.folds; + for (var i = 0; i < folds.length; i++) { + this.addFold(folds[i]); + } + // Remove the foldLineNext - no longer needed, as + // it's merged now with foldLineNext. + var foldData = this.foldData; + foldData.splice(foldData.indexOf(foldLineNext), 1); + } + + this.toString = function() { + var ret = [this.range.toString() + ": [" ]; + + this.folds.forEach(function(fold) { + ret.push(" " + fold.toString()); + }); + ret.push("]") + return ret.join("\n"); + } + + this.idxToPosition = function(idx) { + var lastFoldEndColumn = 0; + var fold; + + for (var i = 0; i < this.folds.length; i++) { + var fold = this.folds[i]; + + idx -= fold.start.column - lastFoldEndColumn; + if (idx < 0) { + return { + row: fold.start.row, + column: fold.start.column + idx + }; + } + + idx -= fold.placeholder.length; + if (idx < 0) { + return fold.start; + } + + lastFoldEndColumn = fold.end.column; + } + + return { + row: this.end.row, + column: this.end.column + idx + }; + } +}).call(FoldLine.prototype); + +exports.FoldLine = FoldLine; +}); + +ace.define('ace/edit_session/fold', ['require', 'exports', 'module' ], function(require, exports, module) { + + +/* + * Simple fold-data struct. + **/ +var Fold = exports.Fold = function(range, placeholder) { + this.foldLine = null; + this.placeholder = placeholder; + this.range = range; + this.start = range.start; + this.end = range.end; + + this.sameRow = range.start.row == range.end.row; + this.subFolds = []; +}; + +(function() { + + this.toString = function() { + return '"' + this.placeholder + '" ' + this.range.toString(); + }; + + this.setFoldLine = function(foldLine) { + this.foldLine = foldLine; + this.subFolds.forEach(function(fold) { + fold.setFoldLine(foldLine); + }); + }; + + this.clone = function() { + var range = this.range.clone(); + var fold = new Fold(range, this.placeholder); + this.subFolds.forEach(function(subFold) { + fold.subFolds.push(subFold.clone()); + }); + return fold; + }; + + this.addSubFold = function(fold) { + if (this.range.isEqual(fold)) + return this; + + if (!this.range.containsRange(fold)) + throw "A fold can't intersect already existing fold" + fold.range + this.range; + + var row = fold.range.start.row, column = fold.range.start.column; + for (var i = 0, cmp = -1; i < this.subFolds.length; i++) { + cmp = this.subFolds[i].range.compare(row, column); + if (cmp != 1) + break; + } + var afterStart = this.subFolds[i]; + + if (cmp == 0) + return afterStart.addSubFold(fold); + + // cmp == -1 + var row = fold.range.end.row, column = fold.range.end.column; + for (var j = i, cmp = -1; j < this.subFolds.length; j++) { + cmp = this.subFolds[j].range.compare(row, column); + if (cmp != 1) + break; + } + var afterEnd = this.subFolds[j]; + + if (cmp == 0) + throw "A fold can't intersect already existing fold" + fold.range + this.range; + + var consumedFolds = this.subFolds.splice(i, j - i, fold); + fold.setFoldLine(this.foldLine); + + return fold; + }; + +}).call(Fold.prototype); + +}); + +ace.define('ace/token_iterator', ['require', 'exports', 'module' ], function(require, exports, module) { + + +/** + * class TokenIterator + * + * This class provides an essay way to treat the document as a stream of tokens, and provides methods to iterate over these tokens. + * + **/ + +/** + * new TokenIterator(session, initialRow, initialColumn) + * - session (EditSession): The session to associate with + * - initialRow (Number): The row to start the tokenizing at + * - initialColumn (Number): The column to start the tokenizing at + * + * Creates a new token iterator object. The inital token index is set to the provided row and column coordinates. + * + **/ +var TokenIterator = function(session, initialRow, initialColumn) { + this.$session = session; + this.$row = initialRow; + this.$rowTokens = session.getTokens(initialRow); + + var token = session.getTokenAt(initialRow, initialColumn); + this.$tokenIndex = token ? token.index : -1; +}; + +(function() { + + /** + * TokenIterator.stepBackward() -> [String] + * + (String): If the current point is not at the top of the file, this function returns `null`. Otherwise, it returns an array of the tokenized strings. + * + * Tokenizes all the items from the current point to the row prior in the document. + **/ + this.stepBackward = function() { + this.$tokenIndex -= 1; + + while (this.$tokenIndex < 0) { + this.$row -= 1; + if (this.$row < 0) { + this.$row = 0; + return null; + } + + this.$rowTokens = this.$session.getTokens(this.$row); + this.$tokenIndex = this.$rowTokens.length - 1; + } + + return this.$rowTokens[this.$tokenIndex]; + }; + this.stepForward = function() { + var rowCount = this.$session.getLength(); + this.$tokenIndex += 1; + + while (this.$tokenIndex >= this.$rowTokens.length) { + this.$row += 1; + if (this.$row >= rowCount) { + this.$row = rowCount - 1; + return null; + } + + this.$rowTokens = this.$session.getTokens(this.$row); + this.$tokenIndex = 0; + } + + return this.$rowTokens[this.$tokenIndex]; + }; + this.getCurrentToken = function () { + return this.$rowTokens[this.$tokenIndex]; + }; + this.getCurrentTokenRow = function () { + return this.$row; + }; + this.getCurrentTokenColumn = function() { + var rowTokens = this.$rowTokens; + var tokenIndex = this.$tokenIndex; + + // If a column was cached by EditSession.getTokenAt, then use it + var column = rowTokens[tokenIndex].start; + if (column !== undefined) + return column; + + column = 0; + while (tokenIndex > 0) { + tokenIndex -= 1; + column += rowTokens[tokenIndex].value.length; + } + + return column; + }; + +}).call(TokenIterator.prototype); + +exports.TokenIterator = TokenIterator; +}); + +ace.define('ace/edit_session/bracket_match', ['require', 'exports', 'module' , 'ace/token_iterator', 'ace/range'], function(require, exports, module) { + + +var TokenIterator = require("../token_iterator").TokenIterator; +var Range = require("../range").Range; + + +function BracketMatch() { + + this.findMatchingBracket = function(position) { + if (position.column == 0) return null; + + var charBeforeCursor = this.getLine(position.row).charAt(position.column-1); + if (charBeforeCursor == "") return null; + + var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/); + if (!match) + return null; + + if (match[1]) + return this.$findClosingBracket(match[1], position); + else + return this.$findOpeningBracket(match[2], position); + }; + + this.getBracketRange = function(pos) { + var line = this.getLine(pos.row); + var before = true, range; + + var chr = line.charAt(pos.column-1); + var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/); + if (!match) { + chr = line.charAt(pos.column); + pos = {row: pos.row, column: pos.column + 1}; + match = chr && chr.match(/([\(\[\{])|([\)\]\}])/); + before = false; + } + if (!match) + return null; + + if (match[1]) { + var bracketPos = this.$findClosingBracket(match[1], pos); + if (!bracketPos) + return null; + range = Range.fromPoints(pos, bracketPos); + if (!before) { + range.end.column++; + range.start.column--; + } + range.cursor = range.end; + } else { + var bracketPos = this.$findOpeningBracket(match[2], pos); + if (!bracketPos) + return null; + range = Range.fromPoints(bracketPos, pos); + if (!before) { + range.start.column++; + range.end.column--; + } + range.cursor = range.start; + } + + return range; + }; + + this.$brackets = { + ")": "(", + "(": ")", + "]": "[", + "[": "]", + "{": "}", + "}": "{" + }; + + this.$findOpeningBracket = function(bracket, position, typeRe) { + var openBracket = this.$brackets[bracket]; + var depth = 1; + + var iterator = new TokenIterator(this, position.row, position.column); + var token = iterator.getCurrentToken(); + if (!token) + token = iterator.stepForward(); + if (!token) + return; + + if (!typeRe){ + typeRe = new RegExp( + "(\\.?" + + token.type.replace(".", "\\.").replace("rparen", ".paren") + + ")+" + ); + } + + // Start searching in token, just before the character at position.column + var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2; + var value = token.value; + + while (true) { + + while (valueIndex >= 0) { + var chr = value.charAt(valueIndex); + if (chr == openBracket) { + depth -= 1; + if (depth == 0) { + return {row: iterator.getCurrentTokenRow(), + column: valueIndex + iterator.getCurrentTokenColumn()}; + } + } + else if (chr == bracket) { + depth += 1; + } + valueIndex -= 1; + } + + // Scan backward through the document, looking for the next token + // whose type matches typeRe + do { + token = iterator.stepBackward(); + } while (token && !typeRe.test(token.type)); + + if (token == null) + break; + + value = token.value; + valueIndex = value.length - 1; + } + + return null; + }; + + this.$findClosingBracket = function(bracket, position, typeRe) { + var closingBracket = this.$brackets[bracket]; + var depth = 1; + + var iterator = new TokenIterator(this, position.row, position.column); + var token = iterator.getCurrentToken(); + if (!token) + token = iterator.stepForward(); + if (!token) + return; + + if (!typeRe){ + typeRe = new RegExp( + "(\\.?" + + token.type.replace(".", "\\.").replace("lparen", ".paren") + + ")+" + ); + } + + // Start searching in token, after the character at position.column + var valueIndex = position.column - iterator.getCurrentTokenColumn(); + + while (true) { + + var value = token.value; + var valueLength = value.length; + while (valueIndex < valueLength) { + var chr = value.charAt(valueIndex); + if (chr == closingBracket) { + depth -= 1; + if (depth == 0) { + return {row: iterator.getCurrentTokenRow(), + column: valueIndex + iterator.getCurrentTokenColumn()}; + } + } + else if (chr == bracket) { + depth += 1; + } + valueIndex += 1; + } + + // Scan forward through the document, looking for the next token + // whose type matches typeRe + do { + token = iterator.stepForward(); + } while (token && !typeRe.test(token.type)); + + if (token == null) + break; + + valueIndex = 0; + } + + return null; + }; +} +exports.BracketMatch = BracketMatch; + +}); + +ace.define('ace/search', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/lib/oop', 'ace/range'], function(require, exports, module) { + + +var lang = require("./lib/lang"); +var oop = require("./lib/oop"); +var Range = require("./range").Range; + +/** + * new Search() + * + * Creates a new `Search` object. The following search options are avaliable: + * + * * `needle`: The string or regular expression you're looking for + * * `backwards`: Whether to search backwards from where cursor currently is. Defaults to `false`. + * * `wrap`: Whether to wrap the search back to the beginning when it hits the end. Defaults to `false`. + * * `caseSensitive`: Whether the search ought to be case-sensitive. Defaults to `false`. + * * `wholeWord`: Whether the search matches only on whole words. Defaults to `false`. + * * `range`: The [[Range]] to search within. Set this to `null` for the whole document + * * `regExp`: Whether the search is a regular expression or not. Defaults to `false`. + * * `start`: The starting [[Range]] or cursor position to begin the search + * * `skipCurrent`: Whether or not to include the current line in the search. Default to `false`. + * +**/ + +var Search = function() { + this.$options = {}; +}; + +(function() { + /** + * Search.set(options) -> Search + * - options (Object): An object containing all the new search properties + * + * Sets the search options via the `options` parameter. + * + **/ + this.set = function(options) { + oop.mixin(this.$options, options); + return this; + }; + this.getOptions = function() { + return lang.copyObject(this.$options); + }; + + this.setOptions = function(options) { + this.$options = options; + }; + this.find = function(session) { + var iterator = this.$matchIterator(session, this.$options); + + if (!iterator) + return false; + + var firstRange = null; + iterator.forEach(function(range, row, offset) { + if (!range.start) { + var column = range.offset + (offset || 0); + firstRange = new Range(row, column, row, column+range.length); + } else + firstRange = range; + return true; + }); + + return firstRange; + }; + this.findAll = function(session) { + var options = this.$options; + if (!options.needle) + return []; + this.$assembleRegExp(options); + + var range = options.range; + var lines = range + ? session.getLines(range.start.row, range.end.row) + : session.doc.getAllLines(); + + var ranges = []; + var re = options.re; + if (options.$isMultiLine) { + var len = re.length; + var maxRow = lines.length - len; + for (var row = re.offset || 0; row <= maxRow; row++) { + for (var j = 0; j < len; j++) + if (lines[row + j].search(re[j]) == -1) + break; + + var startLine = lines[row]; + var line = lines[row + len - 1]; + var startIndex = startLine.match(re[0])[0].length; + var endIndex = line.match(re[len - 1])[0].length; + + ranges.push(new Range( + row, startLine.length - startIndex, + row + len - 1, endIndex + )); + } + } else { + for (var i = 0; i < lines.length; i++) { + var matches = lang.getMatchOffsets(lines[i], re); + for (var j = 0; j < matches.length; j++) { + var match = matches[j]; + ranges.push(new Range(i, match.offset, i, match.offset + match.length)); + } + } + } + + if (range) { + var startColumn = range.start.column; + var endColumn = range.start.column; + var i = 0, j = ranges.length - 1; + while (i < j && ranges[i].start.column < startColumn && ranges[i].start.row == range.start.row) + i++; + + while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row) + j--; + return ranges.slice(i, j + 1); + } + + return ranges; + }; + this.replace = function(input, replacement) { + var options = this.$options; + + var re = this.$assembleRegExp(options); + if (options.$isMultiLine) + return replacement; + + if (!re) + return; + + var match = re.exec(input); + if (!match || match[0].length != input.length) + return null; + + replacement = input.replace(re, replacement); + if (options.preserveCase) { + replacement = replacement.split(""); + for (var i = Math.min(input.length, input.length); i--; ) { + var ch = input[i]; + if (ch && ch.toLowerCase() != ch) + replacement[i] = replacement[i].toUpperCase(); + else + replacement[i] = replacement[i].toLowerCase(); + } + replacement = replacement.join(""); + } + + return replacement; + }; + this.$matchIterator = function(session, options) { + var re = this.$assembleRegExp(options); + if (!re) + return false; + + var self = this, callback, backwards = options.backwards; + + if (options.$isMultiLine) { + var len = re.length; + var matchIterator = function(line, row, offset) { + var startIndex = line.search(re[0]); + if (startIndex == -1) + return; + for (var i = 1; i < len; i++) { + line = session.getLine(row + i); + if (line.search(re[i]) == -1) + return; + } + + var endIndex = line.match(re[len - 1])[0].length; + + var range = new Range(row, startIndex, row + len - 1, endIndex); + if (re.offset == 1) { + range.start.row--; + range.start.column = Number.MAX_VALUE; + } else if (offset) + range.start.column += offset; + + if (callback(range)) + return true; + }; + } else if (backwards) { + var matchIterator = function(line, row, startIndex) { + var matches = lang.getMatchOffsets(line, re); + for (var i = matches.length-1; i >= 0; i--) + if (callback(matches[i], row, startIndex)) + return true; + }; + } else { + var matchIterator = function(line, row, startIndex) { + var matches = lang.getMatchOffsets(line, re); + for (var i = 0; i < matches.length; i++) + if (callback(matches[i], row, startIndex)) + return true; + }; + } + + return { + forEach: function(_callback) { + callback = _callback; + self.$lineIterator(session, options).forEach(matchIterator); + } + }; + }; + + this.$assembleRegExp = function(options) { + if (options.needle instanceof RegExp) + return options.re = options.needle; + + var needle = options.needle; + + if (!options.needle) + return options.re = false; + + if (!options.regExp) + needle = lang.escapeRegExp(needle); + + if (options.wholeWord) + needle = "\\b" + needle + "\\b"; + + var modifier = options.caseSensitive ? "g" : "gi"; + + options.$isMultiLine = /[\n\r]/.test(needle); + if (options.$isMultiLine) + return options.re = this.$assembleMultilineRegExp(needle, modifier); + + try { + var re = new RegExp(needle, modifier); + } catch(e) { + re = false; + } + return options.re = re; + }; + + this.$assembleMultilineRegExp = function(needle, modifier) { + var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n"); + var re = []; + for (var i = 0; i < parts.length; i++) try { + re.push(new RegExp(parts[i], modifier)); + } catch(e) { + return false; + } + if (parts[0] == "") { + re.shift(); + re.offset = 1; + } else { + re.offset = 0; + } + return re; + }; + + this.$lineIterator = function(session, options) { + var backwards = options.backwards == true; + var skipCurrent = options.skipCurrent != false; + + var range = options.range; + var start = options.start; + if (!start) + start = range ? range[backwards ? "end" : "start"] : session.selection.getRange(); + + if (start.start) + start = start[skipCurrent != backwards ? "end" : "start"]; + + var firstRow = range ? range.start.row : 0; + var lastRow = range ? range.end.row : session.getLength() - 1; + + var forEach = backwards ? function(callback) { + var row = start.row; + + var line = session.getLine(row).substring(0, start.column); + if (callback(line, row)) + return; + + for (row--; row >= firstRow; row--) + if (callback(session.getLine(row), row)) + return; + + if (options.wrap == false) + return; + + for (row = lastRow, firstRow = start.row; row >= firstRow; row--) + if (callback(session.getLine(row), row)) + return; + } : function(callback) { + var row = start.row; + + var line = session.getLine(row).substr(start.column); + if (callback(line, row, start.column)) + return; + + for (row = row+1; row <= lastRow; row++) + if (callback(session.getLine(row), row)) + return; + + if (options.wrap == false) + return; + + for (row = firstRow, lastRow = start.row; row <= lastRow; row++) + if (callback(session.getLine(row), row)) + return; + }; + + return {forEach: forEach}; + }; + +}).call(Search.prototype); + +exports.Search = Search; +}); +ace.define('ace/commands/command_manager', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/keyboard/hash_handler', 'ace/lib/event_emitter'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var HashHandler = require("../keyboard/hash_handler").HashHandler; +var EventEmitter = require("../lib/event_emitter").EventEmitter; + +/** + * new CommandManager(platform, commands) + * - platform (String): Identifier for the platform; must be either `'mac'` or `'win'` + * - commands (Array): A list of commands + * + * TODO + * + * + **/ + +var CommandManager = function(platform, commands) { + this.platform = platform; + this.commands = this.byName = {}; + this.commmandKeyBinding = {}; + + this.addCommands(commands); + + this.setDefaultHandler("exec", function(e) { + return e.command.exec(e.editor, e.args || {}); + }); +}; + +oop.inherits(CommandManager, HashHandler); + +(function() { + + oop.implement(this, EventEmitter); + + this.exec = function(command, editor, args) { + if (typeof command === 'string') + command = this.commands[command]; + + if (!command) + return false; + + if (editor && editor.$readOnly && !command.readOnly) + return false; + + var retvalue = this._emit("exec", { + editor: editor, + command: command, + args: args + }); + + return retvalue === false ? false : true; + }; + + this.toggleRecording = function(editor) { + if (this.$inReplay) + return; + + editor && editor._emit("changeStatus"); + if (this.recording) { + this.macro.pop(); + this.removeEventListener("exec", this.$addCommandToMacro); + + if (!this.macro.length) + this.macro = this.oldMacro; + + return this.recording = false; + } + if (!this.$addCommandToMacro) { + this.$addCommandToMacro = function(e) { + this.macro.push([e.command, e.args]); + }.bind(this); + } + + this.oldMacro = this.macro; + this.macro = []; + this.on("exec", this.$addCommandToMacro); + return this.recording = true; + }; + + this.replay = function(editor) { + if (this.$inReplay || !this.macro) + return; + + if (this.recording) + return this.toggleRecording(editor); + + try { + this.$inReplay = true; + this.macro.forEach(function(x) { + if (typeof x == "string") + this.exec(x, editor); + else + this.exec(x[0], editor, x[1]); + }, this); + } finally { + this.$inReplay = false; + } + }; + + this.trimMacro = function(m) { + return m.map(function(x){ + if (typeof x[0] != "string") + x[0] = x[0].name; + if (!x[1]) + x = x[0]; + return x; + }); + }; + +}).call(CommandManager.prototype); + +exports.CommandManager = CommandManager; + +}); + +ace.define('ace/keyboard/hash_handler', ['require', 'exports', 'module' , 'ace/lib/keys'], function(require, exports, module) { + + +var keyUtil = require("../lib/keys"); + +function HashHandler(config, platform) { + this.platform = platform; + this.commands = {}; + this.commmandKeyBinding = {}; + + this.addCommands(config); +}; + +(function() { + + this.addCommand = function(command) { + if (this.commands[command.name]) + this.removeCommand(command); + + this.commands[command.name] = command; + + if (command.bindKey) + this._buildKeyHash(command); + }; + + this.removeCommand = function(command) { + var name = (typeof command === 'string' ? command : command.name); + command = this.commands[name]; + delete this.commands[name]; + + // exhaustive search is brute force but since removeCommand is + // not a performance critical operation this should be OK + var ckb = this.commmandKeyBinding; + for (var hashId in ckb) { + for (var key in ckb[hashId]) { + if (ckb[hashId][key] == command) + delete ckb[hashId][key]; + } + } + }; + + this.bindKey = function(key, command) { + if(!key) + return; + if (typeof command == "function") { + this.addCommand({exec: command, bindKey: key, name: key}); + return; + } + + var ckb = this.commmandKeyBinding; + key.split("|").forEach(function(keyPart) { + var binding = this.parseKeys(keyPart, command); + var hashId = binding.hashId; + (ckb[hashId] || (ckb[hashId] = {}))[binding.key] = command; + }, this); + }; + + this.addCommands = function(commands) { + commands && Object.keys(commands).forEach(function(name) { + var command = commands[name]; + if (typeof command === "string") + return this.bindKey(command, name); + + if (typeof command === "function") + command = { exec: command }; + + if (!command.name) + command.name = name; + + this.addCommand(command); + }, this); + }; + + this.removeCommands = function(commands) { + Object.keys(commands).forEach(function(name) { + this.removeCommand(commands[name]); + }, this); + }; + + this.bindKeys = function(keyList) { + Object.keys(keyList).forEach(function(key) { + this.bindKey(key, keyList[key]); + }, this); + }; + + this._buildKeyHash = function(command) { + var binding = command.bindKey; + if (!binding) + return; + + var key = typeof binding == "string" ? binding: binding[this.platform]; + this.bindKey(key, command); + }; + + // accepts keys in the form ctrl+Enter or ctrl-Enter + // keys without modifiers or shift only + this.parseKeys = function(keys) { + var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x}); + var key = parts.pop(); + + var keyCode = keyUtil[key]; + if (keyUtil.FUNCTION_KEYS[keyCode]) + key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase(); + else if (!parts.length) + return {key: key, hashId: -1}; + else if (parts.length == 1 && parts[0] == "shift") + return {key: key.toUpperCase(), hashId: -1}; + + var hashId = 0; + for (var i = parts.length; i--;) { + var modifier = keyUtil.KEY_MODS[parts[i]]; + if (modifier == null) + throw "invalid modifier " + parts[i] + " in " + keys; + hashId |= modifier; + } + return {key: key, hashId: hashId}; + }; + + this.findKeyCommand = function findKeyCommand(hashId, keyString) { + var ckbr = this.commmandKeyBinding; + return ckbr[hashId] && ckbr[hashId][keyString]; + }; + + this.handleKeyboard = function(data, hashId, keyString, keyCode) { + return { + command: this.findKeyCommand(hashId, keyString) + }; + }; + +}).call(HashHandler.prototype) + +exports.HashHandler = HashHandler; +}); + +ace.define('ace/commands/default_commands', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) { + + +var lang = require("../lib/lang"); + +function bindKey(win, mac) { + return { + win: win, + mac: mac + }; +} + +exports.commands = [{ + name: "selectall", + bindKey: bindKey("Ctrl-A", "Command-A"), + exec: function(editor) { editor.selectAll(); }, + readOnly: true +}, { + name: "centerselection", + bindKey: bindKey(null, "Ctrl-L"), + exec: function(editor) { editor.centerSelection(); }, + readOnly: true +}, { + name: "gotoline", + bindKey: bindKey("Ctrl-L", "Command-L"), + exec: function(editor) { + var line = parseInt(prompt("Enter line number:"), 10); + if (!isNaN(line)) { + editor.gotoLine(line); + } + }, + readOnly: true +}, { + name: "fold", + bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"), + exec: function(editor) { editor.session.toggleFold(false); }, + readOnly: true +}, { + name: "unfold", + bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"), + exec: function(editor) { editor.session.toggleFold(true); }, + readOnly: true +}, { + name: "foldall", + bindKey: bindKey("Alt-0", "Command-Option-0"), + exec: function(editor) { editor.session.foldAll(); }, + readOnly: true +}, { + name: "unfoldall", + bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"), + exec: function(editor) { editor.session.unfold(); }, + readOnly: true +}, { + name: "findnext", + bindKey: bindKey("Ctrl-K", "Command-G"), + exec: function(editor) { editor.findNext(); }, + readOnly: true +}, { + name: "findprevious", + bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"), + exec: function(editor) { editor.findPrevious(); }, + readOnly: true +}, { + name: "find", + bindKey: bindKey("Ctrl-F", "Command-F"), + exec: function(editor) { + var needle = prompt("Find:", editor.getCopyText()); + editor.find(needle); + }, + readOnly: true +}, { + name: "overwrite", + bindKey: "Insert", + exec: function(editor) { editor.toggleOverwrite(); }, + readOnly: true +}, { + name: "selecttostart", + bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"), + exec: function(editor) { editor.getSelection().selectFileStart(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "gotostart", + bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"), + exec: function(editor) { editor.navigateFileStart(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "selectup", + bindKey: bindKey("Shift-Up", "Shift-Up"), + exec: function(editor) { editor.getSelection().selectUp(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "golineup", + bindKey: bindKey("Up", "Up|Ctrl-P"), + exec: function(editor, args) { editor.navigateUp(args.times); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "selecttoend", + bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"), + exec: function(editor) { editor.getSelection().selectFileEnd(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "gotoend", + bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"), + exec: function(editor) { editor.navigateFileEnd(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "selectdown", + bindKey: bindKey("Shift-Down", "Shift-Down"), + exec: function(editor) { editor.getSelection().selectDown(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "golinedown", + bindKey: bindKey("Down", "Down|Ctrl-N"), + exec: function(editor, args) { editor.navigateDown(args.times); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "selectwordleft", + bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"), + exec: function(editor) { editor.getSelection().selectWordLeft(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "gotowordleft", + bindKey: bindKey("Ctrl-Left", "Option-Left"), + exec: function(editor) { editor.navigateWordLeft(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "selecttolinestart", + bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"), + exec: function(editor) { editor.getSelection().selectLineStart(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "gotolinestart", + bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"), + exec: function(editor) { editor.navigateLineStart(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "selectleft", + bindKey: bindKey("Shift-Left", "Shift-Left"), + exec: function(editor) { editor.getSelection().selectLeft(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "gotoleft", + bindKey: bindKey("Left", "Left|Ctrl-B"), + exec: function(editor, args) { editor.navigateLeft(args.times); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "selectwordright", + bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"), + exec: function(editor) { editor.getSelection().selectWordRight(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "gotowordright", + bindKey: bindKey("Ctrl-Right", "Option-Right"), + exec: function(editor) { editor.navigateWordRight(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "selecttolineend", + bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"), + exec: function(editor) { editor.getSelection().selectLineEnd(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "gotolineend", + bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"), + exec: function(editor) { editor.navigateLineEnd(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "selectright", + bindKey: bindKey("Shift-Right", "Shift-Right"), + exec: function(editor) { editor.getSelection().selectRight(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "gotoright", + bindKey: bindKey("Right", "Right|Ctrl-F"), + exec: function(editor, args) { editor.navigateRight(args.times); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "selectpagedown", + bindKey: "Shift-PageDown", + exec: function(editor) { editor.selectPageDown(); }, + readOnly: true +}, { + name: "pagedown", + bindKey: bindKey(null, "Option-PageDown"), + exec: function(editor) { editor.scrollPageDown(); }, + readOnly: true +}, { + name: "gotopagedown", + bindKey: bindKey("PageDown", "PageDown|Ctrl-V"), + exec: function(editor) { editor.gotoPageDown(); }, + readOnly: true +}, { + name: "selectpageup", + bindKey: "Shift-PageUp", + exec: function(editor) { editor.selectPageUp(); }, + readOnly: true +}, { + name: "pageup", + bindKey: bindKey(null, "Option-PageUp"), + exec: function(editor) { editor.scrollPageUp(); }, + readOnly: true +}, { + name: "gotopageup", + bindKey: "PageUp", + exec: function(editor) { editor.gotoPageUp(); }, + readOnly: true +}, { + name: "scrollup", + bindKey: bindKey("Ctrl-Up", null), + exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); }, + readOnly: true +}, { + name: "scrolldown", + bindKey: bindKey("Ctrl-Down", null), + exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); }, + readOnly: true +}, { + name: "selectlinestart", + bindKey: "Shift-Home", + exec: function(editor) { editor.getSelection().selectLineStart(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "selectlineend", + bindKey: "Shift-End", + exec: function(editor) { editor.getSelection().selectLineEnd(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "togglerecording", + bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"), + exec: function(editor) { editor.commands.toggleRecording(editor); }, + readOnly: true +}, { + name: "replaymacro", + bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"), + exec: function(editor) { editor.commands.replay(editor); }, + readOnly: true +}, { + name: "jumptomatching", + bindKey: bindKey("Ctrl-P", "Ctrl-Shift-P"), + exec: function(editor) { editor.jumpToMatching(); }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "selecttomatching", + bindKey: bindKey("Ctrl-Shift-P", null), + exec: function(editor) { editor.jumpToMatching(true); }, + readOnly: true +}, + +// commands disabled in readOnly mode +{ + name: "cut", + exec: function(editor) { + var range = editor.getSelectionRange(); + editor._emit("cut", range); + + if (!editor.selection.isEmpty()) { + editor.session.remove(range); + editor.clearSelection(); + } + }, + multiSelectAction: "forEach" +}, { + name: "removeline", + bindKey: bindKey("Ctrl-D", "Command-D"), + exec: function(editor) { editor.removeLines(); }, + multiSelectAction: "forEach" +}, { + name: "duplicateSelection", + bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"), + exec: function(editor) { editor.duplicateSelection(); }, + multiSelectAction: "forEach" +}, { + name: "togglecomment", + bindKey: bindKey("Ctrl-/", "Command-/"), + exec: function(editor) { editor.toggleCommentLines(); }, + multiSelectAction: "forEach" +}, { + name: "replace", + bindKey: bindKey("Ctrl-R", "Command-Option-F"), + exec: function(editor) { + var needle = prompt("Find:", editor.getCopyText()); + if (!needle) + return; + var replacement = prompt("Replacement:"); + if (!replacement) + return; + editor.replace(replacement, {needle: needle}); + } +}, { + name: "replaceall", + bindKey: bindKey("Ctrl-Shift-R", "Command-Shift-Option-F"), + exec: function(editor) { + var needle = prompt("Find:"); + if (!needle) + return; + var replacement = prompt("Replacement:"); + if (!replacement) + return; + editor.replaceAll(replacement, {needle: needle}); + } +}, { + name: "undo", + bindKey: bindKey("Ctrl-Z", "Command-Z"), + exec: function(editor) { editor.undo(); } +}, { + name: "redo", + bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"), + exec: function(editor) { editor.redo(); } +}, { + name: "copylinesup", + bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"), + exec: function(editor) { editor.copyLinesUp(); } +}, { + name: "movelinesup", + bindKey: bindKey("Alt-Up", "Option-Up"), + exec: function(editor) { editor.moveLinesUp(); } +}, { + name: "copylinesdown", + bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"), + exec: function(editor) { editor.copyLinesDown(); } +}, { + name: "movelinesdown", + bindKey: bindKey("Alt-Down", "Option-Down"), + exec: function(editor) { editor.moveLinesDown(); } +}, { + name: "del", + bindKey: bindKey("Delete", "Delete|Ctrl-D"), + exec: function(editor) { editor.remove("right"); }, + multiSelectAction: "forEach" +}, { + name: "backspace", + bindKey: bindKey( + "Command-Backspace|Option-Backspace|Shift-Backspace|Backspace", + "Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H" + ), + exec: function(editor) { editor.remove("left"); }, + multiSelectAction: "forEach" +}, { + name: "removetolinestart", + bindKey: bindKey("Alt-Backspace", "Command-Backspace"), + exec: function(editor) { editor.removeToLineStart(); }, + multiSelectAction: "forEach" +}, { + name: "removetolineend", + bindKey: bindKey("Alt-Delete", "Ctrl-K"), + exec: function(editor) { editor.removeToLineEnd(); }, + multiSelectAction: "forEach" +}, { + name: "removewordleft", + bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"), + exec: function(editor) { editor.removeWordLeft(); }, + multiSelectAction: "forEach" +}, { + name: "removewordright", + bindKey: bindKey("Ctrl-Delete", "Alt-Delete"), + exec: function(editor) { editor.removeWordRight(); }, + multiSelectAction: "forEach" +}, { + name: "outdent", + bindKey: bindKey("Shift-Tab", "Shift-Tab"), + exec: function(editor) { editor.blockOutdent(); }, + multiSelectAction: "forEach" +}, { + name: "indent", + bindKey: bindKey("Tab", "Tab"), + exec: function(editor) { editor.indent(); }, + multiSelectAction: "forEach" +}, { + name: "insertstring", + exec: function(editor, str) { editor.insert(str); }, + multiSelectAction: "forEach" +}, { + name: "inserttext", + exec: function(editor, args) { + editor.insert(lang.stringRepeat(args.text || "", args.times || 1)); + }, + multiSelectAction: "forEach" +}, { + name: "splitline", + bindKey: bindKey(null, "Ctrl-O"), + exec: function(editor) { editor.splitLine(); }, + multiSelectAction: "forEach" +}, { + name: "transposeletters", + bindKey: bindKey("Ctrl-T", "Ctrl-T"), + exec: function(editor) { editor.transposeLetters(); }, + multiSelectAction: function(editor) {editor.transposeSelections(1); } +}, { + name: "touppercase", + bindKey: bindKey("Ctrl-U", "Ctrl-U"), + exec: function(editor) { editor.toUpperCase(); }, + multiSelectAction: "forEach" +}, { + name: "tolowercase", + bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"), + exec: function(editor) { editor.toLowerCase(); }, + multiSelectAction: "forEach" +}]; + +}); + +ace.define('ace/undomanager', ['require', 'exports', 'module' ], function(require, exports, module) { + + +/** + * class UndoManager + * + * This object maintains the undo stack for an [[EditSession `EditSession`]]. + * + **/ + +/** + * new UndoManager() + * + * Resets the current undo state and creates a new `UndoManager`. + **/ +var UndoManager = function() { + this.reset(); +}; + +(function() { + + /** + * UndoManager.execute(options) -> Void + * - options (Object): Contains additional properties + * + * Provides a means for implementing your own undo manager. `options` has one property, `args`, an [[Array `Array`]], with two elements: + * + * * `args[0]` is an array of deltas + * * `args[1]` is the document to associate with + * + **/ + this.execute = function(options) { + var deltas = options.args[0]; + this.$doc = options.args[1]; + this.$undoStack.push(deltas); + this.$redoStack = []; + }; + this.undo = function(dontSelect) { + var deltas = this.$undoStack.pop(); + var undoSelectionRange = null; + if (deltas) { + undoSelectionRange = + this.$doc.undoChanges(deltas, dontSelect); + this.$redoStack.push(deltas); + } + return undoSelectionRange; + }; + this.redo = function(dontSelect) { + var deltas = this.$redoStack.pop(); + var redoSelectionRange = null; + if (deltas) { + redoSelectionRange = + this.$doc.redoChanges(deltas, dontSelect); + this.$undoStack.push(deltas); + } + return redoSelectionRange; + }; + this.reset = function() { + this.$undoStack = []; + this.$redoStack = []; + }; + this.hasUndo = function() { + return this.$undoStack.length > 0; + }; + this.hasRedo = function() { + return this.$redoStack.length > 0; + }; + +}).call(UndoManager.prototype); + +exports.UndoManager = UndoManager; +}); + +ace.define('ace/virtual_renderer', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/event', 'ace/lib/useragent', 'ace/config', 'ace/lib/net', 'ace/layer/gutter', 'ace/layer/marker', 'ace/layer/text', 'ace/layer/cursor', 'ace/scrollbar', 'ace/renderloop', 'ace/lib/event_emitter', 'text!ace/css/editor.css'], function(require, exports, module) { + + +var oop = require("./lib/oop"); +var dom = require("./lib/dom"); +var event = require("./lib/event"); +var useragent = require("./lib/useragent"); +var config = require("./config"); +var net = require("./lib/net"); +var GutterLayer = require("./layer/gutter").Gutter; +var MarkerLayer = require("./layer/marker").Marker; +var TextLayer = require("./layer/text").Text; +var CursorLayer = require("./layer/cursor").Cursor; +var ScrollBar = require("./scrollbar").ScrollBar; +var RenderLoop = require("./renderloop").RenderLoop; +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var editorCss = require("text!./css/editor.css"); + +dom.importCssString(editorCss, "ace_editor"); + +/** + * new VirtualRenderer(container, theme) + * - container (DOMElement): The root element of the editor + * - theme (String): The starting theme + * + * Constructs a new `VirtualRenderer` within the `container` specified, applying the given `theme`. + * + **/ + +var VirtualRenderer = function(container, theme) { + var _self = this; + + this.container = container; + + // TODO: this breaks rendering in Cloud9 with multiple ace instances +// // Imports CSS once per DOM document ('ace_editor' serves as an identifier). +// dom.importCssString(editorCss, "ace_editor", container.ownerDocument); + + // in IE <= 9 the native cursor always shines through + this.$keepTextAreaAtCursor = !useragent.isIE; + + dom.addCssClass(container, "ace_editor"); + + this.setTheme(theme); + + this.$gutter = dom.createElement("div"); + this.$gutter.className = "ace_gutter"; + this.container.appendChild(this.$gutter); + + this.scroller = dom.createElement("div"); + this.scroller.className = "ace_scroller"; + this.container.appendChild(this.scroller); + + this.content = dom.createElement("div"); + this.content.className = "ace_content"; + this.scroller.appendChild(this.content); + + this.setHighlightGutterLine(true); + this.$gutterLayer = new GutterLayer(this.$gutter); + this.$gutterLayer.on("changeGutterWidth", this.onResize.bind(this, true)); + + this.$markerBack = new MarkerLayer(this.content); + + var textLayer = this.$textLayer = new TextLayer(this.content); + this.canvas = textLayer.element; + + this.$markerFront = new MarkerLayer(this.content); + + this.characterWidth = textLayer.getCharacterWidth(); + this.lineHeight = textLayer.getLineHeight(); + + this.$cursorLayer = new CursorLayer(this.content); + this.$cursorPadding = 8; + + // Indicates whether the horizontal scrollbar is visible + this.$horizScroll = false; + this.$horizScrollAlwaysVisible = false; + + this.$animatedScroll = false; + + this.scrollBar = new ScrollBar(container); + this.scrollBar.addEventListener("scroll", function(e) { + if (!_self.$inScrollAnimation) + _self.session.setScrollTop(e.data); + }); + + this.scrollTop = 0; + this.scrollLeft = 0; + + event.addListener(this.scroller, "scroll", function() { + var scrollLeft = _self.scroller.scrollLeft; + _self.scrollLeft = scrollLeft; + _self.session.setScrollLeft(scrollLeft); + }); + + this.cursorPos = { + row : 0, + column : 0 + }; + + this.$textLayer.addEventListener("changeCharacterSize", function() { + _self.characterWidth = textLayer.getCharacterWidth(); + _self.lineHeight = textLayer.getLineHeight(); + _self.$updatePrintMargin(); + _self.onResize(true); + + _self.$loop.schedule(_self.CHANGE_FULL); + }); + + this.$size = { + width: 0, + height: 0, + scrollerHeight: 0, + scrollerWidth: 0 + }; + + this.layerConfig = { + width : 1, + padding : 0, + firstRow : 0, + firstRowScreen: 0, + lastRow : 0, + lineHeight : 1, + characterWidth : 1, + minHeight : 1, + maxHeight : 1, + offset : 0, + height : 1 + }; + + this.$loop = new RenderLoop( + this.$renderChanges.bind(this), + this.container.ownerDocument.defaultView + ); + this.$loop.schedule(this.CHANGE_FULL); + + this.setPadding(4); + this.$updatePrintMargin(); +}; + +(function() { + this.showGutter = true; + + this.CHANGE_CURSOR = 1; + this.CHANGE_MARKER = 2; + this.CHANGE_GUTTER = 4; + this.CHANGE_SCROLL = 8; + this.CHANGE_LINES = 16; + this.CHANGE_TEXT = 32; + this.CHANGE_SIZE = 64; + this.CHANGE_MARKER_BACK = 128; + this.CHANGE_MARKER_FRONT = 256; + this.CHANGE_FULL = 512; + this.CHANGE_H_SCROLL = 1024; + + oop.implement(this, EventEmitter); + this.setSession = function(session) { + this.session = session; + + this.scroller.className = "ace_scroller"; + + this.$cursorLayer.setSession(session); + this.$markerBack.setSession(session); + this.$markerFront.setSession(session); + this.$gutterLayer.setSession(session); + this.$textLayer.setSession(session); + this.$loop.schedule(this.CHANGE_FULL); + + }; + this.updateLines = function(firstRow, lastRow) { + if (lastRow === undefined) + lastRow = Infinity; + + if (!this.$changedLines) { + this.$changedLines = { + firstRow: firstRow, + lastRow: lastRow + }; + } + else { + if (this.$changedLines.firstRow > firstRow) + this.$changedLines.firstRow = firstRow; + + if (this.$changedLines.lastRow < lastRow) + this.$changedLines.lastRow = lastRow; + } + + this.$loop.schedule(this.CHANGE_LINES); + }; + + this.onChangeTabSize = function() { + this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER); + this.$textLayer.onChangeTabSize(); + }; + this.updateText = function() { + this.$loop.schedule(this.CHANGE_TEXT); + }; + this.updateFull = function(force) { + if (force){ + this.$renderChanges(this.CHANGE_FULL, true); + } + else { + this.$loop.schedule(this.CHANGE_FULL); + } + }; + this.updateFontSize = function() { + this.$textLayer.checkForSizeChanges(); + }; + this.onResize = function(force, gutterWidth, width, height) { + var changes = this.CHANGE_SIZE; + var size = this.$size; + + if (this.resizing > 2) + return; + else if (this.resizing > 1) + this.resizing++; + else + this.resizing = force ? 1 : 0; + + if (!height) + height = dom.getInnerHeight(this.container); + if (force || size.height != height) { + size.height = height; + + this.scroller.style.height = height + "px"; + size.scrollerHeight = this.scroller.clientHeight; + this.scrollBar.setHeight(size.scrollerHeight); + + if (this.session) { + this.session.setScrollTop(this.getScrollTop()); + changes = changes | this.CHANGE_FULL; + } + } + + if (!width) + width = dom.getInnerWidth(this.container); + if (force || this.resizing > 1 || size.width != width) { + size.width = width; + + var gutterWidth = this.showGutter ? this.$gutter.offsetWidth : 0; + this.scroller.style.left = gutterWidth + "px"; + size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBar.getWidth()); + this.scroller.style.right = this.scrollBar.getWidth() + "px"; + + if (this.session.getUseWrapMode() && this.adjustWrapLimit() || force) + changes = changes | this.CHANGE_FULL; + } + + if (force) + this.$renderChanges(changes, true); + else + this.$loop.schedule(changes); + + if (force) + delete this.resizing; + }; + this.adjustWrapLimit = function() { + var availableWidth = this.$size.scrollerWidth - this.$padding * 2; + var limit = Math.floor(availableWidth / this.characterWidth); + return this.session.adjustWrapLimit(limit); + }; + this.setAnimatedScroll = function(shouldAnimate){ + this.$animatedScroll = shouldAnimate; + }; + this.getAnimatedScroll = function() { + return this.$animatedScroll; + }; + this.setShowInvisibles = function(showInvisibles) { + if (this.$textLayer.setShowInvisibles(showInvisibles)) + this.$loop.schedule(this.CHANGE_TEXT); + }; + this.getShowInvisibles = function() { + return this.$textLayer.showInvisibles; + }; + + this.getDisplayIndentGuides = function() { + return this.$textLayer.displayIndentGuides; + }; + + this.setDisplayIndentGuides = function(display) { + if (this.$textLayer.setDisplayIndentGuides(display)) + this.$loop.schedule(this.CHANGE_TEXT); + }; + + this.$showPrintMargin = true; + this.setShowPrintMargin = function(showPrintMargin) { + this.$showPrintMargin = showPrintMargin; + this.$updatePrintMargin(); + }; + this.getShowPrintMargin = function() { + return this.$showPrintMargin; + }; + + this.$printMarginColumn = 80; + this.setPrintMarginColumn = function(showPrintMargin) { + this.$printMarginColumn = showPrintMargin; + this.$updatePrintMargin(); + }; + this.getPrintMarginColumn = function() { + return this.$printMarginColumn; + }; + this.getShowGutter = function(){ + return this.showGutter; + }; + this.setShowGutter = function(show){ + if(this.showGutter === show) + return; + this.$gutter.style.display = show ? "block" : "none"; + this.showGutter = show; + this.onResize(true); + }; + + this.getFadeFoldWidgets = function(){ + return dom.hasCssClass(this.$gutter, "ace_fade-fold-widgets"); + }; + + this.setFadeFoldWidgets = function(show) { + if (show) + dom.addCssClass(this.$gutter, "ace_fade-fold-widgets"); + else + dom.removeCssClass(this.$gutter, "ace_fade-fold-widgets"); + }; + + this.$highlightGutterLine = false; + this.setHighlightGutterLine = function(shouldHighlight) { + if (this.$highlightGutterLine == shouldHighlight) + return; + this.$highlightGutterLine = shouldHighlight; + + if (!this.$gutterLineHighlight) { + this.$gutterLineHighlight = dom.createElement("div"); + this.$gutterLineHighlight.className = "ace_gutter_active_line"; + this.$gutter.appendChild(this.$gutterLineHighlight); + return; + } + + this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none"; + // if cursorlayer have never been updated there's nothing on screen to update + if (this.$cursorLayer.$pixelPos) + this.$updateGutterLineHighlight(); + }; + + this.getHighlightGutterLine = function() { + return this.$highlightGutterLine; + }; + + this.$updateGutterLineHighlight = function() { + this.$gutterLineHighlight.style.top = this.$cursorLayer.$pixelPos.top - this.layerConfig.offset + "px"; + this.$gutterLineHighlight.style.height = this.layerConfig.lineHeight + "px"; + }; + + this.$updatePrintMargin = function() { + var containerEl; + + if (!this.$showPrintMargin && !this.$printMarginEl) + return; + + if (!this.$printMarginEl) { + containerEl = dom.createElement("div"); + containerEl.className = "ace_print_margin_layer"; + this.$printMarginEl = dom.createElement("div"); + this.$printMarginEl.className = "ace_print_margin"; + containerEl.appendChild(this.$printMarginEl); + this.content.insertBefore(containerEl, this.$textLayer.element); + } + + var style = this.$printMarginEl.style; + style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px"; + style.visibility = this.$showPrintMargin ? "visible" : "hidden"; + }; + this.getContainerElement = function() { + return this.container; + }; + this.getMouseEventTarget = function() { + return this.content; + }; + this.getTextAreaContainer = function() { + return this.container; + }; + + // move text input over the cursor + // this is required for iOS and IME + this.$moveTextAreaToCursor = function() { + if (!this.$keepTextAreaAtCursor) + return; + + var posTop = this.$cursorLayer.$pixelPos.top; + var posLeft = this.$cursorLayer.$pixelPos.left; + posTop -= this.layerConfig.offset; + + if (posTop < 0 || posTop > this.layerConfig.height - this.lineHeight) + return; + + var w = this.characterWidth; + if (this.$composition) + w += this.textarea.scrollWidth; + posLeft -= this.scrollLeft; + if (posLeft > this.$size.scrollerWidth - w) + posLeft = this.$size.scrollerWidth - w; + + if (this.showGutter) + posLeft += this.$gutterLayer.gutterWidth; + + this.textarea.style.height = this.lineHeight + "px"; + this.textarea.style.width = w + "px"; + this.textarea.style.left = posLeft + "px"; + this.textarea.style.top = posTop - 1 + "px"; + }; + this.getFirstVisibleRow = function() { + return this.layerConfig.firstRow; + }; + this.getFirstFullyVisibleRow = function() { + return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1); + }; + this.getLastFullyVisibleRow = function() { + var flint = Math.floor((this.layerConfig.height + this.layerConfig.offset) / this.layerConfig.lineHeight); + return this.layerConfig.firstRow - 1 + flint; + }; + this.getLastVisibleRow = function() { + return this.layerConfig.lastRow; + }; + + this.$padding = null; + this.setPadding = function(padding) { + this.$padding = padding; + this.$textLayer.setPadding(padding); + this.$cursorLayer.setPadding(padding); + this.$markerFront.setPadding(padding); + this.$markerBack.setPadding(padding); + this.$loop.schedule(this.CHANGE_FULL); + this.$updatePrintMargin(); + }; + this.getHScrollBarAlwaysVisible = function() { + return this.$horizScrollAlwaysVisible; + }; + this.setHScrollBarAlwaysVisible = function(alwaysVisible) { + if (this.$horizScrollAlwaysVisible != alwaysVisible) { + this.$horizScrollAlwaysVisible = alwaysVisible; + if (!this.$horizScrollAlwaysVisible || !this.$horizScroll) + this.$loop.schedule(this.CHANGE_SCROLL); + } + }; + + this.$updateScrollBar = function() { + this.scrollBar.setInnerHeight(this.layerConfig.maxHeight); + this.scrollBar.setScrollTop(this.scrollTop); + }; + + this.$renderChanges = function(changes, force) { + if (!force && (!changes || !this.session || !this.container.offsetWidth)) + return; + + // text, scrolling and resize changes can cause the view port size to change + if (changes & this.CHANGE_FULL || + changes & this.CHANGE_SIZE || + changes & this.CHANGE_TEXT || + changes & this.CHANGE_LINES || + changes & this.CHANGE_SCROLL + ) + this.$computeLayerConfig(); + + // horizontal scrolling + if (changes & this.CHANGE_H_SCROLL) { + this.scroller.scrollLeft = this.scrollLeft; + + // read the value after writing it since the value might get clipped + var scrollLeft = this.scroller.scrollLeft; + this.scrollLeft = scrollLeft; + this.session.setScrollLeft(scrollLeft); + + this.scroller.className = this.scrollLeft == 0 ? "ace_scroller" : "ace_scroller horscroll"; + } + + // full + if (changes & this.CHANGE_FULL) { + this.$textLayer.checkForSizeChanges(); + // update scrollbar first to not lose scroll position when gutter calls resize + this.$updateScrollBar(); + this.$textLayer.update(this.layerConfig); + if (this.showGutter) + this.$gutterLayer.update(this.layerConfig); + this.$markerBack.update(this.layerConfig); + this.$markerFront.update(this.layerConfig); + this.$cursorLayer.update(this.layerConfig); + this.$moveTextAreaToCursor(); + this.$highlightGutterLine && this.$updateGutterLineHighlight(); + return; + } + + // scrolling + if (changes & this.CHANGE_SCROLL) { + this.$updateScrollBar(); + if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES) + this.$textLayer.update(this.layerConfig); + else + this.$textLayer.scrollLines(this.layerConfig); + + if (this.showGutter) + this.$gutterLayer.update(this.layerConfig); + this.$markerBack.update(this.layerConfig); + this.$markerFront.update(this.layerConfig); + this.$cursorLayer.update(this.layerConfig); + this.$moveTextAreaToCursor(); + this.$highlightGutterLine && this.$updateGutterLineHighlight(); + return; + } + + if (changes & this.CHANGE_TEXT) { + this.$textLayer.update(this.layerConfig); + if (this.showGutter) + this.$gutterLayer.update(this.layerConfig); + } + else if (changes & this.CHANGE_LINES) { + if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.showGutter) + this.$gutterLayer.update(this.layerConfig); + } + else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) { + if (this.showGutter) + this.$gutterLayer.update(this.layerConfig); + } + + if (changes & this.CHANGE_CURSOR) { + this.$cursorLayer.update(this.layerConfig); + this.$moveTextAreaToCursor(); + this.$highlightGutterLine && this.$updateGutterLineHighlight(); + } + + if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) { + this.$markerFront.update(this.layerConfig); + } + + if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) { + this.$markerBack.update(this.layerConfig); + } + + if (changes & this.CHANGE_SIZE) + this.$updateScrollBar(); + }; + + this.$computeLayerConfig = function() { + var session = this.session; + + var offset = this.scrollTop % this.lineHeight; + var minHeight = this.$size.scrollerHeight + this.lineHeight; + + var longestLine = this.$getLongestLine(); + + var horizScroll = this.$horizScrollAlwaysVisible || this.$size.scrollerWidth - longestLine < 0; + var horizScrollChanged = this.$horizScroll !== horizScroll; + this.$horizScroll = horizScroll; + if (horizScrollChanged) { + this.scroller.style.overflowX = horizScroll ? "scroll" : "hidden"; + // when we hide scrollbar scroll event isn't emited + // leaving session with wrong scrollLeft value + if (!horizScroll) + this.session.setScrollLeft(0); + } + var maxHeight = this.session.getScreenLength() * this.lineHeight; + this.session.setScrollTop(Math.max(0, Math.min(this.scrollTop, maxHeight - this.$size.scrollerHeight))); + + var lineCount = Math.ceil(minHeight / this.lineHeight) - 1; + var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight)); + var lastRow = firstRow + lineCount; + + // Map lines on the screen to lines in the document. + var firstRowScreen, firstRowHeight; + var lineHeight = this.lineHeight; + firstRow = session.screenToDocumentRow(firstRow, 0); + + // Check if firstRow is inside of a foldLine. If true, then use the first + // row of the foldLine. + var foldLine = session.getFoldLine(firstRow); + if (foldLine) { + firstRow = foldLine.start.row; + } + + firstRowScreen = session.documentToScreenRow(firstRow, 0); + firstRowHeight = session.getRowLength(firstRow) * lineHeight; + + lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1); + minHeight = this.$size.scrollerHeight + session.getRowLength(lastRow) * lineHeight + + firstRowHeight; + + offset = this.scrollTop - firstRowScreen * lineHeight; + + this.layerConfig = { + width : longestLine, + padding : this.$padding, + firstRow : firstRow, + firstRowScreen: firstRowScreen, + lastRow : lastRow, + lineHeight : lineHeight, + characterWidth : this.characterWidth, + minHeight : minHeight, + maxHeight : maxHeight, + offset : offset, + height : this.$size.scrollerHeight + }; + + // For debugging. + // console.log(JSON.stringify(this.layerConfig)); + + this.$gutterLayer.element.style.marginTop = (-offset) + "px"; + this.content.style.marginTop = (-offset) + "px"; + this.content.style.width = longestLine + 2 * this.$padding + "px"; + this.content.style.height = minHeight + "px"; + + // Horizontal scrollbar visibility may have changed, which changes + // the client height of the scroller + if (horizScrollChanged) + this.onResize(true); + }; + + this.$updateLines = function() { + var firstRow = this.$changedLines.firstRow; + var lastRow = this.$changedLines.lastRow; + this.$changedLines = null; + + var layerConfig = this.layerConfig; + + if (firstRow > layerConfig.lastRow + 1) { return; } + if (lastRow < layerConfig.firstRow) { return; } + + // if the last row is unknown -> redraw everything + if (lastRow === Infinity) { + if (this.showGutter) + this.$gutterLayer.update(layerConfig); + this.$textLayer.update(layerConfig); + return; + } + + // else update only the changed rows + this.$textLayer.updateLines(layerConfig, firstRow, lastRow); + return true; + }; + + this.$getLongestLine = function() { + var charCount = this.session.getScreenWidth(); + if (this.$textLayer.showInvisibles) + charCount += 1; + + return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth)); + }; + this.updateFrontMarkers = function() { + this.$markerFront.setMarkers(this.session.getMarkers(true)); + this.$loop.schedule(this.CHANGE_MARKER_FRONT); + }; + this.updateBackMarkers = function() { + this.$markerBack.setMarkers(this.session.getMarkers()); + this.$loop.schedule(this.CHANGE_MARKER_BACK); + }; + this.addGutterDecoration = function(row, className){ + this.$gutterLayer.addGutterDecoration(row, className); + }; + this.removeGutterDecoration = function(row, className){ + this.$gutterLayer.removeGutterDecoration(row, className); + }; + this.updateBreakpoints = function(rows) { + this.$loop.schedule(this.CHANGE_GUTTER); + }; + this.setAnnotations = function(annotations) { + this.$gutterLayer.setAnnotations(annotations); + this.$loop.schedule(this.CHANGE_GUTTER); + }; + this.updateCursor = function() { + this.$loop.schedule(this.CHANGE_CURSOR); + }; + this.hideCursor = function() { + this.$cursorLayer.hideCursor(); + }; + this.showCursor = function() { + this.$cursorLayer.showCursor(); + }; + + this.scrollSelectionIntoView = function(anchor, lead, offset) { + // first scroll anchor into view then scroll lead into view + this.scrollCursorIntoView(anchor, offset); + this.scrollCursorIntoView(lead, offset); + }; + this.scrollCursorIntoView = function(cursor, offset) { + // the editor is not visible + if (this.$size.scrollerHeight === 0) + return; + + var pos = this.$cursorLayer.getPixelPosition(cursor); + + var left = pos.left; + var top = pos.top; + + if (this.scrollTop > top) { + if (offset) + top -= offset * this.$size.scrollerHeight; + this.session.setScrollTop(top); + } else if (this.scrollTop + this.$size.scrollerHeight < top + this.lineHeight) { + if (offset) + top += offset * this.$size.scrollerHeight; + this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight); + } + + var scrollLeft = this.scrollLeft; + + if (scrollLeft > left) { + if (left < this.$padding + 2 * this.layerConfig.characterWidth) + left = 0; + this.session.setScrollLeft(left); + } else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) { + this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth)); + } + }; + this.getScrollTop = function() { + return this.session.getScrollTop(); + }; + this.getScrollLeft = function() { + return this.session.getScrollLeft(); + }; + this.getScrollTopRow = function() { + return this.scrollTop / this.lineHeight; + }; + this.getScrollBottomRow = function() { + return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1); + }; + this.scrollToRow = function(row) { + this.session.setScrollTop(row * this.lineHeight); + }; + + this.alignCursor = function(cursor, alignment) { + if (typeof cursor == "number") + cursor = {row: cursor, column: 0}; + + var pos = this.$cursorLayer.getPixelPosition(cursor); + var h = this.$size.scrollerHeight - this.lineHeight; + var offset = pos.top - h * (alignment || 0); + + this.session.setScrollTop(offset); + return offset; + }; + + this.STEPS = 8; + this.$calcSteps = function(fromValue, toValue){ + var i = 0; + var l = this.STEPS; + var steps = []; + + var func = function(t, x_min, dx) { + return dx * (Math.pow(t - 1, 3) + 1) + x_min; + }; + + for (i = 0; i < l; ++i) + steps.push(func(i / this.STEPS, fromValue, toValue - fromValue)); + + return steps; + }; + this.scrollToLine = function(line, center, animate, callback) { + var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0}); + var offset = pos.top; + if (center) + offset -= this.$size.scrollerHeight / 2; + + var initialScroll = this.scrollTop; + this.session.setScrollTop(offset); + if (animate !== false) + this.animateScrolling(initialScroll, callback); + }; + + this.animateScrolling = function(fromValue, callback) { + var toValue = this.scrollTop; + if (this.$animatedScroll && Math.abs(fromValue - toValue) < 100000) { + var _self = this; + var steps = _self.$calcSteps(fromValue, toValue); + this.$inScrollAnimation = true; + + clearInterval(this.$timer); + + _self.session.setScrollTop(steps.shift()); + this.$timer = setInterval(function() { + if (steps.length) { + _self.session.setScrollTop(steps.shift()); + // trick session to think it's already scrolled to not loose toValue + _self.session.$scrollTop = toValue; + } else if (toValue != null) { + _self.session.$scrollTop = -1; + _self.session.setScrollTop(toValue); + toValue = null; + } else { + // do this on separate step to not get spurious scroll event from scrollbar + _self.$timer = clearInterval(_self.$timer); + _self.$inScrollAnimation = false; + callback && callback(); + } + }, 10); + } + }; + this.scrollToY = function(scrollTop) { + // after calling scrollBar.setScrollTop + // scrollbar sends us event with same scrollTop. ignore it + if (this.scrollTop !== scrollTop) { + this.$loop.schedule(this.CHANGE_SCROLL); + this.scrollTop = scrollTop; + } + }; + this.scrollToX = function(scrollLeft) { + if (scrollLeft < 0) + scrollLeft = 0; + + if (this.scrollLeft !== scrollLeft) + this.scrollLeft = scrollLeft; + this.$loop.schedule(this.CHANGE_H_SCROLL); + }; + this.scrollBy = function(deltaX, deltaY) { + deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY); + deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX); + }; + this.isScrollableBy = function(deltaX, deltaY) { + if (deltaY < 0 && this.session.getScrollTop() > 0) + return true; + if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight < this.layerConfig.maxHeight) + return true; + // todo: handle horizontal scrolling + }; + + this.pixelToScreenCoordinates = function(x, y) { + var canvasPos = this.scroller.getBoundingClientRect(); + + var offset = (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth; + var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight); + var col = Math.round(offset); + + return {row: row, column: col, side: offset - col > 0 ? 1 : -1}; + }; + + this.screenToTextCoordinates = function(x, y) { + var canvasPos = this.scroller.getBoundingClientRect(); + + var col = Math.round( + (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth + ); + var row = Math.floor( + (y + this.scrollTop - canvasPos.top) / this.lineHeight + ); + + return this.session.screenToDocumentPosition(row, Math.max(col, 0)); + }; + this.textToScreenCoordinates = function(row, column) { + var canvasPos = this.scroller.getBoundingClientRect(); + var pos = this.session.documentToScreenPosition(row, column); + + var x = this.$padding + Math.round(pos.column * this.characterWidth); + var y = pos.row * this.lineHeight; + + return { + pageX: canvasPos.left + x - this.scrollLeft, + pageY: canvasPos.top + y - this.scrollTop + }; + }; + this.visualizeFocus = function() { + dom.addCssClass(this.container, "ace_focus"); + }; + this.visualizeBlur = function() { + dom.removeCssClass(this.container, "ace_focus"); + }; + this.showComposition = function(position) { + if (!this.$composition) + this.$composition = { + keepTextAreaAtCursor: this.$keepTextAreaAtCursor, + cssText: this.textarea.style.cssText + }; + + this.$keepTextAreaAtCursor = true; + dom.addCssClass(this.textarea, "ace_composition"); + this.textarea.style.cssText = ""; + this.$moveTextAreaToCursor(); + }; + this.setCompositionText = function(text) { + this.$moveTextAreaToCursor(); + }; + this.hideComposition = function() { + if (!this.$composition) + return; + + dom.removeCssClass(this.textarea, "ace_composition"); + this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor; + this.textarea.style.cssText = this.$composition.cssText; + this.$composition = null; + }; + + this._loadTheme = function(name, callback) { + if (!config.get("packaged")) + return callback(); + + net.loadScript(config.moduleUrl(name, "theme"), callback); + }; + this.setTheme = function(theme) { + var _self = this; + + this.$themeValue = theme; + if (!theme || typeof theme == "string") { + var moduleName = theme || "ace/theme/textmate"; + + var module; + try { + module = require(moduleName); + } catch (e) {}; + if (module) + return afterLoad(module); + + _self._loadTheme(moduleName, function() { + require([moduleName], function(module) { + if (_self.$themeValue !== theme) + return; + + afterLoad(module); + }); + }); + } else { + afterLoad(theme); + } + + function afterLoad(theme) { + dom.importCssString( + theme.cssText, + theme.cssClass, + _self.container.ownerDocument + ); + + if (_self.$theme) + dom.removeCssClass(_self.container, _self.$theme); + + _self.$theme = theme ? theme.cssClass : null; + + if (_self.$theme) + dom.addCssClass(_self.container, _self.$theme); + + if (theme && theme.isDark) + dom.addCssClass(_self.container, "ace_dark"); + else + dom.removeCssClass(_self.container, "ace_dark"); + + // force re-measure of the gutter width + if (_self.$size) { + _self.$size.width = 0; + _self.onResize(); + } + } + }; + this.getTheme = function() { + return this.$themeValue; + }; + + // Methods allows to add / remove CSS classnames to the editor element. + // This feature can be used by plug-ins to provide a visual indication of + // a certain mode that editor is in. + + /** + * VirtualRenderer.setStyle(style) + * - style (String): A class name + * + * [Adds a new class, `style`, to the editor.]{: #VirtualRenderer.setStyle} + **/ + this.setStyle = function setStyle(style) { + dom.addCssClass(this.container, style); + }; + this.unsetStyle = function unsetStyle(style) { + dom.removeCssClass(this.container, style); + }; + this.destroy = function() { + this.$textLayer.destroy(); + this.$cursorLayer.destroy(); + }; + +}).call(VirtualRenderer.prototype); + +exports.VirtualRenderer = VirtualRenderer; +}); + +ace.define('ace/layer/gutter', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) { + + +var dom = require("../lib/dom"); +var oop = require("../lib/oop"); +var EventEmitter = require("../lib/event_emitter").EventEmitter; + +var Gutter = function(parentEl) { + this.element = dom.createElement("div"); + this.element.className = "ace_layer ace_gutter-layer"; + parentEl.appendChild(this.element); + this.setShowFoldWidgets(this.$showFoldWidgets); + + this.gutterWidth = 0; + + this.$annotations = []; +}; + +(function() { + + oop.implement(this, EventEmitter); + + this.setSession = function(session) { + this.session = session; + }; + + this.addGutterDecoration = function(row, className){ + if (window.console) + console.warn && console.warn("deprecated use session.addGutterDecoration"); + this.session.addGutterDecoration(row, className); + }; + + this.removeGutterDecoration = function(row, className){ + if (window.console) + console.warn && console.warn("deprecated use session.removeGutterDecoration"); + this.session.removeGutterDecoration(row, className); + }; + + this.setAnnotations = function(annotations) { + // iterate over sparse array + this.$annotations = []; + for (var row in annotations) if (annotations.hasOwnProperty(row)) { + var rowAnnotations = annotations[row]; + if (!rowAnnotations) + continue; + + var rowInfo = this.$annotations[row] = { + text: [] + }; + for (var i=0; i foldStart) { + i = fold.end.row + 1; + fold = this.session.getNextFoldLine(i, fold); + foldStart = fold ?fold.start.row :Infinity; + } + if(i > lastRow) + break; + + var annotation = this.$annotations[i] || emptyAnno; + html.push( + "
    ", + lastLineNumber = i + 1 + ); + + if (foldWidgets) { + var c = foldWidgets[i]; + // check if cached value is invalidated and we need to recompute + if (c == null) + c = foldWidgets[i] = this.session.getFoldWidget(i); + if (c) + html.push( + "" + ); + } + + html.push("
    "); + + i++; + } + + this.element = dom.setInnerHtml(this.element, html.join("")); + this.element.style.height = config.minHeight + "px"; + + if (this.session.$useWrapMode) + lastLineNumber = this.session.getLength(); + + var gutterWidth = ("" + lastLineNumber).length * config.characterWidth; + var padding = this.$padding || this.$computePadding(); + gutterWidth += padding.left + padding.right; + if (gutterWidth !== this.gutterWidth) { + this.gutterWidth = gutterWidth; + this.element.style.width = Math.ceil(this.gutterWidth) + "px"; + this._emit("changeGutterWidth", gutterWidth); + } + }; + + this.$showFoldWidgets = true; + this.setShowFoldWidgets = function(show) { + if (show) + dom.addCssClass(this.element, "ace_folding-enabled"); + else + dom.removeCssClass(this.element, "ace_folding-enabled"); + + this.$showFoldWidgets = show; + this.$padding = null; + }; + + this.getShowFoldWidgets = function() { + return this.$showFoldWidgets; + }; + + this.$computePadding = function() { + if (!this.element.firstChild) + return {left: 0, right: 0}; + var style = dom.computedStyle(this.element.firstChild); + this.$padding = {} + this.$padding.left = parseInt(style.paddingLeft) + 1; + this.$padding.right = parseInt(style.paddingRight); + return this.$padding; + }; + + this.getRegion = function(point) { + var padding = this.$padding || this.$computePadding(); + var rect = this.element.getBoundingClientRect(); + if (point.x < padding.left + rect.left) + return "markers"; + if (this.$showFoldWidgets && point.x > rect.right - padding.right) + return "foldWidgets"; + }; + +}).call(Gutter.prototype); + +exports.Gutter = Gutter; + +}); + +ace.define('ace/layer/marker', ['require', 'exports', 'module' , 'ace/range', 'ace/lib/dom'], function(require, exports, module) { + + +var Range = require("../range").Range; +var dom = require("../lib/dom"); + +var Marker = function(parentEl) { + this.element = dom.createElement("div"); + this.element.className = "ace_layer ace_marker-layer"; + parentEl.appendChild(this.element); +}; + +(function() { + + this.$padding = 0; + + this.setPadding = function(padding) { + this.$padding = padding; + }; + this.setSession = function(session) { + this.session = session; + }; + + this.setMarkers = function(markers) { + this.markers = markers; + }; + + this.update = function(config) { + var config = config || this.config; + if (!config) + return; + + this.config = config; + + + var html = []; + for (var key in this.markers) { + var marker = this.markers[key]; + + if (!marker.range) { + marker.update(html, this, this.session, config); + continue; + } + + var range = marker.range.clipRows(config.firstRow, config.lastRow); + if (range.isEmpty()) continue; + + range = range.toScreenRange(this.session); + if (marker.renderer) { + var top = this.$getTop(range.start.row, config); + var left = Math.round( + this.$padding + range.start.column * config.characterWidth + ); + marker.renderer(html, range, left, top, config); + } + else if (range.isMultiLine()) { + if (marker.type == "text") { + this.drawTextMarker(html, range, marker.clazz, config); + } else { + this.drawMultiLineMarker( + html, range, marker.clazz, config, + marker.type + ); + } + } + else { + this.drawSingleLineMarker( + html, range, marker.clazz + " start", config, + null, marker.type + ); + } + } + this.element = dom.setInnerHtml(this.element, html.join("")); + }; + + this.$getTop = function(row, layerConfig) { + return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight; + }; + + // Draws a marker, which spans a range of text on multiple lines + this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig) { + // selection start + var row = range.start.row; + + var lineRange = new Range( + row, range.start.column, + row, this.session.getScreenLastRowColumn(row) + ); + this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " start", layerConfig, 1, "text"); + + // selection end + row = range.end.row; + lineRange = new Range(row, 0, row, range.end.column); + this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 0, "text"); + + for (row = range.start.row + 1; row < range.end.row; row++) { + lineRange.start.row = row; + lineRange.end.row = row; + lineRange.end.column = this.session.getScreenLastRowColumn(row); + this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1, "text"); + } + }; + + // Draws a multi line marker, where lines span the full width + this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, type) { + var padding = type === "background" ? 0 : this.$padding; + // from selection start to the end of the line + var height = config.lineHeight; + var top = this.$getTop(range.start.row, config); + var left = Math.round(padding + range.start.column * config.characterWidth); + + stringBuilder.push( + "
    " + ); + + // from start of the last line to the selection end + top = this.$getTop(range.end.row, config); + var width = Math.round(range.end.column * config.characterWidth); + + stringBuilder.push( + "
    " + ); + + // all the complete lines + height = (range.end.row - range.start.row - 1) * config.lineHeight; + if (height < 0) + return; + top = this.$getTop(range.start.row + 1, config); + + stringBuilder.push( + "
    " + ); + }; + + // Draws a marker which covers part or whole width of a single screen line + this.drawSingleLineMarker = function(stringBuilder, range, clazz, layerConfig, extraLength, type) { + var padding = type === "background" ? 0 : this.$padding; + var height = layerConfig.lineHeight; + + if (type === "background") + var width = layerConfig.width; + else + width = Math.round((range.end.column + (extraLength || 0) - range.start.column) * layerConfig.characterWidth); + + var top = this.$getTop(range.start.row, layerConfig); + var left = Math.round( + padding + range.start.column * layerConfig.characterWidth + ); + + stringBuilder.push( + "
    " + ); + }; + +}).call(Marker.prototype); + +exports.Marker = Marker; + +}); + +ace.define('ace/layer/text', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/lang', 'ace/lib/useragent', 'ace/lib/event_emitter'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var dom = require("../lib/dom"); +var lang = require("../lib/lang"); +var useragent = require("../lib/useragent"); +var EventEmitter = require("../lib/event_emitter").EventEmitter; + +var Text = function(parentEl) { + this.element = dom.createElement("div"); + this.element.className = "ace_layer ace_text-layer"; + parentEl.appendChild(this.element); + + this.$characterSize = this.$measureSizes() || {width: 0, height: 0}; + this.$pollSizeChanges(); +}; + +(function() { + + oop.implement(this, EventEmitter); + + this.EOF_CHAR = "\xB6"; //"¶"; + this.EOL_CHAR = "\xAC"; //"¬"; + this.TAB_CHAR = "\u2192"; //"→" "\u21E5"; + this.SPACE_CHAR = "\xB7"; //"·"; + this.$padding = 0; + + this.setPadding = function(padding) { + this.$padding = padding; + this.element.style.padding = "0 " + padding + "px"; + }; + + this.getLineHeight = function() { + return this.$characterSize.height || 1; + }; + + this.getCharacterWidth = function() { + return this.$characterSize.width || 1; + }; + + this.checkForSizeChanges = function() { + var size = this.$measureSizes(); + if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) { + this.$characterSize = size; + this._emit("changeCharacterSize", {data: size}); + } + }; + + this.$pollSizeChanges = function() { + var self = this; + this.$pollSizeChangesTimer = setInterval(function() { + self.checkForSizeChanges(); + }, 500); + }; + + this.$fontStyles = { + fontFamily : 1, + fontSize : 1, + fontWeight : 1, + fontStyle : 1, + lineHeight : 1 + }; + + this.$measureSizes = useragent.isIE || useragent.isOldGecko ? function() { + var n = 1000; + if (!this.$measureNode) { + var measureNode = this.$measureNode = dom.createElement("div"); + var style = measureNode.style; + + style.width = style.height = "auto"; + style.left = style.top = (-n * 40) + "px"; + + style.visibility = "hidden"; + style.position = "fixed"; + style.overflow = "visible"; + style.whiteSpace = "nowrap"; + + // in FF 3.6 monospace fonts can have a fixed sub pixel width. + // that's why we have to measure many characters + // Note: characterWidth can be a float! + measureNode.innerHTML = lang.stringRepeat("Xy", n); + + if (this.element.ownerDocument.body) { + this.element.ownerDocument.body.appendChild(measureNode); + } else { + var container = this.element.parentNode; + while (!dom.hasCssClass(container, "ace_editor")) + container = container.parentNode; + container.appendChild(measureNode); + } + } + + // Size and width can be null if the editor is not visible or + // detached from the document + if (!this.element.offsetWidth) + return null; + + var style = this.$measureNode.style; + var computedStyle = dom.computedStyle(this.element); + for (var prop in this.$fontStyles) + style[prop] = computedStyle[prop]; + + var size = { + height: this.$measureNode.offsetHeight, + width: this.$measureNode.offsetWidth / (n * 2) + }; + + // Size and width can be null if the editor is not visible or + // detached from the document + if (size.width == 0 || size.height == 0) + return null; + + return size; + } + : function() { + if (!this.$measureNode) { + var measureNode = this.$measureNode = dom.createElement("div"); + var style = measureNode.style; + + style.width = style.height = "auto"; + style.left = style.top = -100 + "px"; + + style.visibility = "hidden"; + style.position = "fixed"; + style.overflow = "visible"; + style.whiteSpace = "nowrap"; + + measureNode.innerHTML = "X"; + + var container = this.element.parentNode; + while (container && !dom.hasCssClass(container, "ace_editor")) + container = container.parentNode; + + if (!container) + return this.$measureNode = null; + + container.appendChild(measureNode); + } + + var rect = this.$measureNode.getBoundingClientRect(); + + var size = { + height: rect.height, + width: rect.width + }; + + // Size and width can be null if the editor is not visible or + // detached from the document + if (size.width == 0 || size.height == 0) + return null; + + return size; + }; + + this.setSession = function(session) { + this.session = session; + this.$computeTabString(); + }; + + this.showInvisibles = false; + this.setShowInvisibles = function(showInvisibles) { + if (this.showInvisibles == showInvisibles) + return false; + + this.showInvisibles = showInvisibles; + this.$computeTabString(); + return true; + }; + + this.displayIndentGuides = true; + this.setDisplayIndentGuides = function(display) { + if (this.displayIndentGuides == display) + return false; + + this.displayIndentGuides = display; + this.$computeTabString(); + return true; + }; + + this.$tabStrings = []; + this.onChangeTabSize = + this.$computeTabString = function() { + var tabSize = this.session.getTabSize(); + this.tabSize = tabSize; + var tabStr = this.$tabStrings = [0]; + for (var i = 1; i < tabSize + 1; i++) { + if (this.showInvisibles) { + tabStr.push("" + + this.TAB_CHAR + + Array(i).join(" ") + + ""); + } else { + tabStr.push(new Array(i+1).join(" ")); + } + } + if (this.displayIndentGuides) { + this.$indentGuideRe = /\s\S| \t|\t |\s$/; + var className = "ace_indent-guide"; + var content = Array(this.tabSize + 1).join(" "); + var tabContent = content; + if (this.showInvisibles) { + className += " ace_invisible"; + tabContent = this.TAB_CHAR + content.substr(6); + } + + this.$tabStrings[" "] = "" + content + ""; + this.$tabStrings["\t"] = "" + tabContent + ""; + } + }; + + this.updateLines = function(config, firstRow, lastRow) { + // Due to wrap line changes there can be new lines if e.g. + // the line to updated wrapped in the meantime. + if (this.config.lastRow != config.lastRow || + this.config.firstRow != config.firstRow) { + this.scrollLines(config); + } + this.config = config; + + var first = Math.max(firstRow, config.firstRow); + var last = Math.min(lastRow, config.lastRow); + + var lineElements = this.element.childNodes; + var lineElementsIdx = 0; + + for (var row = config.firstRow; row < first; row++) { + var foldLine = this.session.getFoldLine(row); + if (foldLine) { + if (foldLine.containsRow(first)) { + first = foldLine.start.row; + break; + } else { + row = foldLine.end.row; + } + } + lineElementsIdx ++; + } + + var row = first; + var foldLine = this.session.getNextFoldLine(row); + var foldStart = foldLine ? foldLine.start.row : Infinity; + + while (true) { + if (row > foldStart) { + row = foldLine.end.row+1; + foldLine = this.session.getNextFoldLine(row, foldLine); + foldStart = foldLine ? foldLine.start.row :Infinity; + } + if (row > last) + break; + + var lineElement = lineElements[lineElementsIdx++]; + if (lineElement) { + var html = []; + this.$renderLine( + html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false + ); + dom.setInnerHtml(lineElement, html.join("")); + } + row++; + } + }; + + this.scrollLines = function(config) { + var oldConfig = this.config; + this.config = config; + + if (!oldConfig || oldConfig.lastRow < config.firstRow) + return this.update(config); + + if (config.lastRow < oldConfig.firstRow) + return this.update(config); + + var el = this.element; + if (oldConfig.firstRow < config.firstRow) + for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--) + el.removeChild(el.firstChild); + + if (oldConfig.lastRow > config.lastRow) + for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--) + el.removeChild(el.lastChild); + + if (config.firstRow < oldConfig.firstRow) { + var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1); + if (el.firstChild) + el.insertBefore(fragment, el.firstChild); + else + el.appendChild(fragment); + } + + if (config.lastRow > oldConfig.lastRow) { + var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow); + el.appendChild(fragment); + } + }; + + this.$renderLinesFragment = function(config, firstRow, lastRow) { + var fragment = this.element.ownerDocument.createDocumentFragment(); + var row = firstRow; + var foldLine = this.session.getNextFoldLine(row); + var foldStart = foldLine ? foldLine.start.row : Infinity; + + while (true) { + if (row > foldStart) { + row = foldLine.end.row+1; + foldLine = this.session.getNextFoldLine(row, foldLine); + foldStart = foldLine ? foldLine.start.row : Infinity; + } + if (row > lastRow) + break; + + var container = dom.createElement("div"); + + var html = []; + // Get the tokens per line as there might be some lines in between + // beeing folded. + this.$renderLine(html, row, false, row == foldStart ? foldLine : false); + + // don't use setInnerHtml since we are working with an empty DIV + container.innerHTML = html.join(""); + if (this.$useLineGroups()) { + container.className = 'ace_line_group'; + fragment.appendChild(container); + } else { + var lines = container.childNodes + while(lines.length) + fragment.appendChild(lines[0]); + } + + row++; + } + return fragment; + }; + + this.update = function(config) { + this.config = config; + + var html = []; + var firstRow = config.firstRow, lastRow = config.lastRow; + + var row = firstRow; + var foldLine = this.session.getNextFoldLine(row); + var foldStart = foldLine ? foldLine.start.row : Infinity; + + while (true) { + if (row > foldStart) { + row = foldLine.end.row+1; + foldLine = this.session.getNextFoldLine(row, foldLine); + foldStart = foldLine ? foldLine.start.row :Infinity; + } + if (row > lastRow) + break; + + if (this.$useLineGroups()) + html.push("
    ") + + this.$renderLine(html, row, false, row == foldStart ? foldLine : false); + + if (this.$useLineGroups()) + html.push("
    "); // end the line group + + row++; + } + this.element = dom.setInnerHtml(this.element, html.join("")); + }; + + this.$textToken = { + "text": true, + "rparen": true, + "lparen": true + }; + + this.$renderToken = function(stringBuilder, screenColumn, token, value) { + var self = this; + var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g; + var replaceFunc = function(c, a, b, tabIdx, idx4) { + if (a) { + return new Array(c.length+1).join(" "); + } else if (c == "&") { + return "&"; + } else if (c == "<") { + return "<"; + } else if (c == "\t") { + var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx); + screenColumn += tabSize - 1; + return self.$tabStrings[tabSize]; + } else if (c == "\u3000") { + // U+3000 is both invisible AND full-width, so must be handled uniquely + var classToUse = self.showInvisibles ? "ace_cjk ace_invisible" : "ace_cjk"; + var space = self.showInvisibles ? self.SPACE_CHAR : ""; + screenColumn += 1; + return "" + space + ""; + } else if (b) { + return "" + self.SPACE_CHAR + ""; + } else { + screenColumn += 1; + return "" + c + ""; + } + }; + + var output = value.replace(replaceReg, replaceFunc); + + if (!this.$textToken[token.type]) { + var classes = "ace_" + token.type.replace(/\./g, " ace_"); + var style = ""; + if (token.type == "fold") + style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' "; + stringBuilder.push("", output, ""); + } + else { + stringBuilder.push(output); + } + return screenColumn + value.length; + }; + + this.renderIndentGuide = function(stringBuilder, value) { + var cols = value.search(this.$indentGuideRe); + if (cols <= 0) + return value; + if (value[0] == " ") { + cols -= cols % this.tabSize; + stringBuilder.push(Array(cols/this.tabSize + 1).join(this.$tabStrings[" "])); + return value.substr(cols); + } else if (value[0] == "\t") { + stringBuilder.push(Array(cols + 1).join(this.$tabStrings["\t"])); + return value.substr(cols); + } + return value; + }; + + this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) { + var chars = 0; + var split = 0; + var splitChars = splits[0]; + var screenColumn = 0; + + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + var value = token.value; + if (i == 0 && this.displayIndentGuides) { + chars = value.length; + value = this.renderIndentGuide(stringBuilder, value); + if (!value) + continue; + chars -= value.length; + } + + if (chars + value.length < splitChars) { + screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + chars += value.length; + } else { + while (chars + value.length >= splitChars) { + screenColumn = this.$renderToken( + stringBuilder, screenColumn, + token, value.substring(0, splitChars - chars) + ); + value = value.substring(splitChars - chars); + chars = splitChars; + + if (!onlyContents) { + stringBuilder.push("", + "
    " + ); + } + + split ++; + screenColumn = 0; + splitChars = splits[split] || Number.MAX_VALUE; + } + if (value.length != 0) { + chars += value.length; + screenColumn = this.$renderToken( + stringBuilder, screenColumn, token, value + ); + } + } + } + }; + + this.$renderSimpleLine = function(stringBuilder, tokens) { + var screenColumn = 0; + var token = tokens[0]; + var value = token.value; + if (this.displayIndentGuides) + value = this.renderIndentGuide(stringBuilder, value); + if (value) + screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + for (var i = 1; i < tokens.length; i++) { + token = tokens[i]; + value = token.value; + screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + } + }; + + // row is either first row of foldline or not in fold + this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) { + if (!foldLine && foldLine != false) + foldLine = this.session.getFoldLine(row); + + if (foldLine) + var tokens = this.$getFoldLineTokens(row, foldLine); + else + var tokens = this.session.getTokens(row); + + + if (!onlyContents) { + stringBuilder.push( + "
    " + ); + } + + if (tokens.length) { + var splits = this.session.getRowSplitData(row); + if (splits && splits.length) + this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents); + else + this.$renderSimpleLine(stringBuilder, tokens); + } + + if (this.showInvisibles) { + if (foldLine) + row = foldLine.end.row + + stringBuilder.push( + "", + row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR, + "" + ); + } + if (!onlyContents) + stringBuilder.push("
    "); + }; + + this.$getFoldLineTokens = function(row, foldLine) { + var session = this.session; + var renderTokens = []; + + function addTokens(tokens, from, to) { + var idx = 0, col = 0; + while ((col + tokens[idx].value.length) < from) { + col += tokens[idx].value.length; + idx++; + + if (idx == tokens.length) + return; + } + if (col != from) { + var value = tokens[idx].value.substring(from - col); + // Check if the token value is longer then the from...to spacing. + if (value.length > (to - from)) + value = value.substring(0, to - from); + + renderTokens.push({ + type: tokens[idx].type, + value: value + }); + + col = from + value.length; + idx += 1; + } + + while (col < to && idx < tokens.length) { + var value = tokens[idx].value; + if (value.length + col > to) { + renderTokens.push({ + type: tokens[idx].type, + value: value.substring(0, to - col) + }); + } else + renderTokens.push(tokens[idx]); + col += value.length; + idx += 1; + } + } + + var tokens = session.getTokens(row); + foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) { + if (placeholder) { + renderTokens.push({ + type: "fold", + value: placeholder + }); + } else { + if (isNewRow) + tokens = session.getTokens(row); + + if (tokens.length) + addTokens(tokens, lastColumn, column); + } + }, foldLine.end.row, this.session.getLine(foldLine.end.row).length); + + return renderTokens; + }; + + this.$useLineGroups = function() { + // For the updateLines function to work correctly, it's important that the + // child nodes of this.element correspond on a 1-to-1 basis to rows in the + // document (as distinct from lines on the screen). For sessions that are + // wrapped, this means we need to add a layer to the node hierarchy (tagged + // with the class name ace_line_group). + return this.session.getUseWrapMode(); + }; + + this.destroy = function() { + clearInterval(this.$pollSizeChangesTimer); + if (this.$measureNode) + this.$measureNode.parentNode.removeChild(this.$measureNode); + delete this.$measureNode; + }; + +}).call(Text.prototype); + +exports.Text = Text; + +}); + +ace.define('ace/layer/cursor', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) { + + +var dom = require("../lib/dom"); + +var Cursor = function(parentEl) { + this.element = dom.createElement("div"); + this.element.className = "ace_layer ace_cursor-layer"; + parentEl.appendChild(this.element); + + this.isVisible = false; + this.isBlinking = true; + + this.cursors = []; + this.cursor = this.addCursor(); +}; + +(function() { + + this.$padding = 0; + this.setPadding = function(padding) { + this.$padding = padding; + }; + + this.setSession = function(session) { + this.session = session; + }; + + this.setBlinking = function(blinking) { + this.isBlinking = blinking; + if (blinking) + this.restartTimer(); + }; + + this.addCursor = function() { + var el = dom.createElement("div"); + var className = "ace_cursor"; + if (!this.isVisible) + className += " ace_hidden"; + if (this.overwrite) + className += " ace_overwrite"; + + el.className = className; + this.element.appendChild(el); + this.cursors.push(el); + return el; + }; + + this.removeCursor = function() { + if (this.cursors.length > 1) { + var el = this.cursors.pop(); + el.parentNode.removeChild(el); + return el; + } + }; + + this.hideCursor = function() { + this.isVisible = false; + for (var i = this.cursors.length; i--; ) + dom.addCssClass(this.cursors[i], "ace_hidden"); + clearInterval(this.blinkId); + }; + + this.showCursor = function() { + this.isVisible = true; + for (var i = this.cursors.length; i--; ) + dom.removeCssClass(this.cursors[i], "ace_hidden"); + + this.element.style.visibility = ""; + this.restartTimer(); + }; + + this.restartTimer = function() { + clearInterval(this.blinkId); + if (!this.isBlinking) + return; + if (!this.isVisible) + return; + + var element = this.cursors.length == 1 ? this.cursor : this.element; + this.blinkId = setInterval(function() { + element.style.visibility = "hidden"; + setTimeout(function() { + element.style.visibility = ""; + }, 400); + }, 1000); + }; + + this.getPixelPosition = function(position, onScreen) { + if (!this.config || !this.session) { + return { + left : 0, + top : 0 + }; + } + + if (!position) + position = this.session.selection.getCursor(); + var pos = this.session.documentToScreenPosition(position); + var cursorLeft = Math.round(this.$padding + + pos.column * this.config.characterWidth); + var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) * + this.config.lineHeight; + + return { + left : cursorLeft, + top : cursorTop + }; + }; + + this.update = function(config) { + this.config = config; + + if (this.session.selectionMarkerCount > 0) { + var selections = this.session.$selectionMarkers; + var i = 0, sel, cursorIndex = 0; + + for (var i = selections.length; i--; ) { + sel = selections[i]; + var pixelPos = this.getPixelPosition(sel.cursor, true); + if ((pixelPos.top > config.height + config.offset || + pixelPos.top < -config.offset) && i > 1) { + continue; + } + + var style = (this.cursors[cursorIndex++] || this.addCursor()).style; + + style.left = pixelPos.left + "px"; + style.top = pixelPos.top + "px"; + style.width = config.characterWidth + "px"; + style.height = config.lineHeight + "px"; + } + if (cursorIndex > 1) + while (this.cursors.length > cursorIndex) + this.removeCursor(); + } else { + var pixelPos = this.getPixelPosition(null, true); + var style = this.cursor.style; + style.left = pixelPos.left + "px"; + style.top = pixelPos.top + "px"; + style.width = config.characterWidth + "px"; + style.height = config.lineHeight + "px"; + + while (this.cursors.length > 1) + this.removeCursor(); + } + + var overwrite = this.session.getOverwrite(); + if (overwrite != this.overwrite) + this.$setOverite(overwrite); + + // cache for textarea and gutter highlight + this.$pixelPos = pixelPos; + + this.restartTimer(); + }; + + this.$setOverite = function(overwrite) { + this.overwrite = overwrite; + for (var i = this.cursors.length; i--; ) { + if (overwrite) + dom.addCssClass(this.cursors[i], "ace_overwrite"); + else + dom.removeCssClass(this.cursors[i], "ace_overwrite"); + } + }; + + this.destroy = function() { + clearInterval(this.blinkId); + } + +}).call(Cursor.prototype); + +exports.Cursor = Cursor; + +}); + +ace.define('ace/scrollbar', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/event', 'ace/lib/event_emitter'], function(require, exports, module) { + + +var oop = require("./lib/oop"); +var dom = require("./lib/dom"); +var event = require("./lib/event"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; + +/** + * new ScrollBar(parent) + * - parent (DOMElement): A DOM element + * + * Creates a new `ScrollBar`. `parent` is the owner of the scroll bar. + * + **/ +var ScrollBar = function(parent) { + this.element = dom.createElement("div"); + this.element.className = "ace_sb"; + + this.inner = dom.createElement("div"); + this.element.appendChild(this.inner); + + parent.appendChild(this.element); + + // in OSX lion the scrollbars appear to have no width. In this case resize + // the to show the scrollbar but still pretend that the scrollbar has a width + // of 0px + // in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar + // make element a little bit wider to retain scrollbar when page is zoomed + this.width = dom.scrollbarWidth(parent.ownerDocument); + this.element.style.width = (this.width || 15) + 5 + "px"; + + event.addListener(this.element, "scroll", this.onScroll.bind(this)); +}; + +(function() { + oop.implement(this, EventEmitter); + this.onScroll = function() { + this._emit("scroll", {data: this.element.scrollTop}); + }; + this.getWidth = function() { + return this.width; + }; + this.setHeight = function(height) { + this.element.style.height = height + "px"; + }; + this.setInnerHeight = function(height) { + this.inner.style.height = height + "px"; + }; + // TODO: on chrome 17+ for small zoom levels after calling this function + // this.element.scrollTop != scrollTop which makes page to scroll up. + this.setScrollTop = function(scrollTop) { + this.element.scrollTop = scrollTop; + }; + +}).call(ScrollBar.prototype); + +exports.ScrollBar = ScrollBar; +}); + +ace.define('ace/renderloop', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) { + + +var event = require("./lib/event"); + +/** internal, hide + * new RenderLoop(onRender, win) + * + * + * +**/ +var RenderLoop = function(onRender, win) { + this.onRender = onRender; + this.pending = false; + this.changes = 0; + this.window = win || window; +}; + +(function() { + + /** internal, hide + * RenderLoop.schedule(change) + * - change (Array): + * + * + **/ + this.schedule = function(change) { + //this.onRender(change); + //return; + this.changes = this.changes | change; + if (!this.pending) { + this.pending = true; + var _self = this; + event.nextTick(function() { + _self.pending = false; + var changes; + while (changes = _self.changes) { + _self.changes = 0; + _self.onRender(changes); + } + }, this.window); + } + }; + +}).call(RenderLoop.prototype); + +exports.RenderLoop = RenderLoop; +}); +ace.define("text!ace/css/editor.css", [], ".ace_editor {\n" + + " position: absolute;\n" + + " overflow: hidden;\n" + + " font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Consolas', monospace;\n" + + " font-size: 12px;\n" + + "}\n" + + "\n" + + ".ace_scroller {\n" + + " position: absolute;\n" + + " overflow: hidden;\n" + + "}\n" + + "\n" + + ".ace_content {\n" + + " position: absolute;\n" + + " box-sizing: border-box;\n" + + " -moz-box-sizing: border-box;\n" + + " -webkit-box-sizing: border-box;\n" + + " cursor: text;\n" + + "}\n" + + "\n" + + ".ace_gutter {\n" + + " position: absolute;\n" + + " overflow : hidden;\n" + + " height: 100%;\n" + + " width: auto;\n" + + " cursor: default;\n" + + " z-index: 4;\n" + + "}\n" + + "\n" + + ".ace_gutter_active_line {\n" + + " position: absolute;\n" + + " left: 0;\n" + + " right: 0;\n" + + "}\n" + + "\n" + + ".ace_scroller.horscroll {\n" + + " box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\n" + + "}\n" + + "\n" + + ".ace_gutter-cell {\n" + + " padding-left: 19px;\n" + + " padding-right: 6px;\n" + + " background-repeat: no-repeat;\n" + + "}\n" + + "\n" + + ".ace_gutter-cell.ace_error {\n" + + " background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QUM2OEZDQTQ4RTU0MTFFMUEzM0VFRTM2RUY1M0RBMjYiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QUM2OEZDQTU4RTU0MTFFMUEzM0VFRTM2RUY1M0RBMjYiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBQzY4RkNBMjhFNTQxMUUxQTMzRUVFMzZFRjUzREEyNiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBQzY4RkNBMzhFNTQxMUUxQTMzRUVFMzZFRjUzREEyNiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PkgXxbAAAAJbSURBVHjapFNNaBNBFH4zs5vdZLP5sQmNpT82QY209heh1ioWisaDRcSKF0WKJ0GQnrzrxasHsR6EnlrwD0TagxJabaVEpFYxLWlLSS822tr87m66ccfd2GKyVhA6MMybgfe97/vmPUQphd0sZjto9XIn9OOsvlu2nkqRzVU+6vvlzPf8W6bk8dxQ0NPbxAALgCgg2JkaQuhzQau/El0zbmUA7U0Es8v2CiYmKQJHGO1QICCLoqilMhkmurDAyapKgqItezi/USRdJqEYY4D5jCy03ht2yMkkvL91jTTX10qzyyu2hruPRN7jgbH+EOsXcMLgYiThEgAMhABW85oqy1DXdRIdvP1AHJ2acQXvDIrVHcdQNrEKNYSVMSZGMjEzIIAwDXIo+6G/FxcGnzkC3T2oMhLjre49sBB+RRcHLqdafK6sYdE/GGBwU1VpFNj0aN8pJbe+BkZyevUrvLl6Xmm0W9IuTc0DxrDNAJd5oEvI/KRsNC3bQyNjPO9yQ1YHcfj2QvfQc/5TUhJTBc2iM0U7AWDQtc1nJHvD/cfO2s7jaGkiTEfa/Ep8coLu7zmNmh8+dc5lZDuUeFAGUNA/OY6JVaypQ0vjr7XYjUvJM37vt+j1vuTK5DgVfVUoTjVe+y3/LxMxY2GgU+CSLy4cpfsYorRXuXIOi0Vt40h67uZFTdIo6nLaZcwUJWAzwNS0tBnqqKzQDnjdG/iPyZxo46HaKUpbvYkj8qYRTZsBhge+JHhZyh0x9b95JqjVJkT084kZIPwu/mPWqPgfQ5jXh2+92Ay7HedfAgwA6KDWafb4w3cAAAAASUVORK5CYII=\");\n" + + " background-repeat: no-repeat;\n" + + " background-position: 2px center;\n" + + "}\n" + + "\n" + + ".ace_gutter-cell.ace_warning {\n" + + " background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6QUM2OEZDQTg4RTU0MTFFMUEzM0VFRTM2RUY1M0RBMjYiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QUM2OEZDQTk4RTU0MTFFMUEzM0VFRTM2RUY1M0RBMjYiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpBQzY4RkNBNjhFNTQxMUUxQTMzRUVFMzZFRjUzREEyNiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpBQzY4RkNBNzhFNTQxMUUxQTMzRUVFMzZFRjUzREEyNiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pgd7PfIAAAGmSURBVHjaYvr//z8DJZiJgUIANoCRkREb9gLiSVAaQx4OQM7AAkwd7XU2/v++/rOttdYGEB9dASEvOMydGKfH8Gv/p4XTkvRBfLxeQAP+1cUhXopyvzhP7P/IoSj7g7Mw09cNKO6J1QQ0L4gICPIv/veg/8W+JdFvQNLHVsW9/nmn9zk7B+cCkDwhL7gt6knSZnx9/LuCEOcvkIAMP+cvto9nfqyZmmUAksfnBUtbM60gX/3/kgyv3/xSFOL5DZT+L8vP+Yfh5cvfPvp/xUHyQHXGyAYwgpwBjZYFT3Y1OEl/OfCH4ffv3wzc4iwMvNIsDJ+f/mH4+vIPAxsb631WW0Yln6ZpQLXdMK/DXGDflh+sIv37EivD5x//Gb7+YWT4y86sl7BCCkSD+Z++/1dkvsFRl+HnD1Rvje4F8whjMXmGj58YGf5zsDMwcnAwfPvKcml62DsQDeaDxN+/Y0qwlpEHqrdB94IRNIDUgfgfKJChGK4OikEW3gTiXUB950ASLFAF54AC94A0G9QAfOnmF9DCDzABFqS08IHYDIScdijOjQABBgC+/9awBH96jwAAAABJRU5ErkJggg==\");\n" + + " background-position: 2px center;\n" + + "}\n" + + "\n" + + ".ace_gutter-cell.ace_info {\n" + + " background-image: url(\"data:image/gif;base64,R0lGODlhEAAQAMQAAAAAAEFBQVJSUl5eXmRkZGtra39/f4WFhYmJiZGRkaampry8vMPDw8zMzNXV1dzc3OTk5Orq6vDw8P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABQALAAAAAAQABAAAAUuICWOZGmeaBml5XGwFCQSBGyXRSAwtqQIiRuiwIM5BoYVbEFIyGCQoeJGrVptIQA7\");\n" + + " background-position: 2px center;\n" + + "}\n" + + ".ace_dark .ace_gutter-cell.ace_info {\n" + + " background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpGRTk5MTVGREIxNDkxMUUxOTc5Q0FFREQyMTNGMjBFQyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpGRTk5MTVGRUIxNDkxMUUxOTc5Q0FFREQyMTNGMjBFQyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkZFOTkxNUZCQjE0OTExRTE5NzlDQUVERDIxM0YyMEVDIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkZFOTkxNUZDQjE0OTExRTE5NzlDQUVERDIxM0YyMEVDIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+SIDkjAAAAJ1JREFUeNpi/P//PwMlgImBQkB7A6qrq/+DMC55FkIGKCoq4pVnpFkgTp069f/+/fv/r1u37r+tre1/kg0A+ptn9uzZYLaRkRHpLvjw4cNXWVlZhufPnzOcO3eOdAO0tbVPAjHDmzdvGA4fPsxIsgGSkpJmv379Ynj37h2DjIyMCMkG3LhxQ/T27dsMampqDHZ2dq/pH41DxwCAAAMAFdc68dUsFZgAAAAASUVORK5CYII=\");\n" + + "}\n" + + "\n" + + ".ace_editor .ace_sb {\n" + + " position: absolute;\n" + + " overflow-x: hidden;\n" + + " overflow-y: scroll;\n" + + " right: 0;\n" + + "}\n" + + "\n" + + ".ace_editor .ace_sb div {\n" + + " position: absolute;\n" + + " width: 1px;\n" + + " left: 0;\n" + + "}\n" + + "\n" + + ".ace_editor .ace_print_margin_layer {\n" + + " z-index: 0;\n" + + " position: absolute;\n" + + " overflow: hidden;\n" + + " margin: 0;\n" + + " left: 0;\n" + + " height: 100%;\n" + + " width: 100%;\n" + + "}\n" + + "\n" + + ".ace_editor .ace_print_margin {\n" + + " position: absolute;\n" + + " height: 100%;\n" + + "}\n" + + "\n" + + ".ace_editor > textarea {\n" + + " position: absolute;\n" + + " z-index: 0;\n" + + " width: 0.5em;\n" + + " height: 1em;\n" + + " opacity: 0;\n" + + " background: transparent;\n" + + " appearance: none;\n" + + " -moz-appearance: none;\n" + + " border: none;\n" + + " resize: none;\n" + + " outline: none;\n" + + " overflow: hidden;\n" + + "}\n" + + "\n" + + ".ace_editor > textarea.ace_composition {\n" + + " background: #fff;\n" + + " color: #000;\n" + + " z-index: 1000;\n" + + " opacity: 1;\n" + + " border: solid lightgray 1px;\n" + + " margin: -1px\n" + + "}\n" + + "\n" + + ".ace_layer {\n" + + " z-index: 1;\n" + + " position: absolute;\n" + + " overflow: hidden;\n" + + " white-space: nowrap;\n" + + " height: 100%;\n" + + " width: 100%;\n" + + " box-sizing: border-box;\n" + + " -moz-box-sizing: border-box;\n" + + " -webkit-box-sizing: border-box;\n" + + " /* setting pointer-events: auto; on node under the mouse, which changes\n" + + " during scroll, will break mouse wheel scrolling in Safari */\n" + + " pointer-events: none;\n" + + "}\n" + + "\n" + + ".ace_gutter .ace_layer {\n" + + " position: relative;\n" + + " width: auto;\n" + + " text-align: right;\n" + + " pointer-events: auto;\n" + + "}\n" + + "\n" + + ".ace_text-layer {\n" + + " color: black;\n" + + " font: inherit !important;\n" + + "}\n" + + "\n" + + ".ace_cjk {\n" + + " display: inline-block;\n" + + " text-align: center;\n" + + "}\n" + + "\n" + + ".ace_cursor-layer {\n" + + " z-index: 4;\n" + + "}\n" + + "\n" + + ".ace_cursor {\n" + + " z-index: 4;\n" + + " position: absolute;\n" + + "}\n" + + "\n" + + ".ace_cursor.ace_hidden {\n" + + " opacity: 0.2;\n" + + "}\n" + + "\n" + + ".ace_editor.multiselect .ace_cursor {\n" + + " border-left-width: 1px;\n" + + "}\n" + + "\n" + + ".ace_line {\n" + + " white-space: nowrap;\n" + + "}\n" + + "\n" + + ".ace_marker-layer .ace_step {\n" + + " position: absolute;\n" + + " z-index: 3;\n" + + "}\n" + + "\n" + + ".ace_marker-layer .ace_selection {\n" + + " position: absolute;\n" + + " z-index: 5;\n" + + "}\n" + + "\n" + + ".ace_marker-layer .ace_bracket {\n" + + " position: absolute;\n" + + " z-index: 6;\n" + + "}\n" + + "\n" + + ".ace_marker-layer .ace_active_line {\n" + + " position: absolute;\n" + + " z-index: 2;\n" + + "}\n" + + "\n" + + ".ace_marker-layer .ace_selected_word {\n" + + " position: absolute;\n" + + " z-index: 4;\n" + + " box-sizing: border-box;\n" + + " -moz-box-sizing: border-box;\n" + + " -webkit-box-sizing: border-box;\n" + + "}\n" + + "\n" + + ".ace_line .ace_fold {\n" + + " box-sizing: border-box;\n" + + " -moz-box-sizing: border-box;\n" + + " -webkit-box-sizing: border-box;\n" + + "\n" + + " display: inline-block;\n" + + " height: 11px;\n" + + " margin-top: -2px;\n" + + " vertical-align: middle;\n" + + "\n" + + " background-image:\n" + + " url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%11%00%00%00%09%08%06%00%00%00%D4%E8%C7%0C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%B5IDAT(%15%A5%91%3D%0E%02!%10%85ac%E1%05%D6%CE%D6%C6%CE%D2%E8%ED%CD%DE%C0%C6%D6N.%E0V%F8%3D%9Ca%891XH%C2%BE%D9y%3F%90!%E6%9C%C3%BFk%E5%011%C6-%F5%C8N%04%DF%BD%FF%89%DFt%83DN%60%3E%F3%AB%A0%DE%1A%5Dg%BE%10Q%97%1B%40%9C%A8o%10%8F%5E%828%B4%1B%60%87%F6%02%26%85%1Ch%1E%C1%2B%5Bk%FF%86%EE%B7j%09%9A%DA%9B%ACe%A3%F9%EC%DA!9%B4%D5%A6%81%86%86%98%CC%3C%5B%40%FA%81%B3%E9%CB%23%94%C16Azo%05%D4%E1%C1%95a%3B%8A'%A0%E8%CC%17%22%85%1D%BA%00%A2%FA%DC%0A%94%D1%D1%8D%8B%3A%84%17B%C7%60%1A%25Z%FC%8D%00%00%00%00IEND%AEB%60%82\"),\n" + + " url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%007%08%06%00%00%00%C4%DD%80C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%3AIDAT8%11c%FC%FF%FF%7F%18%03%1A%60%01%F2%3F%A0%891%80%04%FF%11-%F8%17%9BJ%E2%05%B1ZD%81v%26t%E7%80%F8%A3%82h%A12%1A%20%A3%01%02%0F%01%BA%25%06%00%19%C0%0D%AEF%D5%3ES%00%00%00%00IEND%AEB%60%82\");\n" + + " background-repeat: no-repeat, repeat-x;\n" + + " background-position: center center, top left;\n" + + " color: transparent;\n" + + "\n" + + " border: 1px solid black;\n" + + " -moz-border-radius: 2px;\n" + + " -webkit-border-radius: 2px;\n" + + " border-radius: 2px;\n" + + "\n" + + " cursor: pointer;\n" + + " pointer-events: auto;\n" + + "}\n" + + "\n" + + ".ace_dark .ace_fold {\n" + + "}\n" + + "\n" + + ".ace_fold:hover{\n" + + " background-image:\n" + + " url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%11%00%00%00%09%08%06%00%00%00%D4%E8%C7%0C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%00%B5IDAT(%15%A5%91%3D%0E%02!%10%85ac%E1%05%D6%CE%D6%C6%CE%D2%E8%ED%CD%DE%C0%C6%D6N.%E0V%F8%3D%9Ca%891XH%C2%BE%D9y%3F%90!%E6%9C%C3%BFk%E5%011%C6-%F5%C8N%04%DF%BD%FF%89%DFt%83DN%60%3E%F3%AB%A0%DE%1A%5Dg%BE%10Q%97%1B%40%9C%A8o%10%8F%5E%828%B4%1B%60%87%F6%02%26%85%1Ch%1E%C1%2B%5Bk%FF%86%EE%B7j%09%9A%DA%9B%ACe%A3%F9%EC%DA!9%B4%D5%A6%81%86%86%98%CC%3C%5B%40%FA%81%B3%E9%CB%23%94%C16Azo%05%D4%E1%C1%95a%3B%8A'%A0%E8%CC%17%22%85%1D%BA%00%A2%FA%DC%0A%94%D1%D1%8D%8B%3A%84%17B%C7%60%1A%25Z%FC%8D%00%00%00%00IEND%AEB%60%82\"),\n" + + " url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%007%08%06%00%00%00%C4%DD%80C%00%00%03%1EiCCPICC%20Profile%00%00x%01%85T%DFk%D3P%14%FE%DAe%9D%B0%E1%8B%3Ag%11%09%3Eh%91ndStC%9C%B6kW%BA%CDZ%EA6%B7!H%9B%A6m%5C%9A%C6%24%ED~%B0%07%D9%8Bo%3A%C5w%F1%07%3E%F9%07%0C%D9%83o%7B%92%0D%C6%14a%F8%AC%88%22L%F6%22%B3%9E%9B4M'S%03%B9%F7%BB%DF%F9%EE9'%E7%E4%5E%A0%F9qZ%D3%14%2F%0F%14USO%C5%C2%FC%C4%E4%14%DF%F2%01%5E%1CC%2B%FChM%8B%86%16J%26G%40%0F%D3%B2y%EF%B3%F3%0E%1E%C6lt%EEo%DF%AB%FEc%D5%9A%95%0C%11%F0%1C%20%BE%945%C4%22%E1Y%A0i%5C%D4t%13%E0%D6%89%EF%9D15%C2%CDLsX%A7%04%09%1Fg8oc%81%E1%8C%8D%23%96f45%40%9A%09%C2%07%C5B%3AK%B8%408%98i%E0%F3%0D%D8%CE%81%14%E4'%26%A9%92.%8B%3C%ABER%2F%E5dE%B2%0C%F6%F0%1Fs%83%F2_%B0%A8%94%E9%9B%AD%E7%10%8Dm%9A%19N%D1%7C%8A%DE%1F9%7Dp%8C%E6%00%D5%C1%3F_%18%BDA%B8%9DpX6%E3%A35~B%CD%24%AE%11%26%BD%E7%EEti%98%EDe%9A%97Y)%12%25%1C%24%BCbT%AE3li%E6%0B%03%89%9A%E6%D3%ED%F4P%92%B0%9F4%BF43Y%F3%E3%EDP%95%04%EB1%C5%F5%F6KF%F4%BA%BD%D7%DB%91%93%07%E35%3E%A7)%D6%7F%40%FE%BD%F7%F5r%8A%E5y%92%F0%EB%B4%1E%8D%D5%F4%5B%92%3AV%DB%DB%E4%CD%A6%23%C3%C4wQ%3F%03HB%82%8E%1Cd(%E0%91B%0Ca%9Ac%C4%AA%F8L%16%19%22J%A4%D2itTy%B28%D6%3B(%93%96%ED%1CGx%C9_%0E%B8%5E%16%F5%5B%B2%B8%F6%E0%FB%9E%DD%25%D7%8E%BC%15%85%C5%B7%A3%D8Q%ED%B5%81%E9%BA%B2%13%9A%1B%7Fua%A5%A3n%E17%B9%E5%9B%1Bm%AB%0B%08Q%FE%8A%E5%B1H%5Ee%CAO%82Q%D7u6%E6%90S%97%FCu%0B%CF2%94%EE%25v%12X%0C%BA%AC%F0%5E%F8*l%0AO%85%17%C2%97%BF%D4%C8%CE%DE%AD%11%CB%80q%2C%3E%AB%9ES%CD%C6%EC%25%D2L%D2%EBd%B8%BF%8A%F5B%C6%18%F9%901CZ%9D%BE%24M%9C%8A9%F2%DAP%0B'%06w%82%EB%E6%E2%5C%2F%D7%07%9E%BB%CC%5D%E1%FA%B9%08%AD.r%23%8E%C2%17%F5E%7C!%F0%BE3%BE%3E_%B7o%88a%A7%DB%BE%D3d%EB%A31Z%EB%BB%D3%91%BA%A2%B1z%94%8F%DB'%F6%3D%8E%AA%13%19%B2%B1%BE%B1~V%08%2B%B4%A2cjJ%B3tO%00%03%25mN%97%F3%05%93%EF%11%84%0B%7C%88%AE-%89%8F%ABbW%90O%2B%0Ao%99%0C%5E%97%0CI%AFH%D9.%B0%3B%8F%ED%03%B6S%D6%5D%E6i_s9%F3*p%E9%1B%FD%C3%EB.7U%06%5E%19%C0%D1s.%17%A03u%E4%09%B0%7C%5E%2C%EB%15%DB%1F%3C%9E%B7%80%91%3B%DBc%AD%3Dma%BA%8B%3EV%AB%DBt.%5B%1E%01%BB%0F%AB%D5%9F%CF%AA%D5%DD%E7%E4%7F%0Bx%A3%FC%06%A9%23%0A%D6%C2%A1_2%00%00%00%09pHYs%00%00%0B%13%00%00%0B%13%01%00%9A%9C%18%00%00%003IDAT8%11c%FC%FF%FF%7F%3E%03%1A%60%01%F2%3F%A3%891%80%04%FFQ%26%F8w%C0%B43%A1%DB%0C%E2%8F%0A%A2%85%CAh%80%8C%06%08%3C%04%E8%96%18%00%A3S%0D%CD%CF%D8%C1%9D%00%00%00%00IEND%AEB%60%82\");\n" + + " background-repeat: no-repeat, repeat-x;\n" + + " background-position: center center, top left;\n" + + "}\n" + + "\n" + + ".ace_dragging .ace_content {\n" + + " cursor: move;\n" + + "}\n" + + "\n" + + ".ace_gutter_tooltip {\n" + + " background-color: #FFFFD5;\n" + + " border: 1px solid gray;\n" + + " box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);\n" + + " color: black;\n" + + " display: inline-block;\n" + + " padding: 4px;\n" + + " position: absolute;\n" + + " z-index: 300;\n" + + " box-sizing: border-box;\n" + + " -moz-box-sizing: border-box;\n" + + " -webkit-box-sizing: border-box;\n" + + " cursor: default;\n" + + "}\n" + + "\n" + + ".ace_folding-enabled > .ace_gutter-cell {\n" + + " padding-right: 13px;\n" + + "}\n" + + "\n" + + ".ace_fold-widget {\n" + + " box-sizing: border-box;\n" + + " -moz-box-sizing: border-box;\n" + + " -webkit-box-sizing: border-box;\n" + + "\n" + + " margin: 0 -12px 0 1px;\n" + + " display: inline-block;\n" + + " width: 11px;\n" + + " vertical-align: top;\n" + + "\n" + + " background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAe%8A%B1%0D%000%0C%C2%F2%2CK%96%BC%D0%8F9%81%88H%E9%D0%0E%96%C0%10%92%3E%02%80%5E%82%E4%A9*-%EEsw%C8%CC%11%EE%96w%D8%DC%E9*Eh%0C%151(%00%00%00%00IEND%AEB%60%82\");\n" + + " background-repeat: no-repeat;\n" + + " background-position: center;\n" + + "\n" + + " border-radius: 3px;\n" + + " \n" + + " border: 1px solid transparent;\n" + + "}\n" + + "\n" + + ".ace_fold-widget.end {\n" + + " background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAm%C7%C1%09%000%08C%D1%8C%ECE%C8E(%8E%EC%02)%1EZJ%F1%C1'%04%07I%E1%E5%EE%CAL%F5%A2%99%99%22%E2%D6%1FU%B5%FE0%D9x%A7%26Wz5%0E%D5%00%00%00%00IEND%AEB%60%82\");\n" + + "}\n" + + "\n" + + ".ace_fold-widget.closed {\n" + + " background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%03%00%00%00%06%08%06%00%00%00%06%E5%24%0C%00%00%009IDATx%DA5%CA%C1%09%000%08%03%C0%AC*(%3E%04%C1%0D%BA%B1%23%A4Uh%E0%20%81%C0%CC%F8%82%81%AA%A2%AArGfr%88%08%11%11%1C%DD%7D%E0%EE%5B%F6%F6%CB%B8%05Q%2F%E9tai%D9%00%00%00%00IEND%AEB%60%82\");\n" + + "}\n" + + "\n" + + ".ace_fold-widget:hover {\n" + + " border: 1px solid rgba(0, 0, 0, 0.3);\n" + + " background-color: rgba(255, 255, 255, 0.2);\n" + + " -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n" + + " -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n" + + " box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n" + + "}\n" + + "\n" + + ".ace_fold-widget:active {\n" + + " border: 1px solid rgba(0, 0, 0, 0.4);\n" + + " background-color: rgba(0, 0, 0, 0.05);\n" + + " -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n" + + " -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n" + + " box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n" + + "}\n" + + "/**\n" + + " * Dark version for fold widgets\n" + + " */\n" + + ".ace_dark .ace_fold-widget {\n" + + " background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\n" + + "}\n" + + ".ace_dark .ace_fold-widget.end {\n" + + " background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\n" + + "}\n" + + ".ace_dark .ace_fold-widget.closed {\n" + + " background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\n" + + "}\n" + + ".ace_dark .ace_fold-widget:hover {\n" + + " box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n" + + " background-color: rgba(255, 255, 255, 0.1);\n" + + "}\n" + + ".ace_dark .ace_fold-widget:active {\n" + + " -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n" + + " -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n" + + " box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n" + + "}\n" + + " \n" + + " \n" + + " \n" + + ".ace_fold-widget.invalid {\n" + + " background-color: #FFB4B4;\n" + + " border-color: #DE5555;\n" + + "}\n" + + "\n" + + ".ace_fade-fold-widgets .ace_fold-widget {\n" + + " -moz-transition: opacity 0.4s ease 0.05s;\n" + + " -webkit-transition: opacity 0.4s ease 0.05s;\n" + + " -o-transition: opacity 0.4s ease 0.05s;\n" + + " -ms-transition: opacity 0.4s ease 0.05s;\n" + + " transition: opacity 0.4s ease 0.05s;\n" + + " opacity: 0;\n" + + "}\n" + + "\n" + + ".ace_fade-fold-widgets:hover .ace_fold-widget {\n" + + " -moz-transition: opacity 0.05s ease 0.05s;\n" + + " -webkit-transition: opacity 0.05s ease 0.05s;\n" + + " -o-transition: opacity 0.05s ease 0.05s;\n" + + " -ms-transition: opacity 0.05s ease 0.05s;\n" + + " transition: opacity 0.05s ease 0.05s;\n" + + " opacity:1;\n" + + "}\n" + + "\n" + + ".ace_underline {\n" + + " text-decoration: underline;\n" + + "}\n" + + "\n" + + ".ace_bold {\n" + + " font-weight: bold;\n" + + "}\n" + + "\n" + + ".ace_italic {\n" + + " font-style: italic;\n" + + "}\n" + + ""); + +ace.define('ace/multi_select', ['require', 'exports', 'module' , 'ace/range_list', 'ace/range', 'ace/selection', 'ace/mouse/multi_select_handler', 'ace/lib/event', 'ace/lib/lang', 'ace/commands/multi_select_commands', 'ace/search', 'ace/edit_session', 'ace/editor'], function(require, exports, module) { + +var RangeList = require("./range_list").RangeList; +var Range = require("./range").Range; +var Selection = require("./selection").Selection; +var onMouseDown = require("./mouse/multi_select_handler").onMouseDown; +var event = require("./lib/event"); +var lang = require("./lib/lang"); +var commands = require("./commands/multi_select_commands"); +exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands); + +// Todo: session.find or editor.findVolatile that returns range +var Search = require("./search").Search; +var search = new Search(); + +function find(session, needle, dir) { + search.$options.wrap = true; + search.$options.needle = needle; + search.$options.backwards = dir == -1; + return search.find(session); +} + +// extend EditSession +var EditSession = require("./edit_session").EditSession; +(function() { + this.getSelectionMarkers = function() { + return this.$selectionMarkers; + }; +}).call(EditSession.prototype); + +// extend Selection +(function() { + // list of ranges in reverse addition order + this.ranges = null; + + // automatically sorted list of ranges + this.rangeList = null; + this.addRange = function(range, $blockChangeEvents) { + if (!range) + return; + + if (!this.inMultiSelectMode && this.rangeCount == 0) { + var oldRange = this.toOrientedRange(); + if (range.intersects(oldRange)) + return $blockChangeEvents || this.fromOrientedRange(range); + + this.rangeList.add(oldRange); + this.$onAddRange(oldRange); + } + + if (!range.cursor) + range.cursor = range.end; + + var removed = this.rangeList.add(range); + + this.$onAddRange(range); + + if (removed.length) + this.$onRemoveRange(removed); + + if (this.rangeCount > 1 && !this.inMultiSelectMode) { + this._emit("multiSelect"); + this.inMultiSelectMode = true; + this.session.$undoSelect = false; + this.rangeList.attach(this.session); + } + + return $blockChangeEvents || this.fromOrientedRange(range); + }; + + this.toSingleRange = function(range) { + range = range || this.ranges[0]; + var removed = this.rangeList.removeAll(); + if (removed.length) + this.$onRemoveRange(removed); + + range && this.fromOrientedRange(range); + }; + this.substractPoint = function(pos) { + var removed = this.rangeList.substractPoint(pos); + if (removed) { + this.$onRemoveRange(removed); + return removed[0]; + } + }; + this.mergeOverlappingRanges = function() { + var removed = this.rangeList.merge(); + if (removed.length) + this.$onRemoveRange(removed); + else if(this.ranges[0]) + this.fromOrientedRange(this.ranges[0]); + }; + + this.$onAddRange = function(range) { + this.rangeCount = this.rangeList.ranges.length; + this.ranges.unshift(range); + this._emit("addRange", {range: range}); + }; + + this.$onRemoveRange = function(removed) { + this.rangeCount = this.rangeList.ranges.length; + if (this.rangeCount == 1 && this.inMultiSelectMode) { + var lastRange = this.rangeList.ranges.pop(); + removed.push(lastRange); + this.rangeCount = 0; + } + + for (var i = removed.length; i--; ) { + var index = this.ranges.indexOf(removed[i]); + this.ranges.splice(index, 1); + } + + this._emit("removeRange", {ranges: removed}); + + if (this.rangeCount == 0 && this.inMultiSelectMode) { + this.inMultiSelectMode = false; + this._emit("singleSelect"); + this.session.$undoSelect = true; + this.rangeList.detach(this.session); + } + + lastRange = lastRange || this.ranges[0]; + if (lastRange && !lastRange.isEqual(this.getRange())) + this.fromOrientedRange(lastRange); + }; + + // adds multicursor support to selection + this.$initRangeList = function() { + if (this.rangeList) + return; + + this.rangeList = new RangeList(); + this.ranges = []; + this.rangeCount = 0; + }; + + this.getAllRanges = function() { + return this.rangeList.ranges.concat(); + }; + + this.splitIntoLines = function () { + if (this.rangeCount > 1) { + var ranges = this.rangeList.ranges; + var lastRange = ranges[ranges.length - 1]; + var range = Range.fromPoints(ranges[0].start, lastRange.end); + + this.toSingleRange(); + this.setSelectionRange(range, lastRange.cursor == lastRange.start); + } else { + var range = this.getRange(); + var isBackwards = this.isBackwards(); + var startRow = range.start.row; + var endRow = range.end.row; + if (startRow == endRow) { + if (isBackwards) + var start = range.end, end = range.start; + else + var start = range.start, end = range.end; + + this.addRange(Range.fromPoints(end, end)); + this.addRange(Range.fromPoints(start, start)); + return; + } + + var rectSel = []; + var r = this.getLineRange(startRow, true); + r.start.column = range.start.column; + rectSel.push(r); + + for (var i = startRow + 1; i < endRow; i++) + rectSel.push(this.getLineRange(i, true)); + + r = this.getLineRange(endRow, true); + r.end.column = range.end.column; + rectSel.push(r); + + rectSel.forEach(this.addRange, this); + } + }; + + this.toggleBlockSelection = function () { + if (this.rangeCount > 1) { + var ranges = this.rangeList.ranges; + var lastRange = ranges[ranges.length - 1]; + var range = Range.fromPoints(ranges[0].start, lastRange.end); + + this.toSingleRange(); + this.setSelectionRange(range, lastRange.cursor == lastRange.start); + } else { + var cursor = this.session.documentToScreenPosition(this.selectionLead); + var anchor = this.session.documentToScreenPosition(this.selectionAnchor); + + var rectSel = this.rectangularRangeBlock(cursor, anchor); + rectSel.forEach(this.addRange, this); + } + }; + this.rectangularRangeBlock = function(screenCursor, screenAnchor, includeEmptyLines) { + var rectSel = []; + + var xBackwards = screenCursor.column < screenAnchor.column; + if (xBackwards) { + var startColumn = screenCursor.column; + var endColumn = screenAnchor.column; + } else { + var startColumn = screenAnchor.column; + var endColumn = screenCursor.column; + } + + var yBackwards = screenCursor.row < screenAnchor.row; + if (yBackwards) { + var startRow = screenCursor.row; + var endRow = screenAnchor.row; + } else { + var startRow = screenAnchor.row; + var endRow = screenCursor.row; + } + + if (startColumn < 0) + startColumn = 0; + if (startRow < 0) + startRow = 0; + + if (startRow == endRow) + includeEmptyLines = true; + + for (var row = startRow; row <= endRow; row++) { + var range = Range.fromPoints( + this.session.screenToDocumentPosition(row, startColumn), + this.session.screenToDocumentPosition(row, endColumn) + ); + if (range.isEmpty()) { + if (docEnd && isSamePoint(range.end, docEnd)) + break; + var docEnd = range.end; + } + range.cursor = xBackwards ? range.start : range.end; + rectSel.push(range); + } + + if (yBackwards) + rectSel.reverse(); + + if (!includeEmptyLines) { + var end = rectSel.length - 1; + while (rectSel[end].isEmpty() && end > 0) + end--; + if (end > 0) { + var start = 0; + while (rectSel[start].isEmpty()) + start++; + } + for (var i = end; i >= start; i--) { + if (rectSel[i].isEmpty()) + rectSel.splice(i, 1); + } + } + + return rectSel; + }; +}).call(Selection.prototype); + +// extend Editor +var Editor = require("./editor").Editor; +(function() { + + /** extension + * Editor.updateSelectionMarkers() + * + * Updates the cursor and marker layers. + **/ + this.updateSelectionMarkers = function() { + this.renderer.updateCursor(); + this.renderer.updateBackMarkers(); + }; + this.addSelectionMarker = function(orientedRange) { + if (!orientedRange.cursor) + orientedRange.cursor = orientedRange.end; + + var style = this.getSelectionStyle(); + orientedRange.marker = this.session.addMarker(orientedRange, "ace_selection", style); + + this.session.$selectionMarkers.push(orientedRange); + this.session.selectionMarkerCount = this.session.$selectionMarkers.length; + return orientedRange; + }; + this.removeSelectionMarker = function(range) { + if (!range.marker) + return; + this.session.removeMarker(range.marker); + var index = this.session.$selectionMarkers.indexOf(range); + if (index != -1) + this.session.$selectionMarkers.splice(index, 1); + this.session.selectionMarkerCount = this.session.$selectionMarkers.length; + }; + + this.removeSelectionMarkers = function(ranges) { + var markerList = this.session.$selectionMarkers; + for (var i = ranges.length; i--; ) { + var range = ranges[i]; + if (!range.marker) + continue; + this.session.removeMarker(range.marker); + var index = markerList.indexOf(range); + if (index != -1) + markerList.splice(index, 1); + } + this.session.selectionMarkerCount = markerList.length; + }; + + this.$onAddRange = function(e) { + this.addSelectionMarker(e.range); + this.renderer.updateCursor(); + this.renderer.updateBackMarkers(); + }; + + this.$onRemoveRange = function(e) { + this.removeSelectionMarkers(e.ranges); + this.renderer.updateCursor(); + this.renderer.updateBackMarkers(); + }; + + this.$onMultiSelect = function(e) { + if (this.inMultiSelectMode) + return; + this.inMultiSelectMode = true; + + this.setStyle("multiselect"); + this.keyBinding.addKeyboardHandler(commands.keyboardHandler); + this.commands.on("exec", this.$onMultiSelectExec); + + this.renderer.updateCursor(); + this.renderer.updateBackMarkers(); + }; + + this.$onSingleSelect = function(e) { + if (this.session.multiSelect.inVirtualMode) + return; + this.inMultiSelectMode = false; + + this.unsetStyle("multiselect"); + this.keyBinding.removeKeyboardHandler(commands.keyboardHandler); + + this.commands.removeEventListener("exec", this.$onMultiSelectExec); + this.renderer.updateCursor(); + this.renderer.updateBackMarkers(); + }; + + this.$onMultiSelectExec = function(e) { + var command = e.command; + var editor = e.editor; + if (!editor.multiSelect) + return; + if (!command.multiSelectAction) { + command.exec(editor, e.args || {}); + editor.multiSelect.addRange(editor.multiSelect.toOrientedRange()); + editor.multiSelect.mergeOverlappingRanges(); + } else if (command.multiSelectAction == "forEach") { + editor.forEachSelection(command, e.args); + } else if (command.multiSelectAction == "single") { + editor.exitMultiSelectMode(); + command.exec(editor, e.args || {}); + } else { + command.multiSelectAction(editor, e.args || {}); + } + e.preventDefault(); + }; + this.forEachSelection = function(cmd, args) { + if (this.inVirtualSelectionMode) + return; + + var session = this.session; + var selection = this.selection; + var rangeList = selection.rangeList; + + var reg = selection._eventRegistry; + selection._eventRegistry = {}; + + var tmpSel = new Selection(session); + this.inVirtualSelectionMode = true; + for (var i = rangeList.ranges.length; i--;) { + tmpSel.fromOrientedRange(rangeList.ranges[i]); + this.selection = session.selection = tmpSel; + cmd.exec(this, args || {}); + tmpSel.toOrientedRange(rangeList.ranges[i]); + } + tmpSel.detach(); + + this.selection = session.selection = selection; + this.inVirtualSelectionMode = false; + selection._eventRegistry = reg; + selection.mergeOverlappingRanges(); + + this.onCursorChange(); + this.onSelectionChange(); + }; + this.exitMultiSelectMode = function() { + if (this.inVirtualSelectionMode) + return; + this.multiSelect.toSingleRange(); + }; + + this.getCopyText = function() { + var text = ""; + if (this.inMultiSelectMode) { + var ranges = this.multiSelect.rangeList.ranges; + text = []; + for (var i = 0; i < ranges.length; i++) { + text.push(this.session.getTextRange(ranges[i])); + } + text = text.join(this.session.getDocument().getNewLineCharacter()); + } else if (!this.selection.isEmpty()) { + text = this.session.getTextRange(this.getSelectionRange()); + } + + return text; + }; + + // todo this should change when paste becomes a command + this.onPaste = function(text) { + if (this.$readOnly) + return; + + this._emit("paste", text); + if (!this.inMultiSelectMode) + return this.insert(text); + + var lines = text.split(/\r\n|\r|\n/); + var ranges = this.selection.rangeList.ranges; + + if (lines.length > ranges.length || (lines.length <= 2 || !lines[1])) + return this.commands.exec("insertstring", this, text); + + for (var i = ranges.length; i--; ) { + var range = ranges[i]; + if (!range.isEmpty()) + this.session.remove(range); + + this.session.insert(range.start, lines[i]); + } + }; + this.findAll = function(needle, options, additive) { + options = options || {}; + options.needle = needle || options.needle; + this.$search.set(options); + + var ranges = this.$search.findAll(this.session); + if (!ranges.length) + return 0; + + this.$blockScrolling += 1; + var selection = this.multiSelect; + + if (!additive) + selection.toSingleRange(ranges[0]); + + for (var i = ranges.length; i--; ) + selection.addRange(ranges[i], true); + + this.$blockScrolling -= 1; + + return ranges.length; + }; + + // commands + /** extension + * Editor.selectMoreLines(dir, skip) + * - dir (Number): The direction of lines to select: -1 for up, 1 for down + * - skip (Boolean): If `true`, removes the active selection range + * + * Adds a cursor above or below the active cursor. + **/ + this.selectMoreLines = function(dir, skip) { + var range = this.selection.toOrientedRange(); + var isBackwards = range.cursor == range.end; + + var screenLead = this.session.documentToScreenPosition(range.cursor); + if (this.selection.$desiredColumn) + screenLead.column = this.selection.$desiredColumn; + + var lead = this.session.screenToDocumentPosition(screenLead.row + dir, screenLead.column); + + if (!range.isEmpty()) { + var screenAnchor = this.session.documentToScreenPosition(isBackwards ? range.end : range.start); + var anchor = this.session.screenToDocumentPosition(screenAnchor.row + dir, screenAnchor.column); + } else { + var anchor = lead; + } + + if (isBackwards) { + var newRange = Range.fromPoints(lead, anchor); + newRange.cursor = newRange.start; + } else { + var newRange = Range.fromPoints(anchor, lead); + newRange.cursor = newRange.end; + } + + newRange.desiredColumn = screenLead.column; + if (!this.selection.inMultiSelectMode) { + this.selection.addRange(range); + } else { + if (skip) + var toRemove = range.cursor; + } + + this.selection.addRange(newRange); + if (toRemove) + this.selection.substractPoint(toRemove); + }; + this.transposeSelections = function(dir) { + var session = this.session; + var sel = session.multiSelect; + var all = sel.ranges; + + for (var i = all.length; i--; ) { + var range = all[i]; + if (range.isEmpty()) { + var tmp = session.getWordRange(range.start.row, range.start.column); + range.start.row = tmp.start.row; + range.start.column = tmp.start.column; + range.end.row = tmp.end.row; + range.end.column = tmp.end.column; + } + } + sel.mergeOverlappingRanges(); + + var words = []; + for (var i = all.length; i--; ) { + var range = all[i]; + words.unshift(session.getTextRange(range)); + } + + if (dir < 0) + words.unshift(words.pop()); + else + words.push(words.shift()); + + for (var i = all.length; i--; ) { + var range = all[i]; + var tmp = range.clone(); + session.replace(range, words[i]); + range.start.row = tmp.start.row; + range.start.column = tmp.start.column; + } + } + + /** extension + * Editor.selectMore(dir, skip) + * - dir (Number): The direction of lines to select: -1 for up, 1 for down + * - skip (Boolean): If `true`, removes the active selection range + * + * Finds the next occurence of text in an active selection and adds it to the selections. + **/ + this.selectMore = function(dir, skip) { + var session = this.session; + var sel = session.multiSelect; + + var range = sel.toOrientedRange(); + if (range.isEmpty()) { + var range = session.getWordRange(range.start.row, range.start.column); + range.cursor = range.end; + this.multiSelect.addRange(range); + } + var needle = session.getTextRange(range); + + var newRange = find(session, needle, dir); + if (newRange) { + newRange.cursor = dir == -1 ? newRange.start : newRange.end; + this.multiSelect.addRange(newRange); + } + if (skip) + this.multiSelect.substractPoint(range.cursor); + }; + this.alignCursors = function() { + var session = this.session; + var sel = session.multiSelect; + var ranges = sel.ranges; + + if (!ranges.length) { + var range = this.selection.getRange(); + var fr = range.start.row, lr = range.end.row; + var lines = this.session.doc.removeLines(fr, lr); + lines = this.$reAlignText(lines); + this.session.doc.insertLines(fr, lines); + range.start.column = 0; + range.end.column = lines[lines.length - 1].length; + this.selection.setRange(range); + } else { + // filter out ranges on same row + var row = -1; + var sameRowRanges = ranges.filter(function(r) { + if (r.cursor.row == row) + return true; + row = r.cursor.row; + }); + sel.$onRemoveRange(sameRowRanges); + + var maxCol = 0; + var minSpace = Infinity; + var spaceOffsets = ranges.map(function(r) { + var p = r.cursor; + var line = session.getLine(p.row); + var spaceOffset = line.substr(p.column).search(/\S/g); + if (spaceOffset == -1) + spaceOffset = 0; + + if (p.column > maxCol) + maxCol = p.column; + if (spaceOffset < minSpace) + minSpace = spaceOffset; + return spaceOffset; + }); + ranges.forEach(function(r, i) { + var p = r.cursor; + var l = maxCol - p.column; + var d = spaceOffsets[i] - minSpace; + if (l > d) + session.insert(p, lang.stringRepeat(" ", l - d)); + else + session.remove(new Range(p.row, p.column, p.row, p.column - l + d)); + + r.start.column = r.end.column = maxCol; + r.start.row = r.end.row = p.row; + r.cursor = r.end; + }); + sel.fromOrientedRange(ranges[0]); + this.renderer.updateCursor(); + this.renderer.updateBackMarkers(); + } + }; + + this.$reAlignText = function(lines) { + var isLeftAligned = true, isRightAligned = true; + var startW, textW, endW; + + return lines.map(function(line) { + var m = line.match(/(\s*)(.*?)(\s*)([=:].*)/); + if (!m) + return [line]; + + if (startW == null) { + startW = m[1].length; + textW = m[2].length; + endW = m[3].length; + return m; + } + + if (startW + textW + endW != m[1].length + m[2].length + m[3].length) + isRightAligned = false; + if (startW != m[1].length) + isLeftAligned = false; + + if (startW > m[1].length) + startW = m[1].length; + if (textW < m[2].length) + textW = m[2].length; + if (endW > m[3].length) + endW = m[3].length; + + return m; + }).map(isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign); + + function strRepeat(n, ch) { + return Array(n + 1).join(ch) + } + + function alignLeft(m) { + return !m[2] ? m[0] : strRepeat(startW, " ") + m[2] + + strRepeat(textW - m[2].length + endW, " ") + + m[4].replace(/^([=:])\s+/, "$1 ") + } + function alignRight(m) { + return !m[2] ? m[0] : strRepeat(startW + textW - m[2].length, " ") + m[2] + + strRepeat(endW, " ") + + m[4].replace(/^([=:])\s+/, "$1 ") + } + function unAlign(m) { + return !m[2] ? m[0] : strRepeat(startW, " ") + m[2] + + strRepeat(endW, " ") + + m[4].replace(/^([=:])\s+/, "$1 ") + } + } +}).call(Editor.prototype); + + +function isSamePoint(p1, p2) { + return p1.row == p2.row && p1.column == p2.column; +} + +// patch +// adds multicursor support to a session +exports.onSessionChange = function(e) { + var session = e.session; + if (!session.multiSelect) { + session.$selectionMarkers = []; + session.selection.$initRangeList(); + session.multiSelect = session.selection; + } + this.multiSelect = session.multiSelect; + + var oldSession = e.oldSession; + if (oldSession) { + // todo use events + if (oldSession.multiSelect && oldSession.multiSelect.editor == this) + oldSession.multiSelect.editor = null; + + session.multiSelect.removeEventListener("addRange", this.$onAddRange); + session.multiSelect.removeEventListener("removeRange", this.$onRemoveRange); + session.multiSelect.removeEventListener("multiSelect", this.$onMultiSelect); + session.multiSelect.removeEventListener("singleSelect", this.$onSingleSelect); + } + + session.multiSelect.on("addRange", this.$onAddRange); + session.multiSelect.on("removeRange", this.$onRemoveRange); + session.multiSelect.on("multiSelect", this.$onMultiSelect); + session.multiSelect.on("singleSelect", this.$onSingleSelect); + + // this.$onSelectionChange = this.onSelectionChange.bind(this); + + if (this.inMultiSelectMode != session.selection.inMultiSelectMode) { + if (session.selection.inMultiSelectMode) + this.$onMultiSelect(); + else + this.$onSingleSelect(); + } +}; + +// MultiSelect(editor) +// adds multiple selection support to the editor +// (note: should be called only once for each editor instance) +function MultiSelect(editor) { + editor.$onAddRange = editor.$onAddRange.bind(editor); + editor.$onRemoveRange = editor.$onRemoveRange.bind(editor); + editor.$onMultiSelect = editor.$onMultiSelect.bind(editor); + editor.$onSingleSelect = editor.$onSingleSelect.bind(editor); + + exports.onSessionChange.call(editor, editor); + editor.on("changeSession", exports.onSessionChange.bind(editor)); + + editor.on("mousedown", onMouseDown); + editor.commands.addCommands(commands.defaultCommands); + + addAltCursorListeners(editor); +} + +function addAltCursorListeners(editor){ + var el = editor.textInput.getElement(); + var altCursor = false; + var contentEl = editor.renderer.content; + event.addListener(el, "keydown", function(e) { + if (e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey)) { + if (!altCursor) { + contentEl.style.cursor = "crosshair"; + altCursor = true; + } + } else if (altCursor) { + contentEl.style.cursor = ""; + } + }); + + event.addListener(el, "keyup", reset); + event.addListener(el, "blur", reset); + function reset() { + if (altCursor) { + contentEl.style.cursor = ""; + altCursor = false; + } + } +} + +exports.MultiSelect = MultiSelect; + +}); + +ace.define('ace/range_list', ['require', 'exports', 'module' ], function(require, exports, module) { + + + +var RangeList = function() { + this.ranges = []; +}; + +(function() { + this.comparePoints = function(p1, p2) { + return p1.row - p2.row || p1.column - p2.column; + }; + + this.pointIndex = function(pos, startIndex) { + var list = this.ranges; + + for (var i = startIndex || 0; i < list.length; i++) { + var range = list[i]; + var cmp = this.comparePoints(pos, range.end); + + if (cmp > 0) + continue; + if (cmp == 0) + return i; + cmp = this.comparePoints(pos, range.start); + if (cmp >= 0) + return i; + + return -i-1; + } + return -i - 1; + }; + + this.add = function(range) { + var startIndex = this.pointIndex(range.start); + if (startIndex < 0) + startIndex = -startIndex - 1; + + var endIndex = this.pointIndex(range.end, startIndex); + + if (endIndex < 0) + endIndex = -endIndex - 1; + else + endIndex++; + + return this.ranges.splice(startIndex, endIndex - startIndex, range); + }; + + this.addList = function(list) { + var removed = []; + for (var i = list.length; i--; ) { + removed.push.call(removed, this.add(list[i])); + } + return removed; + }; + + this.substractPoint = function(pos) { + var i = this.pointIndex(pos); + + if (i >= 0) + return this.ranges.splice(i, 1); + }; + + // merge overlapping ranges + this.merge = function() { + var removed = []; + var list = this.ranges; + var next = list[0], range; + for (var i = 1; i < list.length; i++) { + range = next; + next = list[i]; + var cmp = this.comparePoints(range.end, next.start); + if (cmp < 0) + continue; + + if (cmp == 0 && !(range.isEmpty() || next.isEmpty())) + continue; + + if (this.comparePoints(range.end, next.end) < 0) { + range.end.row = next.end.row; + range.end.column = next.end.column; + } + + list.splice(i, 1); + removed.push(next); + next = range; + i--; + } + + return removed; + }; + + this.contains = function(row, column) { + return this.pointIndex({row: row, column: column}) >= 0; + }; + + this.containsPoint = function(pos) { + return this.pointIndex(pos) >= 0; + }; + + this.rangeAtPoint = function(pos) { + var i = this.pointIndex(pos); + if (i >= 0) + return this.ranges[i]; + }; + + + this.clipRows = function(startRow, endRow) { + var list = this.ranges; + if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow) + return []; + + var startIndex = this.pointIndex({row: startRow, column: 0}); + if (startIndex < 0) + startIndex = -startIndex - 1; + var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex); + if (endIndex < 0) + endIndex = -endIndex - 1; + + var clipped = []; + for (var i = startIndex; i < endIndex; i++) { + clipped.push(list[i]); + } + return clipped; + }; + + this.removeAll = function() { + return this.ranges.splice(0, this.ranges.length); + }; + + this.attach = function(session) { + if (this.session) + this.detach(); + + this.session = session; + this.onChange = this.$onChange.bind(this); + + this.session.on('change', this.onChange); + }; + + this.detach = function() { + if (!this.session) + return; + this.session.removeListener('change', this.onChange); + this.session = null; + }; + + this.$onChange = function(e) { + var changeRange = e.data.range; + if (e.data.action[0] == "i"){ + var start = changeRange.start; + var end = changeRange.end; + } else { + var end = changeRange.start; + var start = changeRange.end; + } + var startRow = start.row; + var endRow = end.row; + var lineDif = endRow - startRow; + + var colDiff = -start.column + end.column; + var ranges = this.ranges; + + for (var i = 0, n = ranges.length; i < n; i++) { + var r = ranges[i]; + if (r.end.row < startRow) + continue; + if (r.start.row > startRow) + break; + + if (r.start.row == startRow && r.start.column >= start.column ) { + r.start.column += colDiff; + r.start.row += lineDif; + } + if (r.end.row == startRow && r.end.column >= start.column) { + r.end.column += colDiff; + r.end.row += lineDif; + } + } + + if (lineDif != 0 && i < n) { + for (; i < n; i++) { + var r = ranges[i]; + r.start.row += lineDif; + r.end.row += lineDif; + } + } + }; + +}).call(RangeList.prototype); + +exports.RangeList = RangeList; +}); + +ace.define('ace/mouse/multi_select_handler', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) { + +var event = require("../lib/event"); + + +// mouse +function isSamePoint(p1, p2) { + return p1.row == p2.row && p1.column == p2.column; +} + +function onMouseDown(e) { + var ev = e.domEvent; + var alt = ev.altKey; + var shift = ev.shiftKey; + var ctrl = e.getAccelKey(); + var button = e.getButton(); + + if (e.editor.inMultiSelectMode && button == 2) { + e.editor.textInput.onContextMenu(e.domEvent); + return; + } + + if (!ctrl && !alt) { + if (button == 0 && e.editor.inMultiSelectMode) + e.editor.exitMultiSelectMode(); + return; + } + + var editor = e.editor; + var selection = editor.selection; + var isMultiSelect = editor.inMultiSelectMode; + var pos = e.getDocumentPosition(); + var cursor = selection.getCursor(); + var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor)); + + + var mouseX = e.x, mouseY = e.y; + var onMouseSelection = function(e) { + mouseX = e.clientX; + mouseY = e.clientY; + }; + + var blockSelect = function() { + var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY); + var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column); + + if (isSamePoint(screenCursor, newCursor) + && isSamePoint(cursor, selection.selectionLead)) + return; + screenCursor = newCursor; + + editor.selection.moveCursorToPosition(cursor); + editor.selection.clearSelection(); + editor.renderer.scrollCursorIntoView(); + + editor.removeSelectionMarkers(rectSel); + rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor); + rectSel.forEach(editor.addSelectionMarker, editor); + editor.updateSelectionMarkers(); + }; + + var session = editor.session; + var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY); + var screenCursor = screenAnchor; + + + + if (ctrl && !shift && !alt && button == 0) { + if (!isMultiSelect && inSelection) + return; // dragging + + if (!isMultiSelect) { + var range = selection.toOrientedRange(); + editor.addSelectionMarker(range); + } + + var oldRange = selection.rangeList.rangeAtPoint(pos); + + event.capture(editor.container, function(){}, function() { + var tmpSel = selection.toOrientedRange(); + + if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor)) + selection.substractPoint(tmpSel.cursor); + else { + if (range) { + editor.removeSelectionMarker(range); + selection.addRange(range); + } + selection.addRange(tmpSel); + } + }); + + } else if (!shift && alt && button == 0) { + e.stop(); + + if (isMultiSelect && !ctrl) + selection.toSingleRange(); + else if (!isMultiSelect && ctrl) + selection.addRange(); + + selection.moveCursorToPosition(pos); + selection.clearSelection(); + + var rectSel = []; + + var onMouseSelectionEnd = function(e) { + clearInterval(timerId); + editor.removeSelectionMarkers(rectSel); + for (var i = 0; i < rectSel.length; i++) + selection.addRange(rectSel[i]); + }; + + var onSelectionInterval = blockSelect; + + event.capture(editor.container, onMouseSelection, onMouseSelectionEnd); + var timerId = setInterval(function() {onSelectionInterval();}, 20); + + return e.preventDefault(); + } +} + + +exports.onMouseDown = onMouseDown; + +}); + +ace.define('ace/commands/multi_select_commands', ['require', 'exports', 'module' , 'ace/keyboard/hash_handler'], function(require, exports, module) { + +// commands to enter multiselect mode +exports.defaultCommands = [{ + name: "addCursorAbove", + exec: function(editor) { editor.selectMoreLines(-1); }, + bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"}, + readonly: true +}, { + name: "addCursorBelow", + exec: function(editor) { editor.selectMoreLines(1); }, + bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"}, + readonly: true +}, { + name: "addCursorAboveSkipCurrent", + exec: function(editor) { editor.selectMoreLines(-1, true); }, + bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"}, + readonly: true +}, { + name: "addCursorBelowSkipCurrent", + exec: function(editor) { editor.selectMoreLines(1, true); }, + bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"}, + readonly: true +}, { + name: "selectMoreBefore", + exec: function(editor) { editor.selectMore(-1); }, + bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"}, + readonly: true +}, { + name: "selectMoreAfter", + exec: function(editor) { editor.selectMore(1); }, + bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"}, + readonly: true +}, { + name: "selectNextBefore", + exec: function(editor) { editor.selectMore(-1, true); }, + bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"}, + readonly: true +}, { + name: "selectNextAfter", + exec: function(editor) { editor.selectMore(1, true); }, + bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"}, + readonly: true +}, { + name: "splitIntoLines", + exec: function(editor) { editor.multiSelect.splitIntoLines(); }, + bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"}, + readonly: true +}, { + name: "alignCursors", + exec: function(editor) { editor.alignCursors(); }, + bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"} +}]; + +// commands active only in multiselect mode +exports.multiSelectCommands = [{ + name: "singleSelection", + bindKey: "esc", + exec: function(editor) { editor.exitMultiSelectMode(); }, + readonly: true, + isAvailable: function(editor) {return editor && editor.inMultiSelectMode} +}]; + +var HashHandler = require("../keyboard/hash_handler").HashHandler; +exports.keyboardHandler = new HashHandler(exports.multiSelectCommands); + +}); + +ace.define('ace/worker/worker_client', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/config'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var EventEmitter = require("../lib/event_emitter").EventEmitter; +var config = require("../config"); + +var WorkerClient = function(topLevelNamespaces, mod, classname) { + + this.changeListener = this.changeListener.bind(this); + + if (config.get("packaged")) { + this.$worker = new Worker(config.moduleUrl(mod, "worker")); + } + else { + var workerUrl; + if (typeof require.supports !== "undefined" && require.supports.indexOf("ucjs2-pinf-0") >= 0) { + // We are running in the sourcemint loader. + workerUrl = require.nameToUrl("ace/worker/worker_sourcemint"); + } else { + // We are running in RequireJS. + // nameToUrl is renamed to toUrl in requirejs 2 + if (require.nameToUrl && !require.toUrl) + require.toUrl = require.nameToUrl; + workerUrl = this.$normalizePath(require.toUrl("ace/worker/worker", null, "_")); + } + this.$worker = new Worker(workerUrl); + + var tlns = {}; + for (var i=0; i= this.pos.column && range.start.column <= this.pos.column + this.length + 1) { + var distanceFromStart = range.start.column - this.pos.column; + this.length += lengthDiff; + if(!this.session.$fromUndo) { + if(delta.action === "insertText") { + for (var i = this.others.length - 1; i >= 0; i--) { + var otherPos = this.others[i]; + var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart}; + if(otherPos.row === range.start.row && range.start.column < otherPos.column) + newPos.column += lengthDiff; + this.doc.insert(newPos, delta.text); + } + } else if(delta.action === "removeText") { + for (var i = this.others.length - 1; i >= 0; i--) { + var otherPos = this.others[i]; + var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart}; + if(otherPos.row === range.start.row && range.start.column < otherPos.column) + newPos.column += lengthDiff; + this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff)); + } + } + // Special case: insert in beginning + if(range.start.column === this.pos.column && delta.action === "insertText") { + setTimeout(function() { + this.pos.setPosition(this.pos.row, this.pos.column - lengthDiff); + for (var i = 0; i < this.others.length; i++) { + var other = this.others[i]; + var newPos = {row: other.row, column: other.column - lengthDiff}; + if(other.row === range.start.row && range.start.column < other.column) + newPos.column += lengthDiff; + other.setPosition(newPos.row, newPos.column); + } + }.bind(this), 0); + } + else if(range.start.column === this.pos.column && delta.action === "removeText") { + setTimeout(function() { + for (var i = 0; i < this.others.length; i++) { + var other = this.others[i]; + if(other.row === range.start.row && range.start.column < other.column) { + other.setPosition(other.row, other.column - lengthDiff); + } + } + }.bind(this), 0); + } + } + this.pos._emit("change", {value: this.pos}); + for (var i = 0; i < this.others.length; i++) { + this.others[i]._emit("change", {value: this.others[i]}); + } + } + this.$updating = false; + }; + + this.onCursorChange = function(event) { + if (this.$updating) return; + var pos = this.session.selection.getCursor(); + if(pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) { + this.showOtherMarkers(); + this._emit("cursorEnter", event); + } else { + this.hideOtherMarkers(); + this._emit("cursorLeave", event); + } + }; + this.detach = function() { + this.session.removeMarker(this.markerId); + this.hideOtherMarkers(); + this.doc.removeEventListener("change", this.$onUpdate); + this.session.selection.removeEventListener("changeCursor", this.$onCursorChange); + this.pos.detach(); + for (var i = 0; i < this.others.length; i++) { + this.others[i].detach(); + } + this.session.setUndoSelect(true); + }; + this.cancel = function() { + if(this.$undoStackDepth === -1) + throw Error("Canceling placeholders only supported with undo manager attached to session."); + var undoManager = this.session.getUndoManager(); + var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth; + for (var i = 0; i < undosRequired; i++) { + undoManager.undo(true); + } + }; +}).call(PlaceHolder.prototype); + + +exports.PlaceHolder = PlaceHolder; +}); + +ace.define('ace/theme/textmate', ['require', 'exports', 'module' , 'text!ace/theme/textmate.css', 'ace/lib/dom'], function(require, exports, module) { + + +exports.isDark = false; +exports.cssClass = "ace-tm"; +exports.cssText = require('text!./textmate.css'); + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); +ace.define("text!ace/theme/textmate.css", [], ".ace-tm .ace_editor {\n" + + " border: 2px solid rgb(159, 159, 159);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_editor.ace_focus {\n" + + " border: 2px solid #327fbd;\n" + + "}\n" + + "\n" + + ".ace-tm .ace_gutter {\n" + + " background: #f0f0f0;\n" + + " color: #333;\n" + + "}\n" + + "\n" + + ".ace-tm .ace_print_margin {\n" + + " width: 1px;\n" + + " background: #e8e8e8;\n" + + "}\n" + + "\n" + + ".ace-tm .ace_fold {\n" + + " background-color: #6B72E6;\n" + + "}\n" + + "\n" + + ".ace-tm .ace_scroller {\n" + + " background-color: #FFFFFF;\n" + + "}\n" + + "\n" + + ".ace-tm .ace_cursor {\n" + + " border-left: 2px solid black;\n" + + "}\n" + + "\n" + + ".ace-tm .ace_cursor.ace_overwrite {\n" + + " border-left: 0px;\n" + + " border-bottom: 1px solid black;\n" + + "}\n" + + " \n" + + ".ace-tm .ace_line .ace_invisible {\n" + + " color: rgb(191, 191, 191);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_storage,\n" + + ".ace-tm .ace_line .ace_keyword {\n" + + " color: blue;\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_constant {\n" + + " color: rgb(197, 6, 11);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_constant.ace_buildin {\n" + + " color: rgb(88, 72, 246);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_constant.ace_language {\n" + + " color: rgb(88, 92, 246);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_constant.ace_library {\n" + + " color: rgb(6, 150, 14);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_invalid {\n" + + " background-color: rgba(255, 0, 0, 0.1);\n" + + " color: red;\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_support.ace_function {\n" + + " color: rgb(60, 76, 114);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_support.ace_constant {\n" + + " color: rgb(6, 150, 14);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_support.ace_type,\n" + + ".ace-tm .ace_line .ace_support.ace_class {\n" + + " color: rgb(109, 121, 222);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_keyword.ace_operator {\n" + + " color: rgb(104, 118, 135);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_string {\n" + + " color: rgb(3, 106, 7);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_comment {\n" + + " color: rgb(76, 136, 107);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_comment.ace_doc {\n" + + " color: rgb(0, 102, 255);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_comment.ace_doc.ace_tag {\n" + + " color: rgb(128, 159, 191);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_constant.ace_numeric {\n" + + " color: rgb(0, 0, 205);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_variable {\n" + + " color: rgb(49, 132, 149);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_line .ace_xml_pe {\n" + + " color: rgb(104, 104, 91);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_entity.ace_name.ace_function {\n" + + " color: #0000A2;\n" + + "}\n" + + "\n" + + "\n" + + ".ace-tm .ace_markup.ace_heading {\n" + + " color: rgb(12, 7, 255);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_markup.ace_list {\n" + + " color:rgb(185, 6, 144);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_meta.ace_tag {\n" + + " color:rgb(0, 22, 142);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_string.ace_regex {\n" + + " color: rgb(255, 0, 0)\n" + + "}\n" + + "\n" + + ".ace-tm .ace_marker-layer .ace_selection {\n" + + " background: rgb(181, 213, 255);\n" + + "}\n" + + ".ace-tm.multiselect .ace_selection.start {\n" + + " box-shadow: 0 0 3px 0px white;\n" + + " border-radius: 2px;\n" + + "}\n" + + ".ace-tm .ace_marker-layer .ace_step {\n" + + " background: rgb(252, 255, 0);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_marker-layer .ace_stack {\n" + + " background: rgb(164, 229, 101);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_marker-layer .ace_bracket {\n" + + " margin: -1px 0 0 -1px;\n" + + " border: 1px solid rgb(192, 192, 192);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_marker-layer .ace_active_line {\n" + + " background: rgba(0, 0, 0, 0.07);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_gutter_active_line {\n" + + " background-color : #dcdcdc;\n" + + "}\n" + + "\n" + + ".ace-tm .ace_marker-layer .ace_selected_word {\n" + + " background: rgb(250, 250, 255);\n" + + " border: 1px solid rgb(200, 200, 250);\n" + + "}\n" + + "\n" + + ".ace-tm .ace_indent-guide {\n" + + " background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\n" + + "}\n" + + ""); + +; + (function() { + ace.require(["ace/ace"], function(a) { + a && a.config.init(); + if (!window.ace) + window.ace = {}; + for (var key in a) if (a.hasOwnProperty(key)) + ace[key] = a[key]; + }); + })(); + \ No newline at end of file diff --git a/vendor/assets/javascripts/ace-src-noconflict/keybinding-emacs.js b/vendor/assets/javascripts/ace-src-noconflict/keybinding-emacs.js new file mode 100644 index 00000000..ba53c7c5 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/keybinding-emacs.js @@ -0,0 +1,374 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/keyboard/emacs', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/keyboard/hash_handler', 'ace/lib/keys'], function(require, exports, module) { + + +var dom = require("../lib/dom"); + +var screenToTextBlockCoordinates = function(pageX, pageY) { + var canvasPos = this.scroller.getBoundingClientRect(); + + var col = Math.floor( + (pageX + this.scrollLeft - canvasPos.left - this.$padding - dom.getPageScrollLeft()) / this.characterWidth + ); + var row = Math.floor( + (pageY + this.scrollTop - canvasPos.top - dom.getPageScrollTop()) / this.lineHeight + ); + + return this.session.screenToDocumentPosition(row, col); +}; + +var HashHandler = require("./hash_handler").HashHandler; +exports.handler = new HashHandler(); + +var initialized = false; +exports.handler.attach = function(editor) { + if (!initialized) { + initialized = true; + dom.importCssString('\ + .emacs-mode .ace_cursor{\ + border: 2px rgba(50,250,50,0.8) solid!important;\ + -moz-box-sizing: border-box!important;\ + box-sizing: border-box!important;\ + background-color: rgba(0,250,0,0.9);\ + opacity: 0.5;\ + }\ + .emacs-mode .ace_cursor.ace_hidden{\ + opacity: 1;\ + background-color: transparent;\ + }\ + .emacs-mode .ace_cursor.ace_overwrite {\ + opacity: 1;\ + background-color: transparent;\ + border-width: 0 0 2px 2px !important;\ + }\ + .emacs-mode .ace_text-layer {\ + z-index: 4\ + }\ + .emacs-mode .ace_cursor-layer {\ + z-index: 2\ + }', 'emacsMode' + ); + } + + editor.renderer.screenToTextCoordinates = screenToTextBlockCoordinates; + editor.setStyle("emacs-mode"); +}; + +exports.handler.detach = function(editor) { + delete editor.renderer.screenToTextCoordinates; + editor.unsetStyle("emacs-mode"); +}; + + +var keys = require("../lib/keys").KEY_MODS; +var eMods = { + C: "ctrl", S: "shift", M: "alt" +}; +["S-C-M", "S-C", "S-M", "C-M", "S", "C", "M"].forEach(function(c) { + var hashId = 0; + c.split("-").forEach(function(c){ + hashId = hashId | keys[eMods[c]]; + }); + eMods[hashId] = c.toLowerCase() + "-"; +}); + +exports.handler.bindKey = function(key, command) { + if (!key) + return; + + var ckb = this.commmandKeyBinding; + key.split("|").forEach(function(keyPart) { + keyPart = keyPart.toLowerCase(); + ckb[keyPart] = command; + keyPart = keyPart.split(" ")[0]; + if (!ckb[keyPart]) + ckb[keyPart] = "null"; + }, this); +}; + + +exports.handler.handleKeyboard = function(data, hashId, key, keyCode) { + if (hashId == -1) { + if (data.count) { + var str = Array(data.count + 1).join(key); + data.count = null; + return {command: "insertstring", args: str}; + } + } + + if (key == "\x00") + return; + + var modifier = eMods[hashId]; + if (modifier == "c-" || data.universalArgument) { + var count = parseInt(key[key.length - 1]); + if (count) { + data.count = count; + return {command: "null"}; + } + } + data.universalArgument = false; + + if (modifier) + key = modifier + key; + + if (data.keyChain) + key = data.keyChain += " " + key; + + var command = this.commmandKeyBinding[key]; + data.keyChain = command == "null" ? key : ""; + + if (!command) + return; + + if (command == "null") + return {command: "null"}; + + if (command == "universalArgument") { + data.universalArgument = true; + return {command: "null"}; + } + + if (typeof command != "string") { + var args = command.args; + command = command.command; + } + + if (typeof command == "string") { + command = this.commands[command] || data.editor.commands.commands[command]; + } + + if (!command.readonly && !command.isYank) + data.lastCommand = null; + + if (data.count) { + var count = data.count; + data.count = 0; + return { + args: args, + command: { + exec: function(editor, args) { + for (var i = 0; i < count; i++) + command.exec(editor, args); + } + } + }; + } + + return {command: command, args: args}; +}; + +exports.emacsKeys = { + // movement + "Up|C-p" : "golineup", + "Down|C-n" : "golinedown", + "Left|C-b" : "gotoleft", + "Right|C-f" : "gotoright", + "C-Left|M-b" : "gotowordleft", + "C-Right|M-f" : "gotowordright", + "Home|C-a" : "gotolinestart", + "End|C-e" : "gotolineend", + "C-Home|S-M-,": "gotostart", + "C-End|S-M-." : "gotoend", + + // selection + "S-Up|S-C-p" : "selectup", + "S-Down|S-C-n" : "selectdown", + "S-Left|S-C-b" : "selectleft", + "S-Right|S-C-f" : "selectright", + "S-C-Left|S-M-b" : "selectwordleft", + "S-C-Right|S-M-f" : "selectwordright", + "S-Home|S-C-a" : "selecttolinestart", + "S-End|S-C-e" : "selecttolineend", + "S-C-Home" : "selecttostart", + "S-C-End" : "selecttoend", + + "C-l" : "recenterTopBottom", + "M-s" : "centerselection", + "M-g": "gotoline", + "C-x C-p": "selectall", + + // todo fix these + "C-Down": "gotopagedown", + "C-Up": "gotopageup", + "PageDown|C-v": "gotopagedown", + "PageUp|M-v": "gotopageup", + "S-C-Down": "selectpagedown", + "S-C-Up": "selectpageup", + "C-s": "findnext", + "C-r": "findprevious", + "M-C-s": "findnext", + "M-C-r": "findprevious", + "S-M-5": "replace", + + // basic editing + "Backspace": "backspace", + "Delete|C-d": "del", + "Return|C-m": {command: "insertstring", args: "\n"}, // "newline" + "C-o": "splitline", + + "M-d|C-Delete": {command: "killWord", args: "right"}, + "C-Backspace|M-Backspace|M-Delete": {command: "killWord", args: "left"}, + "C-k": "killLine", + + "C-y|S-Delete": "yank", + "M-y": "yankRotate", + "C-g": "keyboardQuit", + + "C-w": "killRegion", + "M-w": "killRingSave", + + "C-Space": "setMark", + "C-x C-x": "exchangePointAndMark", + + "C-t": "transposeletters", + + "M-u": "touppercase", + "M-l": "tolowercase", + "M-/": "autocomplete", + "C-u": "universalArgument", + "M-;": "togglecomment", + + "C-/|C-x u|S-C--|C-z": "undo", + "S-C-/|S-C-x u|C--|S-C-z": "redo", //infinite undo? + // vertical editing + "C-x r": "selectRectangularRegion" + + // todo + // "M-x" "C-x C-t" "M-t" "M-c" "F11" "C-M- "M-q" +}; + + +exports.handler.bindKeys(exports.emacsKeys); + +exports.handler.addCommands({ + recenterTopBottom: function(editor) { + var renderer = editor.renderer; + var pos = renderer.$cursorLayer.getPixelPosition(); + var h = renderer.$size.scrollerHeight - renderer.lineHeight; + var scrollTop = renderer.scrollTop; + if (Math.abs(pos.top - scrollTop) < 2) { + scrollTop = pos.top - h; + } else if (Math.abs(pos.top - scrollTop - h * 0.5) < 2) { + scrollTop = pos.top; + } else { + scrollTop = pos.top - h * 0.5; + } + editor.session.setScrollTop(scrollTop); + }, + selectRectangularRegion: function(editor) { + editor.multiSelect.toggleBlockSelection(); + }, + setMark: function() { + }, + exchangePointAndMark: { + exec: function(editor) { + var range = editor.selection.getRange(); + editor.selection.setSelectionRange(range, !editor.selection.isBackwards()); + }, + readonly: true, + multiselectAction: "forEach" + }, + killWord: { + exec: function(editor, dir) { + editor.clearSelection(); + if (dir == "left") + editor.selection.selectWordLeft(); + else + editor.selection.selectWordRight(); + + var range = editor.getSelectionRange(); + var text = editor.session.getTextRange(range); + exports.killRing.add(text); + + editor.session.remove(range); + editor.clearSelection(); + }, + multiselectAction: "forEach" + }, + killLine: function(editor) { + editor.selection.selectLine(); + var range = editor.getSelectionRange(); + var text = editor.session.getTextRange(range); + exports.killRing.add(text); + + editor.session.remove(range); + editor.clearSelection(); + }, + yank: function(editor) { + editor.onPaste(exports.killRing.get()); + editor.keyBinding.$data.lastCommand = "yank"; + }, + yankRotate: function(editor) { + if (editor.keyBinding.$data.lastCommand != "yank") + return; + + editor.undo(); + editor.onPaste(exports.killRing.rotate()); + editor.keyBinding.$data.lastCommand = "yank"; + }, + killRegion: function(editor) { + exports.killRing.add(editor.getCopyText()); + editor.commands.byName.cut.exec(editor); + }, + killRingSave: function(editor) { + exports.killRing.add(editor.getCopyText()); + } +}); + +var commands = exports.handler.commands; +commands.yank.isYank = true; +commands.yankRotate.isYank = true; + +exports.killRing = { + $data: [], + add: function(str) { + str && this.$data.push(str); + if (this.$data.length > 30) + this.$data.shift(); + }, + get: function() { + return this.$data[this.$data.length - 1] || ""; + }, + pop: function() { + if (this.$data.length > 1) + this.$data.pop(); + return this.get(); + }, + rotate: function() { + this.$data.unshift(this.$data.pop()); + return this.get(); + } +}; + + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/keybinding-vim.js b/vendor/assets/javascripts/ace-src-noconflict/keybinding-vim.js new file mode 100644 index 00000000..88ebc4e7 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/keybinding-vim.js @@ -0,0 +1,1679 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/keyboard/vim', ['require', 'exports', 'module' , 'ace/keyboard/vim/commands', 'ace/keyboard/vim/maps/util', 'ace/lib/useragent'], function(require, exports, module) { + + +var cmds = require("./vim/commands"); +var coreCommands = cmds.coreCommands; +var util = require("./vim/maps/util"); +var useragent = require("../lib/useragent"); + +var startCommands = { + "i": { + command: coreCommands.start + }, + "I": { + command: coreCommands.startBeginning + }, + "a": { + command: coreCommands.append + }, + "A": { + command: coreCommands.appendEnd + }, + "ctrl-f": { + command: "gotopagedown" + }, + "ctrl-b": { + command: "gotopageup" + } +}; + +exports.handler = { + // workaround for j not repeating with `defaults write -g ApplePressAndHoldEnabled -bool true` + handleMacRepeat: function(data, hashId, key) { + if (hashId == -1) { + // record key + data.inputChar = key; + data.lastEvent = "input"; + } else if (data.inputChar && data.$lastHash == hashId && data.$lastKey == key) { + // check for repeated keypress + if (data.lastEvent == "input") { + data.lastEvent = "input1"; + } else if (data.lastEvent == "input1") { + // simulate textinput + return true; + } + } else { + // reset + data.$lastHash = hashId; + data.$lastKey = key; + data.lastEvent = "keypress"; + } + }, + + handleKeyboard: function(data, hashId, key, keyCode, e) { + // ignore command keys (shift, ctrl etc.) + if (hashId != 0 && (key == "" || key == "\x00")) + return null; + + if (hashId == 1) + key = "ctrl-" + key; + + if ((key == "esc" && hashId == 0) || key == "ctrl-[") { + return {command: coreCommands.stop}; + } else if (data.state == "start") { + if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) { + hashId = -1; + key = data.inputChar; + } + + if (hashId == -1 || hashId == 1) { + if (cmds.inputBuffer.idle && startCommands[key]) + return startCommands[key]; + return { + command: { + exec: function(editor) {cmds.inputBuffer.push(editor, key);} + } + }; + } // if no modifier || shift: wait for input. + else if (key.length == 1 && (hashId == 0 || hashId == 4)) { + return {command: "null", passEvent: true}; + } else if (key == "esc" && hashId == 0) { + return {command: coreCommands.stop}; + } + } else { + if (key == "ctrl-w") { + return {command: "removewordleft"}; + } + } + }, + + attach: function(editor) { + editor.on("click", exports.onCursorMove); + if (util.currentMode !== "insert") + cmds.coreCommands.stop.exec(editor); + editor.$vimModeHandler = this; + }, + + detach: function(editor) { + editor.removeListener("click", exports.onCursorMove); + util.noMode(editor); + util.currentMode = "normal"; + }, + + actions: cmds.actions, + getStatusText: function() { + if (util.currentMode == "insert") + return "INSERT"; + if (util.onVisualMode) + return (util.onVisualLineMode ? "VISUAL LINE " : "VISUAL ") + cmds.inputBuffer.status; + return cmds.inputBuffer.status; + } +}; + + +exports.onCursorMove = function(e) { + cmds.onCursorMove(e.editor, e); + exports.onCursorMove.scheduled = false; +}; + +}); + +ace.define('ace/keyboard/vim/commands', ['require', 'exports', 'module' , 'ace/keyboard/vim/maps/util', 'ace/keyboard/vim/maps/motions', 'ace/keyboard/vim/maps/operators', 'ace/keyboard/vim/maps/aliases', 'ace/keyboard/vim/registers'], function(require, exports, module) { + +"never use strict"; + +var util = require("./maps/util"); +var motions = require("./maps/motions"); +var operators = require("./maps/operators"); +var alias = require("./maps/aliases"); +var registers = require("./registers"); + +var NUMBER = 1; +var OPERATOR = 2; +var MOTION = 3; +var ACTION = 4; +var HMARGIN = 8; // Minimum amount of line separation between margins; + +var repeat = function repeat(fn, count, args) { + while (0 < count--) + fn.apply(this, args); +}; + +var ensureScrollMargin = function(editor) { + var renderer = editor.renderer; + var pos = renderer.$cursorLayer.getPixelPosition(); + + var top = pos.top; + + var margin = HMARGIN * renderer.layerConfig.lineHeight; + if (2 * margin > renderer.$size.scrollerHeight) + margin = renderer.$size.scrollerHeight / 2; + + if (renderer.scrollTop > top - margin) { + renderer.session.setScrollTop(top - margin); + } + + if (renderer.scrollTop + renderer.$size.scrollerHeight < top + margin + renderer.lineHeight) { + renderer.session.setScrollTop(top + margin + renderer.lineHeight - renderer.$size.scrollerHeight); + } +}; + +var actions = exports.actions = { + "z": { + param: true, + fn: function(editor, range, count, param) { + switch (param) { + case "z": + editor.alignCursor(null, 0.5); + break; + case "t": + editor.alignCursor(null, 0); + break; + case "b": + editor.alignCursor(null, 1); + break; + } + } + }, + "r": { + param: true, + fn: function(editor, range, count, param) { + if (param && param.length) { + repeat(function() { editor.insert(param); }, count || 1); + editor.navigateLeft(); + } + } + }, + "R": { + fn: function(editor, range, count, param) { + util.insertMode(editor); + editor.setOverwrite(true); + } + }, + "~": { + fn: function(editor, range, count) { + repeat(function() { + var range = editor.selection.getRange(); + if (range.isEmpty()) + range.end.column++; + var text = editor.session.getTextRange(range); + var toggled = text.toUpperCase(); + if (toggled == text) + editor.navigateRight(); + else + editor.session.replace(range, toggled); + }, count || 1); + } + }, + "*": { + fn: function(editor, range, count, param) { + editor.selection.selectWord(); + editor.findNext(); + ensureScrollMargin(editor); + var r = editor.selection.getRange(); + editor.selection.setSelectionRange(r, true); + } + }, + "#": { + fn: function(editor, range, count, param) { + editor.selection.selectWord(); + editor.findPrevious(); + ensureScrollMargin(editor); + var r = editor.selection.getRange(); + editor.selection.setSelectionRange(r, true); + } + }, + "n": { + fn: function(editor, range, count, param) { + var options = editor.getLastSearchOptions(); + options.backwards = false; + + editor.selection.moveCursorRight(); + editor.selection.clearSelection(); + editor.findNext(options); + + ensureScrollMargin(editor); + var r = editor.selection.getRange(); + r.end.row = r.start.row; + r.end.column = r.start.column; + editor.selection.setSelectionRange(r, true); + } + }, + "N": { + fn: function(editor, range, count, param) { + var options = editor.getLastSearchOptions(); + options.backwards = true; + + editor.findPrevious(options); + ensureScrollMargin(editor); + var r = editor.selection.getRange(); + r.end.row = r.start.row; + r.end.column = r.start.column; + editor.selection.setSelectionRange(r, true); + } + }, + "v": { + fn: function(editor, range, count, param) { + editor.selection.selectRight(); + util.visualMode(editor, false); + }, + acceptsMotion: true + }, + "V": { + fn: function(editor, range, count, param) { + //editor.selection.selectLine(); + //editor.selection.selectLeft(); + var row = editor.getCursorPosition().row; + editor.selection.clearSelection(); + editor.selection.moveCursorTo(row, 0); + editor.selection.selectLineEnd(); + editor.selection.visualLineStart = row; + + util.visualMode(editor, true); + }, + acceptsMotion: true + }, + "Y": { + fn: function(editor, range, count, param) { + util.copyLine(editor); + } + }, + "p": { + fn: function(editor, range, count, param) { + var defaultReg = registers._default; + + editor.setOverwrite(false); + if (defaultReg.isLine) { + var pos = editor.getCursorPosition(); + var lines = defaultReg.text.split("\n"); + editor.session.getDocument().insertLines(pos.row + 1, lines); + editor.moveCursorTo(pos.row + 1, 0); + } + else { + editor.navigateRight(); + editor.insert(defaultReg.text); + editor.navigateLeft(); + } + editor.setOverwrite(true); + editor.selection.clearSelection(); + } + }, + "P": { + fn: function(editor, range, count, param) { + var defaultReg = registers._default; + editor.setOverwrite(false); + + if (defaultReg.isLine) { + var pos = editor.getCursorPosition(); + var lines = defaultReg.text.split("\n"); + editor.session.getDocument().insertLines(pos.row, lines); + editor.moveCursorTo(pos.row, 0); + } + else { + editor.insert(defaultReg.text); + } + editor.setOverwrite(true); + editor.selection.clearSelection(); + } + }, + "J": { + fn: function(editor, range, count, param) { + var session = editor.session; + range = editor.getSelectionRange(); + var pos = {row: range.start.row, column: range.start.column}; + count = count || range.end.row - range.start.row; + var maxRow = Math.min(pos.row + (count || 1), session.getLength() - 1); + + range.start.column = session.getLine(pos.row).length; + range.end.column = session.getLine(maxRow).length; + range.end.row = maxRow; + + var text = ""; + for (var i = pos.row; i < maxRow; i++) { + var nextLine = session.getLine(i + 1); + text += " " + /^\s*(.*)$/.exec(nextLine)[1] || ""; + } + + session.replace(range, text); + editor.moveCursorTo(pos.row, pos.column); + } + }, + "u": { + fn: function(editor, range, count, param) { + count = parseInt(count || 1, 10); + for (var i = 0; i < count; i++) { + editor.undo(); + } + editor.selection.clearSelection(); + } + }, + "ctrl-r": { + fn: function(editor, range, count, param) { + count = parseInt(count || 1, 10); + for (var i = 0; i < count; i++) { + editor.redo(); + } + editor.selection.clearSelection(); + } + }, + ":": { + fn: function(editor, range, count, param) { + // not implemented + } + }, + "/": { + fn: function(editor, range, count, param) { + // not implemented + } + }, + "?": { + fn: function(editor, range, count, param) { + // not implemented + } + }, + ".": { + fn: function(editor, range, count, param) { + util.onInsertReplaySequence = inputBuffer.lastInsertCommands; + var previous = inputBuffer.previous; + if (previous) // If there is a previous action + inputBuffer.exec(editor, previous.action, previous.param); + } + } +}; + +var inputBuffer = exports.inputBuffer = { + accepting: [NUMBER, OPERATOR, MOTION, ACTION], + currentCmd: null, + //currentMode: 0, + currentCount: "", + status: "", + + // Types + operator: null, + motion: null, + + lastInsertCommands: [], + + push: function(editor, char, keyId) { + this.idle = false; + var wObj = this.waitingForParam; + if (wObj) { + this.exec(editor, wObj, char); + } + // If input is a number (that doesn't start with 0) + else if (!(char === "0" && !this.currentCount.length) && + (char.match(/^\d+$/) && this.isAccepting(NUMBER))) { + // Assuming that char is always of type String, and not Number + this.currentCount += char; + this.currentCmd = NUMBER; + this.accepting = [NUMBER, OPERATOR, MOTION, ACTION]; + } + else if (!this.operator && this.isAccepting(OPERATOR) && operators[char]) { + this.operator = { + char: char, + count: this.getCount() + }; + this.currentCmd = OPERATOR; + this.accepting = [NUMBER, MOTION, ACTION]; + this.exec(editor, { operator: this.operator }); + } + else if (motions[char] && this.isAccepting(MOTION)) { + this.currentCmd = MOTION; + + var ctx = { + operator: this.operator, + motion: { + char: char, + count: this.getCount() + } + }; + + if (motions[char].param) + this.waitForParam(ctx); + else + this.exec(editor, ctx); + } + else if (alias[char] && this.isAccepting(MOTION)) { + alias[char].operator.count = this.getCount(); + this.exec(editor, alias[char]); + } + else if (actions[char] && this.isAccepting(ACTION)) { + var actionObj = { + action: { + fn: actions[char].fn, + count: this.getCount() + } + }; + + if (actions[char].param) { + this.waitForParam(actionObj); + } + else { + this.exec(editor, actionObj); + } + + if (actions[char].acceptsMotion) + this.idle = false; + } + else if (this.operator) { + this.exec(editor, { operator: this.operator }, char); + } + else { + this.reset(); + } + + if (this.waitingForParam || this.motion || this.operator) { + this.status += char; + } else if (this.currentCount) { + this.status = this.currentCount; + } else if (this.status) { + this.status = ""; + } else { + return; + } + editor._emit("changeStatus"); + }, + + waitForParam: function(cmd) { + this.waitingForParam = cmd; + }, + + getCount: function() { + var count = this.currentCount; + this.currentCount = ""; + return count && parseInt(count, 10); + }, + + exec: function(editor, action, param) { + var m = action.motion; + var o = action.operator; + var a = action.action; + + if (!param) + param = action.param; + + if (o) { + this.previous = { + action: action, + param: param + }; + } + + if (o && !editor.selection.isEmpty()) { + if (operators[o.char].selFn) { + operators[o.char].selFn(editor, editor.getSelectionRange(), o.count, param); + this.reset(); + } + return; + } + + // There is an operator, but no motion or action. We try to pass the + // current char to the operator to see if it responds to it (an example + // of this is the 'dd' operator). + else if (!m && !a && o && param) { + operators[o.char].fn(editor, null, o.count, param); + this.reset(); + } + else if (m) { + var run = function(fn) { + if (fn && typeof fn === "function") { // There should always be a motion + if (m.count && !motionObj.handlesCount) + repeat(fn, m.count, [editor, null, m.count, param]); + else + fn(editor, null, m.count, param); + } + }; + + var motionObj = motions[m.char]; + var selectable = motionObj.sel; + + if (!o) { + if ((util.onVisualMode || util.onVisualLineMode) && selectable) + run(motionObj.sel); + else + run(motionObj.nav); + } + else if (selectable) { + repeat(function() { + run(motionObj.sel); + operators[o.char].fn(editor, editor.getSelectionRange(), o.count, param); + }, o.count || 1); + } + this.reset(); + } + else if (a) { + a.fn(editor, editor.getSelectionRange(), a.count, param); + this.reset(); + } + handleCursorMove(editor); + }, + + isAccepting: function(type) { + return this.accepting.indexOf(type) !== -1; + }, + + reset: function() { + this.operator = null; + this.motion = null; + this.currentCount = ""; + this.status = ""; + this.accepting = [NUMBER, OPERATOR, MOTION, ACTION]; + this.idle = true; + this.waitingForParam = null; + } +}; + +function setPreviousCommand(fn) { + inputBuffer.previous = { action: { action: { fn: fn } } }; +} + +exports.coreCommands = { + start: { + exec: function start(editor) { + util.insertMode(editor); + setPreviousCommand(start); + } + }, + startBeginning: { + exec: function startBeginning(editor) { + editor.navigateLineStart(); + util.insertMode(editor); + setPreviousCommand(startBeginning); + } + }, + // Stop Insert mode as soon as possible. Works like typing in + // insert mode. + stop: { + exec: function stop(editor) { + inputBuffer.reset(); + util.onVisualMode = false; + util.onVisualLineMode = false; + inputBuffer.lastInsertCommands = util.normalMode(editor); + } + }, + append: { + exec: function append(editor) { + var pos = editor.getCursorPosition(); + var lineLen = editor.session.getLine(pos.row).length; + if (lineLen) + editor.navigateRight(); + util.insertMode(editor); + setPreviousCommand(append); + } + }, + appendEnd: { + exec: function appendEnd(editor) { + editor.navigateLineEnd(); + util.insertMode(editor); + setPreviousCommand(appendEnd); + } + } +}; + +var handleCursorMove = exports.onCursorMove = function(editor, e) { + if (util.currentMode === 'insert' || handleCursorMove.running) + return; + else if(!editor.selection.isEmpty()) { + handleCursorMove.running = true; + if (util.onVisualLineMode) { + var originRow = editor.selection.visualLineStart; + var cursorRow = editor.getCursorPosition().row; + if(originRow <= cursorRow) { + var endLine = editor.session.getLine(cursorRow); + editor.selection.clearSelection(); + editor.selection.moveCursorTo(originRow, 0); + editor.selection.selectTo(cursorRow, endLine.length); + } else { + var endLine = editor.session.getLine(originRow); + editor.selection.clearSelection(); + editor.selection.moveCursorTo(originRow, endLine.length); + editor.selection.selectTo(cursorRow, 0); + } + } + handleCursorMove.running = false; + return; + } + else { + if (e && (util.onVisualLineMode || util.onVisualMode)) { + editor.selection.clearSelection(); + util.normalMode(editor); + } + + handleCursorMove.running = true; + var pos = editor.getCursorPosition(); + var lineLen = editor.session.getLine(pos.row).length; + + if (lineLen && pos.column === lineLen) + editor.navigateLeft(); + handleCursorMove.running = false; + } +}; +}); +ace.define('ace/keyboard/vim/maps/util', ['require', 'exports', 'module' , 'ace/keyboard/vim/registers', 'ace/lib/dom'], function(require, exports, module) { +var registers = require("../registers"); + +var dom = require("../../../lib/dom"); +dom.importCssString('.insert-mode. ace_cursor{\ + border-left: 2px solid #333333;\ +}\ +.ace_dark.insert-mode .ace_cursor{\ + border-left: 2px solid #eeeeee;\ +}\ +.normal-mode .ace_cursor{\ + border: 0!important;\ + background-color: red;\ + opacity: 0.5;\ +}', 'vimMode'); + +module.exports = { + onVisualMode: false, + onVisualLineMode: false, + currentMode: 'normal', + noMode: function(editor) { + editor.unsetStyle('insert-mode'); + editor.unsetStyle('normal-mode'); + if (editor.commands.recording) + editor.commands.toggleRecording(editor); + editor.setOverwrite(false); + }, + insertMode: function(editor) { + this.currentMode = 'insert'; + // Switch editor to insert mode + editor.setStyle('insert-mode'); + editor.unsetStyle('normal-mode'); + + editor.setOverwrite(false); + editor.keyBinding.$data.buffer = ""; + editor.keyBinding.$data.state = "insertMode"; + this.onVisualMode = false; + this.onVisualLineMode = false; + if(this.onInsertReplaySequence) { + // Ok, we're apparently replaying ("."), so let's do it + editor.commands.macro = this.onInsertReplaySequence; + editor.commands.replay(editor); + this.onInsertReplaySequence = null; + this.normalMode(editor); + } else { + editor._emit("changeStatus"); + // Record any movements, insertions in insert mode + if(!editor.commands.recording) + editor.commands.toggleRecording(editor); + } + }, + normalMode: function(editor) { + // Switch editor to normal mode + this.currentMode = 'normal'; + + editor.unsetStyle('insert-mode'); + editor.setStyle('normal-mode'); + editor.clearSelection(); + + var pos; + if (!editor.getOverwrite()) { + pos = editor.getCursorPosition(); + if (pos.column > 0) + editor.navigateLeft(); + } + + editor.setOverwrite(true); + editor.keyBinding.$data.buffer = ""; + editor.keyBinding.$data.state = "start"; + this.onVisualMode = false; + this.onVisualLineMode = false; + editor._emit("changeStatus"); + // Save recorded keystrokes + if (editor.commands.recording) { + editor.commands.toggleRecording(editor); + return editor.commands.macro; + } + else { + return []; + } + }, + visualMode: function(editor, lineMode) { + if ( + (this.onVisualLineMode && lineMode) + || (this.onVisualMode && !lineMode) + ) { + this.normalMode(editor); + return; + } + + editor.setStyle('insert-mode'); + editor.unsetStyle('normal-mode'); + + editor._emit("changeStatus"); + if (lineMode) { + this.onVisualLineMode = true; + } else { + this.onVisualMode = true; + this.onVisualLineMode = false; + } + }, + getRightNthChar: function(editor, cursor, char, n) { + var line = editor.getSession().getLine(cursor.row); + var matches = line.substr(cursor.column + 1).split(char); + + return n < matches.length ? matches.slice(0, n).join(char).length : null; + }, + getLeftNthChar: function(editor, cursor, char, n) { + var line = editor.getSession().getLine(cursor.row); + var matches = line.substr(0, cursor.column).split(char); + + return n < matches.length ? matches.slice(-1 * n).join(char).length : null; + }, + toRealChar: function(char) { + if (char.length === 1) + return char; + + if (/^shift-./.test(char)) + return char[char.length - 1].toUpperCase(); + else + return ""; + }, + copyLine: function(editor) { + var pos = editor.getCursorPosition(); + editor.selection.clearSelection(); + editor.moveCursorTo(pos.row, pos.column); + editor.selection.selectLine(); + registers._default.isLine = true; + registers._default.text = editor.getCopyText().replace(/\n$/, ""); + editor.selection.clearSelection(); + editor.moveCursorTo(pos.row, pos.column); + } +}; +}); + +ace.define('ace/keyboard/vim/registers', ['require', 'exports', 'module' ], function(require, exports, module) { + +"never use strict"; + +module.exports = { + _default: { + text: "", + isLine: false + } +}; + +}); + +"use strict" + +ace.define('ace/keyboard/vim/maps/motions', ['require', 'exports', 'module' , 'ace/keyboard/vim/maps/util', 'ace/search', 'ace/range'], function(require, exports, module) { + +var util = require("./util"); + +var keepScrollPosition = function(editor, fn) { + var scrollTopRow = editor.renderer.getScrollTopRow(); + var initialRow = editor.getCursorPosition().row; + var diff = initialRow - scrollTopRow; + fn && fn.call(editor); + editor.renderer.scrollToRow(editor.getCursorPosition().row - diff); +}; + +function Motion(getRange, type){ + if (type == 'extend') + var extend = true; + else + var reverse = type; + + this.nav = function(editor) { + var r = getRange(editor); + if (!r) + return; + if (!r.end) + var a = r; + else if (reverse) + var a = r.start; + else + var a = r.end; + + editor.clearSelection(); + editor.moveCursorTo(a.row, a.column); + } + this.sel = function(editor){ + var r = getRange(editor); + if (!r) + return; + if (extend) + return editor.selection.setSelectionRange(r); + + if (!r.end) + var a = r; + else if (reverse) + var a = r.start; + else + var a = r.end; + + editor.selection.selectTo(a.row, a.column); + } +} + +var nonWordRe = /[\s.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/; +var wordSeparatorRe = /[.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/; +var whiteRe = /\s/; +var StringStream = function(editor, cursor) { + var sel = editor.selection; + this.range = sel.getRange(); + cursor = cursor || sel.selectionLead; + this.row = cursor.row; + this.col = cursor.column; + var line = editor.session.getLine(this.row); + var maxRow = editor.session.getLength() + this.ch = line[this.col] || '\n' + this.skippedLines = 0; + + this.next = function() { + this.ch = line[++this.col] || this.handleNewLine(1); + //this.debug() + return this.ch; + } + this.prev = function() { + this.ch = line[--this.col] || this.handleNewLine(-1); + //this.debug() + return this.ch; + } + this.peek = function(dir) { + var ch = line[this.col + dir]; + if (ch) + return ch; + if (dir == -1) + return '\n'; + if (this.col == line.length - 1) + return '\n'; + return editor.session.getLine(this.row + 1)[0] || '\n'; + } + + this.handleNewLine = function(dir) { + if (dir == 1){ + if (this.col == line.length) + return '\n'; + if (this.row == maxRow - 1) + return ''; + this.col = 0; + this.row ++; + line = editor.session.getLine(this.row); + this.skippedLines++; + return line[0] || '\n'; + } + if (dir == -1) { + if (this.row == 0) + return ''; + this.row --; + line = editor.session.getLine(this.row); + this.col = line.length; + this.skippedLines--; + return '\n'; + } + } + this.debug = function() { + console.log(line.substring(0, this.col)+'|'+this.ch+'\''+this.col+'\''+line.substr(this.col+1)); + } +} + +var Search = require("ace/search").Search; +var search = new Search(); + +function find(editor, needle, dir) { + search.$options.needle = needle; + search.$options.backwards = dir == -1; + return search.find(editor.session); +} + +var Range = require("ace/range").Range; + +module.exports = { + "w": new Motion(function(editor) { + var str = new StringStream(editor); + + if (str.ch && wordSeparatorRe.test(str.ch)) { + while (str.ch && wordSeparatorRe.test(str.ch)) + str.next(); + } else { + while (str.ch && !nonWordRe.test(str.ch)) + str.next(); + } + while (str.ch && whiteRe.test(str.ch) && str.skippedLines < 2) + str.next(); + + str.skippedLines == 2 && str.prev(); + return {column: str.col, row: str.row}; + }), + "W": new Motion(function(editor) { + var str = new StringStream(editor); + while(str.ch && !(whiteRe.test(str.ch) && !whiteRe.test(str.peek(1))) && str.skippedLines < 2) + str.next(); + if (str.skippedLines == 2) + str.prev(); + else + str.next(); + + return {column: str.col, row: str.row} + }), + "b": new Motion(function(editor) { + var str = new StringStream(editor); + + str.prev(); + while (str.ch && whiteRe.test(str.ch) && str.skippedLines > -2) + str.prev(); + + if (str.ch && wordSeparatorRe.test(str.ch)) { + while (str.ch && wordSeparatorRe.test(str.ch)) + str.prev(); + } else { + while (str.ch && !nonWordRe.test(str.ch)) + str.prev(); + } + str.ch && str.next(); + return {column: str.col, row: str.row}; + }), + "B": new Motion(function(editor) { + var str = new StringStream(editor) + str.prev(); + while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(-1))) && str.skippedLines > -2) + str.prev(); + + if (str.skippedLines == -2) + str.next(); + + return {column: str.col, row: str.row}; + }, true), + "e": new Motion(function(editor) { + var str = new StringStream(editor); + + str.next(); + while (str.ch && whiteRe.test(str.ch)) + str.next(); + + if (str.ch && wordSeparatorRe.test(str.ch)) { + while (str.ch && wordSeparatorRe.test(str.ch)) + str.next(); + } else { + while (str.ch && !nonWordRe.test(str.ch)) + str.next(); + } + str.ch && str.prev(); + return {column: str.col, row: str.row}; + }), + "E": new Motion(function(editor) { + var str = new StringStream(editor); + str.next(); + while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(1)))) + str.next(); + + return {column: str.col, row: str.row}; + }), + + "l": { + nav: function(editor) { + editor.navigateRight(); + }, + sel: function(editor) { + var pos = editor.getCursorPosition(); + var col = pos.column; + var lineLen = editor.session.getLine(pos.row).length; + + // Solving the behavior at the end of the line due to the + // different 0 index-based colum positions in ACE. + if (lineLen && col !== lineLen) //In selection mode you can select the newline + editor.selection.selectRight(); + } + }, + "h": { + nav: function(editor) { + var pos = editor.getCursorPosition(); + if (pos.column > 0) + editor.navigateLeft(); + }, + sel: function(editor) { + var pos = editor.getCursorPosition(); + if (pos.column > 0) + editor.selection.selectLeft(); + } + }, + "H": { + nav: function(editor) { + var row = editor.renderer.getScrollTopRow(); + editor.moveCursorTo(row); + }, + sel: function(editor) { + var row = editor.renderer.getScrollTopRow(); + editor.selection.selectTo(row); + } + }, + "M": { + nav: function(editor) { + var topRow = editor.renderer.getScrollTopRow(); + var bottomRow = editor.renderer.getScrollBottomRow(); + var row = topRow + ((bottomRow - topRow) / 2); + editor.moveCursorTo(row); + }, + sel: function(editor) { + var topRow = editor.renderer.getScrollTopRow(); + var bottomRow = editor.renderer.getScrollBottomRow(); + var row = topRow + ((bottomRow - topRow) / 2); + editor.selection.selectTo(row); + } + }, + "L": { + nav: function(editor) { + var row = editor.renderer.getScrollBottomRow(); + editor.moveCursorTo(row); + }, + sel: function(editor) { + var row = editor.renderer.getScrollBottomRow(); + editor.selection.selectTo(row); + } + }, + "k": { + nav: function(editor) { + editor.navigateUp(); + }, + sel: function(editor) { + editor.selection.selectUp(); + } + }, + "j": { + nav: function(editor) { + editor.navigateDown(); + }, + sel: function(editor) { + editor.selection.selectDown(); + } + }, + + "i": { + param: true, + sel: function(editor, range, count, param) { + switch (param) { + case "w": + editor.selection.selectWord(); + break; + case "W": + editor.selection.selectAWord(); + break; + case "(": + case "{": + case "[": + var cursor = editor.getCursorPosition(); + var end = editor.session.$findClosingBracket(param, cursor, /paren/); + if (!end) + return; + var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/); + if (!start) + return; + start.column ++; + editor.selection.setSelectionRange(Range.fromPoints(start, end)); + break; + case "'": + case '"': + case "/": + var end = find(editor, param, 1); + if (!end) + return; + var start = find(editor, param, -1); + if (!start) + return; + editor.selection.setSelectionRange(Range.fromPoints(start.end, end.start)); + break; + } + } + }, + "a": { + param: true, + sel: function(editor, range, count, param) { + switch (param) { + case "w": + editor.selection.selectAWord(); + break; + case "W": + editor.selection.selectAWord(); + break; + case "(": + case "{": + case "[": + var cursor = editor.getCursorPosition(); + var end = editor.session.$findClosingBracket(param, cursor, /paren/); + if (!end) + return; + var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/); + if (!start) + return; + end.column ++; + editor.selection.setSelectionRange(Range.fromPoints(start, end)); + break; + case "'": + case "\"": + case "/": + var end = find(editor, param, 1); + if (!end) + return; + var start = find(editor, param, -1); + if (!start) + return; + end.column ++; + editor.selection.setSelectionRange(Range.fromPoints(start.start, end.end)); + break; + } + } + }, + + "f": { + param: true, + handlesCount: true, + nav: function(editor, range, count, param) { + var ed = editor; + var cursor = ed.getCursorPosition(); + var column = util.getRightNthChar(editor, cursor, param, count || 1); + + if (typeof column === "number") { + ed.selection.clearSelection(); // Why does it select in the first place? + ed.moveCursorTo(cursor.row, column + cursor.column + 1); + } + }, + sel: function(editor, range, count, param) { + var ed = editor; + var cursor = ed.getCursorPosition(); + var column = util.getRightNthChar(editor, cursor, param, count || 1); + + if (typeof column === "number") { + ed.moveCursorTo(cursor.row, column + cursor.column + 1); + } + } + }, + "F": { + param: true, + handlesCount: true, + nav: function(editor, range, count, param) { + var ed = editor; + var cursor = ed.getCursorPosition(); + var column = util.getLeftNthChar(editor, cursor, param, count || 1); + + if (typeof column === "number") { + ed.selection.clearSelection(); // Why does it select in the first place? + ed.moveCursorTo(cursor.row, cursor.column - column - 1); + } + }, + sel: function(editor, range, count, param) { + var ed = editor; + var cursor = ed.getCursorPosition(); + var column = util.getLeftNthChar(editor, cursor, param, count || 1); + + if (typeof column === "number") { + ed.moveCursorTo(cursor.row, cursor.column - column - 1); + } + } + }, + "t": { + param: true, + handlesCount: true, + nav: function(editor, range, count, param) { + var ed = editor; + var cursor = ed.getCursorPosition(); + var column = util.getRightNthChar(editor, cursor, param, count || 1); + + if (typeof column === "number") { + ed.selection.clearSelection(); // Why does it select in the first place? + ed.moveCursorTo(cursor.row, column + cursor.column); + } + }, + sel: function(editor, range, count, param) { + var ed = editor; + var cursor = ed.getCursorPosition(); + var column = util.getRightNthChar(editor, cursor, param, count || 1); + + if (typeof column === "number") { + ed.moveCursorTo(cursor.row, column + cursor.column); + } + } + }, + "T": { + param: true, + handlesCount: true, + nav: function(editor, range, count, param) { + var ed = editor; + var cursor = ed.getCursorPosition(); + var column = util.getLeftNthChar(editor, cursor, param, count || 1); + + if (typeof column === "number") { + ed.selection.clearSelection(); // Why does it select in the first place? + ed.moveCursorTo(cursor.row, -column + cursor.column); + } + }, + sel: function(editor, range, count, param) { + var ed = editor; + var cursor = ed.getCursorPosition(); + var column = util.getLeftNthChar(editor, cursor, param, count || 1); + + if (typeof column === "number") { + ed.moveCursorTo(cursor.row, -column + cursor.column); + } + } + }, + + "^": { + nav: function(editor) { + editor.navigateLineStart(); + }, + sel: function(editor) { + editor.selection.selectLineStart(); + } + }, + "$": { + nav: function(editor) { + editor.navigateLineEnd(); + }, + sel: function(editor) { + editor.selection.selectLineEnd(); + } + }, + "0": new Motion(function(ed) { + return {row: ed.selection.lead.row, column: 0}; + }), + "G": { + nav: function(editor, range, count, param) { + if (!count && count !== 0) { // Stupid JS + count = editor.session.getLength(); + } + editor.gotoLine(count); + }, + sel: function(editor, range, count, param) { + if (!count && count !== 0) { // Stupid JS + count = editor.session.getLength(); + } + editor.selection.selectTo(count, 0); + } + }, + "g": { + param: true, + nav: function(editor, range, count, param) { + switch(param) { + case "m": + console.log("Middle line"); + break; + case "e": + console.log("End of prev word"); + break; + case "g": + editor.gotoLine(count || 0); + case "u": + editor.gotoLine(count || 0); + case "U": + editor.gotoLine(count || 0); + } + }, + sel: function(editor, range, count, param) { + switch(param) { + case "m": + console.log("Middle line"); + break; + case "e": + console.log("End of prev word"); + break; + case "g": + editor.selection.selectTo(count || 0, 0); + } + } + }, + "o": { + nav: function(editor, range, count, param) { + count = count || 1; + var content = ""; + while (0 < count--) + content += "\n"; + + if (content.length) { + editor.navigateLineEnd() + editor.insert(content); + util.insertMode(editor); + } + } + }, + "O": { + nav: function(editor, range, count, param) { + var row = editor.getCursorPosition().row; + count = count || 1; + var content = ""; + while (0 < count--) + content += "\n"; + + if (content.length) { + if(row > 0) { + editor.navigateUp(); + editor.navigateLineEnd() + editor.insert(content); + } else { + editor.session.insert({row: 0, column: 0}, content); + editor.navigateUp(); + } + util.insertMode(editor); + } + } + }, + "%": new Motion(function(editor){ + var brRe = /[\[\]{}()]/g; + var cursor = editor.getCursorPosition(); + var ch = editor.session.getLine(cursor.row)[cursor.column]; + if (!brRe.test(ch)) { + var range = find(editor, brRe); + if (!range) + return; + cursor = range.start; + } + var match = editor.session.findMatchingBracket({ + row: cursor.row, + column: cursor.column + 1 + }); + + return match; + }), + "{": new Motion(function(ed) { + var session = ed.session; + var row = session.selection.lead.row; + while(row > 0 && !/\S/.test(session.getLine(row))) + row--; + while(/\S/.test(session.getLine(row))) + row--; + return {column: 0, row: row}; + }), + "}": new Motion(function(ed) { + var session = ed.session; + var l = session.getLength(); + var row = session.selection.lead.row; + while(row < l && !/\S/.test(session.getLine(row))) + row++; + while(/\S/.test(session.getLine(row))) + row++; + return {column: 0, row: row}; + }), + "ctrl-d": { + nav: function(editor, range, count, param) { + editor.selection.clearSelection(); + keepScrollPosition(editor, editor.gotoPageDown); + }, + sel: function(editor, range, count, param) { + keepScrollPosition(editor, editor.selectPageDown); + } + }, + "ctrl-u": { + nav: function(editor, range, count, param) { + editor.selection.clearSelection(); + keepScrollPosition(editor, editor.gotoPageUp); + + }, + sel: function(editor, range, count, param) { + keepScrollPosition(editor, editor.selectPageUp); + } + }, +}; + +module.exports.backspace = module.exports.left = module.exports.h; +module.exports.right = module.exports.l; +module.exports.up = module.exports.k; +module.exports.down = module.exports.j; +module.exports.pagedown = module.exports["ctrl-d"]; +module.exports.pageup = module.exports["ctrl-u"]; + +}); + +ace.define('ace/keyboard/vim/maps/operators', ['require', 'exports', 'module' , 'ace/keyboard/vim/maps/util', 'ace/keyboard/vim/registers'], function(require, exports, module) { + +"never use strict"; + +var util = require("./util"); +var registers = require("../registers"); + +module.exports = { + "d": { + selFn: function(editor, range, count, param) { + registers._default.text = editor.getCopyText(); + registers._default.isLine = util.onVisualLineMode; + if(util.onVisualLineMode) + editor.removeLines(); + else + editor.session.remove(range); + util.normalMode(editor); + }, + fn: function(editor, range, count, param) { + count = count || 1; + switch (param) { + case "d": + registers._default.text = ""; + registers._default.isLine = true; + for (var i = 0; i < count; i++) { + editor.selection.selectLine(); + registers._default.text += editor.getCopyText(); + var selRange = editor.getSelectionRange(); + // check if end of the document was reached + if (!selRange.isMultiLine()) { + lastLineReached = true + var row = selRange.start.row - 1; + var col = editor.session.getLine(row).length + selRange.setStart(row, col); + editor.session.remove(selRange); + editor.selection.clearSelection(); + break; + } + editor.session.remove(selRange); + editor.selection.clearSelection(); + } + registers._default.text = registers._default.text.replace(/\n$/, ""); + break; + default: + if (range) { + editor.selection.setSelectionRange(range); + registers._default.text = editor.getCopyText(); + registers._default.isLine = false; + editor.session.remove(range); + editor.selection.clearSelection(); + } + } + } + }, + "c": { + selFn: function(editor, range, count, param) { + editor.session.remove(range); + util.insertMode(editor); + }, + fn: function(editor, range, count, param) { + count = count || 1; + switch (param) { + case "c": + for (var i = 0; i < count; i++) { + editor.removeLines(); + util.insertMode(editor); + } + + break; + default: + if (range) { + + // range.end.column ++; + editor.session.remove(range); + util.insertMode(editor); + } + } + } + }, + "y": { + selFn: function(editor, range, count, param) { + registers._default.text = editor.getCopyText(); + registers._default.isLine = util.onVisualLineMode; + editor.selection.clearSelection(); + util.normalMode(editor); + }, + fn: function(editor, range, count, param) { + count = count || 1; + switch (param) { + case "y": + var pos = editor.getCursorPosition(); + editor.selection.selectLine(); + for (var i = 0; i < count - 1; i++) { + editor.selection.moveCursorDown(); + } + registers._default.text = editor.getCopyText().replace(/\n$/, ""); + editor.selection.clearSelection(); + registers._default.isLine = true; + editor.moveCursorToPosition(pos); + break; + default: + if (range) { + var pos = editor.getCursorPosition(); + editor.selection.setSelectionRange(range); + registers._default.text = editor.getCopyText(); + registers._default.isLine = false; + editor.selection.clearSelection(); + editor.moveCursorTo(pos.row, pos.column); + } + } + } + }, + ">": { + selFn: function(editor, range, count, param) { + count = count || 1; + for (var i = 0; i < count; i++) { + editor.indent(); + } + util.normalMode(editor); + }, + fn: function(editor, range, count, param) { + count = parseInt(count || 1, 10); + switch (param) { + case ">": + var pos = editor.getCursorPosition(); + editor.selection.selectLine(); + for (var i = 0; i < count - 1; i++) { + editor.selection.moveCursorDown(); + } + editor.indent(); + editor.selection.clearSelection(); + editor.moveCursorToPosition(pos); + editor.navigateLineEnd(); + editor.navigateLineStart(); + break; + } + } + }, + "<": { + selFn: function(editor, range, count, param) { + count = count || 1; + for (var i = 0; i < count; i++) { + editor.blockOutdent(); + } + util.normalMode(editor); + }, + fn: function(editor, range, count, param) { + count = count || 1; + switch (param) { + case "<": + var pos = editor.getCursorPosition(); + editor.selection.selectLine(); + for (var i = 0; i < count - 1; i++) { + editor.selection.moveCursorDown(); + } + editor.blockOutdent(); + editor.selection.clearSelection(); + editor.moveCursorToPosition(pos); + editor.navigateLineEnd(); + editor.navigateLineStart(); + break; + } + } + } +}; +}); + +"use strict" + +ace.define('ace/keyboard/vim/maps/aliases', ['require', 'exports', 'module' ], function(require, exports, module) { +module.exports = { + "x": { + operator: { + char: "d", + count: 1 + }, + motion: { + char: "l", + count: 1 + } + }, + "X": { + operator: { + char: "d", + count: 1 + }, + motion: { + char: "h", + count: 1 + } + }, + "D": { + operator: { + char: "d", + count: 1 + }, + motion: { + char: "$", + count: 1 + } + }, + "C": { + operator: { + char: "c", + count: 1 + }, + motion: { + char: "$", + count: 1 + } + }, + "s": { + operator: { + char: "c", + count: 1 + }, + motion: { + char: "l", + count: 1 + } + }, + "S": { + operator: { + char: "c", + count: 1 + }, + param: "c" + } +}; +}); + diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-c9search.js b/vendor/assets/javascripts/ace-src-noconflict/mode-c9search.js new file mode 100644 index 00000000..9f8401b7 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-c9search.js @@ -0,0 +1,268 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/c9search', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/c9search_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/folding/c9search'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var C9SearchHighlightRules = require("./c9search_highlight_rules").C9SearchHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var C9StyleFoldMode = require("./folding/c9search").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new C9SearchHighlightRules().getRules(), "i"); + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new C9StyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/c9search_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var C9SearchHighlightRules = function() { + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + this.$rules = { + "start" : [ + { + token : ["c9searchresults.constant.numeric", "c9searchresults.text", "c9searchresults.text"], + regex : "(^\\s+[0-9]+)(:\\s*)(.+)" + }, + { + token : ["string", "text"], // single line + regex : "(.+)(:$)" + } + ] + }; +}; + +oop.inherits(C9SearchHighlightRules, TextHighlightRules); + +exports.C9SearchHighlightRules = C9SearchHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + + +ace.define('ace/mode/folding/c9search', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /^(\S.*\:|Searching for.*)$/; + this.foldingStopMarker = /^(\s+|Found.*)$/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var lines = session.doc.getAllLines(row); + var line = lines[row]; + var level1 = /^(Found.*|Searching for.*)$/; + var level2 = /^(\S.*\:|\s*)$/; + var re = level1.test(line) ? level1 : level2; + + if (this.foldingStartMarker.test(line)) { + for (var i = row + 1, l = session.getLength(); i < l; i++) { + if (re.test(lines[i])) + break; + } + + return new Range(row, line.length, i, 0); + } + + if (this.foldingStopMarker.test(line)) { + for (var i = row - 1; i >= 0; i--) { + line = lines[i]; + if (re.test(line)) + break; + } + + return new Range(i, line.length, row, 0); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-c_cpp.js b/vendor/assets/javascripts/ace-src-noconflict/mode-c_cpp.js new file mode 100644 index 00000000..4b128fa4 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-c_cpp.js @@ -0,0 +1,759 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/c_cpp', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/c_cpp_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new c_cppHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/c_cpp_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +// used by objective-c +var cFunctions = exports.cFunctions = "\\s*\\bhypot(?:f|l)?|s(?:scanf|ystem|nprintf|ca(?:nf|lb(?:n(?:f|l)?|ln(?:f|l)?))|i(?:n(?:h(?:f|l)?|f|l)?|gn(?:al|bit))|tr(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(?:jmp|vbuf|locale|buf)|qrt(?:f|l)?|w(?:scanf|printf)|rand)|n(?:e(?:arbyint(?:f|l)?|xt(?:toward(?:f|l)?|after(?:f|l)?))|an(?:f|l)?)|c(?:s(?:in(?:h(?:f|l)?|f|l)?|qrt(?:f|l)?)|cos(?:h(?:f)?|f|l)?|imag(?:f|l)?|t(?:ime|an(?:h(?:f|l)?|f|l)?)|o(?:s(?:h(?:f|l)?|f|l)?|nj(?:f|l)?|pysign(?:f|l)?)|p(?:ow(?:f|l)?|roj(?:f|l)?)|e(?:il(?:f|l)?|xp(?:f|l)?)|l(?:o(?:ck|g(?:f|l)?)|earerr)|a(?:sin(?:h(?:f|l)?|f|l)?|cos(?:h(?:f|l)?|f|l)?|tan(?:h(?:f|l)?|f|l)?|lloc|rg(?:f|l)?|bs(?:f|l)?)|real(?:f|l)?|brt(?:f|l)?)|t(?:ime|o(?:upper|lower)|an(?:h(?:f|l)?|f|l)?|runc(?:f|l)?|gamma(?:f|l)?|mp(?:nam|file))|i(?:s(?:space|n(?:ormal|an)|cntrl|inf|digit|u(?:nordered|pper)|p(?:unct|rint)|finite|w(?:space|c(?:ntrl|type)|digit|upper|p(?:unct|rint)|lower|al(?:num|pha)|graph|xdigit|blank)|l(?:ower|ess(?:equal|greater)?)|al(?:num|pha)|gr(?:eater(?:equal)?|aph)|xdigit|blank)|logb(?:f|l)?|max(?:div|abs))|di(?:v|fftime)|_Exit|unget(?:c|wc)|p(?:ow(?:f|l)?|ut(?:s|c(?:har)?|wc(?:har)?)|error|rintf)|e(?:rf(?:c(?:f|l)?|f|l)?|x(?:it|p(?:2(?:f|l)?|f|l|m1(?:f|l)?)?))|v(?:s(?:scanf|nprintf|canf|printf|w(?:scanf|printf))|printf|f(?:scanf|printf|w(?:scanf|printf))|w(?:scanf|printf)|a_(?:start|copy|end|arg))|qsort|f(?:s(?:canf|e(?:tpos|ek))|close|tell|open|dim(?:f|l)?|p(?:classify|ut(?:s|c|w(?:s|c))|rintf)|e(?:holdexcept|set(?:e(?:nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(?:aiseexcept|ror)|get(?:e(?:nv|xceptflag)|round))|flush|w(?:scanf|ide|printf|rite)|loor(?:f|l)?|abs(?:f|l)?|get(?:s|c|pos|w(?:s|c))|re(?:open|e|ad|xp(?:f|l)?)|m(?:in(?:f|l)?|od(?:f|l)?|a(?:f|l|x(?:f|l)?)?))|l(?:d(?:iv|exp(?:f|l)?)|o(?:ngjmp|cal(?:time|econv)|g(?:1(?:p(?:f|l)?|0(?:f|l)?)|2(?:f|l)?|f|l|b(?:f|l)?)?)|abs|l(?:div|abs|r(?:int(?:f|l)?|ound(?:f|l)?))|r(?:int(?:f|l)?|ound(?:f|l)?)|gamma(?:f|l)?)|w(?:scanf|c(?:s(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?|mbs)|pbrk|ftime|len|r(?:chr|tombs)|xfrm)|to(?:b|mb)|rtomb)|printf|mem(?:set|c(?:hr|py|mp)|move))|a(?:s(?:sert|ctime|in(?:h(?:f|l)?|f|l)?)|cos(?:h(?:f|l)?|f|l)?|t(?:o(?:i|f|l(?:l)?)|exit|an(?:h(?:f|l)?|2(?:f|l)?|f|l)?)|b(?:s|ort))|g(?:et(?:s|c(?:har)?|env|wc(?:har)?)|mtime)|r(?:int(?:f|l)?|ound(?:f|l)?|e(?:name|alloc|wind|m(?:ove|quo(?:f|l)?|ainder(?:f|l)?))|a(?:nd|ise))|b(?:search|towc)|m(?:odf(?:f|l)?|em(?:set|c(?:hr|py|mp)|move)|ktime|alloc|b(?:s(?:init|towcs|rtowcs)|towc|len|r(?:towc|len)))\\b" + +var c_cppHighlightRules = function() { + + var keywordControls = ( + "break|case|continue|default|do|else|for|goto|if|_Pragma|" + + "return|switch|while|catch|operator|try|throw|using" + ); + + var storageType = ( + "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" + + "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void" + + "class|wchar_t|template" + ); + + var storageModifiers = ( + "const|extern|register|restrict|static|volatile|inline|private:|" + + "protected:|public:|friend|explicit|virtual|export|mutable|typename" + ); + + var keywordOperators = ( + "and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq" + + "const_cast|dynamic_cast|reinterpret_cast|static_cast|sizeof|namespace" + ); + + var builtinConstants = ( + "NULL|true|false|TRUE|FALSE" + ); + + var keywordMapper = this.createKeywordMapper({ + "keyword.control" : keywordControls, + "storage.type" : storageType, + "storage.modifier" : storageModifiers, + "keyword.operator" : keywordOperators, + "variable.language": "this", + "constant.language": builtinConstants + }, "identifier"); + + var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\d\\$_\u00a1-\uffff]*\\b"; + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*\\\\$', + next : "qqstring" + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*\\\\$", + next : "qstring" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant", // + regex : "<[a-zA-Z0-9.]+>" + }, { + token : "keyword", // pre-compiler directivs + regex : "(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)" + }, { + token : "support.function.C99.c", + regex : cFunctions + }, { + // function myFunc(arg) { } + token : [ + "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(\\s+)(" + identifierRe + ")(\\s*)(\\()" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)" + }, { + token : "punctuation.operator", + regex : "\\?|\\:|\\,|\\;|\\." + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "string", + regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ], + "qstring" : [ + { + token : "string", + regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(c_cppHighlightRules, TextHighlightRules); + +exports.c_cppHighlightRules = c_cppHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-clojure.js b/vendor/assets/javascripts/ace-src-noconflict/mode-clojure.js new file mode 100644 index 00000000..6aa6fd71 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-clojure.js @@ -0,0 +1,347 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/clojure', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/clojure_highlight_rules', 'ace/mode/matching_parens_outdent', 'ace/range'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var ClojureHighlightRules = require("./clojure_highlight_rules").ClojureHighlightRules; +var MatchingParensOutdent = require("./matching_parens_outdent").MatchingParensOutdent; +var Range = require("../range").Range; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new ClojureHighlightRules().getRules()); + this.$outdent = new MatchingParensOutdent(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)#/; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, ";"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/[\(\[]/); + if (match) { + indent += " "; + } + match = line.match(/[\)]/); + if (match) { + indent = ""; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/clojure_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + + + +var ClojureHighlightRules = function() { + + var builtinFunctions = ( + '* *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* ' + + '*command-line-args* *compile-files* *compile-path* *e *err* *file* ' + + '*flush-on-newline* *in* *macro-meta* *math-context* *ns* *out* ' + + '*print-dup* *print-length* *print-level* *print-meta* *print-readably* ' + + '*read-eval* *source-path* *use-context-classloader* ' + + '*warn-on-reflection* + - -> ->> .. / < <= = ' + + '== > > >= >= accessor aclone ' + + 'add-classpath add-watch agent agent-errors aget alength alias all-ns ' + + 'alter alter-meta! alter-var-root amap ancestors and apply areduce ' + + 'array-map aset aset-boolean aset-byte aset-char aset-double aset-float ' + + 'aset-int aset-long aset-short assert assoc assoc! assoc-in associative? ' + + 'atom await await-for await1 bases bean bigdec bigint binding bit-and ' + + 'bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left ' + + 'bit-shift-right bit-test bit-xor boolean boolean-array booleans ' + + 'bound-fn bound-fn* butlast byte byte-array bytes cast char char-array ' + + 'char-escape-string char-name-string char? chars chunk chunk-append ' + + 'chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? ' + + 'class class? clear-agent-errors clojure-version coll? comment commute ' + + 'comp comparator compare compare-and-set! compile complement concat cond ' + + 'condp conj conj! cons constantly construct-proxy contains? count ' + + 'counted? create-ns create-struct cycle dec decimal? declare definline ' + + 'defmacro defmethod defmulti defn defn- defonce defstruct delay delay? ' + + 'deliver deref derive descendants destructure disj disj! dissoc dissoc! ' + + 'distinct distinct? doall doc dorun doseq dosync dotimes doto double ' + + 'double-array doubles drop drop-last drop-while empty empty? ensure ' + + 'enumeration-seq eval even? every? false? ffirst file-seq filter find ' + + 'find-doc find-ns find-var first float float-array float? floats flush ' + + 'fn fn? fnext for force format future future-call future-cancel ' + + 'future-cancelled? future-done? future? gen-class gen-interface gensym ' + + 'get get-in get-method get-proxy-class get-thread-bindings get-validator ' + + 'hash hash-map hash-set identical? identity if-let if-not ifn? import ' + + 'in-ns inc init-proxy instance? int int-array integer? interleave intern ' + + 'interpose into into-array ints io! isa? iterate iterator-seq juxt key ' + + 'keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list ' + + 'list* list? load load-file load-reader load-string loaded-libs locking ' + + 'long long-array longs loop macroexpand macroexpand-1 make-array ' + + 'make-hierarchy map map? mapcat max max-key memfn memoize merge ' + + 'merge-with meta method-sig methods min min-key mod name namespace neg? ' + + 'newline next nfirst nil? nnext not not-any? not-empty not-every? not= ' + + 'ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ' + + 'ns-refers ns-resolve ns-unalias ns-unmap nth nthnext num number? odd? ' + + 'or parents partial partition pcalls peek persistent! pmap pop pop! ' + + 'pop-thread-bindings pos? pr pr-str prefer-method prefers ' + + 'primitives-classnames print print-ctor print-doc print-dup print-method ' + + 'print-namespace-doc print-simple print-special-doc print-str printf ' + + 'println println-str prn prn-str promise proxy proxy-call-with-super ' + + 'proxy-mappings proxy-name proxy-super push-thread-bindings pvalues quot ' + + 'rand rand-int range ratio? rational? rationalize re-find re-groups ' + + 're-matcher re-matches re-pattern re-seq read read-line read-string ' + + 'reduce ref ref-history-count ref-max-history ref-min-history ref-set ' + + 'refer refer-clojure release-pending-sends rem remove remove-method ' + + 'remove-ns remove-watch repeat repeatedly replace replicate require ' + + 'reset! reset-meta! resolve rest resultset-seq reverse reversible? rseq ' + + 'rsubseq second select-keys send send-off seq seq? seque sequence ' + + 'sequential? set set-validator! set? short short-array shorts ' + + 'shutdown-agents slurp some sort sort-by sorted-map sorted-map-by ' + + 'sorted-set sorted-set-by sorted? special-form-anchor special-symbol? ' + + 'split-at split-with str stream? string? struct struct-map subs subseq ' + + 'subvec supers swap! symbol symbol? sync syntax-symbol-anchor take ' + + 'take-last take-nth take-while test the-ns time to-array to-array-2d ' + + 'trampoline transient tree-seq true? type unchecked-add unchecked-dec ' + + 'unchecked-divide unchecked-inc unchecked-multiply unchecked-negate ' + + 'unchecked-remainder unchecked-subtract underive unquote ' + + 'unquote-splicing update-in update-proxy use val vals var-get var-set ' + + 'var? vary-meta vec vector vector? when when-first when-let when-not ' + + 'while with-bindings with-bindings* with-in-str with-loading-context ' + + 'with-local-vars with-meta with-open with-out-str with-precision xml-seq ' + + 'zero? zipmap' + ); + + var keywords = ('throw try var ' + + 'def do fn if let loop monitor-enter monitor-exit new quote recur set!' + ); + + var buildinConstants = ("true false nil"); + + var keywordMapper = this.createKeywordMapper({ + "keyword": keywords, + "constant.language": buildinConstants, + "support.function": builtinFunctions + }, "identifier", false, " "); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : ";.*$" + }, { + token : "comment", // multi line comment + regex : "^=begin$", + next : "comment" + }, { + token : "keyword", //parens + regex : "[\\(|\\)]" + }, { + token : "keyword", //lists + regex : "[\\'\\(]" + }, { + token : "keyword", //vectors + regex : "[\\[|\\]]" + }, { + token : "keyword", //sets and maps + regex : "[\\{|\\}|\\#\\{|\\#\\}]" + }, { + token : "keyword", // ampersands + regex : '[\\&]' + }, { + token : "keyword", // metadata + regex : '[\\#\\^\\{]' + }, { + token : "keyword", // anonymous fn syntactic sugar + regex : '[\\%]' + }, { + token : "keyword", // deref reader macro + regex : '[@]' + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language", + regex : '[!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+||=|!=|<=|>=|<>|<|>|!|&&]' + }, { + token : keywordMapper, + // TODO: Unicode escape sequences + // TODO: Unicode identifiers + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "string", // single line + regex : '"', + next: "string" + }, { + token : "string", // symbol + regex : "[:](?:[a-zA-Z]|\\d)+" + }, { + token : "string.regexp", //Regular Expressions + regex : '/#"(?:\\.|(?:\\\")|[^\""\n])*"/g' + } + + ], + "comment" : [ + { + token : "comment", // closing comment + regex : "^=end$", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "string" : [ + { + token : "constant.language.escape", + merge : true, + regex : "\\\\.|\\\\$" + }, { + token : "string", + merge : true, + regex : '[^"\\\\]+' + }, { + token : "string", + regex : '"', + next : "start" + } + ] + }; +}; + +oop.inherits(ClojureHighlightRules, TextHighlightRules); + +exports.ClojureHighlightRules = ClojureHighlightRules; +}); + +ace.define('ace/mode/matching_parens_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingParensOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\)/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\))/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingParensOutdent.prototype); + +exports.MatchingParensOutdent = MatchingParensOutdent; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-coffee.js b/vendor/assets/javascripts/ace-src-noconflict/mode-coffee.js new file mode 100644 index 00000000..b1d5e5f2 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-coffee.js @@ -0,0 +1,513 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/coffee', ['require', 'exports', 'module' , 'ace/tokenizer', 'ace/mode/coffee_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/folding/coffee', 'ace/range', 'ace/mode/text', 'ace/worker/worker_client', 'ace/lib/oop'], function(require, exports, module) { + + +var Tokenizer = require("../tokenizer").Tokenizer; +var Rules = require("./coffee_highlight_rules").CoffeeHighlightRules; +var Outdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var FoldMode = require("./folding/coffee").FoldMode; +var Range = require("../range").Range; +var TextMode = require("./text").Mode; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var oop = require("../lib/oop"); + +function Mode() { + this.$tokenizer = new Tokenizer(new Rules().getRules()); + this.$outdent = new Outdent(); + this.foldingRules = new FoldMode(); +} + +oop.inherits(Mode, TextMode); + +(function() { + + var indenter = /(?:[({[=:]|[-=]>|\b(?:else|switch|try|catch(?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$/; + var commentLine = /^(\s*)#/; + var hereComment = /^\s*###(?!#)/; + var indentation = /^\s*/; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + var tokens = this.$tokenizer.getLineTokens(line, state).tokens; + + if (!(tokens.length && tokens[tokens.length - 1].type === 'comment') && + state === 'start' && indenter.test(line)) + indent += tab; + return indent; + }; + + this.toggleCommentLines = function(state, doc, startRow, endRow){ + console.log("toggle"); + var range = new Range(0, 0, 0, 0); + for (var i = startRow; i <= endRow; ++i) { + var line = doc.getLine(i); + if (hereComment.test(line)) + continue; + + if (commentLine.test(line)) + line = line.replace(commentLine, '$1'); + else + line = line.replace(indentation, '$&#'); + + range.end.row = range.start.row = i; + range.end.column = line.length + 1; + doc.replace(range, line); + } + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/coffee_worker", "Worker"); + worker.attachToDocument(session.getDocument()); + + worker.on("error", function(e) { + session.setAnnotations([e.data]); + }); + + worker.on("ok", function(e) { + session.clearAnnotations(); + }); + + return worker; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/coffee_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + + var oop = require("../lib/oop"); + var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + + oop.inherits(CoffeeHighlightRules, TextHighlightRules); + + function CoffeeHighlightRules() { + var identifier = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*"; + var stringfill = { + token : "string", + merge : true, + regex : ".+" + }; + + var keywords = ( + "this|throw|then|try|typeof|super|switch|return|break|by)|continue|" + + "catch|class|in|instanceof|is|isnt|if|else|extends|for|forown|" + + "finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|" + + "or|on|unless|until|and|yes" + ); + + var langConstant = ( + "true|false|null|undefined" + ); + + var illegal = ( + "case|const|default|function|var|void|with|enum|export|implements|" + + "interface|let|package|private|protected|public|static|yield|" + + "__hasProp|extends|slice|bind|indexOf" + ); + + var supportClass = ( + "Array|Boolean|Date|Function|Number|Object|RegExp|ReferenceError|" + + "String|RangeError|SyntaxError|Error|EvalError|TypeError|URIError" + ); + + var supportFunction = ( + "Math|JSON|isNaN|isFinite|parseInt|parseFloat|encodeURI|" + + "encodeURIComponent|decodeURI|decodeURIComponent|String|" + ); + + var keywordMapper = this.createKeywordMapper({ + "keyword": keywords, + "constant.language": langConstant, + "invalid.illegal": illegal, + "language.support.class": supportClass, + "language.support.function": supportFunction, + }, "identifier"); + + this.$rules = { + start : [ + { + token : "identifier", + regex : "(?:(?:\\.|::)\\s*)" + identifier + }, { + token : "variable", + regex : "@(?:" + identifier + ")?" + }, { + token: keywordMapper, + regex : identifier + }, { + token : "constant.numeric", + regex : "(?:0x[\\da-fA-F]+|(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?)" + }, { + token : "string", + merge : true, + regex : "'''", + next : "qdoc" + }, { + token : "string", + merge : true, + regex : '"""', + next : "qqdoc" + }, { + token : "string", + merge : true, + regex : "'", + next : "qstring" + }, { + token : "string", + merge : true, + regex : '"', + next : "qqstring" + }, { + token : "string", + merge : true, + regex : "`", + next : "js" + }, { + token : "string.regex", + merge : true, + regex : "///", + next : "heregex" + }, { + token : "string.regex", + regex : "/(?!\\s)[^[/\\n\\\\]*(?: (?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[/\\n\\\\]*)*/[imgy]{0,4}(?!\\w)" + }, { + token : "comment", + merge : true, + regex : "###(?!#)", + next : "comment" + }, { + token : "comment", + regex : "#.*" + }, { + token : "punctuation.operator", + regex : "\\?|\\:|\\,|\\." + }, { + token : "keyword.operator", + regex : "(?:[\\-=]>|[-+*/%<>&|^!?=]=|>>>=?|\\-\\-|\\+\\+|::|&&=|\\|\\|=|<<=|>>=|\\?\\.|\\.{2,3}|[!*+-=><])" + }, { + token : "paren.lparen", + regex : "[({[]" + }, { + token : "paren.rparen", + regex : "[\\]})]" + }, { + token : "text", + regex : "\\s+" + }], + + qdoc : [{ + token : "string", + regex : ".*?'''", + next : "start" + }, stringfill], + + qqdoc : [{ + token : "string", + regex : '.*?"""', + next : "start" + }, stringfill], + + qstring : [{ + token : "string", + regex : "[^\\\\']*(?:\\\\.[^\\\\']*)*'", + merge : true, + next : "start" + }, stringfill], + + qqstring : [{ + token : "string", + regex : '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"', + merge : true, + next : "start" + }, stringfill], + + js : [{ + token : "string", + merge : true, + regex : "[^\\\\`]*(?:\\\\.[^\\\\`]*)*`", + next : "start" + }, stringfill], + + heregex : [{ + token : "string.regex", + regex : '.*?///[imgy]{0,4}', + next : "start" + }, { + token : "comment.regex", + regex : "\\s+(?:#.*)?" + }, { + token : "string.regex", + merge : true, + regex : "\\S+" + }], + + comment : [{ + token : "comment", + regex : '.*?###', + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + }] + }; + } + + exports.CoffeeHighlightRules = CoffeeHighlightRules; +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/folding/coffee', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var BaseFoldMode = require("./fold_mode").FoldMode; +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var range = this.indentationBlock(session, row); + if (range) + return range; + + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1 || line[startLevel] != "#") + return; + + var startColumn = line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + line = session.getLine(row); + var level = line.search(re); + + if (level == -1) + continue; + + if (line[level] != "#") + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + var indent = line.search(/\S/); + var next = session.getLine(row + 1); + var prev = session.getLine(row - 1); + var prevIndent = prev.search(/\S/); + var nextIndent = next.search(/\S/); + + if (indent == -1) { + session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : ""; + return ""; + } + + // documentation comments + if (prevIndent == -1) { + if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") { + session.foldWidgets[row - 1] = ""; + session.foldWidgets[row + 1] = ""; + return "start"; + } + } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") { + if (session.getLine(row - 2).search(/\S/) == -1) { + session.foldWidgets[row - 1] = "start"; + session.foldWidgets[row + 1] = ""; + return ""; + } + } + + if (prevIndent!= -1 && prevIndent < indent) + session.foldWidgets[row - 1] = "start"; + else + session.foldWidgets[row - 1] = ""; + + if (indent < nextIndent) + return "start"; + else + return ""; + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-coldfusion.js b/vendor/assets/javascripts/ace-src-noconflict/mode-coldfusion.js new file mode 100644 index 00000000..1b41d001 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-coldfusion.js @@ -0,0 +1,1852 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/coldfusion', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml', 'ace/mode/javascript', 'ace/mode/css', 'ace/tokenizer', 'ace/mode/coldfusion_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var XmlMode = require("./xml").Mode; +var JavaScriptMode = require("./javascript").Mode; +var CssMode = require("./css").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var ColdfusionHighlightRules = require("./coldfusion_highlight_rules").ColdfusionHighlightRules; + +var Mode = function() { + XmlMode.call(this); + + var highlighter = new ColdfusionHighlightRules(); + this.$tokenizer = new Tokenizer(highlighter.getRules()); + + this.$embeds = highlighter.getEmbeds(); + this.createModeDelegates({ + "js-": JavaScriptMode, + "css-": CssMode + }); +}; +oop.inherits(Mode, XmlMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + return this.$getIndent(line); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xml_highlight_rules', 'ace/mode/behaviour/xml', 'ace/mode/folding/xml'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules; +var XmlBehaviour = require("./behaviour/xml").XmlBehaviour; +var XmlFoldMode = require("./folding/xml").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules()); + this.$behaviour = new XmlBehaviour(); + this.foldingRules = new XmlFoldMode(); +}; + +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + return this.$getIndent(line); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/xml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var xmlUtil = require("./xml_util"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var XmlHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + this.$rules = { + start : [{ + token : "text", + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "xml_pe", + regex : "<\\!.*?>" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "constant.character.entity", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }, { + token : "text", + regex : "[^<]+" + }], + + cdata : [{ + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + regex : "\\s+" + }, { + token : "text", + regex : "(?:[^\\]]|\\](?!\\]>))+" + }], + + comment : [{ + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + }] + }; + + xmlUtil.tag(this.$rules, "tag", "start"); +}; + +oop.inherits(XmlHighlightRules, TextHighlightRules); + +exports.XmlHighlightRules = XmlHighlightRules; +}); + +ace.define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) { + + +function string(state) { + return [{ + token : "string", + regex : '".*?"' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*', + next : state + "_qqstring" + }, { + token : "string", + regex : "'.*?'" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*", + next : state + "_qstring" + }]; +} + +function multiLineString(quote, state) { + return [{ + token : "string", + merge : true, + regex : ".*?" + quote, + next : state + }, { + token : "string", + merge : true, + regex : '.+' + }]; +} + +exports.tag = function(states, name, nextState, tagMap) { + states[name] = [{ + token : "text", + regex : "\\s+" + }, { + //token : "meta.tag", + + token : !tagMap ? "meta.tag.tag-name" : function(value) { + if (tagMap[value]) + return "meta.tag.tag-name." + tagMap[value]; + else + return "meta.tag.tag-name"; + }, + merge : true, + regex : "[-_a-zA-Z0-9:]+", + next : name + "_embed_attribute_list" + }, { + token: "empty", + regex: "", + next : name + "_embed_attribute_list" + }]; + + states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list"); + states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list"); + + states[name + "_embed_attribute_list"] = [{ + token : "meta.tag", + merge : true, + regex : "\/?>", + next : nextState + }, { + token : "keyword.operator", + regex : "=" + }, { + token : "entity.other.attribute-name", + regex : "[-_a-zA-Z0-9:]+" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "text", + regex : "\\s+" + }].concat(string(name)); +}; + +}); + +ace.define('ace/mode/behaviour/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; + +function hasType(token, type) { + var hasType = true; + var typeList = token.type.split('.'); + var needleList = type.split('.'); + needleList.forEach(function(needle){ + if (typeList.indexOf(needle) == -1) { + hasType = false; + return false; + } + }); + return hasType; +} + +var XmlBehaviour = function () { + + this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour + + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { + if (text == '>') { + var position = editor.getCursorPosition(); + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken(); + var atCursor = false; + if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ + do { + token = iterator.stepBackward(); + } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); + } else { + atCursor = true; + } + if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) { + return + } + var tag = token.value; + if (atCursor){ + var tag = tag.substring(0, position.column - token.start); + } + + return { + text: '>' + '', + selection: [1, 1] + } + } + }); + + this.add('autoindent', 'insertion', function (state, action, editor, session, text) { + if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChars = line.substring(cursor.column, cursor.column + 2); + if (rightChars == ' selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/range', 'ace/mode/folding/fold_mode', 'ace/token_iterator'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var lang = require("../../lib/lang"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; +var TokenIterator = require("../../token_iterator").TokenIterator; + +var FoldMode = exports.FoldMode = function(voidElements) { + BaseFoldMode.call(this); + this.voidElements = voidElements || {}; +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.getFoldWidget = function(session, foldStyle, row) { + var tag = this._getFirstTagInLine(session, row); + + if (tag.closing) + return foldStyle == "markbeginend" ? "end" : ""; + + if (!tag.tagName || this.voidElements[tag.tagName.toLowerCase()]) + return ""; + + if (tag.selfClosing) + return ""; + + if (tag.value.indexOf("/" + tag.tagName) !== -1) + return ""; + + return "start"; + }; + + this._getFirstTagInLine = function(session, row) { + var tokens = session.getTokens(row); + var value = ""; + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + if (token.type.indexOf("meta.tag") === 0) + value += token.value; + else + value += lang.stringRepeat(" ", token.value.length); + } + + return this._parseTag(value); + }; + + this.tagRe = /^(\s*)(?)/; + this._parseTag = function(tag) { + + var match = this.tagRe.exec(tag); + var column = this.tagRe.lastIndex || 0; + this.tagRe.lastIndex = 0; + + return { + value: tag, + match: match ? match[2] : "", + closing: match ? !!match[3] : false, + selfClosing: match ? !!match[5] || match[2] == "/>" : false, + tagName: match ? match[4] : "", + column: match[1] ? column + match[1].length : column + }; + }; + this._readTagForward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var start; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!start) { + var start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + } + value += token.value; + if (value.indexOf(">") !== -1) { + var tag = this._parseTag(value); + tag.start = start; + tag.end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + iterator.stepForward(); + return tag; + } + } + } while(token = iterator.stepForward()); + + return null; + }; + + this._readTagBackward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var end; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!end) { + end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + } + value = token.value + value; + if (value.indexOf("<") !== -1) { + var tag = this._parseTag(value); + tag.end = end; + tag.start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + iterator.stepBackward(); + return tag; + } + } + } while(token = iterator.stepBackward()); + + return null; + }; + + this._pop = function(stack, tag) { + while (stack.length) { + + var top = stack[stack.length-1]; + if (!tag || top.tagName == tag.tagName) { + return stack.pop(); + } + else if (this.voidElements[tag.tagName]) { + return; + } + else if (this.voidElements[top.tagName]) { + stack.pop(); + continue; + } else { + return null; + } + } + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var firstTag = this._getFirstTagInLine(session, row); + + if (!firstTag.match) + return null; + + var isBackward = firstTag.closing || firstTag.selfClosing; + var stack = []; + var tag; + + if (!isBackward) { + var iterator = new TokenIterator(session, row, firstTag.column); + var start = { + row: row, + column: firstTag.column + firstTag.tagName.length + 2 + }; + while (tag = this._readTagForward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) + return Range.fromPoints(start, tag.start); + } + else { + stack.push(tag) + } + } + } + else { + var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length); + var end = { + row: row, + column: firstTag.column + }; + + while (tag = this._readTagBackward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (!tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) { + tag.start.column += tag.tagName.length + 2; + return Range.fromPoints(tag.start, end); + } + } + else { + stack.push(tag) + } + } + } + + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start" || state == "regex_allowed") { + var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start" || state == "regex_allowed") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); + worker.attachToDocument(session.getDocument()); + + worker.on("jslint", function(results) { + var errors = []; + for (var i=0; i the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + // Sound.prototype.play = + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + // Sound.play = function() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // play = function() { } + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + // function myFunc(arg) { } + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + // foobar: function() { } + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + // escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + // invalid operators + token : "invalid", + regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?] + }, { + // operators + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/ + }, { + token: "string.regexp", + regex: /{|[^\[\\{()$^+*?\/]+/, + merge: true + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex", + merge: true + }, { + token: "constant.language.escape", + regex: "-", + }, { + token: "string.regexp.charachterclass", + regex: /[^\]\-\\]+/, + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/css', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/css_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/worker/worker_client', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules(), "i"); + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.foldingRules = "cStyle"; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + // ignore braces in comments + var tokens = this.$tokenizer.getLineTokens(line, state).tokens; + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + var match = line.match(/^.*\{\s*$/); + if (match) { + indent += tab; + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker"); + worker.attachToDocument(session.getDocument()); + + worker.on("csslint", function(e) { + var errors = []; + e.data.forEach(function(message) { + errors.push({ + row: message.line - 1, + column: message.col - 1, + text: message.message, + type: message.type, + lint: message + }); + }); + + session.setAnnotations(errors); + }); + return worker; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CssHighlightRules = function() { + var keywordMapper = this.createKeywordMapper({ + "support.type": "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index", + "support.function": "rgb|rgba|url|attr|counter|counters", + "support.constant": "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero", + "support.constant.color": "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow", + "support.constant.fonts": "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace" + }, "text", true); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b"; + var pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b"; + + var base_ruleset = [ + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "ruleset_comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : ["constant.numeric", "keyword"], + regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)" + }, { + token : ["constant.numeric"], + regex : "([0-9]+)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"], + regex : pseudoElements + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], + regex : pseudoClasses + }, { + token : keywordMapper, + regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" + } + ]; + + var ruleset = lang.copyArray(base_ruleset); + ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "start" + }); + + var media_ruleset = lang.copyArray( base_ruleset ); + media_ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "media" + }); + + var base_comment = [{ + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + }]; + + var comment = lang.copyArray(base_comment); + comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }); + + var media_comment = lang.copyArray(base_comment); + media_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "media" + }); + + var ruleset_comment = lang.copyArray(base_comment); + ruleset_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "ruleset" + }); + + this.$rules = { + "start" : [{ + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "ruleset" + }, { + token: "string", + regex: "@.*?{", + next: "media" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "media" : [ { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "media_comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "media_ruleset" + },{ + token: "string", + regex: "\\}", + next: "start" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "comment" : comment, + + "ruleset" : ruleset, + "ruleset_comment" : ruleset_comment, + + "media_ruleset" : media_ruleset, + "media_comment" : media_comment + }; +}; + +oop.inherits(CssHighlightRules, TextHighlightRules); + +exports.CssHighlightRules = CssHighlightRules; + +}); + +ace.define('ace/mode/coldfusion_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/text_highlight_rules', 'ace/mode/xml_util'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; +var xml_util = require("./xml_util"); + +var ColdfusionHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + + this.$rules = { + start : [ { + token : "text", + merge : true, + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "meta.tag", + regex : "<(?=\s*script)", + next : "script" + }, { + token : "meta.tag", + regex : "<(?=\s*style)", + next : "style" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "text", + regex : "[^<]+" + } ], + + cdata : [ { + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + merge : true, + regex : "\\s+" + }, { + token : "text", + merge : true, + regex : ".+" + } ], + + comment : [ { + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + } ] + }; + + xml_util.tag(this.$rules, "tag", "start"); + xml_util.tag(this.$rules, "style", "css-start"); + xml_util.tag(this.$rules, "script", "js-start"); + + this.embedRules(JavaScriptHighlightRules, "js-", [{ + token: "comment", + regex: "\\/\\/.*(?=<\\/script>)", + next: "tag" + }, { + token: "meta.tag", + regex: "<\\/(?=script)", + next: "tag" + }]); + + this.embedRules(CssHighlightRules, "css-", [{ + token: "meta.tag", + regex: "<\\/(?=style)", + next: "tag" + }]); +}; + +oop.inherits(ColdfusionHighlightRules, TextHighlightRules); + +exports.ColdfusionHighlightRules = ColdfusionHighlightRules; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-csharp.js b/vendor/assets/javascripts/ace-src-noconflict/mode-csharp.js new file mode 100644 index 00000000..7aa8082f --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-csharp.js @@ -0,0 +1,619 @@ +ace.define('ace/mode/csharp', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/csharp_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new CSharpHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + + this.createWorker = function(session) { + return null; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); +ace.define('ace/mode/csharp_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CSharpHighlightRules = function() { + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": "abstract|event|new|struct|as|explicit|null|switch|base|extern|object|this|bool|false|operator|throw|break|finally|out|true|byte|fixed|override|try|case|float|params|typeof|catch|for|private|uint|char|foreach|protected|ulong|checked|goto|public|unchecked|class|if|readonly|unsafe|const|implicit|ref|ushort|continue|in|return|using|decimal|int|sbyte|virtual|default|interface|sealed|volatile|delegate|internal|short|void|do|is|sizeof|while|double|lock|stackalloc|else|long|static|enum|namespace|string|var|dynamic", + "constant.language": "null|true|false" + }, "identifier"); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + regex : "\\/\\*", + merge : true, + next : "comment" + }, { + token : "string.regexp", + regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "(?:true|false)\\b" + }, { + token : keywordMapper, + // TODO: Unicode escape sequences + // TODO: Unicode identifiers + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "punctuation.operator", + regex : "\\?|\\:|\\,|\\;|\\." + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(CSharpHighlightRules, TextHighlightRules); + +exports.CSharpHighlightRules = CSharpHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-css.js b/vendor/assets/javascripts/ace-src-noconflict/mode-css.js new file mode 100644 index 00000000..48665f95 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-css.js @@ -0,0 +1,457 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/css', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/css_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/worker/worker_client', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules(), "i"); + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.foldingRules = "cStyle"; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + // ignore braces in comments + var tokens = this.$tokenizer.getLineTokens(line, state).tokens; + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + var match = line.match(/^.*\{\s*$/); + if (match) { + indent += tab; + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker"); + worker.attachToDocument(session.getDocument()); + + worker.on("csslint", function(e) { + var errors = []; + e.data.forEach(function(message) { + errors.push({ + row: message.line - 1, + column: message.col - 1, + text: message.message, + type: message.type, + lint: message + }); + }); + + session.setAnnotations(errors); + }); + return worker; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CssHighlightRules = function() { + var keywordMapper = this.createKeywordMapper({ + "support.type": "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index", + "support.function": "rgb|rgba|url|attr|counter|counters", + "support.constant": "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero", + "support.constant.color": "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow", + "support.constant.fonts": "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace" + }, "text", true); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b"; + var pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b"; + + var base_ruleset = [ + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "ruleset_comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : ["constant.numeric", "keyword"], + regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)" + }, { + token : ["constant.numeric"], + regex : "([0-9]+)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"], + regex : pseudoElements + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], + regex : pseudoClasses + }, { + token : keywordMapper, + regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" + } + ]; + + var ruleset = lang.copyArray(base_ruleset); + ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "start" + }); + + var media_ruleset = lang.copyArray( base_ruleset ); + media_ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "media" + }); + + var base_comment = [{ + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + }]; + + var comment = lang.copyArray(base_comment); + comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }); + + var media_comment = lang.copyArray(base_comment); + media_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "media" + }); + + var ruleset_comment = lang.copyArray(base_comment); + ruleset_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "ruleset" + }); + + this.$rules = { + "start" : [{ + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "ruleset" + }, { + token: "string", + regex: "@.*?{", + next: "media" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "media" : [ { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "media_comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "media_ruleset" + },{ + token: "string", + regex: "\\}", + next: "start" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "comment" : comment, + + "ruleset" : ruleset, + "ruleset_comment" : ruleset_comment, + + "media_ruleset" : media_ruleset, + "media_comment" : media_comment + }; +}; + +oop.inherits(CssHighlightRules, TextHighlightRules); + +exports.CssHighlightRules = CssHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-diff.js b/vendor/assets/javascripts/ace-src-noconflict/mode-diff.js new file mode 100644 index 00000000..75e26cc7 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-diff.js @@ -0,0 +1,244 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/diff', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/diff_highlight_rules', 'ace/mode/folding/diff'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var HighlightRules = require("./diff_highlight_rules").DiffHighlightRules; +var FoldMode = require("./folding/diff").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new HighlightRules().getRules(), "i"); + this.foldingRules = new FoldMode(["diff", "index", "\\+{3}", "@@|\\*{5}"], "i"); +}; +oop.inherits(Mode, TextMode); + +(function() { + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/diff_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DiffHighlightRules = function() { + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [{ + "regex": "^(?:\\*{15}|={67}|-{3}|\\+{3})$", + "token": "punctuation.definition.separator.diff", + "name": "keyword" + }, { //diff.range.unified + "regex": "^(@@)(\\s*.+?\\s*)(@@)(.*)$", + "token": [ + "constant", + "constant.numeric", + "constant", + "comment.doc.tag" + ] + }, { //diff.range.normal + "regex": "^(\\d+)([,\\d]+)(a|d|c)(\\d+)([,\\d]+)(.*)$", + "token": [ + "constant.numeric", + "punctuation.definition.range.diff", + "constant.function", + "constant.numeric", + "punctuation.definition.range.diff", + "invalid" + ], + "name": "meta." + }, { + "regex": "^(?:(\\-{3}|\\+{3}|\\*{3})( .+))$", + "token": [ + "constant.numeric", + "meta.tag" + ] + }, { // added + "regex": "^([!+>])(.*?)(\\s*)$", + "token": [ + "support.constant", + "text", + "invalid" + ], + }, { // removed + "regex": "^([<\\-])(.*?)(\\s*)$", + "token": [ + "support.function", + "string", + "invalid" + ], + }, { + "regex": "^(diff)(\\s+--\\w+)?(.+?)( .+)?$", + "token": ["variable", "variable", "keyword", "variable"] + }, { + "regex": "^Index.+$", + "token": "variable" + }, { + "regex": "^(.*?)(\\s*)$", + "token": ["invisible", "invalid"] + } + ] + }; +}; + +oop.inherits(DiffHighlightRules, TextHighlightRules); + +exports.DiffHighlightRules = DiffHighlightRules; +}); + +ace.define('ace/mode/folding/diff', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var BaseFoldMode = require("./fold_mode").FoldMode; +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function(levels, flag) { + this.regExpList = levels; + this.flag = flag; + this.foldingStartMarker = RegExp("^(" + levels.join("|") + ")", this.flag); +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var start = {row: row, column: line.length}; + + var regList = this.regExpList; + for (var i = 1; i <= regList.length; i++) { + var re = RegExp("^(" + regList.slice(0, i).join("|") + ")", this.flag); + if (re.test(line)) + break; + } + + for (var l = session.getLength(); ++row < l; ) { + line = session.getLine(row); + if (re.test(line)) + break; + } + if (row == start.row + 1) + return; + return Range.fromPoints(start, {row: row - 1, column: line.length}); + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-glsl.js b/vendor/assets/javascripts/ace-src-noconflict/mode-glsl.js new file mode 100644 index 00000000..c46651b2 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-glsl.js @@ -0,0 +1,834 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/glsl', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/c_cpp', 'ace/tokenizer', 'ace/mode/glsl_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var CMode = require("./c_cpp").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var glslHighlightRules = require("./glsl_highlight_rules").glslHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new glslHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, CMode); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/c_cpp', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/c_cpp_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new c_cppHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/c_cpp_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +// used by objective-c +var cFunctions = exports.cFunctions = "\\s*\\bhypot(?:f|l)?|s(?:scanf|ystem|nprintf|ca(?:nf|lb(?:n(?:f|l)?|ln(?:f|l)?))|i(?:n(?:h(?:f|l)?|f|l)?|gn(?:al|bit))|tr(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(?:jmp|vbuf|locale|buf)|qrt(?:f|l)?|w(?:scanf|printf)|rand)|n(?:e(?:arbyint(?:f|l)?|xt(?:toward(?:f|l)?|after(?:f|l)?))|an(?:f|l)?)|c(?:s(?:in(?:h(?:f|l)?|f|l)?|qrt(?:f|l)?)|cos(?:h(?:f)?|f|l)?|imag(?:f|l)?|t(?:ime|an(?:h(?:f|l)?|f|l)?)|o(?:s(?:h(?:f|l)?|f|l)?|nj(?:f|l)?|pysign(?:f|l)?)|p(?:ow(?:f|l)?|roj(?:f|l)?)|e(?:il(?:f|l)?|xp(?:f|l)?)|l(?:o(?:ck|g(?:f|l)?)|earerr)|a(?:sin(?:h(?:f|l)?|f|l)?|cos(?:h(?:f|l)?|f|l)?|tan(?:h(?:f|l)?|f|l)?|lloc|rg(?:f|l)?|bs(?:f|l)?)|real(?:f|l)?|brt(?:f|l)?)|t(?:ime|o(?:upper|lower)|an(?:h(?:f|l)?|f|l)?|runc(?:f|l)?|gamma(?:f|l)?|mp(?:nam|file))|i(?:s(?:space|n(?:ormal|an)|cntrl|inf|digit|u(?:nordered|pper)|p(?:unct|rint)|finite|w(?:space|c(?:ntrl|type)|digit|upper|p(?:unct|rint)|lower|al(?:num|pha)|graph|xdigit|blank)|l(?:ower|ess(?:equal|greater)?)|al(?:num|pha)|gr(?:eater(?:equal)?|aph)|xdigit|blank)|logb(?:f|l)?|max(?:div|abs))|di(?:v|fftime)|_Exit|unget(?:c|wc)|p(?:ow(?:f|l)?|ut(?:s|c(?:har)?|wc(?:har)?)|error|rintf)|e(?:rf(?:c(?:f|l)?|f|l)?|x(?:it|p(?:2(?:f|l)?|f|l|m1(?:f|l)?)?))|v(?:s(?:scanf|nprintf|canf|printf|w(?:scanf|printf))|printf|f(?:scanf|printf|w(?:scanf|printf))|w(?:scanf|printf)|a_(?:start|copy|end|arg))|qsort|f(?:s(?:canf|e(?:tpos|ek))|close|tell|open|dim(?:f|l)?|p(?:classify|ut(?:s|c|w(?:s|c))|rintf)|e(?:holdexcept|set(?:e(?:nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(?:aiseexcept|ror)|get(?:e(?:nv|xceptflag)|round))|flush|w(?:scanf|ide|printf|rite)|loor(?:f|l)?|abs(?:f|l)?|get(?:s|c|pos|w(?:s|c))|re(?:open|e|ad|xp(?:f|l)?)|m(?:in(?:f|l)?|od(?:f|l)?|a(?:f|l|x(?:f|l)?)?))|l(?:d(?:iv|exp(?:f|l)?)|o(?:ngjmp|cal(?:time|econv)|g(?:1(?:p(?:f|l)?|0(?:f|l)?)|2(?:f|l)?|f|l|b(?:f|l)?)?)|abs|l(?:div|abs|r(?:int(?:f|l)?|ound(?:f|l)?))|r(?:int(?:f|l)?|ound(?:f|l)?)|gamma(?:f|l)?)|w(?:scanf|c(?:s(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?|mbs)|pbrk|ftime|len|r(?:chr|tombs)|xfrm)|to(?:b|mb)|rtomb)|printf|mem(?:set|c(?:hr|py|mp)|move))|a(?:s(?:sert|ctime|in(?:h(?:f|l)?|f|l)?)|cos(?:h(?:f|l)?|f|l)?|t(?:o(?:i|f|l(?:l)?)|exit|an(?:h(?:f|l)?|2(?:f|l)?|f|l)?)|b(?:s|ort))|g(?:et(?:s|c(?:har)?|env|wc(?:har)?)|mtime)|r(?:int(?:f|l)?|ound(?:f|l)?|e(?:name|alloc|wind|m(?:ove|quo(?:f|l)?|ainder(?:f|l)?))|a(?:nd|ise))|b(?:search|towc)|m(?:odf(?:f|l)?|em(?:set|c(?:hr|py|mp)|move)|ktime|alloc|b(?:s(?:init|towcs|rtowcs)|towc|len|r(?:towc|len)))\\b" + +var c_cppHighlightRules = function() { + + var keywordControls = ( + "break|case|continue|default|do|else|for|goto|if|_Pragma|" + + "return|switch|while|catch|operator|try|throw|using" + ); + + var storageType = ( + "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" + + "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void" + + "class|wchar_t|template" + ); + + var storageModifiers = ( + "const|extern|register|restrict|static|volatile|inline|private:|" + + "protected:|public:|friend|explicit|virtual|export|mutable|typename" + ); + + var keywordOperators = ( + "and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq" + + "const_cast|dynamic_cast|reinterpret_cast|static_cast|sizeof|namespace" + ); + + var builtinConstants = ( + "NULL|true|false|TRUE|FALSE" + ); + + var keywordMapper = this.createKeywordMapper({ + "keyword.control" : keywordControls, + "storage.type" : storageType, + "storage.modifier" : storageModifiers, + "keyword.operator" : keywordOperators, + "variable.language": "this", + "constant.language": builtinConstants + }, "identifier"); + + var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\d\\$_\u00a1-\uffff]*\\b"; + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*\\\\$', + next : "qqstring" + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*\\\\$", + next : "qstring" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant", // + regex : "<[a-zA-Z0-9.]+>" + }, { + token : "keyword", // pre-compiler directivs + regex : "(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)" + }, { + token : "support.function.C99.c", + regex : cFunctions + }, { + // function myFunc(arg) { } + token : [ + "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(\\s+)(" + identifierRe + ")(\\s*)(\\()" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)" + }, { + token : "punctuation.operator", + regex : "\\?|\\:|\\,|\\;|\\." + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "string", + regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ], + "qstring" : [ + { + token : "string", + regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(c_cppHighlightRules, TextHighlightRules); + +exports.c_cppHighlightRules = c_cppHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/glsl_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/c_cpp_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules; + +var glslHighlightRules = function() { + + var keywords = ( + "attribute|const|uniform|varying|break|continue|do|for|while|" + + "if|else|in|out|inout|float|int|void|bool|true|false|" + + "lowp|mediump|highp|precision|invariant|discard|return|mat2|mat3|" + + "mat4|vec2|vec3|vec4|ivec2|ivec3|ivec4|bvec2|bvec3|bvec4|sampler2D|" + + "samplerCube|struct" + ); + + var buildinConstants = ( + "radians|degrees|sin|cos|tan|asin|acos|atan|pow|" + + "exp|log|exp2|log2|sqrt|inversesqrt|abs|sign|floor|ceil|fract|mod|" + + "min|max|clamp|mix|step|smoothstep|length|distance|dot|cross|" + + "normalize|faceforward|reflect|refract|matrixCompMult|lessThan|" + + "lessThanEqual|greaterThan|greaterThanEqual|equal|notEqual|any|all|" + + "not|dFdx|dFdy|fwidth|texture2D|texture2DProj|texture2DLod|" + + "texture2DProjLod|textureCube|textureCubeLod|" + + "gl_MaxVertexAttribs|gl_MaxVertexUniformVectors|gl_MaxVaryingVectors|" + + "gl_MaxVertexTextureImageUnits|gl_MaxCombinedTextureImageUnits|" + + "gl_MaxTextureImageUnits|gl_MaxFragmentUniformVectors|gl_MaxDrawBuffers|" + + "gl_DepthRangeParameters|gl_DepthRange|" + + // The following two are only for MIME x-shader/x-vertex. + "gl_Position|gl_PointSize|" + + // The following five are only for MIME x-shader/x-fragment. + "gl_FragCoord|gl_FrontFacing|gl_PointCoord|gl_FragColor|gl_FragData" + ); + + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": keywords, + "constant.language": buildinConstants + }, "identifier"); + + this.$rules = new c_cppHighlightRules().$rules; + this.$rules.start.forEach(function(rule) { + if (typeof rule.token == "function") + rule.token = keywordMapper; + }) +}; + +oop.inherits(glslHighlightRules, c_cppHighlightRules); + +exports.glslHighlightRules = glslHighlightRules; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-golang.js b/vendor/assets/javascripts/ace-src-noconflict/mode-golang.js new file mode 100644 index 00000000..c894682d --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-golang.js @@ -0,0 +1,674 @@ +ace.define('ace/mode/golang', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/golang_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + var oop = require("../lib/oop"); + var TextMode = require("./text").Mode; + var Tokenizer = require("../tokenizer").Tokenizer; + var GolangHighlightRules = require("./golang_highlight_rules").GolangHighlightRules; + var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; + var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; + var CStyleFoldMode = require("./folding/cstyle").FoldMode; + + var Mode = function() { + this.$tokenizer = new Tokenizer(new GolangHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new CStyleFoldMode(); + }; + oop.inherits(Mode, TextMode); + + (function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var outentedRows = []; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + };//end getNextLineIndent + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + }).call(Mode.prototype); + + exports.Mode = Mode; +}); +ace.define('ace/mode/golang_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + var oop = require("../lib/oop"); + var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; + var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + + var GolangHighlightRules = function() { + var keywords = ( + "true|else|false|break|case|return|goto|if|const|" + + "continue|struct|default|switch|for|" + + "func|import|package|chan|defer|fallthrough|go|interface|map|range" + + "select|type|var" + ); + var buildinConstants = ("nil|true|false|iota"); + + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": keywords, + "constant.language": buildinConstants + }, "identifier"); + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*\\\\$', + next : "qqstring" + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*\\\\$", + next : "qstring" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant", // + regex : "<[a-zA-Z0-9.]+>" + }, { + token : "keyword", // pre-compiler directivs + regex : "(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)" + }, { + token : "punctuation.operator", + regex : "\\?|\\:|\\,|\\;|\\." + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "string", + regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ], + "qstring" : [ + { + token : "string", + regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); + } + oop.inherits(GolangHighlightRules, TextHighlightRules); + + exports.GolangHighlightRules = GolangHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-groovy.js b/vendor/assets/javascripts/ace-src-noconflict/mode-groovy.js new file mode 100644 index 00000000..ad7bdf58 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-groovy.js @@ -0,0 +1,1160 @@ +ace.define('ace/mode/groovy', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/javascript', 'ace/tokenizer', 'ace/mode/groovy_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var JavaScriptMode = require("./javascript").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var GroovyHighlightRules = require("./groovy_highlight_rules").GroovyHighlightRules; + +var Mode = function() { + JavaScriptMode.call(this); + this.$tokenizer = new Tokenizer(new GroovyHighlightRules().getRules()); +}; +oop.inherits(Mode, JavaScriptMode); + +(function() { + + this.createWorker = function(session) { + return null; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start" || state == "regex_allowed") { + var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start" || state == "regex_allowed") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); + worker.attachToDocument(session.getDocument()); + + worker.on("jslint", function(results) { + var errors = []; + for (var i=0; i the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + // Sound.prototype.play = + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + // Sound.play = function() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // play = function() { } + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + // function myFunc(arg) { } + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + // foobar: function() { } + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + // escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + // invalid operators + token : "invalid", + regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?] + }, { + // operators + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/ + }, { + token: "string.regexp", + regex: /{|[^\[\\{()$^+*?\/]+/, + merge: true + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex", + merge: true + }, { + token: "constant.language.escape", + regex: "-", + }, { + token: "string.regexp.charachterclass", + regex: /[^\]\-\\]+/, + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); +ace.define('ace/mode/groovy_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var GroovyHighlightRules = function() { + + var keywords = ( + "assert|with|abstract|continue|for|new|switch|" + + "assert|default|goto|package|synchronized|" + + "boolean|do|if|private|this|" + + "break|double|implements|protected|throw|" + + "byte|else|import|public|throws|" + + "case|enum|instanceof|return|transient|" + + "catch|extends|int|short|try|" + + "char|final|interface|static|void|" + + "class|finally|long|strictfp|volatile|" + + "def|float|native|super|while" + ); + + var buildinConstants = ( + "null|Infinity|NaN|undefined" + ); + + var langClasses = ( + "AbstractMethodError|AssertionError|ClassCircularityError|"+ + "ClassFormatError|Deprecated|EnumConstantNotPresentException|"+ + "ExceptionInInitializerError|IllegalAccessError|"+ + "IllegalThreadStateException|InstantiationError|InternalError|"+ + "NegativeArraySizeException|NoSuchFieldError|Override|Process|"+ + "ProcessBuilder|SecurityManager|StringIndexOutOfBoundsException|"+ + "SuppressWarnings|TypeNotPresentException|UnknownError|"+ + "UnsatisfiedLinkError|UnsupportedClassVersionError|VerifyError|"+ + "InstantiationException|IndexOutOfBoundsException|"+ + "ArrayIndexOutOfBoundsException|CloneNotSupportedException|"+ + "NoSuchFieldException|IllegalArgumentException|NumberFormatException|"+ + "SecurityException|Void|InheritableThreadLocal|IllegalStateException|"+ + "InterruptedException|NoSuchMethodException|IllegalAccessException|"+ + "UnsupportedOperationException|Enum|StrictMath|Package|Compiler|"+ + "Readable|Runtime|StringBuilder|Math|IncompatibleClassChangeError|"+ + "NoSuchMethodError|ThreadLocal|RuntimePermission|ArithmeticException|"+ + "NullPointerException|Long|Integer|Short|Byte|Double|Number|Float|"+ + "Character|Boolean|StackTraceElement|Appendable|StringBuffer|"+ + "Iterable|ThreadGroup|Runnable|Thread|IllegalMonitorStateException|"+ + "StackOverflowError|OutOfMemoryError|VirtualMachineError|"+ + "ArrayStoreException|ClassCastException|LinkageError|"+ + "NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+ + "Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+ + "Cloneable|Class|CharSequence|Comparable|String|Object" + ); + + // TODO var importClasses = ""; + + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": keywords, + "support.function": langClasses, + "constant.language": buildinConstants + }, "identifier"); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token : "string.regexp", + regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + }, { + token : "string", + regex : '"""', + next : "qqstring" + }, { + token : "string", + regex : "'''", + next : "qstring" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "(?:true|false)\\b" + }, { + token : keywordMapper, + // TODO: Unicode escape sequences + // TODO: Unicode identifiers + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\?:|\\?\\.|\\*\\.|<=>|=~|==~|\\.@|\\*\\.@|\\.&|as|in|is|!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "lparen", + regex : "[[({]" + }, { + token : "rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : /\\(?:u[0-9A-Fa-f]{4}|.|$)/ + }, { + token : "constant.language.escape", + regex : /\$[\w\d]+/ + }, { + token : "constant.language.escape", + regex : /\$\{[^"\}]+\}?/ + }, { + token : "string", + regex : '"{3,5}', + next : "start" + }, { + token : "string", + regex : '.+?' + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : /\\(?:u[0-9A-Fa-f]{4}|.|$)/ + }, { + token : "string", + regex : "'{3,5}", + next : "start" + }, { + token : "string", + regex : ".+?" + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(GroovyHighlightRules, TextHighlightRules); + +exports.GroovyHighlightRules = GroovyHighlightRules; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-haxe.js b/vendor/assets/javascripts/ace-src-noconflict/mode-haxe.js new file mode 100644 index 00000000..78910005 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-haxe.js @@ -0,0 +1,624 @@ +ace.define('ace/mode/haxe', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/haxe_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var HaxeHighlightRules = require("./haxe_highlight_rules").HaxeHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new HaxeHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); +ace.define('ace/mode/haxe_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); + +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var HaxeHighlightRules = function() { + + var keywords = ( + "break|case|cast|catch|class|continue|default|else|enum|extends|for|function|if|implements|import|in|inline|interface|new|override|package|private|public|return|static|super|switch|this|throw|trace|try|typedef|untyped|var|while|Array|Void|Bool|Int|UInt|Float|Dynamic|String|List|Hash|IntHash|Error|Unknown|Type|Std" + ); + + var buildinConstants = ( + "null|true|false" + ); + + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": keywords, + "constant.language": buildinConstants + }, "identifier"); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + regex : "\\/\\*", + merge : true, + next : "comment" + }, { + token : "string.regexp", + regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "(?:true|false)\\b" + }, { + token : keywordMapper, + // TODO: Unicode escape sequences + // TODO: Unicode identifiers + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "punctuation.operator", + regex : "\\?|\\:|\\,|\\;|\\." + }, { + token : "paren.lparen", + regex : "[[({<]" + }, { + token : "paren.rparen", + regex : "[\\])}>]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(HaxeHighlightRules, TextHighlightRules); + +exports.HaxeHighlightRules = HaxeHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-html.js b/vendor/assets/javascripts/ace-src-noconflict/mode-html.js new file mode 100644 index 00000000..0ea36845 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-html.js @@ -0,0 +1,1950 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/mode/javascript', 'ace/mode/css', 'ace/tokenizer', 'ace/mode/html_highlight_rules', 'ace/mode/behaviour/html', 'ace/mode/folding/html'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var JavaScriptMode = require("./javascript").Mode; +var CssMode = require("./css").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; +var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour; +var HtmlFoldMode = require("./folding/html").FoldMode; + +var Mode = function() { + var highlighter = new HtmlHighlightRules(); + this.$tokenizer = new Tokenizer(highlighter.getRules()); + this.$behaviour = new HtmlBehaviour(); + + this.$embeds = highlighter.getEmbeds(); + this.createModeDelegates({ + "js-": JavaScriptMode, + "css-": CssMode + }); + + this.foldingRules = new HtmlFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + return 0; + }; + + this.getNextLineIndent = function(state, line, tab) { + return this.$getIndent(line); + }; + + this.checkOutdent = function(state, line, input) { + return false; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start" || state == "regex_allowed") { + var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start" || state == "regex_allowed") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); + worker.attachToDocument(session.getDocument()); + + worker.on("jslint", function(results) { + var errors = []; + for (var i=0; i the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + // Sound.prototype.play = + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + // Sound.play = function() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // play = function() { } + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + // function myFunc(arg) { } + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + // foobar: function() { } + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + // escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + // invalid operators + token : "invalid", + regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?] + }, { + // operators + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/ + }, { + token: "string.regexp", + regex: /{|[^\[\\{()$^+*?\/]+/, + merge: true + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex", + merge: true + }, { + token: "constant.language.escape", + regex: "-", + }, { + token: "string.regexp.charachterclass", + regex: /[^\]\-\\]+/, + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/css', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/css_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/worker/worker_client', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules(), "i"); + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.foldingRules = "cStyle"; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + // ignore braces in comments + var tokens = this.$tokenizer.getLineTokens(line, state).tokens; + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + var match = line.match(/^.*\{\s*$/); + if (match) { + indent += tab; + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker"); + worker.attachToDocument(session.getDocument()); + + worker.on("csslint", function(e) { + var errors = []; + e.data.forEach(function(message) { + errors.push({ + row: message.line - 1, + column: message.col - 1, + text: message.message, + type: message.type, + lint: message + }); + }); + + session.setAnnotations(errors); + }); + return worker; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CssHighlightRules = function() { + var keywordMapper = this.createKeywordMapper({ + "support.type": "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index", + "support.function": "rgb|rgba|url|attr|counter|counters", + "support.constant": "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero", + "support.constant.color": "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow", + "support.constant.fonts": "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace" + }, "text", true); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b"; + var pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b"; + + var base_ruleset = [ + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "ruleset_comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : ["constant.numeric", "keyword"], + regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)" + }, { + token : ["constant.numeric"], + regex : "([0-9]+)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"], + regex : pseudoElements + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], + regex : pseudoClasses + }, { + token : keywordMapper, + regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" + } + ]; + + var ruleset = lang.copyArray(base_ruleset); + ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "start" + }); + + var media_ruleset = lang.copyArray( base_ruleset ); + media_ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "media" + }); + + var base_comment = [{ + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + }]; + + var comment = lang.copyArray(base_comment); + comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }); + + var media_comment = lang.copyArray(base_comment); + media_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "media" + }); + + var ruleset_comment = lang.copyArray(base_comment); + ruleset_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "ruleset" + }); + + this.$rules = { + "start" : [{ + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "ruleset" + }, { + token: "string", + regex: "@.*?{", + next: "media" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "media" : [ { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "media_comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "media_ruleset" + },{ + token: "string", + regex: "\\}", + next: "start" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "comment" : comment, + + "ruleset" : ruleset, + "ruleset_comment" : ruleset_comment, + + "media_ruleset" : media_ruleset, + "media_comment" : media_comment + }; +}; + +oop.inherits(CssHighlightRules, TextHighlightRules); + +exports.CssHighlightRules = CssHighlightRules; + +}); + +ace.define('ace/mode/html_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var xmlUtil = require("./xml_util"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var tagMap = lang.createMap({ + a : 'anchor', + button : 'form', + form : 'form', + img : 'image', + input : 'form', + label : 'form', + script : 'script', + select : 'form', + textarea : 'form', + style : 'style', + table : 'table', + tbody : 'table', + td : 'table', + tfoot : 'table', + th : 'table', + tr : 'table' +}); + +var HtmlHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + this.$rules = { + start : [{ + token : "text", + merge : true, + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "xml_pe", + regex : "<\\!.*?>" + }, { + token : "meta.tag", + regex : "<(?=\s*script\\b)", + next : "script" + }, { + token : "meta.tag", + regex : "<(?=\s*style\\b)", + next : "style" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "constant.character.entity", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }, { + token : "text", + regex : "[^<]+" + } ], + + cdata : [ { + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + merge : true, + regex : "\\s+" + }, { + token : "text", + merge : true, + regex : ".+" + } ], + + comment : [ { + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + } ] + }; + + xmlUtil.tag(this.$rules, "tag", "start", tagMap); + xmlUtil.tag(this.$rules, "style", "css-start", tagMap); + xmlUtil.tag(this.$rules, "script", "js-start", tagMap); + + this.embedRules(JavaScriptHighlightRules, "js-", [{ + token: "comment", + regex: "\\/\\/.*(?=<\\/script>)", + next: "tag" + }, { + token: "meta.tag", + regex: "<\\/(?=script)", + next: "tag" + }]); + + this.embedRules(CssHighlightRules, "css-", [{ + token: "meta.tag", + regex: "<\\/(?=style)", + next: "tag" + }]); +}; + +oop.inherits(HtmlHighlightRules, TextHighlightRules); + +exports.HtmlHighlightRules = HtmlHighlightRules; +}); + +ace.define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) { + + +function string(state) { + return [{ + token : "string", + regex : '".*?"' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*', + next : state + "_qqstring" + }, { + token : "string", + regex : "'.*?'" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*", + next : state + "_qstring" + }]; +} + +function multiLineString(quote, state) { + return [{ + token : "string", + merge : true, + regex : ".*?" + quote, + next : state + }, { + token : "string", + merge : true, + regex : '.+' + }]; +} + +exports.tag = function(states, name, nextState, tagMap) { + states[name] = [{ + token : "text", + regex : "\\s+" + }, { + //token : "meta.tag", + + token : !tagMap ? "meta.tag.tag-name" : function(value) { + if (tagMap[value]) + return "meta.tag.tag-name." + tagMap[value]; + else + return "meta.tag.tag-name"; + }, + merge : true, + regex : "[-_a-zA-Z0-9:]+", + next : name + "_embed_attribute_list" + }, { + token: "empty", + regex: "", + next : name + "_embed_attribute_list" + }]; + + states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list"); + states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list"); + + states[name + "_embed_attribute_list"] = [{ + token : "meta.tag", + merge : true, + regex : "\/?>", + next : nextState + }, { + token : "keyword.operator", + regex : "=" + }, { + token : "entity.other.attribute-name", + regex : "[-_a-zA-Z0-9:]+" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "text", + regex : "\\s+" + }].concat(string(name)); +}; + +}); + +ace.define('ace/mode/behaviour/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour/xml', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var XmlBehaviour = require("../behaviour/xml").XmlBehaviour; +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; +var voidElements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']; + +function hasType(token, type) { + var hasType = true; + var typeList = token.type.split('.'); + var needleList = type.split('.'); + needleList.forEach(function(needle){ + if (typeList.indexOf(needle) == -1) { + hasType = false; + return false; + } + }); + return hasType; +} + +var HtmlBehaviour = function () { + + this.inherit(XmlBehaviour); // Get xml behaviour + + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { + if (text == '>') { + var position = editor.getCursorPosition(); + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken(); + var atCursor = false; + if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ + do { + token = iterator.stepBackward(); + } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); + } else { + atCursor = true; + } + if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) { + return + } + var element = token.value; + if (atCursor){ + var element = element.substring(0, position.column - token.start); + } + if (voidElements.indexOf(element) !== -1){ + return; + } + return { + text: '>' + '', + selection: [1, 1] + } + } + }); +} +oop.inherits(HtmlBehaviour, XmlBehaviour); + +exports.HtmlBehaviour = HtmlBehaviour; +}); + +ace.define('ace/mode/behaviour/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; + +function hasType(token, type) { + var hasType = true; + var typeList = token.type.split('.'); + var needleList = type.split('.'); + needleList.forEach(function(needle){ + if (typeList.indexOf(needle) == -1) { + hasType = false; + return false; + } + }); + return hasType; +} + +var XmlBehaviour = function () { + + this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour + + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { + if (text == '>') { + var position = editor.getCursorPosition(); + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken(); + var atCursor = false; + if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ + do { + token = iterator.stepBackward(); + } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); + } else { + atCursor = true; + } + if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) { + return + } + var tag = token.value; + if (atCursor){ + var tag = tag.substring(0, position.column - token.start); + } + + return { + text: '>' + '', + selection: [1, 1] + } + } + }); + + this.add('autoindent', 'insertion', function (state, action, editor, session, text) { + if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChars = line.substring(cursor.column, cursor.column + 2); + if (rightChars == '?)/; + this._parseTag = function(tag) { + + var match = this.tagRe.exec(tag); + var column = this.tagRe.lastIndex || 0; + this.tagRe.lastIndex = 0; + + return { + value: tag, + match: match ? match[2] : "", + closing: match ? !!match[3] : false, + selfClosing: match ? !!match[5] || match[2] == "/>" : false, + tagName: match ? match[4] : "", + column: match[1] ? column + match[1].length : column + }; + }; + this._readTagForward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var start; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!start) { + var start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + } + value += token.value; + if (value.indexOf(">") !== -1) { + var tag = this._parseTag(value); + tag.start = start; + tag.end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + iterator.stepForward(); + return tag; + } + } + } while(token = iterator.stepForward()); + + return null; + }; + + this._readTagBackward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var end; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!end) { + end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + } + value = token.value + value; + if (value.indexOf("<") !== -1) { + var tag = this._parseTag(value); + tag.end = end; + tag.start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + iterator.stepBackward(); + return tag; + } + } + } while(token = iterator.stepBackward()); + + return null; + }; + + this._pop = function(stack, tag) { + while (stack.length) { + + var top = stack[stack.length-1]; + if (!tag || top.tagName == tag.tagName) { + return stack.pop(); + } + else if (this.voidElements[tag.tagName]) { + return; + } + else if (this.voidElements[top.tagName]) { + stack.pop(); + continue; + } else { + return null; + } + } + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var firstTag = this._getFirstTagInLine(session, row); + + if (!firstTag.match) + return null; + + var isBackward = firstTag.closing || firstTag.selfClosing; + var stack = []; + var tag; + + if (!isBackward) { + var iterator = new TokenIterator(session, row, firstTag.column); + var start = { + row: row, + column: firstTag.column + firstTag.tagName.length + 2 + }; + while (tag = this._readTagForward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) + return Range.fromPoints(start, tag.start); + } + else { + stack.push(tag) + } + } + } + else { + var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length); + var end = { + row: row, + column: firstTag.column + }; + + while (tag = this._readTagBackward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (!tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) { + tag.start.column += tag.tagName.length + 2; + return Range.fromPoints(tag.start, end); + } + } + else { + stack.push(tag) + } + } + } + + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-jade.js b/vendor/assets/javascripts/ace-src-noconflict/mode-jade.js new file mode 100644 index 00000000..c01a3598 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-jade.js @@ -0,0 +1,2038 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * + * Contributor(s): + * + * Garen J. Torikian + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/jade', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/jade_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JadeHighlightRules = require("./jade_highlight_rules").JadeHighlightRules; +// var JavascriptMode = require("ace/mode/javascript").Mode; +// var CssMode = require("ace/mode/css").Mode; + +var Mode = function() { + var highlighter = new JadeHighlightRules(); + + this.$tokenizer = new Tokenizer(highlighter.getRules()); +}; +oop.inherits(Mode, TextMode); + +(function() { + // Extra logic goes here. +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +/* + THIS FILE WAS AUTOGENERATED BY mode_highlight_rules.tmpl.js (UUID: C5B73B98-5F2A-42E3-9F0E-028A74A9FE4B) +*/ + +ace.define('ace/mode/jade_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules', 'ace/mode/markdown_highlight_rules', 'ace/mode/scss_highlight_rules', 'ace/mode/less_highlight_rules', 'ace/mode/coffee_highlight_rules', 'ace/mode/javascript_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; +var MarkdownHighlightRules = require("./markdown_highlight_rules").MarkdownHighlightRules; +var SassHighlightRules = require("./scss_highlight_rules").ScssHighlightRules; +var LessHighlightRules = require("./less_highlight_rules").LessHighlightRules; +var CoffeeHighlightRules = require("./coffee_highlight_rules").CoffeeHighlightRules; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; + +function mixin_embed(tag, prefix) { + return { + token : "entity.name.function.jade", + regex : "^\\s*\\:" + tag, + next : prefix + "start" + }; +} + +var JadeHighlightRules = function() { + + var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex + "u[0-9a-fA-F]{4}|" + // unicode + "[0-2][0-7]{0,2}|" + // oct + "3[0-6][0-7]?|" + // oct + "37[0-7]?|" + // oct + "[4-7][0-7]?|" + //oct + ".)"; + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = + { + "start": [ + { + "token": "keyword.control.import.include.jade", + "regex": "\\s*\\binclude\\b" + }, + { + "token": "keyword.other.doctype.jade", + "regex": "^!!!\\s*(?:[a-zA-Z0-9-_]+)?" + }, + { + "token" : "punctuation.section.comment", + "regex" : "^\\s*\/\/(?:\\s*[^-\\s]|\\s+\\S)(?:.*$)", + }, + { + "token" : function(space, text) { + return "punctuation.section.comment"; + }, + "regex" : "^((\\s*)\/\/)(?:\\s*$)", + "next": "comment_block" + }, + mixin_embed("markdown", "markdown-"), + mixin_embed("sass", "sass-"), + mixin_embed("less", "less-"), + mixin_embed("coffee", "coffee-"), + /* + { + "token": { + "2": { + "name": "entity.name.function.jade" + } + }, + "regex": "^(\\s*)(\\:cdata)", + "next": "state_9" + },*/ + // match stuff like: mixin dialog-title-desc(title, desc) + { + "token": [ "storage.type.function.jade", + "entity.name.function.jade", + "punctuation.definition.parameters.begin.jade", + "variable.parameter.function.jade", + "punctuation.definition.parameters.end.jade" + ], + "regex": "^(\\s*mixin)( [\\w\\-]+)(\\s*\\()(.*?)(\\))" + }, + // match stuff like: mixin dialog-title-desc + { + "token": [ "storage.type.function.jade", "entity.name.function.jade"], + "regex": "^(\\s*mixin)( [\\w\\-]+)" + }, + /* { + "token": "source.js.embedded.jade", + "regex": "^\\s*-|=|!=", + "next": "js_code" + },*/ + /*{ + "token": "entity.name.tag.script.jade", + "regex": "^\\s*script", + "next": "js_code_tag" + },*/ + { + "token": "string.interpolated.jade", + "regex": "[#!]\\{[^\\}]+\\}" + }, + // Match any tag, id or class. skip AST filters + { + "token": ["meta.tag.any.jade", "entity.variable.tag.jade"], + "regex": /^\s*(?!\w+\:)(?:[\w]+|(?=\.|#)])/, + "next": "tag_single" + }, + { + "token": "suport.type.attribute.id.jade", + "regex": "#\\w+" + }, + { + "token": "suport.type.attribute.class.jade", + "regex": "\\.\\w+" + }, + { + "token": "punctuation", + "regex": "\\s*(?:\\()", + "next": "tag_attributes" + } + ], + "comment_block": [ + { + "token": function(text) { + return "text"; + }, + "regex": "^(\\1\\S|$)", + "captures": "1", + "next": "start" + }, + { + "token": "comment.block.jade", + "merge" : true, + "regex" : ".+" + } + ], + /* + + "state_9": [ + { + "token": "TODO", + "regex": "^(?!\\1\\s+)", + "next": "start" + }, + { + "token": "TODO", + "regex": ".+", + "next": "state_9" + } + ],*/ + /*"js_code": [ + { + "token": "keyword.control.js", + "regex": "\\beach\\b" + }, + { + "token": "text", + "regex": "$", + "next": "start" + } + ],*/ + /*"js_code_tag": [ + { + "include": "source.js" + }, + { + "token": "TODO", + "regex": "^((?=(\\1)([\\w#\\.]|$\\n?))|^$\\n?)", + "next": "start" + } + ],*/ + "tag_single": [ + { + "token": "suport.type.attribute.class.jade", + "regex": "\\.[\\w-]+" + }, + { + "token": "suport.type.attribute.id.jade", + "regex": "#[\\w-]+" + }, + { + "token": ["text", "punctuation"], + "regex": "($)|((?!\\.|#|=|-))", + "next": "start" + } + ], + "tag_attributes": [ + { + "token": ["entity.other.attribute-name.jade", "punctuation"], + "regex": "\\b([a-zA-Z:\\.-]+)(=)", + "next": "attribute_strings" + }, + { + "token": "punctuation", + "regex": "\\)", + "next": "start" + } + ], + "attribute_strings": [ + { + "token" : "string", + "regex" : "'(?=.)", + "next" : "qstring" + }, + { + "token" : "string", + "regex" : '"(?=.)', + "next" : "qqstring" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "tag_attributes", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "tag_attributes", + merge : true + } + ] +}; +}; + +oop.inherits(JadeHighlightRules, TextHighlightRules); + +exports.JadeHighlightRules = JadeHighlightRules; +}); + +ace.define('ace/mode/markdown_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_highlight_rules', 'ace/mode/html_highlight_rules', 'ace/mode/css_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules; +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; + +function github_embed(tag, prefix) { + return { // Github style block + token : "support.function", + regex : "^```" + tag + "\\s*$", + next : prefix + "start" + }; +} + +var MarkdownHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ { + token : "empty_line", + regex : '^$' + }, { // code span ` + token : ["support.function", "support.function", "support.function"], + regex : "(`+)([^\\r]*?[^`])(\\1)" + }, { // code block + token : "support.function", + regex : "^[ ]{4}.+" + }, { // h1 + token: "markup.heading.1", + regex: "^=+(?=\\s*$)" + }, { // h2 + token: "markup.heading.2", + regex: "^\\-+(?=\\s*$)" + }, { // header + token : function(value) { + return "markup.heading." + value.search(/[^#]/); + }, + regex : "^#{1,6}(?:[^ #].*| +.*(?:[^ #].*|[^ ]+.* +#+ *))$" + }, github_embed("(?:javascript|js)", "js-"), + github_embed("xml", "xml-"), + github_embed("html", "html-"), + github_embed("css", "css-"), + { // Github style block + token : "support.function", + regex : "^```[a-zA-Z]+\\s*$", + next : "githubblock" + }, { // block quote + token : "string", + regex : "^>[ ].+$", + next : "blockquote" + }, { // reference + token : ["text", "constant", "text", "url", "string", "text"], + regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?(\\s*))$" + }, { // link by reference + token : ["text", "string", "text", "constant", "text"], + regex : "(\\[)((?:[[^\\]]*\\]|[^\\[\\]])*)(\\][ ]?(?:\\n[ ]*)?\\[)(.*?)(\\])" + }, { // link by url + token : ["text", "string", "text", "markup.underline", "string", "text"], + regex : "(\\[)"+ + "(\\[[^\\]]*\\]|[^\\[\\]]*)"+ + "(\\]\\([ \\t]*)"+ + "(?)"+ + "((?:[ \t]*\"(?:.*?)\"[ \\t]*)?)"+ + "(\\))" + }, { // HR * + token : "constant", + regex : "^[ ]{0,2}(?:[ ]?\\*[ ]?){3,}\\s*$" + }, { // HR - + token : "constant", + regex : "^[ ]{0,2}(?:[ ]?\\-[ ]?){3,}\\s*$" + }, { // HR _ + token : "constant", + regex : "^[ ]{0,2}(?:[ ]?\\_[ ]?){3,}\\s*$" + }, { // list + token : "markup.list", + regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+", + next : "listblock" + }, { // strong ** __ + token : ["string", "string", "string"], + regex : "([*]{2}|[_]{2}(?=\\S))([^\\r]*?\\S[*_]*)(\\1)" + }, { // emphasis * _ + token : ["string", "string", "string"], + regex : "([*]|[_](?=\\S))([^\\r]*?\\S[*_]*)(\\1)" + }, { // + token : ["text", "url", "text"], + regex : "(<)("+ + "(?:https?|ftp|dict):[^'\">\\s]+"+ + "|"+ + "(?:mailto:)?[-.\\w]+\\@[-a-z0-9]+(?:\\.[-a-z0-9]+)*\\.[a-z]+"+ + ")(>)" + }, { + token : "text", + regex : "[^\\*_%$`\\[#<>]+" + } ], + + "listblock" : [ { // Lists only escape on completely blank lines. + token : "empty_line", + regex : "^$", + next : "start" + }, { + token : "markup.list", + regex : ".+" + } ], + + "blockquote" : [ { // BLockquotes only escape on blank lines. + token : "empty_line", + regex : "^\\s*$", + next : "start" + }, { + token : "string", + regex : ".+" + } ], + + "githubblock" : [ { + token : "support.function", + regex : "^```", + next : "start" + }, { + token : "support.function", + regex : ".+" + } ] + }; + + this.embedRules(JavaScriptHighlightRules, "js-", [{ + token : "support.function", + regex : "^```", + next : "start" + }]); + + this.embedRules(HtmlHighlightRules, "html-", [{ + token : "support.function", + regex : "^```", + next : "start" + }]); + + this.embedRules(CssHighlightRules, "css-", [{ + token : "support.function", + regex : "^```", + next : "start" + }]); + + this.embedRules(XmlHighlightRules, "xml-", [{ + token : "support.function", + regex : "^```", + next : "start" + }]); +}; +oop.inherits(MarkdownHighlightRules, TextHighlightRules); + +exports.MarkdownHighlightRules = MarkdownHighlightRules; +}); + +ace.define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/unicode', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var unicode = require("../unicode"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var JavaScriptHighlightRules = function() { + // see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects + var keywordMapper = this.createKeywordMapper({ + "variable.language": + "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors + "Namespace|QName|XML|XMLList|" + // E4X + "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" + + "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" + + "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors + "SyntaxError|TypeError|URIError|" + + "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions + "isNaN|parseFloat|parseInt|" + + "JSON|Math|" + // Other + "this|arguments|prototype|window|document" , // Pseudo + "invalid.deprecated": + "__parent__|__count__|escape|unescape|with|__proto__|debugger", + "keyword": + "const|yield|import|get|set" + + "break|case|catch|continue|default|delete|do|else|finally|for|function|" + + "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|", + "storage.type": + "const|let|var|function", + "invalid.illegal": + "class|enum|extends|super|export|implements|private|" + + "public|interface|package|protected|static", + "constant.language": + "null|Infinity|NaN|undefined", + }, "identifier"); + + + // keywords which can be followed by regular expressions + var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield"; + + // TODO: Unicode escape sequences + var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b"; + + var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex + "u[0-9a-fA-F]{4}|" + // unicode + "[0-2][0-7]{0,2}|" + // oct + "3[0-6][0-7]?|" + // oct + "37[0-7]?|" + // oct + "[4-7][0-7]?|" + //oct + ".)"; + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + // Sound.prototype.play = + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + // Sound.play = function() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // play = function() { } + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + // function myFunc(arg) { } + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + // foobar: function() { } + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + // escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + // invalid operators + token : "invalid", + regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?] + }, { + // operators + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/ + }, { + token: "string.regexp", + regex: /{|[^\[\\{()$^+*?\/]+/, + merge: true + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex", + merge: true + }, { + token: "constant.language.escape", + regex: "-", + }, { + token: "string.regexp.charachterclass", + regex: /[^\]\-\\]+/, + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/xml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var xmlUtil = require("./xml_util"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var XmlHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + this.$rules = { + start : [{ + token : "text", + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "xml_pe", + regex : "<\\!.*?>" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "constant.character.entity", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }, { + token : "text", + regex : "[^<]+" + }], + + cdata : [{ + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + regex : "\\s+" + }, { + token : "text", + regex : "(?:[^\\]]|\\](?!\\]>))+" + }], + + comment : [{ + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + }] + }; + + xmlUtil.tag(this.$rules, "tag", "start"); +}; + +oop.inherits(XmlHighlightRules, TextHighlightRules); + +exports.XmlHighlightRules = XmlHighlightRules; +}); + +ace.define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) { + + +function string(state) { + return [{ + token : "string", + regex : '".*?"' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*', + next : state + "_qqstring" + }, { + token : "string", + regex : "'.*?'" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*", + next : state + "_qstring" + }]; +} + +function multiLineString(quote, state) { + return [{ + token : "string", + merge : true, + regex : ".*?" + quote, + next : state + }, { + token : "string", + merge : true, + regex : '.+' + }]; +} + +exports.tag = function(states, name, nextState, tagMap) { + states[name] = [{ + token : "text", + regex : "\\s+" + }, { + //token : "meta.tag", + + token : !tagMap ? "meta.tag.tag-name" : function(value) { + if (tagMap[value]) + return "meta.tag.tag-name." + tagMap[value]; + else + return "meta.tag.tag-name"; + }, + merge : true, + regex : "[-_a-zA-Z0-9:]+", + next : name + "_embed_attribute_list" + }, { + token: "empty", + regex: "", + next : name + "_embed_attribute_list" + }]; + + states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list"); + states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list"); + + states[name + "_embed_attribute_list"] = [{ + token : "meta.tag", + merge : true, + regex : "\/?>", + next : nextState + }, { + token : "keyword.operator", + regex : "=" + }, { + token : "entity.other.attribute-name", + regex : "[-_a-zA-Z0-9:]+" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "text", + regex : "\\s+" + }].concat(string(name)); +}; + +}); + +ace.define('ace/mode/html_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var xmlUtil = require("./xml_util"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var tagMap = lang.createMap({ + a : 'anchor', + button : 'form', + form : 'form', + img : 'image', + input : 'form', + label : 'form', + script : 'script', + select : 'form', + textarea : 'form', + style : 'style', + table : 'table', + tbody : 'table', + td : 'table', + tfoot : 'table', + th : 'table', + tr : 'table' +}); + +var HtmlHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + this.$rules = { + start : [{ + token : "text", + merge : true, + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "xml_pe", + regex : "<\\!.*?>" + }, { + token : "meta.tag", + regex : "<(?=\s*script\\b)", + next : "script" + }, { + token : "meta.tag", + regex : "<(?=\s*style\\b)", + next : "style" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "constant.character.entity", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }, { + token : "text", + regex : "[^<]+" + } ], + + cdata : [ { + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + merge : true, + regex : "\\s+" + }, { + token : "text", + merge : true, + regex : ".+" + } ], + + comment : [ { + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + } ] + }; + + xmlUtil.tag(this.$rules, "tag", "start", tagMap); + xmlUtil.tag(this.$rules, "style", "css-start", tagMap); + xmlUtil.tag(this.$rules, "script", "js-start", tagMap); + + this.embedRules(JavaScriptHighlightRules, "js-", [{ + token: "comment", + regex: "\\/\\/.*(?=<\\/script>)", + next: "tag" + }, { + token: "meta.tag", + regex: "<\\/(?=script)", + next: "tag" + }]); + + this.embedRules(CssHighlightRules, "css-", [{ + token: "meta.tag", + regex: "<\\/(?=style)", + next: "tag" + }]); +}; + +oop.inherits(HtmlHighlightRules, TextHighlightRules); + +exports.HtmlHighlightRules = HtmlHighlightRules; +}); + +ace.define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CssHighlightRules = function() { + var keywordMapper = this.createKeywordMapper({ + "support.type": "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index", + "support.function": "rgb|rgba|url|attr|counter|counters", + "support.constant": "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero", + "support.constant.color": "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow", + "support.constant.fonts": "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace" + }, "text", true); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b"; + var pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b"; + + var base_ruleset = [ + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "ruleset_comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : ["constant.numeric", "keyword"], + regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)" + }, { + token : ["constant.numeric"], + regex : "([0-9]+)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"], + regex : pseudoElements + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], + regex : pseudoClasses + }, { + token : keywordMapper, + regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" + } + ]; + + var ruleset = lang.copyArray(base_ruleset); + ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "start" + }); + + var media_ruleset = lang.copyArray( base_ruleset ); + media_ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "media" + }); + + var base_comment = [{ + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + }]; + + var comment = lang.copyArray(base_comment); + comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }); + + var media_comment = lang.copyArray(base_comment); + media_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "media" + }); + + var ruleset_comment = lang.copyArray(base_comment); + ruleset_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "ruleset" + }); + + this.$rules = { + "start" : [{ + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "ruleset" + }, { + token: "string", + regex: "@.*?{", + next: "media" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "media" : [ { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "media_comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "media_ruleset" + },{ + token: "string", + regex: "\\}", + next: "start" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "comment" : comment, + + "ruleset" : ruleset, + "ruleset_comment" : ruleset_comment, + + "media_ruleset" : media_ruleset, + "media_comment" : media_comment + }; +}; + +oop.inherits(CssHighlightRules, TextHighlightRules); + +exports.CssHighlightRules = CssHighlightRules; + +}); + +ace.define('ace/mode/scss_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var ScssHighlightRules = function() { + + var properties = lang.arrayToMap( (function () { + + var browserPrefix = ("-webkit-|-moz-|-o-|-ms-|-svg-|-pie-|-khtml-").split("|"); + + var prefixProperties = ("appearance|background-clip|background-inline-policy|background-origin|" + + "background-size|binding|border-bottom-colors|border-left-colors|" + + "border-right-colors|border-top-colors|border-end|border-end-color|" + + "border-end-style|border-end-width|border-image|border-start|" + + "border-start-color|border-start-style|border-start-width|box-align|" + + "box-direction|box-flex|box-flexgroup|box-ordinal-group|box-orient|" + + "box-pack|box-sizing|column-count|column-gap|column-width|column-rule|" + + "column-rule-width|column-rule-style|column-rule-color|float-edge|" + + "font-feature-settings|font-language-override|force-broken-image-icon|" + + "image-region|margin-end|margin-start|opacity|outline|outline-color|" + + "outline-offset|outline-radius|outline-radius-bottomleft|" + + "outline-radius-bottomright|outline-radius-topleft|outline-radius-topright|" + + "outline-style|outline-width|padding-end|padding-start|stack-sizing|" + + "tab-size|text-blink|text-decoration-color|text-decoration-line|" + + "text-decoration-style|transform|transform-origin|transition|" + + "transition-delay|transition-duration|transition-property|" + + "transition-timing-function|user-focus|user-input|user-modify|user-select|" + + "window-shadow|border-radius").split("|"); + + var properties = ("azimuth|background-attachment|background-color|background-image|" + + "background-position|background-repeat|background|border-bottom-color|" + + "border-bottom-style|border-bottom-width|border-bottom|border-collapse|" + + "border-color|border-left-color|border-left-style|border-left-width|" + + "border-left|border-right-color|border-right-style|border-right-width|" + + "border-right|border-spacing|border-style|border-top-color|" + + "border-top-style|border-top-width|border-top|border-width|border|" + + "bottom|box-sizing|caption-side|clear|clip|color|content|counter-increment|" + + "counter-reset|cue-after|cue-before|cue|cursor|direction|display|" + + "elevation|empty-cells|float|font-family|font-size-adjust|font-size|" + + "font-stretch|font-style|font-variant|font-weight|font|height|left|" + + "letter-spacing|line-height|list-style-image|list-style-position|" + + "list-style-type|list-style|margin-bottom|margin-left|margin-right|" + + "margin-top|marker-offset|margin|marks|max-height|max-width|min-height|" + + "min-width|opacity|orphans|outline-color|" + + "outline-style|outline-width|outline|overflow|overflow-x|overflow-y|padding-bottom|" + + "padding-left|padding-right|padding-top|padding|page-break-after|" + + "page-break-before|page-break-inside|page|pause-after|pause-before|" + + "pause|pitch-range|pitch|play-during|position|quotes|richness|right|" + + "size|speak-header|speak-numeral|speak-punctuation|speech-rate|speak|" + + "stress|table-layout|text-align|text-decoration|text-indent|" + + "text-shadow|text-transform|top|unicode-bidi|vertical-align|" + + "visibility|voice-family|volume|white-space|widows|width|word-spacing|" + + "z-index").split("|"); + + //The return array + var ret = []; + + //All prefixProperties will get the browserPrefix in + //the begning by join the prefixProperties array with the value of browserPrefix + for (var i=0, ln=browserPrefix.length; i the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*\\\\$', + next : "qqstring" + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*\\\\$", + next : "qstring" + }, { + token : "constant.numeric", + regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : "constant.numeric", + regex : numRe + }, { + token : function(value) { + if (properties.hasOwnProperty(value.toLowerCase())) + return "support.type"; + if (keywords.hasOwnProperty(value)) + return "keyword"; + else if (constants.hasOwnProperty(value)) + return "constant.language"; + else if (functions.hasOwnProperty(value)) + return "support.function"; + else if (colors.hasOwnProperty(value.toLowerCase())) + return "support.constant.color"; + else if (tags.hasOwnProperty(value.toLowerCase())) + return "variable.language"; + else + return "text"; + }, + regex : "\\-?[@a-z_][@a-z0-9_\\-]*" + }, { + token : "variable", + regex : "[a-z_\\-$][a-z0-9_\\-$]*\\b" + }, { + token: "variable.language", + regex: "#[a-z0-9-_]+" + }, { + token: "variable.language", + regex: "\\.[a-z0-9-_]+" + }, { + token: "variable.language", + regex: ":[a-z0-9-_]+" + }, { + token: "constant", + regex: "[a-z0-9-_]+" + }, { + token : "keyword.operator", + regex : "<|>|<=|>=|==|!=|-|%|#|\\+|\\$|\\+|\\*" + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "string", + regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ], + "qstring" : [ + { + token : "string", + regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ] + }; +}; + +oop.inherits(ScssHighlightRules, TextHighlightRules); + +exports.ScssHighlightRules = ScssHighlightRules; + +}); + +ace.define('ace/mode/less_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var LessHighlightRules = function() { + + var properties = lang.arrayToMap( (function () { + + var browserPrefix = ("-webkit-|-moz-|-o-|-ms-|-svg-|-pie-|-khtml-").split("|"); + + var prefixProperties = ("appearance|background-clip|background-inline-policy|background-origin|" + + "background-size|binding|border-bottom-colors|border-left-colors|" + + "border-right-colors|border-top-colors|border-end|border-end-color|" + + "border-end-style|border-end-width|border-image|border-start|" + + "border-start-color|border-start-style|border-start-width|box-align|" + + "box-direction|box-flex|box-flexgroup|box-ordinal-group|box-orient|" + + "box-pack|box-sizing|column-count|column-gap|column-width|column-rule|" + + "column-rule-width|column-rule-style|column-rule-color|float-edge|" + + "font-feature-settings|font-language-override|force-broken-image-icon|" + + "image-region|margin-end|margin-start|opacity|outline|outline-color|" + + "outline-offset|outline-radius|outline-radius-bottomleft|" + + "outline-radius-bottomright|outline-radius-topleft|outline-radius-topright|" + + "outline-style|outline-width|padding-end|padding-start|stack-sizing|" + + "tab-size|text-blink|text-decoration-color|text-decoration-line|" + + "text-decoration-style|transform|transform-origin|transition|" + + "transition-delay|transition-duration|transition-property|" + + "transition-timing-function|user-focus|user-input|user-modify|user-select|" + + "window-shadow|border-radius").split("|"); + + var properties = ("azimuth|background-attachment|background-color|background-image|" + + "background-position|background-repeat|background|border-bottom-color|" + + "border-bottom-style|border-bottom-width|border-bottom|border-collapse|" + + "border-color|border-left-color|border-left-style|border-left-width|" + + "border-left|border-right-color|border-right-style|border-right-width|" + + "border-right|border-spacing|border-style|border-top-color|" + + "border-top-style|border-top-width|border-top|border-width|border|" + + "bottom|box-sizing|caption-side|clear|clip|color|content|counter-increment|" + + "counter-reset|cue-after|cue-before|cue|cursor|direction|display|" + + "elevation|empty-cells|float|font-family|font-size-adjust|font-size|" + + "font-stretch|font-style|font-variant|font-weight|font|height|left|" + + "letter-spacing|line-height|list-style-image|list-style-position|" + + "list-style-type|list-style|margin-bottom|margin-left|margin-right|" + + "margin-top|marker-offset|margin|marks|max-height|max-width|min-height|" + + "min-width|opacity|orphans|outline-color|" + + "outline-style|outline-width|outline|overflow|overflow-x|overflow-y|padding-bottom|" + + "padding-left|padding-right|padding-top|padding|page-break-after|" + + "page-break-before|page-break-inside|page|pause-after|pause-before|" + + "pause|pitch-range|pitch|play-during|position|quotes|richness|right|" + + "size|speak-header|speak-numeral|speak-punctuation|speech-rate|speak|" + + "stress|table-layout|text-align|text-decoration|text-indent|" + + "text-shadow|text-transform|top|unicode-bidi|vertical-align|" + + "visibility|voice-family|volume|white-space|widows|width|word-spacing|" + + "z-index").split("|"); + + //The return array + var ret = []; + + //All prefixProperties will get the browserPrefix in + //the begning by join the prefixProperties array with the value of browserPrefix + for (var i=0, ln=browserPrefix.length; i the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "constant.numeric", + regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : "constant.numeric", + regex : numRe + }, { + token : function(value) { + if (keywords.hasOwnProperty(value)) + return "keyword"; + else + return "variable"; + }, + regex : "@[a-z0-9_\\-@]*\\b" + }, { + token : function(value) { + if (properties.hasOwnProperty(value.toLowerCase())) + return "support.type"; + else if (keywords.hasOwnProperty(value)) + return "keyword"; + else if (constants.hasOwnProperty(value)) + return "constant.language"; + else if (functions.hasOwnProperty(value)) + return "support.function"; + else if (colors.hasOwnProperty(value.toLowerCase())) + return "support.constant.color"; + else if (tags.hasOwnProperty(value.toLowerCase())) + return "variable.language"; + else + return "text"; + }, + regex : "\\-?[@a-z_][@a-z0-9_\\-]*" + }, { + token: "variable.language", + regex: "#[a-z0-9-_]+" + }, { + token: "variable.language", + regex: "\\.[a-z0-9-_]+" + }, { + token: "variable.language", + regex: ":[a-z0-9-_]+" + }, { + token: "constant", + regex: "[a-z0-9-_]+" + }, { + token : "keyword.operator", + regex : "<|>|<=|>=|==|!=|-|%|#|\\+|\\$|\\+|\\*" + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ] + }; +}; + +oop.inherits(LessHighlightRules, TextHighlightRules); + +exports.LessHighlightRules = LessHighlightRules; + +}); + +ace.define('ace/mode/coffee_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + + var oop = require("../lib/oop"); + var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + + oop.inherits(CoffeeHighlightRules, TextHighlightRules); + + function CoffeeHighlightRules() { + var identifier = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*"; + var stringfill = { + token : "string", + merge : true, + regex : ".+" + }; + + var keywords = ( + "this|throw|then|try|typeof|super|switch|return|break|by)|continue|" + + "catch|class|in|instanceof|is|isnt|if|else|extends|for|forown|" + + "finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|" + + "or|on|unless|until|and|yes" + ); + + var langConstant = ( + "true|false|null|undefined" + ); + + var illegal = ( + "case|const|default|function|var|void|with|enum|export|implements|" + + "interface|let|package|private|protected|public|static|yield|" + + "__hasProp|extends|slice|bind|indexOf" + ); + + var supportClass = ( + "Array|Boolean|Date|Function|Number|Object|RegExp|ReferenceError|" + + "String|RangeError|SyntaxError|Error|EvalError|TypeError|URIError" + ); + + var supportFunction = ( + "Math|JSON|isNaN|isFinite|parseInt|parseFloat|encodeURI|" + + "encodeURIComponent|decodeURI|decodeURIComponent|String|" + ); + + var keywordMapper = this.createKeywordMapper({ + "keyword": keywords, + "constant.language": langConstant, + "invalid.illegal": illegal, + "language.support.class": supportClass, + "language.support.function": supportFunction, + }, "identifier"); + + this.$rules = { + start : [ + { + token : "identifier", + regex : "(?:(?:\\.|::)\\s*)" + identifier + }, { + token : "variable", + regex : "@(?:" + identifier + ")?" + }, { + token: keywordMapper, + regex : identifier + }, { + token : "constant.numeric", + regex : "(?:0x[\\da-fA-F]+|(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?)" + }, { + token : "string", + merge : true, + regex : "'''", + next : "qdoc" + }, { + token : "string", + merge : true, + regex : '"""', + next : "qqdoc" + }, { + token : "string", + merge : true, + regex : "'", + next : "qstring" + }, { + token : "string", + merge : true, + regex : '"', + next : "qqstring" + }, { + token : "string", + merge : true, + regex : "`", + next : "js" + }, { + token : "string.regex", + merge : true, + regex : "///", + next : "heregex" + }, { + token : "string.regex", + regex : "/(?!\\s)[^[/\\n\\\\]*(?: (?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[/\\n\\\\]*)*/[imgy]{0,4}(?!\\w)" + }, { + token : "comment", + merge : true, + regex : "###(?!#)", + next : "comment" + }, { + token : "comment", + regex : "#.*" + }, { + token : "punctuation.operator", + regex : "\\?|\\:|\\,|\\." + }, { + token : "keyword.operator", + regex : "(?:[\\-=]>|[-+*/%<>&|^!?=]=|>>>=?|\\-\\-|\\+\\+|::|&&=|\\|\\|=|<<=|>>=|\\?\\.|\\.{2,3}|[!*+-=><])" + }, { + token : "paren.lparen", + regex : "[({[]" + }, { + token : "paren.rparen", + regex : "[\\]})]" + }, { + token : "text", + regex : "\\s+" + }], + + qdoc : [{ + token : "string", + regex : ".*?'''", + next : "start" + }, stringfill], + + qqdoc : [{ + token : "string", + regex : '.*?"""', + next : "start" + }, stringfill], + + qstring : [{ + token : "string", + regex : "[^\\\\']*(?:\\\\.[^\\\\']*)*'", + merge : true, + next : "start" + }, stringfill], + + qqstring : [{ + token : "string", + regex : '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"', + merge : true, + next : "start" + }, stringfill], + + js : [{ + token : "string", + merge : true, + regex : "[^\\\\`]*(?:\\\\.[^\\\\`]*)*`", + next : "start" + }, stringfill], + + heregex : [{ + token : "string.regex", + regex : '.*?///[imgy]{0,4}', + next : "start" + }, { + token : "comment.regex", + regex : "\\s+(?:#.*)?" + }, { + token : "string.regex", + merge : true, + regex : "\\S+" + }], + + comment : [{ + token : "comment", + regex : '.*?###', + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + }] + }; + } + + exports.CoffeeHighlightRules = CoffeeHighlightRules; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-java.js b/vendor/assets/javascripts/ace-src-noconflict/mode-java.js new file mode 100644 index 00000000..23f9e603 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-java.js @@ -0,0 +1,1120 @@ +ace.define('ace/mode/java', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/javascript', 'ace/tokenizer', 'ace/mode/java_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var JavaScriptMode = require("./javascript").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JavaHighlightRules = require("./java_highlight_rules").JavaHighlightRules; + +var Mode = function() { + JavaScriptMode.call(this); + + this.$tokenizer = new Tokenizer(new JavaHighlightRules().getRules()); +}; +oop.inherits(Mode, JavaScriptMode); + +(function() { + + this.createWorker = function(session) { + return null; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start" || state == "regex_allowed") { + var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start" || state == "regex_allowed") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); + worker.attachToDocument(session.getDocument()); + + worker.on("jslint", function(results) { + var errors = []; + for (var i=0; i the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + // Sound.prototype.play = + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + // Sound.play = function() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // play = function() { } + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + // function myFunc(arg) { } + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + // foobar: function() { } + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + // escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + // invalid operators + token : "invalid", + regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?] + }, { + // operators + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/ + }, { + token: "string.regexp", + regex: /{|[^\[\\{()$^+*?\/]+/, + merge: true + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex", + merge: true + }, { + token: "constant.language.escape", + regex: "-", + }, { + token: "string.regexp.charachterclass", + regex: /[^\]\-\\]+/, + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); +ace.define('ace/mode/java_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var JavaHighlightRules = function() { + + // taken from http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html + var keywords = ( + "abstract|continue|for|new|switch|" + + "assert|default|goto|package|synchronized|" + + "boolean|do|if|private|this|" + + "break|double|implements|protected|throw|" + + "byte|else|import|public|throws|" + + "case|enum|instanceof|return|transient|" + + "catch|extends|int|short|try|" + + "char|final|interface|static|void|" + + "class|finally|long|strictfp|volatile|" + + "const|float|native|super|while" + ); + + var buildinConstants = ("null|Infinity|NaN|undefined"); + + + var langClasses = ( + "AbstractMethodError|AssertionError|ClassCircularityError|"+ + "ClassFormatError|Deprecated|EnumConstantNotPresentException|"+ + "ExceptionInInitializerError|IllegalAccessError|"+ + "IllegalThreadStateException|InstantiationError|InternalError|"+ + "NegativeArraySizeException|NoSuchFieldError|Override|Process|"+ + "ProcessBuilder|SecurityManager|StringIndexOutOfBoundsException|"+ + "SuppressWarnings|TypeNotPresentException|UnknownError|"+ + "UnsatisfiedLinkError|UnsupportedClassVersionError|VerifyError|"+ + "InstantiationException|IndexOutOfBoundsException|"+ + "ArrayIndexOutOfBoundsException|CloneNotSupportedException|"+ + "NoSuchFieldException|IllegalArgumentException|NumberFormatException|"+ + "SecurityException|Void|InheritableThreadLocal|IllegalStateException|"+ + "InterruptedException|NoSuchMethodException|IllegalAccessException|"+ + "UnsupportedOperationException|Enum|StrictMath|Package|Compiler|"+ + "Readable|Runtime|StringBuilder|Math|IncompatibleClassChangeError|"+ + "NoSuchMethodError|ThreadLocal|RuntimePermission|ArithmeticException|"+ + "NullPointerException|Long|Integer|Short|Byte|Double|Number|Float|"+ + "Character|Boolean|StackTraceElement|Appendable|StringBuffer|"+ + "Iterable|ThreadGroup|Runnable|Thread|IllegalMonitorStateException|"+ + "StackOverflowError|OutOfMemoryError|VirtualMachineError|"+ + "ArrayStoreException|ClassCastException|LinkageError|"+ + "NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+ + "Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+ + "Cloneable|Class|CharSequence|Comparable|String|Object" + ); + + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": keywords, + "constant.language": buildinConstants, + "support.function": langClasses, + + }, "identifier"); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token : "string.regexp", + regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "(?:true|false)\\b" + }, { + token : keywordMapper, + // TODO: Unicode escape sequences + // TODO: Unicode identifiers + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "lparen", + regex : "[[({]" + }, { + token : "rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaHighlightRules, TextHighlightRules); + +exports.JavaHighlightRules = JavaHighlightRules; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-javascript.js b/vendor/assets/javascripts/ace-src-noconflict/mode-javascript.js new file mode 100644 index 00000000..d266bffb --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-javascript.js @@ -0,0 +1,990 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start" || state == "regex_allowed") { + var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start" || state == "regex_allowed") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); + worker.attachToDocument(session.getDocument()); + + worker.on("jslint", function(results) { + var errors = []; + for (var i=0; i the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + // Sound.prototype.play = + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + // Sound.play = function() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // play = function() { } + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + // function myFunc(arg) { } + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + // foobar: function() { } + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + // escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + // invalid operators + token : "invalid", + regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?] + }, { + // operators + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/ + }, { + token: "string.regexp", + regex: /{|[^\[\\{()$^+*?\/]+/, + merge: true + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex", + merge: true + }, { + token: "constant.language.escape", + regex: "-", + }, { + token: "string.regexp.charachterclass", + regex: /[^\]\-\\]+/, + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-json.js b/vendor/assets/javascripts/ace-src-noconflict/mode-json.js new file mode 100644 index 00000000..19260b47 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-json.js @@ -0,0 +1,581 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/json', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/json_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle', 'ace/worker/worker_client'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var HighlightRules = require("./json_highlight_rules").JsonHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; +var WorkerClient = require("../worker/worker_client").WorkerClient; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new HighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/json_worker", "JsonWorker"); + worker.attachToDocument(session.getDocument()); + + worker.on("error", function(e) { + session.setAnnotations([e.data]); + }); + + worker.on("ok", function() { + session.clearAnnotations(); + }); + + return worker; + }; + + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/json_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var JsonHighlightRules = function() { + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + this.$rules = { + "start" : [ + { + token : "variable", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)' + }, { + token : "string", // single line + regex : '"', + next : "string" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "(?:true|false)\\b" + }, { + token : "invalid.illegal", // single quoted strings are not allowed + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "invalid.illegal", // comments are not allowed + regex : "\\/\\/.*$" + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "string" : [ + { + token : "constant.language.escape", + regex : /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\\\/bfnrt])/ + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : '"', + next : "start", + merge : true + }, { + token : "string", + regex : "", + next : "start", + merge : true + } + ] + }; + +}; + +oop.inherits(JsonHighlightRules, TextHighlightRules); + +exports.JsonHighlightRules = JsonHighlightRules; +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-jsp.js b/vendor/assets/javascripts/ace-src-noconflict/mode-jsp.js new file mode 100644 index 00000000..c96d25e9 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-jsp.js @@ -0,0 +1,1664 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/jsp', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/jsp_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle', 'ace/mode/javascript', 'ace/mode/css'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JspHighlightRules = require("./jsp_highlight_rules").JspHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + + +var JavaScriptMode = require("./javascript").Mode; +var CssMode = require("./css").Mode; + +var Mode = function() { + var highlighter = new JspHighlightRules(); + this.$tokenizer = new Tokenizer(highlighter.getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/jsp_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/html_highlight_rules', 'ace/mode/java_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; +var JavaHighlightRules = require("./java_highlight_rules").JavaHighlightRules; + +var JspHighlightRules = function() { + HtmlHighlightRules.call(this); + for (var i in this.$rules) { + this.$rules[i].unshift({ + token : "meta.tag", // jsp open tag + regex : "<%@?|<%=?|]+>", + next : "jsp-start" + }); + } + + var builtinVariables = 'request|response|out|session|' + + 'application|config|pageContext|page|Exception'; + + var keywords = 'page|include|taglib'; + + this.embedRules(JavaHighlightRules, "jsp-"); + + this.$rules["start"].unshift({ + token : "comment", + merge : true, + regex : "<%--", + next : "comment" + }); + + this.$rules["jsp-start"].unshift({ + token : "meta.tag", // jsp close tag + regex : "%>|<\\/jsp:[^>]+>", + next : "start" + }, + { + token: "variable.language", + regex : builtinVariables + }, { + token: "keyword", + regex : keywords + }); + + this.$rules.comment.unshift({ + token : "comment", + regex : ".*?--%>", + next : "start" + }); +}; + +oop.inherits(JspHighlightRules, HtmlHighlightRules); + +exports.JspHighlightRules = JspHighlightRules; +}); + +ace.define('ace/mode/html_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var xmlUtil = require("./xml_util"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var tagMap = lang.createMap({ + a : 'anchor', + button : 'form', + form : 'form', + img : 'image', + input : 'form', + label : 'form', + script : 'script', + select : 'form', + textarea : 'form', + style : 'style', + table : 'table', + tbody : 'table', + td : 'table', + tfoot : 'table', + th : 'table', + tr : 'table' +}); + +var HtmlHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + this.$rules = { + start : [{ + token : "text", + merge : true, + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "xml_pe", + regex : "<\\!.*?>" + }, { + token : "meta.tag", + regex : "<(?=\s*script\\b)", + next : "script" + }, { + token : "meta.tag", + regex : "<(?=\s*style\\b)", + next : "style" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "constant.character.entity", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }, { + token : "text", + regex : "[^<]+" + } ], + + cdata : [ { + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + merge : true, + regex : "\\s+" + }, { + token : "text", + merge : true, + regex : ".+" + } ], + + comment : [ { + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + } ] + }; + + xmlUtil.tag(this.$rules, "tag", "start", tagMap); + xmlUtil.tag(this.$rules, "style", "css-start", tagMap); + xmlUtil.tag(this.$rules, "script", "js-start", tagMap); + + this.embedRules(JavaScriptHighlightRules, "js-", [{ + token: "comment", + regex: "\\/\\/.*(?=<\\/script>)", + next: "tag" + }, { + token: "meta.tag", + regex: "<\\/(?=script)", + next: "tag" + }]); + + this.embedRules(CssHighlightRules, "css-", [{ + token: "meta.tag", + regex: "<\\/(?=style)", + next: "tag" + }]); +}; + +oop.inherits(HtmlHighlightRules, TextHighlightRules); + +exports.HtmlHighlightRules = HtmlHighlightRules; +}); + +ace.define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CssHighlightRules = function() { + var keywordMapper = this.createKeywordMapper({ + "support.type": "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index", + "support.function": "rgb|rgba|url|attr|counter|counters", + "support.constant": "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero", + "support.constant.color": "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow", + "support.constant.fonts": "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace" + }, "text", true); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b"; + var pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b"; + + var base_ruleset = [ + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "ruleset_comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : ["constant.numeric", "keyword"], + regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)" + }, { + token : ["constant.numeric"], + regex : "([0-9]+)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"], + regex : pseudoElements + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], + regex : pseudoClasses + }, { + token : keywordMapper, + regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" + } + ]; + + var ruleset = lang.copyArray(base_ruleset); + ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "start" + }); + + var media_ruleset = lang.copyArray( base_ruleset ); + media_ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "media" + }); + + var base_comment = [{ + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + }]; + + var comment = lang.copyArray(base_comment); + comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }); + + var media_comment = lang.copyArray(base_comment); + media_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "media" + }); + + var ruleset_comment = lang.copyArray(base_comment); + ruleset_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "ruleset" + }); + + this.$rules = { + "start" : [{ + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "ruleset" + }, { + token: "string", + regex: "@.*?{", + next: "media" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "media" : [ { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "media_comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "media_ruleset" + },{ + token: "string", + regex: "\\}", + next: "start" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "comment" : comment, + + "ruleset" : ruleset, + "ruleset_comment" : ruleset_comment, + + "media_ruleset" : media_ruleset, + "media_comment" : media_comment + }; +}; + +oop.inherits(CssHighlightRules, TextHighlightRules); + +exports.CssHighlightRules = CssHighlightRules; + +}); + +ace.define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/unicode', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var unicode = require("../unicode"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var JavaScriptHighlightRules = function() { + // see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects + var keywordMapper = this.createKeywordMapper({ + "variable.language": + "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors + "Namespace|QName|XML|XMLList|" + // E4X + "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" + + "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" + + "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors + "SyntaxError|TypeError|URIError|" + + "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions + "isNaN|parseFloat|parseInt|" + + "JSON|Math|" + // Other + "this|arguments|prototype|window|document" , // Pseudo + "invalid.deprecated": + "__parent__|__count__|escape|unescape|with|__proto__|debugger", + "keyword": + "const|yield|import|get|set" + + "break|case|catch|continue|default|delete|do|else|finally|for|function|" + + "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|", + "storage.type": + "const|let|var|function", + "invalid.illegal": + "class|enum|extends|super|export|implements|private|" + + "public|interface|package|protected|static", + "constant.language": + "null|Infinity|NaN|undefined", + }, "identifier"); + + + // keywords which can be followed by regular expressions + var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield"; + + // TODO: Unicode escape sequences + var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b"; + + var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex + "u[0-9a-fA-F]{4}|" + // unicode + "[0-2][0-7]{0,2}|" + // oct + "3[0-6][0-7]?|" + // oct + "37[0-7]?|" + // oct + "[4-7][0-7]?|" + //oct + ".)"; + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + // Sound.prototype.play = + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + // Sound.play = function() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // play = function() { } + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + // function myFunc(arg) { } + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + // foobar: function() { } + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + // escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + // invalid operators + token : "invalid", + regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?] + }, { + // operators + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/ + }, { + token: "string.regexp", + regex: /{|[^\[\\{()$^+*?\/]+/, + merge: true + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex", + merge: true + }, { + token: "constant.language.escape", + regex: "-", + }, { + token: "string.regexp.charachterclass", + regex: /[^\]\-\\]+/, + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) { + + +function string(state) { + return [{ + token : "string", + regex : '".*?"' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*', + next : state + "_qqstring" + }, { + token : "string", + regex : "'.*?'" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*", + next : state + "_qstring" + }]; +} + +function multiLineString(quote, state) { + return [{ + token : "string", + merge : true, + regex : ".*?" + quote, + next : state + }, { + token : "string", + merge : true, + regex : '.+' + }]; +} + +exports.tag = function(states, name, nextState, tagMap) { + states[name] = [{ + token : "text", + regex : "\\s+" + }, { + //token : "meta.tag", + + token : !tagMap ? "meta.tag.tag-name" : function(value) { + if (tagMap[value]) + return "meta.tag.tag-name." + tagMap[value]; + else + return "meta.tag.tag-name"; + }, + merge : true, + regex : "[-_a-zA-Z0-9:]+", + next : name + "_embed_attribute_list" + }, { + token: "empty", + regex: "", + next : name + "_embed_attribute_list" + }]; + + states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list"); + states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list"); + + states[name + "_embed_attribute_list"] = [{ + token : "meta.tag", + merge : true, + regex : "\/?>", + next : nextState + }, { + token : "keyword.operator", + regex : "=" + }, { + token : "entity.other.attribute-name", + regex : "[-_a-zA-Z0-9:]+" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "text", + regex : "\\s+" + }].concat(string(name)); +}; + +}); +ace.define('ace/mode/java_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var JavaHighlightRules = function() { + + // taken from http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html + var keywords = ( + "abstract|continue|for|new|switch|" + + "assert|default|goto|package|synchronized|" + + "boolean|do|if|private|this|" + + "break|double|implements|protected|throw|" + + "byte|else|import|public|throws|" + + "case|enum|instanceof|return|transient|" + + "catch|extends|int|short|try|" + + "char|final|interface|static|void|" + + "class|finally|long|strictfp|volatile|" + + "const|float|native|super|while" + ); + + var buildinConstants = ("null|Infinity|NaN|undefined"); + + + var langClasses = ( + "AbstractMethodError|AssertionError|ClassCircularityError|"+ + "ClassFormatError|Deprecated|EnumConstantNotPresentException|"+ + "ExceptionInInitializerError|IllegalAccessError|"+ + "IllegalThreadStateException|InstantiationError|InternalError|"+ + "NegativeArraySizeException|NoSuchFieldError|Override|Process|"+ + "ProcessBuilder|SecurityManager|StringIndexOutOfBoundsException|"+ + "SuppressWarnings|TypeNotPresentException|UnknownError|"+ + "UnsatisfiedLinkError|UnsupportedClassVersionError|VerifyError|"+ + "InstantiationException|IndexOutOfBoundsException|"+ + "ArrayIndexOutOfBoundsException|CloneNotSupportedException|"+ + "NoSuchFieldException|IllegalArgumentException|NumberFormatException|"+ + "SecurityException|Void|InheritableThreadLocal|IllegalStateException|"+ + "InterruptedException|NoSuchMethodException|IllegalAccessException|"+ + "UnsupportedOperationException|Enum|StrictMath|Package|Compiler|"+ + "Readable|Runtime|StringBuilder|Math|IncompatibleClassChangeError|"+ + "NoSuchMethodError|ThreadLocal|RuntimePermission|ArithmeticException|"+ + "NullPointerException|Long|Integer|Short|Byte|Double|Number|Float|"+ + "Character|Boolean|StackTraceElement|Appendable|StringBuffer|"+ + "Iterable|ThreadGroup|Runnable|Thread|IllegalMonitorStateException|"+ + "StackOverflowError|OutOfMemoryError|VirtualMachineError|"+ + "ArrayStoreException|ClassCastException|LinkageError|"+ + "NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+ + "Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+ + "Cloneable|Class|CharSequence|Comparable|String|Object" + ); + + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": keywords, + "constant.language": buildinConstants, + "support.function": langClasses, + + }, "identifier"); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token : "string.regexp", + regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "(?:true|false)\\b" + }, { + token : keywordMapper, + // TODO: Unicode escape sequences + // TODO: Unicode identifiers + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "lparen", + regex : "[[({]" + }, { + token : "rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaHighlightRules, TextHighlightRules); + +exports.JavaHighlightRules = JavaHighlightRules; +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start" || state == "regex_allowed") { + var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start" || state == "regex_allowed") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); + worker.attachToDocument(session.getDocument()); + + worker.on("jslint", function(results) { + var errors = []; + for (var i=0; i=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "punctuation.operator", + regex : "\\?|\\:|\\,|\\;|\\." + }, { + token : "paren.lparen", + regex : "[[({<]" + }, { + token : "paren.rparen", + regex : "[\\])}>]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); + }; + + oop.inherits(JsxHighlightRules, TextHighlightRules); + + exports.JsxHighlightRules = JsxHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-latex.js b/vendor/assets/javascripts/ace-src-noconflict/mode-latex.js new file mode 100644 index 00000000..eb706bbd --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-latex.js @@ -0,0 +1,95 @@ +ace.define('ace/mode/latex', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/latex_highlight_rules', 'ace/range'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var LatexHighlightRules = require("./latex_highlight_rules").LatexHighlightRules; +var Range = require("../range").Range; + +var Mode = function() +{ + this.$tokenizer = new Tokenizer(new LatexHighlightRules().getRules()); +}; +oop.inherits(Mode, TextMode); + +(function() { + this.toggleCommentLines = function(state, doc, startRow, endRow) { + // This code is adapted from ruby.js + var outdent = true; + + // LaTeX comments begin with % and go to the end of the line + var commentRegEx = /^(\s*)\%/; + + for (var i = startRow; i <= endRow; i++) { + if (!commentRegEx.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i = startRow; i <= endRow; i++) { + var line = doc.getLine(i); + var m = line.match(commentRegEx); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "%"); + } + }; + + // There is no universally accepted way of indenting a tex document + // so just maintain the indentation of the previous line + this.getNextLineIndent = function(state, line, tab) { + return this.$getIndent(line); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); +ace.define('ace/mode/latex_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var LatexHighlightRules = function() { + this.$rules = { + "start" : [{ + // A tex command e.g. \foo + token : "keyword", + regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)", + }, { + // Curly and square braces + token : "lparen", + regex : "[[({]" + }, { + // Curly and square braces + token : "rparen", + regex : "[\\])}]" + }, { + // Inline math between two $ symbols + token : "string", + regex : "\\$(?:(?:\\\\.)|(?:[^\\$\\\\]))*?\\$" + }, { + // A comment. Tex comments start with % and go to + // the end of the line + token : "comment", + regex : "%.*$" + }] + }; +}; + +oop.inherits(LatexHighlightRules, TextHighlightRules); + +exports.LatexHighlightRules = LatexHighlightRules; + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-less.js b/vendor/assets/javascripts/ace-src-noconflict/mode-less.js new file mode 100644 index 00000000..43bf8a9d --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-less.js @@ -0,0 +1,504 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/less', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/less_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var LessHighlightRules = require("./less_highlight_rules").LessHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new LessHighlightRules().getRules(), "i"); + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + // ignore braces in comments + var tokens = this.$tokenizer.getLineTokens(line, state).tokens; + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + var match = line.match(/^.*\{\s*$/); + if (match) { + indent += tab; + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/less_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var LessHighlightRules = function() { + + var properties = lang.arrayToMap( (function () { + + var browserPrefix = ("-webkit-|-moz-|-o-|-ms-|-svg-|-pie-|-khtml-").split("|"); + + var prefixProperties = ("appearance|background-clip|background-inline-policy|background-origin|" + + "background-size|binding|border-bottom-colors|border-left-colors|" + + "border-right-colors|border-top-colors|border-end|border-end-color|" + + "border-end-style|border-end-width|border-image|border-start|" + + "border-start-color|border-start-style|border-start-width|box-align|" + + "box-direction|box-flex|box-flexgroup|box-ordinal-group|box-orient|" + + "box-pack|box-sizing|column-count|column-gap|column-width|column-rule|" + + "column-rule-width|column-rule-style|column-rule-color|float-edge|" + + "font-feature-settings|font-language-override|force-broken-image-icon|" + + "image-region|margin-end|margin-start|opacity|outline|outline-color|" + + "outline-offset|outline-radius|outline-radius-bottomleft|" + + "outline-radius-bottomright|outline-radius-topleft|outline-radius-topright|" + + "outline-style|outline-width|padding-end|padding-start|stack-sizing|" + + "tab-size|text-blink|text-decoration-color|text-decoration-line|" + + "text-decoration-style|transform|transform-origin|transition|" + + "transition-delay|transition-duration|transition-property|" + + "transition-timing-function|user-focus|user-input|user-modify|user-select|" + + "window-shadow|border-radius").split("|"); + + var properties = ("azimuth|background-attachment|background-color|background-image|" + + "background-position|background-repeat|background|border-bottom-color|" + + "border-bottom-style|border-bottom-width|border-bottom|border-collapse|" + + "border-color|border-left-color|border-left-style|border-left-width|" + + "border-left|border-right-color|border-right-style|border-right-width|" + + "border-right|border-spacing|border-style|border-top-color|" + + "border-top-style|border-top-width|border-top|border-width|border|" + + "bottom|box-sizing|caption-side|clear|clip|color|content|counter-increment|" + + "counter-reset|cue-after|cue-before|cue|cursor|direction|display|" + + "elevation|empty-cells|float|font-family|font-size-adjust|font-size|" + + "font-stretch|font-style|font-variant|font-weight|font|height|left|" + + "letter-spacing|line-height|list-style-image|list-style-position|" + + "list-style-type|list-style|margin-bottom|margin-left|margin-right|" + + "margin-top|marker-offset|margin|marks|max-height|max-width|min-height|" + + "min-width|opacity|orphans|outline-color|" + + "outline-style|outline-width|outline|overflow|overflow-x|overflow-y|padding-bottom|" + + "padding-left|padding-right|padding-top|padding|page-break-after|" + + "page-break-before|page-break-inside|page|pause-after|pause-before|" + + "pause|pitch-range|pitch|play-during|position|quotes|richness|right|" + + "size|speak-header|speak-numeral|speak-punctuation|speech-rate|speak|" + + "stress|table-layout|text-align|text-decoration|text-indent|" + + "text-shadow|text-transform|top|unicode-bidi|vertical-align|" + + "visibility|voice-family|volume|white-space|widows|width|word-spacing|" + + "z-index").split("|"); + + //The return array + var ret = []; + + //All prefixProperties will get the browserPrefix in + //the begning by join the prefixProperties array with the value of browserPrefix + for (var i=0, ln=browserPrefix.length; i the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "constant.numeric", + regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : "constant.numeric", + regex : numRe + }, { + token : function(value) { + if (keywords.hasOwnProperty(value)) + return "keyword"; + else + return "variable"; + }, + regex : "@[a-z0-9_\\-@]*\\b" + }, { + token : function(value) { + if (properties.hasOwnProperty(value.toLowerCase())) + return "support.type"; + else if (keywords.hasOwnProperty(value)) + return "keyword"; + else if (constants.hasOwnProperty(value)) + return "constant.language"; + else if (functions.hasOwnProperty(value)) + return "support.function"; + else if (colors.hasOwnProperty(value.toLowerCase())) + return "support.constant.color"; + else if (tags.hasOwnProperty(value.toLowerCase())) + return "variable.language"; + else + return "text"; + }, + regex : "\\-?[@a-z_][@a-z0-9_\\-]*" + }, { + token: "variable.language", + regex: "#[a-z0-9-_]+" + }, { + token: "variable.language", + regex: "\\.[a-z0-9-_]+" + }, { + token: "variable.language", + regex: ":[a-z0-9-_]+" + }, { + token: "constant", + regex: "[a-z0-9-_]+" + }, { + token : "keyword.operator", + regex : "<|>|<=|>=|==|!=|-|%|#|\\+|\\$|\\+|\\*" + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ] + }; +}; + +oop.inherits(LessHighlightRules, TextHighlightRules); + +exports.LessHighlightRules = LessHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-liquid.js b/vendor/assets/javascripts/ace-src-noconflict/mode-liquid.js new file mode 100644 index 00000000..2623396c --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-liquid.js @@ -0,0 +1,1003 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/liquid', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/liquid_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range'], function(require, exports, module) { + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var LiquidHighlightRules = require("./liquid_highlight_rules").LiquidHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new LiquidHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var outentedRows = []; + var re = /^(\s*)#/; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "#"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/liquid_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var xmlUtil = require("./xml_util"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var LiquidHighlightRules = function() { + + // see: https://developer.mozilla.org/en/Liquid/Reference/Global_Objects + var functions = ( + // Standard Filters + "date|capitalize|downcase|upcase|first|last|join|sort|map|size|escape|" + + "escape_once|strip_html|strip_newlines|newline_to_br|replace|replace_first|" + + "truncate|truncatewords|prepend|append|minus|plus|times|divided_by|split" + ); + + var keywords = ( + // Standard Tags + "capture|endcapture|case|endcase|when|comment|endcomment|" + + "cycle|for|endfor|in|reversed|if|endif|else|elsif|include|endinclude|unless|endunless|" + + // Commonly used tags + "style|text|image|widget|plugin|marker|endmarker|tablerow|endtablerow" + ); + + var builtinVariables = 'forloop|tablerowloop'; + // "forloop\\.(length|index|index0|rindex|rindex0|first|last)|limit|offset|range" + + // "tablerowloop\\.(length|index|index0|rindex|rindex0|first|last|col|col0|"+ + // "col_first|col_last)" + + var definitions = ("assign"); + + var keywordMapper = this.createKeywordMapper({ + "variable.language": builtinVariables, + "keyword": keywords, + "support.function": functions, + "keyword.definition": definitions + }, "identifier"); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + start : [{ + token : "variable", + regex : "{%", + next : "liquid_start" + }, { + token : "variable", + regex : "{{", + next : "liquid_start" + }, { + token : "meta.tag", + merge : true, + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "meta.tag", + regex : "<(?=\\s*script\\b)", + next : "script" + }, { + token : "meta.tag", + regex : "<(?=\\s*style\\b)", + next : "style" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "text", + regex : "[^<]+" + } ], + + cdata : [ { + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + merge : true, + regex : "\\s+" + }, { + token : "text", + merge : true, + regex : ".+" + } ], + + comment : [ { + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + } ] , + + liquid_start : [{ + token: "variable", + regex: "}}", + next: "start" + }, { + token: "variable", + regex: "%}", + next: "start" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "(?:true|false)\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\/|\\*|\\-|\\+|=|!=|\\?\\:" + }, { + token : "paren.lparen", + regex : /[\[\({]/ + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "text", + regex : "\\s+" + }] + }; + + xmlUtil.tag(this.$rules, "tag", "start"); + xmlUtil.tag(this.$rules, "style", "css-start"); + xmlUtil.tag(this.$rules, "script", "js-start"); + + this.embedRules(JavaScriptHighlightRules, "js-", [{ + token: "comment", + regex: "\\/\\/.*(?=<\\/script>)", + next: "tag" + }, { + token: "meta.tag", + regex: "<\\/(?=script)", + next: "tag" + }]); + + this.embedRules(CssHighlightRules, "css-", [{ + token: "meta.tag", + regex: "<\\/(?=style)", + next: "tag" + }]); +}; +oop.inherits(LiquidHighlightRules, TextHighlightRules); + +exports.LiquidHighlightRules = LiquidHighlightRules; +}); + +ace.define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CssHighlightRules = function() { + var keywordMapper = this.createKeywordMapper({ + "support.type": "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index", + "support.function": "rgb|rgba|url|attr|counter|counters", + "support.constant": "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero", + "support.constant.color": "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow", + "support.constant.fonts": "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace" + }, "text", true); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b"; + var pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b"; + + var base_ruleset = [ + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "ruleset_comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : ["constant.numeric", "keyword"], + regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)" + }, { + token : ["constant.numeric"], + regex : "([0-9]+)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"], + regex : pseudoElements + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], + regex : pseudoClasses + }, { + token : keywordMapper, + regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" + } + ]; + + var ruleset = lang.copyArray(base_ruleset); + ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "start" + }); + + var media_ruleset = lang.copyArray( base_ruleset ); + media_ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "media" + }); + + var base_comment = [{ + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + }]; + + var comment = lang.copyArray(base_comment); + comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }); + + var media_comment = lang.copyArray(base_comment); + media_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "media" + }); + + var ruleset_comment = lang.copyArray(base_comment); + ruleset_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "ruleset" + }); + + this.$rules = { + "start" : [{ + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "ruleset" + }, { + token: "string", + regex: "@.*?{", + next: "media" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "media" : [ { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "media_comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "media_ruleset" + },{ + token: "string", + regex: "\\}", + next: "start" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "comment" : comment, + + "ruleset" : ruleset, + "ruleset_comment" : ruleset_comment, + + "media_ruleset" : media_ruleset, + "media_comment" : media_comment + }; +}; + +oop.inherits(CssHighlightRules, TextHighlightRules); + +exports.CssHighlightRules = CssHighlightRules; + +}); + +ace.define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/unicode', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var unicode = require("../unicode"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var JavaScriptHighlightRules = function() { + // see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects + var keywordMapper = this.createKeywordMapper({ + "variable.language": + "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors + "Namespace|QName|XML|XMLList|" + // E4X + "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" + + "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" + + "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors + "SyntaxError|TypeError|URIError|" + + "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions + "isNaN|parseFloat|parseInt|" + + "JSON|Math|" + // Other + "this|arguments|prototype|window|document" , // Pseudo + "invalid.deprecated": + "__parent__|__count__|escape|unescape|with|__proto__|debugger", + "keyword": + "const|yield|import|get|set" + + "break|case|catch|continue|default|delete|do|else|finally|for|function|" + + "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|", + "storage.type": + "const|let|var|function", + "invalid.illegal": + "class|enum|extends|super|export|implements|private|" + + "public|interface|package|protected|static", + "constant.language": + "null|Infinity|NaN|undefined", + }, "identifier"); + + + // keywords which can be followed by regular expressions + var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield"; + + // TODO: Unicode escape sequences + var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b"; + + var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex + "u[0-9a-fA-F]{4}|" + // unicode + "[0-2][0-7]{0,2}|" + // oct + "3[0-6][0-7]?|" + // oct + "37[0-7]?|" + // oct + "[4-7][0-7]?|" + //oct + ".)"; + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + // Sound.prototype.play = + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + // Sound.play = function() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // play = function() { } + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + // function myFunc(arg) { } + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + // foobar: function() { } + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + // escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + // invalid operators + token : "invalid", + regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?] + }, { + // operators + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/ + }, { + token: "string.regexp", + regex: /{|[^\[\\{()$^+*?\/]+/, + merge: true + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex", + merge: true + }, { + token: "constant.language.escape", + regex: "-", + }, { + token: "string.regexp.charachterclass", + regex: /[^\]\-\\]+/, + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) { + + +function string(state) { + return [{ + token : "string", + regex : '".*?"' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*', + next : state + "_qqstring" + }, { + token : "string", + regex : "'.*?'" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*", + next : state + "_qstring" + }]; +} + +function multiLineString(quote, state) { + return [{ + token : "string", + merge : true, + regex : ".*?" + quote, + next : state + }, { + token : "string", + merge : true, + regex : '.+' + }]; +} + +exports.tag = function(states, name, nextState, tagMap) { + states[name] = [{ + token : "text", + regex : "\\s+" + }, { + //token : "meta.tag", + + token : !tagMap ? "meta.tag.tag-name" : function(value) { + if (tagMap[value]) + return "meta.tag.tag-name." + tagMap[value]; + else + return "meta.tag.tag-name"; + }, + merge : true, + regex : "[-_a-zA-Z0-9:]+", + next : name + "_embed_attribute_list" + }, { + token: "empty", + regex: "", + next : name + "_embed_attribute_list" + }]; + + states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list"); + states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list"); + + states[name + "_embed_attribute_list"] = [{ + token : "meta.tag", + merge : true, + regex : "\/?>", + next : nextState + }, { + token : "keyword.operator", + regex : "=" + }, { + token : "entity.other.attribute-name", + regex : "[-_a-zA-Z0-9:]+" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "text", + regex : "\\s+" + }].concat(string(name)); +}; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-lua.js b/vendor/assets/javascripts/ace-src-noconflict/mode-lua.js new file mode 100644 index 00000000..22d35f18 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-lua.js @@ -0,0 +1,524 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/lua', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/lua_highlight_rules', 'ace/range'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var LuaHighlightRules = require("./lua_highlight_rules").LuaHighlightRules; +var Range = require("../range").Range; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new LuaHighlightRules().getRules()); +}; +oop.inherits(Mode, TextMode); + +(function() { + var indentKeywords = { + "function": 1, + "then": 1, + "do": 1, + "else": 1, + "elseif": 1, + "repeat": 1, + "end": -1, + "until": -1, + }; + var outdentKeywords = [ + "else", + "elseif", + "end", + "until" + ]; + + function getNetIndentLevel(tokens) { + var level = 0; + // Support single-line blocks by decrementing the indent level if + // an ending token is found + for (var i in tokens){ + var token = tokens[i]; + if (token.type == "keyword") { + if (token.value in indentKeywords) { + level += indentKeywords[token.value]; + } + } else if (token.type == "paren.lparen") { + level ++; + } else if (token.type == "paren.rparen") { + level --; + } + } + // Limit the level to +/- 1 since usually users only indent one level + // at a time regardless of the logical nesting level + if (level < 0) { + return -1; + } else if (level > 0) { + return 1; + } else { + return 0; + } + } + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + var level = 0; + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (state == "start") { + level = getNetIndentLevel(tokens); + } + if (level > 0) { + return indent + tab; + } else if (level < 0 && indent.substr(indent.length - tab.length) == tab) { + // Don't do a next-line outdent if we're going to do a real outdent of this line + if (!this.checkOutdent(state, line, "\n")) { + return indent.substr(0, indent.length - tab.length); + } + } + return indent; + }; + + this.checkOutdent = function(state, line, input) { + if (input != "\n" && input != "\r" && input != "\r\n") + return false; + + if (line.match(/^\s*[\)\}\]]$/)) + return true; + + var tokens = this.$tokenizer.getLineTokens(line.trim(), state).tokens; + + if (!tokens || !tokens.length) + return false; + + return (tokens[0].type == "keyword" && outdentKeywords.indexOf(tokens[0].value) != -1); + }; + + this.autoOutdent = function(state, session, row) { + var prevLine = session.getLine(row - 1); + var prevIndent = this.$getIndent(prevLine).length; + var prevTokens = this.$tokenizer.getLineTokens(prevLine, "start").tokens; + var tabLength = session.getTabString().length; + var expectedIndent = prevIndent + tabLength * getNetIndentLevel(prevTokens); + var curIndent = this.$getIndent(session.getLine(row)).length; + if (curIndent < expectedIndent) { + // User already outdented // + return; + } + session.outdentRows(new Range(row, 0, row + 2, 0)); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/lua_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var LuaHighlightRules = function() { + + var keywords = ( + "break|do|else|elseif|end|for|function|if|in|local|repeat|"+ + "return|then|until|while|or|and|not" + ); + + var builtinConstants = ("true|false|nil|_G|_VERSION"); + + var functions = ( + // builtinFunctions + "string|xpcall|package|tostring|print|os|unpack|require|"+ + "getfenv|setmetatable|next|assert|tonumber|io|rawequal|"+ + "collectgarbage|getmetatable|module|rawset|math|debug|"+ + "pcall|table|newproxy|type|coroutine|_G|select|gcinfo|"+ + "pairs|rawget|loadstring|ipairs|_VERSION|dofile|setfenv|"+ + "load|error|loadfile|"+ + + "sub|upper|len|gfind|rep|find|match|char|dump|gmatch|"+ + "reverse|byte|format|gsub|lower|preload|loadlib|loaded|"+ + "loaders|cpath|config|path|seeall|exit|setlocale|date|"+ + "getenv|difftime|remove|time|clock|tmpname|rename|execute|"+ + "lines|write|close|flush|open|output|type|read|stderr|"+ + "stdin|input|stdout|popen|tmpfile|log|max|acos|huge|"+ + "ldexp|pi|cos|tanh|pow|deg|tan|cosh|sinh|random|randomseed|"+ + "frexp|ceil|floor|rad|abs|sqrt|modf|asin|min|mod|fmod|log10|"+ + "atan2|exp|sin|atan|getupvalue|debug|sethook|getmetatable|"+ + "gethook|setmetatable|setlocal|traceback|setfenv|getinfo|"+ + "setupvalue|getlocal|getregistry|getfenv|setn|insert|getn|"+ + "foreachi|maxn|foreach|concat|sort|remove|resume|yield|"+ + "status|wrap|create|running|"+ + // metatableMethods + "__add|__sub|__mod|__unm|__concat|__lt|__index|__call|__gc|__metatable|"+ + "__mul|__div|__pow|__len|__eq|__le|__newindex|__tostring|__mode|__tonumber" + ); + + var stdLibaries = ("string|package|os|io|math|debug|table|coroutine"); + + var futureReserved = ""; + + var deprecatedIn5152 = ("setn|foreach|foreachi|gcinfo|log10|maxn"); + + var keywordMapper = this.createKeywordMapper({ + "keyword": keywords, + "support.function": functions, + "invalid.deprecated": deprecatedIn5152, + "constant.library": stdLibaries, + "constant.language": builtinConstants, + "invalid.illegal": futureReserved, + "variable.language": "this" + }, "identifier"); + + var strPre = ""; + + var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))"; + var hexInteger = "(?:0[xX][\\dA-Fa-f]+)"; + var integer = "(?:" + decimalInteger + "|" + hexInteger + ")"; + + var fraction = "(?:\\.\\d+)"; + var intPart = "(?:\\d+)"; + var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))"; + var floatNumber = "(?:" + pointFloat + ")"; + + var comment_stack = []; + + this.$rules = { + "start" : + + + // bracketed comments + [{ + token : "comment", // --[[ comment + regex : strPre + '\\-\\-\\[\\[.*\\]\\]' + }, { + token : "comment", // --[=[ comment + regex : strPre + '\\-\\-\\[\\=\\[.*\\]\\=\\]' + }, { + token : "comment", // --[==[ comment + regex : strPre + '\\-\\-\\[\\={2}\\[.*\\]\\={2}\\]' + }, { + token : "comment", // --[===[ comment + regex : strPre + '\\-\\-\\[\\={3}\\[.*\\]\\={3}\\]' + }, { + token : "comment", // --[====[ comment + regex : strPre + '\\-\\-\\[\\={4}\\[.*\\]\\={4}\\]' + }, { + token : "comment", // --[====+[ comment + regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]' + }, + + // multiline bracketed comments + { + token : "comment", // --[[ comment + regex : strPre + '\\-\\-\\[\\[.*$', + merge : true, + next : "qcomment" + }, { + token : "comment", // --[=[ comment + regex : strPre + '\\-\\-\\[\\=\\[.*$', + merge : true, + next : "qcomment1" + }, { + token : "comment", // --[==[ comment + regex : strPre + '\\-\\-\\[\\={2}\\[.*$', + merge : true, + next : "qcomment2" + }, { + token : "comment", // --[===[ comment + regex : strPre + '\\-\\-\\[\\={3}\\[.*$', + merge : true, + next : "qcomment3" + }, { + token : "comment", // --[====[ comment + regex : strPre + '\\-\\-\\[\\={4}\\[.*$', + merge : true, + next : "qcomment4" + }, { + token : function(value){ // --[====+[ comment + // WARNING: EXTREMELY SLOW, but this is the only way to circumvent the + // limits imposed by the current automaton. + // I've never personally seen any practical code where 5 or more '='s are + // used for string or commenting, so this will rarely be invoked. + var pattern = /\-\-\[(\=+)\[/, match; + // you can never be too paranoid ;) + if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined) + comment_stack.push(match.length); + + return "comment"; + }, + regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*$', + merge : true, + next : "qcomment5" + }, + + // single line comments + { + token : "comment", + regex : "\\-\\-.*$" + }, + + // bracketed strings + { + token : "string", // [[ string + regex : strPre + '\\[\\[.*\\]\\]' + }, { + token : "string", // [=[ string + regex : strPre + '\\[\\=\\[.*\\]\\=\\]' + }, { + token : "string", // [==[ string + regex : strPre + '\\[\\={2}\\[.*\\]\\={2}\\]' + }, { + token : "string", // [===[ string + regex : strPre + '\\[\\={3}\\[.*\\]\\={3}\\]' + }, { + token : "string", // [====[ string + regex : strPre + '\\[\\={4}\\[.*\\]\\={4}\\]' + }, { + token : "string", // [====+[ string + regex : strPre + '\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]' + }, + + // multiline bracketed strings + { + token : "string", // [[ string + regex : strPre + '\\[\\[.*$', + merge : true, + next : "qstring" + }, { + token : "string", // [=[ string + regex : strPre + '\\[\\=\\[.*$', + merge : true, + next : "qstring1" + }, { + token : "string", // [==[ string + regex : strPre + '\\[\\={2}\\[.*$', + merge : true, + next : "qstring2" + }, { + token : "string", // [===[ string + regex : strPre + '\\[\\={3}\\[.*$', + merge : true, + next : "qstring3" + }, { + token : "string", // [====[ string + regex : strPre + '\\[\\={4}\\[.*$', + merge : true, + next : "qstring4" + }, { + token : function(value){ // --[====+[ string + // WARNING: EXTREMELY SLOW, see above. + var pattern = /\[(\=+)\[/, match; + if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined) + comment_stack.push(match.length); + + return "string"; + }, + regex : strPre + '\\[\\={5}\\=*\\[.*$', + merge : true, + next : "qstring5" + }, + + { + token : "string", // " string + regex : strPre + '"(?:[^\\\\]|\\\\.)*?"' + }, { + token : "string", // ' string + regex : strPre + "'(?:[^\\\\]|\\\\.)*?'" + }, { + token : "constant.numeric", // float + regex : floatNumber + }, { + token : "constant.numeric", // integer + regex : integer + "\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\+|\\-|\\*|\\/|%|\\#|\\^|~|<|>|<=|=>|==|~=|=|\\:|\\.\\.\\.|\\.\\." + }, { + token : "paren.lparen", + regex : "[\\[\\(\\{]" + }, { + token : "paren.rparen", + regex : "[\\]\\)\\}]" + }, { + token : "text", + regex : "\\s+" + } ], + + "qcomment": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment1": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\=\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment2": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment3": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment4": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment5": [ { + token : function(value){ + // very hackish, mutates the qcomment5 field on the fly. + var pattern = /\](\=+)\]/, rule = this.rules.qcomment5[0], match; + rule.next = "start"; + if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined){ + var found = match.length, expected; + if ((expected = comment_stack.pop()) != found){ + comment_stack.push(expected); + rule.next = "qcomment5"; + } + } + + return "comment"; + }, + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + + "qstring": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring1": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\=\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring2": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring3": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring4": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring5": [ { + token : function(value){ + // very hackish, mutates the qstring5 field on the fly. + var pattern = /\](\=+)\]/, rule = this.rules.qstring5[0], match; + rule.next = "start"; + if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined){ + var found = match.length, expected; + if ((expected = comment_stack.pop()) != found){ + comment_stack.push(expected); + rule.next = "qstring5"; + } + } + + return "string"; + }, + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ] + + }; + +} + +oop.inherits(LuaHighlightRules, TextHighlightRules); + +exports.LuaHighlightRules = LuaHighlightRules; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-luahtml.js b/vendor/assets/javascripts/ace-src-noconflict/mode-luahtml.js new file mode 100644 index 00000000..89bc2ec7 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-luahtml.js @@ -0,0 +1,2415 @@ +ace.define('ace/mode/luahtml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/html', 'ace/mode/lua', 'ace/tokenizer', 'ace/mode/luahtml_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var HtmlMode = require("./html").Mode; +var LuaMode = require("./lua").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var LuaHtmlHighlightRules = require("./luahtml_highlight_rules").LuaHtmlHighlightRules; + +var Mode = function() { + var highlighter = new LuaHtmlHighlightRules(); + + this.$tokenizer = new Tokenizer(new LuaHtmlHighlightRules().getRules()); + this.$embeds = highlighter.getEmbeds(); + this.createModeDelegates({ + "lua-": LuaMode + }); +}; +oop.inherits(Mode, HtmlMode); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/mode/javascript', 'ace/mode/css', 'ace/tokenizer', 'ace/mode/html_highlight_rules', 'ace/mode/behaviour/xml', 'ace/mode/folding/html'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var JavaScriptMode = require("./javascript").Mode; +var CssMode = require("./css").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; +var XmlBehaviour = require("./behaviour/xml").XmlBehaviour; +var HtmlFoldMode = require("./folding/html").FoldMode; + +var Mode = function() { + var highlighter = new HtmlHighlightRules(); + this.$tokenizer = new Tokenizer(highlighter.getRules()); + this.$behaviour = new XmlBehaviour(); + + this.$embeds = highlighter.getEmbeds(); + this.createModeDelegates({ + "js-": JavaScriptMode, + "css-": CssMode + }); + + this.foldingRules = new HtmlFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + return 0; + }; + + this.getNextLineIndent = function(state, line, tab) { + return this.$getIndent(line); + }; + + this.checkOutdent = function(state, line, input) { + return false; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start" || state == "regex_allowed") { + var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start" || state == "regex_allowed") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "worker-javascript.js", "ace/mode/javascript_worker", "JavaScriptWorker"); + worker.attachToDocument(session.getDocument()); + + worker.on("jslint", function(results) { + var errors = []; + for (var i=0; i the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { // match stuff like: Sound.prototype.play = function() { } + token : [ + "storage.type", + "punctuation.operator", + "support.function", + "punctuation.operator", + "entity.name.function", + "text", + "keyword.operator", + "text", + "storage.type", + "text", + "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { // match stuff like: Sound.prototype.play = myfunc + token : [ + "storage.type", + "punctuation.operator", + "support.function", + "punctuation.operator", + "entity.name.function", + "text", + "keyword.operator", + "text" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)", + next: "function_arguments" + }, { // match stuff like: Sound.play = function() { } + token : [ + "storage.type", + "punctuation.operator", + "entity.name.function", + "text", + "keyword.operator", + "text", + "storage.type", + "text", + "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { // match stuff like: play = function() { } + token : [ + "entity.name.function", + "text", + "keyword.operator", + "text", + "storage.type", + "text", + "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { // match stuff like: Sound.play = function play() { } + token : [ + "storage.type", + "punctuation.operator", + "entity.name.function", + "text", + "keyword.operator", + "text", + "storage.type", + "text", + "entity.name.function", + "text", + "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { // match regular function like: function myFunc(arg) { } + token : [ + "storage.type", + "text", + "entity.name.function", + "text", + "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { // match stuff like: foobar: function() { } + token : [ + "entity.name.function", + "text", + "punctuation.operator", + "text", + "storage.type", + "text", + "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { // Attempt to match : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", + "text", + "storage.type", + "text", + "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : function(value) { + if (globals.hasOwnProperty(value)) + return "variable.language"; + else if (deprecated.hasOwnProperty(value)) + return "invalid.deprecated"; + else if (definitions.hasOwnProperty(value)) + return "storage.type"; + else if (keywords.hasOwnProperty(value)) + return "keyword"; + else if (buildinConstants.hasOwnProperty(value)) + return "constant.language"; + else if (futureReserved.hasOwnProperty(value)) + return "invalid.illegal"; + else if (value == "debugger") + return "invalid.deprecated"; + else + return "identifier"; + }, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + token: "string.regexp", + regex: "[^\\\\/\\[]+", + merge: true + }, { + token: "string.regexp.charachterclass", + regex: "\\[", + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "string.regexp.charachterclass", + regex: "]", + next: "regex", + merge: true + }, { + token: "string.regexp.charachterclass", + regex: "[^\\\\\\]]+", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe, + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /^\s*/; + var startRow = row; + var endRow = row; + var line = session.getLine(row); + var startColumn = column || line.length; + var startLevel = line.match(re)[0].length; + var maxRow = session.getLength() + + while (++row < maxRow) { + line = session.getLine(row); + var level = line.match(re)[0].length; + + if (level == line.length) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe, allowBlankLine) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe, allowBlankLine); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start") { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/css', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/css_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/worker/worker_client', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules(), "i"); + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.foldingRules = "cStyle"; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + // ignore braces in comments + var tokens = this.$tokenizer.getLineTokens(line, state).tokens; + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + var match = line.match(/^.*\{\s*$/); + if (match) { + indent += tab; + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "worker-css.js", "ace/mode/css_worker", "Worker"); + worker.attachToDocument(session.getDocument()); + + worker.on("csslint", function(e) { + var errors = []; + e.data.forEach(function(message) { + errors.push({ + row: message.line - 1, + column: message.col - 1, + text: message.message, + type: message.type, + lint: message + }); + }); + + session.setAnnotations(errors); + }); + return worker; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CssHighlightRules = function() { + + var properties = lang.arrayToMap( + ("animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index").split("|") + ); + + var functions = lang.arrayToMap( + ("rgb|rgba|url|attr|counter|counters").split("|") + ); + + var constants = lang.arrayToMap( + ("absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|font-size|font|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|top|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero").split("|") + ); + + var colors = lang.arrayToMap( + ("aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|" + + "purple|red|silver|teal|white|yellow").split("|") + ); + + var fonts = lang.arrayToMap( + ("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" + + "symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" + + "serif|monospace").split("|") + ); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b"; + var pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b"; + + var base_ruleset = [ + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "ruleset_comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : ["constant.numeric", "keyword"], + regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)" + }, { + token : ["constant.numeric"], + regex : "([0-9]+)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"], + regex : pseudoElements + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], + regex : pseudoClasses + }, { + token : function(value) { + if (properties.hasOwnProperty(value.toLowerCase())) { + return "support.type"; + } + else if (functions.hasOwnProperty(value.toLowerCase())) { + return "support.function"; + } + else if (constants.hasOwnProperty(value.toLowerCase())) { + return "support.constant"; + } + else if (colors.hasOwnProperty(value.toLowerCase())) { + return "support.constant.color"; + } + else if (fonts.hasOwnProperty(value.toLowerCase())) { + return "support.constant.fonts"; + } + else { + return "text"; + } + }, + regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" + } + ]; + + var ruleset = lang.copyArray(base_ruleset); + ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "start" + }); + + var media_ruleset = lang.copyArray( base_ruleset ); + media_ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "media" + }); + + var base_comment = [{ + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + }]; + + var comment = lang.copyArray(base_comment); + comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }); + + var media_comment = lang.copyArray(base_comment); + media_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "media" + }); + + var ruleset_comment = lang.copyArray(base_comment); + ruleset_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "ruleset" + }); + + this.$rules = { + "start" : [{ + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "ruleset" + }, { + token: "string", + regex: "@.*?{", + next: "media" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "media" : [ { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "media_comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "media_ruleset" + },{ + token: "string", + regex: "\\}", + next: "start" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "comment" : comment, + + "ruleset" : ruleset, + "ruleset_comment" : ruleset_comment, + + "media_ruleset" : media_ruleset, + "media_comment" : media_comment + }; +}; + +oop.inherits(CssHighlightRules, TextHighlightRules); + +exports.CssHighlightRules = CssHighlightRules; + +}); + +ace.define('ace/mode/html_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var xmlUtil = require("./xml_util"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var HtmlHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + this.$rules = { + start : [{ + token : "text", + merge : true, + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "xml_pe", + regex : "<\\!.*?>" + }, { + token : "meta.tag", + regex : "<(?=\s*script\\b)", + next : "script" + }, { + token : "meta.tag", + regex : "<(?=\s*style\\b)", + next : "style" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "constant.character.entity", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }, { + token : "text", + regex : "[^<]+" + } ], + + cdata : [ { + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + merge : true, + regex : "\\s+" + }, { + token : "text", + merge : true, + regex : ".+" + } ], + + comment : [ { + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + } ] + }; + + xmlUtil.tag(this.$rules, "tag", "start"); + xmlUtil.tag(this.$rules, "style", "css-start"); + xmlUtil.tag(this.$rules, "script", "js-start"); + + this.embedRules(JavaScriptHighlightRules, "js-", [{ + token: "comment", + regex: "\\/\\/.*(?=<\\/script>)", + next: "tag" + }, { + token: "meta.tag", + regex: "<\\/(?=script)", + next: "tag" + }]); + + this.embedRules(CssHighlightRules, "css-", [{ + token: "meta.tag", + regex: "<\\/(?=style)", + next: "tag" + }]); +}; + +oop.inherits(HtmlHighlightRules, TextHighlightRules); + +exports.HtmlHighlightRules = HtmlHighlightRules; +}); + +ace.define('ace/mode/xml_util', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) { + + +var lang = require("../lib/lang"); + +var formTags = lang.arrayToMap( + ("button|form|input|label|select|textarea").split("|") +); + +var tableTags = lang.arrayToMap( + ("table|tbody|td|tfoot|th|tr").split("|") +); + +function string(state) { + return [{ + token : "string", + regex : '".*?"' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*', + next : state + "_qqstring" + }, { + token : "string", + regex : "'.*?'" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*", + next : state + "_qstring" + }]; +} + +function multiLineString(quote, state) { + return [{ + token : "string", + merge : true, + regex : ".*?" + quote, + next : state + }, { + token : "string", + merge : true, + regex : '.+' + }]; +} + +exports.tag = function(states, name, nextState) { + states[name] = [{ + token : "text", + regex : "\\s+" + }, { + //token : "meta.tag", + + token : function(value) { + if ( value==='a' ) { + return "meta.tag.anchor"; + } + else if ( value==='img' ) { + return "meta.tag.image"; + } + else if ( value==='script' ) { + return "meta.tag.script"; + } + else if ( value==='style' ) { + return "meta.tag.style"; + } + else if (formTags.hasOwnProperty(value.toLowerCase())) { + return "meta.tag.form"; + } + else if (tableTags.hasOwnProperty(value.toLowerCase())) { + return "meta.tag.table"; + } + else { + return "meta.tag"; + } + }, + merge : true, + regex : "[-_a-zA-Z0-9:]+", + next : name + "_embed_attribute_list" + }, { + token: "empty", + regex: "", + next : name + "_embed_attribute_list" + }]; + + states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list"); + states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list"); + + states[name + "_embed_attribute_list"] = [{ + token : "meta.tag", + merge : true, + regex : "\/?>", + next : nextState + }, { + token : "keyword.operator", + regex : "=" + }, { + token : "entity.other.attribute-name", + regex : "[-_a-zA-Z0-9:]+" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "text", + regex : "\\s+" + }].concat(string(name)); +}; + +}); + +ace.define('ace/mode/behaviour/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; + +var XmlBehaviour = function () { + + this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '<') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return false; + } else { + return { + text: '<>', + selection: [1, 1] + } + } + } else if (text == '>') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '>') { // need some kind of matching check here + return { + text: '', + selection: [1, 1] + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChars = line.substring(cursor.column, cursor.column + 2); + if (rightChars == '?)/; + this._parseTag = function(tag) { + + var match = this.tagRe.exec(tag); + var column = this.tagRe.lastIndex || 0; + this.tagRe.lastIndex = 0; + + return { + value: tag, + match: match ? match[2] : "", + closing: match ? !!match[3] : false, + selfClosing: match ? !!match[5] || match[2] == "/>" : false, + tagName: match ? match[4] : "", + column: match[1] ? column + match[1].length : column + }; + }; + this._readTagForward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var start; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!start) { + var start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + } + value += token.value; + if (value.indexOf(">") !== -1) { + var tag = this._parseTag(value); + tag.start = start; + tag.end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + iterator.stepForward(); + return tag; + } + } + } while(token = iterator.stepForward()); + + return null; + }; + + this._readTagBackward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var end; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!end) { + end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + } + value = token.value + value; + if (value.indexOf("<") !== -1) { + var tag = this._parseTag(value); + tag.end = end; + tag.start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + iterator.stepBackward(); + return tag; + } + } + } while(token = iterator.stepBackward()); + + return null; + }; + + this._pop = function(stack, tag) { + while (stack.length) { + + var top = stack[stack.length-1]; + if (!tag || top.tagName == tag.tagName) { + return stack.pop(); + } + else if (this.voidElements[tag.tagName]) { + return; + } + else if (this.voidElements[top.tagName]) { + stack.pop(); + continue; + } else { + return null; + } + } + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var firstTag = this._getFirstTagInLine(session, row); + + if (!firstTag.match) + return null; + + var isBackward = firstTag.closing || firstTag.selfClosing; + var stack = []; + var tag; + + if (!isBackward) { + var iterator = new TokenIterator(session, row, firstTag.column); + var start = { + row: row, + column: firstTag.column + firstTag.tagName.length + 2 + }; + while (tag = this._readTagForward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) + return Range.fromPoints(start, tag.start); + } + else { + stack.push(tag) + } + } + } + else { + var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length); + var end = { + row: row, + column: firstTag.column + }; + + while (tag = this._readTagBackward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (!tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) { + tag.start.column += tag.tagName.length + 2; + return Range.fromPoints(tag.start, end); + } + } + else { + stack.push(tag) + } + } + } + + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/lua', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/lua_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var LuaHighlightRules = require("./lua_highlight_rules").LuaHighlightRules; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new LuaHighlightRules().getRules()); +}; +oop.inherits(Mode, TextMode); + +(function() { + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + var chunks = ["function", "then", "do", "repeat"]; + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } else { + for (var i in tokens){ + var token = tokens[i]; + if (token.type != "keyword") continue; + var chunk_i = chunks.indexOf(token.value); + if (chunk_i != -1){ + indent += tab; + break; + } + } + } + } + + return indent; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/lua_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var LuaHighlightRules = function() { + + var keywords = lang.arrayToMap( + ("break|do|else|elseif|end|for|function|if|in|local|repeat|"+ + "return|then|until|while|or|and|not").split("|") + ); + + var builtinConstants = lang.arrayToMap( + ("true|false|nil|_G|_VERSION").split("|") + ); + + var builtinFunctions = lang.arrayToMap( + ("string|xpcall|package|tostring|print|os|unpack|require|"+ + "getfenv|setmetatable|next|assert|tonumber|io|rawequal|"+ + "collectgarbage|getmetatable|module|rawset|math|debug|"+ + "pcall|table|newproxy|type|coroutine|_G|select|gcinfo|"+ + "pairs|rawget|loadstring|ipairs|_VERSION|dofile|setfenv|"+ + "load|error|loadfile|"+ + + "sub|upper|len|gfind|rep|find|match|char|dump|gmatch|"+ + "reverse|byte|format|gsub|lower|preload|loadlib|loaded|"+ + "loaders|cpath|config|path|seeall|exit|setlocale|date|"+ + "getenv|difftime|remove|time|clock|tmpname|rename|execute|"+ + "lines|write|close|flush|open|output|type|read|stderr|"+ + "stdin|input|stdout|popen|tmpfile|log|max|acos|huge|"+ + "ldexp|pi|cos|tanh|pow|deg|tan|cosh|sinh|random|randomseed|"+ + "frexp|ceil|floor|rad|abs|sqrt|modf|asin|min|mod|fmod|log10|"+ + "atan2|exp|sin|atan|getupvalue|debug|sethook|getmetatable|"+ + "gethook|setmetatable|setlocal|traceback|setfenv|getinfo|"+ + "setupvalue|getlocal|getregistry|getfenv|setn|insert|getn|"+ + "foreachi|maxn|foreach|concat|sort|remove|resume|yield|"+ + "status|wrap|create|running").split("|") + ); + + var stdLibaries = lang.arrayToMap( + ("string|package|os|io|math|debug|table|coroutine").split("|") + ); + + var metatableMethods = lang.arrayToMap( + ("__add|__sub|__mod|__unm|__concat|__lt|__index|__call|__gc|__metatable|"+ + "__mul|__div|__pow|__len|__eq|__le|__newindex|__tostring|__mode|__tonumber").split("|") + ); + + var futureReserved = lang.arrayToMap( + ("").split("|") + ); + + var deprecatedIn5152 = lang.arrayToMap( + ("setn|foreach|foreachi|gcinfo|log10|maxn").split("|") + ); + + var strPre = ""; + + var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))"; + var hexInteger = "(?:0[xX][\\dA-Fa-f]+)"; + var integer = "(?:" + decimalInteger + "|" + hexInteger + ")"; + + var fraction = "(?:\\.\\d+)"; + var intPart = "(?:\\d+)"; + var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))"; + var floatNumber = "(?:" + pointFloat + ")"; + + var comment_stack = []; + + this.$rules = { + "start" : + + + // bracketed comments + [{ + token : "comment", // --[[ comment + regex : strPre + '\\-\\-\\[\\[.*\\]\\]' + }, { + token : "comment", // --[=[ comment + regex : strPre + '\\-\\-\\[\\=\\[.*\\]\\=\\]' + }, { + token : "comment", // --[==[ comment + regex : strPre + '\\-\\-\\[\\={2}\\[.*\\]\\={2}\\]' + }, { + token : "comment", // --[===[ comment + regex : strPre + '\\-\\-\\[\\={3}\\[.*\\]\\={3}\\]' + }, { + token : "comment", // --[====[ comment + regex : strPre + '\\-\\-\\[\\={4}\\[.*\\]\\={4}\\]' + }, { + token : "comment", // --[====+[ comment + regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]' + }, + + // multiline bracketed comments + { + token : "comment", // --[[ comment + regex : strPre + '\\-\\-\\[\\[.*$', + merge : true, + next : "qcomment" + }, { + token : "comment", // --[=[ comment + regex : strPre + '\\-\\-\\[\\=\\[.*$', + merge : true, + next : "qcomment1" + }, { + token : "comment", // --[==[ comment + regex : strPre + '\\-\\-\\[\\={2}\\[.*$', + merge : true, + next : "qcomment2" + }, { + token : "comment", // --[===[ comment + regex : strPre + '\\-\\-\\[\\={3}\\[.*$', + merge : true, + next : "qcomment3" + }, { + token : "comment", // --[====[ comment + regex : strPre + '\\-\\-\\[\\={4}\\[.*$', + merge : true, + next : "qcomment4" + }, { + token : function(value){ // --[====+[ comment + // WARNING: EXTREMELY SLOW, but this is the only way to circumvent the + // limits imposed by the current automaton. + // I've never personally seen any practical code where 5 or more '='s are + // used for string or commenting, so this will rarely be invoked. + var pattern = /\-\-\[(\=+)\[/, match; + // you can never be too paranoid ;) + if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined) + comment_stack.push(match.length); + + return "comment"; + }, + regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*$', + merge : true, + next : "qcomment5" + }, + + // single line comments + { + token : "comment", + regex : "\\-\\-.*$" + }, + + // bracketed strings + { + token : "string", // [[ string + regex : strPre + '\\[\\[.*\\]\\]' + }, { + token : "string", // [=[ string + regex : strPre + '\\[\\=\\[.*\\]\\=\\]' + }, { + token : "string", // [==[ string + regex : strPre + '\\[\\={2}\\[.*\\]\\={2}\\]' + }, { + token : "string", // [===[ string + regex : strPre + '\\[\\={3}\\[.*\\]\\={3}\\]' + }, { + token : "string", // [====[ string + regex : strPre + '\\[\\={4}\\[.*\\]\\={4}\\]' + }, { + token : "string", // [====+[ string + regex : strPre + '\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]' + }, + + // multiline bracketed strings + { + token : "string", // [[ string + regex : strPre + '\\[\\[.*$', + merge : true, + next : "qstring" + }, { + token : "string", // [=[ string + regex : strPre + '\\[\\=\\[.*$', + merge : true, + next : "qstring1" + }, { + token : "string", // [==[ string + regex : strPre + '\\[\\={2}\\[.*$', + merge : true, + next : "qstring2" + }, { + token : "string", // [===[ string + regex : strPre + '\\[\\={3}\\[.*$', + merge : true, + next : "qstring3" + }, { + token : "string", // [====[ string + regex : strPre + '\\[\\={4}\\[.*$', + merge : true, + next : "qstring4" + }, { + token : function(value){ // --[====+[ string + // WARNING: EXTREMELY SLOW, see above. + var pattern = /\[(\=+)\[/, match; + if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined) + comment_stack.push(match.length); + + return "string"; + }, + regex : strPre + '\\[\\={5}\\=*\\[.*$', + merge : true, + next : "qstring5" + }, + + { + token : "string", // " string + regex : strPre + '"(?:[^\\\\]|\\\\.)*?"' + }, { + token : "string", // ' string + regex : strPre + "'(?:[^\\\\]|\\\\.)*?'" + }, { + token : "constant.numeric", // float + regex : floatNumber + }, { + token : "constant.numeric", // integer + regex : integer + "\\b" + }, { + token : function(value) { + if (keywords.hasOwnProperty(value)) + return "keyword"; + else if (builtinConstants.hasOwnProperty(value)) + return "constant.language"; + else if (futureReserved.hasOwnProperty(value)) + return "invalid.illegal"; + else if (stdLibaries.hasOwnProperty(value)) + return "constant.library"; + else if (deprecatedIn5152.hasOwnProperty(value)) + return "invalid.deprecated"; + else if (builtinFunctions.hasOwnProperty(value)) + return "support.function"; + else if (metatableMethods.hasOwnProperty(value)) + return "support.function"; + else + return "identifier"; + }, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\+|\\-|\\*|\\/|%|\\#|\\^|~|<|>|<=|=>|==|~=|=|\\:|\\.\\.\\.|\\.\\." + }, { + token : "paren.lparen", + regex : "[\\[\\(\\{]" + }, { + token : "paren.rparen", + regex : "[\\]\\)\\}]" + }, { + token : "text", + regex : "\\s+" + } ], + + "qcomment": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment1": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\=\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment2": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment3": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment4": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment5": [ { + token : function(value){ + // very hackish, mutates the qcomment5 field on the fly. + var pattern = /\](\=+)\]/, rule = this.rules.qcomment5[0], match; + rule.next = "start"; + if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined){ + var found = match.length, expected; + if ((expected = comment_stack.pop()) != found){ + comment_stack.push(expected); + rule.next = "qcomment5"; + } + } + + return "comment"; + }, + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + + "qstring": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring1": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\=\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring2": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring3": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring4": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring5": [ { + token : function(value){ + // very hackish, mutates the qstring5 field on the fly. + var pattern = /\](\=+)\]/, rule = this.rules.qstring5[0], match; + rule.next = "start"; + if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined){ + var found = match.length, expected; + if ((expected = comment_stack.pop()) != found){ + comment_stack.push(expected); + rule.next = "qstring5"; + } + } + + return "string"; + }, + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ] + + }; + +} + +oop.inherits(LuaHighlightRules, TextHighlightRules); + +exports.LuaHighlightRules = LuaHighlightRules; +}); +ace.define('ace/mode/luahtml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/html_highlight_rules', 'ace/mode/lua_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; +var LuaHighlightRules = require("./lua_highlight_rules").LuaHighlightRules; + +var LuaHtmlHighlightRules = function() { + this.$rules = new HtmlHighlightRules().getRules(); + + for (var i in this.$rules) + this.$rules[i].unshift({ + token: "luatag-percent", + regex: "<\\%", + next: "lua-start" + }, { + token: "luatag-lua", + regex: "<\\?lua", + next: "lua-start" + }); + + this.embedRules(LuaHighlightRules, "lua-", [ + { + token: "keyword1", + regex: "\\%>", + next: "start" + }, + { + token: "keyword2", + regex: "\\?>", + next: "start" + } + ]); +}; + +oop.inherits(LuaHtmlHighlightRules, HtmlHighlightRules); + +exports.LuaHtmlHighlightRules = LuaHtmlHighlightRules; + +}); \ No newline at end of file diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-luapage.js b/vendor/assets/javascripts/ace-src-noconflict/mode-luapage.js new file mode 100644 index 00000000..8f03866d --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-luapage.js @@ -0,0 +1,2480 @@ +ace.define('ace/mode/luapage', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/html', 'ace/mode/lua', 'ace/tokenizer', 'ace/mode/luapage_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var HtmlMode = require("./html").Mode; +var LuaMode = require("./lua").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var LuaPageHighlightRules = require("./luapage_highlight_rules").LuaPageHighlightRules; + +var Mode = function() { + var highlighter = new LuaPageHighlightRules(); + + this.$tokenizer = new Tokenizer(new LuaPageHighlightRules().getRules()); + this.$embeds = highlighter.getEmbeds(); + this.createModeDelegates({ + "lua-": LuaMode + }); +}; +oop.inherits(Mode, HtmlMode); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/mode/javascript', 'ace/mode/css', 'ace/tokenizer', 'ace/mode/html_highlight_rules', 'ace/mode/behaviour/html', 'ace/mode/folding/html'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var JavaScriptMode = require("./javascript").Mode; +var CssMode = require("./css").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; +var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour; +var HtmlFoldMode = require("./folding/html").FoldMode; + +var Mode = function() { + var highlighter = new HtmlHighlightRules(); + this.$tokenizer = new Tokenizer(highlighter.getRules()); + this.$behaviour = new HtmlBehaviour(); + + this.$embeds = highlighter.getEmbeds(); + this.createModeDelegates({ + "js-": JavaScriptMode, + "css-": CssMode + }); + + this.foldingRules = new HtmlFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + return 0; + }; + + this.getNextLineIndent = function(state, line, tab) { + return this.$getIndent(line); + }; + + this.checkOutdent = function(state, line, input) { + return false; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start" || state == "regex_allowed") { + var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start" || state == "regex_allowed") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); + worker.attachToDocument(session.getDocument()); + + worker.on("jslint", function(results) { + var errors = []; + for (var i=0; i the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + // Sound.prototype.play = + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + // Sound.play = function() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // play = function() { } + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + // function myFunc(arg) { } + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + // foobar: function() { } + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + // escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + // invalid operators + token : "invalid", + regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?] + }, { + // operators + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/ + }, { + token: "string.regexp", + regex: /{|[^\[\\{()$^+*?\/]+/, + merge: true + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex", + merge: true + }, { + token: "constant.language.escape", + regex: "-", + }, { + token: "string.regexp.charachterclass", + regex: /[^\]\-\\]+/, + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/css', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/css_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/worker/worker_client', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules(), "i"); + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.foldingRules = "cStyle"; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + // ignore braces in comments + var tokens = this.$tokenizer.getLineTokens(line, state).tokens; + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + var match = line.match(/^.*\{\s*$/); + if (match) { + indent += tab; + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker"); + worker.attachToDocument(session.getDocument()); + + worker.on("csslint", function(e) { + var errors = []; + e.data.forEach(function(message) { + errors.push({ + row: message.line - 1, + column: message.col - 1, + text: message.message, + type: message.type, + lint: message + }); + }); + + session.setAnnotations(errors); + }); + return worker; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CssHighlightRules = function() { + var keywordMapper = this.createKeywordMapper({ + "support.type": "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index", + "support.function": "rgb|rgba|url|attr|counter|counters", + "support.constant": "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero", + "support.constant.color": "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow", + "support.constant.fonts": "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace" + }, "text", true); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b"; + var pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b"; + + var base_ruleset = [ + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "ruleset_comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : ["constant.numeric", "keyword"], + regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)" + }, { + token : ["constant.numeric"], + regex : "([0-9]+)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"], + regex : pseudoElements + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], + regex : pseudoClasses + }, { + token : keywordMapper, + regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" + } + ]; + + var ruleset = lang.copyArray(base_ruleset); + ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "start" + }); + + var media_ruleset = lang.copyArray( base_ruleset ); + media_ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "media" + }); + + var base_comment = [{ + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + }]; + + var comment = lang.copyArray(base_comment); + comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }); + + var media_comment = lang.copyArray(base_comment); + media_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "media" + }); + + var ruleset_comment = lang.copyArray(base_comment); + ruleset_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "ruleset" + }); + + this.$rules = { + "start" : [{ + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "ruleset" + }, { + token: "string", + regex: "@.*?{", + next: "media" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "media" : [ { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "media_comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "media_ruleset" + },{ + token: "string", + regex: "\\}", + next: "start" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "comment" : comment, + + "ruleset" : ruleset, + "ruleset_comment" : ruleset_comment, + + "media_ruleset" : media_ruleset, + "media_comment" : media_comment + }; +}; + +oop.inherits(CssHighlightRules, TextHighlightRules); + +exports.CssHighlightRules = CssHighlightRules; + +}); + +ace.define('ace/mode/html_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var xmlUtil = require("./xml_util"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var tagMap = lang.createMap({ + a : 'anchor', + button : 'form', + form : 'form', + img : 'image', + input : 'form', + label : 'form', + script : 'script', + select : 'form', + textarea : 'form', + style : 'style', + table : 'table', + tbody : 'table', + td : 'table', + tfoot : 'table', + th : 'table', + tr : 'table' +}); + +var HtmlHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + this.$rules = { + start : [{ + token : "text", + merge : true, + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "xml_pe", + regex : "<\\!.*?>" + }, { + token : "meta.tag", + regex : "<(?=\s*script\\b)", + next : "script" + }, { + token : "meta.tag", + regex : "<(?=\s*style\\b)", + next : "style" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "constant.character.entity", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }, { + token : "text", + regex : "[^<]+" + } ], + + cdata : [ { + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + merge : true, + regex : "\\s+" + }, { + token : "text", + merge : true, + regex : ".+" + } ], + + comment : [ { + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + } ] + }; + + xmlUtil.tag(this.$rules, "tag", "start", tagMap); + xmlUtil.tag(this.$rules, "style", "css-start", tagMap); + xmlUtil.tag(this.$rules, "script", "js-start", tagMap); + + this.embedRules(JavaScriptHighlightRules, "js-", [{ + token: "comment", + regex: "\\/\\/.*(?=<\\/script>)", + next: "tag" + }, { + token: "meta.tag", + regex: "<\\/(?=script)", + next: "tag" + }]); + + this.embedRules(CssHighlightRules, "css-", [{ + token: "meta.tag", + regex: "<\\/(?=style)", + next: "tag" + }]); +}; + +oop.inherits(HtmlHighlightRules, TextHighlightRules); + +exports.HtmlHighlightRules = HtmlHighlightRules; +}); + +ace.define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) { + + +function string(state) { + return [{ + token : "string", + regex : '".*?"' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*', + next : state + "_qqstring" + }, { + token : "string", + regex : "'.*?'" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*", + next : state + "_qstring" + }]; +} + +function multiLineString(quote, state) { + return [{ + token : "string", + merge : true, + regex : ".*?" + quote, + next : state + }, { + token : "string", + merge : true, + regex : '.+' + }]; +} + +exports.tag = function(states, name, nextState, tagMap) { + states[name] = [{ + token : "text", + regex : "\\s+" + }, { + //token : "meta.tag", + + token : !tagMap ? "meta.tag.tag-name" : function(value) { + if (tagMap[value]) + return "meta.tag.tag-name." + tagMap[value]; + else + return "meta.tag.tag-name"; + }, + merge : true, + regex : "[-_a-zA-Z0-9:]+", + next : name + "_embed_attribute_list" + }, { + token: "empty", + regex: "", + next : name + "_embed_attribute_list" + }]; + + states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list"); + states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list"); + + states[name + "_embed_attribute_list"] = [{ + token : "meta.tag", + merge : true, + regex : "\/?>", + next : nextState + }, { + token : "keyword.operator", + regex : "=" + }, { + token : "entity.other.attribute-name", + regex : "[-_a-zA-Z0-9:]+" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "text", + regex : "\\s+" + }].concat(string(name)); +}; + +}); + +ace.define('ace/mode/behaviour/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour/xml', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var XmlBehaviour = require("../behaviour/xml").XmlBehaviour; +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; +var voidElements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']; + +function hasType(token, type) { + var hasType = true; + var typeList = token.type.split('.'); + var needleList = type.split('.'); + needleList.forEach(function(needle){ + if (typeList.indexOf(needle) == -1) { + hasType = false; + return false; + } + }); + return hasType; +} + +var HtmlBehaviour = function () { + + this.inherit(XmlBehaviour); // Get xml behaviour + + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { + if (text == '>') { + var position = editor.getCursorPosition(); + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken(); + var atCursor = false; + if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ + do { + token = iterator.stepBackward(); + } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); + } else { + atCursor = true; + } + if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) { + return + } + var element = token.value; + if (atCursor){ + var element = element.substring(0, position.column - token.start); + } + if (voidElements.indexOf(element) !== -1){ + return; + } + return { + text: '>' + '', + selection: [1, 1] + } + } + }); +} +oop.inherits(HtmlBehaviour, XmlBehaviour); + +exports.HtmlBehaviour = HtmlBehaviour; +}); + +ace.define('ace/mode/behaviour/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; + +function hasType(token, type) { + var hasType = true; + var typeList = token.type.split('.'); + var needleList = type.split('.'); + needleList.forEach(function(needle){ + if (typeList.indexOf(needle) == -1) { + hasType = false; + return false; + } + }); + return hasType; +} + +var XmlBehaviour = function () { + + this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour + + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { + if (text == '>') { + var position = editor.getCursorPosition(); + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken(); + var atCursor = false; + if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ + do { + token = iterator.stepBackward(); + } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); + } else { + atCursor = true; + } + if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) { + return + } + var tag = token.value; + if (atCursor){ + var tag = tag.substring(0, position.column - token.start); + } + + return { + text: '>' + '', + selection: [1, 1] + } + } + }); + + this.add('autoindent', 'insertion', function (state, action, editor, session, text) { + if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChars = line.substring(cursor.column, cursor.column + 2); + if (rightChars == '?)/; + this._parseTag = function(tag) { + + var match = this.tagRe.exec(tag); + var column = this.tagRe.lastIndex || 0; + this.tagRe.lastIndex = 0; + + return { + value: tag, + match: match ? match[2] : "", + closing: match ? !!match[3] : false, + selfClosing: match ? !!match[5] || match[2] == "/>" : false, + tagName: match ? match[4] : "", + column: match[1] ? column + match[1].length : column + }; + }; + this._readTagForward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var start; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!start) { + var start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + } + value += token.value; + if (value.indexOf(">") !== -1) { + var tag = this._parseTag(value); + tag.start = start; + tag.end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + iterator.stepForward(); + return tag; + } + } + } while(token = iterator.stepForward()); + + return null; + }; + + this._readTagBackward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var end; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!end) { + end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + } + value = token.value + value; + if (value.indexOf("<") !== -1) { + var tag = this._parseTag(value); + tag.end = end; + tag.start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + iterator.stepBackward(); + return tag; + } + } + } while(token = iterator.stepBackward()); + + return null; + }; + + this._pop = function(stack, tag) { + while (stack.length) { + + var top = stack[stack.length-1]; + if (!tag || top.tagName == tag.tagName) { + return stack.pop(); + } + else if (this.voidElements[tag.tagName]) { + return; + } + else if (this.voidElements[top.tagName]) { + stack.pop(); + continue; + } else { + return null; + } + } + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var firstTag = this._getFirstTagInLine(session, row); + + if (!firstTag.match) + return null; + + var isBackward = firstTag.closing || firstTag.selfClosing; + var stack = []; + var tag; + + if (!isBackward) { + var iterator = new TokenIterator(session, row, firstTag.column); + var start = { + row: row, + column: firstTag.column + firstTag.tagName.length + 2 + }; + while (tag = this._readTagForward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) + return Range.fromPoints(start, tag.start); + } + else { + stack.push(tag) + } + } + } + else { + var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length); + var end = { + row: row, + column: firstTag.column + }; + + while (tag = this._readTagBackward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (!tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) { + tag.start.column += tag.tagName.length + 2; + return Range.fromPoints(tag.start, end); + } + } + else { + stack.push(tag) + } + } + } + + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/lua', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/lua_highlight_rules', 'ace/range'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var LuaHighlightRules = require("./lua_highlight_rules").LuaHighlightRules; +var Range = require("../range").Range; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new LuaHighlightRules().getRules()); +}; +oop.inherits(Mode, TextMode); + +(function() { + var indentKeywords = { + "function": 1, + "then": 1, + "do": 1, + "else": 1, + "elseif": 1, + "repeat": 1, + "end": -1, + "until": -1, + }; + var outdentKeywords = [ + "else", + "elseif", + "end", + "until" + ]; + + function getNetIndentLevel(tokens) { + var level = 0; + // Support single-line blocks by decrementing the indent level if + // an ending token is found + for (var i in tokens){ + var token = tokens[i]; + if (token.type == "keyword") { + if (token.value in indentKeywords) { + level += indentKeywords[token.value]; + } + } else if (token.type == "paren.lparen") { + level ++; + } else if (token.type == "paren.rparen") { + level --; + } + } + // Limit the level to +/- 1 since usually users only indent one level + // at a time regardless of the logical nesting level + if (level < 0) { + return -1; + } else if (level > 0) { + return 1; + } else { + return 0; + } + } + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + var level = 0; + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (state == "start") { + level = getNetIndentLevel(tokens); + } + if (level > 0) { + return indent + tab; + } else if (level < 0 && indent.substr(indent.length - tab.length) == tab) { + // Don't do a next-line outdent if we're going to do a real outdent of this line + if (!this.checkOutdent(state, line, "\n")) { + return indent.substr(0, indent.length - tab.length); + } + } + return indent; + }; + + this.checkOutdent = function(state, line, input) { + if (input != "\n" && input != "\r" && input != "\r\n") + return false; + + if (line.match(/^\s*[\)\}\]]$/)) + return true; + + var tokens = this.$tokenizer.getLineTokens(line.trim(), state).tokens; + + if (!tokens || !tokens.length) + return false; + + return (tokens[0].type == "keyword" && outdentKeywords.indexOf(tokens[0].value) != -1); + }; + + this.autoOutdent = function(state, session, row) { + var prevLine = session.getLine(row - 1); + var prevIndent = this.$getIndent(prevLine).length; + var prevTokens = this.$tokenizer.getLineTokens(prevLine, "start").tokens; + var tabLength = session.getTabString().length; + var expectedIndent = prevIndent + tabLength * getNetIndentLevel(prevTokens); + var curIndent = this.$getIndent(session.getLine(row)).length; + if (curIndent < expectedIndent) { + // User already outdented // + return; + } + session.outdentRows(new Range(row, 0, row + 2, 0)); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/lua_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var LuaHighlightRules = function() { + + var keywords = ( + "break|do|else|elseif|end|for|function|if|in|local|repeat|"+ + "return|then|until|while|or|and|not" + ); + + var builtinConstants = ("true|false|nil|_G|_VERSION"); + + var functions = ( + // builtinFunctions + "string|xpcall|package|tostring|print|os|unpack|require|"+ + "getfenv|setmetatable|next|assert|tonumber|io|rawequal|"+ + "collectgarbage|getmetatable|module|rawset|math|debug|"+ + "pcall|table|newproxy|type|coroutine|_G|select|gcinfo|"+ + "pairs|rawget|loadstring|ipairs|_VERSION|dofile|setfenv|"+ + "load|error|loadfile|"+ + + "sub|upper|len|gfind|rep|find|match|char|dump|gmatch|"+ + "reverse|byte|format|gsub|lower|preload|loadlib|loaded|"+ + "loaders|cpath|config|path|seeall|exit|setlocale|date|"+ + "getenv|difftime|remove|time|clock|tmpname|rename|execute|"+ + "lines|write|close|flush|open|output|type|read|stderr|"+ + "stdin|input|stdout|popen|tmpfile|log|max|acos|huge|"+ + "ldexp|pi|cos|tanh|pow|deg|tan|cosh|sinh|random|randomseed|"+ + "frexp|ceil|floor|rad|abs|sqrt|modf|asin|min|mod|fmod|log10|"+ + "atan2|exp|sin|atan|getupvalue|debug|sethook|getmetatable|"+ + "gethook|setmetatable|setlocal|traceback|setfenv|getinfo|"+ + "setupvalue|getlocal|getregistry|getfenv|setn|insert|getn|"+ + "foreachi|maxn|foreach|concat|sort|remove|resume|yield|"+ + "status|wrap|create|running|"+ + // metatableMethods + "__add|__sub|__mod|__unm|__concat|__lt|__index|__call|__gc|__metatable|"+ + "__mul|__div|__pow|__len|__eq|__le|__newindex|__tostring|__mode|__tonumber" + ); + + var stdLibaries = ("string|package|os|io|math|debug|table|coroutine"); + + var futureReserved = ""; + + var deprecatedIn5152 = ("setn|foreach|foreachi|gcinfo|log10|maxn"); + + var keywordMapper = this.createKeywordMapper({ + "keyword": keywords, + "support.function": functions, + "invalid.deprecated": deprecatedIn5152, + "constant.library": stdLibaries, + "constant.language": builtinConstants, + "invalid.illegal": futureReserved, + "variable.language": "this" + }, "identifier"); + + var strPre = ""; + + var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))"; + var hexInteger = "(?:0[xX][\\dA-Fa-f]+)"; + var integer = "(?:" + decimalInteger + "|" + hexInteger + ")"; + + var fraction = "(?:\\.\\d+)"; + var intPart = "(?:\\d+)"; + var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))"; + var floatNumber = "(?:" + pointFloat + ")"; + + var comment_stack = []; + + this.$rules = { + "start" : + + + // bracketed comments + [{ + token : "comment", // --[[ comment + regex : strPre + '\\-\\-\\[\\[.*\\]\\]' + }, { + token : "comment", // --[=[ comment + regex : strPre + '\\-\\-\\[\\=\\[.*\\]\\=\\]' + }, { + token : "comment", // --[==[ comment + regex : strPre + '\\-\\-\\[\\={2}\\[.*\\]\\={2}\\]' + }, { + token : "comment", // --[===[ comment + regex : strPre + '\\-\\-\\[\\={3}\\[.*\\]\\={3}\\]' + }, { + token : "comment", // --[====[ comment + regex : strPre + '\\-\\-\\[\\={4}\\[.*\\]\\={4}\\]' + }, { + token : "comment", // --[====+[ comment + regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]' + }, + + // multiline bracketed comments + { + token : "comment", // --[[ comment + regex : strPre + '\\-\\-\\[\\[.*$', + merge : true, + next : "qcomment" + }, { + token : "comment", // --[=[ comment + regex : strPre + '\\-\\-\\[\\=\\[.*$', + merge : true, + next : "qcomment1" + }, { + token : "comment", // --[==[ comment + regex : strPre + '\\-\\-\\[\\={2}\\[.*$', + merge : true, + next : "qcomment2" + }, { + token : "comment", // --[===[ comment + regex : strPre + '\\-\\-\\[\\={3}\\[.*$', + merge : true, + next : "qcomment3" + }, { + token : "comment", // --[====[ comment + regex : strPre + '\\-\\-\\[\\={4}\\[.*$', + merge : true, + next : "qcomment4" + }, { + token : function(value){ // --[====+[ comment + // WARNING: EXTREMELY SLOW, but this is the only way to circumvent the + // limits imposed by the current automaton. + // I've never personally seen any practical code where 5 or more '='s are + // used for string or commenting, so this will rarely be invoked. + var pattern = /\-\-\[(\=+)\[/, match; + // you can never be too paranoid ;) + if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined) + comment_stack.push(match.length); + + return "comment"; + }, + regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*$', + merge : true, + next : "qcomment5" + }, + + // single line comments + { + token : "comment", + regex : "\\-\\-.*$" + }, + + // bracketed strings + { + token : "string", // [[ string + regex : strPre + '\\[\\[.*\\]\\]' + }, { + token : "string", // [=[ string + regex : strPre + '\\[\\=\\[.*\\]\\=\\]' + }, { + token : "string", // [==[ string + regex : strPre + '\\[\\={2}\\[.*\\]\\={2}\\]' + }, { + token : "string", // [===[ string + regex : strPre + '\\[\\={3}\\[.*\\]\\={3}\\]' + }, { + token : "string", // [====[ string + regex : strPre + '\\[\\={4}\\[.*\\]\\={4}\\]' + }, { + token : "string", // [====+[ string + regex : strPre + '\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]' + }, + + // multiline bracketed strings + { + token : "string", // [[ string + regex : strPre + '\\[\\[.*$', + merge : true, + next : "qstring" + }, { + token : "string", // [=[ string + regex : strPre + '\\[\\=\\[.*$', + merge : true, + next : "qstring1" + }, { + token : "string", // [==[ string + regex : strPre + '\\[\\={2}\\[.*$', + merge : true, + next : "qstring2" + }, { + token : "string", // [===[ string + regex : strPre + '\\[\\={3}\\[.*$', + merge : true, + next : "qstring3" + }, { + token : "string", // [====[ string + regex : strPre + '\\[\\={4}\\[.*$', + merge : true, + next : "qstring4" + }, { + token : function(value){ // --[====+[ string + // WARNING: EXTREMELY SLOW, see above. + var pattern = /\[(\=+)\[/, match; + if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined) + comment_stack.push(match.length); + + return "string"; + }, + regex : strPre + '\\[\\={5}\\=*\\[.*$', + merge : true, + next : "qstring5" + }, + + { + token : "string", // " string + regex : strPre + '"(?:[^\\\\]|\\\\.)*?"' + }, { + token : "string", // ' string + regex : strPre + "'(?:[^\\\\]|\\\\.)*?'" + }, { + token : "constant.numeric", // float + regex : floatNumber + }, { + token : "constant.numeric", // integer + regex : integer + "\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\+|\\-|\\*|\\/|%|\\#|\\^|~|<|>|<=|=>|==|~=|=|\\:|\\.\\.\\.|\\.\\." + }, { + token : "paren.lparen", + regex : "[\\[\\(\\{]" + }, { + token : "paren.rparen", + regex : "[\\]\\)\\}]" + }, { + token : "text", + regex : "\\s+" + } ], + + "qcomment": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment1": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\=\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment2": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment3": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment4": [ { + token : "comment", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + "qcomment5": [ { + token : function(value){ + // very hackish, mutates the qcomment5 field on the fly. + var pattern = /\](\=+)\]/, rule = this.rules.qcomment5[0], match; + rule.next = "start"; + if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined){ + var found = match.length, expected; + if ((expected = comment_stack.pop()) != found){ + comment_stack.push(expected); + rule.next = "qcomment5"; + } + } + + return "comment"; + }, + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]", + next : "start" + }, { + token : "comment", + merge : true, + regex : '.+' + } ], + + "qstring": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring1": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\=\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring2": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring3": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring4": [ { + token : "string", + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring5": [ { + token : function(value){ + // very hackish, mutates the qstring5 field on the fly. + var pattern = /\](\=+)\]/, rule = this.rules.qstring5[0], match; + rule.next = "start"; + if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined){ + var found = match.length, expected; + if ((expected = comment_stack.pop()) != found){ + comment_stack.push(expected); + rule.next = "qstring5"; + } + } + + return "string"; + }, + regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ] + + }; + +} + +oop.inherits(LuaHighlightRules, TextHighlightRules); + +exports.LuaHighlightRules = LuaHighlightRules; +}); +// LuaPage implements the LuaPage markup as described by the Kepler Project's CGILua +// documentation: http://keplerproject.github.com/cgilua/manual.html#templates +ace.define('ace/mode/luapage_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/html_highlight_rules', 'ace/mode/lua_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; +var LuaHighlightRules = require("./lua_highlight_rules").LuaHighlightRules; + +var LuaPageHighlightRules = function() { + this.$rules = new HtmlHighlightRules().getRules(); + + for (var i in this.$rules) { + this.$rules[i].unshift({ + token: "keyword", + regex: "<\\%\\=?", + next: "lua-start" + }, { + token: "keyword", + regex: "<\\?lua\\=?", + next: "lua-start" + }); + } + this.embedRules(LuaHighlightRules, "lua-", [ + { + token: "keyword", + regex: "\\%>", + next: "start" + }, + { + token: "keyword", + regex: "\\?>", + next: "start" + } + ]); +}; + +oop.inherits(LuaPageHighlightRules, HtmlHighlightRules); + +exports.LuaPageHighlightRules = LuaPageHighlightRules; + +}); \ No newline at end of file diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-markdown.js b/vendor/assets/javascripts/ace-src-noconflict/mode-markdown.js new file mode 100644 index 00000000..179376aa --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-markdown.js @@ -0,0 +1,2252 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/markdown', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/mode/javascript', 'ace/mode/xml', 'ace/mode/html', 'ace/tokenizer', 'ace/mode/markdown_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var JavaScriptMode = require("./javascript").Mode; +var XmlMode = require("./xml").Mode; +var HtmlMode = require("./html").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var MarkdownHighlightRules = require("./markdown_highlight_rules").MarkdownHighlightRules; + +var Mode = function() { + var highlighter = new MarkdownHighlightRules(); + + this.$tokenizer = new Tokenizer(highlighter.getRules()); + this.$embeds = highlighter.getEmbeds(); + this.createModeDelegates({ + "js-": JavaScriptMode, + "xml-": XmlMode, + "html-": HtmlMode + }); +}; +oop.inherits(Mode, TextMode); + +(function() { + this.getNextLineIndent = function(state, line, tab) { + if (state == "listblock") { + var match = /^((?:.+)?)(([-+*]|\d+\.)\s+)/.exec(line); + if (match) { + return new Array(match[1].length + 1).join(" ") + match[2]; + } else { + return ""; + } + } else { + return this.$getIndent(line); + } + }; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start" || state == "regex_allowed") { + var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start" || state == "regex_allowed") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); + worker.attachToDocument(session.getDocument()); + + worker.on("jslint", function(results) { + var errors = []; + for (var i=0; i the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + // Sound.prototype.play = + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + // Sound.play = function() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // play = function() { } + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + // function myFunc(arg) { } + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + // foobar: function() { } + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + // escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + // invalid operators + token : "invalid", + regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?] + }, { + // operators + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/ + }, { + token: "string.regexp", + regex: /{|[^\[\\{()$^+*?\/]+/, + merge: true + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex", + merge: true + }, { + token: "constant.language.escape", + regex: "-", + }, { + token: "string.regexp.charachterclass", + regex: /[^\]\-\\]+/, + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xml_highlight_rules', 'ace/mode/behaviour/xml', 'ace/mode/folding/xml'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules; +var XmlBehaviour = require("./behaviour/xml").XmlBehaviour; +var XmlFoldMode = require("./folding/xml").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules()); + this.$behaviour = new XmlBehaviour(); + this.foldingRules = new XmlFoldMode(); +}; + +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + return this.$getIndent(line); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/xml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var xmlUtil = require("./xml_util"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var XmlHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + this.$rules = { + start : [{ + token : "text", + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "xml_pe", + regex : "<\\!.*?>" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "constant.character.entity", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }, { + token : "text", + regex : "[^<]+" + }], + + cdata : [{ + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + regex : "\\s+" + }, { + token : "text", + regex : "(?:[^\\]]|\\](?!\\]>))+" + }], + + comment : [{ + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + }] + }; + + xmlUtil.tag(this.$rules, "tag", "start"); +}; + +oop.inherits(XmlHighlightRules, TextHighlightRules); + +exports.XmlHighlightRules = XmlHighlightRules; +}); + +ace.define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) { + + +function string(state) { + return [{ + token : "string", + regex : '".*?"' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*', + next : state + "_qqstring" + }, { + token : "string", + regex : "'.*?'" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*", + next : state + "_qstring" + }]; +} + +function multiLineString(quote, state) { + return [{ + token : "string", + merge : true, + regex : ".*?" + quote, + next : state + }, { + token : "string", + merge : true, + regex : '.+' + }]; +} + +exports.tag = function(states, name, nextState, tagMap) { + states[name] = [{ + token : "text", + regex : "\\s+" + }, { + //token : "meta.tag", + + token : !tagMap ? "meta.tag.tag-name" : function(value) { + if (tagMap[value]) + return "meta.tag.tag-name." + tagMap[value]; + else + return "meta.tag.tag-name"; + }, + merge : true, + regex : "[-_a-zA-Z0-9:]+", + next : name + "_embed_attribute_list" + }, { + token: "empty", + regex: "", + next : name + "_embed_attribute_list" + }]; + + states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list"); + states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list"); + + states[name + "_embed_attribute_list"] = [{ + token : "meta.tag", + merge : true, + regex : "\/?>", + next : nextState + }, { + token : "keyword.operator", + regex : "=" + }, { + token : "entity.other.attribute-name", + regex : "[-_a-zA-Z0-9:]+" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "text", + regex : "\\s+" + }].concat(string(name)); +}; + +}); + +ace.define('ace/mode/behaviour/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; + +function hasType(token, type) { + var hasType = true; + var typeList = token.type.split('.'); + var needleList = type.split('.'); + needleList.forEach(function(needle){ + if (typeList.indexOf(needle) == -1) { + hasType = false; + return false; + } + }); + return hasType; +} + +var XmlBehaviour = function () { + + this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour + + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { + if (text == '>') { + var position = editor.getCursorPosition(); + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken(); + var atCursor = false; + if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ + do { + token = iterator.stepBackward(); + } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); + } else { + atCursor = true; + } + if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) { + return + } + var tag = token.value; + if (atCursor){ + var tag = tag.substring(0, position.column - token.start); + } + + return { + text: '>' + '', + selection: [1, 1] + } + } + }); + + this.add('autoindent', 'insertion', function (state, action, editor, session, text) { + if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChars = line.substring(cursor.column, cursor.column + 2); + if (rightChars == '?)/; + this._parseTag = function(tag) { + + var match = this.tagRe.exec(tag); + var column = this.tagRe.lastIndex || 0; + this.tagRe.lastIndex = 0; + + return { + value: tag, + match: match ? match[2] : "", + closing: match ? !!match[3] : false, + selfClosing: match ? !!match[5] || match[2] == "/>" : false, + tagName: match ? match[4] : "", + column: match[1] ? column + match[1].length : column + }; + }; + this._readTagForward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var start; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!start) { + var start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + } + value += token.value; + if (value.indexOf(">") !== -1) { + var tag = this._parseTag(value); + tag.start = start; + tag.end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + iterator.stepForward(); + return tag; + } + } + } while(token = iterator.stepForward()); + + return null; + }; + + this._readTagBackward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var end; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!end) { + end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + } + value = token.value + value; + if (value.indexOf("<") !== -1) { + var tag = this._parseTag(value); + tag.end = end; + tag.start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + iterator.stepBackward(); + return tag; + } + } + } while(token = iterator.stepBackward()); + + return null; + }; + + this._pop = function(stack, tag) { + while (stack.length) { + + var top = stack[stack.length-1]; + if (!tag || top.tagName == tag.tagName) { + return stack.pop(); + } + else if (this.voidElements[tag.tagName]) { + return; + } + else if (this.voidElements[top.tagName]) { + stack.pop(); + continue; + } else { + return null; + } + } + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var firstTag = this._getFirstTagInLine(session, row); + + if (!firstTag.match) + return null; + + var isBackward = firstTag.closing || firstTag.selfClosing; + var stack = []; + var tag; + + if (!isBackward) { + var iterator = new TokenIterator(session, row, firstTag.column); + var start = { + row: row, + column: firstTag.column + firstTag.tagName.length + 2 + }; + while (tag = this._readTagForward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) + return Range.fromPoints(start, tag.start); + } + else { + stack.push(tag) + } + } + } + else { + var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length); + var end = { + row: row, + column: firstTag.column + }; + + while (tag = this._readTagBackward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (!tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) { + tag.start.column += tag.tagName.length + 2; + return Range.fromPoints(tag.start, end); + } + } + else { + stack.push(tag) + } + } + } + + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/mode/javascript', 'ace/mode/css', 'ace/tokenizer', 'ace/mode/html_highlight_rules', 'ace/mode/behaviour/html', 'ace/mode/folding/html'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var JavaScriptMode = require("./javascript").Mode; +var CssMode = require("./css").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; +var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour; +var HtmlFoldMode = require("./folding/html").FoldMode; + +var Mode = function() { + var highlighter = new HtmlHighlightRules(); + this.$tokenizer = new Tokenizer(highlighter.getRules()); + this.$behaviour = new HtmlBehaviour(); + + this.$embeds = highlighter.getEmbeds(); + this.createModeDelegates({ + "js-": JavaScriptMode, + "css-": CssMode + }); + + this.foldingRules = new HtmlFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + return 0; + }; + + this.getNextLineIndent = function(state, line, tab) { + return this.$getIndent(line); + }; + + this.checkOutdent = function(state, line, input) { + return false; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/css', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/css_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/worker/worker_client', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules(), "i"); + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.foldingRules = "cStyle"; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + // ignore braces in comments + var tokens = this.$tokenizer.getLineTokens(line, state).tokens; + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + var match = line.match(/^.*\{\s*$/); + if (match) { + indent += tab; + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker"); + worker.attachToDocument(session.getDocument()); + + worker.on("csslint", function(e) { + var errors = []; + e.data.forEach(function(message) { + errors.push({ + row: message.line - 1, + column: message.col - 1, + text: message.message, + type: message.type, + lint: message + }); + }); + + session.setAnnotations(errors); + }); + return worker; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CssHighlightRules = function() { + var keywordMapper = this.createKeywordMapper({ + "support.type": "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index", + "support.function": "rgb|rgba|url|attr|counter|counters", + "support.constant": "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero", + "support.constant.color": "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow", + "support.constant.fonts": "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace" + }, "text", true); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b"; + var pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b"; + + var base_ruleset = [ + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "ruleset_comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : ["constant.numeric", "keyword"], + regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)" + }, { + token : ["constant.numeric"], + regex : "([0-9]+)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"], + regex : pseudoElements + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], + regex : pseudoClasses + }, { + token : keywordMapper, + regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" + } + ]; + + var ruleset = lang.copyArray(base_ruleset); + ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "start" + }); + + var media_ruleset = lang.copyArray( base_ruleset ); + media_ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "media" + }); + + var base_comment = [{ + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + }]; + + var comment = lang.copyArray(base_comment); + comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }); + + var media_comment = lang.copyArray(base_comment); + media_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "media" + }); + + var ruleset_comment = lang.copyArray(base_comment); + ruleset_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "ruleset" + }); + + this.$rules = { + "start" : [{ + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "ruleset" + }, { + token: "string", + regex: "@.*?{", + next: "media" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "media" : [ { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "media_comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "media_ruleset" + },{ + token: "string", + regex: "\\}", + next: "start" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "comment" : comment, + + "ruleset" : ruleset, + "ruleset_comment" : ruleset_comment, + + "media_ruleset" : media_ruleset, + "media_comment" : media_comment + }; +}; + +oop.inherits(CssHighlightRules, TextHighlightRules); + +exports.CssHighlightRules = CssHighlightRules; + +}); + +ace.define('ace/mode/html_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var xmlUtil = require("./xml_util"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var tagMap = lang.createMap({ + a : 'anchor', + button : 'form', + form : 'form', + img : 'image', + input : 'form', + label : 'form', + script : 'script', + select : 'form', + textarea : 'form', + style : 'style', + table : 'table', + tbody : 'table', + td : 'table', + tfoot : 'table', + th : 'table', + tr : 'table' +}); + +var HtmlHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + this.$rules = { + start : [{ + token : "text", + merge : true, + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "xml_pe", + regex : "<\\!.*?>" + }, { + token : "meta.tag", + regex : "<(?=\s*script\\b)", + next : "script" + }, { + token : "meta.tag", + regex : "<(?=\s*style\\b)", + next : "style" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "constant.character.entity", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }, { + token : "text", + regex : "[^<]+" + } ], + + cdata : [ { + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + merge : true, + regex : "\\s+" + }, { + token : "text", + merge : true, + regex : ".+" + } ], + + comment : [ { + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + } ] + }; + + xmlUtil.tag(this.$rules, "tag", "start", tagMap); + xmlUtil.tag(this.$rules, "style", "css-start", tagMap); + xmlUtil.tag(this.$rules, "script", "js-start", tagMap); + + this.embedRules(JavaScriptHighlightRules, "js-", [{ + token: "comment", + regex: "\\/\\/.*(?=<\\/script>)", + next: "tag" + }, { + token: "meta.tag", + regex: "<\\/(?=script)", + next: "tag" + }]); + + this.embedRules(CssHighlightRules, "css-", [{ + token: "meta.tag", + regex: "<\\/(?=style)", + next: "tag" + }]); +}; + +oop.inherits(HtmlHighlightRules, TextHighlightRules); + +exports.HtmlHighlightRules = HtmlHighlightRules; +}); + +ace.define('ace/mode/behaviour/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour/xml', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var XmlBehaviour = require("../behaviour/xml").XmlBehaviour; +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; +var voidElements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']; + +function hasType(token, type) { + var hasType = true; + var typeList = token.type.split('.'); + var needleList = type.split('.'); + needleList.forEach(function(needle){ + if (typeList.indexOf(needle) == -1) { + hasType = false; + return false; + } + }); + return hasType; +} + +var HtmlBehaviour = function () { + + this.inherit(XmlBehaviour); // Get xml behaviour + + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { + if (text == '>') { + var position = editor.getCursorPosition(); + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken(); + var atCursor = false; + if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ + do { + token = iterator.stepBackward(); + } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); + } else { + atCursor = true; + } + if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) { + return + } + var element = token.value; + if (atCursor){ + var element = element.substring(0, position.column - token.start); + } + if (voidElements.indexOf(element) !== -1){ + return; + } + return { + text: '>' + '', + selection: [1, 1] + } + } + }); +} +oop.inherits(HtmlBehaviour, XmlBehaviour); + +exports.HtmlBehaviour = HtmlBehaviour; +}); + +ace.define('ace/mode/folding/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/mixed', 'ace/mode/folding/xml', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var MixedFoldMode = require("./mixed").FoldMode; +var XmlFoldMode = require("./xml").FoldMode; +var CStyleFoldMode = require("./cstyle").FoldMode; + +var FoldMode = exports.FoldMode = function() { + MixedFoldMode.call(this, new XmlFoldMode({ + // void elements + "area": 1, + "base": 1, + "br": 1, + "col": 1, + "command": 1, + "embed": 1, + "hr": 1, + "img": 1, + "input": 1, + "keygen": 1, + "link": 1, + "meta": 1, + "param": 1, + "source": 1, + "track": 1, + "wbr": 1, + + // optional tags + "li": 1, + "dt": 1, + "dd": 1, + "p": 1, + "rt": 1, + "rp": 1, + "optgroup": 1, + "option": 1, + "colgroup": 1, + "td": 1, + "th": 1 + }), { + "js-": new CStyleFoldMode(), + "css-": new CStyleFoldMode() + }); +}; + +oop.inherits(FoldMode, MixedFoldMode); + +}); + +ace.define('ace/mode/folding/mixed', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function(defaultMode, subModes) { + this.defaultMode = defaultMode; + this.subModes = subModes; +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + + this.$getMode = function(state) { + for (var key in this.subModes) { + if (state.indexOf(key) === 0) + return this.subModes[key]; + } + return null; + }; + + this.$tryMode = function(state, session, foldStyle, row) { + var mode = this.$getMode(state); + return (mode ? mode.getFoldWidget(session, foldStyle, row) : ""); + }; + + this.getFoldWidget = function(session, foldStyle, row) { + return ( + this.$tryMode(session.getState(row-1), session, foldStyle, row) || + this.$tryMode(session.getState(row), session, foldStyle, row) || + this.defaultMode.getFoldWidget(session, foldStyle, row) + ); + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var mode = this.$getMode(session.getState(row-1)); + + if (!mode || !mode.getFoldWidget(session, foldStyle, row)) + mode = this.$getMode(session.getState(row)); + + if (!mode || !mode.getFoldWidget(session, foldStyle, row)) + mode = this.defaultMode; + + return mode.getFoldWidgetRange(session, foldStyle, row); + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/markdown_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_highlight_rules', 'ace/mode/html_highlight_rules', 'ace/mode/css_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules; +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; + +function github_embed(tag, prefix) { + return { // Github style block + token : "support.function", + regex : "^```" + tag + "\\s*$", + next : prefix + "start" + }; +} + +var MarkdownHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ { + token : "empty_line", + regex : '^$' + }, { // code span ` + token : ["support.function", "support.function", "support.function"], + regex : "(`+)([^\\r]*?[^`])(\\1)" + }, { // code block + token : "support.function", + regex : "^[ ]{4}.+" + }, { // h1 + token: "markup.heading.1", + regex: "^=+(?=\\s*$)" + }, { // h2 + token: "markup.heading.2", + regex: "^\\-+(?=\\s*$)" + }, { // header + token : function(value) { + return "markup.heading." + value.search(/[^#]/); + }, + regex : "^#{1,6}(?:[^ #].*| +.*(?:[^ #].*|[^ ]+.* +#+ *))$" + }, github_embed("(?:javascript|js)", "js-"), + github_embed("xml", "xml-"), + github_embed("html", "html-"), + github_embed("css", "css-"), + { // Github style block + token : "support.function", + regex : "^```[a-zA-Z]+\\s*$", + next : "githubblock" + }, { // block quote + token : "string", + regex : "^>[ ].+$", + next : "blockquote" + }, { // reference + token : ["text", "constant", "text", "url", "string", "text"], + regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?(\\s*))$" + }, { // link by reference + token : ["text", "string", "text", "constant", "text"], + regex : "(\\[)((?:[[^\\]]*\\]|[^\\[\\]])*)(\\][ ]?(?:\\n[ ]*)?\\[)(.*?)(\\])" + }, { // link by url + token : ["text", "string", "text", "markup.underline", "string", "text"], + regex : "(\\[)"+ + "(\\[[^\\]]*\\]|[^\\[\\]]*)"+ + "(\\]\\([ \\t]*)"+ + "(?)"+ + "((?:[ \t]*\"(?:.*?)\"[ \\t]*)?)"+ + "(\\))" + }, { // HR * + token : "constant", + regex : "^[ ]{0,2}(?:[ ]?\\*[ ]?){3,}\\s*$" + }, { // HR - + token : "constant", + regex : "^[ ]{0,2}(?:[ ]?\\-[ ]?){3,}\\s*$" + }, { // HR _ + token : "constant", + regex : "^[ ]{0,2}(?:[ ]?\\_[ ]?){3,}\\s*$" + }, { // list + token : "markup.list", + regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+", + next : "listblock" + }, { // strong ** __ + token : ["string", "string", "string"], + regex : "([*]{2}|[_]{2}(?=\\S))([^\\r]*?\\S[*_]*)(\\1)" + }, { // emphasis * _ + token : ["string", "string", "string"], + regex : "([*]|[_](?=\\S))([^\\r]*?\\S[*_]*)(\\1)" + }, { // + token : ["text", "url", "text"], + regex : "(<)("+ + "(?:https?|ftp|dict):[^'\">\\s]+"+ + "|"+ + "(?:mailto:)?[-.\\w]+\\@[-a-z0-9]+(?:\\.[-a-z0-9]+)*\\.[a-z]+"+ + ")(>)" + }, { + token : "text", + regex : "[^\\*_%$`\\[#<>]+" + } ], + + "listblock" : [ { // Lists only escape on completely blank lines. + token : "empty_line", + regex : "^$", + next : "start" + }, { + token : "markup.list", + regex : ".+" + } ], + + "blockquote" : [ { // BLockquotes only escape on blank lines. + token : "empty_line", + regex : "^\\s*$", + next : "start" + }, { + token : "string", + regex : ".+" + } ], + + "githubblock" : [ { + token : "support.function", + regex : "^```", + next : "start" + }, { + token : "support.function", + regex : ".+" + } ] + }; + + this.embedRules(JavaScriptHighlightRules, "js-", [{ + token : "support.function", + regex : "^```", + next : "start" + }]); + + this.embedRules(HtmlHighlightRules, "html-", [{ + token : "support.function", + regex : "^```", + next : "start" + }]); + + this.embedRules(CssHighlightRules, "css-", [{ + token : "support.function", + regex : "^```", + next : "start" + }]); + + this.embedRules(XmlHighlightRules, "xml-", [{ + token : "support.function", + regex : "^```", + next : "start" + }]); +}; +oop.inherits(MarkdownHighlightRules, TextHighlightRules); + +exports.MarkdownHighlightRules = MarkdownHighlightRules; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-ocaml.js b/vendor/assets/javascripts/ace-src-noconflict/mode-ocaml.js new file mode 100644 index 00000000..e6188c73 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-ocaml.js @@ -0,0 +1,452 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/ocaml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/ocaml_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var OcamlHighlightRules = require("./ocaml_highlight_rules").OcamlHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new OcamlHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); +}; +oop.inherits(Mode, TextMode); + +var indenter = /(?:[({[=:]|[-=]>|\b(?:else|try|with))\s*$/; + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var i, line; + var outdent = true; + var re = /^\s*\(\*(.*)\*\)/; + + for (i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + var range = new Range(0, 0, 0, 0); + for (i=startRow; i<= endRow; i++) { + line = doc.getLine(i); + range.start.row = i; + range.end.row = i; + range.end.column = line.length; + + doc.replace(range, outdent ? line.match(re)[1] : "(*" + line + "*)"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + var tokens = this.$tokenizer.getLineTokens(line, state).tokens; + + if (!(tokens.length && tokens[tokens.length - 1].type === 'comment') && + state === 'start' && indenter.test(line)) + indent += tab; + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/ocaml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var OcamlHighlightRules = function() { + + var keywords = ( + "and|as|assert|begin|class|constraint|do|done|downto|else|end|" + + "exception|external|for|fun|function|functor|if|in|include|" + + "inherit|initializer|lazy|let|match|method|module|mutable|new|" + + "object|of|open|or|private|rec|sig|struct|then|to|try|type|val|" + + "virtual|when|while|with" + ); + + var builtinConstants = ("true|false"); + + var builtinFunctions = ( + "abs|abs_big_int|abs_float|abs_num|abstract_tag|accept|access|acos|add|" + + "add_available_units|add_big_int|add_buffer|add_channel|add_char|" + + "add_initializer|add_int_big_int|add_interfaces|add_num|add_string|" + + "add_substitute|add_substring|alarm|allocated_bytes|allow_only|" + + "allow_unsafe_modules|always|append|appname_get|appname_set|" + + "approx_num_exp|approx_num_fix|arg|argv|arith_status|array|" + + "array1_of_genarray|array2_of_genarray|array3_of_genarray|asin|asr|" + + "assoc|assq|at_exit|atan|atan2|auto_synchronize|background|basename|" + + "beginning_of_input|big_int_of_int|big_int_of_num|big_int_of_string|bind|" + + "bind_class|bind_tag|bits|bits_of_float|black|blit|blit_image|blue|bool|" + + "bool_of_string|bounded_full_split|bounded_split|bounded_split_delim|" + + "bprintf|break|broadcast|bscanf|button_down|c_layout|capitalize|cardinal|" + + "cardinal|catch|catch_break|ceil|ceiling_num|channel|char|char_of_int|" + + "chdir|check|check_suffix|chmod|choose|chop_extension|chop_suffix|chown|" + + "chown|chr|chroot|classify_float|clear|clear_available_units|" + + "clear_close_on_exec|clear_graph|clear_nonblock|clear_parser|" + + "close|close|closeTk|close_box|close_graph|close_in|close_in_noerr|" + + "close_out|close_out_noerr|close_process|close_process|" + + "close_process_full|close_process_in|close_process_out|close_subwindow|" + + "close_tag|close_tbox|closedir|closedir|closure_tag|code|combine|" + + "combine|combine|command|compact|compare|compare_big_int|compare_num|" + + "complex32|complex64|concat|conj|connect|contains|contains_from|contents|" + + "copy|cos|cosh|count|count|counters|create|create_alarm|create_image|" + + "create_matrix|create_matrix|create_matrix|create_object|" + + "create_object_and_run_initializers|create_object_opt|create_process|" + + "create_process|create_process_env|create_process_env|create_table|" + + "current|current_dir_name|current_point|current_x|current_y|curveto|" + + "custom_tag|cyan|data_size|decr|decr_num|default_available_units|delay|" + + "delete_alarm|descr_of_in_channel|descr_of_out_channel|destroy|diff|dim|" + + "dim1|dim2|dim3|dims|dirname|display_mode|div|div_big_int|div_num|" + + "double_array_tag|double_tag|draw_arc|draw_char|draw_circle|draw_ellipse|" + + "draw_image|draw_poly|draw_poly_line|draw_rect|draw_segments|draw_string|" + + "dummy_pos|dummy_table|dump_image|dup|dup2|elements|empty|end_of_input|" + + "environment|eprintf|epsilon_float|eq_big_int|eq_num|equal|err_formatter|" + + "error_message|escaped|establish_server|executable_name|execv|execve|execvp|" + + "execvpe|exists|exists2|exit|exp|failwith|fast_sort|fchmod|fchown|field|" + + "file|file_exists|fill|fill_arc|fill_circle|fill_ellipse|fill_poly|fill_rect|" + + "filter|final_tag|finalise|find|find_all|first_chars|firstkey|flatten|" + + "float|float32|float64|float_of_big_int|float_of_bits|float_of_int|" + + "float_of_num|float_of_string|floor|floor_num|flush|flush_all|flush_input|" + + "flush_str_formatter|fold|fold_left|fold_left2|fold_right|fold_right2|" + + "for_all|for_all2|force|force_newline|force_val|foreground|fork|" + + "format_of_string|formatter_of_buffer|formatter_of_out_channel|" + + "fortran_layout|forward_tag|fprintf|frexp|from|from_channel|from_file|" + + "from_file_bin|from_function|from_string|fscanf|fst|fstat|ftruncate|" + + "full_init|full_major|full_split|gcd_big_int|ge_big_int|ge_num|" + + "genarray_of_array1|genarray_of_array2|genarray_of_array3|get|" + + "get_all_formatter_output_functions|get_approx_printing|get_copy|" + + "get_ellipsis_text|get_error_when_null_denominator|get_floating_precision|" + + "get_formatter_output_functions|get_formatter_tag_functions|get_image|" + + "get_margin|get_mark_tags|get_max_boxes|get_max_indent|get_method|" + + "get_method_label|get_normalize_ratio|get_normalize_ratio_when_printing|" + + "get_print_tags|get_state|get_variable|getcwd|getegid|getegid|getenv|" + + "getenv|getenv|geteuid|geteuid|getgid|getgid|getgrgid|getgrgid|getgrnam|" + + "getgrnam|getgroups|gethostbyaddr|gethostbyname|gethostname|getitimer|" + + "getlogin|getpeername|getpid|getppid|getprotobyname|getprotobynumber|" + + "getpwnam|getpwuid|getservbyname|getservbyport|getsockname|getsockopt|" + + "getsockopt_float|getsockopt_int|getsockopt_optint|gettimeofday|getuid|" + + "global_replace|global_substitute|gmtime|green|grid|group_beginning|" + + "group_end|gt_big_int|gt_num|guard|handle_unix_error|hash|hash_param|" + + "hd|header_size|i|id|ignore|in_channel_length|in_channel_of_descr|incr|" + + "incr_num|index|index_from|inet_addr_any|inet_addr_of_string|infinity|" + + "infix_tag|init|init_class|input|input_binary_int|input_byte|input_char|" + + "input_line|input_value|int|int16_signed|int16_unsigned|int32|int64|" + + "int8_signed|int8_unsigned|int_of_big_int|int_of_char|int_of_float|" + + "int_of_num|int_of_string|integer_num|inter|interactive|inv|invalid_arg|" + + "is_block|is_empty|is_implicit|is_int|is_int_big_int|is_integer_num|" + + "is_relative|iter|iter2|iteri|join|junk|key_pressed|kill|kind|kprintf|" + + "kscanf|land|last_chars|layout|lazy_from_fun|lazy_from_val|lazy_is_val|" + + "lazy_tag|ldexp|le_big_int|le_num|length|lexeme|lexeme_char|lexeme_end|" + + "lexeme_end_p|lexeme_start|lexeme_start_p|lineto|link|list|listen|lnot|" + + "loadfile|loadfile_private|localtime|lock|lockf|log|log10|logand|lognot|" + + "logor|logxor|lor|lower_window|lowercase|lseek|lsl|lsr|lstat|lt_big_int|" + + "lt_num|lxor|magenta|magic|mainLoop|major|major_slice|make|make_formatter|" + + "make_image|make_lexer|make_matrix|make_self_init|map|map2|map_file|mapi|" + + "marshal|match_beginning|match_end|matched_group|matched_string|max|" + + "max_array_length|max_big_int|max_elt|max_float|max_int|max_num|" + + "max_string_length|mem|mem_assoc|mem_assq|memq|merge|min|min_big_int|" + + "min_elt|min_float|min_int|min_num|minor|minus_big_int|minus_num|" + + "minus_one|mkdir|mkfifo|mktime|mod|mod_big_int|mod_float|mod_num|modf|" + + "mouse_pos|moveto|mul|mult_big_int|mult_int_big_int|mult_num|nan|narrow|" + + "nat_of_num|nativeint|neg|neg_infinity|new_block|new_channel|new_method|" + + "new_variable|next|nextkey|nice|nice|no_scan_tag|norm|norm2|not|npeek|" + + "nth|nth_dim|num_digits_big_int|num_dims|num_of_big_int|num_of_int|" + + "num_of_nat|num_of_ratio|num_of_string|O|obj|object_tag|ocaml_version|" + + "of_array|of_channel|of_float|of_int|of_int32|of_list|of_nativeint|" + + "of_string|one|openTk|open_box|open_connection|open_graph|open_hbox|" + + "open_hovbox|open_hvbox|open_in|open_in_bin|open_in_gen|open_out|" + + "open_out_bin|open_out_gen|open_process|open_process_full|open_process_in|" + + "open_process_out|open_subwindow|open_tag|open_tbox|open_temp_file|" + + "open_vbox|opendbm|opendir|openfile|or|os_type|out_channel_length|" + + "out_channel_of_descr|output|output_binary_int|output_buffer|output_byte|" + + "output_char|output_string|output_value|over_max_boxes|pack|params|" + + "parent_dir_name|parse|parse_argv|partition|pause|peek|pipe|pixels|" + + "place|plot|plots|point_color|polar|poll|pop|pos_in|pos_out|pow|" + + "power_big_int_positive_big_int|power_big_int_positive_int|" + + "power_int_positive_big_int|power_int_positive_int|power_num|" + + "pp_close_box|pp_close_tag|pp_close_tbox|pp_force_newline|" + + "pp_get_all_formatter_output_functions|pp_get_ellipsis_text|" + + "pp_get_formatter_output_functions|pp_get_formatter_tag_functions|" + + "pp_get_margin|pp_get_mark_tags|pp_get_max_boxes|pp_get_max_indent|" + + "pp_get_print_tags|pp_open_box|pp_open_hbox|pp_open_hovbox|pp_open_hvbox|" + + "pp_open_tag|pp_open_tbox|pp_open_vbox|pp_over_max_boxes|pp_print_as|" + + "pp_print_bool|pp_print_break|pp_print_char|pp_print_cut|pp_print_float|" + + "pp_print_flush|pp_print_if_newline|pp_print_int|pp_print_newline|" + + "pp_print_space|pp_print_string|pp_print_tab|pp_print_tbreak|" + + "pp_set_all_formatter_output_functions|pp_set_ellipsis_text|" + + "pp_set_formatter_out_channel|pp_set_formatter_output_functions|" + + "pp_set_formatter_tag_functions|pp_set_margin|pp_set_mark_tags|" + + "pp_set_max_boxes|pp_set_max_indent|pp_set_print_tags|pp_set_tab|" + + "pp_set_tags|pred|pred_big_int|pred_num|prerr_char|prerr_endline|" + + "prerr_float|prerr_int|prerr_newline|prerr_string|print|print_as|" + + "print_bool|print_break|print_char|print_cut|print_endline|print_float|" + + "print_flush|print_if_newline|print_int|print_newline|print_space|" + + "print_stat|print_string|print_tab|print_tbreak|printf|prohibit|" + + "public_method_label|push|putenv|quo_num|quomod_big_int|quote|raise|" + + "raise_window|ratio_of_num|rcontains_from|read|read_float|read_int|" + + "read_key|read_line|readdir|readdir|readlink|really_input|receive|recv|" + + "recvfrom|red|ref|regexp|regexp_case_fold|regexp_string|" + + "regexp_string_case_fold|register|register_exception|rem|remember_mode|" + + "remove|remove_assoc|remove_assq|rename|replace|replace_first|" + + "replace_matched|repr|reset|reshape|reshape_1|reshape_2|reshape_3|rev|" + + "rev_append|rev_map|rev_map2|rewinddir|rgb|rhs_end|rhs_end_pos|rhs_start|" + + "rhs_start_pos|rindex|rindex_from|rlineto|rmdir|rmoveto|round_num|" + + "run_initializers|run_initializers_opt|scanf|search_backward|" + + "search_forward|seek_in|seek_out|select|self|self_init|send|sendto|set|" + + "set_all_formatter_output_functions|set_approx_printing|" + + "set_binary_mode_in|set_binary_mode_out|set_close_on_exec|" + + "set_close_on_exec|set_color|set_ellipsis_text|" + + "set_error_when_null_denominator|set_field|set_floating_precision|" + + "set_font|set_formatter_out_channel|set_formatter_output_functions|" + + "set_formatter_tag_functions|set_line_width|set_margin|set_mark_tags|" + + "set_max_boxes|set_max_indent|set_method|set_nonblock|set_nonblock|" + + "set_normalize_ratio|set_normalize_ratio_when_printing|set_print_tags|" + + "set_signal|set_state|set_tab|set_tag|set_tags|set_text_size|" + + "set_window_title|setgid|setgid|setitimer|setitimer|setsid|setsid|" + + "setsockopt|setsockopt|setsockopt_float|setsockopt_float|setsockopt_int|" + + "setsockopt_int|setsockopt_optint|setsockopt_optint|setuid|setuid|" + + "shift_left|shift_left|shift_left|shift_right|shift_right|shift_right|" + + "shift_right_logical|shift_right_logical|shift_right_logical|show_buckets|" + + "shutdown|shutdown|shutdown_connection|shutdown_connection|sigabrt|" + + "sigalrm|sigchld|sigcont|sigfpe|sighup|sigill|sigint|sigkill|sign_big_int|" + + "sign_num|signal|signal|sigpending|sigpending|sigpipe|sigprocmask|" + + "sigprocmask|sigprof|sigquit|sigsegv|sigstop|sigsuspend|sigsuspend|" + + "sigterm|sigtstp|sigttin|sigttou|sigusr1|sigusr2|sigvtalrm|sin|singleton|" + + "sinh|size|size|size_x|size_y|sleep|sleep|sleep|slice_left|slice_left|" + + "slice_left_1|slice_left_2|slice_right|slice_right|slice_right_1|" + + "slice_right_2|snd|socket|socket|socket|socketpair|socketpair|sort|sound|" + + "split|split_delim|sprintf|sprintf|sqrt|sqrt|sqrt_big_int|square_big_int|" + + "square_num|sscanf|stable_sort|stable_sort|stable_sort|stable_sort|stable_sort|" + + "stable_sort|stat|stat|stat|stat|stat|stats|stats|std_formatter|stdbuf|" + + "stderr|stderr|stderr|stdib|stdin|stdin|stdin|stdout|stdout|stdout|" + + "str_formatter|string|string_after|string_before|string_match|" + + "string_of_big_int|string_of_bool|string_of_float|string_of_format|" + + "string_of_inet_addr|string_of_inet_addr|string_of_int|string_of_num|" + + "string_partial_match|string_tag|sub|sub|sub_big_int|sub_left|sub_num|" + + "sub_right|subset|subset|substitute_first|substring|succ|succ|" + + "succ|succ|succ_big_int|succ_num|symbol_end|symbol_end_pos|symbol_start|" + + "symbol_start_pos|symlink|symlink|sync|synchronize|system|system|system|" + + "tag|take|tan|tanh|tcdrain|tcdrain|tcflow|tcflow|tcflush|tcflush|" + + "tcgetattr|tcgetattr|tcsendbreak|tcsendbreak|tcsetattr|tcsetattr|" + + "temp_file|text_size|time|time|time|timed_read|timed_write|times|times|" + + "tl|tl|tl|to_buffer|to_channel|to_float|to_hex|to_int|to_int32|to_list|" + + "to_list|to_list|to_nativeint|to_string|to_string|to_string|to_string|" + + "to_string|top|top|total_size|transfer|transp|truncate|truncate|truncate|" + + "truncate|truncate|truncate|try_lock|umask|umask|uncapitalize|uncapitalize|" + + "uncapitalize|union|union|unit_big_int|unlink|unlink|unlock|unmarshal|" + + "unsafe_blit|unsafe_fill|unsafe_get|unsafe_get|unsafe_set|unsafe_set|" + + "update|uppercase|uppercase|uppercase|uppercase|usage|utimes|utimes|wait|" + + "wait|wait|wait|wait_next_event|wait_pid|wait_read|wait_signal|" + + "wait_timed_read|wait_timed_write|wait_write|waitpid|white|" + + "widen|window_id|word_size|wrap|wrap_abort|write|yellow|yield|zero|zero_big_int|" + + + "Arg|Arith_status|Array|Array1|Array2|Array3|ArrayLabels|Big_int|Bigarray|" + + "Buffer|Callback|CamlinternalOO|Char|Complex|Condition|Dbm|Digest|Dynlink|" + + "Event|Filename|Format|Gc|Genarray|Genlex|Graphics|GraphicsX11|Hashtbl|" + + "Int32|Int64|LargeFile|Lazy|Lexing|List|ListLabels|Make|Map|Marshal|" + + "MoreLabels|Mutex|Nativeint|Num|Obj|Oo|Parsing|Pervasives|Printexc|" + + "Printf|Queue|Random|Scanf|Scanning|Set|Sort|Stack|State|StdLabels|Str|" + + "Stream|String|StringLabels|Sys|Thread|ThreadUnix|Tk|Unix|UnixLabels|Weak" + ); + + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": keywords, + "constant.language": builtinConstants, + "support.function": builtinFunctions + }, "identifier"); + + var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))"; + var octInteger = "(?:0[oO]?[0-7]+)"; + var hexInteger = "(?:0[xX][\\dA-Fa-f]+)"; + var binInteger = "(?:0[bB][01]+)"; + var integer = "(?:" + decimalInteger + "|" + octInteger + "|" + hexInteger + "|" + binInteger + ")"; + + var exponent = "(?:[eE][+-]?\\d+)"; + var fraction = "(?:\\.\\d+)"; + var intPart = "(?:\\d+)"; + var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))"; + var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + exponent + ")"; + var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")"; + + this.$rules = { + "start" : [ + { + token : "comment", + regex : '\\(\\*.*?\\*\\)\\s*?$' + }, + { + token : "comment", + merge : true, + regex : '\\(\\*.*', + next : "comment" + }, + { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, + { + token : "string", // single char + regex : "'.'" + }, + { + token : "string", // " string + merge : true, + regex : '"', + next : "qstring" + }, + { + token : "constant.numeric", // imaginary + regex : "(?:" + floatNumber + "|\\d+)[jJ]\\b" + }, + { + token : "constant.numeric", // float + regex : floatNumber + }, + { + token : "constant.numeric", // integer + regex : integer + "\\b" + }, + { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, + { + token : "keyword.operator", + regex : "\\+\\.|\\-\\.|\\*\\.|\\/\\.|#|;;|\\+|\\-|\\*|\\*\\*\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|<-|=" + }, + { + token : "paren.lparen", + regex : "[[({]" + }, + { + token : "paren.rparen", + regex : "[\\])}]" + }, + { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\)", + next : "start" + }, + { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + + "qstring" : [ + { + token : "string", + regex : '"', + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ] + }; +}; + +oop.inherits(OcamlHighlightRules, TextHighlightRules); + +exports.OcamlHighlightRules = OcamlHighlightRules; +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-perl.js b/vendor/assets/javascripts/ace-src-noconflict/mode-perl.js new file mode 100644 index 00000000..d53a347a --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-perl.js @@ -0,0 +1,419 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/perl', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/perl_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var PerlHighlightRules = require("./perl_highlight_rules").PerlHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new PerlHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)#/; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "#"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[\:]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/perl_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var PerlHighlightRules = function() { + + var keywords = ( + "base|constant|continue|else|elsif|for|foreach|format|goto|if|last|local|my|next|" + + "no|package|parent|redo|require|scalar|sub|unless|until|while|use|vars" + ); + + var buildinConstants = ("ARGV|ENV|INC|SIG"); + + var builtinFunctions = ( + "getprotobynumber|getprotobyname|getservbyname|gethostbyaddr|" + + "gethostbyname|getservbyport|getnetbyaddr|getnetbyname|getsockname|" + + "getpeername|setpriority|getprotoent|setprotoent|getpriority|" + + "endprotoent|getservent|setservent|endservent|sethostent|socketpair|" + + "getsockopt|gethostent|endhostent|setsockopt|setnetent|quotemeta|" + + "localtime|prototype|getnetent|endnetent|rewinddir|wantarray|getpwuid|" + + "closedir|getlogin|readlink|endgrent|getgrgid|getgrnam|shmwrite|" + + "shutdown|readline|endpwent|setgrent|readpipe|formline|truncate|" + + "dbmclose|syswrite|setpwent|getpwnam|getgrent|getpwent|ucfirst|sysread|" + + "setpgrp|shmread|sysseek|sysopen|telldir|defined|opendir|connect|" + + "lcfirst|getppid|binmode|syscall|sprintf|getpgrp|readdir|seekdir|" + + "waitpid|reverse|unshift|symlink|dbmopen|semget|msgrcv|rename|listen|" + + "chroot|msgsnd|shmctl|accept|unpack|exists|fileno|shmget|system|" + + "unlink|printf|gmtime|msgctl|semctl|values|rindex|substr|splice|" + + "length|msgget|select|socket|return|caller|delete|alarm|ioctl|index|" + + "undef|lstat|times|srand|chown|fcntl|close|write|umask|rmdir|study|" + + "sleep|chomp|untie|print|utime|mkdir|atan2|split|crypt|flock|chmod|" + + "BEGIN|bless|chdir|semop|shift|reset|link|stat|chop|grep|fork|dump|" + + "join|open|tell|pipe|exit|glob|warn|each|bind|sort|pack|eval|push|" + + "keys|getc|kill|seek|sqrt|send|wait|rand|tied|read|time|exec|recv|" + + "eof|chr|int|ord|exp|pos|pop|sin|log|abs|oct|hex|tie|cos|vec|END|ref|" + + "map|die|uc|lc|do" + ); + + var keywordMapper = this.createKeywordMapper({ + "keyword": keywords, + "constant.language": buildinConstants, + "support.function": builtinFunctions + }, "identifier"); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "#.*$" + }, { + token : "string.regexp", + regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*\\\\$', + next : "qqstring" + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*\\\\$", + next : "qstring" + }, { + token : "constant.numeric", // hex + regex : "0x[0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\.\\.\\.|\\|\\|=|>>=|<<=|<=>|&&=|=>|!~|\\^=|&=|\\|=|\\.=|x=|%=|\\/=|\\*=|\\-=|\\+=|=~|\\*\\*|\\-\\-|\\.\\.|\\|\\||&&|\\+\\+|\\->|!=|==|>=|<=|>>|<<|,|=|\\?\\:|\\^|\\||x|%|\\/|\\*|<|&|\\\\|~|!|>|\\.|\\-|\\+|\\-C|\\-b|\\-S|\\-u|\\-t|\\-p|\\-l|\\-d|\\-f|\\-g|\\-s|\\-z|\\-k|\\-e|\\-O|\\-T|\\-B|\\-M|\\-A|\\-X|\\-W|\\-c|\\-R|\\-o|\\-x|\\-w|\\-r|\\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)" + }, { + token : "lparen", + regex : "[[({]" + }, { + token : "rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "qqstring" : [ + { + token : "string", + regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ], + "qstring" : [ + { + token : "string", + regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ] + }; +}; + +oop.inherits(PerlHighlightRules, TextHighlightRules); + +exports.PerlHighlightRules = PerlHighlightRules; +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-pgsql.js b/vendor/assets/javascripts/ace-src-noconflict/mode-pgsql.js new file mode 100644 index 00000000..2bc99ff9 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-pgsql.js @@ -0,0 +1,963 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/pgsql', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/pgsql_highlight_rules', 'ace/range'], function(require, exports, module) { + + var oop = require("../lib/oop"); + var TextMode = require("../mode/text").Mode; + var Tokenizer = require("../tokenizer").Tokenizer; + var PgsqlHighlightRules = require("./pgsql_highlight_rules").PgsqlHighlightRules; + var Range = require("../range").Range; + + var Mode = function() { + this.$tokenizer = new Tokenizer(new PgsqlHighlightRules().getRules()); + }; + oop.inherits(Mode, TextMode); + + (function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + // var outentedRows = []; + var re = /^(\s*)--/; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "--"); + } + }; + + + this.getNextLineIndent = function(state, line, tab) { + if (state == "start" || state == "keyword.statementEnd") { + return ""; + } else { + return this.$getIndent(line); // Keep whatever indent the previous line has + } + } + + }).call(Mode.prototype); + + exports.Mode = Mode; +}); + +ace.define('ace/mode/pgsql_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules', 'ace/mode/perl_highlight_rules', 'ace/mode/python_highlight_rules'], function(require, exports, module) { + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; +// Supporting perl and python for now -- both in pg core and ace +var PerlHighlightRules = require("./perl_highlight_rules").PerlHighlightRules; +var PythonHighlightRules = require("./python_highlight_rules").PythonHighlightRules; + +var PgsqlHighlightRules = function() { + + // Keywords, functions, operators last updated for pg 9.1. + var keywords = ( + "abort|absolute|abstime|access|aclitem|action|add|admin|after|aggregate|all|also|alter|always|" + + "analyse|analyze|and|any|anyarray|anyelement|anyenum|anynonarray|array|as|asc|assertion|" + + "assignment|asymmetric|at|attribute|authorization|backward|before|begin|between|bigint|" + + "binary|bit|bool|boolean|both|box|bpchar|by|bytea|cache|called|cascade|cascaded|case|cast|" + + "catalog|chain|char|character|characteristics|check|checkpoint|cid|cidr|circle|class|close|" + + "cluster|coalesce|collate|collation|column|comment|comments|commit|committed|concurrently|" + + "configuration|connection|constraint|constraints|content|continue|conversion|copy|cost|" + + "create|cross|cstring|csv|current|current_catalog|current_date|current_role|" + + "current_schema|current_time|current_timestamp|current_user|cursor|cycle|data|database|" + + "date|day|deallocate|dec|decimal|declare|default|defaults|deferrable|deferred|definer|delete|" + + "delimiter|delimiters|desc|dictionary|disable|discard|distinct|do|document|domain|double|" + + "drop|each|else|enable|encoding|encrypted|end|enum|escape|except|exclude|excluding|exclusive|" + + "execute|exists|explain|extension|external|extract|false|family|fdw_handler|fetch|first|" + + "float|float4|float8|following|for|force|foreign|forward|freeze|from|full|function|functions|" + + "global|grant|granted|greatest|group|gtsvector|handler|having|header|hold|hour|identity|if|" + + "ilike|immediate|immutable|implicit|in|including|increment|index|indexes|inet|inherit|" + + "inherits|initially|inline|inner|inout|input|insensitive|insert|instead|int|int2|int2vector|" + + "int4|int8|integer|internal|intersect|interval|into|invoker|is|isnull|isolation|join|key|label|" + + "language|language_handler|large|last|lc_collate|lc_ctype|leading|least|left|level|like|" + + "limit|line|listen|load|local|localtime|localtimestamp|location|lock|lseg|macaddr|mapping|" + + "match|maxvalue|minute|minvalue|mode|money|month|move|name|names|national|natural|nchar|next|no|" + + "none|not|nothing|notify|notnull|nowait|null|nullif|nulls|numeric|object|of|off|offset|oid|oids|" + + "oidvector|on|only|opaque|operator|option|options|or|order|out|outer|over|overlaps|overlay|" + + "owned|owner|parser|partial|partition|passing|password|path|pg_attribute|pg_auth_members|" + + "pg_authid|pg_class|pg_database|pg_node_tree|pg_proc|pg_type|placing|plans|point|polygon|" + + "position|preceding|precision|prepare|prepared|preserve|primary|prior|privileges|" + + "procedural|procedure|quote|range|read|real|reassign|recheck|record|recursive|ref|refcursor|" + + "references|regclass|regconfig|regdictionary|regoper|regoperator|regproc|regprocedure|" + + "regtype|reindex|relative|release|reltime|rename|repeatable|replace|replica|reset|restart|" + + "restrict|returning|returns|revoke|right|role|rollback|row|rows|rule|savepoint|schema|scroll|" + + "search|second|security|select|sequence|sequences|serializable|server|session|session_user|" + + "set|setof|share|show|similar|simple|smallint|smgr|some|stable|standalone|start|statement|" + + "statistics|stdin|stdout|storage|strict|strip|substring|symmetric|sysid|system|table|tables|" + + "tablespace|temp|template|temporary|text|then|tid|time|timestamp|timestamptz|timetz|" + + "tinterval|to|trailing|transaction|treat|trigger|trim|true|truncate|trusted|tsquery|tsvector|" + + "txid_snapshot|type|unbounded|uncommitted|unencrypted|union|unique|unknown|unlisten|" + + "unlogged|until|update|user|using|uuid|vacuum|valid|validate|validator|value|values|varbit|" + + "varchar|variadic|varying|verbose|version|view|void|volatile|when|where|whitespace|window|" + + "with|without|work|wrapper|write|xid|xml|xmlattributes|xmlconcat|xmlelement|xmlexists|" + + "xmlforest|xmlparse|xmlpi|xmlroot|xmlserialize|year|yes|zone" + ); + + + var builtinFunctions = ( + "RI_FKey_cascade_del|RI_FKey_cascade_upd|RI_FKey_check_ins|RI_FKey_check_upd|" + + "RI_FKey_noaction_del|RI_FKey_noaction_upd|RI_FKey_restrict_del|RI_FKey_restrict_upd|" + + "RI_FKey_setdefault_del|RI_FKey_setdefault_upd|RI_FKey_setnull_del|" + + "RI_FKey_setnull_upd|abbrev|abs|abstime|abstimeeq|abstimege|abstimegt|abstimein|abstimele|" + + "abstimelt|abstimene|abstimeout|abstimerecv|abstimesend|aclcontains|aclexplode|aclinsert|" + + "aclitemeq|aclitemin|aclitemout|aclremove|acos|age|any_in|any_out|anyarray_in|anyarray_out|" + + "anyarray_recv|anyarray_send|anyelement_in|anyelement_out|anyenum_in|anyenum_out|" + + "anynonarray_in|anynonarray_out|anytextcat|area|areajoinsel|areasel|array_agg|" + + "array_agg_finalfn|array_agg_transfn|array_append|array_cat|array_dims|array_eq|" + + "array_fill|array_ge|array_gt|array_in|array_larger|array_le|array_length|array_lower|" + + "array_lt|array_ndims|array_ne|array_out|array_prepend|array_recv|array_send|" + + "array_smaller|array_to_string|array_upper|arraycontained|arraycontains|arrayoverlap|" + + "ascii|ascii_to_mic|ascii_to_utf8|asin|atan|atan2|avg|big5_to_euc_tw|big5_to_mic|" + + "big5_to_utf8|bit_and|bit_in|bit_length|bit_or|bit_out|bit_recv|bit_send|bitand|bitcat|" + + "bitcmp|biteq|bitge|bitgt|bitle|bitlt|bitne|bitnot|bitor|bitshiftleft|bitshiftright|" + + "bittypmodin|bittypmodout|bitxor|bool|bool_and|bool_or|booland_statefunc|booleq|boolge|" + + "boolgt|boolin|boolle|boollt|boolne|boolor_statefunc|boolout|boolrecv|boolsend|box|" + + "box_above|box_above_eq|box_add|box_below|box_below_eq|box_center|box_contain|" + + "box_contain_pt|box_contained|box_distance|box_div|box_eq|box_ge|box_gt|box_in|" + + "box_intersect|box_le|box_left|box_lt|box_mul|box_out|box_overabove|box_overbelow|" + + "box_overlap|box_overleft|box_overright|box_recv|box_right|box_same|box_send|box_sub|" + + "bpchar_larger|bpchar_pattern_ge|bpchar_pattern_gt|bpchar_pattern_le|" + + "bpchar_pattern_lt|bpchar_smaller|bpcharcmp|bpchareq|bpcharge|bpchargt|bpchariclike|" + + "bpcharicnlike|bpcharicregexeq|bpcharicregexne|bpcharin|bpcharle|bpcharlike|bpcharlt|" + + "bpcharne|bpcharnlike|bpcharout|bpcharrecv|bpcharregexeq|bpcharregexne|bpcharsend|" + + "bpchartypmodin|bpchartypmodout|broadcast|btabstimecmp|btarraycmp|btbeginscan|btboolcmp|" + + "btbpchar_pattern_cmp|btbuild|btbuildempty|btbulkdelete|btcharcmp|btcostestimate|" + + "btendscan|btfloat48cmp|btfloat4cmp|btfloat84cmp|btfloat8cmp|btgetbitmap|btgettuple|" + + "btinsert|btint24cmp|btint28cmp|btint2cmp|btint42cmp|btint48cmp|btint4cmp|btint82cmp|" + + "btint84cmp|btint8cmp|btmarkpos|btnamecmp|btoidcmp|btoidvectorcmp|btoptions|btrecordcmp|" + + "btreltimecmp|btrescan|btrestrpos|btrim|bttext_pattern_cmp|bttextcmp|bttidcmp|" + + "bttintervalcmp|btvacuumcleanup|byteacat|byteacmp|byteaeq|byteage|byteagt|byteain|byteale|" + + "bytealike|bytealt|byteane|byteanlike|byteaout|bytearecv|byteasend|cash_cmp|cash_div_cash|" + + "cash_div_flt4|cash_div_flt8|cash_div_int2|cash_div_int4|cash_eq|cash_ge|cash_gt|cash_in|" + + "cash_le|cash_lt|cash_mi|cash_mul_flt4|cash_mul_flt8|cash_mul_int2|cash_mul_int4|cash_ne|" + + "cash_out|cash_pl|cash_recv|cash_send|cash_words|cashlarger|cashsmaller|cbrt|ceil|ceiling|" + + "center|char|char_length|character_length|chareq|charge|chargt|charin|charle|charlt|charne|" + + "charout|charrecv|charsend|chr|cideq|cidin|cidout|cidr|cidr_in|cidr_out|cidr_recv|cidr_send|" + + "cidrecv|cidsend|circle|circle_above|circle_add_pt|circle_below|circle_center|" + + "circle_contain|circle_contain_pt|circle_contained|circle_distance|circle_div_pt|" + + "circle_eq|circle_ge|circle_gt|circle_in|circle_le|circle_left|circle_lt|circle_mul_pt|" + + "circle_ne|circle_out|circle_overabove|circle_overbelow|circle_overlap|circle_overleft|" + + "circle_overright|circle_recv|circle_right|circle_same|circle_send|circle_sub_pt|" + + "clock_timestamp|close_lb|close_ls|close_lseg|close_pb|close_pl|close_ps|close_sb|" + + "close_sl|col_description|concat|concat_ws|contjoinsel|contsel|convert|convert_from|" + + "convert_to|corr|cos|cot|count|covar_pop|covar_samp|cstring_in|cstring_out|cstring_recv|" + + "cstring_send|cume_dist|current_database|current_query|current_schema|current_schemas|" + + "current_setting|current_user|currtid|currtid2|currval|cursor_to_xml|" + + "cursor_to_xmlschema|database_to_xml|database_to_xml_and_xmlschema|" + + "database_to_xmlschema|date|date_cmp|date_cmp_timestamp|date_cmp_timestamptz|date_eq|" + + "date_eq_timestamp|date_eq_timestamptz|date_ge|date_ge_timestamp|date_ge_timestamptz|" + + "date_gt|date_gt_timestamp|date_gt_timestamptz|date_in|date_larger|date_le|" + + "date_le_timestamp|date_le_timestamptz|date_lt|date_lt_timestamp|date_lt_timestamptz|" + + "date_mi|date_mi_interval|date_mii|date_ne|date_ne_timestamp|date_ne_timestamptz|" + + "date_out|date_part|date_pl_interval|date_pli|date_recv|date_send|date_smaller|" + + "date_trunc|datetime_pl|datetimetz_pl|dcbrt|decode|degrees|dense_rank|dexp|diagonal|" + + "diameter|dispell_init|dispell_lexize|dist_cpoly|dist_lb|dist_pb|dist_pc|dist_pl|" + + "dist_ppath|dist_ps|dist_sb|dist_sl|div|dlog1|dlog10|domain_in|domain_recv|dpow|dround|" + + "dsimple_init|dsimple_lexize|dsnowball_init|dsnowball_lexize|dsqrt|dsynonym_init|" + + "dsynonym_lexize|dtrunc|encode|enum_cmp|enum_eq|enum_first|enum_ge|enum_gt|enum_in|" + + "enum_larger|enum_last|enum_le|enum_lt|enum_ne|enum_out|enum_range|enum_recv|enum_send|" + + "enum_smaller|eqjoinsel|eqsel|euc_cn_to_mic|euc_cn_to_utf8|" + + "euc_jis_2004_to_shift_jis_2004|euc_jis_2004_to_utf8|euc_jp_to_mic|euc_jp_to_sjis|" + + "euc_jp_to_utf8|euc_kr_to_mic|euc_kr_to_utf8|euc_tw_to_big5|euc_tw_to_mic|" + + "euc_tw_to_utf8|every|exp|factorial|family|fdw_handler_in|fdw_handler_out|first_value|" + + "float4|float48div|float48eq|float48ge|float48gt|float48le|float48lt|float48mi|float48mul|" + + "float48ne|float48pl|float4_accum|float4abs|float4div|float4eq|float4ge|float4gt|float4in|" + + "float4larger|float4le|float4lt|float4mi|float4mul|float4ne|float4out|float4pl|float4recv|" + + "float4send|float4smaller|float4um|float4up|float8|float84div|float84eq|float84ge|" + + "float84gt|float84le|float84lt|float84mi|float84mul|float84ne|float84pl|float8_accum|" + + "float8_avg|float8_corr|float8_covar_pop|float8_covar_samp|float8_regr_accum|" + + "float8_regr_avgx|float8_regr_avgy|float8_regr_intercept|float8_regr_r2|" + + "float8_regr_slope|float8_regr_sxx|float8_regr_sxy|float8_regr_syy|float8_stddev_pop|" + + "float8_stddev_samp|float8_var_pop|float8_var_samp|float8abs|float8div|float8eq|" + + "float8ge|float8gt|float8in|float8larger|float8le|float8lt|float8mi|float8mul|float8ne|" + + "float8out|float8pl|float8recv|float8send|float8smaller|float8um|float8up|floor|" + + "flt4_mul_cash|flt8_mul_cash|fmgr_c_validator|fmgr_internal_validator|" + + "fmgr_sql_validator|format|format_type|gb18030_to_utf8|gbk_to_utf8|generate_series|" + + "generate_subscripts|get_bit|get_byte|get_current_ts_config|getdatabaseencoding|" + + "getpgusername|gin_cmp_prefix|gin_cmp_tslexeme|gin_extract_tsquery|" + + "gin_extract_tsvector|gin_tsquery_consistent|ginarrayconsistent|ginarrayextract|" + + "ginbeginscan|ginbuild|ginbuildempty|ginbulkdelete|gincostestimate|ginendscan|" + + "gingetbitmap|gininsert|ginmarkpos|ginoptions|ginqueryarrayextract|ginrescan|" + + "ginrestrpos|ginvacuumcleanup|gist_box_compress|gist_box_consistent|" + + "gist_box_decompress|gist_box_penalty|gist_box_picksplit|gist_box_same|gist_box_union|" + + "gist_circle_compress|gist_circle_consistent|gist_point_compress|" + + "gist_point_consistent|gist_point_distance|gist_poly_compress|gist_poly_consistent|" + + "gistbeginscan|gistbuild|gistbuildempty|gistbulkdelete|gistcostestimate|gistendscan|" + + "gistgetbitmap|gistgettuple|gistinsert|gistmarkpos|gistoptions|gistrescan|gistrestrpos|" + + "gistvacuumcleanup|gtsquery_compress|gtsquery_consistent|gtsquery_decompress|" + + "gtsquery_penalty|gtsquery_picksplit|gtsquery_same|gtsquery_union|gtsvector_compress|" + + "gtsvector_consistent|gtsvector_decompress|gtsvector_penalty|gtsvector_picksplit|" + + "gtsvector_same|gtsvector_union|gtsvectorin|gtsvectorout|has_any_column_privilege|" + + "has_column_privilege|has_database_privilege|has_foreign_data_wrapper_privilege|" + + "has_function_privilege|has_language_privilege|has_schema_privilege|" + + "has_sequence_privilege|has_server_privilege|has_table_privilege|" + + "has_tablespace_privilege|hash_aclitem|hash_array|hash_numeric|hashbeginscan|" + + "hashbpchar|hashbuild|hashbuildempty|hashbulkdelete|hashchar|hashcostestimate|" + + "hashendscan|hashenum|hashfloat4|hashfloat8|hashgetbitmap|hashgettuple|hashinet|" + + "hashinsert|hashint2|hashint2vector|hashint4|hashint8|hashmacaddr|hashmarkpos|hashname|" + + "hashoid|hashoidvector|hashoptions|hashrescan|hashrestrpos|hashtext|hashvacuumcleanup|" + + "hashvarlena|height|host|hostmask|iclikejoinsel|iclikesel|icnlikejoinsel|icnlikesel|" + + "icregexeqjoinsel|icregexeqsel|icregexnejoinsel|icregexnesel|inet_client_addr|" + + "inet_client_port|inet_in|inet_out|inet_recv|inet_send|inet_server_addr|" + + "inet_server_port|inetand|inetmi|inetmi_int8|inetnot|inetor|inetpl|initcap|int2|int24div|" + + "int24eq|int24ge|int24gt|int24le|int24lt|int24mi|int24mul|int24ne|int24pl|int28div|int28eq|" + + "int28ge|int28gt|int28le|int28lt|int28mi|int28mul|int28ne|int28pl|int2_accum|" + + "int2_avg_accum|int2_mul_cash|int2_sum|int2abs|int2and|int2div|int2eq|int2ge|int2gt|int2in|" + + "int2larger|int2le|int2lt|int2mi|int2mod|int2mul|int2ne|int2not|int2or|int2out|int2pl|" + + "int2recv|int2send|int2shl|int2shr|int2smaller|int2um|int2up|int2vectoreq|int2vectorin|" + + "int2vectorout|int2vectorrecv|int2vectorsend|int2xor|int4|int42div|int42eq|int42ge|" + + "int42gt|int42le|int42lt|int42mi|int42mul|int42ne|int42pl|int48div|int48eq|int48ge|int48gt|" + + "int48le|int48lt|int48mi|int48mul|int48ne|int48pl|int4_accum|int4_avg_accum|int4_mul_cash|" + + "int4_sum|int4abs|int4and|int4div|int4eq|int4ge|int4gt|int4in|int4inc|int4larger|int4le|" + + "int4lt|int4mi|int4mod|int4mul|int4ne|int4not|int4or|int4out|int4pl|int4recv|int4send|" + + "int4shl|int4shr|int4smaller|int4um|int4up|int4xor|int8|int82div|int82eq|int82ge|int82gt|" + + "int82le|int82lt|int82mi|int82mul|int82ne|int82pl|int84div|int84eq|int84ge|int84gt|int84le|" + + "int84lt|int84mi|int84mul|int84ne|int84pl|int8_accum|int8_avg|int8_avg_accum|int8_sum|" + + "int8abs|int8and|int8div|int8eq|int8ge|int8gt|int8in|int8inc|int8inc_any|" + + "int8inc_float8_float8|int8larger|int8le|int8lt|int8mi|int8mod|int8mul|int8ne|int8not|" + + "int8or|int8out|int8pl|int8pl_inet|int8recv|int8send|int8shl|int8shr|int8smaller|int8um|" + + "int8up|int8xor|integer_pl_date|inter_lb|inter_sb|inter_sl|internal_in|internal_out|" + + "interval_accum|interval_avg|interval_cmp|interval_div|interval_eq|interval_ge|" + + "interval_gt|interval_hash|interval_in|interval_larger|interval_le|interval_lt|" + + "interval_mi|interval_mul|interval_ne|interval_out|interval_pl|interval_pl_date|" + + "interval_pl_time|interval_pl_timestamp|interval_pl_timestamptz|interval_pl_timetz|" + + "interval_recv|interval_send|interval_smaller|interval_um|intervaltypmodin|" + + "intervaltypmodout|intinterval|isclosed|isfinite|ishorizontal|iso8859_1_to_utf8|" + + "iso8859_to_utf8|iso_to_koi8r|iso_to_mic|iso_to_win1251|iso_to_win866|isopen|isparallel|" + + "isperp|isvertical|johab_to_utf8|justify_days|justify_hours|justify_interval|" + + "koi8r_to_iso|koi8r_to_mic|koi8r_to_utf8|koi8r_to_win1251|koi8r_to_win866|" + + "koi8u_to_utf8|lag|language_handler_in|language_handler_out|last_value|lastval|" + + "latin1_to_mic|latin2_to_mic|latin2_to_win1250|latin3_to_mic|latin4_to_mic|lead|left|" + + "length|like|like_escape|likejoinsel|likesel|line|line_distance|line_eq|line_horizontal|" + + "line_in|line_interpt|line_intersect|line_out|line_parallel|line_perp|line_recv|" + + "line_send|line_vertical|ln|lo_close|lo_creat|lo_create|lo_export|lo_import|lo_lseek|" + + "lo_open|lo_tell|lo_truncate|lo_unlink|log|loread|lower|lowrite|lpad|lseg|lseg_center|" + + "lseg_distance|lseg_eq|lseg_ge|lseg_gt|lseg_horizontal|lseg_in|lseg_interpt|" + + "lseg_intersect|lseg_le|lseg_length|lseg_lt|lseg_ne|lseg_out|lseg_parallel|lseg_perp|" + + "lseg_recv|lseg_send|lseg_vertical|ltrim|macaddr_cmp|macaddr_eq|macaddr_ge|macaddr_gt|" + + "macaddr_in|macaddr_le|macaddr_lt|macaddr_ne|macaddr_out|macaddr_recv|macaddr_send|" + + "makeaclitem|masklen|max|md5|mic_to_ascii|mic_to_big5|mic_to_euc_cn|mic_to_euc_jp|" + + "mic_to_euc_kr|mic_to_euc_tw|mic_to_iso|mic_to_koi8r|mic_to_latin1|mic_to_latin2|" + + "mic_to_latin3|mic_to_latin4|mic_to_sjis|mic_to_win1250|mic_to_win1251|mic_to_win866|" + + "min|mktinterval|mod|money|mul_d_interval|name|nameeq|namege|namegt|nameiclike|nameicnlike|" + + "nameicregexeq|nameicregexne|namein|namele|namelike|namelt|namene|namenlike|nameout|" + + "namerecv|nameregexeq|nameregexne|namesend|neqjoinsel|neqsel|netmask|network|network_cmp|" + + "network_eq|network_ge|network_gt|network_le|network_lt|network_ne|network_sub|" + + "network_subeq|network_sup|network_supeq|nextval|nlikejoinsel|nlikesel|notlike|now|" + + "npoints|nth_value|ntile|numeric_abs|numeric_accum|numeric_add|numeric_avg|" + + "numeric_avg_accum|numeric_cmp|numeric_div|numeric_div_trunc|numeric_eq|numeric_exp|" + + "numeric_fac|numeric_ge|numeric_gt|numeric_in|numeric_inc|numeric_larger|numeric_le|" + + "numeric_ln|numeric_log|numeric_lt|numeric_mod|numeric_mul|numeric_ne|numeric_out|" + + "numeric_power|numeric_recv|numeric_send|numeric_smaller|numeric_sqrt|" + + "numeric_stddev_pop|numeric_stddev_samp|numeric_sub|numeric_uminus|numeric_uplus|" + + "numeric_var_pop|numeric_var_samp|numerictypmodin|numerictypmodout|numnode|" + + "obj_description|octet_length|oid|oideq|oidge|oidgt|oidin|oidlarger|oidle|oidlt|oidne|oidout|" + + "oidrecv|oidsend|oidsmaller|oidvectoreq|oidvectorge|oidvectorgt|oidvectorin|oidvectorle|" + + "oidvectorlt|oidvectorne|oidvectorout|oidvectorrecv|oidvectorsend|oidvectortypes|on_pb|" + + "on_pl|on_ppath|on_ps|on_sb|on_sl|opaque_in|opaque_out|overlaps|overlay|path|path_add|" + + "path_add_pt|path_center|path_contain_pt|path_distance|path_div_pt|path_in|path_inter|" + + "path_length|path_mul_pt|path_n_eq|path_n_ge|path_n_gt|path_n_le|path_n_lt|path_npoints|" + + "path_out|path_recv|path_send|path_sub_pt|pclose|percent_rank|pg_advisory_lock|" + + "pg_advisory_lock_shared|pg_advisory_unlock|pg_advisory_unlock_all|" + + "pg_advisory_unlock_shared|pg_advisory_xact_lock|pg_advisory_xact_lock_shared|" + + "pg_available_extension_versions|pg_available_extensions|pg_backend_pid|" + + "pg_cancel_backend|pg_char_to_encoding|pg_client_encoding|pg_collation_is_visible|" + + "pg_column_size|pg_conf_load_time|pg_conversion_is_visible|pg_create_restore_point|" + + "pg_current_xlog_insert_location|pg_current_xlog_location|pg_cursor|pg_database_size|" + + "pg_describe_object|pg_encoding_max_length|pg_encoding_to_char|" + + "pg_extension_config_dump|pg_extension_update_paths|pg_function_is_visible|" + + "pg_get_constraintdef|pg_get_expr|pg_get_function_arguments|" + + "pg_get_function_identity_arguments|pg_get_function_result|pg_get_functiondef|" + + "pg_get_indexdef|pg_get_keywords|pg_get_ruledef|pg_get_serial_sequence|" + + "pg_get_triggerdef|pg_get_userbyid|pg_get_viewdef|pg_has_role|pg_indexes_size|" + + "pg_is_in_recovery|pg_is_other_temp_schema|pg_is_xlog_replay_paused|" + + "pg_last_xact_replay_timestamp|pg_last_xlog_receive_location|" + + "pg_last_xlog_replay_location|pg_listening_channels|pg_lock_status|pg_ls_dir|" + + "pg_my_temp_schema|pg_node_tree_in|pg_node_tree_out|pg_node_tree_recv|" + + "pg_node_tree_send|pg_notify|pg_opclass_is_visible|pg_operator_is_visible|" + + "pg_options_to_table|pg_postmaster_start_time|pg_prepared_statement|pg_prepared_xact|" + + "pg_read_binary_file|pg_read_file|pg_relation_filenode|pg_relation_filepath|" + + "pg_relation_size|pg_reload_conf|pg_rotate_logfile|pg_sequence_parameters|" + + "pg_show_all_settings|pg_size_pretty|pg_sleep|pg_start_backup|pg_stat_clear_snapshot|" + + "pg_stat_file|pg_stat_get_activity|pg_stat_get_analyze_count|" + + "pg_stat_get_autoanalyze_count|pg_stat_get_autovacuum_count|" + + "pg_stat_get_backend_activity|pg_stat_get_backend_activity_start|" + + "pg_stat_get_backend_client_addr|pg_stat_get_backend_client_port|" + + "pg_stat_get_backend_dbid|pg_stat_get_backend_idset|pg_stat_get_backend_pid|" + + "pg_stat_get_backend_start|pg_stat_get_backend_userid|pg_stat_get_backend_waiting|" + + "pg_stat_get_backend_xact_start|pg_stat_get_bgwriter_buf_written_checkpoints|" + + "pg_stat_get_bgwriter_buf_written_clean|pg_stat_get_bgwriter_maxwritten_clean|" + + "pg_stat_get_bgwriter_requested_checkpoints|pg_stat_get_bgwriter_stat_reset_time|" + + "pg_stat_get_bgwriter_timed_checkpoints|pg_stat_get_blocks_fetched|" + + "pg_stat_get_blocks_hit|pg_stat_get_buf_alloc|pg_stat_get_buf_fsync_backend|" + + "pg_stat_get_buf_written_backend|pg_stat_get_db_blocks_fetched|" + + "pg_stat_get_db_blocks_hit|pg_stat_get_db_conflict_all|" + + "pg_stat_get_db_conflict_bufferpin|pg_stat_get_db_conflict_lock|" + + "pg_stat_get_db_conflict_snapshot|pg_stat_get_db_conflict_startup_deadlock|" + + "pg_stat_get_db_conflict_tablespace|pg_stat_get_db_numbackends|" + + "pg_stat_get_db_stat_reset_time|pg_stat_get_db_tuples_deleted|" + + "pg_stat_get_db_tuples_fetched|pg_stat_get_db_tuples_inserted|" + + "pg_stat_get_db_tuples_returned|pg_stat_get_db_tuples_updated|" + + "pg_stat_get_db_xact_commit|pg_stat_get_db_xact_rollback|pg_stat_get_dead_tuples|" + + "pg_stat_get_function_calls|pg_stat_get_function_self_time|" + + "pg_stat_get_function_time|pg_stat_get_last_analyze_time|" + + "pg_stat_get_last_autoanalyze_time|pg_stat_get_last_autovacuum_time|" + + "pg_stat_get_last_vacuum_time|pg_stat_get_live_tuples|pg_stat_get_numscans|" + + "pg_stat_get_tuples_deleted|pg_stat_get_tuples_fetched|" + + "pg_stat_get_tuples_hot_updated|pg_stat_get_tuples_inserted|" + + "pg_stat_get_tuples_returned|pg_stat_get_tuples_updated|pg_stat_get_vacuum_count|" + + "pg_stat_get_wal_senders|pg_stat_get_xact_blocks_fetched|" + + "pg_stat_get_xact_blocks_hit|pg_stat_get_xact_function_calls|" + + "pg_stat_get_xact_function_self_time|pg_stat_get_xact_function_time|" + + "pg_stat_get_xact_numscans|pg_stat_get_xact_tuples_deleted|" + + "pg_stat_get_xact_tuples_fetched|pg_stat_get_xact_tuples_hot_updated|" + + "pg_stat_get_xact_tuples_inserted|pg_stat_get_xact_tuples_returned|" + + "pg_stat_get_xact_tuples_updated|pg_stat_reset|pg_stat_reset_shared|" + + "pg_stat_reset_single_function_counters|pg_stat_reset_single_table_counters|" + + "pg_stop_backup|pg_switch_xlog|pg_table_is_visible|pg_table_size|" + + "pg_tablespace_databases|pg_tablespace_size|pg_terminate_backend|pg_timezone_abbrevs|" + + "pg_timezone_names|pg_total_relation_size|pg_try_advisory_lock|" + + "pg_try_advisory_lock_shared|pg_try_advisory_xact_lock|" + + "pg_try_advisory_xact_lock_shared|pg_ts_config_is_visible|pg_ts_dict_is_visible|" + + "pg_ts_parser_is_visible|pg_ts_template_is_visible|pg_type_is_visible|pg_typeof|" + + "pg_xlog_replay_pause|pg_xlog_replay_resume|pg_xlogfile_name|pg_xlogfile_name_offset|" + + "pi|plainto_tsquery|plpgsql_call_handler|plpgsql_inline_handler|plpgsql_validator|" + + "point|point_above|point_add|point_below|point_distance|point_div|point_eq|point_horiz|" + + "point_in|point_left|point_mul|point_ne|point_out|point_recv|point_right|point_send|" + + "point_sub|point_vert|poly_above|poly_below|poly_center|poly_contain|poly_contain_pt|" + + "poly_contained|poly_distance|poly_in|poly_left|poly_npoints|poly_out|poly_overabove|" + + "poly_overbelow|poly_overlap|poly_overleft|poly_overright|poly_recv|poly_right|" + + "poly_same|poly_send|polygon|popen|position|positionjoinsel|positionsel|" + + "postgresql_fdw_validator|pow|power|prsd_end|prsd_headline|prsd_lextype|prsd_nexttoken|" + + "prsd_start|pt_contained_circle|pt_contained_poly|query_to_xml|" + + "query_to_xml_and_xmlschema|query_to_xmlschema|querytree|quote_ident|quote_literal|" + + "quote_nullable|radians|radius|random|rank|record_eq|record_ge|record_gt|record_in|" + + "record_le|record_lt|record_ne|record_out|record_recv|record_send|regclass|regclassin|" + + "regclassout|regclassrecv|regclasssend|regconfigin|regconfigout|regconfigrecv|" + + "regconfigsend|regdictionaryin|regdictionaryout|regdictionaryrecv|regdictionarysend|" + + "regexeqjoinsel|regexeqsel|regexnejoinsel|regexnesel|regexp_matches|regexp_replace|" + + "regexp_split_to_array|regexp_split_to_table|regoperatorin|regoperatorout|" + + "regoperatorrecv|regoperatorsend|regoperin|regoperout|regoperrecv|regopersend|" + + "regprocedurein|regprocedureout|regprocedurerecv|regproceduresend|regprocin|regprocout|" + + "regprocrecv|regprocsend|regr_avgx|regr_avgy|regr_count|regr_intercept|regr_r2|" + + "regr_slope|regr_sxx|regr_sxy|regr_syy|regtypein|regtypeout|regtyperecv|regtypesend|" + + "reltime|reltimeeq|reltimege|reltimegt|reltimein|reltimele|reltimelt|reltimene|reltimeout|" + + "reltimerecv|reltimesend|repeat|replace|reverse|right|round|row_number|rpad|rtrim|" + + "scalargtjoinsel|scalargtsel|scalarltjoinsel|scalarltsel|schema_to_xml|" + + "schema_to_xml_and_xmlschema|schema_to_xmlschema|session_user|set_bit|set_byte|" + + "set_config|set_masklen|setseed|setval|setweight|shell_in|shell_out|" + + "shift_jis_2004_to_euc_jis_2004|shift_jis_2004_to_utf8|shobj_description|sign|" + + "similar_escape|sin|sjis_to_euc_jp|sjis_to_mic|sjis_to_utf8|slope|smgreq|smgrin|smgrne|" + + "smgrout|split_part|sqrt|statement_timestamp|stddev|stddev_pop|stddev_samp|string_agg|" + + "string_agg_finalfn|string_agg_transfn|string_to_array|strip|strpos|substr|substring|sum|" + + "suppress_redundant_updates_trigger|table_to_xml|table_to_xml_and_xmlschema|" + + "table_to_xmlschema|tan|text|text_ge|text_gt|text_larger|text_le|text_lt|text_pattern_ge|" + + "text_pattern_gt|text_pattern_le|text_pattern_lt|text_smaller|textanycat|textcat|texteq|" + + "texticlike|texticnlike|texticregexeq|texticregexne|textin|textlen|textlike|textne|" + + "textnlike|textout|textrecv|textregexeq|textregexne|textsend|thesaurus_init|" + + "thesaurus_lexize|tideq|tidge|tidgt|tidin|tidlarger|tidle|tidlt|tidne|tidout|tidrecv|tidsend|" + + "tidsmaller|time_cmp|time_eq|time_ge|time_gt|time_hash|time_in|time_larger|time_le|time_lt|" + + "time_mi_interval|time_mi_time|time_ne|time_out|time_pl_interval|time_recv|time_send|" + + "time_smaller|timedate_pl|timemi|timenow|timeofday|timepl|timestamp_cmp|" + + "timestamp_cmp_date|timestamp_cmp_timestamptz|timestamp_eq|timestamp_eq_date|" + + "timestamp_eq_timestamptz|timestamp_ge|timestamp_ge_date|timestamp_ge_timestamptz|" + + "timestamp_gt|timestamp_gt_date|timestamp_gt_timestamptz|timestamp_hash|timestamp_in|" + + "timestamp_larger|timestamp_le|timestamp_le_date|timestamp_le_timestamptz|" + + "timestamp_lt|timestamp_lt_date|timestamp_lt_timestamptz|timestamp_mi|" + + "timestamp_mi_interval|timestamp_ne|timestamp_ne_date|timestamp_ne_timestamptz|" + + "timestamp_out|timestamp_pl_interval|timestamp_recv|timestamp_send|timestamp_smaller|" + + "timestamptypmodin|timestamptypmodout|timestamptz_cmp|timestamptz_cmp_date|" + + "timestamptz_cmp_timestamp|timestamptz_eq|timestamptz_eq_date|" + + "timestamptz_eq_timestamp|timestamptz_ge|timestamptz_ge_date|" + + "timestamptz_ge_timestamp|timestamptz_gt|timestamptz_gt_date|" + + "timestamptz_gt_timestamp|timestamptz_in|timestamptz_larger|timestamptz_le|" + + "timestamptz_le_date|timestamptz_le_timestamp|timestamptz_lt|timestamptz_lt_date|" + + "timestamptz_lt_timestamp|timestamptz_mi|timestamptz_mi_interval|timestamptz_ne|" + + "timestamptz_ne_date|timestamptz_ne_timestamp|timestamptz_out|" + + "timestamptz_pl_interval|timestamptz_recv|timestamptz_send|timestamptz_smaller|" + + "timestamptztypmodin|timestamptztypmodout|timetypmodin|timetypmodout|timetz_cmp|" + + "timetz_eq|timetz_ge|timetz_gt|timetz_hash|timetz_in|timetz_larger|timetz_le|timetz_lt|" + + "timetz_mi_interval|timetz_ne|timetz_out|timetz_pl_interval|timetz_recv|timetz_send|" + + "timetz_smaller|timetzdate_pl|timetztypmodin|timetztypmodout|timezone|tinterval|" + + "tintervalct|tintervalend|tintervaleq|tintervalge|tintervalgt|tintervalin|tintervalle|" + + "tintervalleneq|tintervallenge|tintervallengt|tintervallenle|tintervallenlt|" + + "tintervallenne|tintervallt|tintervalne|tintervalout|tintervalov|tintervalrecv|" + + "tintervalrel|tintervalsame|tintervalsend|tintervalstart|to_ascii|to_char|to_date|to_hex|" + + "to_number|to_timestamp|to_tsquery|to_tsvector|transaction_timestamp|translate|" + + "trigger_in|trigger_out|trunc|ts_debug|ts_headline|ts_lexize|ts_match_qv|ts_match_tq|" + + "ts_match_tt|ts_match_vq|ts_parse|ts_rank|ts_rank_cd|ts_rewrite|ts_stat|ts_token_type|" + + "ts_typanalyze|tsmatchjoinsel|tsmatchsel|tsq_mcontained|tsq_mcontains|tsquery_and|" + + "tsquery_cmp|tsquery_eq|tsquery_ge|tsquery_gt|tsquery_le|tsquery_lt|tsquery_ne|" + + "tsquery_not|tsquery_or|tsqueryin|tsqueryout|tsqueryrecv|tsquerysend|tsvector_cmp|" + + "tsvector_concat|tsvector_eq|tsvector_ge|tsvector_gt|tsvector_le|tsvector_lt|" + + "tsvector_ne|tsvector_update_trigger|tsvector_update_trigger_column|tsvectorin|" + + "tsvectorout|tsvectorrecv|tsvectorsend|txid_current|txid_current_snapshot|" + + "txid_snapshot_in|txid_snapshot_out|txid_snapshot_recv|txid_snapshot_send|" + + "txid_snapshot_xip|txid_snapshot_xmax|txid_snapshot_xmin|txid_visible_in_snapshot|" + + "uhc_to_utf8|unique_key_recheck|unknownin|unknownout|unknownrecv|unknownsend|unnest|" + + "upper|utf8_to_ascii|utf8_to_big5|utf8_to_euc_cn|utf8_to_euc_jis_2004|utf8_to_euc_jp|" + + "utf8_to_euc_kr|utf8_to_euc_tw|utf8_to_gb18030|utf8_to_gbk|utf8_to_iso8859|" + + "utf8_to_iso8859_1|utf8_to_johab|utf8_to_koi8r|utf8_to_koi8u|utf8_to_shift_jis_2004|" + + "utf8_to_sjis|utf8_to_uhc|utf8_to_win|uuid_cmp|uuid_eq|uuid_ge|uuid_gt|uuid_hash|uuid_in|" + + "uuid_le|uuid_lt|uuid_ne|uuid_out|uuid_recv|uuid_send|var_pop|var_samp|varbit_in|" + + "varbit_out|varbit_recv|varbit_send|varbitcmp|varbiteq|varbitge|varbitgt|varbitle|" + + "varbitlt|varbitne|varbittypmodin|varbittypmodout|varcharin|varcharout|varcharrecv|" + + "varcharsend|varchartypmodin|varchartypmodout|variance|version|void_in|void_out|" + + "void_recv|void_send|width|width_bucket|win1250_to_latin2|win1250_to_mic|win1251_to_iso|" + + "win1251_to_koi8r|win1251_to_mic|win1251_to_win866|win866_to_iso|win866_to_koi8r|" + + "win866_to_mic|win866_to_win1251|win_to_utf8|xideq|xideqint4|xidin|xidout|xidrecv|xidsend|" + + "xml|xml_in|xml_is_well_formed|xml_is_well_formed_content|xml_is_well_formed_document|" + + "xml_out|xml_recv|xml_send|xmlagg|xmlcomment|xmlconcat2|xmlexists|xmlvalidate|xpath|" + + "xpath_exists" + ); + + var keywordMapper = this.createKeywordMapper({ + "support.function": builtinFunctions, + "keyword": keywords, + }, "identifier", true); + + + var sqlRules = [ + { + token : "string", // single line string -- assume dollar strings if multi-line for now + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "variable.language", // pg identifier + regex : '".*?"' + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_][a-zA-Z0-9_$]*\\b" // TODO - Unicode in identifiers + }, { + token : "keyword.operator", + regex : "!|!!|!~|!~\\*|!~~|!~~\\*|#|##|#<|#<=|#<>|#=|#>|#>=|%|\\&|\\&\\&|\\&<|\\&<\\||\\&>|\\*|\\+|" + + "\\-|/|<|<#>|<\\->|<<|<<=|<<\\||<=|<>|<\\?>|<@|<\\^|=|>|>=|>>|>>=|>\\^|\\?#|\\?\\-|\\?\\-\\||" + + "\\?\\||\\?\\|\\||@|@\\-@|@>|@@|@@@|\\^|\\||\\|\\&>|\\|/|\\|>>|\\|\\||\\|\\|/|~|~\\*|~<=~|~<~|" + + "~=|~>=~|~>~|~~|~~\\*" + }, { + token : "paren.lparen", + regex : "[\\(]" + }, { + token : "paren.rparen", + regex : "[\\)]" + }, { + token : "text", + regex : "\\s+" + } + ]; + + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "--.*$" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi-line comment + merge : true, + regex : "\\/\\*", + next : "comment" + },{ + token : "keyword.statementBegin", + regex : "^[a-zA-Z]+", // Could enumerate starting keywords but this allows things to work when new statements are added. + next : "statement" + },{ + token : "support.buildin", // psql directive + regex : "^\\\\[\\S]+.*$" + } + ], + + "statement" : [ + { + token : "comment", + regex : "--.*$" + }, { + token : "comment", // multi-line comment + merge : true, + regex : "\\/\\*", + next : "commentStatement" + }, { + token : "statementEnd", + regex : ";", + next : "start" + }, { + token : "string", // perl, python, tcl are in the pg default dist (no tcl highlighter) + regex : "\\$perl\\$", + next : "perl-start" + }, { + token : "string", + regex : "\\$python\\$", + next : "python-start" + },{ + token : "string", + regex : "\\$[\\w_0-9]*\\$$", // dollar quote at the end of a line + next : "dollarSql" + }, { + token : "string", + regex : "\\$[\\w_0-9]*\\$", + next : "dollarStatementString" + } + ].concat(sqlRules), + + "dollarSql" : [ + { + token : "comment", + regex : "--.*$" + }, { + token : "comment", // multi-line comment + merge : true, + regex : "\\/\\*", + next : "commentDollarSql" + }, { + token : "string", // end quoting with dollar at the start of a line + regex : "^\\$[\\w_0-9]*\\$", + next : "statement" + }, { + token : "string", + regex : "\\$[\\w_0-9]*\\$", + next : "dollarSqlString" + } + ].concat(sqlRules), + + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + + "commentStatement" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "statement" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + + "commentDollarSql" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "dollarSql" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + + "dollarStatementString" : [ + { + token : "string", // closing dollarstring + regex : ".*?\\$[\\w_0-9]*\\$", + next : "statement" + }, { + token : "string", // dollarstring spanning whole line + merge : true, + regex : ".+" + } + ], + + "dollarSqlString" : [ + { + token : "string", // closing dollarstring + regex : ".*?\\$[\\w_0-9]*\\$", + next : "dollarSql" + }, { + token : "string", // dollarstring spanning whole line + merge : true, + regex : ".+" + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("start") ]); + this.embedRules(PerlHighlightRules, "perl-", [{token : "string", regex : "\\$perl\\$", next : "statement"}]); + this.embedRules(PythonHighlightRules, "python-", [{token : "string", regex : "\\$python\\$", next : "statement"}]); +}; + +oop.inherits(PgsqlHighlightRules, TextHighlightRules); + +exports.PgsqlHighlightRules = PgsqlHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/perl_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var PerlHighlightRules = function() { + + var keywords = ( + "base|constant|continue|else|elsif|for|foreach|format|goto|if|last|local|my|next|" + + "no|package|parent|redo|require|scalar|sub|unless|until|while|use|vars" + ); + + var buildinConstants = ("ARGV|ENV|INC|SIG"); + + var builtinFunctions = ( + "getprotobynumber|getprotobyname|getservbyname|gethostbyaddr|" + + "gethostbyname|getservbyport|getnetbyaddr|getnetbyname|getsockname|" + + "getpeername|setpriority|getprotoent|setprotoent|getpriority|" + + "endprotoent|getservent|setservent|endservent|sethostent|socketpair|" + + "getsockopt|gethostent|endhostent|setsockopt|setnetent|quotemeta|" + + "localtime|prototype|getnetent|endnetent|rewinddir|wantarray|getpwuid|" + + "closedir|getlogin|readlink|endgrent|getgrgid|getgrnam|shmwrite|" + + "shutdown|readline|endpwent|setgrent|readpipe|formline|truncate|" + + "dbmclose|syswrite|setpwent|getpwnam|getgrent|getpwent|ucfirst|sysread|" + + "setpgrp|shmread|sysseek|sysopen|telldir|defined|opendir|connect|" + + "lcfirst|getppid|binmode|syscall|sprintf|getpgrp|readdir|seekdir|" + + "waitpid|reverse|unshift|symlink|dbmopen|semget|msgrcv|rename|listen|" + + "chroot|msgsnd|shmctl|accept|unpack|exists|fileno|shmget|system|" + + "unlink|printf|gmtime|msgctl|semctl|values|rindex|substr|splice|" + + "length|msgget|select|socket|return|caller|delete|alarm|ioctl|index|" + + "undef|lstat|times|srand|chown|fcntl|close|write|umask|rmdir|study|" + + "sleep|chomp|untie|print|utime|mkdir|atan2|split|crypt|flock|chmod|" + + "BEGIN|bless|chdir|semop|shift|reset|link|stat|chop|grep|fork|dump|" + + "join|open|tell|pipe|exit|glob|warn|each|bind|sort|pack|eval|push|" + + "keys|getc|kill|seek|sqrt|send|wait|rand|tied|read|time|exec|recv|" + + "eof|chr|int|ord|exp|pos|pop|sin|log|abs|oct|hex|tie|cos|vec|END|ref|" + + "map|die|uc|lc|do" + ); + + var keywordMapper = this.createKeywordMapper({ + "keyword": keywords, + "constant.language": buildinConstants, + "support.function": builtinFunctions + }, "identifier"); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "#.*$" + }, { + token : "string.regexp", + regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*\\\\$', + next : "qqstring" + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*\\\\$", + next : "qstring" + }, { + token : "constant.numeric", // hex + regex : "0x[0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\.\\.\\.|\\|\\|=|>>=|<<=|<=>|&&=|=>|!~|\\^=|&=|\\|=|\\.=|x=|%=|\\/=|\\*=|\\-=|\\+=|=~|\\*\\*|\\-\\-|\\.\\.|\\|\\||&&|\\+\\+|\\->|!=|==|>=|<=|>>|<<|,|=|\\?\\:|\\^|\\||x|%|\\/|\\*|<|&|\\\\|~|!|>|\\.|\\-|\\+|\\-C|\\-b|\\-S|\\-u|\\-t|\\-p|\\-l|\\-d|\\-f|\\-g|\\-s|\\-z|\\-k|\\-e|\\-O|\\-T|\\-B|\\-M|\\-A|\\-X|\\-W|\\-c|\\-R|\\-o|\\-x|\\-w|\\-r|\\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)" + }, { + token : "lparen", + regex : "[[({]" + }, { + token : "rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "qqstring" : [ + { + token : "string", + regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ], + "qstring" : [ + { + token : "string", + regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ] + }; +}; + +oop.inherits(PerlHighlightRules, TextHighlightRules); + +exports.PerlHighlightRules = PerlHighlightRules; +}); +/* + * TODO: python delimiters + */ + +ace.define('ace/mode/python_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var PythonHighlightRules = function() { + + var keywords = ( + "and|as|assert|break|class|continue|def|del|elif|else|except|exec|" + + "finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|" + + "raise|return|try|while|with|yield" + ); + + var builtinConstants = ( + "True|False|None|NotImplemented|Ellipsis|__debug__" + ); + + var builtinFunctions = ( + "abs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|" + + "eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|" + + "binfile|iter|property|tuple|bool|filter|len|range|type|bytearray|" + + "float|list|raw_input|unichr|callable|format|locals|reduce|unicode|" + + "chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|" + + "cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|" + + "__import__|complex|hash|min|set|apply|delattr|help|next|setattr|" + + "buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern" + ); + + //var futureReserved = ""; + var keywordMapper = this.createKeywordMapper({ + "invalid.deprecated": "debugger", + "support.function": builtinFunctions, + //"invalid.illegal": futureReserved, + "constant.language": builtinConstants, + "keyword": keywords + }, "identifier"); + + var strPre = "(?:r|u|ur|R|U|UR|Ur|uR)?"; + + var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))"; + var octInteger = "(?:0[oO]?[0-7]+)"; + var hexInteger = "(?:0[xX][\\dA-Fa-f]+)"; + var binInteger = "(?:0[bB][01]+)"; + var integer = "(?:" + decimalInteger + "|" + octInteger + "|" + hexInteger + "|" + binInteger + ")"; + + var exponent = "(?:[eE][+-]?\\d+)"; + var fraction = "(?:\\.\\d+)"; + var intPart = "(?:\\d+)"; + var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))"; + var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + exponent + ")"; + var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")"; + + this.$rules = { + "start" : [ { + token : "comment", + regex : "#.*$" + }, { + token : "string", // """ string + regex : strPre + '"{3}(?:[^\\\\]|\\\\.)*?"{3}' + }, { + token : "string", // multi line """ string start + merge : true, + regex : strPre + '"{3}.*$', + next : "qqstring" + }, { + token : "string", // " string + regex : strPre + '"(?:[^\\\\]|\\\\.)*?"' + }, { + token : "string", // ''' string + regex : strPre + "'{3}(?:[^\\\\]|\\\\.)*?'{3}" + }, { + token : "string", // multi line ''' string start + merge : true, + regex : strPre + "'{3}.*$", + next : "qstring" + }, { + token : "string", // ' string + regex : strPre + "'(?:[^\\\\]|\\\\.)*?'" + }, { + token : "constant.numeric", // imaginary + regex : "(?:" + floatNumber + "|\\d+)[jJ]\\b" + }, { + token : "constant.numeric", // float + regex : floatNumber + }, { + token : "constant.numeric", // long integer + regex : integer + "[lL]\\b" + }, { + token : "constant.numeric", // integer + regex : integer + "\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|=" + }, { + token : "paren.lparen", + regex : "[\\[\\(\\{]" + }, { + token : "paren.rparen", + regex : "[\\]\\)\\}]" + }, { + token : "text", + regex : "\\s+" + } ], + "qqstring" : [ { + token : "string", // multi line """ string end + regex : '(?:[^\\\\]|\\\\.)*?"{3}', + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring" : [ { + token : "string", // multi line ''' string end + regex : "(?:[^\\\\]|\\\\.)*?'{3}", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ] + }; +}; + +oop.inherits(PythonHighlightRules, TextHighlightRules); + +exports.PythonHighlightRules = PythonHighlightRules; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-php.js b/vendor/assets/javascripts/ace-src-noconflict/mode-php.js new file mode 100644 index 00000000..d3deefc6 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-php.js @@ -0,0 +1,2359 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/php', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/php_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var PhpHighlightRules = require("./php_highlight_rules").PhpHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new PhpHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)#/; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "#"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[\:]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/php_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules', 'ace/mode/html_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; + +var PhpLangHighlightRules = function() { + var docComment = DocCommentHighlightRules; + // http://php.net/quickref.php + var builtinFunctions = lang.arrayToMap( + ('abs|acos|acosh|addcslashes|addslashes|aggregate|aggregate_info|aggregate_methods|aggregate_methods_by_list|aggregate_methods_by_regexp|' + + 'aggregate_properties|aggregate_properties_by_list|aggregate_properties_by_regexp|aggregation_info|amqpconnection|amqpexchange|amqpqueue|' + + 'apache_child_terminate|apache_get_modules|apache_get_version|apache_getenv|apache_lookup_uri|apache_note|apache_request_headers|' + + 'apache_reset_timeout|apache_response_headers|apache_setenv|apc_add|apc_bin_dump|apc_bin_dumpfile|apc_bin_load|apc_bin_loadfile|' + + 'apc_cache_info|apc_cas|apc_clear_cache|apc_compile_file|apc_dec|apc_define_constants|apc_delete|apc_delete_file|apc_exists|apc_fetch|' + + 'apc_inc|apc_load_constants|apc_sma_info|apc_store|apciterator|apd_breakpoint|apd_callstack|apd_clunk|apd_continue|apd_croak|' + + 'apd_dump_function_table|apd_dump_persistent_resources|apd_dump_regular_resources|apd_echo|apd_get_active_symbols|apd_set_pprof_trace|' + + 'apd_set_session|apd_set_session_trace|apd_set_session_trace_socket|appenditerator|array|array_change_key_case|array_chunk|array_combine|' + + 'array_count_values|array_diff|array_diff_assoc|array_diff_key|array_diff_uassoc|array_diff_ukey|array_fill|array_fill_keys|array_filter|' + + 'array_flip|array_intersect|array_intersect_assoc|array_intersect_key|array_intersect_uassoc|array_intersect_ukey|array_key_exists|' + + 'array_keys|array_map|array_merge|array_merge_recursive|array_multisort|array_pad|array_pop|array_product|array_push|array_rand|' + + 'array_reduce|array_replace|array_replace_recursive|array_reverse|array_search|array_shift|array_slice|array_splice|array_sum|array_udiff|' + + 'array_udiff_assoc|array_udiff_uassoc|array_uintersect|array_uintersect_assoc|array_uintersect_uassoc|array_unique|array_unshift|' + + 'array_values|array_walk|array_walk_recursive|arrayaccess|arrayiterator|arrayobject|arsort|asin|asinh|asort|assert|assert_options|atan|' + + 'atan2|atanh|audioproperties|badfunctioncallexception|badmethodcallexception|base64_decode|base64_encode|base_convert|basename|' + + 'bbcode_add_element|bbcode_add_smiley|bbcode_create|bbcode_destroy|bbcode_parse|bbcode_set_arg_parser|bbcode_set_flags|bcadd|bccomp|bcdiv|' + + 'bcmod|bcmul|bcompiler_load|bcompiler_load_exe|bcompiler_parse_class|bcompiler_read|bcompiler_write_class|bcompiler_write_constant|' + + 'bcompiler_write_exe_footer|bcompiler_write_file|bcompiler_write_footer|bcompiler_write_function|bcompiler_write_functions_from_file|' + + 'bcompiler_write_header|bcompiler_write_included_filename|bcpow|bcpowmod|bcscale|bcsqrt|bcsub|bin2hex|bind_textdomain_codeset|bindec|' + + 'bindtextdomain|bson_decode|bson_encode|bumpValue|bzclose|bzcompress|bzdecompress|bzerrno|bzerror|bzerrstr|bzflush|bzopen|bzread|bzwrite|' + + 'cachingiterator|cairo|cairo_create|cairo_font_face_get_type|cairo_font_face_status|cairo_font_options_create|cairo_font_options_equal|' + + 'cairo_font_options_get_antialias|cairo_font_options_get_hint_metrics|cairo_font_options_get_hint_style|' + + 'cairo_font_options_get_subpixel_order|cairo_font_options_hash|cairo_font_options_merge|cairo_font_options_set_antialias|' + + 'cairo_font_options_set_hint_metrics|cairo_font_options_set_hint_style|cairo_font_options_set_subpixel_order|cairo_font_options_status|' + + 'cairo_format_stride_for_width|cairo_image_surface_create|cairo_image_surface_create_for_data|cairo_image_surface_create_from_png|' + + 'cairo_image_surface_get_data|cairo_image_surface_get_format|cairo_image_surface_get_height|cairo_image_surface_get_stride|' + + 'cairo_image_surface_get_width|cairo_matrix_create_scale|cairo_matrix_create_translate|cairo_matrix_invert|cairo_matrix_multiply|' + + 'cairo_matrix_rotate|cairo_matrix_transform_distance|cairo_matrix_transform_point|cairo_matrix_translate|cairo_pattern_add_color_stop_rgb|' + + 'cairo_pattern_add_color_stop_rgba|cairo_pattern_create_for_surface|cairo_pattern_create_linear|cairo_pattern_create_radial|' + + 'cairo_pattern_create_rgb|cairo_pattern_create_rgba|cairo_pattern_get_color_stop_count|cairo_pattern_get_color_stop_rgba|' + + 'cairo_pattern_get_extend|cairo_pattern_get_filter|cairo_pattern_get_linear_points|cairo_pattern_get_matrix|' + + 'cairo_pattern_get_radial_circles|cairo_pattern_get_rgba|cairo_pattern_get_surface|cairo_pattern_get_type|cairo_pattern_set_extend|' + + 'cairo_pattern_set_filter|cairo_pattern_set_matrix|cairo_pattern_status|cairo_pdf_surface_create|cairo_pdf_surface_set_size|' + + 'cairo_ps_get_levels|cairo_ps_level_to_string|cairo_ps_surface_create|cairo_ps_surface_dsc_begin_page_setup|' + + 'cairo_ps_surface_dsc_begin_setup|cairo_ps_surface_dsc_comment|cairo_ps_surface_get_eps|cairo_ps_surface_restrict_to_level|' + + 'cairo_ps_surface_set_eps|cairo_ps_surface_set_size|cairo_scaled_font_create|cairo_scaled_font_extents|cairo_scaled_font_get_ctm|' + + 'cairo_scaled_font_get_font_face|cairo_scaled_font_get_font_matrix|cairo_scaled_font_get_font_options|cairo_scaled_font_get_scale_matrix|' + + 'cairo_scaled_font_get_type|cairo_scaled_font_glyph_extents|cairo_scaled_font_status|cairo_scaled_font_text_extents|' + + 'cairo_surface_copy_page|cairo_surface_create_similar|cairo_surface_finish|cairo_surface_flush|cairo_surface_get_content|' + + 'cairo_surface_get_device_offset|cairo_surface_get_font_options|cairo_surface_get_type|cairo_surface_mark_dirty|' + + 'cairo_surface_mark_dirty_rectangle|cairo_surface_set_device_offset|cairo_surface_set_fallback_resolution|cairo_surface_show_page|' + + 'cairo_surface_status|cairo_surface_write_to_png|cairo_svg_surface_create|cairo_svg_surface_restrict_to_version|' + + 'cairo_svg_version_to_string|cairoantialias|cairocontent|cairocontext|cairoexception|cairoextend|cairofillrule|cairofilter|cairofontface|' + + 'cairofontoptions|cairofontslant|cairofonttype|cairofontweight|cairoformat|cairogradientpattern|cairohintmetrics|cairohintstyle|' + + 'cairoimagesurface|cairolineargradient|cairolinecap|cairolinejoin|cairomatrix|cairooperator|cairopath|cairopattern|cairopatterntype|' + + 'cairopdfsurface|cairopslevel|cairopssurface|cairoradialgradient|cairoscaledfont|cairosolidpattern|cairostatus|cairosubpixelorder|' + + 'cairosurface|cairosurfacepattern|cairosurfacetype|cairosvgsurface|cairosvgversion|cairotoyfontface|cal_days_in_month|cal_from_jd|cal_info|' + + 'cal_to_jd|calcul_hmac|calculhmac|call_user_func|call_user_func_array|call_user_method|call_user_method_array|callbackfilteriterator|ceil|' + + 'chdb|chdb_create|chdir|checkdate|checkdnsrr|chgrp|chmod|chop|chown|chr|chroot|chunk_split|class_alias|class_exists|class_implements|' + + 'class_parents|classkit_import|classkit_method_add|classkit_method_copy|classkit_method_redefine|classkit_method_remove|' + + 'classkit_method_rename|clearstatcache|clone|closedir|closelog|collator|com|com_addref|com_create_guid|com_event_sink|com_get|' + + 'com_get_active_object|com_invoke|com_isenum|com_load|com_load_typelib|com_message_pump|com_print_typeinfo|com_propget|com_propput|' + + 'com_propset|com_release|com_set|compact|connection_aborted|connection_status|connection_timeout|constant|construct|construct|construct|' + + 'convert_cyr_string|convert_uudecode|convert_uuencode|copy|cos|cosh|count|count_chars|countable|counter_bump|counter_bump_value|' + + 'counter_create|counter_get|counter_get_meta|counter_get_named|counter_get_value|counter_reset|counter_reset_value|crack_check|' + + 'crack_closedict|crack_getlastmessage|crack_opendict|crc32|create_function|crypt|ctype_alnum|ctype_alpha|ctype_cntrl|ctype_digit|' + + 'ctype_graph|ctype_lower|ctype_print|ctype_punct|ctype_space|ctype_upper|ctype_xdigit|cubrid_affected_rows|cubrid_bind|' + + 'cubrid_client_encoding|cubrid_close|cubrid_close_prepare|cubrid_close_request|cubrid_col_get|cubrid_col_size|cubrid_column_names|' + + 'cubrid_column_types|cubrid_commit|cubrid_connect|cubrid_connect_with_url|cubrid_current_oid|cubrid_data_seek|cubrid_db_name|' + + 'cubrid_disconnect|cubrid_drop|cubrid_errno|cubrid_error|cubrid_error_code|cubrid_error_code_facility|cubrid_error_msg|cubrid_execute|' + + 'cubrid_fetch|cubrid_fetch_array|cubrid_fetch_assoc|cubrid_fetch_field|cubrid_fetch_lengths|cubrid_fetch_object|cubrid_fetch_row|' + + 'cubrid_field_flags|cubrid_field_len|cubrid_field_name|cubrid_field_seek|cubrid_field_table|cubrid_field_type|cubrid_free_result|' + + 'cubrid_get|cubrid_get_autocommit|cubrid_get_charset|cubrid_get_class_name|cubrid_get_client_info|cubrid_get_db_parameter|' + + 'cubrid_get_server_info|cubrid_insert_id|cubrid_is_instance|cubrid_list_dbs|cubrid_load_from_glo|cubrid_lob_close|cubrid_lob_export|' + + 'cubrid_lob_get|cubrid_lob_send|cubrid_lob_size|cubrid_lock_read|cubrid_lock_write|cubrid_move_cursor|cubrid_new_glo|cubrid_next_result|' + + 'cubrid_num_cols|cubrid_num_fields|cubrid_num_rows|cubrid_ping|cubrid_prepare|cubrid_put|cubrid_query|cubrid_real_escape_string|' + + 'cubrid_result|cubrid_rollback|cubrid_save_to_glo|cubrid_schema|cubrid_send_glo|cubrid_seq_drop|cubrid_seq_insert|cubrid_seq_put|' + + 'cubrid_set_add|cubrid_set_autocommit|cubrid_set_db_parameter|cubrid_set_drop|cubrid_unbuffered_query|cubrid_version|curl_close|' + + 'curl_copy_handle|curl_errno|curl_error|curl_exec|curl_getinfo|curl_init|curl_multi_add_handle|curl_multi_close|curl_multi_exec|' + + 'curl_multi_getcontent|curl_multi_info_read|curl_multi_init|curl_multi_remove_handle|curl_multi_select|curl_setopt|curl_setopt_array|' + + 'curl_version|current|cyrus_authenticate|cyrus_bind|cyrus_close|cyrus_connect|cyrus_query|cyrus_unbind|date|date_add|date_create|' + + 'date_create_from_format|date_date_set|date_default_timezone_get|date_default_timezone_set|date_diff|date_format|date_get_last_errors|' + + 'date_interval_create_from_date_string|date_interval_format|date_isodate_set|date_modify|date_offset_get|date_parse|date_parse_from_format|' + + 'date_sub|date_sun_info|date_sunrise|date_sunset|date_time_set|date_timestamp_get|date_timestamp_set|date_timezone_get|date_timezone_set|' + + 'dateinterval|dateperiod|datetime|datetimezone|db2_autocommit|db2_bind_param|db2_client_info|db2_close|db2_column_privileges|db2_columns|' + + 'db2_commit|db2_conn_error|db2_conn_errormsg|db2_connect|db2_cursor_type|db2_escape_string|db2_exec|db2_execute|db2_fetch_array|' + + 'db2_fetch_assoc|db2_fetch_both|db2_fetch_object|db2_fetch_row|db2_field_display_size|db2_field_name|db2_field_num|db2_field_precision|' + + 'db2_field_scale|db2_field_type|db2_field_width|db2_foreign_keys|db2_free_result|db2_free_stmt|db2_get_option|db2_last_insert_id|' + + 'db2_lob_read|db2_next_result|db2_num_fields|db2_num_rows|db2_pclose|db2_pconnect|db2_prepare|db2_primary_keys|db2_procedure_columns|' + + 'db2_procedures|db2_result|db2_rollback|db2_server_info|db2_set_option|db2_special_columns|db2_statistics|db2_stmt_error|db2_stmt_errormsg|' + + 'db2_table_privileges|db2_tables|dba_close|dba_delete|dba_exists|dba_fetch|dba_firstkey|dba_handlers|dba_insert|dba_key_split|dba_list|' + + 'dba_nextkey|dba_open|dba_optimize|dba_popen|dba_replace|dba_sync|dbase_add_record|dbase_close|dbase_create|dbase_delete_record|' + + 'dbase_get_header_info|dbase_get_record|dbase_get_record_with_names|dbase_numfields|dbase_numrecords|dbase_open|dbase_pack|' + + 'dbase_replace_record|dbplus_add|dbplus_aql|dbplus_chdir|dbplus_close|dbplus_curr|dbplus_errcode|dbplus_errno|dbplus_find|dbplus_first|' + + 'dbplus_flush|dbplus_freealllocks|dbplus_freelock|dbplus_freerlocks|dbplus_getlock|dbplus_getunique|dbplus_info|dbplus_last|dbplus_lockrel|' + + 'dbplus_next|dbplus_open|dbplus_prev|dbplus_rchperm|dbplus_rcreate|dbplus_rcrtexact|dbplus_rcrtlike|dbplus_resolve|dbplus_restorepos|' + + 'dbplus_rkeys|dbplus_ropen|dbplus_rquery|dbplus_rrename|dbplus_rsecindex|dbplus_runlink|dbplus_rzap|dbplus_savepos|dbplus_setindex|' + + 'dbplus_setindexbynumber|dbplus_sql|dbplus_tcl|dbplus_tremove|dbplus_undo|dbplus_undoprepare|dbplus_unlockrel|dbplus_unselect|' + + 'dbplus_update|dbplus_xlockrel|dbplus_xunlockrel|dbx_close|dbx_compare|dbx_connect|dbx_error|dbx_escape_string|dbx_fetch_row|dbx_query|' + + 'dbx_sort|dcgettext|dcngettext|deaggregate|debug_backtrace|debug_print_backtrace|debug_zval_dump|decbin|dechex|decoct|define|' + + 'define_syslog_variables|defined|deg2rad|delete|dgettext|die|dio_close|dio_fcntl|dio_open|dio_read|dio_seek|dio_stat|dio_tcsetattr|' + + 'dio_truncate|dio_write|dir|directoryiterator|dirname|disk_free_space|disk_total_space|diskfreespace|dl|dngettext|dns_check_record|' + + 'dns_get_mx|dns_get_record|dom_import_simplexml|domainexception|domattr|domattribute_name|domattribute_set_value|domattribute_specified|' + + 'domattribute_value|domcharacterdata|domcomment|domdocument|domdocument_add_root|domdocument_create_attribute|' + + 'domdocument_create_cdata_section|domdocument_create_comment|domdocument_create_element|domdocument_create_element_ns|' + + 'domdocument_create_entity_reference|domdocument_create_processing_instruction|domdocument_create_text_node|domdocument_doctype|' + + 'domdocument_document_element|domdocument_dump_file|domdocument_dump_mem|domdocument_get_element_by_id|domdocument_get_elements_by_tagname|' + + 'domdocument_html_dump_mem|domdocument_xinclude|domdocumentfragment|domdocumenttype|domdocumenttype_entities|' + + 'domdocumenttype_internal_subset|domdocumenttype_name|domdocumenttype_notations|domdocumenttype_public_id|domdocumenttype_system_id|' + + 'domelement|domelement_get_attribute|domelement_get_attribute_node|domelement_get_elements_by_tagname|domelement_has_attribute|' + + 'domelement_remove_attribute|domelement_set_attribute|domelement_set_attribute_node|domelement_tagname|domentity|domentityreference|' + + 'domexception|domimplementation|domnamednodemap|domnode|domnode_add_namespace|domnode_append_child|domnode_append_sibling|' + + 'domnode_attributes|domnode_child_nodes|domnode_clone_node|domnode_dump_node|domnode_first_child|domnode_get_content|' + + 'domnode_has_attributes|domnode_has_child_nodes|domnode_insert_before|domnode_is_blank_node|domnode_last_child|domnode_next_sibling|' + + 'domnode_node_name|domnode_node_type|domnode_node_value|domnode_owner_document|domnode_parent_node|domnode_prefix|domnode_previous_sibling|' + + 'domnode_remove_child|domnode_replace_child|domnode_replace_node|domnode_set_content|domnode_set_name|domnode_set_namespace|' + + 'domnode_unlink_node|domnodelist|domnotation|domprocessinginstruction|domprocessinginstruction_data|domprocessinginstruction_target|' + + 'domtext|domxml_new_doc|domxml_open_file|domxml_open_mem|domxml_version|domxml_xmltree|domxml_xslt_stylesheet|domxml_xslt_stylesheet_doc|' + + 'domxml_xslt_stylesheet_file|domxml_xslt_version|domxpath|domxsltstylesheet_process|domxsltstylesheet_result_dump_file|' + + 'domxsltstylesheet_result_dump_mem|dotnet|dotnet_load|doubleval|each|easter_date|easter_days|echo|empty|emptyiterator|' + + 'enchant_broker_describe|enchant_broker_dict_exists|enchant_broker_free|enchant_broker_free_dict|enchant_broker_get_error|' + + 'enchant_broker_init|enchant_broker_list_dicts|enchant_broker_request_dict|enchant_broker_request_pwl_dict|enchant_broker_set_ordering|' + + 'enchant_dict_add_to_personal|enchant_dict_add_to_session|enchant_dict_check|enchant_dict_describe|enchant_dict_get_error|' + + 'enchant_dict_is_in_session|enchant_dict_quick_check|enchant_dict_store_replacement|enchant_dict_suggest|end|ereg|ereg_replace|eregi|' + + 'eregi_replace|error_get_last|error_log|error_reporting|errorexception|escapeshellarg|escapeshellcmd|eval|event_add|event_base_free|' + + 'event_base_loop|event_base_loopbreak|event_base_loopexit|event_base_new|event_base_priority_init|event_base_set|event_buffer_base_set|' + + 'event_buffer_disable|event_buffer_enable|event_buffer_fd_set|event_buffer_free|event_buffer_new|event_buffer_priority_set|' + + 'event_buffer_read|event_buffer_set_callback|event_buffer_timeout_set|event_buffer_watermark_set|event_buffer_write|event_del|event_free|' + + 'event_new|event_set|exception|exec|exif_imagetype|exif_read_data|exif_tagname|exif_thumbnail|exit|exp|expect_expectl|expect_popen|explode|' + + 'expm1|export|export|extension_loaded|extract|ezmlm_hash|fam_cancel_monitor|fam_close|fam_monitor_collection|fam_monitor_directory|' + + 'fam_monitor_file|fam_next_event|fam_open|fam_pending|fam_resume_monitor|fam_suspend_monitor|fbsql_affected_rows|fbsql_autocommit|' + + 'fbsql_blob_size|fbsql_change_user|fbsql_clob_size|fbsql_close|fbsql_commit|fbsql_connect|fbsql_create_blob|fbsql_create_clob|' + + 'fbsql_create_db|fbsql_data_seek|fbsql_database|fbsql_database_password|fbsql_db_query|fbsql_db_status|fbsql_drop_db|fbsql_errno|' + + 'fbsql_error|fbsql_fetch_array|fbsql_fetch_assoc|fbsql_fetch_field|fbsql_fetch_lengths|fbsql_fetch_object|fbsql_fetch_row|' + + 'fbsql_field_flags|fbsql_field_len|fbsql_field_name|fbsql_field_seek|fbsql_field_table|fbsql_field_type|fbsql_free_result|' + + 'fbsql_get_autostart_info|fbsql_hostname|fbsql_insert_id|fbsql_list_dbs|fbsql_list_fields|fbsql_list_tables|fbsql_next_result|' + + 'fbsql_num_fields|fbsql_num_rows|fbsql_password|fbsql_pconnect|fbsql_query|fbsql_read_blob|fbsql_read_clob|fbsql_result|fbsql_rollback|' + + 'fbsql_rows_fetched|fbsql_select_db|fbsql_set_characterset|fbsql_set_lob_mode|fbsql_set_password|fbsql_set_transaction|fbsql_start_db|' + + 'fbsql_stop_db|fbsql_table_name|fbsql_tablename|fbsql_username|fbsql_warnings|fclose|fdf_add_doc_javascript|fdf_add_template|fdf_close|' + + 'fdf_create|fdf_enum_values|fdf_errno|fdf_error|fdf_get_ap|fdf_get_attachment|fdf_get_encoding|fdf_get_file|fdf_get_flags|fdf_get_opt|' + + 'fdf_get_status|fdf_get_value|fdf_get_version|fdf_header|fdf_next_field_name|fdf_open|fdf_open_string|fdf_remove_item|fdf_save|' + + 'fdf_save_string|fdf_set_ap|fdf_set_encoding|fdf_set_file|fdf_set_flags|fdf_set_javascript_action|fdf_set_on_import_javascript|fdf_set_opt|' + + 'fdf_set_status|fdf_set_submit_form_action|fdf_set_target_frame|fdf_set_value|fdf_set_version|feof|fflush|fgetc|fgetcsv|fgets|fgetss|file|' + + 'file_exists|file_get_contents|file_put_contents|fileatime|filectime|filegroup|fileinode|filemtime|fileowner|fileperms|filepro|' + + 'filepro_fieldcount|filepro_fieldname|filepro_fieldtype|filepro_fieldwidth|filepro_retrieve|filepro_rowcount|filesize|filesystemiterator|' + + 'filetype|filter_has_var|filter_id|filter_input|filter_input_array|filter_list|filter_var|filter_var_array|filteriterator|finfo_buffer|' + + 'finfo_close|finfo_file|finfo_open|finfo_set_flags|floatval|flock|floor|flush|fmod|fnmatch|fopen|forward_static_call|' + + 'forward_static_call_array|fpassthru|fprintf|fputcsv|fputs|fread|frenchtojd|fribidi_log2vis|fscanf|fseek|fsockopen|fstat|ftell|ftok|' + + 'ftp_alloc|ftp_cdup|ftp_chdir|ftp_chmod|ftp_close|ftp_connect|ftp_delete|ftp_exec|ftp_fget|ftp_fput|ftp_get|ftp_get_option|ftp_login|' + + 'ftp_mdtm|ftp_mkdir|ftp_nb_continue|ftp_nb_fget|ftp_nb_fput|ftp_nb_get|ftp_nb_put|ftp_nlist|ftp_pasv|ftp_put|ftp_pwd|ftp_quit|ftp_raw|' + + 'ftp_rawlist|ftp_rename|ftp_rmdir|ftp_set_option|ftp_site|ftp_size|ftp_ssl_connect|ftp_systype|ftruncate|func_get_arg|func_get_args|' + + 'func_num_args|function_exists|fwrite|gc_collect_cycles|gc_disable|gc_enable|gc_enabled|gd_info|gearmanclient|gearmanjob|gearmantask|' + + 'gearmanworker|geoip_continent_code_by_name|geoip_country_code3_by_name|geoip_country_code_by_name|geoip_country_name_by_name|' + + 'geoip_database_info|geoip_db_avail|geoip_db_filename|geoip_db_get_all_info|geoip_id_by_name|geoip_isp_by_name|geoip_org_by_name|' + + 'geoip_record_by_name|geoip_region_by_name|geoip_region_name_by_code|geoip_time_zone_by_country_and_region|getMeta|getNamed|getValue|' + + 'get_browser|get_called_class|get_cfg_var|get_class|get_class_methods|get_class_vars|get_current_user|get_declared_classes|' + + 'get_declared_interfaces|get_defined_constants|get_defined_functions|get_defined_vars|get_extension_funcs|get_headers|' + + 'get_html_translation_table|get_include_path|get_included_files|get_loaded_extensions|get_magic_quotes_gpc|get_magic_quotes_runtime|' + + 'get_meta_tags|get_object_vars|get_parent_class|get_required_files|get_resource_type|getallheaders|getconstant|getconstants|getconstructor|' + + 'getcwd|getdate|getdefaultproperties|getdoccomment|getendline|getenv|getextension|getextensionname|getfilename|gethostbyaddr|gethostbyname|' + + 'gethostbynamel|gethostname|getimagesize|getinterfacenames|getinterfaces|getlastmod|getmethod|getmethods|getmodifiers|getmxrr|getmygid|' + + 'getmyinode|getmypid|getmyuid|getname|getnamespacename|getopt|getparentclass|getproperties|getproperty|getprotobyname|getprotobynumber|' + + 'getrandmax|getrusage|getservbyname|getservbyport|getshortname|getstartline|getstaticproperties|getstaticpropertyvalue|gettext|' + + 'gettimeofday|gettype|glob|globiterator|gmagick|gmagickdraw|gmagickpixel|gmdate|gmmktime|gmp_abs|gmp_add|gmp_and|gmp_clrbit|gmp_cmp|' + + 'gmp_com|gmp_div|gmp_div_q|gmp_div_qr|gmp_div_r|gmp_divexact|gmp_fact|gmp_gcd|gmp_gcdext|gmp_hamdist|gmp_init|gmp_intval|gmp_invert|' + + 'gmp_jacobi|gmp_legendre|gmp_mod|gmp_mul|gmp_neg|gmp_nextprime|gmp_or|gmp_perfect_square|gmp_popcount|gmp_pow|gmp_powm|gmp_prob_prime|' + + 'gmp_random|gmp_scan0|gmp_scan1|gmp_setbit|gmp_sign|gmp_sqrt|gmp_sqrtrem|gmp_strval|gmp_sub|gmp_testbit|gmp_xor|gmstrftime|' + + 'gnupg_adddecryptkey|gnupg_addencryptkey|gnupg_addsignkey|gnupg_cleardecryptkeys|gnupg_clearencryptkeys|gnupg_clearsignkeys|gnupg_decrypt|' + + 'gnupg_decryptverify|gnupg_encrypt|gnupg_encryptsign|gnupg_export|gnupg_geterror|gnupg_getprotocol|gnupg_import|gnupg_init|gnupg_keyinfo|' + + 'gnupg_setarmor|gnupg_seterrormode|gnupg_setsignmode|gnupg_sign|gnupg_verify|gopher_parsedir|grapheme_extract|grapheme_stripos|' + + 'grapheme_stristr|grapheme_strlen|grapheme_strpos|grapheme_strripos|grapheme_strrpos|grapheme_strstr|grapheme_substr|gregoriantojd|' + + 'gupnp_context_get_host_ip|gupnp_context_get_port|gupnp_context_get_subscription_timeout|gupnp_context_host_path|gupnp_context_new|' + + 'gupnp_context_set_subscription_timeout|gupnp_context_timeout_add|gupnp_context_unhost_path|gupnp_control_point_browse_start|' + + 'gupnp_control_point_browse_stop|gupnp_control_point_callback_set|gupnp_control_point_new|gupnp_device_action_callback_set|' + + 'gupnp_device_info_get|gupnp_device_info_get_service|gupnp_root_device_get_available|gupnp_root_device_get_relative_location|' + + 'gupnp_root_device_new|gupnp_root_device_set_available|gupnp_root_device_start|gupnp_root_device_stop|gupnp_service_action_get|' + + 'gupnp_service_action_return|gupnp_service_action_return_error|gupnp_service_action_set|gupnp_service_freeze_notify|gupnp_service_info_get|' + + 'gupnp_service_info_get_introspection|gupnp_service_introspection_get_state_variable|gupnp_service_notify|gupnp_service_proxy_action_get|' + + 'gupnp_service_proxy_action_set|gupnp_service_proxy_add_notify|gupnp_service_proxy_callback_set|gupnp_service_proxy_get_subscribed|' + + 'gupnp_service_proxy_remove_notify|gupnp_service_proxy_set_subscribed|gupnp_service_thaw_notify|gzclose|gzcompress|gzdecode|gzdeflate|' + + 'gzencode|gzeof|gzfile|gzgetc|gzgets|gzgetss|gzinflate|gzopen|gzpassthru|gzputs|gzread|gzrewind|gzseek|gztell|gzuncompress|gzwrite|' + + 'halt_compiler|haruannotation|haruannotation_setborderstyle|haruannotation_sethighlightmode|haruannotation_seticon|' + + 'haruannotation_setopened|harudestination|harudestination_setfit|harudestination_setfitb|harudestination_setfitbh|harudestination_setfitbv|' + + 'harudestination_setfith|harudestination_setfitr|harudestination_setfitv|harudestination_setxyz|harudoc|harudoc_addpage|' + + 'harudoc_addpagelabel|harudoc_construct|harudoc_createoutline|harudoc_getcurrentencoder|harudoc_getcurrentpage|harudoc_getencoder|' + + 'harudoc_getfont|harudoc_getinfoattr|harudoc_getpagelayout|harudoc_getpagemode|harudoc_getstreamsize|harudoc_insertpage|harudoc_loadjpeg|' + + 'harudoc_loadpng|harudoc_loadraw|harudoc_loadttc|harudoc_loadttf|harudoc_loadtype1|harudoc_output|harudoc_readfromstream|' + + 'harudoc_reseterror|harudoc_resetstream|harudoc_save|harudoc_savetostream|harudoc_setcompressionmode|harudoc_setcurrentencoder|' + + 'harudoc_setencryptionmode|harudoc_setinfoattr|harudoc_setinfodateattr|harudoc_setopenaction|harudoc_setpagelayout|harudoc_setpagemode|' + + 'harudoc_setpagesconfiguration|harudoc_setpassword|harudoc_setpermission|harudoc_usecnsencodings|harudoc_usecnsfonts|' + + 'harudoc_usecntencodings|harudoc_usecntfonts|harudoc_usejpencodings|harudoc_usejpfonts|harudoc_usekrencodings|harudoc_usekrfonts|' + + 'haruencoder|haruencoder_getbytetype|haruencoder_gettype|haruencoder_getunicode|haruencoder_getwritingmode|haruexception|harufont|' + + 'harufont_getascent|harufont_getcapheight|harufont_getdescent|harufont_getencodingname|harufont_getfontname|harufont_gettextwidth|' + + 'harufont_getunicodewidth|harufont_getxheight|harufont_measuretext|haruimage|haruimage_getbitspercomponent|haruimage_getcolorspace|' + + 'haruimage_getheight|haruimage_getsize|haruimage_getwidth|haruimage_setcolormask|haruimage_setmaskimage|haruoutline|' + + 'haruoutline_setdestination|haruoutline_setopened|harupage|harupage_arc|harupage_begintext|harupage_circle|harupage_closepath|' + + 'harupage_concat|harupage_createdestination|harupage_createlinkannotation|harupage_createtextannotation|harupage_createurlannotation|' + + 'harupage_curveto|harupage_curveto2|harupage_curveto3|harupage_drawimage|harupage_ellipse|harupage_endpath|harupage_endtext|' + + 'harupage_eofill|harupage_eofillstroke|harupage_fill|harupage_fillstroke|harupage_getcharspace|harupage_getcmykfill|harupage_getcmykstroke|' + + 'harupage_getcurrentfont|harupage_getcurrentfontsize|harupage_getcurrentpos|harupage_getcurrenttextpos|harupage_getdash|' + + 'harupage_getfillingcolorspace|harupage_getflatness|harupage_getgmode|harupage_getgrayfill|harupage_getgraystroke|harupage_getheight|' + + 'harupage_gethorizontalscaling|harupage_getlinecap|harupage_getlinejoin|harupage_getlinewidth|harupage_getmiterlimit|harupage_getrgbfill|' + + 'harupage_getrgbstroke|harupage_getstrokingcolorspace|harupage_gettextleading|harupage_gettextmatrix|harupage_gettextrenderingmode|' + + 'harupage_gettextrise|harupage_gettextwidth|harupage_gettransmatrix|harupage_getwidth|harupage_getwordspace|harupage_lineto|' + + 'harupage_measuretext|harupage_movetextpos|harupage_moveto|harupage_movetonextline|harupage_rectangle|harupage_setcharspace|' + + 'harupage_setcmykfill|harupage_setcmykstroke|harupage_setdash|harupage_setflatness|harupage_setfontandsize|harupage_setgrayfill|' + + 'harupage_setgraystroke|harupage_setheight|harupage_sethorizontalscaling|harupage_setlinecap|harupage_setlinejoin|harupage_setlinewidth|' + + 'harupage_setmiterlimit|harupage_setrgbfill|harupage_setrgbstroke|harupage_setrotate|harupage_setsize|harupage_setslideshow|' + + 'harupage_settextleading|harupage_settextmatrix|harupage_settextrenderingmode|harupage_settextrise|harupage_setwidth|harupage_setwordspace|' + + 'harupage_showtext|harupage_showtextnextline|harupage_stroke|harupage_textout|harupage_textrect|hasconstant|hash|hash_algos|hash_copy|' + + 'hash_file|hash_final|hash_hmac|hash_hmac_file|hash_init|hash_update|hash_update_file|hash_update_stream|hasmethod|hasproperty|header|' + + 'header_register_callback|header_remove|headers_list|headers_sent|hebrev|hebrevc|hex2bin|hexdec|highlight_file|highlight_string|' + + 'html_entity_decode|htmlentities|htmlspecialchars|htmlspecialchars_decode|http_build_cookie|http_build_query|http_build_str|http_build_url|' + + 'http_cache_etag|http_cache_last_modified|http_chunked_decode|http_date|http_deflate|http_get|http_get_request_body|' + + 'http_get_request_body_stream|http_get_request_headers|http_head|http_inflate|http_match_etag|http_match_modified|' + + 'http_match_request_header|http_negotiate_charset|http_negotiate_content_type|http_negotiate_language|http_parse_cookie|http_parse_headers|' + + 'http_parse_message|http_parse_params|http_persistent_handles_clean|http_persistent_handles_count|http_persistent_handles_ident|' + + 'http_post_data|http_post_fields|http_put_data|http_put_file|http_put_stream|http_redirect|http_request|http_request_body_encode|' + + 'http_request_method_exists|http_request_method_name|http_request_method_register|http_request_method_unregister|http_response_code|' + + 'http_send_content_disposition|http_send_content_type|http_send_data|http_send_file|http_send_last_modified|http_send_status|' + + 'http_send_stream|http_support|http_throttle|httpdeflatestream|httpdeflatestream_construct|httpdeflatestream_factory|' + + 'httpdeflatestream_finish|httpdeflatestream_flush|httpdeflatestream_update|httpinflatestream|httpinflatestream_construct|' + + 'httpinflatestream_factory|httpinflatestream_finish|httpinflatestream_flush|httpinflatestream_update|httpmessage|httpmessage_addheaders|' + + 'httpmessage_construct|httpmessage_detach|httpmessage_factory|httpmessage_fromenv|httpmessage_fromstring|httpmessage_getbody|' + + 'httpmessage_getheader|httpmessage_getheaders|httpmessage_gethttpversion|httpmessage_getparentmessage|httpmessage_getrequestmethod|' + + 'httpmessage_getrequesturl|httpmessage_getresponsecode|httpmessage_getresponsestatus|httpmessage_gettype|httpmessage_guesscontenttype|' + + 'httpmessage_prepend|httpmessage_reverse|httpmessage_send|httpmessage_setbody|httpmessage_setheaders|httpmessage_sethttpversion|' + + 'httpmessage_setrequestmethod|httpmessage_setrequesturl|httpmessage_setresponsecode|httpmessage_setresponsestatus|httpmessage_settype|' + + 'httpmessage_tomessagetypeobject|httpmessage_tostring|httpquerystring|httpquerystring_construct|httpquerystring_get|httpquerystring_mod|' + + 'httpquerystring_set|httpquerystring_singleton|httpquerystring_toarray|httpquerystring_tostring|httpquerystring_xlate|httprequest|' + + 'httprequest_addcookies|httprequest_addheaders|httprequest_addpostfields|httprequest_addpostfile|httprequest_addputdata|' + + 'httprequest_addquerydata|httprequest_addrawpostdata|httprequest_addssloptions|httprequest_clearhistory|httprequest_construct|' + + 'httprequest_enablecookies|httprequest_getcontenttype|httprequest_getcookies|httprequest_getheaders|httprequest_gethistory|' + + 'httprequest_getmethod|httprequest_getoptions|httprequest_getpostfields|httprequest_getpostfiles|httprequest_getputdata|' + + 'httprequest_getputfile|httprequest_getquerydata|httprequest_getrawpostdata|httprequest_getrawrequestmessage|' + + 'httprequest_getrawresponsemessage|httprequest_getrequestmessage|httprequest_getresponsebody|httprequest_getresponsecode|' + + 'httprequest_getresponsecookies|httprequest_getresponsedata|httprequest_getresponseheader|httprequest_getresponseinfo|' + + 'httprequest_getresponsemessage|httprequest_getresponsestatus|httprequest_getssloptions|httprequest_geturl|httprequest_resetcookies|' + + 'httprequest_send|httprequest_setcontenttype|httprequest_setcookies|httprequest_setheaders|httprequest_setmethod|httprequest_setoptions|' + + 'httprequest_setpostfields|httprequest_setpostfiles|httprequest_setputdata|httprequest_setputfile|httprequest_setquerydata|' + + 'httprequest_setrawpostdata|httprequest_setssloptions|httprequest_seturl|httprequestpool|httprequestpool_attach|httprequestpool_construct|' + + 'httprequestpool_destruct|httprequestpool_detach|httprequestpool_getattachedrequests|httprequestpool_getfinishedrequests|' + + 'httprequestpool_reset|httprequestpool_send|httprequestpool_socketperform|httprequestpool_socketselect|httpresponse|httpresponse_capture|' + + 'httpresponse_getbuffersize|httpresponse_getcache|httpresponse_getcachecontrol|httpresponse_getcontentdisposition|' + + 'httpresponse_getcontenttype|httpresponse_getdata|httpresponse_getetag|httpresponse_getfile|httpresponse_getgzip|httpresponse_getheader|' + + 'httpresponse_getlastmodified|httpresponse_getrequestbody|httpresponse_getrequestbodystream|httpresponse_getrequestheaders|' + + 'httpresponse_getstream|httpresponse_getthrottledelay|httpresponse_guesscontenttype|httpresponse_redirect|httpresponse_send|' + + 'httpresponse_setbuffersize|httpresponse_setcache|httpresponse_setcachecontrol|httpresponse_setcontentdisposition|' + + 'httpresponse_setcontenttype|httpresponse_setdata|httpresponse_setetag|httpresponse_setfile|httpresponse_setgzip|httpresponse_setheader|' + + 'httpresponse_setlastmodified|httpresponse_setstream|httpresponse_setthrottledelay|httpresponse_status|hw_array2objrec|hw_changeobject|' + + 'hw_children|hw_childrenobj|hw_close|hw_connect|hw_connection_info|hw_cp|hw_deleteobject|hw_docbyanchor|hw_docbyanchorobj|' + + 'hw_document_attributes|hw_document_bodytag|hw_document_content|hw_document_setcontent|hw_document_size|hw_dummy|hw_edittext|hw_error|' + + 'hw_errormsg|hw_free_document|hw_getanchors|hw_getanchorsobj|hw_getandlock|hw_getchildcoll|hw_getchildcollobj|hw_getchilddoccoll|' + + 'hw_getchilddoccollobj|hw_getobject|hw_getobjectbyquery|hw_getobjectbyquerycoll|hw_getobjectbyquerycollobj|hw_getobjectbyqueryobj|' + + 'hw_getparents|hw_getparentsobj|hw_getrellink|hw_getremote|hw_getremotechildren|hw_getsrcbydestobj|hw_gettext|hw_getusername|hw_identify|' + + 'hw_incollections|hw_info|hw_inscoll|hw_insdoc|hw_insertanchors|hw_insertdocument|hw_insertobject|hw_mapid|hw_modifyobject|hw_mv|' + + 'hw_new_document|hw_objrec2array|hw_output_document|hw_pconnect|hw_pipedocument|hw_root|hw_setlinkroot|hw_stat|hw_unlock|hw_who|' + + 'hwapi_attribute|hwapi_attribute_key|hwapi_attribute_langdepvalue|hwapi_attribute_value|hwapi_attribute_values|hwapi_checkin|' + + 'hwapi_checkout|hwapi_children|hwapi_content|hwapi_content_mimetype|hwapi_content_read|hwapi_copy|hwapi_dbstat|hwapi_dcstat|' + + 'hwapi_dstanchors|hwapi_dstofsrcanchor|hwapi_error_count|hwapi_error_reason|hwapi_find|hwapi_ftstat|hwapi_hgcsp|hwapi_hwstat|' + + 'hwapi_identify|hwapi_info|hwapi_insert|hwapi_insertanchor|hwapi_insertcollection|hwapi_insertdocument|hwapi_link|hwapi_lock|hwapi_move|' + + 'hwapi_new_content|hwapi_object|hwapi_object_assign|hwapi_object_attreditable|hwapi_object_count|hwapi_object_insert|hwapi_object_new|' + + 'hwapi_object_remove|hwapi_object_title|hwapi_object_value|hwapi_objectbyanchor|hwapi_parents|hwapi_reason_description|hwapi_reason_type|' + + 'hwapi_remove|hwapi_replace|hwapi_setcommittedversion|hwapi_srcanchors|hwapi_srcsofdst|hwapi_unlock|hwapi_user|hwapi_userlist|hypot|' + + 'ibase_add_user|ibase_affected_rows|ibase_backup|ibase_blob_add|ibase_blob_cancel|ibase_blob_close|ibase_blob_create|ibase_blob_echo|' + + 'ibase_blob_get|ibase_blob_import|ibase_blob_info|ibase_blob_open|ibase_close|ibase_commit|ibase_commit_ret|ibase_connect|ibase_db_info|' + + 'ibase_delete_user|ibase_drop_db|ibase_errcode|ibase_errmsg|ibase_execute|ibase_fetch_assoc|ibase_fetch_object|ibase_fetch_row|' + + 'ibase_field_info|ibase_free_event_handler|ibase_free_query|ibase_free_result|ibase_gen_id|ibase_maintain_db|ibase_modify_user|' + + 'ibase_name_result|ibase_num_fields|ibase_num_params|ibase_param_info|ibase_pconnect|ibase_prepare|ibase_query|ibase_restore|' + + 'ibase_rollback|ibase_rollback_ret|ibase_server_info|ibase_service_attach|ibase_service_detach|ibase_set_event_handler|ibase_timefmt|' + + 'ibase_trans|ibase_wait_event|iconv|iconv_get_encoding|iconv_mime_decode|iconv_mime_decode_headers|iconv_mime_encode|iconv_set_encoding|' + + 'iconv_strlen|iconv_strpos|iconv_strrpos|iconv_substr|id3_get_frame_long_name|id3_get_frame_short_name|id3_get_genre_id|id3_get_genre_list|' + + 'id3_get_genre_name|id3_get_tag|id3_get_version|id3_remove_tag|id3_set_tag|id3v2attachedpictureframe|id3v2frame|id3v2tag|idate|' + + 'idn_to_ascii|idn_to_unicode|idn_to_utf8|ifx_affected_rows|ifx_blobinfile_mode|ifx_byteasvarchar|ifx_close|ifx_connect|ifx_copy_blob|' + + 'ifx_create_blob|ifx_create_char|ifx_do|ifx_error|ifx_errormsg|ifx_fetch_row|ifx_fieldproperties|ifx_fieldtypes|ifx_free_blob|' + + 'ifx_free_char|ifx_free_result|ifx_get_blob|ifx_get_char|ifx_getsqlca|ifx_htmltbl_result|ifx_nullformat|ifx_num_fields|ifx_num_rows|' + + 'ifx_pconnect|ifx_prepare|ifx_query|ifx_textasvarchar|ifx_update_blob|ifx_update_char|ifxus_close_slob|ifxus_create_slob|ifxus_free_slob|' + + 'ifxus_open_slob|ifxus_read_slob|ifxus_seek_slob|ifxus_tell_slob|ifxus_write_slob|ignore_user_abort|iis_add_server|iis_get_dir_security|' + + 'iis_get_script_map|iis_get_server_by_comment|iis_get_server_by_path|iis_get_server_rights|iis_get_service_state|iis_remove_server|' + + 'iis_set_app_settings|iis_set_dir_security|iis_set_script_map|iis_set_server_rights|iis_start_server|iis_start_service|iis_stop_server|' + + 'iis_stop_service|image2wbmp|image_type_to_extension|image_type_to_mime_type|imagealphablending|imageantialias|imagearc|imagechar|' + + 'imagecharup|imagecolorallocate|imagecolorallocatealpha|imagecolorat|imagecolorclosest|imagecolorclosestalpha|imagecolorclosesthwb|' + + 'imagecolordeallocate|imagecolorexact|imagecolorexactalpha|imagecolormatch|imagecolorresolve|imagecolorresolvealpha|imagecolorset|' + + 'imagecolorsforindex|imagecolorstotal|imagecolortransparent|imageconvolution|imagecopy|imagecopymerge|imagecopymergegray|' + + 'imagecopyresampled|imagecopyresized|imagecreate|imagecreatefromgd|imagecreatefromgd2|imagecreatefromgd2part|imagecreatefromgif|' + + 'imagecreatefromjpeg|imagecreatefrompng|imagecreatefromstring|imagecreatefromwbmp|imagecreatefromxbm|imagecreatefromxpm|' + + 'imagecreatetruecolor|imagedashedline|imagedestroy|imageellipse|imagefill|imagefilledarc|imagefilledellipse|imagefilledpolygon|' + + 'imagefilledrectangle|imagefilltoborder|imagefilter|imagefontheight|imagefontwidth|imageftbbox|imagefttext|imagegammacorrect|imagegd|' + + 'imagegd2|imagegif|imagegrabscreen|imagegrabwindow|imageinterlace|imageistruecolor|imagejpeg|imagelayereffect|imageline|imageloadfont|' + + 'imagepalettecopy|imagepng|imagepolygon|imagepsbbox|imagepsencodefont|imagepsextendfont|imagepsfreefont|imagepsloadfont|imagepsslantfont|' + + 'imagepstext|imagerectangle|imagerotate|imagesavealpha|imagesetbrush|imagesetpixel|imagesetstyle|imagesetthickness|imagesettile|' + + 'imagestring|imagestringup|imagesx|imagesy|imagetruecolortopalette|imagettfbbox|imagettftext|imagetypes|imagewbmp|imagexbm|imagick|' + + 'imagick_adaptiveblurimage|imagick_adaptiveresizeimage|imagick_adaptivesharpenimage|imagick_adaptivethresholdimage|imagick_addimage|' + + 'imagick_addnoiseimage|imagick_affinetransformimage|imagick_animateimages|imagick_annotateimage|imagick_appendimages|imagick_averageimages|' + + 'imagick_blackthresholdimage|imagick_blurimage|imagick_borderimage|imagick_charcoalimage|imagick_chopimage|imagick_clear|imagick_clipimage|' + + 'imagick_clippathimage|imagick_clone|imagick_clutimage|imagick_coalesceimages|imagick_colorfloodfillimage|imagick_colorizeimage|' + + 'imagick_combineimages|imagick_commentimage|imagick_compareimagechannels|imagick_compareimagelayers|imagick_compareimages|' + + 'imagick_compositeimage|imagick_construct|imagick_contrastimage|imagick_contraststretchimage|imagick_convolveimage|imagick_cropimage|' + + 'imagick_cropthumbnailimage|imagick_current|imagick_cyclecolormapimage|imagick_decipherimage|imagick_deconstructimages|' + + 'imagick_deleteimageartifact|imagick_despeckleimage|imagick_destroy|imagick_displayimage|imagick_displayimages|imagick_distortimage|' + + 'imagick_drawimage|imagick_edgeimage|imagick_embossimage|imagick_encipherimage|imagick_enhanceimage|imagick_equalizeimage|' + + 'imagick_evaluateimage|imagick_extentimage|imagick_flattenimages|imagick_flipimage|imagick_floodfillpaintimage|imagick_flopimage|' + + 'imagick_frameimage|imagick_fximage|imagick_gammaimage|imagick_gaussianblurimage|imagick_getcolorspace|imagick_getcompression|' + + 'imagick_getcompressionquality|imagick_getcopyright|imagick_getfilename|imagick_getfont|imagick_getformat|imagick_getgravity|' + + 'imagick_gethomeurl|imagick_getimage|imagick_getimagealphachannel|imagick_getimageartifact|imagick_getimagebackgroundcolor|' + + 'imagick_getimageblob|imagick_getimageblueprimary|imagick_getimagebordercolor|imagick_getimagechanneldepth|' + + 'imagick_getimagechanneldistortion|imagick_getimagechanneldistortions|imagick_getimagechannelextrema|imagick_getimagechannelmean|' + + 'imagick_getimagechannelrange|imagick_getimagechannelstatistics|imagick_getimageclipmask|imagick_getimagecolormapcolor|' + + 'imagick_getimagecolors|imagick_getimagecolorspace|imagick_getimagecompose|imagick_getimagecompression|imagick_getimagecompressionquality|' + + 'imagick_getimagedelay|imagick_getimagedepth|imagick_getimagedispose|imagick_getimagedistortion|imagick_getimageextrema|' + + 'imagick_getimagefilename|imagick_getimageformat|imagick_getimagegamma|imagick_getimagegeometry|imagick_getimagegravity|' + + 'imagick_getimagegreenprimary|imagick_getimageheight|imagick_getimagehistogram|imagick_getimageindex|imagick_getimageinterlacescheme|' + + 'imagick_getimageinterpolatemethod|imagick_getimageiterations|imagick_getimagelength|imagick_getimagemagicklicense|imagick_getimagematte|' + + 'imagick_getimagemattecolor|imagick_getimageorientation|imagick_getimagepage|imagick_getimagepixelcolor|imagick_getimageprofile|' + + 'imagick_getimageprofiles|imagick_getimageproperties|imagick_getimageproperty|imagick_getimageredprimary|imagick_getimageregion|' + + 'imagick_getimagerenderingintent|imagick_getimageresolution|imagick_getimagesblob|imagick_getimagescene|imagick_getimagesignature|' + + 'imagick_getimagesize|imagick_getimagetickspersecond|imagick_getimagetotalinkdensity|imagick_getimagetype|imagick_getimageunits|' + + 'imagick_getimagevirtualpixelmethod|imagick_getimagewhitepoint|imagick_getimagewidth|imagick_getinterlacescheme|imagick_getiteratorindex|' + + 'imagick_getnumberimages|imagick_getoption|imagick_getpackagename|imagick_getpage|imagick_getpixeliterator|imagick_getpixelregioniterator|' + + 'imagick_getpointsize|imagick_getquantumdepth|imagick_getquantumrange|imagick_getreleasedate|imagick_getresource|imagick_getresourcelimit|' + + 'imagick_getsamplingfactors|imagick_getsize|imagick_getsizeoffset|imagick_getversion|imagick_hasnextimage|imagick_haspreviousimage|' + + 'imagick_identifyimage|imagick_implodeimage|imagick_labelimage|imagick_levelimage|imagick_linearstretchimage|imagick_liquidrescaleimage|' + + 'imagick_magnifyimage|imagick_mapimage|imagick_mattefloodfillimage|imagick_medianfilterimage|imagick_mergeimagelayers|imagick_minifyimage|' + + 'imagick_modulateimage|imagick_montageimage|imagick_morphimages|imagick_mosaicimages|imagick_motionblurimage|imagick_negateimage|' + + 'imagick_newimage|imagick_newpseudoimage|imagick_nextimage|imagick_normalizeimage|imagick_oilpaintimage|imagick_opaquepaintimage|' + + 'imagick_optimizeimagelayers|imagick_orderedposterizeimage|imagick_paintfloodfillimage|imagick_paintopaqueimage|' + + 'imagick_painttransparentimage|imagick_pingimage|imagick_pingimageblob|imagick_pingimagefile|imagick_polaroidimage|imagick_posterizeimage|' + + 'imagick_previewimages|imagick_previousimage|imagick_profileimage|imagick_quantizeimage|imagick_quantizeimages|imagick_queryfontmetrics|' + + 'imagick_queryfonts|imagick_queryformats|imagick_radialblurimage|imagick_raiseimage|imagick_randomthresholdimage|imagick_readimage|' + + 'imagick_readimageblob|imagick_readimagefile|imagick_recolorimage|imagick_reducenoiseimage|imagick_removeimage|imagick_removeimageprofile|' + + 'imagick_render|imagick_resampleimage|imagick_resetimagepage|imagick_resizeimage|imagick_rollimage|imagick_rotateimage|' + + 'imagick_roundcorners|imagick_sampleimage|imagick_scaleimage|imagick_separateimagechannel|imagick_sepiatoneimage|' + + 'imagick_setbackgroundcolor|imagick_setcolorspace|imagick_setcompression|imagick_setcompressionquality|imagick_setfilename|' + + 'imagick_setfirstiterator|imagick_setfont|imagick_setformat|imagick_setgravity|imagick_setimage|imagick_setimagealphachannel|' + + 'imagick_setimageartifact|imagick_setimagebackgroundcolor|imagick_setimagebias|imagick_setimageblueprimary|imagick_setimagebordercolor|' + + 'imagick_setimagechanneldepth|imagick_setimageclipmask|imagick_setimagecolormapcolor|imagick_setimagecolorspace|imagick_setimagecompose|' + + 'imagick_setimagecompression|imagick_setimagecompressionquality|imagick_setimagedelay|imagick_setimagedepth|imagick_setimagedispose|' + + 'imagick_setimageextent|imagick_setimagefilename|imagick_setimageformat|imagick_setimagegamma|imagick_setimagegravity|' + + 'imagick_setimagegreenprimary|imagick_setimageindex|imagick_setimageinterlacescheme|imagick_setimageinterpolatemethod|' + + 'imagick_setimageiterations|imagick_setimagematte|imagick_setimagemattecolor|imagick_setimageopacity|imagick_setimageorientation|' + + 'imagick_setimagepage|imagick_setimageprofile|imagick_setimageproperty|imagick_setimageredprimary|imagick_setimagerenderingintent|' + + 'imagick_setimageresolution|imagick_setimagescene|imagick_setimagetickspersecond|imagick_setimagetype|imagick_setimageunits|' + + 'imagick_setimagevirtualpixelmethod|imagick_setimagewhitepoint|imagick_setinterlacescheme|imagick_setiteratorindex|imagick_setlastiterator|' + + 'imagick_setoption|imagick_setpage|imagick_setpointsize|imagick_setresolution|imagick_setresourcelimit|imagick_setsamplingfactors|' + + 'imagick_setsize|imagick_setsizeoffset|imagick_settype|imagick_shadeimage|imagick_shadowimage|imagick_sharpenimage|imagick_shaveimage|' + + 'imagick_shearimage|imagick_sigmoidalcontrastimage|imagick_sketchimage|imagick_solarizeimage|imagick_spliceimage|imagick_spreadimage|' + + 'imagick_steganoimage|imagick_stereoimage|imagick_stripimage|imagick_swirlimage|imagick_textureimage|imagick_thresholdimage|' + + 'imagick_thumbnailimage|imagick_tintimage|imagick_transformimage|imagick_transparentpaintimage|imagick_transposeimage|' + + 'imagick_transverseimage|imagick_trimimage|imagick_uniqueimagecolors|imagick_unsharpmaskimage|imagick_valid|imagick_vignetteimage|' + + 'imagick_waveimage|imagick_whitethresholdimage|imagick_writeimage|imagick_writeimagefile|imagick_writeimages|imagick_writeimagesfile|' + + 'imagickdraw|imagickdraw_affine|imagickdraw_annotation|imagickdraw_arc|imagickdraw_bezier|imagickdraw_circle|imagickdraw_clear|' + + 'imagickdraw_clone|imagickdraw_color|imagickdraw_comment|imagickdraw_composite|imagickdraw_construct|imagickdraw_destroy|' + + 'imagickdraw_ellipse|imagickdraw_getclippath|imagickdraw_getcliprule|imagickdraw_getclipunits|imagickdraw_getfillcolor|' + + 'imagickdraw_getfillopacity|imagickdraw_getfillrule|imagickdraw_getfont|imagickdraw_getfontfamily|imagickdraw_getfontsize|' + + 'imagickdraw_getfontstyle|imagickdraw_getfontweight|imagickdraw_getgravity|imagickdraw_getstrokeantialias|imagickdraw_getstrokecolor|' + + 'imagickdraw_getstrokedasharray|imagickdraw_getstrokedashoffset|imagickdraw_getstrokelinecap|imagickdraw_getstrokelinejoin|' + + 'imagickdraw_getstrokemiterlimit|imagickdraw_getstrokeopacity|imagickdraw_getstrokewidth|imagickdraw_gettextalignment|' + + 'imagickdraw_gettextantialias|imagickdraw_gettextdecoration|imagickdraw_gettextencoding|imagickdraw_gettextundercolor|' + + 'imagickdraw_getvectorgraphics|imagickdraw_line|imagickdraw_matte|imagickdraw_pathclose|imagickdraw_pathcurvetoabsolute|' + + 'imagickdraw_pathcurvetoquadraticbezierabsolute|imagickdraw_pathcurvetoquadraticbezierrelative|' + + 'imagickdraw_pathcurvetoquadraticbeziersmoothabsolute|imagickdraw_pathcurvetoquadraticbeziersmoothrelative|imagickdraw_pathcurvetorelative|' + + 'imagickdraw_pathcurvetosmoothabsolute|imagickdraw_pathcurvetosmoothrelative|imagickdraw_pathellipticarcabsolute|' + + 'imagickdraw_pathellipticarcrelative|imagickdraw_pathfinish|imagickdraw_pathlinetoabsolute|imagickdraw_pathlinetohorizontalabsolute|' + + 'imagickdraw_pathlinetohorizontalrelative|imagickdraw_pathlinetorelative|imagickdraw_pathlinetoverticalabsolute|' + + 'imagickdraw_pathlinetoverticalrelative|imagickdraw_pathmovetoabsolute|imagickdraw_pathmovetorelative|imagickdraw_pathstart|' + + 'imagickdraw_point|imagickdraw_polygon|imagickdraw_polyline|imagickdraw_pop|imagickdraw_popclippath|imagickdraw_popdefs|' + + 'imagickdraw_poppattern|imagickdraw_push|imagickdraw_pushclippath|imagickdraw_pushdefs|imagickdraw_pushpattern|imagickdraw_rectangle|' + + 'imagickdraw_render|imagickdraw_rotate|imagickdraw_roundrectangle|imagickdraw_scale|imagickdraw_setclippath|imagickdraw_setcliprule|' + + 'imagickdraw_setclipunits|imagickdraw_setfillalpha|imagickdraw_setfillcolor|imagickdraw_setfillopacity|imagickdraw_setfillpatternurl|' + + 'imagickdraw_setfillrule|imagickdraw_setfont|imagickdraw_setfontfamily|imagickdraw_setfontsize|imagickdraw_setfontstretch|' + + 'imagickdraw_setfontstyle|imagickdraw_setfontweight|imagickdraw_setgravity|imagickdraw_setstrokealpha|imagickdraw_setstrokeantialias|' + + 'imagickdraw_setstrokecolor|imagickdraw_setstrokedasharray|imagickdraw_setstrokedashoffset|imagickdraw_setstrokelinecap|' + + 'imagickdraw_setstrokelinejoin|imagickdraw_setstrokemiterlimit|imagickdraw_setstrokeopacity|imagickdraw_setstrokepatternurl|' + + 'imagickdraw_setstrokewidth|imagickdraw_settextalignment|imagickdraw_settextantialias|imagickdraw_settextdecoration|' + + 'imagickdraw_settextencoding|imagickdraw_settextundercolor|imagickdraw_setvectorgraphics|imagickdraw_setviewbox|imagickdraw_skewx|' + + 'imagickdraw_skewy|imagickdraw_translate|imagickpixel|imagickpixel_clear|imagickpixel_construct|imagickpixel_destroy|imagickpixel_getcolor|' + + 'imagickpixel_getcolorasstring|imagickpixel_getcolorcount|imagickpixel_getcolorvalue|imagickpixel_gethsl|imagickpixel_issimilar|' + + 'imagickpixel_setcolor|imagickpixel_setcolorvalue|imagickpixel_sethsl|imagickpixeliterator|imagickpixeliterator_clear|' + + 'imagickpixeliterator_construct|imagickpixeliterator_destroy|imagickpixeliterator_getcurrentiteratorrow|' + + 'imagickpixeliterator_getiteratorrow|imagickpixeliterator_getnextiteratorrow|imagickpixeliterator_getpreviousiteratorrow|' + + 'imagickpixeliterator_newpixeliterator|imagickpixeliterator_newpixelregioniterator|imagickpixeliterator_resetiterator|' + + 'imagickpixeliterator_setiteratorfirstrow|imagickpixeliterator_setiteratorlastrow|imagickpixeliterator_setiteratorrow|' + + 'imagickpixeliterator_synciterator|imap_8bit|imap_alerts|imap_append|imap_base64|imap_binary|imap_body|imap_bodystruct|imap_check|' + + 'imap_clearflag_full|imap_close|imap_create|imap_createmailbox|imap_delete|imap_deletemailbox|imap_errors|imap_expunge|imap_fetch_overview|' + + 'imap_fetchbody|imap_fetchheader|imap_fetchmime|imap_fetchstructure|imap_fetchtext|imap_gc|imap_get_quota|imap_get_quotaroot|imap_getacl|' + + 'imap_getmailboxes|imap_getsubscribed|imap_header|imap_headerinfo|imap_headers|imap_last_error|imap_list|imap_listmailbox|imap_listscan|' + + 'imap_listsubscribed|imap_lsub|imap_mail|imap_mail_compose|imap_mail_copy|imap_mail_move|imap_mailboxmsginfo|imap_mime_header_decode|' + + 'imap_msgno|imap_num_msg|imap_num_recent|imap_open|imap_ping|imap_qprint|imap_rename|imap_renamemailbox|imap_reopen|' + + 'imap_rfc822_parse_adrlist|imap_rfc822_parse_headers|imap_rfc822_write_address|imap_savebody|imap_scan|imap_scanmailbox|imap_search|' + + 'imap_set_quota|imap_setacl|imap_setflag_full|imap_sort|imap_status|imap_subscribe|imap_thread|imap_timeout|imap_uid|imap_undelete|' + + 'imap_unsubscribe|imap_utf7_decode|imap_utf7_encode|imap_utf8|implementsinterface|implode|import_request_variables|in_array|include|' + + 'include_once|inclued_get_data|inet_ntop|inet_pton|infiniteiterator|ingres_autocommit|ingres_autocommit_state|ingres_charset|ingres_close|' + + 'ingres_commit|ingres_connect|ingres_cursor|ingres_errno|ingres_error|ingres_errsqlstate|ingres_escape_string|ingres_execute|' + + 'ingres_fetch_array|ingres_fetch_assoc|ingres_fetch_object|ingres_fetch_proc_return|ingres_fetch_row|ingres_field_length|ingres_field_name|' + + 'ingres_field_nullable|ingres_field_precision|ingres_field_scale|ingres_field_type|ingres_free_result|ingres_next_error|ingres_num_fields|' + + 'ingres_num_rows|ingres_pconnect|ingres_prepare|ingres_query|ingres_result_seek|ingres_rollback|ingres_set_environment|' + + 'ingres_unbuffered_query|ini_alter|ini_get|ini_get_all|ini_restore|ini_set|innamespace|inotify_add_watch|inotify_init|inotify_queue_len|' + + 'inotify_read|inotify_rm_watch|interface_exists|intl_error_name|intl_get_error_code|intl_get_error_message|intl_is_failure|' + + 'intldateformatter|intval|invalidargumentexception|invoke|invokeargs|ip2long|iptcembed|iptcparse|is_a|is_array|is_bool|is_callable|is_dir|' + + 'is_double|is_executable|is_file|is_finite|is_float|is_infinite|is_int|is_integer|is_link|is_long|is_nan|is_null|is_numeric|is_object|' + + 'is_readable|is_real|is_resource|is_scalar|is_soap_fault|is_string|is_subclass_of|is_uploaded_file|is_writable|is_writeable|isabstract|' + + 'iscloneable|isdisabled|isfinal|isinstance|isinstantiable|isinterface|isinternal|isiterateable|isset|issubclassof|isuserdefined|iterator|' + + 'iterator_apply|iterator_count|iterator_to_array|iteratoraggregate|iteratoriterator|java_last_exception_clear|java_last_exception_get|' + + 'jddayofweek|jdmonthname|jdtofrench|jdtogregorian|jdtojewish|jdtojulian|jdtounix|jewishtojd|join|jpeg2wbmp|json_decode|json_encode|' + + 'json_last_error|jsonserializable|judy|judy_type|judy_version|juliantojd|kadm5_chpass_principal|kadm5_create_principal|' + + 'kadm5_delete_principal|kadm5_destroy|kadm5_flush|kadm5_get_policies|kadm5_get_principal|kadm5_get_principals|kadm5_init_with_password|' + + 'kadm5_modify_principal|key|krsort|ksort|lcfirst|lcg_value|lchgrp|lchown|ldap_8859_to_t61|ldap_add|ldap_bind|ldap_close|ldap_compare|' + + 'ldap_connect|ldap_count_entries|ldap_delete|ldap_dn2ufn|ldap_err2str|ldap_errno|ldap_error|ldap_explode_dn|ldap_first_attribute|' + + 'ldap_first_entry|ldap_first_reference|ldap_free_result|ldap_get_attributes|ldap_get_dn|ldap_get_entries|ldap_get_option|ldap_get_values|' + + 'ldap_get_values_len|ldap_list|ldap_mod_add|ldap_mod_del|ldap_mod_replace|ldap_modify|ldap_next_attribute|ldap_next_entry|' + + 'ldap_next_reference|ldap_parse_reference|ldap_parse_result|ldap_read|ldap_rename|ldap_sasl_bind|ldap_search|ldap_set_option|' + + 'ldap_set_rebind_proc|ldap_sort|ldap_start_tls|ldap_t61_to_8859|ldap_unbind|lengthexception|levenshtein|libxml_clear_errors|' + + 'libxml_disable_entity_loader|libxml_get_errors|libxml_get_last_error|libxml_set_streams_context|libxml_use_internal_errors|libxmlerror|' + + 'limititerator|link|linkinfo|list|locale|localeconv|localtime|log|log10|log1p|logicexception|long2ip|lstat|ltrim|lzf_compress|' + + 'lzf_decompress|lzf_optimized_for|m_checkstatus|m_completeauthorizations|m_connect|m_connectionerror|m_deletetrans|m_destroyconn|' + + 'm_destroyengine|m_getcell|m_getcellbynum|m_getcommadelimited|m_getheader|m_initconn|m_initengine|m_iscommadelimited|m_maxconntimeout|' + + 'm_monitor|m_numcolumns|m_numrows|m_parsecommadelimited|m_responsekeys|m_responseparam|m_returnstatus|m_setblocking|m_setdropfile|m_setip|' + + 'm_setssl|m_setssl_cafile|m_setssl_files|m_settimeout|m_sslcert_gen_hash|m_transactionssent|m_transinqueue|m_transkeyval|m_transnew|' + + 'm_transsend|m_uwait|m_validateidentifier|m_verifyconnection|m_verifysslcert|magic_quotes_runtime|mail|' + + 'mailparse_determine_best_xfer_encoding|mailparse_msg_create|mailparse_msg_extract_part|mailparse_msg_extract_part_file|' + + 'mailparse_msg_extract_whole_part_file|mailparse_msg_free|mailparse_msg_get_part|mailparse_msg_get_part_data|mailparse_msg_get_structure|' + + 'mailparse_msg_parse|mailparse_msg_parse_file|mailparse_rfc822_parse_addresses|mailparse_stream_encode|mailparse_uudecode_all|main|max|' + + 'maxdb_affected_rows|maxdb_autocommit|maxdb_bind_param|maxdb_bind_result|maxdb_change_user|maxdb_character_set_name|maxdb_client_encoding|' + + 'maxdb_close|maxdb_close_long_data|maxdb_commit|maxdb_connect|maxdb_connect_errno|maxdb_connect_error|maxdb_data_seek|maxdb_debug|' + + 'maxdb_disable_reads_from_master|maxdb_disable_rpl_parse|maxdb_dump_debug_info|maxdb_embedded_connect|maxdb_enable_reads_from_master|' + + 'maxdb_enable_rpl_parse|maxdb_errno|maxdb_error|maxdb_escape_string|maxdb_execute|maxdb_fetch|maxdb_fetch_array|maxdb_fetch_assoc|' + + 'maxdb_fetch_field|maxdb_fetch_field_direct|maxdb_fetch_fields|maxdb_fetch_lengths|maxdb_fetch_object|maxdb_fetch_row|maxdb_field_count|' + + 'maxdb_field_seek|maxdb_field_tell|maxdb_free_result|maxdb_get_client_info|maxdb_get_client_version|maxdb_get_host_info|maxdb_get_metadata|' + + 'maxdb_get_proto_info|maxdb_get_server_info|maxdb_get_server_version|maxdb_info|maxdb_init|maxdb_insert_id|maxdb_kill|maxdb_master_query|' + + 'maxdb_more_results|maxdb_multi_query|maxdb_next_result|maxdb_num_fields|maxdb_num_rows|maxdb_options|maxdb_param_count|maxdb_ping|' + + 'maxdb_prepare|maxdb_query|maxdb_real_connect|maxdb_real_escape_string|maxdb_real_query|maxdb_report|maxdb_rollback|' + + 'maxdb_rpl_parse_enabled|maxdb_rpl_probe|maxdb_rpl_query_type|maxdb_select_db|maxdb_send_long_data|maxdb_send_query|maxdb_server_end|' + + 'maxdb_server_init|maxdb_set_opt|maxdb_sqlstate|maxdb_ssl_set|maxdb_stat|maxdb_stmt_affected_rows|maxdb_stmt_bind_param|' + + 'maxdb_stmt_bind_result|maxdb_stmt_close|maxdb_stmt_close_long_data|maxdb_stmt_data_seek|maxdb_stmt_errno|maxdb_stmt_error|' + + 'maxdb_stmt_execute|maxdb_stmt_fetch|maxdb_stmt_free_result|maxdb_stmt_init|maxdb_stmt_num_rows|maxdb_stmt_param_count|maxdb_stmt_prepare|' + + 'maxdb_stmt_reset|maxdb_stmt_result_metadata|maxdb_stmt_send_long_data|maxdb_stmt_sqlstate|maxdb_stmt_store_result|maxdb_store_result|' + + 'maxdb_thread_id|maxdb_thread_safe|maxdb_use_result|maxdb_warning_count|mb_check_encoding|mb_convert_case|mb_convert_encoding|' + + 'mb_convert_kana|mb_convert_variables|mb_decode_mimeheader|mb_decode_numericentity|mb_detect_encoding|mb_detect_order|mb_encode_mimeheader|' + + 'mb_encode_numericentity|mb_encoding_aliases|mb_ereg|mb_ereg_match|mb_ereg_replace|mb_ereg_search|mb_ereg_search_getpos|' + + 'mb_ereg_search_getregs|mb_ereg_search_init|mb_ereg_search_pos|mb_ereg_search_regs|mb_ereg_search_setpos|mb_eregi|mb_eregi_replace|' + + 'mb_get_info|mb_http_input|mb_http_output|mb_internal_encoding|mb_language|mb_list_encodings|mb_output_handler|mb_parse_str|' + + 'mb_preferred_mime_name|mb_regex_encoding|mb_regex_set_options|mb_send_mail|mb_split|mb_strcut|mb_strimwidth|mb_stripos|mb_stristr|' + + 'mb_strlen|mb_strpos|mb_strrchr|mb_strrichr|mb_strripos|mb_strrpos|mb_strstr|mb_strtolower|mb_strtoupper|mb_strwidth|' + + 'mb_substitute_character|mb_substr|mb_substr_count|mcrypt_cbc|mcrypt_cfb|mcrypt_create_iv|mcrypt_decrypt|mcrypt_ecb|' + + 'mcrypt_enc_get_algorithms_name|mcrypt_enc_get_block_size|mcrypt_enc_get_iv_size|mcrypt_enc_get_key_size|mcrypt_enc_get_modes_name|' + + 'mcrypt_enc_get_supported_key_sizes|mcrypt_enc_is_block_algorithm|mcrypt_enc_is_block_algorithm_mode|mcrypt_enc_is_block_mode|' + + 'mcrypt_enc_self_test|mcrypt_encrypt|mcrypt_generic|mcrypt_generic_deinit|mcrypt_generic_end|mcrypt_generic_init|mcrypt_get_block_size|' + + 'mcrypt_get_cipher_name|mcrypt_get_iv_size|mcrypt_get_key_size|mcrypt_list_algorithms|mcrypt_list_modes|mcrypt_module_close|' + + 'mcrypt_module_get_algo_block_size|mcrypt_module_get_algo_key_size|mcrypt_module_get_supported_key_sizes|mcrypt_module_is_block_algorithm|' + + 'mcrypt_module_is_block_algorithm_mode|mcrypt_module_is_block_mode|mcrypt_module_open|mcrypt_module_self_test|mcrypt_ofb|md5|md5_file|' + + 'mdecrypt_generic|memcache|memcache_debug|memcached|memory_get_peak_usage|memory_get_usage|messageformatter|metaphone|method_exists|mhash|' + + 'mhash_count|mhash_get_block_size|mhash_get_hash_name|mhash_keygen_s2k|microtime|mime_content_type|min|ming_keypress|' + + 'ming_setcubicthreshold|ming_setscale|ming_setswfcompression|ming_useconstants|ming_useswfversion|mkdir|mktime|money_format|mongo|' + + 'mongobindata|mongocode|mongocollection|mongoconnectionexception|mongocursor|mongocursorexception|mongocursortimeoutexception|mongodate|' + + 'mongodb|mongodbref|mongoexception|mongogridfs|mongogridfscursor|mongogridfsexception|mongogridfsfile|mongoid|mongoint32|mongoint64|' + + 'mongomaxkey|mongominkey|mongoregex|mongotimestamp|move_uploaded_file|mpegfile|mqseries_back|mqseries_begin|mqseries_close|mqseries_cmit|' + + 'mqseries_conn|mqseries_connx|mqseries_disc|mqseries_get|mqseries_inq|mqseries_open|mqseries_put|mqseries_put1|mqseries_set|' + + 'mqseries_strerror|msession_connect|msession_count|msession_create|msession_destroy|msession_disconnect|msession_find|msession_get|' + + 'msession_get_array|msession_get_data|msession_inc|msession_list|msession_listvar|msession_lock|msession_plugin|msession_randstr|' + + 'msession_set|msession_set_array|msession_set_data|msession_timeout|msession_uniq|msession_unlock|msg_get_queue|msg_queue_exists|' + + 'msg_receive|msg_remove_queue|msg_send|msg_set_queue|msg_stat_queue|msql|msql_affected_rows|msql_close|msql_connect|msql_create_db|' + + 'msql_createdb|msql_data_seek|msql_db_query|msql_dbname|msql_drop_db|msql_error|msql_fetch_array|msql_fetch_field|msql_fetch_object|' + + 'msql_fetch_row|msql_field_flags|msql_field_len|msql_field_name|msql_field_seek|msql_field_table|msql_field_type|msql_fieldflags|' + + 'msql_fieldlen|msql_fieldname|msql_fieldtable|msql_fieldtype|msql_free_result|msql_list_dbs|msql_list_fields|msql_list_tables|' + + 'msql_num_fields|msql_num_rows|msql_numfields|msql_numrows|msql_pconnect|msql_query|msql_regcase|msql_result|msql_select_db|msql_tablename|' + + 'mssql_bind|mssql_close|mssql_connect|mssql_data_seek|mssql_execute|mssql_fetch_array|mssql_fetch_assoc|mssql_fetch_batch|' + + 'mssql_fetch_field|mssql_fetch_object|mssql_fetch_row|mssql_field_length|mssql_field_name|mssql_field_seek|mssql_field_type|' + + 'mssql_free_result|mssql_free_statement|mssql_get_last_message|mssql_guid_string|mssql_init|mssql_min_error_severity|' + + 'mssql_min_message_severity|mssql_next_result|mssql_num_fields|mssql_num_rows|mssql_pconnect|mssql_query|mssql_result|mssql_rows_affected|' + + 'mssql_select_db|mt_getrandmax|mt_rand|mt_srand|multipleiterator|mysql_affected_rows|mysql_client_encoding|mysql_close|mysql_connect|' + + 'mysql_create_db|mysql_data_seek|mysql_db_name|mysql_db_query|mysql_drop_db|mysql_errno|mysql_error|mysql_escape_string|mysql_fetch_array|' + + 'mysql_fetch_assoc|mysql_fetch_field|mysql_fetch_lengths|mysql_fetch_object|mysql_fetch_row|mysql_field_flags|mysql_field_len|' + + 'mysql_field_name|mysql_field_seek|mysql_field_table|mysql_field_type|mysql_free_result|mysql_get_client_info|mysql_get_host_info|' + + 'mysql_get_proto_info|mysql_get_server_info|mysql_info|mysql_insert_id|mysql_list_dbs|mysql_list_fields|mysql_list_processes|' + + 'mysql_list_tables|mysql_num_fields|mysql_num_rows|mysql_pconnect|mysql_ping|mysql_query|mysql_real_escape_string|mysql_result|' + + 'mysql_select_db|mysql_set_charset|mysql_stat|mysql_tablename|mysql_thread_id|mysql_unbuffered_query|mysqli|mysqli_bind_param|' + + 'mysqli_bind_result|mysqli_client_encoding|mysqli_connect|mysqli_disable_reads_from_master|mysqli_disable_rpl_parse|mysqli_driver|' + + 'mysqli_enable_reads_from_master|mysqli_enable_rpl_parse|mysqli_escape_string|mysqli_execute|mysqli_fetch|mysqli_get_metadata|' + + 'mysqli_master_query|mysqli_param_count|mysqli_report|mysqli_result|mysqli_rpl_parse_enabled|mysqli_rpl_probe|mysqli_rpl_query_type|' + + 'mysqli_send_long_data|mysqli_send_query|mysqli_set_opt|mysqli_slave_query|mysqli_stmt|mysqli_warning|mysqlnd_ms_get_stats|' + + 'mysqlnd_ms_query_is_select|mysqlnd_ms_set_user_pick_server|mysqlnd_qc_change_handler|mysqlnd_qc_clear_cache|mysqlnd_qc_get_cache_info|' + + 'mysqlnd_qc_get_core_stats|mysqlnd_qc_get_handler|mysqlnd_qc_get_query_trace_log|mysqlnd_qc_set_user_handlers|natcasesort|natsort|' + + 'ncurses_addch|ncurses_addchnstr|ncurses_addchstr|ncurses_addnstr|ncurses_addstr|ncurses_assume_default_colors|ncurses_attroff|' + + 'ncurses_attron|ncurses_attrset|ncurses_baudrate|ncurses_beep|ncurses_bkgd|ncurses_bkgdset|ncurses_border|ncurses_bottom_panel|' + + 'ncurses_can_change_color|ncurses_cbreak|ncurses_clear|ncurses_clrtobot|ncurses_clrtoeol|ncurses_color_content|ncurses_color_set|' + + 'ncurses_curs_set|ncurses_def_prog_mode|ncurses_def_shell_mode|ncurses_define_key|ncurses_del_panel|ncurses_delay_output|ncurses_delch|' + + 'ncurses_deleteln|ncurses_delwin|ncurses_doupdate|ncurses_echo|ncurses_echochar|ncurses_end|ncurses_erase|ncurses_erasechar|ncurses_filter|' + + 'ncurses_flash|ncurses_flushinp|ncurses_getch|ncurses_getmaxyx|ncurses_getmouse|ncurses_getyx|ncurses_halfdelay|ncurses_has_colors|' + + 'ncurses_has_ic|ncurses_has_il|ncurses_has_key|ncurses_hide_panel|ncurses_hline|ncurses_inch|ncurses_init|ncurses_init_color|' + + 'ncurses_init_pair|ncurses_insch|ncurses_insdelln|ncurses_insertln|ncurses_insstr|ncurses_instr|ncurses_isendwin|ncurses_keyok|' + + 'ncurses_keypad|ncurses_killchar|ncurses_longname|ncurses_meta|ncurses_mouse_trafo|ncurses_mouseinterval|ncurses_mousemask|ncurses_move|' + + 'ncurses_move_panel|ncurses_mvaddch|ncurses_mvaddchnstr|ncurses_mvaddchstr|ncurses_mvaddnstr|ncurses_mvaddstr|ncurses_mvcur|' + + 'ncurses_mvdelch|ncurses_mvgetch|ncurses_mvhline|ncurses_mvinch|ncurses_mvvline|ncurses_mvwaddstr|ncurses_napms|ncurses_new_panel|' + + 'ncurses_newpad|ncurses_newwin|ncurses_nl|ncurses_nocbreak|ncurses_noecho|ncurses_nonl|ncurses_noqiflush|ncurses_noraw|' + + 'ncurses_pair_content|ncurses_panel_above|ncurses_panel_below|ncurses_panel_window|ncurses_pnoutrefresh|ncurses_prefresh|ncurses_putp|' + + 'ncurses_qiflush|ncurses_raw|ncurses_refresh|ncurses_replace_panel|ncurses_reset_prog_mode|ncurses_reset_shell_mode|ncurses_resetty|' + + 'ncurses_savetty|ncurses_scr_dump|ncurses_scr_init|ncurses_scr_restore|ncurses_scr_set|ncurses_scrl|ncurses_show_panel|ncurses_slk_attr|' + + 'ncurses_slk_attroff|ncurses_slk_attron|ncurses_slk_attrset|ncurses_slk_clear|ncurses_slk_color|ncurses_slk_init|ncurses_slk_noutrefresh|' + + 'ncurses_slk_refresh|ncurses_slk_restore|ncurses_slk_set|ncurses_slk_touch|ncurses_standend|ncurses_standout|ncurses_start_color|' + + 'ncurses_termattrs|ncurses_termname|ncurses_timeout|ncurses_top_panel|ncurses_typeahead|ncurses_ungetch|ncurses_ungetmouse|' + + 'ncurses_update_panels|ncurses_use_default_colors|ncurses_use_env|ncurses_use_extended_names|ncurses_vidattr|ncurses_vline|ncurses_waddch|' + + 'ncurses_waddstr|ncurses_wattroff|ncurses_wattron|ncurses_wattrset|ncurses_wborder|ncurses_wclear|ncurses_wcolor_set|ncurses_werase|' + + 'ncurses_wgetch|ncurses_whline|ncurses_wmouse_trafo|ncurses_wmove|ncurses_wnoutrefresh|ncurses_wrefresh|ncurses_wstandend|' + + 'ncurses_wstandout|ncurses_wvline|newinstance|newinstanceargs|newt_bell|newt_button|newt_button_bar|newt_centered_window|newt_checkbox|' + + 'newt_checkbox_get_value|newt_checkbox_set_flags|newt_checkbox_set_value|newt_checkbox_tree|newt_checkbox_tree_add_item|' + + 'newt_checkbox_tree_find_item|newt_checkbox_tree_get_current|newt_checkbox_tree_get_entry_value|newt_checkbox_tree_get_multi_selection|' + + 'newt_checkbox_tree_get_selection|newt_checkbox_tree_multi|newt_checkbox_tree_set_current|newt_checkbox_tree_set_entry|' + + 'newt_checkbox_tree_set_entry_value|newt_checkbox_tree_set_width|newt_clear_key_buffer|newt_cls|newt_compact_button|' + + 'newt_component_add_callback|newt_component_takes_focus|newt_create_grid|newt_cursor_off|newt_cursor_on|newt_delay|newt_draw_form|' + + 'newt_draw_root_text|newt_entry|newt_entry_get_value|newt_entry_set|newt_entry_set_filter|newt_entry_set_flags|newt_finished|newt_form|' + + 'newt_form_add_component|newt_form_add_components|newt_form_add_hot_key|newt_form_destroy|newt_form_get_current|newt_form_run|' + + 'newt_form_set_background|newt_form_set_height|newt_form_set_size|newt_form_set_timer|newt_form_set_width|newt_form_watch_fd|' + + 'newt_get_screen_size|newt_grid_add_components_to_form|newt_grid_basic_window|newt_grid_free|newt_grid_get_size|newt_grid_h_close_stacked|' + + 'newt_grid_h_stacked|newt_grid_place|newt_grid_set_field|newt_grid_simple_window|newt_grid_v_close_stacked|newt_grid_v_stacked|' + + 'newt_grid_wrapped_window|newt_grid_wrapped_window_at|newt_init|newt_label|newt_label_set_text|newt_listbox|newt_listbox_append_entry|' + + 'newt_listbox_clear|newt_listbox_clear_selection|newt_listbox_delete_entry|newt_listbox_get_current|newt_listbox_get_selection|' + + 'newt_listbox_insert_entry|newt_listbox_item_count|newt_listbox_select_item|newt_listbox_set_current|newt_listbox_set_current_by_key|' + + 'newt_listbox_set_data|newt_listbox_set_entry|newt_listbox_set_width|newt_listitem|newt_listitem_get_data|newt_listitem_set|' + + 'newt_open_window|newt_pop_help_line|newt_pop_window|newt_push_help_line|newt_radio_get_current|newt_radiobutton|newt_redraw_help_line|' + + 'newt_reflow_text|newt_refresh|newt_resize_screen|newt_resume|newt_run_form|newt_scale|newt_scale_set|newt_scrollbar_set|' + + 'newt_set_help_callback|newt_set_suspend_callback|newt_suspend|newt_textbox|newt_textbox_get_num_lines|newt_textbox_reflowed|' + + 'newt_textbox_set_height|newt_textbox_set_text|newt_vertical_scrollbar|newt_wait_for_key|newt_win_choice|newt_win_entries|newt_win_menu|' + + 'newt_win_message|newt_win_messagev|newt_win_ternary|next|ngettext|nl2br|nl_langinfo|norewinditerator|normalizer|notes_body|notes_copy_db|' + + 'notes_create_db|notes_create_note|notes_drop_db|notes_find_note|notes_header_info|notes_list_msgs|notes_mark_read|notes_mark_unread|' + + 'notes_nav_create|notes_search|notes_unread|notes_version|nsapi_request_headers|nsapi_response_headers|nsapi_virtual|nthmac|number_format|' + + 'numberformatter|oauth|oauth_get_sbs|oauth_urlencode|oauthexception|oauthprovider|ob_clean|ob_deflatehandler|ob_end_clean|ob_end_flush|' + + 'ob_etaghandler|ob_flush|ob_get_clean|ob_get_contents|ob_get_flush|ob_get_length|ob_get_level|ob_get_status|ob_gzhandler|ob_iconv_handler|' + + 'ob_implicit_flush|ob_inflatehandler|ob_list_handlers|ob_start|ob_tidyhandler|oci_bind_array_by_name|oci_bind_by_name|oci_cancel|' + + 'oci_client_version|oci_close|oci_collection_append|oci_collection_assign|oci_collection_element_assign|oci_collection_element_get|' + + 'oci_collection_free|oci_collection_max|oci_collection_size|oci_collection_trim|oci_commit|oci_connect|oci_define_by_name|oci_error|' + + 'oci_execute|oci_fetch|oci_fetch_all|oci_fetch_array|oci_fetch_assoc|oci_fetch_object|oci_fetch_row|oci_field_is_null|oci_field_name|' + + 'oci_field_precision|oci_field_scale|oci_field_size|oci_field_type|oci_field_type_raw|oci_free_statement|oci_internal_debug|oci_lob_append|' + + 'oci_lob_close|oci_lob_copy|oci_lob_eof|oci_lob_erase|oci_lob_export|oci_lob_flush|oci_lob_free|oci_lob_getbuffering|oci_lob_import|' + + 'oci_lob_is_equal|oci_lob_load|oci_lob_read|oci_lob_rewind|oci_lob_save|oci_lob_savefile|oci_lob_seek|oci_lob_setbuffering|oci_lob_size|' + + 'oci_lob_tell|oci_lob_truncate|oci_lob_write|oci_lob_writetemporary|oci_lob_writetofile|oci_new_collection|oci_new_connect|oci_new_cursor|' + + 'oci_new_descriptor|oci_num_fields|oci_num_rows|oci_parse|oci_password_change|oci_pconnect|oci_result|oci_rollback|oci_server_version|' + + 'oci_set_action|oci_set_client_identifier|oci_set_client_info|oci_set_edition|oci_set_module_name|oci_set_prefetch|oci_statement_type|' + + 'ocibindbyname|ocicancel|ocicloselob|ocicollappend|ocicollassign|ocicollassignelem|ocicollgetelem|ocicollmax|ocicollsize|ocicolltrim|' + + 'ocicolumnisnull|ocicolumnname|ocicolumnprecision|ocicolumnscale|ocicolumnsize|ocicolumntype|ocicolumntyperaw|ocicommit|ocidefinebyname|' + + 'ocierror|ociexecute|ocifetch|ocifetchinto|ocifetchstatement|ocifreecollection|ocifreecursor|ocifreedesc|ocifreestatement|ociinternaldebug|' + + 'ociloadlob|ocilogoff|ocilogon|ocinewcollection|ocinewcursor|ocinewdescriptor|ocinlogon|ocinumcols|ociparse|ociplogon|ociresult|' + + 'ocirollback|ocirowcount|ocisavelob|ocisavelobfile|ociserverversion|ocisetprefetch|ocistatementtype|ociwritelobtofile|ociwritetemporarylob|' + + 'octdec|odbc_autocommit|odbc_binmode|odbc_close|odbc_close_all|odbc_columnprivileges|odbc_columns|odbc_commit|odbc_connect|odbc_cursor|' + + 'odbc_data_source|odbc_do|odbc_error|odbc_errormsg|odbc_exec|odbc_execute|odbc_fetch_array|odbc_fetch_into|odbc_fetch_object|' + + 'odbc_fetch_row|odbc_field_len|odbc_field_name|odbc_field_num|odbc_field_precision|odbc_field_scale|odbc_field_type|odbc_foreignkeys|' + + 'odbc_free_result|odbc_gettypeinfo|odbc_longreadlen|odbc_next_result|odbc_num_fields|odbc_num_rows|odbc_pconnect|odbc_prepare|' + + 'odbc_primarykeys|odbc_procedurecolumns|odbc_procedures|odbc_result|odbc_result_all|odbc_rollback|odbc_setoption|odbc_specialcolumns|' + + 'odbc_statistics|odbc_tableprivileges|odbc_tables|openal_buffer_create|openal_buffer_data|openal_buffer_destroy|openal_buffer_get|' + + 'openal_buffer_loadwav|openal_context_create|openal_context_current|openal_context_destroy|openal_context_process|openal_context_suspend|' + + 'openal_device_close|openal_device_open|openal_listener_get|openal_listener_set|openal_source_create|openal_source_destroy|' + + 'openal_source_get|openal_source_pause|openal_source_play|openal_source_rewind|openal_source_set|openal_source_stop|openal_stream|opendir|' + + 'openlog|openssl_cipher_iv_length|openssl_csr_export|openssl_csr_export_to_file|openssl_csr_get_public_key|openssl_csr_get_subject|' + + 'openssl_csr_new|openssl_csr_sign|openssl_decrypt|openssl_dh_compute_key|openssl_digest|openssl_encrypt|openssl_error_string|' + + 'openssl_free_key|openssl_get_cipher_methods|openssl_get_md_methods|openssl_get_privatekey|openssl_get_publickey|openssl_open|' + + 'openssl_pkcs12_export|openssl_pkcs12_export_to_file|openssl_pkcs12_read|openssl_pkcs7_decrypt|openssl_pkcs7_encrypt|openssl_pkcs7_sign|' + + 'openssl_pkcs7_verify|openssl_pkey_export|openssl_pkey_export_to_file|openssl_pkey_free|openssl_pkey_get_details|openssl_pkey_get_private|' + + 'openssl_pkey_get_public|openssl_pkey_new|openssl_private_decrypt|openssl_private_encrypt|openssl_public_decrypt|openssl_public_encrypt|' + + 'openssl_random_pseudo_bytes|openssl_seal|openssl_sign|openssl_verify|openssl_x509_check_private_key|openssl_x509_checkpurpose|' + + 'openssl_x509_export|openssl_x509_export_to_file|openssl_x509_free|openssl_x509_parse|openssl_x509_read|ord|outeriterator|' + + 'outofboundsexception|outofrangeexception|output_add_rewrite_var|output_reset_rewrite_vars|overflowexception|overload|override_function|' + + 'ovrimos_close|ovrimos_commit|ovrimos_connect|ovrimos_cursor|ovrimos_exec|ovrimos_execute|ovrimos_fetch_into|ovrimos_fetch_row|' + + 'ovrimos_field_len|ovrimos_field_name|ovrimos_field_num|ovrimos_field_type|ovrimos_free_result|ovrimos_longreadlen|ovrimos_num_fields|' + + 'ovrimos_num_rows|ovrimos_prepare|ovrimos_result|ovrimos_result_all|ovrimos_rollback|pack|parentiterator|parse_ini_file|parse_ini_string|' + + 'parse_str|parse_url|parsekit_compile_file|parsekit_compile_string|parsekit_func_arginfo|passthru|pathinfo|pclose|pcntl_alarm|pcntl_exec|' + + 'pcntl_fork|pcntl_getpriority|pcntl_setpriority|pcntl_signal|pcntl_signal_dispatch|pcntl_sigprocmask|pcntl_sigtimedwait|pcntl_sigwaitinfo|' + + 'pcntl_wait|pcntl_waitpid|pcntl_wexitstatus|pcntl_wifexited|pcntl_wifsignaled|pcntl_wifstopped|pcntl_wstopsig|pcntl_wtermsig|' + + 'pdf_activate_item|pdf_add_annotation|pdf_add_bookmark|pdf_add_launchlink|pdf_add_locallink|pdf_add_nameddest|pdf_add_note|pdf_add_outline|' + + 'pdf_add_pdflink|pdf_add_table_cell|pdf_add_textflow|pdf_add_thumbnail|pdf_add_weblink|pdf_arc|pdf_arcn|pdf_attach_file|pdf_begin_document|' + + 'pdf_begin_font|pdf_begin_glyph|pdf_begin_item|pdf_begin_layer|pdf_begin_page|pdf_begin_page_ext|pdf_begin_pattern|pdf_begin_template|' + + 'pdf_begin_template_ext|pdf_circle|pdf_clip|pdf_close|pdf_close_image|pdf_close_pdi|pdf_close_pdi_page|pdf_closepath|' + + 'pdf_closepath_fill_stroke|pdf_closepath_stroke|pdf_concat|pdf_continue_text|pdf_create_3dview|pdf_create_action|pdf_create_annotation|' + + 'pdf_create_bookmark|pdf_create_field|pdf_create_fieldgroup|pdf_create_gstate|pdf_create_pvf|pdf_create_textflow|pdf_curveto|' + + 'pdf_define_layer|pdf_delete|pdf_delete_pvf|pdf_delete_table|pdf_delete_textflow|pdf_encoding_set_char|pdf_end_document|pdf_end_font|' + + 'pdf_end_glyph|pdf_end_item|pdf_end_layer|pdf_end_page|pdf_end_page_ext|pdf_end_pattern|pdf_end_template|pdf_endpath|pdf_fill|' + + 'pdf_fill_imageblock|pdf_fill_pdfblock|pdf_fill_stroke|pdf_fill_textblock|pdf_findfont|pdf_fit_image|pdf_fit_pdi_page|pdf_fit_table|' + + 'pdf_fit_textflow|pdf_fit_textline|pdf_get_apiname|pdf_get_buffer|pdf_get_errmsg|pdf_get_errnum|pdf_get_font|pdf_get_fontname|' + + 'pdf_get_fontsize|pdf_get_image_height|pdf_get_image_width|pdf_get_majorversion|pdf_get_minorversion|pdf_get_parameter|' + + 'pdf_get_pdi_parameter|pdf_get_pdi_value|pdf_get_value|pdf_info_font|pdf_info_matchbox|pdf_info_table|pdf_info_textflow|pdf_info_textline|' + + 'pdf_initgraphics|pdf_lineto|pdf_load_3ddata|pdf_load_font|pdf_load_iccprofile|pdf_load_image|pdf_makespotcolor|pdf_moveto|pdf_new|' + + 'pdf_open_ccitt|pdf_open_file|pdf_open_gif|pdf_open_image|pdf_open_image_file|pdf_open_jpeg|pdf_open_memory_image|pdf_open_pdi|' + + 'pdf_open_pdi_document|pdf_open_pdi_page|pdf_open_tiff|pdf_pcos_get_number|pdf_pcos_get_stream|pdf_pcos_get_string|pdf_place_image|' + + 'pdf_place_pdi_page|pdf_process_pdi|pdf_rect|pdf_restore|pdf_resume_page|pdf_rotate|pdf_save|pdf_scale|pdf_set_border_color|' + + 'pdf_set_border_dash|pdf_set_border_style|pdf_set_char_spacing|pdf_set_duration|pdf_set_gstate|pdf_set_horiz_scaling|pdf_set_info|' + + 'pdf_set_info_author|pdf_set_info_creator|pdf_set_info_keywords|pdf_set_info_subject|pdf_set_info_title|pdf_set_layer_dependency|' + + 'pdf_set_leading|pdf_set_parameter|pdf_set_text_matrix|pdf_set_text_pos|pdf_set_text_rendering|pdf_set_text_rise|pdf_set_value|' + + 'pdf_set_word_spacing|pdf_setcolor|pdf_setdash|pdf_setdashpattern|pdf_setflat|pdf_setfont|pdf_setgray|pdf_setgray_fill|pdf_setgray_stroke|' + + 'pdf_setlinecap|pdf_setlinejoin|pdf_setlinewidth|pdf_setmatrix|pdf_setmiterlimit|pdf_setpolydash|pdf_setrgbcolor|pdf_setrgbcolor_fill|' + + 'pdf_setrgbcolor_stroke|pdf_shading|pdf_shading_pattern|pdf_shfill|pdf_show|pdf_show_boxed|pdf_show_xy|pdf_skew|pdf_stringwidth|pdf_stroke|' + + 'pdf_suspend_page|pdf_translate|pdf_utf16_to_utf8|pdf_utf32_to_utf16|pdf_utf8_to_utf16|pdo|pdo_cubrid_schema|pdo_pgsqllobcreate|' + + 'pdo_pgsqllobopen|pdo_pgsqllobunlink|pdo_sqlitecreateaggregate|pdo_sqlitecreatefunction|pdoexception|pdostatement|pfsockopen|' + + 'pg_affected_rows|pg_cancel_query|pg_client_encoding|pg_close|pg_connect|pg_connection_busy|pg_connection_reset|pg_connection_status|' + + 'pg_convert|pg_copy_from|pg_copy_to|pg_dbname|pg_delete|pg_end_copy|pg_escape_bytea|pg_escape_string|pg_execute|pg_fetch_all|' + + 'pg_fetch_all_columns|pg_fetch_array|pg_fetch_assoc|pg_fetch_object|pg_fetch_result|pg_fetch_row|pg_field_is_null|pg_field_name|' + + 'pg_field_num|pg_field_prtlen|pg_field_size|pg_field_table|pg_field_type|pg_field_type_oid|pg_free_result|pg_get_notify|pg_get_pid|' + + 'pg_get_result|pg_host|pg_insert|pg_last_error|pg_last_notice|pg_last_oid|pg_lo_close|pg_lo_create|pg_lo_export|pg_lo_import|pg_lo_open|' + + 'pg_lo_read|pg_lo_read_all|pg_lo_seek|pg_lo_tell|pg_lo_unlink|pg_lo_write|pg_meta_data|pg_num_fields|pg_num_rows|pg_options|' + + 'pg_parameter_status|pg_pconnect|pg_ping|pg_port|pg_prepare|pg_put_line|pg_query|pg_query_params|pg_result_error|pg_result_error_field|' + + 'pg_result_seek|pg_result_status|pg_select|pg_send_execute|pg_send_prepare|pg_send_query|pg_send_query_params|pg_set_client_encoding|' + + 'pg_set_error_verbosity|pg_trace|pg_transaction_status|pg_tty|pg_unescape_bytea|pg_untrace|pg_update|pg_version|php_check_syntax|' + + 'php_ini_loaded_file|php_ini_scanned_files|php_logo_guid|php_sapi_name|php_strip_whitespace|php_uname|phpcredits|phpinfo|phpversion|pi|' + + 'png2wbmp|popen|pos|posix_access|posix_ctermid|posix_errno|posix_get_last_error|posix_getcwd|posix_getegid|posix_geteuid|posix_getgid|' + + 'posix_getgrgid|posix_getgrnam|posix_getgroups|posix_getlogin|posix_getpgid|posix_getpgrp|posix_getpid|posix_getppid|posix_getpwnam|' + + 'posix_getpwuid|posix_getrlimit|posix_getsid|posix_getuid|posix_initgroups|posix_isatty|posix_kill|posix_mkfifo|posix_mknod|posix_setegid|' + + 'posix_seteuid|posix_setgid|posix_setpgid|posix_setsid|posix_setuid|posix_strerror|posix_times|posix_ttyname|posix_uname|pow|preg_filter|' + + 'preg_grep|preg_last_error|preg_match|preg_match_all|preg_quote|preg_replace|preg_replace_callback|preg_split|prev|print|print_r|' + + 'printer_abort|printer_close|printer_create_brush|printer_create_dc|printer_create_font|printer_create_pen|printer_delete_brush|' + + 'printer_delete_dc|printer_delete_font|printer_delete_pen|printer_draw_bmp|printer_draw_chord|printer_draw_elipse|printer_draw_line|' + + 'printer_draw_pie|printer_draw_rectangle|printer_draw_roundrect|printer_draw_text|printer_end_doc|printer_end_page|printer_get_option|' + + 'printer_list|printer_logical_fontheight|printer_open|printer_select_brush|printer_select_font|printer_select_pen|printer_set_option|' + + 'printer_start_doc|printer_start_page|printer_write|printf|proc_close|proc_get_status|proc_nice|proc_open|proc_terminate|property_exists|' + + 'ps_add_bookmark|ps_add_launchlink|ps_add_locallink|ps_add_note|ps_add_pdflink|ps_add_weblink|ps_arc|ps_arcn|ps_begin_page|' + + 'ps_begin_pattern|ps_begin_template|ps_circle|ps_clip|ps_close|ps_close_image|ps_closepath|ps_closepath_stroke|ps_continue_text|ps_curveto|' + + 'ps_delete|ps_end_page|ps_end_pattern|ps_end_template|ps_fill|ps_fill_stroke|ps_findfont|ps_get_buffer|ps_get_parameter|ps_get_value|' + + 'ps_hyphenate|ps_include_file|ps_lineto|ps_makespotcolor|ps_moveto|ps_new|ps_open_file|ps_open_image|ps_open_image_file|' + + 'ps_open_memory_image|ps_place_image|ps_rect|ps_restore|ps_rotate|ps_save|ps_scale|ps_set_border_color|ps_set_border_dash|' + + 'ps_set_border_style|ps_set_info|ps_set_parameter|ps_set_text_pos|ps_set_value|ps_setcolor|ps_setdash|ps_setflat|ps_setfont|ps_setgray|' + + 'ps_setlinecap|ps_setlinejoin|ps_setlinewidth|ps_setmiterlimit|ps_setoverprintmode|ps_setpolydash|ps_shading|ps_shading_pattern|ps_shfill|' + + 'ps_show|ps_show2|ps_show_boxed|ps_show_xy|ps_show_xy2|ps_string_geometry|ps_stringwidth|ps_stroke|ps_symbol|ps_symbol_name|' + + 'ps_symbol_width|ps_translate|pspell_add_to_personal|pspell_add_to_session|pspell_check|pspell_clear_session|pspell_config_create|' + + 'pspell_config_data_dir|pspell_config_dict_dir|pspell_config_ignore|pspell_config_mode|pspell_config_personal|pspell_config_repl|' + + 'pspell_config_runtogether|pspell_config_save_repl|pspell_new|pspell_new_config|pspell_new_personal|pspell_save_wordlist|' + + 'pspell_store_replacement|pspell_suggest|putenv|px_close|px_create_fp|px_date2string|px_delete|px_delete_record|px_get_field|px_get_info|' + + 'px_get_parameter|px_get_record|px_get_schema|px_get_value|px_insert_record|px_new|px_numfields|px_numrecords|px_open_fp|px_put_record|' + + 'px_retrieve_record|px_set_blob_file|px_set_parameter|px_set_tablename|px_set_targetencoding|px_set_value|px_timestamp2string|' + + 'px_update_record|qdom_error|qdom_tree|quoted_printable_decode|quoted_printable_encode|quotemeta|rad2deg|radius_acct_open|' + + 'radius_add_server|radius_auth_open|radius_close|radius_config|radius_create_request|radius_cvt_addr|radius_cvt_int|radius_cvt_string|' + + 'radius_demangle|radius_demangle_mppe_key|radius_get_attr|radius_get_vendor_attr|radius_put_addr|radius_put_attr|radius_put_int|' + + 'radius_put_string|radius_put_vendor_addr|radius_put_vendor_attr|radius_put_vendor_int|radius_put_vendor_string|' + + 'radius_request_authenticator|radius_send_request|radius_server_secret|radius_strerror|rand|range|rangeexception|rar_wrapper_cache_stats|' + + 'rararchive|rarentry|rarexception|rawurldecode|rawurlencode|read_exif_data|readdir|readfile|readgzfile|readline|readline_add_history|' + + 'readline_callback_handler_install|readline_callback_handler_remove|readline_callback_read_char|readline_clear_history|' + + 'readline_completion_function|readline_info|readline_list_history|readline_on_new_line|readline_read_history|readline_redisplay|' + + 'readline_write_history|readlink|realpath|realpath_cache_get|realpath_cache_size|recode|recode_file|recode_string|recursivearrayiterator|' + + 'recursivecachingiterator|recursivecallbackfilteriterator|recursivedirectoryiterator|recursivefilteriterator|recursiveiterator|' + + 'recursiveiteratoriterator|recursiveregexiterator|recursivetreeiterator|reflection|reflectionclass|reflectionexception|reflectionextension|' + + 'reflectionfunction|reflectionfunctionabstract|reflectionmethod|reflectionobject|reflectionparameter|reflectionproperty|reflector|' + + 'regexiterator|register_shutdown_function|register_tick_function|rename|rename_function|require|require_once|reset|resetValue|' + + 'resourcebundle|restore_error_handler|restore_exception_handler|restore_include_path|return|rewind|rewinddir|rmdir|round|rpm_close|' + + 'rpm_get_tag|rpm_is_valid|rpm_open|rpm_version|rrd_create|rrd_error|rrd_fetch|rrd_first|rrd_graph|rrd_info|rrd_last|rrd_lastupdate|' + + 'rrd_restore|rrd_tune|rrd_update|rrd_xport|rrdcreator|rrdgraph|rrdupdater|rsort|rtrim|runkit_class_adopt|runkit_class_emancipate|' + + 'runkit_constant_add|runkit_constant_redefine|runkit_constant_remove|runkit_function_add|runkit_function_copy|runkit_function_redefine|' + + 'runkit_function_remove|runkit_function_rename|runkit_import|runkit_lint|runkit_lint_file|runkit_method_add|runkit_method_copy|' + + 'runkit_method_redefine|runkit_method_remove|runkit_method_rename|runkit_return_value_used|runkit_sandbox_output_handler|' + + 'runkit_superglobals|runtimeexception|samconnection_commit|samconnection_connect|samconnection_constructor|samconnection_disconnect|' + + 'samconnection_errno|samconnection_error|samconnection_isconnected|samconnection_peek|samconnection_peekall|samconnection_receive|' + + 'samconnection_remove|samconnection_rollback|samconnection_send|samconnection_setDebug|samconnection_subscribe|samconnection_unsubscribe|' + + 'sammessage_body|sammessage_constructor|sammessage_header|sca_createdataobject|sca_getservice|sca_localproxy_createdataobject|' + + 'sca_soapproxy_createdataobject|scandir|sdo_das_changesummary_beginlogging|sdo_das_changesummary_endlogging|' + + 'sdo_das_changesummary_getchangeddataobjects|sdo_das_changesummary_getchangetype|sdo_das_changesummary_getoldcontainer|' + + 'sdo_das_changesummary_getoldvalues|sdo_das_changesummary_islogging|sdo_das_datafactory_addpropertytotype|sdo_das_datafactory_addtype|' + + 'sdo_das_datafactory_getdatafactory|sdo_das_dataobject_getchangesummary|sdo_das_relational_applychanges|sdo_das_relational_construct|' + + 'sdo_das_relational_createrootdataobject|sdo_das_relational_executepreparedquery|sdo_das_relational_executequery|' + + 'sdo_das_setting_getlistindex|sdo_das_setting_getpropertyindex|sdo_das_setting_getpropertyname|sdo_das_setting_getvalue|' + + 'sdo_das_setting_isset|sdo_das_xml_addtypes|sdo_das_xml_create|sdo_das_xml_createdataobject|sdo_das_xml_createdocument|' + + 'sdo_das_xml_document_getrootdataobject|sdo_das_xml_document_getrootelementname|sdo_das_xml_document_getrootelementuri|' + + 'sdo_das_xml_document_setencoding|sdo_das_xml_document_setxmldeclaration|sdo_das_xml_document_setxmlversion|sdo_das_xml_loadfile|' + + 'sdo_das_xml_loadstring|sdo_das_xml_savefile|sdo_das_xml_savestring|sdo_datafactory_create|sdo_dataobject_clear|' + + 'sdo_dataobject_createdataobject|sdo_dataobject_getcontainer|sdo_dataobject_getsequence|sdo_dataobject_gettypename|' + + 'sdo_dataobject_gettypenamespaceuri|sdo_exception_getcause|sdo_list_insert|sdo_model_property_getcontainingtype|' + + 'sdo_model_property_getdefault|sdo_model_property_getname|sdo_model_property_gettype|sdo_model_property_iscontainment|' + + 'sdo_model_property_ismany|sdo_model_reflectiondataobject_construct|sdo_model_reflectiondataobject_export|' + + 'sdo_model_reflectiondataobject_getcontainmentproperty|sdo_model_reflectiondataobject_getinstanceproperties|' + + 'sdo_model_reflectiondataobject_gettype|sdo_model_type_getbasetype|sdo_model_type_getname|sdo_model_type_getnamespaceuri|' + + 'sdo_model_type_getproperties|sdo_model_type_getproperty|sdo_model_type_isabstracttype|sdo_model_type_isdatatype|sdo_model_type_isinstance|' + + 'sdo_model_type_isopentype|sdo_model_type_issequencedtype|sdo_sequence_getproperty|sdo_sequence_insert|sdo_sequence_move|seekableiterator|' + + 'sem_acquire|sem_get|sem_release|sem_remove|serializable|serialize|session_cache_expire|session_cache_limiter|session_commit|' + + 'session_decode|session_destroy|session_encode|session_get_cookie_params|session_id|session_is_registered|session_module_name|session_name|' + + 'session_pgsql_add_error|session_pgsql_get_error|session_pgsql_get_field|session_pgsql_reset|session_pgsql_set_field|session_pgsql_status|' + + 'session_regenerate_id|session_register|session_save_path|session_set_cookie_params|session_set_save_handler|session_start|' + + 'session_unregister|session_unset|session_write_close|setCounterClass|set_error_handler|set_exception_handler|set_file_buffer|' + + 'set_include_path|set_magic_quotes_runtime|set_socket_blocking|set_time_limit|setcookie|setlocale|setproctitle|setrawcookie|' + + 'setstaticpropertyvalue|setthreadtitle|settype|sha1|sha1_file|shell_exec|shm_attach|shm_detach|shm_get_var|shm_has_var|shm_put_var|' + + 'shm_remove|shm_remove_var|shmop_close|shmop_delete|shmop_open|shmop_read|shmop_size|shmop_write|show_source|shuffle|signeurlpaiement|' + + 'similar_text|simplexml_import_dom|simplexml_load_file|simplexml_load_string|simplexmlelement|simplexmliterator|sin|sinh|sizeof|sleep|snmp|' + + 'snmp2_get|snmp2_getnext|snmp2_real_walk|snmp2_set|snmp2_walk|snmp3_get|snmp3_getnext|snmp3_real_walk|snmp3_set|snmp3_walk|' + + 'snmp_get_quick_print|snmp_get_valueretrieval|snmp_read_mib|snmp_set_enum_print|snmp_set_oid_numeric_print|snmp_set_oid_output_format|' + + 'snmp_set_quick_print|snmp_set_valueretrieval|snmpget|snmpgetnext|snmprealwalk|snmpset|snmpwalk|snmpwalkoid|soapclient|soapfault|' + + 'soapheader|soapparam|soapserver|soapvar|socket_accept|socket_bind|socket_clear_error|socket_close|socket_connect|socket_create|' + + 'socket_create_listen|socket_create_pair|socket_get_option|socket_get_status|socket_getpeername|socket_getsockname|socket_last_error|' + + 'socket_listen|socket_read|socket_recv|socket_recvfrom|socket_select|socket_send|socket_sendto|socket_set_block|socket_set_blocking|' + + 'socket_set_nonblock|socket_set_option|socket_set_timeout|socket_shutdown|socket_strerror|socket_write|solr_get_version|solrclient|' + + 'solrclientexception|solrdocument|solrdocumentfield|solrexception|solrgenericresponse|solrillegalargumentexception|' + + 'solrillegaloperationexception|solrinputdocument|solrmodifiableparams|solrobject|solrparams|solrpingresponse|solrquery|solrqueryresponse|' + + 'solrresponse|solrupdateresponse|solrutils|sort|soundex|sphinxclient|spl_autoload|spl_autoload_call|spl_autoload_extensions|' + + 'spl_autoload_functions|spl_autoload_register|spl_autoload_unregister|spl_classes|spl_object_hash|splbool|spldoublylinkedlist|splenum|' + + 'splfileinfo|splfileobject|splfixedarray|splfloat|splheap|splint|split|spliti|splmaxheap|splminheap|splobjectstorage|splobserver|' + + 'splpriorityqueue|splqueue|splstack|splstring|splsubject|spltempfileobject|spoofchecker|sprintf|sql_regcase|sqlite3|sqlite3result|' + + 'sqlite3stmt|sqlite_array_query|sqlite_busy_timeout|sqlite_changes|sqlite_close|sqlite_column|sqlite_create_aggregate|' + + 'sqlite_create_function|sqlite_current|sqlite_error_string|sqlite_escape_string|sqlite_exec|sqlite_factory|sqlite_fetch_all|' + + 'sqlite_fetch_array|sqlite_fetch_column_types|sqlite_fetch_object|sqlite_fetch_single|sqlite_fetch_string|sqlite_field_name|' + + 'sqlite_has_more|sqlite_has_prev|sqlite_key|sqlite_last_error|sqlite_last_insert_rowid|sqlite_libencoding|sqlite_libversion|sqlite_next|' + + 'sqlite_num_fields|sqlite_num_rows|sqlite_open|sqlite_popen|sqlite_prev|sqlite_query|sqlite_rewind|sqlite_seek|sqlite_single_query|' + + 'sqlite_udf_decode_binary|sqlite_udf_encode_binary|sqlite_unbuffered_query|sqlite_valid|sqrt|srand|sscanf|ssdeep_fuzzy_compare|' + + 'ssdeep_fuzzy_hash|ssdeep_fuzzy_hash_filename|ssh2_auth_hostbased_file|ssh2_auth_none|ssh2_auth_password|ssh2_auth_pubkey_file|' + + 'ssh2_connect|ssh2_exec|ssh2_fetch_stream|ssh2_fingerprint|ssh2_methods_negotiated|ssh2_publickey_add|ssh2_publickey_init|' + + 'ssh2_publickey_list|ssh2_publickey_remove|ssh2_scp_recv|ssh2_scp_send|ssh2_sftp|ssh2_sftp_lstat|ssh2_sftp_mkdir|ssh2_sftp_readlink|' + + 'ssh2_sftp_realpath|ssh2_sftp_rename|ssh2_sftp_rmdir|ssh2_sftp_stat|ssh2_sftp_symlink|ssh2_sftp_unlink|ssh2_shell|ssh2_tunnel|stat|' + + 'stats_absolute_deviation|stats_cdf_beta|stats_cdf_binomial|stats_cdf_cauchy|stats_cdf_chisquare|stats_cdf_exponential|stats_cdf_f|' + + 'stats_cdf_gamma|stats_cdf_laplace|stats_cdf_logistic|stats_cdf_negative_binomial|stats_cdf_noncentral_chisquare|stats_cdf_noncentral_f|' + + 'stats_cdf_poisson|stats_cdf_t|stats_cdf_uniform|stats_cdf_weibull|stats_covariance|stats_den_uniform|stats_dens_beta|stats_dens_cauchy|' + + 'stats_dens_chisquare|stats_dens_exponential|stats_dens_f|stats_dens_gamma|stats_dens_laplace|stats_dens_logistic|' + + 'stats_dens_negative_binomial|stats_dens_normal|stats_dens_pmf_binomial|stats_dens_pmf_hypergeometric|stats_dens_pmf_poisson|stats_dens_t|' + + 'stats_dens_weibull|stats_harmonic_mean|stats_kurtosis|stats_rand_gen_beta|stats_rand_gen_chisquare|stats_rand_gen_exponential|' + + 'stats_rand_gen_f|stats_rand_gen_funiform|stats_rand_gen_gamma|stats_rand_gen_ibinomial|stats_rand_gen_ibinomial_negative|' + + 'stats_rand_gen_int|stats_rand_gen_ipoisson|stats_rand_gen_iuniform|stats_rand_gen_noncenral_chisquare|stats_rand_gen_noncentral_f|' + + 'stats_rand_gen_noncentral_t|stats_rand_gen_normal|stats_rand_gen_t|stats_rand_get_seeds|stats_rand_phrase_to_seeds|stats_rand_ranf|' + + 'stats_rand_setall|stats_skew|stats_standard_deviation|stats_stat_binomial_coef|stats_stat_correlation|stats_stat_gennch|' + + 'stats_stat_independent_t|stats_stat_innerproduct|stats_stat_noncentral_t|stats_stat_paired_t|stats_stat_percentile|stats_stat_powersum|' + + 'stats_variance|stomp|stomp_connect_error|stomp_version|stompexception|stompframe|str_getcsv|str_ireplace|str_pad|str_repeat|str_replace|' + + 'str_rot13|str_shuffle|str_split|str_word_count|strcasecmp|strchr|strcmp|strcoll|strcspn|stream_bucket_append|stream_bucket_make_writeable|' + + 'stream_bucket_new|stream_bucket_prepend|stream_context_create|stream_context_get_default|stream_context_get_options|' + + 'stream_context_get_params|stream_context_set_default|stream_context_set_option|stream_context_set_params|stream_copy_to_stream|' + + 'stream_encoding|stream_filter_append|stream_filter_prepend|stream_filter_register|stream_filter_remove|stream_get_contents|' + + 'stream_get_filters|stream_get_line|stream_get_meta_data|stream_get_transports|stream_get_wrappers|stream_is_local|' + + 'stream_notification_callback|stream_register_wrapper|stream_resolve_include_path|stream_select|stream_set_blocking|stream_set_read_buffer|' + + 'stream_set_timeout|stream_set_write_buffer|stream_socket_accept|stream_socket_client|stream_socket_enable_crypto|stream_socket_get_name|' + + 'stream_socket_pair|stream_socket_recvfrom|stream_socket_sendto|stream_socket_server|stream_socket_shutdown|stream_supports_lock|' + + 'stream_wrapper_register|stream_wrapper_restore|stream_wrapper_unregister|streamwrapper|strftime|strip_tags|stripcslashes|stripos|' + + 'stripslashes|stristr|strlen|strnatcasecmp|strnatcmp|strncasecmp|strncmp|strpbrk|strpos|strptime|strrchr|strrev|strripos|strrpos|strspn|' + + 'strstr|strtok|strtolower|strtotime|strtoupper|strtr|strval|substr|substr_compare|substr_count|substr_replace|svm|svmmodel|svn_add|' + + 'svn_auth_get_parameter|svn_auth_set_parameter|svn_blame|svn_cat|svn_checkout|svn_cleanup|svn_client_version|svn_commit|svn_delete|' + + 'svn_diff|svn_export|svn_fs_abort_txn|svn_fs_apply_text|svn_fs_begin_txn2|svn_fs_change_node_prop|svn_fs_check_path|' + + 'svn_fs_contents_changed|svn_fs_copy|svn_fs_delete|svn_fs_dir_entries|svn_fs_file_contents|svn_fs_file_length|svn_fs_is_dir|svn_fs_is_file|' + + 'svn_fs_make_dir|svn_fs_make_file|svn_fs_node_created_rev|svn_fs_node_prop|svn_fs_props_changed|svn_fs_revision_prop|svn_fs_revision_root|' + + 'svn_fs_txn_root|svn_fs_youngest_rev|svn_import|svn_log|svn_ls|svn_mkdir|svn_repos_create|svn_repos_fs|svn_repos_fs_begin_txn_for_commit|' + + 'svn_repos_fs_commit_txn|svn_repos_hotcopy|svn_repos_open|svn_repos_recover|svn_revert|svn_status|svn_update|swf_actiongeturl|' + + 'swf_actiongotoframe|swf_actiongotolabel|swf_actionnextframe|swf_actionplay|swf_actionprevframe|swf_actionsettarget|swf_actionstop|' + + 'swf_actiontogglequality|swf_actionwaitforframe|swf_addbuttonrecord|swf_addcolor|swf_closefile|swf_definebitmap|swf_definefont|' + + 'swf_defineline|swf_definepoly|swf_definerect|swf_definetext|swf_endbutton|swf_enddoaction|swf_endshape|swf_endsymbol|swf_fontsize|' + + 'swf_fontslant|swf_fonttracking|swf_getbitmapinfo|swf_getfontinfo|swf_getframe|swf_labelframe|swf_lookat|swf_modifyobject|swf_mulcolor|' + + 'swf_nextid|swf_oncondition|swf_openfile|swf_ortho|swf_ortho2|swf_perspective|swf_placeobject|swf_polarview|swf_popmatrix|swf_posround|' + + 'swf_pushmatrix|swf_removeobject|swf_rotate|swf_scale|swf_setfont|swf_setframe|swf_shapearc|swf_shapecurveto|swf_shapecurveto3|' + + 'swf_shapefillbitmapclip|swf_shapefillbitmaptile|swf_shapefilloff|swf_shapefillsolid|swf_shapelinesolid|swf_shapelineto|swf_shapemoveto|' + + 'swf_showframe|swf_startbutton|swf_startdoaction|swf_startshape|swf_startsymbol|swf_textwidth|swf_translate|swf_viewport|swfaction|' + + 'swfbitmap|swfbutton|swfdisplayitem|swffill|swffont|swffontchar|swfgradient|swfmorph|swfmovie|swfprebuiltclip|swfshape|swfsound|' + + 'swfsoundinstance|swfsprite|swftext|swftextfield|swfvideostream|swish_construct|swish_getmetalist|swish_getpropertylist|swish_prepare|' + + 'swish_query|swishresult_getmetalist|swishresult_stem|swishresults_getparsedwords|swishresults_getremovedstopwords|swishresults_nextresult|' + + 'swishresults_seekresult|swishsearch_execute|swishsearch_resetlimit|swishsearch_setlimit|swishsearch_setphrasedelimiter|' + + 'swishsearch_setsort|swishsearch_setstructure|sybase_affected_rows|sybase_close|sybase_connect|sybase_data_seek|' + + 'sybase_deadlock_retry_count|sybase_fetch_array|sybase_fetch_assoc|sybase_fetch_field|sybase_fetch_object|sybase_fetch_row|' + + 'sybase_field_seek|sybase_free_result|sybase_get_last_message|sybase_min_client_severity|sybase_min_error_severity|' + + 'sybase_min_message_severity|sybase_min_server_severity|sybase_num_fields|sybase_num_rows|sybase_pconnect|sybase_query|sybase_result|' + + 'sybase_select_db|sybase_set_message_handler|sybase_unbuffered_query|symlink|sys_get_temp_dir|sys_getloadavg|syslog|system|tag|tan|tanh|' + + 'tcpwrap_check|tempnam|textdomain|tidy|tidy_access_count|tidy_config_count|tidy_diagnose|tidy_error_count|tidy_get_error_buffer|' + + 'tidy_get_output|tidy_load_config|tidy_reset_config|tidy_save_config|tidy_set_encoding|tidy_setopt|tidy_warning_count|tidynode|time|' + + 'time_nanosleep|time_sleep_until|timezone_abbreviations_list|timezone_identifiers_list|timezone_location_get|timezone_name_from_abbr|' + + 'timezone_name_get|timezone_offset_get|timezone_open|timezone_transitions_get|timezone_version_get|tmpfile|token_get_all|token_name|' + + 'tokyotyrant|tokyotyrantquery|tokyotyranttable|tostring|tostring|touch|transliterator|traversable|trigger_error|trim|uasort|ucfirst|' + + 'ucwords|udm_add_search_limit|udm_alloc_agent|udm_alloc_agent_array|udm_api_version|udm_cat_list|udm_cat_path|udm_check_charset|' + + 'udm_check_stored|udm_clear_search_limits|udm_close_stored|udm_crc32|udm_errno|udm_error|udm_find|udm_free_agent|udm_free_ispell_data|' + + 'udm_free_res|udm_get_doc_count|udm_get_res_field|udm_get_res_param|udm_hash32|udm_load_ispell_data|udm_open_stored|udm_set_agent_param|' + + 'uksort|umask|underflowexception|unexpectedvalueexception|uniqid|unixtojd|unlink|unpack|unregister_tick_function|unserialize|unset|' + + 'urldecode|urlencode|use_soap_error_handler|user_error|usleep|usort|utf8_decode|utf8_encode|v8js|v8jsexception|var_dump|var_export|variant|' + + 'variant_abs|variant_add|variant_and|variant_cast|variant_cat|variant_cmp|variant_date_from_timestamp|variant_date_to_timestamp|' + + 'variant_div|variant_eqv|variant_fix|variant_get_type|variant_idiv|variant_imp|variant_int|variant_mod|variant_mul|variant_neg|variant_not|' + + 'variant_or|variant_pow|variant_round|variant_set|variant_set_type|variant_sub|variant_xor|version_compare|vfprintf|virtual|' + + 'vpopmail_add_alias_domain|vpopmail_add_alias_domain_ex|vpopmail_add_domain|vpopmail_add_domain_ex|vpopmail_add_user|vpopmail_alias_add|' + + 'vpopmail_alias_del|vpopmail_alias_del_domain|vpopmail_alias_get|vpopmail_alias_get_all|vpopmail_auth_user|vpopmail_del_domain|' + + 'vpopmail_del_domain_ex|vpopmail_del_user|vpopmail_error|vpopmail_passwd|vpopmail_set_user_quota|vprintf|vsprintf|w32api_deftype|' + + 'w32api_init_dtype|w32api_invoke_function|w32api_register_function|w32api_set_call_method|wddx_add_vars|wddx_deserialize|wddx_packet_end|' + + 'wddx_packet_start|wddx_serialize_value|wddx_serialize_vars|win32_continue_service|win32_create_service|win32_delete_service|' + + 'win32_get_last_control_message|win32_pause_service|win32_ps_list_procs|win32_ps_stat_mem|win32_ps_stat_proc|win32_query_service_status|' + + 'win32_set_service_status|win32_start_service|win32_start_service_ctrl_dispatcher|win32_stop_service|wincache_fcache_fileinfo|' + + 'wincache_fcache_meminfo|wincache_lock|wincache_ocache_fileinfo|wincache_ocache_meminfo|wincache_refresh_if_changed|' + + 'wincache_rplist_fileinfo|wincache_rplist_meminfo|wincache_scache_info|wincache_scache_meminfo|wincache_ucache_add|wincache_ucache_cas|' + + 'wincache_ucache_clear|wincache_ucache_dec|wincache_ucache_delete|wincache_ucache_exists|wincache_ucache_get|wincache_ucache_inc|' + + 'wincache_ucache_info|wincache_ucache_meminfo|wincache_ucache_set|wincache_unlock|wordwrap|xattr_get|xattr_list|xattr_remove|xattr_set|' + + 'xattr_supported|xdiff_file_bdiff|xdiff_file_bdiff_size|xdiff_file_bpatch|xdiff_file_diff|xdiff_file_diff_binary|xdiff_file_merge3|' + + 'xdiff_file_patch|xdiff_file_patch_binary|xdiff_file_rabdiff|xdiff_string_bdiff|xdiff_string_bdiff_size|xdiff_string_bpatch|' + + 'xdiff_string_diff|xdiff_string_diff_binary|xdiff_string_merge3|xdiff_string_patch|xdiff_string_patch_binary|xdiff_string_rabdiff|' + + 'xhprof_disable|xhprof_enable|xhprof_sample_disable|xhprof_sample_enable|xml_error_string|xml_get_current_byte_index|' + + 'xml_get_current_column_number|xml_get_current_line_number|xml_get_error_code|xml_parse|xml_parse_into_struct|xml_parser_create|' + + 'xml_parser_create_ns|xml_parser_free|xml_parser_get_option|xml_parser_set_option|xml_set_character_data_handler|xml_set_default_handler|' + + 'xml_set_element_handler|xml_set_end_namespace_decl_handler|xml_set_external_entity_ref_handler|xml_set_notation_decl_handler|' + + 'xml_set_object|xml_set_processing_instruction_handler|xml_set_start_namespace_decl_handler|xml_set_unparsed_entity_decl_handler|xmlreader|' + + 'xmlrpc_decode|xmlrpc_decode_request|xmlrpc_encode|xmlrpc_encode_request|xmlrpc_get_type|xmlrpc_is_fault|xmlrpc_parse_method_descriptions|' + + 'xmlrpc_server_add_introspection_data|xmlrpc_server_call_method|xmlrpc_server_create|xmlrpc_server_destroy|' + + 'xmlrpc_server_register_introspection_callback|xmlrpc_server_register_method|xmlrpc_set_type|xmlwriter_end_attribute|xmlwriter_end_cdata|' + + 'xmlwriter_end_comment|xmlwriter_end_document|xmlwriter_end_dtd|xmlwriter_end_dtd_attlist|xmlwriter_end_dtd_element|' + + 'xmlwriter_end_dtd_entity|xmlwriter_end_element|xmlwriter_end_pi|xmlwriter_flush|xmlwriter_full_end_element|xmlwriter_open_memory|' + + 'xmlwriter_open_uri|xmlwriter_output_memory|xmlwriter_set_indent|xmlwriter_set_indent_string|xmlwriter_start_attribute|' + + 'xmlwriter_start_attribute_ns|xmlwriter_start_cdata|xmlwriter_start_comment|xmlwriter_start_document|xmlwriter_start_dtd|' + + 'xmlwriter_start_dtd_attlist|xmlwriter_start_dtd_element|xmlwriter_start_dtd_entity|xmlwriter_start_element|xmlwriter_start_element_ns|' + + 'xmlwriter_start_pi|xmlwriter_text|xmlwriter_write_attribute|xmlwriter_write_attribute_ns|xmlwriter_write_cdata|xmlwriter_write_comment|' + + 'xmlwriter_write_dtd|xmlwriter_write_dtd_attlist|xmlwriter_write_dtd_element|xmlwriter_write_dtd_entity|xmlwriter_write_element|' + + 'xmlwriter_write_element_ns|xmlwriter_write_pi|xmlwriter_write_raw|xpath_eval|xpath_eval_expression|xpath_new_context|xpath_register_ns|' + + 'xpath_register_ns_auto|xptr_eval|xptr_new_context|xslt_backend_info|xslt_backend_name|xslt_backend_version|xslt_create|xslt_errno|' + + 'xslt_error|xslt_free|xslt_getopt|xslt_process|xslt_set_base|xslt_set_encoding|xslt_set_error_handler|xslt_set_log|xslt_set_object|' + + 'xslt_set_sax_handler|xslt_set_sax_handlers|xslt_set_scheme_handler|xslt_set_scheme_handlers|xslt_setopt|xsltprocessor|yaml_emit|' + + 'yaml_emit_file|yaml_parse|yaml_parse_file|yaml_parse_url|yaz_addinfo|yaz_ccl_conf|yaz_ccl_parse|yaz_close|yaz_connect|yaz_database|' + + 'yaz_element|yaz_errno|yaz_error|yaz_es|yaz_es_result|yaz_get_option|yaz_hits|yaz_itemorder|yaz_present|yaz_range|yaz_record|yaz_scan|' + + 'yaz_scan_result|yaz_schema|yaz_search|yaz_set_option|yaz_sort|yaz_syntax|yaz_wait|yp_all|yp_cat|yp_err_string|yp_errno|yp_first|' + + 'yp_get_default_domain|yp_master|yp_match|yp_next|yp_order|zend_logo_guid|zend_thread_id|zend_version|zip_close|zip_entry_close|' + + 'zip_entry_compressedsize|zip_entry_compressionmethod|zip_entry_filesize|zip_entry_name|zip_entry_open|zip_entry_read|zip_open|zip_read|' + + 'ziparchive|ziparchive_addemptydir|ziparchive_addfile|ziparchive_addfromstring|ziparchive_close|ziparchive_deleteindex|' + + 'ziparchive_deletename|ziparchive_extractto|ziparchive_getarchivecomment|ziparchive_getcommentindex|ziparchive_getcommentname|' + + 'ziparchive_getfromindex|ziparchive_getfromname|ziparchive_getnameindex|ziparchive_getstatusstring|ziparchive_getstream|' + + 'ziparchive_locatename|ziparchive_open|ziparchive_renameindex|ziparchive_renamename|ziparchive_setCommentName|ziparchive_setarchivecomment|' + + 'ziparchive_setcommentindex|ziparchive_statindex|ziparchive_statname|ziparchive_unchangeall|ziparchive_unchangearchive|' + + 'ziparchive_unchangeindex|ziparchive_unchangename|zlib_get_coding_type').split('|') + ); + + // http://php.net/manual/en/reserved.keywords.php + var keywords = lang.arrayToMap( + ('abstract|and|array|as|break|case|catch|class|clone|const|continue|declare|default|do|else|elseif|enddeclare|endfor|endforeach|endif|' + + 'endswitch|endwhile|extends|final|for|foreach|function|global|goto|if|implements|interface|instanceof|namespace|new|or|private|protected|' + + 'public|static|switch|throw|try|use|var|while|xor').split('|') + ); + + // http://php.net/manual/en/reserved.keywords.php + var languageConstructs = lang.arrayToMap( + ('die|echo|empty|exit|eval|include|include_once|isset|list|require|require_once|return|print|unset').split('|') + ); + + var builtinConstants = lang.arrayToMap( + ('true|false|null|__CLASS__|__DIR__|__FILE__|__LINE__|__METHOD__|__FUNCTION__|__NAMESPACE__').split('|') + ); + + var builtinVariables = lang.arrayToMap( + ('$GLOBALS|$_SERVER|$_GET|$_POST|$_FILES|$_REQUEST|$_SESSION|$_ENV|$_COOKIE|$php_errormsg|$HTTP_RAW_POST_DATA|' + + '$http_response_header|$argc|$argv').split('|') + ); + + // Discovery done by downloading 'Many HTML files' from: http://php.net/download-docs.php + // Then search for files containing 'deprecated' (case-insensitive) and look at each file that turns up. + var builtinFunctionsDeprecated = lang.arrayToMap( + ('key_exists|cairo_matrix_create_scale|cairo_matrix_create_translate|call_user_method|call_user_method_array|com_addref|com_get|' + + 'com_invoke|com_isenum|com_load|com_release|com_set|connection_timeout|cubrid_load_from_glo|cubrid_new_glo|cubrid_save_to_glo|' + + 'cubrid_send_glo|define_syslog_variables|dl|ereg|ereg_replace|eregi|eregi_replace|hw_documentattributes|hw_documentbodytag|' + + 'hw_documentsize|hw_outputdocument|imagedashedline|maxdb_bind_param|maxdb_bind_result|maxdb_client_encoding|maxdb_close_long_data|' + + 'maxdb_execute|maxdb_fetch|maxdb_get_metadata|maxdb_param_count|maxdb_send_long_data|mcrypt_ecb|mcrypt_generic_end|mime_content_type|' + + 'mysql_createdb|mysql_dbname|mysql_db_query|mysql_drop_db|mysql_dropdb|mysql_escape_string|mysql_fieldflags|mysql_fieldflags|' + + 'mysql_fieldname|mysql_fieldtable|mysql_fieldtype|mysql_freeresult|mysql_listdbs|mysql_list_fields|mysql_listfields|mysql_list_tables|' + + 'mysql_listtables|mysql_numfields|mysql_numrows|mysql_selectdb|mysql_tablename|mysqli_bind_param|mysqli_bind_result|' + + 'mysqli_disable_reads_from_master|mysqli_disable_rpl_parse|mysqli_enable_reads_from_master|mysqli_enable_rpl_parse|mysqli_execute|' + + 'mysqli_fetch|mysqli_get_metadata|mysqli_master_query|mysqli_param_count|mysqli_rpl_parse_enabled|mysqli_rpl_probe|mysqli_rpl_query_type|' + + 'mysqli_send_long_data|mysqli_send_query|mysqli_slave_query|ocibindbyname|ocicancel|ocicloselob|ocicollappend|ocicollassign|' + + 'ocicollassignelem|ocicollgetelem|ocicollmax|ocicollsize|ocicolltrim|ocicolumnisnull|ocicolumnname|ocicolumnprecision|ocicolumnscale|' + + 'ocicolumnsize|ocicolumntype|ocicolumntyperaw|ocicommit|ocidefinebyname|ocierror|ociexecute|ocifetch|ocifetchinto|ocifetchstatement|' + + 'ocifreecollection|ocifreecursor|ocifreedesc|ocifreestatement|ociinternaldebug|ociloadlob|ocilogoff|ocilogon|ocinewcollection|' + + 'ocinewcursor|ocinewdescriptor|ocinlogon|ocinumcols|ociparse|ociplogon|ociresult|ocirollback|ocirowcount|ocisavelob|ocisavelobfile|' + + 'ociserverversion|ocisetprefetch|ocistatementtype|ociwritelobtofile|ociwritetemporarylob|PDF_add_annotation|PDF_add_bookmark|' + + 'PDF_add_launchlink|PDF_add_locallink|PDF_add_note|PDF_add_outline|PDF_add_pdflink|PDF_add_weblink|PDF_attach_file|PDF_begin_page|' + + 'PDF_begin_template|PDF_close_pdi|PDF_close|PDF_findfont|PDF_get_font|PDF_get_fontname|PDF_get_fontsize|PDF_get_image_height|' + + 'PDF_get_image_width|PDF_get_majorversion|PDF_get_minorversion|PDF_get_pdi_parameter|PDF_get_pdi_value|PDF_open_ccitt|PDF_open_file|' + + 'PDF_open_gif|PDF_open_image_file|PDF_open_image|PDF_open_jpeg|PDF_open_pdi|PDF_open_tiff|PDF_place_image|PDF_place_pdi_page|' + + 'PDF_set_border_color|PDF_set_border_dash|PDF_set_border_style|PDF_set_char_spacing|PDF_set_duration|PDF_set_horiz_scaling|' + + 'PDF_set_info_author|PDF_set_info_creator|PDF_set_info_keywords|PDF_set_info_subject|PDF_set_info_title|PDF_set_leading|' + + 'PDF_set_text_matrix|PDF_set_text_rendering|PDF_set_text_rise|PDF_set_word_spacing|PDF_setgray_fill|PDF_setgray_stroke|PDF_setgray|' + + 'PDF_setpolydash|PDF_setrgbcolor_fill|PDF_setrgbcolor_stroke|PDF_setrgbcolor|PDF_show_boxed|php_check_syntax|px_set_tablename|' + + 'px_set_targetencoding|runkit_sandbox_output_handler|session_is_registered|session_register|session_unregister' + + 'set_magic_quotes_runtime|magic_quotes_runtime|set_socket_blocking|socket_set_blocking|set_socket_timeout|socket_set_timeout|split|spliti|' + + 'sql_regcase').split('|') + ); + + var keywordsDeprecated = lang.arrayToMap( + ('cfunction|old_function').split('|') + ); + + var futureReserved = lang.arrayToMap([]); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + { + token : "comment", + regex : "#.*$" + }, + docComment.getStartRule("doc-start"), + { + token : "comment", // multi line comment + regex : "\\/\\*", + next : "comment" + }, { + token : "string.regexp", + regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/][gimy]*\\s*(?=[).,;]|$)" + }, { + token : "string", // " string start + regex : '"', + next : "qqstring" + }, { + token : "string", // ' string start + regex : "'", + next : "qstring" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language", // constants + regex : "\\b(?:DEFAULT_INCLUDE_PATH|E_(?:ALL|CO(?:MPILE_(?:ERROR|WARNING)|RE_(?:ERROR|WARNING))|" + + "ERROR|NOTICE|PARSE|STRICT|USER_(?:ERROR|NOTICE|WARNING)|WARNING)|P(?:EAR_(?:EXTENSION_DIR|INSTALL_DIR)|" + + "HP_(?:BINDIR|CONFIG_FILE_(?:PATH|SCAN_DIR)|DATADIR|E(?:OL|XTENSION_DIR)|INT_(?:MAX|SIZE)|" + + "L(?:IBDIR|OCALSTATEDIR)|O(?:S|UTPUT_HANDLER_(?:CONT|END|START))|PREFIX|S(?:API|HLIB_SUFFIX|YSCONFDIR)|" + + "VERSION))|__COMPILER_HALT_OFFSET__)\\b" + }, { + token : "constant.language", // constants + regex : "\\b(?:A(?:B(?:DAY_(?:1|2|3|4|5|6|7)|MON_(?:1(?:0|1|2|)|2|3|4|5|6|7|8|9))|LT_DIGITS|M_STR|" + + "SSERT_(?:ACTIVE|BAIL|CALLBACK|QUIET_EVAL|WARNING))|C(?:ASE_(?:LOWER|UPPER)|HAR_MAX|" + + "O(?:DESET|NNECTION_(?:ABORTED|NORMAL|TIMEOUT)|UNT_(?:NORMAL|RECURSIVE))|" + + "R(?:EDITS_(?:ALL|DOCS|FULLPAGE|G(?:ENERAL|ROUP)|MODULES|QA|SAPI)|NCYSTR|" + + "YPT_(?:BLOWFISH|EXT_DES|MD5|S(?:ALT_LENGTH|TD_DES)))|URRENCY_SYMBOL)|D(?:AY_(?:1|2|3|4|5|6|7)|" + + "ECIMAL_POINT|IRECTORY_SEPARATOR|_(?:FMT|T_FMT))|E(?:NT_(?:COMPAT|NOQUOTES|QUOTES)|RA(?:_(?:D_(?:FMT|T_FMT)|" + + "T_FMT|YEAR)|)|XTR_(?:IF_EXISTS|OVERWRITE|PREFIX_(?:ALL|I(?:F_EXISTS|NVALID)|SAME)|SKIP))|FRAC_DIGITS|GROUPING|" + + "HTML_(?:ENTITIES|SPECIALCHARS)|IN(?:FO_(?:ALL|C(?:ONFIGURATION|REDITS)|ENVIRONMENT|GENERAL|LICENSE|MODULES|VARIABLES)|" + + "I_(?:ALL|PERDIR|SYSTEM|USER)|T_(?:CURR_SYMBOL|FRAC_DIGITS))|L(?:C_(?:ALL|C(?:OLLATE|TYPE)|M(?:ESSAGES|ONETARY)|NUMERIC|TIME)|" + + "O(?:CK_(?:EX|NB|SH|UN)|G_(?:A(?:LERT|UTH(?:PRIV|))|C(?:ONS|R(?:IT|ON))|D(?:AEMON|EBUG)|E(?:MERG|RR)|INFO|KERN|" + + "L(?:OCAL(?:0|1|2|3|4|5|6|7)|PR)|MAIL|N(?:DELAY|EWS|O(?:TICE|WAIT))|ODELAY|P(?:ERROR|ID)|SYSLOG|U(?:SER|UCP)|WARNING)))|" + + "M(?:ON_(?:1(?:0|1|2|)|2|3|4|5|6|7|8|9|DECIMAL_POINT|GROUPING|THOUSANDS_SEP)|_(?:1_PI|2_(?:PI|SQRTPI)|E|L(?:N(?:10|2)|" + + "OG(?:10E|2E))|PI(?:_(?:2|4)|)|SQRT(?:1_2|2)))|N(?:EGATIVE_SIGN|O(?:EXPR|STR)|_(?:CS_PRECEDES|S(?:EP_BY_SPACE|IGN_POSN)))|" + + "P(?:ATH(?:INFO_(?:BASENAME|DIRNAME|EXTENSION)|_SEPARATOR)|M_STR|OSITIVE_SIGN|_(?:CS_PRECEDES|S(?:EP_BY_SPACE|IGN_POSN)))|" + + "RADIXCHAR|S(?:EEK_(?:CUR|END|SET)|ORT_(?:ASC|DESC|NUMERIC|REGULAR|STRING)|TR_PAD_(?:BOTH|LEFT|RIGHT))|" + + "T(?:HOUS(?:ANDS_SEP|EP)|_FMT(?:_AMPM|))|YES(?:EXPR|STR)|STD(?:IN|OUT|ERR))\\b" + }, { + token : function(value) { + if (keywords.hasOwnProperty(value)) + return "keyword"; + else if (builtinConstants.hasOwnProperty(value)) + return "constant.language"; + else if (builtinVariables.hasOwnProperty(value)) + return "variable.language"; + else if (futureReserved.hasOwnProperty(value)) + return "invalid.illegal"; + else if (builtinFunctions.hasOwnProperty(value)) + return "support.function"; + else if (value == "debugger") + return "invalid.deprecated"; + else + if(value.match(/^(\$[a-zA-Z][a-zA-Z0-9_]*|self|parent)$/)) + return "variable"; + return "identifier"; + }, + // TODO: Unicode escape sequences + // TODO: Unicode identifiers + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "lparen", + regex : "[[({]" + }, { + token : "rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : '\\\\(?:[nrtvef\\\\"$]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})' + }, { + token : "constant.language.escape", + regex : /\$[\w\d]+(?:\[[\w\d]+\])?/ + }, { + token : "constant.language.escape", + regex : /\$\{[^"\}]+\}?/ // this is wrong but ok for now + }, { + token : "string", + regex : '"', + next : "start" + }, { + token : "string", + regex : '.+?' + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : "\\\\['\\\\]" + }, { + token : "string", + regex : "'", + next : "start" + }, { + token : "string", + regex : ".+?" + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(PhpLangHighlightRules, TextHighlightRules); + + +var PhpHighlightRules = function() { + HtmlHighlightRules.call(this); + + for (var i in this.$rules) { + this.$rules[i].unshift({ + token : "support.php_tag", // php open tag + regex : "<\\?(?:php|\\=)", + next : "php-start" + }); + } + + this.embedRules(PhpLangHighlightRules, "php-"); + + this.$rules["php-start"].unshift({ + token : "support.php_tag", // php close tag + regex : "\\?>", + next : "start" + }); +}; + +oop.inherits(PhpHighlightRules, HtmlHighlightRules); + +exports.PhpHighlightRules = PhpHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/html_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var xmlUtil = require("./xml_util"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var tagMap = lang.createMap({ + a : 'anchor', + button : 'form', + form : 'form', + img : 'image', + input : 'form', + label : 'form', + script : 'script', + select : 'form', + textarea : 'form', + style : 'style', + table : 'table', + tbody : 'table', + td : 'table', + tfoot : 'table', + th : 'table', + tr : 'table' +}); + +var HtmlHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + this.$rules = { + start : [{ + token : "text", + merge : true, + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "xml_pe", + regex : "<\\!.*?>" + }, { + token : "meta.tag", + regex : "<(?=\s*script\\b)", + next : "script" + }, { + token : "meta.tag", + regex : "<(?=\s*style\\b)", + next : "style" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "constant.character.entity", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }, { + token : "text", + regex : "[^<]+" + } ], + + cdata : [ { + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + merge : true, + regex : "\\s+" + }, { + token : "text", + merge : true, + regex : ".+" + } ], + + comment : [ { + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + } ] + }; + + xmlUtil.tag(this.$rules, "tag", "start", tagMap); + xmlUtil.tag(this.$rules, "style", "css-start", tagMap); + xmlUtil.tag(this.$rules, "script", "js-start", tagMap); + + this.embedRules(JavaScriptHighlightRules, "js-", [{ + token: "comment", + regex: "\\/\\/.*(?=<\\/script>)", + next: "tag" + }, { + token: "meta.tag", + regex: "<\\/(?=script)", + next: "tag" + }]); + + this.embedRules(CssHighlightRules, "css-", [{ + token: "meta.tag", + regex: "<\\/(?=style)", + next: "tag" + }]); +}; + +oop.inherits(HtmlHighlightRules, TextHighlightRules); + +exports.HtmlHighlightRules = HtmlHighlightRules; +}); + +ace.define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var CssHighlightRules = function() { + var keywordMapper = this.createKeywordMapper({ + "support.type": "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index", + "support.function": "rgb|rgba|url|attr|counter|counters", + "support.constant": "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero", + "support.constant.color": "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow", + "support.constant.fonts": "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace" + }, "text", true); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b"; + var pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b"; + + var base_ruleset = [ + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "ruleset_comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : ["constant.numeric", "keyword"], + regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)" + }, { + token : ["constant.numeric"], + regex : "([0-9]+)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"], + regex : pseudoElements + }, { + token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], + regex : pseudoClasses + }, { + token : keywordMapper, + regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" + } + ]; + + var ruleset = lang.copyArray(base_ruleset); + ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "start" + }); + + var media_ruleset = lang.copyArray( base_ruleset ); + media_ruleset.unshift({ + token : "paren.rparen", + regex : "\\}", + next: "media" + }); + + var base_comment = [{ + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + }]; + + var comment = lang.copyArray(base_comment); + comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }); + + var media_comment = lang.copyArray(base_comment); + media_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "media" + }); + + var ruleset_comment = lang.copyArray(base_comment); + ruleset_comment.unshift({ + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "ruleset" + }); + + this.$rules = { + "start" : [{ + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "ruleset" + }, { + token: "string", + regex: "@.*?{", + next: "media" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "media" : [ { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "media_comment" + }, { + token: "paren.lparen", + regex: "\\{", + next: "media_ruleset" + },{ + token: "string", + regex: "\\}", + next: "start" + },{ + token: "keyword", + regex: "#[a-z0-9-_]+" + },{ + token: "variable", + regex: "\\.[a-z0-9-_]+" + },{ + token: "string", + regex: ":[a-z0-9-_]+" + },{ + token: "constant", + regex: "[a-z0-9-_]+" + }], + + "comment" : comment, + + "ruleset" : ruleset, + "ruleset_comment" : ruleset_comment, + + "media_ruleset" : media_ruleset, + "media_comment" : media_comment + }; +}; + +oop.inherits(CssHighlightRules, TextHighlightRules); + +exports.CssHighlightRules = CssHighlightRules; + +}); + +ace.define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/unicode', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var unicode = require("../unicode"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var JavaScriptHighlightRules = function() { + // see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects + var keywordMapper = this.createKeywordMapper({ + "variable.language": + "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors + "Namespace|QName|XML|XMLList|" + // E4X + "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" + + "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" + + "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors + "SyntaxError|TypeError|URIError|" + + "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions + "isNaN|parseFloat|parseInt|" + + "JSON|Math|" + // Other + "this|arguments|prototype|window|document" , // Pseudo + "invalid.deprecated": + "__parent__|__count__|escape|unescape|with|__proto__|debugger", + "keyword": + "const|yield|import|get|set" + + "break|case|catch|continue|default|delete|do|else|finally|for|function|" + + "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|", + "storage.type": + "const|let|var|function", + "invalid.illegal": + "class|enum|extends|super|export|implements|private|" + + "public|interface|package|protected|static", + "constant.language": + "null|Infinity|NaN|undefined", + }, "identifier"); + + + // keywords which can be followed by regular expressions + var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield"; + + // TODO: Unicode escape sequences + var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b"; + + var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex + "u[0-9a-fA-F]{4}|" + // unicode + "[0-2][0-7]{0,2}|" + // oct + "3[0-6][0-7]?|" + // oct + "37[0-7]?|" + // oct + "[4-7][0-7]?|" + //oct + ".)"; + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + // Sound.prototype.play = + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + // Sound.play = function() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // play = function() { } + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + // function myFunc(arg) { } + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + // foobar: function() { } + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + // escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + // invalid operators + token : "invalid", + regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?] + }, { + // operators + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/ + }, { + token: "string.regexp", + regex: /{|[^\[\\{()$^+*?\/]+/, + merge: true + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex", + merge: true + }, { + token: "constant.language.escape", + regex: "-", + }, { + token: "string.regexp.charachterclass", + regex: /[^\]\-\\]+/, + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) { + + +function string(state) { + return [{ + token : "string", + regex : '".*?"' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*', + next : state + "_qqstring" + }, { + token : "string", + regex : "'.*?'" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*", + next : state + "_qstring" + }]; +} + +function multiLineString(quote, state) { + return [{ + token : "string", + merge : true, + regex : ".*?" + quote, + next : state + }, { + token : "string", + merge : true, + regex : '.+' + }]; +} + +exports.tag = function(states, name, nextState, tagMap) { + states[name] = [{ + token : "text", + regex : "\\s+" + }, { + //token : "meta.tag", + + token : !tagMap ? "meta.tag.tag-name" : function(value) { + if (tagMap[value]) + return "meta.tag.tag-name." + tagMap[value]; + else + return "meta.tag.tag-name"; + }, + merge : true, + regex : "[-_a-zA-Z0-9:]+", + next : name + "_embed_attribute_list" + }, { + token: "empty", + regex: "", + next : name + "_embed_attribute_list" + }]; + + states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list"); + states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list"); + + states[name + "_embed_attribute_list"] = [{ + token : "meta.tag", + merge : true, + regex : "\/?>", + next : nextState + }, { + token : "keyword.operator", + regex : "=" + }, { + token : "entity.other.attribute-name", + regex : "[-_a-zA-Z0-9:]+" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "text", + regex : "\\s+" + }].concat(string(name)); +}; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-powershell.js b/vendor/assets/javascripts/ace-src-noconflict/mode-powershell.js new file mode 100644 index 00000000..6e58237b --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-powershell.js @@ -0,0 +1,608 @@ +ace.define('ace/mode/powershell', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/powershell_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var PowershellHighlightRules = require("./powershell_highlight_rules").PowershellHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new PowershellHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + + this.createWorker = function(session) { + return null; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); +ace.define('ace/mode/powershell_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var PowershellHighlightRules = function() { + + var keywords = ( + "function|if|else|elseif|switch|while|default|for|do|until|break|continue|" + + "foreach|return|filter|in|trap|throw|param|begin|process|end" + ); + + var builtinFunctions = ( + "Get-Alias|Import-Alias|New-Alias|Set-Alias|Get-AuthenticodeSignature|Set-AuthenticodeSignature|" + + "Set-Location|Get-ChildItem|Clear-Item|Get-Command|Measure-Command|Trace-Command|" + + "Add-Computer|Checkpoint-Computer|Remove-Computer|Restart-Computer|Restore-Computer|Stop-Computer|" + + "Reset-ComputerMachinePassword|Test-ComputerSecureChannel|Add-Content|Get-Content|Set-Content|Clear-Content|" + + "Get-Command|Invoke-Command|Enable-ComputerRestore|Disable-ComputerRestore|Get-ComputerRestorePoint|Test-Connection|" + + "ConvertFrom-CSV|ConvertTo-CSV|ConvertTo-Html|ConvertTo-Xml|ConvertFrom-SecureString|ConvertTo-SecureString|" + + "Copy-Item|Export-Counter|Get-Counter|Import-Counter|Get-Credential|Get-Culture|" + + "Get-ChildItem|Get-Date|Set-Date|Remove-Item|Compare-Object|Get-Event|" + + "Get-WinEvent|New-Event|Remove-Event|Unregister-Event|Wait-Event|Clear-EventLog|" + + "Get-Eventlog|Limit-EventLog|New-Eventlog|Remove-EventLog|Show-EventLog|Write-EventLog|" + + "Get-EventSubscriber|Register-EngineEvent|Register-ObjectEvent|Register-WmiEvent|Get-ExecutionPolicy|Set-ExecutionPolicy|" + + "Export-Alias|Export-Clixml|Export-Console|Export-Csv|ForEach-Object|Format-Custom|" + + "Format-List|Format-Table|Format-Wide|Export-FormatData|Get-FormatData|Get-Item|" + + "Get-ChildItem|Get-Help|Add-History|Clear-History|Get-History|Invoke-History|" + + "Get-Host|Read-Host|Write-Host|Get-HotFix|Import-Clixml|Import-Csv|" + + "Invoke-Command|Invoke-Expression|Get-Item|Invoke-Item|New-Item|Remove-Item|" + + "Set-Item|Clear-ItemProperty|Copy-ItemProperty|Get-ItemProperty|Move-ItemProperty|New-ItemProperty|" + + "Remove-ItemProperty|Rename-ItemProperty|Set-ItemProperty|Get-Job|Receive-Job|Remove-Job|" + + "Start-Job|Stop-Job|Wait-Job|Stop-Process|Update-List|Get-Location|" + + "Pop-Location|Push-Location|Set-Location|Send-MailMessage|Add-Member|Get-Member|" + + "Move-Item|Compare-Object|Group-Object|Measure-Object|New-Object|Select-Object|" + + "Sort-Object|Where-Object|Out-Default|Out-File|Out-GridView|Out-Host|" + + "Out-Null|Out-Printer|Out-String|Convert-Path|Join-Path|Resolve-Path|" + + "Split-Path|Test-Path|Get-Pfxcertificate|Pop-Location|Push-Location|Get-Process|" + + "Start-Process|Stop-Process|Wait-Process|Enable-PSBreakpoint|Disable-PSBreakpoint|Get-PSBreakpoint|" + + "Set-PSBreakpoint|Remove-PSBreakpoint|Get-PSDrive|New-PSDrive|Remove-PSDrive|Get-PSProvider|" + + "Set-PSdebug|Enter-PSSession|Exit-PSSession|Export-PSSession|Get-PSSession|Import-PSSession|" + + "New-PSSession|Remove-PSSession|Disable-PSSessionConfiguration|Enable-PSSessionConfiguration|Get-PSSessionConfiguration|Register-PSSessionConfiguration|" + + "Set-PSSessionConfiguration|Unregister-PSSessionConfiguration|New-PSSessionOption|Add-PsSnapIn|Get-PsSnapin|Remove-PSSnapin|" + + "Get-Random|Read-Host|Remove-Item|Rename-Item|Rename-ItemProperty|Select-Object|" + + "Select-XML|Send-MailMessage|Get-Service|New-Service|Restart-Service|Resume-Service|" + + "Set-Service|Start-Service|Stop-Service|Suspend-Service|Sort-Object|Start-Sleep|" + + "ConvertFrom-StringData|Select-String|Tee-Object|New-Timespan|Trace-Command|Get-Tracesource|" + + "Set-Tracesource|Start-Transaction|Complete-Transaction|Get-Transaction|Use-Transaction|Undo-Transaction|" + + "Start-Transcript|Stop-Transcript|Add-Type|Update-TypeData|Get-Uiculture|Get-Unique|" + + "Update-Formatdata|Update-Typedata|Clear-Variable|Get-Variable|New-Variable|Remove-Variable|" + + "Set-Variable|New-WebServiceProxy|Where-Object|Write-Debug|Write-Error|Write-Host|" + + "Write-Output|Write-Progress|Write-Verbose|Write-Warning|Set-WmiInstance|Invoke-WmiMethod|" + + "Get-WmiObject|Remove-WmiObject|Connect-WSMan|Disconnect-WSMan|Test-WSMan|Invoke-WSManAction|" + + "Disable-WSManCredSSP|Enable-WSManCredSSP|Get-WSManCredSSP|New-WSManInstance|Get-WSManInstance|Set-WSManInstance|" + + "Remove-WSManInstance|Set-WSManQuickConfig|New-WSManSessionOption" + ); + + var keywordMapper = this.createKeywordMapper({ + "support.function": builtinFunctions, + "keyword": keywords + }, "identifier"); + + var binaryOperatorsRe = "eq|ne|ge|gt|lt|le|like|notlike|match|notmatch|replace|contains|notcontains|" + + "ieq|ine|ige|igt|ile|ilt|ilike|inotlike|imatch|inotmatch|ireplace|icontains|inotcontains|" + + "is|isnot|as|" + + "and|or|band|bor|not"; + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "#.*$" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "[$](?:[Tt]rue|[Ff]alse)\\b" + }, { + token : "constant.language", + regex : "[$][Nn]ull\\b" + }, { + token : "variable.instance", + regex : "[$][a-zA-Z][a-zA-Z0-9_]*\\b" + }, { + token : keywordMapper, + // TODO: Unicode escape sequences + // TODO: Unicode identifiers + regex : "[a-zA-Z_$][a-zA-Z0-9_$\\-]*\\b" + }, { + token : "keyword.operator", + regex : "\\-(?:" + binaryOperatorsRe + ")" + }, { + token : "keyword.operator", + regex : "&|\\*|\\+|\\-|\\=|\\+=|\\-=" + }, { + token : "lparen", + regex : "[[({]" + }, { + token : "rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ] + }; +}; + +oop.inherits(PowershellHighlightRules, TextHighlightRules); + +exports.PowershellHighlightRules = PowershellHighlightRules; +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-python.js b/vendor/assets/javascripts/ace-src-noconflict/mode-python.js new file mode 100644 index 00000000..51e1acf7 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-python.js @@ -0,0 +1,383 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/python', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/python_highlight_rules', 'ace/mode/folding/pythonic', 'ace/range'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var PythonHighlightRules = require("./python_highlight_rules").PythonHighlightRules; +var PythonFoldMode = require("./folding/pythonic").FoldMode; +var Range = require("../range").Range; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new PythonHighlightRules().getRules()); + this.foldingRules = new PythonFoldMode("\\:"); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)#/; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "#"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[\:]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + var outdents = { + "pass": 1, + "return": 1, + "raise": 1, + "break": 1, + "continue": 1 + }; + + this.checkOutdent = function(state, line, input) { + if (input !== "\r\n" && input !== "\r" && input !== "\n") + return false; + + var tokens = this.$tokenizer.getLineTokens(line.trim(), state).tokens; + + if (!tokens) + return false; + + // ignore trailing comments + do { + var last = tokens.pop(); + } while (last && (last.type == "comment" || (last.type == "text" && last.value.match(/^\s+$/)))); + + if (!last) + return false; + + return (last.type == "keyword" && outdents[last.value]); + }; + + this.autoOutdent = function(state, doc, row) { + // outdenting in python is slightly different because it always applies + // to the next line and only of a new line is inserted + + row += 1; + var indent = this.$getIndent(doc.getLine(row)); + var tab = doc.getTabString(); + if (indent.slice(-tab.length) == tab) + doc.remove(new Range(row, indent.length-tab.length, row, indent.length)); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); +/* + * TODO: python delimiters + */ + +ace.define('ace/mode/python_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var PythonHighlightRules = function() { + + var keywords = ( + "and|as|assert|break|class|continue|def|del|elif|else|except|exec|" + + "finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|" + + "raise|return|try|while|with|yield" + ); + + var builtinConstants = ( + "True|False|None|NotImplemented|Ellipsis|__debug__" + ); + + var builtinFunctions = ( + "abs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|" + + "eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|" + + "binfile|iter|property|tuple|bool|filter|len|range|type|bytearray|" + + "float|list|raw_input|unichr|callable|format|locals|reduce|unicode|" + + "chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|" + + "cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|" + + "__import__|complex|hash|min|set|apply|delattr|help|next|setattr|" + + "buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern" + ); + + //var futureReserved = ""; + var keywordMapper = this.createKeywordMapper({ + "invalid.deprecated": "debugger", + "support.function": builtinFunctions, + //"invalid.illegal": futureReserved, + "constant.language": builtinConstants, + "keyword": keywords + }, "identifier"); + + var strPre = "(?:r|u|ur|R|U|UR|Ur|uR)?"; + + var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))"; + var octInteger = "(?:0[oO]?[0-7]+)"; + var hexInteger = "(?:0[xX][\\dA-Fa-f]+)"; + var binInteger = "(?:0[bB][01]+)"; + var integer = "(?:" + decimalInteger + "|" + octInteger + "|" + hexInteger + "|" + binInteger + ")"; + + var exponent = "(?:[eE][+-]?\\d+)"; + var fraction = "(?:\\.\\d+)"; + var intPart = "(?:\\d+)"; + var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))"; + var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + exponent + ")"; + var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")"; + + this.$rules = { + "start" : [ { + token : "comment", + regex : "#.*$" + }, { + token : "string", // """ string + regex : strPre + '"{3}(?:[^\\\\]|\\\\.)*?"{3}' + }, { + token : "string", // multi line """ string start + merge : true, + regex : strPre + '"{3}.*$', + next : "qqstring" + }, { + token : "string", // " string + regex : strPre + '"(?:[^\\\\]|\\\\.)*?"' + }, { + token : "string", // ''' string + regex : strPre + "'{3}(?:[^\\\\]|\\\\.)*?'{3}" + }, { + token : "string", // multi line ''' string start + merge : true, + regex : strPre + "'{3}.*$", + next : "qstring" + }, { + token : "string", // ' string + regex : strPre + "'(?:[^\\\\]|\\\\.)*?'" + }, { + token : "constant.numeric", // imaginary + regex : "(?:" + floatNumber + "|\\d+)[jJ]\\b" + }, { + token : "constant.numeric", // float + regex : floatNumber + }, { + token : "constant.numeric", // long integer + regex : integer + "[lL]\\b" + }, { + token : "constant.numeric", // integer + regex : integer + "\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|=" + }, { + token : "paren.lparen", + regex : "[\\[\\(\\{]" + }, { + token : "paren.rparen", + regex : "[\\]\\)\\}]" + }, { + token : "text", + regex : "\\s+" + } ], + "qqstring" : [ { + token : "string", // multi line """ string end + regex : '(?:[^\\\\]|\\\\.)*?"{3}', + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ], + "qstring" : [ { + token : "string", // multi line ''' string end + regex : "(?:[^\\\\]|\\\\.)*?'{3}", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ] + }; +}; + +oop.inherits(PythonHighlightRules, TextHighlightRules); + +exports.PythonHighlightRules = PythonHighlightRules; +}); + +ace.define('ace/mode/folding/pythonic', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function(markers) { + this.foldingStartMarker = new RegExp("([\\[{])(?:\\s*)$|(" + markers + ")(?:\\s*)(?:#.*)?$"); +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + if (match[1]) + return this.openingBracketBlock(session, match[1], row, match.index); + if (match[2]) + return this.indentationBlock(session, row, match.index + match[2].length); + return this.indentationBlock(session, row); + } + } + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-ruby.js b/vendor/assets/javascripts/ace-src-noconflict/mode-ruby.js new file mode 100644 index 00000000..72ad0a4a --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-ruby.js @@ -0,0 +1,302 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/ruby', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/ruby_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new RubyHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)#/; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "#"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/ruby_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var RubyHighlightRules = function() { + + var builtinFunctions = ( + "abort|Array|assert|assert_equal|assert_not_equal|assert_same|assert_not_same|" + + "assert_nil|assert_not_nil|assert_match|assert_no_match|assert_in_delta|assert_throws|" + + "assert_raise|assert_nothing_raised|assert_instance_of|assert_kind_of|assert_respond_to|" + + "assert_operator|assert_send|assert_difference|assert_no_difference|assert_recognizes|" + + "assert_generates|assert_response|assert_redirected_to|assert_template|assert_select|" + + "assert_select_email|assert_select_rjs|assert_select_encoded|css_select|at_exit|" + + "attr|attr_writer|attr_reader|attr_accessor|attr_accessible|autoload|binding|block_given?|callcc|" + + "caller|catch|chomp|chomp!|chop|chop!|defined?|delete_via_redirect|eval|exec|exit|" + + "exit!|fail|Float|flunk|follow_redirect!|fork|form_for|form_tag|format|gets|global_variables|gsub|" + + "gsub!|get_via_redirect|h|host!|https?|https!|include|Integer|lambda|link_to|" + + "link_to_unless_current|link_to_function|link_to_remote|load|local_variables|loop|open|open_session|" + + "p|print|printf|proc|putc|puts|post_via_redirect|put_via_redirect|raise|rand|" + + "raw|readline|readlines|redirect?|request_via_redirect|require|scan|select|" + + "set_trace_func|sleep|split|sprintf|srand|String|stylesheet_link_tag|syscall|system|sub|sub!|test|" + + "throw|trace_var|trap|untrace_var|atan2|cos|exp|frexp|ldexp|log|log10|sin|sqrt|tan|" + + "render|javascript_include_tag|csrf_meta_tag|label_tag|text_field_tag|submit_tag|check_box_tag|" + + "content_tag|radio_button_tag|text_area_tag|password_field_tag|hidden_field_tag|" + + "fields_for|select_tag|options_for_select|options_from_collection_for_select|collection_select|" + + "time_zone_select|select_date|select_time|select_datetime|date_select|time_select|datetime_select|" + + "select_year|select_month|select_day|select_hour|select_minute|select_second|file_field_tag|" + + "file_field|respond_to|skip_before_filter|around_filter|after_filter|verify|" + + "protect_from_forgery|rescue_from|helper_method|redirect_to|before_filter|" + + "send_data|send_file|validates_presence_of|validates_uniqueness_of|validates_length_of|" + + "validates_format_of|validates_acceptance_of|validates_associated|validates_exclusion_of|" + + "validates_inclusion_of|validates_numericality_of|validates_with|validates_each|" + + "authenticate_or_request_with_http_basic|authenticate_or_request_with_http_digest|" + + "filter_parameter_logging|match|get|post|resources|redirect|scope|assert_routing|" + + "translate|localize|extract_locale_from_tld|t|l|caches_page|expire_page|caches_action|expire_action|" + + "cache|expire_fragment|expire_cache_for|observe|cache_sweeper|" + + "has_many|has_one|belongs_to|has_and_belongs_to_many" + ); + + var keywords = ( + "alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|" + + "__FILE__|finally|for|gem|if|in|__LINE__|module|next|not|or|private|protected|public|" + + "redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield" + ); + + var buildinConstants = ( + "true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|" + + "RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING" + ); + + var builtinVariables = ( + "\$DEBUG|\$defout|\$FILENAME|\$LOAD_PATH|\$SAFE|\$stdin|\$stdout|\$stderr|\$VERBOSE|" + + "$!|root_url|flash|session|cookies|params|request|response|logger|self" + ); + + var keywordMapper = this.createKeywordMapper({ + "keyword": keywords, + "constant.language": buildinConstants, + "variable.language": builtinVariables, + "support.function": builtinFunctions, + "invalid.deprecated": "debugger" // TODO is this a remnant from js mode? + }, "identifier"); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "#.*$" + }, { + token : "comment", // multi line comment + merge : true, + regex : "^\=begin$", + next : "comment" + }, { + token : "string.regexp", + regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "string", // backtick string + regex : "[`](?:(?:\\\\.)|(?:[^'\\\\]))*?[`]" + }, { + token : "text", // namespaces aren't symbols + regex : "::" + }, { + token : "variable.instancce", // instance variable + regex : "@{1,2}(?:[a-zA-Z_]|\d)+" + }, { + token : "variable.class", // class name + regex : "[A-Z](?:[a-zA-Z_]|\d)+" + }, { + token : "string", // symbol + regex : "[:](?:[A-Za-z_]|[@$](?=[a-zA-Z0-9_]))[a-zA-Z0-9_]*[!=?]?" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F](?:[0-9a-fA-F]|_(?=[0-9a-fA-F]))*\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d(?:\\d|_(?=\\d))*(?:(?:\\.\\d(?:\\d|_(?=\\d))*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "(?:true|false)\\b" + }, { + token : keywordMapper, + // TODO: Unicode escape sequences + // TODO: Unicode identifiers + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : "^\=end$", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ] + }; +}; + +oop.inherits(RubyHighlightRules, TextHighlightRules); + +exports.RubyHighlightRules = RubyHighlightRules; +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-scad.js b/vendor/assets/javascripts/ace-src-noconflict/mode-scad.js new file mode 100644 index 00000000..3d3c42cd --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-scad.js @@ -0,0 +1,712 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/scad', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/scad_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var scadHighlightRules = require("./scad_highlight_rules").scadHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new scadHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/scad_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var scadHighlightRules = function() { + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": "module|if|else|for", + "constant.language": "NULL", + }, "identifier"); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + DocCommentHighlightRules.getStartRule("start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // multi line string start + regex : '["].*\\\\$', + next : "qqstring" + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "string", // multi line string start + regex : "['].*\\\\$", + next : "qstring" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant", // + regex : "<[a-zA-Z0-9.]+>" + }, { + token : "keyword", // pre-compiler directivs + regex : "(?:use|include)" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)" + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "string", + regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ], + "qstring" : [ + { + token : "string", + regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(scadHighlightRules, TextHighlightRules); + +exports.scadHighlightRules = scadHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-scala.js b/vendor/assets/javascripts/ace-src-noconflict/mode-scala.js new file mode 100644 index 00000000..ee8ebb8f --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-scala.js @@ -0,0 +1,1151 @@ +ace.define('ace/mode/scala', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/javascript', 'ace/tokenizer', 'ace/mode/scala_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var JavaScriptMode = require("./javascript").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var ScalaHighlightRules = require("./scala_highlight_rules").ScalaHighlightRules; + +var Mode = function() { + JavaScriptMode.call(this); + + this.$tokenizer = new Tokenizer(new ScalaHighlightRules().getRules()); +}; +oop.inherits(Mode, JavaScriptMode); + +(function() { + + this.createWorker = function(session) { + return null; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start" || state == "regex_allowed") { + var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start" || state == "regex_allowed") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); + worker.attachToDocument(session.getDocument()); + + worker.on("jslint", function(results) { + var errors = []; + for (var i=0; i the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + // Sound.prototype.play = + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + // Sound.play = function() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // play = function() { } + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + // function myFunc(arg) { } + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + // foobar: function() { } + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + // escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + // invalid operators + token : "invalid", + regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?] + }, { + // operators + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/ + }, { + token: "string.regexp", + regex: /{|[^\[\\{()$^+*?\/]+/, + merge: true + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex", + merge: true + }, { + token: "constant.language.escape", + regex: "-", + }, { + token: "string.regexp.charachterclass", + regex: /[^\]\-\\]+/, + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); +ace.define('ace/mode/scala_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var ScalaHighlightRules = function() { + + // taken from http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html + var keywords = ( + "case|default|do|else|for|if|match|while|throw|return|try|catch|finally|yield|" + + "abstract|class|def|extends|final|forSome|implicit|implicits|import|lazy|new|object|" + + "override|package|private|protected|sealed|super|this|trait|type|val|var|with" + ); + + var buildinConstants = ("true|false"); + + var langClasses = ( + "AbstractMethodError|AssertionError|ClassCircularityError|"+ + "ClassFormatError|Deprecated|EnumConstantNotPresentException|"+ + "ExceptionInInitializerError|IllegalAccessError|"+ + "IllegalThreadStateException|InstantiationError|InternalError|"+ + + "NegativeArraySizeException|NoSuchFieldError|Override|Process|"+ + "ProcessBuilder|SecurityManager|StringIndexOutOfBoundsException|"+ + "SuppressWarnings|TypeNotPresentException|UnknownError|"+ + "UnsatisfiedLinkError|UnsupportedClassVersionError|VerifyError|"+ + "InstantiationException|IndexOutOfBoundsException|"+ + "ArrayIndexOutOfBoundsException|CloneNotSupportedException|"+ + "NoSuchFieldException|IllegalArgumentException|NumberFormatException|"+ + "SecurityException|Void|InheritableThreadLocal|IllegalStateException|"+ + "InterruptedException|NoSuchMethodException|IllegalAccessException|"+ + "UnsupportedOperationException|Enum|StrictMath|Package|Compiler|"+ + "Readable|Runtime|StringBuilder|Math|IncompatibleClassChangeError|"+ + "NoSuchMethodError|ThreadLocal|RuntimePermission|ArithmeticException|"+ + "NullPointerException|Long|Integer|Short|Byte|Double|Number|Float|"+ + "Character|Boolean|StackTraceElement|Appendable|StringBuffer|"+ + "Iterable|ThreadGroup|Runnable|Thread|IllegalMonitorStateException|"+ + "StackOverflowError|OutOfMemoryError|VirtualMachineError|"+ + "ArrayStoreException|ClassCastException|LinkageError|"+ + "NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+ + "Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+ + "Cloneable|Class|CharSequence|Comparable|String|Object|" + + "Unit|Any|AnyVal|AnyRef|Null|ScalaObject|Singleton|Seq|Iterable|List|" + + "Option|Array|Char|Byte|Short|Int|Long|Nothing" + + + ); + + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": keywords, + "support.function": langClasses, + "constant.language": buildinConstants + }, "identifier"); + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token : "string.regexp", + regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + }, { + token : "string", + regex : '"""', + next : "tstring" + }, { + token : "string", + regex : '"(?=.)', // " strings can't span multiple lines + next : "string" + }, { + token : "symbol.constant", // single line + regex : "'[\\w\\d_]+" + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "(?:true|false)\\b" + }, { + token : keywordMapper, + // TODO: Unicode escape sequences + // TODO: Unicode identifiers + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "string" : [ + { + token : "escape", + regex : '\\\\"', + }, { + token : "string", + merge : true, + regex : '"', + next : "start" + }, { + token : "string.invalid", + regex : '[^"\\\\]*$', + next : "start" + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + } + ], + "tstring" : [ + { + token : "string", // closing comment + regex : '"{3,5}', + next : "start" + }, { + token : "string", // comment spanning whole line + merge : true, + regex : ".+?" + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(ScalaHighlightRules, TextHighlightRules); + +exports.ScalaHighlightRules = ScalaHighlightRules; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-scss.js b/vendor/assets/javascripts/ace-src-noconflict/mode-scss.js new file mode 100644 index 00000000..10a2b33d --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-scss.js @@ -0,0 +1,530 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/scss', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/scss_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var ScssHighlightRules = require("./scss_highlight_rules").ScssHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new ScssHighlightRules().getRules(), "i"); + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + // ignore braces in comments + var tokens = this.$tokenizer.getLineTokens(line, state).tokens; + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + var match = line.match(/^.*\{\s*$/); + if (match) { + indent += tab; + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/scss_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var ScssHighlightRules = function() { + + var properties = lang.arrayToMap( (function () { + + var browserPrefix = ("-webkit-|-moz-|-o-|-ms-|-svg-|-pie-|-khtml-").split("|"); + + var prefixProperties = ("appearance|background-clip|background-inline-policy|background-origin|" + + "background-size|binding|border-bottom-colors|border-left-colors|" + + "border-right-colors|border-top-colors|border-end|border-end-color|" + + "border-end-style|border-end-width|border-image|border-start|" + + "border-start-color|border-start-style|border-start-width|box-align|" + + "box-direction|box-flex|box-flexgroup|box-ordinal-group|box-orient|" + + "box-pack|box-sizing|column-count|column-gap|column-width|column-rule|" + + "column-rule-width|column-rule-style|column-rule-color|float-edge|" + + "font-feature-settings|font-language-override|force-broken-image-icon|" + + "image-region|margin-end|margin-start|opacity|outline|outline-color|" + + "outline-offset|outline-radius|outline-radius-bottomleft|" + + "outline-radius-bottomright|outline-radius-topleft|outline-radius-topright|" + + "outline-style|outline-width|padding-end|padding-start|stack-sizing|" + + "tab-size|text-blink|text-decoration-color|text-decoration-line|" + + "text-decoration-style|transform|transform-origin|transition|" + + "transition-delay|transition-duration|transition-property|" + + "transition-timing-function|user-focus|user-input|user-modify|user-select|" + + "window-shadow|border-radius").split("|"); + + var properties = ("azimuth|background-attachment|background-color|background-image|" + + "background-position|background-repeat|background|border-bottom-color|" + + "border-bottom-style|border-bottom-width|border-bottom|border-collapse|" + + "border-color|border-left-color|border-left-style|border-left-width|" + + "border-left|border-right-color|border-right-style|border-right-width|" + + "border-right|border-spacing|border-style|border-top-color|" + + "border-top-style|border-top-width|border-top|border-width|border|" + + "bottom|box-sizing|caption-side|clear|clip|color|content|counter-increment|" + + "counter-reset|cue-after|cue-before|cue|cursor|direction|display|" + + "elevation|empty-cells|float|font-family|font-size-adjust|font-size|" + + "font-stretch|font-style|font-variant|font-weight|font|height|left|" + + "letter-spacing|line-height|list-style-image|list-style-position|" + + "list-style-type|list-style|margin-bottom|margin-left|margin-right|" + + "margin-top|marker-offset|margin|marks|max-height|max-width|min-height|" + + "min-width|opacity|orphans|outline-color|" + + "outline-style|outline-width|outline|overflow|overflow-x|overflow-y|padding-bottom|" + + "padding-left|padding-right|padding-top|padding|page-break-after|" + + "page-break-before|page-break-inside|page|pause-after|pause-before|" + + "pause|pitch-range|pitch|play-during|position|quotes|richness|right|" + + "size|speak-header|speak-numeral|speak-punctuation|speech-rate|speak|" + + "stress|table-layout|text-align|text-decoration|text-indent|" + + "text-shadow|text-transform|top|unicode-bidi|vertical-align|" + + "visibility|voice-family|volume|white-space|widows|width|word-spacing|" + + "z-index").split("|"); + + //The return array + var ret = []; + + //All prefixProperties will get the browserPrefix in + //the begning by join the prefixProperties array with the value of browserPrefix + for (var i=0, ln=browserPrefix.length; i the first match is used + + var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))"; + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "\\/\\/.*$" + }, + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*\\\\$', + next : "qqstring" + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*\\\\$", + next : "qstring" + }, { + token : "constant.numeric", + regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" + }, { + token : "constant.numeric", // hex6 color + regex : "#[a-f0-9]{6}" + }, { + token : "constant.numeric", // hex3 color + regex : "#[a-f0-9]{3}" + }, { + token : "constant.numeric", + regex : numRe + }, { + token : function(value) { + if (properties.hasOwnProperty(value.toLowerCase())) + return "support.type"; + if (keywords.hasOwnProperty(value)) + return "keyword"; + else if (constants.hasOwnProperty(value)) + return "constant.language"; + else if (functions.hasOwnProperty(value)) + return "support.function"; + else if (colors.hasOwnProperty(value.toLowerCase())) + return "support.constant.color"; + else if (tags.hasOwnProperty(value.toLowerCase())) + return "variable.language"; + else + return "text"; + }, + regex : "\\-?[@a-z_][@a-z0-9_\\-]*" + }, { + token : "variable", + regex : "[a-z_\\-$][a-z0-9_\\-$]*\\b" + }, { + token: "variable.language", + regex: "#[a-z0-9-_]+" + }, { + token: "variable.language", + regex: "\\.[a-z0-9-_]+" + }, { + token: "variable.language", + regex: ":[a-z0-9-_]+" + }, { + token: "constant", + regex: "[a-z0-9-_]+" + }, { + token : "keyword.operator", + regex : "<|>|<=|>=|==|!=|-|%|#|\\+|\\$|\\+|\\*" + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "string", + regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ], + "qstring" : [ + { + token : "string", + regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ] + }; +}; + +oop.inherits(ScssHighlightRules, TextHighlightRules); + +exports.ScssHighlightRules = ScssHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-sh.js b/vendor/assets/javascripts/ace-src-noconflict/mode-sh.js new file mode 100644 index 00000000..52fbfae3 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-sh.js @@ -0,0 +1,238 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/sh', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/sh_highlight_rules', 'ace/range'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var ShHighlightRules = require("./sh_highlight_rules").ShHighlightRules; +var Range = require("../range").Range; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new ShHighlightRules().getRules()); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)#/; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "#"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[\:]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + var outdents = { + "pass": 1, + "return": 1, + "raise": 1, + "break": 1, + "continue": 1 + }; + + this.checkOutdent = function(state, line, input) { + if (input !== "\r\n" && input !== "\r" && input !== "\n") + return false; + + var tokens = this.$tokenizer.getLineTokens(line.trim(), state).tokens; + + if (!tokens) + return false; + + // ignore trailing comments + do { + var last = tokens.pop(); + } while (last && (last.type == "comment" || (last.type == "text" && last.value.match(/^\s+$/)))); + + if (!last) + return false; + + return (last.type == "keyword" && outdents[last.value]); + }; + + this.autoOutdent = function(state, doc, row) { + // outdenting in sh is slightly different because it always applies + // to the next line and only of a new line is inserted + + row += 1; + var indent = this.$getIndent(doc.getLine(row)); + var tab = doc.getTabString(); + if (indent.slice(-tab.length) == tab) + doc.remove(new Range(row, indent.length-tab.length, row, indent.length)); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/sh_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var ShHighlightRules = function() { + + var reservedKeywords = ( + '!|{|}|case|do|done|elif|else|'+ + 'esac|fi|for|if|in|then|until|while|'+ + '&|;|export|local|read|typeset|unset|'+ + 'elif|select|set' + ); + + var languageConstructs = ( + '[|]|alias|bg|bind|break|builtin|'+ + 'cd|command|compgen|complete|continue|'+ + 'dirs|disown|echo|enable|eval|exec|'+ + 'exit|fc|fg|getopts|hash|help|history|'+ + 'jobs|kill|let|logout|popd|printf|pushd|'+ + 'pwd|return|set|shift|shopt|source|'+ + 'suspend|test|times|trap|type|ulimit|'+ + 'umask|unalias|wait' + ); + + var keywordMapper = this.createKeywordMapper({ + "keyword": reservedKeywords, + "constant.language": languageConstructs, + "invalid.deprecated": "debugger" + }, "identifier"); + + var integer = "(?:(?:[1-9]\\d*)|(?:0))"; + // var integer = "(?:" + decimalInteger + ")"; + + var fraction = "(?:\\.\\d+)"; + var intPart = "(?:\\d+)"; + var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))"; + var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + ")"; + var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")"; + var fileDescriptor = "(?:&" + intPart + ")"; + + var variableName = "[a-zA-Z][a-zA-Z0-9_]*"; + var variable = "(?:(?:\\$" + variableName + ")|(?:" + variableName + "=))"; + + var builtinVariable = "(?:\\$(?:SHLVL|\\$|\\!|\\?))"; + + var func = "(?:" + variableName + "\\s*\\(\\))"; + + this.$rules = { + "start" : [ { + token : "comment", + regex : "#.*$" + }, { + token : "string", // " string + regex : '"(?:[^\\\\]|\\\\.)*?"' + }, { + token : "variable.language", + regex : builtinVariable + }, { + token : "variable", + regex : variable + }, { + token : "support.function", + regex : func, + }, { + token : "support.function", + regex : fileDescriptor + }, { + token : "string", // ' string + regex : "'(?:[^\\\\]|\\\\.)*?'" + }, { + token : "constant.numeric", // float + regex : floatNumber + }, { + token : "constant.numeric", // integer + regex : integer + "\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|~|<|>|<=|=>|=|!=" + }, { + token : "paren.lparen", + regex : "[\\[\\(\\{]" + }, { + token : "paren.rparen", + regex : "[\\]\\)\\}]" + }, { + token : "text", + regex : "\\s+" + } ] + }; +}; + +oop.inherits(ShHighlightRules, TextHighlightRules); + +exports.ShHighlightRules = ShHighlightRules; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-sql.js b/vendor/assets/javascripts/ace-src-noconflict/mode-sql.js new file mode 100644 index 00000000..d7fab1c5 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-sql.js @@ -0,0 +1,145 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/sql', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/sql_highlight_rules', 'ace/range'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var SqlHighlightRules = require("./sql_highlight_rules").SqlHighlightRules; +var Range = require("../range").Range; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new SqlHighlightRules().getRules()); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var outentedRows = []; + var re = /^(\s*)--/; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "--"); + } + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/sql_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var SqlHighlightRules = function() { + + var keywords = ( + "select|from|where|and|or|group|by|order|limit|offset|having|as|case|" + + "when|else|end|type|left|right|join|on|outer|desc|asc" + ); + + var builtinConstants = ( + "true|false|null" + ); + + var builtinFunctions = ( + "count|min|max|avg|sum|rank|now|coalesce" + ); + + var keywordMapper = this.createKeywordMapper({ + "support.function": builtinFunctions, + "keyword": keywords, + "constant.language": builtinConstants + }, "identifier", true); + + this.$rules = { + "start" : [ { + token : "comment", + regex : "--.*$" + }, { + token : "string", // " string + regex : '".*?"' + }, { + token : "string", // ' string + regex : "'.*?'" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=" + }, { + token : "paren.lparen", + regex : "[\\(]" + }, { + token : "paren.rparen", + regex : "[\\)]" + }, { + token : "text", + regex : "\\s+" + } ] + }; +}; + +oop.inherits(SqlHighlightRules, TextHighlightRules); + +exports.SqlHighlightRules = SqlHighlightRules; +}); + diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-svg.js b/vendor/assets/javascripts/ace-src-noconflict/mode-svg.js new file mode 100644 index 00000000..29c2b17b --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-svg.js @@ -0,0 +1,1602 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/svg', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml', 'ace/mode/javascript', 'ace/tokenizer', 'ace/mode/svg_highlight_rules', 'ace/mode/folding/mixed', 'ace/mode/folding/xml', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var XmlMode = require("./xml").Mode; +var JavaScriptMode = require("./javascript").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var SvgHighlightRules = require("./svg_highlight_rules").SvgHighlightRules; +var MixedFoldMode = require("./folding/mixed").FoldMode; +var XmlFoldMode = require("./folding/xml").FoldMode; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + XmlMode.call(this); + + this.highlighter = new SvgHighlightRules(); + this.$tokenizer = new Tokenizer(this.highlighter.getRules()); + + this.$embeds = this.highlighter.getEmbeds(); + this.createModeDelegates({ + "js-": JavaScriptMode + }); + + this.foldingRules = new MixedFoldMode(new XmlFoldMode({}), { + "js-": new CStyleFoldMode() + }); +}; + +oop.inherits(Mode, XmlMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + return this.$getIndent(line); + }; + + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xml_highlight_rules', 'ace/mode/behaviour/xml', 'ace/mode/folding/xml'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules; +var XmlBehaviour = require("./behaviour/xml").XmlBehaviour; +var XmlFoldMode = require("./folding/xml").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules()); + this.$behaviour = new XmlBehaviour(); + this.foldingRules = new XmlFoldMode(); +}; + +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + return this.$getIndent(line); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/xml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var xmlUtil = require("./xml_util"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var XmlHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + this.$rules = { + start : [{ + token : "text", + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "xml_pe", + regex : "<\\!.*?>" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "constant.character.entity", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }, { + token : "text", + regex : "[^<]+" + }], + + cdata : [{ + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + regex : "\\s+" + }, { + token : "text", + regex : "(?:[^\\]]|\\](?!\\]>))+" + }], + + comment : [{ + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + }] + }; + + xmlUtil.tag(this.$rules, "tag", "start"); +}; + +oop.inherits(XmlHighlightRules, TextHighlightRules); + +exports.XmlHighlightRules = XmlHighlightRules; +}); + +ace.define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) { + + +function string(state) { + return [{ + token : "string", + regex : '".*?"' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*', + next : state + "_qqstring" + }, { + token : "string", + regex : "'.*?'" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*", + next : state + "_qstring" + }]; +} + +function multiLineString(quote, state) { + return [{ + token : "string", + merge : true, + regex : ".*?" + quote, + next : state + }, { + token : "string", + merge : true, + regex : '.+' + }]; +} + +exports.tag = function(states, name, nextState, tagMap) { + states[name] = [{ + token : "text", + regex : "\\s+" + }, { + //token : "meta.tag", + + token : !tagMap ? "meta.tag.tag-name" : function(value) { + if (tagMap[value]) + return "meta.tag.tag-name." + tagMap[value]; + else + return "meta.tag.tag-name"; + }, + merge : true, + regex : "[-_a-zA-Z0-9:]+", + next : name + "_embed_attribute_list" + }, { + token: "empty", + regex: "", + next : name + "_embed_attribute_list" + }]; + + states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list"); + states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list"); + + states[name + "_embed_attribute_list"] = [{ + token : "meta.tag", + merge : true, + regex : "\/?>", + next : nextState + }, { + token : "keyword.operator", + regex : "=" + }, { + token : "entity.other.attribute-name", + regex : "[-_a-zA-Z0-9:]+" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "text", + regex : "\\s+" + }].concat(string(name)); +}; + +}); + +ace.define('ace/mode/behaviour/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; + +function hasType(token, type) { + var hasType = true; + var typeList = token.type.split('.'); + var needleList = type.split('.'); + needleList.forEach(function(needle){ + if (typeList.indexOf(needle) == -1) { + hasType = false; + return false; + } + }); + return hasType; +} + +var XmlBehaviour = function () { + + this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour + + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { + if (text == '>') { + var position = editor.getCursorPosition(); + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken(); + var atCursor = false; + if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ + do { + token = iterator.stepBackward(); + } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); + } else { + atCursor = true; + } + if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) { + return + } + var tag = token.value; + if (atCursor){ + var tag = tag.substring(0, position.column - token.start); + } + + return { + text: '>' + '', + selection: [1, 1] + } + } + }); + + this.add('autoindent', 'insertion', function (state, action, editor, session, text) { + if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChars = line.substring(cursor.column, cursor.column + 2); + if (rightChars == ' selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/range', 'ace/mode/folding/fold_mode', 'ace/token_iterator'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var lang = require("../../lib/lang"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; +var TokenIterator = require("../../token_iterator").TokenIterator; + +var FoldMode = exports.FoldMode = function(voidElements) { + BaseFoldMode.call(this); + this.voidElements = voidElements || {}; +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.getFoldWidget = function(session, foldStyle, row) { + var tag = this._getFirstTagInLine(session, row); + + if (tag.closing) + return foldStyle == "markbeginend" ? "end" : ""; + + if (!tag.tagName || this.voidElements[tag.tagName.toLowerCase()]) + return ""; + + if (tag.selfClosing) + return ""; + + if (tag.value.indexOf("/" + tag.tagName) !== -1) + return ""; + + return "start"; + }; + + this._getFirstTagInLine = function(session, row) { + var tokens = session.getTokens(row); + var value = ""; + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + if (token.type.indexOf("meta.tag") === 0) + value += token.value; + else + value += lang.stringRepeat(" ", token.value.length); + } + + return this._parseTag(value); + }; + + this.tagRe = /^(\s*)(?)/; + this._parseTag = function(tag) { + + var match = this.tagRe.exec(tag); + var column = this.tagRe.lastIndex || 0; + this.tagRe.lastIndex = 0; + + return { + value: tag, + match: match ? match[2] : "", + closing: match ? !!match[3] : false, + selfClosing: match ? !!match[5] || match[2] == "/>" : false, + tagName: match ? match[4] : "", + column: match[1] ? column + match[1].length : column + }; + }; + this._readTagForward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var start; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!start) { + var start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + } + value += token.value; + if (value.indexOf(">") !== -1) { + var tag = this._parseTag(value); + tag.start = start; + tag.end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + iterator.stepForward(); + return tag; + } + } + } while(token = iterator.stepForward()); + + return null; + }; + + this._readTagBackward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var end; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!end) { + end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + } + value = token.value + value; + if (value.indexOf("<") !== -1) { + var tag = this._parseTag(value); + tag.end = end; + tag.start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + iterator.stepBackward(); + return tag; + } + } + } while(token = iterator.stepBackward()); + + return null; + }; + + this._pop = function(stack, tag) { + while (stack.length) { + + var top = stack[stack.length-1]; + if (!tag || top.tagName == tag.tagName) { + return stack.pop(); + } + else if (this.voidElements[tag.tagName]) { + return; + } + else if (this.voidElements[top.tagName]) { + stack.pop(); + continue; + } else { + return null; + } + } + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var firstTag = this._getFirstTagInLine(session, row); + + if (!firstTag.match) + return null; + + var isBackward = firstTag.closing || firstTag.selfClosing; + var stack = []; + var tag; + + if (!isBackward) { + var iterator = new TokenIterator(session, row, firstTag.column); + var start = { + row: row, + column: firstTag.column + firstTag.tagName.length + 2 + }; + while (tag = this._readTagForward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) + return Range.fromPoints(start, tag.start); + } + else { + stack.push(tag) + } + } + } + else { + var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length); + var end = { + row: row, + column: firstTag.column + }; + + while (tag = this._readTagBackward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (!tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) { + tag.start.column += tag.tagName.length + 2; + return Range.fromPoints(tag.start, end); + } + } + else { + stack.push(tag) + } + } + } + + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; +var WorkerClient = require("../worker/worker_client").WorkerClient; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = new CstyleBehaviour(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)\/\//; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "//"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start" || state == "regex_allowed") { + var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); + if (match) { + indent += tab; + } + } else if (state == "doc-start") { + if (endState == "start" || state == "regex_allowed") { + return ""; + } + var match = line.match(/^\s*(\/?)\*/); + if (match) { + if (match[1]) { + indent += " "; + } + indent += "* "; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + this.createWorker = function(session) { + var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); + worker.attachToDocument(session.getDocument()); + + worker.on("jslint", function(results) { + var errors = []; + for (var i=0; i the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : /\/\/.*$/ + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : /\/\*/, + next : "comment" + }, { + token : "string", + regex : "'(?=.)", + next : "qstring" + }, { + token : "string", + regex : '"(?=.)', + next : "qqstring" + }, { + token : "constant.numeric", // hex + regex : /0[xX][0-9a-fA-F]+\b/ + }, { + token : "constant.numeric", // float + regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/ + }, { + // Sound.prototype.play = + token : [ + "storage.type", "punctuation.operator", "support.function", + "punctuation.operator", "entity.name.function", "text","keyword.operator" + ], + regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", + next: "function_arguments" + }, { + // Sound.play = function() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // play = function() { } + token : [ + "entity.name.function", "text", "keyword.operator", "text", "storage.type", + "text", "paren.lparen" + ], + regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // Sound.play = function play() { } + token : [ + "storage.type", "punctuation.operator", "entity.name.function", "text", + "keyword.operator", "text", + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", + next: "function_arguments" + }, { + // function myFunc(arg) { } + token : [ + "storage.type", "text", "entity.name.function", "text", "paren.lparen" + ], + regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", + next: "function_arguments" + }, { + // foobar: function() { } + token : [ + "entity.name.function", "text", "punctuation.operator", + "text", "storage.type", "text", "paren.lparen" + ], + regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + // : function() { } (this is for issues with 'foo': function() { }) + token : [ + "text", "text", "storage.type", "text", "paren.lparen" + ], + regex : "(:)(\\s*)(function)(\\s*)(\\()", + next: "function_arguments" + }, { + token : "constant.language.boolean", + regex : /(?:true|false)\b/ + }, { + token : "keyword", + regex : "(?:" + kwBeforeRe + ")\\b", + next : "regex_allowed" + }, { + token : ["punctuation.operator", "support.function"], + regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/ + }, { + token : ["punctuation.operator", "support.function.dom"], + regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/ + }, { + token : ["punctuation.operator", "support.constant"], + regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ + }, { + token : ["storage.type", "punctuation.operator", "support.function.firebug"], + regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ + }, { + token : keywordMapper, + regex : identifierRe + }, { + token : "keyword.operator", + regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/, + next : "regex_allowed" + }, { + token : "punctuation.operator", + regex : /\?|\:|\,|\;|\./, + next : "regex_allowed" + }, { + token : "paren.lparen", + regex : /[\[({]/, + next : "regex_allowed" + }, { + token : "paren.rparen", + regex : /[\])}]/ + }, { + token : "keyword.operator", + regex : /\/=?/, + next : "regex_allowed" + }, { + token: "comment", + regex: /^#!.*$/ + }, { + token : "text", + regex : /\s+/ + } + ], + // regular expressions are only allowed after certain tokens. This + // makes sure we don't mix up regexps with the divison operator + "regex_allowed": [ + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + merge : true, + regex : "\\/\\*", + next : "comment_regex_allowed" + }, { + token : "comment", + regex : "\\/\\/.*$" + }, { + token: "string.regexp", + regex: "\\/", + next: "regex", + merge: true + }, { + token : "text", + regex : "\\s+" + }, { + // immediately return to the start mode without matching + // anything + token: "empty", + regex: "", + next: "start" + } + ], + "regex": [ + { + // escapes + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + // flag + token: "string.regexp", + regex: "/\\w*", + next: "start", + merge: true + }, { + // invalid operators + token : "invalid", + regex: /\{\d+,?(?:\d+)?}[+*]|[+*^$?][+*]|\?\?/ // |[^$][?] + }, { + // operators + token : "constant.language.escape", + regex: /\(\?[:=!]|\)|\{\d+,?(?:\d+)?}|[+*]\?|[(|)$^+*?]/ + }, { + token: "string.regexp", + regex: /{|[^\[\\{()$^+*?\/]+/, + merge: true + }, { + token: "constant.language.escape", + regex: /\[\^?/, + next: "regex_character_class", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "regex_character_class": [ + { + token: "regexp.keyword.operator", + regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" + }, { + token: "constant.language.escape", + regex: "]", + next: "regex", + merge: true + }, { + token: "constant.language.escape", + regex: "-", + }, { + token: "string.regexp.charachterclass", + regex: /[^\]\-\\]+/, + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "function_arguments": [ + { + token: "variable.parameter", + regex: identifierRe + }, { + token: "punctuation.operator", + regex: "[, ]+", + merge: true + }, { + token: "punctuation.operator", + regex: "$", + merge: true + }, { + token: "empty", + regex: "", + next: "start" + } + ], + "comment_regex_allowed" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "regex_allowed" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : ".*?\\*\\/", + merge : true, + next : "start" + }, { + token : "comment", // comment spanning whole line + merge : true, + regex : ".+" + } + ], + "qqstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : '[^"\\\\]+', + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qqstring", + merge : true + }, { + token : "string", + regex : '"|$', + next : "start", + merge : true + } + ], + "qstring" : [ + { + token : "constant.language.escape", + regex : escapedRe + }, { + token : "string", + regex : "[^'\\\\]+", + merge : true + }, { + token : "string", + regex : "\\\\$", + next : "qstring", + merge : true + }, { + token : "string", + regex : "'|$", + next : "start", + merge : true + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); +}; + +oop.inherits(JavaScriptHighlightRules, TextHighlightRules); + +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); + +ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var DocCommentHighlightRules = function() { + + this.$rules = { + "start" : [ { + token : "comment.doc.tag", + regex : "@[\\w\\d_]+" // TODO: fix email addresses + }, { + token : "comment.doc", + merge : true, + regex : "\\s+" + }, { + token : "comment.doc", + merge : true, + regex : "TODO" + }, { + token : "comment.doc", + merge : true, + regex : "[^@\\*]+" + }, { + token : "comment.doc", + merge : true, + regex : "." + }] + }; +}; + +oop.inherits(DocCommentHighlightRules, TextHighlightRules); + +DocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + merge : true, + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +DocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + merge : true, + regex : "\\*\\/", + next : start + }; +}; + + +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/svg_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_highlight_rules', 'ace/mode/xml_util'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; +var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules; +var xmlUtil = require("./xml_util"); + +var SvgHighlightRules = function() { + XmlHighlightRules.call(this); + + this.$rules.start.splice(3, 0, { + token : "meta.tag", + regex : "<(?=\s*script)", + next : "script" + }); + + xmlUtil.tag(this.$rules, "script", "js-start"); + + this.embedRules(JavaScriptHighlightRules, "js-", [{ + token: "comment", + regex: "\\/\\/.*(?=<\\/script>)", + next: "tag" + }, { + token: "meta.tag", + regex: "<\\/(?=script)", + next: "tag" + }]); +}; + +oop.inherits(SvgHighlightRules, XmlHighlightRules); + +exports.SvgHighlightRules = SvgHighlightRules; +}); + +ace.define('ace/mode/folding/mixed', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function(defaultMode, subModes) { + this.defaultMode = defaultMode; + this.subModes = subModes; +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + + this.$getMode = function(state) { + for (var key in this.subModes) { + if (state.indexOf(key) === 0) + return this.subModes[key]; + } + return null; + }; + + this.$tryMode = function(state, session, foldStyle, row) { + var mode = this.$getMode(state); + return (mode ? mode.getFoldWidget(session, foldStyle, row) : ""); + }; + + this.getFoldWidget = function(session, foldStyle, row) { + return ( + this.$tryMode(session.getState(row-1), session, foldStyle, row) || + this.$tryMode(session.getState(row), session, foldStyle, row) || + this.defaultMode.getFoldWidget(session, foldStyle, row) + ); + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var mode = this.$getMode(session.getState(row-1)); + + if (!mode || !mode.getFoldWidget(session, foldStyle, row)) + mode = this.$getMode(session.getState(row)); + + if (!mode || !mode.getFoldWidget(session, foldStyle, row)) + mode = this.defaultMode; + + return mode.getFoldWidgetRange(session, foldStyle, row); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-tcl.js b/vendor/assets/javascripts/ace-src-noconflict/mode-tcl.js new file mode 100644 index 00000000..64473a24 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-tcl.js @@ -0,0 +1,444 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/tcl', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/folding/cstyle', 'ace/mode/tcl_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; +var TclHighlightRules = require("./tcl_highlight_rules").TclHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new TclHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var outdent = true; + var re = /^(\s*)#/; + + for (var i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=startRow; i<= endRow; i++) + { + var line = doc.getLine(i); + var m = line.match(re); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = m[0].length; + doc.replace(deleteRange, m[1]); + } + } + else { + doc.indentRows(startRow, endRow, "#"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/; + this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var line = session.getLine(row); + var match = line.match(this.foldingStartMarker); + if (match) { + var i = match.index; + + if (match[1]) + return this.openingBracketBlock(session, match[1], row, i); + + var range = session.getCommentFoldRange(row, i + match[0].length); + range.end.column -= 2; + return range; + } + + if (foldStyle !== "markbeginend") + return; + + var match = line.match(this.foldingStopMarker); + if (match) { + var i = match.index + match[0].length; + + if (match[2]) { + var range = session.getCommentFoldRange(row, i); + range.end.column -= 2; + return range; + } + + var end = {row: row, column: i}; + var start = session.$findOpeningBracket(match[1], end); + + if (!start) + return; + + start.column++; + end.column--; + + return Range.fromPoints(start, end); + } + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/tcl_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var TclHighlightRules = function() { + + //TODO var builtinFunctions = ""; + + this.$rules = { + "start" : [ + { + token : "comment", + merge : true, + regex : "#.*\\\\$", + next : "commentfollow" + }, { + token : "comment", + regex : "#.*$" + }, { + token : "support.function", + regex : '[\\\\]$', + next : "splitlineStart" + }, { + token : "text", + regex : '[\\\\](?:["]|[{]|[}]|[[]|[]]|[$]|[\])' + }, { + token : "text", // last value before command + regex : '^|[^{][;][^}]|[/\r/]', + next : "commandItem" + }, { + token : "string", // single line + regex : '[ ]*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // multi line """ string start + merge : true, + regex : '[ ]*["]', + next : "qqstring" + }, { + token : "variable.instancce", // variable xotcl with braces + merge : true, + regex : "[$]", + next : "variable" + }, { + token : "support.function", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|{\\*}|;|::" + }, { + token : "identifier", + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "paren.lparen", + regex : "[[{]", + next : "commandItem" + }, { + token : "paren.lparen", + regex : "[(]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "commandItem" : [ + { + token : "comment", + merge : true, + regex : "#.*\\\\$", + next : "commentfollow" + }, { + token : "comment", + regex : "#.*$", + next : "start" + }, { + token : "string", // single line + regex : '[ ]*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "variable.instancce", // variable xotcl with braces + merge : true, + regex : "[$]", + next : "variable" + }, { + token : "support.function", + regex : "(?:[:][:])[a-zA-Z0-9_/]+(?:[:][:])", + next : "commandItem" + }, { + token : "support.function", + regex : "[a-zA-Z0-9_/]+(?:[:][:])", + next : "commandItem" + }, { + token : "support.function", + regex : "(?:[:][:])", + next : "commandItem" + }, { + token : "support.function", + regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|{\\*}|;|::" + }, { + token : "keyword", + regex : "[a-zA-Z0-9_/]+", + next : "start" + } ], + "commentfollow" : [ + { + token : "comment", + regex : ".*\\\\$", + next : "commentfollow" + }, { + token : "comment", + merge : true, + regex : '.+', + next : "start" + } ], + "splitlineStart" : [ + { + token : "text", + regex : "^.", + next : "start" + }], + "variable" : [ + { + token : "variable.instancce", // variable xotcl with braces + regex : "(?:[:][:])?(?:[a-zA-Z_]|\d)+(?:(?:[:][:])?(?:[a-zA-Z_]|\d)+)?(?:[(](?:[a-zA-Z_]|\d)+[)])?", + next : "start" + }, { + token : "variable.instancce", // variable tcl + regex : "(?:[a-zA-Z_]|\d)+(?:[(](?:[a-zA-Z_]|\d)+[)])?", + next : "start" + }, { + token : "variable.instancce", // variable tcl with braces + regex : "{?(?:[a-zA-Z_]|\d)+}?", + next : "start" + }], + "qqstring" : [ { + token : "string", // multi line """ string end + regex : '(?:[^\\\\]|\\\\.)*?["]', + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } ] + }; +}; + +oop.inherits(TclHighlightRules, TextHighlightRules); + +exports.TclHighlightRules = TclHighlightRules; +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-text.js b/vendor/assets/javascripts/ace-src-noconflict/mode-text.js new file mode 100644 index 00000000..e69de29b diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-textile.js b/vendor/assets/javascripts/ace-src-noconflict/mode-textile.js new file mode 100644 index 00000000..fb70ddc0 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-textile.js @@ -0,0 +1,175 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/textile', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/textile_highlight_rules', 'ace/mode/matching_brace_outdent'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var TextileHighlightRules = require("./textile_highlight_rules").TextileHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new TextileHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); +}; +oop.inherits(Mode, TextMode); + +(function() { + this.getNextLineIndent = function(state, line, tab) { + if (state == "intag") + return tab; + + return ""; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/textile_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var TextileHighlightRules = function() { + this.$rules = { + "start" : [ + { + token : function(value) { + if (value.charAt(0) == "h") + return "markup.heading." + value.charAt(1); + else + return "markup.heading"; + }, + regex : "h1|h2|h3|h4|h5|h6|bq|p|bc|pre", + next : "blocktag" + }, + { + token : "keyword", + regex : "[\\*]+|[#]+" + }, + { + token : "text", + regex : ".+" + } + ], + "blocktag" : [ + { + token : "keyword", + regex : "\\. ", + next : "start" + }, + { + token : "keyword", + regex : "\\(", + next : "blocktagproperties" + } + ], + "blocktagproperties" : [ + { + token : "keyword", + regex : "\\)", + next : "blocktag" + }, + { + token : "string", + regex : "[a-zA-Z0-9\\-_]+" + }, + { + token : "keyword", + regex : "#" + } + ] + }; +}; + +oop.inherits(TextileHighlightRules, TextHighlightRules); + +exports.TextileHighlightRules = TextileHighlightRules; + +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-xml.js b/vendor/assets/javascripts/ace-src-noconflict/mode-xml.js new file mode 100644 index 00000000..07a154d6 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-xml.js @@ -0,0 +1,822 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xml_highlight_rules', 'ace/mode/behaviour/xml', 'ace/mode/folding/xml'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules; +var XmlBehaviour = require("./behaviour/xml").XmlBehaviour; +var XmlFoldMode = require("./folding/xml").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules()); + this.$behaviour = new XmlBehaviour(); + this.foldingRules = new XmlFoldMode(); +}; + +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + return this.$getIndent(line); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); + +ace.define('ace/mode/xml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var xmlUtil = require("./xml_util"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var XmlHighlightRules = function() { + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + this.$rules = { + start : [{ + token : "text", + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + merge : true, + regex : "<\\!--", + next : "comment" + }, { + token : "xml_pe", + regex : "<\\!.*?>" + }, { + token : "meta.tag", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "text", + regex : "\\s+" + }, { + token : "constant.character.entity", + regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" + }, { + token : "text", + regex : "[^<]+" + }], + + cdata : [{ + token : "text", + regex : "\\]\\]>", + next : "start" + }, { + token : "text", + regex : "\\s+" + }, { + token : "text", + regex : "(?:[^\\]]|\\](?!\\]>))+" + }], + + comment : [{ + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + merge : true, + regex : ".+" + }] + }; + + xmlUtil.tag(this.$rules, "tag", "start"); +}; + +oop.inherits(XmlHighlightRules, TextHighlightRules); + +exports.XmlHighlightRules = XmlHighlightRules; +}); + +ace.define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) { + + +function string(state) { + return [{ + token : "string", + regex : '".*?"' + }, { + token : "string", // multi line string start + merge : true, + regex : '["].*', + next : state + "_qqstring" + }, { + token : "string", + regex : "'.*?'" + }, { + token : "string", // multi line string start + merge : true, + regex : "['].*", + next : state + "_qstring" + }]; +} + +function multiLineString(quote, state) { + return [{ + token : "string", + merge : true, + regex : ".*?" + quote, + next : state + }, { + token : "string", + merge : true, + regex : '.+' + }]; +} + +exports.tag = function(states, name, nextState, tagMap) { + states[name] = [{ + token : "text", + regex : "\\s+" + }, { + //token : "meta.tag", + + token : !tagMap ? "meta.tag.tag-name" : function(value) { + if (tagMap[value]) + return "meta.tag.tag-name." + tagMap[value]; + else + return "meta.tag.tag-name"; + }, + merge : true, + regex : "[-_a-zA-Z0-9:]+", + next : name + "_embed_attribute_list" + }, { + token: "empty", + regex: "", + next : name + "_embed_attribute_list" + }]; + + states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list"); + states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list"); + + states[name + "_embed_attribute_list"] = [{ + token : "meta.tag", + merge : true, + regex : "\/?>", + next : nextState + }, { + token : "keyword.operator", + regex : "=" + }, { + token : "entity.other.attribute-name", + regex : "[-_a-zA-Z0-9:]+" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "text", + regex : "\\s+" + }].concat(string(name)); +}; + +}); + +ace.define('ace/mode/behaviour/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; + +function hasType(token, type) { + var hasType = true; + var typeList = token.type.split('.'); + var needleList = type.split('.'); + needleList.forEach(function(needle){ + if (typeList.indexOf(needle) == -1) { + hasType = false; + return false; + } + }); + return hasType; +} + +var XmlBehaviour = function () { + + this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour + + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { + if (text == '>') { + var position = editor.getCursorPosition(); + var iterator = new TokenIterator(session, position.row, position.column); + var token = iterator.getCurrentToken(); + var atCursor = false; + if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ + do { + token = iterator.stepBackward(); + } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); + } else { + atCursor = true; + } + if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) { + return + } + var tag = token.value; + if (atCursor){ + var tag = tag.substring(0, position.column - token.start); + } + + return { + text: '>' + '', + selection: [1, 1] + } + } + }); + + this.add('autoindent', 'insertion', function (state, action, editor, session, text) { + if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChars = line.substring(cursor.column, cursor.column + 2); + if (rightChars == ' selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); + +ace.define('ace/mode/folding/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/range', 'ace/mode/folding/fold_mode', 'ace/token_iterator'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var lang = require("../../lib/lang"); +var Range = require("../../range").Range; +var BaseFoldMode = require("./fold_mode").FoldMode; +var TokenIterator = require("../../token_iterator").TokenIterator; + +var FoldMode = exports.FoldMode = function(voidElements) { + BaseFoldMode.call(this); + this.voidElements = voidElements || {}; +}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.getFoldWidget = function(session, foldStyle, row) { + var tag = this._getFirstTagInLine(session, row); + + if (tag.closing) + return foldStyle == "markbeginend" ? "end" : ""; + + if (!tag.tagName || this.voidElements[tag.tagName.toLowerCase()]) + return ""; + + if (tag.selfClosing) + return ""; + + if (tag.value.indexOf("/" + tag.tagName) !== -1) + return ""; + + return "start"; + }; + + this._getFirstTagInLine = function(session, row) { + var tokens = session.getTokens(row); + var value = ""; + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + if (token.type.indexOf("meta.tag") === 0) + value += token.value; + else + value += lang.stringRepeat(" ", token.value.length); + } + + return this._parseTag(value); + }; + + this.tagRe = /^(\s*)(?)/; + this._parseTag = function(tag) { + + var match = this.tagRe.exec(tag); + var column = this.tagRe.lastIndex || 0; + this.tagRe.lastIndex = 0; + + return { + value: tag, + match: match ? match[2] : "", + closing: match ? !!match[3] : false, + selfClosing: match ? !!match[5] || match[2] == "/>" : false, + tagName: match ? match[4] : "", + column: match[1] ? column + match[1].length : column + }; + }; + this._readTagForward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var start; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!start) { + var start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + } + value += token.value; + if (value.indexOf(">") !== -1) { + var tag = this._parseTag(value); + tag.start = start; + tag.end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + iterator.stepForward(); + return tag; + } + } + } while(token = iterator.stepForward()); + + return null; + }; + + this._readTagBackward = function(iterator) { + var token = iterator.getCurrentToken(); + if (!token) + return null; + + var value = ""; + var end; + + do { + if (token.type.indexOf("meta.tag") === 0) { + if (!end) { + end = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + token.value.length + }; + } + value = token.value + value; + if (value.indexOf("<") !== -1) { + var tag = this._parseTag(value); + tag.end = end; + tag.start = { + row: iterator.getCurrentTokenRow(), + column: iterator.getCurrentTokenColumn() + }; + iterator.stepBackward(); + return tag; + } + } + } while(token = iterator.stepBackward()); + + return null; + }; + + this._pop = function(stack, tag) { + while (stack.length) { + + var top = stack[stack.length-1]; + if (!tag || top.tagName == tag.tagName) { + return stack.pop(); + } + else if (this.voidElements[tag.tagName]) { + return; + } + else if (this.voidElements[top.tagName]) { + stack.pop(); + continue; + } else { + return null; + } + } + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var firstTag = this._getFirstTagInLine(session, row); + + if (!firstTag.match) + return null; + + var isBackward = firstTag.closing || firstTag.selfClosing; + var stack = []; + var tag; + + if (!isBackward) { + var iterator = new TokenIterator(session, row, firstTag.column); + var start = { + row: row, + column: firstTag.column + firstTag.tagName.length + 2 + }; + while (tag = this._readTagForward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) + return Range.fromPoints(start, tag.start); + } + else { + stack.push(tag) + } + } + } + else { + var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length); + var end = { + row: row, + column: firstTag.column + }; + + while (tag = this._readTagBackward(iterator)) { + if (tag.selfClosing) { + if (!stack.length) { + tag.start.column += tag.tagName.length + 2; + tag.end.column -= 2; + return Range.fromPoints(tag.start, tag.end); + } else + continue; + } + + if (!tag.closing) { + this._pop(stack, tag); + if (stack.length == 0) { + tag.start.column += tag.tagName.length + 2; + return Range.fromPoints(tag.start, end); + } + } + else { + stack.push(tag) + } + } + } + + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-xquery.js b/vendor/assets/javascripts/ace-src-noconflict/mode-xquery.js new file mode 100644 index 00000000..b42730f9 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-xquery.js @@ -0,0 +1,591 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ +ace.define('ace/mode/xquery', ['require', 'exports', 'module' , 'ace/worker/worker_client', 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xquery_highlight_rules', 'ace/mode/behaviour/xquery', 'ace/range'], function(require, exports, module) { + + +var WorkerClient = require("../worker/worker_client").WorkerClient; +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var XQueryHighlightRules = require("./xquery_highlight_rules").XQueryHighlightRules; +var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour; +//var XQueryBackgroundHighlighter = require("./xquery_background_highlighter").XQueryBackgroundHighlighter; +var Range = require("../range").Range; + +var Mode = function(parent) { + this.$tokenizer = new Tokenizer(new XQueryHighlightRules().getRules()); + this.$behaviour = new XQueryBehaviour(parent); +}; + +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + var match = line.match(/\s*(?:then|else|return|[{\(]|<\w+>)\s*$/); + if (match) + indent += tab; + return indent; + }; + + this.checkOutdent = function(state, line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*[\}\)]/.test(input); + }; + + this.autoOutdent = function(state, doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*[\}\)])/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + + this.toggleCommentLines = function(state, doc, startRow, endRow) { + var i, line; + var outdent = true; + var re = /^\s*\(:(.*):\)/; + + for (i=startRow; i<= endRow; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + var range = new Range(0, 0, 0, 0); + for (i=startRow; i<= endRow; i++) { + line = doc.getLine(i); + range.start.row = i; + range.end.row = i; + range.end.column = line.length; + + doc.replace(range, outdent ? line.match(re)[1] : "(:" + line + ":)"); + } + }; + + this.createWorker = function(session) { + this.$deltas = []; + var worker = new WorkerClient(["ace"], "ace/mode/xquery_worker", "XQueryWorker"); + var that = this; + + session.getDocument().on('change', function(evt){ + that.$deltas.push(evt.data); + }); + + worker.attachToDocument(session.getDocument()); + + worker.on("start", function(e) { + //console.log("start"); + that.$deltas = []; + }); + + worker.on("error", function(e) { + session.setAnnotations([e.data]); + }); + + worker.on("ok", function(e) { + session.clearAnnotations(); + }); + + worker.on("highlight", function(tokens) { + var firstRow = 0; + var lastRow = session.getLength() - 1; + + var lines = tokens.data.lines; + var states = tokens.data.states; + + for(var i=0; i < that.$deltas.length; i++) + { + var delta = that.$deltas[i]; + + if (delta.action === "insertLines") + { + var newLineCount = delta.lines.length; + for (var i = 0; i < newLineCount; i++) { + lines.splice(delta.range.start.row + i, 0, undefined); + states.splice(delta.range.start.row + i, 0, undefined); + } + } + else if (delta.action === "insertText") + { + if (session.getDocument().isNewLine(delta.text)) + { + lines.splice(delta.range.end.row, 0, undefined); + states.splice(delta.range.end.row, 0, undefined); + } else { + lines[delta.range.start.row] = undefined; + states[delta.range.start.row] = undefined; + } + } else if (delta.action === "removeLines") { + var oldLineCount = delta.lines.length; + lines.splice(delta.range.start.row, oldLineCount); + states.splice(delta.range.start.row, oldLineCount); + } else if (delta.action === "removeText") { + if (session.getDocument().isNewLine(delta.text)) + { + lines[delta.range.start.row] = undefined; + lines.splice(delta.range.end.row, 1); + states[delta.range.start.row] = undefined; + states.splice(delta.range.end.row, 1); + } else { + lines[delta.range.start.row] = undefined; + states[delta.range.start.row] = undefined; + } + } + } + session.bgTokenizer.lines = lines; + session.bgTokenizer.states = states; + session.bgTokenizer.fireUpdateEvent(firstRow, lastRow); + }); + + return worker; + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); +ace.define('ace/mode/xquery_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var XQueryHighlightRules = function() { + + var keywordMapper = this.createKeywordMapper({ + keyword: "after|ancestor|ancestor-or-self|and|as|ascending|attribute|before|case|cast|castable|child|collation|comment|copy|count|declare|default|delete|descendant|descendant-or-self|descending|div|document|document-node|element|else|empty|empty-sequence|end|eq|every|except|first|following|following-sibling|for|function|ge|group|gt|idiv|if|import|insert|instance|intersect|into|is|item|last|le|let|lt|mod|modify|module|namespace|namespace-node|ne|node|only|or|order|ordered|parent|preceding|preceding-sibling|processing-instruction|rename|replace|return|satisfies|schema-attribute|schema-element|self|some|stable|start|switch|text|to|treat|try|typeswitch|union|unordered|validate|where|with|xquery|contains|paragraphs|sentences|times|words|by|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning|append|json|position" + }, "identifier"); + + // regexp must not have capturing parentheses + // regexps are ordered -> the first match is used + + this.$rules = { + start : [ { + token : "text", + regex : "<\\!\\[CDATA\\[", + next : "cdata" + }, { + token : "xml_pe", + regex : "<\\?.*?\\?>" + }, { + token : "comment", + regex : "<\\!--", + next : "comment" + }, { + token : "comment", + regex : "\\(:", + next : "comment" + }, { + token : "text", // opening tag + regex : "<\\/?", + next : "tag" + }, { + token : "constant", // number + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "variable", // variable + regex : "\\$[a-zA-Z_][a-zA-Z0-9_\\-:]*\\b" + }, { + token: "string", + regex : '".*?"' + }, { + token: "string", + regex : "'.*?'" + }, { + token : "text", + regex : "\\s+" + }, { + token: "support.function", + regex: "\\w[\\w+_\\-:]+(?=\\()" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token: "keyword.operator", + regex: "\\*|=|<|>|\\-|\\+" + }, { + token: "lparen", + regex: "[[({]" + }, { + token: "rparen", + regex: "[\\])}]" + } ], + + tag : [ { + token : "text", + regex : ">", + next : "start" + }, { + token : "meta.tag", + regex : "[-_a-zA-Z0-9:]+" + }, { + token : "text", + regex : "\\s+" + }, { + token : "string", + regex : '".*?"' + }, { + token : "string", + regex : "'.*?'" + } ], + + cdata : [ { + token : "comment", + regex : "\\]\\]>", + next : "start" + }, { + token : "comment", + regex : "\\s+" + }, { + token : "comment", + regex : "(?:[^\\]]|\\](?!\\]>))+" + } ], + + comment : [ { + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token: "comment", + regex : ".*:\\)", + next : "start" + }, { + token : "comment", + regex : ".+" + } ] + }; +}; + +oop.inherits(XQueryHighlightRules, TextHighlightRules); + +exports.XQueryHighlightRules = XQueryHighlightRules; +}); +ace.define('ace/mode/behaviour/xquery', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle'], function(require, exports, module) { + + + var oop = require("../../lib/oop"); + var Behaviour = require('../behaviour').Behaviour; + var CstyleBehaviour = require('./cstyle').CstyleBehaviour; + + var XQueryBehaviour = function (parent) { + + this.inherit(CstyleBehaviour, ["braces", "parens", "string_dquotes"]); // Get string behaviour + this.parent = parent; + +// this.add("brackets", "insertion", function (state, action, editor, session, text) { +// if (text == "\n") { +// var cursor = editor.getCursorPosition(); +// var line = session.doc.getLine(cursor.row); +// var rightChars = line.substring(cursor.column, cursor.column + 2); +// if (rightChars == ' 0 && line.charAt(cursor.column - 1) == "<") { +// line = line.substring(0, cursor.column) + "/" + line.substring(cursor.column); +// var lines = session.doc.getAllLines(); +// lines[cursor.row] = line; +// // call mode helper to close the tag if possible +// parent.exec("closeTag", lines.join(session.doc.getNewLineCharacter()), cursor.row); +// } +// } +// return false; +// }); + } + oop.inherits(XQueryBehaviour, Behaviour); + + exports.XQueryBehaviour = XQueryBehaviour; +}); + +ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var Behaviour = require("../behaviour").Behaviour; + +var CstyleBehaviour = function () { + + this.add("braces", "insertion", function (state, action, editor, session, text) { + if (text == '{') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '{' + selected + '}', + selection: false + }; + } else { + return { + text: '{}', + selection: [1, 1] + }; + } + } else if (text == '}') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } else if (text == "\n") { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1}); + if (!openBracePos) + return null; + + var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString()); + var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row)); + + return { + text: '\n' + indent + '\n' + next_indent, + selection: [1, indent.length, 1, indent.length] + }; + } + } + }); + + this.add("braces", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '{') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.end.column, range.end.column + 1); + if (rightChar == '}') { + range.end.column++; + return range; + } + } + }); + + this.add("parens", "insertion", function (state, action, editor, session, text) { + if (text == '(') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '(' + selected + ')', + selection: false + }; + } else { + return { + text: '()', + selection: [1, 1] + }; + } + } else if (text == ')') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ')') { + var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("parens", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '(') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ')') { + range.end.column++; + return range; + } + } + }); + + this.add("brackets", "insertion", function (state, action, editor, session, text) { + if (text == '[') { + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: '[' + selected + ']', + selection: false + }; + } else { + return { + text: '[]', + selection: [1, 1] + }; + } + } else if (text == ']') { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == ']') { + var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); + if (matching !== null) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + }); + + this.add("brackets", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && selected == '[') { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == ']') { + range.end.column++; + return range; + } + } + }); + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selection = editor.getSelectionRange(); + var selected = session.doc.getTextRange(selection); + if (selected !== "") { + return { + text: quote + selected + quote, + selection: false + }; + } else { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var leftChar = line.substring(cursor.column-1, cursor.column); + + // We're escaped. + if (leftChar == '\\') { + return null; + } + + // Find what token we're inside. + var tokens = session.getTokens(selection.start.row); + var col = 0, token; + var quotepos = -1; // Track whether we're inside an open quote. + + for (var x = 0; x < tokens.length; x++) { + token = tokens[x]; + if (token.type == "string") { + quotepos = -1; + } else if (quotepos < 0) { + quotepos = token.value.indexOf(quote); + } + if ((token.value.length + col) > selection.start.column) { + break; + } + col += tokens[x].value.length; + } + + // Try and be smart about when we auto insert. + if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { + return { + text: quote + quote, + selection: [1,1] + }; + } else if (token && token.type === "string") { + // Ignore input and move right one if we're typing over the closing quote. + var rightChar = line.substring(cursor.column, cursor.column + 1); + if (rightChar == quote) { + return { + text: '', + selection: [1, 1] + }; + } + } + } + } + }); + + this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == '"') { + range.end.column++; + return range; + } + } + }); + +}; + +oop.inherits(CstyleBehaviour, Behaviour); + +exports.CstyleBehaviour = CstyleBehaviour; +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-yaml.js b/vendor/assets/javascripts/ace-src-noconflict/mode-yaml.js new file mode 100644 index 00000000..87a059fa --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/mode-yaml.js @@ -0,0 +1,371 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/mode/yaml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/yaml_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/folding/coffee'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var YamlHighlightRules = require("./yaml_highlight_rules").YamlHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var FoldMode = require("./folding/coffee").FoldMode; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new YamlHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); + this.foldingRules = new FoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; + + +}).call(Mode.prototype); + +exports.Mode = Mode; + +}); + +ace.define('ace/mode/yaml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var YamlHighlightRules = function() { + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + this.$rules = { + "start" : [ + { + token : "comment", + regex : "#.*$" + }, { + token : "comment", + regex : "^---" + }, { + token: "variable", + regex: "[&\\*][a-zA-Z0-9-_]+" + }, { + token: ["identifier", "text"], + regex: "(\\w+\\s*:)(\\w*)" + }, { + token : "keyword.operator", + regex : "<<\\w*:\\w*" + }, { + token : "keyword.operator", + regex : "-\\s*(?=[{])" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // multi line string start + merge : true, + regex : '[\\|>]\\w*', + next : "qqstring" + }, { + token : "string", // single quoted string + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : "constant.language.boolean", + regex : "(?:true|false|yes|no)\\b" + }, { + token : "invalid.illegal", // comments are not allowed + regex : "\\/\\/.*$" + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "qqstring" : [ + { + token : "string", + regex : '(?=(?:(?:\\\\.)|(?:[^:]))*?:)', + next : "start" + }, { + token : "string", + merge : true, + regex : '.+' + } + ]} + +}; + +oop.inherits(YamlHighlightRules, TextHighlightRules); + +exports.YamlHighlightRules = YamlHighlightRules; +}); + +ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../range").Range; + +var MatchingBraceOutdent = function() {}; + +(function() { + + this.checkOutdent = function(line, input) { + if (! /^\s+$/.test(line)) + return false; + + return /^\s*\}/.test(input); + }; + + this.autoOutdent = function(doc, row) { + var line = doc.getLine(row); + var match = line.match(/^(\s*\})/); + + if (!match) return 0; + + var column = match[1].length; + var openBracePos = doc.findMatchingBracket({row: row, column: column}); + + if (!openBracePos || openBracePos.row == row) return 0; + + var indent = this.$getIndent(doc.getLine(openBracePos.row)); + doc.replace(new Range(row, 0, row, column-1), indent); + }; + + this.$getIndent = function(line) { + var match = line.match(/^(\s+)/); + if (match) { + return match[1]; + } + + return ""; + }; + +}).call(MatchingBraceOutdent.prototype); + +exports.MatchingBraceOutdent = MatchingBraceOutdent; +}); + +ace.define('ace/mode/folding/coffee', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range'], function(require, exports, module) { + + +var oop = require("../../lib/oop"); +var BaseFoldMode = require("./fold_mode").FoldMode; +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; +oop.inherits(FoldMode, BaseFoldMode); + +(function() { + + this.getFoldWidgetRange = function(session, foldStyle, row) { + var range = this.indentationBlock(session, row); + if (range) + return range; + + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1 || line[startLevel] != "#") + return; + + var startColumn = line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + line = session.getLine(row); + var level = line.search(re); + + if (level == -1) + continue; + + if (line[level] != "#") + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + var indent = line.search(/\S/); + var next = session.getLine(row + 1); + var prev = session.getLine(row - 1); + var prevIndent = prev.search(/\S/); + var nextIndent = next.search(/\S/); + + if (indent == -1) { + session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : ""; + return ""; + } + + // documentation comments + if (prevIndent == -1) { + if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") { + session.foldWidgets[row - 1] = ""; + session.foldWidgets[row + 1] = ""; + return "start"; + } + } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") { + if (session.getLine(row - 2).search(/\S/) == -1) { + session.foldWidgets[row - 1] = "start"; + session.foldWidgets[row + 1] = ""; + return ""; + } + } + + if (prevIndent!= -1 && prevIndent < indent) + session.foldWidgets[row - 1] = "start"; + else + session.foldWidgets[row - 1] = ""; + + if (indent < nextIndent) + return "start"; + else + return ""; + }; + +}).call(FoldMode.prototype); + +}); + +ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + + +var Range = require("../../range").Range; + +var FoldMode = exports.FoldMode = function() {}; + +(function() { + + this.foldingStartMarker = null; + this.foldingStopMarker = null; + + // must return "" if there's no fold, to enable caching + this.getFoldWidget = function(session, foldStyle, row) { + var line = session.getLine(row); + if (this.foldingStartMarker.test(line)) + return "start"; + if (foldStyle == "markbeginend" + && this.foldingStopMarker + && this.foldingStopMarker.test(line)) + return "end"; + return ""; + }; + + this.getFoldWidgetRange = function(session, foldStyle, row) { + return null; + }; + + this.indentationBlock = function(session, row, column) { + var re = /\S/; + var line = session.getLine(row); + var startLevel = line.search(re); + if (startLevel == -1) + return; + + var startColumn = column || line.length; + var maxRow = session.getLength(); + var startRow = row; + var endRow = row; + + while (++row < maxRow) { + var level = session.getLine(row).search(re); + + if (level == -1) + continue; + + if (level <= startLevel) + break; + + endRow = row; + } + + if (endRow > startRow) { + var endColumn = session.getLine(endRow).length; + return new Range(startRow, startColumn, endRow, endColumn); + } + }; + + this.openingBracketBlock = function(session, bracket, row, column, typeRe) { + var start = {row: row, column: column + 1}; + var end = session.$findClosingBracket(bracket, start, typeRe); + if (!end) + return; + + var fw = session.foldWidgets[end.row]; + if (fw == null) + fw = this.getFoldWidget(session, end.row); + + if (fw == "start" && end.row > start.row) { + end.row --; + end.column = session.getLine(end.row).length; + } + return Range.fromPoints(start, end); + }; + +}).call(FoldMode.prototype); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-ambiance.js b/vendor/assets/javascripts/ace-src-noconflict/theme-ambiance.js new file mode 100644 index 00000000..fb4e1570 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-ambiance.js @@ -0,0 +1,269 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright 2011 Irakli Gozalishvili. All rights reserved. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/ambiance', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-ambiance"; +exports.cssText = ".ace-ambiance {\ + background-color: #202020;\ +}\ +\ +.ace-ambiance .ace_editor {\ + border: 2px solid rgb(159, 159, 159);\ +}\ +\ +.ace-ambiance .ace_editor.ace_focus {\ + border: 2px solid #327fbd;\ +}\ +\ +.ace-ambiance .ace_gutter {\ + background-image: -moz-linear-gradient(left, #3D3D3D, #333);\ + background-image: -ms-linear-gradient(left, #3D3D3D, #333);\ + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#3D3D3D), to(#333));\ + background-image: -webkit-linear-gradient(left, #3D3D3D, #333);\ + background-image: -o-linear-gradient(left, #3D3D3D, #333);\ + background-image: linear-gradient(left, #3D3D3D, #333);\ + background-repeat: repeat-x;\ +\ + text-shadow: 0px 1px 1px #4d4d4d;\ + color: #222;\ + border-right: 1px solid #4d4d4d;\ + overflow : hidden;\ +}\ +\ +.ace-ambiance .ace_gutter-layer {\ + background: repeat left top;\ + width: 100%;\ + text-align: right;\ +}\ +\ +.ace-ambiance .ace_gutter-layer .ace_gutter-cell .ace_fold-widget {\ + position: absolute;\ + right: 2px;\ + margin: 0;\ + vertical-align: middle;\ + height: inherit;\ + width: auto;\ + background: none;\ + border: none;\ + box-shadow: none;\ + outline: none;\ +}\ +\ +.ace-ambiance .ace_gutter-layer .ace_gutter-cell .ace_fold-widget:hover {\ + color: #777;\ +}\ +\ +.ace-ambiance .ace_gutter-layer .ace_gutter-cell .ace_fold-widget:hover {\ + color: #777;\ +}\ +\ +.ace-ambiance .ace_gutter-layer .ace_gutter-cell .ace_fold-widget.open:after {\ + content: '▾'\ +}\ +\ +.ace-ambiance .ace_gutter-layer .ace_gutter-cell .ace_fold-widget.closed:after {\ + content: '‣'\ +}\ +\ +.ace-ambiance .ace_print_margin {\ + border-left: 1px dotted #2D2D2D;\ + width: 100%;\ + background: #262626;\ +}\ +\ +.ace-ambiance .ace_scroller {\ + background-color: #202020;\ + -webkit-box-shadow: inset 0 0 10px black;\ + -moz-box-shadow: inset 0 0 10px black;\ + -o-box-shadow: inset 0 0 10px black;\ + box-shadow: inset 0 0 10px black;\ +}\ +\ +.ace-ambiance .ace_text-layer {\ + cursor: text;\ + color: #E6E1DC;\ + background: url(\"noise.png\") repeat left top;\ +}\ +\ +.ace-ambiance .ace_cursor {\ + border-left: 1px solid #7991E8;\ +}\ +\ +.ace-ambiance .ace_cursor.ace_overwrite {\ + border: 1px solid #FFE300;\ + background: #766B13;\ +}\ +\ +.ace-ambiance.normal-mode .ace_cursor-layer {\ + z-index: 0;\ +}\ + \ +.ace-ambiance .ace_marker-layer .ace_selection {\ + background: rgba(221, 240, 255, 0.20);\ +}\ +\ +.ace-ambiance .ace_marker-layer .ace_selected_word {\ + border-radius: 4px;\ + border: 8px solid #3f475d;\ + box-shadow: 0 0 4px black;\ +}\ +\ +.ace-ambiance .ace_marker-layer .ace_step {\ + background: rgb(198, 219, 174);\ +}\ +\ +.ace-ambiance .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgba(255, 255, 255, 0.25);\ +}\ +\ +.ace-ambiance .ace_marker-layer .ace_active_line {\ + background: rgba(255, 255, 255, 0.031);\ +}\ +\ +\ +\ +.ace-ambiance .ace_invisible {\ + color: #333;\ +}\ +\ +.ace-ambiance .ace_paren {\ + color: #24C2C7;\ +}\ +\ +.ace-ambiance .ace_keyword {\ + color: #cda869;\ +}\ +\ +.ace-ambiance .ace_keyword.ace_operator {\ + color: #fa8d6a;\ +}\ +\ +.ace-ambiance .ace_punctuation.ace_operator {\ + color: #fa8d6a;\ +}\ +\ +.ace-ambiance .ace_identifier {\ +}\ +\ +.ace-ambiance .ace-statement {\ + color: #cda869;\ +}\ +\ +.ace-ambiance .ace_constant {\ + color: #CF7EA9;\ +}\ +\ +.ace-ambiance .ace_constant.ace_language {\ + color: #CF7EA9;\ +}\ +\ +.ace-ambiance .ace_constant.ace_library {\ + \ +}\ +\ +.ace-ambiance .ace_constant.ace_numeric {\ + color: #78CF8A;\ +}\ +\ +.ace-ambiance .ace_invalid {\ + text-decoration: underline;\ +}\ +\ +.ace-ambiance .ace_invalid.ace_illegal {\ + color:#F8F8F8;\ + background-color: rgba(86, 45, 86, 0.75);\ +}\ +\ +.ace-ambiance .ace_invalid,\ +.ace-ambiance .ace_deprecated {\ + text-decoration: underline;\ + font-style: italic;\ + color: #D2A8A1;\ +}\ +\ +.ace-ambiance .ace_support {\ + color: #9B859D;\ +}\ +\ +.ace-ambiance .ace_support.ace_function {\ + color: #DAD085;\ +}\ +\ +.ace-ambiance .ace_function.ace_buildin {\ + color: #9b859d;\ +}\ +\ +.ace-ambiance .ace_string {\ + color: #8f9d6a;\ +}\ +\ +.ace-ambiance .ace_string.ace_regexp {\ + color: #DAD085;\ +}\ +\ +.ace-ambiance .ace_comment {\ + font-style: italic;\ + color: #555;\ +}\ +\ +.ace-ambiance .ace_comment.ace_doc {\ +}\ +\ +.ace-ambiance .ace_comment.ace_doc.ace_tag {\ + color: #666;\ + font-style: normal;\ +}\ +\ +.ace-ambiance .ace_definition,\ +.ace-ambiance .ace_type {\ + color: #aac6e3;\ +}\ +\ +.ace-ambiance .ace_variable {\ + color: #9999cc;\ +}\ +\ +.ace-ambiance .ace_variable.ace_language {\ + color: #9b859d;\ +}\ +\ +.ace-ambiance .ace_xml_pe {\ + color: #494949;\ +}\ +\ +.ace-ambiance .ace_gutter-layer,\ +.ace-ambiance .ace_text-layer {\ + background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAQAAAAHUWYVAABFFUlEQVQYGbzBCeDVU/74/6fj9HIcx/FRHx9JCFmzMyGRURhLZIkUsoeRfUjS2FNDtr6WkMhO9sm+S8maJfu+Jcsg+/o/c+Z4z/t97/vezy3z+z8ekGlnYICG/o7gdk+wmSHZ1z4pJItqapjoKXWahm8NmV6eOTbWUOp6/6a/XIg6GQqmenJ2lDHyvCFZ2cBDbmtHA043VFhHwXxClWmeYAdLhV00Bd85go8VmaFCkbVkzlQENzfBDZ5gtN7HwF0KDrTwJ0dypSOzpaKCMwQHKTIreYIxlmhXTzTWkVm+LTynZhiSBT3RZQ7aGfjGEd3qyXQ1FDymqbKxpspERQN2MiRjNZlFFQXfCNFm9nM1zpAsoYjmtRTc5ajwuaXc5xrWskT97RaKzAGe5ARHhVUsDbjKklziiX5WROcJwSNCNI+9w1Jwv4Zb2r7lCMZ4oq5C0EdTx+2GzNuKpJ+iFf38JEWkHJn9DNF7mmBDITrWEg0VWL3pHU20tSZnuqWu+R3BtYa8XxV1HO7GyD32UkOpL/yDloINFTmvtId+nmAjxRw40VMwVKiwrKLE4bK5UOVntYwhOcSSXKrJHKPJedocpGjVz/ZMIbnYUPB10/eKCrs5apqpgVmWzBYWpmtKHecJPjaUuEgRDDaU0oZghCJ6zNMQ5ZhDYx05r5v2muQdM0EILtXUsaKiQX9WMEUotagQzFbUNN6NUPC2nm5pxEWGCjMc3GdJHjSU2kORLK/JGSrkfGEIjncU/CYUnOipoYemwj8tST9NsJmB7TUVXtbUtXATJVZXBMvYeTXJfobgJUPmGMP/yFaWonaa6BcFO3nqcIqCozSZoZoSr1g4zJOzuyGnxTEX3lUEJ7WcZgme8ddaWvWJo2AJR9DZU3CUIbhCSG6ybSwN6qtJVnCU2svDTP2ZInOw2cBTrqtQahtNZn9NcJ4l2NaSmSkkP1noZWnVwkLmdUPOwLZEwy2Z3S3R+4rIG9hcbpPXHFVWcQdZkn2FOta3cKWQnNRC5g1LsJah4GCzSVsKnCOY5OAFRTBekyyryeyilhFKva75r4Mc0aWanGEaThcy31s439KKxTzJYY5WTHPU1FtIHjQU3Oip4xlNzj/lBw23dYZVliQa7WAXf4shetcQfatI+jWRDBPmyNeW6A1P5kdDgyYJlba0BIM8BZu1JfrFwItyjcAMR3K0BWOIrtMEXyhyrlVEx3ui5dUBjmB/Q3CXW85R4mBD0s7B+4q5tKUjOlb9qqmhi5AZ6GFIC5HXtOobdYGlVdMVbNJ8toNTFcHxnoL+muBagcctjWnbNMuR00uI7nQESwg5q2qqrKWIfrNUmeQocY6HuyxJV02wj36w00yhpmUFenv4p6fUkZYqLyuinx2RGOjhCXYyJF84oiU00YMOOhhquNdfbOB7gU88pY4xJO8LVdp6/q2voeB4R04vIdhSE40xZObx1HGGJ/ja0LBthFInKaLPPFzuCaYaoj8JjPME8yoyxo6zlBqkiUZYgq00OYMswbWO5NGmq+xhipxHLRW29ARjNKXO0wRnear8XSg4XFPLKEPUS1GqvyLwiuBUoa7zpZ0l5xxFwWmWZC1H5h5FwU8eQ7K+g8UcVY6TMQreVQT/8uQ8Z+ALIXnSEa2pYZQneE9RZbSBNYXfWYJzW/h/4j4Dp1tYVcFIC5019Vyi4ThPqSFCzjGWaHQTBU8q6vrVwgxP9Lkm840imWKpcLCjYTtrKuwvsKSnrvHCXGkSMk9p6lhckfRpIeis+N2PiszT+mFLspyGleUhDwcLrZqmyeylxwjBcKHEapqkmyangyLZRVOijwOtCY5SsG5zL0OwlCJ4y5KznF3EUNDDrinwiyLZRzOXtlBbK5ITHFGLp8Q0R6ab6mS7enI2cFrxOyHvOCFaT1HThS1krjCwqWeurCkk+willhCC+RSZnRXBiZaC5RXRIZYKp2lyfrHwiKPKR0JDzrdU2EFgpidawlFDR6FgXUMNa+g1FY3bUQh2cLCwosRdnuQTS/S+JVrGLeWIvtQUvONJxlqSQYYKpwoN2kaocLjdVsis4Mk80ESF2YpSkzwldjHkjFCUutI/r+EHDU8oCs6yzL3PhWiEooZdFMkymlas4AcI3KmoMMNSQ3tHzjGWCrcJJdYyZC7QFGwjRL9p+MrRkAGWzIaWCn9W0F3TsK01c2ZvQw0byvxuQU0r1lM0qJO7wW0kRIMdDTtXEdzi4VIh+EoIHm0mWtAtpCixlabgn83fKTI7anJe9ST7WIK1DMGpQmYeA58ImV6ezOGOzK2Kgq01pd60cKWiUi9Lievb/0vIDPHQ05Kzt4ddPckQBQtoaurjyHnek/nKzpQLrVgKPjIkh2v4uyezpv+Xoo7fPFXaGFp1vaLKxQ4uUpQQS5VuQs7BCq4xRJv7fwpVvvFEB3j+620haOuocqMhWd6TTPAEx+mdFNGHdranFe95WrWmIvlY4F1Dle2ECgc6cto7SryuqGGGha0tFQ5V53migUKmg6XKAo4qS3mik+0OZpAhOLeZKicacgaYcyx5hypYQE02ZA4xi/pNhOQxR4klNKyqacj+mpxnLTnnGSo85++3ZCZq6lrZkXlGEX3o+C9FieccJbZWVFjC0Yo1FZnJhoYMFoI1hEZ9r6hwg75HwzBNhbZCdJEfJwTPGzJvaKImw1yYX1HDAmpXR+ZJQ/SmgqMNVQb5vgamGwLtt7VwvP7Qk1xpiM5x5Cyv93E06MZmgs0Nya2azIKOYKCGBQQW97RmhKNKF02JZqHEJ4o58qp7X5EcZmc56trXEqzjCBZ1MFGR87Ql2tSTs6CGxS05PTzRQorkbw7aKoKXFDXsYW42VJih/q+FP2BdTzDTwVqOYB13liM50vG7wy28qagyuIXMeQI/Oqq8bcn5wJI50xH00CRntyfpL1T4hydYpoXgNiFzoIUTDZnLNRzh4TBHwbYGDvZkxmlyJloyr6tRihpeUG94GnKtIznREF0tzJG/OOr73JBcrSh1k6WuTprgLU+mnSGnv6Zge0NNz+kTDdH8nuAuTdJDCNb21LCiIuqlYbqGzT3RAoZofQfjFazkqeNWdYaGvYTM001EW2oKPvVk1ldUGSgUtHFwjKM1h9jnFcmy5lChoLNaQMGGDsYbKixlaMBmmsx1QjCfflwTfO/gckW0ruZ3jugKR3R5W9hGUWqCgxuFgsuaCHorotGKzGaeZB9DMsaTnKCpMtwTvOzhYk0rdrArKCqcaWmVk1+F372ur1YkKxgatI8Qfe1gIX9wE9FgS8ESmuABIXnRUbCapcKe+nO7slClSZFzpV/LkLncEb1qiO42fS3R855Su2mCLh62t1SYZZYVmKwIHjREF2uihTzB20JOkz7dkxzYQnK0UOU494wh+VWRc6Un2kpTaVgLDFEkJ/uhzRcI0YKGgpGWOlocBU/a4fKoJ/pEaNV6jip3+Es9VXY078rGnmAdf7t9ylPXS34RBSuYPs1UecZTU78WanhBCHpZ5sAoTz0LGZKjPf9TRypqWEiTvOFglL1fCEY3wY/++rbk7C8bWebA6p6om6PgOL2kp44TFJlVNBXae2rqqdZztOJpT87GQsE9jqCPIe9VReZuQ/CIgacsyZdCpIScSYqcZk8r+nsyCzhyfhOqHGOIvrLknC8wTpFcaYiGC/RU1NRbUeUpocQOnkRpGOrIOcNRx+1uA0UrzhSSt+VyS3SJpnFWkzNDqOFGIWcfR86DnmARTQ1HKIL33ExPiemeOhYSSjzlSUZZuE4TveoJLnBUOFof6KiysCbnAEcZgcUNTDOwkqWu3RWtmGpZwlHhJENdZ3miGz0lJlsKnjbwqSHQjpxnFDlTLLwqJPMZMjd7KrzkSG7VsxXBZE+F8YZkb01Oe00yyRK9psh5SYh29ySPKBo2ylNht7ZkZnsKenjKNJu9PNEyZpaCHv4Kt6RQsLvAVp7M9kIimmCUwGeWqLMmGuIotYMmWNpSahkhZw9FqZsVnKJhsjAHvtHMsTM9fCI06Dx/u3vfUXCqfsKRc4oFY2jMsoo/7DJDwZ1CsIKnJu+J9ldkpmiCxQx1rWjI+T9FwcWWzOuaYH0Hj7klNRVWEQpmaqosakiGNTFHdjS/qnUdmf0NJW5xsL0HhimCCZZSRzmSPTXJQ4aaztAwtZnoabebJ+htCaZ7Cm535ByoqXKbX1WRc4Eh2MkRXWzImVc96Cj4VdOKVxR84VdQsIUM8Psoou2byVHyZFuq7O8otbSQ2UAoeEWTudATLGSpZzVLlXVkPU2Jc+27lsw2jmg5T5VhbeE3BT083K9WsTTkFU/Osi0rC5lRlpwRHUiesNS0sOvmqGML1aRbPAxTJD9ZKtxuob+hhl8cwYGWpJ8nub7t5p6coYbMovZ1BTdaKn1jYD6h4GFDNFyT/Kqe1XCXphXHOKLZmuRSRdBPEfVUXQzJm5YGPGGJdvAEr7hHNdGZnuBvrpciGmopOLf5N0uVMy0FfYToJk90uUCbJupaVpO53UJXR2bVpoU00V2KOo4zMFrBd0Jtz2pa0clT5Q5L8IpQ177mWQejPMEJhuQjS10ref6HHjdEhy1P1EYR7GtO0uSsKJQYLiTnG1rVScj5lyazpqWGl5uBbRWl7m6ixGOOnEsMJR7z8J0n6KMnCdxhiNYQCoZ6CmYLnO8omC3MkW3bktlPmEt/VQQHejL3+dOE5FlPdK/Mq8hZxxJtLyRrepLThYKbLZxkSb5W52vYxNOaOxUF0yxMUPwBTYqCzy01XayYK0sJyWBLqX0MwU5CzoymRzV0EjjeUeLgDpTo6ij42ZAzvD01dHUUTPLU96MdLbBME8nFBn7zJCMtJcZokn8YoqU0FS5WFKyniHobguMcmW8N0XkWZjkyN3hqOMtS08r+/xTBwpZSZ3qiVRX8SzMHHjfUNFjgHEPmY9PL3ykEzxkSre/1ZD6z/NuznuB0RcE1TWTm9zRgfUWVJiG6yrzgmWPXC8EAR4Wxhlad0ZbgQyEz3pG5RVEwwDJH2mgKpjcTiCOzn1lfUWANFbZ2BA8balnEweJC9J0iuaeZoI+ippFCztEKVvckR2iice1JvhVytrQwUAZpgsubCPaU7xUe9vWnaOpaSBEspalykhC9bUlOMpT42ZHca6hyrqKmw/wMR8H5ZmdFoBVJb03O4UL0tSNnvIeRmkrLWqrs78gcrEn2tpcboh0UPOW3UUR9PMk4T4nnNKWmCjlrefhCwxRNztfmIQVdDElvS4m1/WuOujoZCs5XVOjtKPGokJzsYCtFYoWonSPT21DheU/wWhM19FcElwqNGOsp9Q8N/cwXaiND1MmeL1Q5XROtYYgGeFq1aTMsoMmcrKjQrOFQTQ1fmBYhmW6o8Jkjc7iDJRTBIo5kgJD5yMEYA3srCg7VFKwiVJkmRCc5ohGOKhsYMn/XBLdo5taZjlb9YAlGWRimqbCsoY7HFAXLa5I1HPRxMMsQDHFkWtRNniqT9UEeNjcE7RUlrCJ4R2CSJuqlKHWvJXjAUNcITYkenuBRB84TbeepcqTj3zZyFJzgYQdHnqfgI0ddUwS6GqWpsKWhjq9cV0vBAEMN2znq+EBfIWT+pClYw5xsTlJU6GeIBsjGmmANTzJZiIYpgrM0Oa8ZMjd7NP87jxhqGOhJlnQtjuQpB+8aEE00wZFznSJPyHxgH3HkPOsJFvYk8zqCHzTs1BYOa4J3PFU+UVRZxlHDM4YavlNUuMoRveiZA2d7grMNc2g+RbSCEKzmgYsUmWmazFJyoiOZ4KnyhKOGRzWJa0+moyV4TVHDzn51Awtqaphfk/lRQ08FX1iiqxTB/kLwd0VynKfEvI6cd4XMV5bMhZ7gZUWVzYQ6Nm2BYzxJbw3bGthEUUMfgbGeorae6DxHtJoZ6alhZ0+ytiVoK1R4z5PTrOECT/SugseEOlb1MMNR4VRNcJy+V1Hg9ONClSZFZjdHlc6W6FBLdJja2MC5hhpu0DBYEY1TFGwiFAxRRCsYkiM9JRb0JNMVkW6CZYT/2EiTGWmo8k+h4FhDNE7BvppoTSFnmCV5xZKzvcCdDo7VVPnIU+I+Rc68juApC90MwcFCsJ5hDqxgScYKreruyQwTqrzoqDCmhWi4IbhB0Yrt3RGa6GfDv52rKXWhh28dyZaWUvcZeMTBaZoSGyiCtRU5J8iviioHaErs7Jkj61syVzTTgOcUOQ8buFBTYWdL5g3T4qlpe0+wvD63heAXRfCCIed9RbCsp2CiI7raUOYOTU13N8PNHvpaGvayo4a3LLT1lDrVEPT2zLUlheB1R+ZTRfKWJ+dcocLJfi11vyJ51lLqJ0WD7tRwryezjiV5W28uJO9qykzX8JDe2lHl/9oyBwa2UMfOngpXCixvKdXTk3wrsKmiVYdZIqsoWEERjbcUNDuiaQomGoIbFdEHmsyWnuR+IeriKDVLnlawlyNHKwKlSU631PKep8J4Q+ayjkSLKYLhalNHlYvttb6fHm0p6OApsZ4l2VfdqZkjuysy6ysKLlckf1KUutCTs39bmCgEyyoasIWlVaMF7mgmWtBT8Kol5xpH9IGllo8cJdopcvZ2sImlDmMIbtDk3KIpeNiS08lQw11NFPTwVFlPP6pJ2gvRfI7gQUfmNAtf6Gs0wQxDsKGlVBdF8rCa3jzdwMaGHOsItrZk7hAyOzpK9VS06j5F49b0VNGOOfKs3lDToMsMBe9ZWtHFEgxTJLs7qrygKZjUnmCYoeAqeU6jqWuLJup4WghOdvCYJnrSkSzoyRkm5M2StQwVltPkfCAk58tET/CSg+8MUecmotMEnhBKfWBIZsg2ihruMJQaoIm+tkTLKEqspMh00w95gvFCQRtDwTT1gVDDSEVdlwqZfxoQRbK0g+tbiBZxzKlpnpypejdDwTaeOvorMk/IJE10h9CqRe28hhLbe0pMsdSwv4ZbhKivo2BjDWfL8UKJgeavwlwb5KlwhyE4u4XkGE2ytZCznKLCDZZq42VzT8HLCrpruFbIfOIINmh/qCdZ1ZBc65kLHR1Bkyf5zn6pN3SvGKIlFNGplhrO9QSXanLOMQTLCa0YJCRrCZm/CZmrLTm7WzCK4GJDiWUdFeYx1LCFg3NMd0XmCuF3Y5rITLDUsYS9zoHVzwnJoYpSTQoObyEzr4cFBNqYTopoaU/wkyLZ2lPhX/5Y95ulxGTV7KjhWrOZgl8MyUUafjYraNjNU1N3IWcjT5WzWqjwtoarHSUObGYO3GCJZpsBlnJGPd6ZYLyl1GdCA2625IwwJDP8GUKymbzuyPlZlvTUsaUh5zFDhRWFzPKKZLAlWdcQbObgF9tOqOsmB1dqcqYJmWstFbZRRI9poolmqiLnU0POvxScpah2iSL5UJNzgScY5+AuIbpO0YD3NCW+dLMszFSdFCWGqG6eVq2uYVNDdICGD6W7EPRWZEY5gpsE9rUkS3mijzzJnm6UpUFXG1hCUeVoS5WfNcFpblELL2qqrCvMvRfd45oalvKU2tiQ6ePJOVMRXase9iTtLJztPxJKLWpo2CRDcJwn2sWSLKIO1WQWNTCvpVUvOZhgSC40JD0dOctaSqzkCRbXsKlb11Oip6PCJ0IwSJM31j3akRxlP7Rwn6aGaUL0qiLnJkvB3xWZ2+Q1TfCwpQH3G0o92UzmX4o/oJNQMMSQc547wVHhdk+VCw01DFYEnTxzZKAm74QmeNNR1w6WzEhNK15VJzuCdxQ53dRUDws5KvwgBMOEgpcVNe0hZI6RXT1Jd0cyj5nsaEAHgVmGaJIlWdsc5Ui2ElrRR6jrRAttNMEAIWrTDFubkZaok7/AkzfIwfuWVq0jHzuCK4QabtLUMVPB3kJ0oyHTSVFlqMALilJf2Rf8k5aaHtMfayocLBS8L89oKoxpJvnAkDPa0qp5DAUTHKWmCcnthlou8iCKaFFLHWcINd1nyIwXqrSxMNmSs6KmoL2QrKuWtlQ5V0120xQ5vRyZS1rgFkWwhiOwiuQbR0OOVhQM9iS3tiXp4RawRPMp5tDletOOBL95MpM01dZTBM9pkn5qF010rIeHFcFZhmSGpYpTsI6nwhqe5C9ynhlpp5ophuRb6WcJFldkVnVEwwxVfrVkvnWUuNLCg5bgboFHPDlDPDmnK7hUrWiIbjadDclujlZcaokOFup4Ri1kacV6jmrrK1hN9bGwpKEBQ4Q6DvIUXOmo6U5LqQM6EPyiKNjVkPnJkDPNEaxhiFay5ExW1NXVUGqcpYYdPcGiCq7z/TSlbhL4pplWXKd7NZO5QQFrefhRQW/NHOsqcIglc4UhWklR8K0QzbAw08CBDnpbgqXdeD/QUsM4RZXDFBW6WJKe/mFPdH0LtBgiq57wFLzlyQzz82qYx5D5WJP5yVJDW01BfyHnS6HKO/reZqId1WGa4Hkh2kWodJ8i6KoIPlAj2hPt76CzXsVR6koPRzWTfKqIentatYpQw2me4AA3y1Kind3SwoOKZDcFXTwl9tWU6mfgRk9d71sKtlNwrjnYw5tC5n5LdKiGry3JKNlHEd3oaMCFHrazBPMp/uNJ+V7IudcSbeOIdjUEdwl0VHCOZo5t6YluEuaC9mQeMgSfOyKnYGFHcIeQ84yQWbuJYJpZw5CzglDH7gKnWqqM9ZTaXcN0TeYhR84eQtJT76JJ1lREe7WnnvsMmRc9FQ7SBBM9mV3lCUdmHk/S2RAMt0QjFNFqQpWjDPQ01DXWUdDBkXziKPjGEP3VP+zIWU2t7im41FOloyWzn/L6dkUy3VLDaZ6appgDLHPjJEsyvJngWEPUyVBiAaHCTEXwrLvSEbV1e1gKJniicWorC1MUrVjB3uDhJE/wgSOzk1DXpk0k73qCM8xw2UvD5kJmDUfOomqMpWCkJRlvKXGmoeBm18USjVIk04SClxTB6YrgLAPLWYK9HLUt5cmc0vYES8GnTeRc6skZbQkWdxRsIcyBRzx1DbTk9FbU0caTPOgJHhJKnOGIVhQqvKmo0llRw9sabrZkDtdg3PqaKi9oatjY8B+G371paMg6+mZFNNtQ04mWBq3rYLOmtWWQp8KJnpy9DdFensyjdqZ+yY40VJlH8wcdLzC8PZnvHMFUTZUrDTkLyQaGus5X5LzpYAf3i+e/ZlhqGqWhh6Ou6xTR9Z6oi5AZZtp7Mj2EEm8oSpxiYZCHU/1fbGdNNNRRoZMhmilEb2gqHOEJDtXkHK/JnG6IrvbPCwV3NhONVdS1thBMs1T4QOBcTWa2IzhMk2nW5Kyn9tXUtpv9RsG2msxk+ZsQzRQacJncpgke0+T8y5Fzj8BiGo7XlJjaTIlpQs7KFjpqGnKuoyEPeIKnFMkZHvopgh81ySxNFWvJWcKRs70j2FOT012IllEEO1n4pD1513Yg2ssQPOThOkvyrqHUdEXOSEsihmBbTbKX1kLBPWqWkLOqJbjB3GBIZmoa8qWl4CG/iZ7oiA72ZL7TJNeZUY7kFQftDcHHluBzRbCegzMtrRjVQpX2lgoPKKLJAkcbMl01XK2p7yhL8pCBbQ3BN2avJgKvttcrWDK3CiUOVxQ8ZP+pqXKyIxnmBymCg5vJjNfkPK4+c8cIfK8ocVt7kmfd/I5SR1hKvCzUtb+lhgc00ZaO6CyhIQP1Uv4yIZjload72PXX0OIJvnFU+0Zf6MhsJwTfW0r0UwQfW4LNLZl5HK261JCZ4qnBaAreVAS3WrjV0LBnNDUNNDToCEeFfwgcb4gOEqLRhirWkexrCEYKVV711DLYEE1XBEsp5tpTGjorkomKYF9FDXv7fR3BGwbettSxnyL53MBPjsxDZjMh+VUW9NRxq1DhVk+FSxQcaGjV9Pawv6eGByw5qzoy7xk4RsOShqjJwWKe/1pEEfzkobeD/dQJmpqedcyBTy2sr4nGNRH0c0SPWTLrqAc0OQcb/gemKgqucQT7ySWKCn2EUotoCvpZct7RO2sy/QW0IWcXd7pQRQyZVwT2USRO87uhjioTLKV2brpMUcMQRbKH/N2T+UlTpaMls6cmc6CCNy3JdYYSUzzJQ4oSD3oKLncULOiJvjBEC2oqnCJkJluCYy2ZQ5so9YYlZ1VLlQU1mXEW1jZERwj/MUSRc24TdexlqLKfQBtDTScJUV8FszXBEY5ktpD5Ur9hYB4Nb1iikw3JoYpkKX+RodRKFt53MMuRnKSpY31PwYaGaILh3wxJGz9TkTPEETxoCWZrgvOlmyMzxFEwVJE5xZKzvyJ4WxEc16Gd4Xe3Weq4XH2jKRikqOkGQ87hQnC7wBmGYLAnesX3M+S87eFATauuN+Qcrh7xIxXJbUIdMw3JGE3ylCWzrieaqCn4zhGM19TQ3z1oH1AX+pWEqIc7wNGAkULBo/ZxRaV9NNyh4Br3rCHZzbzmSfawBL0dNRwpW1kK9mxPXR9povcdrGSZK9c2k0xwFGzjuniCtRSZCZ6ccZ7gaktmgAOtKbG/JnOkJrjcQTdFMsxRQ2cLY3WTIrlCw1eWKn8R6pvt4GFDso3QoL4a3nLk3G6JrtME3dSenpx7PNFTmga0EaJTLQ061sEeQoWXhSo9LTXsaSjoJQRXeZLtDclbCrYzfzHHeaKjHCVOUkQHO3JeEepr56mhiyaYYKjjNU+Fed1wS5VlhWSqI/hYUdDOkaxiKehoyOnrCV5yBHtbWFqTHCCwtpDcYolesVR5yUzTZBb3RNMd0d6WP+SvhuBmRcGxnuQzT95IC285cr41cLGQ6aJJhmi4TMGempxeimBRQw1tFKV+8jd6KuzoSTqqDxzRtpZkurvKEHxlqXKRIjjfUNNXQsNOsRScoWFLT+YeRZVD3GRN0MdQcKqQjHDMrdGGVu3iYJpQx3WGUvfbmxwFfR20WBq0oYY7LMFhhgYtr8jpaEnaOzjawWWaTP8mMr0t/EPDPoqcnxTBI5o58L7uoWnMrpoqPwgVrlAUWE+V+TQl9rawoyP6QGAlQw2TPRX+YSkxyBC8Z6jhHkXBgQL7WII3DVFnRfCrBfxewv9D6xsyjys4VkhWb9pUU627JllV0YDNHMku/ldNMMXDEo4aFnAkk4U6frNEU4XgZUPmEKHUl44KrzmYamjAbh0JFvGnaTLPu1s9jPCwjFpYiN7z1DTOk/nc07CfDFzmCf7i+bfNHXhDtLeBXzTBT5rkMvWOIxpl4EMh2LGJBu2syDnAEx2naEhHDWMMzPZEhygyS1mS5RTJr5ZkoKbEUoYqr2kqdDUE8ztK7OaIntJkFrIECwv8LJTaVx5XJE86go8dFeZ3FN3rjabCAYpoYEeC9zzJVULBbmZhDyd7ko09ydpNZ3nm2Kee4FPPXHnYEF1nqOFEC08LUVcDvYXkJHW8gTaKCk9YGOeIJhqiE4ToPEepdp7IWFjdwnWaufGMwJJCMtUTTBBK9BGCOy2tGGrJTHIwyEOzp6aPzNMOtlZkDvcEWpP5SVNhfkvDxhmSazTJXYrM9U1E0xwFVwqZQwzJxw6+kGGGUj2FglGGmnb1/G51udRSMNlTw6GGnCcUwVcOpmsqTHa06o72sw1RL02p9z0VbnMLOaIX3QKaYKSCFQzBKEUNHTSc48k53RH9wxGMtpQa5KjjW0W0n6XCCCG4yxNNdhQ4R4l1Ff+2sSd6UFHiIEOyqqFgT01mEUMD+joy75jPhOA+oVVLm309FR4yVOlp4RhLiScNmSmaYF5Pw0STrOIoWMSR2UkRXOMp+M4SHW8o8Zoi6OZgjKOaFar8zZDzkWzvKOjkKBjmCXby8JahhjXULY4KlzgKLvAwxVGhvyd4zxB1d9T0piazmKLCVZY5sKiD0y2ZSYrkUEPUbIk+dlQ4SJHTR50k1DPaUWIdTZW9NJwnJMOECgd7ou/MnppMJ02O1VT4Wsh85MnZzcFTngpXGKo84qmwgKbCL/orR/SzJ2crA+t6Mp94KvxJUeIbT3CQu1uIdlQEOzlKfS3UMcrTiFmOuroocrZrT2AcmamOKg8YomeEKm/rlT2sociMaybaUlFhuqHCM2qIJ+rg4EcDFymiDSxzaHdPcpE62pD5kyM5SBMoA1PaUtfIthS85ig1VPiPPYXgYEMNk4Qq7TXBgo7oT57gPUdwgCHzhIVFPFU6OYJzHAX9m5oNrVjeE61miDrqQ4VSa1oiURTsKHC0IfjNwU2WzK6eqK8jWln4g15TVBnqmDteCJ501PGAocJhhqjZdtBEB6lnhLreFJKxmlKbeGrqLiSThVIbCdGzloasa6lpMQXHCME2boLpJgT7yWaemu6wBONbqGNVRS0PKIL7LckbjmQtR7K8I5qtqel+T/ChJTNIKLjdUMNIRyvOEko9YYl2cwQveBikCNawJKcLBbc7+JM92mysNvd/Fqp8a0k6CNEe7cnZrxlW0wQXaXjaktnRwNOGZKYiONwS7a1JVheq3WgJHlQUGKHKmp4KAxXR/ULURcNgoa4zhKSLpZR3kxRRb0NmD0OFn+UCS7CzI1nbP6+o4x47QZE5xRCt3ZagnYcvmpYQktXdk5YKXTzBC57kKEe0VVuiSYqapssMS3C9p2CKkHOg8B8Pa8p5atrIw3qezIWanMGa5HRDNF6RM9wcacl0N+Q8Z8hsIkSnaIIdHRUOEebAPy1zbCkhM062FCJtif7PU+UtoVXzWKqM1PxXO8cfdruhFQ/a6x3JKYagvVDhQEtNiyiiSQ7OsuRsZUku0CRNDs4Sog6KKjsZgk2bYJqijgsEenoKeniinRXBn/U3lgpPdyDZynQx8IiioMnCep5Ky8mjGs6Wty0l1hUQTcNWswS3WRp2kCNZwJG8omG8JphPUaFbC8lEfabwP7VtM9yoaNCAjpR41VNhrD9LkbN722v0CoZMByFzhaW+MyzRYEWFDQwN2M4/JiT76PuljT3VU/A36eaIThb+R9oZGOAJ9tewkgGvqOMNRWYjT/Cwu99Q8LqDE4TgbLWxJ1jaDDAERsFOFrobgjUsBScaguXU8kKm2RL19tRypSHnHNlHiIZqgufs4opgQdVdwxBNNFBR6kVFqb8ogimOzB6a6HTzrlDHEpYaxjiiA4TMQobkDg2vejjfwJGWmnbVFAw3H3hq2NyQfG7hz4aC+w3BbwbesG0swYayvpAs6++Ri1Vfzx93mFChvyN5xVHTS+0p9aqCAxyZ6ZacZyw5+7uuQkFPR9DDk9NOiE7X1PCYJVjVUqq7JlrHwWALF5nfHNGjApdpqgzx5OwilDhCiDYTgnc9waGW4BdLNNUQvOtpzDOWHDH8D7TR/A/85KljEQu3NREc4Pl/6B1Hhc8Umb5CsKMmGC9EPcxoT2amwHNCmeOEnOPbklnMkbOgIvO5UMOpQrS9UGVdt6iH/fURjhI/WOpaW9OKLYRod6HCUEdOX000wpDZQ6hwg6LgZfOqo1RfT/CrJzjekXOGhpc1VW71ZLbXyyp+93ILbC1kPtIEYx0FIx1VDrLoVzXRKRYWk809yYlC9ImcrinxtabKnzRJk3lAU1OLEN1j2zrYzr2myHRXJFf4h4QKT1qSTzTB5+ZNTzTRkAxX8FcLV2uS8eoQQ2aAkFzvCM72sJIcJET3WPjRk5wi32uSS9rfZajpWEvj9hW42F4o5NytSXYy8IKHay10VYdrcl4SkqscrXpMwyGOgtkajheSxdQqmpxP1L3t4R5PqasFnrQEjytq6qgp9Y09Qx9o4S1FzhUCn1kyHSzBWLemoSGvOqLNhZyBjmCaAUYpMgt4Ck7wBBMMwWKWgjsUwTaGVsxWC1mYoKiyqqeGKYqonSIRQ3KIkHO0pmAxTdBHkbOvfllfr+AA+7gnc50huVKYK393FOyg7rbPO/izI7hE4CnHHHnJ0ogNPRUGeUpsrZZTBJcrovUcJe51BPsr6GkJdhCCsZ6aTtMEb2pqWkqeVtDXE/QVggsU/Nl86d9RMF3DxvZTA58agu810RWawCiSzzXBeU3MMW9oyJUedvNEvQyNu1f10BSMddR1vaLCYpYa/mGocLSiYDcLbQz8aMn5iyF4xBNMs1P0QEOV7o5gaWGuzSeLue4tt3ro7y4Tgm4G/mopdZgl6q0o6KzJWE3mMksNr3r+a6CbT8g5wZNzT9O7fi/zpaOmnz3BRoqos+tv9zMbdpxsqDBOEewtJLt7cg5wtKKbvldpSzRRCD43VFheCI7yZLppggMVBS/KMAdHODJvOwq2NQSbKKKPLdFWQs7Fqo+mpl01JXYRgq8dnGLhTiFzqmWsUMdpllZdbKlyvSdYxhI9YghOtxR8LgSLWHK62mGGVoxzBE8LNWzqH9CUesQzFy5RQzTc56mhi6fgXEWwpKfE5Z7M05ZgZUPmo6auiv8YKzDYwWBLMErIbKHJvOwIrvEdhOBcQ9JdU1NHQ7CXn2XIDFBKU2WAgcX9UAUzDXWd5alwuyJ41Z9rjKLCL4aCp4WarhPm2rH+SaHUYE001JDZ2ZAzXPjdMpZWvC9wmqIB2lLhQ01D5jO06hghWMndbM7yRJMsoCj1vYbnFQVrW9jak3OlEJ3s/96+p33dEPRV5GxiqaGjIthUU6FFEZyqCa5qJrpBdzSw95IUnOPIrCUUjRZQFrbw5PR0R1qiYx3cb6nrWUMrBmmiBQxVHtTew5ICP/ip6g4hed/Akob/32wvBHsIOX83cI8hGeNeNPCIkPmXe8fPKx84OMSRM1MTdXSwjCZ4S30jVGhvqTRak/OVhgGazHuOCud5onEO1lJr6ecVyaOK6H7zqlBlIaHE0oroCgfvGJIdPcmfLNGLjpz7hZwZQpUbFME0A1cIJa7VNORkgfsMBatbKgwwJM9bSvQXeNOvbIjelg6WWvo5kvbKaJJNHexkKNHL9xRyFlH8Ti2riB5wVPhUk7nGkJnoCe428LR/wRGdYIlmWebCyxou1rCk4g/ShugBDX0V0ZQWkh0dOVsagkM0yV6OoLd5ye+pRlsCr0n+KiQrGuq5yJDzrTAXHtLUMduTDBVKrSm3eHL+6ijxhFDX9Z5gVU/wliHYTMiMFpKLNMEywu80wd3meoFmt6VbRMPenhrOc6DVe4pgXU8DnnHakLOIIrlF4FZPIw6R+zxBP0dyq6OOZ4Q5sLKCcz084ok+VsMMyQhNZmmBgX5xIXOEJTmi7VsGTvMTNdHHhpzdbE8Du2oKxgvBqQKdDDnTFOylCFaxR1syz2iqrOI/FEpNc3C6f11/7+ASS6l2inq2ciTrCCzgyemrCL5SVPjQkdPZUmGy2c9Sw9FtR1sS30RmsKPCS4rkIC/2U0MduwucYolGaPjKEyhzmiPYXagyWbYz8LWBDdzRimAXzxx4z8K9hpzlhLq+NiQ97HuKorMUfK/OVvC2JfiHUPCQI/q7J2gjK+tTDNxkCc4TMssqCs4TGtLVwQihyoAWgj9bosU80XGW6Ac9TJGziaUh5+hnFcHOnlaM1iRn29NaqGENTTTSUHCH2tWTeV0osUhH6psuVLjRUmGWhm6OZEshGeNowABHcJ2Bpy2ZszRcKkRXd2QuKVEeXnbfaEq825FguqfgfE2whlChSRMdron+LATTPQ2Z369t4B9C5gs/ylzv+CMmepIDPclFQl13W0rspPd1JOcbghGOEutqCv5qacURQl3dDKyvyJlqKXGPgcM9FfawJAMVmdcspcYKOZc4GjDYkFlK05olNMHyHn4zFNykyOxt99RkHlfwmiHo60l2EKI+mhreEKp080Tbug08BVPcgoqC5zWt+NLDTZ7oNSF51N1qie7Va3uCCwyZbkINf/NED6jzOsBdZjFN8oqG3wxVunqCSYYKf3EdhJyf9YWGf7tRU2oH3VHgPr1fe5J9hOgHd7xQ0y7qBwXr23aGErP0cm64JVjZwsOGqL+mhNgZmhJLW2oY4UhedsyBgzrCKrq7BmcpNVhR6jBPq64Vgi+kn6XE68pp8J5/+0wRHGOpsKenQn9DZntPzjRLZpDAdD2fnSgkG9tmIXnUwQ6WVighs7Yi2MxQ0N3CqYaCXkJ0oyOztMDJjmSSpcpvlrk0RMMOjmArQ04PRV1DO1FwhCVaUVPpKUM03JK5SxPsIWRu8/CGHi8UHChiqGFDTbSRJWeYUDDcH6vJWUxR4k1FXbMUwV6e4AJFXS8oMqsZKqzvYQ9DDQdZckY4aGsIhtlubbd2r3j4QBMoTamdPZk7O/Bf62lacZwneNjQoGcdVU7zJOd7ghsUHOkosagic6cnWc8+4gg285R6zZP5s1/LUbCKIznTwK36PkdwlOrl4U1LwfdCCa+IrvFkmgw1PCAUXKWo0sURXWcI2muKJlgyFzhynCY4RBOsqCjoI1R5zREco0n2Vt09BQtYSizgKNHfUmUrQ5UOCh51BFcLmY7umhYqXKQomOop8bUnWNNQcIiBcYaC6xzMNOS8JQQfeqKBmmglB+97ok/lfk3ygaHSyZaCRTzRxQo6GzLfa2jWBPepw+UmT7SQEJyiyRkhBLMVOfcoMjcK0eZChfUNzFAUzCsEN5vP/X1uP/n/aoMX+K+nw/Hjr/9xOo7j7Pju61tLcgvJpTWXNbfN5jLpi6VfCOviTktKlFusQixdEKWmEBUKNaIpjZRSSOXSgzaaKLdabrm1/9nZ+/f+vd/vz/v9+Xy+zZ7PRorYoZqyLrCwQdEAixxVOEXNNnjX2nUSRlkqGmWowk8lxR50JPy9Bo6qJXaXwNvREBvnThPEPrewryLhcAnj5WE15Fqi8W7R1sAuEu86S4ENikItFN4xkv9Af4nXSnUVcLiA9xzesFpivRRVeFKtsMRaKBhuSbjOELnAUtlSQUpXgdfB4Z1oSbnFEetbQ0IrAe+Y+pqnDcEJFj6S8LDZzZHwY4e3XONNlARraomNEt2bkvGsosA3ioyHm+6jCMbI59wqt4eeara28IzEmyPgoRaUOEDhTVdEJhmCoTWfC0p8aNkCp0oYqih2iqGi4yXeMkOsn4LdLLnmKfh/YogjNsPebeFGR4m9BJHLzB61XQ3BtpISfS2FugsK9FAtLWX1dCRcrCnUp44CNzuCowUZmxSRgYaE6Za0W2u/E7CVXCiI/UOR8aAm1+OSyE3mOUcwyc1zBBeoX1kiKy0Zfxck1Gsyulti11i83QTBF5Kg3pDQThFMVHiPSlK+0cSedng/VaS8bOZbtsBcTcZAR8JP5KeqQ1OYKAi20njdNNRpgnsU//K+JnaXJaGTomr7aYIphoRn9aeShJWKEq9LcozSF7QleEfDI5LYm5bgVkFkRwVDBCVu0DDIkGupo8TZBq+/pMQURYErJQmPKGKjNDkWOLx7Jd5QizdUweIaKrlP7SwJDhZvONjLkOsBBX9UpGxnydhXkfBLQ8IxgojQbLFnJf81JytSljclYYyEFyx0kVBvKWOFJmONpshGAcsduQY5giVNCV51eOdJYo/pLhbvM0uDHSevNKRcrKZIqnCtJeEsO95RoqcgGK4ocZcho1tTYtcZvH41pNQ7vA0WrhIfOSraIIntIAi+NXWCErdbkvrWwjRLrt0NKUdL6KSOscTOdMSOUtBHwL6OLA0vNSdynaWQEnCpIvKaIrJJEbvHkmuNhn6OjM8VkSGSqn1uYJCGHnq9I3aLhNME3t6GjIkO7xrNFumpyTNX/NrwX7CrIRiqqWijI9JO4d1iieykyfiposQIQ8YjjsjlBh6oHWbwRjgYJQn2NgSnNycmJAk3NiXhx44Sxykihxm8ybUwT1OVKySc7vi3OXVkdBJ4AyXBeksDXG0IhgtYY0lY5ahCD0ehborIk5aUWRJviMA7Xt5kyRjonrXENkm8yYqgs8VzgrJmClK20uMM3jRJ0FiQICQF9hdETlLQWRIb5ki6WDfWRPobvO6a4GP5mcOrNzDFELtTkONLh9dXE8xypEg7z8A9jkhrQ6Fhjlg/QVktJXxt4WXzT/03Q8IaQWSqIuEvloQ2mqC9Jfi7wRul4RX3pSPlzpoVlmCtI2jvKHCFhjcM3sN6lqF6HxnKelLjXWbwrpR4xzuCrTUZx2qq9oAh8p6ixCUGr78g8oyjRAtB5CZFwi80VerVpI0h+IeBxa6Zg6kWvpDHaioYYuEsRbDC3eOmC2JvGYLeioxGknL2UATNJN6hmtj1DlpLvDVmocYbrGCVJKOrg4X6DgddLA203BKMFngdJJFtFd7vJLm6KEpc5yjQrkk7M80SGe34X24nSex1Ra5Omgb71JKyg8SrU3i/kARKwWpH0kOGhKkObyfd0ZGjvyXlAkVZ4xRbYJ2irFMkFY1SwyWxr2oo4zlNiV+7zmaweFpT4kR3kaDAFW6xpSqzJay05FtYR4HmZhc9UxKbbfF2V8RG1MBmSaE+kmC6JnaRXK9gsiXhJHl/U0qM0WTcbyhwkYIvFGwjSbjfwhiJt8ZSQU+Bd5+marPMOkVkD0muxYLIfEuhh60x/J92itguihJSEMySVPQnTewnEm+620rTQEMsOfo4/kP/0ARvWjitlpSX7GxBgcMEsd3EEeYWvdytd+Saawi6aCIj1CkGb6Aj9rwhx16Cf3vAwFy5pyLhVonXzy51FDpdEblbkdJbUcEPDEFzQ8qNmhzzLTmmKWKbFCXeEuRabp6rxbvAtLF442QjQ+wEA9eL1xSR7Q0JXzlSHjJ4exq89yR0laScJ/FW6z4a73pFMEfDiRZvuvijIt86RaSFOl01riV2mD1UEvxGk/Geg5aWwGki1zgKPG9J2U8PEg8qYvMsZeytiTRXBMslCU8JSlxi8EabjwUldlDNLfzTUmCgxWsjqWCOHavYAqsknKFIO0yQ61VL5AVFxk6WhEaCAkdJgt9aSkzXlKNX2jEa79waYuc7gq0N3GDJGCBhoiTXUEPsdknCUE1CK0fwsiaylSF2uiDyO4XX3pFhNd7R4itFGc0k/ElBZwWvq+GC6szVeEoS/MZ+qylwpKNKv9Z469UOjqCjwlusicyTxG6VpNxcQ8IncoR4RhLbR+NdpGGmJWOcIzJGUuKPGpQg8rrG21dOMqQssJQ4RxH5jaUqnZuQ0F4Q+cjxLwPtpZbIAk3QTJHQWBE5S1BokoVtDd6lhqr9UpHSUxMcIYl9pojsb8h4SBOsMQcqvOWC2E8EVehqiJ1hrrAEbQxeK0NGZ0Gkq+guSRgniM23bIHVkqwx4hiHd7smaOyglyIyQuM978j4VS08J/A2G1KeMBRo4fBaSNhKUEZfQewVQ/C1I+MgfbEleEzCUw7mKXI0M3hd1EESVji8x5uQ41nxs1q4RMJCCXs7Iq9acpxn22oSDnQ/sJTxsCbHIYZiLyhY05TY0ZLIOQrGaSJDDN4t8pVaIrsqqFdEegtizc1iTew5Q4ayBDMUsQMkXocaYkc0hZua412siZ1rSXlR460zRJ5SlHGe5j801RLMlJTxtaOM3Q1pvxJ45zUlWFD7rsAbpfEm1JHxG0eh8w2R7QQVzBUw28FhFp5QZzq8t2rx2joqulYTWSuJdTYfWwqMFMcovFmSyJPNyLhE4E10pHzYjOC3huArRa571ZsGajQpQx38SBP5pyZB6lMU3khDnp0MBV51BE9o2E+TY5Ml2E8S7C0o6w1xvCZjf0HkVEHCzFoyNmqC+9wdcqN+Tp7jSDheE9ws8Y5V0NJCn2bk2tqSY4okdrEhx1iDN8cSudwepWmAGXKcJXK65H9to8jYQRH7SBF01ESUJdd0TayVInaWhLkOjlXE5irKGOnI6GSWGCJa482zBI9rCr0jyTVcEuzriC1vcr6mwFGSiqy5zMwxBH/TJHwjSPhL8+01kaaSUuMFKTcLEvaUePcrSmwn8DZrgikWb7CGPxkSjhQwrRk57tctmxLsb9sZvL9LSlyuSLlWkqOjwduo8b6Uv1DkmudIeFF2dHCgxVtk8dpIvHpBxhEOdhKk7OLIUSdJ+cSRY57B+0DgGUUlNfpthTfGkauzxrvTsUUaCVhlKeteTXCoJDCa2NOKhOmC4G1H8JBd4OBZReSRGkqcb/CO1PyLJTLB4j1q8JYaIutEjSLX8YKM+a6phdMsdLFUoV5RTm9JSkuDN8WcIon0NZMNZWh1q8C7SJEwV5HxrmnnTrf3KoJBlmCYI2ilSLlfEvlE4011NNgjgthzEua0oKK7JLE7HZHlEl60BLMVFewg4EWNt0ThrVNEVkkiTwpKXSWJzdRENgvKGq4IhjsiezgSFtsfCUq8qki5S1LRQeYQQ4nemmCkImWMw3tFUoUBZk4NOeZYEp4XRKTGa6wJjrWNHBVJR4m3FCnbuD6aak2WsMTh3SZImGCIPKNgsDpVwnsa70K31lCFJZYcwwSMFcQulGTsZuEaSdBXkPGZhu0FsdUO73RHjq8MPGGIfaGIbVTk6iuI3GFgucHrIQkmWSJdBd7BBu+uOryWAhY7+Lki9rK5wtEQzWwvtbqGhIMFwWRJsElsY4m9IIg9L6lCX0VklaPAYkfkZEGDnOWowlBJjtMUkcGK4Lg6EtoZInMUBVYLgn0UsdmCyCz7gIGHFfk+k1QwTh5We7A9x+IdJ6CvIkEagms0hR50eH9UnTQJ+2oiKyVlLFUE+8gBGu8MQ3CppUHesnjTHN4QB/UGPhCTHLFPHMFrCqa73gqObUJGa03wgbhHkrCfpEpzNLE7JDS25FMKhlhKKWKfCgqstLCPu1zBXy0J2ztwjtixBu8UTRn9LVtkmCN2iyFhtME70JHRQ1KVZXqKI/KNIKYMCYs1GUMEKbM1bKOI9LDXC7zbHS+bt+1MTWS9odA9DtrYtpbImQJ2VHh/lisEwaHqUk1kjKTAKknkBEXkbkdMGwq0dnhzLJF3NJH3JVwrqOB4Sca2hti75nmJN0WzxS6UxDYoEpxpa4htVlRjkYE7DZGzJVU72uC9IyhQL4i8YfGWSYLLNcHXloyz7QhNifmKSE9JgfGmuyLhc403Xm9vqcp6gXe3xuuv8F6VJNxkyTHEkHG2g0aKXL0MsXc1bGfgas2//dCONXiNLCX+5mB7eZIl1kHh7ajwpikyzlUUWOVOsjSQlsS+M0R+pPje/dzBXRZGO0rMtgQrLLG9VSu9n6CMXS3BhwYmSoIBhsjNBmZbgusE9BCPCP5triU4VhNbJfE+swSP27aayE8tuTpYYjtrYjMVGZdp2NpS1s6aBnKSHDsbKuplKbHM4a0wMFd/5/DmGyKrJSUaW4IBrqUhx0vyfzTBBLPIUcnZdrAkNsKR0sWRspumSns6Ch0v/qqIbBYUWKvPU/CFoyrDJGwSNFhbA/MlzKqjrO80hRbpKx0Jewsi/STftwGSlKc1JZyAzx05dhLEdnfQvhZOqiHWWEAHC7+30FuRcZUgaO5gpaIK+xsiHRUsqaPElTV40xQZQ107Q9BZE1nryDVGU9ZSQ47bmhBpLcYpUt7S+xuK/FiT8qKjwXYw5ypS2iuCv7q1gtgjhuBuB8LCFY5cUuCNtsQOFcT+4Ih9JX+k8Ea6v0iCIRZOtCT0Et00JW5UeC85Cg0ScK0k411HcG1zKtre3SeITBRk7WfwDhEvaYLTHP9le0m8By0JDwn4TlLW/aJOvGHxdjYUes+ScZigCkYQdNdEOhkiezgShqkx8ueKjI8lDfK2oNiOFvrZH1hS+tk7NV7nOmLHicGWEgubkXKdwdtZknCLJXaCpkrjZBtLZFsDP9CdxWsSr05Sxl6CMmoFbCOgryX40uDtamB7SVmXW4Ihlgpmq+00tBKUUa83WbjLUNkzDmY7cow1JDygyPGlhgGKYKz4vcV7QBNbJIgM11TUqZaMdwTeSguH6rOaw1JRKzaaGyxVm2EJ/uCIrVWUcZUkcp2grMsEjK+DMwS59jQk3Kd6SEq1d0S6uVmO4Bc1lDXTUcHjluCXEq+1OlBDj1pi9zgiXxnKuE0SqTXwhqbETW6RggMEnGl/q49UT2iCzgJvRwVXS2K/d6+ZkyUl7jawSVLit46EwxVljDZwoSQ20sDBihztHfk2yA8NVZghiXwrYHQdfKAOtzsayjhY9bY0yE2CWEeJ9xfzO423xhL5syS2TFJofO2pboHob0nY4GiAgRrvGQEDa/FWSsoaaYl0syRsEt3kWoH3B01shCXhTUWe9w3Bt44SC9QCh3eShQctwbaK2ApLroGCMlZrYqvlY3qYhM0aXpFkPOuoqJ3Dm6fxXrGwVF9gCWZagjPqznfkuMKQ8DPTQRO8ZqG1hPGKEm9IgpGW4DZDgTNriTxvFiq+Lz+0cKfp4wj6OCK9JSnzNSn9LFU7UhKZZMnYwcJ8s8yRsECScK4j5UOB95HFO0CzhY4xJxuCix0lDlEUeMdS6EZBkTsUkZ4K74dugyTXS7aNgL8aqjDfkCE0ZbwkCXpaWCKhl8P7VD5jxykivSyxyZrYERbe168LYu9ZYh86IkscgVLE7tWPKmJv11CgoyJltMEbrohtVAQfO4ImltiHEroYEs7RxAarVpY8AwXMcMReFOTYWe5iiLRQxJ5Q8DtJ8LQhWOhIeFESPGsILhbNDRljNbHzNRlTFbk2S3L0NOS6V1KFJYKUbSTcIIhM0wQ/s2TM0SRMNcQmSap3jCH4yhJZKSkwyRHpYYgsFeQ4U7xoCB7VVOExhXepo9ABBsYbvGWKXPME3lyH95YioZ0gssQRWWbI+FaSMkXijZXwgiTlYdPdkNLaETxlyDVIwqeaEus0aTcYcg0RVOkpR3CSJqIddK+90JCxzsDVloyrFd5ZAr4TBKfaWa6boEA7C7s6EpYaeFPjveooY72mjIccLHJ9HUwVlDhKkmutJDJBwnp1rvulJZggKDRfbXAkvC/4l3ozQOG9a8lxjx0i7nV4jSXc7vhe3OwIxjgSHjdEhhsif9YkPGlus3iLFDnWOFhtCZbJg0UbQcIaR67JjthoCyMEZRwhiXWyxO5QxI6w5NhT4U1WsJvDO60J34fW9hwzwlKij6ZAW9ne4L0s8C6XeBMEkd/LQy1VucBRot6QMlbivaBhoBgjqGiCJNhsqVp/S2SsG6DIONCR0dXhvWbJ+MRRZJkkuEjgDXJjFQW6SSL7GXK8Z2CZg7cVsbWGoKmEpzQ5elpiy8Ryg7dMkLLUEauzeO86CuwlSOlgYLojZWeJ9xM3S1PWfEfKl5ISLQ0MEKR8YOB2QfCxJBjrKPCN4f9MkaSsqoVXJBmP7EpFZ9UQfOoOFwSzBN4MQ8LsGrymlipcJQhmy0GaQjPqCHaXRwuCZwRbqK2Fg9wlClZqYicrIgMdZfxTQ0c7TBIbrChxmuzoKG8XRaSrIhhiyNFJkrC7oIAWMEOQa5aBekPCRknCo4IKPrYkvCDI8aYmY7WFtprgekcJZ3oLIqssCSMtFbQTJKwXYy3BY5oCh2iKPCpJOE+zRdpYgi6O2KmOAgvVCYaU4ySRek1sgyFhJ403QFHiVEmJHwtybO1gs8Hr5+BETQX3War0qZngYGgtVZtoqd6vFSk/UwdZElYqyjrF4HXUeFspIi9IGKf4j92pKGAdCYMVsbcV3kRF0N+R8LUd5PCsIGWoxDtBkCI0nKofdJQxT+LtZflvuc8Q3CjwWkq8KwUpHzkK/NmSsclCL0nseQdj5FRH5CNHSgtLiW80Of5HU9Hhlsga9bnBq3fEVltKfO5IaSTmGjjc4J0otcP7QsJUSQM8pEj5/wCuUuC2DWz8AAAAAElFTkSuQmCC\");\ +}\ +\ +.ace-ambiance .ace_indent-guide {\ + background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNQUFD4z6Crq/sfAAuYAuYl+7lfAAAAAElFTkSuQmCC\") right repeat-y;\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-chrome.js b/vendor/assets/javascripts/ace-src-noconflict/theme-chrome.js new file mode 100644 index 00000000..dbbe865f --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-chrome.js @@ -0,0 +1,205 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/chrome', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = false; +exports.cssClass = "ace-chrome"; +exports.cssText = ".ace-chrome .ace_editor {\ + border: 2px solid rgb(159, 159, 159);\ +}\ +\ +.ace-chrome .ace_editor.ace_focus {\ + border: 2px solid #327fbd;\ +}\ +\ +.ace-chrome .ace_gutter {\ + background: #ebebeb;\ + color: #333;\ + overflow : hidden;\ +}\ +\ +.ace-chrome .ace_print_margin {\ + width: 1px;\ + background: #e8e8e8;\ +}\ +\ +.ace-chrome .ace_scroller {\ + background-color: #FFFFFF;\ +}\ +\ +.ace-chrome .ace_cursor {\ + border-left: 2px solid black;\ +}\ +\ +.ace-chrome .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid black;\ +}\ +\ +.ace-chrome .ace_line .ace_invisible {\ + color: rgb(191, 191, 191);\ +}\ +\ +.ace-chrome .ace_line .ace_constant.ace_buildin {\ + color: rgb(88, 72, 246);\ +}\ +\ +.ace-chrome .ace_line .ace_constant.ace_language {\ + color: rgb(88, 92, 246);\ +}\ +\ +.ace-chrome .ace_line .ace_constant.ace_library {\ + color: rgb(6, 150, 14);\ +}\ +\ +.ace-chrome .ace_line .ace_invalid {\ + background-color: rgb(153, 0, 0);\ + color: white;\ +}\ +\ +.ace-chrome .ace_line .ace_fold {\ +}\ +\ +.ace-chrome .ace_line .ace_support.ace_function {\ + color: rgb(60, 76, 114);\ +}\ +\ +.ace-chrome .ace_line .ace_support.ace_constant {\ + color: rgb(6, 150, 14);\ +}\ +\ +.ace-chrome .ace_line .ace_support.ace_type,\ +.ace-chrome .ace_line .ace_support.ace_class\ +.ace-chrome .ace_line .ace_support.ace_other, {\ + color: rgb(109, 121, 222);\ +}\ +\ +.ace-chrome .ace_variable.ace_parameter {\ + font-style:italic;\ + color:#FD971F;\ +}\ +.ace-chrome .ace_line .ace_keyword.ace_operator {\ + color: rgb(104, 118, 135);\ +}\ +\ +.ace-chrome .ace_line .ace_comment {\ + color: #236e24;\ +}\ +\ +.ace-chrome .ace_line .ace_comment.ace_doc {\ + color: #236e24;\ +}\ +\ +.ace-chrome .ace_line .ace_comment.ace_doc.ace_tag {\ + color: #236e24;\ +}\ +\ +.ace-chrome .ace_line .ace_constant.ace_numeric {\ + color: rgb(0, 0, 205);\ +}\ +\ +.ace-chrome .ace_line .ace_variable {\ + color: rgb(49, 132, 149);\ +}\ +\ +.ace-chrome .ace_line .ace_xml_pe {\ + color: rgb(104, 104, 91);\ +}\ +\ +.ace-chrome .ace_entity.ace_name.ace_function {\ + color: #0000A2;\ +}\ +\ +\ +.ace-chrome .ace_markup.ace_heading {\ + color: rgb(12, 7, 255);\ +}\ +\ +.ace-chrome .ace_markup.ace_list {\ + color:rgb(185, 6, 144);\ +}\ +\ +.ace-chrome .ace_marker-layer .ace_selection {\ + background: rgb(181, 213, 255);\ +}\ +\ +.ace-chrome .ace_marker-layer .ace_step {\ + background: rgb(252, 255, 0);\ +}\ +\ +.ace-chrome .ace_marker-layer .ace_stack {\ + background: rgb(164, 229, 101);\ +}\ +\ +.ace-chrome .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgb(192, 192, 192);\ +}\ +\ +.ace-chrome .ace_marker-layer .ace_active_line {\ + background: rgba(0, 0, 0, 0.07);\ +}\ +\ +.ace-chrome .ace_gutter_active_line {\ + background-color : #dcdcdc;\ +}\ +\ +.ace-chrome .ace_marker-layer .ace_selected_word {\ + background: rgb(250, 250, 255);\ + border: 1px solid rgb(200, 200, 250);\ +}\ +\ +.ace-chrome .ace_storage,\ +.ace-chrome .ace_line .ace_keyword,\ +.ace-chrome .ace_meta.ace_tag {\ + color: rgb(147, 15, 128);\ +}\ +\ +.ace-chrome .ace_string.ace_regex {\ + color: rgb(255, 0, 0)\ +}\ +\ +.ace-chrome .ace_line .ace_string {\ + color: #1A1AA6;\ +}\ +\ +.ace-chrome .ace_entity.ace_other.ace_attribute-name {\ + color: #994409;\ +}\ +\ +.ace-chrome .ace_indent-guide {\ + background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\ +}\ +"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-clouds.js b/vendor/assets/javascripts/ace-src-noconflict/theme-clouds.js new file mode 100644 index 00000000..b6d47490 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-clouds.js @@ -0,0 +1,170 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/clouds', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = false; +exports.cssClass = "ace-clouds"; +exports.cssText = ".ace-clouds .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-clouds .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-clouds .ace_gutter {\ + background: #ebebeb;\ + color: #333\ +}\ +\ +.ace-clouds .ace_print_margin {\ + width: 1px;\ + background: #e8e8e8\ +}\ +\ +.ace-clouds .ace_scroller {\ + background-color: #FFFFFF\ +}\ +\ +.ace-clouds .ace_text-layer {\ + color: #000000\ +}\ +\ +.ace-clouds .ace_cursor {\ + border-left: 2px solid #000000\ +}\ +\ +.ace-clouds .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #000000\ +}\ +\ +.ace-clouds .ace_marker-layer .ace_selection {\ + background: #BDD5FC\ +}\ +\ +.ace-clouds.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #FFFFFF;\ + border-radius: 2px\ +}\ +\ +.ace-clouds .ace_marker-layer .ace_step {\ + background: rgb(255, 255, 0)\ +}\ +\ +.ace-clouds .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid #BFBFBF\ +}\ +\ +.ace-clouds .ace_marker-layer .ace_active_line {\ + background: #FFFBD1\ +}\ +\ +.ace-clouds .ace_gutter_active_line {\ + background-color : #dcdcdc\ +}\ +\ +.ace-clouds .ace_marker-layer .ace_selected_word {\ + border: 1px solid #BDD5FC\ +}\ +\ +.ace-clouds .ace_invisible {\ + color: #BFBFBF\ +}\ +\ +.ace-clouds .ace_keyword,\ +.ace-clouds .ace_meta,\ +.ace-clouds .ace_support.ace_constant.ace_property-value {\ + color: #AF956F\ +}\ +\ +.ace-clouds .ace_keyword.ace_operator {\ + color: #484848\ +}\ +\ +.ace-clouds .ace_keyword.ace_other.ace_unit {\ + color: #96DC5F\ +}\ +\ +.ace-clouds .ace_constant.ace_language {\ + color: #39946A\ +}\ +\ +.ace-clouds .ace_constant.ace_numeric {\ + color: #46A609\ +}\ +\ +.ace-clouds .ace_constant.ace_character.ace_entity {\ + color: #BF78CC\ +}\ +\ +.ace-clouds .ace_invalid {\ + background-color: #FF002A\ +}\ +\ +.ace-clouds .ace_fold {\ + background-color: #AF956F;\ + border-color: #000000\ +}\ +\ +.ace-clouds .ace_storage,\ +.ace-clouds .ace_support.ace_class,\ +.ace-clouds .ace_support.ace_function,\ +.ace-clouds .ace_support.ace_other,\ +.ace-clouds .ace_support.ace_type {\ + color: #C52727\ +}\ +\ +.ace-clouds .ace_string {\ + color: #5D90CD\ +}\ +\ +.ace-clouds .ace_comment {\ + color: #BCC8BA\ +}\ +\ +.ace-clouds .ace_entity.ace_name.ace_tag,\ +.ace-clouds .ace_entity.ace_other.ace_attribute-name {\ + color: #606060\ +}\ +\ +.ace-clouds .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-clouds .ace_indent-guide {\ + background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-clouds_midnight.js b/vendor/assets/javascripts/ace-src-noconflict/theme-clouds_midnight.js new file mode 100644 index 00000000..57501d91 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-clouds_midnight.js @@ -0,0 +1,171 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/clouds_midnight', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-clouds-midnight"; +exports.cssText = ".ace-clouds-midnight .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-clouds-midnight .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-clouds-midnight .ace_gutter {\ + background: #232323;\ + color: #929292\ +}\ +\ +.ace-clouds-midnight .ace_print_margin {\ + width: 1px;\ + background: #232323\ +}\ +\ +.ace-clouds-midnight .ace_scroller {\ + background-color: #191919\ +}\ +\ +.ace-clouds-midnight .ace_text-layer {\ + color: #929292\ +}\ +\ +.ace-clouds-midnight .ace_cursor {\ + border-left: 2px solid #7DA5DC\ +}\ +\ +.ace-clouds-midnight .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #7DA5DC\ +}\ +\ +.ace-clouds-midnight .ace_marker-layer .ace_selection {\ + background: #000000\ +}\ +\ +.ace-clouds-midnight.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #191919;\ + border-radius: 2px\ +}\ +\ +.ace-clouds-midnight .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-clouds-midnight .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid #BFBFBF\ +}\ +\ +.ace-clouds-midnight .ace_marker-layer .ace_active_line {\ + background: rgba(215, 215, 215, 0.031)\ +}\ +\ +.ace-clouds-midnight .ace_gutter_active_line {\ + background-color: rgba(215, 215, 215, 0.031)\ +}\ +\ +.ace-clouds-midnight .ace_marker-layer .ace_selected_word {\ + border: 1px solid #000000\ +}\ +\ +.ace-clouds-midnight .ace_invisible {\ + color: #BFBFBF\ +}\ +\ +.ace-clouds-midnight .ace_keyword,\ +.ace-clouds-midnight .ace_meta,\ +.ace-clouds-midnight .ace_support.ace_constant.ace_property-value {\ + color: #927C5D\ +}\ +\ +.ace-clouds-midnight .ace_keyword.ace_operator {\ + color: #4B4B4B\ +}\ +\ +.ace-clouds-midnight .ace_keyword.ace_other.ace_unit {\ + color: #366F1A\ +}\ +\ +.ace-clouds-midnight .ace_constant.ace_language {\ + color: #39946A\ +}\ +\ +.ace-clouds-midnight .ace_constant.ace_numeric {\ + color: #46A609\ +}\ +\ +.ace-clouds-midnight .ace_constant.ace_character.ace_entity {\ + color: #A165AC\ +}\ +\ +.ace-clouds-midnight .ace_invalid {\ + color: #FFFFFF;\ + background-color: #E92E2E\ +}\ +\ +.ace-clouds-midnight .ace_fold {\ + background-color: #927C5D;\ + border-color: #929292\ +}\ +\ +.ace-clouds-midnight .ace_storage,\ +.ace-clouds-midnight .ace_support.ace_class,\ +.ace-clouds-midnight .ace_support.ace_function,\ +.ace-clouds-midnight .ace_support.ace_other,\ +.ace-clouds-midnight .ace_support.ace_type {\ + color: #E92E2E\ +}\ +\ +.ace-clouds-midnight .ace_string {\ + color: #5D90CD\ +}\ +\ +.ace-clouds-midnight .ace_comment {\ + color: #3C403B\ +}\ +\ +.ace-clouds-midnight .ace_entity.ace_name.ace_tag,\ +.ace-clouds-midnight .ace_entity.ace_other.ace_attribute-name {\ + color: #606060\ +}\ +\ +.ace-clouds-midnight .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-clouds-midnight .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWOQlJT8z1BeXv4fAA2KA6+h9Z+2AAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-cobalt.js b/vendor/assets/javascripts/ace-src-noconflict/theme-cobalt.js new file mode 100644 index 00000000..d0c8d24e --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-cobalt.js @@ -0,0 +1,182 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/cobalt', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-cobalt"; +exports.cssText = ".ace-cobalt .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-cobalt .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-cobalt .ace_gutter {\ + background: #011e3a;\ + color: #fff\ +}\ +\ +.ace-cobalt .ace_print_margin {\ + width: 1px;\ + background: #011e3a\ +}\ +\ +.ace-cobalt .ace_scroller {\ + background-color: #002240\ +}\ +\ +.ace-cobalt .ace_text-layer {\ + color: #FFFFFF\ +}\ +\ +.ace-cobalt .ace_cursor {\ + border-left: 2px solid #FFFFFF\ +}\ +\ +.ace-cobalt .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #FFFFFF\ +}\ +\ +.ace-cobalt .ace_marker-layer .ace_selection {\ + background: rgba(179, 101, 57, 0.75)\ +}\ +\ +.ace-cobalt.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #002240;\ + border-radius: 2px\ +}\ +\ +.ace-cobalt .ace_marker-layer .ace_step {\ + background: rgb(127, 111, 19)\ +}\ +\ +.ace-cobalt .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgba(255, 255, 255, 0.15)\ +}\ +\ +.ace-cobalt .ace_marker-layer .ace_active_line {\ + background: rgba(0, 0, 0, 0.35)\ +}\ +\ +.ace-cobalt .ace_gutter_active_line {\ + background-color: rgba(0, 0, 0, 0.35)\ +}\ +\ +.ace-cobalt .ace_marker-layer .ace_selected_word {\ + border: 1px solid rgba(179, 101, 57, 0.75)\ +}\ +\ +.ace-cobalt .ace_invisible {\ + color: rgba(255, 255, 255, 0.15)\ +}\ +\ +.ace-cobalt .ace_keyword,\ +.ace-cobalt .ace_meta {\ + color: #FF9D00\ +}\ +\ +.ace-cobalt .ace_constant,\ +.ace-cobalt .ace_constant.ace_character,\ +.ace-cobalt .ace_constant.ace_character.ace_escape,\ +.ace-cobalt .ace_constant.ace_other {\ + color: #FF628C\ +}\ +\ +.ace-cobalt .ace_invalid {\ + color: #F8F8F8;\ + background-color: #800F00\ +}\ +\ +.ace-cobalt .ace_support {\ + color: #80FFBB\ +}\ +\ +.ace-cobalt .ace_support.ace_constant {\ + color: #EB939A\ +}\ +\ +.ace-cobalt .ace_fold {\ + background-color: #FF9D00;\ + border-color: #FFFFFF\ +}\ +\ +.ace-cobalt .ace_support.ace_function {\ + color: #FFB054\ +}\ +\ +.ace-cobalt .ace_storage {\ + color: #FFEE80\ +}\ +\ +.ace-cobalt .ace_string.ace_regexp {\ + color: #80FFC2\ +}\ +\ +.ace-cobalt .ace_comment {\ + font-style: italic;\ + color: #0088FF\ +}\ +\ +.ace-cobalt .ace_variable {\ + color: #CCCCCC\ +}\ +\ +.ace-cobalt .ace_variable.ace_language {\ + color: #FF80E1\ +}\ +\ +.ace-cobalt .ace_meta.ace_tag {\ + color: #9EFFFF\ +}\ +\ +.ace-cobalt .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-cobalt .ace_markup.ace_heading {\ + color: #C8E4FD;\ + background-color: #001221\ +}\ +\ +.ace-cobalt .ace_markup.ace_list {\ + background-color: #130D26\ +}\ +\ +.ace-cobalt .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNgUHL4zzBz5sz/AA80BCzv+WXhAAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-crimson_editor.js b/vendor/assets/javascripts/ace-src-noconflict/theme-crimson_editor.js new file mode 100644 index 00000000..38230ae8 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-crimson_editor.js @@ -0,0 +1,197 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/crimson_editor', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { +exports.isDark = false; +exports.cssText = ".ace-crimson-editor .ace_editor {\ + border: 2px solid rgb(159, 159, 159);\ +}\ +\ +.ace-crimson-editor .ace_editor.ace_focus {\ + border: 2px solid #327fbd;\ +}\ +\ +.ace-crimson-editor .ace_gutter {\ + background: #ebebeb;\ + color: #333;\ + overflow : hidden;\ +}\ +\ +.ace-crimson-editor .ace_gutter-layer {\ + width: 100%;\ + text-align: right;\ +}\ +\ +.ace-crimson-editor .ace_print_margin {\ + width: 1px;\ + background: #e8e8e8;\ +}\ +\ +.ace-crimson-editor .ace_scroller {\ + background-color: #FFFFFF;\ +}\ +\ +.ace-crimson-editor .ace_text-layer {\ + color: rgb(64, 64, 64);\ +}\ +\ +.ace-crimson-editor .ace_cursor {\ + border-left: 2px solid black;\ +}\ +\ +.ace-crimson-editor .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid black;\ +}\ +\ +.ace-crimson-editor .ace_line .ace_invisible {\ + color: rgb(191, 191, 191);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_identifier {\ + color: black;\ +}\ +\ +.ace-crimson-editor .ace_line .ace_keyword {\ + color: blue;\ +}\ +\ +.ace-crimson-editor .ace_line .ace_constant.ace_buildin {\ + color: rgb(88, 72, 246);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_constant.ace_language {\ + color: rgb(255, 156, 0);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_constant.ace_library {\ + color: rgb(6, 150, 14);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_invalid {\ + text-decoration: line-through;\ + color: rgb(224, 0, 0);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_fold {\ +}\ +\ +.ace-crimson-editor .ace_line .ace_support.ace_function {\ + color: rgb(192, 0, 0);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_support.ace_constant {\ + color: rgb(6, 150, 14);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_support.ace_type,\ +.ace-crimson-editor .ace_line .ace_support.ace_class {\ + color: rgb(109, 121, 222);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_keyword.ace_operator {\ + color: rgb(49, 132, 149);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_string {\ + color: rgb(128, 0, 128);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_comment {\ + color: rgb(76, 136, 107);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_comment.ace_doc {\ + color: rgb(0, 102, 255);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_comment.ace_doc.ace_tag {\ + color: rgb(128, 159, 191);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_constant.ace_numeric {\ + color: rgb(0, 0, 64);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_variable {\ + color: rgb(0, 64, 128);\ +}\ +\ +.ace-crimson-editor .ace_line .ace_xml_pe {\ + color: rgb(104, 104, 91);\ +}\ +\ +.ace-crimson-editor .ace_marker-layer .ace_selection {\ + background: rgb(181, 213, 255);\ +}\ +\ +.ace-crimson-editor .ace_marker-layer .ace_step {\ + background: rgb(252, 255, 0);\ +}\ +\ +.ace-crimson-editor .ace_marker-layer .ace_stack {\ + background: rgb(164, 229, 101);\ +}\ +\ +.ace-crimson-editor .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgb(192, 192, 192);\ +}\ +\ +.ace-crimson-editor .ace_marker-layer .ace_active_line {\ + background: rgb(232, 242, 254);\ +}\ +\ +.ace-crimson-editor .ace_gutter_active_line {\ + background-color : #dcdcdc;\ +}\ +\ +.ace-crimson-editor .ace_meta.ace_tag {\ + color:rgb(28, 2, 255);\ +}\ +\ +.ace-crimson-editor .ace_marker-layer .ace_selected_word {\ + background: rgb(250, 250, 255);\ + border: 1px solid rgb(200, 200, 250);\ +}\ +\ +.ace-crimson-editor .ace_string.ace_regex {\ + color: rgb(192, 0, 192);\ +}\ +\ +.ace-crimson-editor .ace_indent-guide {\ + background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\ +}"; + +exports.cssClass = "ace-crimson-editor"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-dawn.js b/vendor/assets/javascripts/ace-src-noconflict/theme-dawn.js new file mode 100644 index 00000000..8ac1239a --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-dawn.js @@ -0,0 +1,183 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/dawn', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = false; +exports.cssClass = "ace-dawn"; +exports.cssText = ".ace-dawn .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-dawn .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-dawn .ace_gutter {\ + background: #ebebeb;\ + color: #333\ +}\ +\ +.ace-dawn .ace_print_margin {\ + width: 1px;\ + background: #e8e8e8\ +}\ +\ +.ace-dawn .ace_scroller {\ + background-color: #F9F9F9\ +}\ +\ +.ace-dawn .ace_text-layer {\ + color: #080808\ +}\ +\ +.ace-dawn .ace_cursor {\ + border-left: 2px solid #000000\ +}\ +\ +.ace-dawn .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #000000\ +}\ +\ +.ace-dawn .ace_marker-layer .ace_selection {\ + background: rgba(39, 95, 255, 0.30)\ +}\ +\ +.ace-dawn.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #F9F9F9;\ + border-radius: 2px\ +}\ +\ +.ace-dawn .ace_marker-layer .ace_step {\ + background: rgb(255, 255, 0)\ +}\ +\ +.ace-dawn .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgba(75, 75, 126, 0.50)\ +}\ +\ +.ace-dawn .ace_marker-layer .ace_active_line {\ + background: rgba(36, 99, 180, 0.12)\ +}\ +\ +.ace-dawn .ace_gutter_active_line {\ + background-color : #dcdcdc\ +}\ +\ +.ace-dawn .ace_marker-layer .ace_selected_word {\ + border: 1px solid rgba(39, 95, 255, 0.30)\ +}\ +\ +.ace-dawn .ace_invisible {\ + color: rgba(75, 75, 126, 0.50)\ +}\ +\ +.ace-dawn .ace_keyword,\ +.ace-dawn .ace_meta {\ + color: #794938\ +}\ +\ +.ace-dawn .ace_constant,\ +.ace-dawn .ace_constant.ace_character,\ +.ace-dawn .ace_constant.ace_character.ace_escape,\ +.ace-dawn .ace_constant.ace_other {\ + color: #811F24\ +}\ +\ +.ace-dawn .ace_invalid.ace_illegal {\ + text-decoration: underline;\ + font-style: italic;\ + color: #F8F8F8;\ + background-color: #B52A1D\ +}\ +\ +.ace-dawn .ace_invalid.ace_deprecated {\ + text-decoration: underline;\ + font-style: italic;\ + color: #B52A1D\ +}\ +\ +.ace-dawn .ace_support {\ + color: #691C97\ +}\ +\ +.ace-dawn .ace_support.ace_constant {\ + color: #B4371F\ +}\ +\ +.ace-dawn .ace_fold {\ + background-color: #794938;\ + border-color: #080808\ +}\ +\ +.ace-dawn .ace_markup.ace_list,\ +.ace-dawn .ace_support.ace_function {\ + color: #693A17\ +}\ +\ +.ace-dawn .ace_storage {\ + font-style: italic;\ + color: #A71D5D\ +}\ +\ +.ace-dawn .ace_string {\ + color: #0B6125\ +}\ +\ +.ace-dawn .ace_string.ace_regexp {\ + color: #CF5628\ +}\ +\ +.ace-dawn .ace_comment {\ + font-style: italic;\ + color: #5A525F\ +}\ +\ +.ace-dawn .ace_variable {\ + color: #234A97\ +}\ +\ +.ace-dawn .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-dawn .ace_markup.ace_heading {\ + color: #19356D\ +}\ +\ +.ace-dawn .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4+fPnf4ZVq1b9BwAkVQboFQv98gAAAABJRU5ErkJggg==) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-dreamweaver.js b/vendor/assets/javascripts/ace-src-noconflict/theme-dreamweaver.js new file mode 100644 index 00000000..315df6b3 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-dreamweaver.js @@ -0,0 +1,224 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/dreamweaver', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { +exports.isDark = false; +exports.cssClass = "ace-dreamweaver"; +exports.cssText = ".ace-dreamweaver .ace_editor {\ + border: 2px solid rgb(159, 159, 159);\ +}\ +\ +.ace-dreamweaver .ace_editor.ace_focus {\ + border: 2px solid #327fbd;\ +}\ +\ +.ace-dreamweaver .ace_gutter {\ + background: #e8e8e8;\ + color: #333;\ +}\ +\ +.ace-dreamweaver .ace_print_margin {\ + width: 1px;\ + background: #e8e8e8;\ +}\ +\ +.ace-dreamweaver .ace_scroller {\ + background-color: #FFFFFF;\ +}\ +\ +.ace-dreamweaver .ace_fold {\ + background-color: #757AD8;\ +}\ +\ +.ace-dreamweaver .ace_text-layer {\ +}\ +\ +.ace-dreamweaver .ace_cursor {\ + border-left: 2px solid black;\ +}\ +\ +.ace-dreamweaver .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid black;\ +}\ + \ +.ace-dreamweaver .ace_line .ace_invisible {\ + color: rgb(191, 191, 191);\ +}\ +\ +.ace-dreamweaver .ace_line .ace_storage,\ +.ace-dreamweaver .ace_line .ace_keyword {\ + color: blue;\ +}\ +\ +.ace-dreamweaver .ace_line .ace_constant.ace_buildin {\ + color: rgb(88, 72, 246);\ +}\ +\ +.ace-dreamweaver .ace_line .ace_constant.ace_language {\ + color: rgb(88, 92, 246);\ +}\ +\ +.ace-dreamweaver .ace_line .ace_constant.ace_library {\ + color: rgb(6, 150, 14);\ +}\ +\ +.ace-dreamweaver .ace_line .ace_invalid {\ + background-color: rgb(153, 0, 0);\ + color: white;\ +}\ +\ +.ace-dreamweaver .ace_line .ace_support.ace_function {\ + color: rgb(60, 76, 114);\ +}\ +\ +.ace-dreamweaver .ace_line .ace_support.ace_constant {\ + color: rgb(6, 150, 14);\ +}\ +\ +.ace-dreamweaver .ace_line .ace_support.ace_type,\ +.ace-dreamweaver .ace_line .ace_support.ace_class {\ + color: #009;\ +}\ +\ +.ace-dreamweaver .ace_line .ace_support.ace_php_tag {\ + color: #f00;\ +}\ +\ +.ace-dreamweaver .ace_line .ace_keyword.ace_operator {\ + color: rgb(104, 118, 135);\ +}\ +\ +.ace-dreamweaver .ace_line .ace_string {\ + color: #00F;\ +}\ +\ +.ace-dreamweaver .ace_line .ace_comment {\ + color: rgb(76, 136, 107);\ +}\ +\ +.ace-dreamweaver .ace_line .ace_comment.ace_doc {\ + color: rgb(0, 102, 255);\ +}\ +\ +.ace-dreamweaver .ace_line .ace_comment.ace_doc.ace_tag {\ + color: rgb(128, 159, 191);\ +}\ +\ +.ace-dreamweaver .ace_line .ace_constant.ace_numeric {\ + color: rgb(0, 0, 205);\ +}\ +\ +.ace-dreamweaver .ace_line .ace_variable {\ + color: #06F\ +}\ +\ +.ace-dreamweaver .ace_line .ace_xml_pe {\ + color: rgb(104, 104, 91);\ +}\ +\ +.ace-dreamweaver .ace_entity.ace_name.ace_function {\ + color: #00F;\ +}\ +\ +\ +.ace-dreamweaver .ace_markup.ace_heading {\ + color: rgb(12, 7, 255);\ +}\ +\ +.ace-dreamweaver .ace_markup.ace_list {\ + color:rgb(185, 6, 144);\ +}\ +\ +.ace-dreamweaver .ace_marker-layer .ace_selection {\ + background: rgb(181, 213, 255);\ +}\ +\ +.ace-dreamweaver .ace_marker-layer .ace_step {\ + background: rgb(252, 255, 0);\ +}\ +\ +.ace-dreamweaver .ace_marker-layer .ace_stack {\ + background: rgb(164, 229, 101);\ +}\ +\ +.ace-dreamweaver .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgb(192, 192, 192);\ +}\ +\ +.ace-dreamweaver .ace_marker-layer .ace_active_line {\ + background: rgba(0, 0, 0, 0.07);\ +}\ +\ +.ace-dreamweaver .ace_marker-layer .ace_selected_word {\ + background: rgb(250, 250, 255);\ + border: 1px solid rgb(200, 200, 250);\ +}\ +\ +.ace-dreamweaver .ace_meta.ace_tag {\ + color:#009;\ +}\ +\ +.ace-dreamweaver .ace_meta.ace_tag.ace_anchor {\ + color:#060;\ +}\ +\ +.ace-dreamweaver .ace_meta.ace_tag.ace_form {\ + color:#F90;\ +}\ +\ +.ace-dreamweaver .ace_meta.ace_tag.ace_image {\ + color:#909;\ +}\ +\ +.ace-dreamweaver .ace_meta.ace_tag.ace_script {\ + color:#900;\ +}\ +\ +.ace-dreamweaver .ace_meta.ace_tag.ace_style {\ + color:#909;\ +}\ +\ +.ace-dreamweaver .ace_meta.ace_tag.ace_table {\ + color:#099;\ +}\ +\ +.ace-dreamweaver .ace_string.ace_regex {\ + color: rgb(255, 0, 0)\ +}\ +\ +.ace-dreamweaver .ace_indent-guide {\ + background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-eclipse.js b/vendor/assets/javascripts/ace-src-noconflict/theme-eclipse.js new file mode 100644 index 00000000..a26af55e --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-eclipse.js @@ -0,0 +1,154 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/eclipse', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + + +exports.isDark = false; +exports.cssText = ".ace-eclipse .ace_editor {\ + border: 2px solid rgb(159, 159, 159);\ +}\ +\ +.ace-eclipse .ace_editor.ace_focus {\ + border: 2px solid #327fbd;\ +}\ +\ +.ace-eclipse .ace_gutter {\ + background: #ebebeb;\ + border-right: 1px solid rgb(159, 159, 159);\ + color: rgb(136, 136, 136);\ +}\ +\ +.ace-eclipse .ace_print_margin {\ + width: 1px;\ + background: #ebebeb;\ +}\ +\ +.ace-eclipse .ace_scroller {\ + background-color: #FFFFFF;\ +}\ +\ +.ace-eclipse .ace_fold {\ + background-color: rgb(60, 76, 114);\ +}\ +\ +.ace-eclipse .ace_text-layer {\ +}\ +\ +.ace-eclipse .ace_cursor {\ + border-left: 2px solid black;\ +}\ +\ +.ace-eclipse .ace_line .ace_storage,\ +.ace-eclipse .ace_line .ace_keyword,\ +.ace-eclipse .ace_line .ace_variable {\ + color: rgb(127, 0, 85);\ +}\ +\ +.ace-eclipse .ace_line .ace_constant.ace_buildin {\ + color: rgb(88, 72, 246);\ +}\ +\ +.ace-eclipse .ace_line .ace_constant.ace_library {\ + color: rgb(6, 150, 14);\ +}\ +\ +.ace-eclipse .ace_line .ace_function {\ + color: rgb(60, 76, 114);\ +}\ +\ +.ace-eclipse .ace_line .ace_string {\ + color: rgb(42, 0, 255);\ +}\ +\ +.ace-eclipse .ace_line .ace_comment {\ + color: rgb(63, 127, 95);\ +}\ +\ +.ace-eclipse .ace_line .ace_comment.ace_doc {\ + color: rgb(63, 95, 191);\ +}\ +\ +.ace-eclipse .ace_line .ace_comment.ace_doc.ace_tag {\ + color: rgb(127, 159, 191);\ +}\ +\ +.ace-eclipse .ace_line .ace_constant.ace_numeric {\ +}\ +\ +.ace-eclipse .ace_line .ace_tag {\ + color: rgb(63, 127, 127);\ +}\ +\ +.ace-eclipse .ace_line .ace_type {\ + color: rgb(127, 0, 127);\ +}\ +\ +.ace-eclipse .ace_line .ace_xml_pe {\ + color: rgb(104, 104, 91);\ +}\ +\ +.ace-eclipse .ace_marker-layer .ace_selection {\ + background: rgb(181, 213, 255);\ +}\ +\ +.ace-eclipse .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgb(192, 192, 192);\ +}\ +\ +.ace-eclipse .ace_line .ace_meta.ace_tag {\ + color:rgb(63, 127, 127);\ +}\ +\ +.ace-eclipse .ace_entity.ace_other.ace_attribute-name {\ + color:rgb(127, 0, 127);\ +}\ +.ace-eclipse .ace_marker-layer .ace_step {\ + background: rgb(255, 255, 0);\ +}\ +\ +.ace-eclipse .ace_marker-layer .ace_active_line {\ + background: rgb(232, 242, 254);\ +}\ +\ +.ace-eclipse .ace_marker-layer .ace_selected_word {\ + border: 1px solid rgb(181, 213, 255);\ +}\ +\ +.ace-eclipse .ace_indent-guide {\ + background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\ +}"; + +exports.cssClass = "ace-eclipse"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-github.js b/vendor/assets/javascripts/ace-src-noconflict/theme-github.js new file mode 100644 index 00000000..7aacdf1a --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-github.js @@ -0,0 +1,175 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/github', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = false; +exports.cssClass = "ace-github"; +exports.cssText = "/* CSS style content from github's default pygments highlighter template.\ + Cursor and selection styles from textmate.css. */\ +.ace-github .ace_editor {\ + color: #333;\ + background-color: #F8F8F8;\ + border: 1px solid #CCC;\ + font: 13px 'Bitstream Vera Sans Mono', Courier, monospace !important;\ + line-height: 19px !important;\ + overflow: auto;\ + padding: 6px 10px;\ + border-radius: 3px;\ + position: relative;\ + margin-bottom: 15px;\ +}\ +\ +.ace-github .ace_gutter {\ + background: #e8e8e8;\ + color: #AAA;\ +}\ +\ +.ace-github .ace_scroller {\ + background: #fff;\ +}\ +\ +.ace-github .ace_keyword {\ + font-weight: bold;\ +}\ +\ +.ace-github .ace_string {\ + color: #D14;\ +}\ +\ +.ace-github .ace_variable.ace_class {\ + color: teal;\ +}\ +\ +.ace-github .ace_constant.ace_numeric {\ + color: #099;\ +}\ +\ +.ace-github .ace_constant.ace_buildin {\ + color: #0086B3;\ +}\ +\ +.ace-github .ace_support.ace_function {\ + color: #0086B3;\ +}\ +\ +.ace-github .ace_comment {\ + color: #998;\ + font-style: italic;\ +}\ +\ +.ace-github .ace_variable.ace_language {\ + color: #0086B3;\ +}\ +\ +.ace-github .ace_paren {\ + font-weight: bold;\ +}\ +\ +.ace-github .ace_boolean {\ + font-weight: bold;\ +}\ +\ +.ace-github .ace_string.ace_regexp {\ + color: #009926;\ + font-weight: normal;\ +}\ +\ +.ace-github .ace_variable.ace_instancce {\ + color: teal;\ +}\ +\ +.ace-github .ace_constant.ace_language {\ + font-weight: bold;\ +}\ +\ +.ace-github .ace_text-layer {\ +}\ +\ +.ace-github .ace_cursor {\ + border-left: 2px solid black;\ +}\ +\ +.ace-github .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid black;\ +}\ +\ +.ace-github .ace_marker-layer .ace_active_line {\ + background: rgb(255, 255, 204);\ +}\ +.ace-github .ace_marker-layer .ace_selection {\ + background: rgb(181, 213, 255);\ +}\ +.ace-github.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px white;\ + border-radius: 2px;\ +}\ +/* bold keywords cause cursor issues for some fonts */\ +/* this disables bold style for editor and keeps for static highlighter */\ +.ace-github.ace_editor .ace_line > span {\ + font-weight: normal !important;\ +}\ +\ +.ace-github .ace_marker-layer .ace_step {\ + background: rgb(252, 255, 0);\ +}\ +\ +.ace-github .ace_marker-layer .ace_stack {\ + background: rgb(164, 229, 101);\ +}\ +\ +.ace-github .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgb(192, 192, 192);\ +}\ +\ +.ace-github .ace_gutter_active_line {\ + background-color : rgba(0, 0, 0, 0.07);\ +}\ +\ +.ace-github .ace_marker-layer .ace_selected_word {\ + background: rgb(250, 250, 255);\ + border: 1px solid rgb(200, 200, 250);\ +\ +}\ +\ +.ace-github .ace_print_margin {\ + width: 1px;\ + background: #e8e8e8;\ +}\ +\ +.ace-github .ace_indent-guide {\ + background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\ +}"; + + var dom = require("../lib/dom"); + dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-idle_fingers.js b/vendor/assets/javascripts/ace-src-noconflict/theme-idle_fingers.js new file mode 100644 index 00000000..79c12990 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-idle_fingers.js @@ -0,0 +1,171 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/idle_fingers', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-idle-fingers"; +exports.cssText = ".ace-idle-fingers .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-idle-fingers .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-idle-fingers .ace_gutter {\ + background: #3b3b3b;\ + color: #fff\ +}\ +\ +.ace-idle-fingers .ace_print_margin {\ + width: 1px;\ + background: #3b3b3b\ +}\ +\ +.ace-idle-fingers .ace_scroller {\ + background-color: #323232\ +}\ +\ +.ace-idle-fingers .ace_text-layer {\ + color: #FFFFFF\ +}\ +\ +.ace-idle-fingers .ace_cursor {\ + border-left: 2px solid #91FF00\ +}\ +\ +.ace-idle-fingers .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #91FF00\ +}\ +\ +.ace-idle-fingers .ace_marker-layer .ace_selection {\ + background: rgba(90, 100, 126, 0.88)\ +}\ +\ +.ace-idle-fingers.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #323232;\ + border-radius: 2px\ +}\ +\ +.ace-idle-fingers .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-idle-fingers .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid #404040\ +}\ +\ +.ace-idle-fingers .ace_marker-layer .ace_active_line {\ + background: #353637\ +}\ +\ +.ace-idle-fingers .ace_gutter_active_line {\ + background-color: #353637\ +}\ +\ +.ace-idle-fingers .ace_marker-layer .ace_selected_word {\ + border: 1px solid rgba(90, 100, 126, 0.88)\ +}\ +\ +.ace-idle-fingers .ace_invisible {\ + color: #404040\ +}\ +\ +.ace-idle-fingers .ace_keyword,\ +.ace-idle-fingers .ace_meta {\ + color: #CC7833\ +}\ +\ +.ace-idle-fingers .ace_constant,\ +.ace-idle-fingers .ace_constant.ace_character,\ +.ace-idle-fingers .ace_constant.ace_character.ace_escape,\ +.ace-idle-fingers .ace_constant.ace_other,\ +.ace-idle-fingers .ace_support.ace_constant {\ + color: #6C99BB\ +}\ +\ +.ace-idle-fingers .ace_invalid {\ + color: #FFFFFF;\ + background-color: #FF0000\ +}\ +\ +.ace-idle-fingers .ace_fold {\ + background-color: #CC7833;\ + border-color: #FFFFFF\ +}\ +\ +.ace-idle-fingers .ace_support.ace_function {\ + color: #B83426\ +}\ +\ +.ace-idle-fingers .ace_variable.ace_parameter {\ + font-style: italic\ +}\ +\ +.ace-idle-fingers .ace_string {\ + color: #A5C261\ +}\ +\ +.ace-idle-fingers .ace_string.ace_regexp {\ + color: #CCCC33\ +}\ +\ +.ace-idle-fingers .ace_comment {\ + font-style: italic;\ + color: #BC9458\ +}\ +\ +.ace-idle-fingers .ace_meta.ace_tag {\ + color: #FFE5BB\ +}\ +\ +.ace-idle-fingers .ace_entity.ace_name {\ + color: #FFC66D\ +}\ +\ +.ace-idle-fingers .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-idle-fingers .ace_collab.ace_user1 {\ + color: #323232;\ + background-color: #FFF980\ +}\ +\ +.ace-idle-fingers .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWMwMjL6zzBz5sz/ABEUBGCqhK6UAAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-kr_theme.js b/vendor/assets/javascripts/ace-src-noconflict/theme-kr_theme.js new file mode 100644 index 00000000..12f5d5b3 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-kr_theme.js @@ -0,0 +1,177 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/kr_theme', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-kr-theme"; +exports.cssText = ".ace-kr-theme .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-kr-theme .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-kr-theme .ace_gutter {\ + background: #1c1917;\ + color: #FCFFE0\ +}\ +\ +.ace-kr-theme .ace_print_margin {\ + width: 1px;\ + background: #1c1917\ +}\ +\ +.ace-kr-theme .ace_scroller {\ + background-color: #0B0A09\ +}\ +\ +.ace-kr-theme .ace_text-layer {\ + color: #FCFFE0\ +}\ +\ +.ace-kr-theme .ace_cursor {\ + border-left: 2px solid #FF9900\ +}\ +\ +.ace-kr-theme .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #FF9900\ +}\ +\ +.ace-kr-theme .ace_marker-layer .ace_selection {\ + background: rgba(170, 0, 255, 0.45)\ +}\ +\ +.ace-kr-theme.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #0B0A09;\ + border-radius: 2px\ +}\ +\ +.ace-kr-theme .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-kr-theme .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgba(255, 177, 111, 0.32)\ +}\ +\ +.ace-kr-theme .ace_marker-layer .ace_active_line {\ + background: #38403D\ +}\ +\ +.ace-kr-theme .ace_gutter_active_line {\ + background-color : #38403D\ +}\ +\ +.ace-kr-theme .ace_marker-layer .ace_selected_word {\ + border: 1px solid rgba(170, 0, 255, 0.45)\ +}\ +\ +.ace-kr-theme .ace_invisible {\ + color: rgba(255, 177, 111, 0.32)\ +}\ +\ +.ace-kr-theme .ace_keyword,\ +.ace-kr-theme .ace_meta {\ + color: #949C8B\ +}\ +\ +.ace-kr-theme .ace_constant,\ +.ace-kr-theme .ace_constant.ace_character,\ +.ace-kr-theme .ace_constant.ace_character.ace_escape,\ +.ace-kr-theme .ace_constant.ace_other {\ + color: rgba(210, 117, 24, 0.76)\ +}\ +\ +.ace-kr-theme .ace_invalid {\ + color: #F8F8F8;\ + background-color: #A41300\ +}\ +\ +.ace-kr-theme .ace_support {\ + color: #9FC28A\ +}\ +\ +.ace-kr-theme .ace_support.ace_constant {\ + color: #C27E66\ +}\ +\ +.ace-kr-theme .ace_fold {\ + background-color: #949C8B;\ + border-color: #FCFFE0\ +}\ +\ +.ace-kr-theme .ace_support.ace_function {\ + color: #85873A\ +}\ +\ +.ace-kr-theme .ace_storage {\ + color: #FFEE80\ +}\ +\ +.ace-kr-theme .ace_string.ace_regexp {\ + color: rgba(125, 255, 192, 0.65)\ +}\ +\ +.ace-kr-theme .ace_comment {\ + font-style: italic;\ + color: #706D5B\ +}\ +\ +.ace-kr-theme .ace_variable {\ + color: #D1A796\ +}\ +\ +.ace-kr-theme .ace_variable.ace_language {\ + color: #FF80E1\ +}\ +\ +.ace-kr-theme .ace_meta.ace_tag {\ + color: #BABD9C\ +}\ +\ +.ace-kr-theme .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-kr-theme .ace_markup.ace_list {\ + background-color: #0F0040\ +}\ +\ +.ace-kr-theme .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWPg5uL8zzBz5sz/AA1WA+hUYIqjAAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-merbivore.js b/vendor/assets/javascripts/ace-src-noconflict/theme-merbivore.js new file mode 100644 index 00000000..2e2926d5 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-merbivore.js @@ -0,0 +1,168 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/merbivore', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-merbivore"; +exports.cssText = ".ace-merbivore .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-merbivore .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-merbivore .ace_gutter {\ + background: #202020;\ + color: #E6E1DC\ +}\ +\ +.ace-merbivore .ace_print_margin {\ + width: 1px;\ + background: #555651\ +}\ +\ +.ace-merbivore .ace_scroller {\ + background-color: #161616\ +}\ +\ +.ace-merbivore .ace_text-layer {\ + color: #E6E1DC\ +}\ +\ +.ace-merbivore .ace_cursor {\ + border-left: 2px solid #FFFFFF\ +}\ +\ +.ace-merbivore .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #FFFFFF\ +}\ +\ +.ace-merbivore .ace_marker-layer .ace_selection {\ + background: #454545\ +}\ +\ +.ace-merbivore.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #161616;\ + border-radius: 2px\ +}\ +\ +.ace-merbivore .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-merbivore .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid #404040\ +}\ +\ +.ace-merbivore .ace_marker-layer .ace_active_line {\ + background: #333435\ +}\ +\ +.ace-merbivore .ace_gutter_active_line {\ + background-color: #333435\ +}\ +\ +.ace-merbivore .ace_marker-layer .ace_selected_word {\ + border: 1px solid #454545\ +}\ +\ +.ace-merbivore .ace_invisible {\ + color: #404040\ +}\ +\ +.ace-merbivore .ace_entity.ace_name.ace_tag,\ +.ace-merbivore .ace_keyword,\ +.ace-merbivore .ace_meta,\ +.ace-merbivore .ace_meta.ace_tag,\ +.ace-merbivore .ace_storage,\ +.ace-merbivore .ace_support.ace_function {\ + color: #FC6F09\ +}\ +\ +.ace-merbivore .ace_constant,\ +.ace-merbivore .ace_constant.ace_character,\ +.ace-merbivore .ace_constant.ace_character.ace_escape,\ +.ace-merbivore .ace_constant.ace_other,\ +.ace-merbivore .ace_support.ace_type {\ + color: #1EDAFB\ +}\ +\ +.ace-merbivore .ace_constant.ace_character.ace_escape {\ + color: #519F50\ +}\ +\ +.ace-merbivore .ace_constant.ace_language {\ + color: #FDC251\ +}\ +\ +.ace-merbivore .ace_constant.ace_library,\ +.ace-merbivore .ace_string,\ +.ace-merbivore .ace_support.ace_constant {\ + color: #8DFF0A\ +}\ +\ +.ace-merbivore .ace_constant.ace_numeric {\ + color: #58C554\ +}\ +\ +.ace-merbivore .ace_invalid {\ + color: #FFFFFF;\ + background-color: #990000\ +}\ +\ +.ace-merbivore .ace_fold {\ + background-color: #FC6F09;\ + border-color: #E6E1DC\ +}\ +\ +.ace-merbivore .ace_comment {\ + font-style: italic;\ + color: #AD2EA4\ +}\ +\ +.ace-merbivore .ace_entity.ace_other.ace_attribute-name {\ + color: #FFFF89\ +}\ +\ +.ace-merbivore .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-merbivore .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWMQExP7zzBz5sz/AA50BAyDznYhAAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-merbivore_soft.js b/vendor/assets/javascripts/ace-src-noconflict/theme-merbivore_soft.js new file mode 100644 index 00000000..9e41cb7c --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-merbivore_soft.js @@ -0,0 +1,169 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/merbivore_soft', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-merbivore-soft"; +exports.cssText = ".ace-merbivore-soft .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-merbivore-soft .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-merbivore-soft .ace_gutter {\ + background: #262424;\ + color: #E6E1DC\ +}\ +\ +.ace-merbivore-soft .ace_print_margin {\ + width: 1px;\ + background: #262424\ +}\ +\ +.ace-merbivore-soft .ace_scroller {\ + background-color: #1C1C1C\ +}\ +\ +.ace-merbivore-soft .ace_text-layer {\ + color: #E6E1DC\ +}\ +\ +.ace-merbivore-soft .ace_cursor {\ + border-left: 2px solid #FFFFFF\ +}\ +\ +.ace-merbivore-soft .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #FFFFFF\ +}\ +\ +.ace-merbivore-soft .ace_marker-layer .ace_selection {\ + background: #494949\ +}\ +\ +.ace-merbivore-soft.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #1C1C1C;\ + border-radius: 2px\ +}\ +\ +.ace-merbivore-soft .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-merbivore-soft .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid #404040\ +}\ +\ +.ace-merbivore-soft .ace_marker-layer .ace_active_line {\ + background: #333435\ +}\ +\ +.ace-merbivore-soft .ace_gutter_active_line {\ + background-color: #333435\ +}\ +\ +.ace-merbivore-soft .ace_marker-layer .ace_selected_word {\ + border: 1px solid #494949\ +}\ +\ +.ace-merbivore-soft .ace_invisible {\ + color: #404040\ +}\ +\ +.ace-merbivore-soft .ace_entity.ace_name.ace_tag,\ +.ace-merbivore-soft .ace_keyword,\ +.ace-merbivore-soft .ace_meta,\ +.ace-merbivore-soft .ace_meta.ace_tag,\ +.ace-merbivore-soft .ace_storage {\ + color: #FC803A\ +}\ +\ +.ace-merbivore-soft .ace_constant,\ +.ace-merbivore-soft .ace_constant.ace_character,\ +.ace-merbivore-soft .ace_constant.ace_character.ace_escape,\ +.ace-merbivore-soft .ace_constant.ace_other,\ +.ace-merbivore-soft .ace_support.ace_type {\ + color: #68C1D8\ +}\ +\ +.ace-merbivore-soft .ace_constant.ace_character.ace_escape {\ + color: #B3E5B4\ +}\ +\ +.ace-merbivore-soft .ace_constant.ace_language {\ + color: #E1C582\ +}\ +\ +.ace-merbivore-soft .ace_constant.ace_library,\ +.ace-merbivore-soft .ace_string,\ +.ace-merbivore-soft .ace_support.ace_constant {\ + color: #8EC65F\ +}\ +\ +.ace-merbivore-soft .ace_constant.ace_numeric {\ + color: #7FC578\ +}\ +\ +.ace-merbivore-soft .ace_invalid,\ +.ace-merbivore-soft .ace_invalid.ace_deprecated {\ + color: #FFFFFF;\ + background-color: #FE3838\ +}\ +\ +.ace-merbivore-soft .ace_fold {\ + background-color: #FC803A;\ + border-color: #E6E1DC\ +}\ +\ +.ace-merbivore-soft .ace_comment,\ +.ace-merbivore-soft .ace_meta {\ + font-style: italic;\ + color: #AC4BB8\ +}\ +\ +.ace-merbivore-soft .ace_entity.ace_other.ace_attribute-name {\ + color: #EAF1A3\ +}\ +\ +.ace-merbivore-soft .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-merbivore-soft .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWOQkZH5zzBz5sz/AA8EBB6crd1rAAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-mono_industrial.js b/vendor/assets/javascripts/ace-src-noconflict/theme-mono_industrial.js new file mode 100644 index 00000000..7f9c355d --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-mono_industrial.js @@ -0,0 +1,180 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/mono_industrial', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-mono-industrial"; +exports.cssText = ".ace-mono-industrial .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-mono-industrial .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-mono-industrial .ace_gutter {\ + background: #1d2521;\ + color: #C5C9C9\ +}\ +\ +.ace-mono-industrial .ace_print_margin {\ + width: 1px;\ + background: #555651\ +}\ +\ +.ace-mono-industrial .ace_scroller {\ + background-color: #222C28\ +}\ +\ +.ace-mono-industrial .ace_text-layer {\ + color: #FFFFFF\ +}\ +\ +.ace-mono-industrial .ace_cursor {\ + border-left: 2px solid #FFFFFF\ +}\ +\ +.ace-mono-industrial .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #FFFFFF\ +}\ +\ +.ace-mono-industrial .ace_marker-layer .ace_selection {\ + background: rgba(145, 153, 148, 0.40)\ +}\ +\ +.ace-mono-industrial.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #222C28;\ + border-radius: 2px\ +}\ +\ +.ace-mono-industrial .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-mono-industrial .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgba(102, 108, 104, 0.50)\ +}\ +\ +.ace-mono-industrial .ace_marker-layer .ace_active_line {\ + background: rgba(12, 13, 12, 0.25)\ +}\ +\ +.ace-mono-industrial .ace_gutter_active_line {\ + background-color: rgba(12, 13, 12, 0.25)\ +}\ +\ +.ace-mono-industrial .ace_marker-layer .ace_selected_word {\ + border: 1px solid rgba(145, 153, 148, 0.40)\ +}\ +\ +.ace-mono-industrial .ace_invisible {\ + color: rgba(102, 108, 104, 0.50)\ +}\ +\ +.ace-mono-industrial .ace_keyword,\ +.ace-mono-industrial .ace_meta {\ + color: #A39E64\ +}\ +\ +.ace-mono-industrial .ace_constant,\ +.ace-mono-industrial .ace_constant.ace_character,\ +.ace-mono-industrial .ace_constant.ace_character.ace_escape,\ +.ace-mono-industrial .ace_constant.ace_numeric,\ +.ace-mono-industrial .ace_constant.ace_other {\ + color: #E98800\ +}\ +\ +.ace-mono-industrial .ace_entity.ace_name.ace_function,\ +.ace-mono-industrial .ace_keyword.ace_operator,\ +.ace-mono-industrial .ace_variable {\ + color: #A8B3AB\ +}\ +\ +.ace-mono-industrial .ace_invalid {\ + color: #FFFFFF;\ + background-color: rgba(153, 0, 0, 0.68)\ +}\ +\ +.ace-mono-industrial .ace_support.ace_constant {\ + color: #C87500\ +}\ +\ +.ace-mono-industrial .ace_fold {\ + background-color: #A8B3AB;\ + border-color: #FFFFFF\ +}\ +\ +.ace-mono-industrial .ace_support.ace_function {\ + color: #588E60\ +}\ +\ +.ace-mono-industrial .ace_entity.ace_name,\ +.ace-mono-industrial .ace_support.ace_class,\ +.ace-mono-industrial .ace_support.ace_type {\ + color: #5778B6\ +}\ +\ +.ace-mono-industrial .ace_storage {\ + color: #C23B00\ +}\ +\ +.ace-mono-industrial .ace_variable.ace_language,\ +.ace-mono-industrial .ace_variable.ace_parameter {\ + color: #648BD2\ +}\ +\ +.ace-mono-industrial .ace_comment {\ + color: #666C68;\ + background-color: #151C19\ +}\ +\ +.ace-mono-industrial .ace_entity.ace_other.ace_attribute-name {\ + color: #909993\ +}\ +\ +.ace-mono-industrial .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-mono-industrial .ace_entity.ace_name.ace_tag {\ + color: #A65EFF\ +}\ +\ +.ace-mono-industrial .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNQ0tH4zzBz5sz/ABAOBECKH+evAAAAAElFTkSuQmCC) right repeat-y\ +}\ +"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-monokai.js b/vendor/assets/javascripts/ace-src-noconflict/theme-monokai.js new file mode 100644 index 00000000..e1f832aa --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-monokai.js @@ -0,0 +1,174 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/monokai', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-monokai"; +exports.cssText = ".ace-monokai .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-monokai .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-monokai .ace_gutter {\ + background: #2f3129;\ + color: #f1f1f1\ +}\ +\ +.ace-monokai .ace_print_margin {\ + width: 1px;\ + background: #555651\ +}\ +\ +.ace-monokai .ace_scroller {\ + background-color: #272822\ +}\ +\ +.ace-monokai .ace_text-layer {\ + color: #F8F8F2\ +}\ +\ +.ace-monokai .ace_cursor {\ + border-left: 2px solid #F8F8F0\ +}\ +\ +.ace-monokai .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #F8F8F0\ +}\ +\ +.ace-monokai .ace_marker-layer .ace_selection {\ + background: #49483E\ +}\ +\ +.ace-monokai.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #272822;\ + border-radius: 2px\ +}\ +\ +.ace-monokai .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-monokai .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid #49483E\ +}\ +\ +.ace-monokai .ace_marker-layer .ace_active_line {\ + background: #202020\ +}\ +\ +.ace-monokai .ace_gutter_active_line {\ + background-color: #272727\ +}\ +\ +.ace-monokai .ace_marker-layer .ace_selected_word {\ + border: 1px solid #49483E\ +}\ +\ +.ace-monokai .ace_invisible {\ + color: #49483E\ +}\ +\ +.ace-monokai .ace_entity.ace_name.ace_tag,\ +.ace-monokai .ace_keyword,\ +.ace-monokai .ace_meta,\ +.ace-monokai .ace_storage {\ + color: #F92672\ +}\ +\ +.ace-monokai .ace_constant.ace_character,\ +.ace-monokai .ace_constant.ace_language,\ +.ace-monokai .ace_constant.ace_numeric,\ +.ace-monokai .ace_constant.ace_other {\ + color: #AE81FF\ +}\ +\ +.ace-monokai .ace_invalid {\ + color: #F8F8F0;\ + background-color: #F92672\ +}\ +\ +.ace-monokai .ace_invalid.ace_deprecated {\ + color: #F8F8F0;\ + background-color: #AE81FF\ +}\ +\ +.ace-monokai .ace_support.ace_constant,\ +.ace-monokai .ace_support.ace_function {\ + color: #66D9EF\ +}\ +\ +.ace-monokai .ace_fold {\ + background-color: #A6E22E;\ + border-color: #F8F8F2\ +}\ +\ +.ace-monokai .ace_storage.ace_type,\ +.ace-monokai .ace_support.ace_class,\ +.ace-monokai .ace_support.ace_type {\ + font-style: italic;\ + color: #66D9EF\ +}\ +\ +.ace-monokai .ace_entity.ace_name.ace_function,\ +.ace-monokai .ace_entity.ace_other.ace_attribute-name,\ +.ace-monokai .ace_variable {\ + color: #A6E22E\ +}\ +\ +.ace-monokai .ace_variable.ace_parameter {\ + font-style: italic;\ + color: #FD971F\ +}\ +\ +.ace-monokai .ace_string {\ + color: #E6DB74\ +}\ +\ +.ace-monokai .ace_comment {\ + color: #75715E\ +}\ +\ +.ace-monokai .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-monokai .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNQ11D6z7Bq1ar/ABCKBG6g04U2AAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-pastel_on_dark.js b/vendor/assets/javascripts/ace-src-noconflict/theme-pastel_on_dark.js new file mode 100644 index 00000000..df29686a --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-pastel_on_dark.js @@ -0,0 +1,187 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/pastel_on_dark', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-pastel-on-dark"; +exports.cssText = ".ace-pastel-on-dark .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-pastel-on-dark .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-pastel-on-dark .ace_gutter {\ + background: #353030;\ + color: #8F938F\ +}\ +\ +.ace-pastel-on-dark .ace_print_margin {\ + width: 1px;\ + background: #353030\ +}\ +\ +.ace-pastel-on-dark .ace_scroller {\ + background-color: #2C2828\ +}\ +\ +.ace-pastel-on-dark .ace_text-layer {\ + color: #8F938F\ +}\ +\ +.ace-pastel-on-dark .ace_cursor {\ + border-left: 2px solid #A7A7A7\ +}\ +\ +.ace-pastel-on-dark .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #A7A7A7\ +}\ +\ +.ace-pastel-on-dark .ace_marker-layer .ace_selection {\ + background: rgba(221, 240, 255, 0.20)\ +}\ +\ +.ace-pastel-on-dark.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #2C2828;\ + border-radius: 2px\ +}\ +\ +.ace-pastel-on-dark .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-pastel-on-dark .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgba(255, 255, 255, 0.25)\ +}\ +\ +.ace-pastel-on-dark .ace_marker-layer .ace_active_line {\ + background: rgba(255, 255, 255, 0.031)\ +}\ +\ +.ace-pastel-on-dark .ace_gutter_active_line {\ + background-color: rgba(255, 255, 255, 0.031)\ +}\ +\ +.ace-pastel-on-dark .ace_marker-layer .ace_selected_word {\ + border: 1px solid rgba(221, 240, 255, 0.20)\ +}\ +\ +.ace-pastel-on-dark .ace_invisible {\ + color: rgba(255, 255, 255, 0.25)\ +}\ +\ +.ace-pastel-on-dark .ace_keyword,\ +.ace-pastel-on-dark .ace_meta {\ + color: #757aD8\ +}\ +\ +.ace-pastel-on-dark .ace_constant,\ +.ace-pastel-on-dark .ace_constant.ace_character,\ +.ace-pastel-on-dark .ace_constant.ace_character.ace_escape,\ +.ace-pastel-on-dark .ace_constant.ace_other {\ + color: #4FB7C5\ +}\ +\ +.ace-pastel-on-dark .ace_keyword.ace_operator {\ + color: #797878\ +}\ +\ +.ace-pastel-on-dark .ace_constant.ace_character {\ + color: #AFA472\ +}\ +\ +.ace-pastel-on-dark .ace_constant.ace_language {\ + color: #DE8E30\ +}\ +\ +.ace-pastel-on-dark .ace_constant.ace_numeric {\ + color: #CCCCCC\ +}\ +\ +.ace-pastel-on-dark .ace_invalid,\ +.ace-pastel-on-dark .ace_invalid.ace_illegal {\ + color: #F8F8F8;\ + background-color: rgba(86, 45, 86, 0.75)\ +}\ +\ +.ace-pastel-on-dark .ace_invalid.ace_deprecated {\ + text-decoration: underline;\ + font-style: italic;\ + color: #D2A8A1\ +}\ +\ +.ace-pastel-on-dark .ace_fold {\ + background-color: #757aD8;\ + border-color: #8F938F\ +}\ +\ +.ace-pastel-on-dark .ace_support.ace_function {\ + color: #AEB2F8\ +}\ +\ +.ace-pastel-on-dark .ace_string {\ + color: #66A968\ +}\ +\ +.ace-pastel-on-dark .ace_string.ace_regexp {\ + color: #E9C062\ +}\ +\ +.ace-pastel-on-dark .ace_comment {\ + color: #A6C6FF\ +}\ +\ +.ace-pastel-on-dark .ace_variable {\ + color: #BEBF55\ +}\ +\ +.ace-pastel-on-dark .ace_variable.ace_language {\ + color: #C1C144\ +}\ +\ +.ace-pastel-on-dark .ace_xml_pe {\ + color: #494949\ +}\ +\ +.ace-pastel-on-dark .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-pastel-on-dark .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWPQ0dD4z9DR0fEfAA+vBBPqhbn1AAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-solarized_dark.js b/vendor/assets/javascripts/ace-src-noconflict/theme-solarized_dark.js new file mode 100644 index 00000000..7894bdef --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-solarized_dark.js @@ -0,0 +1,159 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/solarized_dark', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-solarized-dark"; +exports.cssText = ".ace-solarized-dark .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-solarized-dark .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-solarized-dark .ace_gutter {\ + background: #01313f;\ + color: #d0edf7\ +}\ +\ +.ace-solarized-dark .ace_print_margin {\ + width: 1px;\ + background: #33555E\ +}\ +\ +.ace-solarized-dark .ace_scroller {\ + background-color: #002B36\ +}\ +\ +.ace-solarized-dark .ace_entity.ace_other.ace_attribute-name,\ +.ace-solarized-dark .ace_storage,\ +.ace-solarized-dark .ace_text-layer {\ + color: #93A1A1\ +}\ +\ +.ace-solarized-dark .ace_cursor {\ + border-left: 2px solid #D30102\ +}\ +\ +.ace-solarized-dark .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #D30102\ +}\ +\ +.ace-solarized-dark .ace_marker-layer .ace_active_line,\ +.ace-solarized-dark .ace_marker-layer .ace_selection {\ + background: rgba(255, 255, 255, 0.1)\ +}\ +\ +.ace-solarized-dark.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #002B36;\ + border-radius: 2px\ +}\ +\ +.ace-solarized-dark .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-solarized-dark .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgba(147, 161, 161, 0.50)\ +}\ +\ +.ace-solarized-dark .ace_gutter_active_line {\ + background-color: #0d3440\ +}\ +\ +.ace-solarized-dark .ace_marker-layer .ace_selected_word {\ + border: 1px solid #073642\ +}\ +\ +.ace-solarized-dark .ace_invisible {\ + color: rgba(147, 161, 161, 0.50)\ +}\ +\ +.ace-solarized-dark .ace_keyword,\ +.ace-solarized-dark .ace_meta,\ +.ace-solarized-dark .ace_support.ace_class,\ +.ace-solarized-dark .ace_support.ace_type {\ + color: #859900\ +}\ +\ +.ace-solarized-dark .ace_constant.ace_character,\ +.ace-solarized-dark .ace_constant.ace_other {\ + color: #CB4B16\ +}\ +\ +.ace-solarized-dark .ace_constant.ace_language {\ + color: #B58900\ +}\ +\ +.ace-solarized-dark .ace_constant.ace_numeric {\ + color: #D33682\ +}\ +\ +.ace-solarized-dark .ace_fold {\ + background-color: #268BD2;\ + border-color: #93A1A1\ +}\ +\ +.ace-solarized-dark .ace_entity.ace_name.ace_function,\ +.ace-solarized-dark .ace_entity.ace_name.ace_tag,\ +.ace-solarized-dark .ace_support.ace_function,\ +.ace-solarized-dark .ace_variable,\ +.ace-solarized-dark .ace_variable.ace_language {\ + color: #268BD2\ +}\ +\ +.ace-solarized-dark .ace_string {\ + color: #2AA198\ +}\ +\ +.ace-solarized-dark .ace_string.ace_regexp {\ + color: #D30102\ +}\ +\ +.ace-solarized-dark .ace_comment {\ + font-style: italic;\ + color: #657B83\ +}\ +\ +.ace-solarized-dark .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-solarized-dark .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNg0Db7zzBz5sz/AA82BCv7wOIDAAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-solarized_light.js b/vendor/assets/javascripts/ace-src-noconflict/theme-solarized_light.js new file mode 100644 index 00000000..35f880c2 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-solarized_light.js @@ -0,0 +1,164 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/solarized_light', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = false; +exports.cssClass = "ace-solarized-light"; +exports.cssText = ".ace-solarized-light .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-solarized-light .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-solarized-light .ace_gutter {\ + background: #fbf1d3;\ + color: #333\ +}\ +\ +.ace-solarized-light .ace_print_margin {\ + width: 1px;\ + background: #e8e8e8\ +}\ +\ +.ace-solarized-light .ace_scroller {\ + background-color: #FDF6E3\ +}\ +\ +.ace-solarized-light .ace_text-layer {\ + color: #586E75\ +}\ +\ +.ace-solarized-light .ace_cursor {\ + border-left: 2px solid #000000\ +}\ +\ +.ace-solarized-light .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #000000\ +}\ +\ +.ace-solarized-light .ace_marker-layer .ace_selection {\ + background: #073642\ +}\ +\ +.ace-solarized-light.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #FDF6E3;\ + border-radius: 2px\ +}\ +\ +.ace-solarized-light .ace_marker-layer .ace_step {\ + background: rgb(255, 255, 0)\ +}\ +\ +.ace-solarized-light .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgba(147, 161, 161, 0.50)\ +}\ +\ +.ace-solarized-light .ace_marker-layer .ace_active_line {\ + background: #EEE8D5\ +}\ +\ +.ace-solarized-light .ace_gutter_active_line {\ + background-color : #dcdcdc\ +}\ +\ +.ace-solarized-light .ace_marker-layer .ace_selected_word {\ + border: 1px solid #073642\ +}\ +\ +.ace-solarized-light .ace_invisible {\ + color: rgba(147, 161, 161, 0.50)\ +}\ +\ +.ace-solarized-light .ace_keyword,\ +.ace-solarized-light .ace_meta,\ +.ace-solarized-light .ace_support.ace_class,\ +.ace-solarized-light .ace_support.ace_type {\ + color: #859900\ +}\ +\ +.ace-solarized-light .ace_constant.ace_character,\ +.ace-solarized-light .ace_constant.ace_other {\ + color: #CB4B16\ +}\ +\ +.ace-solarized-light .ace_constant.ace_language {\ + color: #B58900\ +}\ +\ +.ace-solarized-light .ace_constant.ace_numeric {\ + color: #D33682\ +}\ +\ +.ace-solarized-light .ace_fold {\ + background-color: #268BD2;\ + border-color: #586E75\ +}\ +\ +.ace-solarized-light .ace_entity.ace_name.ace_function,\ +.ace-solarized-light .ace_entity.ace_name.ace_tag,\ +.ace-solarized-light .ace_support.ace_function,\ +.ace-solarized-light .ace_variable,\ +.ace-solarized-light .ace_variable.ace_language {\ + color: #268BD2\ +}\ +\ +.ace-solarized-light .ace_storage {\ + color: #073642\ +}\ +\ +.ace-solarized-light .ace_string {\ + color: #2AA198\ +}\ +\ +.ace-solarized-light .ace_string.ace_regexp {\ + color: #D30102\ +}\ +\ +.ace-solarized-light .ace_comment,\ +.ace-solarized-light .ace_entity.ace_other.ace_attribute-name {\ + color: #93A1A1\ +}\ +\ +.ace-solarized-light .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-solarized-light .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4++3xf4ZVq1b9BwAjxwbT1g3hiwAAAABJRU5ErkJggg==) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-textmate.js b/vendor/assets/javascripts/ace-src-noconflict/theme-textmate.js new file mode 100644 index 00000000..97c0b183 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-textmate.js @@ -0,0 +1,207 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/textmate', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + + +exports.isDark = false; +exports.cssClass = "ace-tm"; +exports.cssText = ".ace-tm .ace_editor {\ + border: 2px solid rgb(159, 159, 159);\ +}\ +\ +.ace-tm .ace_editor.ace_focus {\ + border: 2px solid #327fbd;\ +}\ +\ +.ace-tm .ace_gutter {\ + background: #f0f0f0;\ + color: #333;\ +}\ +\ +.ace-tm .ace_print_margin {\ + width: 1px;\ + background: #e8e8e8;\ +}\ +\ +.ace-tm .ace_fold {\ + background-color: #6B72E6;\ +}\ +\ +.ace-tm .ace_scroller {\ + background-color: #FFFFFF;\ +}\ +\ +.ace-tm .ace_cursor {\ + border-left: 2px solid black;\ +}\ +\ +.ace-tm .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid black;\ +}\ + \ +.ace-tm .ace_line .ace_invisible {\ + color: rgb(191, 191, 191);\ +}\ +\ +.ace-tm .ace_line .ace_storage,\ +.ace-tm .ace_line .ace_keyword {\ + color: blue;\ +}\ +\ +.ace-tm .ace_line .ace_constant {\ + color: rgb(197, 6, 11);\ +}\ +\ +.ace-tm .ace_line .ace_constant.ace_buildin {\ + color: rgb(88, 72, 246);\ +}\ +\ +.ace-tm .ace_line .ace_constant.ace_language {\ + color: rgb(88, 92, 246);\ +}\ +\ +.ace-tm .ace_line .ace_constant.ace_library {\ + color: rgb(6, 150, 14);\ +}\ +\ +.ace-tm .ace_line .ace_invalid {\ + background-color: rgba(255, 0, 0, 0.1);\ + color: red;\ +}\ +\ +.ace-tm .ace_line .ace_support.ace_function {\ + color: rgb(60, 76, 114);\ +}\ +\ +.ace-tm .ace_line .ace_support.ace_constant {\ + color: rgb(6, 150, 14);\ +}\ +\ +.ace-tm .ace_line .ace_support.ace_type,\ +.ace-tm .ace_line .ace_support.ace_class {\ + color: rgb(109, 121, 222);\ +}\ +\ +.ace-tm .ace_line .ace_keyword.ace_operator {\ + color: rgb(104, 118, 135);\ +}\ +\ +.ace-tm .ace_line .ace_string {\ + color: rgb(3, 106, 7);\ +}\ +\ +.ace-tm .ace_line .ace_comment {\ + color: rgb(76, 136, 107);\ +}\ +\ +.ace-tm .ace_line .ace_comment.ace_doc {\ + color: rgb(0, 102, 255);\ +}\ +\ +.ace-tm .ace_line .ace_comment.ace_doc.ace_tag {\ + color: rgb(128, 159, 191);\ +}\ +\ +.ace-tm .ace_line .ace_constant.ace_numeric {\ + color: rgb(0, 0, 205);\ +}\ +\ +.ace-tm .ace_line .ace_variable {\ + color: rgb(49, 132, 149);\ +}\ +\ +.ace-tm .ace_line .ace_xml_pe {\ + color: rgb(104, 104, 91);\ +}\ +\ +.ace-tm .ace_entity.ace_name.ace_function {\ + color: #0000A2;\ +}\ +\ +\ +.ace-tm .ace_markup.ace_heading {\ + color: rgb(12, 7, 255);\ +}\ +\ +.ace-tm .ace_markup.ace_list {\ + color:rgb(185, 6, 144);\ +}\ +\ +.ace-tm .ace_meta.ace_tag {\ + color:rgb(0, 22, 142);\ +}\ +\ +.ace-tm .ace_string.ace_regex {\ + color: rgb(255, 0, 0)\ +}\ +\ +.ace-tm .ace_marker-layer .ace_selection {\ + background: rgb(181, 213, 255);\ +}\ +.ace-tm.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px white;\ + border-radius: 2px;\ +}\ +.ace-tm .ace_marker-layer .ace_step {\ + background: rgb(252, 255, 0);\ +}\ +\ +.ace-tm .ace_marker-layer .ace_stack {\ + background: rgb(164, 229, 101);\ +}\ +\ +.ace-tm .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgb(192, 192, 192);\ +}\ +\ +.ace-tm .ace_marker-layer .ace_active_line {\ + background: rgba(0, 0, 0, 0.07);\ +}\ +\ +.ace-tm .ace_gutter_active_line {\ + background-color : #dcdcdc;\ +}\ +\ +.ace-tm .ace_marker-layer .ace_selected_word {\ + background: rgb(250, 250, 255);\ + border: 1px solid rgb(200, 200, 250);\ +}\ +\ +.ace-tm .ace_indent-guide {\ + background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\ +}\ +"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow.js b/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow.js new file mode 100644 index 00000000..f7e24444 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow.js @@ -0,0 +1,182 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/tomorrow', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = false; +exports.cssClass = "ace-tomorrow"; +exports.cssText = ".ace-tomorrow .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-tomorrow .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-tomorrow .ace_gutter {\ + background: #f6f6f6;\ + color: #4D4D4C\ +}\ +\ +.ace-tomorrow .ace_print_margin {\ + width: 1px;\ + background: #f6f6f6\ +}\ +\ +.ace-tomorrow .ace_scroller {\ + background-color: #FFFFFF\ +}\ +\ +.ace-tomorrow .ace_text-layer {\ + color: #4D4D4C\ +}\ +\ +.ace-tomorrow .ace_cursor {\ + border-left: 2px solid #AEAFAD\ +}\ +\ +.ace-tomorrow .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #AEAFAD\ +}\ +\ +.ace-tomorrow .ace_marker-layer .ace_selection {\ + background: #D6D6D6\ +}\ +\ +.ace-tomorrow.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #FFFFFF;\ + border-radius: 2px\ +}\ +\ +.ace-tomorrow .ace_marker-layer .ace_step {\ + background: rgb(255, 255, 0)\ +}\ +\ +.ace-tomorrow .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid #D1D1D1\ +}\ +\ +.ace-tomorrow .ace_marker-layer .ace_active_line {\ + background: #EFEFEF\ +}\ +\ +.ace-tomorrow .ace_gutter_active_line {\ + background-color : #dcdcdc\ +}\ +\ +.ace-tomorrow .ace_marker-layer .ace_selected_word {\ + border: 1px solid #D6D6D6\ +}\ +\ +.ace-tomorrow .ace_invisible {\ + color: #D1D1D1\ +}\ +\ +.ace-tomorrow .ace_keyword,\ +.ace-tomorrow .ace_meta,\ +.ace-tomorrow .ace_storage,\ +.ace-tomorrow .ace_storage.ace_type,\ +.ace-tomorrow .ace_support.ace_type {\ + color: #8959A8\ +}\ +\ +.ace-tomorrow .ace_keyword.ace_operator {\ + color: #3E999F\ +}\ +\ +.ace-tomorrow .ace_constant.ace_character,\ +.ace-tomorrow .ace_constant.ace_language,\ +.ace-tomorrow .ace_constant.ace_numeric,\ +.ace-tomorrow .ace_keyword.ace_other.ace_unit,\ +.ace-tomorrow .ace_support.ace_constant,\ +.ace-tomorrow .ace_variable.ace_parameter {\ + color: #F5871F\ +}\ +\ +.ace-tomorrow .ace_constant.ace_other {\ + color: #666969\ +}\ +\ +.ace-tomorrow .ace_invalid {\ + color: #FFFFFF;\ + background-color: #C82829\ +}\ +\ +.ace-tomorrow .ace_invalid.ace_deprecated {\ + color: #FFFFFF;\ + background-color: #8959A8\ +}\ +\ +.ace-tomorrow .ace_fold {\ + background-color: #4271AE;\ + border-color: #4D4D4C\ +}\ +\ +.ace-tomorrow .ace_entity.ace_name.ace_function,\ +.ace-tomorrow .ace_support.ace_function,\ +.ace-tomorrow .ace_variable {\ + color: #4271AE\ +}\ +\ +.ace-tomorrow .ace_support.ace_class,\ +.ace-tomorrow .ace_support.ace_type {\ + color: #C99E00\ +}\ +\ +.ace-tomorrow .ace_markup.ace_heading,\ +.ace-tomorrow .ace_string {\ + color: #718C00\ +}\ +\ +.ace-tomorrow .ace_entity.ace_name.ace_tag,\ +.ace-tomorrow .ace_entity.ace_other.ace_attribute-name,\ +.ace-tomorrow .ace_meta.ace_tag,\ +.ace-tomorrow .ace_string.ace_regexp,\ +.ace-tomorrow .ace_variable {\ + color: #C82829\ +}\ +\ +.ace-tomorrow .ace_comment {\ + color: #8E908C\ +}\ +\ +.ace-tomorrow .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-tomorrow .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bdu3f/BwAlfgctduB85QAAAABJRU5ErkJggg==) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night.js b/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night.js new file mode 100644 index 00000000..9e65098d --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night.js @@ -0,0 +1,182 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/tomorrow_night', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-tomorrow-night"; +exports.cssText = ".ace-tomorrow-night .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-tomorrow-night .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-tomorrow-night .ace_gutter {\ + background: #25282c;\ + color: #C5C8C6\ +}\ +\ +.ace-tomorrow-night .ace_print_margin {\ + width: 1px;\ + background: #25282c\ +}\ +\ +.ace-tomorrow-night .ace_scroller {\ + background-color: #1D1F21\ +}\ +\ +.ace-tomorrow-night .ace_text-layer {\ + color: #C5C8C6\ +}\ +\ +.ace-tomorrow-night .ace_cursor {\ + border-left: 2px solid #AEAFAD\ +}\ +\ +.ace-tomorrow-night .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #AEAFAD\ +}\ +\ +.ace-tomorrow-night .ace_marker-layer .ace_selection {\ + background: #373B41\ +}\ +\ +.ace-tomorrow-night.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #1D1F21;\ + border-radius: 2px\ +}\ +\ +.ace-tomorrow-night .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-tomorrow-night .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid #4B4E55\ +}\ +\ +.ace-tomorrow-night .ace_marker-layer .ace_active_line {\ + background: #282A2E\ +}\ +\ +.ace-tomorrow-night .ace_gutter_active_line {\ + background-color: #282A2E\ +}\ +\ +.ace-tomorrow-night .ace_marker-layer .ace_selected_word {\ + border: 1px solid #373B41\ +}\ +\ +.ace-tomorrow-night .ace_invisible {\ + color: #4B4E55\ +}\ +\ +.ace-tomorrow-night .ace_keyword,\ +.ace-tomorrow-night .ace_meta,\ +.ace-tomorrow-night .ace_storage,\ +.ace-tomorrow-night .ace_storage.ace_type,\ +.ace-tomorrow-night .ace_support.ace_type {\ + color: #B294BB\ +}\ +\ +.ace-tomorrow-night .ace_keyword.ace_operator {\ + color: #8ABEB7\ +}\ +\ +.ace-tomorrow-night .ace_constant.ace_character,\ +.ace-tomorrow-night .ace_constant.ace_language,\ +.ace-tomorrow-night .ace_constant.ace_numeric,\ +.ace-tomorrow-night .ace_keyword.ace_other.ace_unit,\ +.ace-tomorrow-night .ace_support.ace_constant,\ +.ace-tomorrow-night .ace_variable.ace_parameter {\ + color: #DE935F\ +}\ +\ +.ace-tomorrow-night .ace_constant.ace_other {\ + color: #CED1CF\ +}\ +\ +.ace-tomorrow-night .ace_invalid {\ + color: #CED2CF;\ + background-color: #DF5F5F\ +}\ +\ +.ace-tomorrow-night .ace_invalid.ace_deprecated {\ + color: #CED2CF;\ + background-color: #B798BF\ +}\ +\ +.ace-tomorrow-night .ace_fold {\ + background-color: #81A2BE;\ + border-color: #C5C8C6\ +}\ +\ +.ace-tomorrow-night .ace_entity.ace_name.ace_function,\ +.ace-tomorrow-night .ace_support.ace_function,\ +.ace-tomorrow-night .ace_variable {\ + color: #81A2BE\ +}\ +\ +.ace-tomorrow-night .ace_support.ace_class,\ +.ace-tomorrow-night .ace_support.ace_type {\ + color: #F0C674\ +}\ +\ +.ace-tomorrow-night .ace_markup.ace_heading,\ +.ace-tomorrow-night .ace_string {\ + color: #B5BD68\ +}\ +\ +.ace-tomorrow-night .ace_entity.ace_name.ace_tag,\ +.ace-tomorrow-night .ace_entity.ace_other.ace_attribute-name,\ +.ace-tomorrow-night .ace_meta.ace_tag,\ +.ace-tomorrow-night .ace_string.ace_regexp,\ +.ace-tomorrow-night .ace_variable {\ + color: #CC6666\ +}\ +\ +.ace-tomorrow-night .ace_comment {\ + color: #969896\ +}\ +\ +.ace-tomorrow-night .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-tomorrow-night .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWOQlVf8z7Bq1ar/AA/hBFp7egmpAAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_blue.js b/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_blue.js new file mode 100644 index 00000000..19d8c3b5 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_blue.js @@ -0,0 +1,179 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/tomorrow_night_blue', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-tomorrow-night-blue"; +exports.cssText = ".ace-tomorrow-night-blue .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-tomorrow-night-blue .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-tomorrow-night-blue .ace_gutter {\ + background: #00204b;\ + color: #7388b5\ +}\ +\ +.ace-tomorrow-night-blue .ace_print_margin {\ + width: 1px;\ + background: #00204b\ +}\ +\ +.ace-tomorrow-night-blue .ace_scroller {\ + background-color: #002451\ +}\ +\ +.ace-tomorrow-night-blue .ace_constant.ace_other,\ +.ace-tomorrow-night-blue .ace_text-layer {\ + color: #FFFFFF\ +}\ +\ +.ace-tomorrow-night-blue .ace_cursor {\ + border-left: 2px solid #FFFFFF\ +}\ +\ +.ace-tomorrow-night-blue .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #FFFFFF\ +}\ +\ +.ace-tomorrow-night-blue .ace_marker-layer .ace_selection {\ + background: #003F8E\ +}\ +\ +.ace-tomorrow-night-blue.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #002451;\ + border-radius: 2px\ +}\ +\ +.ace-tomorrow-night-blue .ace_marker-layer .ace_step {\ + background: rgb(127, 111, 19)\ +}\ +\ +.ace-tomorrow-night-blue .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid #404F7D\ +}\ +\ +.ace-tomorrow-night-blue .ace_marker-layer .ace_active_line {\ + background: #00346E\ +}\ +\ +.ace-tomorrow-night-blue .ace_gutter_active_line {\ + background-color: #022040\ +}\ +\ +.ace-tomorrow-night-blue .ace_marker-layer .ace_selected_word {\ + border: 1px solid #003F8E\ +}\ +\ +.ace-tomorrow-night-blue .ace_invisible {\ + color: #404F7D\ +}\ +\ +.ace-tomorrow-night-blue .ace_keyword,\ +.ace-tomorrow-night-blue .ace_meta,\ +.ace-tomorrow-night-blue .ace_storage,\ +.ace-tomorrow-night-blue .ace_storage.ace_type,\ +.ace-tomorrow-night-blue .ace_support.ace_type {\ + color: #EBBBFF\ +}\ +\ +.ace-tomorrow-night-blue .ace_keyword.ace_operator {\ + color: #99FFFF\ +}\ +\ +.ace-tomorrow-night-blue .ace_constant.ace_character,\ +.ace-tomorrow-night-blue .ace_constant.ace_language,\ +.ace-tomorrow-night-blue .ace_constant.ace_numeric,\ +.ace-tomorrow-night-blue .ace_keyword.ace_other.ace_unit,\ +.ace-tomorrow-night-blue .ace_support.ace_constant,\ +.ace-tomorrow-night-blue .ace_variable.ace_parameter {\ + color: #FFC58F\ +}\ +\ +.ace-tomorrow-night-blue .ace_invalid {\ + color: #FFFFFF;\ + background-color: #F99DA5\ +}\ +\ +.ace-tomorrow-night-blue .ace_invalid.ace_deprecated {\ + color: #FFFFFF;\ + background-color: #EBBBFF\ +}\ +\ +.ace-tomorrow-night-blue .ace_fold {\ + background-color: #BBDAFF;\ + border-color: #FFFFFF\ +}\ +\ +.ace-tomorrow-night-blue .ace_entity.ace_name.ace_function,\ +.ace-tomorrow-night-blue .ace_support.ace_function,\ +.ace-tomorrow-night-blue .ace_variable {\ + color: #BBDAFF\ +}\ +\ +.ace-tomorrow-night-blue .ace_support.ace_class,\ +.ace-tomorrow-night-blue .ace_support.ace_type {\ + color: #FFEEAD\ +}\ +\ +.ace-tomorrow-night-blue .ace_markup.ace_heading,\ +.ace-tomorrow-night-blue .ace_string {\ + color: #D1F1A9\ +}\ +\ +.ace-tomorrow-night-blue .ace_entity.ace_name.ace_tag,\ +.ace-tomorrow-night-blue .ace_entity.ace_other.ace_attribute-name,\ +.ace-tomorrow-night-blue .ace_meta.ace_tag,\ +.ace-tomorrow-night-blue .ace_string.ace_regexp,\ +.ace-tomorrow-night-blue .ace_variable {\ + color: #FF9DA4\ +}\ +\ +.ace-tomorrow-night-blue .ace_comment {\ + color: #7285B7\ +}\ +\ +.ace-tomorrow-night-blue .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-tomorrow-night-blue .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNgUAn8z7Bq1ar/ABBUBHJ4/r3JAAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_bright.js b/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_bright.js new file mode 100644 index 00000000..c5009ba7 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_bright.js @@ -0,0 +1,182 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/tomorrow_night_bright', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-tomorrow-night-bright"; +exports.cssText = ".ace-tomorrow-night-bright .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-tomorrow-night-bright .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-tomorrow-night-bright .ace_gutter {\ + background: #1a1a1a;\ + color: #DEDEDE\ +}\ +\ +.ace-tomorrow-night-bright .ace_print_margin {\ + width: 1px;\ + background: #1a1a1a\ +}\ +\ +.ace-tomorrow-night-bright .ace_scroller {\ + background-color: #000000\ +}\ +\ +.ace-tomorrow-night-bright .ace_text-layer {\ + color: #DEDEDE\ +}\ +\ +.ace-tomorrow-night-bright .ace_cursor {\ + border-left: 2px solid #9F9F9F\ +}\ +\ +.ace-tomorrow-night-bright .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #9F9F9F\ +}\ +\ +.ace-tomorrow-night-bright .ace_marker-layer .ace_selection {\ + background: #424242\ +}\ +\ +.ace-tomorrow-night-bright.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #000000;\ + border-radius: 2px\ +}\ +\ +.ace-tomorrow-night-bright .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-tomorrow-night-bright .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid #343434\ +}\ +\ +.ace-tomorrow-night-bright .ace_marker-layer .ace_active_line {\ + background: #2A2A2A\ +}\ +\ +.ace-tomorrow-night-bright .ace_gutter_active_line {\ + background-color: #2A2A2A\ +}\ +\ +.ace-tomorrow-night-bright .ace_marker-layer .ace_selected_word {\ + border: 1px solid #424242\ +}\ +\ +.ace-tomorrow-night-bright .ace_invisible {\ + color: #343434\ +}\ +\ +.ace-tomorrow-night-bright .ace_keyword,\ +.ace-tomorrow-night-bright .ace_meta,\ +.ace-tomorrow-night-bright .ace_storage,\ +.ace-tomorrow-night-bright .ace_storage.ace_type,\ +.ace-tomorrow-night-bright .ace_support.ace_type {\ + color: #C397D8\ +}\ +\ +.ace-tomorrow-night-bright .ace_keyword.ace_operator {\ + color: #70C0B1\ +}\ +\ +.ace-tomorrow-night-bright .ace_constant.ace_character,\ +.ace-tomorrow-night-bright .ace_constant.ace_language,\ +.ace-tomorrow-night-bright .ace_constant.ace_numeric,\ +.ace-tomorrow-night-bright .ace_keyword.ace_other.ace_unit,\ +.ace-tomorrow-night-bright .ace_support.ace_constant,\ +.ace-tomorrow-night-bright .ace_variable.ace_parameter {\ + color: #E78C45\ +}\ +\ +.ace-tomorrow-night-bright .ace_constant.ace_other {\ + color: #EEEEEE\ +}\ +\ +.ace-tomorrow-night-bright .ace_invalid {\ + color: #CED2CF;\ + background-color: #DF5F5F\ +}\ +\ +.ace-tomorrow-night-bright .ace_invalid.ace_deprecated {\ + color: #CED2CF;\ + background-color: #B798BF\ +}\ +\ +.ace-tomorrow-night-bright .ace_fold {\ + background-color: #7AA6DA;\ + border-color: #DEDEDE\ +}\ +\ +.ace-tomorrow-night-bright .ace_entity.ace_name.ace_function,\ +.ace-tomorrow-night-bright .ace_support.ace_function,\ +.ace-tomorrow-night-bright .ace_variable {\ + color: #7AA6DA\ +}\ +\ +.ace-tomorrow-night-bright .ace_support.ace_class,\ +.ace-tomorrow-night-bright .ace_support.ace_type {\ + color: #E7C547\ +}\ +\ +.ace-tomorrow-night-bright .ace_markup.ace_heading,\ +.ace-tomorrow-night-bright .ace_string {\ + color: #B9CA4A\ +}\ +\ +.ace-tomorrow-night-bright .ace_entity.ace_name.ace_tag,\ +.ace-tomorrow-night-bright .ace_entity.ace_other.ace_attribute-name,\ +.ace-tomorrow-night-bright .ace_meta.ace_tag,\ +.ace-tomorrow-night-bright .ace_string.ace_regexp,\ +.ace-tomorrow-night-bright .ace_variable {\ + color: #D54E53\ +}\ +\ +.ace-tomorrow-night-bright .ace_comment {\ + color: #969896\ +}\ +\ +.ace-tomorrow-night-bright .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-tomorrow-night-bright .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWNgYGD4z7Bq1ar/AAz9A/2naJQKAAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_eighties.js b/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_eighties.js new file mode 100644 index 00000000..e68e3279 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_eighties.js @@ -0,0 +1,178 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/tomorrow_night_eighties', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-tomorrow-night-eighties"; +exports.cssText = ".ace-tomorrow-night-eighties .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-tomorrow-night-eighties .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-tomorrow-night-eighties .ace_gutter {\ + background: #272727;\ + color: #CCC\ +}\ +\ +.ace-tomorrow-night-eighties .ace_print_margin {\ + width: 1px;\ + background: #272727\ +}\ +\ +.ace-tomorrow-night-eighties .ace_scroller {\ + background-color: #2D2D2D\ +}\ +\ +.ace-tomorrow-night-eighties .ace_constant.ace_other,\ +.ace-tomorrow-night-eighties .ace_text-layer {\ + color: #CCCCCC\ +}\ +\ +.ace-tomorrow-night-eighties .ace_cursor {\ + border-left: 2px solid #CCCCCC\ +}\ +\ +.ace-tomorrow-night-eighties .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #CCCCCC\ +}\ +\ +.ace-tomorrow-night-eighties .ace_marker-layer .ace_selection {\ + background: #515151\ +}\ +\ +.ace-tomorrow-night-eighties.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #2D2D2D;\ + border-radius: 2px\ +}\ +\ +.ace-tomorrow-night-eighties .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-tomorrow-night-eighties .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid #6A6A6A\ +}\ +\ +.ace-tomorrow-night-eighties .ace_marker-layer .ace_active_line {\ + background: #393939\ +}\ +\ +.ace-tomorrow-night-eighties .ace_gutter_active_line {\ + background-color: #393939\ +}\ +\ +.ace-tomorrow-night-eighties .ace_marker-layer .ace_selected_word {\ + border: 1px solid #515151\ +}\ +\ +.ace-tomorrow-night-eighties .ace_invisible {\ + color: #6A6A6A\ +}\ +\ +.ace-tomorrow-night-eighties .ace_keyword,\ +.ace-tomorrow-night-eighties .ace_meta,\ +.ace-tomorrow-night-eighties .ace_storage,\ +.ace-tomorrow-night-eighties .ace_storage.ace_type,\ +.ace-tomorrow-night-eighties .ace_support.ace_type {\ + color: #CC99CC\ +}\ +\ +.ace-tomorrow-night-eighties .ace_keyword.ace_operator {\ + color: #66CCCC\ +}\ +\ +.ace-tomorrow-night-eighties .ace_constant.ace_character,\ +.ace-tomorrow-night-eighties .ace_constant.ace_language,\ +.ace-tomorrow-night-eighties .ace_constant.ace_numeric,\ +.ace-tomorrow-night-eighties .ace_keyword.ace_other.ace_unit,\ +.ace-tomorrow-night-eighties .ace_support.ace_constant,\ +.ace-tomorrow-night-eighties .ace_variable.ace_parameter {\ + color: #F99157\ +}\ +\ +.ace-tomorrow-night-eighties .ace_invalid {\ + color: #CDCDCD;\ + background-color: #F2777A\ +}\ +\ +.ace-tomorrow-night-eighties .ace_invalid.ace_deprecated {\ + color: #CDCDCD;\ + background-color: #CC99CC\ +}\ +\ +.ace-tomorrow-night-eighties .ace_fold {\ + background-color: #6699CC;\ + border-color: #CCCCCC\ +}\ +\ +.ace-tomorrow-night-eighties .ace_entity.ace_name.ace_function,\ +.ace-tomorrow-night-eighties .ace_support.ace_function,\ +.ace-tomorrow-night-eighties .ace_variable {\ + color: #6699CC\ +}\ +\ +.ace-tomorrow-night-eighties .ace_support.ace_class,\ +.ace-tomorrow-night-eighties .ace_support.ace_type {\ + color: #FFCC66\ +}\ +\ +.ace-tomorrow-night-eighties .ace_markup.ace_heading,\ +.ace-tomorrow-night-eighties .ace_string {\ + color: #99CC99\ +}\ +\ +.ace-tomorrow-night-eighties .ace_comment {\ + color: #999999\ +}\ +\ +.ace-tomorrow-night-eighties .ace_entity.ace_name.ace_tag,\ +.ace-tomorrow-night-eighties .ace_entity.ace_other.ace_attribute-name,\ +.ace-tomorrow-night-eighties .ace_meta.ace_tag,\ +.ace-tomorrow-night-eighties .ace_variable {\ + color: #F2777A\ +}\ +\ +.ace-tomorrow-night-eighties .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-tomorrow-night-eighties .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWPQ1dX9z7Bq1ar/ABE1BITwhhuFAAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-twilight.js b/vendor/assets/javascripts/ace-src-noconflict/theme-twilight.js new file mode 100644 index 00000000..925093bb --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-twilight.js @@ -0,0 +1,184 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/twilight', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-twilight"; +exports.cssText = ".ace-twilight .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-twilight .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-twilight .ace_gutter {\ + background: #232323;\ + color: #E2E2E2\ +}\ +\ +.ace-twilight .ace_print_margin {\ + width: 1px;\ + background: #232323\ +}\ +\ +.ace-twilight .ace_scroller {\ + background-color: #141414\ +}\ +\ +.ace-twilight .ace_text-layer {\ + color: #F8F8F8\ +}\ +\ +.ace-twilight .ace_cursor {\ + border-left: 2px solid #A7A7A7\ +}\ +\ +.ace-twilight .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #A7A7A7\ +}\ +\ +.ace-twilight .ace_marker-layer .ace_selection {\ + background: rgba(221, 240, 255, 0.20)\ +}\ +\ +.ace-twilight.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #141414;\ + border-radius: 2px\ +}\ +\ +.ace-twilight .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-twilight .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgba(255, 255, 255, 0.25)\ +}\ +\ +.ace-twilight .ace_marker-layer .ace_active_line {\ + background: rgba(255, 255, 255, 0.031)\ +}\ +\ +.ace-twilight .ace_gutter_active_line {\ + background-color: rgba(255, 255, 255, 0.031)\ +}\ +\ +.ace-twilight .ace_marker-layer .ace_selected_word {\ + border: 1px solid rgba(221, 240, 255, 0.20)\ +}\ +\ +.ace-twilight .ace_invisible {\ + color: rgba(255, 255, 255, 0.25)\ +}\ +\ +.ace-twilight .ace_keyword,\ +.ace-twilight .ace_meta {\ + color: #CDA869\ +}\ +\ +.ace-twilight .ace_constant,\ +.ace-twilight .ace_constant.ace_character,\ +.ace-twilight .ace_constant.ace_character.ace_escape,\ +.ace-twilight .ace_constant.ace_other,\ +.ace-twilight .ace_markup.ace_heading,\ +.ace-twilight .ace_support.ace_constant {\ + color: #CF6A4C\ +}\ +\ +.ace-twilight .ace_invalid.ace_illegal {\ + color: #F8F8F8;\ + background-color: rgba(86, 45, 86, 0.75)\ +}\ +\ +.ace-twilight .ace_invalid.ace_deprecated {\ + text-decoration: underline;\ + font-style: italic;\ + color: #D2A8A1\ +}\ +\ +.ace-twilight .ace_support {\ + color: #9B859D\ +}\ +\ +.ace-twilight .ace_fold {\ + background-color: #AC885B;\ + border-color: #F8F8F8\ +}\ +\ +.ace-twilight .ace_support.ace_function {\ + color: #DAD085\ +}\ +\ +.ace-twilight .ace_markup.ace_list,\ +.ace-twilight .ace_storage {\ + color: #F9EE98\ +}\ +\ +.ace-twilight .ace_entity.ace_name.ace_function,\ +.ace-twilight .ace_meta.ace_tag,\ +.ace-twilight .ace_variable {\ + color: #AC885B\ +}\ +\ +.ace-twilight .ace_string {\ + color: #8F9D6A\ +}\ +\ +.ace-twilight .ace_string.ace_regexp {\ + color: #E9C062\ +}\ +\ +.ace-twilight .ace_comment {\ + font-style: italic;\ + color: #5F5A60\ +}\ +\ +.ace-twilight .ace_variable {\ + color: #7587A6\ +}\ +\ +.ace-twilight .ace_xml_pe {\ + color: #494949\ +}\ +\ +.ace-twilight .ace_markup.ace_underline {\ + text-decoration: underline\ +}\ +\ +.ace-twilight .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWMQERH5zzBz5sz/AA5EBAYqeZXWAAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-vibrant_ink.js b/vendor/assets/javascripts/ace-src-noconflict/theme-vibrant_ink.js new file mode 100644 index 00000000..097810cd --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-vibrant_ink.js @@ -0,0 +1,164 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/vibrant_ink', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = true; +exports.cssClass = "ace-vibrant-ink"; +exports.cssText = ".ace-vibrant-ink .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-vibrant-ink .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-vibrant-ink .ace_gutter {\ + background: #1a1a1a;\ + color: #BEBEBE\ +}\ +\ +.ace-vibrant-ink .ace_print_margin {\ + width: 1px;\ + background: #1a1a1a\ +}\ +\ +.ace-vibrant-ink .ace_scroller {\ + background-color: #0F0F0F\ +}\ +\ +.ace-vibrant-ink .ace_text-layer {\ + color: #FFFFFF\ +}\ +\ +.ace-vibrant-ink .ace_cursor {\ + border-left: 2px solid #FFFFFF\ +}\ +\ +.ace-vibrant-ink .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #FFFFFF\ +}\ +\ +.ace-vibrant-ink .ace_marker-layer .ace_selection {\ + background: #6699CC\ +}\ +\ +.ace-vibrant-ink.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #0F0F0F;\ + border-radius: 2px\ +}\ +\ +.ace-vibrant-ink .ace_marker-layer .ace_step {\ + background: rgb(102, 82, 0)\ +}\ +\ +.ace-vibrant-ink .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid #404040\ +}\ +\ +.ace-vibrant-ink .ace_marker-layer .ace_active_line {\ + background: #333333\ +}\ +\ +.ace-vibrant-ink .ace_gutter_active_line {\ + background-color: #333333\ +}\ +\ +.ace-vibrant-ink .ace_marker-layer .ace_selected_word {\ + border: 1px solid #6699CC\ +}\ +\ +.ace-vibrant-ink .ace_invisible {\ + color: #404040\ +}\ +\ +.ace-vibrant-ink .ace_keyword,\ +.ace-vibrant-ink .ace_meta {\ + color: #FF6600\ +}\ +\ +.ace-vibrant-ink .ace_constant,\ +.ace-vibrant-ink .ace_constant.ace_character,\ +.ace-vibrant-ink .ace_constant.ace_character.ace_escape,\ +.ace-vibrant-ink .ace_constant.ace_other {\ + color: #339999\ +}\ +\ +.ace-vibrant-ink .ace_constant.ace_numeric {\ + color: #99CC99\ +}\ +\ +.ace-vibrant-ink .ace_invalid,\ +.ace-vibrant-ink .ace_invalid.ace_deprecated {\ + color: #CCFF33;\ + background-color: #000000\ +}\ +\ +.ace-vibrant-ink .ace_fold {\ + background-color: #FFCC00;\ + border-color: #FFFFFF\ +}\ +\ +.ace-vibrant-ink .ace_entity.ace_name.ace_function,\ +.ace-vibrant-ink .ace_support.ace_function,\ +.ace-vibrant-ink .ace_variable {\ + color: #FFCC00\ +}\ +\ +.ace-vibrant-ink .ace_variable.ace_parameter {\ + font-style: italic\ +}\ +\ +.ace-vibrant-ink .ace_string {\ + color: #66FF00\ +}\ +\ +.ace-vibrant-ink .ace_string.ace_regexp {\ + color: #44B4CC\ +}\ +\ +.ace-vibrant-ink .ace_comment {\ + color: #9933CC\ +}\ +\ +.ace-vibrant-ink .ace_entity.ace_other.ace_attribute-name {\ + font-style: italic;\ + color: #99CC99\ +}\ +\ +.ace-vibrant-ink .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWPg5+f/z7Bq1ar/AA5lBCqoLxsgAAAAAElFTkSuQmCC) right repeat-y\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/theme-xcode.js b/vendor/assets/javascripts/ace-src-noconflict/theme-xcode.js new file mode 100644 index 00000000..7c040fa2 --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/theme-xcode.js @@ -0,0 +1,156 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * 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 Ajax.org B.V. 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 AJAX.ORG B.V. 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. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/theme/xcode', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { + +exports.isDark = false; +exports.cssClass = "ace-xcode"; +exports.cssText = "/* THIS THEME WAS AUTOGENERATED BY Theme.tmpl.css (UUID: EE3AD170-2B7F-4DE1-B724-C75F13FE0085) */\ +.ace-xcode .ace_editor {\ + border: 2px solid rgb(159, 159, 159)\ +}\ +\ +.ace-xcode .ace_editor.ace_focus {\ + border: 2px solid #327fbd\ +}\ +\ +.ace-xcode .ace_gutter {\ + background: #e8e8e8;\ + color: #333\ +}\ +\ +.ace-xcode .ace_print_margin {\ + width: 1px;\ + background: #e8e8e8\ +}\ +\ +.ace-xcode .ace_scroller {\ + background-color: #FFFFFF\ +}\ +\ +.ace-xcode .ace_text-layer {\ + color: #000000\ +}\ +\ +.ace-xcode .ace_cursor {\ + border-left: 2px solid #000000\ +}\ +\ +.ace-xcode .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid #000000\ +}\ +\ +.ace-xcode .ace_marker-layer .ace_selection {\ + background: #B5D5FF\ +}\ +\ +.ace-xcode.multiselect .ace_selection.start {\ + box-shadow: 0 0 3px 0px #FFFFFF;\ + border-radius: 2px\ +}\ +\ +.ace-xcode .ace_marker-layer .ace_step {\ + background: rgb(198, 219, 174)\ +}\ +\ +.ace-xcode .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid #BFBFBF\ +}\ +\ +.ace-xcode .ace_marker-layer .ace_active_line {\ + background: rgba(0, 0, 0, 0.071)\ +}\ +\ +.ace-xcode .ace_gutter_active_line {\ + background-color: rgba(0, 0, 0, 0.071)\ +}\ +\ +.ace-xcode .ace_marker-layer .ace_selected_word {\ + border: 1px solid #B5D5FF\ +}\ +\ +.ace-xcode .ace_constant.ace_language,\ +.ace-xcode .ace_keyword,\ +.ace-xcode .ace_meta,\ +.ace-xcode .ace_variable.ace_language {\ + color: #C800A4\ +}\ +\ +.ace-xcode .ace_invisible {\ + color: #BFBFBF\ +}\ +\ +.ace-xcode .ace_constant.ace_character,\ +.ace-xcode .ace_constant.ace_other {\ + color: #275A5E\ +}\ +\ +.ace-xcode .ace_constant.ace_numeric {\ + color: #3A00DC\ +}\ +\ +.ace-xcode .ace_entity.ace_other.ace_attribute-name,\ +.ace-xcode .ace_support.ace_constant,\ +.ace-xcode .ace_support.ace_function {\ + color: #450084\ +}\ +\ +.ace-xcode .ace_fold {\ + background-color: #C800A4;\ + border-color: #000000\ +}\ +\ +.ace-xcode .ace_entity.ace_name.ace_tag,\ +.ace-xcode .ace_support.ace_class,\ +.ace-xcode .ace_support.ace_type {\ + color: #790EAD\ +}\ +\ +.ace-xcode .ace_storage {\ + color: #C900A4\ +}\ +\ +.ace-xcode .ace_string {\ + color: #DF0002\ +}\ +\ +.ace-xcode .ace_comment {\ + color: #008E00\ +}\ +\ +.ace-xcode .ace_indent-guide {\ + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==) right repeat-y;\ +}"; + +var dom = require("../lib/dom"); +dom.importCssString(exports.cssText, exports.cssClass); +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/worker-coffee.js b/vendor/assets/javascripts/ace-src-noconflict/worker-coffee.js new file mode 100644 index 00000000..3a7bf80f --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/worker-coffee.js @@ -0,0 +1,7213 @@ +"no use strict"; + +var console = { + log: function(msgs) { + postMessage({type: "log", data: arguments.join(" ")}); + } +}; +var window = { + console: console +}; + +var normalizeModule = function(parentId, moduleName) { + // normalize plugin requires + if (moduleName.indexOf("!") !== -1) { + var chunks = moduleName.split("!"); + return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]); + } + // normalize relative requires + if (moduleName.charAt(0) == ".") { + var base = parentId.split("/").slice(0, -1).join("/"); + var moduleName = base + "/" + moduleName; + + while(moduleName.indexOf(".") !== -1 && previous != moduleName) { + var previous = moduleName; + var moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); + } + } + + return moduleName; +}; + +var require = function(parentId, id) { + if (!id.charAt) + throw new Error("worker.js require() accepts only (parentId, id) as arguments"); + + var id = normalizeModule(parentId, id); + + var module = require.modules[id]; + if (module) { + if (!module.initialized) { + module.initialized = true; + module.exports = module.factory().exports; + } + return module.exports; + } + + var chunks = id.split("/"); + chunks[0] = require.tlns[chunks[0]] || chunks[0]; + var path = chunks.join("/") + ".js"; + + require.id = id; + importScripts(path); + return require(parentId, id); +}; + +require.modules = {}; +require.tlns = {}; + +var define = function(id, deps, factory) { + if (arguments.length == 2) { + factory = deps; + if (typeof id != "string") { + deps = id; + id = require.id; + } + } else if (arguments.length == 1) { + factory = id; + id = require.id; + } + + if (id.indexOf("text!") === 0) + return; + + var req = function(deps, factory) { + return require(id, deps, factory); + }; + + require.modules[id] = { + factory: function() { + var module = { + exports: {} + }; + var returnExports = factory(req, module.exports, module); + if (returnExports) + module.exports = returnExports; + return module; + } + }; +}; + +function initBaseUrls(topLevelNamespaces) { + require.tlns = topLevelNamespaces; +} + +function initSender() { + + var EventEmitter = require(null, "ace/lib/event_emitter").EventEmitter; + var oop = require(null, "ace/lib/oop"); + + var Sender = function() {}; + + (function() { + + oop.implement(this, EventEmitter); + + this.callback = function(data, callbackId) { + postMessage({ + type: "call", + id: callbackId, + data: data + }); + }; + + this.emit = function(name, data) { + postMessage({ + type: "event", + name: name, + data: data + }); + }; + + }).call(Sender.prototype); + + return new Sender(); +} + +var main; +var sender; + +onmessage = function(e) { + var msg = e.data; + if (msg.command) { + main[msg.command].apply(main, msg.args); + } + else if (msg.init) { + initBaseUrls(msg.tlns); + require(null, "ace/lib/fixoldbrowsers"); + sender = initSender(); + var clazz = require(null, msg.module)[msg.classname]; + main = new clazz(sender); + } + else if (msg.event && sender) { + sender._emit(msg.event, msg.data); + } +}; +// vim:set ts=4 sts=4 sw=4 st: +// -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License +// -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project) +// -- dantman Daniel Friesen Copyright(C) 2010 XXX No License Specified +// -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License +// -- Irakli Gozalishvili Copyright (C) 2010 MIT License + +/*! + Copyright (c) 2009, 280 North Inc. http://280north.com/ + MIT License. http://github.com/280north/narwhal/blob/master/README.md +*/ + +define('ace/lib/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/regexp', 'ace/lib/es5-shim'], function(require, exports, module) { + + +require("./regexp"); +require("./es5-shim"); + +}); + +define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, exports, module) { + + + //--------------------------------- + // Private variables + //--------------------------------- + + var real = { + exec: RegExp.prototype.exec, + test: RegExp.prototype.test, + match: String.prototype.match, + replace: String.prototype.replace, + split: String.prototype.split + }, + compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups + compliantLastIndexIncrement = function () { + var x = /^/g; + real.test.call(x, ""); + return !x.lastIndex; + }(); + + if (compliantLastIndexIncrement && compliantExecNpcg) + return; + + //--------------------------------- + // Overriden native methods + //--------------------------------- + + // Adds named capture support (with backreferences returned as `result.name`), and fixes two + // cross-browser issues per ES3: + // - Captured values for nonparticipating capturing groups should be returned as `undefined`, + // rather than the empty string. + // - `lastIndex` should not be incremented after zero-length matches. + RegExp.prototype.exec = function (str) { + var match = real.exec.apply(this, arguments), + name, r2; + if ( typeof(str) == 'string' && match) { + // Fix browsers whose `exec` methods don't consistently return `undefined` for + // nonparticipating capturing groups + if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) { + r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", "")); + // Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed + // matching due to characters outside the match + real.replace.call(str.slice(match.index), r2, function () { + for (var i = 1; i < arguments.length - 2; i++) { + if (arguments[i] === undefined) + match[i] = undefined; + } + }); + } + // Attach named capture properties + if (this._xregexp && this._xregexp.captureNames) { + for (var i = 1; i < match.length; i++) { + name = this._xregexp.captureNames[i - 1]; + if (name) + match[name] = match[i]; + } + } + // Fix browsers that increment `lastIndex` after zero-length matches + if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index)) + this.lastIndex--; + } + return match; + }; + + // Don't override `test` if it won't change anything + if (!compliantLastIndexIncrement) { + // Fix browser bug in native method + RegExp.prototype.test = function (str) { + // Use the native `exec` to skip some processing overhead, even though the overriden + // `exec` would take care of the `lastIndex` fix + var match = real.exec.call(this, str); + // Fix browsers that increment `lastIndex` after zero-length matches + if (match && this.global && !match[0].length && (this.lastIndex > match.index)) + this.lastIndex--; + return !!match; + }; + } + + //--------------------------------- + // Private helper functions + //--------------------------------- + + function getNativeFlags (regex) { + return (regex.global ? "g" : "") + + (regex.ignoreCase ? "i" : "") + + (regex.multiline ? "m" : "") + + (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3 + (regex.sticky ? "y" : ""); + } + + function indexOf (array, item, from) { + if (Array.prototype.indexOf) // Use the native array method if available + return array.indexOf(item, from); + for (var i = from || 0; i < array.length; i++) { + if (array[i] === item) + return i; + } + return -1; + } + +}); +// vim: ts=4 sts=4 sw=4 expandtab +// -- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License +// -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project) +// -- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA +// -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License +// -- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License +// -- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License +// -- kossnocorp Sasha Koss XXX TODO License or CLA +// -- bryanforbes Bryan Forbes XXX TODO License or CLA +// -- killdream Quildreen Motta Copyright (C) 2011 MIT Licence +// -- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD License +// -- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License +// -- bbqsrc Brendan Molloy (C) 2011 Creative Commons Zero (public domain) +// -- iwyg XXX TODO License or CLA +// -- DomenicDenicola Domenic Denicola Copyright (C) 2011 MIT License +// -- xavierm02 Montillet Xavier XXX TODO License or CLA +// -- Raynos Raynos XXX TODO License or CLA +// -- samsonjs Sami Samhuri Copyright (C) 2010 MIT License +// -- rwldrn Rick Waldron Copyright (C) 2011 MIT License +// -- lexer Alexey Zakharov XXX TODO License or CLA + +/*! + Copyright (c) 2009, 280 North Inc. http://280north.com/ + MIT License. http://github.com/280north/narwhal/blob/master/README.md +*/ + +define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) { + +/* + * Brings an environment as close to ECMAScript 5 compliance + * as is possible with the facilities of erstwhile engines. + * + * Annotated ES5: http://es5.github.com/ (specific links below) + * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf + * + * @module + */ + +/*whatsupdoc*/ + +// +// Function +// ======== +// + +// ES-5 15.3.4.5 +// http://es5.github.com/#x15.3.4.5 + +if (!Function.prototype.bind) { + Function.prototype.bind = function bind(that) { // .length is 1 + // 1. Let Target be the this value. + var target = this; + // 2. If IsCallable(Target) is false, throw a TypeError exception. + if (typeof target != "function") + throw new TypeError(); // TODO message + // 3. Let A be a new (possibly empty) internal list of all of the + // argument values provided after thisArg (arg1, arg2 etc), in order. + // XXX slicedArgs will stand in for "A" if used + var args = slice.call(arguments, 1); // for normal call + // 4. Let F be a new native ECMAScript object. + // 11. Set the [[Prototype]] internal property of F to the standard + // built-in Function prototype object as specified in 15.3.3.1. + // 12. Set the [[Call]] internal property of F as described in + // 15.3.4.5.1. + // 13. Set the [[Construct]] internal property of F as described in + // 15.3.4.5.2. + // 14. Set the [[HasInstance]] internal property of F as described in + // 15.3.4.5.3. + var bound = function () { + + if (this instanceof bound) { + // 15.3.4.5.2 [[Construct]] + // When the [[Construct]] internal method of a function object, + // F that was created using the bind function is called with a + // list of arguments ExtraArgs, the following steps are taken: + // 1. Let target be the value of F's [[TargetFunction]] + // internal property. + // 2. If target has no [[Construct]] internal method, a + // TypeError exception is thrown. + // 3. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Construct]] internal + // method of target providing args as the arguments. + + var F = function(){}; + F.prototype = target.prototype; + var self = new F; + + var result = target.apply( + self, + args.concat(slice.call(arguments)) + ); + if (result !== null && Object(result) === result) + return result; + return self; + + } else { + // 15.3.4.5.1 [[Call]] + // When the [[Call]] internal method of a function object, F, + // which was created using the bind function is called with a + // this value and a list of arguments ExtraArgs, the following + // steps are taken: + // 1. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 2. Let boundThis be the value of F's [[BoundThis]] internal + // property. + // 3. Let target be the value of F's [[TargetFunction]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Call]] internal method + // of target providing boundThis as the this value and + // providing args as the arguments. + + // equiv: target.call(this, ...boundArgs, ...args) + return target.apply( + that, + args.concat(slice.call(arguments)) + ); + + } + + }; + // XXX bound.length is never writable, so don't even try + // + // 15. If the [[Class]] internal property of Target is "Function", then + // a. Let L be the length property of Target minus the length of A. + // b. Set the length own property of F to either 0 or L, whichever is + // larger. + // 16. Else set the length own property of F to 0. + // 17. Set the attributes of the length own property of F to the values + // specified in 15.3.5.1. + + // TODO + // 18. Set the [[Extensible]] internal property of F to true. + + // TODO + // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3). + // 20. Call the [[DefineOwnProperty]] internal method of F with + // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]: + // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and + // false. + // 21. Call the [[DefineOwnProperty]] internal method of F with + // arguments "arguments", PropertyDescriptor {[[Get]]: thrower, + // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false}, + // and false. + + // TODO + // NOTE Function objects created using Function.prototype.bind do not + // have a prototype property or the [[Code]], [[FormalParameters]], and + // [[Scope]] internal properties. + // XXX can't delete prototype in pure-js. + + // 22. Return F. + return bound; + }; +} + +// Shortcut to an often accessed properties, in order to avoid multiple +// dereference that costs universally. +// _Please note: Shortcuts are defined after `Function.prototype.bind` as we +// us it in defining shortcuts. +var call = Function.prototype.call; +var prototypeOfArray = Array.prototype; +var prototypeOfObject = Object.prototype; +var slice = prototypeOfArray.slice; +var toString = call.bind(prototypeOfObject.toString); +var owns = call.bind(prototypeOfObject.hasOwnProperty); + +// If JS engine supports accessors creating shortcuts. +var defineGetter; +var defineSetter; +var lookupGetter; +var lookupSetter; +var supportsAccessors; +if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) { + defineGetter = call.bind(prototypeOfObject.__defineGetter__); + defineSetter = call.bind(prototypeOfObject.__defineSetter__); + lookupGetter = call.bind(prototypeOfObject.__lookupGetter__); + lookupSetter = call.bind(prototypeOfObject.__lookupSetter__); +} + +// +// Array +// ===== +// + +// ES5 15.4.3.2 +// http://es5.github.com/#x15.4.3.2 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray +if (!Array.isArray) { + Array.isArray = function isArray(obj) { + return toString(obj) == "[object Array]"; + }; +} + +// The IsCallable() check in the Array functions +// has been replaced with a strict check on the +// internal class of the object to trap cases where +// the provided function was actually a regular +// expression literal, which in V8 and +// JavaScriptCore is a typeof "function". Only in +// V8 are regular expression literals permitted as +// reduce parameters, so it is desirable in the +// general case for the shim to match the more +// strict and common behavior of rejecting regular +// expressions. + +// ES5 15.4.4.18 +// http://es5.github.com/#x15.4.4.18 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach +if (!Array.prototype.forEach) { + Array.prototype.forEach = function forEach(fun /*, thisp*/) { + var self = toObject(this), + thisp = arguments[1], + i = 0, + length = self.length >>> 0; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + while (i < length) { + if (i in self) { + // Invoke the callback function with call, passing arguments: + // context, property value, property key, thisArg object context + fun.call(thisp, self[i], i, self); + } + i++; + } + }; +} + +// ES5 15.4.4.19 +// http://es5.github.com/#x15.4.4.19 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map +if (!Array.prototype.map) { + Array.prototype.map = function map(fun /*, thisp*/) { + var self = toObject(this), + length = self.length >>> 0, + result = Array(length), + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + for (var i = 0; i < length; i++) { + if (i in self) + result[i] = fun.call(thisp, self[i], i, self); + } + return result; + }; +} + +// ES5 15.4.4.20 +// http://es5.github.com/#x15.4.4.20 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter +if (!Array.prototype.filter) { + Array.prototype.filter = function filter(fun /*, thisp */) { + var self = toObject(this), + length = self.length >>> 0, + result = [], + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + for (var i = 0; i < length; i++) { + if (i in self && fun.call(thisp, self[i], i, self)) + result.push(self[i]); + } + return result; + }; +} + +// ES5 15.4.4.16 +// http://es5.github.com/#x15.4.4.16 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every +if (!Array.prototype.every) { + Array.prototype.every = function every(fun /*, thisp */) { + var self = toObject(this), + length = self.length >>> 0, + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + for (var i = 0; i < length; i++) { + if (i in self && !fun.call(thisp, self[i], i, self)) + return false; + } + return true; + }; +} + +// ES5 15.4.4.17 +// http://es5.github.com/#x15.4.4.17 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some +if (!Array.prototype.some) { + Array.prototype.some = function some(fun /*, thisp */) { + var self = toObject(this), + length = self.length >>> 0, + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + for (var i = 0; i < length; i++) { + if (i in self && fun.call(thisp, self[i], i, self)) + return true; + } + return false; + }; +} + +// ES5 15.4.4.21 +// http://es5.github.com/#x15.4.4.21 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce +if (!Array.prototype.reduce) { + Array.prototype.reduce = function reduce(fun /*, initial*/) { + var self = toObject(this), + length = self.length >>> 0; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + // no value to return if no initial value and an empty array + if (!length && arguments.length == 1) + throw new TypeError(); // TODO message + + var i = 0; + var result; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i++]; + break; + } + + // if array contains no values, no initial value to return + if (++i >= length) + throw new TypeError(); // TODO message + } while (true); + } + + for (; i < length; i++) { + if (i in self) + result = fun.call(void 0, result, self[i], i, self); + } + + return result; + }; +} + +// ES5 15.4.4.22 +// http://es5.github.com/#x15.4.4.22 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight +if (!Array.prototype.reduceRight) { + Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) { + var self = toObject(this), + length = self.length >>> 0; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + // no value to return if no initial value, empty array + if (!length && arguments.length == 1) + throw new TypeError(); // TODO message + + var result, i = length - 1; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i--]; + break; + } + + // if array contains no values, no initial value to return + if (--i < 0) + throw new TypeError(); // TODO message + } while (true); + } + + do { + if (i in this) + result = fun.call(void 0, result, self[i], i, self); + } while (i--); + + return result; + }; +} + +// ES5 15.4.4.14 +// http://es5.github.com/#x15.4.4.14 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf +if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) { + var self = toObject(this), + length = self.length >>> 0; + + if (!length) + return -1; + + var i = 0; + if (arguments.length > 1) + i = toInteger(arguments[1]); + + // handle negative indices + i = i >= 0 ? i : Math.max(0, length + i); + for (; i < length; i++) { + if (i in self && self[i] === sought) { + return i; + } + } + return -1; + }; +} + +// ES5 15.4.4.15 +// http://es5.github.com/#x15.4.4.15 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf +if (!Array.prototype.lastIndexOf) { + Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) { + var self = toObject(this), + length = self.length >>> 0; + + if (!length) + return -1; + var i = length - 1; + if (arguments.length > 1) + i = Math.min(i, toInteger(arguments[1])); + // handle negative indices + i = i >= 0 ? i : length - Math.abs(i); + for (; i >= 0; i--) { + if (i in self && sought === self[i]) + return i; + } + return -1; + }; +} + +// +// Object +// ====== +// + +// ES5 15.2.3.2 +// http://es5.github.com/#x15.2.3.2 +if (!Object.getPrototypeOf) { + // https://github.com/kriskowal/es5-shim/issues#issue/2 + // http://ejohn.org/blog/objectgetprototypeof/ + // recommended by fschaefer on github + Object.getPrototypeOf = function getPrototypeOf(object) { + return object.__proto__ || ( + object.constructor ? + object.constructor.prototype : + prototypeOfObject + ); + }; +} + +// ES5 15.2.3.3 +// http://es5.github.com/#x15.2.3.3 +if (!Object.getOwnPropertyDescriptor) { + var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " + + "non-object: "; + Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) { + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError(ERR_NON_OBJECT + object); + // If object does not owns property return undefined immediately. + if (!owns(object, property)) + return; + + var descriptor, getter, setter; + + // If object has a property then it's for sure both `enumerable` and + // `configurable`. + descriptor = { enumerable: true, configurable: true }; + + // If JS engine supports accessor properties then property may be a + // getter or setter. + if (supportsAccessors) { + // Unfortunately `__lookupGetter__` will return a getter even + // if object has own non getter property along with a same named + // inherited getter. To avoid misbehavior we temporary remove + // `__proto__` so that `__lookupGetter__` will return getter only + // if it's owned by an object. + var prototype = object.__proto__; + object.__proto__ = prototypeOfObject; + + var getter = lookupGetter(object, property); + var setter = lookupSetter(object, property); + + // Once we have getter and setter we can put values back. + object.__proto__ = prototype; + + if (getter || setter) { + if (getter) descriptor.get = getter; + if (setter) descriptor.set = setter; + + // If it was accessor property we're done and return here + // in order to avoid adding `value` to the descriptor. + return descriptor; + } + } + + // If we got this far we know that object has an own property that is + // not an accessor so we set it as a value and return descriptor. + descriptor.value = object[property]; + return descriptor; + }; +} + +// ES5 15.2.3.4 +// http://es5.github.com/#x15.2.3.4 +if (!Object.getOwnPropertyNames) { + Object.getOwnPropertyNames = function getOwnPropertyNames(object) { + return Object.keys(object); + }; +} + +// ES5 15.2.3.5 +// http://es5.github.com/#x15.2.3.5 +if (!Object.create) { + Object.create = function create(prototype, properties) { + var object; + if (prototype === null) { + object = { "__proto__": null }; + } else { + if (typeof prototype != "object") + throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'"); + var Type = function () {}; + Type.prototype = prototype; + object = new Type(); + // IE has no built-in implementation of `Object.getPrototypeOf` + // neither `__proto__`, but this manually setting `__proto__` will + // guarantee that `Object.getPrototypeOf` will work as expected with + // objects created using `Object.create` + object.__proto__ = prototype; + } + if (properties !== void 0) + Object.defineProperties(object, properties); + return object; + }; +} + +// ES5 15.2.3.6 +// http://es5.github.com/#x15.2.3.6 + +// Patch for WebKit and IE8 standard mode +// Designed by hax +// related issue: https://github.com/kriskowal/es5-shim/issues#issue/5 +// IE8 Reference: +// http://msdn.microsoft.com/en-us/library/dd282900.aspx +// http://msdn.microsoft.com/en-us/library/dd229916.aspx +// WebKit Bugs: +// https://bugs.webkit.org/show_bug.cgi?id=36423 + +function doesDefinePropertyWork(object) { + try { + Object.defineProperty(object, "sentinel", {}); + return "sentinel" in object; + } catch (exception) { + // returns falsy + } +} + +// check whether defineProperty works if it's given. Otherwise, +// shim partially. +if (Object.defineProperty) { + var definePropertyWorksOnObject = doesDefinePropertyWork({}); + var definePropertyWorksOnDom = typeof document == "undefined" || + doesDefinePropertyWork(document.createElement("div")); + if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) { + var definePropertyFallback = Object.defineProperty; + } +} + +if (!Object.defineProperty || definePropertyFallback) { + var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: "; + var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: " + var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " + + "on this javascript engine"; + + Object.defineProperty = function defineProperty(object, property, descriptor) { + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError(ERR_NON_OBJECT_TARGET + object); + if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null) + throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor); + + // make a valiant attempt to use the real defineProperty + // for I8's DOM elements. + if (definePropertyFallback) { + try { + return definePropertyFallback.call(Object, object, property, descriptor); + } catch (exception) { + // try the shim if the real one doesn't work + } + } + + // If it's a data property. + if (owns(descriptor, "value")) { + // fail silently if "writable", "enumerable", or "configurable" + // are requested but not supported + /* + // alternate approach: + if ( // can't implement these features; allow false but not true + !(owns(descriptor, "writable") ? descriptor.writable : true) || + !(owns(descriptor, "enumerable") ? descriptor.enumerable : true) || + !(owns(descriptor, "configurable") ? descriptor.configurable : true) + ) + throw new RangeError( + "This implementation of Object.defineProperty does not " + + "support configurable, enumerable, or writable." + ); + */ + + if (supportsAccessors && (lookupGetter(object, property) || + lookupSetter(object, property))) + { + // As accessors are supported only on engines implementing + // `__proto__` we can safely override `__proto__` while defining + // a property to make sure that we don't hit an inherited + // accessor. + var prototype = object.__proto__; + object.__proto__ = prototypeOfObject; + // Deleting a property anyway since getter / setter may be + // defined on object itself. + delete object[property]; + object[property] = descriptor.value; + // Setting original `__proto__` back now. + object.__proto__ = prototype; + } else { + object[property] = descriptor.value; + } + } else { + if (!supportsAccessors) + throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED); + // If we got that far then getters and setters can be defined !! + if (owns(descriptor, "get")) + defineGetter(object, property, descriptor.get); + if (owns(descriptor, "set")) + defineSetter(object, property, descriptor.set); + } + + return object; + }; +} + +// ES5 15.2.3.7 +// http://es5.github.com/#x15.2.3.7 +if (!Object.defineProperties) { + Object.defineProperties = function defineProperties(object, properties) { + for (var property in properties) { + if (owns(properties, property)) + Object.defineProperty(object, property, properties[property]); + } + return object; + }; +} + +// ES5 15.2.3.8 +// http://es5.github.com/#x15.2.3.8 +if (!Object.seal) { + Object.seal = function seal(object) { + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; +} + +// ES5 15.2.3.9 +// http://es5.github.com/#x15.2.3.9 +if (!Object.freeze) { + Object.freeze = function freeze(object) { + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; +} + +// detect a Rhino bug and patch it +try { + Object.freeze(function () {}); +} catch (exception) { + Object.freeze = (function freeze(freezeObject) { + return function freeze(object) { + if (typeof object == "function") { + return object; + } else { + return freezeObject(object); + } + }; + })(Object.freeze); +} + +// ES5 15.2.3.10 +// http://es5.github.com/#x15.2.3.10 +if (!Object.preventExtensions) { + Object.preventExtensions = function preventExtensions(object) { + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; +} + +// ES5 15.2.3.11 +// http://es5.github.com/#x15.2.3.11 +if (!Object.isSealed) { + Object.isSealed = function isSealed(object) { + return false; + }; +} + +// ES5 15.2.3.12 +// http://es5.github.com/#x15.2.3.12 +if (!Object.isFrozen) { + Object.isFrozen = function isFrozen(object) { + return false; + }; +} + +// ES5 15.2.3.13 +// http://es5.github.com/#x15.2.3.13 +if (!Object.isExtensible) { + Object.isExtensible = function isExtensible(object) { + // 1. If Type(O) is not Object throw a TypeError exception. + if (Object(object) === object) { + throw new TypeError(); // TODO message + } + // 2. Return the Boolean value of the [[Extensible]] internal property of O. + var name = ''; + while (owns(object, name)) { + name += '?'; + } + object[name] = true; + var returnValue = owns(object, name); + delete object[name]; + return returnValue; + }; +} + +// ES5 15.2.3.14 +// http://es5.github.com/#x15.2.3.14 +if (!Object.keys) { + // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation + var hasDontEnumBug = true, + dontEnums = [ + "toString", + "toLocaleString", + "valueOf", + "hasOwnProperty", + "isPrototypeOf", + "propertyIsEnumerable", + "constructor" + ], + dontEnumsLength = dontEnums.length; + + for (var key in {"toString": null}) + hasDontEnumBug = false; + + Object.keys = function keys(object) { + + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError("Object.keys called on a non-object"); + + var keys = []; + for (var name in object) { + if (owns(object, name)) { + keys.push(name); + } + } + + if (hasDontEnumBug) { + for (var i = 0, ii = dontEnumsLength; i < ii; i++) { + var dontEnum = dontEnums[i]; + if (owns(object, dontEnum)) { + keys.push(dontEnum); + } + } + } + + return keys; + }; + +} + +// +// Date +// ==== +// + +// ES5 15.9.5.43 +// http://es5.github.com/#x15.9.5.43 +// This function returns a String value represent the instance in time +// represented by this Date object. The format of the String is the Date Time +// string format defined in 15.9.1.15. All fields are present in the String. +// The time zone is always UTC, denoted by the suffix Z. If the time value of +// this object is not a finite Number a RangeError exception is thrown. +if (!Date.prototype.toISOString || (new Date(-62198755200000).toISOString().indexOf('-000001') === -1)) { + Date.prototype.toISOString = function toISOString() { + var result, length, value, year; + if (!isFinite(this)) + throw new RangeError; + + // the date time string format is specified in 15.9.1.15. + result = [this.getUTCMonth() + 1, this.getUTCDate(), + this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()]; + year = this.getUTCFullYear(); + year = (year < 0 ? '-' : (year > 9999 ? '+' : '')) + ('00000' + Math.abs(year)).slice(0 <= year && year <= 9999 ? -4 : -6); + + length = result.length; + while (length--) { + value = result[length]; + // pad months, days, hours, minutes, and seconds to have two digits. + if (value < 10) + result[length] = "0" + value; + } + // pad milliseconds to have three digits. + return year + "-" + result.slice(0, 2).join("-") + "T" + result.slice(2).join(":") + "." + + ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"; + } +} + +// ES5 15.9.4.4 +// http://es5.github.com/#x15.9.4.4 +if (!Date.now) { + Date.now = function now() { + return new Date().getTime(); + }; +} + +// ES5 15.9.5.44 +// http://es5.github.com/#x15.9.5.44 +// This function provides a String representation of a Date object for use by +// JSON.stringify (15.12.3). +if (!Date.prototype.toJSON) { + Date.prototype.toJSON = function toJSON(key) { + // When the toJSON method is called with argument key, the following + // steps are taken: + + // 1. Let O be the result of calling ToObject, giving it the this + // value as its argument. + // 2. Let tv be ToPrimitive(O, hint Number). + // 3. If tv is a Number and is not finite, return null. + // XXX + // 4. Let toISO be the result of calling the [[Get]] internal method of + // O with argument "toISOString". + // 5. If IsCallable(toISO) is false, throw a TypeError exception. + if (typeof this.toISOString != "function") + throw new TypeError(); // TODO message + // 6. Return the result of calling the [[Call]] internal method of + // toISO with O as the this value and an empty argument list. + return this.toISOString(); + + // NOTE 1 The argument is ignored. + + // NOTE 2 The toJSON function is intentionally generic; it does not + // require that its this value be a Date object. Therefore, it can be + // transferred to other kinds of objects for use as a method. However, + // it does require that any such object have a toISOString method. An + // object is free to use the argument key to filter its + // stringification. + }; +} + +// ES5 15.9.4.2 +// http://es5.github.com/#x15.9.4.2 +// based on work shared by Daniel Friesen (dantman) +// http://gist.github.com/303249 +if (Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) { + // XXX global assignment won't work in embeddings that use + // an alternate object for the context. + Date = (function(NativeDate) { + + // Date.length === 7 + var Date = function Date(Y, M, D, h, m, s, ms) { + var length = arguments.length; + if (this instanceof NativeDate) { + var date = length == 1 && String(Y) === Y ? // isString(Y) + // We explicitly pass it through parse: + new NativeDate(Date.parse(Y)) : + // We have to manually make calls depending on argument + // length here + length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) : + length >= 6 ? new NativeDate(Y, M, D, h, m, s) : + length >= 5 ? new NativeDate(Y, M, D, h, m) : + length >= 4 ? new NativeDate(Y, M, D, h) : + length >= 3 ? new NativeDate(Y, M, D) : + length >= 2 ? new NativeDate(Y, M) : + length >= 1 ? new NativeDate(Y) : + new NativeDate(); + // Prevent mixups with unfixed Date object + date.constructor = Date; + return date; + } + return NativeDate.apply(this, arguments); + }; + + // 15.9.1.15 Date Time String Format. + var isoDateExpression = new RegExp("^" + + "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign + 6-digit extended year + "(?:-(\\d{2})" + // optional month capture + "(?:-(\\d{2})" + // optional day capture + "(?:" + // capture hours:minutes:seconds.milliseconds + "T(\\d{2})" + // hours capture + ":(\\d{2})" + // minutes capture + "(?:" + // optional :seconds.milliseconds + ":(\\d{2})" + // seconds capture + "(?:\\.(\\d{3}))?" + // milliseconds capture + ")?" + + "(?:" + // capture UTC offset component + "Z|" + // UTC capture + "(?:" + // offset specifier +/-hours:minutes + "([-+])" + // sign capture + "(\\d{2})" + // hours offset capture + ":(\\d{2})" + // minutes offset capture + ")" + + ")?)?)?)?" + + "$"); + + // Copy any custom methods a 3rd party library may have added + for (var key in NativeDate) + Date[key] = NativeDate[key]; + + // Copy "native" methods explicitly; they may be non-enumerable + Date.now = NativeDate.now; + Date.UTC = NativeDate.UTC; + Date.prototype = NativeDate.prototype; + Date.prototype.constructor = Date; + + // Upgrade Date.parse to handle simplified ISO 8601 strings + Date.parse = function parse(string) { + var match = isoDateExpression.exec(string); + if (match) { + match.shift(); // kill match[0], the full match + // parse months, days, hours, minutes, seconds, and milliseconds + for (var i = 1; i < 7; i++) { + // provide default values if necessary + match[i] = +(match[i] || (i < 3 ? 1 : 0)); + // match[1] is the month. Months are 0-11 in JavaScript + // `Date` objects, but 1-12 in ISO notation, so we + // decrement. + if (i == 1) + match[i]--; + } + + // parse the UTC offset component + var minuteOffset = +match.pop(), hourOffset = +match.pop(), sign = match.pop(); + + // compute the explicit time zone offset if specified + var offset = 0; + if (sign) { + // detect invalid offsets and return early + if (hourOffset > 23 || minuteOffset > 59) + return NaN; + + // express the provided time zone offset in minutes. The offset is + // negative for time zones west of UTC; positive otherwise. + offset = (hourOffset * 60 + minuteOffset) * 6e4 * (sign == "+" ? -1 : 1); + } + + // Date.UTC for years between 0 and 99 converts year to 1900 + year + // The Gregorian calendar has a 400-year cycle, so + // to Date.UTC(year + 400, .... ) - 12622780800000 == Date.UTC(year, ...), + // where 12622780800000 - number of milliseconds in Gregorian calendar 400 years + var year = +match[0]; + if (0 <= year && year <= 99) { + match[0] = year + 400; + return NativeDate.UTC.apply(this, match) + offset - 12622780800000; + } + + // compute a new UTC date value, accounting for the optional offset + return NativeDate.UTC.apply(this, match) + offset; + } + return NativeDate.parse.apply(this, arguments); + }; + + return Date; + })(Date); +} + +// +// String +// ====== +// + +// ES5 15.5.4.20 +// http://es5.github.com/#x15.5.4.20 +var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" + + "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" + + "\u2029\uFEFF"; +if (!String.prototype.trim || ws.trim()) { + // http://blog.stevenlevithan.com/archives/faster-trim-javascript + // http://perfectionkills.com/whitespace-deviations/ + ws = "[" + ws + "]"; + var trimBeginRegexp = new RegExp("^" + ws + ws + "*"), + trimEndRegexp = new RegExp(ws + ws + "*$"); + String.prototype.trim = function trim() { + return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, ""); + }; +} + +// +// Util +// ====== +// + +// ES5 9.4 +// http://es5.github.com/#x9.4 +// http://jsperf.com/to-integer +var toInteger = function (n) { + n = +n; + if (n !== n) // isNaN + n = 0; + else if (n !== 0 && n !== (1/0) && n !== -(1/0)) + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + return n; +}; + +var prepareString = "a"[0] != "a", + // ES5 9.9 + // http://es5.github.com/#x9.9 + toObject = function (o) { + if (o == null) { // this matches both null and undefined + throw new TypeError(); // TODO message + } + // If the implementation doesn't support by-index access of + // string characters (ex. IE < 7), split the string + if (prepareString && typeof o == "string" && o) { + return o.split(""); + } + return Object(o); + }; +}); + +define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) { + + +var EventEmitter = {}; + +EventEmitter._emit = +EventEmitter._dispatchEvent = function(eventName, e) { + this._eventRegistry = this._eventRegistry || {}; + this._defaultHandlers = this._defaultHandlers || {}; + + var listeners = this._eventRegistry[eventName] || []; + var defaultHandler = this._defaultHandlers[eventName]; + if (!listeners.length && !defaultHandler) + return; + + if (typeof e != "object" || !e) + e = {}; + + if (!e.type) + e.type = eventName; + + if (!e.stopPropagation) { + e.stopPropagation = function() { + this.propagationStopped = true; + }; + } + + if (!e.preventDefault) { + e.preventDefault = function() { + this.defaultPrevented = true; + }; + } + + for (var i=0; i= length) { + position.row = Math.max(0, length - 1); + position.column = this.getLine(length-1).length; + } + return position; + }; + this.insert = function(position, text) { + if (!text || text.length === 0) + return position; + + position = this.$clipPosition(position); + + // only detect new lines if the document has no line break yet + if (this.getLength() <= 1) + this.$detectNewLine(text); + + var lines = this.$split(text); + var firstLine = lines.splice(0, 1)[0]; + var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0]; + + position = this.insertInLine(position, firstLine); + if (lastLine !== null) { + position = this.insertNewLine(position); // terminate first line + position = this.insertLines(position.row, lines); + position = this.insertInLine(position, lastLine || ""); + } + return position; + }; + /** + * Document@change(e) + * - e (Object): Contains at least one property called `"action"`. `"action"` indicates the action that triggered the change. Each action also has a set of additional properties. + * + * Fires whenever the document changes. + * + * Several methods trigger different `"change"` events. Below is a list of each action type, followed by each property that's also available: + * + * * `"insertLines"` (emitted by [[Document.insertLines]]) + * * `range`: the [[Range]] of the change within the document + * * `lines`: the lines in the document that are changing + * * `"insertText"` (emitted by [[Document.insertNewLine]]) + * * `range`: the [[Range]] of the change within the document + * * `text`: the text that's being added + * * `"removeLines"` (emitted by [[Document.insertLines]]) + * * `range`: the [[Range]] of the change within the document + * * `lines`: the lines in the document that were removed + * * `nl`: the new line character (as defined by [[Document.getNewLineCharacter]]) + * * `"removeText"` (emitted by [[Document.removeInLine]] and [[Document.removeNewLine]]) + * * `range`: the [[Range]] of the change within the document + * * `text`: the text that's being removed + * + **/ + this.insertLines = function(row, lines) { + if (lines.length == 0) + return {row: row, column: 0}; + + // apply doesn't work for big arrays (smallest threshold is on safari 0xFFFF) + // to circumvent that we have to break huge inserts into smaller chunks here + if (lines.length > 0xFFFF) { + var end = this.insertLines(row, lines.slice(0xFFFF)); + lines = lines.slice(0, 0xFFFF); + } + + var args = [row, 0]; + args.push.apply(args, lines); + this.$lines.splice.apply(this.$lines, args); + + var range = new Range(row, 0, row + lines.length, 0); + var delta = { + action: "insertLines", + range: range, + lines: lines + }; + this._emit("change", { data: delta }); + return end || range.end; + }; + this.insertNewLine = function(position) { + position = this.$clipPosition(position); + var line = this.$lines[position.row] || ""; + + this.$lines[position.row] = line.substring(0, position.column); + this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length)); + + var end = { + row : position.row + 1, + column : 0 + }; + + var delta = { + action: "insertText", + range: Range.fromPoints(position, end), + text: this.getNewLineCharacter() + }; + this._emit("change", { data: delta }); + + return end; + }; + this.insertInLine = function(position, text) { + if (text.length == 0) + return position; + + var line = this.$lines[position.row] || ""; + + this.$lines[position.row] = line.substring(0, position.column) + text + + line.substring(position.column); + + var end = { + row : position.row, + column : position.column + text.length + }; + + var delta = { + action: "insertText", + range: Range.fromPoints(position, end), + text: text + }; + this._emit("change", { data: delta }); + + return end; + }; + this.remove = function(range) { + // clip to document + range.start = this.$clipPosition(range.start); + range.end = this.$clipPosition(range.end); + + if (range.isEmpty()) + return range.start; + + var firstRow = range.start.row; + var lastRow = range.end.row; + + if (range.isMultiLine()) { + var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1; + var lastFullRow = lastRow - 1; + + if (range.end.column > 0) + this.removeInLine(lastRow, 0, range.end.column); + + if (lastFullRow >= firstFullRow) + this.removeLines(firstFullRow, lastFullRow); + + if (firstFullRow != firstRow) { + this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length); + this.removeNewLine(range.start.row); + } + } + else { + this.removeInLine(firstRow, range.start.column, range.end.column); + } + return range.start; + }; + this.removeInLine = function(row, startColumn, endColumn) { + if (startColumn == endColumn) + return; + + var range = new Range(row, startColumn, row, endColumn); + var line = this.getLine(row); + var removed = line.substring(startColumn, endColumn); + var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length); + this.$lines.splice(row, 1, newLine); + + var delta = { + action: "removeText", + range: range, + text: removed + }; + this._emit("change", { data: delta }); + return range.start; + }; + this.removeLines = function(firstRow, lastRow) { + var range = new Range(firstRow, 0, lastRow + 1, 0); + var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1); + + var delta = { + action: "removeLines", + range: range, + nl: this.getNewLineCharacter(), + lines: removed + }; + this._emit("change", { data: delta }); + return removed; + }; + this.removeNewLine = function(row) { + var firstLine = this.getLine(row); + var secondLine = this.getLine(row+1); + + var range = new Range(row, firstLine.length, row+1, 0); + var line = firstLine + secondLine; + + this.$lines.splice(row, 2, line); + + var delta = { + action: "removeText", + range: range, + text: this.getNewLineCharacter() + }; + this._emit("change", { data: delta }); + }; + this.replace = function(range, text) { + if (text.length == 0 && range.isEmpty()) + return range.start; + + // Shortcut: If the text we want to insert is the same as it is already + // in the document, we don't have to replace anything. + if (text == this.getTextRange(range)) + return range.end; + + this.remove(range); + if (text) { + var end = this.insert(range.start, text); + } + else { + end = range.start; + } + + return end; + }; + this.applyDeltas = function(deltas) { + for (var i=0; i=0; i--) { + var delta = deltas[i]; + + var range = Range.fromPoints(delta.range.start, delta.range.end); + + if (delta.action == "insertLines") + this.removeLines(range.start.row, range.end.row - 1); + else if (delta.action == "insertText") + this.remove(range); + else if (delta.action == "removeLines") + this.insertLines(range.start.row, delta.lines); + else if (delta.action == "removeText") + this.insert(range.start, delta.text); + } + }; + +}).call(Document.prototype); + +exports.Document = Document; +}); + +define('ace/range', ['require', 'exports', 'module' ], function(require, exports, module) { + + +/** + * class Range + * + * This object is used in various places to indicate a region within the editor. To better visualize how this works, imagine a rectangle. Each quadrant of the rectangle is analogus to a range, as ranges contain a starting row and starting column, and an ending row, and ending column. + * + **/ + +/** + * new Range(startRow, startColumn, endRow, endColumn) + * - startRow (Number): The starting row + * - startColumn (Number): The starting column + * - endRow (Number): The ending row + * - endColumn (Number): The ending column + * + * Creates a new `Range` object with the given starting and ending row and column points. + * + **/ +var Range = function(startRow, startColumn, endRow, endColumn) { + this.start = { + row: startRow, + column: startColumn + }; + + this.end = { + row: endRow, + column: endColumn + }; +}; + +(function() { + /** + * Range.isEqual(range) -> Boolean + * - range (Range): A range to check against + * + * Returns `true` if and only if the starting row and column, and ending tow and column, are equivalent to those given by `range`. + * + **/ + this.isEqual = function(range) { + return this.start.row == range.start.row && + this.end.row == range.end.row && + this.start.column == range.start.column && + this.end.column == range.end.column + }; + this.toString = function() { + return ("Range: [" + this.start.row + "/" + this.start.column + + "] -> [" + this.end.row + "/" + this.end.column + "]"); + }; + + this.contains = function(row, column) { + return this.compare(row, column) == 0; + }; + this.compareRange = function(range) { + var cmp, + end = range.end, + start = range.start; + + cmp = this.compare(end.row, end.column); + if (cmp == 1) { + cmp = this.compare(start.row, start.column); + if (cmp == 1) { + return 2; + } else if (cmp == 0) { + return 1; + } else { + return 0; + } + } else if (cmp == -1) { + return -2; + } else { + cmp = this.compare(start.row, start.column); + if (cmp == -1) { + return -1; + } else if (cmp == 1) { + return 42; + } else { + return 0; + } + } + } + + /** related to: Range.compare + * Range.comparePoint(p) -> Number + * - p (Range): A point to compare with + * + (Number): This method returns one of the following numbers:
    + * * `0` if the two points are exactly equal
    + * * `-1` if `p.row` is less then the calling range
    + * * `1` if `p.row` is greater than the calling range
    + *
    + * If the starting row of the calling range is equal to `p.row`, and:
    + * * `p.column` is greater than or equal to the calling range's starting column, this returns `0`
    + * * Otherwise, it returns -1
    + *
    + * If the ending row of the calling range is equal to `p.row`, and:
    + * * `p.column` is less than or equal to the calling range's ending column, this returns `0`
    + * * Otherwise, it returns 1
    + * + * Checks the row and column points of `p` with the row and column points of the calling range. + * + * + * + **/ + this.comparePoint = function(p) { + return this.compare(p.row, p.column); + } + + /** related to: Range.comparePoint + * Range.containsRange(range) -> Boolean + * - range (Range): A range to compare with + * + * Checks the start and end points of `range` and compares them to the calling range. Returns `true` if the `range` is contained within the caller's range. + * + **/ + this.containsRange = function(range) { + return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0; + } + + /** + * Range.intersects(range) -> Boolean + * - range (Range): A range to compare with + * + * Returns `true` if passed in `range` intersects with the one calling this method. + * + **/ + this.intersects = function(range) { + var cmp = this.compareRange(range); + return (cmp == -1 || cmp == 0 || cmp == 1); + } + + /** + * Range.isEnd(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the caller's ending row point is the same as `row`, and if the caller's ending column is the same as `column`. + * + **/ + this.isEnd = function(row, column) { + return this.end.row == row && this.end.column == column; + } + + /** + * Range.isStart(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the caller's starting row point is the same as `row`, and if the caller's starting column is the same as `column`. + * + **/ + this.isStart = function(row, column) { + return this.start.row == row && this.start.column == column; + } + + /** + * Range.setStart(row, column) + * - row (Number): A row point to set + * - column (Number): A column point to set + * + * Sets the starting row and column for the range. + * + **/ + this.setStart = function(row, column) { + if (typeof row == "object") { + this.start.column = row.column; + this.start.row = row.row; + } else { + this.start.row = row; + this.start.column = column; + } + } + + /** + * Range.setEnd(row, column) + * - row (Number): A row point to set + * - column (Number): A column point to set + * + * Sets the starting row and column for the range. + * + **/ + this.setEnd = function(row, column) { + if (typeof row == "object") { + this.end.column = row.column; + this.end.row = row.row; + } else { + this.end.row = row; + this.end.column = column; + } + } + + /** related to: Range.compare + * Range.inside(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the `row` and `column` are within the given range. + * + **/ + this.inside = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isEnd(row, column) || this.isStart(row, column)) { + return false; + } else { + return true; + } + } + return false; + } + + /** related to: Range.compare + * Range.insideStart(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the `row` and `column` are within the given range's starting points. + * + **/ + this.insideStart = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isEnd(row, column)) { + return false; + } else { + return true; + } + } + return false; + } + + /** related to: Range.compare + * Range.insideEnd(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the `row` and `column` are within the given range's ending points. + * + **/ + this.insideEnd = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isStart(row, column)) { + return false; + } else { + return true; + } + } + return false; + } + + /** + * Range.compare(row, column) -> Number + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + (Number): This method returns one of the following numbers:
    + * * `0` if the two points are exactly equal
    + * * `-1` if `p.row` is less then the calling range
    + * * `1` if `p.row` is greater than the calling range
    + *
    + * If the starting row of the calling range is equal to `p.row`, and:
    + * * `p.column` is greater than or equal to the calling range's starting column, this returns `0`
    + * * Otherwise, it returns -1
    + *
    + * If the ending row of the calling range is equal to `p.row`, and:
    + * * `p.column` is less than or equal to the calling range's ending column, this returns `0`
    + * * Otherwise, it returns 1 + * + * Checks the row and column points with the row and column points of the calling range. + * + * + **/ + this.compare = function(row, column) { + if (!this.isMultiLine()) { + if (row === this.start.row) { + return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0); + }; + } + + if (row < this.start.row) + return -1; + + if (row > this.end.row) + return 1; + + if (this.start.row === row) + return column >= this.start.column ? 0 : -1; + + if (this.end.row === row) + return column <= this.end.column ? 0 : 1; + + return 0; + }; + this.compareStart = function(row, column) { + if (this.start.row == row && this.start.column == column) { + return -1; + } else { + return this.compare(row, column); + } + } + + /** + * Range.compareEnd(row, column) -> Number + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + (Number): This method returns one of the following numbers:
    + * * `0` if the two points are exactly equal
    + * * `-1` if `p.row` is less then the calling range
    + * * `1` if `p.row` is greater than the calling range, or if `isEnd` is `true.
    + *
    + * If the starting row of the calling range is equal to `p.row`, and:
    + * * `p.column` is greater than or equal to the calling range's starting column, this returns `0`
    + * * Otherwise, it returns -1
    + *
    + * If the ending row of the calling range is equal to `p.row`, and:
    + * * `p.column` is less than or equal to the calling range's ending column, this returns `0`
    + * * Otherwise, it returns 1 + * + * Checks the row and column points with the row and column points of the calling range. + * + * + **/ + this.compareEnd = function(row, column) { + if (this.end.row == row && this.end.column == column) { + return 1; + } else { + return this.compare(row, column); + } + } + + /** + * Range.compareInside(row, column) -> Number + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + (Number): This method returns one of the following numbers:
    + * * `1` if the ending row of the calling range is equal to `row`, and the ending column of the calling range is equal to `column`
    + * * `-1` if the starting row of the calling range is equal to `row`, and the starting column of the calling range is equal to `column`
    + *
    + * Otherwise, it returns the value after calling [[Range.compare `compare()`]]. + * + * Checks the row and column points with the row and column points of the calling range. + * + * + * + **/ + this.compareInside = function(row, column) { + if (this.end.row == row && this.end.column == column) { + return 1; + } else if (this.start.row == row && this.start.column == column) { + return -1; + } else { + return this.compare(row, column); + } + } + + /** + * Range.clipRows(firstRow, lastRow) -> Range + * - firstRow (Number): The starting row + * - lastRow (Number): The ending row + * + * Returns the part of the current `Range` that occurs within the boundaries of `firstRow` and `lastRow` as a new `Range` object. + * + **/ + this.clipRows = function(firstRow, lastRow) { + if (this.end.row > lastRow) { + var end = { + row: lastRow+1, + column: 0 + }; + } + + if (this.start.row > lastRow) { + var start = { + row: lastRow+1, + column: 0 + }; + } + + if (this.start.row < firstRow) { + var start = { + row: firstRow, + column: 0 + }; + } + + if (this.end.row < firstRow) { + var end = { + row: firstRow, + column: 0 + }; + } + return Range.fromPoints(start || this.start, end || this.end); + }; + this.extend = function(row, column) { + var cmp = this.compare(row, column); + + if (cmp == 0) + return this; + else if (cmp == -1) + var start = {row: row, column: column}; + else + var end = {row: row, column: column}; + + return Range.fromPoints(start || this.start, end || this.end); + }; + + this.isEmpty = function() { + return (this.start.row == this.end.row && this.start.column == this.end.column); + }; + this.isMultiLine = function() { + return (this.start.row !== this.end.row); + }; + this.clone = function() { + return Range.fromPoints(this.start, this.end); + }; + this.collapseRows = function() { + if (this.end.column == 0) + return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0) + else + return new Range(this.start.row, 0, this.end.row, 0) + }; + this.toScreenRange = function(session) { + var screenPosStart = + session.documentToScreenPosition(this.start); + var screenPosEnd = + session.documentToScreenPosition(this.end); + + return new Range( + screenPosStart.row, screenPosStart.column, + screenPosEnd.row, screenPosEnd.column + ); + }; + +}).call(Range.prototype); +Range.fromPoints = function(start, end) { + return new Range(start.row, start.column, end.row, end.column); +}; + +exports.Range = Range; +}); + +define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) { + + +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; + +/** + * new Anchor(doc, row, column) + * - doc (Document): The document to associate with the anchor + * - row (Number): The starting row position + * - column (Number): The starting column position + * + * Creates a new `Anchor` and associates it with a document. + * + **/ + +var Anchor = exports.Anchor = function(doc, row, column) { + this.document = doc; + + if (typeof column == "undefined") + this.setPosition(row.row, row.column); + else + this.setPosition(row, column); + + this.$onChange = this.onChange.bind(this); + doc.on("change", this.$onChange); +}; + +(function() { + + oop.implement(this, EventEmitter); + + this.getPosition = function() { + return this.$clipPositionToDocument(this.row, this.column); + }; + + this.getDocument = function() { + return this.document; + }; + + this.onChange = function(e) { + var delta = e.data; + var range = delta.range; + + if (range.start.row == range.end.row && range.start.row != this.row) + return; + + if (range.start.row > this.row) + return; + + if (range.start.row == this.row && range.start.column > this.column) + return; + + var row = this.row; + var column = this.column; + + if (delta.action === "insertText") { + if (range.start.row === row && range.start.column <= column) { + if (range.start.row === range.end.row) { + column += range.end.column - range.start.column; + } + else { + column -= range.start.column; + row += range.end.row - range.start.row; + } + } + else if (range.start.row !== range.end.row && range.start.row < row) { + row += range.end.row - range.start.row; + } + } else if (delta.action === "insertLines") { + if (range.start.row <= row) { + row += range.end.row - range.start.row; + } + } + else if (delta.action == "removeText") { + if (range.start.row == row && range.start.column < column) { + if (range.end.column >= column) + column = range.start.column; + else + column = Math.max(0, column - (range.end.column - range.start.column)); + + } else if (range.start.row !== range.end.row && range.start.row < row) { + if (range.end.row == row) { + column = Math.max(0, column - range.end.column) + range.start.column; + } + row -= (range.end.row - range.start.row); + } + else if (range.end.row == row) { + row -= range.end.row - range.start.row; + column = Math.max(0, column - range.end.column) + range.start.column; + } + } else if (delta.action == "removeLines") { + if (range.start.row <= row) { + if (range.end.row <= row) + row -= range.end.row - range.start.row; + else { + row = range.start.row; + column = 0; + } + } + } + + this.setPosition(row, column, true); + }; + + this.setPosition = function(row, column, noClip) { + var pos; + if (noClip) { + pos = { + row: row, + column: column + }; + } + else { + pos = this.$clipPositionToDocument(row, column); + } + + if (this.row == pos.row && this.column == pos.column) + return; + + var old = { + row: this.row, + column: this.column + }; + + this.row = pos.row; + this.column = pos.column; + this._emit("change", { + old: old, + value: pos + }); + }; + + this.detach = function() { + this.document.removeEventListener("change", this.$onChange); + }; + + this.$clipPositionToDocument = function(row, column) { + var pos = {}; + + if (row >= this.document.getLength()) { + pos.row = Math.max(0, this.document.getLength() - 1); + pos.column = this.document.getLine(pos.row).length; + } + else if (row < 0) { + pos.row = 0; + pos.column = 0; + } + else { + pos.row = row; + pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column)); + } + + if (column < 0) + pos.column = 0; + + return pos; + }; + +}).call(Anchor.prototype); + +}); + +define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.stringReverse = function(string) { + return string.split("").reverse().join(""); +}; + +exports.stringRepeat = function (string, count) { + return new Array(count + 1).join(string); +}; + +var trimBeginRegexp = /^\s\s*/; +var trimEndRegexp = /\s\s*$/; + +exports.stringTrimLeft = function (string) { + return string.replace(trimBeginRegexp, ''); +}; + +exports.stringTrimRight = function (string) { + return string.replace(trimEndRegexp, ''); +}; + +exports.copyObject = function(obj) { + var copy = {}; + for (var key in obj) { + copy[key] = obj[key]; + } + return copy; +}; + +exports.copyArray = function(array){ + var copy = []; + for (var i=0, l=array.length; i= 0 || __indexOf.call(COFFEE_KEYWORDS, id) >= 0)) { + tag = id.toUpperCase(); + if (tag === 'WHEN' && (_ref3 = this.tag(), __indexOf.call(LINE_BREAK, _ref3) >= 0)) { + tag = 'LEADING_WHEN'; + } else if (tag === 'FOR') { + this.seenFor = true; + } else if (tag === 'UNLESS') { + tag = 'IF'; + } else if (__indexOf.call(UNARY, tag) >= 0) { + tag = 'UNARY'; + } else if (__indexOf.call(RELATION, tag) >= 0) { + if (tag !== 'INSTANCEOF' && this.seenFor) { + tag = 'FOR' + tag; + this.seenFor = false; + } else { + tag = 'RELATION'; + if (this.value() === '!') { + this.tokens.pop(); + id = '!' + id; + } + } + } + } + if (__indexOf.call(JS_FORBIDDEN, id) >= 0) { + if (forcedIdentifier) { + tag = 'IDENTIFIER'; + id = new String(id); + id.reserved = true; + } else if (__indexOf.call(RESERVED, id) >= 0) { + this.error("reserved word \"" + id + "\""); + } + } + if (!forcedIdentifier) { + if (__indexOf.call(COFFEE_ALIASES, id) >= 0) id = COFFEE_ALIAS_MAP[id]; + tag = (function() { + switch (id) { + case '!': + return 'UNARY'; + case '==': + case '!=': + return 'COMPARE'; + case '&&': + case '||': + return 'LOGIC'; + case 'true': + case 'false': + case 'null': + case 'undefined': + return 'BOOL'; + case 'break': + case 'continue': + return 'STATEMENT'; + default: + return tag; + } + })(); + } + this.token(tag, id); + if (colon) this.token(':', ':'); + return input.length; + }; + + Lexer.prototype.numberToken = function() { + var binaryLiteral, lexedLength, match, number, octalLiteral; + if (!(match = NUMBER.exec(this.chunk))) return 0; + number = match[0]; + if (/E/.test(number)) { + this.error("exponential notation '" + number + "' must be indicated with a lowercase 'e'"); + } else if (/[BOX]/.test(number)) { + this.error("radix prefix '" + number + "' must be lowercase"); + } else if (/^0[89]/.test(number)) { + this.error("decimal literal '" + number + "' must not be prefixed with '0'"); + } else if (/^0[0-7]/.test(number)) { + this.error("octal literal '" + number + "' must be prefixed with '0o'"); + } + lexedLength = number.length; + if (octalLiteral = /0o([0-7]+)/.exec(number)) { + number = (parseInt(octalLiteral[1], 8)).toString(); + } + if (binaryLiteral = /0b([01]+)/.exec(number)) { + number = (parseInt(binaryLiteral[1], 2)).toString(); + } + this.token('NUMBER', number); + return lexedLength; + }; + + Lexer.prototype.stringToken = function() { + var match, octalEsc, string; + switch (this.chunk.charAt(0)) { + case "'": + if (!(match = SIMPLESTR.exec(this.chunk))) return 0; + this.token('STRING', (string = match[0]).replace(MULTILINER, '\\\n')); + break; + case '"': + if (!(string = this.balancedString(this.chunk, '"'))) return 0; + if (0 < string.indexOf('#{', 1)) { + this.interpolateString(string.slice(1, -1)); + } else { + this.token('STRING', this.escapeLines(string)); + } + break; + default: + return 0; + } + if (octalEsc = /^(?:\\.|[^\\])*\\[0-7]/.test(string)) { + this.error("octal escape sequences " + string + " are not allowed"); + } + this.line += count(string, '\n'); + return string.length; + }; + + Lexer.prototype.heredocToken = function() { + var doc, heredoc, match, quote; + if (!(match = HEREDOC.exec(this.chunk))) return 0; + heredoc = match[0]; + quote = heredoc.charAt(0); + doc = this.sanitizeHeredoc(match[2], { + quote: quote, + indent: null + }); + if (quote === '"' && 0 <= doc.indexOf('#{')) { + this.interpolateString(doc, { + heredoc: true + }); + } else { + this.token('STRING', this.makeString(doc, quote, true)); + } + this.line += count(heredoc, '\n'); + return heredoc.length; + }; + + Lexer.prototype.commentToken = function() { + var comment, here, match; + if (!(match = this.chunk.match(COMMENT))) return 0; + comment = match[0], here = match[1]; + if (here) { + this.token('HERECOMMENT', this.sanitizeHeredoc(here, { + herecomment: true, + indent: Array(this.indent + 1).join(' ') + })); + } + this.line += count(comment, '\n'); + return comment.length; + }; + + Lexer.prototype.jsToken = function() { + var match, script; + if (!(this.chunk.charAt(0) === '`' && (match = JSTOKEN.exec(this.chunk)))) { + return 0; + } + this.token('JS', (script = match[0]).slice(1, -1)); + return script.length; + }; + + Lexer.prototype.regexToken = function() { + var flags, length, match, prev, regex, _ref2, _ref3; + if (this.chunk.charAt(0) !== '/') return 0; + if (match = HEREGEX.exec(this.chunk)) { + length = this.heregexToken(match); + this.line += count(match[0], '\n'); + return length; + } + prev = last(this.tokens); + if (prev && (_ref2 = prev[0], __indexOf.call((prev.spaced ? NOT_REGEX : NOT_SPACED_REGEX), _ref2) >= 0)) { + return 0; + } + if (!(match = REGEX.exec(this.chunk))) return 0; + _ref3 = match, match = _ref3[0], regex = _ref3[1], flags = _ref3[2]; + if (regex.slice(0, 2) === '/*') { + this.error('regular expressions cannot begin with `*`'); + } + if (regex === '//') regex = '/(?:)/'; + this.token('REGEX', "" + regex + flags); + return match.length; + }; + + Lexer.prototype.heregexToken = function(match) { + var body, flags, heregex, re, tag, tokens, value, _i, _len, _ref2, _ref3, _ref4, _ref5; + heregex = match[0], body = match[1], flags = match[2]; + if (0 > body.indexOf('#{')) { + re = body.replace(HEREGEX_OMIT, '').replace(/\//g, '\\/'); + if (re.match(/^\*/)) { + this.error('regular expressions cannot begin with `*`'); + } + this.token('REGEX', "/" + (re || '(?:)') + "/" + flags); + return heregex.length; + } + this.token('IDENTIFIER', 'RegExp'); + this.tokens.push(['CALL_START', '(']); + tokens = []; + _ref2 = this.interpolateString(body, { + regex: true + }); + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + _ref3 = _ref2[_i], tag = _ref3[0], value = _ref3[1]; + if (tag === 'TOKENS') { + tokens.push.apply(tokens, value); + } else { + if (!(value = value.replace(HEREGEX_OMIT, ''))) continue; + value = value.replace(/\\/g, '\\\\'); + tokens.push(['STRING', this.makeString(value, '"', true)]); + } + tokens.push(['+', '+']); + } + tokens.pop(); + if (((_ref4 = tokens[0]) != null ? _ref4[0] : void 0) !== 'STRING') { + this.tokens.push(['STRING', '""'], ['+', '+']); + } + (_ref5 = this.tokens).push.apply(_ref5, tokens); + if (flags) this.tokens.push([',', ','], ['STRING', '"' + flags + '"']); + this.token(')', ')'); + return heregex.length; + }; + + Lexer.prototype.lineToken = function() { + var diff, indent, match, noNewlines, prev, size; + if (!(match = MULTI_DENT.exec(this.chunk))) return 0; + indent = match[0]; + this.line += count(indent, '\n'); + this.seenFor = false; + prev = last(this.tokens, 1); + size = indent.length - 1 - indent.lastIndexOf('\n'); + noNewlines = this.unfinished(); + if (size - this.indebt === this.indent) { + if (noNewlines) { + this.suppressNewlines(); + } else { + this.newlineToken(); + } + return indent.length; + } + if (size > this.indent) { + if (noNewlines) { + this.indebt = size - this.indent; + this.suppressNewlines(); + return indent.length; + } + diff = size - this.indent + this.outdebt; + this.token('INDENT', diff); + this.indents.push(diff); + this.ends.push('OUTDENT'); + this.outdebt = this.indebt = 0; + } else { + this.indebt = 0; + this.outdentToken(this.indent - size, noNewlines); + } + this.indent = size; + return indent.length; + }; + + Lexer.prototype.outdentToken = function(moveOut, noNewlines) { + var dent, len; + while (moveOut > 0) { + len = this.indents.length - 1; + if (this.indents[len] === void 0) { + moveOut = 0; + } else if (this.indents[len] === this.outdebt) { + moveOut -= this.outdebt; + this.outdebt = 0; + } else if (this.indents[len] < this.outdebt) { + this.outdebt -= this.indents[len]; + moveOut -= this.indents[len]; + } else { + dent = this.indents.pop() - this.outdebt; + moveOut -= dent; + this.outdebt = 0; + this.pair('OUTDENT'); + this.token('OUTDENT', dent); + } + } + if (dent) this.outdebt -= moveOut; + while (this.value() === ';') { + this.tokens.pop(); + } + if (!(this.tag() === 'TERMINATOR' || noNewlines)) { + this.token('TERMINATOR', '\n'); + } + return this; + }; + + Lexer.prototype.whitespaceToken = function() { + var match, nline, prev; + if (!((match = WHITESPACE.exec(this.chunk)) || (nline = this.chunk.charAt(0) === '\n'))) { + return 0; + } + prev = last(this.tokens); + if (prev) prev[match ? 'spaced' : 'newLine'] = true; + if (match) { + return match[0].length; + } else { + return 0; + } + }; + + Lexer.prototype.newlineToken = function() { + while (this.value() === ';') { + this.tokens.pop(); + } + if (this.tag() !== 'TERMINATOR') this.token('TERMINATOR', '\n'); + return this; + }; + + Lexer.prototype.suppressNewlines = function() { + if (this.value() === '\\') this.tokens.pop(); + return this; + }; + + Lexer.prototype.literalToken = function() { + var match, prev, tag, value, _ref2, _ref3, _ref4, _ref5; + if (match = OPERATOR.exec(this.chunk)) { + value = match[0]; + if (CODE.test(value)) this.tagParameters(); + } else { + value = this.chunk.charAt(0); + } + tag = value; + prev = last(this.tokens); + if (value === '=' && prev) { + if (!prev[1].reserved && (_ref2 = prev[1], __indexOf.call(JS_FORBIDDEN, _ref2) >= 0)) { + this.error("reserved word \"" + (this.value()) + "\" can't be assigned"); + } + if ((_ref3 = prev[1]) === '||' || _ref3 === '&&') { + prev[0] = 'COMPOUND_ASSIGN'; + prev[1] += '='; + return value.length; + } + } + if (value === ';') { + this.seenFor = false; + tag = 'TERMINATOR'; + } else if (__indexOf.call(MATH, value) >= 0) { + tag = 'MATH'; + } else if (__indexOf.call(COMPARE, value) >= 0) { + tag = 'COMPARE'; + } else if (__indexOf.call(COMPOUND_ASSIGN, value) >= 0) { + tag = 'COMPOUND_ASSIGN'; + } else if (__indexOf.call(UNARY, value) >= 0) { + tag = 'UNARY'; + } else if (__indexOf.call(SHIFT, value) >= 0) { + tag = 'SHIFT'; + } else if (__indexOf.call(LOGIC, value) >= 0 || value === '?' && (prev != null ? prev.spaced : void 0)) { + tag = 'LOGIC'; + } else if (prev && !prev.spaced) { + if (value === '(' && (_ref4 = prev[0], __indexOf.call(CALLABLE, _ref4) >= 0)) { + if (prev[0] === '?') prev[0] = 'FUNC_EXIST'; + tag = 'CALL_START'; + } else if (value === '[' && (_ref5 = prev[0], __indexOf.call(INDEXABLE, _ref5) >= 0)) { + tag = 'INDEX_START'; + switch (prev[0]) { + case '?': + prev[0] = 'INDEX_SOAK'; + } + } + } + switch (value) { + case '(': + case '{': + case '[': + this.ends.push(INVERSES[value]); + break; + case ')': + case '}': + case ']': + this.pair(value); + } + this.token(tag, value); + return value.length; + }; + + Lexer.prototype.sanitizeHeredoc = function(doc, options) { + var attempt, herecomment, indent, match, _ref2; + indent = options.indent, herecomment = options.herecomment; + if (herecomment) { + if (HEREDOC_ILLEGAL.test(doc)) { + this.error("block comment cannot contain \"*/\", starting"); + } + if (doc.indexOf('\n') <= 0) return doc; + } else { + while (match = HEREDOC_INDENT.exec(doc)) { + attempt = match[1]; + if (indent === null || (0 < (_ref2 = attempt.length) && _ref2 < indent.length)) { + indent = attempt; + } + } + } + if (indent) doc = doc.replace(RegExp("\\n" + indent, "g"), '\n'); + if (!herecomment) doc = doc.replace(/^\n/, ''); + return doc; + }; + + Lexer.prototype.tagParameters = function() { + var i, stack, tok, tokens; + if (this.tag() !== ')') return this; + stack = []; + tokens = this.tokens; + i = tokens.length; + tokens[--i][0] = 'PARAM_END'; + while (tok = tokens[--i]) { + switch (tok[0]) { + case ')': + stack.push(tok); + break; + case '(': + case 'CALL_START': + if (stack.length) { + stack.pop(); + } else if (tok[0] === '(') { + tok[0] = 'PARAM_START'; + return this; + } else { + return this; + } + } + } + return this; + }; + + Lexer.prototype.closeIndentation = function() { + return this.outdentToken(this.indent); + }; + + Lexer.prototype.balancedString = function(str, end) { + var continueCount, i, letter, match, prev, stack, _i, _ref2; + continueCount = 0; + stack = [end]; + for (i = _i = 1, _ref2 = str.length; 1 <= _ref2 ? _i < _ref2 : _i > _ref2; i = 1 <= _ref2 ? ++_i : --_i) { + if (continueCount) { + --continueCount; + continue; + } + switch (letter = str.charAt(i)) { + case '\\': + ++continueCount; + continue; + case end: + stack.pop(); + if (!stack.length) return str.slice(0, i + 1 || 9e9); + end = stack[stack.length - 1]; + continue; + } + if (end === '}' && (letter === '"' || letter === "'")) { + stack.push(end = letter); + } else if (end === '}' && letter === '/' && (match = HEREGEX.exec(str.slice(i)) || REGEX.exec(str.slice(i)))) { + continueCount += match[0].length - 1; + } else if (end === '}' && letter === '{') { + stack.push(end = '}'); + } else if (end === '"' && prev === '#' && letter === '{') { + stack.push(end = '}'); + } + prev = letter; + } + return this.error("missing " + (stack.pop()) + ", starting"); + }; + + Lexer.prototype.interpolateString = function(str, options) { + var expr, heredoc, i, inner, interpolated, len, letter, nested, pi, regex, tag, tokens, value, _i, _len, _ref2, _ref3, _ref4; + if (options == null) options = {}; + heredoc = options.heredoc, regex = options.regex; + tokens = []; + pi = 0; + i = -1; + while (letter = str.charAt(i += 1)) { + if (letter === '\\') { + i += 1; + continue; + } + if (!(letter === '#' && str.charAt(i + 1) === '{' && (expr = this.balancedString(str.slice(i + 1), '}')))) { + continue; + } + if (pi < i) tokens.push(['NEOSTRING', str.slice(pi, i)]); + inner = expr.slice(1, -1); + if (inner.length) { + nested = new Lexer().tokenize(inner, { + line: this.line, + rewrite: false + }); + nested.pop(); + if (((_ref2 = nested[0]) != null ? _ref2[0] : void 0) === 'TERMINATOR') { + nested.shift(); + } + if (len = nested.length) { + if (len > 1) { + nested.unshift(['(', '(', this.line]); + nested.push([')', ')', this.line]); + } + tokens.push(['TOKENS', nested]); + } + } + i += expr.length; + pi = i + 1; + } + if ((i > pi && pi < str.length)) tokens.push(['NEOSTRING', str.slice(pi)]); + if (regex) return tokens; + if (!tokens.length) return this.token('STRING', '""'); + if (tokens[0][0] !== 'NEOSTRING') tokens.unshift(['', '']); + if (interpolated = tokens.length > 1) this.token('(', '('); + for (i = _i = 0, _len = tokens.length; _i < _len; i = ++_i) { + _ref3 = tokens[i], tag = _ref3[0], value = _ref3[1]; + if (i) this.token('+', '+'); + if (tag === 'TOKENS') { + (_ref4 = this.tokens).push.apply(_ref4, value); + } else { + this.token('STRING', this.makeString(value, '"', heredoc)); + } + } + if (interpolated) this.token(')', ')'); + return tokens; + }; + + Lexer.prototype.pair = function(tag) { + var size, wanted; + if (tag !== (wanted = last(this.ends))) { + if ('OUTDENT' !== wanted) this.error("unmatched " + tag); + this.indent -= size = last(this.indents); + this.outdentToken(size, true); + return this.pair(tag); + } + return this.ends.pop(); + }; + + Lexer.prototype.token = function(tag, value) { + return this.tokens.push([tag, value, this.line]); + }; + + Lexer.prototype.tag = function(index, tag) { + var tok; + return (tok = last(this.tokens, index)) && (tag ? tok[0] = tag : tok[0]); + }; + + Lexer.prototype.value = function(index, val) { + var tok; + return (tok = last(this.tokens, index)) && (val ? tok[1] = val : tok[1]); + }; + + Lexer.prototype.unfinished = function() { + var _ref2; + return LINE_CONTINUER.test(this.chunk) || ((_ref2 = this.tag()) === '\\' || _ref2 === '.' || _ref2 === '?.' || _ref2 === 'UNARY' || _ref2 === 'MATH' || _ref2 === '+' || _ref2 === '-' || _ref2 === 'SHIFT' || _ref2 === 'RELATION' || _ref2 === 'COMPARE' || _ref2 === 'LOGIC' || _ref2 === 'THROW' || _ref2 === 'EXTENDS'); + }; + + Lexer.prototype.escapeLines = function(str, heredoc) { + return str.replace(MULTILINER, heredoc ? '\\n' : ''); + }; + + Lexer.prototype.makeString = function(body, quote, heredoc) { + if (!body) return quote + quote; + body = body.replace(/\\([\s\S])/g, function(match, contents) { + if (contents === '\n' || contents === quote) { + return contents; + } else { + return match; + } + }); + body = body.replace(RegExp("" + quote, "g"), '\\$&'); + return quote + this.escapeLines(body, heredoc) + quote; + }; + + Lexer.prototype.error = function(message) { + throw SyntaxError("" + message + " on line " + (this.line + 1)); + }; + + return Lexer; + + })(); + + JS_KEYWORDS = ['true', 'false', 'null', 'this', 'new', 'delete', 'typeof', 'in', 'instanceof', 'return', 'throw', 'break', 'continue', 'debugger', 'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally', 'class', 'extends', 'super']; + + COFFEE_KEYWORDS = ['undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when']; + + COFFEE_ALIAS_MAP = { + and: '&&', + or: '||', + is: '==', + isnt: '!=', + not: '!', + yes: 'true', + no: 'false', + on: 'true', + off: 'false' + }; + + COFFEE_ALIASES = (function() { + var _results; + _results = []; + for (key in COFFEE_ALIAS_MAP) { + _results.push(key); + } + return _results; + })(); + + COFFEE_KEYWORDS = COFFEE_KEYWORDS.concat(COFFEE_ALIASES); + + RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice', '__bind', '__indexOf', 'implements', 'interface', 'let', 'package', 'private', 'protected', 'public', 'static', 'yield']; + + STRICT_PROSCRIBED = ['arguments', 'eval']; + + JS_FORBIDDEN = JS_KEYWORDS.concat(RESERVED).concat(STRICT_PROSCRIBED); + + exports.RESERVED = RESERVED.concat(JS_KEYWORDS).concat(COFFEE_KEYWORDS).concat(STRICT_PROSCRIBED); + + exports.STRICT_PROSCRIBED = STRICT_PROSCRIBED; + + IDENTIFIER = /^([$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)([^\n\S]*:(?!:))?/; + + NUMBER = /^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i; + + HEREDOC = /^("""|''')([\s\S]*?)(?:\n[^\n\S]*)?\1/; + + OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/; + + WHITESPACE = /^[^\n\S]+/; + + COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|(?:###)?$)|^(?:\s*#(?!##[^#]).*)+/; + + CODE = /^[-=]>/; + + MULTI_DENT = /^(?:\n[^\n\S]*)+/; + + SIMPLESTR = /^'[^\\']*(?:\\.[^\\']*)*'/; + + JSTOKEN = /^`[^\\`]*(?:\\.[^\\`]*)*`/; + + REGEX = /^(\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)([imgy]{0,4})(?!\w)/; + + HEREGEX = /^\/{3}([\s\S]+?)\/{3}([imgy]{0,4})(?!\w)/; + + HEREGEX_OMIT = /\s+(?:#.*)?/g; + + MULTILINER = /\n/g; + + HEREDOC_INDENT = /\n+([^\n\S]*)/g; + + HEREDOC_ILLEGAL = /\*\//; + + LINE_CONTINUER = /^\s*(?:,|\??\.(?![.\d])|::)/; + + TRAILING_SPACES = /\s+$/; + + COMPOUND_ASSIGN = ['-=', '+=', '/=', '*=', '%=', '||=', '&&=', '?=', '<<=', '>>=', '>>>=', '&=', '^=', '|=']; + + UNARY = ['!', '~', 'NEW', 'TYPEOF', 'DELETE', 'DO']; + + LOGIC = ['&&', '||', '&', '|', '^']; + + SHIFT = ['<<', '>>', '>>>']; + + COMPARE = ['==', '!=', '<', '>', '<=', '>=']; + + MATH = ['*', '/', '%']; + + RELATION = ['IN', 'OF', 'INSTANCEOF']; + + BOOL = ['TRUE', 'FALSE', 'NULL', 'UNDEFINED']; + + NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', '++', '--', ']']; + + NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING'); + + CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER']; + + INDEXABLE = CALLABLE.concat('NUMBER', 'BOOL'); + + LINE_BREAK = ['INDENT', 'OUTDENT', 'TERMINATOR']; + + +}); + +define('ace/mode/coffee/rewriter', ['require', 'exports', 'module' ], function(require, exports, module) { +// Generated by CoffeeScript 1.2.1-pre + + var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, left, rite, _i, _len, _ref, + __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, + __slice = [].slice; + + exports.Rewriter = (function() { + + Rewriter.name = 'Rewriter'; + + function Rewriter() {} + + Rewriter.prototype.rewrite = function(tokens) { + this.tokens = tokens; + this.removeLeadingNewlines(); + this.removeMidExpressionNewlines(); + this.closeOpenCalls(); + this.closeOpenIndexes(); + this.addImplicitIndentation(); + this.tagPostfixConditionals(); + this.addImplicitBraces(); + this.addImplicitParentheses(); + return this.tokens; + }; + + Rewriter.prototype.scanTokens = function(block) { + var i, token, tokens; + tokens = this.tokens; + i = 0; + while (token = tokens[i]) { + i += block.call(this, token, i, tokens); + } + return true; + }; + + Rewriter.prototype.detectEnd = function(i, condition, action) { + var levels, token, tokens, _ref, _ref1; + tokens = this.tokens; + levels = 0; + while (token = tokens[i]) { + if (levels === 0 && condition.call(this, token, i)) { + return action.call(this, token, i); + } + if (!token || levels < 0) return action.call(this, token, i - 1); + if (_ref = token[0], __indexOf.call(EXPRESSION_START, _ref) >= 0) { + levels += 1; + } else if (_ref1 = token[0], __indexOf.call(EXPRESSION_END, _ref1) >= 0) { + levels -= 1; + } + i += 1; + } + return i - 1; + }; + + Rewriter.prototype.removeLeadingNewlines = function() { + var i, tag, _i, _len, _ref; + _ref = this.tokens; + for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { + tag = _ref[i][0]; + if (tag !== 'TERMINATOR') break; + } + if (i) return this.tokens.splice(0, i); + }; + + Rewriter.prototype.removeMidExpressionNewlines = function() { + return this.scanTokens(function(token, i, tokens) { + var _ref; + if (!(token[0] === 'TERMINATOR' && (_ref = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref) >= 0))) { + return 1; + } + tokens.splice(i, 1); + return 0; + }); + }; + + Rewriter.prototype.closeOpenCalls = function() { + var action, condition; + condition = function(token, i) { + var _ref; + return ((_ref = token[0]) === ')' || _ref === 'CALL_END') || token[0] === 'OUTDENT' && this.tag(i - 1) === ')'; + }; + action = function(token, i) { + return this.tokens[token[0] === 'OUTDENT' ? i - 1 : i][0] = 'CALL_END'; + }; + return this.scanTokens(function(token, i) { + if (token[0] === 'CALL_START') this.detectEnd(i + 1, condition, action); + return 1; + }); + }; + + Rewriter.prototype.closeOpenIndexes = function() { + var action, condition; + condition = function(token, i) { + var _ref; + return (_ref = token[0]) === ']' || _ref === 'INDEX_END'; + }; + action = function(token, i) { + return token[0] = 'INDEX_END'; + }; + return this.scanTokens(function(token, i) { + if (token[0] === 'INDEX_START') this.detectEnd(i + 1, condition, action); + return 1; + }); + }; + + Rewriter.prototype.addImplicitBraces = function() { + var action, condition, sameLine, stack, start, startIndent, startsLine; + stack = []; + start = null; + startsLine = null; + sameLine = true; + startIndent = 0; + condition = function(token, i) { + var one, tag, three, two, _ref, _ref1; + _ref = this.tokens.slice(i + 1, (i + 3) + 1 || 9e9), one = _ref[0], two = _ref[1], three = _ref[2]; + if ('HERECOMMENT' === (one != null ? one[0] : void 0)) return false; + tag = token[0]; + if (__indexOf.call(LINEBREAKS, tag) >= 0) sameLine = false; + return (((tag === 'TERMINATOR' || tag === 'OUTDENT') || (__indexOf.call(IMPLICIT_END, tag) >= 0 && sameLine)) && ((!startsLine && this.tag(i - 1) !== ',') || !((two != null ? two[0] : void 0) === ':' || (one != null ? one[0] : void 0) === '@' && (three != null ? three[0] : void 0) === ':'))) || (tag === ',' && one && ((_ref1 = one[0]) !== 'IDENTIFIER' && _ref1 !== 'NUMBER' && _ref1 !== 'STRING' && _ref1 !== '@' && _ref1 !== 'TERMINATOR' && _ref1 !== 'OUTDENT')); + }; + action = function(token, i) { + var tok; + tok = this.generate('}', '}', token[2]); + return this.tokens.splice(i, 0, tok); + }; + return this.scanTokens(function(token, i, tokens) { + var ago, idx, prevTag, tag, tok, value, _ref, _ref1; + if (_ref = (tag = token[0]), __indexOf.call(EXPRESSION_START, _ref) >= 0) { + stack.push([(tag === 'INDENT' && this.tag(i - 1) === '{' ? '{' : tag), i]); + return 1; + } + if (__indexOf.call(EXPRESSION_END, tag) >= 0) { + start = stack.pop(); + return 1; + } + if (!(tag === ':' && ((ago = this.tag(i - 2)) === ':' || ((_ref1 = stack[stack.length - 1]) != null ? _ref1[0] : void 0) !== '{'))) { + return 1; + } + sameLine = true; + stack.push(['{']); + idx = ago === '@' ? i - 2 : i - 1; + while (this.tag(idx - 2) === 'HERECOMMENT') { + idx -= 2; + } + prevTag = this.tag(idx - 1); + startsLine = !prevTag || (__indexOf.call(LINEBREAKS, prevTag) >= 0); + value = new String('{'); + value.generated = true; + tok = this.generate('{', value, token[2]); + tokens.splice(idx, 0, tok); + this.detectEnd(i + 2, condition, action); + return 2; + }); + }; + + Rewriter.prototype.addImplicitParentheses = function() { + var action, condition, noCall, seenControl, seenSingle; + noCall = seenSingle = seenControl = false; + condition = function(token, i) { + var post, tag, _ref, _ref1; + tag = token[0]; + if (!seenSingle && token.fromThen) return true; + if (tag === 'IF' || tag === 'ELSE' || tag === 'CATCH' || tag === '->' || tag === '=>' || tag === 'CLASS') { + seenSingle = true; + } + if (tag === 'IF' || tag === 'ELSE' || tag === 'SWITCH' || tag === 'TRY' || tag === '=') { + seenControl = true; + } + if ((tag === '.' || tag === '?.' || tag === '::') && this.tag(i - 1) === 'OUTDENT') { + return true; + } + return !token.generated && this.tag(i - 1) !== ',' && (__indexOf.call(IMPLICIT_END, tag) >= 0 || (tag === 'INDENT' && !seenControl)) && (tag !== 'INDENT' || (((_ref = this.tag(i - 2)) !== 'CLASS' && _ref !== 'EXTENDS') && (_ref1 = this.tag(i - 1), __indexOf.call(IMPLICIT_BLOCK, _ref1) < 0) && !((post = this.tokens[i + 1]) && post.generated && post[0] === '{'))); + }; + action = function(token, i) { + return this.tokens.splice(i, 0, this.generate('CALL_END', ')', token[2])); + }; + return this.scanTokens(function(token, i, tokens) { + var callObject, current, next, prev, tag, _ref, _ref1, _ref2; + tag = token[0]; + if (tag === 'CLASS' || tag === 'IF' || tag === 'FOR' || tag === 'WHILE') { + noCall = true; + } + _ref = tokens.slice(i - 1, (i + 1) + 1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2]; + callObject = !noCall && tag === 'INDENT' && next && next.generated && next[0] === '{' && prev && (_ref1 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref1) >= 0); + seenSingle = false; + seenControl = false; + if (__indexOf.call(LINEBREAKS, tag) >= 0) noCall = false; + if (prev && !prev.spaced && tag === '?') token.call = true; + if (token.fromThen) return 1; + if (!(callObject || (prev != null ? prev.spaced : void 0) && (prev.call || (_ref2 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref2) >= 0)) && (__indexOf.call(IMPLICIT_CALL, tag) >= 0 || !(token.spaced || token.newLine) && __indexOf.call(IMPLICIT_UNSPACED_CALL, tag) >= 0))) { + return 1; + } + tokens.splice(i, 0, this.generate('CALL_START', '(', token[2])); + this.detectEnd(i + 1, condition, action); + if (prev[0] === '?') prev[0] = 'FUNC_EXIST'; + return 2; + }); + }; + + Rewriter.prototype.addImplicitIndentation = function() { + var action, condition, indent, outdent, starter; + starter = indent = outdent = null; + condition = function(token, i) { + var _ref; + return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'ELSE' && (starter !== 'IF' && starter !== 'THEN')); + }; + action = function(token, i) { + return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent); + }; + return this.scanTokens(function(token, i, tokens) { + var tag, _ref, _ref1; + tag = token[0]; + if (tag === 'TERMINATOR' && this.tag(i + 1) === 'THEN') { + tokens.splice(i, 1); + return 0; + } + if (tag === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') { + tokens.splice.apply(tokens, [i, 0].concat(__slice.call(this.indentation(token)))); + return 2; + } + if (tag === 'CATCH' && ((_ref = this.tag(i + 2)) === 'OUTDENT' || _ref === 'TERMINATOR' || _ref === 'FINALLY')) { + tokens.splice.apply(tokens, [i + 2, 0].concat(__slice.call(this.indentation(token)))); + return 4; + } + if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) { + starter = tag; + _ref1 = this.indentation(token, true), indent = _ref1[0], outdent = _ref1[1]; + if (starter === 'THEN') indent.fromThen = true; + tokens.splice(i + 1, 0, indent); + this.detectEnd(i + 2, condition, action); + if (tag === 'THEN') tokens.splice(i, 1); + return 1; + } + return 1; + }); + }; + + Rewriter.prototype.tagPostfixConditionals = function() { + var action, condition, original; + original = null; + condition = function(token, i) { + var _ref; + return (_ref = token[0]) === 'TERMINATOR' || _ref === 'INDENT'; + }; + action = function(token, i) { + if (token[0] !== 'INDENT' || (token.generated && !token.fromThen)) { + return original[0] = 'POST_' + original[0]; + } + }; + return this.scanTokens(function(token, i) { + if (token[0] !== 'IF') return 1; + original = token; + this.detectEnd(i + 1, condition, action); + return 1; + }); + }; + + Rewriter.prototype.indentation = function(token, implicit) { + var indent, outdent; + if (implicit == null) implicit = false; + indent = ['INDENT', 2, token[2]]; + outdent = ['OUTDENT', 2, token[2]]; + if (implicit) indent.generated = outdent.generated = true; + return [indent, outdent]; + }; + + Rewriter.prototype.generate = function(tag, value, line) { + var tok; + tok = [tag, value, line]; + tok.generated = true; + return tok; + }; + + Rewriter.prototype.tag = function(i) { + var _ref; + return (_ref = this.tokens[i]) != null ? _ref[0] : void 0; + }; + + return Rewriter; + + })(); + + BALANCED_PAIRS = [['(', ')'], ['[', ']'], ['{', '}'], ['INDENT', 'OUTDENT'], ['CALL_START', 'CALL_END'], ['PARAM_START', 'PARAM_END'], ['INDEX_START', 'INDEX_END']]; + + exports.INVERSES = INVERSES = {}; + + EXPRESSION_START = []; + + EXPRESSION_END = []; + + for (_i = 0, _len = BALANCED_PAIRS.length; _i < _len; _i++) { + _ref = BALANCED_PAIRS[_i], left = _ref[0], rite = _ref[1]; + EXPRESSION_START.push(INVERSES[rite] = left); + EXPRESSION_END.push(INVERSES[left] = rite); + } + + EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_END); + + IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS']; + + IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'UNARY', 'SUPER', '@', '->', '=>', '[', '(', '{', '--', '++']; + + IMPLICIT_UNSPACED_CALL = ['+', '-']; + + IMPLICIT_BLOCK = ['->', '=>', '{', '[', ',']; + + IMPLICIT_END = ['POST_IF', 'FOR', 'WHILE', 'UNTIL', 'WHEN', 'BY', 'LOOP', 'TERMINATOR']; + + SINGLE_LINERS = ['ELSE', '->', '=>', 'TRY', 'FINALLY', 'THEN']; + + SINGLE_CLOSERS = ['TERMINATOR', 'CATCH', 'FINALLY', 'ELSE', 'OUTDENT', 'LEADING_WHEN']; + + LINEBREAKS = ['TERMINATOR', 'INDENT', 'OUTDENT']; + + +}); + +define('ace/mode/coffee/helpers', ['require', 'exports', 'module' ], function(require, exports, module) { +// Generated by CoffeeScript 1.2.1-pre + + var extend, flatten; + + exports.starts = function(string, literal, start) { + return literal === string.substr(start, literal.length); + }; + + exports.ends = function(string, literal, back) { + var len; + len = literal.length; + return literal === string.substr(string.length - len - (back || 0), len); + }; + + exports.compact = function(array) { + var item, _i, _len, _results; + _results = []; + for (_i = 0, _len = array.length; _i < _len; _i++) { + item = array[_i]; + if (item) _results.push(item); + } + return _results; + }; + + exports.count = function(string, substr) { + var num, pos; + num = pos = 0; + if (!substr.length) return 1 / 0; + while (pos = 1 + string.indexOf(substr, pos)) { + num++; + } + return num; + }; + + exports.merge = function(options, overrides) { + return extend(extend({}, options), overrides); + }; + + extend = exports.extend = function(object, properties) { + var key, val; + for (key in properties) { + val = properties[key]; + object[key] = val; + } + return object; + }; + + exports.flatten = flatten = function(array) { + var element, flattened, _i, _len; + flattened = []; + for (_i = 0, _len = array.length; _i < _len; _i++) { + element = array[_i]; + if (element instanceof Array) { + flattened = flattened.concat(flatten(element)); + } else { + flattened.push(element); + } + } + return flattened; + }; + + exports.del = function(obj, key) { + var val; + val = obj[key]; + delete obj[key]; + return val; + }; + + exports.last = function(array, back) { + return array[array.length - (back || 0) - 1]; + }; + + +}); + +define('ace/mode/coffee/parser', ['require', 'exports', 'module' ], function(require, exports, module) { +/* Jison generated parser */ + +undefined +var parser = {trace: function trace() { }, +yy: {}, +symbols_: {"error":2,"Root":3,"Body":4,"Block":5,"TERMINATOR":6,"Line":7,"Expression":8,"Statement":9,"Return":10,"Comment":11,"STATEMENT":12,"Value":13,"Invocation":14,"Code":15,"Operation":16,"Assign":17,"If":18,"Try":19,"While":20,"For":21,"Switch":22,"Class":23,"Throw":24,"INDENT":25,"OUTDENT":26,"Identifier":27,"IDENTIFIER":28,"AlphaNumeric":29,"NUMBER":30,"STRING":31,"Literal":32,"JS":33,"REGEX":34,"DEBUGGER":35,"BOOL":36,"Assignable":37,"=":38,"AssignObj":39,"ObjAssignable":40,":":41,"ThisProperty":42,"RETURN":43,"HERECOMMENT":44,"PARAM_START":45,"ParamList":46,"PARAM_END":47,"FuncGlyph":48,"->":49,"=>":50,"OptComma":51,",":52,"Param":53,"ParamVar":54,"...":55,"Array":56,"Object":57,"Splat":58,"SimpleAssignable":59,"Accessor":60,"Parenthetical":61,"Range":62,"This":63,".":64,"?.":65,"::":66,"Index":67,"INDEX_START":68,"IndexValue":69,"INDEX_END":70,"INDEX_SOAK":71,"Slice":72,"{":73,"AssignList":74,"}":75,"CLASS":76,"EXTENDS":77,"OptFuncExist":78,"Arguments":79,"SUPER":80,"FUNC_EXIST":81,"CALL_START":82,"CALL_END":83,"ArgList":84,"THIS":85,"@":86,"[":87,"]":88,"RangeDots":89,"..":90,"Arg":91,"SimpleArgs":92,"TRY":93,"Catch":94,"FINALLY":95,"CATCH":96,"THROW":97,"(":98,")":99,"WhileSource":100,"WHILE":101,"WHEN":102,"UNTIL":103,"Loop":104,"LOOP":105,"ForBody":106,"FOR":107,"ForStart":108,"ForSource":109,"ForVariables":110,"OWN":111,"ForValue":112,"FORIN":113,"FOROF":114,"BY":115,"SWITCH":116,"Whens":117,"ELSE":118,"When":119,"LEADING_WHEN":120,"IfBlock":121,"IF":122,"POST_IF":123,"UNARY":124,"-":125,"+":126,"--":127,"++":128,"?":129,"MATH":130,"SHIFT":131,"COMPARE":132,"LOGIC":133,"RELATION":134,"COMPOUND_ASSIGN":135,"$accept":0,"$end":1}, +terminals_: {2:"error",6:"TERMINATOR",12:"STATEMENT",25:"INDENT",26:"OUTDENT",28:"IDENTIFIER",30:"NUMBER",31:"STRING",33:"JS",34:"REGEX",35:"DEBUGGER",36:"BOOL",38:"=",41:":",43:"RETURN",44:"HERECOMMENT",45:"PARAM_START",47:"PARAM_END",49:"->",50:"=>",52:",",55:"...",64:".",65:"?.",66:"::",68:"INDEX_START",70:"INDEX_END",71:"INDEX_SOAK",73:"{",75:"}",76:"CLASS",77:"EXTENDS",80:"SUPER",81:"FUNC_EXIST",82:"CALL_START",83:"CALL_END",85:"THIS",86:"@",87:"[",88:"]",90:"..",93:"TRY",95:"FINALLY",96:"CATCH",97:"THROW",98:"(",99:")",101:"WHILE",102:"WHEN",103:"UNTIL",105:"LOOP",107:"FOR",111:"OWN",113:"FORIN",114:"FOROF",115:"BY",116:"SWITCH",118:"ELSE",120:"LEADING_WHEN",122:"IF",123:"POST_IF",124:"UNARY",125:"-",126:"+",127:"--",128:"++",129:"?",130:"MATH",131:"SHIFT",132:"COMPARE",133:"LOGIC",134:"RELATION",135:"COMPOUND_ASSIGN"}, +productions_: [0,[3,0],[3,1],[3,2],[4,1],[4,3],[4,2],[7,1],[7,1],[9,1],[9,1],[9,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[5,2],[5,3],[27,1],[29,1],[29,1],[32,1],[32,1],[32,1],[32,1],[32,1],[17,3],[17,4],[17,5],[39,1],[39,3],[39,5],[39,1],[40,1],[40,1],[40,1],[10,2],[10,1],[11,1],[15,5],[15,2],[48,1],[48,1],[51,0],[51,1],[46,0],[46,1],[46,3],[53,1],[53,2],[53,3],[54,1],[54,1],[54,1],[54,1],[58,2],[59,1],[59,2],[59,2],[59,1],[37,1],[37,1],[37,1],[13,1],[13,1],[13,1],[13,1],[13,1],[60,2],[60,2],[60,2],[60,1],[60,1],[67,3],[67,2],[69,1],[69,1],[57,4],[74,0],[74,1],[74,3],[74,4],[74,6],[23,1],[23,2],[23,3],[23,4],[23,2],[23,3],[23,4],[23,5],[14,3],[14,3],[14,1],[14,2],[78,0],[78,1],[79,2],[79,4],[63,1],[63,1],[42,2],[56,2],[56,4],[89,1],[89,1],[62,5],[72,3],[72,2],[72,2],[72,1],[84,1],[84,3],[84,4],[84,4],[84,6],[91,1],[91,1],[92,1],[92,3],[19,2],[19,3],[19,4],[19,5],[94,3],[24,2],[61,3],[61,5],[100,2],[100,4],[100,2],[100,4],[20,2],[20,2],[20,2],[20,1],[104,2],[104,2],[21,2],[21,2],[21,2],[106,2],[106,2],[108,2],[108,3],[112,1],[112,1],[112,1],[110,1],[110,3],[109,2],[109,2],[109,4],[109,4],[109,4],[109,6],[109,6],[22,5],[22,7],[22,4],[22,6],[117,1],[117,2],[119,3],[119,4],[121,3],[121,5],[18,1],[18,3],[18,3],[18,3],[16,2],[16,2],[16,2],[16,2],[16,2],[16,2],[16,2],[16,2],[16,3],[16,3],[16,3],[16,3],[16,3],[16,3],[16,3],[16,3],[16,5],[16,3]], +performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) { + +var $0 = $$.length - 1; +switch (yystate) { +case 1:return this.$ = new yy.Block; +break; +case 2:return this.$ = $$[$0]; +break; +case 3:return this.$ = $$[$0-1]; +break; +case 4:this.$ = yy.Block.wrap([$$[$0]]); +break; +case 5:this.$ = $$[$0-2].push($$[$0]); +break; +case 6:this.$ = $$[$0-1]; +break; +case 7:this.$ = $$[$0]; +break; +case 8:this.$ = $$[$0]; +break; +case 9:this.$ = $$[$0]; +break; +case 10:this.$ = $$[$0]; +break; +case 11:this.$ = new yy.Literal($$[$0]); +break; +case 12:this.$ = $$[$0]; +break; +case 13:this.$ = $$[$0]; +break; +case 14:this.$ = $$[$0]; +break; +case 15:this.$ = $$[$0]; +break; +case 16:this.$ = $$[$0]; +break; +case 17:this.$ = $$[$0]; +break; +case 18:this.$ = $$[$0]; +break; +case 19:this.$ = $$[$0]; +break; +case 20:this.$ = $$[$0]; +break; +case 21:this.$ = $$[$0]; +break; +case 22:this.$ = $$[$0]; +break; +case 23:this.$ = $$[$0]; +break; +case 24:this.$ = new yy.Block; +break; +case 25:this.$ = $$[$0-1]; +break; +case 26:this.$ = new yy.Literal($$[$0]); +break; +case 27:this.$ = new yy.Literal($$[$0]); +break; +case 28:this.$ = new yy.Literal($$[$0]); +break; +case 29:this.$ = $$[$0]; +break; +case 30:this.$ = new yy.Literal($$[$0]); +break; +case 31:this.$ = new yy.Literal($$[$0]); +break; +case 32:this.$ = new yy.Literal($$[$0]); +break; +case 33:this.$ = (function () { + var val; + val = new yy.Literal($$[$0]); + if ($$[$0] === 'undefined') val.isUndefined = true; + return val; + }()); +break; +case 34:this.$ = new yy.Assign($$[$0-2], $$[$0]); +break; +case 35:this.$ = new yy.Assign($$[$0-3], $$[$0]); +break; +case 36:this.$ = new yy.Assign($$[$0-4], $$[$0-1]); +break; +case 37:this.$ = new yy.Value($$[$0]); +break; +case 38:this.$ = new yy.Assign(new yy.Value($$[$0-2]), $$[$0], 'object'); +break; +case 39:this.$ = new yy.Assign(new yy.Value($$[$0-4]), $$[$0-1], 'object'); +break; +case 40:this.$ = $$[$0]; +break; +case 41:this.$ = $$[$0]; +break; +case 42:this.$ = $$[$0]; +break; +case 43:this.$ = $$[$0]; +break; +case 44:this.$ = new yy.Return($$[$0]); +break; +case 45:this.$ = new yy.Return; +break; +case 46:this.$ = new yy.Comment($$[$0]); +break; +case 47:this.$ = new yy.Code($$[$0-3], $$[$0], $$[$0-1]); +break; +case 48:this.$ = new yy.Code([], $$[$0], $$[$0-1]); +break; +case 49:this.$ = 'func'; +break; +case 50:this.$ = 'boundfunc'; +break; +case 51:this.$ = $$[$0]; +break; +case 52:this.$ = $$[$0]; +break; +case 53:this.$ = []; +break; +case 54:this.$ = [$$[$0]]; +break; +case 55:this.$ = $$[$0-2].concat($$[$0]); +break; +case 56:this.$ = new yy.Param($$[$0]); +break; +case 57:this.$ = new yy.Param($$[$0-1], null, true); +break; +case 58:this.$ = new yy.Param($$[$0-2], $$[$0]); +break; +case 59:this.$ = $$[$0]; +break; +case 60:this.$ = $$[$0]; +break; +case 61:this.$ = $$[$0]; +break; +case 62:this.$ = $$[$0]; +break; +case 63:this.$ = new yy.Splat($$[$0-1]); +break; +case 64:this.$ = new yy.Value($$[$0]); +break; +case 65:this.$ = $$[$0-1].add($$[$0]); +break; +case 66:this.$ = new yy.Value($$[$0-1], [].concat($$[$0])); +break; +case 67:this.$ = $$[$0]; +break; +case 68:this.$ = $$[$0]; +break; +case 69:this.$ = new yy.Value($$[$0]); +break; +case 70:this.$ = new yy.Value($$[$0]); +break; +case 71:this.$ = $$[$0]; +break; +case 72:this.$ = new yy.Value($$[$0]); +break; +case 73:this.$ = new yy.Value($$[$0]); +break; +case 74:this.$ = new yy.Value($$[$0]); +break; +case 75:this.$ = $$[$0]; +break; +case 76:this.$ = new yy.Access($$[$0]); +break; +case 77:this.$ = new yy.Access($$[$0], 'soak'); +break; +case 78:this.$ = [new yy.Access(new yy.Literal('prototype')), new yy.Access($$[$0])]; +break; +case 79:this.$ = new yy.Access(new yy.Literal('prototype')); +break; +case 80:this.$ = $$[$0]; +break; +case 81:this.$ = $$[$0-1]; +break; +case 82:this.$ = yy.extend($$[$0], { + soak: true + }); +break; +case 83:this.$ = new yy.Index($$[$0]); +break; +case 84:this.$ = new yy.Slice($$[$0]); +break; +case 85:this.$ = new yy.Obj($$[$0-2], $$[$0-3].generated); +break; +case 86:this.$ = []; +break; +case 87:this.$ = [$$[$0]]; +break; +case 88:this.$ = $$[$0-2].concat($$[$0]); +break; +case 89:this.$ = $$[$0-3].concat($$[$0]); +break; +case 90:this.$ = $$[$0-5].concat($$[$0-2]); +break; +case 91:this.$ = new yy.Class; +break; +case 92:this.$ = new yy.Class(null, null, $$[$0]); +break; +case 93:this.$ = new yy.Class(null, $$[$0]); +break; +case 94:this.$ = new yy.Class(null, $$[$0-1], $$[$0]); +break; +case 95:this.$ = new yy.Class($$[$0]); +break; +case 96:this.$ = new yy.Class($$[$0-1], null, $$[$0]); +break; +case 97:this.$ = new yy.Class($$[$0-2], $$[$0]); +break; +case 98:this.$ = new yy.Class($$[$0-3], $$[$0-1], $$[$0]); +break; +case 99:this.$ = new yy.Call($$[$0-2], $$[$0], $$[$0-1]); +break; +case 100:this.$ = new yy.Call($$[$0-2], $$[$0], $$[$0-1]); +break; +case 101:this.$ = new yy.Call('super', [new yy.Splat(new yy.Literal('arguments'))]); +break; +case 102:this.$ = new yy.Call('super', $$[$0]); +break; +case 103:this.$ = false; +break; +case 104:this.$ = true; +break; +case 105:this.$ = []; +break; +case 106:this.$ = $$[$0-2]; +break; +case 107:this.$ = new yy.Value(new yy.Literal('this')); +break; +case 108:this.$ = new yy.Value(new yy.Literal('this')); +break; +case 109:this.$ = new yy.Value(new yy.Literal('this'), [new yy.Access($$[$0])], 'this'); +break; +case 110:this.$ = new yy.Arr([]); +break; +case 111:this.$ = new yy.Arr($$[$0-2]); +break; +case 112:this.$ = 'inclusive'; +break; +case 113:this.$ = 'exclusive'; +break; +case 114:this.$ = new yy.Range($$[$0-3], $$[$0-1], $$[$0-2]); +break; +case 115:this.$ = new yy.Range($$[$0-2], $$[$0], $$[$0-1]); +break; +case 116:this.$ = new yy.Range($$[$0-1], null, $$[$0]); +break; +case 117:this.$ = new yy.Range(null, $$[$0], $$[$0-1]); +break; +case 118:this.$ = new yy.Range(null, null, $$[$0]); +break; +case 119:this.$ = [$$[$0]]; +break; +case 120:this.$ = $$[$0-2].concat($$[$0]); +break; +case 121:this.$ = $$[$0-3].concat($$[$0]); +break; +case 122:this.$ = $$[$0-2]; +break; +case 123:this.$ = $$[$0-5].concat($$[$0-2]); +break; +case 124:this.$ = $$[$0]; +break; +case 125:this.$ = $$[$0]; +break; +case 126:this.$ = $$[$0]; +break; +case 127:this.$ = [].concat($$[$0-2], $$[$0]); +break; +case 128:this.$ = new yy.Try($$[$0]); +break; +case 129:this.$ = new yy.Try($$[$0-1], $$[$0][0], $$[$0][1]); +break; +case 130:this.$ = new yy.Try($$[$0-2], null, null, $$[$0]); +break; +case 131:this.$ = new yy.Try($$[$0-3], $$[$0-2][0], $$[$0-2][1], $$[$0]); +break; +case 132:this.$ = [$$[$0-1], $$[$0]]; +break; +case 133:this.$ = new yy.Throw($$[$0]); +break; +case 134:this.$ = new yy.Parens($$[$0-1]); +break; +case 135:this.$ = new yy.Parens($$[$0-2]); +break; +case 136:this.$ = new yy.While($$[$0]); +break; +case 137:this.$ = new yy.While($$[$0-2], { + guard: $$[$0] + }); +break; +case 138:this.$ = new yy.While($$[$0], { + invert: true + }); +break; +case 139:this.$ = new yy.While($$[$0-2], { + invert: true, + guard: $$[$0] + }); +break; +case 140:this.$ = $$[$0-1].addBody($$[$0]); +break; +case 141:this.$ = $$[$0].addBody(yy.Block.wrap([$$[$0-1]])); +break; +case 142:this.$ = $$[$0].addBody(yy.Block.wrap([$$[$0-1]])); +break; +case 143:this.$ = $$[$0]; +break; +case 144:this.$ = new yy.While(new yy.Literal('true')).addBody($$[$0]); +break; +case 145:this.$ = new yy.While(new yy.Literal('true')).addBody(yy.Block.wrap([$$[$0]])); +break; +case 146:this.$ = new yy.For($$[$0-1], $$[$0]); +break; +case 147:this.$ = new yy.For($$[$0-1], $$[$0]); +break; +case 148:this.$ = new yy.For($$[$0], $$[$0-1]); +break; +case 149:this.$ = { + source: new yy.Value($$[$0]) + }; +break; +case 150:this.$ = (function () { + $$[$0].own = $$[$0-1].own; + $$[$0].name = $$[$0-1][0]; + $$[$0].index = $$[$0-1][1]; + return $$[$0]; + }()); +break; +case 151:this.$ = $$[$0]; +break; +case 152:this.$ = (function () { + $$[$0].own = true; + return $$[$0]; + }()); +break; +case 153:this.$ = $$[$0]; +break; +case 154:this.$ = new yy.Value($$[$0]); +break; +case 155:this.$ = new yy.Value($$[$0]); +break; +case 156:this.$ = [$$[$0]]; +break; +case 157:this.$ = [$$[$0-2], $$[$0]]; +break; +case 158:this.$ = { + source: $$[$0] + }; +break; +case 159:this.$ = { + source: $$[$0], + object: true + }; +break; +case 160:this.$ = { + source: $$[$0-2], + guard: $$[$0] + }; +break; +case 161:this.$ = { + source: $$[$0-2], + guard: $$[$0], + object: true + }; +break; +case 162:this.$ = { + source: $$[$0-2], + step: $$[$0] + }; +break; +case 163:this.$ = { + source: $$[$0-4], + guard: $$[$0-2], + step: $$[$0] + }; +break; +case 164:this.$ = { + source: $$[$0-4], + step: $$[$0-2], + guard: $$[$0] + }; +break; +case 165:this.$ = new yy.Switch($$[$0-3], $$[$0-1]); +break; +case 166:this.$ = new yy.Switch($$[$0-5], $$[$0-3], $$[$0-1]); +break; +case 167:this.$ = new yy.Switch(null, $$[$0-1]); +break; +case 168:this.$ = new yy.Switch(null, $$[$0-3], $$[$0-1]); +break; +case 169:this.$ = $$[$0]; +break; +case 170:this.$ = $$[$0-1].concat($$[$0]); +break; +case 171:this.$ = [[$$[$0-1], $$[$0]]]; +break; +case 172:this.$ = [[$$[$0-2], $$[$0-1]]]; +break; +case 173:this.$ = new yy.If($$[$0-1], $$[$0], { + type: $$[$0-2] + }); +break; +case 174:this.$ = $$[$0-4].addElse(new yy.If($$[$0-1], $$[$0], { + type: $$[$0-2] + })); +break; +case 175:this.$ = $$[$0]; +break; +case 176:this.$ = $$[$0-2].addElse($$[$0]); +break; +case 177:this.$ = new yy.If($$[$0], yy.Block.wrap([$$[$0-2]]), { + type: $$[$0-1], + statement: true + }); +break; +case 178:this.$ = new yy.If($$[$0], yy.Block.wrap([$$[$0-2]]), { + type: $$[$0-1], + statement: true + }); +break; +case 179:this.$ = new yy.Op($$[$0-1], $$[$0]); +break; +case 180:this.$ = new yy.Op('-', $$[$0]); +break; +case 181:this.$ = new yy.Op('+', $$[$0]); +break; +case 182:this.$ = new yy.Op('--', $$[$0]); +break; +case 183:this.$ = new yy.Op('++', $$[$0]); +break; +case 184:this.$ = new yy.Op('--', $$[$0-1], null, true); +break; +case 185:this.$ = new yy.Op('++', $$[$0-1], null, true); +break; +case 186:this.$ = new yy.Existence($$[$0-1]); +break; +case 187:this.$ = new yy.Op('+', $$[$0-2], $$[$0]); +break; +case 188:this.$ = new yy.Op('-', $$[$0-2], $$[$0]); +break; +case 189:this.$ = new yy.Op($$[$0-1], $$[$0-2], $$[$0]); +break; +case 190:this.$ = new yy.Op($$[$0-1], $$[$0-2], $$[$0]); +break; +case 191:this.$ = new yy.Op($$[$0-1], $$[$0-2], $$[$0]); +break; +case 192:this.$ = new yy.Op($$[$0-1], $$[$0-2], $$[$0]); +break; +case 193:this.$ = (function () { + if ($$[$0-1].charAt(0) === '!') { + return new yy.Op($$[$0-1].slice(1), $$[$0-2], $$[$0]).invert(); + } else { + return new yy.Op($$[$0-1], $$[$0-2], $$[$0]); + } + }()); +break; +case 194:this.$ = new yy.Assign($$[$0-2], $$[$0], $$[$0-1]); +break; +case 195:this.$ = new yy.Assign($$[$0-4], $$[$0-1], $$[$0-3]); +break; +case 196:this.$ = new yy.Extends($$[$0-2], $$[$0]); +break; +} +}, +table: [{1:[2,1],3:1,4:2,5:3,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,5],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[3]},{1:[2,2],6:[1,72]},{6:[1,73]},{1:[2,4],6:[2,4],26:[2,4],99:[2,4]},{4:75,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,26:[1,74],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,7],6:[2,7],26:[2,7],99:[2,7],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,8],6:[2,8],26:[2,8],99:[2,8],100:88,101:[1,63],103:[1,64],106:89,107:[1,66],108:67,123:[1,87]},{1:[2,12],6:[2,12],25:[2,12],26:[2,12],47:[2,12],52:[2,12],55:[2,12],60:91,64:[1,93],65:[1,94],66:[1,95],67:96,68:[1,97],70:[2,12],71:[1,98],75:[2,12],78:90,81:[1,92],82:[2,103],83:[2,12],88:[2,12],90:[2,12],99:[2,12],101:[2,12],102:[2,12],103:[2,12],107:[2,12],115:[2,12],123:[2,12],125:[2,12],126:[2,12],129:[2,12],130:[2,12],131:[2,12],132:[2,12],133:[2,12],134:[2,12]},{1:[2,13],6:[2,13],25:[2,13],26:[2,13],47:[2,13],52:[2,13],55:[2,13],60:100,64:[1,93],65:[1,94],66:[1,95],67:96,68:[1,97],70:[2,13],71:[1,98],75:[2,13],78:99,81:[1,92],82:[2,103],83:[2,13],88:[2,13],90:[2,13],99:[2,13],101:[2,13],102:[2,13],103:[2,13],107:[2,13],115:[2,13],123:[2,13],125:[2,13],126:[2,13],129:[2,13],130:[2,13],131:[2,13],132:[2,13],133:[2,13],134:[2,13]},{1:[2,14],6:[2,14],25:[2,14],26:[2,14],47:[2,14],52:[2,14],55:[2,14],70:[2,14],75:[2,14],83:[2,14],88:[2,14],90:[2,14],99:[2,14],101:[2,14],102:[2,14],103:[2,14],107:[2,14],115:[2,14],123:[2,14],125:[2,14],126:[2,14],129:[2,14],130:[2,14],131:[2,14],132:[2,14],133:[2,14],134:[2,14]},{1:[2,15],6:[2,15],25:[2,15],26:[2,15],47:[2,15],52:[2,15],55:[2,15],70:[2,15],75:[2,15],83:[2,15],88:[2,15],90:[2,15],99:[2,15],101:[2,15],102:[2,15],103:[2,15],107:[2,15],115:[2,15],123:[2,15],125:[2,15],126:[2,15],129:[2,15],130:[2,15],131:[2,15],132:[2,15],133:[2,15],134:[2,15]},{1:[2,16],6:[2,16],25:[2,16],26:[2,16],47:[2,16],52:[2,16],55:[2,16],70:[2,16],75:[2,16],83:[2,16],88:[2,16],90:[2,16],99:[2,16],101:[2,16],102:[2,16],103:[2,16],107:[2,16],115:[2,16],123:[2,16],125:[2,16],126:[2,16],129:[2,16],130:[2,16],131:[2,16],132:[2,16],133:[2,16],134:[2,16]},{1:[2,17],6:[2,17],25:[2,17],26:[2,17],47:[2,17],52:[2,17],55:[2,17],70:[2,17],75:[2,17],83:[2,17],88:[2,17],90:[2,17],99:[2,17],101:[2,17],102:[2,17],103:[2,17],107:[2,17],115:[2,17],123:[2,17],125:[2,17],126:[2,17],129:[2,17],130:[2,17],131:[2,17],132:[2,17],133:[2,17],134:[2,17]},{1:[2,18],6:[2,18],25:[2,18],26:[2,18],47:[2,18],52:[2,18],55:[2,18],70:[2,18],75:[2,18],83:[2,18],88:[2,18],90:[2,18],99:[2,18],101:[2,18],102:[2,18],103:[2,18],107:[2,18],115:[2,18],123:[2,18],125:[2,18],126:[2,18],129:[2,18],130:[2,18],131:[2,18],132:[2,18],133:[2,18],134:[2,18]},{1:[2,19],6:[2,19],25:[2,19],26:[2,19],47:[2,19],52:[2,19],55:[2,19],70:[2,19],75:[2,19],83:[2,19],88:[2,19],90:[2,19],99:[2,19],101:[2,19],102:[2,19],103:[2,19],107:[2,19],115:[2,19],123:[2,19],125:[2,19],126:[2,19],129:[2,19],130:[2,19],131:[2,19],132:[2,19],133:[2,19],134:[2,19]},{1:[2,20],6:[2,20],25:[2,20],26:[2,20],47:[2,20],52:[2,20],55:[2,20],70:[2,20],75:[2,20],83:[2,20],88:[2,20],90:[2,20],99:[2,20],101:[2,20],102:[2,20],103:[2,20],107:[2,20],115:[2,20],123:[2,20],125:[2,20],126:[2,20],129:[2,20],130:[2,20],131:[2,20],132:[2,20],133:[2,20],134:[2,20]},{1:[2,21],6:[2,21],25:[2,21],26:[2,21],47:[2,21],52:[2,21],55:[2,21],70:[2,21],75:[2,21],83:[2,21],88:[2,21],90:[2,21],99:[2,21],101:[2,21],102:[2,21],103:[2,21],107:[2,21],115:[2,21],123:[2,21],125:[2,21],126:[2,21],129:[2,21],130:[2,21],131:[2,21],132:[2,21],133:[2,21],134:[2,21]},{1:[2,22],6:[2,22],25:[2,22],26:[2,22],47:[2,22],52:[2,22],55:[2,22],70:[2,22],75:[2,22],83:[2,22],88:[2,22],90:[2,22],99:[2,22],101:[2,22],102:[2,22],103:[2,22],107:[2,22],115:[2,22],123:[2,22],125:[2,22],126:[2,22],129:[2,22],130:[2,22],131:[2,22],132:[2,22],133:[2,22],134:[2,22]},{1:[2,23],6:[2,23],25:[2,23],26:[2,23],47:[2,23],52:[2,23],55:[2,23],70:[2,23],75:[2,23],83:[2,23],88:[2,23],90:[2,23],99:[2,23],101:[2,23],102:[2,23],103:[2,23],107:[2,23],115:[2,23],123:[2,23],125:[2,23],126:[2,23],129:[2,23],130:[2,23],131:[2,23],132:[2,23],133:[2,23],134:[2,23]},{1:[2,9],6:[2,9],26:[2,9],99:[2,9],101:[2,9],103:[2,9],107:[2,9],123:[2,9]},{1:[2,10],6:[2,10],26:[2,10],99:[2,10],101:[2,10],103:[2,10],107:[2,10],123:[2,10]},{1:[2,11],6:[2,11],26:[2,11],99:[2,11],101:[2,11],103:[2,11],107:[2,11],123:[2,11]},{1:[2,71],6:[2,71],25:[2,71],26:[2,71],38:[1,101],47:[2,71],52:[2,71],55:[2,71],64:[2,71],65:[2,71],66:[2,71],68:[2,71],70:[2,71],71:[2,71],75:[2,71],81:[2,71],82:[2,71],83:[2,71],88:[2,71],90:[2,71],99:[2,71],101:[2,71],102:[2,71],103:[2,71],107:[2,71],115:[2,71],123:[2,71],125:[2,71],126:[2,71],129:[2,71],130:[2,71],131:[2,71],132:[2,71],133:[2,71],134:[2,71]},{1:[2,72],6:[2,72],25:[2,72],26:[2,72],47:[2,72],52:[2,72],55:[2,72],64:[2,72],65:[2,72],66:[2,72],68:[2,72],70:[2,72],71:[2,72],75:[2,72],81:[2,72],82:[2,72],83:[2,72],88:[2,72],90:[2,72],99:[2,72],101:[2,72],102:[2,72],103:[2,72],107:[2,72],115:[2,72],123:[2,72],125:[2,72],126:[2,72],129:[2,72],130:[2,72],131:[2,72],132:[2,72],133:[2,72],134:[2,72]},{1:[2,73],6:[2,73],25:[2,73],26:[2,73],47:[2,73],52:[2,73],55:[2,73],64:[2,73],65:[2,73],66:[2,73],68:[2,73],70:[2,73],71:[2,73],75:[2,73],81:[2,73],82:[2,73],83:[2,73],88:[2,73],90:[2,73],99:[2,73],101:[2,73],102:[2,73],103:[2,73],107:[2,73],115:[2,73],123:[2,73],125:[2,73],126:[2,73],129:[2,73],130:[2,73],131:[2,73],132:[2,73],133:[2,73],134:[2,73]},{1:[2,74],6:[2,74],25:[2,74],26:[2,74],47:[2,74],52:[2,74],55:[2,74],64:[2,74],65:[2,74],66:[2,74],68:[2,74],70:[2,74],71:[2,74],75:[2,74],81:[2,74],82:[2,74],83:[2,74],88:[2,74],90:[2,74],99:[2,74],101:[2,74],102:[2,74],103:[2,74],107:[2,74],115:[2,74],123:[2,74],125:[2,74],126:[2,74],129:[2,74],130:[2,74],131:[2,74],132:[2,74],133:[2,74],134:[2,74]},{1:[2,75],6:[2,75],25:[2,75],26:[2,75],47:[2,75],52:[2,75],55:[2,75],64:[2,75],65:[2,75],66:[2,75],68:[2,75],70:[2,75],71:[2,75],75:[2,75],81:[2,75],82:[2,75],83:[2,75],88:[2,75],90:[2,75],99:[2,75],101:[2,75],102:[2,75],103:[2,75],107:[2,75],115:[2,75],123:[2,75],125:[2,75],126:[2,75],129:[2,75],130:[2,75],131:[2,75],132:[2,75],133:[2,75],134:[2,75]},{1:[2,101],6:[2,101],25:[2,101],26:[2,101],47:[2,101],52:[2,101],55:[2,101],64:[2,101],65:[2,101],66:[2,101],68:[2,101],70:[2,101],71:[2,101],75:[2,101],79:102,81:[2,101],82:[1,103],83:[2,101],88:[2,101],90:[2,101],99:[2,101],101:[2,101],102:[2,101],103:[2,101],107:[2,101],115:[2,101],123:[2,101],125:[2,101],126:[2,101],129:[2,101],130:[2,101],131:[2,101],132:[2,101],133:[2,101],134:[2,101]},{27:107,28:[1,71],42:108,46:104,47:[2,53],52:[2,53],53:105,54:106,56:109,57:110,73:[1,68],86:[1,111],87:[1,112]},{5:113,25:[1,5]},{8:114,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:116,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:117,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{13:119,14:120,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:121,42:61,56:47,57:48,59:118,61:25,62:26,63:27,73:[1,68],80:[1,28],85:[1,56],86:[1,57],87:[1,55],98:[1,54]},{13:119,14:120,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:121,42:61,56:47,57:48,59:122,61:25,62:26,63:27,73:[1,68],80:[1,28],85:[1,56],86:[1,57],87:[1,55],98:[1,54]},{1:[2,68],6:[2,68],25:[2,68],26:[2,68],38:[2,68],47:[2,68],52:[2,68],55:[2,68],64:[2,68],65:[2,68],66:[2,68],68:[2,68],70:[2,68],71:[2,68],75:[2,68],77:[1,126],81:[2,68],82:[2,68],83:[2,68],88:[2,68],90:[2,68],99:[2,68],101:[2,68],102:[2,68],103:[2,68],107:[2,68],115:[2,68],123:[2,68],125:[2,68],126:[2,68],127:[1,123],128:[1,124],129:[2,68],130:[2,68],131:[2,68],132:[2,68],133:[2,68],134:[2,68],135:[1,125]},{1:[2,175],6:[2,175],25:[2,175],26:[2,175],47:[2,175],52:[2,175],55:[2,175],70:[2,175],75:[2,175],83:[2,175],88:[2,175],90:[2,175],99:[2,175],101:[2,175],102:[2,175],103:[2,175],107:[2,175],115:[2,175],118:[1,127],123:[2,175],125:[2,175],126:[2,175],129:[2,175],130:[2,175],131:[2,175],132:[2,175],133:[2,175],134:[2,175]},{5:128,25:[1,5]},{5:129,25:[1,5]},{1:[2,143],6:[2,143],25:[2,143],26:[2,143],47:[2,143],52:[2,143],55:[2,143],70:[2,143],75:[2,143],83:[2,143],88:[2,143],90:[2,143],99:[2,143],101:[2,143],102:[2,143],103:[2,143],107:[2,143],115:[2,143],123:[2,143],125:[2,143],126:[2,143],129:[2,143],130:[2,143],131:[2,143],132:[2,143],133:[2,143],134:[2,143]},{5:130,25:[1,5]},{8:131,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,132],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,91],5:133,6:[2,91],13:119,14:120,25:[1,5],26:[2,91],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:121,42:61,47:[2,91],52:[2,91],55:[2,91],56:47,57:48,59:135,61:25,62:26,63:27,70:[2,91],73:[1,68],75:[2,91],77:[1,134],80:[1,28],83:[2,91],85:[1,56],86:[1,57],87:[1,55],88:[2,91],90:[2,91],98:[1,54],99:[2,91],101:[2,91],102:[2,91],103:[2,91],107:[2,91],115:[2,91],123:[2,91],125:[2,91],126:[2,91],129:[2,91],130:[2,91],131:[2,91],132:[2,91],133:[2,91],134:[2,91]},{8:136,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,45],6:[2,45],8:137,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,26:[2,45],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],99:[2,45],100:39,101:[2,45],103:[2,45],104:40,105:[1,65],106:41,107:[2,45],108:67,116:[1,42],121:37,122:[1,62],123:[2,45],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,46],6:[2,46],25:[2,46],26:[2,46],52:[2,46],75:[2,46],99:[2,46],101:[2,46],103:[2,46],107:[2,46],123:[2,46]},{1:[2,69],6:[2,69],25:[2,69],26:[2,69],38:[2,69],47:[2,69],52:[2,69],55:[2,69],64:[2,69],65:[2,69],66:[2,69],68:[2,69],70:[2,69],71:[2,69],75:[2,69],81:[2,69],82:[2,69],83:[2,69],88:[2,69],90:[2,69],99:[2,69],101:[2,69],102:[2,69],103:[2,69],107:[2,69],115:[2,69],123:[2,69],125:[2,69],126:[2,69],129:[2,69],130:[2,69],131:[2,69],132:[2,69],133:[2,69],134:[2,69]},{1:[2,70],6:[2,70],25:[2,70],26:[2,70],38:[2,70],47:[2,70],52:[2,70],55:[2,70],64:[2,70],65:[2,70],66:[2,70],68:[2,70],70:[2,70],71:[2,70],75:[2,70],81:[2,70],82:[2,70],83:[2,70],88:[2,70],90:[2,70],99:[2,70],101:[2,70],102:[2,70],103:[2,70],107:[2,70],115:[2,70],123:[2,70],125:[2,70],126:[2,70],129:[2,70],130:[2,70],131:[2,70],132:[2,70],133:[2,70],134:[2,70]},{1:[2,29],6:[2,29],25:[2,29],26:[2,29],47:[2,29],52:[2,29],55:[2,29],64:[2,29],65:[2,29],66:[2,29],68:[2,29],70:[2,29],71:[2,29],75:[2,29],81:[2,29],82:[2,29],83:[2,29],88:[2,29],90:[2,29],99:[2,29],101:[2,29],102:[2,29],103:[2,29],107:[2,29],115:[2,29],123:[2,29],125:[2,29],126:[2,29],129:[2,29],130:[2,29],131:[2,29],132:[2,29],133:[2,29],134:[2,29]},{1:[2,30],6:[2,30],25:[2,30],26:[2,30],47:[2,30],52:[2,30],55:[2,30],64:[2,30],65:[2,30],66:[2,30],68:[2,30],70:[2,30],71:[2,30],75:[2,30],81:[2,30],82:[2,30],83:[2,30],88:[2,30],90:[2,30],99:[2,30],101:[2,30],102:[2,30],103:[2,30],107:[2,30],115:[2,30],123:[2,30],125:[2,30],126:[2,30],129:[2,30],130:[2,30],131:[2,30],132:[2,30],133:[2,30],134:[2,30]},{1:[2,31],6:[2,31],25:[2,31],26:[2,31],47:[2,31],52:[2,31],55:[2,31],64:[2,31],65:[2,31],66:[2,31],68:[2,31],70:[2,31],71:[2,31],75:[2,31],81:[2,31],82:[2,31],83:[2,31],88:[2,31],90:[2,31],99:[2,31],101:[2,31],102:[2,31],103:[2,31],107:[2,31],115:[2,31],123:[2,31],125:[2,31],126:[2,31],129:[2,31],130:[2,31],131:[2,31],132:[2,31],133:[2,31],134:[2,31]},{1:[2,32],6:[2,32],25:[2,32],26:[2,32],47:[2,32],52:[2,32],55:[2,32],64:[2,32],65:[2,32],66:[2,32],68:[2,32],70:[2,32],71:[2,32],75:[2,32],81:[2,32],82:[2,32],83:[2,32],88:[2,32],90:[2,32],99:[2,32],101:[2,32],102:[2,32],103:[2,32],107:[2,32],115:[2,32],123:[2,32],125:[2,32],126:[2,32],129:[2,32],130:[2,32],131:[2,32],132:[2,32],133:[2,32],134:[2,32]},{1:[2,33],6:[2,33],25:[2,33],26:[2,33],47:[2,33],52:[2,33],55:[2,33],64:[2,33],65:[2,33],66:[2,33],68:[2,33],70:[2,33],71:[2,33],75:[2,33],81:[2,33],82:[2,33],83:[2,33],88:[2,33],90:[2,33],99:[2,33],101:[2,33],102:[2,33],103:[2,33],107:[2,33],115:[2,33],123:[2,33],125:[2,33],126:[2,33],129:[2,33],130:[2,33],131:[2,33],132:[2,33],133:[2,33],134:[2,33]},{4:138,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,139],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:140,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,144],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,58:145,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],84:142,85:[1,56],86:[1,57],87:[1,55],88:[1,141],91:143,93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,107],6:[2,107],25:[2,107],26:[2,107],47:[2,107],52:[2,107],55:[2,107],64:[2,107],65:[2,107],66:[2,107],68:[2,107],70:[2,107],71:[2,107],75:[2,107],81:[2,107],82:[2,107],83:[2,107],88:[2,107],90:[2,107],99:[2,107],101:[2,107],102:[2,107],103:[2,107],107:[2,107],115:[2,107],123:[2,107],125:[2,107],126:[2,107],129:[2,107],130:[2,107],131:[2,107],132:[2,107],133:[2,107],134:[2,107]},{1:[2,108],6:[2,108],25:[2,108],26:[2,108],27:146,28:[1,71],47:[2,108],52:[2,108],55:[2,108],64:[2,108],65:[2,108],66:[2,108],68:[2,108],70:[2,108],71:[2,108],75:[2,108],81:[2,108],82:[2,108],83:[2,108],88:[2,108],90:[2,108],99:[2,108],101:[2,108],102:[2,108],103:[2,108],107:[2,108],115:[2,108],123:[2,108],125:[2,108],126:[2,108],129:[2,108],130:[2,108],131:[2,108],132:[2,108],133:[2,108],134:[2,108]},{25:[2,49]},{25:[2,50]},{1:[2,64],6:[2,64],25:[2,64],26:[2,64],38:[2,64],47:[2,64],52:[2,64],55:[2,64],64:[2,64],65:[2,64],66:[2,64],68:[2,64],70:[2,64],71:[2,64],75:[2,64],77:[2,64],81:[2,64],82:[2,64],83:[2,64],88:[2,64],90:[2,64],99:[2,64],101:[2,64],102:[2,64],103:[2,64],107:[2,64],115:[2,64],123:[2,64],125:[2,64],126:[2,64],127:[2,64],128:[2,64],129:[2,64],130:[2,64],131:[2,64],132:[2,64],133:[2,64],134:[2,64],135:[2,64]},{1:[2,67],6:[2,67],25:[2,67],26:[2,67],38:[2,67],47:[2,67],52:[2,67],55:[2,67],64:[2,67],65:[2,67],66:[2,67],68:[2,67],70:[2,67],71:[2,67],75:[2,67],77:[2,67],81:[2,67],82:[2,67],83:[2,67],88:[2,67],90:[2,67],99:[2,67],101:[2,67],102:[2,67],103:[2,67],107:[2,67],115:[2,67],123:[2,67],125:[2,67],126:[2,67],127:[2,67],128:[2,67],129:[2,67],130:[2,67],131:[2,67],132:[2,67],133:[2,67],134:[2,67],135:[2,67]},{8:147,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:148,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:149,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{5:150,8:151,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,5],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{27:156,28:[1,71],56:157,57:158,62:152,73:[1,68],87:[1,55],110:153,111:[1,154],112:155},{109:159,113:[1,160],114:[1,161]},{6:[2,86],11:165,25:[2,86],27:166,28:[1,71],29:167,30:[1,69],31:[1,70],39:163,40:164,42:168,44:[1,46],52:[2,86],74:162,75:[2,86],86:[1,111]},{1:[2,27],6:[2,27],25:[2,27],26:[2,27],41:[2,27],47:[2,27],52:[2,27],55:[2,27],64:[2,27],65:[2,27],66:[2,27],68:[2,27],70:[2,27],71:[2,27],75:[2,27],81:[2,27],82:[2,27],83:[2,27],88:[2,27],90:[2,27],99:[2,27],101:[2,27],102:[2,27],103:[2,27],107:[2,27],115:[2,27],123:[2,27],125:[2,27],126:[2,27],129:[2,27],130:[2,27],131:[2,27],132:[2,27],133:[2,27],134:[2,27]},{1:[2,28],6:[2,28],25:[2,28],26:[2,28],41:[2,28],47:[2,28],52:[2,28],55:[2,28],64:[2,28],65:[2,28],66:[2,28],68:[2,28],70:[2,28],71:[2,28],75:[2,28],81:[2,28],82:[2,28],83:[2,28],88:[2,28],90:[2,28],99:[2,28],101:[2,28],102:[2,28],103:[2,28],107:[2,28],115:[2,28],123:[2,28],125:[2,28],126:[2,28],129:[2,28],130:[2,28],131:[2,28],132:[2,28],133:[2,28],134:[2,28]},{1:[2,26],6:[2,26],25:[2,26],26:[2,26],38:[2,26],41:[2,26],47:[2,26],52:[2,26],55:[2,26],64:[2,26],65:[2,26],66:[2,26],68:[2,26],70:[2,26],71:[2,26],75:[2,26],77:[2,26],81:[2,26],82:[2,26],83:[2,26],88:[2,26],90:[2,26],99:[2,26],101:[2,26],102:[2,26],103:[2,26],107:[2,26],113:[2,26],114:[2,26],115:[2,26],123:[2,26],125:[2,26],126:[2,26],127:[2,26],128:[2,26],129:[2,26],130:[2,26],131:[2,26],132:[2,26],133:[2,26],134:[2,26],135:[2,26]},{1:[2,6],6:[2,6],7:169,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,26:[2,6],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],99:[2,6],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,3]},{1:[2,24],6:[2,24],25:[2,24],26:[2,24],47:[2,24],52:[2,24],55:[2,24],70:[2,24],75:[2,24],83:[2,24],88:[2,24],90:[2,24],95:[2,24],96:[2,24],99:[2,24],101:[2,24],102:[2,24],103:[2,24],107:[2,24],115:[2,24],118:[2,24],120:[2,24],123:[2,24],125:[2,24],126:[2,24],129:[2,24],130:[2,24],131:[2,24],132:[2,24],133:[2,24],134:[2,24]},{6:[1,72],26:[1,170]},{1:[2,186],6:[2,186],25:[2,186],26:[2,186],47:[2,186],52:[2,186],55:[2,186],70:[2,186],75:[2,186],83:[2,186],88:[2,186],90:[2,186],99:[2,186],101:[2,186],102:[2,186],103:[2,186],107:[2,186],115:[2,186],123:[2,186],125:[2,186],126:[2,186],129:[2,186],130:[2,186],131:[2,186],132:[2,186],133:[2,186],134:[2,186]},{8:171,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:172,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:173,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:174,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:175,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:176,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:177,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:178,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,142],6:[2,142],25:[2,142],26:[2,142],47:[2,142],52:[2,142],55:[2,142],70:[2,142],75:[2,142],83:[2,142],88:[2,142],90:[2,142],99:[2,142],101:[2,142],102:[2,142],103:[2,142],107:[2,142],115:[2,142],123:[2,142],125:[2,142],126:[2,142],129:[2,142],130:[2,142],131:[2,142],132:[2,142],133:[2,142],134:[2,142]},{1:[2,147],6:[2,147],25:[2,147],26:[2,147],47:[2,147],52:[2,147],55:[2,147],70:[2,147],75:[2,147],83:[2,147],88:[2,147],90:[2,147],99:[2,147],101:[2,147],102:[2,147],103:[2,147],107:[2,147],115:[2,147],123:[2,147],125:[2,147],126:[2,147],129:[2,147],130:[2,147],131:[2,147],132:[2,147],133:[2,147],134:[2,147]},{8:179,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,141],6:[2,141],25:[2,141],26:[2,141],47:[2,141],52:[2,141],55:[2,141],70:[2,141],75:[2,141],83:[2,141],88:[2,141],90:[2,141],99:[2,141],101:[2,141],102:[2,141],103:[2,141],107:[2,141],115:[2,141],123:[2,141],125:[2,141],126:[2,141],129:[2,141],130:[2,141],131:[2,141],132:[2,141],133:[2,141],134:[2,141]},{1:[2,146],6:[2,146],25:[2,146],26:[2,146],47:[2,146],52:[2,146],55:[2,146],70:[2,146],75:[2,146],83:[2,146],88:[2,146],90:[2,146],99:[2,146],101:[2,146],102:[2,146],103:[2,146],107:[2,146],115:[2,146],123:[2,146],125:[2,146],126:[2,146],129:[2,146],130:[2,146],131:[2,146],132:[2,146],133:[2,146],134:[2,146]},{79:180,82:[1,103]},{1:[2,65],6:[2,65],25:[2,65],26:[2,65],38:[2,65],47:[2,65],52:[2,65],55:[2,65],64:[2,65],65:[2,65],66:[2,65],68:[2,65],70:[2,65],71:[2,65],75:[2,65],77:[2,65],81:[2,65],82:[2,65],83:[2,65],88:[2,65],90:[2,65],99:[2,65],101:[2,65],102:[2,65],103:[2,65],107:[2,65],115:[2,65],123:[2,65],125:[2,65],126:[2,65],127:[2,65],128:[2,65],129:[2,65],130:[2,65],131:[2,65],132:[2,65],133:[2,65],134:[2,65],135:[2,65]},{82:[2,104]},{27:181,28:[1,71]},{27:182,28:[1,71]},{1:[2,79],6:[2,79],25:[2,79],26:[2,79],27:183,28:[1,71],38:[2,79],47:[2,79],52:[2,79],55:[2,79],64:[2,79],65:[2,79],66:[2,79],68:[2,79],70:[2,79],71:[2,79],75:[2,79],77:[2,79],81:[2,79],82:[2,79],83:[2,79],88:[2,79],90:[2,79],99:[2,79],101:[2,79],102:[2,79],103:[2,79],107:[2,79],115:[2,79],123:[2,79],125:[2,79],126:[2,79],127:[2,79],128:[2,79],129:[2,79],130:[2,79],131:[2,79],132:[2,79],133:[2,79],134:[2,79],135:[2,79]},{1:[2,80],6:[2,80],25:[2,80],26:[2,80],38:[2,80],47:[2,80],52:[2,80],55:[2,80],64:[2,80],65:[2,80],66:[2,80],68:[2,80],70:[2,80],71:[2,80],75:[2,80],77:[2,80],81:[2,80],82:[2,80],83:[2,80],88:[2,80],90:[2,80],99:[2,80],101:[2,80],102:[2,80],103:[2,80],107:[2,80],115:[2,80],123:[2,80],125:[2,80],126:[2,80],127:[2,80],128:[2,80],129:[2,80],130:[2,80],131:[2,80],132:[2,80],133:[2,80],134:[2,80],135:[2,80]},{8:185,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],55:[1,189],56:47,57:48,59:36,61:25,62:26,63:27,69:184,72:186,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],89:187,90:[1,188],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{67:190,68:[1,97],71:[1,98]},{79:191,82:[1,103]},{1:[2,66],6:[2,66],25:[2,66],26:[2,66],38:[2,66],47:[2,66],52:[2,66],55:[2,66],64:[2,66],65:[2,66],66:[2,66],68:[2,66],70:[2,66],71:[2,66],75:[2,66],77:[2,66],81:[2,66],82:[2,66],83:[2,66],88:[2,66],90:[2,66],99:[2,66],101:[2,66],102:[2,66],103:[2,66],107:[2,66],115:[2,66],123:[2,66],125:[2,66],126:[2,66],127:[2,66],128:[2,66],129:[2,66],130:[2,66],131:[2,66],132:[2,66],133:[2,66],134:[2,66],135:[2,66]},{6:[1,193],8:192,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,194],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,102],6:[2,102],25:[2,102],26:[2,102],47:[2,102],52:[2,102],55:[2,102],64:[2,102],65:[2,102],66:[2,102],68:[2,102],70:[2,102],71:[2,102],75:[2,102],81:[2,102],82:[2,102],83:[2,102],88:[2,102],90:[2,102],99:[2,102],101:[2,102],102:[2,102],103:[2,102],107:[2,102],115:[2,102],123:[2,102],125:[2,102],126:[2,102],129:[2,102],130:[2,102],131:[2,102],132:[2,102],133:[2,102],134:[2,102]},{8:197,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,144],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,58:145,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],83:[1,195],84:196,85:[1,56],86:[1,57],87:[1,55],91:143,93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{47:[1,198],52:[1,199]},{47:[2,54],52:[2,54]},{38:[1,201],47:[2,56],52:[2,56],55:[1,200]},{38:[2,59],47:[2,59],52:[2,59],55:[2,59]},{38:[2,60],47:[2,60],52:[2,60],55:[2,60]},{38:[2,61],47:[2,61],52:[2,61],55:[2,61]},{38:[2,62],47:[2,62],52:[2,62],55:[2,62]},{27:146,28:[1,71]},{8:197,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,144],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,58:145,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],84:142,85:[1,56],86:[1,57],87:[1,55],88:[1,141],91:143,93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,48],6:[2,48],25:[2,48],26:[2,48],47:[2,48],52:[2,48],55:[2,48],70:[2,48],75:[2,48],83:[2,48],88:[2,48],90:[2,48],99:[2,48],101:[2,48],102:[2,48],103:[2,48],107:[2,48],115:[2,48],123:[2,48],125:[2,48],126:[2,48],129:[2,48],130:[2,48],131:[2,48],132:[2,48],133:[2,48],134:[2,48]},{1:[2,179],6:[2,179],25:[2,179],26:[2,179],47:[2,179],52:[2,179],55:[2,179],70:[2,179],75:[2,179],83:[2,179],88:[2,179],90:[2,179],99:[2,179],100:85,101:[2,179],102:[2,179],103:[2,179],106:86,107:[2,179],108:67,115:[2,179],123:[2,179],125:[2,179],126:[2,179],129:[1,76],130:[2,179],131:[2,179],132:[2,179],133:[2,179],134:[2,179]},{100:88,101:[1,63],103:[1,64],106:89,107:[1,66],108:67,123:[1,87]},{1:[2,180],6:[2,180],25:[2,180],26:[2,180],47:[2,180],52:[2,180],55:[2,180],70:[2,180],75:[2,180],83:[2,180],88:[2,180],90:[2,180],99:[2,180],100:85,101:[2,180],102:[2,180],103:[2,180],106:86,107:[2,180],108:67,115:[2,180],123:[2,180],125:[2,180],126:[2,180],129:[1,76],130:[2,180],131:[2,180],132:[2,180],133:[2,180],134:[2,180]},{1:[2,181],6:[2,181],25:[2,181],26:[2,181],47:[2,181],52:[2,181],55:[2,181],70:[2,181],75:[2,181],83:[2,181],88:[2,181],90:[2,181],99:[2,181],100:85,101:[2,181],102:[2,181],103:[2,181],106:86,107:[2,181],108:67,115:[2,181],123:[2,181],125:[2,181],126:[2,181],129:[1,76],130:[2,181],131:[2,181],132:[2,181],133:[2,181],134:[2,181]},{1:[2,182],6:[2,182],25:[2,182],26:[2,182],47:[2,182],52:[2,182],55:[2,182],64:[2,68],65:[2,68],66:[2,68],68:[2,68],70:[2,182],71:[2,68],75:[2,182],81:[2,68],82:[2,68],83:[2,182],88:[2,182],90:[2,182],99:[2,182],101:[2,182],102:[2,182],103:[2,182],107:[2,182],115:[2,182],123:[2,182],125:[2,182],126:[2,182],129:[2,182],130:[2,182],131:[2,182],132:[2,182],133:[2,182],134:[2,182]},{60:91,64:[1,93],65:[1,94],66:[1,95],67:96,68:[1,97],71:[1,98],78:90,81:[1,92],82:[2,103]},{60:100,64:[1,93],65:[1,94],66:[1,95],67:96,68:[1,97],71:[1,98],78:99,81:[1,92],82:[2,103]},{64:[2,71],65:[2,71],66:[2,71],68:[2,71],71:[2,71],81:[2,71],82:[2,71]},{1:[2,183],6:[2,183],25:[2,183],26:[2,183],47:[2,183],52:[2,183],55:[2,183],64:[2,68],65:[2,68],66:[2,68],68:[2,68],70:[2,183],71:[2,68],75:[2,183],81:[2,68],82:[2,68],83:[2,183],88:[2,183],90:[2,183],99:[2,183],101:[2,183],102:[2,183],103:[2,183],107:[2,183],115:[2,183],123:[2,183],125:[2,183],126:[2,183],129:[2,183],130:[2,183],131:[2,183],132:[2,183],133:[2,183],134:[2,183]},{1:[2,184],6:[2,184],25:[2,184],26:[2,184],47:[2,184],52:[2,184],55:[2,184],70:[2,184],75:[2,184],83:[2,184],88:[2,184],90:[2,184],99:[2,184],101:[2,184],102:[2,184],103:[2,184],107:[2,184],115:[2,184],123:[2,184],125:[2,184],126:[2,184],129:[2,184],130:[2,184],131:[2,184],132:[2,184],133:[2,184],134:[2,184]},{1:[2,185],6:[2,185],25:[2,185],26:[2,185],47:[2,185],52:[2,185],55:[2,185],70:[2,185],75:[2,185],83:[2,185],88:[2,185],90:[2,185],99:[2,185],101:[2,185],102:[2,185],103:[2,185],107:[2,185],115:[2,185],123:[2,185],125:[2,185],126:[2,185],129:[2,185],130:[2,185],131:[2,185],132:[2,185],133:[2,185],134:[2,185]},{8:202,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,203],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:204,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{5:205,25:[1,5],122:[1,206]},{1:[2,128],6:[2,128],25:[2,128],26:[2,128],47:[2,128],52:[2,128],55:[2,128],70:[2,128],75:[2,128],83:[2,128],88:[2,128],90:[2,128],94:207,95:[1,208],96:[1,209],99:[2,128],101:[2,128],102:[2,128],103:[2,128],107:[2,128],115:[2,128],123:[2,128],125:[2,128],126:[2,128],129:[2,128],130:[2,128],131:[2,128],132:[2,128],133:[2,128],134:[2,128]},{1:[2,140],6:[2,140],25:[2,140],26:[2,140],47:[2,140],52:[2,140],55:[2,140],70:[2,140],75:[2,140],83:[2,140],88:[2,140],90:[2,140],99:[2,140],101:[2,140],102:[2,140],103:[2,140],107:[2,140],115:[2,140],123:[2,140],125:[2,140],126:[2,140],129:[2,140],130:[2,140],131:[2,140],132:[2,140],133:[2,140],134:[2,140]},{1:[2,148],6:[2,148],25:[2,148],26:[2,148],47:[2,148],52:[2,148],55:[2,148],70:[2,148],75:[2,148],83:[2,148],88:[2,148],90:[2,148],99:[2,148],101:[2,148],102:[2,148],103:[2,148],107:[2,148],115:[2,148],123:[2,148],125:[2,148],126:[2,148],129:[2,148],130:[2,148],131:[2,148],132:[2,148],133:[2,148],134:[2,148]},{25:[1,210],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{117:211,119:212,120:[1,213]},{1:[2,92],6:[2,92],25:[2,92],26:[2,92],47:[2,92],52:[2,92],55:[2,92],70:[2,92],75:[2,92],83:[2,92],88:[2,92],90:[2,92],99:[2,92],101:[2,92],102:[2,92],103:[2,92],107:[2,92],115:[2,92],123:[2,92],125:[2,92],126:[2,92],129:[2,92],130:[2,92],131:[2,92],132:[2,92],133:[2,92],134:[2,92]},{8:214,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,95],5:215,6:[2,95],25:[1,5],26:[2,95],47:[2,95],52:[2,95],55:[2,95],64:[2,68],65:[2,68],66:[2,68],68:[2,68],70:[2,95],71:[2,68],75:[2,95],77:[1,216],81:[2,68],82:[2,68],83:[2,95],88:[2,95],90:[2,95],99:[2,95],101:[2,95],102:[2,95],103:[2,95],107:[2,95],115:[2,95],123:[2,95],125:[2,95],126:[2,95],129:[2,95],130:[2,95],131:[2,95],132:[2,95],133:[2,95],134:[2,95]},{1:[2,133],6:[2,133],25:[2,133],26:[2,133],47:[2,133],52:[2,133],55:[2,133],70:[2,133],75:[2,133],83:[2,133],88:[2,133],90:[2,133],99:[2,133],100:85,101:[2,133],102:[2,133],103:[2,133],106:86,107:[2,133],108:67,115:[2,133],123:[2,133],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,44],6:[2,44],26:[2,44],99:[2,44],100:85,101:[2,44],103:[2,44],106:86,107:[2,44],108:67,123:[2,44],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{6:[1,72],99:[1,217]},{4:218,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{6:[2,124],25:[2,124],52:[2,124],55:[1,220],88:[2,124],89:219,90:[1,188],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,110],6:[2,110],25:[2,110],26:[2,110],38:[2,110],47:[2,110],52:[2,110],55:[2,110],64:[2,110],65:[2,110],66:[2,110],68:[2,110],70:[2,110],71:[2,110],75:[2,110],81:[2,110],82:[2,110],83:[2,110],88:[2,110],90:[2,110],99:[2,110],101:[2,110],102:[2,110],103:[2,110],107:[2,110],113:[2,110],114:[2,110],115:[2,110],123:[2,110],125:[2,110],126:[2,110],129:[2,110],130:[2,110],131:[2,110],132:[2,110],133:[2,110],134:[2,110]},{6:[2,51],25:[2,51],51:221,52:[1,222],88:[2,51]},{6:[2,119],25:[2,119],26:[2,119],52:[2,119],83:[2,119],88:[2,119]},{8:197,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,144],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,58:145,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],84:223,85:[1,56],86:[1,57],87:[1,55],91:143,93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{6:[2,125],25:[2,125],26:[2,125],52:[2,125],83:[2,125],88:[2,125]},{1:[2,109],6:[2,109],25:[2,109],26:[2,109],38:[2,109],41:[2,109],47:[2,109],52:[2,109],55:[2,109],64:[2,109],65:[2,109],66:[2,109],68:[2,109],70:[2,109],71:[2,109],75:[2,109],77:[2,109],81:[2,109],82:[2,109],83:[2,109],88:[2,109],90:[2,109],99:[2,109],101:[2,109],102:[2,109],103:[2,109],107:[2,109],115:[2,109],123:[2,109],125:[2,109],126:[2,109],127:[2,109],128:[2,109],129:[2,109],130:[2,109],131:[2,109],132:[2,109],133:[2,109],134:[2,109],135:[2,109]},{5:224,25:[1,5],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,136],6:[2,136],25:[2,136],26:[2,136],47:[2,136],52:[2,136],55:[2,136],70:[2,136],75:[2,136],83:[2,136],88:[2,136],90:[2,136],99:[2,136],100:85,101:[1,63],102:[1,225],103:[1,64],106:86,107:[1,66],108:67,115:[2,136],123:[2,136],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,138],6:[2,138],25:[2,138],26:[2,138],47:[2,138],52:[2,138],55:[2,138],70:[2,138],75:[2,138],83:[2,138],88:[2,138],90:[2,138],99:[2,138],100:85,101:[1,63],102:[1,226],103:[1,64],106:86,107:[1,66],108:67,115:[2,138],123:[2,138],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,144],6:[2,144],25:[2,144],26:[2,144],47:[2,144],52:[2,144],55:[2,144],70:[2,144],75:[2,144],83:[2,144],88:[2,144],90:[2,144],99:[2,144],101:[2,144],102:[2,144],103:[2,144],107:[2,144],115:[2,144],123:[2,144],125:[2,144],126:[2,144],129:[2,144],130:[2,144],131:[2,144],132:[2,144],133:[2,144],134:[2,144]},{1:[2,145],6:[2,145],25:[2,145],26:[2,145],47:[2,145],52:[2,145],55:[2,145],70:[2,145],75:[2,145],83:[2,145],88:[2,145],90:[2,145],99:[2,145],100:85,101:[1,63],102:[2,145],103:[1,64],106:86,107:[1,66],108:67,115:[2,145],123:[2,145],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,149],6:[2,149],25:[2,149],26:[2,149],47:[2,149],52:[2,149],55:[2,149],70:[2,149],75:[2,149],83:[2,149],88:[2,149],90:[2,149],99:[2,149],101:[2,149],102:[2,149],103:[2,149],107:[2,149],115:[2,149],123:[2,149],125:[2,149],126:[2,149],129:[2,149],130:[2,149],131:[2,149],132:[2,149],133:[2,149],134:[2,149]},{113:[2,151],114:[2,151]},{27:156,28:[1,71],56:157,57:158,73:[1,68],87:[1,112],110:227,112:155},{52:[1,228],113:[2,156],114:[2,156]},{52:[2,153],113:[2,153],114:[2,153]},{52:[2,154],113:[2,154],114:[2,154]},{52:[2,155],113:[2,155],114:[2,155]},{1:[2,150],6:[2,150],25:[2,150],26:[2,150],47:[2,150],52:[2,150],55:[2,150],70:[2,150],75:[2,150],83:[2,150],88:[2,150],90:[2,150],99:[2,150],101:[2,150],102:[2,150],103:[2,150],107:[2,150],115:[2,150],123:[2,150],125:[2,150],126:[2,150],129:[2,150],130:[2,150],131:[2,150],132:[2,150],133:[2,150],134:[2,150]},{8:229,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:230,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{6:[2,51],25:[2,51],51:231,52:[1,232],75:[2,51]},{6:[2,87],25:[2,87],26:[2,87],52:[2,87],75:[2,87]},{6:[2,37],25:[2,37],26:[2,37],41:[1,233],52:[2,37],75:[2,37]},{6:[2,40],25:[2,40],26:[2,40],52:[2,40],75:[2,40]},{6:[2,41],25:[2,41],26:[2,41],41:[2,41],52:[2,41],75:[2,41]},{6:[2,42],25:[2,42],26:[2,42],41:[2,42],52:[2,42],75:[2,42]},{6:[2,43],25:[2,43],26:[2,43],41:[2,43],52:[2,43],75:[2,43]},{1:[2,5],6:[2,5],26:[2,5],99:[2,5]},{1:[2,25],6:[2,25],25:[2,25],26:[2,25],47:[2,25],52:[2,25],55:[2,25],70:[2,25],75:[2,25],83:[2,25],88:[2,25],90:[2,25],95:[2,25],96:[2,25],99:[2,25],101:[2,25],102:[2,25],103:[2,25],107:[2,25],115:[2,25],118:[2,25],120:[2,25],123:[2,25],125:[2,25],126:[2,25],129:[2,25],130:[2,25],131:[2,25],132:[2,25],133:[2,25],134:[2,25]},{1:[2,187],6:[2,187],25:[2,187],26:[2,187],47:[2,187],52:[2,187],55:[2,187],70:[2,187],75:[2,187],83:[2,187],88:[2,187],90:[2,187],99:[2,187],100:85,101:[2,187],102:[2,187],103:[2,187],106:86,107:[2,187],108:67,115:[2,187],123:[2,187],125:[2,187],126:[2,187],129:[1,76],130:[1,79],131:[2,187],132:[2,187],133:[2,187],134:[2,187]},{1:[2,188],6:[2,188],25:[2,188],26:[2,188],47:[2,188],52:[2,188],55:[2,188],70:[2,188],75:[2,188],83:[2,188],88:[2,188],90:[2,188],99:[2,188],100:85,101:[2,188],102:[2,188],103:[2,188],106:86,107:[2,188],108:67,115:[2,188],123:[2,188],125:[2,188],126:[2,188],129:[1,76],130:[1,79],131:[2,188],132:[2,188],133:[2,188],134:[2,188]},{1:[2,189],6:[2,189],25:[2,189],26:[2,189],47:[2,189],52:[2,189],55:[2,189],70:[2,189],75:[2,189],83:[2,189],88:[2,189],90:[2,189],99:[2,189],100:85,101:[2,189],102:[2,189],103:[2,189],106:86,107:[2,189],108:67,115:[2,189],123:[2,189],125:[2,189],126:[2,189],129:[1,76],130:[2,189],131:[2,189],132:[2,189],133:[2,189],134:[2,189]},{1:[2,190],6:[2,190],25:[2,190],26:[2,190],47:[2,190],52:[2,190],55:[2,190],70:[2,190],75:[2,190],83:[2,190],88:[2,190],90:[2,190],99:[2,190],100:85,101:[2,190],102:[2,190],103:[2,190],106:86,107:[2,190],108:67,115:[2,190],123:[2,190],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[2,190],132:[2,190],133:[2,190],134:[2,190]},{1:[2,191],6:[2,191],25:[2,191],26:[2,191],47:[2,191],52:[2,191],55:[2,191],70:[2,191],75:[2,191],83:[2,191],88:[2,191],90:[2,191],99:[2,191],100:85,101:[2,191],102:[2,191],103:[2,191],106:86,107:[2,191],108:67,115:[2,191],123:[2,191],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[2,191],133:[2,191],134:[1,83]},{1:[2,192],6:[2,192],25:[2,192],26:[2,192],47:[2,192],52:[2,192],55:[2,192],70:[2,192],75:[2,192],83:[2,192],88:[2,192],90:[2,192],99:[2,192],100:85,101:[2,192],102:[2,192],103:[2,192],106:86,107:[2,192],108:67,115:[2,192],123:[2,192],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[2,192],134:[1,83]},{1:[2,193],6:[2,193],25:[2,193],26:[2,193],47:[2,193],52:[2,193],55:[2,193],70:[2,193],75:[2,193],83:[2,193],88:[2,193],90:[2,193],99:[2,193],100:85,101:[2,193],102:[2,193],103:[2,193],106:86,107:[2,193],108:67,115:[2,193],123:[2,193],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[2,193],133:[2,193],134:[2,193]},{1:[2,178],6:[2,178],25:[2,178],26:[2,178],47:[2,178],52:[2,178],55:[2,178],70:[2,178],75:[2,178],83:[2,178],88:[2,178],90:[2,178],99:[2,178],100:85,101:[1,63],102:[2,178],103:[1,64],106:86,107:[1,66],108:67,115:[2,178],123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,177],6:[2,177],25:[2,177],26:[2,177],47:[2,177],52:[2,177],55:[2,177],70:[2,177],75:[2,177],83:[2,177],88:[2,177],90:[2,177],99:[2,177],100:85,101:[1,63],102:[2,177],103:[1,64],106:86,107:[1,66],108:67,115:[2,177],123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,99],6:[2,99],25:[2,99],26:[2,99],47:[2,99],52:[2,99],55:[2,99],64:[2,99],65:[2,99],66:[2,99],68:[2,99],70:[2,99],71:[2,99],75:[2,99],81:[2,99],82:[2,99],83:[2,99],88:[2,99],90:[2,99],99:[2,99],101:[2,99],102:[2,99],103:[2,99],107:[2,99],115:[2,99],123:[2,99],125:[2,99],126:[2,99],129:[2,99],130:[2,99],131:[2,99],132:[2,99],133:[2,99],134:[2,99]},{1:[2,76],6:[2,76],25:[2,76],26:[2,76],38:[2,76],47:[2,76],52:[2,76],55:[2,76],64:[2,76],65:[2,76],66:[2,76],68:[2,76],70:[2,76],71:[2,76],75:[2,76],77:[2,76],81:[2,76],82:[2,76],83:[2,76],88:[2,76],90:[2,76],99:[2,76],101:[2,76],102:[2,76],103:[2,76],107:[2,76],115:[2,76],123:[2,76],125:[2,76],126:[2,76],127:[2,76],128:[2,76],129:[2,76],130:[2,76],131:[2,76],132:[2,76],133:[2,76],134:[2,76],135:[2,76]},{1:[2,77],6:[2,77],25:[2,77],26:[2,77],38:[2,77],47:[2,77],52:[2,77],55:[2,77],64:[2,77],65:[2,77],66:[2,77],68:[2,77],70:[2,77],71:[2,77],75:[2,77],77:[2,77],81:[2,77],82:[2,77],83:[2,77],88:[2,77],90:[2,77],99:[2,77],101:[2,77],102:[2,77],103:[2,77],107:[2,77],115:[2,77],123:[2,77],125:[2,77],126:[2,77],127:[2,77],128:[2,77],129:[2,77],130:[2,77],131:[2,77],132:[2,77],133:[2,77],134:[2,77],135:[2,77]},{1:[2,78],6:[2,78],25:[2,78],26:[2,78],38:[2,78],47:[2,78],52:[2,78],55:[2,78],64:[2,78],65:[2,78],66:[2,78],68:[2,78],70:[2,78],71:[2,78],75:[2,78],77:[2,78],81:[2,78],82:[2,78],83:[2,78],88:[2,78],90:[2,78],99:[2,78],101:[2,78],102:[2,78],103:[2,78],107:[2,78],115:[2,78],123:[2,78],125:[2,78],126:[2,78],127:[2,78],128:[2,78],129:[2,78],130:[2,78],131:[2,78],132:[2,78],133:[2,78],134:[2,78],135:[2,78]},{70:[1,234]},{55:[1,189],70:[2,83],89:235,90:[1,188],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{70:[2,84]},{8:236,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,70:[2,118],73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{12:[2,112],28:[2,112],30:[2,112],31:[2,112],33:[2,112],34:[2,112],35:[2,112],36:[2,112],43:[2,112],44:[2,112],45:[2,112],49:[2,112],50:[2,112],70:[2,112],73:[2,112],76:[2,112],80:[2,112],85:[2,112],86:[2,112],87:[2,112],93:[2,112],97:[2,112],98:[2,112],101:[2,112],103:[2,112],105:[2,112],107:[2,112],116:[2,112],122:[2,112],124:[2,112],125:[2,112],126:[2,112],127:[2,112],128:[2,112]},{12:[2,113],28:[2,113],30:[2,113],31:[2,113],33:[2,113],34:[2,113],35:[2,113],36:[2,113],43:[2,113],44:[2,113],45:[2,113],49:[2,113],50:[2,113],70:[2,113],73:[2,113],76:[2,113],80:[2,113],85:[2,113],86:[2,113],87:[2,113],93:[2,113],97:[2,113],98:[2,113],101:[2,113],103:[2,113],105:[2,113],107:[2,113],116:[2,113],122:[2,113],124:[2,113],125:[2,113],126:[2,113],127:[2,113],128:[2,113]},{1:[2,82],6:[2,82],25:[2,82],26:[2,82],38:[2,82],47:[2,82],52:[2,82],55:[2,82],64:[2,82],65:[2,82],66:[2,82],68:[2,82],70:[2,82],71:[2,82],75:[2,82],77:[2,82],81:[2,82],82:[2,82],83:[2,82],88:[2,82],90:[2,82],99:[2,82],101:[2,82],102:[2,82],103:[2,82],107:[2,82],115:[2,82],123:[2,82],125:[2,82],126:[2,82],127:[2,82],128:[2,82],129:[2,82],130:[2,82],131:[2,82],132:[2,82],133:[2,82],134:[2,82],135:[2,82]},{1:[2,100],6:[2,100],25:[2,100],26:[2,100],47:[2,100],52:[2,100],55:[2,100],64:[2,100],65:[2,100],66:[2,100],68:[2,100],70:[2,100],71:[2,100],75:[2,100],81:[2,100],82:[2,100],83:[2,100],88:[2,100],90:[2,100],99:[2,100],101:[2,100],102:[2,100],103:[2,100],107:[2,100],115:[2,100],123:[2,100],125:[2,100],126:[2,100],129:[2,100],130:[2,100],131:[2,100],132:[2,100],133:[2,100],134:[2,100]},{1:[2,34],6:[2,34],25:[2,34],26:[2,34],47:[2,34],52:[2,34],55:[2,34],70:[2,34],75:[2,34],83:[2,34],88:[2,34],90:[2,34],99:[2,34],100:85,101:[2,34],102:[2,34],103:[2,34],106:86,107:[2,34],108:67,115:[2,34],123:[2,34],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{8:237,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:238,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,105],6:[2,105],25:[2,105],26:[2,105],47:[2,105],52:[2,105],55:[2,105],64:[2,105],65:[2,105],66:[2,105],68:[2,105],70:[2,105],71:[2,105],75:[2,105],81:[2,105],82:[2,105],83:[2,105],88:[2,105],90:[2,105],99:[2,105],101:[2,105],102:[2,105],103:[2,105],107:[2,105],115:[2,105],123:[2,105],125:[2,105],126:[2,105],129:[2,105],130:[2,105],131:[2,105],132:[2,105],133:[2,105],134:[2,105]},{6:[2,51],25:[2,51],51:239,52:[1,222],83:[2,51]},{6:[2,124],25:[2,124],26:[2,124],52:[2,124],55:[1,240],83:[2,124],88:[2,124],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{48:241,49:[1,58],50:[1,59]},{27:107,28:[1,71],42:108,53:242,54:106,56:109,57:110,73:[1,68],86:[1,111],87:[1,112]},{47:[2,57],52:[2,57]},{8:243,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,194],6:[2,194],25:[2,194],26:[2,194],47:[2,194],52:[2,194],55:[2,194],70:[2,194],75:[2,194],83:[2,194],88:[2,194],90:[2,194],99:[2,194],100:85,101:[2,194],102:[2,194],103:[2,194],106:86,107:[2,194],108:67,115:[2,194],123:[2,194],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{8:244,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,196],6:[2,196],25:[2,196],26:[2,196],47:[2,196],52:[2,196],55:[2,196],70:[2,196],75:[2,196],83:[2,196],88:[2,196],90:[2,196],99:[2,196],100:85,101:[2,196],102:[2,196],103:[2,196],106:86,107:[2,196],108:67,115:[2,196],123:[2,196],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,176],6:[2,176],25:[2,176],26:[2,176],47:[2,176],52:[2,176],55:[2,176],70:[2,176],75:[2,176],83:[2,176],88:[2,176],90:[2,176],99:[2,176],101:[2,176],102:[2,176],103:[2,176],107:[2,176],115:[2,176],123:[2,176],125:[2,176],126:[2,176],129:[2,176],130:[2,176],131:[2,176],132:[2,176],133:[2,176],134:[2,176]},{8:245,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,129],6:[2,129],25:[2,129],26:[2,129],47:[2,129],52:[2,129],55:[2,129],70:[2,129],75:[2,129],83:[2,129],88:[2,129],90:[2,129],95:[1,246],99:[2,129],101:[2,129],102:[2,129],103:[2,129],107:[2,129],115:[2,129],123:[2,129],125:[2,129],126:[2,129],129:[2,129],130:[2,129],131:[2,129],132:[2,129],133:[2,129],134:[2,129]},{5:247,25:[1,5]},{27:248,28:[1,71]},{117:249,119:212,120:[1,213]},{26:[1,250],118:[1,251],119:252,120:[1,213]},{26:[2,169],118:[2,169],120:[2,169]},{8:254,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],92:253,93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,93],5:255,6:[2,93],25:[1,5],26:[2,93],47:[2,93],52:[2,93],55:[2,93],70:[2,93],75:[2,93],83:[2,93],88:[2,93],90:[2,93],99:[2,93],100:85,101:[1,63],102:[2,93],103:[1,64],106:86,107:[1,66],108:67,115:[2,93],123:[2,93],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,96],6:[2,96],25:[2,96],26:[2,96],47:[2,96],52:[2,96],55:[2,96],70:[2,96],75:[2,96],83:[2,96],88:[2,96],90:[2,96],99:[2,96],101:[2,96],102:[2,96],103:[2,96],107:[2,96],115:[2,96],123:[2,96],125:[2,96],126:[2,96],129:[2,96],130:[2,96],131:[2,96],132:[2,96],133:[2,96],134:[2,96]},{8:256,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,134],6:[2,134],25:[2,134],26:[2,134],47:[2,134],52:[2,134],55:[2,134],64:[2,134],65:[2,134],66:[2,134],68:[2,134],70:[2,134],71:[2,134],75:[2,134],81:[2,134],82:[2,134],83:[2,134],88:[2,134],90:[2,134],99:[2,134],101:[2,134],102:[2,134],103:[2,134],107:[2,134],115:[2,134],123:[2,134],125:[2,134],126:[2,134],129:[2,134],130:[2,134],131:[2,134],132:[2,134],133:[2,134],134:[2,134]},{6:[1,72],26:[1,257]},{8:258,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{6:[2,63],12:[2,113],25:[2,63],28:[2,113],30:[2,113],31:[2,113],33:[2,113],34:[2,113],35:[2,113],36:[2,113],43:[2,113],44:[2,113],45:[2,113],49:[2,113],50:[2,113],52:[2,63],73:[2,113],76:[2,113],80:[2,113],85:[2,113],86:[2,113],87:[2,113],88:[2,63],93:[2,113],97:[2,113],98:[2,113],101:[2,113],103:[2,113],105:[2,113],107:[2,113],116:[2,113],122:[2,113],124:[2,113],125:[2,113],126:[2,113],127:[2,113],128:[2,113]},{6:[1,260],25:[1,261],88:[1,259]},{6:[2,52],8:197,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[2,52],26:[2,52],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,58:145,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],83:[2,52],85:[1,56],86:[1,57],87:[1,55],88:[2,52],91:262,93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{6:[2,51],25:[2,51],26:[2,51],51:263,52:[1,222]},{1:[2,173],6:[2,173],25:[2,173],26:[2,173],47:[2,173],52:[2,173],55:[2,173],70:[2,173],75:[2,173],83:[2,173],88:[2,173],90:[2,173],99:[2,173],101:[2,173],102:[2,173],103:[2,173],107:[2,173],115:[2,173],118:[2,173],123:[2,173],125:[2,173],126:[2,173],129:[2,173],130:[2,173],131:[2,173],132:[2,173],133:[2,173],134:[2,173]},{8:264,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:265,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{113:[2,152],114:[2,152]},{27:156,28:[1,71],56:157,57:158,73:[1,68],87:[1,112],112:266},{1:[2,158],6:[2,158],25:[2,158],26:[2,158],47:[2,158],52:[2,158],55:[2,158],70:[2,158],75:[2,158],83:[2,158],88:[2,158],90:[2,158],99:[2,158],100:85,101:[2,158],102:[1,267],103:[2,158],106:86,107:[2,158],108:67,115:[1,268],123:[2,158],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,159],6:[2,159],25:[2,159],26:[2,159],47:[2,159],52:[2,159],55:[2,159],70:[2,159],75:[2,159],83:[2,159],88:[2,159],90:[2,159],99:[2,159],100:85,101:[2,159],102:[1,269],103:[2,159],106:86,107:[2,159],108:67,115:[2,159],123:[2,159],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{6:[1,271],25:[1,272],75:[1,270]},{6:[2,52],11:165,25:[2,52],26:[2,52],27:166,28:[1,71],29:167,30:[1,69],31:[1,70],39:273,40:164,42:168,44:[1,46],75:[2,52],86:[1,111]},{8:274,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,275],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,81],6:[2,81],25:[2,81],26:[2,81],38:[2,81],47:[2,81],52:[2,81],55:[2,81],64:[2,81],65:[2,81],66:[2,81],68:[2,81],70:[2,81],71:[2,81],75:[2,81],77:[2,81],81:[2,81],82:[2,81],83:[2,81],88:[2,81],90:[2,81],99:[2,81],101:[2,81],102:[2,81],103:[2,81],107:[2,81],115:[2,81],123:[2,81],125:[2,81],126:[2,81],127:[2,81],128:[2,81],129:[2,81],130:[2,81],131:[2,81],132:[2,81],133:[2,81],134:[2,81],135:[2,81]},{8:276,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,70:[2,116],73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{70:[2,117],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,35],6:[2,35],25:[2,35],26:[2,35],47:[2,35],52:[2,35],55:[2,35],70:[2,35],75:[2,35],83:[2,35],88:[2,35],90:[2,35],99:[2,35],100:85,101:[2,35],102:[2,35],103:[2,35],106:86,107:[2,35],108:67,115:[2,35],123:[2,35],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{26:[1,277],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{6:[1,260],25:[1,261],83:[1,278]},{6:[2,63],25:[2,63],26:[2,63],52:[2,63],83:[2,63],88:[2,63]},{5:279,25:[1,5]},{47:[2,55],52:[2,55]},{47:[2,58],52:[2,58],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{26:[1,280],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{5:281,25:[1,5],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{5:282,25:[1,5]},{1:[2,130],6:[2,130],25:[2,130],26:[2,130],47:[2,130],52:[2,130],55:[2,130],70:[2,130],75:[2,130],83:[2,130],88:[2,130],90:[2,130],99:[2,130],101:[2,130],102:[2,130],103:[2,130],107:[2,130],115:[2,130],123:[2,130],125:[2,130],126:[2,130],129:[2,130],130:[2,130],131:[2,130],132:[2,130],133:[2,130],134:[2,130]},{5:283,25:[1,5]},{26:[1,284],118:[1,285],119:252,120:[1,213]},{1:[2,167],6:[2,167],25:[2,167],26:[2,167],47:[2,167],52:[2,167],55:[2,167],70:[2,167],75:[2,167],83:[2,167],88:[2,167],90:[2,167],99:[2,167],101:[2,167],102:[2,167],103:[2,167],107:[2,167],115:[2,167],123:[2,167],125:[2,167],126:[2,167],129:[2,167],130:[2,167],131:[2,167],132:[2,167],133:[2,167],134:[2,167]},{5:286,25:[1,5]},{26:[2,170],118:[2,170],120:[2,170]},{5:287,25:[1,5],52:[1,288]},{25:[2,126],52:[2,126],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,94],6:[2,94],25:[2,94],26:[2,94],47:[2,94],52:[2,94],55:[2,94],70:[2,94],75:[2,94],83:[2,94],88:[2,94],90:[2,94],99:[2,94],101:[2,94],102:[2,94],103:[2,94],107:[2,94],115:[2,94],123:[2,94],125:[2,94],126:[2,94],129:[2,94],130:[2,94],131:[2,94],132:[2,94],133:[2,94],134:[2,94]},{1:[2,97],5:289,6:[2,97],25:[1,5],26:[2,97],47:[2,97],52:[2,97],55:[2,97],70:[2,97],75:[2,97],83:[2,97],88:[2,97],90:[2,97],99:[2,97],100:85,101:[1,63],102:[2,97],103:[1,64],106:86,107:[1,66],108:67,115:[2,97],123:[2,97],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{99:[1,290]},{88:[1,291],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,111],6:[2,111],25:[2,111],26:[2,111],38:[2,111],47:[2,111],52:[2,111],55:[2,111],64:[2,111],65:[2,111],66:[2,111],68:[2,111],70:[2,111],71:[2,111],75:[2,111],81:[2,111],82:[2,111],83:[2,111],88:[2,111],90:[2,111],99:[2,111],101:[2,111],102:[2,111],103:[2,111],107:[2,111],113:[2,111],114:[2,111],115:[2,111],123:[2,111],125:[2,111],126:[2,111],129:[2,111],130:[2,111],131:[2,111],132:[2,111],133:[2,111],134:[2,111]},{8:197,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,58:145,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],91:292,93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:197,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,144],27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,58:145,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],84:293,85:[1,56],86:[1,57],87:[1,55],91:143,93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{6:[2,120],25:[2,120],26:[2,120],52:[2,120],83:[2,120],88:[2,120]},{6:[1,260],25:[1,261],26:[1,294]},{1:[2,137],6:[2,137],25:[2,137],26:[2,137],47:[2,137],52:[2,137],55:[2,137],70:[2,137],75:[2,137],83:[2,137],88:[2,137],90:[2,137],99:[2,137],100:85,101:[1,63],102:[2,137],103:[1,64],106:86,107:[1,66],108:67,115:[2,137],123:[2,137],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,139],6:[2,139],25:[2,139],26:[2,139],47:[2,139],52:[2,139],55:[2,139],70:[2,139],75:[2,139],83:[2,139],88:[2,139],90:[2,139],99:[2,139],100:85,101:[1,63],102:[2,139],103:[1,64],106:86,107:[1,66],108:67,115:[2,139],123:[2,139],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{113:[2,157],114:[2,157]},{8:295,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:296,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:297,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,85],6:[2,85],25:[2,85],26:[2,85],38:[2,85],47:[2,85],52:[2,85],55:[2,85],64:[2,85],65:[2,85],66:[2,85],68:[2,85],70:[2,85],71:[2,85],75:[2,85],81:[2,85],82:[2,85],83:[2,85],88:[2,85],90:[2,85],99:[2,85],101:[2,85],102:[2,85],103:[2,85],107:[2,85],113:[2,85],114:[2,85],115:[2,85],123:[2,85],125:[2,85],126:[2,85],129:[2,85],130:[2,85],131:[2,85],132:[2,85],133:[2,85],134:[2,85]},{11:165,27:166,28:[1,71],29:167,30:[1,69],31:[1,70],39:298,40:164,42:168,44:[1,46],86:[1,111]},{6:[2,86],11:165,25:[2,86],26:[2,86],27:166,28:[1,71],29:167,30:[1,69],31:[1,70],39:163,40:164,42:168,44:[1,46],52:[2,86],74:299,86:[1,111]},{6:[2,88],25:[2,88],26:[2,88],52:[2,88],75:[2,88]},{6:[2,38],25:[2,38],26:[2,38],52:[2,38],75:[2,38],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{8:300,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{70:[2,115],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,36],6:[2,36],25:[2,36],26:[2,36],47:[2,36],52:[2,36],55:[2,36],70:[2,36],75:[2,36],83:[2,36],88:[2,36],90:[2,36],99:[2,36],101:[2,36],102:[2,36],103:[2,36],107:[2,36],115:[2,36],123:[2,36],125:[2,36],126:[2,36],129:[2,36],130:[2,36],131:[2,36],132:[2,36],133:[2,36],134:[2,36]},{1:[2,106],6:[2,106],25:[2,106],26:[2,106],47:[2,106],52:[2,106],55:[2,106],64:[2,106],65:[2,106],66:[2,106],68:[2,106],70:[2,106],71:[2,106],75:[2,106],81:[2,106],82:[2,106],83:[2,106],88:[2,106],90:[2,106],99:[2,106],101:[2,106],102:[2,106],103:[2,106],107:[2,106],115:[2,106],123:[2,106],125:[2,106],126:[2,106],129:[2,106],130:[2,106],131:[2,106],132:[2,106],133:[2,106],134:[2,106]},{1:[2,47],6:[2,47],25:[2,47],26:[2,47],47:[2,47],52:[2,47],55:[2,47],70:[2,47],75:[2,47],83:[2,47],88:[2,47],90:[2,47],99:[2,47],101:[2,47],102:[2,47],103:[2,47],107:[2,47],115:[2,47],123:[2,47],125:[2,47],126:[2,47],129:[2,47],130:[2,47],131:[2,47],132:[2,47],133:[2,47],134:[2,47]},{1:[2,195],6:[2,195],25:[2,195],26:[2,195],47:[2,195],52:[2,195],55:[2,195],70:[2,195],75:[2,195],83:[2,195],88:[2,195],90:[2,195],99:[2,195],101:[2,195],102:[2,195],103:[2,195],107:[2,195],115:[2,195],123:[2,195],125:[2,195],126:[2,195],129:[2,195],130:[2,195],131:[2,195],132:[2,195],133:[2,195],134:[2,195]},{1:[2,174],6:[2,174],25:[2,174],26:[2,174],47:[2,174],52:[2,174],55:[2,174],70:[2,174],75:[2,174],83:[2,174],88:[2,174],90:[2,174],99:[2,174],101:[2,174],102:[2,174],103:[2,174],107:[2,174],115:[2,174],118:[2,174],123:[2,174],125:[2,174],126:[2,174],129:[2,174],130:[2,174],131:[2,174],132:[2,174],133:[2,174],134:[2,174]},{1:[2,131],6:[2,131],25:[2,131],26:[2,131],47:[2,131],52:[2,131],55:[2,131],70:[2,131],75:[2,131],83:[2,131],88:[2,131],90:[2,131],99:[2,131],101:[2,131],102:[2,131],103:[2,131],107:[2,131],115:[2,131],123:[2,131],125:[2,131],126:[2,131],129:[2,131],130:[2,131],131:[2,131],132:[2,131],133:[2,131],134:[2,131]},{1:[2,132],6:[2,132],25:[2,132],26:[2,132],47:[2,132],52:[2,132],55:[2,132],70:[2,132],75:[2,132],83:[2,132],88:[2,132],90:[2,132],95:[2,132],99:[2,132],101:[2,132],102:[2,132],103:[2,132],107:[2,132],115:[2,132],123:[2,132],125:[2,132],126:[2,132],129:[2,132],130:[2,132],131:[2,132],132:[2,132],133:[2,132],134:[2,132]},{1:[2,165],6:[2,165],25:[2,165],26:[2,165],47:[2,165],52:[2,165],55:[2,165],70:[2,165],75:[2,165],83:[2,165],88:[2,165],90:[2,165],99:[2,165],101:[2,165],102:[2,165],103:[2,165],107:[2,165],115:[2,165],123:[2,165],125:[2,165],126:[2,165],129:[2,165],130:[2,165],131:[2,165],132:[2,165],133:[2,165],134:[2,165]},{5:301,25:[1,5]},{26:[1,302]},{6:[1,303],26:[2,171],118:[2,171],120:[2,171]},{8:304,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{1:[2,98],6:[2,98],25:[2,98],26:[2,98],47:[2,98],52:[2,98],55:[2,98],70:[2,98],75:[2,98],83:[2,98],88:[2,98],90:[2,98],99:[2,98],101:[2,98],102:[2,98],103:[2,98],107:[2,98],115:[2,98],123:[2,98],125:[2,98],126:[2,98],129:[2,98],130:[2,98],131:[2,98],132:[2,98],133:[2,98],134:[2,98]},{1:[2,135],6:[2,135],25:[2,135],26:[2,135],47:[2,135],52:[2,135],55:[2,135],64:[2,135],65:[2,135],66:[2,135],68:[2,135],70:[2,135],71:[2,135],75:[2,135],81:[2,135],82:[2,135],83:[2,135],88:[2,135],90:[2,135],99:[2,135],101:[2,135],102:[2,135],103:[2,135],107:[2,135],115:[2,135],123:[2,135],125:[2,135],126:[2,135],129:[2,135],130:[2,135],131:[2,135],132:[2,135],133:[2,135],134:[2,135]},{1:[2,114],6:[2,114],25:[2,114],26:[2,114],47:[2,114],52:[2,114],55:[2,114],64:[2,114],65:[2,114],66:[2,114],68:[2,114],70:[2,114],71:[2,114],75:[2,114],81:[2,114],82:[2,114],83:[2,114],88:[2,114],90:[2,114],99:[2,114],101:[2,114],102:[2,114],103:[2,114],107:[2,114],115:[2,114],123:[2,114],125:[2,114],126:[2,114],129:[2,114],130:[2,114],131:[2,114],132:[2,114],133:[2,114],134:[2,114]},{6:[2,121],25:[2,121],26:[2,121],52:[2,121],83:[2,121],88:[2,121]},{6:[2,51],25:[2,51],26:[2,51],51:305,52:[1,222]},{6:[2,122],25:[2,122],26:[2,122],52:[2,122],83:[2,122],88:[2,122]},{1:[2,160],6:[2,160],25:[2,160],26:[2,160],47:[2,160],52:[2,160],55:[2,160],70:[2,160],75:[2,160],83:[2,160],88:[2,160],90:[2,160],99:[2,160],100:85,101:[2,160],102:[2,160],103:[2,160],106:86,107:[2,160],108:67,115:[1,306],123:[2,160],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,162],6:[2,162],25:[2,162],26:[2,162],47:[2,162],52:[2,162],55:[2,162],70:[2,162],75:[2,162],83:[2,162],88:[2,162],90:[2,162],99:[2,162],100:85,101:[2,162],102:[1,307],103:[2,162],106:86,107:[2,162],108:67,115:[2,162],123:[2,162],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,161],6:[2,161],25:[2,161],26:[2,161],47:[2,161],52:[2,161],55:[2,161],70:[2,161],75:[2,161],83:[2,161],88:[2,161],90:[2,161],99:[2,161],100:85,101:[2,161],102:[2,161],103:[2,161],106:86,107:[2,161],108:67,115:[2,161],123:[2,161],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{6:[2,89],25:[2,89],26:[2,89],52:[2,89],75:[2,89]},{6:[2,51],25:[2,51],26:[2,51],51:308,52:[1,232]},{26:[1,309],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{26:[1,310]},{1:[2,168],6:[2,168],25:[2,168],26:[2,168],47:[2,168],52:[2,168],55:[2,168],70:[2,168],75:[2,168],83:[2,168],88:[2,168],90:[2,168],99:[2,168],101:[2,168],102:[2,168],103:[2,168],107:[2,168],115:[2,168],123:[2,168],125:[2,168],126:[2,168],129:[2,168],130:[2,168],131:[2,168],132:[2,168],133:[2,168],134:[2,168]},{26:[2,172],118:[2,172],120:[2,172]},{25:[2,127],52:[2,127],100:85,101:[1,63],103:[1,64],106:86,107:[1,66],108:67,123:[1,84],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{6:[1,260],25:[1,261],26:[1,311]},{8:312,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{8:313,9:115,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:60,28:[1,71],29:49,30:[1,69],31:[1,70],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:23,42:61,43:[1,45],44:[1,46],45:[1,29],48:30,49:[1,58],50:[1,59],56:47,57:48,59:36,61:25,62:26,63:27,73:[1,68],76:[1,43],80:[1,28],85:[1,56],86:[1,57],87:[1,55],93:[1,38],97:[1,44],98:[1,54],100:39,101:[1,63],103:[1,64],104:40,105:[1,65],106:41,107:[1,66],108:67,116:[1,42],121:37,122:[1,62],124:[1,31],125:[1,32],126:[1,33],127:[1,34],128:[1,35]},{6:[1,271],25:[1,272],26:[1,314]},{6:[2,39],25:[2,39],26:[2,39],52:[2,39],75:[2,39]},{1:[2,166],6:[2,166],25:[2,166],26:[2,166],47:[2,166],52:[2,166],55:[2,166],70:[2,166],75:[2,166],83:[2,166],88:[2,166],90:[2,166],99:[2,166],101:[2,166],102:[2,166],103:[2,166],107:[2,166],115:[2,166],123:[2,166],125:[2,166],126:[2,166],129:[2,166],130:[2,166],131:[2,166],132:[2,166],133:[2,166],134:[2,166]},{6:[2,123],25:[2,123],26:[2,123],52:[2,123],83:[2,123],88:[2,123]},{1:[2,163],6:[2,163],25:[2,163],26:[2,163],47:[2,163],52:[2,163],55:[2,163],70:[2,163],75:[2,163],83:[2,163],88:[2,163],90:[2,163],99:[2,163],100:85,101:[2,163],102:[2,163],103:[2,163],106:86,107:[2,163],108:67,115:[2,163],123:[2,163],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{1:[2,164],6:[2,164],25:[2,164],26:[2,164],47:[2,164],52:[2,164],55:[2,164],70:[2,164],75:[2,164],83:[2,164],88:[2,164],90:[2,164],99:[2,164],100:85,101:[2,164],102:[2,164],103:[2,164],106:86,107:[2,164],108:67,115:[2,164],123:[2,164],125:[1,78],126:[1,77],129:[1,76],130:[1,79],131:[1,80],132:[1,81],133:[1,82],134:[1,83]},{6:[2,90],25:[2,90],26:[2,90],52:[2,90],75:[2,90]}], +defaultActions: {58:[2,49],59:[2,50],73:[2,3],92:[2,104],186:[2,84]}, +parseError: function parseError(str, hash) { + throw new Error(str); +}, +parse: function parse(input) { + var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + this.lexer.setInput(input); + this.lexer.yy = this.yy; + this.yy.lexer = this.lexer; + if (typeof this.lexer.yylloc == "undefined") + this.lexer.yylloc = {}; + var yyloc = this.lexer.yylloc; + lstack.push(yyloc); + if (typeof this.yy.parseError === "function") + this.parseError = this.yy.parseError; + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + function lex() { + var token; + token = self.lexer.lex() || 1; + if (typeof token !== "number") { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol == null) + symbol = lex(); + action = table[state] && table[state][symbol]; + } + if (typeof action === "undefined" || !action.length || !action[0]) { + if (!recovering) { + expected = []; + for (p in table[state]) + if (this.terminals_[p] && p > 2) { + expected.push("'" + this.terminals_[p] + "'"); + } + var errStr = ""; + if (this.lexer.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + this.terminals_[symbol] + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected}); + } + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(this.lexer.yytext); + lstack.push(this.lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = this.lexer.yyleng; + yytext = this.lexer.yytext; + yylineno = this.lexer.yylineno; + yyloc = this.lexer.yylloc; + if (recovering > 0) + recovering--; + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column}; + r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +} +}; + +module.exports = parser; + + +}); + +define('ace/mode/coffee/nodes', ['require', 'exports', 'module' , 'ace/mode/coffee/scope', 'ace/mode/coffee/lexer', 'ace/mode/coffee/helpers'], function(require, exports, module) { +// Generated by CoffeeScript 1.2.1-pre + + var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, Comment, Existence, Extends, For, IDENTIFIER, IDENTIFIER_STR, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, compact, del, ends, extend, flatten, last, merge, multident, starts, unfoldSoak, utility, _ref, _ref1, + __hasProp = {}.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }, + __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; + + Scope = require('./scope').Scope; + + _ref = require('./lexer'), RESERVED = _ref.RESERVED, STRICT_PROSCRIBED = _ref.STRICT_PROSCRIBED; + + _ref1 = require('./helpers'), compact = _ref1.compact, flatten = _ref1.flatten, extend = _ref1.extend, merge = _ref1.merge, del = _ref1.del, starts = _ref1.starts, ends = _ref1.ends, last = _ref1.last; + + exports.extend = extend; + + YES = function() { + return true; + }; + + NO = function() { + return false; + }; + + THIS = function() { + return this; + }; + + NEGATE = function() { + this.negated = !this.negated; + return this; + }; + + exports.Base = Base = (function() { + + Base.name = 'Base'; + + function Base() {} + + Base.prototype.compile = function(o, lvl) { + var node; + o = extend({}, o); + if (lvl) o.level = lvl; + node = this.unfoldSoak(o) || this; + node.tab = o.indent; + if (o.level === LEVEL_TOP || !node.isStatement(o)) { + return node.compileNode(o); + } else { + return node.compileClosure(o); + } + }; + + Base.prototype.compileClosure = function(o) { + if (this.jumps()) { + throw SyntaxError('cannot use a pure statement in an expression.'); + } + o.sharedScope = true; + return Closure.wrap(this).compileNode(o); + }; + + Base.prototype.cache = function(o, level, reused) { + var ref, sub; + if (!this.isComplex()) { + ref = level ? this.compile(o, level) : this; + return [ref, ref]; + } else { + ref = new Literal(reused || o.scope.freeVariable('ref')); + sub = new Assign(ref, this); + if (level) { + return [sub.compile(o, level), ref.value]; + } else { + return [sub, ref]; + } + } + }; + + Base.prototype.compileLoopReference = function(o, name) { + var src, tmp; + src = tmp = this.compile(o, LEVEL_LIST); + if (!((-Infinity < +src && +src < Infinity) || IDENTIFIER.test(src) && o.scope.check(src, true))) { + src = "" + (tmp = o.scope.freeVariable(name)) + " = " + src; + } + return [src, tmp]; + }; + + Base.prototype.makeReturn = function(res) { + var me; + me = this.unwrapAll(); + if (res) { + return new Call(new Literal("" + res + ".push"), [me]); + } else { + return new Return(me); + } + }; + + Base.prototype.contains = function(pred) { + var contains; + contains = false; + this.traverseChildren(false, function(node) { + if (pred(node)) { + contains = true; + return false; + } + }); + return contains; + }; + + Base.prototype.containsType = function(type) { + return this instanceof type || this.contains(function(node) { + return node instanceof type; + }); + }; + + Base.prototype.lastNonComment = function(list) { + var i; + i = list.length; + while (i--) { + if (!(list[i] instanceof Comment)) return list[i]; + } + return null; + }; + + Base.prototype.toString = function(idt, name) { + var tree; + if (idt == null) idt = ''; + if (name == null) name = this.constructor.name; + tree = '\n' + idt + name; + if (this.soak) tree += '?'; + this.eachChild(function(node) { + return tree += node.toString(idt + TAB); + }); + return tree; + }; + + Base.prototype.eachChild = function(func) { + var attr, child, _i, _j, _len, _len1, _ref2, _ref3; + if (!this.children) return this; + _ref2 = this.children; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + attr = _ref2[_i]; + if (this[attr]) { + _ref3 = flatten([this[attr]]); + for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) { + child = _ref3[_j]; + if (func(child) === false) return this; + } + } + } + return this; + }; + + Base.prototype.traverseChildren = function(crossScope, func) { + return this.eachChild(function(child) { + if (func(child) === false) return false; + return child.traverseChildren(crossScope, func); + }); + }; + + Base.prototype.invert = function() { + return new Op('!', this); + }; + + Base.prototype.unwrapAll = function() { + var node; + node = this; + while (node !== (node = node.unwrap())) { + continue; + } + return node; + }; + + Base.prototype.children = []; + + Base.prototype.isStatement = NO; + + Base.prototype.jumps = NO; + + Base.prototype.isComplex = YES; + + Base.prototype.isChainable = NO; + + Base.prototype.isAssignable = NO; + + Base.prototype.unwrap = THIS; + + Base.prototype.unfoldSoak = NO; + + Base.prototype.assigns = NO; + + return Base; + + })(); + + exports.Block = Block = (function(_super) { + + __extends(Block, _super); + + Block.name = 'Block'; + + function Block(nodes) { + this.expressions = compact(flatten(nodes || [])); + } + + Block.prototype.children = ['expressions']; + + Block.prototype.push = function(node) { + this.expressions.push(node); + return this; + }; + + Block.prototype.pop = function() { + return this.expressions.pop(); + }; + + Block.prototype.unshift = function(node) { + this.expressions.unshift(node); + return this; + }; + + Block.prototype.unwrap = function() { + if (this.expressions.length === 1) { + return this.expressions[0]; + } else { + return this; + } + }; + + Block.prototype.isEmpty = function() { + return !this.expressions.length; + }; + + Block.prototype.isStatement = function(o) { + var exp, _i, _len, _ref2; + _ref2 = this.expressions; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + exp = _ref2[_i]; + if (exp.isStatement(o)) return true; + } + return false; + }; + + Block.prototype.jumps = function(o) { + var exp, _i, _len, _ref2; + _ref2 = this.expressions; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + exp = _ref2[_i]; + if (exp.jumps(o)) return exp; + } + }; + + Block.prototype.makeReturn = function(res) { + var expr, len; + len = this.expressions.length; + while (len--) { + expr = this.expressions[len]; + if (!(expr instanceof Comment)) { + this.expressions[len] = expr.makeReturn(res); + if (expr instanceof Return && !expr.expression) { + this.expressions.splice(len, 1); + } + break; + } + } + return this; + }; + + Block.prototype.compile = function(o, level) { + if (o == null) o = {}; + if (o.scope) { + return Block.__super__.compile.call(this, o, level); + } else { + return this.compileRoot(o); + } + }; + + Block.prototype.compileNode = function(o) { + var code, codes, node, top, _i, _len, _ref2; + this.tab = o.indent; + top = o.level === LEVEL_TOP; + codes = []; + _ref2 = this.expressions; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + node = _ref2[_i]; + node = node.unwrapAll(); + node = node.unfoldSoak(o) || node; + if (node instanceof Block) { + codes.push(node.compileNode(o)); + } else if (top) { + node.front = true; + code = node.compile(o); + if (!node.isStatement(o)) { + code = "" + this.tab + code + ";"; + if (node instanceof Literal) code = "" + code + "\n"; + } + codes.push(code); + } else { + codes.push(node.compile(o, LEVEL_LIST)); + } + } + if (top) { + if (this.spaced) { + return "\n" + (codes.join('\n\n')) + "\n"; + } else { + return codes.join('\n'); + } + } + code = codes.join(', ') || 'void 0'; + if (codes.length > 1 && o.level >= LEVEL_LIST) { + return "(" + code + ")"; + } else { + return code; + } + }; + + Block.prototype.compileRoot = function(o) { + var code, exp, i, prelude, preludeExps, rest; + o.indent = o.bare ? '' : TAB; + o.scope = new Scope(null, this, null); + o.level = LEVEL_TOP; + this.spaced = true; + prelude = ""; + if (!o.bare) { + preludeExps = (function() { + var _i, _len, _ref2, _results; + _ref2 = this.expressions; + _results = []; + for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) { + exp = _ref2[i]; + if (!(exp.unwrap() instanceof Comment)) break; + _results.push(exp); + } + return _results; + }).call(this); + rest = this.expressions.slice(preludeExps.length); + this.expressions = preludeExps; + if (preludeExps.length) { + prelude = "" + (this.compileNode(merge(o, { + indent: '' + }))) + "\n"; + } + this.expressions = rest; + } + code = this.compileWithDeclarations(o); + if (o.bare) return code; + return "" + prelude + "(function() {\n" + code + "\n}).call(this);\n"; + }; + + Block.prototype.compileWithDeclarations = function(o) { + var assigns, code, declars, exp, i, post, rest, scope, spaced, _i, _len, _ref2, _ref3, _ref4; + code = post = ''; + _ref2 = this.expressions; + for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) { + exp = _ref2[i]; + exp = exp.unwrap(); + if (!(exp instanceof Comment || exp instanceof Literal)) break; + } + o = merge(o, { + level: LEVEL_TOP + }); + if (i) { + rest = this.expressions.splice(i, 9e9); + _ref3 = [this.spaced, false], spaced = _ref3[0], this.spaced = _ref3[1]; + _ref4 = [this.compileNode(o), spaced], code = _ref4[0], this.spaced = _ref4[1]; + this.expressions = rest; + } + post = this.compileNode(o); + scope = o.scope; + if (scope.expressions === this) { + declars = o.scope.hasDeclarations(); + assigns = scope.hasAssignments; + if (declars || assigns) { + if (i) code += '\n'; + code += "" + this.tab + "var "; + if (declars) code += scope.declaredVariables().join(', '); + if (assigns) { + if (declars) code += ",\n" + (this.tab + TAB); + code += scope.assignedVariables().join(",\n" + (this.tab + TAB)); + } + code += ';\n'; + } + } + return code + post; + }; + + Block.wrap = function(nodes) { + if (nodes.length === 1 && nodes[0] instanceof Block) return nodes[0]; + return new Block(nodes); + }; + + return Block; + + })(Base); + + exports.Literal = Literal = (function(_super) { + + __extends(Literal, _super); + + Literal.name = 'Literal'; + + function Literal(value) { + this.value = value; + } + + Literal.prototype.makeReturn = function() { + if (this.isStatement()) { + return this; + } else { + return Literal.__super__.makeReturn.apply(this, arguments); + } + }; + + Literal.prototype.isAssignable = function() { + return IDENTIFIER.test(this.value); + }; + + Literal.prototype.isStatement = function() { + var _ref2; + return (_ref2 = this.value) === 'break' || _ref2 === 'continue' || _ref2 === 'debugger'; + }; + + Literal.prototype.isComplex = NO; + + Literal.prototype.assigns = function(name) { + return name === this.value; + }; + + Literal.prototype.jumps = function(o) { + if (this.value === 'break' && !((o != null ? o.loop : void 0) || (o != null ? o.block : void 0))) { + return this; + } + if (this.value === 'continue' && !(o != null ? o.loop : void 0)) return this; + }; + + Literal.prototype.compileNode = function(o) { + var code, _ref2; + code = this.isUndefined ? o.level >= LEVEL_ACCESS ? '(void 0)' : 'void 0' : this.value === 'this' ? ((_ref2 = o.scope.method) != null ? _ref2.bound : void 0) ? o.scope.method.context : this.value : this.value.reserved ? "\"" + this.value + "\"" : this.value; + if (this.isStatement()) { + return "" + this.tab + code + ";"; + } else { + return code; + } + }; + + Literal.prototype.toString = function() { + return ' "' + this.value + '"'; + }; + + return Literal; + + })(Base); + + exports.Return = Return = (function(_super) { + + __extends(Return, _super); + + Return.name = 'Return'; + + function Return(expr) { + if (expr && !expr.unwrap().isUndefined) this.expression = expr; + } + + Return.prototype.children = ['expression']; + + Return.prototype.isStatement = YES; + + Return.prototype.makeReturn = THIS; + + Return.prototype.jumps = THIS; + + Return.prototype.compile = function(o, level) { + var expr, _ref2; + expr = (_ref2 = this.expression) != null ? _ref2.makeReturn() : void 0; + if (expr && !(expr instanceof Return)) { + return expr.compile(o, level); + } else { + return Return.__super__.compile.call(this, o, level); + } + }; + + Return.prototype.compileNode = function(o) { + return this.tab + ("return" + [this.expression ? " " + (this.expression.compile(o, LEVEL_PAREN)) : void 0] + ";"); + }; + + return Return; + + })(Base); + + exports.Value = Value = (function(_super) { + + __extends(Value, _super); + + Value.name = 'Value'; + + function Value(base, props, tag) { + if (!props && base instanceof Value) return base; + this.base = base; + this.properties = props || []; + if (tag) this[tag] = true; + return this; + } + + Value.prototype.children = ['base', 'properties']; + + Value.prototype.add = function(props) { + this.properties = this.properties.concat(props); + return this; + }; + + Value.prototype.hasProperties = function() { + return !!this.properties.length; + }; + + Value.prototype.isArray = function() { + return !this.properties.length && this.base instanceof Arr; + }; + + Value.prototype.isComplex = function() { + return this.hasProperties() || this.base.isComplex(); + }; + + Value.prototype.isAssignable = function() { + return this.hasProperties() || this.base.isAssignable(); + }; + + Value.prototype.isSimpleNumber = function() { + return this.base instanceof Literal && SIMPLENUM.test(this.base.value); + }; + + Value.prototype.isString = function() { + return this.base instanceof Literal && IS_STRING.test(this.base.value); + }; + + Value.prototype.isAtomic = function() { + var node, _i, _len, _ref2; + _ref2 = this.properties.concat(this.base); + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + node = _ref2[_i]; + if (node.soak || node instanceof Call) return false; + } + return true; + }; + + Value.prototype.isStatement = function(o) { + return !this.properties.length && this.base.isStatement(o); + }; + + Value.prototype.assigns = function(name) { + return !this.properties.length && this.base.assigns(name); + }; + + Value.prototype.jumps = function(o) { + return !this.properties.length && this.base.jumps(o); + }; + + Value.prototype.isObject = function(onlyGenerated) { + if (this.properties.length) return false; + return (this.base instanceof Obj) && (!onlyGenerated || this.base.generated); + }; + + Value.prototype.isSplice = function() { + return last(this.properties) instanceof Slice; + }; + + Value.prototype.unwrap = function() { + if (this.properties.length) { + return this; + } else { + return this.base; + } + }; + + Value.prototype.cacheReference = function(o) { + var base, bref, name, nref; + name = last(this.properties); + if (this.properties.length < 2 && !this.base.isComplex() && !(name != null ? name.isComplex() : void 0)) { + return [this, this]; + } + base = new Value(this.base, this.properties.slice(0, -1)); + if (base.isComplex()) { + bref = new Literal(o.scope.freeVariable('base')); + base = new Value(new Parens(new Assign(bref, base))); + } + if (!name) return [base, bref]; + if (name.isComplex()) { + nref = new Literal(o.scope.freeVariable('name')); + name = new Index(new Assign(nref, name.index)); + nref = new Index(nref); + } + return [base.add(name), new Value(bref || base.base, [nref || name])]; + }; + + Value.prototype.compileNode = function(o) { + var code, prop, props, _i, _len; + this.base.front = this.front; + props = this.properties; + code = this.base.compile(o, props.length ? LEVEL_ACCESS : null); + if ((this.base instanceof Parens || props.length) && SIMPLENUM.test(code)) { + code = "" + code + "."; + } + for (_i = 0, _len = props.length; _i < _len; _i++) { + prop = props[_i]; + code += prop.compile(o); + } + return code; + }; + + Value.prototype.unfoldSoak = function(o) { + var result, + _this = this; + if (this.unfoldedSoak != null) return this.unfoldedSoak; + result = (function() { + var fst, i, ifn, prop, ref, snd, _i, _len, _ref2; + if (ifn = _this.base.unfoldSoak(o)) { + Array.prototype.push.apply(ifn.body.properties, _this.properties); + return ifn; + } + _ref2 = _this.properties; + for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) { + prop = _ref2[i]; + if (!prop.soak) continue; + prop.soak = false; + fst = new Value(_this.base, _this.properties.slice(0, i)); + snd = new Value(_this.base, _this.properties.slice(i)); + if (fst.isComplex()) { + ref = new Literal(o.scope.freeVariable('ref')); + fst = new Parens(new Assign(ref, fst)); + snd.base = ref; + } + return new If(new Existence(fst), snd, { + soak: true + }); + } + return null; + })(); + return this.unfoldedSoak = result || false; + }; + + return Value; + + })(Base); + + exports.Comment = Comment = (function(_super) { + + __extends(Comment, _super); + + Comment.name = 'Comment'; + + function Comment(comment) { + this.comment = comment; + } + + Comment.prototype.isStatement = YES; + + Comment.prototype.makeReturn = THIS; + + Comment.prototype.compileNode = function(o, level) { + var code; + code = '/*' + multident(this.comment, this.tab) + ("\n" + this.tab + "*/\n"); + if ((level || o.level) === LEVEL_TOP) code = o.indent + code; + return code; + }; + + return Comment; + + })(Base); + + exports.Call = Call = (function(_super) { + + __extends(Call, _super); + + Call.name = 'Call'; + + function Call(variable, args, soak) { + this.args = args != null ? args : []; + this.soak = soak; + this.isNew = false; + this.isSuper = variable === 'super'; + this.variable = this.isSuper ? null : variable; + } + + Call.prototype.children = ['variable', 'args']; + + Call.prototype.newInstance = function() { + var base, _ref2; + base = ((_ref2 = this.variable) != null ? _ref2.base : void 0) || this.variable; + if (base instanceof Call && !base.isNew) { + base.newInstance(); + } else { + this.isNew = true; + } + return this; + }; + + Call.prototype.superReference = function(o) { + var accesses, method, name; + method = o.scope.method; + if (!method) throw SyntaxError('cannot call super outside of a function.'); + name = method.name; + if (name == null) { + throw SyntaxError('cannot call super on an anonymous function.'); + } + if (method.klass) { + accesses = [new Access(new Literal('__super__'))]; + if (method["static"]) { + accesses.push(new Access(new Literal('constructor'))); + } + accesses.push(new Access(new Literal(name))); + return (new Value(new Literal(method.klass), accesses)).compile(o); + } else { + return "" + name + ".__super__.constructor"; + } + }; + + Call.prototype.unfoldSoak = function(o) { + var call, ifn, left, list, rite, _i, _len, _ref2, _ref3; + if (this.soak) { + if (this.variable) { + if (ifn = unfoldSoak(o, this, 'variable')) return ifn; + _ref2 = new Value(this.variable).cacheReference(o), left = _ref2[0], rite = _ref2[1]; + } else { + left = new Literal(this.superReference(o)); + rite = new Value(left); + } + rite = new Call(rite, this.args); + rite.isNew = this.isNew; + left = new Literal("typeof " + (left.compile(o)) + " === \"function\""); + return new If(left, new Value(rite), { + soak: true + }); + } + call = this; + list = []; + while (true) { + if (call.variable instanceof Call) { + list.push(call); + call = call.variable; + continue; + } + if (!(call.variable instanceof Value)) break; + list.push(call); + if (!((call = call.variable.base) instanceof Call)) break; + } + _ref3 = list.reverse(); + for (_i = 0, _len = _ref3.length; _i < _len; _i++) { + call = _ref3[_i]; + if (ifn) { + if (call.variable instanceof Call) { + call.variable = ifn; + } else { + call.variable.base = ifn; + } + } + ifn = unfoldSoak(o, call, 'variable'); + } + return ifn; + }; + + Call.prototype.filterImplicitObjects = function(list) { + var node, nodes, obj, prop, properties, _i, _j, _len, _len1, _ref2; + nodes = []; + for (_i = 0, _len = list.length; _i < _len; _i++) { + node = list[_i]; + if (!((typeof node.isObject === "function" ? node.isObject() : void 0) && node.base.generated)) { + nodes.push(node); + continue; + } + obj = null; + _ref2 = node.base.properties; + for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { + prop = _ref2[_j]; + if (prop instanceof Assign || prop instanceof Comment) { + if (!obj) nodes.push(obj = new Obj(properties = [], true)); + properties.push(prop); + } else { + nodes.push(prop); + obj = null; + } + } + } + return nodes; + }; + + Call.prototype.compileNode = function(o) { + var arg, args, code, _ref2; + if ((_ref2 = this.variable) != null) _ref2.front = this.front; + if (code = Splat.compileSplattedArray(o, this.args, true)) { + return this.compileSplat(o, code); + } + args = this.filterImplicitObjects(this.args); + args = ((function() { + var _i, _len, _results; + _results = []; + for (_i = 0, _len = args.length; _i < _len; _i++) { + arg = args[_i]; + _results.push(arg.compile(o, LEVEL_LIST)); + } + return _results; + })()).join(', '); + if (this.isSuper) { + return this.superReference(o) + (".call(this" + (args && ', ' + args) + ")"); + } else { + return (this.isNew ? 'new ' : '') + this.variable.compile(o, LEVEL_ACCESS) + ("(" + args + ")"); + } + }; + + Call.prototype.compileSuper = function(args, o) { + return "" + (this.superReference(o)) + ".call(this" + (args.length ? ', ' : '') + args + ")"; + }; + + Call.prototype.compileSplat = function(o, splatArgs) { + var base, fun, idt, name, ref; + if (this.isSuper) { + return "" + (this.superReference(o)) + ".apply(this, " + splatArgs + ")"; + } + if (this.isNew) { + idt = this.tab + TAB; + return "(function(func, args, ctor) {\n" + idt + "ctor.prototype = func.prototype;\n" + idt + "var child = new ctor, result = func.apply(child, args), t = typeof result;\n" + idt + "return t == \"object\" || t == \"function\" ? result || child : child;\n" + this.tab + "})(" + (this.variable.compile(o, LEVEL_LIST)) + ", " + splatArgs + ", function(){})"; + } + base = new Value(this.variable); + if ((name = base.properties.pop()) && base.isComplex()) { + ref = o.scope.freeVariable('ref'); + fun = "(" + ref + " = " + (base.compile(o, LEVEL_LIST)) + ")" + (name.compile(o)); + } else { + fun = base.compile(o, LEVEL_ACCESS); + if (SIMPLENUM.test(fun)) fun = "(" + fun + ")"; + if (name) { + ref = fun; + fun += name.compile(o); + } else { + ref = 'null'; + } + } + return "" + fun + ".apply(" + ref + ", " + splatArgs + ")"; + }; + + return Call; + + })(Base); + + exports.Extends = Extends = (function(_super) { + + __extends(Extends, _super); + + Extends.name = 'Extends'; + + function Extends(child, parent) { + this.child = child; + this.parent = parent; + } + + Extends.prototype.children = ['child', 'parent']; + + Extends.prototype.compile = function(o) { + return new Call(new Value(new Literal(utility('extends'))), [this.child, this.parent]).compile(o); + }; + + return Extends; + + })(Base); + + exports.Access = Access = (function(_super) { + + __extends(Access, _super); + + Access.name = 'Access'; + + function Access(name, tag) { + this.name = name; + this.name.asKey = true; + this.soak = tag === 'soak'; + } + + Access.prototype.children = ['name']; + + Access.prototype.compile = function(o) { + var name; + name = this.name.compile(o); + if (IDENTIFIER.test(name)) { + return "." + name; + } else { + return "[" + name + "]"; + } + }; + + Access.prototype.isComplex = NO; + + return Access; + + })(Base); + + exports.Index = Index = (function(_super) { + + __extends(Index, _super); + + Index.name = 'Index'; + + function Index(index) { + this.index = index; + } + + Index.prototype.children = ['index']; + + Index.prototype.compile = function(o) { + return "[" + (this.index.compile(o, LEVEL_PAREN)) + "]"; + }; + + Index.prototype.isComplex = function() { + return this.index.isComplex(); + }; + + return Index; + + })(Base); + + exports.Range = Range = (function(_super) { + + __extends(Range, _super); + + Range.name = 'Range'; + + Range.prototype.children = ['from', 'to']; + + function Range(from, to, tag) { + this.from = from; + this.to = to; + this.exclusive = tag === 'exclusive'; + this.equals = this.exclusive ? '' : '='; + } + + Range.prototype.compileVariables = function(o) { + var step, _ref2, _ref3, _ref4, _ref5; + o = merge(o, { + top: true + }); + _ref2 = this.from.cache(o, LEVEL_LIST), this.fromC = _ref2[0], this.fromVar = _ref2[1]; + _ref3 = this.to.cache(o, LEVEL_LIST), this.toC = _ref3[0], this.toVar = _ref3[1]; + if (step = del(o, 'step')) { + _ref4 = step.cache(o, LEVEL_LIST), this.step = _ref4[0], this.stepVar = _ref4[1]; + } + _ref5 = [this.fromVar.match(SIMPLENUM), this.toVar.match(SIMPLENUM)], this.fromNum = _ref5[0], this.toNum = _ref5[1]; + if (this.stepVar) return this.stepNum = this.stepVar.match(SIMPLENUM); + }; + + Range.prototype.compileNode = function(o) { + var cond, condPart, from, gt, idx, idxName, known, lt, namedIndex, stepPart, to, varPart, _ref2, _ref3; + if (!this.fromVar) this.compileVariables(o); + if (!o.index) return this.compileArray(o); + known = this.fromNum && this.toNum; + idx = del(o, 'index'); + idxName = del(o, 'name'); + namedIndex = idxName && idxName !== idx; + varPart = "" + idx + " = " + this.fromC; + if (this.toC !== this.toVar) varPart += ", " + this.toC; + if (this.step !== this.stepVar) varPart += ", " + this.step; + _ref2 = ["" + idx + " <" + this.equals, "" + idx + " >" + this.equals], lt = _ref2[0], gt = _ref2[1]; + condPart = this.stepNum ? +this.stepNum > 0 ? "" + lt + " " + this.toVar : "" + gt + " " + this.toVar : known ? ((_ref3 = [+this.fromNum, +this.toNum], from = _ref3[0], to = _ref3[1], _ref3), from <= to ? "" + lt + " " + to : "" + gt + " " + to) : (cond = "" + this.fromVar + " <= " + this.toVar, "" + cond + " ? " + lt + " " + this.toVar + " : " + gt + " " + this.toVar); + stepPart = this.stepVar ? "" + idx + " += " + this.stepVar : known ? namedIndex ? from <= to ? "++" + idx : "--" + idx : from <= to ? "" + idx + "++" : "" + idx + "--" : namedIndex ? "" + cond + " ? ++" + idx + " : --" + idx : "" + cond + " ? " + idx + "++ : " + idx + "--"; + if (namedIndex) varPart = "" + idxName + " = " + varPart; + if (namedIndex) stepPart = "" + idxName + " = " + stepPart; + return "" + varPart + "; " + condPart + "; " + stepPart; + }; + + Range.prototype.compileArray = function(o) { + var args, body, cond, hasArgs, i, idt, post, pre, range, result, vars, _i, _ref2, _ref3, _results; + if (this.fromNum && this.toNum && Math.abs(this.fromNum - this.toNum) <= 20) { + range = (function() { + _results = []; + for (var _i = _ref2 = +this.fromNum, _ref3 = +this.toNum; _ref2 <= _ref3 ? _i <= _ref3 : _i >= _ref3; _ref2 <= _ref3 ? _i++ : _i--){ _results.push(_i); } + return _results; + }).apply(this); + if (this.exclusive) range.pop(); + return "[" + (range.join(', ')) + "]"; + } + idt = this.tab + TAB; + i = o.scope.freeVariable('i'); + result = o.scope.freeVariable('results'); + pre = "\n" + idt + result + " = [];"; + if (this.fromNum && this.toNum) { + o.index = i; + body = this.compileNode(o); + } else { + vars = ("" + i + " = " + this.fromC) + (this.toC !== this.toVar ? ", " + this.toC : ''); + cond = "" + this.fromVar + " <= " + this.toVar; + body = "var " + vars + "; " + cond + " ? " + i + " <" + this.equals + " " + this.toVar + " : " + i + " >" + this.equals + " " + this.toVar + "; " + cond + " ? " + i + "++ : " + i + "--"; + } + post = "{ " + result + ".push(" + i + "); }\n" + idt + "return " + result + ";\n" + o.indent; + hasArgs = function(node) { + return node != null ? node.contains(function(n) { + return n instanceof Literal && n.value === 'arguments' && !n.asKey; + }) : void 0; + }; + if (hasArgs(this.from) || hasArgs(this.to)) args = ', arguments'; + return "(function() {" + pre + "\n" + idt + "for (" + body + ")" + post + "}).apply(this" + (args != null ? args : '') + ")"; + }; + + return Range; + + })(Base); + + exports.Slice = Slice = (function(_super) { + + __extends(Slice, _super); + + Slice.name = 'Slice'; + + Slice.prototype.children = ['range']; + + function Slice(range) { + this.range = range; + Slice.__super__.constructor.call(this); + } + + Slice.prototype.compileNode = function(o) { + var compiled, from, fromStr, to, toStr, _ref2; + _ref2 = this.range, to = _ref2.to, from = _ref2.from; + fromStr = from && from.compile(o, LEVEL_PAREN) || '0'; + compiled = to && to.compile(o, LEVEL_PAREN); + if (to && !(!this.range.exclusive && +compiled === -1)) { + toStr = ', ' + (this.range.exclusive ? compiled : SIMPLENUM.test(compiled) ? "" + (+compiled + 1) : (compiled = to.compile(o, LEVEL_ACCESS), "" + compiled + " + 1 || 9e9")); + } + return ".slice(" + fromStr + (toStr || '') + ")"; + }; + + return Slice; + + })(Base); + + exports.Obj = Obj = (function(_super) { + + __extends(Obj, _super); + + Obj.name = 'Obj'; + + function Obj(props, generated) { + this.generated = generated != null ? generated : false; + this.objects = this.properties = props || []; + } + + Obj.prototype.children = ['properties']; + + Obj.prototype.compileNode = function(o) { + var i, idt, indent, join, lastNoncom, node, obj, prop, propName, propNames, props, _i, _j, _len, _len1, _ref2; + props = this.properties; + propNames = []; + _ref2 = this.properties; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + prop = _ref2[_i]; + if (prop.isComplex()) prop = prop.variable; + if (prop != null) { + propName = prop.unwrapAll().value.toString(); + if (__indexOf.call(propNames, propName) >= 0) { + throw SyntaxError("multiple object literal properties named \"" + propName + "\""); + } + propNames.push(propName); + } + } + if (!props.length) return (this.front ? '({})' : '{}'); + if (this.generated) { + for (_j = 0, _len1 = props.length; _j < _len1; _j++) { + node = props[_j]; + if (node instanceof Value) { + throw new Error('cannot have an implicit value in an implicit object'); + } + } + } + idt = o.indent += TAB; + lastNoncom = this.lastNonComment(this.properties); + props = (function() { + var _k, _len2, _results; + _results = []; + for (i = _k = 0, _len2 = props.length; _k < _len2; i = ++_k) { + prop = props[i]; + join = i === props.length - 1 ? '' : prop === lastNoncom || prop instanceof Comment ? '\n' : ',\n'; + indent = prop instanceof Comment ? '' : idt; + if (prop instanceof Value && prop["this"]) { + prop = new Assign(prop.properties[0].name, prop, 'object'); + } + if (!(prop instanceof Comment)) { + if (!(prop instanceof Assign)) prop = new Assign(prop, prop, 'object'); + (prop.variable.base || prop.variable).asKey = true; + } + _results.push(indent + prop.compile(o, LEVEL_TOP) + join); + } + return _results; + })(); + props = props.join(''); + obj = "{" + (props && '\n' + props + '\n' + this.tab) + "}"; + if (this.front) { + return "(" + obj + ")"; + } else { + return obj; + } + }; + + Obj.prototype.assigns = function(name) { + var prop, _i, _len, _ref2; + _ref2 = this.properties; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + prop = _ref2[_i]; + if (prop.assigns(name)) return true; + } + return false; + }; + + return Obj; + + })(Base); + + exports.Arr = Arr = (function(_super) { + + __extends(Arr, _super); + + Arr.name = 'Arr'; + + function Arr(objs) { + this.objects = objs || []; + } + + Arr.prototype.children = ['objects']; + + Arr.prototype.filterImplicitObjects = Call.prototype.filterImplicitObjects; + + Arr.prototype.compileNode = function(o) { + var code, obj, objs; + if (!this.objects.length) return '[]'; + o.indent += TAB; + objs = this.filterImplicitObjects(this.objects); + if (code = Splat.compileSplattedArray(o, objs)) return code; + code = ((function() { + var _i, _len, _results; + _results = []; + for (_i = 0, _len = objs.length; _i < _len; _i++) { + obj = objs[_i]; + _results.push(obj.compile(o, LEVEL_LIST)); + } + return _results; + })()).join(', '); + if (code.indexOf('\n') >= 0) { + return "[\n" + o.indent + code + "\n" + this.tab + "]"; + } else { + return "[" + code + "]"; + } + }; + + Arr.prototype.assigns = function(name) { + var obj, _i, _len, _ref2; + _ref2 = this.objects; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + obj = _ref2[_i]; + if (obj.assigns(name)) return true; + } + return false; + }; + + return Arr; + + })(Base); + + exports.Class = Class = (function(_super) { + + __extends(Class, _super); + + Class.name = 'Class'; + + function Class(variable, parent, body) { + this.variable = variable; + this.parent = parent; + this.body = body != null ? body : new Block; + this.boundFuncs = []; + this.body.classBody = true; + } + + Class.prototype.children = ['variable', 'parent', 'body']; + + Class.prototype.determineName = function() { + var decl, tail; + if (!this.variable) return null; + decl = (tail = last(this.variable.properties)) ? tail instanceof Access && tail.name.value : this.variable.base.value; + if (__indexOf.call(STRICT_PROSCRIBED, decl) >= 0) { + throw SyntaxError("variable name may not be " + decl); + } + return decl && (decl = IDENTIFIER.test(decl) && decl); + }; + + Class.prototype.setContext = function(name) { + return this.body.traverseChildren(false, function(node) { + if (node.classBody) return false; + if (node instanceof Literal && node.value === 'this') { + return node.value = name; + } else if (node instanceof Code) { + node.klass = name; + if (node.bound) return node.context = name; + } + }); + }; + + Class.prototype.addBoundFunctions = function(o) { + var bvar, lhs, _i, _len, _ref2, _results; + if (this.boundFuncs.length) { + _ref2 = this.boundFuncs; + _results = []; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + bvar = _ref2[_i]; + lhs = (new Value(new Literal("this"), [new Access(bvar)])).compile(o); + _results.push(this.ctor.body.unshift(new Literal("" + lhs + " = " + (utility('bind')) + "(" + lhs + ", this)"))); + } + return _results; + } + }; + + Class.prototype.addProperties = function(node, name, o) { + var assign, base, exprs, func, props; + props = node.base.properties.slice(0); + exprs = (function() { + var _results; + _results = []; + while (assign = props.shift()) { + if (assign instanceof Assign) { + base = assign.variable.base; + delete assign.context; + func = assign.value; + if (base.value === 'constructor') { + if (this.ctor) { + throw new Error('cannot define more than one constructor in a class'); + } + if (func.bound) { + throw new Error('cannot define a constructor as a bound function'); + } + if (func instanceof Code) { + assign = this.ctor = func; + } else { + this.externalCtor = o.scope.freeVariable('class'); + assign = new Assign(new Literal(this.externalCtor), func); + } + } else { + if (assign.variable["this"]) { + func["static"] = true; + if (func.bound) func.context = name; + } else { + assign.variable = new Value(new Literal(name), [new Access(new Literal('prototype')), new Access(base)]); + if (func instanceof Code && func.bound) { + this.boundFuncs.push(base); + func.bound = false; + } + } + } + } + _results.push(assign); + } + return _results; + }).call(this); + return compact(exprs); + }; + + Class.prototype.walkBody = function(name, o) { + var _this = this; + return this.traverseChildren(false, function(child) { + var exps, i, node, _i, _len, _ref2; + if (child instanceof Class) return false; + if (child instanceof Block) { + _ref2 = exps = child.expressions; + for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) { + node = _ref2[i]; + if (node instanceof Value && node.isObject(true)) { + exps[i] = _this.addProperties(node, name, o); + } + } + return child.expressions = exps = flatten(exps); + } + }); + }; + + Class.prototype.hoistDirectivePrologue = function() { + var expressions, index, node; + index = 0; + expressions = this.body.expressions; + while ((node = expressions[index]) && node instanceof Comment || node instanceof Value && node.isString()) { + ++index; + } + return this.directives = expressions.splice(0, index); + }; + + Class.prototype.ensureConstructor = function(name) { + if (!this.ctor) { + this.ctor = new Code; + if (this.parent) { + this.ctor.body.push(new Literal("" + name + ".__super__.constructor.apply(this, arguments)")); + } + if (this.externalCtor) { + this.ctor.body.push(new Literal("" + this.externalCtor + ".apply(this, arguments)")); + } + this.ctor.body.makeReturn(); + this.body.expressions.unshift(this.ctor); + } + this.ctor.ctor = this.ctor.name = name; + this.ctor.klass = null; + return this.ctor.noReturn = true; + }; + + Class.prototype.compileNode = function(o) { + var call, decl, klass, lname, name, params, _ref2; + decl = this.determineName(); + name = decl || '_Class'; + if (name.reserved) name = "_" + name; + lname = new Literal(name); + this.hoistDirectivePrologue(); + this.setContext(name); + this.walkBody(name, o); + this.ensureConstructor(name); + this.body.spaced = true; + if (!(this.ctor instanceof Code)) this.body.expressions.unshift(this.ctor); + if (decl) { + this.body.expressions.unshift(new Assign(new Value(new Literal(name), [new Access(new Literal('name'))]), new Literal("'" + name + "'"))); + } + this.body.expressions.push(lname); + (_ref2 = this.body.expressions).unshift.apply(_ref2, this.directives); + this.addBoundFunctions(o); + call = Closure.wrap(this.body); + if (this.parent) { + this.superClass = new Literal(o.scope.freeVariable('super', false)); + this.body.expressions.unshift(new Extends(lname, this.superClass)); + call.args.push(this.parent); + params = call.variable.params || call.variable.base.params; + params.push(new Param(this.superClass)); + } + klass = new Parens(call, true); + if (this.variable) klass = new Assign(this.variable, klass); + return klass.compile(o); + }; + + return Class; + + })(Base); + + exports.Assign = Assign = (function(_super) { + + __extends(Assign, _super); + + Assign.name = 'Assign'; + + function Assign(variable, value, context, options) { + var forbidden, name, _ref2; + this.variable = variable; + this.value = value; + this.context = context; + this.param = options && options.param; + this.subpattern = options && options.subpattern; + forbidden = (_ref2 = (name = this.variable.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref2) >= 0); + if (forbidden && this.context !== 'object') { + throw SyntaxError("variable name may not be \"" + name + "\""); + } + } + + Assign.prototype.children = ['variable', 'value']; + + Assign.prototype.isStatement = function(o) { + return (o != null ? o.level : void 0) === LEVEL_TOP && (this.context != null) && __indexOf.call(this.context, "?") >= 0; + }; + + Assign.prototype.assigns = function(name) { + return this[this.context === 'object' ? 'value' : 'variable'].assigns(name); + }; + + Assign.prototype.unfoldSoak = function(o) { + return unfoldSoak(o, this, 'variable'); + }; + + Assign.prototype.compileNode = function(o) { + var isValue, match, name, val, varBase, _ref2, _ref3, _ref4, _ref5; + if (isValue = this.variable instanceof Value) { + if (this.variable.isArray() || this.variable.isObject()) { + return this.compilePatternMatch(o); + } + if (this.variable.isSplice()) return this.compileSplice(o); + if ((_ref2 = this.context) === '||=' || _ref2 === '&&=' || _ref2 === '?=') { + return this.compileConditional(o); + } + } + name = this.variable.compile(o, LEVEL_LIST); + if (!this.context) { + if (!(varBase = this.variable.unwrapAll()).isAssignable()) { + throw SyntaxError("\"" + (this.variable.compile(o)) + "\" cannot be assigned."); + } + if (!(typeof varBase.hasProperties === "function" ? varBase.hasProperties() : void 0)) { + if (this.param) { + o.scope.add(name, 'var'); + } else { + o.scope.find(name); + } + } + } + if (this.value instanceof Code && (match = METHOD_DEF.exec(name))) { + if (match[1]) this.value.klass = match[1]; + this.value.name = (_ref3 = (_ref4 = (_ref5 = match[2]) != null ? _ref5 : match[3]) != null ? _ref4 : match[4]) != null ? _ref3 : match[5]; + } + val = this.value.compile(o, LEVEL_LIST); + if (this.context === 'object') return "" + name + ": " + val; + val = name + (" " + (this.context || '=') + " ") + val; + if (o.level <= LEVEL_LIST) { + return val; + } else { + return "(" + val + ")"; + } + }; + + Assign.prototype.compilePatternMatch = function(o) { + var acc, assigns, code, i, idx, isObject, ivar, name, obj, objects, olen, ref, rest, splat, top, val, value, vvar, _i, _len, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8; + top = o.level === LEVEL_TOP; + value = this.value; + objects = this.variable.base.objects; + if (!(olen = objects.length)) { + code = value.compile(o); + if (o.level >= LEVEL_OP) { + return "(" + code + ")"; + } else { + return code; + } + } + isObject = this.variable.isObject(); + if (top && olen === 1 && !((obj = objects[0]) instanceof Splat)) { + if (obj instanceof Assign) { + _ref2 = obj, (_ref3 = _ref2.variable, idx = _ref3.base), obj = _ref2.value; + } else { + if (obj.base instanceof Parens) { + _ref4 = new Value(obj.unwrapAll()).cacheReference(o), obj = _ref4[0], idx = _ref4[1]; + } else { + idx = isObject ? obj["this"] ? obj.properties[0].name : obj : new Literal(0); + } + } + acc = IDENTIFIER.test(idx.unwrap().value || 0); + value = new Value(value); + value.properties.push(new (acc ? Access : Index)(idx)); + if (_ref5 = obj.unwrap().value, __indexOf.call(RESERVED, _ref5) >= 0) { + throw new SyntaxError("assignment to a reserved word: " + (obj.compile(o)) + " = " + (value.compile(o))); + } + return new Assign(obj, value, null, { + param: this.param + }).compile(o, LEVEL_TOP); + } + vvar = value.compile(o, LEVEL_LIST); + assigns = []; + splat = false; + if (!IDENTIFIER.test(vvar) || this.variable.assigns(vvar)) { + assigns.push("" + (ref = o.scope.freeVariable('ref')) + " = " + vvar); + vvar = ref; + } + for (i = _i = 0, _len = objects.length; _i < _len; i = ++_i) { + obj = objects[i]; + idx = i; + if (isObject) { + if (obj instanceof Assign) { + _ref6 = obj, (_ref7 = _ref6.variable, idx = _ref7.base), obj = _ref6.value; + } else { + if (obj.base instanceof Parens) { + _ref8 = new Value(obj.unwrapAll()).cacheReference(o), obj = _ref8[0], idx = _ref8[1]; + } else { + idx = obj["this"] ? obj.properties[0].name : obj; + } + } + } + if (!splat && obj instanceof Splat) { + name = obj.name.unwrap().value; + obj = obj.unwrap(); + val = "" + olen + " <= " + vvar + ".length ? " + (utility('slice')) + ".call(" + vvar + ", " + i; + if (rest = olen - i - 1) { + ivar = o.scope.freeVariable('i'); + val += ", " + ivar + " = " + vvar + ".length - " + rest + ") : (" + ivar + " = " + i + ", [])"; + } else { + val += ") : []"; + } + val = new Literal(val); + splat = "" + ivar + "++"; + } else { + name = obj.unwrap().value; + if (obj instanceof Splat) { + obj = obj.name.compile(o); + throw new SyntaxError("multiple splats are disallowed in an assignment: " + obj + "..."); + } + if (typeof idx === 'number') { + idx = new Literal(splat || idx); + acc = false; + } else { + acc = isObject && IDENTIFIER.test(idx.unwrap().value || 0); + } + val = new Value(new Literal(vvar), [new (acc ? Access : Index)(idx)]); + } + if ((name != null) && __indexOf.call(RESERVED, name) >= 0) { + throw new SyntaxError("assignment to a reserved word: " + (obj.compile(o)) + " = " + (val.compile(o))); + } + assigns.push(new Assign(obj, val, null, { + param: this.param, + subpattern: true + }).compile(o, LEVEL_LIST)); + } + if (!(top || this.subpattern)) assigns.push(vvar); + code = assigns.join(', '); + if (o.level < LEVEL_LIST) { + return code; + } else { + return "(" + code + ")"; + } + }; + + Assign.prototype.compileConditional = function(o) { + var left, right, _ref2; + _ref2 = this.variable.cacheReference(o), left = _ref2[0], right = _ref2[1]; + if (left.base instanceof Literal && left.base.value !== "this" && !o.scope.check(left.base.value)) { + throw new Error("the variable \"" + left.base.value + "\" can't be assigned with " + this.context + " because it has not been defined."); + } + if (__indexOf.call(this.context, "?") >= 0) o.isExistentialEquals = true; + return new Op(this.context.slice(0, -1), left, new Assign(right, this.value, '=')).compile(o); + }; + + Assign.prototype.compileSplice = function(o) { + var code, exclusive, from, fromDecl, fromRef, name, to, valDef, valRef, _ref2, _ref3, _ref4; + _ref2 = this.variable.properties.pop().range, from = _ref2.from, to = _ref2.to, exclusive = _ref2.exclusive; + name = this.variable.compile(o); + _ref3 = (from != null ? from.cache(o, LEVEL_OP) : void 0) || ['0', '0'], fromDecl = _ref3[0], fromRef = _ref3[1]; + if (to) { + if ((from != null ? from.isSimpleNumber() : void 0) && to.isSimpleNumber()) { + to = +to.compile(o) - +fromRef; + if (!exclusive) to += 1; + } else { + to = to.compile(o, LEVEL_ACCESS) + ' - ' + fromRef; + if (!exclusive) to += ' + 1'; + } + } else { + to = "9e9"; + } + _ref4 = this.value.cache(o, LEVEL_LIST), valDef = _ref4[0], valRef = _ref4[1]; + code = "[].splice.apply(" + name + ", [" + fromDecl + ", " + to + "].concat(" + valDef + ")), " + valRef; + if (o.level > LEVEL_TOP) { + return "(" + code + ")"; + } else { + return code; + } + }; + + return Assign; + + })(Base); + + exports.Code = Code = (function(_super) { + + __extends(Code, _super); + + Code.name = 'Code'; + + function Code(params, body, tag) { + this.params = params || []; + this.body = body || new Block; + this.bound = tag === 'boundfunc'; + if (this.bound) this.context = '_this'; + } + + Code.prototype.children = ['params', 'body']; + + Code.prototype.isStatement = function() { + return !!this.ctor; + }; + + Code.prototype.jumps = NO; + + Code.prototype.compileNode = function(o) { + var code, exprs, i, idt, lit, name, p, param, params, ref, splats, uniqs, val, wasEmpty, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _len5, _m, _n, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8; + o.scope = new Scope(o.scope, this.body, this); + o.scope.shared = del(o, 'sharedScope'); + o.indent += TAB; + delete o.bare; + delete o.isExistentialEquals; + params = []; + exprs = []; + _ref2 = this.paramNames(); + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + name = _ref2[_i]; + if (!o.scope.check(name)) o.scope.parameter(name); + } + _ref3 = this.params; + for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) { + param = _ref3[_j]; + if (!param.splat) continue; + _ref4 = this.params; + for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) { + p = _ref4[_k]; + if (p.name.value) o.scope.add(p.name.value, 'var', true); + } + splats = new Assign(new Value(new Arr((function() { + var _l, _len3, _ref5, _results; + _ref5 = this.params; + _results = []; + for (_l = 0, _len3 = _ref5.length; _l < _len3; _l++) { + p = _ref5[_l]; + _results.push(p.asReference(o)); + } + return _results; + }).call(this))), new Value(new Literal('arguments'))); + break; + } + _ref5 = this.params; + for (_l = 0, _len3 = _ref5.length; _l < _len3; _l++) { + param = _ref5[_l]; + if (param.isComplex()) { + val = ref = param.asReference(o); + if (param.value) val = new Op('?', ref, param.value); + exprs.push(new Assign(new Value(param.name), val, '=', { + param: true + })); + } else { + ref = param; + if (param.value) { + lit = new Literal(ref.name.value + ' == null'); + val = new Assign(new Value(param.name), param.value, '='); + exprs.push(new If(lit, val)); + } + } + if (!splats) params.push(ref); + } + wasEmpty = this.body.isEmpty(); + if (splats) exprs.unshift(splats); + if (exprs.length) { + (_ref6 = this.body.expressions).unshift.apply(_ref6, exprs); + } + for (i = _m = 0, _len4 = params.length; _m < _len4; i = ++_m) { + p = params[i]; + o.scope.parameter(params[i] = p.compile(o)); + } + uniqs = []; + _ref7 = this.paramNames(); + for (_n = 0, _len5 = _ref7.length; _n < _len5; _n++) { + name = _ref7[_n]; + if (__indexOf.call(uniqs, name) >= 0) { + throw SyntaxError("multiple parameters named '" + name + "'"); + } + uniqs.push(name); + } + if (!(wasEmpty || this.noReturn)) this.body.makeReturn(); + if (this.bound) { + if ((_ref8 = o.scope.parent.method) != null ? _ref8.bound : void 0) { + this.bound = this.context = o.scope.parent.method.context; + } else if (!this["static"]) { + o.scope.parent.assign('_this', 'this'); + } + } + idt = o.indent; + code = 'function'; + if (this.ctor) code += ' ' + this.name; + code += '(' + params.join(', ') + ') {'; + if (!this.body.isEmpty()) { + code += "\n" + (this.body.compileWithDeclarations(o)) + "\n" + this.tab; + } + code += '}'; + if (this.ctor) return this.tab + code; + if (this.front || (o.level >= LEVEL_ACCESS)) { + return "(" + code + ")"; + } else { + return code; + } + }; + + Code.prototype.paramNames = function() { + var names, param, _i, _len, _ref2; + names = []; + _ref2 = this.params; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + param = _ref2[_i]; + names.push.apply(names, param.names()); + } + return names; + }; + + Code.prototype.traverseChildren = function(crossScope, func) { + if (crossScope) { + return Code.__super__.traverseChildren.call(this, crossScope, func); + } + }; + + return Code; + + })(Base); + + exports.Param = Param = (function(_super) { + + __extends(Param, _super); + + Param.name = 'Param'; + + function Param(name, value, splat) { + var _ref2; + this.name = name; + this.value = value; + this.splat = splat; + if (_ref2 = (name = this.name.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref2) >= 0) { + throw SyntaxError("parameter name \"" + name + "\" is not allowed"); + } + } + + Param.prototype.children = ['name', 'value']; + + Param.prototype.compile = function(o) { + return this.name.compile(o, LEVEL_LIST); + }; + + Param.prototype.asReference = function(o) { + var node; + if (this.reference) return this.reference; + node = this.name; + if (node["this"]) { + node = node.properties[0].name; + if (node.value.reserved) { + node = new Literal(o.scope.freeVariable(node.value)); + } + } else if (node.isComplex()) { + node = new Literal(o.scope.freeVariable('arg')); + } + node = new Value(node); + if (this.splat) node = new Splat(node); + return this.reference = node; + }; + + Param.prototype.isComplex = function() { + return this.name.isComplex(); + }; + + Param.prototype.names = function(name) { + var atParam, names, obj, _i, _len, _ref2; + if (name == null) name = this.name; + atParam = function(obj) { + var value; + value = obj.properties[0].name.value; + if (value.reserved) { + return []; + } else { + return [value]; + } + }; + if (name instanceof Literal) return [name.value]; + if (name instanceof Value) return atParam(name); + names = []; + _ref2 = name.objects; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + obj = _ref2[_i]; + if (obj instanceof Assign) { + names.push(obj.variable.base.value); + } else if (obj.isArray() || obj.isObject()) { + names.push.apply(names, this.names(obj.base)); + } else if (obj["this"]) { + names.push.apply(names, atParam(obj)); + } else { + names.push(obj.base.value); + } + } + return names; + }; + + return Param; + + })(Base); + + exports.Splat = Splat = (function(_super) { + + __extends(Splat, _super); + + Splat.name = 'Splat'; + + Splat.prototype.children = ['name']; + + Splat.prototype.isAssignable = YES; + + function Splat(name) { + this.name = name.compile ? name : new Literal(name); + } + + Splat.prototype.assigns = function(name) { + return this.name.assigns(name); + }; + + Splat.prototype.compile = function(o) { + if (this.index != null) { + return this.compileParam(o); + } else { + return this.name.compile(o); + } + }; + + Splat.prototype.unwrap = function() { + return this.name; + }; + + Splat.compileSplattedArray = function(o, list, apply) { + var args, base, code, i, index, node, _i, _len; + index = -1; + while ((node = list[++index]) && !(node instanceof Splat)) { + continue; + } + if (index >= list.length) return ''; + if (list.length === 1) { + code = list[0].compile(o, LEVEL_LIST); + if (apply) return code; + return "" + (utility('slice')) + ".call(" + code + ")"; + } + args = list.slice(index); + for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) { + node = args[i]; + code = node.compile(o, LEVEL_LIST); + args[i] = node instanceof Splat ? "" + (utility('slice')) + ".call(" + code + ")" : "[" + code + "]"; + } + if (index === 0) { + return args[0] + (".concat(" + (args.slice(1).join(', ')) + ")"); + } + base = (function() { + var _j, _len1, _ref2, _results; + _ref2 = list.slice(0, index); + _results = []; + for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { + node = _ref2[_j]; + _results.push(node.compile(o, LEVEL_LIST)); + } + return _results; + })(); + return "[" + (base.join(', ')) + "].concat(" + (args.join(', ')) + ")"; + }; + + return Splat; + + })(Base); + + exports.While = While = (function(_super) { + + __extends(While, _super); + + While.name = 'While'; + + function While(condition, options) { + this.condition = (options != null ? options.invert : void 0) ? condition.invert() : condition; + this.guard = options != null ? options.guard : void 0; + } + + While.prototype.children = ['condition', 'guard', 'body']; + + While.prototype.isStatement = YES; + + While.prototype.makeReturn = function(res) { + if (res) { + return While.__super__.makeReturn.apply(this, arguments); + } else { + this.returns = !this.jumps({ + loop: true + }); + return this; + } + }; + + While.prototype.addBody = function(body) { + this.body = body; + return this; + }; + + While.prototype.jumps = function() { + var expressions, node, _i, _len; + expressions = this.body.expressions; + if (!expressions.length) return false; + for (_i = 0, _len = expressions.length; _i < _len; _i++) { + node = expressions[_i]; + if (node.jumps({ + loop: true + })) return node; + } + return false; + }; + + While.prototype.compileNode = function(o) { + var body, code, rvar, set; + o.indent += TAB; + set = ''; + body = this.body; + if (body.isEmpty()) { + body = ''; + } else { + if (this.returns) { + body.makeReturn(rvar = o.scope.freeVariable('results')); + set = "" + this.tab + rvar + " = [];\n"; + } + if (this.guard) { + if (body.expressions.length > 1) { + body.expressions.unshift(new If((new Parens(this.guard)).invert(), new Literal("continue"))); + } else { + if (this.guard) body = Block.wrap([new If(this.guard, body)]); + } + } + body = "\n" + (body.compile(o, LEVEL_TOP)) + "\n" + this.tab; + } + code = set + this.tab + ("while (" + (this.condition.compile(o, LEVEL_PAREN)) + ") {" + body + "}"); + if (this.returns) code += "\n" + this.tab + "return " + rvar + ";"; + return code; + }; + + return While; + + })(Base); + + exports.Op = Op = (function(_super) { + var CONVERSIONS, INVERSIONS; + + __extends(Op, _super); + + Op.name = 'Op'; + + function Op(op, first, second, flip) { + if (op === 'in') return new In(first, second); + if (op === 'do') return this.generateDo(first); + if (op === 'new') { + if (first instanceof Call && !first["do"] && !first.isNew) { + return first.newInstance(); + } + if (first instanceof Code && first.bound || first["do"]) { + first = new Parens(first); + } + } + this.operator = CONVERSIONS[op] || op; + this.first = first; + this.second = second; + this.flip = !!flip; + return this; + } + + CONVERSIONS = { + '==': '===', + '!=': '!==', + 'of': 'in' + }; + + INVERSIONS = { + '!==': '===', + '===': '!==' + }; + + Op.prototype.children = ['first', 'second']; + + Op.prototype.isSimpleNumber = NO; + + Op.prototype.isUnary = function() { + return !this.second; + }; + + Op.prototype.isComplex = function() { + var _ref2; + return !(this.isUnary() && ((_ref2 = this.operator) === '+' || _ref2 === '-')) || this.first.isComplex(); + }; + + Op.prototype.isChainable = function() { + var _ref2; + return (_ref2 = this.operator) === '<' || _ref2 === '>' || _ref2 === '>=' || _ref2 === '<=' || _ref2 === '===' || _ref2 === '!=='; + }; + + Op.prototype.invert = function() { + var allInvertable, curr, fst, op, _ref2; + if (this.isChainable() && this.first.isChainable()) { + allInvertable = true; + curr = this; + while (curr && curr.operator) { + allInvertable && (allInvertable = curr.operator in INVERSIONS); + curr = curr.first; + } + if (!allInvertable) return new Parens(this).invert(); + curr = this; + while (curr && curr.operator) { + curr.invert = !curr.invert; + curr.operator = INVERSIONS[curr.operator]; + curr = curr.first; + } + return this; + } else if (op = INVERSIONS[this.operator]) { + this.operator = op; + if (this.first.unwrap() instanceof Op) this.first.invert(); + return this; + } else if (this.second) { + return new Parens(this).invert(); + } else if (this.operator === '!' && (fst = this.first.unwrap()) instanceof Op && ((_ref2 = fst.operator) === '!' || _ref2 === 'in' || _ref2 === 'instanceof')) { + return fst; + } else { + return new Op('!', this); + } + }; + + Op.prototype.unfoldSoak = function(o) { + var _ref2; + return ((_ref2 = this.operator) === '++' || _ref2 === '--' || _ref2 === 'delete') && unfoldSoak(o, this, 'first'); + }; + + Op.prototype.generateDo = function(exp) { + var call, func, param, passedParams, ref, _i, _len, _ref2; + passedParams = []; + func = exp instanceof Assign && (ref = exp.value.unwrap()) instanceof Code ? ref : exp; + _ref2 = func.params || []; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + param = _ref2[_i]; + if (param.value) { + passedParams.push(param.value); + delete param.value; + } else { + passedParams.push(param); + } + } + call = new Call(exp, passedParams); + call["do"] = true; + return call; + }; + + Op.prototype.compileNode = function(o) { + var code, isChain, _ref2, _ref3; + isChain = this.isChainable() && this.first.isChainable(); + if (!isChain) this.first.front = this.front; + if (this.operator === 'delete' && o.scope.check(this.first.unwrapAll().value)) { + throw SyntaxError('delete operand may not be argument or var'); + } + if (((_ref2 = this.operator) === '--' || _ref2 === '++') && (_ref3 = this.first.unwrapAll().value, __indexOf.call(STRICT_PROSCRIBED, _ref3) >= 0)) { + throw SyntaxError('prefix increment/decrement may not have eval or arguments operand'); + } + if (this.isUnary()) return this.compileUnary(o); + if (isChain) return this.compileChain(o); + if (this.operator === '?') return this.compileExistence(o); + code = this.first.compile(o, LEVEL_OP) + ' ' + this.operator + ' ' + this.second.compile(o, LEVEL_OP); + if (o.level <= LEVEL_OP) { + return code; + } else { + return "(" + code + ")"; + } + }; + + Op.prototype.compileChain = function(o) { + var code, fst, shared, _ref2; + _ref2 = this.first.second.cache(o), this.first.second = _ref2[0], shared = _ref2[1]; + fst = this.first.compile(o, LEVEL_OP); + code = "" + fst + " " + (this.invert ? '&&' : '||') + " " + (shared.compile(o)) + " " + this.operator + " " + (this.second.compile(o, LEVEL_OP)); + return "(" + code + ")"; + }; + + Op.prototype.compileExistence = function(o) { + var fst, ref; + if (this.first.isComplex() && o.level > LEVEL_TOP) { + ref = new Literal(o.scope.freeVariable('ref')); + fst = new Parens(new Assign(ref, this.first)); + } else { + fst = this.first; + ref = fst; + } + return new If(new Existence(fst), ref, { + type: 'if' + }).addElse(this.second).compile(o); + }; + + Op.prototype.compileUnary = function(o) { + var op, parts, plusMinus; + if (o.level >= LEVEL_ACCESS) return (new Parens(this)).compile(o); + parts = [op = this.operator]; + plusMinus = op === '+' || op === '-'; + if ((op === 'new' || op === 'typeof' || op === 'delete') || plusMinus && this.first instanceof Op && this.first.operator === op) { + parts.push(' '); + } + if ((plusMinus && this.first instanceof Op) || (op === 'new' && this.first.isStatement(o))) { + this.first = new Parens(this.first); + } + parts.push(this.first.compile(o, LEVEL_OP)); + if (this.flip) parts.reverse(); + return parts.join(''); + }; + + Op.prototype.toString = function(idt) { + return Op.__super__.toString.call(this, idt, this.constructor.name + ' ' + this.operator); + }; + + return Op; + + })(Base); + + exports.In = In = (function(_super) { + + __extends(In, _super); + + In.name = 'In'; + + function In(object, array) { + this.object = object; + this.array = array; + } + + In.prototype.children = ['object', 'array']; + + In.prototype.invert = NEGATE; + + In.prototype.compileNode = function(o) { + var hasSplat, obj, _i, _len, _ref2; + if (this.array instanceof Value && this.array.isArray()) { + _ref2 = this.array.base.objects; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + obj = _ref2[_i]; + if (!(obj instanceof Splat)) continue; + hasSplat = true; + break; + } + if (!hasSplat) return this.compileOrTest(o); + } + return this.compileLoopTest(o); + }; + + In.prototype.compileOrTest = function(o) { + var cmp, cnj, i, item, ref, sub, tests, _ref2, _ref3; + if (this.array.base.objects.length === 0) return "" + (!!this.negated); + _ref2 = this.object.cache(o, LEVEL_OP), sub = _ref2[0], ref = _ref2[1]; + _ref3 = this.negated ? [' !== ', ' && '] : [' === ', ' || '], cmp = _ref3[0], cnj = _ref3[1]; + tests = (function() { + var _i, _len, _ref4, _results; + _ref4 = this.array.base.objects; + _results = []; + for (i = _i = 0, _len = _ref4.length; _i < _len; i = ++_i) { + item = _ref4[i]; + _results.push((i ? ref : sub) + cmp + item.compile(o, LEVEL_ACCESS)); + } + return _results; + }).call(this); + tests = tests.join(cnj); + if (o.level < LEVEL_OP) { + return tests; + } else { + return "(" + tests + ")"; + } + }; + + In.prototype.compileLoopTest = function(o) { + var code, ref, sub, _ref2; + _ref2 = this.object.cache(o, LEVEL_LIST), sub = _ref2[0], ref = _ref2[1]; + code = utility('indexOf') + (".call(" + (this.array.compile(o, LEVEL_LIST)) + ", " + ref + ") ") + (this.negated ? '< 0' : '>= 0'); + if (sub === ref) return code; + code = sub + ', ' + code; + if (o.level < LEVEL_LIST) { + return code; + } else { + return "(" + code + ")"; + } + }; + + In.prototype.toString = function(idt) { + return In.__super__.toString.call(this, idt, this.constructor.name + (this.negated ? '!' : '')); + }; + + return In; + + })(Base); + + exports.Try = Try = (function(_super) { + + __extends(Try, _super); + + Try.name = 'Try'; + + function Try(attempt, error, recovery, ensure) { + this.attempt = attempt; + this.error = error; + this.recovery = recovery; + this.ensure = ensure; + } + + Try.prototype.children = ['attempt', 'recovery', 'ensure']; + + Try.prototype.isStatement = YES; + + Try.prototype.jumps = function(o) { + var _ref2; + return this.attempt.jumps(o) || ((_ref2 = this.recovery) != null ? _ref2.jumps(o) : void 0); + }; + + Try.prototype.makeReturn = function(res) { + if (this.attempt) this.attempt = this.attempt.makeReturn(res); + if (this.recovery) this.recovery = this.recovery.makeReturn(res); + return this; + }; + + Try.prototype.compileNode = function(o) { + var catchPart, ensurePart, errorPart, tryPart; + o.indent += TAB; + errorPart = this.error ? " (" + (this.error.compile(o)) + ") " : ' '; + tryPart = this.attempt.compile(o, LEVEL_TOP); + catchPart = (function() { + var _ref2; + if (this.recovery) { + if (_ref2 = this.error.value, __indexOf.call(STRICT_PROSCRIBED, _ref2) >= 0) { + throw SyntaxError("catch variable may not be \"" + this.error.value + "\""); + } + if (!o.scope.check(this.error.value)) { + o.scope.add(this.error.value, 'param'); + } + return " catch" + errorPart + "{\n" + (this.recovery.compile(o, LEVEL_TOP)) + "\n" + this.tab + "}"; + } else if (!(this.ensure || this.recovery)) { + return ' catch (_error) {}'; + } + }).call(this); + ensurePart = this.ensure ? " finally {\n" + (this.ensure.compile(o, LEVEL_TOP)) + "\n" + this.tab + "}" : ''; + return "" + this.tab + "try {\n" + tryPart + "\n" + this.tab + "}" + (catchPart || '') + ensurePart; + }; + + return Try; + + })(Base); + + exports.Throw = Throw = (function(_super) { + + __extends(Throw, _super); + + Throw.name = 'Throw'; + + function Throw(expression) { + this.expression = expression; + } + + Throw.prototype.children = ['expression']; + + Throw.prototype.isStatement = YES; + + Throw.prototype.jumps = NO; + + Throw.prototype.makeReturn = THIS; + + Throw.prototype.compileNode = function(o) { + return this.tab + ("throw " + (this.expression.compile(o)) + ";"); + }; + + return Throw; + + })(Base); + + exports.Existence = Existence = (function(_super) { + + __extends(Existence, _super); + + Existence.name = 'Existence'; + + function Existence(expression) { + this.expression = expression; + } + + Existence.prototype.children = ['expression']; + + Existence.prototype.invert = NEGATE; + + Existence.prototype.compileNode = function(o) { + var cmp, cnj, code, _ref2; + this.expression.front = this.front; + code = this.expression.compile(o, LEVEL_OP); + if (IDENTIFIER.test(code) && !o.scope.check(code)) { + _ref2 = this.negated ? ['===', '||'] : ['!==', '&&'], cmp = _ref2[0], cnj = _ref2[1]; + code = "typeof " + code + " " + cmp + " \"undefined\" " + cnj + " " + code + " " + cmp + " null"; + } else { + code = "" + code + " " + (this.negated ? '==' : '!=') + " null"; + } + if (o.level <= LEVEL_COND) { + return code; + } else { + return "(" + code + ")"; + } + }; + + return Existence; + + })(Base); + + exports.Parens = Parens = (function(_super) { + + __extends(Parens, _super); + + Parens.name = 'Parens'; + + function Parens(body) { + this.body = body; + } + + Parens.prototype.children = ['body']; + + Parens.prototype.unwrap = function() { + return this.body; + }; + + Parens.prototype.isComplex = function() { + return this.body.isComplex(); + }; + + Parens.prototype.compileNode = function(o) { + var bare, code, expr; + expr = this.body.unwrap(); + if (expr instanceof Value && expr.isAtomic()) { + expr.front = this.front; + return expr.compile(o); + } + code = expr.compile(o, LEVEL_PAREN); + bare = o.level < LEVEL_OP && (expr instanceof Op || expr instanceof Call || (expr instanceof For && expr.returns)); + if (bare) { + return code; + } else { + return "(" + code + ")"; + } + }; + + return Parens; + + })(Base); + + exports.For = For = (function(_super) { + + __extends(For, _super); + + For.name = 'For'; + + function For(body, source) { + var _ref2; + this.source = source.source, this.guard = source.guard, this.step = source.step, this.name = source.name, this.index = source.index; + this.body = Block.wrap([body]); + this.own = !!source.own; + this.object = !!source.object; + if (this.object) { + _ref2 = [this.index, this.name], this.name = _ref2[0], this.index = _ref2[1]; + } + if (this.index instanceof Value) { + throw SyntaxError('index cannot be a pattern matching expression'); + } + this.range = this.source instanceof Value && this.source.base instanceof Range && !this.source.properties.length; + this.pattern = this.name instanceof Value; + if (this.range && this.index) { + throw SyntaxError('indexes do not apply to range loops'); + } + if (this.range && this.pattern) { + throw SyntaxError('cannot pattern match over range loops'); + } + this.returns = false; + } + + For.prototype.children = ['body', 'source', 'guard', 'step']; + + For.prototype.compileNode = function(o) { + var body, defPart, forPart, forVarPart, guardPart, idt1, index, ivar, kvar, kvarAssign, lastJumps, lvar, name, namePart, ref, resultPart, returnResult, rvar, scope, source, stepPart, stepvar, svar, varPart, _ref2; + body = Block.wrap([this.body]); + lastJumps = (_ref2 = last(body.expressions)) != null ? _ref2.jumps() : void 0; + if (lastJumps && lastJumps instanceof Return) this.returns = false; + source = this.range ? this.source.base : this.source; + scope = o.scope; + name = this.name && this.name.compile(o, LEVEL_LIST); + index = this.index && this.index.compile(o, LEVEL_LIST); + if (name && !this.pattern) { + scope.find(name, { + immediate: true + }); + } + if (index) { + scope.find(index, { + immediate: true + }); + } + if (this.returns) rvar = scope.freeVariable('results'); + ivar = (this.object && index) || scope.freeVariable('i'); + kvar = (this.range && name) || index || ivar; + kvarAssign = kvar !== ivar ? "" + kvar + " = " : ""; + if (this.step && !this.range) stepvar = scope.freeVariable("step"); + if (this.pattern) name = ivar; + varPart = ''; + guardPart = ''; + defPart = ''; + idt1 = this.tab + TAB; + if (this.range) { + forPart = source.compile(merge(o, { + index: ivar, + name: name, + step: this.step + })); + } else { + svar = this.source.compile(o, LEVEL_LIST); + if ((name || this.own) && !IDENTIFIER.test(svar)) { + defPart = "" + this.tab + (ref = scope.freeVariable('ref')) + " = " + svar + ";\n"; + svar = ref; + } + if (name && !this.pattern) { + namePart = "" + name + " = " + svar + "[" + kvar + "]"; + } + if (!this.object) { + lvar = scope.freeVariable('len'); + forVarPart = "" + kvarAssign + ivar + " = 0, " + lvar + " = " + svar + ".length"; + if (this.step) { + forVarPart += ", " + stepvar + " = " + (this.step.compile(o, LEVEL_OP)); + } + stepPart = "" + kvarAssign + (this.step ? "" + ivar + " += " + stepvar : (kvar !== ivar ? "++" + ivar : "" + ivar + "++")); + forPart = "" + forVarPart + "; " + ivar + " < " + lvar + "; " + stepPart; + } + } + if (this.returns) { + resultPart = "" + this.tab + rvar + " = [];\n"; + returnResult = "\n" + this.tab + "return " + rvar + ";"; + body.makeReturn(rvar); + } + if (this.guard) { + if (body.expressions.length > 1) { + body.expressions.unshift(new If((new Parens(this.guard)).invert(), new Literal("continue"))); + } else { + if (this.guard) body = Block.wrap([new If(this.guard, body)]); + } + } + if (this.pattern) { + body.expressions.unshift(new Assign(this.name, new Literal("" + svar + "[" + kvar + "]"))); + } + defPart += this.pluckDirectCall(o, body); + if (namePart) varPart = "\n" + idt1 + namePart + ";"; + if (this.object) { + forPart = "" + kvar + " in " + svar; + if (this.own) { + guardPart = "\n" + idt1 + "if (!" + (utility('hasProp')) + ".call(" + svar + ", " + kvar + ")) continue;"; + } + } + body = body.compile(merge(o, { + indent: idt1 + }), LEVEL_TOP); + if (body) body = '\n' + body + '\n'; + return "" + defPart + (resultPart || '') + this.tab + "for (" + forPart + ") {" + guardPart + varPart + body + this.tab + "}" + (returnResult || ''); + }; + + For.prototype.pluckDirectCall = function(o, body) { + var base, defs, expr, fn, idx, ref, val, _i, _len, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7; + defs = ''; + _ref2 = body.expressions; + for (idx = _i = 0, _len = _ref2.length; _i < _len; idx = ++_i) { + expr = _ref2[idx]; + expr = expr.unwrapAll(); + if (!(expr instanceof Call)) continue; + val = expr.variable.unwrapAll(); + if (!((val instanceof Code) || (val instanceof Value && ((_ref3 = val.base) != null ? _ref3.unwrapAll() : void 0) instanceof Code && val.properties.length === 1 && ((_ref4 = (_ref5 = val.properties[0].name) != null ? _ref5.value : void 0) === 'call' || _ref4 === 'apply')))) { + continue; + } + fn = ((_ref6 = val.base) != null ? _ref6.unwrapAll() : void 0) || val; + ref = new Literal(o.scope.freeVariable('fn')); + base = new Value(ref); + if (val.base) _ref7 = [base, val], val.base = _ref7[0], base = _ref7[1]; + body.expressions[idx] = new Call(base, expr.args); + defs += this.tab + new Assign(ref, fn).compile(o, LEVEL_TOP) + ';\n'; + } + return defs; + }; + + return For; + + })(While); + + exports.Switch = Switch = (function(_super) { + + __extends(Switch, _super); + + Switch.name = 'Switch'; + + function Switch(subject, cases, otherwise) { + this.subject = subject; + this.cases = cases; + this.otherwise = otherwise; + } + + Switch.prototype.children = ['subject', 'cases', 'otherwise']; + + Switch.prototype.isStatement = YES; + + Switch.prototype.jumps = function(o) { + var block, conds, _i, _len, _ref2, _ref3, _ref4; + if (o == null) { + o = { + block: true + }; + } + _ref2 = this.cases; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + _ref3 = _ref2[_i], conds = _ref3[0], block = _ref3[1]; + if (block.jumps(o)) return block; + } + return (_ref4 = this.otherwise) != null ? _ref4.jumps(o) : void 0; + }; + + Switch.prototype.makeReturn = function(res) { + var pair, _i, _len, _ref2, _ref3; + _ref2 = this.cases; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + pair = _ref2[_i]; + pair[1].makeReturn(res); + } + if (res) { + this.otherwise || (this.otherwise = new Block([new Literal('void 0')])); + } + if ((_ref3 = this.otherwise) != null) _ref3.makeReturn(res); + return this; + }; + + Switch.prototype.compileNode = function(o) { + var block, body, code, cond, conditions, expr, i, idt1, idt2, _i, _j, _len, _len1, _ref2, _ref3, _ref4, _ref5; + idt1 = o.indent + TAB; + idt2 = o.indent = idt1 + TAB; + code = this.tab + ("switch (" + (((_ref2 = this.subject) != null ? _ref2.compile(o, LEVEL_PAREN) : void 0) || false) + ") {\n"); + _ref3 = this.cases; + for (i = _i = 0, _len = _ref3.length; _i < _len; i = ++_i) { + _ref4 = _ref3[i], conditions = _ref4[0], block = _ref4[1]; + _ref5 = flatten([conditions]); + for (_j = 0, _len1 = _ref5.length; _j < _len1; _j++) { + cond = _ref5[_j]; + if (!this.subject) cond = cond.invert(); + code += idt1 + ("case " + (cond.compile(o, LEVEL_PAREN)) + ":\n"); + } + if (body = block.compile(o, LEVEL_TOP)) code += body + '\n'; + if (i === this.cases.length - 1 && !this.otherwise) break; + expr = this.lastNonComment(block.expressions); + if (expr instanceof Return || (expr instanceof Literal && expr.jumps() && expr.value !== 'debugger')) { + continue; + } + code += idt2 + 'break;\n'; + } + if (this.otherwise && this.otherwise.expressions.length) { + code += idt1 + ("default:\n" + (this.otherwise.compile(o, LEVEL_TOP)) + "\n"); + } + return code + this.tab + '}'; + }; + + return Switch; + + })(Base); + + exports.If = If = (function(_super) { + + __extends(If, _super); + + If.name = 'If'; + + function If(condition, body, options) { + this.body = body; + if (options == null) options = {}; + this.condition = options.type === 'unless' ? condition.invert() : condition; + this.elseBody = null; + this.isChain = false; + this.soak = options.soak; + } + + If.prototype.children = ['condition', 'body', 'elseBody']; + + If.prototype.bodyNode = function() { + var _ref2; + return (_ref2 = this.body) != null ? _ref2.unwrap() : void 0; + }; + + If.prototype.elseBodyNode = function() { + var _ref2; + return (_ref2 = this.elseBody) != null ? _ref2.unwrap() : void 0; + }; + + If.prototype.addElse = function(elseBody) { + if (this.isChain) { + this.elseBodyNode().addElse(elseBody); + } else { + this.isChain = elseBody instanceof If; + this.elseBody = this.ensureBlock(elseBody); + } + return this; + }; + + If.prototype.isStatement = function(o) { + var _ref2; + return (o != null ? o.level : void 0) === LEVEL_TOP || this.bodyNode().isStatement(o) || ((_ref2 = this.elseBodyNode()) != null ? _ref2.isStatement(o) : void 0); + }; + + If.prototype.jumps = function(o) { + var _ref2; + return this.body.jumps(o) || ((_ref2 = this.elseBody) != null ? _ref2.jumps(o) : void 0); + }; + + If.prototype.compileNode = function(o) { + if (this.isStatement(o)) { + return this.compileStatement(o); + } else { + return this.compileExpression(o); + } + }; + + If.prototype.makeReturn = function(res) { + if (res) { + this.elseBody || (this.elseBody = new Block([new Literal('void 0')])); + } + this.body && (this.body = new Block([this.body.makeReturn(res)])); + this.elseBody && (this.elseBody = new Block([this.elseBody.makeReturn(res)])); + return this; + }; + + If.prototype.ensureBlock = function(node) { + if (node instanceof Block) { + return node; + } else { + return new Block([node]); + } + }; + + If.prototype.compileStatement = function(o) { + var body, bodyc, child, cond, exeq, ifPart, _ref2; + child = del(o, 'chainChild'); + exeq = del(o, 'isExistentialEquals'); + if (exeq) { + return new If(this.condition.invert(), this.elseBodyNode(), { + type: 'if' + }).compile(o); + } + cond = this.condition.compile(o, LEVEL_PAREN); + o.indent += TAB; + body = this.ensureBlock(this.body); + bodyc = body.compile(o); + if (1 === ((_ref2 = body.expressions) != null ? _ref2.length : void 0) && !this.elseBody && !child && bodyc && cond && -1 === (bodyc.indexOf('\n')) && 80 > cond.length + bodyc.length) { + return "" + this.tab + "if (" + cond + ") " + (bodyc.replace(/^\s+/, '')); + } + if (bodyc) bodyc = "\n" + bodyc + "\n" + this.tab; + ifPart = "if (" + cond + ") {" + bodyc + "}"; + if (!child) ifPart = this.tab + ifPart; + if (!this.elseBody) return ifPart; + return ifPart + ' else ' + (this.isChain ? (o.indent = this.tab, o.chainChild = true, this.elseBody.unwrap().compile(o, LEVEL_TOP)) : "{\n" + (this.elseBody.compile(o, LEVEL_TOP)) + "\n" + this.tab + "}"); + }; + + If.prototype.compileExpression = function(o) { + var alt, body, code, cond; + cond = this.condition.compile(o, LEVEL_COND); + body = this.bodyNode().compile(o, LEVEL_LIST); + alt = this.elseBodyNode() ? this.elseBodyNode().compile(o, LEVEL_LIST) : 'void 0'; + code = "" + cond + " ? " + body + " : " + alt; + if (o.level >= LEVEL_COND) { + return "(" + code + ")"; + } else { + return code; + } + }; + + If.prototype.unfoldSoak = function() { + return this.soak && this; + }; + + return If; + + })(Base); + + Closure = { + wrap: function(expressions, statement, noReturn) { + var args, call, func, mentionsArgs, meth; + if (expressions.jumps()) return expressions; + func = new Code([], Block.wrap([expressions])); + args = []; + if ((mentionsArgs = expressions.contains(this.literalArgs)) || expressions.contains(this.literalThis)) { + meth = new Literal(mentionsArgs ? 'apply' : 'call'); + args = [new Literal('this')]; + if (mentionsArgs) args.push(new Literal('arguments')); + func = new Value(func, [new Access(meth)]); + } + func.noReturn = noReturn; + call = new Call(func, args); + if (statement) { + return Block.wrap([call]); + } else { + return call; + } + }, + literalArgs: function(node) { + return node instanceof Literal && node.value === 'arguments' && !node.asKey; + }, + literalThis: function(node) { + return (node instanceof Literal && node.value === 'this' && !node.asKey) || (node instanceof Code && node.bound); + } + }; + + unfoldSoak = function(o, parent, name) { + var ifn; + if (!(ifn = parent[name].unfoldSoak(o))) return; + parent[name] = ifn.body; + ifn.body = new Value(parent); + return ifn; + }; + + UTILITIES = { + "extends": function() { + return "function(child, parent) { for (var key in parent) { if (" + (utility('hasProp')) + ".call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }"; + }, + bind: function() { + return 'function(fn, me){ return function(){ return fn.apply(me, arguments); }; }'; + }, + indexOf: function() { + return "[].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }"; + }, + hasProp: function() { + return '{}.hasOwnProperty'; + }, + slice: function() { + return '[].slice'; + } + }; + + LEVEL_TOP = 1; + + LEVEL_PAREN = 2; + + LEVEL_LIST = 3; + + LEVEL_COND = 4; + + LEVEL_OP = 5; + + LEVEL_ACCESS = 6; + + TAB = ' '; + + IDENTIFIER_STR = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*"; + + IDENTIFIER = RegExp("^" + IDENTIFIER_STR + "$"); + + SIMPLENUM = /^[+-]?\d+$/; + + METHOD_DEF = RegExp("^(?:(" + IDENTIFIER_STR + ")\\.prototype(?:\\.(" + IDENTIFIER_STR + ")|\\[(\"(?:[^\\\\\"\\r\\n]|\\\\.)*\"|'(?:[^\\\\'\\r\\n]|\\\\.)*')\\]|\\[(0x[\\da-fA-F]+|\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\]))|(" + IDENTIFIER_STR + ")$"); + + IS_STRING = /^['"]/; + + utility = function(name) { + var ref; + ref = "__" + name; + Scope.root.assign(ref, UTILITIES[name]()); + return ref; + }; + + multident = function(code, tab) { + code = code.replace(/\n/g, '$&' + tab); + return code.replace(/\s+$/, ''); + }; + + +}); + +define('ace/mode/coffee/scope', ['require', 'exports', 'module' , 'ace/mode/coffee/helpers'], function(require, exports, module) { +// Generated by CoffeeScript 1.2.1-pre + + var Scope, extend, last, _ref; + + _ref = require('./helpers'), extend = _ref.extend, last = _ref.last; + + exports.Scope = Scope = (function() { + + Scope.name = 'Scope'; + + Scope.root = null; + + function Scope(parent, expressions, method) { + this.parent = parent; + this.expressions = expressions; + this.method = method; + this.variables = [ + { + name: 'arguments', + type: 'arguments' + } + ]; + this.positions = {}; + if (!this.parent) Scope.root = this; + } + + Scope.prototype.add = function(name, type, immediate) { + if (this.shared && !immediate) return this.parent.add(name, type, immediate); + if (Object.prototype.hasOwnProperty.call(this.positions, name)) { + return this.variables[this.positions[name]].type = type; + } else { + return this.positions[name] = this.variables.push({ + name: name, + type: type + }) - 1; + } + }; + + Scope.prototype.find = function(name, options) { + if (this.check(name, options)) return true; + this.add(name, 'var'); + return false; + }; + + Scope.prototype.parameter = function(name) { + if (this.shared && this.parent.check(name, true)) return; + return this.add(name, 'param'); + }; + + Scope.prototype.check = function(name, immediate) { + var found, _ref1; + found = !!this.type(name); + if (found || immediate) return found; + return !!((_ref1 = this.parent) != null ? _ref1.check(name) : void 0); + }; + + Scope.prototype.temporary = function(name, index) { + if (name.length > 1) { + return '_' + name + (index > 1 ? index - 1 : ''); + } else { + return '_' + (index + parseInt(name, 36)).toString(36).replace(/\d/g, 'a'); + } + }; + + Scope.prototype.type = function(name) { + var v, _i, _len, _ref1; + _ref1 = this.variables; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + v = _ref1[_i]; + if (v.name === name) return v.type; + } + return null; + }; + + Scope.prototype.freeVariable = function(name, reserve) { + var index, temp; + if (reserve == null) reserve = true; + index = 0; + while (this.check((temp = this.temporary(name, index)))) { + index++; + } + if (reserve) this.add(temp, 'var', true); + return temp; + }; + + Scope.prototype.assign = function(name, value) { + this.add(name, { + value: value, + assigned: true + }, true); + return this.hasAssignments = true; + }; + + Scope.prototype.hasDeclarations = function() { + return !!this.declaredVariables().length; + }; + + Scope.prototype.declaredVariables = function() { + var realVars, tempVars, v, _i, _len, _ref1; + realVars = []; + tempVars = []; + _ref1 = this.variables; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + v = _ref1[_i]; + if (v.type === 'var') { + (v.name.charAt(0) === '_' ? tempVars : realVars).push(v.name); + } + } + return realVars.sort().concat(tempVars.sort()); + }; + + Scope.prototype.assignedVariables = function() { + var v, _i, _len, _ref1, _results; + _ref1 = this.variables; + _results = []; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + v = _ref1[_i]; + if (v.type.assigned) _results.push("" + v.name + " = " + v.type.value); + } + return _results; + }; + + return Scope; + + })(); + + +}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/worker-css.js b/vendor/assets/javascripts/ace-src-noconflict/worker-css.js new file mode 100644 index 00000000..19513c7b --- /dev/null +++ b/vendor/assets/javascripts/ace-src-noconflict/worker-css.js @@ -0,0 +1,10940 @@ +"no use strict"; + +var console = { + log: function(msgs) { + postMessage({type: "log", data: arguments.join(" ")}); + } +}; +var window = { + console: console +}; + +var normalizeModule = function(parentId, moduleName) { + // normalize plugin requires + if (moduleName.indexOf("!") !== -1) { + var chunks = moduleName.split("!"); + return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]); + } + // normalize relative requires + if (moduleName.charAt(0) == ".") { + var base = parentId.split("/").slice(0, -1).join("/"); + var moduleName = base + "/" + moduleName; + + while(moduleName.indexOf(".") !== -1 && previous != moduleName) { + var previous = moduleName; + var moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); + } + } + + return moduleName; +}; + +var require = function(parentId, id) { + if (!id.charAt) + throw new Error("worker.js require() accepts only (parentId, id) as arguments"); + + var id = normalizeModule(parentId, id); + + var module = require.modules[id]; + if (module) { + if (!module.initialized) { + module.initialized = true; + module.exports = module.factory().exports; + } + return module.exports; + } + + var chunks = id.split("/"); + chunks[0] = require.tlns[chunks[0]] || chunks[0]; + var path = chunks.join("/") + ".js"; + + require.id = id; + importScripts(path); + return require(parentId, id); +}; + +require.modules = {}; +require.tlns = {}; + +var define = function(id, deps, factory) { + if (arguments.length == 2) { + factory = deps; + if (typeof id != "string") { + deps = id; + id = require.id; + } + } else if (arguments.length == 1) { + factory = id; + id = require.id; + } + + if (id.indexOf("text!") === 0) + return; + + var req = function(deps, factory) { + return require(id, deps, factory); + }; + + require.modules[id] = { + factory: function() { + var module = { + exports: {} + }; + var returnExports = factory(req, module.exports, module); + if (returnExports) + module.exports = returnExports; + return module; + } + }; +}; + +function initBaseUrls(topLevelNamespaces) { + require.tlns = topLevelNamespaces; +} + +function initSender() { + + var EventEmitter = require(null, "ace/lib/event_emitter").EventEmitter; + var oop = require(null, "ace/lib/oop"); + + var Sender = function() {}; + + (function() { + + oop.implement(this, EventEmitter); + + this.callback = function(data, callbackId) { + postMessage({ + type: "call", + id: callbackId, + data: data + }); + }; + + this.emit = function(name, data) { + postMessage({ + type: "event", + name: name, + data: data + }); + }; + + }).call(Sender.prototype); + + return new Sender(); +} + +var main; +var sender; + +onmessage = function(e) { + var msg = e.data; + if (msg.command) { + main[msg.command].apply(main, msg.args); + } + else if (msg.init) { + initBaseUrls(msg.tlns); + require(null, "ace/lib/fixoldbrowsers"); + sender = initSender(); + var clazz = require(null, msg.module)[msg.classname]; + main = new clazz(sender); + } + else if (msg.event && sender) { + sender._emit(msg.event, msg.data); + } +}; +// vim:set ts=4 sts=4 sw=4 st: +// -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License +// -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project) +// -- dantman Daniel Friesen Copyright(C) 2010 XXX No License Specified +// -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License +// -- Irakli Gozalishvili Copyright (C) 2010 MIT License + +/*! + Copyright (c) 2009, 280 North Inc. http://280north.com/ + MIT License. http://github.com/280north/narwhal/blob/master/README.md +*/ + +define('ace/lib/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/regexp', 'ace/lib/es5-shim'], function(require, exports, module) { + + +require("./regexp"); +require("./es5-shim"); + +}); + +define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, exports, module) { + + + //--------------------------------- + // Private variables + //--------------------------------- + + var real = { + exec: RegExp.prototype.exec, + test: RegExp.prototype.test, + match: String.prototype.match, + replace: String.prototype.replace, + split: String.prototype.split + }, + compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups + compliantLastIndexIncrement = function () { + var x = /^/g; + real.test.call(x, ""); + return !x.lastIndex; + }(); + + if (compliantLastIndexIncrement && compliantExecNpcg) + return; + + //--------------------------------- + // Overriden native methods + //--------------------------------- + + // Adds named capture support (with backreferences returned as `result.name`), and fixes two + // cross-browser issues per ES3: + // - Captured values for nonparticipating capturing groups should be returned as `undefined`, + // rather than the empty string. + // - `lastIndex` should not be incremented after zero-length matches. + RegExp.prototype.exec = function (str) { + var match = real.exec.apply(this, arguments), + name, r2; + if ( typeof(str) == 'string' && match) { + // Fix browsers whose `exec` methods don't consistently return `undefined` for + // nonparticipating capturing groups + if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) { + r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", "")); + // Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed + // matching due to characters outside the match + real.replace.call(str.slice(match.index), r2, function () { + for (var i = 1; i < arguments.length - 2; i++) { + if (arguments[i] === undefined) + match[i] = undefined; + } + }); + } + // Attach named capture properties + if (this._xregexp && this._xregexp.captureNames) { + for (var i = 1; i < match.length; i++) { + name = this._xregexp.captureNames[i - 1]; + if (name) + match[name] = match[i]; + } + } + // Fix browsers that increment `lastIndex` after zero-length matches + if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index)) + this.lastIndex--; + } + return match; + }; + + // Don't override `test` if it won't change anything + if (!compliantLastIndexIncrement) { + // Fix browser bug in native method + RegExp.prototype.test = function (str) { + // Use the native `exec` to skip some processing overhead, even though the overriden + // `exec` would take care of the `lastIndex` fix + var match = real.exec.call(this, str); + // Fix browsers that increment `lastIndex` after zero-length matches + if (match && this.global && !match[0].length && (this.lastIndex > match.index)) + this.lastIndex--; + return !!match; + }; + } + + //--------------------------------- + // Private helper functions + //--------------------------------- + + function getNativeFlags (regex) { + return (regex.global ? "g" : "") + + (regex.ignoreCase ? "i" : "") + + (regex.multiline ? "m" : "") + + (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3 + (regex.sticky ? "y" : ""); + } + + function indexOf (array, item, from) { + if (Array.prototype.indexOf) // Use the native array method if available + return array.indexOf(item, from); + for (var i = from || 0; i < array.length; i++) { + if (array[i] === item) + return i; + } + return -1; + } + +}); +// vim: ts=4 sts=4 sw=4 expandtab +// -- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License +// -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project) +// -- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA +// -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License +// -- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License +// -- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License +// -- kossnocorp Sasha Koss XXX TODO License or CLA +// -- bryanforbes Bryan Forbes XXX TODO License or CLA +// -- killdream Quildreen Motta Copyright (C) 2011 MIT Licence +// -- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD License +// -- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License +// -- bbqsrc Brendan Molloy (C) 2011 Creative Commons Zero (public domain) +// -- iwyg XXX TODO License or CLA +// -- DomenicDenicola Domenic Denicola Copyright (C) 2011 MIT License +// -- xavierm02 Montillet Xavier XXX TODO License or CLA +// -- Raynos Raynos XXX TODO License or CLA +// -- samsonjs Sami Samhuri Copyright (C) 2010 MIT License +// -- rwldrn Rick Waldron Copyright (C) 2011 MIT License +// -- lexer Alexey Zakharov XXX TODO License or CLA + +/*! + Copyright (c) 2009, 280 North Inc. http://280north.com/ + MIT License. http://github.com/280north/narwhal/blob/master/README.md +*/ + +define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) { + +/* + * Brings an environment as close to ECMAScript 5 compliance + * as is possible with the facilities of erstwhile engines. + * + * Annotated ES5: http://es5.github.com/ (specific links below) + * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf + * + * @module + */ + +/*whatsupdoc*/ + +// +// Function +// ======== +// + +// ES-5 15.3.4.5 +// http://es5.github.com/#x15.3.4.5 + +if (!Function.prototype.bind) { + Function.prototype.bind = function bind(that) { // .length is 1 + // 1. Let Target be the this value. + var target = this; + // 2. If IsCallable(Target) is false, throw a TypeError exception. + if (typeof target != "function") + throw new TypeError(); // TODO message + // 3. Let A be a new (possibly empty) internal list of all of the + // argument values provided after thisArg (arg1, arg2 etc), in order. + // XXX slicedArgs will stand in for "A" if used + var args = slice.call(arguments, 1); // for normal call + // 4. Let F be a new native ECMAScript object. + // 11. Set the [[Prototype]] internal property of F to the standard + // built-in Function prototype object as specified in 15.3.3.1. + // 12. Set the [[Call]] internal property of F as described in + // 15.3.4.5.1. + // 13. Set the [[Construct]] internal property of F as described in + // 15.3.4.5.2. + // 14. Set the [[HasInstance]] internal property of F as described in + // 15.3.4.5.3. + var bound = function () { + + if (this instanceof bound) { + // 15.3.4.5.2 [[Construct]] + // When the [[Construct]] internal method of a function object, + // F that was created using the bind function is called with a + // list of arguments ExtraArgs, the following steps are taken: + // 1. Let target be the value of F's [[TargetFunction]] + // internal property. + // 2. If target has no [[Construct]] internal method, a + // TypeError exception is thrown. + // 3. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Construct]] internal + // method of target providing args as the arguments. + + var F = function(){}; + F.prototype = target.prototype; + var self = new F; + + var result = target.apply( + self, + args.concat(slice.call(arguments)) + ); + if (result !== null && Object(result) === result) + return result; + return self; + + } else { + // 15.3.4.5.1 [[Call]] + // When the [[Call]] internal method of a function object, F, + // which was created using the bind function is called with a + // this value and a list of arguments ExtraArgs, the following + // steps are taken: + // 1. Let boundArgs be the value of F's [[BoundArgs]] internal + // property. + // 2. Let boundThis be the value of F's [[BoundThis]] internal + // property. + // 3. Let target be the value of F's [[TargetFunction]] internal + // property. + // 4. Let args be a new list containing the same values as the + // list boundArgs in the same order followed by the same + // values as the list ExtraArgs in the same order. + // 5. Return the result of calling the [[Call]] internal method + // of target providing boundThis as the this value and + // providing args as the arguments. + + // equiv: target.call(this, ...boundArgs, ...args) + return target.apply( + that, + args.concat(slice.call(arguments)) + ); + + } + + }; + // XXX bound.length is never writable, so don't even try + // + // 15. If the [[Class]] internal property of Target is "Function", then + // a. Let L be the length property of Target minus the length of A. + // b. Set the length own property of F to either 0 or L, whichever is + // larger. + // 16. Else set the length own property of F to 0. + // 17. Set the attributes of the length own property of F to the values + // specified in 15.3.5.1. + + // TODO + // 18. Set the [[Extensible]] internal property of F to true. + + // TODO + // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3). + // 20. Call the [[DefineOwnProperty]] internal method of F with + // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]: + // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and + // false. + // 21. Call the [[DefineOwnProperty]] internal method of F with + // arguments "arguments", PropertyDescriptor {[[Get]]: thrower, + // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false}, + // and false. + + // TODO + // NOTE Function objects created using Function.prototype.bind do not + // have a prototype property or the [[Code]], [[FormalParameters]], and + // [[Scope]] internal properties. + // XXX can't delete prototype in pure-js. + + // 22. Return F. + return bound; + }; +} + +// Shortcut to an often accessed properties, in order to avoid multiple +// dereference that costs universally. +// _Please note: Shortcuts are defined after `Function.prototype.bind` as we +// us it in defining shortcuts. +var call = Function.prototype.call; +var prototypeOfArray = Array.prototype; +var prototypeOfObject = Object.prototype; +var slice = prototypeOfArray.slice; +var toString = call.bind(prototypeOfObject.toString); +var owns = call.bind(prototypeOfObject.hasOwnProperty); + +// If JS engine supports accessors creating shortcuts. +var defineGetter; +var defineSetter; +var lookupGetter; +var lookupSetter; +var supportsAccessors; +if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) { + defineGetter = call.bind(prototypeOfObject.__defineGetter__); + defineSetter = call.bind(prototypeOfObject.__defineSetter__); + lookupGetter = call.bind(prototypeOfObject.__lookupGetter__); + lookupSetter = call.bind(prototypeOfObject.__lookupSetter__); +} + +// +// Array +// ===== +// + +// ES5 15.4.3.2 +// http://es5.github.com/#x15.4.3.2 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray +if (!Array.isArray) { + Array.isArray = function isArray(obj) { + return toString(obj) == "[object Array]"; + }; +} + +// The IsCallable() check in the Array functions +// has been replaced with a strict check on the +// internal class of the object to trap cases where +// the provided function was actually a regular +// expression literal, which in V8 and +// JavaScriptCore is a typeof "function". Only in +// V8 are regular expression literals permitted as +// reduce parameters, so it is desirable in the +// general case for the shim to match the more +// strict and common behavior of rejecting regular +// expressions. + +// ES5 15.4.4.18 +// http://es5.github.com/#x15.4.4.18 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach +if (!Array.prototype.forEach) { + Array.prototype.forEach = function forEach(fun /*, thisp*/) { + var self = toObject(this), + thisp = arguments[1], + i = 0, + length = self.length >>> 0; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + while (i < length) { + if (i in self) { + // Invoke the callback function with call, passing arguments: + // context, property value, property key, thisArg object context + fun.call(thisp, self[i], i, self); + } + i++; + } + }; +} + +// ES5 15.4.4.19 +// http://es5.github.com/#x15.4.4.19 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map +if (!Array.prototype.map) { + Array.prototype.map = function map(fun /*, thisp*/) { + var self = toObject(this), + length = self.length >>> 0, + result = Array(length), + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + for (var i = 0; i < length; i++) { + if (i in self) + result[i] = fun.call(thisp, self[i], i, self); + } + return result; + }; +} + +// ES5 15.4.4.20 +// http://es5.github.com/#x15.4.4.20 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter +if (!Array.prototype.filter) { + Array.prototype.filter = function filter(fun /*, thisp */) { + var self = toObject(this), + length = self.length >>> 0, + result = [], + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + for (var i = 0; i < length; i++) { + if (i in self && fun.call(thisp, self[i], i, self)) + result.push(self[i]); + } + return result; + }; +} + +// ES5 15.4.4.16 +// http://es5.github.com/#x15.4.4.16 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every +if (!Array.prototype.every) { + Array.prototype.every = function every(fun /*, thisp */) { + var self = toObject(this), + length = self.length >>> 0, + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + for (var i = 0; i < length; i++) { + if (i in self && !fun.call(thisp, self[i], i, self)) + return false; + } + return true; + }; +} + +// ES5 15.4.4.17 +// http://es5.github.com/#x15.4.4.17 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some +if (!Array.prototype.some) { + Array.prototype.some = function some(fun /*, thisp */) { + var self = toObject(this), + length = self.length >>> 0, + thisp = arguments[1]; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + for (var i = 0; i < length; i++) { + if (i in self && fun.call(thisp, self[i], i, self)) + return true; + } + return false; + }; +} + +// ES5 15.4.4.21 +// http://es5.github.com/#x15.4.4.21 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce +if (!Array.prototype.reduce) { + Array.prototype.reduce = function reduce(fun /*, initial*/) { + var self = toObject(this), + length = self.length >>> 0; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + // no value to return if no initial value and an empty array + if (!length && arguments.length == 1) + throw new TypeError(); // TODO message + + var i = 0; + var result; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i++]; + break; + } + + // if array contains no values, no initial value to return + if (++i >= length) + throw new TypeError(); // TODO message + } while (true); + } + + for (; i < length; i++) { + if (i in self) + result = fun.call(void 0, result, self[i], i, self); + } + + return result; + }; +} + +// ES5 15.4.4.22 +// http://es5.github.com/#x15.4.4.22 +// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight +if (!Array.prototype.reduceRight) { + Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) { + var self = toObject(this), + length = self.length >>> 0; + + // If no callback function or if callback is not a callable function + if (toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + // no value to return if no initial value, empty array + if (!length && arguments.length == 1) + throw new TypeError(); // TODO message + + var result, i = length - 1; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i--]; + break; + } + + // if array contains no values, no initial value to return + if (--i < 0) + throw new TypeError(); // TODO message + } while (true); + } + + do { + if (i in this) + result = fun.call(void 0, result, self[i], i, self); + } while (i--); + + return result; + }; +} + +// ES5 15.4.4.14 +// http://es5.github.com/#x15.4.4.14 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf +if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) { + var self = toObject(this), + length = self.length >>> 0; + + if (!length) + return -1; + + var i = 0; + if (arguments.length > 1) + i = toInteger(arguments[1]); + + // handle negative indices + i = i >= 0 ? i : Math.max(0, length + i); + for (; i < length; i++) { + if (i in self && self[i] === sought) { + return i; + } + } + return -1; + }; +} + +// ES5 15.4.4.15 +// http://es5.github.com/#x15.4.4.15 +// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf +if (!Array.prototype.lastIndexOf) { + Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) { + var self = toObject(this), + length = self.length >>> 0; + + if (!length) + return -1; + var i = length - 1; + if (arguments.length > 1) + i = Math.min(i, toInteger(arguments[1])); + // handle negative indices + i = i >= 0 ? i : length - Math.abs(i); + for (; i >= 0; i--) { + if (i in self && sought === self[i]) + return i; + } + return -1; + }; +} + +// +// Object +// ====== +// + +// ES5 15.2.3.2 +// http://es5.github.com/#x15.2.3.2 +if (!Object.getPrototypeOf) { + // https://github.com/kriskowal/es5-shim/issues#issue/2 + // http://ejohn.org/blog/objectgetprototypeof/ + // recommended by fschaefer on github + Object.getPrototypeOf = function getPrototypeOf(object) { + return object.__proto__ || ( + object.constructor ? + object.constructor.prototype : + prototypeOfObject + ); + }; +} + +// ES5 15.2.3.3 +// http://es5.github.com/#x15.2.3.3 +if (!Object.getOwnPropertyDescriptor) { + var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " + + "non-object: "; + Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) { + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError(ERR_NON_OBJECT + object); + // If object does not owns property return undefined immediately. + if (!owns(object, property)) + return; + + var descriptor, getter, setter; + + // If object has a property then it's for sure both `enumerable` and + // `configurable`. + descriptor = { enumerable: true, configurable: true }; + + // If JS engine supports accessor properties then property may be a + // getter or setter. + if (supportsAccessors) { + // Unfortunately `__lookupGetter__` will return a getter even + // if object has own non getter property along with a same named + // inherited getter. To avoid misbehavior we temporary remove + // `__proto__` so that `__lookupGetter__` will return getter only + // if it's owned by an object. + var prototype = object.__proto__; + object.__proto__ = prototypeOfObject; + + var getter = lookupGetter(object, property); + var setter = lookupSetter(object, property); + + // Once we have getter and setter we can put values back. + object.__proto__ = prototype; + + if (getter || setter) { + if (getter) descriptor.get = getter; + if (setter) descriptor.set = setter; + + // If it was accessor property we're done and return here + // in order to avoid adding `value` to the descriptor. + return descriptor; + } + } + + // If we got this far we know that object has an own property that is + // not an accessor so we set it as a value and return descriptor. + descriptor.value = object[property]; + return descriptor; + }; +} + +// ES5 15.2.3.4 +// http://es5.github.com/#x15.2.3.4 +if (!Object.getOwnPropertyNames) { + Object.getOwnPropertyNames = function getOwnPropertyNames(object) { + return Object.keys(object); + }; +} + +// ES5 15.2.3.5 +// http://es5.github.com/#x15.2.3.5 +if (!Object.create) { + Object.create = function create(prototype, properties) { + var object; + if (prototype === null) { + object = { "__proto__": null }; + } else { + if (typeof prototype != "object") + throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'"); + var Type = function () {}; + Type.prototype = prototype; + object = new Type(); + // IE has no built-in implementation of `Object.getPrototypeOf` + // neither `__proto__`, but this manually setting `__proto__` will + // guarantee that `Object.getPrototypeOf` will work as expected with + // objects created using `Object.create` + object.__proto__ = prototype; + } + if (properties !== void 0) + Object.defineProperties(object, properties); + return object; + }; +} + +// ES5 15.2.3.6 +// http://es5.github.com/#x15.2.3.6 + +// Patch for WebKit and IE8 standard mode +// Designed by hax +// related issue: https://github.com/kriskowal/es5-shim/issues#issue/5 +// IE8 Reference: +// http://msdn.microsoft.com/en-us/library/dd282900.aspx +// http://msdn.microsoft.com/en-us/library/dd229916.aspx +// WebKit Bugs: +// https://bugs.webkit.org/show_bug.cgi?id=36423 + +function doesDefinePropertyWork(object) { + try { + Object.defineProperty(object, "sentinel", {}); + return "sentinel" in object; + } catch (exception) { + // returns falsy + } +} + +// check whether defineProperty works if it's given. Otherwise, +// shim partially. +if (Object.defineProperty) { + var definePropertyWorksOnObject = doesDefinePropertyWork({}); + var definePropertyWorksOnDom = typeof document == "undefined" || + doesDefinePropertyWork(document.createElement("div")); + if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) { + var definePropertyFallback = Object.defineProperty; + } +} + +if (!Object.defineProperty || definePropertyFallback) { + var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: "; + var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: " + var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " + + "on this javascript engine"; + + Object.defineProperty = function defineProperty(object, property, descriptor) { + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError(ERR_NON_OBJECT_TARGET + object); + if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null) + throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor); + + // make a valiant attempt to use the real defineProperty + // for I8's DOM elements. + if (definePropertyFallback) { + try { + return definePropertyFallback.call(Object, object, property, descriptor); + } catch (exception) { + // try the shim if the real one doesn't work + } + } + + // If it's a data property. + if (owns(descriptor, "value")) { + // fail silently if "writable", "enumerable", or "configurable" + // are requested but not supported + /* + // alternate approach: + if ( // can't implement these features; allow false but not true + !(owns(descriptor, "writable") ? descriptor.writable : true) || + !(owns(descriptor, "enumerable") ? descriptor.enumerable : true) || + !(owns(descriptor, "configurable") ? descriptor.configurable : true) + ) + throw new RangeError( + "This implementation of Object.defineProperty does not " + + "support configurable, enumerable, or writable." + ); + */ + + if (supportsAccessors && (lookupGetter(object, property) || + lookupSetter(object, property))) + { + // As accessors are supported only on engines implementing + // `__proto__` we can safely override `__proto__` while defining + // a property to make sure that we don't hit an inherited + // accessor. + var prototype = object.__proto__; + object.__proto__ = prototypeOfObject; + // Deleting a property anyway since getter / setter may be + // defined on object itself. + delete object[property]; + object[property] = descriptor.value; + // Setting original `__proto__` back now. + object.__proto__ = prototype; + } else { + object[property] = descriptor.value; + } + } else { + if (!supportsAccessors) + throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED); + // If we got that far then getters and setters can be defined !! + if (owns(descriptor, "get")) + defineGetter(object, property, descriptor.get); + if (owns(descriptor, "set")) + defineSetter(object, property, descriptor.set); + } + + return object; + }; +} + +// ES5 15.2.3.7 +// http://es5.github.com/#x15.2.3.7 +if (!Object.defineProperties) { + Object.defineProperties = function defineProperties(object, properties) { + for (var property in properties) { + if (owns(properties, property)) + Object.defineProperty(object, property, properties[property]); + } + return object; + }; +} + +// ES5 15.2.3.8 +// http://es5.github.com/#x15.2.3.8 +if (!Object.seal) { + Object.seal = function seal(object) { + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; +} + +// ES5 15.2.3.9 +// http://es5.github.com/#x15.2.3.9 +if (!Object.freeze) { + Object.freeze = function freeze(object) { + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; +} + +// detect a Rhino bug and patch it +try { + Object.freeze(function () {}); +} catch (exception) { + Object.freeze = (function freeze(freezeObject) { + return function freeze(object) { + if (typeof object == "function") { + return object; + } else { + return freezeObject(object); + } + }; + })(Object.freeze); +} + +// ES5 15.2.3.10 +// http://es5.github.com/#x15.2.3.10 +if (!Object.preventExtensions) { + Object.preventExtensions = function preventExtensions(object) { + // this is misleading and breaks feature-detection, but + // allows "securable" code to "gracefully" degrade to working + // but insecure code. + return object; + }; +} + +// ES5 15.2.3.11 +// http://es5.github.com/#x15.2.3.11 +if (!Object.isSealed) { + Object.isSealed = function isSealed(object) { + return false; + }; +} + +// ES5 15.2.3.12 +// http://es5.github.com/#x15.2.3.12 +if (!Object.isFrozen) { + Object.isFrozen = function isFrozen(object) { + return false; + }; +} + +// ES5 15.2.3.13 +// http://es5.github.com/#x15.2.3.13 +if (!Object.isExtensible) { + Object.isExtensible = function isExtensible(object) { + // 1. If Type(O) is not Object throw a TypeError exception. + if (Object(object) === object) { + throw new TypeError(); // TODO message + } + // 2. Return the Boolean value of the [[Extensible]] internal property of O. + var name = ''; + while (owns(object, name)) { + name += '?'; + } + object[name] = true; + var returnValue = owns(object, name); + delete object[name]; + return returnValue; + }; +} + +// ES5 15.2.3.14 +// http://es5.github.com/#x15.2.3.14 +if (!Object.keys) { + // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation + var hasDontEnumBug = true, + dontEnums = [ + "toString", + "toLocaleString", + "valueOf", + "hasOwnProperty", + "isPrototypeOf", + "propertyIsEnumerable", + "constructor" + ], + dontEnumsLength = dontEnums.length; + + for (var key in {"toString": null}) + hasDontEnumBug = false; + + Object.keys = function keys(object) { + + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError("Object.keys called on a non-object"); + + var keys = []; + for (var name in object) { + if (owns(object, name)) { + keys.push(name); + } + } + + if (hasDontEnumBug) { + for (var i = 0, ii = dontEnumsLength; i < ii; i++) { + var dontEnum = dontEnums[i]; + if (owns(object, dontEnum)) { + keys.push(dontEnum); + } + } + } + + return keys; + }; + +} + +// +// Date +// ==== +// + +// ES5 15.9.5.43 +// http://es5.github.com/#x15.9.5.43 +// This function returns a String value represent the instance in time +// represented by this Date object. The format of the String is the Date Time +// string format defined in 15.9.1.15. All fields are present in the String. +// The time zone is always UTC, denoted by the suffix Z. If the time value of +// this object is not a finite Number a RangeError exception is thrown. +if (!Date.prototype.toISOString || (new Date(-62198755200000).toISOString().indexOf('-000001') === -1)) { + Date.prototype.toISOString = function toISOString() { + var result, length, value, year; + if (!isFinite(this)) + throw new RangeError; + + // the date time string format is specified in 15.9.1.15. + result = [this.getUTCMonth() + 1, this.getUTCDate(), + this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()]; + year = this.getUTCFullYear(); + year = (year < 0 ? '-' : (year > 9999 ? '+' : '')) + ('00000' + Math.abs(year)).slice(0 <= year && year <= 9999 ? -4 : -6); + + length = result.length; + while (length--) { + value = result[length]; + // pad months, days, hours, minutes, and seconds to have two digits. + if (value < 10) + result[length] = "0" + value; + } + // pad milliseconds to have three digits. + return year + "-" + result.slice(0, 2).join("-") + "T" + result.slice(2).join(":") + "." + + ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"; + } +} + +// ES5 15.9.4.4 +// http://es5.github.com/#x15.9.4.4 +if (!Date.now) { + Date.now = function now() { + return new Date().getTime(); + }; +} + +// ES5 15.9.5.44 +// http://es5.github.com/#x15.9.5.44 +// This function provides a String representation of a Date object for use by +// JSON.stringify (15.12.3). +if (!Date.prototype.toJSON) { + Date.prototype.toJSON = function toJSON(key) { + // When the toJSON method is called with argument key, the following + // steps are taken: + + // 1. Let O be the result of calling ToObject, giving it the this + // value as its argument. + // 2. Let tv be ToPrimitive(O, hint Number). + // 3. If tv is a Number and is not finite, return null. + // XXX + // 4. Let toISO be the result of calling the [[Get]] internal method of + // O with argument "toISOString". + // 5. If IsCallable(toISO) is false, throw a TypeError exception. + if (typeof this.toISOString != "function") + throw new TypeError(); // TODO message + // 6. Return the result of calling the [[Call]] internal method of + // toISO with O as the this value and an empty argument list. + return this.toISOString(); + + // NOTE 1 The argument is ignored. + + // NOTE 2 The toJSON function is intentionally generic; it does not + // require that its this value be a Date object. Therefore, it can be + // transferred to other kinds of objects for use as a method. However, + // it does require that any such object have a toISOString method. An + // object is free to use the argument key to filter its + // stringification. + }; +} + +// ES5 15.9.4.2 +// http://es5.github.com/#x15.9.4.2 +// based on work shared by Daniel Friesen (dantman) +// http://gist.github.com/303249 +if (Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) { + // XXX global assignment won't work in embeddings that use + // an alternate object for the context. + Date = (function(NativeDate) { + + // Date.length === 7 + var Date = function Date(Y, M, D, h, m, s, ms) { + var length = arguments.length; + if (this instanceof NativeDate) { + var date = length == 1 && String(Y) === Y ? // isString(Y) + // We explicitly pass it through parse: + new NativeDate(Date.parse(Y)) : + // We have to manually make calls depending on argument + // length here + length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) : + length >= 6 ? new NativeDate(Y, M, D, h, m, s) : + length >= 5 ? new NativeDate(Y, M, D, h, m) : + length >= 4 ? new NativeDate(Y, M, D, h) : + length >= 3 ? new NativeDate(Y, M, D) : + length >= 2 ? new NativeDate(Y, M) : + length >= 1 ? new NativeDate(Y) : + new NativeDate(); + // Prevent mixups with unfixed Date object + date.constructor = Date; + return date; + } + return NativeDate.apply(this, arguments); + }; + + // 15.9.1.15 Date Time String Format. + var isoDateExpression = new RegExp("^" + + "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign + 6-digit extended year + "(?:-(\\d{2})" + // optional month capture + "(?:-(\\d{2})" + // optional day capture + "(?:" + // capture hours:minutes:seconds.milliseconds + "T(\\d{2})" + // hours capture + ":(\\d{2})" + // minutes capture + "(?:" + // optional :seconds.milliseconds + ":(\\d{2})" + // seconds capture + "(?:\\.(\\d{3}))?" + // milliseconds capture + ")?" + + "(?:" + // capture UTC offset component + "Z|" + // UTC capture + "(?:" + // offset specifier +/-hours:minutes + "([-+])" + // sign capture + "(\\d{2})" + // hours offset capture + ":(\\d{2})" + // minutes offset capture + ")" + + ")?)?)?)?" + + "$"); + + // Copy any custom methods a 3rd party library may have added + for (var key in NativeDate) + Date[key] = NativeDate[key]; + + // Copy "native" methods explicitly; they may be non-enumerable + Date.now = NativeDate.now; + Date.UTC = NativeDate.UTC; + Date.prototype = NativeDate.prototype; + Date.prototype.constructor = Date; + + // Upgrade Date.parse to handle simplified ISO 8601 strings + Date.parse = function parse(string) { + var match = isoDateExpression.exec(string); + if (match) { + match.shift(); // kill match[0], the full match + // parse months, days, hours, minutes, seconds, and milliseconds + for (var i = 1; i < 7; i++) { + // provide default values if necessary + match[i] = +(match[i] || (i < 3 ? 1 : 0)); + // match[1] is the month. Months are 0-11 in JavaScript + // `Date` objects, but 1-12 in ISO notation, so we + // decrement. + if (i == 1) + match[i]--; + } + + // parse the UTC offset component + var minuteOffset = +match.pop(), hourOffset = +match.pop(), sign = match.pop(); + + // compute the explicit time zone offset if specified + var offset = 0; + if (sign) { + // detect invalid offsets and return early + if (hourOffset > 23 || minuteOffset > 59) + return NaN; + + // express the provided time zone offset in minutes. The offset is + // negative for time zones west of UTC; positive otherwise. + offset = (hourOffset * 60 + minuteOffset) * 6e4 * (sign == "+" ? -1 : 1); + } + + // Date.UTC for years between 0 and 99 converts year to 1900 + year + // The Gregorian calendar has a 400-year cycle, so + // to Date.UTC(year + 400, .... ) - 12622780800000 == Date.UTC(year, ...), + // where 12622780800000 - number of milliseconds in Gregorian calendar 400 years + var year = +match[0]; + if (0 <= year && year <= 99) { + match[0] = year + 400; + return NativeDate.UTC.apply(this, match) + offset - 12622780800000; + } + + // compute a new UTC date value, accounting for the optional offset + return NativeDate.UTC.apply(this, match) + offset; + } + return NativeDate.parse.apply(this, arguments); + }; + + return Date; + })(Date); +} + +// +// String +// ====== +// + +// ES5 15.5.4.20 +// http://es5.github.com/#x15.5.4.20 +var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" + + "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" + + "\u2029\uFEFF"; +if (!String.prototype.trim || ws.trim()) { + // http://blog.stevenlevithan.com/archives/faster-trim-javascript + // http://perfectionkills.com/whitespace-deviations/ + ws = "[" + ws + "]"; + var trimBeginRegexp = new RegExp("^" + ws + ws + "*"), + trimEndRegexp = new RegExp(ws + ws + "*$"); + String.prototype.trim = function trim() { + return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, ""); + }; +} + +// +// Util +// ====== +// + +// ES5 9.4 +// http://es5.github.com/#x9.4 +// http://jsperf.com/to-integer +var toInteger = function (n) { + n = +n; + if (n !== n) // isNaN + n = 0; + else if (n !== 0 && n !== (1/0) && n !== -(1/0)) + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + return n; +}; + +var prepareString = "a"[0] != "a", + // ES5 9.9 + // http://es5.github.com/#x9.9 + toObject = function (o) { + if (o == null) { // this matches both null and undefined + throw new TypeError(); // TODO message + } + // If the implementation doesn't support by-index access of + // string characters (ex. IE < 7), split the string + if (prepareString && typeof o == "string" && o) { + return o.split(""); + } + return Object(o); + }; +}); + +define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) { + + +var EventEmitter = {}; + +EventEmitter._emit = +EventEmitter._dispatchEvent = function(eventName, e) { + this._eventRegistry = this._eventRegistry || {}; + this._defaultHandlers = this._defaultHandlers || {}; + + var listeners = this._eventRegistry[eventName] || []; + var defaultHandler = this._defaultHandlers[eventName]; + if (!listeners.length && !defaultHandler) + return; + + if (typeof e != "object" || !e) + e = {}; + + if (!e.type) + e.type = eventName; + + if (!e.stopPropagation) { + e.stopPropagation = function() { + this.propagationStopped = true; + }; + } + + if (!e.preventDefault) { + e.preventDefault = function() { + this.defaultPrevented = true; + }; + } + + for (var i=0; i= length) { + position.row = Math.max(0, length - 1); + position.column = this.getLine(length-1).length; + } + return position; + }; + this.insert = function(position, text) { + if (!text || text.length === 0) + return position; + + position = this.$clipPosition(position); + + // only detect new lines if the document has no line break yet + if (this.getLength() <= 1) + this.$detectNewLine(text); + + var lines = this.$split(text); + var firstLine = lines.splice(0, 1)[0]; + var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0]; + + position = this.insertInLine(position, firstLine); + if (lastLine !== null) { + position = this.insertNewLine(position); // terminate first line + position = this.insertLines(position.row, lines); + position = this.insertInLine(position, lastLine || ""); + } + return position; + }; + /** + * Document@change(e) + * - e (Object): Contains at least one property called `"action"`. `"action"` indicates the action that triggered the change. Each action also has a set of additional properties. + * + * Fires whenever the document changes. + * + * Several methods trigger different `"change"` events. Below is a list of each action type, followed by each property that's also available: + * + * * `"insertLines"` (emitted by [[Document.insertLines]]) + * * `range`: the [[Range]] of the change within the document + * * `lines`: the lines in the document that are changing + * * `"insertText"` (emitted by [[Document.insertNewLine]]) + * * `range`: the [[Range]] of the change within the document + * * `text`: the text that's being added + * * `"removeLines"` (emitted by [[Document.insertLines]]) + * * `range`: the [[Range]] of the change within the document + * * `lines`: the lines in the document that were removed + * * `nl`: the new line character (as defined by [[Document.getNewLineCharacter]]) + * * `"removeText"` (emitted by [[Document.removeInLine]] and [[Document.removeNewLine]]) + * * `range`: the [[Range]] of the change within the document + * * `text`: the text that's being removed + * + **/ + this.insertLines = function(row, lines) { + if (lines.length == 0) + return {row: row, column: 0}; + + // apply doesn't work for big arrays (smallest threshold is on safari 0xFFFF) + // to circumvent that we have to break huge inserts into smaller chunks here + if (lines.length > 0xFFFF) { + var end = this.insertLines(row, lines.slice(0xFFFF)); + lines = lines.slice(0, 0xFFFF); + } + + var args = [row, 0]; + args.push.apply(args, lines); + this.$lines.splice.apply(this.$lines, args); + + var range = new Range(row, 0, row + lines.length, 0); + var delta = { + action: "insertLines", + range: range, + lines: lines + }; + this._emit("change", { data: delta }); + return end || range.end; + }; + this.insertNewLine = function(position) { + position = this.$clipPosition(position); + var line = this.$lines[position.row] || ""; + + this.$lines[position.row] = line.substring(0, position.column); + this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length)); + + var end = { + row : position.row + 1, + column : 0 + }; + + var delta = { + action: "insertText", + range: Range.fromPoints(position, end), + text: this.getNewLineCharacter() + }; + this._emit("change", { data: delta }); + + return end; + }; + this.insertInLine = function(position, text) { + if (text.length == 0) + return position; + + var line = this.$lines[position.row] || ""; + + this.$lines[position.row] = line.substring(0, position.column) + text + + line.substring(position.column); + + var end = { + row : position.row, + column : position.column + text.length + }; + + var delta = { + action: "insertText", + range: Range.fromPoints(position, end), + text: text + }; + this._emit("change", { data: delta }); + + return end; + }; + this.remove = function(range) { + // clip to document + range.start = this.$clipPosition(range.start); + range.end = this.$clipPosition(range.end); + + if (range.isEmpty()) + return range.start; + + var firstRow = range.start.row; + var lastRow = range.end.row; + + if (range.isMultiLine()) { + var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1; + var lastFullRow = lastRow - 1; + + if (range.end.column > 0) + this.removeInLine(lastRow, 0, range.end.column); + + if (lastFullRow >= firstFullRow) + this.removeLines(firstFullRow, lastFullRow); + + if (firstFullRow != firstRow) { + this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length); + this.removeNewLine(range.start.row); + } + } + else { + this.removeInLine(firstRow, range.start.column, range.end.column); + } + return range.start; + }; + this.removeInLine = function(row, startColumn, endColumn) { + if (startColumn == endColumn) + return; + + var range = new Range(row, startColumn, row, endColumn); + var line = this.getLine(row); + var removed = line.substring(startColumn, endColumn); + var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length); + this.$lines.splice(row, 1, newLine); + + var delta = { + action: "removeText", + range: range, + text: removed + }; + this._emit("change", { data: delta }); + return range.start; + }; + this.removeLines = function(firstRow, lastRow) { + var range = new Range(firstRow, 0, lastRow + 1, 0); + var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1); + + var delta = { + action: "removeLines", + range: range, + nl: this.getNewLineCharacter(), + lines: removed + }; + this._emit("change", { data: delta }); + return removed; + }; + this.removeNewLine = function(row) { + var firstLine = this.getLine(row); + var secondLine = this.getLine(row+1); + + var range = new Range(row, firstLine.length, row+1, 0); + var line = firstLine + secondLine; + + this.$lines.splice(row, 2, line); + + var delta = { + action: "removeText", + range: range, + text: this.getNewLineCharacter() + }; + this._emit("change", { data: delta }); + }; + this.replace = function(range, text) { + if (text.length == 0 && range.isEmpty()) + return range.start; + + // Shortcut: If the text we want to insert is the same as it is already + // in the document, we don't have to replace anything. + if (text == this.getTextRange(range)) + return range.end; + + this.remove(range); + if (text) { + var end = this.insert(range.start, text); + } + else { + end = range.start; + } + + return end; + }; + this.applyDeltas = function(deltas) { + for (var i=0; i=0; i--) { + var delta = deltas[i]; + + var range = Range.fromPoints(delta.range.start, delta.range.end); + + if (delta.action == "insertLines") + this.removeLines(range.start.row, range.end.row - 1); + else if (delta.action == "insertText") + this.remove(range); + else if (delta.action == "removeLines") + this.insertLines(range.start.row, delta.lines); + else if (delta.action == "removeText") + this.insert(range.start, delta.text); + } + }; + +}).call(Document.prototype); + +exports.Document = Document; +}); + +define('ace/range', ['require', 'exports', 'module' ], function(require, exports, module) { + + +/** + * class Range + * + * This object is used in various places to indicate a region within the editor. To better visualize how this works, imagine a rectangle. Each quadrant of the rectangle is analogus to a range, as ranges contain a starting row and starting column, and an ending row, and ending column. + * + **/ + +/** + * new Range(startRow, startColumn, endRow, endColumn) + * - startRow (Number): The starting row + * - startColumn (Number): The starting column + * - endRow (Number): The ending row + * - endColumn (Number): The ending column + * + * Creates a new `Range` object with the given starting and ending row and column points. + * + **/ +var Range = function(startRow, startColumn, endRow, endColumn) { + this.start = { + row: startRow, + column: startColumn + }; + + this.end = { + row: endRow, + column: endColumn + }; +}; + +(function() { + /** + * Range.isEqual(range) -> Boolean + * - range (Range): A range to check against + * + * Returns `true` if and only if the starting row and column, and ending tow and column, are equivalent to those given by `range`. + * + **/ + this.isEqual = function(range) { + return this.start.row == range.start.row && + this.end.row == range.end.row && + this.start.column == range.start.column && + this.end.column == range.end.column + }; + this.toString = function() { + return ("Range: [" + this.start.row + "/" + this.start.column + + "] -> [" + this.end.row + "/" + this.end.column + "]"); + }; + + this.contains = function(row, column) { + return this.compare(row, column) == 0; + }; + this.compareRange = function(range) { + var cmp, + end = range.end, + start = range.start; + + cmp = this.compare(end.row, end.column); + if (cmp == 1) { + cmp = this.compare(start.row, start.column); + if (cmp == 1) { + return 2; + } else if (cmp == 0) { + return 1; + } else { + return 0; + } + } else if (cmp == -1) { + return -2; + } else { + cmp = this.compare(start.row, start.column); + if (cmp == -1) { + return -1; + } else if (cmp == 1) { + return 42; + } else { + return 0; + } + } + } + + /** related to: Range.compare + * Range.comparePoint(p) -> Number + * - p (Range): A point to compare with + * + (Number): This method returns one of the following numbers:
    + * * `0` if the two points are exactly equal
    + * * `-1` if `p.row` is less then the calling range
    + * * `1` if `p.row` is greater than the calling range
    + *
    + * If the starting row of the calling range is equal to `p.row`, and:
    + * * `p.column` is greater than or equal to the calling range's starting column, this returns `0`
    + * * Otherwise, it returns -1
    + *
    + * If the ending row of the calling range is equal to `p.row`, and:
    + * * `p.column` is less than or equal to the calling range's ending column, this returns `0`
    + * * Otherwise, it returns 1
    + * + * Checks the row and column points of `p` with the row and column points of the calling range. + * + * + * + **/ + this.comparePoint = function(p) { + return this.compare(p.row, p.column); + } + + /** related to: Range.comparePoint + * Range.containsRange(range) -> Boolean + * - range (Range): A range to compare with + * + * Checks the start and end points of `range` and compares them to the calling range. Returns `true` if the `range` is contained within the caller's range. + * + **/ + this.containsRange = function(range) { + return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0; + } + + /** + * Range.intersects(range) -> Boolean + * - range (Range): A range to compare with + * + * Returns `true` if passed in `range` intersects with the one calling this method. + * + **/ + this.intersects = function(range) { + var cmp = this.compareRange(range); + return (cmp == -1 || cmp == 0 || cmp == 1); + } + + /** + * Range.isEnd(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the caller's ending row point is the same as `row`, and if the caller's ending column is the same as `column`. + * + **/ + this.isEnd = function(row, column) { + return this.end.row == row && this.end.column == column; + } + + /** + * Range.isStart(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the caller's starting row point is the same as `row`, and if the caller's starting column is the same as `column`. + * + **/ + this.isStart = function(row, column) { + return this.start.row == row && this.start.column == column; + } + + /** + * Range.setStart(row, column) + * - row (Number): A row point to set + * - column (Number): A column point to set + * + * Sets the starting row and column for the range. + * + **/ + this.setStart = function(row, column) { + if (typeof row == "object") { + this.start.column = row.column; + this.start.row = row.row; + } else { + this.start.row = row; + this.start.column = column; + } + } + + /** + * Range.setEnd(row, column) + * - row (Number): A row point to set + * - column (Number): A column point to set + * + * Sets the starting row and column for the range. + * + **/ + this.setEnd = function(row, column) { + if (typeof row == "object") { + this.end.column = row.column; + this.end.row = row.row; + } else { + this.end.row = row; + this.end.column = column; + } + } + + /** related to: Range.compare + * Range.inside(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the `row` and `column` are within the given range. + * + **/ + this.inside = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isEnd(row, column) || this.isStart(row, column)) { + return false; + } else { + return true; + } + } + return false; + } + + /** related to: Range.compare + * Range.insideStart(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the `row` and `column` are within the given range's starting points. + * + **/ + this.insideStart = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isEnd(row, column)) { + return false; + } else { + return true; + } + } + return false; + } + + /** related to: Range.compare + * Range.insideEnd(row, column) -> Boolean + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + * Returns `true` if the `row` and `column` are within the given range's ending points. + * + **/ + this.insideEnd = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isStart(row, column)) { + return false; + } else { + return true; + } + } + return false; + } + + /** + * Range.compare(row, column) -> Number + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + (Number): This method returns one of the following numbers:
    + * * `0` if the two points are exactly equal
    + * * `-1` if `p.row` is less then the calling range
    + * * `1` if `p.row` is greater than the calling range
    + *
    + * If the starting row of the calling range is equal to `p.row`, and:
    + * * `p.column` is greater than or equal to the calling range's starting column, this returns `0`
    + * * Otherwise, it returns -1
    + *
    + * If the ending row of the calling range is equal to `p.row`, and:
    + * * `p.column` is less than or equal to the calling range's ending column, this returns `0`
    + * * Otherwise, it returns 1 + * + * Checks the row and column points with the row and column points of the calling range. + * + * + **/ + this.compare = function(row, column) { + if (!this.isMultiLine()) { + if (row === this.start.row) { + return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0); + }; + } + + if (row < this.start.row) + return -1; + + if (row > this.end.row) + return 1; + + if (this.start.row === row) + return column >= this.start.column ? 0 : -1; + + if (this.end.row === row) + return column <= this.end.column ? 0 : 1; + + return 0; + }; + this.compareStart = function(row, column) { + if (this.start.row == row && this.start.column == column) { + return -1; + } else { + return this.compare(row, column); + } + } + + /** + * Range.compareEnd(row, column) -> Number + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + (Number): This method returns one of the following numbers:
    + * * `0` if the two points are exactly equal
    + * * `-1` if `p.row` is less then the calling range
    + * * `1` if `p.row` is greater than the calling range, or if `isEnd` is `true.
    + *
    + * If the starting row of the calling range is equal to `p.row`, and:
    + * * `p.column` is greater than or equal to the calling range's starting column, this returns `0`
    + * * Otherwise, it returns -1
    + *
    + * If the ending row of the calling range is equal to `p.row`, and:
    + * * `p.column` is less than or equal to the calling range's ending column, this returns `0`
    + * * Otherwise, it returns 1 + * + * Checks the row and column points with the row and column points of the calling range. + * + * + **/ + this.compareEnd = function(row, column) { + if (this.end.row == row && this.end.column == column) { + return 1; + } else { + return this.compare(row, column); + } + } + + /** + * Range.compareInside(row, column) -> Number + * - row (Number): A row point to compare with + * - column (Number): A column point to compare with + * + (Number): This method returns one of the following numbers:
    + * * `1` if the ending row of the calling range is equal to `row`, and the ending column of the calling range is equal to `column`
    + * * `-1` if the starting row of the calling range is equal to `row`, and the starting column of the calling range is equal to `column`
    + *
    + * Otherwise, it returns the value after calling [[Range.compare `compare()`]]. + * + * Checks the row and column points with the row and column points of the calling range. + * + * + * + **/ + this.compareInside = function(row, column) { + if (this.end.row == row && this.end.column == column) { + return 1; + } else if (this.start.row == row && this.start.column == column) { + return -1; + } else { + return this.compare(row, column); + } + } + + /** + * Range.clipRows(firstRow, lastRow) -> Range + * - firstRow (Number): The starting row + * - lastRow (Number): The ending row + * + * Returns the part of the current `Range` that occurs within the boundaries of `firstRow` and `lastRow` as a new `Range` object. + * + **/ + this.clipRows = function(firstRow, lastRow) { + if (this.end.row > lastRow) { + var end = { + row: lastRow+1, + column: 0 + }; + } + + if (this.start.row > lastRow) { + var start = { + row: lastRow+1, + column: 0 + }; + } + + if (this.start.row < firstRow) { + var start = { + row: firstRow, + column: 0 + }; + } + + if (this.end.row < firstRow) { + var end = { + row: firstRow, + column: 0 + }; + } + return Range.fromPoints(start || this.start, end || this.end); + }; + this.extend = function(row, column) { + var cmp = this.compare(row, column); + + if (cmp == 0) + return this; + else if (cmp == -1) + var start = {row: row, column: column}; + else + var end = {row: row, column: column}; + + return Range.fromPoints(start || this.start, end || this.end); + }; + + this.isEmpty = function() { + return (this.start.row == this.end.row && this.start.column == this.end.column); + }; + this.isMultiLine = function() { + return (this.start.row !== this.end.row); + }; + this.clone = function() { + return Range.fromPoints(this.start, this.end); + }; + this.collapseRows = function() { + if (this.end.column == 0) + return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0) + else + return new Range(this.start.row, 0, this.end.row, 0) + }; + this.toScreenRange = function(session) { + var screenPosStart = + session.documentToScreenPosition(this.start); + var screenPosEnd = + session.documentToScreenPosition(this.end); + + return new Range( + screenPosStart.row, screenPosStart.column, + screenPosEnd.row, screenPosEnd.column + ); + }; + +}).call(Range.prototype); +Range.fromPoints = function(start, end) { + return new Range(start.row, start.column, end.row, end.column); +}; + +exports.Range = Range; +}); + +define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) { + + +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; + +/** + * new Anchor(doc, row, column) + * - doc (Document): The document to associate with the anchor + * - row (Number): The starting row position + * - column (Number): The starting column position + * + * Creates a new `Anchor` and associates it with a document. + * + **/ + +var Anchor = exports.Anchor = function(doc, row, column) { + this.document = doc; + + if (typeof column == "undefined") + this.setPosition(row.row, row.column); + else + this.setPosition(row, column); + + this.$onChange = this.onChange.bind(this); + doc.on("change", this.$onChange); +}; + +(function() { + + oop.implement(this, EventEmitter); + + this.getPosition = function() { + return this.$clipPositionToDocument(this.row, this.column); + }; + + this.getDocument = function() { + return this.document; + }; + + this.onChange = function(e) { + var delta = e.data; + var range = delta.range; + + if (range.start.row == range.end.row && range.start.row != this.row) + return; + + if (range.start.row > this.row) + return; + + if (range.start.row == this.row && range.start.column > this.column) + return; + + var row = this.row; + var column = this.column; + + if (delta.action === "insertText") { + if (range.start.row === row && range.start.column <= column) { + if (range.start.row === range.end.row) { + column += range.end.column - range.start.column; + } + else { + column -= range.start.column; + row += range.end.row - range.start.row; + } + } + else if (range.start.row !== range.end.row && range.start.row < row) { + row += range.end.row - range.start.row; + } + } else if (delta.action === "insertLines") { + if (range.start.row <= row) { + row += range.end.row - range.start.row; + } + } + else if (delta.action == "removeText") { + if (range.start.row == row && range.start.column < column) { + if (range.end.column >= column) + column = range.start.column; + else + column = Math.max(0, column - (range.end.column - range.start.column)); + + } else if (range.start.row !== range.end.row && range.start.row < row) { + if (range.end.row == row) { + column = Math.max(0, column - range.end.column) + range.start.column; + } + row -= (range.end.row - range.start.row); + } + else if (range.end.row == row) { + row -= range.end.row - range.start.row; + column = Math.max(0, column - range.end.column) + range.start.column; + } + } else if (delta.action == "removeLines") { + if (range.start.row <= row) { + if (range.end.row <= row) + row -= range.end.row - range.start.row; + else { + row = range.start.row; + column = 0; + } + } + } + + this.setPosition(row, column, true); + }; + + this.setPosition = function(row, column, noClip) { + var pos; + if (noClip) { + pos = { + row: row, + column: column + }; + } + else { + pos = this.$clipPositionToDocument(row, column); + } + + if (this.row == pos.row && this.column == pos.column) + return; + + var old = { + row: this.row, + column: this.column + }; + + this.row = pos.row; + this.column = pos.column; + this._emit("change", { + old: old, + value: pos + }); + }; + + this.detach = function() { + this.document.removeEventListener("change", this.$onChange); + }; + + this.$clipPositionToDocument = function(row, column) { + var pos = {}; + + if (row >= this.document.getLength()) { + pos.row = Math.max(0, this.document.getLength() - 1); + pos.column = this.document.getLine(pos.row).length; + } + else if (row < 0) { + pos.row = 0; + pos.column = 0; + } + else { + pos.row = row; + pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column)); + } + + if (column < 0) + pos.column = 0; + + return pos; + }; + +}).call(Anchor.prototype); + +}); + +define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.stringReverse = function(string) { + return string.split("").reverse().join(""); +}; + +exports.stringRepeat = function (string, count) { + return new Array(count + 1).join(string); +}; + +var trimBeginRegexp = /^\s\s*/; +var trimEndRegexp = /\s\s*$/; + +exports.stringTrimLeft = function (string) { + return string.replace(trimBeginRegexp, ''); +}; + +exports.stringTrimRight = function (string) { + return string.replace(trimEndRegexp, ''); +}; + +exports.copyObject = function(obj) { + var copy = {}; + for (var key in obj) { + copy[key] = obj[key]; + } + return copy; +}; + +exports.copyArray = function(array){ + var copy = []; + for (var i=0, l=array.length; i= 0 && this._ltIndex < this._lt.length){ + + i++; + this._token = this._lt[this._ltIndex++]; + info = tokenInfo[this._token.type]; + + //obey channels logic + while((info.channel !== undefined && channel !== info.channel) && + this._ltIndex < this._lt.length){ + this._token = this._lt[this._ltIndex++]; + info = tokenInfo[this._token.type]; + i++; + } + + //here be dragons + if ((info.channel === undefined || channel === info.channel) && + this._ltIndex <= this._lt.length){ + this._ltIndexCache.push(i); + return this._token.type; + } + } + + //call token retriever method + token = this._getToken(); + + //if it should be hidden, don't save a token + if (token.type > -1 && !tokenInfo[token.type].hide){ + + //apply token channel + token.channel = tokenInfo[token.type].channel; + + //save for later + this._token = token; + this._lt.push(token); + + //save space that will be moved (must be done before array is truncated) + this._ltIndexCache.push(this._lt.length - this._ltIndex + i); + + //keep the buffer under 5 items + if (this._lt.length > 5){ + this._lt.shift(); + } + + //also keep the shift buffer under 5 items + if (this._ltIndexCache.length > 5){ + this._ltIndexCache.shift(); + } + + //update lookahead index + this._ltIndex = this._lt.length; + } + + /* + * Skip to the next token if: + * 1. The token type is marked as hidden. + * 2. The token type has a channel specified and it isn't the current channel. + */ + info = tokenInfo[token.type]; + if (info && + (info.hide || + (info.channel !== undefined && channel !== info.channel))){ + return this.get(channel); + } else { + //return just the type + return token.type; + } + }, + + /** + * Looks ahead a certain number of tokens and returns the token type at + * that position. This will throw an error if you lookahead past the + * end of input, past the size of the lookahead buffer, or back past + * the first token in the lookahead buffer. + * @param {int} The index of the token type to retrieve. 0 for the + * current token, 1 for the next, -1 for the previous, etc. + * @return {int} The token type of the token in the given position. + * @method LA + */ + LA: function(index){ + var total = index, + tt; + if (index > 0){ + //TODO: Store 5 somewhere + if (index > 5){ + throw new Error("Too much lookahead."); + } + + //get all those tokens + while(total){ + tt = this.get(); + total--; + } + + //unget all those tokens + while(total < index){ + this.unget(); + total++; + } + } else if (index < 0){ + + if(this._lt[this._ltIndex+index]){ + tt = this._lt[this._ltIndex+index].type; + } else { + throw new Error("Too much lookbehind."); + } + + } else { + tt = this._token.type; + } + + return tt; + + }, + + /** + * Looks ahead a certain number of tokens and returns the token at + * that position. This will throw an error if you lookahead past the + * end of input, past the size of the lookahead buffer, or back past + * the first token in the lookahead buffer. + * @param {int} The index of the token type to retrieve. 0 for the + * current token, 1 for the next, -1 for the previous, etc. + * @return {Object} The token of the token in the given position. + * @method LA + */ + LT: function(index){ + + //lookahead first to prime the token buffer + this.LA(index); + + //now find the token, subtract one because _ltIndex is already at the next index + return this._lt[this._ltIndex+index-1]; + }, + + /** + * Returns the token type for the next token in the stream without + * consuming it. + * @return {int} The token type of the next token in the stream. + * @method peek + */ + peek: function(){ + return this.LA(1); + }, + + /** + * Returns the actual token object for the last consumed token. + * @return {Token} The token object for the last consumed token. + * @method token + */ + token: function(){ + return this._token; + }, + + /** + * Returns the name of the token for the given token type. + * @param {int} tokenType The type of token to get the name of. + * @return {String} The name of the token or "UNKNOWN_TOKEN" for any + * invalid token type. + * @method tokenName + */ + tokenName: function(tokenType){ + if (tokenType < 0 || tokenType > this._tokenData.length){ + return "UNKNOWN_TOKEN"; + } else { + return this._tokenData[tokenType].name; + } + }, + + /** + * Returns the token type value for the given token name. + * @param {String} tokenName The name of the token whose value should be returned. + * @return {int} The token type value for the given token name or -1 + * for an unknown token. + * @method tokenName + */ + tokenType: function(tokenName){ + return this._tokenData[tokenName] || -1; + }, + + /** + * Returns the last consumed token to the token stream. + * @method unget + */ + unget: function(){ + //if (this._ltIndex > -1){ + if (this._ltIndexCache.length){ + this._ltIndex -= this._ltIndexCache.pop();//--; + this._token = this._lt[this._ltIndex - 1]; + } else { + throw new Error("Too much lookahead."); + } + } + +}; + + + + +parserlib.util = { +StringReader: StringReader, +SyntaxError : SyntaxError, +SyntaxUnit : SyntaxUnit, +EventTarget : EventTarget, +TokenStreamBase : TokenStreamBase +}; +})(); +/* Version v0.1.6, Build time: 2-March-2012 02:44:32 */ +(function(){ +var EventTarget = parserlib.util.EventTarget, +TokenStreamBase = parserlib.util.TokenStreamBase, +StringReader = parserlib.util.StringReader, +SyntaxError = parserlib.util.SyntaxError, +SyntaxUnit = parserlib.util.SyntaxUnit; + + +var Colors = { + aliceblue :"#f0f8ff", + antiquewhite :"#faebd7", + aqua :"#00ffff", + aquamarine :"#7fffd4", + azure :"#f0ffff", + beige :"#f5f5dc", + bisque :"#ffe4c4", + black :"#000000", + blanchedalmond :"#ffebcd", + blue :"#0000ff", + blueviolet :"#8a2be2", + brown :"#a52a2a", + burlywood :"#deb887", + cadetblue :"#5f9ea0", + chartreuse :"#7fff00", + chocolate :"#d2691e", + coral :"#ff7f50", + cornflowerblue :"#6495ed", + cornsilk :"#fff8dc", + crimson :"#dc143c", + cyan :"#00ffff", + darkblue :"#00008b", + darkcyan :"#008b8b", + darkgoldenrod :"#b8860b", + darkgray :"#a9a9a9", + darkgreen :"#006400", + darkkhaki :"#bdb76b", + darkmagenta :"#8b008b", + darkolivegreen :"#556b2f", + darkorange :"#ff8c00", + darkorchid :"#9932cc", + darkred :"#8b0000", + darksalmon :"#e9967a", + darkseagreen :"#8fbc8f", + darkslateblue :"#483d8b", + darkslategray :"#2f4f4f", + darkturquoise :"#00ced1", + darkviolet :"#9400d3", + deeppink :"#ff1493", + deepskyblue :"#00bfff", + dimgray :"#696969", + dodgerblue :"#1e90ff", + firebrick :"#b22222", + floralwhite :"#fffaf0", + forestgreen :"#228b22", + fuchsia :"#ff00ff", + gainsboro :"#dcdcdc", + ghostwhite :"#f8f8ff", + gold :"#ffd700", + goldenrod :"#daa520", + gray :"#808080", + green :"#008000", + greenyellow :"#adff2f", + honeydew :"#f0fff0", + hotpink :"#ff69b4", + indianred :"#cd5c5c", + indigo :"#4b0082", + ivory :"#fffff0", + khaki :"#f0e68c", + lavender :"#e6e6fa", + lavenderblush :"#fff0f5", + lawngreen :"#7cfc00", + lemonchiffon :"#fffacd", + lightblue :"#add8e6", + lightcoral :"#f08080", + lightcyan :"#e0ffff", + lightgoldenrodyellow :"#fafad2", + lightgray :"#d3d3d3", + lightgreen :"#90ee90", + lightpink :"#ffb6c1", + lightsalmon :"#ffa07a", + lightseagreen :"#20b2aa", + lightskyblue :"#87cefa", + lightslategray :"#778899", + lightsteelblue :"#b0c4de", + lightyellow :"#ffffe0", + lime :"#00ff00", + limegreen :"#32cd32", + linen :"#faf0e6", + magenta :"#ff00ff", + maroon :"#800000", + mediumaquamarine:"#66cdaa", + mediumblue :"#0000cd", + mediumorchid :"#ba55d3", + mediumpurple :"#9370d8", + mediumseagreen :"#3cb371", + mediumslateblue :"#7b68ee", + mediumspringgreen :"#00fa9a", + mediumturquoise :"#48d1cc", + mediumvioletred :"#c71585", + midnightblue :"#191970", + mintcream :"#f5fffa", + mistyrose :"#ffe4e1", + moccasin :"#ffe4b5", + navajowhite :"#ffdead", + navy :"#000080", + oldlace :"#fdf5e6", + olive :"#808000", + olivedrab :"#6b8e23", + orange :"#ffa500", + orangered :"#ff4500", + orchid :"#da70d6", + palegoldenrod :"#eee8aa", + palegreen :"#98fb98", + paleturquoise :"#afeeee", + palevioletred :"#d87093", + papayawhip :"#ffefd5", + peachpuff :"#ffdab9", + peru :"#cd853f", + pink :"#ffc0cb", + plum :"#dda0dd", + powderblue :"#b0e0e6", + purple :"#800080", + red :"#ff0000", + rosybrown :"#bc8f8f", + royalblue :"#4169e1", + saddlebrown :"#8b4513", + salmon :"#fa8072", + sandybrown :"#f4a460", + seagreen :"#2e8b57", + seashell :"#fff5ee", + sienna :"#a0522d", + silver :"#c0c0c0", + skyblue :"#87ceeb", + slateblue :"#6a5acd", + slategray :"#708090", + snow :"#fffafa", + springgreen :"#00ff7f", + steelblue :"#4682b4", + tan :"#d2b48c", + teal :"#008080", + thistle :"#d8bfd8", + tomato :"#ff6347", + turquoise :"#40e0d0", + violet :"#ee82ee", + wheat :"#f5deb3", + white :"#ffffff", + whitesmoke :"#f5f5f5", + yellow :"#ffff00", + yellowgreen :"#9acd32" +}; +/** + * Represents a selector combinator (whitespace, +, >). + * @namespace parserlib.css + * @class Combinator + * @extends parserlib.util.SyntaxUnit + * @constructor + * @param {String} text The text representation of the unit. + * @param {int} line The line of text on which the unit resides. + * @param {int} col The column of text on which the unit resides. + */ +function Combinator(text, line, col){ + + SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE); + this.type = "unknown"; + + //pretty simple + if (/^\s+$/.test(text)){ + this.type = "descendant"; + } else if (text == ">"){ + this.type = "child"; + } else if (text == "+"){ + this.type = "adjacent-sibling"; + } else if (text == "~"){ + this.type = "sibling"; + } + +} + +Combinator.prototype = new SyntaxUnit(); +Combinator.prototype.constructor = Combinator; +/** + * Represents a media feature, such as max-width:500. + * @namespace parserlib.css + * @class MediaFeature + * @extends parserlib.util.SyntaxUnit + * @constructor + * @param {SyntaxUnit} name The name of the feature. + * @param {SyntaxUnit} value The value of the feature or null if none. + */ +function MediaFeature(name, value){ + + SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE); + this.name = name; + this.value = value; +} + +MediaFeature.prototype = new SyntaxUnit(); +MediaFeature.prototype.constructor = MediaFeature; +/** + * Represents an individual media query. + * @namespace parserlib.css + * @class MediaQuery + * @extends parserlib.util.SyntaxUnit + * @constructor + * @param {String} modifier The modifier "not" or "only" (or null). + * @param {String} mediaType The type of media (i.e., "print"). + * @param {Array} parts Array of selectors parts making up this selector. + * @param {int} line The line of text on which the unit resides. + * @param {int} col The column of text on which the unit resides. + */ +function MediaQuery(modifier, mediaType, features, line, col){ + + SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType + " " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE); + this.modifier = modifier; + this.mediaType = mediaType; + this.features = features; + +} + +MediaQuery.prototype = new SyntaxUnit(); +MediaQuery.prototype.constructor = MediaQuery; + +/** + * A CSS3 parser. + * @namespace parserlib.css + * @class Parser + * @constructor + * @param {Object} options (Optional) Various options for the parser: + * starHack (true|false) to allow IE6 star hack as valid, + * underscoreHack (true|false) to interpret leading underscores + * as IE6-7 targeting for known properties, ieFilters (true|false) + * to indicate that IE < 8 filters should be accepted and not throw + * syntax errors. + */ +function Parser(options){ + + //inherit event functionality + EventTarget.call(this); + + + this.options = options || {}; + + this._tokenStream = null; +} + +//Static constants +Parser.DEFAULT_TYPE = 0; +Parser.COMBINATOR_TYPE = 1; +Parser.MEDIA_FEATURE_TYPE = 2; +Parser.MEDIA_QUERY_TYPE = 3; +Parser.PROPERTY_NAME_TYPE = 4; +Parser.PROPERTY_VALUE_TYPE = 5; +Parser.PROPERTY_VALUE_PART_TYPE = 6; +Parser.SELECTOR_TYPE = 7; +Parser.SELECTOR_PART_TYPE = 8; +Parser.SELECTOR_SUB_PART_TYPE = 9; + +Parser.prototype = function(){ + + var proto = new EventTarget(), //new prototype + prop, + additions = { + + //restore constructor + constructor: Parser, + + //instance constants - yuck + DEFAULT_TYPE : 0, + COMBINATOR_TYPE : 1, + MEDIA_FEATURE_TYPE : 2, + MEDIA_QUERY_TYPE : 3, + PROPERTY_NAME_TYPE : 4, + PROPERTY_VALUE_TYPE : 5, + PROPERTY_VALUE_PART_TYPE : 6, + SELECTOR_TYPE : 7, + SELECTOR_PART_TYPE : 8, + SELECTOR_SUB_PART_TYPE : 9, + + //----------------------------------------------------------------- + // Grammar + //----------------------------------------------------------------- + + _stylesheet: function(){ + + /* + * stylesheet + * : [ CHARSET_SYM S* STRING S* ';' ]? + * [S|CDO|CDC]* [ import [S|CDO|CDC]* ]* + * [ namespace [S|CDO|CDC]* ]* + * [ [ ruleset | media | page | font_face | keyframes ] [S|CDO|CDC]* ]* + * ; + */ + + var tokenStream = this._tokenStream, + charset = null, + count, + token, + tt; + + this.fire("startstylesheet"); + + //try to read character set + this._charset(); + + this._skipCruft(); + + //try to read imports - may be more than one + while (tokenStream.peek() == Tokens.IMPORT_SYM){ + this._import(); + this._skipCruft(); + } + + //try to read namespaces - may be more than one + while (tokenStream.peek() == Tokens.NAMESPACE_SYM){ + this._namespace(); + this._skipCruft(); + } + + //get the next token + tt = tokenStream.peek(); + + //try to read the rest + while(tt > Tokens.EOF){ + + try { + + switch(tt){ + case Tokens.MEDIA_SYM: + this._media(); + this._skipCruft(); + break; + case Tokens.PAGE_SYM: + this._page(); + this._skipCruft(); + break; + case Tokens.FONT_FACE_SYM: + this._font_face(); + this._skipCruft(); + break; + case Tokens.KEYFRAMES_SYM: + this._keyframes(); + this._skipCruft(); + break; + case Tokens.UNKNOWN_SYM: //unknown @ rule + tokenStream.get(); + if (!this.options.strict){ + + //fire error event + this.fire({ + type: "error", + error: null, + message: "Unknown @ rule: " + tokenStream.LT(0).value + ".", + line: tokenStream.LT(0).startLine, + col: tokenStream.LT(0).startCol + }); + + //skip braces + count=0; + while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) == Tokens.LBRACE){ + count++; //keep track of nesting depth + } + + while(count){ + tokenStream.advance([Tokens.RBRACE]); + count--; + } + + } else { + //not a syntax error, rethrow it + throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol); + } + break; + case Tokens.S: + this._readWhitespace(); + break; + default: + if(!this._ruleset()){ + + //error handling for known issues + switch(tt){ + case Tokens.CHARSET_SYM: + token = tokenStream.LT(1); + this._charset(false); + throw new SyntaxError("@charset not allowed here.", token.startLine, token.startCol); + case Tokens.IMPORT_SYM: + token = tokenStream.LT(1); + this._import(false); + throw new SyntaxError("@import not allowed here.", token.startLine, token.startCol); + case Tokens.NAMESPACE_SYM: + token = tokenStream.LT(1); + this._namespace(false); + throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol); + default: + tokenStream.get(); //get the last token + this._unexpectedToken(tokenStream.token()); + } + + } + } + } catch(ex) { + if (ex instanceof SyntaxError && !this.options.strict){ + this.fire({ + type: "error", + error: ex, + message: ex.message, + line: ex.line, + col: ex.col + }); + } else { + throw ex; + } + } + + tt = tokenStream.peek(); + } + + if (tt != Tokens.EOF){ + this._unexpectedToken(tokenStream.token()); + } + + this.fire("endstylesheet"); + }, + + _charset: function(emit){ + var tokenStream = this._tokenStream, + charset, + token, + line, + col; + + if (tokenStream.match(Tokens.CHARSET_SYM)){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + tokenStream.mustMatch(Tokens.STRING); + + token = tokenStream.token(); + charset = token.value; + + this._readWhitespace(); + tokenStream.mustMatch(Tokens.SEMICOLON); + + if (emit !== false){ + this.fire({ + type: "charset", + charset:charset, + line: line, + col: col + }); + } + } + }, + + _import: function(emit){ + /* + * import + * : IMPORT_SYM S* + * [STRING|URI] S* media_query_list? ';' S* + */ + + var tokenStream = this._tokenStream, + tt, + uri, + importToken, + mediaList = []; + + //read import symbol + tokenStream.mustMatch(Tokens.IMPORT_SYM); + importToken = tokenStream.token(); + this._readWhitespace(); + + tokenStream.mustMatch([Tokens.STRING, Tokens.URI]); + + //grab the URI value + uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); + + this._readWhitespace(); + + mediaList = this._media_query_list(); + + //must end with a semicolon + tokenStream.mustMatch(Tokens.SEMICOLON); + this._readWhitespace(); + + if (emit !== false){ + this.fire({ + type: "import", + uri: uri, + media: mediaList, + line: importToken.startLine, + col: importToken.startCol + }); + } + + }, + + _namespace: function(emit){ + /* + * namespace + * : NAMESPACE_SYM S* [namespace_prefix S*]? [STRING|URI] S* ';' S* + */ + + var tokenStream = this._tokenStream, + line, + col, + prefix, + uri; + + //read import symbol + tokenStream.mustMatch(Tokens.NAMESPACE_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + this._readWhitespace(); + + //it's a namespace prefix - no _namespace_prefix() method because it's just an IDENT + if (tokenStream.match(Tokens.IDENT)){ + prefix = tokenStream.token().value; + this._readWhitespace(); + } + + tokenStream.mustMatch([Tokens.STRING, Tokens.URI]); + + //grab the URI value + uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); + + this._readWhitespace(); + + //must end with a semicolon + tokenStream.mustMatch(Tokens.SEMICOLON); + this._readWhitespace(); + + if (emit !== false){ + this.fire({ + type: "namespace", + prefix: prefix, + uri: uri, + line: line, + col: col + }); + } + + }, + + _media: function(){ + /* + * media + * : MEDIA_SYM S* media_query_list S* '{' S* ruleset* '}' S* + * ; + */ + var tokenStream = this._tokenStream, + line, + col, + mediaList;// = []; + + //look for @media + tokenStream.mustMatch(Tokens.MEDIA_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + + mediaList = this._media_query_list(); + + tokenStream.mustMatch(Tokens.LBRACE); + this._readWhitespace(); + + this.fire({ + type: "startmedia", + media: mediaList, + line: line, + col: col + }); + + while(true) { + if (tokenStream.peek() == Tokens.PAGE_SYM){ + this._page(); + } else if (!this._ruleset()){ + break; + } + } + + tokenStream.mustMatch(Tokens.RBRACE); + this._readWhitespace(); + + this.fire({ + type: "endmedia", + media: mediaList, + line: line, + col: col + }); + }, + + + //CSS3 Media Queries + _media_query_list: function(){ + /* + * media_query_list + * : S* [media_query [ ',' S* media_query ]* ]? + * ; + */ + var tokenStream = this._tokenStream, + mediaList = []; + + + this._readWhitespace(); + + if (tokenStream.peek() == Tokens.IDENT || tokenStream.peek() == Tokens.LPAREN){ + mediaList.push(this._media_query()); + } + + while(tokenStream.match(Tokens.COMMA)){ + this._readWhitespace(); + mediaList.push(this._media_query()); + } + + return mediaList; + }, + + /* + * Note: "expression" in the grammar maps to the _media_expression + * method. + + */ + _media_query: function(){ + /* + * media_query + * : [ONLY | NOT]? S* media_type S* [ AND S* expression ]* + * | expression [ AND S* expression ]* + * ; + */ + var tokenStream = this._tokenStream, + type = null, + ident = null, + token = null, + expressions = []; + + if (tokenStream.match(Tokens.IDENT)){ + ident = tokenStream.token().value.toLowerCase(); + + //since there's no custom tokens for these, need to manually check + if (ident != "only" && ident != "not"){ + tokenStream.unget(); + ident = null; + } else { + token = tokenStream.token(); + } + } + + this._readWhitespace(); + + if (tokenStream.peek() == Tokens.IDENT){ + type = this._media_type(); + if (token === null){ + token = tokenStream.token(); + } + } else if (tokenStream.peek() == Tokens.LPAREN){ + if (token === null){ + token = tokenStream.LT(1); + } + expressions.push(this._media_expression()); + } + + if (type === null && expressions.length === 0){ + return null; + } else { + this._readWhitespace(); + while (tokenStream.match(Tokens.IDENT)){ + if (tokenStream.token().value.toLowerCase() != "and"){ + this._unexpectedToken(tokenStream.token()); + } + + this._readWhitespace(); + expressions.push(this._media_expression()); + } + } + + return new MediaQuery(ident, type, expressions, token.startLine, token.startCol); + }, + + //CSS3 Media Queries + _media_type: function(){ + /* + * media_type + * : IDENT + * ; + */ + return this._media_feature(); + }, + + /** + * Note: in CSS3 Media Queries, this is called "expression". + * Renamed here to avoid conflict with CSS3 Selectors + * definition of "expression". Also note that "expr" in the + * grammar now maps to "expression" from CSS3 selectors. + * @method _media_expression + * @private + */ + _media_expression: function(){ + /* + * expression + * : '(' S* media_feature S* [ ':' S* expr ]? ')' S* + * ; + */ + var tokenStream = this._tokenStream, + feature = null, + token, + expression = null; + + tokenStream.mustMatch(Tokens.LPAREN); + + feature = this._media_feature(); + this._readWhitespace(); + + if (tokenStream.match(Tokens.COLON)){ + this._readWhitespace(); + token = tokenStream.LT(1); + expression = this._expression(); + } + + tokenStream.mustMatch(Tokens.RPAREN); + this._readWhitespace(); + + return new MediaFeature(feature, (expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null)); + }, + + //CSS3 Media Queries + _media_feature: function(){ + /* + * media_feature + * : IDENT + * ; + */ + var tokenStream = this._tokenStream; + + tokenStream.mustMatch(Tokens.IDENT); + + return SyntaxUnit.fromToken(tokenStream.token()); + }, + + //CSS3 Paged Media + _page: function(){ + /* + * page: + * PAGE_SYM S* IDENT? pseudo_page? S* + * '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S* + * ; + */ + var tokenStream = this._tokenStream, + line, + col, + identifier = null, + pseudoPage = null; + + //look for @page + tokenStream.mustMatch(Tokens.PAGE_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + + if (tokenStream.match(Tokens.IDENT)){ + identifier = tokenStream.token().value; + + //The value 'auto' may not be used as a page name and MUST be treated as a syntax error. + if (identifier.toLowerCase() === "auto"){ + this._unexpectedToken(tokenStream.token()); + } + } + + //see if there's a colon upcoming + if (tokenStream.peek() == Tokens.COLON){ + pseudoPage = this._pseudo_page(); + } + + this._readWhitespace(); + + this.fire({ + type: "startpage", + id: identifier, + pseudo: pseudoPage, + line: line, + col: col + }); + + this._readDeclarations(true, true); + + this.fire({ + type: "endpage", + id: identifier, + pseudo: pseudoPage, + line: line, + col: col + }); + + }, + + //CSS3 Paged Media + _margin: function(){ + /* + * margin : + * margin_sym S* '{' declaration [ ';' S* declaration? ]* '}' S* + * ; + */ + var tokenStream = this._tokenStream, + line, + col, + marginSym = this._margin_sym(); + + if (marginSym){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this.fire({ + type: "startpagemargin", + margin: marginSym, + line: line, + col: col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endpagemargin", + margin: marginSym, + line: line, + col: col + }); + return true; + } else { + return false; + } + }, + + //CSS3 Paged Media + _margin_sym: function(){ + + /* + * margin_sym : + * TOPLEFTCORNER_SYM | + * TOPLEFT_SYM | + * TOPCENTER_SYM | + * TOPRIGHT_SYM | + * TOPRIGHTCORNER_SYM | + * BOTTOMLEFTCORNER_SYM | + * BOTTOMLEFT_SYM | + * BOTTOMCENTER_SYM | + * BOTTOMRIGHT_SYM | + * BOTTOMRIGHTCORNER_SYM | + * LEFTTOP_SYM | + * LEFTMIDDLE_SYM | + * LEFTBOTTOM_SYM | + * RIGHTTOP_SYM | + * RIGHTMIDDLE_SYM | + * RIGHTBOTTOM_SYM + * ; + */ + + var tokenStream = this._tokenStream; + + if(tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM, + Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM, + Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM, + Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM, + Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM, + Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM, + Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) + { + return SyntaxUnit.fromToken(tokenStream.token()); + } else { + return null; + } + + }, + + _pseudo_page: function(){ + /* + * pseudo_page + * : ':' IDENT + * ; + */ + + var tokenStream = this._tokenStream; + + tokenStream.mustMatch(Tokens.COLON); + tokenStream.mustMatch(Tokens.IDENT); + + //TODO: CSS3 Paged Media says only "left", "center", and "right" are allowed + + return tokenStream.token().value; + }, + + _font_face: function(){ + /* + * font_face + * : FONT_FACE_SYM S* + * '{' S* declaration [ ';' S* declaration ]* '}' S* + * ; + */ + var tokenStream = this._tokenStream, + line, + col; + + //look for @page + tokenStream.mustMatch(Tokens.FONT_FACE_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + + this.fire({ + type: "startfontface", + line: line, + col: col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endfontface", + line: line, + col: col + }); + }, + + _operator: function(){ + + /* + * operator + * : '/' S* | ',' S* | /( empty )/ + * ; + */ + + var tokenStream = this._tokenStream, + token = null; + + if (tokenStream.match([Tokens.SLASH, Tokens.COMMA])){ + token = tokenStream.token(); + this._readWhitespace(); + } + return token ? PropertyValuePart.fromToken(token) : null; + + }, + + _combinator: function(){ + + /* + * combinator + * : PLUS S* | GREATER S* | TILDE S* | S+ + * ; + */ + + var tokenStream = this._tokenStream, + value = null, + token; + + if(tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])){ + token = tokenStream.token(); + value = new Combinator(token.value, token.startLine, token.startCol); + this._readWhitespace(); + } + + return value; + }, + + _unary_operator: function(){ + + /* + * unary_operator + * : '-' | '+' + * ; + */ + + var tokenStream = this._tokenStream; + + if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])){ + return tokenStream.token().value; + } else { + return null; + } + }, + + _property: function(){ + + /* + * property + * : IDENT S* + * ; + */ + + var tokenStream = this._tokenStream, + value = null, + hack = null, + tokenValue, + token, + line, + col; + + //check for star hack - throws error if not allowed + if (tokenStream.peek() == Tokens.STAR && this.options.starHack){ + tokenStream.get(); + token = tokenStream.token(); + hack = token.value; + line = token.startLine; + col = token.startCol; + } + + if(tokenStream.match(Tokens.IDENT)){ + token = tokenStream.token(); + tokenValue = token.value; + + //check for underscore hack - no error if not allowed because it's valid CSS syntax + if (tokenValue.charAt(0) == "_" && this.options.underscoreHack){ + hack = "_"; + tokenValue = tokenValue.substring(1); + } + + value = new PropertyName(tokenValue, hack, (line||token.startLine), (col||token.startCol)); + this._readWhitespace(); + } + + return value; + }, + + //Augmented with CSS3 Selectors + _ruleset: function(){ + /* + * ruleset + * : selectors_group + * '{' S* declaration? [ ';' S* declaration? ]* '}' S* + * ; + */ + + var tokenStream = this._tokenStream, + tt, + selectors; + try { + selectors = this._selectors_group(); + } catch (ex){ + if (ex instanceof SyntaxError && !this.options.strict){ + + //fire error event + this.fire({ + type: "error", + error: ex, + message: ex.message, + line: ex.line, + col: ex.col + }); + + //skip over everything until closing brace + tt = tokenStream.advance([Tokens.RBRACE]); + if (tt == Tokens.RBRACE){ + //if there's a right brace, the rule is finished so don't do anything + } else { + //otherwise, rethrow the error because it wasn't handled properly + throw ex; + } + + } else { + //not a syntax error, rethrow it + throw ex; + } + + //trigger parser to continue + return true; + } + + //if it got here, all selectors parsed + if (selectors){ + + this.fire({ + type: "startrule", + selectors: selectors, + line: selectors[0].line, + col: selectors[0].col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endrule", + selectors: selectors, + line: selectors[0].line, + col: selectors[0].col + }); + + } + + return selectors; + + }, + + //CSS3 Selectors + _selectors_group: function(){ + + /* + * selectors_group + * : selector [ COMMA S* selector ]* + * ; + */ + var tokenStream = this._tokenStream, + selectors = [], + selector; + + selector = this._selector(); + if (selector !== null){ + + selectors.push(selector); + while(tokenStream.match(Tokens.COMMA)){ + this._readWhitespace(); + selector = this._selector(); + if (selector !== null){ + selectors.push(selector); + } else { + this._unexpectedToken(tokenStream.LT(1)); + } + } + } + + return selectors.length ? selectors : null; + }, + + //CSS3 Selectors + _selector: function(){ + /* + * selector + * : simple_selector_sequence [ combinator simple_selector_sequence ]* + * ; + */ + + var tokenStream = this._tokenStream, + selector = [], + nextSelector = null, + combinator = null, + ws = null; + + //if there's no simple selector, then there's no selector + nextSelector = this._simple_selector_sequence(); + if (nextSelector === null){ + return null; + } + + selector.push(nextSelector); + + do { + + //look for a combinator + combinator = this._combinator(); + + if (combinator !== null){ + selector.push(combinator); + nextSelector = this._simple_selector_sequence(); + + //there must be a next selector + if (nextSelector === null){ + this._unexpectedToken(this.LT(1)); + } else { + + //nextSelector is an instance of SelectorPart + selector.push(nextSelector); + } + } else { + + //if there's not whitespace, we're done + if (this._readWhitespace()){ + + //add whitespace separator + ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol); + + //combinator is not required + combinator = this._combinator(); + + //selector is required if there's a combinator + nextSelector = this._simple_selector_sequence(); + if (nextSelector === null){ + if (combinator !== null){ + this._unexpectedToken(tokenStream.LT(1)); + } + } else { + + if (combinator !== null){ + selector.push(combinator); + } else { + selector.push(ws); + } + + selector.push(nextSelector); + } + } else { + break; + } + + } + } while(true); + + return new Selector(selector, selector[0].line, selector[0].col); + }, + + //CSS3 Selectors + _simple_selector_sequence: function(){ + /* + * simple_selector_sequence + * : [ type_selector | universal ] + * [ HASH | class | attrib | pseudo | negation ]* + * | [ HASH | class | attrib | pseudo | negation ]+ + * ; + */ + + var tokenStream = this._tokenStream, + + //parts of a simple selector + elementName = null, + modifiers = [], + + //complete selector text + selectorText= "", + + //the different parts after the element name to search for + components = [ + //HASH + function(){ + return tokenStream.match(Tokens.HASH) ? + new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) : + null; + }, + this._class, + this._attrib, + this._pseudo, + this._negation + ], + i = 0, + len = components.length, + component = null, + found = false, + line, + col; + + + //get starting line and column for the selector + line = tokenStream.LT(1).startLine; + col = tokenStream.LT(1).startCol; + + elementName = this._type_selector(); + if (!elementName){ + elementName = this._universal(); + } + + if (elementName !== null){ + selectorText += elementName; + } + + while(true){ + + //whitespace means we're done + if (tokenStream.peek() === Tokens.S){ + break; + } + + //check for each component + while(i < len && component === null){ + component = components[i++].call(this); + } + + if (component === null){ + + //we don't have a selector + if (selectorText === ""){ + return null; + } else { + break; + } + } else { + i = 0; + modifiers.push(component); + selectorText += component.toString(); + component = null; + } + } + + + return selectorText !== "" ? + new SelectorPart(elementName, modifiers, selectorText, line, col) : + null; + }, + + //CSS3 Selectors + _type_selector: function(){ + /* + * type_selector + * : [ namespace_prefix ]? element_name + * ; + */ + + var tokenStream = this._tokenStream, + ns = this._namespace_prefix(), + elementName = this._element_name(); + + if (!elementName){ + /* + * Need to back out the namespace that was read due to both + * type_selector and universal reading namespace_prefix + * first. Kind of hacky, but only way I can figure out + * right now how to not change the grammar. + */ + if (ns){ + tokenStream.unget(); + if (ns.length > 1){ + tokenStream.unget(); + } + } + + return null; + } else { + if (ns){ + elementName.text = ns + elementName.text; + elementName.col -= ns.length; + } + return elementName; + } + }, + + //CSS3 Selectors + _class: function(){ + /* + * class + * : '.' IDENT + * ; + */ + + var tokenStream = this._tokenStream, + token; + + if (tokenStream.match(Tokens.DOT)){ + tokenStream.mustMatch(Tokens.IDENT); + token = tokenStream.token(); + return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1); + } else { + return null; + } + + }, + + //CSS3 Selectors + _element_name: function(){ + /* + * element_name + * : IDENT + * ; + */ + + var tokenStream = this._tokenStream, + token; + + if (tokenStream.match(Tokens.IDENT)){ + token = tokenStream.token(); + return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol); + + } else { + return null; + } + }, + + //CSS3 Selectors + _namespace_prefix: function(){ + /* + * namespace_prefix + * : [ IDENT | '*' ]? '|' + * ; + */ + var tokenStream = this._tokenStream, + value = ""; + + //verify that this is a namespace prefix + if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE){ + + if(tokenStream.match([Tokens.IDENT, Tokens.STAR])){ + value += tokenStream.token().value; + } + + tokenStream.mustMatch(Tokens.PIPE); + value += "|"; + + } + + return value.length ? value : null; + }, + + //CSS3 Selectors + _universal: function(){ + /* + * universal + * : [ namespace_prefix ]? '*' + * ; + */ + var tokenStream = this._tokenStream, + value = "", + ns; + + ns = this._namespace_prefix(); + if(ns){ + value += ns; + } + + if(tokenStream.match(Tokens.STAR)){ + value += "*"; + } + + return value.length ? value : null; + + }, + + //CSS3 Selectors + _attrib: function(){ + /* + * attrib + * : '[' S* [ namespace_prefix ]? IDENT S* + * [ [ PREFIXMATCH | + * SUFFIXMATCH | + * SUBSTRINGMATCH | + * '=' | + * INCLUDES | + * DASHMATCH ] S* [ IDENT | STRING ] S* + * ]? ']' + * ; + */ + + var tokenStream = this._tokenStream, + value = null, + ns, + token; + + if (tokenStream.match(Tokens.LBRACKET)){ + token = tokenStream.token(); + value = token.value; + value += this._readWhitespace(); + + ns = this._namespace_prefix(); + + if (ns){ + value += ns; + } + + tokenStream.mustMatch(Tokens.IDENT); + value += tokenStream.token().value; + value += this._readWhitespace(); + + if(tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH, + Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])){ + + value += tokenStream.token().value; + value += this._readWhitespace(); + + tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]); + value += tokenStream.token().value; + value += this._readWhitespace(); + } + + tokenStream.mustMatch(Tokens.RBRACKET); + + return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol); + } else { + return null; + } + }, + + //CSS3 Selectors + _pseudo: function(){ + + /* + * pseudo + * : ':' ':'? [ IDENT | functional_pseudo ] + * ; + */ + + var tokenStream = this._tokenStream, + pseudo = null, + colons = ":", + line, + col; + + if (tokenStream.match(Tokens.COLON)){ + + if (tokenStream.match(Tokens.COLON)){ + colons += ":"; + } + + if (tokenStream.match(Tokens.IDENT)){ + pseudo = tokenStream.token().value; + line = tokenStream.token().startLine; + col = tokenStream.token().startCol - colons.length; + } else if (tokenStream.peek() == Tokens.FUNCTION){ + line = tokenStream.LT(1).startLine; + col = tokenStream.LT(1).startCol - colons.length; + pseudo = this._functional_pseudo(); + } + + if (pseudo){ + pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col); + } + } + + return pseudo; + }, + + //CSS3 Selectors + _functional_pseudo: function(){ + /* + * functional_pseudo + * : FUNCTION S* expression ')' + * ; + */ + + var tokenStream = this._tokenStream, + value = null; + + if(tokenStream.match(Tokens.FUNCTION)){ + value = tokenStream.token().value; + value += this._readWhitespace(); + value += this._expression(); + tokenStream.mustMatch(Tokens.RPAREN); + value += ")"; + } + + return value; + }, + + //CSS3 Selectors + _expression: function(){ + /* + * expression + * : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+ + * ; + */ + + var tokenStream = this._tokenStream, + value = ""; + + while(tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION, + Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH, + Tokens.FREQ, Tokens.ANGLE, Tokens.TIME, + Tokens.RESOLUTION])){ + + value += tokenStream.token().value; + value += this._readWhitespace(); + } + + return value.length ? value : null; + + }, + + //CSS3 Selectors + _negation: function(){ + /* + * negation + * : NOT S* negation_arg S* ')' + * ; + */ + + var tokenStream = this._tokenStream, + line, + col, + value = "", + arg, + subpart = null; + + if (tokenStream.match(Tokens.NOT)){ + value = tokenStream.token().value; + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + value += this._readWhitespace(); + arg = this._negation_arg(); + value += arg; + value += this._readWhitespace(); + tokenStream.match(Tokens.RPAREN); + value += tokenStream.token().value; + + subpart = new SelectorSubPart(value, "not", line, col); + subpart.args.push(arg); + } + + return subpart; + }, + + //CSS3 Selectors + _negation_arg: function(){ + /* + * negation_arg + * : type_selector | universal | HASH | class | attrib | pseudo + * ; + */ + + var tokenStream = this._tokenStream, + args = [ + this._type_selector, + this._universal, + function(){ + return tokenStream.match(Tokens.HASH) ? + new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) : + null; + }, + this._class, + this._attrib, + this._pseudo + ], + arg = null, + i = 0, + len = args.length, + elementName, + line, + col, + part; + + line = tokenStream.LT(1).startLine; + col = tokenStream.LT(1).startCol; + + while(i < len && arg === null){ + + arg = args[i].call(this); + i++; + } + + //must be a negation arg + if (arg === null){ + this._unexpectedToken(tokenStream.LT(1)); + } + + //it's an element name + if (arg.type == "elementName"){ + part = new SelectorPart(arg, [], arg.toString(), line, col); + } else { + part = new SelectorPart(null, [arg], arg.toString(), line, col); + } + + return part; + }, + + _declaration: function(){ + + /* + * declaration + * : property ':' S* expr prio? + * | /( empty )/ + * ; + */ + + var tokenStream = this._tokenStream, + property = null, + expr = null, + prio = null, + error = null, + invalid = null; + + property = this._property(); + if (property !== null){ + + tokenStream.mustMatch(Tokens.COLON); + this._readWhitespace(); + + expr = this._expr(); + + //if there's no parts for the value, it's an error + if (!expr || expr.length === 0){ + this._unexpectedToken(tokenStream.LT(1)); + } + + prio = this._prio(); + + try { + this._validateProperty(property, expr); + } catch (ex) { + invalid = ex; + } + + this.fire({ + type: "property", + property: property, + value: expr, + important: prio, + line: property.line, + col: property.col, + invalid: invalid + }); + + return true; + } else { + return false; + } + }, + + _prio: function(){ + /* + * prio + * : IMPORTANT_SYM S* + * ; + */ + + var tokenStream = this._tokenStream, + result = tokenStream.match(Tokens.IMPORTANT_SYM); + + this._readWhitespace(); + return result; + }, + + _expr: function(){ + /* + * expr + * : term [ operator term ]* + * ; + */ + + var tokenStream = this._tokenStream, + values = [], + //valueParts = [], + value = null, + operator = null; + + value = this._term(); + if (value !== null){ + + values.push(value); + + do { + operator = this._operator(); + + //if there's an operator, keep building up the value parts + if (operator){ + values.push(operator); + } /*else { + //if there's not an operator, you have a full value + values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col)); + valueParts = []; + }*/ + + value = this._term(); + + if (value === null){ + break; + } else { + values.push(value); + } + } while(true); + } + + //cleanup + /*if (valueParts.length){ + values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col)); + }*/ + + return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null; + }, + + _term: function(){ + + /* + * term + * : unary_operator? + * [ NUMBER S* | PERCENTAGE S* | LENGTH S* | ANGLE S* | + * TIME S* | FREQ S* | function | ie_function ] + * | STRING S* | IDENT S* | URI S* | UNICODERANGE S* | hexcolor + * ; + */ + + var tokenStream = this._tokenStream, + unary = null, + value = null, + token, + line, + col; + + //returns the operator or null + unary = this._unary_operator(); + if (unary !== null){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + } + + //exception for IE filters + if (tokenStream.peek() == Tokens.IE_FUNCTION && this.options.ieFilters){ + + value = this._ie_function(); + if (unary === null){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + } + + //see if there's a simple match + } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH, + Tokens.ANGLE, Tokens.TIME, + Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])){ + + value = tokenStream.token().value; + if (unary === null){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + } + this._readWhitespace(); + } else { + + //see if it's a color + token = this._hexcolor(); + if (token === null){ + + //if there's no unary, get the start of the next token for line/col info + if (unary === null){ + line = tokenStream.LT(1).startLine; + col = tokenStream.LT(1).startCol; + } + + //has to be a function + if (value === null){ + + /* + * This checks for alpha(opacity=0) style of IE + * functions. IE_FUNCTION only presents progid: style. + */ + if (tokenStream.LA(3) == Tokens.EQUALS && this.options.ieFilters){ + value = this._ie_function(); + } else { + value = this._function(); + } + } + + /*if (value === null){ + return null; + //throw new Error("Expected identifier at line " + tokenStream.token().startLine + ", character " + tokenStream.token().startCol + "."); + }*/ + + } else { + value = token.value; + if (unary === null){ + line = token.startLine; + col = token.startCol; + } + } + + } + + return value !== null ? + new PropertyValuePart(unary !== null ? unary + value : value, line, col) : + null; + + }, + + _function: function(){ + + /* + * function + * : FUNCTION S* expr ')' S* + * ; + */ + + var tokenStream = this._tokenStream, + functionText = null, + expr = null, + lt; + + if (tokenStream.match(Tokens.FUNCTION)){ + functionText = tokenStream.token().value; + this._readWhitespace(); + expr = this._expr(); + functionText += expr; + + //START: Horrible hack in case it's an IE filter + if (this.options.ieFilters && tokenStream.peek() == Tokens.EQUALS){ + do { + + if (this._readWhitespace()){ + functionText += tokenStream.token().value; + } + + //might be second time in the loop + if (tokenStream.LA(0) == Tokens.COMMA){ + functionText += tokenStream.token().value; + } + + tokenStream.match(Tokens.IDENT); + functionText += tokenStream.token().value; + + tokenStream.match(Tokens.EQUALS); + functionText += tokenStream.token().value; + + //functionText += this._term(); + lt = tokenStream.peek(); + while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){ + tokenStream.get(); + functionText += tokenStream.token().value; + lt = tokenStream.peek(); + } + } while(tokenStream.match([Tokens.COMMA, Tokens.S])); + } + + //END: Horrible Hack + + tokenStream.match(Tokens.RPAREN); + functionText += ")"; + this._readWhitespace(); + } + + return functionText; + }, + + _ie_function: function(){ + + /* (My own extension) + * ie_function + * : IE_FUNCTION S* IDENT '=' term [S* ','? IDENT '=' term]+ ')' S* + * ; + */ + + var tokenStream = this._tokenStream, + functionText = null, + expr = null, + lt; + + //IE function can begin like a regular function, too + if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])){ + functionText = tokenStream.token().value; + + do { + + if (this._readWhitespace()){ + functionText += tokenStream.token().value; + } + + //might be second time in the loop + if (tokenStream.LA(0) == Tokens.COMMA){ + functionText += tokenStream.token().value; + } + + tokenStream.match(Tokens.IDENT); + functionText += tokenStream.token().value; + + tokenStream.match(Tokens.EQUALS); + functionText += tokenStream.token().value; + + //functionText += this._term(); + lt = tokenStream.peek(); + while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){ + tokenStream.get(); + functionText += tokenStream.token().value; + lt = tokenStream.peek(); + } + } while(tokenStream.match([Tokens.COMMA, Tokens.S])); + + tokenStream.match(Tokens.RPAREN); + functionText += ")"; + this._readWhitespace(); + } + + return functionText; + }, + + _hexcolor: function(){ + /* + * There is a constraint on the color that it must + * have either 3 or 6 hex-digits (i.e., [0-9a-fA-F]) + * after the "#"; e.g., "#000" is OK, but "#abcd" is not. + * + * hexcolor + * : HASH S* + * ; + */ + + var tokenStream = this._tokenStream, + token = null, + color; + + if(tokenStream.match(Tokens.HASH)){ + + //need to do some validation here + + token = tokenStream.token(); + color = token.value; + if (!/#[a-f0-9]{3,6}/i.test(color)){ + throw new SyntaxError("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); + } + this._readWhitespace(); + } + + return token; + }, + + //----------------------------------------------------------------- + // Animations methods + //----------------------------------------------------------------- + + _keyframes: function(){ + + /* + * keyframes: + * : KEYFRAMES_SYM S* keyframe_name S* '{' S* keyframe_rule* '}' { + * ; + */ + var tokenStream = this._tokenStream, + token, + tt, + name; + + tokenStream.mustMatch(Tokens.KEYFRAMES_SYM); + this._readWhitespace(); + name = this._keyframe_name(); + + this._readWhitespace(); + tokenStream.mustMatch(Tokens.LBRACE); + + this.fire({ + type: "startkeyframes", + name: name, + line: name.line, + col: name.col + }); + + this._readWhitespace(); + tt = tokenStream.peek(); + + //check for key + while(tt == Tokens.IDENT || tt == Tokens.PERCENTAGE) { + this._keyframe_rule(); + this._readWhitespace(); + tt = tokenStream.peek(); + } + + this.fire({ + type: "endkeyframes", + name: name, + line: name.line, + col: name.col + }); + + this._readWhitespace(); + tokenStream.mustMatch(Tokens.RBRACE); + + }, + + _keyframe_name: function(){ + + /* + * keyframe_name: + * : IDENT + * | STRING + * ; + */ + var tokenStream = this._tokenStream, + token; + + tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]); + return SyntaxUnit.fromToken(tokenStream.token()); + }, + + _keyframe_rule: function(){ + + /* + * keyframe_rule: + * : key_list S* + * '{' S* declaration [ ';' S* declaration ]* '}' S* + * ; + */ + var tokenStream = this._tokenStream, + token, + keyList = this._key_list(); + + this.fire({ + type: "startkeyframerule", + keys: keyList, + line: keyList[0].line, + col: keyList[0].col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endkeyframerule", + keys: keyList, + line: keyList[0].line, + col: keyList[0].col + }); + + }, + + _key_list: function(){ + + /* + * key_list: + * : key [ S* ',' S* key]* + * ; + */ + var tokenStream = this._tokenStream, + token, + key, + keyList = []; + + //must be least one key + keyList.push(this._key()); + + this._readWhitespace(); + + while(tokenStream.match(Tokens.COMMA)){ + this._readWhitespace(); + keyList.push(this._key()); + this._readWhitespace(); + } + + return keyList; + }, + + _key: function(){ + /* + * There is a restriction that IDENT can be only "from" or "to". + * + * key + * : PERCENTAGE + * | IDENT + * ; + */ + + var tokenStream = this._tokenStream, + token; + + if (tokenStream.match(Tokens.PERCENTAGE)){ + return SyntaxUnit.fromToken(tokenStream.token()); + } else if (tokenStream.match(Tokens.IDENT)){ + token = tokenStream.token(); + + if (/from|to/i.test(token.value)){ + return SyntaxUnit.fromToken(token); + } + + tokenStream.unget(); + } + + //if it gets here, there wasn't a valid token, so time to explode + this._unexpectedToken(tokenStream.LT(1)); + }, + + //----------------------------------------------------------------- + // Helper methods + //----------------------------------------------------------------- + + /** + * Not part of CSS grammar, but useful for skipping over + * combination of white space and HTML-style comments. + * @return {void} + * @method _skipCruft + * @private + */ + _skipCruft: function(){ + while(this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])){ + //noop + } + }, + + /** + * Not part of CSS grammar, but this pattern occurs frequently + * in the official CSS grammar. Split out here to eliminate + * duplicate code. + * @param {Boolean} checkStart Indicates if the rule should check + * for the left brace at the beginning. + * @param {Boolean} readMargins Indicates if the rule should check + * for margin patterns. + * @return {void} + * @method _readDeclarations + * @private + */ + _readDeclarations: function(checkStart, readMargins){ + /* + * Reads the pattern + * S* '{' S* declaration [ ';' S* declaration ]* '}' S* + * or + * S* '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S* + * Note that this is how it is described in CSS3 Paged Media, but is actually incorrect. + * A semicolon is only necessary following a delcaration is there's another declaration + * or margin afterwards. + */ + var tokenStream = this._tokenStream, + tt; + + + this._readWhitespace(); + + if (checkStart){ + tokenStream.mustMatch(Tokens.LBRACE); + } + + this._readWhitespace(); + + try { + + while(true){ + + if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){ + //noop + } else if (this._declaration()){ + if (!tokenStream.match(Tokens.SEMICOLON)){ + break; + } + } else { + break; + } + + //if ((!this._margin() && !this._declaration()) || !tokenStream.match(Tokens.SEMICOLON)){ + // break; + //} + this._readWhitespace(); + } + + tokenStream.mustMatch(Tokens.RBRACE); + this._readWhitespace(); + + } catch (ex) { + if (ex instanceof SyntaxError && !this.options.strict){ + + //fire error event + this.fire({ + type: "error", + error: ex, + message: ex.message, + line: ex.line, + col: ex.col + }); + + //see if there's another declaration + tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]); + if (tt == Tokens.SEMICOLON){ + //if there's a semicolon, then there might be another declaration + this._readDeclarations(false, readMargins); + } else if (tt != Tokens.RBRACE){ + //if there's a right brace, the rule is finished so don't do anything + //otherwise, rethrow the error because it wasn't handled properly + throw ex; + } + + } else { + //not a syntax error, rethrow it + throw ex; + } + } + + }, + + /** + * In some cases, you can end up with two white space tokens in a + * row. Instead of making a change in every function that looks for + * white space, this function is used to match as much white space + * as necessary. + * @method _readWhitespace + * @return {String} The white space if found, empty string if not. + * @private + */ + _readWhitespace: function(){ + + var tokenStream = this._tokenStream, + ws = ""; + + while(tokenStream.match(Tokens.S)){ + ws += tokenStream.token().value; + } + + return ws; + }, + + + /** + * Throws an error when an unexpected token is found. + * @param {Object} token The token that was found. + * @method _unexpectedToken + * @return {void} + * @private + */ + _unexpectedToken: function(token){ + throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); + }, + + /** + * Helper method used for parsing subparts of a style sheet. + * @return {void} + * @method _verifyEnd + * @private + */ + _verifyEnd: function(){ + if (this._tokenStream.LA(1) != Tokens.EOF){ + this._unexpectedToken(this._tokenStream.LT(1)); + } + }, + + //----------------------------------------------------------------- + // Validation methods + //----------------------------------------------------------------- + _validateProperty: function(property, value){ + Validation.validate(property, value); + }, + + //----------------------------------------------------------------- + // Parsing methods + //----------------------------------------------------------------- + + parse: function(input){ + this._tokenStream = new TokenStream(input, Tokens); + this._stylesheet(); + }, + + parseStyleSheet: function(input){ + //just passthrough + return this.parse(input); + }, + + parseMediaQuery: function(input){ + this._tokenStream = new TokenStream(input, Tokens); + var result = this._media_query(); + + //if there's anything more, then it's an invalid selector + this._verifyEnd(); + + //otherwise return result + return result; + }, + + /** + * Parses a property value (everything after the semicolon). + * @return {parserlib.css.PropertyValue} The property value. + * @throws parserlib.util.SyntaxError If an unexpected token is found. + * @method parserPropertyValue + */ + parsePropertyValue: function(input){ + + this._tokenStream = new TokenStream(input, Tokens); + this._readWhitespace(); + + var result = this._expr(); + + //okay to have a trailing white space + this._readWhitespace(); + + //if there's anything more, then it's an invalid selector + this._verifyEnd(); + + //otherwise return result + return result; + }, + + /** + * Parses a complete CSS rule, including selectors and + * properties. + * @param {String} input The text to parser. + * @return {Boolean} True if the parse completed successfully, false if not. + * @method parseRule + */ + parseRule: function(input){ + this._tokenStream = new TokenStream(input, Tokens); + + //skip any leading white space + this._readWhitespace(); + + var result = this._ruleset(); + + //skip any trailing white space + this._readWhitespace(); + + //if there's anything more, then it's an invalid selector + this._verifyEnd(); + + //otherwise return result + return result; + }, + + /** + * Parses a single CSS selector (no comma) + * @param {String} input The text to parse as a CSS selector. + * @return {Selector} An object representing the selector. + * @throws parserlib.util.SyntaxError If an unexpected token is found. + * @method parseSelector + */ + parseSelector: function(input){ + + this._tokenStream = new TokenStream(input, Tokens); + + //skip any leading white space + this._readWhitespace(); + + var result = this._selector(); + + //skip any trailing white space + this._readWhitespace(); + + //if there's anything more, then it's an invalid selector + this._verifyEnd(); + + //otherwise return result + return result; + }, + + /** + * Parses an HTML style attribute: a set of CSS declarations + * separated by semicolons. + * @param {String} input The text to parse as a style attribute + * @return {void} + * @method parseStyleAttribute + */ + parseStyleAttribute: function(input){ + input += "}"; // for error recovery in _readDeclarations() + this._tokenStream = new TokenStream(input, Tokens); + this._readDeclarations(); + } + }; + + //copy over onto prototype + for (prop in additions){ + if (additions.hasOwnProperty(prop)){ + proto[prop] = additions[prop]; + } + } + + return proto; +}(); +/*global Validation, ValidationTypes, ValidationError*/ +var Properties = { + + //A + "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | | ", + "alignment-baseline" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical", + "animation" : 1, + "animation-delay" : { multi: "