diff --git a/.gitignore b/.gitignore index 084edd30df..d151849b71 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,6 @@ doc/code/* .secret *.log public/uploads.* +public/assets/ +.envrc +dump.rdb diff --git a/.pkgr.yml b/.pkgr.yml new file mode 100644 index 0000000000..09cb83783d --- /dev/null +++ b/.pkgr.yml @@ -0,0 +1,19 @@ +user: git +group: git +before_precompile: ./bin/pkgr_before_precompile.sh +targets: + debian-7: &wheezy + build_dependencies: + - libicu-dev + dependencies: + - libicu48 + - libpcre3 + - git + ubuntu-12.04: *wheezy + ubuntu-14.04: + build_dependencies: + - libicu-dev + dependencies: + - libicu52 + - libpcre3 + - git diff --git a/.rspec b/.rspec index 7488cbe779..4e1e0d2f72 100644 --- a/.rspec +++ b/.rspec @@ -1 +1 @@ ---color --drb +--color diff --git a/.travis.yml b/.travis.yml index c137aec907..9bab337f33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,32 @@ language: ruby env: global: - - DB=mysql - TRAVIS=true matrix: - - TASK=spinach - - TASK=spec - - TASK=jasmine:ci + - TASK=spinach DB=mysql + - TASK=spec:api DB=mysql + - TASK=spec:feature DB=mysql + - TASK=spec:other DB=mysql + - TASK=jasmine:ci DB=mysql + - TASK=spinach DB=postgresql + - TASK=spec:api DB=postgresql + - TASK=spec:feature DB=postgresql + - TASK=spec:other DB=postgresql + - TASK=jasmine:ci DB=postgresql before_install: - sudo apt-get install libicu-dev -y - - gem install charlock_holmes -v="0.6.9" branches: only: - 'master' rvm: - 2.0.0 services: - - mysql + - redis-server before_script: - "cp config/database.yml.$DB config/database.yml" - "cp config/gitlab.yml.example config/gitlab.yml" - "bundle exec rake db:setup" - "bundle exec rake db:seed_fu" script: "bundle exec rake $TASK --trace" +notifications: + email: false diff --git a/CHANGELOG b/CHANGELOG index 6994c4cf97..2f7874ba72 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,194 @@ +v 6.9.0 + - Store Rails cache data in the Redis `cache:gitlab` namespace + - Adjust MySQL limits for existing installations + - Add db index on project_id+iid column. This prevents duplicate on iid (During migration duplicates will be removed) + - Markdown preview or diff during editing via web editor (Evgeniy Sokovikov) + - Give the Rails cache its own Redis namespace + - Add ability to set different ssh host, if different from http/https + - Fix syntax highlighting for code comments blocks + - Improve comments loading logic + - Stop refreshing comments when the tab is hidden + - Improve issue and merge request mobile UI (Drew Blessing) + - Document how to convert a backup to PostgreSQL + - Fix locale bug in backup manager + - Fix can not automerge when MR description is too long + - Fix wiki backup skip bug + - Two Step MR creation process + - Remove unwanted files from satellite working directory with git clean -fdx + - Accept merge request via API (sponsored by O'Reilly Media) + - Add more access checks during API calls + - Block SSH access for 'disabled' Active Directory users + +v 6.8.0 + - Ability to at mention users that are participating in issue and merge req. discussion + - Enabled GZip Compression for assets in example Nginx, make sure that Nginx is compiled with --with-http_gzip_static_module flag (this is default in Ubuntu) + - Make user search case-insensitive (Christopher Arnold) + - Remove omniauth-ldap nickname bug workaround + - Drop all tables before restoring a Postgres backup + - Make the repository downloads path configurable + - Create branches via API (sponsored by O'Reilly Media) + - Changed permission of gitlab-satellites directory not to be world accessible + - Protected branch does not allow force push + - Fix popen bug in `rake gitlab:satellites:create` + - Disable connection reaping for MySQL + - Allow oauth signup without email for twitter and github + - Fix faulty namespace names that caused 500 on user creation + - Option to disable standard login + - Clean old created archives from repository downloads directory + - Fix download link for huge MR diffs + - Expose event and mergerequest timestamps in API + - Fix emails on push service when only one commit is pushed + +v 6.7.3 + - Fix the merge notification email not being sent (Pierre de La Morinerie) + - Drop all tables before restoring a Postgres backup + - Remove yanked modernizr gem + +v 6.7.2 + - Fix upgrader script + +v 6.7.1 + - Fix GitLab CI integration + +v 6.7.0 + - Increased the example Nginx client_max_body_size from 5MB to 20MB, consider updating it manually on existing installations + - Add support for Gemnasium as a Project Service (Olivier Gonzalez) + - Add edit file button to MergeRequest diff + - Public groups (Jason Hollingsworth) + - Cleaner headers in Notification Emails (Pierre de La Morinerie) + - Blob and tree gfm links to anchors work + - Piwik Integration (Sebastian Winkler) + - Show contribution guide link for new issue form (Jeroen van Baarsen) + - Fix CI status for merge requests from fork + - Added option to remove issue assignee on project issue page and issue edit page (Jason Blanchard) + - New page load indicator that includes a spinner that scrolls with the page + - Converted all the help sections into markdown + - LDAP user filters + - Streamline the content of notification emails (Pierre de La Morinerie) + - Fixes a bug with group member administration (Matt DeTullio) + - Sort tag names using VersionSorter (Robert Speicher) + - Add GFM autocompletion for MergeRequests (Robert Speicher) + - Add webhook when a new tag is pushed (Jeroen van Baarsen) + - Add button for toggling inline comments in diff view + - Add retry feature for repository import + - Reuse the GitLab LDAP connection within each request + - Changed markdown new line behaviour to conform to markdown standards + - Fix global search + - Faster authorized_keys rebuilding in `rake gitlab:shell:setup` (requires gitlab-shell 1.8.5) + - Create and Update MR calls now support the description parameter (Greg Messner) + - Markdown relative links in the wiki link to wiki pages, markdown relative links in repositories link to files in the repository + - Added Slack service integration (Federico Ravasio) + - Better API responses for access_levels (sponsored by O'Reilly Media) + - Requires at least 2 unicorn workers + - Requires gitlab-shell v1.9+ + - Replaced gemoji(due to closed licencing problem) with Phantom Open Emoji library(combined SIL Open Font License, MIT License and the CC 3.0 License) + - Fix `/:username.keys` response content type (Dmitry Medvinsky) + +v 6.6.5 + - Added option to remove issue assignee on project issue page and issue edit page (Jason Blanchard) + - Hide mr close button for comment form if merge request was closed or inline comment + - Adds ability to reopen closed merge request + +v 6.6.4 + - Add missing html escape for highlighted code blocks in comments, issues + +v 6.6.3 + - Fix 500 error when edit yourself from admin area + - Hide private groups for public profiles + +v 6.6.2 + - Fix 500 error on branch/tag create or remove via UI + +v 6.6.1 + - Fix 500 error on files tab if submodules presents + +v 6.6.0 + - Retrieving user ssh keys publically(github style): http://__HOST__/__USERNAME__.keys + - Permissions: Developer now can manage issue tracker (modify any issue) + - Improve Code Compare page performance + - Group avatar + - Pygments.rb replaced with highlight.js + - Improve Merge request diff store logic + - Improve render performnace for MR show page + - Fixed Assembla hardcoded project name + - Jira integration documentation + - Refactored app/services + - Remove snippet expiration + - Mobile UI improvements (Drew Blessing) + - Fix block/remove UI for admin::users#show page + - Show users' group membership on users' activity page (Robert Djurasaj) + - User pages are visible without login if user is authorized to a public project + - Markdown rendered headers have id derived from their name and link to their id + - Improve application to work faster with large groups (100+ members) + - Multiple emails per user + - Show last commit for file when view file source + - Restyle Issue#show page and MR#show page + - Ability to filter by multiple labels for Issues page + - Rails version to 4.0.3 + - Fixed attachment identifier displaying underneath note text (Jason Blanchard) + +v 6.5.1 + - Fix branch selectbox when create merge request from fork + +v 6.5.0 + - Dropdown menus on issue#show page for assignee and milestone (Jason Blanchard) + - Add color custimization and previewing to broadcast messages + - Fixed notes anchors + - Load new comments in issues dynamically + - Added sort options to Public page + - New filters (assigned/authored/all) for Dashboard#issues/merge_requests (sponsored by Say Media) + - Add project visibility icons to dashboard + - Enable secure cookies if https used + - Protect users/confirmation with rack_attack + - Default HTTP headers to protect against MIME-sniffing, force https if enabled + - Bootstrap 3 with responsive UI + - New repository download formats: tar.bz2, zip, tar (Jason Hollingsworth) + - Restyled accept widgets for MR + - SCSS refactored + - Use jquery timeago plugin + - Fix 500 error for rdoc files + - Ability to customize merge commit message (sponsored by Say Media) + - Search autocomplete via ajax + - Add website url to user profile + - Files API supports base64 encoded content (sponsored by O'Reilly Media) + - Added support for Go's repository retrieval (Bruno Albuquerque) + +v6.4.3 + - Don't use unicorn worker killer if PhusionPassenger is defined + +v6.4.2 + - Fixed wrong behaviour of script/upgrade.rb + +v6.4.1 + - Fixed bug with repository rename + - Fixed bug with project transfer + +v 6.4.0 + - Added sorting to project issues page (Jason Blanchard) + - Assembla integration (Carlos Paramio) + - Fixed another 500 error with submodules + - UI: More compact issues page + - Minimal password length increased to 8 symbols + - Side-by-side diff view (Steven Thonus) + - Internal projects (Jason Hollingsworth) + - Allow removal of avatar (Drew Blessing) + - Project web hooks now support issues and merge request events + - Visiting project page while not logged in will redirect to sign-in instead of 404 (Jason Hollingsworth) + - Expire event cache on avatar creation/removal (Drew Blessing) + - Archiving old projects (Steven Thonus) + - Rails 4 + - Add time ago tooltips to show actual date/time + - UI: Fixed UI for admin system hooks + - Ruby script for easier GitLab upgrade + - Do not remove Merge requests if fork project was removed + - Improve sign-in/signup UX + - Add resend confirmation link to sign-in page + - Set noreply@HOSTNAME for reply_to field in all emails + - Show GitLab API version on Admin#dashboard + - API Cross-origin resource sharing + - Show READMe link at project home page + - Show repo size for projects in Admin area + v 6.3.0 - API for adding gitlab-ci service - Init script now waits for pids to appear after (re)starting before reporting status (Rovanion Luckey) @@ -7,6 +198,36 @@ v 6.3.0 - Security improvements - Added support for GitLab CI 4.0 - Fixed issue with 500 error when group did not exist + - Ability to leave project + - You can create file in repo using UI + - You can remove file from repo using UI + - API: dropped default_branch attribute from project during creation + - Project default_branch is not stored in db any more. It takes from repo now. + - Admin broadcast messages + - UI improvements + - Dont show last push widget if user removed this branch + - Fix 500 error for repos with newline in file name + - Extended html titles + - API: create/update/delete repo files + - Admin can transfer project to any namespace + - API: projects/all for admin users + - Fix recent branches order + +v 6.2.4 + - Security: Cast API private_token to string (CVE-2013-4580) + - Security: Require gitlab-shell 1.7.8 (CVE-2013-4581, CVE-2013-4582, CVE-2013-4583) + - Fix for Git SSH access for LDAP users + +v 6.2.3 + - Security: More protection against CVE-2013-4489 + - Security: Require gitlab-shell 1.7.4 (CVE-2013-4490, CVE-2013-4546) + - Fix sidekiq rake tasks + +v 6.2.2 + - Security: Update gitlab_git (CVE-2013-4489) + +v 6.2.1 + - Security: Fix issue with generated passwords for new users v 6.2.0 - Public project pages are now visible to everyone (files, issues, wik, etc.) @@ -28,7 +249,7 @@ v 6.2.0 - Avatar upload on profile page with a maximum of 100KB (Steven Thonus) - Store the sessions in Redis instead of the cookie store - Fixed relative links in markdown - - User must confirm his email if signup enabled + - User must confirm their email if signup enabled - User must confirm changed email v 6.1.0 @@ -50,7 +271,7 @@ v 6.1.0 - Add links to create branch/tag from project home page - Add public-project? checkbox to new-project view - Improved compare page. Added link to proceed into Merge Request - - Send email to user when he was added to group + - Send an email to a user when they are added to group - New landing page when you have 0 projects v 6.0.0 @@ -93,6 +314,14 @@ v 6.0.0 - Improved MR comments logic - Render readme file for projects in public area +v 5.4.2 + - Security: Cast API private_token to string (CVE-2013-4580) + - Security: Require gitlab-shell 1.7.8 (CVE-2013-4581, CVE-2013-4582, CVE-2013-4583) + +v 5.4.1 + - Security: Fixes for CVE-2013-4489 + - Security: Require gitlab-shell 1.7.4 (CVE-2013-4490, CVE-2013-4546) + v 5.4.0 - Ability to edit own comments - Documentation improvements diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d1fdd93850..780db547f8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,38 +1,48 @@ # Contribute to GitLab -This guide details how to use issues and pull requests to improve GitLab. - -- [Closing policy for issues and pull requests](#closing-policy-for-issues-and-pull-requests) -- [Issue tracker](#issue-tracker) -- [Pull requests](#pull-requests) -- [Security vulnerabilities](#security-vulnerabilities) +This guide details how contribute to GitLab. If you want to know how the GitLab team handles contributions have a look at [the GitLab contributing process](PROCESS.md). -## Closing policy for issues and pull requests +## Contributor license agreement -GitLab is a popular open source project and the capacity to deal with issues and pull requests is limited. Out of respect for our volunteers, issues and pull requests not in line with the guidelines listed in this document may be closed without notice. +By submitting code as an individual you agree to the [individual contributor license agreement](doc/legal/individual_contributor_license_agreement.md). By submitting code as an entity you agree to the [corporate contributor license agreement](doc/legal/corporate_contributor_license_agreement.md). + +## Security vulnerability disclosure + +Please report suspected security vulnerabilities in private to support@gitlab.com, also see the [disclosure section on the GitLab.com website](http://www.gitlab.com/disclosure/). Please do NOT create publicly viewable issues for suspected security vulnerabilities. + +## Closing policy for issues and merge requests + +GitLab is a popular open source project and the capacity to deal with issues and merge requests is limited. Out of respect for our volunteers, issues and merge requests not in line with the guidelines listed in this document may be closed without notice. Please treat our volunteers with courtesy and respect, it will go a long way towards getting your issue resolved. -Issues and pull requests should be in English and contain appropriate language for audiences of all ages. +Issues and merge requests should be in English and contain appropriate language for audiences of all ages. ## Issue tracker -To get support for your particular problem please use the channels as detailed in [the getting help section of the readme](https://github.com/gitlabhq/gitlabhq#getting-help). Professional [support subscriptions](http://www.gitlab.com/subscription/) and [consulting services](http://www.gitlab.com/consultancy/) are available from [GitLab.com](http://www.gitlab.com/). +To get support for your particular problem please use the channels as detailed in the [getting help section of the readme](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/README.md#getting-help). Professional [support subscriptions](http://www.gitlab.com/subscription/) and [consulting services](http://www.gitlab.com/consultancy/) are available from [GitLab.com](http://www.gitlab.com/). -The [issue tracker](https://github.com/gitlabhq/gitlabhq/issues) is only for obvious bugs or misbehavior in the latest [stable or development release of GitLab](MAINTENANCE.md). When submitting an issue please conform to the issue submission guidelines listed below. Not all issues will be addressed and your issue is more likely to be addressed if you submit a pull request which partially or fully addresses the issue. +The [issue tracker](https://gitlab.com/gitlab-org/gitlab-ce/issues) is only for obvious errors in the latest [stable or development release of GitLab](MAINTENANCE.md). +If something is wrong but it is not a regression compared to older versions of GitLab please do not open an issue but a feature request. +When submitting an issue please conform to the issue submission guidelines listed below. +Not all issues will be addressed and your issue is more likely to be addressed if you submit a merge request which partially or fully addresses the issue. -Do not use the issue tracker for feature requests. We have a specific [feedback and suggestions forum](http://feedback.gitlab.com) for this purpose. +Issues can be filed either at [gitlab.com](https://gitlab.com/gitlab-org/gitlab-ce/issues) or [github.com](https://github.com/gitlabhq/gitlabhq/issues). -Please send a pull request with a tested solution or a pull request with a failing test instead of opening an issue if you can. If you're unsure where to post, post to the [mailing list](https://groups.google.com/forum/#!forum/gitlabhq) or [Stack Overflow](http://stackoverflow.com/questions/tagged/gitlab) first. There are a lot of helpful GitLab users there who may be able to help you quickly. If your particular issue turns out to be a bug, it will find its way from there. +Do not use the issue tracker for feature requests. +We have a specific [feature request forum](http://feedback.gitlab.com) for this purpose. +Please keep feature requests as small and simple as possible, complex ones might be edited to make them small and simple. + +Please send a merge request with a tested solution or a merge request with a failing test instead of opening an issue if you can. If you're unsure where to post, post to the [mailing list](https://groups.google.com/forum/#!forum/gitlabhq) or [Stack Overflow](http://stackoverflow.com/questions/tagged/gitlab) first. There are a lot of helpful GitLab users there who may be able to help you quickly. If your particular issue turns out to be a bug, it will find its way from there. ### Issue tracker guidelines -**[Search](https://github.com/gitlabhq/gitlabhq/search?q=&ref=cmdform&type=Issues)** for similar entries before submitting your own, there's a good chance somebody else had the same issue. Show your support with `:+1:` and/or join the discussion. Please submit issues in the following format (as the first post): +**[Search the issues](https://gitlab.com/gitlab-org/gitlab-ce/issues)** for similar entries before submitting your own, there's a good chance somebody else had the same issue. Show your support with `:+1:` and/or join the discussion. Please submit issues in the following format (as the first post): 1. **Summary:** Summarize your issue in one sentence (what goes wrong, what did you expect to happen) -2. **Steps to reproduce:** How can we reproduce the issue, preferably on the [GitLab Vagrant virtual machine](https://github.com/gitlabhq/gitlab-vagrant-vm) (start with: `vagrant destroy && vagrant up && vagrant ssh`) +2. **Steps to reproduce:** How can we reproduce the issue, preferably on the [GitLab development virtual machine with vagrant](https://gitlab.com/gitlab-org/cookbook-gitlab/blob/master/doc/development.md) (start your issue with: `vagrant destroy && vagrant up && vagrant ssh`) 3. **Expected behavior:** Describe your issue in detail 4. **Observed behavior** 5. **Relevant logs and/or screenshots:** Please use code blocks (\`\`\`) to format console output, logs, and code as it's very hard to read otherwise. @@ -43,37 +53,64 @@ Please send a pull request with a tested solution or a pull request with a faili * Describe your setup (use relevant parts from `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`) 7. **Possible fixes**: If you can, link to the line of code that might be responsible for the problem -## Pull requests +## Merge requests -We welcome pull requests with fixes and improvements to GitLab code, tests, and/or documentation. The features we would really like a pull request for are listed with the [status 'accepting merge/pull requests' on our feedback forum](http://feedback.gitlab.com/forums/176466-general/status/796455) but other improvements are also welcome. +We welcome merge requests with fixes and improvements to GitLab code, tests, and/or documentation. The features we would really like a merge request for are listed with the [status 'accepting merge requests' on our feature request forum](http://feedback.gitlab.com/forums/176466-general/status/796455) but other improvements are also welcome. If you want to add a new feature that is not marked it is best to first create a feedback issue (if there isn't one already) and leave a comment asking for it to be marked accepting merge requests. Please include screenshots or wireframes if the feature will also change the UI. -### Pull request guidelines +Merge requests can be filed either at [gitlab.com](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests) or [github.com](https://github.com/gitlabhq/gitlabhq/pulls). -If you can, please submit a pull request with the fix or improvements including tests. If you don't know how to fix the issue but can write a test that exposes the issue we will accept that as well. In general bug fixes that include a regression test are merged quickly while new features without proper tests are least likely to receive timely feedback. The workflow to make a pull request is as follows: +### Merge request guidelines -1. Fork the project on GitHub +If you can, please submit a merge request with the fix or improvements including tests. If you don't know how to fix the issue but can write a test that exposes the issue we will accept that as well. In general bug fixes that include a regression test are merged quickly while new features without proper tests are least likely to receive timely feedback. The workflow to make a merge request is as follows: + +1. Fork the project on GitLab Cloud 1. Create a feature branch 1. Write [tests](README.md#run-the-tests) and code 1. Add your changes to the [CHANGELOG](CHANGELOG) 1. If you have multiple commits please combine them into one commit by [squashing them](http://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) 1. Push the commit to your fork -1. Submit a pull request -2. [Search for issues](https://github.com/gitlabhq/gitlabhq/search?q=&ref=cmdform&type=Issues) related to your pull request and mention them in the pull request description +1. Submit a merge request (MR) to the master branch +1. The MR title should describes the change you want to make +1. The MR description should give a motive for your change and the method you used to achieve it +1. If the MR changes the UI it should include before and after screenshots +1. If the MR changes CSS classes please include the list of affected pages `grep css-class ./app -R` +1. Link relevant [issues](https://gitlab.com/gitlab-org/gitlab-ce/issues) and/or [feature requests](http://feedback.gitlab.com/) from the merge request description and leave a comment on them with a link back to the MR +1. Be prepared to answer questions and incorporate feedback even if requests for this arrive weeks or months after your MR submittion +1. If your MR touches code that executes shell commands, make sure it adheres to the [shell command guidelines]( doc/development/shell_commands.md). -We will accept pull requests if: +The **official merge window** is in the beginning of the month from the 1st to the 7th day of the month. The best time to submit a MR and get feedback fast. Before this time the GitLab.com team is still dealing with work that is created by the monthly release such as assisting subscribers with upgrade issues, the release of Enterprise Edition and the upgrade of GitLab Cloud. After the 7th it is already getting closer to the release date of the next version. This means there is less time to fix the issues created by merging large new features. -* The code has proper tests and all tests pass (or it is a test exposing a failure in existing code) -* It can be merged without problems (if not please use: `git rebase master`) -* It does not break any existing functionality -* It's quality code that conforms to the [Ruby](https://github.com/bbatsov/ruby-style-guide) and [Rails](https://github.com/bbatsov/rails-style-guide) style guides and best practices -* The description includes a motive for your change and the method you used to achieve it -* It is not a catch all pull request but rather fixes a specific issue or implements a specific feature -* It keeps the GitLab code base clean and well structured -* We think other users will benefit from the same functionality -* If it makes changes to the UI the pull request should include screenshots -* It is a single commit (please use `git rebase -i` to squash commits) +Please keep the change in a single MR **as small as possible**. If you want to contribute a large feature think very hard what the minimum viable change is. Can you split functionality? Can you only submit the backend/API code? Can you start with a very simple UI? The smaller a MR is the more likely it is it will be merged, after that you can send more MR's to enhance it. -For examples of feedback on pull requests please look at already [closed pull requests](https://github.com/gitlabhq/gitlabhq/pulls?direction=desc&page=1&sort=created&state=closed). +For examples of feedback on merge requests please look at already [closed merge requests](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests?assignee_id=&label_name=&milestone_id=&scope=&sort=&state=closed). Please ensure that your merge request meets the following contribution acceptance criteria. -## Security vulnerabilities -Please report security vulnerabilities in private to support@gitlab.com; also see http://www.gitlab.com/disclosure/. Do NOT create GitHub issues for security vulnerabilities. +**Please format your merge request description as follows:** + +1. What does this MR do? +2. Are there points in the code the reviewer needs to double check? +3. Why was this MR needed? +4. What are the relevant issue numbers / [Feature requests](http://feedback.gitlab.com/)? +5. Screenshots (If appropiate) + +## Contribution acceptance criteria + +1. The change is as small as possible (see the above paragraph for details) +1. Include proper tests and make all tests pass (unless it contains a test exposing a bug in existing code) +1. Can merge without problems (if not please use: `git rebase master`) +1. Does not break any existing functionality +1. Fixes one specific issue or implements one specific feature (do not combine things, send separate merge requests if needed) +1. Keeps the GitLab code base clean and well structured +1. Contains functionality we think other users will benefit from too +1. Doesn't add configuration options since they complicate future changes +1. Contains a single commit (please use `git rebase -i` to squash commits) +1. It conforms to the following style guides + +## Style guides +1. [Ruby](https://github.com/bbatsov/ruby-style-guide) +1. [Rails](https://github.com/bbatsov/rails-style-guide) +1. [Formatting](https://github.com/thoughtbot/guides/tree/master/style#formatting) +1. [Naming](https://github.com/thoughtbot/guides/tree/master/style#naming) +1. [Testing](https://github.com/thoughtbot/guides/tree/master/style#testing) +1. [CoffeeScript](https://github.com/thoughtbot/guides/tree/master/style#coffeescript) +1. [Shell commands](doc/development/shell_commands.md) +1. [Markdown](http://www.cirosantilli.com/markdown-styleguide) diff --git a/Gemfile b/Gemfile index a543c5e3a6..7ff7515143 100644 --- a/Gemfile +++ b/Gemfile @@ -8,15 +8,21 @@ def linux_only(require_as) RUBY_PLATFORM.include?('linux') && require_as end -gem "rails", "3.2.15" +gem "rails", "~> 4.0.0" + +gem "protected_attributes" +gem 'rails-observers' + +# Default values for AR models +gem "default_value_for", "~> 3.0.0" # Supported DBs gem "mysql2", group: :mysql gem "pg", group: :postgres # Auth -gem "devise", '~> 2.2' -gem "devise-async" +gem "devise", '3.0.4' +gem "devise-async", '0.8.0' gem 'omniauth', "~> 1.1.3" gem 'omniauth-google-oauth2' gem 'omniauth-twitter' @@ -24,26 +30,28 @@ gem 'omniauth-github' # Extracting information from a git repository # Provide access to Gitlab::Git library -gem "gitlab_git", "~> 3.0.0.rc2" +gem "gitlab_git", '~> 5.8' # Ruby/Rack Git Smart-HTTP Server Handler -gem 'gitlab-grack', '~> 1.0.1', require: 'grack' +gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack' # LDAP Auth -gem 'gitlab_omniauth-ldap', '1.0.3', require: "omniauth-ldap" - -# Syntax highlighter -gem "gitlab-pygments.rb", '~> 0.3.2', require: 'pygments.rb' +gem 'gitlab_omniauth-ldap', '1.0.4', require: "omniauth-ldap" # Git Wiki -gem "gitlab-gollum-lib", "~> 1.0.1", require: 'gollum-lib' +gem 'gollum-lib', '~> 3.0.0' # Language detection -gem "github-linguist", require: "linguist" +gem "gitlab-linguist", "~> 3.0.0", require: "linguist" # API -gem "grape", "~> 0.4.1" -gem "grape-entity", "~> 0.3.0" +gem "grape", "~> 0.6.1" +# Replace with rubygems when nesteted entities get released +gem "grape-entity", "~> 0.4.2" +gem 'rack-cors', require: 'rack/cors' + +# Email validation +gem "email_validator", "~> 1.4.0", :require => 'email_validator/strict' # Format dates and times # based on human-friendly examples @@ -53,7 +61,7 @@ gem "stamp" gem 'enumerize' # Pagination -gem "kaminari", "~> 0.14.1" +gem "kaminari", "~> 0.15.1" # HAML gem "haml-rails" @@ -62,7 +70,8 @@ gem "haml-rails" gem "carrierwave" # for aws storage -gem "fog", "~> 1.3.1", group: :aws +gem "fog", "~> 1.14", group: :aws +gem "unf", group: :aws # Authorization gem "six" @@ -72,13 +81,19 @@ gem "seed-fu" # Markdown to HTML gem "redcarpet", "~> 2.2.2" -gem "github-markup", "~> 0.7.4", require: 'github/markup' +gem "github-markup" + +# Diffs +gem 'diffy', '~> 3.0.3' # Asciidoc to HTML gem "asciidoctor" # Application server -gem "unicorn", '~> 4.6.3', group: :unicorn +group :unicorn do + gem "unicorn", '~> 4.6.3' + gem 'unicorn-worker-killer' +end # State machine gem "state_machine" @@ -89,7 +104,7 @@ gem "acts-as-taggable-on" # Background jobs gem 'slim' gem 'sinatra', require: nil -gem 'sidekiq' +gem 'sidekiq', '2.17.0' # HTTP requests gem "httparty" @@ -102,6 +117,7 @@ gem 'settingslogic' # Misc gem "foreman" +gem 'version_sorter' # Cache gem "redis-rails" @@ -110,11 +126,17 @@ gem "redis-rails" gem 'tinder', '~> 1.9.2' # HipChat integration -gem "hipchat", "~> 0.9.0" +gem "hipchat", "~> 0.14.0" # Flowdock integration gem "gitlab-flowdock-git-hook", "~> 0.4.2" +# Gemnasium integration +gem "gemnasium-gitlab-service", "~> 0.2" + +# Slack integration +gem "slack-notifier", "~> 0.3.2" + # d3 gem "d3_rails", "~> 3.1.4" @@ -122,37 +144,37 @@ gem "d3_rails", "~> 3.1.4" gem "underscore-rails", "~> 1.4.4" # Sanitize user input -gem "sanitize" +gem "sanitize", '~> 2.0' # Protect against bruteforcing gem "rack-attack" -group :assets do - gem "sass-rails" - gem "coffee-rails" - gem "uglifier" - gem "therubyracer" - gem 'turbolinks' - gem 'jquery-turbolinks' +# Ace editor +gem 'ace-rails-ap' - gem 'chosen-rails', "1.0.0" - gem 'select2-rails' - gem 'jquery-atwho-rails', "0.3.0" - gem "jquery-rails", "2.1.3" - gem "jquery-ui-rails", "2.0.2" - gem "modernizr", "2.6.2" - gem "raphael-rails", "~> 2.1.2" - gem 'bootstrap-sass' - gem "font-awesome-rails" - gem "gemoji", "~> 1.2.1", require: 'emoji/railtie' - gem "gon" -end +gem "sass-rails", '~> 4.0.2' +gem "coffee-rails" +gem "uglifier" +gem "therubyracer" +gem 'turbolinks' +gem 'jquery-turbolinks' + +gem 'select2-rails' +gem 'jquery-atwho-rails', "~> 0.3.3" +gem "jquery-rails" +gem "jquery-ui-rails" +gem "raphael-rails", "~> 2.1.2" +gem 'bootstrap-sass', '~> 3.0' +gem "font-awesome-rails", '~> 3.2' +gem "gitlab_emoji", "~> 0.0.1.1" +gem "gon", '~> 5.0.0' +gem 'nprogress-rails' group :development do gem "annotate", "~> 2.6.0.beta2" gem "letter_opener" gem 'quiet_assets', '~> 1.0.1' - gem 'rack-mini-profiler' + gem 'rack-mini-profiler', require: false # Better errors handler gem 'better_errors' @@ -169,7 +191,7 @@ end group :development, :test do gem 'coveralls', require: false - gem 'rails-dev-tweaks' + # gem 'rails-dev-tweaks' gem 'spinach-rails' gem "rspec-rails" gem "capybara" @@ -197,8 +219,11 @@ group :development, :test do # PhantomJS driver for Capybara gem 'poltergeist', '~> 1.4.1' - gem 'spork', '~> 1.0rc' - gem 'jasmine' + gem 'jasmine', '2.0.0.rc5' + + gem "spring", '1.1.1' + gem "spring-commands-rspec", '1.0.1' + gem "spring-commands-spinach", '1.0.0' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 0b4bf8fe32..f5f31105e1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,198 +1,201 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.15) - actionpack (= 3.2.15) + ace-rails-ap (2.0.1) + actionmailer (4.0.5) + actionpack (= 4.0.5) mail (~> 2.5.4) - actionpack (3.2.15) - activemodel (= 3.2.15) - activesupport (= 3.2.15) - builder (~> 3.0.0) + actionpack (4.0.5) + activesupport (= 4.0.5) + builder (~> 3.1.0) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.15) - activesupport (= 3.2.15) - builder (~> 3.0.0) - activerecord (3.2.15) - activemodel (= 3.2.15) - activesupport (= 3.2.15) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.15) - activemodel (= 3.2.15) - activesupport (= 3.2.15) - activesupport (3.2.15) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + activemodel (4.0.5) + activesupport (= 4.0.5) + builder (~> 3.1.0) + activerecord (4.0.5) + activemodel (= 4.0.5) + activerecord-deprecated_finders (~> 1.0.2) + activesupport (= 4.0.5) + arel (~> 4.0.0) + activerecord-deprecated_finders (1.0.3) + activesupport (4.0.5) + i18n (~> 0.6, >= 0.6.9) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) acts-as-taggable-on (2.4.1) rails (>= 3, < 5) - addressable (2.3.4) - annotate (2.6.0.beta2) + addressable (2.3.5) + annotate (2.6.0) activerecord (>= 2.3.0) rake (>= 0.8.7) - arel (3.0.2) - asciidoctor (0.1.3) + arel (4.0.2) + asciidoctor (0.1.4) awesome_print (1.2.0) - backports (3.3.2) - bcrypt-ruby (3.1.1) + axiom-types (0.0.5) + descendants_tracker (~> 0.0.1) + ice_nine (~> 0.9) + bcrypt-ruby (3.1.2) better_errors (1.0.1) coderay (>= 1.0.0) erubis (>= 2.6.6) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - bootstrap-sass (2.3.2.2) + bootstrap-sass (3.0.3.0) sass (~> 3.2) - builder (3.0.4) + builder (3.1.4) capybara (2.1.0) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - carrierwave (0.8.0) + carrierwave (0.9.0) activemodel (>= 3.2.0) activesupport (>= 3.2.0) - celluloid (0.14.1) - timers (>= 1.0.0) + json (>= 1.7) + celluloid (0.15.2) + timers (~> 1.1.0) charlock_holmes (0.6.9.4) - childprocess (0.3.9) - ffi (~> 1.0, >= 1.0.11) - chosen-rails (1.0.0) - coffee-rails (>= 3.2) - compass-rails (>= 1.0) - railties (>= 3.0) - sass-rails (>= 3.2) - chunky_png (1.2.8) - cliver (0.2.1) + cliver (0.2.2) code_analyzer (0.4.3) sexp_processor - coderay (1.0.9) - coffee-rails (3.2.2) + coderay (1.1.0) + coercible (1.0.0) + descendants_tracker (~> 0.0.1) + coffee-rails (4.0.1) coffee-script (>= 2.2.0) - railties (~> 3.2.0) + railties (>= 4.0.0, < 5.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.6.2) + coffee-script-source (1.6.3) colored (1.2) colorize (0.5.8) - compass (0.12.2) - chunky_png (~> 1.2) - fssm (>= 0.2.7) - sass (~> 3.1) - compass-rails (1.0.3) - compass (>= 0.12.2, < 0.14) - connection_pool (1.1.0) + connection_pool (1.2.0) coveralls (0.7.0) multi_json (~> 1.3) rest-client simplecov (>= 0.7) term-ansicolor thor - crack (0.4.0) + crack (0.4.1) safe_yaml (~> 0.9.0) d3_rails (3.1.10) railties (>= 3.1.0) daemons (1.1.9) - database_cleaner (1.1.1) + database_cleaner (1.2.0) debug_inspector (0.0.2) - descendants_tracker (0.0.1) - devise (2.2.5) + default_value_for (3.0.0) + activerecord (>= 3.2.0, < 5.0) + descendants_tracker (0.0.3) + devise (3.0.4) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.1) - railties (~> 3.1) - warden (~> 1.2.1) + railties (>= 3.2.6, < 5) + warden (~> 1.2.3) devise-async (0.8.0) devise (>= 2.2, < 3.2) - diff-lcs (1.2.4) - dotenv (0.8.0) - email_spec (1.4.0) + diff-lcs (1.2.5) + diffy (3.0.3) + docile (1.1.1) + dotenv (0.9.0) + email_spec (1.5.0) launchy (~> 2.1) mail (~> 2.2) - enumerize (0.6.1) + email_validator (1.4.0) + activemodel + emoji (1.0.1) + json + enumerize (0.7.0) activesupport (>= 3.2) + equalizer (0.0.8) erubis (2.7.0) escape_utils (0.2.4) eventmachine (1.0.3) - excon (0.13.4) - execjs (1.4.0) - multi_json (~> 1.0) - factory_girl (4.2.0) + excon (0.32.1) + execjs (2.0.2) + factory_girl (4.3.0) activesupport (>= 3.0.0) - factory_girl_rails (4.2.1) - factory_girl (~> 4.2.0) + factory_girl_rails (4.3.0) + factory_girl (~> 4.3.0) railties (>= 3.0.0) - faraday (0.8.7) - multipart-post (~> 1.1) + faraday (0.8.8) + multipart-post (~> 1.2.0) faraday_middleware (0.9.0) faraday (>= 0.7.4, < 0.9) - ffaker (1.18.0) - ffi (1.9.0) - fog (1.3.1) + ffaker (1.22.1) + ffi (1.9.3) + fog (1.21.0) + fog-brightbox + fog-core (~> 1.21, >= 1.21.1) + fog-json + nokogiri (~> 1.5, >= 1.5.11) + fog-brightbox (0.0.1) + fog-core + fog-json + fog-core (1.21.1) builder - excon (~> 0.13.0) + excon (~> 0.32) formatador (~> 0.2.0) mime-types - multi_json (~> 1.0) - net-scp (~> 1.0.4) + net-scp (~> 1.1) net-ssh (>= 2.1.3) - nokogiri (~> 1.5.0) - ruby-hmac + fog-json (1.0.0) + multi_json (~> 1.0) font-awesome-rails (3.2.1.3) railties (>= 3.2, < 5.0) foreman (0.63.0) dotenv (>= 0.7) thor (>= 0.13.6) formatador (0.2.4) - fssm (0.2.10) - gemoji (1.2.1) - gherkin-ruby (0.3.0) - 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-markdown (0.5.3) - github-markup (0.7.5) + gemnasium-gitlab-service (0.2.1) + rugged (~> 0.19) + gherkin-ruby (0.3.1) + racc + github-markup (1.1.0) gitlab-flowdock-git-hook (0.4.2.2) gitlab-grit (>= 2.4.1) multi_json - gitlab-gollum-lib (1.0.1) - github-markdown (~> 0.5.3) - github-markup (>= 0.7.5, < 1.0.0) - gitlab-grit (>= 2.5.1) - nokogiri (~> 1.5.9) - pygments.rb (~> 0.4.2) - sanitize (~> 2.0.3) - stringex (~> 1.5.1) - gitlab-grack (1.0.1) - rack (~> 1.4.1) - gitlab-grit (2.6.1) - charlock_holmes (~> 0.6.9) + gitlab-grack (2.0.0.pre) + rack (~> 1.5.1) + gitlab-grit (2.6.7) + charlock_holmes (~> 0.6) diff-lcs (~> 1.1) mime-types (~> 1.15) - posix-spawn (~> 0.3.6) - gitlab-pygments.rb (0.3.2) - posix-spawn (~> 0.3.6) - yajl-ruby (~> 1.1.0) - gitlab_git (3.0.0.rc2) - activesupport (~> 3.2.13) - github-linguist (~> 2.3.4) - gitlab-grit (~> 2.6.1) + posix-spawn (~> 0.3) + gitlab-linguist (3.0.0) + charlock_holmes (~> 0.6.6) + escape_utils (~> 0.2.4) + mime-types (~> 1.19) + gitlab_emoji (0.0.1.1) + emoji (~> 1.0.1) + gitlab_git (5.8.0) + activesupport (~> 4.0) + charlock_holmes (~> 0.6) + gitlab-grit (~> 2.6) + gitlab-linguist (~> 3.0) + rugged (~> 0.19.0) gitlab_meta (6.0) - gitlab_omniauth-ldap (1.0.3) + gitlab_omniauth-ldap (1.0.4) net-ldap (~> 0.3.1) omniauth (~> 1.0) pyu-ruby-sasl (~> 0.0.3.1) rubyntlm (~> 0.1.1) - gon (4.1.1) + gollum-lib (3.0.0) + github-markup (~> 1.1.0) + gitlab-grit (~> 2.6.5) + nokogiri (~> 1.6.1) + rouge (~> 1.3.3) + sanitize (~> 2.1.0) + stringex (~> 2.5.1) + gon (5.0.1) actionpack (>= 2.3.0) json - grape (0.4.1) + grape (0.6.1) activesupport builder hashie (>= 1.2.0) @@ -201,92 +204,92 @@ GEM rack (>= 1.3.0) rack-accept rack-mount - virtus - grape-entity (0.3.0) + virtus (>= 1.0.0) + grape-entity (0.4.2) activesupport multi_json (>= 1.3.2) growl (1.0.3) - guard (1.8.1) + guard (2.2.4) formatador (>= 0.2.4) - listen (>= 1.0.0) - lumberjack (>= 1.0.2) - pry (>= 0.9.10) - thor (>= 0.14.6) - guard-rspec (3.0.2) - guard (>= 1.8) - rspec (~> 2.13) + listen (~> 2.1) + lumberjack (~> 1.0) + pry (>= 0.9.12) + thor (>= 0.18.1) + guard-rspec (4.2.0) + guard (>= 2.1.1) + rspec (>= 2.14, < 4.0) guard-spinach (0.0.2) guard (>= 1.1) spinach - haml (4.0.3) + haml (4.0.4) tilt - haml-rails (0.4) - actionpack (>= 3.1, < 4.1) - activesupport (>= 3.1, < 4.1) - haml (>= 3.1, < 4.1) - railties (>= 3.1, < 4.1) - hashie (1.2.0) + haml-rails (0.5.1) + actionpack (~> 4.0.0) + activesupport (~> 4.0.0) + haml (>= 3.1, < 5.0) + railties (~> 4.0.0) + hashie (2.0.5) hike (1.2.3) - hipchat (0.9.0) + hipchat (0.14.0) httparty httparty http_parser.rb (0.5.3) - httparty (0.11.0) - multi_json (~> 1.0) + httparty (0.13.0) + json (~> 1.8) multi_xml (>= 0.5.2) httpauth (0.2.0) - i18n (0.6.5) - jasmine (1.3.2) - jasmine-core (~> 1.3.1) - rack (~> 1.0) - rspec (>= 1.3.1) - selenium-webdriver (>= 0.1.3) - jasmine-core (1.3.1) - journey (1.0.4) - jquery-atwho-rails (0.3.0) - jquery-rails (2.1.3) - railties (>= 3.1.0, < 5.0) - thor (~> 0.14) - jquery-turbolinks (1.0.0) + i18n (0.6.9) + ice_nine (0.10.0) + jasmine (2.0.0.rc5) + jasmine-core (~> 2.0.0.rc5) + phantomjs + rack (>= 1.2.1) + rake + jasmine-core (2.0.0.rc5) + jquery-atwho-rails (0.3.3) + jquery-rails (3.1.0) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + jquery-turbolinks (2.0.1) railties (>= 3.1.0) turbolinks - jquery-ui-rails (2.0.2) - jquery-rails - railties (>= 3.1.0) - json (1.7.7) + jquery-ui-rails (4.2.1) + railties (>= 3.2.16) + json (1.8.1) jwt (0.1.8) multi_json (>= 1.5) - kaminari (0.14.1) + kaminari (0.15.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) - kgio (2.8.0) - launchy (2.3.0) + kgio (2.8.1) + launchy (2.4.2) addressable (~> 2.3) - letter_opener (1.1.1) + letter_opener (1.1.2) launchy (~> 2.2) - libv8 (3.11.8.17) - listen (1.2.2) + libv8 (3.16.14.3) + listen (2.3.1) + celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) - rb-kqueue (>= 0.2) - lumberjack (1.0.3) + lumberjack (1.0.4) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) - method_source (0.8.1) - mime-types (1.25) - minitest (4.7.4) - modernizr (2.6.2) - sprockets (~> 2.0) - multi_json (1.8.2) - multi_xml (0.5.4) + method_source (0.8.2) + mime-types (1.25.1) + mini_portile (0.5.3) + minitest (4.7.5) + multi_json (1.10.0) + multi_xml (0.5.5) multipart-post (1.2.0) mysql2 (0.3.11) net-ldap (0.3.1) - net-scp (1.0.4) - net-ssh (>= 1.99.1) - net-ssh (2.6.8) - nokogiri (1.5.10) + net-scp (1.1.2) + net-ssh (>= 2.6.5) + net-ssh (2.8.0) + nokogiri (1.6.1) + mini_portile (~> 0.5.0) + nprogress-rails (0.1.2.3) oauth (0.4.7) oauth2 (0.8.1) faraday (~> 0.8) @@ -297,10 +300,10 @@ GEM omniauth (1.1.4) hashie (>= 1.2, < 3) rack - omniauth-github (1.1.0) + omniauth-github (1.1.1) omniauth (~> 1.0) omniauth-oauth2 (~> 1.1) - omniauth-google-oauth2 (0.1.19) + omniauth-google-oauth2 (0.2.1) omniauth (~> 1.0) omniauth-oauth2 omniauth-oauth (1.0.1) @@ -309,56 +312,53 @@ GEM omniauth-oauth2 (1.1.1) oauth2 (~> 0.8.0) omniauth (~> 1.0) - omniauth-twitter (0.0.17) + omniauth-twitter (1.0.1) multi_json (~> 1.3) omniauth-oauth (~> 1.0) - orm_adapter (0.4.0) + orm_adapter (0.5.0) pg (0.15.1) + phantomjs (1.9.2.0) poltergeist (1.4.1) capybara (~> 2.1.0) cliver (~> 0.2.1) multi_json (~> 1.0) websocket-driver (>= 0.2.0) - polyglot (0.3.3) - posix-spawn (0.3.6) - pry (0.9.12.2) - coderay (~> 1.0.5) + polyglot (0.3.4) + posix-spawn (0.3.8) + protected_attributes (1.0.5) + activemodel (>= 4.0.1, < 5.0) + pry (0.9.12.4) + coderay (~> 1.0) method_source (~> 0.8) slop (~> 3.4) - pygments.rb (0.4.2) - posix-spawn (~> 0.3.6) - yajl-ruby (~> 1.1.0) pyu-ruby-sasl (0.0.3.3) quiet_assets (1.0.2) railties (>= 3.1, < 5.0) - rack (1.4.5) + racc (1.4.10) + rack (1.5.2) rack-accept (0.4.5) rack (>= 0.4) - rack-attack (2.2.1) + rack-attack (2.3.0) rack - rack-cache (1.2) - rack (>= 0.4) - rack-mini-profiler (0.1.31) + rack-cors (0.2.9) + rack-mini-profiler (0.9.0) rack (>= 1.1.3) rack-mount (0.8.3) rack (>= 1.0.0) - rack-protection (1.5.0) - rack - rack-ssl (1.3.3) + rack-protection (1.5.1) rack rack-test (0.6.2) rack (>= 1.0) - rails (3.2.15) - actionmailer (= 3.2.15) - actionpack (= 3.2.15) - activerecord (= 3.2.15) - activeresource (= 3.2.15) - activesupport (= 3.2.15) - bundler (~> 1.0) - railties (= 3.2.15) - rails-dev-tweaks (0.6.1) - actionpack (~> 3.1) - railties (~> 3.1) + rails (4.0.5) + actionmailer (= 4.0.5) + actionpack (= 4.0.5) + activerecord (= 4.0.5) + activesupport (= 4.0.5) + bundler (>= 1.3.0, < 2.0) + railties (= 4.0.5) + sprockets-rails (~> 2.0.0) + rails-observers (0.1.2) + activemodel (~> 4.0) rails_best_practices (1.14.4) activesupport awesome_print @@ -368,254 +368,267 @@ GEM i18n require_all ruby-progressbar - railties (3.2.15) - actionpack (= 3.2.15) - activesupport (= 3.2.15) - rack-ssl (~> 1.3.2) + railties (4.0.5) + actionpack (= 4.0.5) + activesupport (= 4.0.5) rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - raindrops (0.11.0) - rake (10.1.0) + thor (>= 0.18.1, < 2.0) + raindrops (0.12.0) + rake (10.3.1) raphael-rails (2.1.2) rb-fsevent (0.9.3) - rb-inotify (0.9.0) - ffi (>= 0.5.0) - rb-kqueue (0.2.0) + rb-inotify (0.9.2) ffi (>= 0.5.0) rdoc (3.12.2) json (~> 1.4) redcarpet (2.2.2) - redis (3.0.4) - redis-actionpack (3.2.4) - actionpack (~> 3.2.0) - redis-rack (~> 1.4.4) - redis-store (~> 1.1.4) - redis-activesupport (3.2.4) - activesupport (~> 3.2.0) + redis (3.0.6) + redis-actionpack (4.0.0) + actionpack (~> 4) + redis-rack (~> 1.5.0) + redis-store (~> 1.1.0) + redis-activesupport (4.0.0) + activesupport (~> 4) + redis-store (~> 1.1.0) + redis-namespace (1.4.1) + redis (~> 3.0.4) + redis-rack (1.5.0) + rack (~> 1.5) + redis-store (~> 1.1.0) + redis-rails (4.0.0) + redis-actionpack (~> 4) + redis-activesupport (~> 4) redis-store (~> 1.1.0) - redis-namespace (1.3.1) - redis (~> 3.0.0) - redis-rack (1.4.4) - rack (~> 1.4.0) - redis-store (~> 1.1.4) - redis-rails (3.2.4) - redis-actionpack (~> 3.2.4) - redis-activesupport (~> 3.2.4) - redis-store (~> 1.1.4) redis-store (1.1.4) redis (>= 2.2) ref (1.0.5) - require_all (1.3.1) + require_all (1.3.2) rest-client (1.6.7) mime-types (>= 1.16) - rspec (2.13.0) - rspec-core (~> 2.13.0) - rspec-expectations (~> 2.13.0) - rspec-mocks (~> 2.13.0) - rspec-core (2.13.1) - rspec-expectations (2.13.0) + rouge (1.3.3) + rspec (2.14.1) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) + rspec-core (2.14.7) + rspec-expectations (2.14.4) diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.13.1) - rspec-rails (2.13.2) + rspec-mocks (2.14.4) + rspec-rails (2.14.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 2.13.0) - rspec-expectations (~> 2.13.0) - rspec-mocks (~> 2.13.0) - ruby-hmac (0.4.0) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) ruby-progressbar (1.2.0) rubyntlm (0.1.1) - rubyzip (0.9.9) - safe_yaml (0.9.3) - sanitize (2.0.3) - nokogiri (>= 1.4.4, < 1.6) - sass (3.2.11) - sass-rails (3.2.6) - railties (~> 3.2.0) - sass (>= 3.1.10) - tilt (~> 1.3) + rugged (0.19.0) + safe_yaml (0.9.7) + sanitize (2.1.0) + nokogiri (>= 1.4.4) + sass (3.2.19) + sass-rails (4.0.3) + railties (>= 4.0.0, < 5.0) + sass (~> 3.2.0) + sprockets (~> 2.8, <= 2.11.0) + sprockets-rails (~> 2.0) sdoc (0.3.20) json (>= 1.1.3) rdoc (~> 3.10) - seed-fu (2.2.0) - activerecord (~> 3.1) - activesupport (~> 3.1) - select2-rails (3.4.2) - sass-rails + seed-fu (2.3.0) + activerecord (>= 3.1, < 4.1) + activesupport (>= 3.1, < 4.1) + select2-rails (3.5.2) thor (~> 0.14) - selenium-webdriver (2.33.0) - childprocess (>= 0.2.5) - multi_json (~> 1.0) - rubyzip - websocket (~> 1.0.4) settingslogic (2.0.9) - sexp_processor (4.3.0) + sexp_processor (4.4.0) shoulda-matchers (2.1.0) activesupport (>= 3.0.0) - sidekiq (2.14.0) - celluloid (>= 0.14.1) + sidekiq (2.17.0) + celluloid (>= 0.15.2) connection_pool (>= 1.0.0) json redis (>= 3.0.4) - redis-namespace + redis-namespace (>= 1.3.1) simple_oauth (0.1.9) - simplecov (0.7.1) - multi_json (~> 1.0) - simplecov-html (~> 0.7.1) - simplecov-html (0.7.1) - sinatra (1.4.3) + simplecov (0.8.2) + docile (~> 1.1.0) + multi_json + simplecov-html (~> 0.8.0) + simplecov-html (0.8.0) + sinatra (1.4.4) rack (~> 1.4) rack-protection (~> 1.4) tilt (~> 1.3, >= 1.3.4) six (0.2.0) - slim (2.0.0) - temple (~> 0.6.5) - tilt (~> 1.3, >= 1.3.3) - slop (3.4.5) - spinach (0.8.3) + slack-notifier (0.3.2) + slim (2.0.2) + temple (~> 0.6.6) + tilt (>= 1.3.3, < 2.1) + slop (3.4.7) + spinach (0.8.7) colorize (= 0.5.8) - gherkin-ruby (~> 0.3.0) + gherkin-ruby (>= 0.3.1) spinach-rails (0.2.1) capybara (>= 2.0.0) railties (>= 3) spinach (>= 0.4) - spork (1.0.0rc2) - sprockets (2.2.2) + spring (1.1.1) + spring-commands-rspec (1.0.1) + spring (>= 0.9.1) + spring-commands-spinach (1.0.0) + spring (>= 0.9.1) + sprockets (2.11.0) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.0.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) stamp (0.5.0) state_machine (1.2.0) - stringex (1.5.1) - temple (0.6.5) + stringex (2.5.1) + temple (0.6.7) term-ansicolor (1.2.2) tins (~> 0.8) - test_after_commit (0.2.1) - therubyracer (0.11.4) - libv8 (~> 3.11.8.12) + test_after_commit (0.2.2) + therubyracer (0.12.0) + libv8 (~> 3.16.14.0) ref - thin (1.5.1) + thin (1.6.1) daemons (>= 1.0.9) - eventmachine (>= 0.12.6) + eventmachine (>= 1.0.0) rack (>= 1.0.0) - thor (0.18.1) + thor (0.19.1) + thread_safe (0.3.3) tilt (1.4.1) timers (1.1.0) - tinder (1.9.2) + tinder (1.9.3) eventmachine (~> 1.0) faraday (~> 0.8) faraday_middleware (~> 0.9) - hashie (~> 1.0) - json (~> 1.7.5) + hashie (>= 1.0, < 3) + json (~> 1.8.0) mime-types (~> 1.19) - multi_json (~> 1.5) + multi_json (~> 1.7) twitter-stream (~> 0.1) - tins (0.11.0) + tins (0.13.1) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - turbolinks (1.2.0) + turbolinks (2.0.0) coffee-rails twitter-stream (0.1.16) eventmachine (>= 0.12.8) http_parser.rb (~> 0.5.1) simple_oauth (~> 0.1.4) - tzinfo (0.3.38) - uglifier (2.1.1) + tzinfo (0.3.39) + uglifier (2.3.2) execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) + json (>= 1.8.0) underscore-rails (1.4.4) + unf (0.1.4) + unf_ext + unf_ext (0.0.6) unicorn (4.6.3) kgio (~> 2.6) rack raindrops (~> 0.7) - virtus (0.5.5) - backports (~> 3.3) + unicorn-worker-killer (0.4.2) + unicorn (~> 4) + version_sorter (1.1.0) + virtus (1.0.1) + axiom-types (~> 0.0.5) + coercible (~> 1.0) descendants_tracker (~> 0.0.1) + equalizer (~> 0.0.7) warden (1.2.3) rack (>= 1.0) - webmock (1.11.0) + webmock (1.16.0) addressable (>= 2.2.7) crack (>= 0.3.2) - websocket (1.0.7) - websocket-driver (0.3.0) + websocket-driver (0.3.1) xpath (2.0.0) nokogiri (~> 1.3) - yajl-ruby (1.1.0) PLATFORMS ruby DEPENDENCIES + ace-rails-ap acts-as-taggable-on annotate (~> 2.6.0.beta2) asciidoctor awesome_print better_errors binding_of_caller - bootstrap-sass + bootstrap-sass (~> 3.0) capybara carrierwave - chosen-rails (= 1.0.0) coffee-rails colored coveralls d3_rails (~> 3.1.4) database_cleaner - devise (~> 2.2) - devise-async + default_value_for (~> 3.0.0) + devise (= 3.0.4) + devise-async (= 0.8.0) + diffy (~> 3.0.3) email_spec + email_validator (~> 1.4.0) enumerize factory_girl_rails ffaker - fog (~> 1.3.1) - font-awesome-rails + fog (~> 1.14) + font-awesome-rails (~> 3.2) foreman - gemoji (~> 1.2.1) - github-linguist - github-markup (~> 0.7.4) + gemnasium-gitlab-service (~> 0.2) + github-markup gitlab-flowdock-git-hook (~> 0.4.2) - gitlab-gollum-lib (~> 1.0.1) - gitlab-grack (~> 1.0.1) - gitlab-pygments.rb (~> 0.3.2) - gitlab_git (~> 3.0.0.rc2) + gitlab-grack (~> 2.0.0.pre) + gitlab-linguist (~> 3.0.0) + gitlab_emoji (~> 0.0.1.1) + gitlab_git (~> 5.8) gitlab_meta (= 6.0) - gitlab_omniauth-ldap (= 1.0.3) - gon - grape (~> 0.4.1) - grape-entity (~> 0.3.0) + gitlab_omniauth-ldap (= 1.0.4) + gollum-lib (~> 3.0.0) + gon (~> 5.0.0) + grape (~> 0.6.1) + grape-entity (~> 0.4.2) growl guard-rspec guard-spinach haml-rails - hipchat (~> 0.9.0) + hipchat (~> 0.14.0) httparty - jasmine - jquery-atwho-rails (= 0.3.0) - jquery-rails (= 2.1.3) + jasmine (= 2.0.0.rc5) + jquery-atwho-rails (~> 0.3.3) + jquery-rails jquery-turbolinks - jquery-ui-rails (= 2.0.2) - kaminari (~> 0.14.1) + jquery-ui-rails + kaminari (~> 0.15.1) launchy letter_opener minitest (~> 4.7.0) - modernizr (= 2.6.2) mysql2 + nprogress-rails omniauth (~> 1.1.3) omniauth-github omniauth-google-oauth2 omniauth-twitter pg poltergeist (~> 1.4.1) + protected_attributes pry quiet_assets (~> 1.0.1) rack-attack + rack-cors rack-mini-profiler - rails (= 3.2.15) - rails-dev-tweaks + rails (~> 4.0.0) + rails-observers rails_best_practices raphael-rails (~> 2.1.2) rb-fsevent @@ -623,20 +636,23 @@ DEPENDENCIES redcarpet (~> 2.2.2) redis-rails rspec-rails - sanitize - sass-rails + sanitize (~> 2.0) + sass-rails (~> 4.0.2) sdoc seed-fu select2-rails settingslogic shoulda-matchers (~> 2.1.0) - sidekiq + sidekiq (= 2.17.0) simplecov sinatra six + slack-notifier (~> 0.3.2) slim spinach-rails - spork (~> 1.0rc) + spring (= 1.1.1) + spring-commands-rspec (= 1.0.1) + spring-commands-spinach (= 1.0.0) stamp state_machine test_after_commit @@ -646,5 +662,8 @@ DEPENDENCIES turbolinks uglifier underscore-rails (~> 1.4.4) + unf unicorn (~> 4.6.3) + unicorn-worker-killer + version_sorter webmock diff --git a/Guardfile b/Guardfile index e682f0b6cf..e19a312377 100644 --- a/Guardfile +++ b/Guardfile @@ -1,7 +1,7 @@ # A sample Guardfile # More info at https://github.com/guard/guard#readme -guard 'rspec', :version => 2, :all_on_start => false, :all_after_pass => false do +guard 'rspec', cmd: "spring rspec", version: 2, all_on_start: false, all_after_pass: false do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch(%r{^lib/api/(.+)\.rb$}) { |m| "spec/requests/api/#{m[1]}_spec.rb" } diff --git a/LICENSE b/LICENSE index 7cecc2485f..8ebd322ffc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2011 Dmitriy Zaporozhets +Copyright (c) 2011-2014 Dmitriy Zaporozhets Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/MAINTENANCE.md b/MAINTENANCE.md index 0dca62974c..95d9f0a5e7 100644 --- a/MAINTENANCE.md +++ b/MAINTENANCE.md @@ -21,3 +21,5 @@ release where the minor version is increased numerically by increments of one (eg. `5.0 -> 5.1`). We encourage everyone to run the latest stable release to ensure that you can easily upgrade to the most secure and feature rich GitLab experience. In order to make sure you can easily run the most recent stable release, we are working hard to keep the update process simple and reliable. + +More information about the release procedures can be found in the doc/release directory. diff --git a/PROCESS.md b/PROCESS.md index 668cacc870..23dbfd0c69 100644 --- a/PROCESS.md +++ b/PROCESS.md @@ -7,26 +7,19 @@ Below we describe the contributing process to GitLab for two reasons. So that co ## Common actions ### Issue team -- Looks for issues without workflow labels and triages issue -- Monitors pull requests -- Closes invalid issues and pull requests with a comment (duplicates, [feature requests](#feature-requests), [fixed in newer version](#issue-fixed-in-newer-version), [issue report for old version](#issue-report-for-old-version), not a problem in GitLab, etc.) -- Assigns appropriate [labels](#how-we-handle-issues) -- Asks for feedback from issue reporter/pull request initiator ([invalid issue reports](#improperly-formatted-issue), [format code](#code-format), etc.) -- Asks for feedback from the relevant developer(s) based on the [list of members and their specialities](http://gitlab.org/team/) -- Monitors all issues/pull requests for feedback (but especially ones commented on since automatically watching them): +- Looks for issues without [workflow labels](#how-we-handle-issues) and triages issue +- Closes invalid issues with a comment (duplicates, [feature requests](#feature-requests), [fixed in newer version](#issue-fixed-in-newer-version), [issue report for old version](#issue-report-for-old-version), not a problem in GitLab, etc.) +- Asks for feedback from issue reporter ([invalid issue reports](#improperly-formatted-issue), [format code](#code-format), etc.) +- Monitors all issues for feedback (but especially ones commented on since automatically watching them) - Closes issues with no feedback from the reporter for two weeks -- Closes stale pull requests -### Development team +### Merge request officers -- Responds to issues and pull requests the issue team mentions them in -- Monitors for new issues in _Awaiting developer action/feedback_ with no developer activity (once a week) -- Monitors for new pull requests (at least once a week) -- Manages their work queue by looking at issues and pull requests assigned to them -- Close fixed issues (via commit messages or manually) -- Codes [new features](http://feedback.gitlab.com/forums/176466-general/filters/top)! -- Response guidelines -- Be kind to people trying to contribute. Be aware that people can be a non-native or a native English speaker, they might not understand thing or they might be very sensitive to how your word things. Use emoji to express your feelings (heart, star, smile, etc.). Some good tips about giving feedback to pull requests is in the [Thoughtbot code review guide](https://github.com/thoughtbot/guides/tree/master/code-review). +- Responds to merge requests the issue team mentions them in and monitors for new merge requests +- Provides feedback to the merge request submitter to improve the merge request (style, tests, etc.) +- Mark merge requests 'ready-for-merge' when they meet the contribution guidelines +- Mention developer(s) based on the [list of members and their specialities](https://www.gitlab.com/core-team/) +- Closes merge requests with no feedback from the reporter for two weeks ## Priorities of the issue team @@ -37,7 +30,7 @@ Below we describe the contributing process to GitLab for two reasons. So that co ## Mentioning people -The most important thing is making sure valid issues receive feedback from the development team. Therefore the priority is mentioning developers that can help on those issue. Please select someone with relevant experience from [GitLab core team](http://gitlab.org/team/). If there is nobody mentioned with that expertise look in the commit history for the affected files to find someone. Avoid mentioning the lead developer, this is the person that is least likely to give a timely response. If the involvement of the lead developer is needed the other core team members will mention this person. +The most important thing is making sure valid issues receive feedback from the development team. Therefore the priority is mentioning developers that can help on those issue. Please select someone with relevant experience from [GitLab core team](https://www.gitlab.com/core-team/). If there is nobody mentioned with that expertise look in the commit history for the affected files to find someone. Avoid mentioning the lead developer, this is the person that is least likely to give a timely response. If the involvement of the lead developer is needed the other core team members will mention this person. ## Workflow labels @@ -45,8 +38,8 @@ Workflow labels are purposely not very detailed since that would be hard to keep - _Awaiting feedback_: Feedback pending from the reporter - _Awaiting confirmation of fix_: The issue should already be solved in **master** (generally you can avoid this workflow item and just close the issue right away) -- _Attached PR_: There is a PR attached and the discussion should happen there - - We need to let issues stay in sync with the PR's. We can do this with a "Closing #XXXX" or "Fixes #XXXX" comment in the PR. We can't close the issue when there is a pull request because sometimes a PR is not good and we just close the PR, then the issue must stay. +- _Attached MR_: There is a MR attached and the discussion should happen there + - We need to let issues stay in sync with the MR's. We can do this with a "Closing #XXXX" or "Fixes #XXXX" comment in the MR. We can't close the issue when there is a merge request because sometimes a MR is not good and we just close the MR, then the issue must stay. - _Awaiting developer action/feedback_: Issue needs to be fixed or clarified by a developer ## Functional labels @@ -59,29 +52,33 @@ If an issue is complex and needs the attention of a specific person, assignment ## Label colors - Light orange `#fef2c0`: workflow labels for issue team members (awaiting feedback, awaiting confirmation of fix) -- Bright orange `#eb6420`: workflow labels for core team members (attached PR, awaiting developer action/feedback) +- Bright orange `#eb6420`: workflow labels for core team members (attached MR, awaiting developer action/feedback) - Light blue `#82C5FF`: functional labels - Green labels `#009800`: issues that can generally be ignored. For example, issues given the following labels normally can be closed immediately: - Feature request (see copy & paste response: [Feature requests](#feature-requests)) - Support (see copy & paste response: [Support requests and configuration questions](#support-requests-and-configuration-questions) +## Be kind + +Be kind to people trying to contribute. Be aware that people can be a non-native or a native English speaker, they might not understand thing or they might be very sensitive to how your word things. Use emoji to express your feelings (heart, star, smile, etc.). Some good tips about giving feedback to merge requests is in the [Thoughtbot code review guide](https://github.com/thoughtbot/guides/tree/master/code-review). + ## Copy & paste responses ### Improperly formatted issue -Thanks for the issue report. Please reformat your issue to conform to the issue tracker guidelines found in our \[contributing guidelines\]\(https://github.com/gitlabhq/gitlabhq/blob/master/CONTRIBUTING.md#issue-tracker-guidelines). +Thanks for the issue report. Please reformat your issue to conform to the issue tracker guidelines found in our \[contributing guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#issue-tracker-guidelines). ### Feature requests -Thanks for your interest in GitLab. We don't use the GitHub issue tracker for feature requests. Please use http://feedback.gitlab.com/ for this purpose or create a pull request implementing this feature. Have a look at the \[contribution guidelines\]\(https://github.com/gitlabhq/gitlabhq/blob/master/CONTRIBUTING.md) for more information. +Thank you for your interest in improving GitLab. We don't use the issue tracker for feature requests. Things that are wrong but are not a regression compared to older versions of GitLab are considered feature requests and not issues. Please use the [feature request forum](http://feedback.gitlab.com/) for this purpose or create a merge request implementing this feature. Have a look at the \[contribution guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md) for more information. ### Issue report for old version -Thanks for the issue report but we only support issues for the latest stable version of GitLab. I'm closing this issue but if you still experience this problem in the latest stable version, please open a new issue (but also reference the old issue(s)). Make sure to also include the necessary debugging information conforming to the issue tracker guidelines found in our \[contributing guidelines\]\(https://github.com/gitlabhq/gitlabhq/blob/master/CONTRIBUTING.md#issue-tracker-guidelines). +Thanks for the issue report but we only support issues for the latest stable version of GitLab. I'm closing this issue but if you still experience this problem in the latest stable version, please open a new issue (but also reference the old issue(s)). Make sure to also include the necessary debugging information conforming to the issue tracker guidelines found in our \[contributing guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#issue-tracker-guidelines). ### Support requests and configuration questions -Thanks for your interest in GitLab. We don't use the GitHub issue tracker for support requests and configuration questions. Please use the \[support forum\]\(https://groups.google.com/forum/#!forum/gitlabhq), \[Stack Overflow\]\(http://stackoverflow.com/questions/tagged/gitlab), the unofficial #gitlab IRC channel on Freenode or the http://www.gitlab.com paid services for this purpose. Have a look at the \[contribution guidelines\]\(https://github.com/gitlabhq/gitlabhq/blob/master/CONTRIBUTING.md) for more information. +Thanks for your interest in GitLab. We don't use the issue tracker for support requests and configuration questions. Please use the \[support forum\]\(https://groups.google.com/forum/#!forum/gitlabhq), \[Stack Overflow\]\(http://stackoverflow.com/questions/tagged/gitlab), the #gitlab IRC channel on Freenode or the http://www.gitlab.com paid services for this purpose. Have a look at the \[contribution guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md) for more information. ### Code format @@ -89,17 +86,24 @@ Please use ``` to format console output, logs, and code as it's very hard to rea ### Issue fixed in newer version -Thanks for the issue report. This issue has already been fixed in newer versions of GitLab. Due to the size of this project and our limited resources we are only able to support the latest stable release as outlined in our \[contributing guidelines\]\(https://github.com/gitlabhq/gitlabhq/blob/master/CONTRIBUTING.md#issue-tracker). In order to get this bug fix and enjoy many new features please \[upgrade\]\(http://blog.gitlab.org/). If you still experience issues at that time please open a new issue following our issue tracker guidelines found in the \[contributing guidelines\]\(https://github.com/gitlabhq/gitlabhq/blob/master/CONTRIBUTING.md#issue-tracker-guidelines). +Thanks for the issue report. This issue has already been fixed in newer versions of GitLab. Due to the size of this project and our limited resources we are only able to support the latest stable release as outlined in our \[contributing guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#issue-tracker). In order to get this bug fix and enjoy many new features please \[upgrade\]\(https://github.com/gitlabhq/gitlabhq/tree/master/doc/update). If you still experience issues at that time please open a new issue following our issue tracker guidelines found in the \[contributing guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#issue-tracker-guidelines). -### Improperly formatted pull request +### Improperly formatted merge request -Thanks for your interest in improving the GitLab codebase! Please update your pull request according to the \[contributing guidelines\]\(https://github.com/gitlabhq/gitlabhq/blob/master/CONTRIBUTING.md#pull-request-guidelines). +Thanks for your interest in improving the GitLab codebase! Please update your merge request according to the \[contributing guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#pull-request-guidelines). ### Inactivity close of an issue -It's been at least 2 weeks (and a new release) since we heard from you. I'm closing this issue but if you still experience this problem, please open a new issue (but also reference the old issue(s)). Make sure to also include the necessary debugging information conforming to the issue tracker guidelines found in our \[contributing guidelines\]\(https://github.com/gitlabhq/gitlabhq/blob/master/CONTRIBUTING.md#issue-tracker-guidelines). +It's been at least 2 weeks (and a new release) since we heard from you. I'm closing this issue but if you still experience this problem, please open a new issue (but also reference the old issue(s)). Make sure to also include the necessary debugging information conforming to the issue tracker guidelines found in our \[contributing guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#issue-tracker-guidelines). -### Inactivity close of a pull request +### Inactivity close of a merge request -This pull request has been closed because a request for more information has not been reacted to for more than 2 weeks. If you respond and conform to the pull request guidelines in our \[contributing guidelines\]\(https://github.com/gitlabhq/gitlabhq/blob/master/CONTRIBUTING.md#pull-requests) we will reopen this pull request. +This merge request has been closed because a request for more information has not been reacted to for more than 2 weeks. If you respond and conform to the merge request guidelines in our \[contributing guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#pull-requests) we will reopen this merge request. +### Accepting merge requests + +Is there a request on [the feature request forum](http://feedback.gitlab.com/forums/176466-general) that is similar to this? +If so, can you make a comment with a link to it? +Please be aware that new functionality that is not marked [accepting merge/pull requests](http://feedback.gitlab.com/forums/176466-general/status/796455) on the forum might not make it into GitLab. +You might be asked to make changes and even after implementing them your feature might still be declined. +If you want to reduce the chance of this happening please have a discussion in the forum first. diff --git a/Procfile b/Procfile index 9003369c93..a5693f8dbc 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -web: bundle exec unicorn_rails -p $PORT -E development +web: bundle exec unicorn_rails -p ${PORT:="3000"} -E ${RAILS_ENV:="development"} -c ${UNICORN_CONFIG:="config/unicorn.rb"} worker: bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,common,default,gitlab_shell diff --git a/README.md b/README.md index 64e40fdc51..efac636c24 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,45 @@ ## GitLab: self hosted Git management software -![logo](https://raw.github.com/gitlabhq/gitlabhq/master/public/gitlab_logo.png) +![logo](https://gitlab.com/gitlab-org/gitlab-ce/raw/master/public/gitlab_logo.png) ![animated-screenshots](https://gist.github.com/fnkr/2f9badd56bfe0ed04ee7/raw/4f48806fbae97f556c2f78d8c2d299c04500cb0d/compiled.gif) -### GitLab allows you to - * keep your code secure on your own server - * manage repositories, users and access permissions - * communicate through issues, line-comments and wiki pages - * perform code review with merge requests +### Gitlab is open source software to collaborate on code -### GitLab is +* Manage git repositories with fine grained access controls that keep your code secure +* Perform code reviews and enhance collaboration with merge requests +* Each project can also have an issue tracker and a wiki +* Used by more than 100,000 organizations, GitLab is the most popular solution to manage git repositories on-premises +* Completely free and open source (MIT Expat license) +* Powered by Ruby on Rails -* powered by Ruby on Rails -* completely free and open source (MIT license) -* used by more than 25.000 organizations to keep their code secure +### Canonical source + +* The source of GitLab Communinity Edition is [hosted on GitLab Cloud](https://gitlab.com/gitlab-org/gitlab-ce/) and there are mirrors to make [contributing](CONTRIBUTING.md) as easy as possible. ### Code status -* [![build status](http://ci.gitlab.org/projects/1/status.png?ref=master)](http://ci.gitlab.org/projects/1?ref=master) on ci.gitlab.org (master branch) +* [![build status](https://ci.gitlab.org/projects/1/status.png?ref=master)](https://ci.gitlab.org/projects/1?ref=master) on ci.gitlab.org (master branch) * [![Code Climate](https://codeclimate.com/github/gitlabhq/gitlabhq.png)](https://codeclimate.com/github/gitlabhq/gitlabhq) -* [![Dependency Status](https://gemnasium.com/gitlabhq/gitlabhq.png)](https://gemnasium.com/gitlabhq/gitlabhq) this button can be yellow (small updates are available) but must not be red (a security fix or an important update is available), gems are updated in major releases of GitLab. - * [![Coverage Status](https://coveralls.io/repos/gitlabhq/gitlabhq/badge.png?branch=master)](https://coveralls.io/r/gitlabhq/gitlabhq) +* [![PullReview stats](https://www.pullreview.com/gitlab/gitlab-org/gitlab-ce/badges/master.svg?)](https://www.pullreview.com/gitlab.gitlab.com/gitlab-org/gitlab-ce/reviews/master) + ### Resources -* GitLab.org community site: [Homepage](http://gitlab.org) | [Screenshots](http://gitlab.org/screenshots/) | [Blog](http://blog.gitlab.org/) | [Demo](http://demo.gitlabhq.com/users/sign_in) +* [GitLab.com](https://www.gitlab.com/) includes information about [subscriptions](https://www.gitlab.com/subscription/), [consultancy](https://www.gitlab.com/consultancy/), the [community](https://www.gitlab.com/community/) and the [hosted GitLab Cloud](https://www.gitlab.com/cloud/). -* GitLab.com commercial services: [Homepage](http://www.gitlab.com/) | [Subscription](http://www.gitlab.com/subscription/) | [Consultancy](http://www.gitlab.com/consultancy/) | [GitLab Cloud](http://www.gitlab.com/cloud/) | [Blog](http://blog.gitlab.com/) +* [GitLab Enterprise Edition](https://www.gitlab.com/gitlab-ee/) offers additional features aimed at larger organizations. -* GitLab CI: [Readme](https://github.com/gitlabhq/gitlab-ci/blob/master/README.md) of the GitLab open-source continuous integration server +* [GitLab CI](https://www.gitlab.com/gitlab-ci/) is a continuous integration (CI) server that is easy to integrate with GitLab. + +* Unofficial third-party [iPhone app](http://gitlabcontrol.com/), [Android app](https://play.google.com/store/apps/details?id=com.bd.gitlab&hl=en) and [command line client](https://github.com/drewblessing/gitlab-cli) and [Ruby API wrapper](https://github.com/NARKOZ/gitlab) for GitLab. ### Requirements -* Ubuntu/Debian** +* Ubuntu/Debian/CentOS/RHEL** * ruby 1.9.3+ * git 1.7.10+ * redis 2.0+ @@ -46,39 +49,33 @@ ### Installation -#### Official production installation +#### Official installation methods -* [Installation guide for a production server](doc/install/installation.md) +* [GitLab packages](https://www.gitlab.com/downloads/) **recommended** These packages contain GitLab and all its depencies (Ruby, PostgreSQL, Redis, Nginx, Unicorn, etc.). They are made with [omnibus-gitlab](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md) that also contains the installation instructions. +* [GitLab Chef Cookbook](https://gitlab.com/gitlab-org/cookbook-gitlab/blob/master/README.md) This cookbook can be used both for development installations and production installations. If you want to [contribute](CONTRIBUTE.md) to GitLab we suggest you follow the [development installation on a virtual machine with Vagrant](https://gitlab.com/gitlab-org/cookbook-gitlab/blob/master/doc/development.md) instructions to install all testing dependencies. -#### Official development installation +* [Manual installation guide](doc/install/installation.md) This guide to set up a production server on Ubuntu offers detailed and complete step-by-step instructions. -If you want to contribute, please first read our [Contributing Guidelines](https://github.com/gitlabhq/gitlabhq/blob/master/CONTRIBUTING.md) and then we suggest you to use the Vagrant virtual machine project to get an environment working with all dependencies. +#### Third party one-click installers -* [Vagrant virtual machine for development](https://github.com/gitlabhq/gitlab-vagrant-vm) +* [Digital Ocean 1-Click Application Install](https://www.digitalocean.com/blog_posts/host-your-git-repositories-in-55-seconds-with-gitlab) Have a new server up in 55 seconds. Digital Ocean uses SSD disks which is great for an IO intensive app such as GitLab. We recommend selecting a droplet with [1GB of memory](https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/requirements.md). +* [BitNami one-click installers](http://bitnami.com/stack/gitlab) This package contains both GitLab and GitLab CI. It is available as installer, virtual machine or for cloud hosting providers (Amazon Web Services/Azure/etc.). -#### Unofficial production installations +#### Unofficial installation methods -* [GitLab recipes](https://github.com/gitlabhq/gitlab-recipes) repository with unofficial guides for using GitLab with different software (operating systems, webservers, etc.) than the official version. +* [GitLab recipes](https://gitlab.com/gitlab-org/gitlab-recipes/) repository with unofficial guides for using GitLab with different software (operating systems, webservers, etc.) than the official version. * [Installation guides](https://github.com/gitlabhq/gitlab-public-wiki/wiki/Unofficial-Installation-Guides) public wiki with unofficial guides to install GitLab on different operating systems. -* [BitNami one-click installers](http://bitnami.com/stack/gitlab) - -* [TurnKey Linux virtual appliance](http://www.turnkeylinux.org/gitlab) - - ### New versions and upgrading -Since 2011 GitLab is released on the 22nd of every month. Every new release includes an upgrade guide. +Since 2011 GitLab is released on the 22nd of every month. Every new release includes an [upgrade guide](doc/update) and new features are detailed in the [Changelog](CHANGELOG). -* [Upgrade guides](doc/update) - -* [Changelog](CHANGELOG) - -* Features that will be in the next releases are listed on [the feedback and suggestions forum](http://feedback.gitlab.com/forums/176466-general) with the status [started](http://feedback.gitlab.com/forums/176466-general/status/796456) and [completed](http://feedback.gitlab.com/forums/176466-general/status/796457). +It is recommended to follow a monthly upgrade schedule. Security releases come out when needed. For more information about the release process see the documentation for [monthly](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/release/monthly.md) and [security](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/release/security.md) releases. +* Features that will be in the next releases are listed on the [feature request forum](http://feedback.gitlab.com/forums/176466-general) with the status [started](http://feedback.gitlab.com/forums/176466-general/status/796456) and [completed](http://feedback.gitlab.com/forums/176466-general/status/796457). ### Run in production mode @@ -90,8 +87,16 @@ or by directly calling the script sudo /etc/init.d/gitlab start +Please login with root / 5iveL!fe + ### Run in development mode +Consider setting up the development environment with [the cookbook](https://gitlab.com/gitlab-org/cookbook-gitlab/blob/master/README.md#installation). + +Copy the example development unicorn configuration file + + cp config/unicorn.rb.example.development config/unicorn.rb + Start it with [Foreman](https://github.com/ddollar/foreman) bundle exec foreman start -p 3000 @@ -101,16 +106,13 @@ or start each component separately bundle exec rails s script/background_jobs start +And surf to [localhost:3000](http://localhost:3000/) and login with root / 5iveL!fe + ### Run the tests -* Seed the database - - bundle exec rake db:setup RAILS_ENV=test - bundle exec rake db:seed_fu RAILS_ENV=test - * Run all tests - bundle exec rake gitlab:test + bundle exec rake test * [RSpec](http://rspec.info/) unit and functional tests @@ -125,43 +127,10 @@ or start each component separately Single Spinach test: bundle exec spinach features/project/issues/milestones.feature -### GitLab interfaces +### Documentation -* [GitLab API doc](doc/api/README.md) or see the [GitLab API website](http://api.gitlab.org/) - -* [Rake tasks](doc/raketasks) including a [backup and restore procedure](doc/raketasks/backup_restore.md) - -* [Directory structure](doc/install/structure.md) - -* [Database installation](doc/install/databases.md) - -* [Markdown specification](doc/markdown/markdown.md) - -* [Security guide](doc/security/rack_attack.md) to throttle abusive requests +All documentation can be found on [doc.gitlab.com/ce/](http://doc.gitlab.com/ce/). ### Getting help -* [Maintenance policy](MAINTENANCE.md) specifies what versions are supported. - -* [Troubleshooting guide](https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide) contains solutions to common problems. - -* [Mailing list](https://groups.google.com/forum/#!forum/gitlabhq) and [Stack Overflow](http://stackoverflow.com/questions/tagged/gitlab) are the best places to ask questions. For example you can use it if you have questions about: permission denied errors, invisible repos, can't clone/pull/push or with web hooks that don't fire. Please search for similar issues before posting your own, there's a good chance somebody else had the same issue you have now and has resolved it. There are a lot of helpful GitLab users there who may be able to help you quickly. If your particular issue turns out to be a bug, it will find its way from there to a fix. - -* [Unofficial #gitlab IRC on Freenode](http://www.freenode.net/) is another way to get in touch with other GitLab users who may be able to help you. - -* [Feedback and suggestions forum](http://feedback.gitlab.com) is the place to propose and discuss new features for GitLab. - -* [Contributing guide](https://github.com/gitlabhq/gitlabhq/blob/master/CONTRIBUTING.md) describes how to submit pull requests and issues. Pull requests and issues not in line with the guidelines in this document will be closed. - -* [Support subscription](http://www.gitlab.com/subscription/) connects you to the knowledge of GitLab experts that will resolve your issues and answer your questions. - -* [Consultancy](http://www.gitlab.com/consultancy/) allows you hire GitLab experts for installations, upgrades and customizations. - - -### Getting in touch - -* [Core team](http://gitlab.org/team/) - -* [Contributors](http://contributors.gitlab.org/) - -* [Community](http://gitlab.org/community/) +Please see [Getting help for GitLab](https://www.gitlab.com/getting-help/) on our website for the many options to get help. diff --git a/VERSION b/VERSION index 5a903253f4..c0ad52beda 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.3.0.pre +6.9.0.pre diff --git a/app/assets/images/ajax_loader.gif b/app/assets/images/ajax_loader.gif deleted file mode 100644 index 8a97c91987..0000000000 Binary files a/app/assets/images/ajax_loader.gif and /dev/null differ diff --git a/app/assets/images/ajax_loader_gray.gif b/app/assets/images/ajax_loader_gray.gif deleted file mode 100644 index af3f618bd0..0000000000 Binary files a/app/assets/images/ajax_loader_gray.gif and /dev/null differ diff --git a/app/assets/images/ajax_loader_tree.gif b/app/assets/images/ajax_loader_tree.gif deleted file mode 100644 index 99d5a0f37f..0000000000 Binary files a/app/assets/images/ajax_loader_tree.gif and /dev/null differ diff --git a/app/assets/images/authbuttons/github_32.png b/app/assets/images/authbuttons/github_32.png new file mode 100644 index 0000000000..c56eef05eb Binary files /dev/null and b/app/assets/images/authbuttons/github_32.png differ diff --git a/vendor/assets/images/authbuttons/github_64.png b/app/assets/images/authbuttons/github_64.png similarity index 97% rename from vendor/assets/images/authbuttons/github_64.png rename to app/assets/images/authbuttons/github_64.png index fca7bf4465..39de55bc79 100644 Binary files a/vendor/assets/images/authbuttons/github_64.png and b/app/assets/images/authbuttons/github_64.png differ diff --git a/app/assets/images/authbuttons/google_32.png b/app/assets/images/authbuttons/google_32.png new file mode 100644 index 0000000000..6225cc9c2d Binary files /dev/null and b/app/assets/images/authbuttons/google_32.png differ diff --git a/app/assets/images/authbuttons/google_64.png b/app/assets/images/authbuttons/google_64.png new file mode 100644 index 0000000000..4d608f7100 Binary files /dev/null and b/app/assets/images/authbuttons/google_64.png differ diff --git a/app/assets/images/authbuttons/twitter_32.png b/app/assets/images/authbuttons/twitter_32.png new file mode 100644 index 0000000000..696eb02484 Binary files /dev/null and b/app/assets/images/authbuttons/twitter_32.png differ diff --git a/app/assets/images/authbuttons/twitter_64.png b/app/assets/images/authbuttons/twitter_64.png new file mode 100644 index 0000000000..2893274766 Binary files /dev/null and b/app/assets/images/authbuttons/twitter_64.png differ diff --git a/app/assets/images/bg-header.png b/app/assets/images/bg-header.png index 8759ca589f..9ecdaf4e2d 100644 Binary files a/app/assets/images/bg-header.png and b/app/assets/images/bg-header.png differ diff --git a/vendor/assets/images/bg_fallback.png b/app/assets/images/bg_fallback.png similarity index 75% rename from vendor/assets/images/bg_fallback.png rename to app/assets/images/bg_fallback.png index 4b2754b804..d9066ad7d7 100644 Binary files a/vendor/assets/images/bg_fallback.png and b/app/assets/images/bg_fallback.png differ diff --git a/app/assets/images/dark-scheme-preview.png b/app/assets/images/dark-scheme-preview.png index 055a9069b6..6dac6cd8ca 100644 Binary files a/app/assets/images/dark-scheme-preview.png and b/app/assets/images/dark-scheme-preview.png differ diff --git a/app/assets/images/favicon.ico b/app/assets/images/favicon.ico index 057f74ac7a..bfb74960c4 100644 Binary files a/app/assets/images/favicon.ico and b/app/assets/images/favicon.ico differ diff --git a/app/assets/images/file_txt.png b/app/assets/images/file_txt.png index f3638cb4e1..b3230b5add 100644 Binary files a/app/assets/images/file_txt.png and b/app/assets/images/file_txt.png differ diff --git a/app/assets/images/icon-link.png b/app/assets/images/icon-link.png new file mode 100644 index 0000000000..32ade0fe9a Binary files /dev/null and b/app/assets/images/icon-link.png differ diff --git a/app/assets/images/icon-search.png b/app/assets/images/icon-search.png index 7632915cac..084b89e3a7 100644 Binary files a/app/assets/images/icon-search.png and b/app/assets/images/icon-search.png differ diff --git a/app/assets/images/icon_sprite.png b/app/assets/images/icon_sprite.png new file mode 100644 index 0000000000..9ad65fc443 Binary files /dev/null and b/app/assets/images/icon_sprite.png differ diff --git a/app/assets/images/images.png b/app/assets/images/images.png index 973d3bdd39..da91f6b1f4 100644 Binary files a/app/assets/images/images.png and b/app/assets/images/images.png differ diff --git a/app/assets/images/logo-black.png b/app/assets/images/logo-black.png index 6567f2e546..4a96572d57 100644 Binary files a/app/assets/images/logo-black.png and b/app/assets/images/logo-black.png differ diff --git a/app/assets/images/logo-white.png b/app/assets/images/logo-white.png index a63fb1c9c0..bc2ef601a5 100644 Binary files a/app/assets/images/logo-white.png and b/app/assets/images/logo-white.png differ diff --git a/app/assets/images/monokai-scheme-preview.png b/app/assets/images/monokai-scheme-preview.png index 9477941778..3aeed886a0 100644 Binary files a/app/assets/images/monokai-scheme-preview.png and b/app/assets/images/monokai-scheme-preview.png differ diff --git a/app/assets/images/no_avatar.png b/app/assets/images/no_avatar.png index 752d26adba..dac3ab1bb8 100644 Binary files a/app/assets/images/no_avatar.png and b/app/assets/images/no_avatar.png differ diff --git a/app/assets/images/no_group_avatar.png b/app/assets/images/no_group_avatar.png new file mode 100644 index 0000000000..a97d451598 Binary files /dev/null and b/app/assets/images/no_group_avatar.png differ diff --git a/app/assets/images/onion_skin_sprites.gif b/app/assets/images/onion_skin_sprites.gif index 85d20260ed..337aa1bfb6 100644 Binary files a/app/assets/images/onion_skin_sprites.gif and b/app/assets/images/onion_skin_sprites.gif differ diff --git a/app/assets/images/progress_bar.gif b/app/assets/images/progress_bar.gif new file mode 100644 index 0000000000..c3d43fa40b Binary files /dev/null and b/app/assets/images/progress_bar.gif differ diff --git a/vendor/assets/images/slider_handles.png b/app/assets/images/slider_handles.png similarity index 61% rename from vendor/assets/images/slider_handles.png rename to app/assets/images/slider_handles.png index b95a46eca9..a6d477033f 100644 Binary files a/vendor/assets/images/slider_handles.png and b/app/assets/images/slider_handles.png differ diff --git a/app/assets/images/solarized-dark-scheme-preview.png b/app/assets/images/solarized-dark-scheme-preview.png index 728964bc4c..ae092ab521 100644 Binary files a/app/assets/images/solarized-dark-scheme-preview.png and b/app/assets/images/solarized-dark-scheme-preview.png differ diff --git a/app/assets/images/swipemode_sprites.gif b/app/assets/images/swipemode_sprites.gif index 327b3c31ff..b010b4e448 100644 Binary files a/app/assets/images/swipemode_sprites.gif and b/app/assets/images/swipemode_sprites.gif differ diff --git a/app/assets/images/switch_icon.png b/app/assets/images/switch_icon.png index 7c11f20659..6b8bde41bc 100644 Binary files a/app/assets/images/switch_icon.png and b/app/assets/images/switch_icon.png differ diff --git a/app/assets/images/trans_bg.gif b/app/assets/images/trans_bg.gif index c7e98e044f..5f6ed04a43 100644 Binary files a/app/assets/images/trans_bg.gif and b/app/assets/images/trans_bg.gif differ diff --git a/app/assets/images/white-scheme-preview.png b/app/assets/images/white-scheme-preview.png index 67eb876304..d1866e0015 100644 Binary files a/app/assets/images/white-scheme-preview.png and b/app/assets/images/white-scheme-preview.png differ diff --git a/app/assets/javascripts/admin.js.coffee b/app/assets/javascripts/admin.js.coffee index 6230fe7f93..6634bb6cc3 100644 --- a/app/assets/javascripts/admin.js.coffee +++ b/app/assets/javascripts/admin.js.coffee @@ -8,6 +8,23 @@ class Admin else elems.removeAttr 'disabled' + $('body').on 'click', '.js-toggle-colors-link', (e) -> + e.preventDefault() + $('.js-toggle-colors-link').hide() + $('.js-toggle-colors-container').show() + + $('input#broadcast_message_color').on 'input', -> + previewColor = $('input#broadcast_message_color').val() + $('div.broadcast-message-preview').css('background-color', previewColor) + + $('input#broadcast_message_font').on 'input', -> + previewColor = $('input#broadcast_message_font').val() + $('div.broadcast-message-preview').css('color', previewColor) + + $('textarea#broadcast_message_message').on 'input', -> + previewMessage = $('textarea#broadcast_message_message').val() + $('div.broadcast-message-preview span').text(previewMessage) + $('.log-tabs a').click (e) -> e.preventDefault() $(this).tab('show') diff --git a/app/assets/javascripts/api.js.coffee b/app/assets/javascripts/api.js.coffee index a36d944cbc..fafa5cdfaa 100644 --- a/app/assets/javascripts/api.js.coffee +++ b/app/assets/javascripts/api.js.coffee @@ -2,6 +2,8 @@ users_path: "/api/:version/users.json" user_path: "/api/:version/users/:id.json" notes_path: "/api/:version/projects/:id/notes.json" + namespaces_path: "/api/:version/namespaces.json" + project_users_path: "/api/:version/projects/:id/users.json" # Get 20 (depends on api) recent notes # and sort the ascending from oldest to newest @@ -49,6 +51,37 @@ ).done (users) -> callback(users) + # Return project users list. Filtered by query + # Only active users retrieved + projectUsers: (project_id, query, callback) -> + url = Api.buildUrl(Api.project_users_path) + url = url.replace(':id', project_id) + + $.ajax( + url: url + data: + private_token: gon.api_token + search: query + per_page: 20 + active: true + dataType: "json" + ).done (users) -> + callback(users) + + # Return namespaces list. Filtered by query + namespaces: (query, callback) -> + url = Api.buildUrl(Api.namespaces_path) + + $.ajax( + url: url + data: + private_token: gon.api_token + search: query + per_page: 20 + dataType: "json" + ).done (namespaces) -> + callback(namespaces) + buildUrl: (url) -> url = gon.relative_url_root + url if gon.relative_url_root? return url.replace(':version', gon.api_version) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js deleted file mode 100644 index 0767b82032..0000000000 --- a/app/assets/javascripts/application.js +++ /dev/null @@ -1,31 +0,0 @@ -// This is a manifest file that'll be compiled into including all the files listed below. -// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically -// be included in the compiled file accessible from http://example.com/assets/application.js -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// the compiled file. -// -//= require jquery -//= require jquery.ui.all -//= require jquery_ujs -//= require jquery.cookie -//= require jquery.endless-scroll -//= require jquery.highlight -//= require jquery.history -//= require jquery.waitforimages -//= require jquery.atwho -//= require jquery.scrollto -//= require jquery.blockUI -//= require turbolinks -//= require jquery.turbolinks -//= require bootstrap -//= require modernizr -//= require chosen-jquery -//= require select2 -//= require raphael -//= require g.raphael-min -//= require g.bar-min -//= require branch-graph -//= require ace-src-noconflict/ace -//= require_tree . -//= require d3 -//= require underscore diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/application.js.coffee similarity index 71% rename from app/assets/javascripts/main.js.coffee rename to app/assets/javascripts/application.js.coffee index ccd5ad48db..a22ff6dec3 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -1,5 +1,35 @@ -window.updatePage = (data) -> - $.ajax({type: "GET", url: location.href, data: data, dataType: "script"}) +# This is a manifest file that'll be compiled into including all the files listed below. +# Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +# be included in the compiled file accessible from http://example.com/assets/application.js +# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +# the compiled file. +# +#= require jquery +#= require jquery.ui.all +#= require jquery_ujs +#= require jquery.cookie +#= require jquery.endless-scroll +#= require jquery.highlight +#= require jquery.history +#= require jquery.waitforimages +#= require jquery.atwho +#= require jquery.scrollto +#= require jquery.blockUI +#= require turbolinks +#= require jquery.turbolinks +#= require bootstrap +#= require select2 +#= require raphael +#= require g.raphael-min +#= require g.bar-min +#= require branch-graph +#= require highlightjs.min +#= require ace/ace +#= require d3 +#= require underscore +#= require nprogress +#= require nprogress-turbolinks +#= require_tree . window.slugify = (text) -> text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase() @@ -44,19 +74,11 @@ window.linkify = (str) -> window.simpleFormat = (str) -> linkify(sanitize(str).replace(/\n/g, '
')) -window.startSpinner = -> - $('.turbolink-spinner').fadeIn() - -window.stopSpinner = -> - $('.turbolink-spinner').fadeOut() - window.unbindEvents = -> $(document).unbind('scroll') $(document).off('scroll') -document.addEventListener("page:fetch", startSpinner) document.addEventListener("page:fetch", unbindEvents) -document.addEventListener("page:receive", stopSpinner) $ -> # Click a .one_click_select field, select the contents @@ -65,13 +87,8 @@ $ -> $('.remove-row').bind 'ajax:success', -> $(this).closest('li').fadeOut() - # Click a .appear-link, appear-data fadeout - $(".appear-link").on 'click', (e) -> - $('.appear-data').fadeIn() - e.preventDefault() - - # Initialize chosen selects - $('select.chosen').chosen() + # Initialize select2 selects + $('select.select2').select2(width: 'resolve', dropdownAutoWidth: true) # Initialize tooltips $('.has_tooltip').tooltip() @@ -84,6 +101,7 @@ $ -> $(@).parents('form').submit() $("abbr.timeago").timeago() + $('.js-timeago').timeago() # Flash if (flash = $(".flash-container")).length > 0 @@ -119,21 +137,11 @@ $ -> # Commit show suppressed diff - $(".content").on "click", ".supp_diff_link", -> + $(".diff-content").on "click", ".supp_diff_link", -> $(@).next('table').show() $(@).remove() - $(".content").on "click", ".js-details-expand", -> - $(@).next('.js-details-contain').removeClass("hide") - $(@).remove() - (($) -> - _chosen = $.fn.chosen - $.fn.extend chosen: (options) -> - default_options = search_contains: "true" - $.extend default_options, options - _chosen.apply @, [default_options] - # Disable an element and add the 'disabled' Bootstrap class $.fn.extend disable: -> $(@).attr('disabled', 'disabled').addClass('disabled') diff --git a/app/assets/javascripts/behaviors/details_behavior.coffee b/app/assets/javascripts/behaviors/details_behavior.coffee index 7ad5c81894..decab3e1be 100644 --- a/app/assets/javascripts/behaviors/details_behavior.coffee +++ b/app/assets/javascripts/behaviors/details_behavior.coffee @@ -1,5 +1,15 @@ $ -> $("body").on "click", ".js-details-target", -> container = $(@).closest(".js-details-container") - container.toggleClass("open") + + # Show details content. Hides link after click. + # + # %div + # %a.js-details-expand + # %div.js-details-content + # + $("body").on "click", ".js-details-expand", (e) -> + $(@).next('.js-details-content').removeClass("hide") + $(@).hide() + e.preventDefault() diff --git a/app/assets/javascripts/behaviors/toggler_behavior.coffee b/app/assets/javascripts/behaviors/toggler_behavior.coffee index 7e438c51c1..d06cb116df 100644 --- a/app/assets/javascripts/behaviors/toggler_behavior.coffee +++ b/app/assets/javascripts/behaviors/toggler_behavior.coffee @@ -1,17 +1,18 @@ $ -> $("body").on "click", ".js-toggler-target", -> container = $(@).closest(".js-toggler-container") - container.toggleClass("on") - - $("body").on "click", ".js-toggle-visibility-link", (e) -> + + # Toggle button. Show/hide content inside parent container. + # Button does not change visibility. If button has icon - it changes chevron style. + # + # %div.js-toggle-container + # %a.js-toggle-button + # %div.js-toggle-content + # + $("body").on "click", ".js-toggle-button", (e) -> $(@).find('i'). toggleClass('icon-chevron-down'). toggleClass('icon-chevron-up') - container = $(".js-toggle-visibility-container") - container.toggleClass("hide") - e.preventDefault() - - $("body").on "click", ".js-toggle-button", (e) -> $(@).closest(".js-toggle-container").find(".js-toggle-content").toggle() e.preventDefault() diff --git a/app/assets/javascripts/blob.js.coffee b/app/assets/javascripts/blob.js.coffee index 03e280f897..584f6faea1 100644 --- a/app/assets/javascripts/blob.js.coffee +++ b/app/assets/javascripts/blob.js.coffee @@ -1,24 +1,76 @@ class BlobView constructor: -> + # handle multi-line select + handleMultiSelect = (e) -> + [ first_line, last_line ] = parseSelectedLines() + [ line_number ] = parseSelectedLines($(this).attr("id")) + hash = "L#{line_number}" + + if e.shiftKey and not isNaN(first_line) and not isNaN(line_number) + if line_number < first_line + last_line = first_line + first_line = line_number + else + last_line = line_number + + hash = if first_line == last_line then "L#{first_line}" else "L#{first_line}-#{last_line}" + + setHash(hash) + e.preventDefault() + # See if there are lines selected # "#L12" and "#L34-56" supported - highlightBlobLines = -> - if window.location.hash isnt "" - matches = window.location.hash.match(/\#L(\d+)(\-(\d+))?/) + highlightBlobLines = (e) -> + [ first_line, last_line ] = parseSelectedLines() + + unless isNaN first_line + $("#tree-content-holder .highlight .line").removeClass("hll") + $("#LC#{line}").addClass("hll") for line in [first_line..last_line] + $("#L#{first_line}").ScrollTo() unless e? + + # parse selected lines from hash + # always return first and last line (initialized to NaN) + parseSelectedLines = (str) -> + first_line = NaN + last_line = NaN + hash = str || window.location.hash + + if hash isnt "" + matches = hash.match(/\#?L(\d+)(\-(\d+))?/) first_line = parseInt(matches?[1]) last_line = parseInt(matches?[3]) + last_line = first_line if isNaN(last_line) - unless isNaN first_line - last_line = first_line if isNaN(last_line) - $("#tree-content-holder .highlight .line").removeClass("hll") - $("#LC#{line}").addClass("hll") for line in [first_line..last_line] - $("#L#{first_line}").ScrollTo() + [ first_line, last_line ] + + setHash = (hash) -> + hash = hash.replace(/^\#/, "") + nodes = $("#" + hash) + # if any nodes are using this id, they must be temporarily changed + # also, add a temporary div at the top of the screen to prevent scrolling + if nodes.length > 0 + scroll_top = $(document).scrollTop() + nodes.attr("id", "") + tmp = $("
") + .css({ position: "absolute", visibility: "hidden", top: scroll_top + "px" }) + .attr("id", hash) + .appendTo(document.body) + + window.location.hash = hash + + # restore the nodes + if nodes.length > 0 + tmp.remove() + nodes.attr("id", hash) + + # initialize multi-line select + $("#tree-content-holder .line-numbers a[id^=L]").on("click", handleMultiSelect) # Highlight the correct lines on load highlightBlobLines() # Highlight the correct lines when the hash part of the URL changes - $(window).on 'hashchange', highlightBlobLines + $(window).on("hashchange", highlightBlobLines) @BlobView = BlobView diff --git a/app/assets/javascripts/branch-graph.js.coffee b/app/assets/javascripts/branch-graph.js.coffee index 318538509a..f6d57bd55b 100644 --- a/app/assets/javascripts/branch-graph.js.coffee +++ b/app/assets/javascripts/branch-graph.js.coffee @@ -194,11 +194,14 @@ class BranchGraph fill: @colors[commit.space] stroke: "none" ) - r.rect(@offsetX + @unitSpace * @mspace + 10, y - 10, 20, 20).attr( - fill: "url(#{commit.author.icon})" + + avatar_box_x = @offsetX + @unitSpace * @mspace + 10 + avatar_box_y = y - 10 + r.rect(avatar_box_x, avatar_box_y, 20, 20).attr( stroke: @colors[commit.space] "stroke-width": 2 ) + r.image(gon.relative_url_root + commit.author.icon, avatar_box_x, avatar_box_y, 20, 20) r.text(@offsetX + @unitSpace * @mspace + 35, y, commit.message.split("\n")[0]).attr( "text-anchor": "start" font: "14px Monaco, monospace" @@ -271,7 +274,7 @@ class BranchGraph Raphael::commitTooltip = (x, y, commit) -> boxWidth = 300 boxHeight = 200 - icon = @image(commit.author.icon, x, y, 20, 20) + icon = @image(gon.relative_url_root + commit.author.icon, x, y, 20, 20) nameText = @text(x + 25, y + 10, commit.author.name) idText = @text(x, y + 35, commit.id) messageText = @text(x, y + 50, commit.message) diff --git a/app/assets/javascripts/commit.js.coffee b/app/assets/javascripts/commit.js.coffee index 9f55a1e636..5f53439ca4 100644 --- a/app/assets/javascripts/commit.js.coffee +++ b/app/assets/javascripts/commit.js.coffee @@ -1,6 +1,6 @@ class Commit constructor: -> - $('.files .file').each -> + $('.files .diff-file').each -> new CommitFile(this) @Commit = Commit diff --git a/app/assets/javascripts/commit/file.js.coffee b/app/assets/javascripts/commit/file.js.coffee index a45ee58d1b..4db9116a9d 100644 --- a/app/assets/javascripts/commit/file.js.coffee +++ b/app/assets/javascripts/commit/file.js.coffee @@ -1,7 +1,7 @@ class CommitFile - + constructor: (file) -> if $('.image', file).length new ImageFile(file) - -this.CommitFile = CommitFile \ No newline at end of file + +@CommitFile = CommitFile diff --git a/app/assets/javascripts/commit/image-file.js.coffee b/app/assets/javascripts/commit/image-file.js.coffee index f901a9e28f..607b85eb45 100644 --- a/app/assets/javascripts/commit/image-file.js.coffee +++ b/app/assets/javascripts/commit/image-file.js.coffee @@ -125,4 +125,4 @@ class ImageFile img.on 'load', => callback.call(this, domImg.naturalWidth, domImg.naturalHeight) -this.ImageFile = ImageFile \ No newline at end of file +@ImageFile = ImageFile diff --git a/app/assets/javascripts/commits.js.coffee b/app/assets/javascripts/commits.js.coffee index de4c06a272..9c004c997e 100644 --- a/app/assets/javascripts/commits.js.coffee +++ b/app/assets/javascripts/commits.js.coffee @@ -4,13 +4,13 @@ class CommitsList limit: 0 offset: 0 @disable = false - + @showProgress: -> $('.loading').show() - + @hideProgress: -> $('.loading').hide() - + @init: (ref, limit) -> $(".day-commits-table li.commit").live 'click', (event) -> if event.target.nodeName != "A" @@ -21,7 +21,7 @@ class CommitsList @data.ref = ref @data.limit = limit @data.offset = limit - + this.initLoadMore() this.showProgress() @@ -32,7 +32,9 @@ class CommitsList url: location.href data: @data complete: this.hideProgress - dataType: "script" + success: (data) -> + CommitsList.append(data.count, data.html) + dataType: "json" @append: (count, html) -> $("#commits-list").append(html) @@ -40,7 +42,7 @@ class CommitsList @data.offset += count else @disable = true - + @initLoadMore: -> $(document).unbind('scroll') $(document).endlessScroll diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee index e264e28130..b61d9875e0 100644 --- a/app/assets/javascripts/dispatcher.js.coffee +++ b/app/assets/javascripts/dispatcher.js.coffee @@ -4,6 +4,7 @@ $ -> class Dispatcher constructor: () -> @initSearch() + @initHighlight() @initPageScripts() initPageScripts: -> @@ -18,6 +19,8 @@ class Dispatcher switch page when 'projects:issues:index' Issues.init() + when 'projects:issues:show' + new Issue() when 'projects:issues:new', 'projects:merge_requests:new' GitLab.GfmAutoComplete.setup() when 'dashboard:show' @@ -47,5 +50,16 @@ class Dispatcher initSearch: -> - autocomplete_json = $('.search-autocomplete-json').data('autocomplete-opts') - new SearchAutocomplete(autocomplete_json) + opts = $('.search-autocomplete-opts') + path = opts.data('autocomplete-path') + project_id = opts.data('autocomplete-project-id') + project_ref = opts.data('autocomplete-project-ref') + + new SearchAutocomplete(path, project_id, project_ref) + + initHighlight: -> + $('.highlight pre code').each (i, e) -> + $(e).html($.map($(e).html().split("\n"), (line, i) -> + "" + line + "" + ).join("\n")) + hljs.highlightBlock(e) diff --git a/app/assets/javascripts/gfm_auto_complete.js.coffee b/app/assets/javascripts/gfm_auto_complete.js.coffee index 77091da8f6..00d56ae5b4 100644 --- a/app/assets/javascripts/gfm_auto_complete.js.coffee +++ b/app/assets/javascripts/gfm_auto_complete.js.coffee @@ -6,13 +6,13 @@ GitLab.GfmAutoComplete = dataSource: '' # Emoji Emoji: - assetBase: '' template: '
  • ${name} ${name}
  • ' # Team Members Members: template: '
  • ${username} ${name}
  • ' + # Issues and MergeRequests Issues: template: '
  • ${id} ${title}
  • ' @@ -26,7 +26,7 @@ GitLab.GfmAutoComplete = tpl: @Emoji.template callbacks: before_save: (emojis) => - $.map emojis, (em) => name: em, insert: em+ ':', image: "#{@Emoji.assetBase}/#{em}.png" + $.map emojis, (em) => name: em.name, insert: em.name+ ':', image: em.path # Team Members input.atwho @@ -46,11 +46,22 @@ GitLab.GfmAutoComplete = before_save: (issues) -> $.map issues, (i) -> id: i.iid, title: sanitize(i.title), search: "#{i.iid} #{i.title}" + input.atwho + at: '!' + alias: 'mergerequests' + search_key: 'search' + tpl: @Issues.template + callbacks: + before_save: (merges) -> + $.map merges, (m) -> id: m.iid, title: sanitize(m.title), search: "#{m.iid} #{m.title}" + input.one "focus", => $.getJSON(@dataSource).done (data) -> # load members input.atwho 'load', "@", data.members # load issues input.atwho 'load', "issues", data.issues + # load merge requests + input.atwho 'load', "mergerequests", data.mergerequests # load emojis input.atwho 'load', ":", data.emojis diff --git a/app/assets/javascripts/groups.js.coffee b/app/assets/javascripts/groups.js.coffee index c0ffccd8f7..7850eb14e7 100644 --- a/app/assets/javascripts/groups.js.coffee +++ b/app/assets/javascripts/groups.js.coffee @@ -4,3 +4,14 @@ class GroupMembers $(this).fadeOut() @GroupMembers = GroupMembers + +$ -> + # avatar + $('.js-choose-group-avatar-button').bind "click", -> + form = $(this).closest("form") + form.find(".js-group-avatar-input").click() + + $('.js-group-avatar-input').bind "change", -> + form = $(this).closest("form") + filename = $(this).val().replace(/^.*[\\\/]/, '') + form.find(".js-avatar-filename").text(filename) \ No newline at end of file diff --git a/app/assets/javascripts/issue.js.coffee b/app/assets/javascripts/issue.js.coffee new file mode 100644 index 0000000000..36935a0a15 --- /dev/null +++ b/app/assets/javascripts/issue.js.coffee @@ -0,0 +1,9 @@ +class Issue + constructor: -> + $('.edit-issue.inline-update input[type="submit"]').hide() + $(".issue-box .inline-update").on "change", "select", -> + $(this).submit() + $(".issue-box .inline-update").on "change", "#issue_assignee_id", -> + $(this).submit() + +@Issue = Issue diff --git a/app/assets/javascripts/issues.js.coffee b/app/assets/javascripts/issues.js.coffee index 67d9498c50..e2f1bc743f 100644 --- a/app/assets/javascripts/issues.js.coffee +++ b/app/assets/javascripts/issues.js.coffee @@ -22,19 +22,17 @@ backgroundColor: '#DDD' opacity: .4 ) - + reload: -> Issues.initSelects() Issues.initChecks() $('#filter_issue_search').val($('#issue_search').val()) initSelects: -> - $("#update_status").chosen() - $("#update_assignee_id").chosen() - $("#update_milestone_id").chosen() - $("#label_name").chosen() - $("#assignee_id").chosen() - $("#milestone_id").chosen() + $("select#update_status").select2(width: 'resolve', dropdownAutoWidth: true) + $("select#update_assignee_id").select2(width: 'resolve', dropdownAutoWidth: true) + $("select#update_milestone_id").select2(width: 'resolve', dropdownAutoWidth: true) + $("select#label_name").select2(width: 'resolve', dropdownAutoWidth: true) $("#milestone_id, #assignee_id, #label_name").on "change", -> $(this).closest("form").submit() @@ -54,7 +52,16 @@ unless terms is last_terms last_terms = terms if terms.length >= 2 or terms.length is 0 - form.submit() + $.ajax + type: "GET" + url: location.href + data: "issue_search=" + terms + complete: -> + $(".loading").hide() + success: (data) -> + $('.issues-holder').html(data.html) + Issues.reload() + dataType: "json" checkChanged: -> checked_issues = $(".selected_issue:checked") diff --git a/app/assets/javascripts/merge_request.js.coffee b/app/assets/javascripts/merge_request.js.coffee new file mode 100644 index 0000000000..7589fc70cd --- /dev/null +++ b/app/assets/javascripts/merge_request.js.coffee @@ -0,0 +1,129 @@ +class MergeRequest + constructor: (@opts) -> + @initContextWidget() + this.$el = $('.merge-request') + @diffs_loaded = if @opts.action == 'diffs' then true else false + @commits_loaded = false + + this.activateTab(@opts.action) + + this.bindEvents() + + this.initMergeWidget() + this.$('.show-all-commits').on 'click', => + this.showAllCommits() + + modal = $('#modal_merge_info').modal(show: false) + + disableButtonIfEmptyField '#merge_commit_message', '.accept_merge_request' + + + # Local jQuery finder + $: (selector) -> + this.$el.find(selector) + + initContextWidget: -> + $('.edit-merge_request.inline-update input[type="submit"]').hide() + $(".issue-box .inline-update").on "change", "select", -> + $(this).submit() + $(".issue-box .inline-update").on "change", "#merge_request_assignee_id", -> + $(this).submit() + + initMergeWidget: -> + this.showState( @opts.current_status ) + + if this.$('.automerge_widget').length and @opts.check_enable + $.get @opts.url_to_automerge_check, (data) => + this.showState( data.merge_status ) + , 'json' + + if @opts.ci_enable + $.get @opts.url_to_ci_check, (data) => + this.showCiState data.status + , 'json' + + bindEvents: -> + this.$('.nav-tabs').on 'click', 'a', (event) => + a = $(event.currentTarget) + + href = a.attr('href') + History.replaceState {path: href}, document.title, href + + event.preventDefault() + + this.$('.nav-tabs').on 'click', 'li', (event) => + this.activateTab($(event.currentTarget).data('action')) + + this.$('.accept_merge_request').on 'click', -> + $('.automerge_widget.can_be_merged').hide() + $('.merge-in-progress').show() + + this.$('.remove_source_branch').on 'click', -> + $('.remove_source_branch_widget').hide() + $('.remove_source_branch_in_progress').show() + + this.$(".remove_source_branch").on "ajax:success", (e, data, status, xhr) -> + location.reload() + + this.$(".remove_source_branch").on "ajax:error", (e, data, status, xhr) => + this.$('.remove_source_branch_widget').hide() + this.$('.remove_source_branch_in_progress').hide() + this.$('.remove_source_branch_widget.failed').show() + + activateTab: (action) -> + this.$('.nav-tabs li').removeClass 'active' + this.$('.tab-content').hide() + switch action + when 'diffs' + this.$('.nav-tabs .diffs-tab').addClass 'active' + this.loadDiff() unless @diffs_loaded + this.$('.diffs').show() + else + this.$('.nav-tabs .notes-tab').addClass 'active' + this.$('.notes').show() + + showState: (state) -> + $('.automerge_widget').hide() + $('.automerge_widget.' + state).show() + + showCiState: (state) -> + $('.ci_widget').hide() + allowed_states = ["failed", "running", "pending", "success"] + if state in allowed_states + $('.ci_widget.ci-' + state).show() + else + $('.ci_widget.ci-error').show() + + switch state + when "success" + $('.mr-state-widget').addClass("panel-success") + when "failed" + $('.mr-state-widget').addClass("panel-danger") + when "running", "pending" + $('.mr-state-widget').addClass("panel-warning") + + + + loadDiff: (event) -> + $.ajax + type: 'GET' + url: this.$('.nav-tabs .diffs-tab a').attr('href') + beforeSend: => + this.$('.status').addClass 'loading' + complete: => + @diffs_loaded = true + this.$('.status').removeClass 'loading' + success: (data) => + this.$(".diffs").html(data.html) + dataType: 'json' + + showAllCommits: -> + this.$('.first-commits').remove() + this.$('.all-commits').removeClass 'hide' + + alreadyOrCannotBeMerged: -> + this.$('.automerge_widget').hide() + this.$('.merge-in-progress').hide() + this.$('.automerge_widget.already_cannot_be_merged').show() + +this.MergeRequest = MergeRequest diff --git a/app/assets/javascripts/merge_requests.js.coffee b/app/assets/javascripts/merge_requests.js.coffee index 5400bc5c1a..9201c84c5e 100644 --- a/app/assets/javascripts/merge_requests.js.coffee +++ b/app/assets/javascripts/merge_requests.js.coffee @@ -2,101 +2,7 @@ # * Filter merge requests # @merge_requestsPage = -> - $('#assignee_id').chosen() - $('#milestone_id').chosen() + $('#assignee_id').select2() + $('#milestone_id').select2() $('#milestone_id, #assignee_id').on 'change', -> $(this).closest('form').submit() - -class MergeRequest - - constructor: (@opts) -> - this.$el = $('.merge-request') - @diffs_loaded = if @opts.action == 'diffs' then true else false - @commits_loaded = false - - this.activateTab(@opts.action) - - this.bindEvents() - - this.initMergeWidget() - this.$('.show-all-commits').on 'click', => - this.showAllCommits() - - modal = $('#modal_merge_info').modal(show: false) - - # Local jQuery finder - $: (selector) -> - this.$el.find(selector) - - initMergeWidget: -> - this.showState( @opts.current_status ) - - if this.$('.automerge_widget').length and @opts.check_enable - $.get @opts.url_to_automerge_check, (data) => - this.showState( data.merge_status ) - , 'json' - - if @opts.ci_enable - $.get @opts.url_to_ci_check, (data) => - this.showCiState data.status - , 'json' - - bindEvents: -> - this.$('.nav-tabs').on 'click', 'a', (event) => - a = $(event.currentTarget) - - href = a.attr('href') - History.replaceState {path: href}, document.title, href - - event.preventDefault() - - this.$('.nav-tabs').on 'click', 'li', (event) => - this.activateTab($(event.currentTarget).data('action')) - - this.$('.accept_merge_request').on 'click', -> - $('.automerge_widget.can_be_merged').hide() - $('.merge-in-progress').show() - - activateTab: (action) -> - this.$('.nav-tabs li').removeClass 'active' - this.$('.tab-content').hide() - switch action - when 'diffs' - this.$('.nav-tabs .diffs-tab').addClass 'active' - this.loadDiff() unless @diffs_loaded - this.$('.diffs').show() - else - this.$('.nav-tabs .notes-tab').addClass 'active' - this.$('.notes').show() - - showState: (state) -> - $('.automerge_widget').hide() - $('.automerge_widget.' + state).show() - - showCiState: (state) -> - $('.ci_widget').hide() - $('.ci_widget.ci-' + state).show() - - loadDiff: (event) -> - $.ajax - type: 'GET' - url: this.$('.nav-tabs .diffs-tab a').attr('href') - beforeSend: => - this.$('.status').addClass 'loading' - - complete: => - @diffs_loaded = true - this.$('.status').removeClass 'loading' - - dataType: 'script' - - showAllCommits: -> - this.$('.first-commits').remove() - this.$('.all-commits').removeClass 'hide' - - alreadyOrCannotBeMerged: -> - this.$('.automerge_widget').hide() - this.$('.merge-in-progress').hide() - this.$('.automerge_widget.already_cannot_be_merged').show() - -this.MergeRequest = MergeRequest diff --git a/app/assets/javascripts/namespace_select.js.coffee b/app/assets/javascripts/namespace_select.js.coffee new file mode 100644 index 0000000000..00d135d144 --- /dev/null +++ b/app/assets/javascripts/namespace_select.js.coffee @@ -0,0 +1,24 @@ +$ -> + namespaceFormatResult = (namespace) -> + markup = "
    " + markup += "" + namespace.kind + "" + markup += "" + namespace.path + "" + markup += "
    " + markup + + formatSelection = (namespace) -> + namespace.kind + ": " + namespace.path + + $('.ajax-namespace-select').each (i, select) -> + $(select).select2 + placeholder: "Search for namespace" + multiple: $(select).hasClass('multiselect') + minimumInputLength: 0 + query: (query) -> + Api.namespaces query.term, (namespaces) -> + data = { results: namespaces } + query.callback(data) + + dropdownCssClass: "ajax-namespace-dropdown" + formatResult: namespaceFormatResult + formatSelection: formatSelection diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js deleted file mode 100644 index 5225623c1f..0000000000 --- a/app/assets/javascripts/notes.js +++ /dev/null @@ -1,580 +0,0 @@ -var NoteList = { - id: null, - notes_path: null, - target_params: null, - target_id: 0, - target_type: null, - - init: function(tid, tt, path) { - NoteList.notes_path = path + ".js"; - NoteList.target_id = tid; - NoteList.target_type = tt; - NoteList.target_params = "target_type=" + NoteList.target_type + "&target_id=" + NoteList.target_id; - - NoteList.setupMainTargetNoteForm(); - - // get initial set of notes - NoteList.getContent(); - - // Unbind events to prevent firing twice - $(document).off("click", ".js-add-diff-note-button"); - $(document).off("click", ".js-discussion-reply-button"); - $(document).off("click", ".js-note-preview-button"); - $(document).off("click", ".js-note-attachment-input"); - $(document).off("click", ".js-close-discussion-note-form"); - $(document).off("click", ".js-note-delete"); - $(document).off("click", ".js-note-edit"); - $(document).off("click", ".js-note-edit-cancel"); - $(document).off("click", ".js-note-attachment-delete"); - $(document).off("click", ".js-choose-note-attachment-button"); - $(document).off("click", ".js-show-outdated-discussion"); - - $(document).off("ajax:complete", ".js-main-target-form"); - - - // add a new diff note - $(document).on("click", - ".js-add-diff-note-button", - NoteList.addDiffNote); - - // reply to diff/discussion notes - $(document).on("click", - ".js-discussion-reply-button", - NoteList.replyToDiscussionNote); - - // setup note preview - $(document).on("click", - ".js-note-preview-button", - NoteList.previewNote); - - // update the file name when an attachment is selected - $(document).on("change", - ".js-note-attachment-input", - NoteList.updateFormAttachment); - - // hide diff note form - $(document).on("click", - ".js-close-discussion-note-form", - NoteList.removeDiscussionNoteForm); - - // remove a note (in general) - $(document).on("click", - ".js-note-delete", - NoteList.removeNote); - - // show the edit note form - $(document).on("click", - ".js-note-edit", - NoteList.showEditNoteForm); - - // cancel note editing - $(document).on("click", - ".note-edit-cancel", - NoteList.cancelNoteEdit); - - // delete note attachment - $(document).on("click", - ".js-note-attachment-delete", - NoteList.deleteNoteAttachment); - - // update the note after editing - $(document).on("ajax:complete", - "form.edit_note", - NoteList.updateNote); - - // reset main target form after submit - $(document).on("ajax:complete", - ".js-main-target-form", - NoteList.resetMainTargetForm); - - - $(document).on("click", - ".js-choose-note-attachment-button", - NoteList.chooseNoteAttachment); - - $(document).on("click", - ".js-show-outdated-discussion", - function(e) { $(this).next('.outdated-discussion').show(); e.preventDefault() }); - }, - - - /** - * When clicking on buttons - */ - - /** - * Called when clicking on the "add a comment" button on the side of a diff line. - * - * Inserts a temporary row for the form below the line. - * Sets up the form and shows it. - */ - addDiffNote: function(e) { - e.preventDefault(); - - // find the form - var form = $(".js-new-note-form"); - var row = $(this).closest("tr"); - var nextRow = row.next(); - - // does it already have notes? - if (nextRow.is(".notes_holder")) { - $.proxy(NoteList.replyToDiscussionNote, - nextRow.find(".js-discussion-reply-button") - ).call(); - } else { - // add a notes row and insert the form - row.after(''); - form.clone().appendTo(row.next().find(".notes_content")); - - // show the form - NoteList.setupDiscussionNoteForm($(this), row.next().find("form")); - } - }, - - /** - * Called when clicking the "Choose File" button. - * - * Opens the file selection dialog. - */ - chooseNoteAttachment: function() { - var form = $(this).closest("form"); - - form.find(".js-note-attachment-input").click(); - }, - - /** - * Shows the note preview. - * - * Lets the server render GFM into Html and displays it. - * - * Note: uses the Toggler behavior to toggle preview/edit views/buttons - */ - previewNote: function(e) { - e.preventDefault(); - - var form = $(this).closest("form"); - var preview = form.find('.js-note-preview'); - var noteText = form.find('.js-note-text').val(); - - if(noteText.trim().length === 0) { - preview.text('Nothing to preview.'); - } else { - preview.text('Loading...'); - $.post($(this).data('url'), {note: noteText}) - .success(function(previewData) { - preview.html(previewData); - }); - } - }, - - /** - * Called in response to "cancel" on a diff note form. - * - * Shows the reply button again. - * Removes the form and if necessary it's temporary row. - */ - removeDiscussionNoteForm: function() { - var form = $(this).closest("form"); - var row = form.closest("tr"); - - // show the reply button (will only work for replies) - form.prev(".js-discussion-reply-button").show(); - - if (row.is(".js-temp-notes-holder")) { - // remove temporary row for diff lines - row.remove(); - } else { - // only remove the form - form.remove(); - } - }, - - /** - * Called in response to deleting a note of any kind. - * - * Removes the actual note from view. - * Removes the whole discussion if the last note is being removed. - */ - removeNote: function() { - var note = $(this).closest(".note"); - var notes = note.closest(".notes"); - - // check if this is the last note for this line - if (notes.find(".note").length === 1) { - // for discussions - notes.closest(".discussion").remove(); - - // for diff lines - notes.closest("tr").remove(); - } - - note.remove(); - NoteList.updateVotes(); - }, - - /** - * Called in response to clicking the edit note link - * - * Replaces the note text with the note edit form - * Adds a hidden div with the original content of the note to fill the edit note form with - * if the user cancels - */ - showEditNoteForm: function(e) { - e.preventDefault(); - var note = $(this).closest(".note"); - note.find(".note-text").hide(); - - // Show the attachment delete link - note.find(".js-note-attachment-delete").show(); - - GitLab.GfmAutoComplete.setup(); - - var form = note.find(".note-edit-form"); - form.show(); - - var textarea = form.find("textarea"); - var p = $("

    ").text(textarea.val()); - var hidden_div = $('
    ').append(p); - form.append(hidden_div); - hidden_div.hide(); - textarea.focus(); - }, - - /** - * Called in response to clicking the cancel button when editing a note - * - * Resets and hides the note editing form - */ - cancelNoteEdit: function(e) { - e.preventDefault(); - var note = $(this).closest(".note"); - NoteList.resetNoteEditing(note); - }, - - - /** - * Called in response to clicking the delete attachment link - * - * Removes the attachment wrapper view, including image tag if it exists - * Resets the note editing form - */ - deleteNoteAttachment: function() { - var note = $(this).closest(".note"); - note.find(".note-attachment").remove(); - NoteList.resetNoteEditing(note); - NoteList.rewriteTimestamp(note.find(".note-last-update")); - }, - - - /** - * Called when clicking on the "reply" button for a diff line. - * - * Shows the note form below the notes. - */ - replyToDiscussionNote: function() { - // find the form - var form = $(".js-new-note-form"); - - // hide reply button - $(this).hide(); - // insert the form after the button - form.clone().insertAfter($(this)); - - // show the form - NoteList.setupDiscussionNoteForm($(this), $(this).next("form")); - }, - - - /** - * Helper for inserting and setting up note forms. - */ - - - /** - * Called in response to creating a note failing validation. - * - * Adds the rendered errors to the respective form. - * If "discussionId" is null or undefined, the main target form is assumed. - */ - errorsOnForm: function(errorsHtml, discussionId) { - // find the form - if (discussionId) { - var form = $("form[rel='"+discussionId+"']"); - } else { - var form = $(".js-main-target-form"); - } - - form.find(".js-errors").remove(); - form.prepend(errorsHtml); - - form.find(".js-note-text").focus(); - }, - - - /** - * Shows the diff/discussion form and does some setup on it. - * - * Sets some hidden fields in the form. - * - * Note: dataHolder must have the "discussionId", "lineCode", "noteableType" - * and "noteableId" data attributes set. - */ - setupDiscussionNoteForm: function(dataHolder, form) { - // setup note target - form.attr("rel", dataHolder.data("discussionId")); - form.find("#note_commit_id").val(dataHolder.data("commitId")); - form.find("#note_line_code").val(dataHolder.data("lineCode")); - form.find("#note_noteable_type").val(dataHolder.data("noteableType")); - form.find("#note_noteable_id").val(dataHolder.data("noteableId")); - - NoteList.setupNoteForm(form); - - form.find(".js-note-text").focus(); - }, - - /** - * Shows the main form and does some setup on it. - * - * Sets some hidden fields in the form. - */ - setupMainTargetNoteForm: function() { - // find the form - var form = $(".js-new-note-form"); - // insert the form after the button - form.clone().replaceAll($(".js-main-target-form")); - - form = form.prev("form"); - - // show the form - NoteList.setupNoteForm(form); - - // fix classes - form.removeClass("js-new-note-form"); - form.addClass("js-main-target-form"); - - // remove unnecessary fields and buttons - form.find("#note_line_code").remove(); - form.find(".js-close-discussion-note-form").remove(); - }, - - /** - * General note form setup. - * - * * deactivates the submit button when text is empty - * * hides the preview button when text is empty - * * setup GFM auto complete - * * show the form - */ - setupNoteForm: function(form) { - disableButtonIfEmptyField(form.find(".js-note-text"), form.find(".js-comment-button")); - - form.removeClass("js-new-note-form"); - - // setup preview buttons - form.find(".js-note-edit-button, .js-note-preview-button") - .tooltip({ placement: 'left' }); - - previewButton = form.find(".js-note-preview-button"); - form.find(".js-note-text").on("input", function() { - if ($(this).val().trim() !== "") { - previewButton.removeClass("turn-off").addClass("turn-on"); - } else { - previewButton.removeClass("turn-on").addClass("turn-off"); - } - }); - - // remove notify commit author checkbox for non-commit notes - if (form.find("#note_noteable_type").val() !== "Commit") { - form.find(".js-notify-commit-author").remove(); - } - - GitLab.GfmAutoComplete.setup(); - - form.show(); - }, - - - /** - * Handle loading the initial set of notes. - * And set up loading more notes when scrolling to the bottom of the page. - */ - - - /** - * Gets an initial set of notes. - */ - getContent: function() { - $.ajax({ - url: NoteList.notes_path, - data: NoteList.target_params, - complete: function(){ $('.js-notes-busy').removeClass("loading")}, - beforeSend: function() { $('.js-notes-busy').addClass("loading") }, - dataType: "script" - }); - }, - - /** - * Called in response to getContent(). - * Replaces the content of #notes-list with the given html. - */ - setContent: function(newNoteIds, html) { - $("#notes-list").html(html); - }, - - - /** - * Adds a single common note to #notes-list. - */ - appendNewNote: function(id, html) { - $("#notes-list").append(html); - NoteList.updateVotes(); - }, - - /** - * Adds a single discussion note to #notes-list. - * - * Also removes the corresponding form. - */ - appendNewDiscussionNote: function(discussionId, diffRowHtml, noteHtml) { - var form = $("form[rel='"+discussionId+"']"); - var row = form.closest("tr"); - - // is this the first note of discussion? - if (row.is(".js-temp-notes-holder")) { - // insert the note and the reply button after the temp row - row.after(diffRowHtml); - // remove the note (will be added again below) - row.next().find(".note").remove(); - } - - // append new note to all matching discussions - $(".notes[rel='"+discussionId+"']").append(noteHtml); - - // cleanup after successfully creating a diff/discussion note - $.proxy(NoteList.removeDiscussionNoteForm, form).call(); - }, - - /** - * Called in response the main target form has been successfully submitted. - * - * Removes any errors. - * Resets text and preview. - * Resets buttons. - */ - resetMainTargetForm: function(){ - var form = $(this); - - // remove validation errors - form.find(".js-errors").remove(); - - // reset text and preview - var previewContainer = form.find(".js-toggler-container.note_text_and_preview"); - if (previewContainer.is(".on")) { - previewContainer.removeClass("on"); - } - form.find(".js-note-text").val("").trigger("input"); - }, - - /** - * Called after an attachment file has been selected. - * - * Updates the file name for the selected attachment. - */ - updateFormAttachment: function() { - var form = $(this).closest("form"); - - // get only the basename - var filename = $(this).val().replace(/^.*[\\\/]/, ''); - - form.find(".js-attachment-filename").text(filename); - }, - - /** - * Recalculates the votes and updates them (if they are displayed at all). - * - * Assumes all relevant notes are displayed (i.e. there are no more notes to - * load via getMore()). - * Might produce inaccurate results when not all notes have been loaded and a - * recalculation is triggered (e.g. when deleting a note). - */ - updateVotes: function() { - var votes = $("#votes .votes"); - var notes = $("#notes-list .note .vote"); - - // only update if there is a vote display - if (votes.size()) { - var upvotes = notes.filter(".upvote").size(); - var downvotes = notes.filter(".downvote").size(); - var votesCount = upvotes + downvotes; - var upvotesPercent = votesCount ? (100.0 / votesCount * upvotes) : 0; - var downvotesPercent = votesCount ? (100.0 - upvotesPercent) : 0; - - // change vote bar lengths - votes.find(".bar-success").css("width", upvotesPercent+"%"); - votes.find(".bar-danger").css("width", downvotesPercent+"%"); - // replace vote numbers - votes.find(".upvotes").text(votes.find(".upvotes").text().replace(/\d+/, upvotes)); - votes.find(".downvotes").text(votes.find(".downvotes").text().replace(/\d+/, downvotes)); - } - }, - - /** - * Called in response to the edit note form being submitted - * - * Updates the current note field. - * Hides the edit note form - */ - updateNote: function(e, xhr, settings) { - response = JSON.parse(xhr.responseText); - if (response.success) { - var note_li = $("#note_" + response.id); - var note_text = note_li.find(".note-text"); - note_text.html(response.note).show(); - - var note_form = note_li.find(".note-edit-form"); - note_form.hide(); - note_form.find(".btn-save").enableButton(); - - // Update the "Edited at xxx label" on the note to show it's just been updated - NoteList.rewriteTimestamp(note_li.find(".note-last-update")); - } - }, - - /** - * Called in response to the 'cancel note' link clicked, or after deleting a note attachment - * - * Hides the edit note form and shows the note - * Resets the edit note form textarea with the original content of the note - */ - resetNoteEditing: function(note) { - note.find(".note-text").show(); - - // Hide the attachment delete link - note.find(".js-note-attachment-delete").hide(); - - // Put the original content of the note back into the edit form textarea - var form = note.find(".note-edit-form"); - var original_content = form.find(".note-original-content"); - form.find("textarea").val(original_content.text()); - original_content.remove(); - - note.find(".note-edit-form").hide(); - }, - - /** - * Utility function to generate new timestamp text for a note - * - */ - rewriteTimestamp: function(element) { - // Strip all newlines from the existing timestamp - var ts = element.text().replace(/\n/g, ' ').trim(); - - // If the timestamp already has '(Edited xxx ago)' text, remove it - ts = ts.replace(new RegExp("\\(Edited [A-Za-z0-9 ]+\\)$", "gi"), ""); - - // Append "(Edited just now)" - ts = (ts + " (Edited just now)"); - - element.html(ts); - } -}; diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee new file mode 100644 index 0000000000..4510718c2f --- /dev/null +++ b/app/assets/javascripts/notes.js.coffee @@ -0,0 +1,473 @@ +class Notes + @interval: null + + constructor: (notes_url, note_ids, last_fetched_at) -> + @notes_url = notes_url + @notes_url = gon.relative_url_root + @notes_url if gon.relative_url_root? + @note_ids = note_ids + @last_fetched_at = last_fetched_at + @initRefresh() + @setupMainTargetNoteForm() + @cleanBinding() + @addBinding() + + addBinding: -> + # add note to UI after creation + $(document).on "ajax:success", ".js-main-target-form", @addNote + $(document).on "ajax:success", ".js-discussion-note-form", @addDiscussionNote + + # change note in UI after update + $(document).on "ajax:success", "form.edit_note", @updateNote + + # Edit note link + $(document).on "click", ".js-note-edit", @showEditForm + $(document).on "click", ".note-edit-cancel", @cancelEdit + + # remove a note (in general) + $(document).on "click", ".js-note-delete", @removeNote + + # delete note attachment + $(document).on "click", ".js-note-attachment-delete", @removeAttachment + + # Preview button + $(document).on "click", ".js-note-preview-button", @previewNote + + # reset main target form after submit + $(document).on "ajax:complete", ".js-main-target-form", @resetMainTargetForm + + # attachment button + $(document).on "click", ".js-choose-note-attachment-button", @chooseNoteAttachment + + # update the file name when an attachment is selected + $(document).on "change", ".js-note-attachment-input", @updateFormAttachment + + # reply to diff/discussion notes + $(document).on "click", ".js-discussion-reply-button", @replyToDiscussionNote + + # add diff note + $(document).on "click", ".js-add-diff-note-button", @addDiffNote + + # hide diff note form + $(document).on "click", ".js-close-discussion-note-form", @cancelDiscussionForm + + # fetch notes when tab becomes visible + $(document).on "visibilitychange", @visibilityChange + + @notes_forms = '.js-main-target-form textarea, .js-discussion-note-form textarea' + $(document).on('keypress', @notes_forms, (e)-> + if e.keyCode == 10 || (e.ctrlKey && e.keyCode == 13) + $(@).parents('form').submit() + ) + + cleanBinding: -> + $(document).off "ajax:success", ".js-main-target-form" + $(document).off "ajax:success", ".js-discussion-note-form" + $(document).off "ajax:success", "form.edit_note" + $(document).off "click", ".js-note-edit" + $(document).off "click", ".note-edit-cancel" + $(document).off "click", ".js-note-delete" + $(document).off "click", ".js-note-attachment-delete" + $(document).off "click", ".js-note-preview-button" + $(document).off "ajax:complete", ".js-main-target-form" + $(document).off "click", ".js-choose-note-attachment-button" + $(document).off "click", ".js-discussion-reply-button" + $(document).off "click", ".js-add-diff-note-button" + $(document).off "visibilitychange" + $(document).off "keypress", @notes_forms + + + initRefresh: -> + clearInterval(Notes.interval) + Notes.interval = setInterval => + @refresh() + , 15000 + + refresh: -> + @getContent() unless document.hidden + + getContent: -> + $.ajax + url: @notes_url + data: "last_fetched_at=" + @last_fetched_at + dataType: "json" + success: (data) => + notes = data.notes + @last_fetched_at = data.last_fetched_at + $.each notes, (i, note) => + @renderNote(note) + + + ### + Render note in main comments area. + + Note: for rendering inline notes use renderDiscussionNote + ### + renderNote: (note) -> + # render note if it not present in loaded list + # or skip if rendered + if @isNewNote(note) + @note_ids.push(note.id) + $('ul.main-notes-list').append(note.html) + code = "#note_" + note.id + " .highlight pre code" + $(code).each (i, e) -> + hljs.highlightBlock(e) + + + ### + Check if note does not exists on page + ### + isNewNote: (note) -> + $.inArray(note.id, @note_ids) == -1 + + + ### + Render note in discussion area. + + Note: for rendering inline notes use renderDiscussionNote + ### + renderDiscussionNote: (note) -> + @note_ids.push(note.id) + form = $("form[rel='" + note.discussion_id + "']") + row = form.closest("tr") + + # is this the first note of discussion? + if row.is(".js-temp-notes-holder") + # insert the note and the reply button after the temp row + row.after note.discussion_html + + # remove the note (will be added again below) + row.next().find(".note").remove() + + # append new note to all matching discussions + $(".notes[rel='" + note.discussion_id + "']").append note.html + + # cleanup after successfully creating a diff/discussion note + @removeDiscussionNoteForm(form) + + ### + Shows the note preview. + + Lets the server render GFM into Html and displays it. + + Note: uses the Toggler behavior to toggle preview/edit views/buttons + ### + previewNote: (e) -> + e.preventDefault() + form = $(this).closest("form") + preview = form.find(".js-note-preview") + noteText = form.find(".js-note-text").val() + if noteText.trim().length is 0 + preview.text "Nothing to preview." + else + preview.text "Loading..." + $.post($(this).data("url"), + note: noteText + ).success (previewData) -> + preview.html previewData + + ### + Called in response the main target form has been successfully submitted. + + Removes any errors. + Resets text and preview. + Resets buttons. + ### + resetMainTargetForm: -> + form = $(".js-main-target-form") + + # remove validation errors + form.find(".js-errors").remove() + + # reset text and preview + previewContainer = form.find(".js-toggler-container.note_text_and_preview") + previewContainer.removeClass "on" if previewContainer.is(".on") + form.find(".js-note-text").val("").trigger "input" + + ### + Called when clicking the "Choose File" button. + + Opens the file selection dialog. + ### + chooseNoteAttachment: -> + form = $(this).closest("form") + form.find(".js-note-attachment-input").click() + + ### + Shows the main form and does some setup on it. + + Sets some hidden fields in the form. + ### + setupMainTargetNoteForm: -> + + # find the form + form = $(".js-new-note-form") + + # insert the form after the button + form.clone().replaceAll $(".js-main-target-form") + form = form.prev("form") + + # show the form + @setupNoteForm(form) + + # fix classes + form.removeClass "js-new-note-form" + form.addClass "js-main-target-form" + + # remove unnecessary fields and buttons + form.find("#note_line_code").remove() + form.find(".js-close-discussion-note-form").remove() + + ### + General note form setup. + + deactivates the submit button when text is empty + hides the preview button when text is empty + setup GFM auto complete + show the form + ### + setupNoteForm: (form) -> + disableButtonIfEmptyField form.find(".js-note-text"), form.find(".js-comment-button") + form.removeClass "js-new-note-form" + + # setup preview buttons + form.find(".js-note-edit-button, .js-note-preview-button").tooltip placement: "left" + previewButton = form.find(".js-note-preview-button") + form.find(".js-note-text").on "input", -> + if $(this).val().trim() isnt "" + previewButton.removeClass("turn-off").addClass "turn-on" + else + previewButton.removeClass("turn-on").addClass "turn-off" + + + # remove notify commit author checkbox for non-commit notes + form.find(".js-notify-commit-author").remove() if form.find("#note_noteable_type").val() isnt "Commit" + GitLab.GfmAutoComplete.setup() + form.show() + + + ### + Called in response to the new note form being submitted + + Adds new note to list. + ### + addNote: (xhr, note, status) => + @renderNote(note) + @updateVotes() + + ### + Called in response to the new note form being submitted + + Adds new note to list. + ### + addDiscussionNote: (xhr, note, status) => + @renderDiscussionNote(note) + + ### + Called in response to the edit note form being submitted + + Updates the current note field. + ### + updateNote: (xhr, note, status) => + note_li = $("#note_" + note.id) + note_li.replaceWith(note.html) + code = "#note_" + note.id + " .highlight pre code" + $(code).each (i, e) -> + hljs.highlightBlock(e) + + ### + Called in response to clicking the edit note link + + Replaces the note text with the note edit form + Adds a hidden div with the original content of the note to fill the edit note form with + if the user cancels + ### + showEditForm: (e) -> + e.preventDefault() + note = $(this).closest(".note") + note.find(".note-text").hide() + + # Show the attachment delete link + note.find(".js-note-attachment-delete").show() + GitLab.GfmAutoComplete.setup() + form = note.find(".note-edit-form") + form.show() + form.find("textarea").focus() + + ### + Called in response to clicking the edit note link + + Hides edit form + ### + cancelEdit: (e) -> + e.preventDefault() + note = $(this).closest(".note") + note.find(".note-text").show() + note.find(".js-note-attachment-delete").hide() + note.find(".note-edit-form").hide() + + ### + Called in response to deleting a note of any kind. + + Removes the actual note from view. + Removes the whole discussion if the last note is being removed. + ### + removeNote: -> + note = $(this).closest(".note") + notes = note.closest(".notes") + + # check if this is the last note for this line + if notes.find(".note").length is 1 + + # for discussions + notes.closest(".discussion").remove() + + # for diff lines + notes.closest("tr").remove() + + note.remove() + + ### + Called in response to clicking the delete attachment link + + Removes the attachment wrapper view, including image tag if it exists + Resets the note editing form + ### + removeAttachment: -> + note = $(this).closest(".note") + note.find(".note-attachment").remove() + note.find(".note-text").show() + note.find(".js-note-attachment-delete").hide() + note.find(".note-edit-form").hide() + + ### + Called when clicking on the "reply" button for a diff line. + + Shows the note form below the notes. + ### + replyToDiscussionNote: (e) => + form = $(".js-new-note-form") + replyLink = $(e.target) + replyLink.hide() + + # insert the form after the button + form.clone().insertAfter replyLink + + # show the form + @setupDiscussionNoteForm(replyLink, replyLink.next("form")) + + ### + Shows the diff or discussion form and does some setup on it. + + Sets some hidden fields in the form. + + Note: dataHolder must have the "discussionId", "lineCode", "noteableType" + and "noteableId" data attributes set. + ### + setupDiscussionNoteForm: (dataHolder, form) => + # setup note target + form.attr "rel", dataHolder.data("discussionId") + form.find("#note_commit_id").val dataHolder.data("commitId") + form.find("#note_line_code").val dataHolder.data("lineCode") + form.find("#note_noteable_type").val dataHolder.data("noteableType") + form.find("#note_noteable_id").val dataHolder.data("noteableId") + @setupNoteForm form + form.find(".js-note-text").focus() + form.addClass "js-discussion-note-form" + + ### + General note form setup. + + deactivates the submit button when text is empty + hides the preview button when text is empty + setup GFM auto complete + show the form + ### + setupNoteForm: (form) => + disableButtonIfEmptyField form.find(".js-note-text"), form.find(".js-comment-button") + form.removeClass "js-new-note-form" + form.removeClass "js-new-note-form" + GitLab.GfmAutoComplete.setup() + + # setup preview buttons + previewButton = form.find(".js-note-preview-button") + form.find(".js-note-text").on "input", -> + if $(this).val().trim() isnt "" + previewButton.removeClass("turn-off").addClass "turn-on" + else + previewButton.removeClass("turn-on").addClass "turn-off" + + form.show() + + ### + Called when clicking on the "add a comment" button on the side of a diff line. + + Inserts a temporary row for the form below the line. + Sets up the form and shows it. + ### + addDiffNote: (e) => + e.preventDefault() + link = e.target + form = $(".js-new-note-form") + row = $(link).closest("tr") + nextRow = row.next() + + # does it already have notes? + if nextRow.is(".notes_holder") + replyButton = nextRow.find(".js-discussion-reply-button") + if replyButton.length > 0 + $.proxy(@replyToDiscussionNote, replyButton).call() + else + # add a notes row and insert the form + row.after "" + form.clone().appendTo row.next().find(".notes_content") + + # show the form + @setupDiscussionNoteForm $(link), row.next().find("form") + + ### + Called in response to "cancel" on a diff note form. + + Shows the reply button again. + Removes the form and if necessary it's temporary row. + ### + removeDiscussionNoteForm: (form)-> + row = form.closest("tr") + + # show the reply button (will only work for replies) + form.prev(".js-discussion-reply-button").show() + if row.is(".js-temp-notes-holder") + # remove temporary row for diff lines + row.remove() + else + # only remove the form + form.remove() + + + cancelDiscussionForm: (e) => + e.preventDefault() + form = $(".js-new-note-form") + form = $(e.target).closest(".js-discussion-note-form") + @removeDiscussionNoteForm(form) + + updateVotes: -> + (new NotesVotes).updateVotes() + + ### + Called after an attachment file has been selected. + + Updates the file name for the selected attachment. + ### + updateFormAttachment: -> + form = $(this).closest("form") + + # get only the basename + filename = $(this).val().replace(/^.*[\\\/]/, "") + form.find(".js-attachment-filename").text filename + + ### + Called when the tab visibility changes + ### + visibilityChange: => + @refresh() + +@Notes = Notes diff --git a/app/assets/javascripts/notes_votes.js.coffee b/app/assets/javascripts/notes_votes.js.coffee new file mode 100644 index 0000000000..b31eb9ac9d --- /dev/null +++ b/app/assets/javascripts/notes_votes.js.coffee @@ -0,0 +1,22 @@ +class NotesVotes + updateVotes: -> + votes = $("#votes .votes") + notes = $("#notes-list .note .vote") + + # only update if there is a vote display + if votes.size() + upvotes = notes.filter(".upvote").size() + downvotes = notes.filter(".downvote").size() + votesCount = upvotes + downvotes + upvotesPercent = (if votesCount then (100.0 / votesCount * upvotes) else 0) + downvotesPercent = (if votesCount then (100.0 - upvotesPercent) else 0) + + # change vote bar lengths + votes.find(".bar-success").css "width", upvotesPercent + "%" + votes.find(".bar-danger").css "width", downvotesPercent + "%" + + # replace vote numbers + votes.find(".upvotes").text votes.find(".upvotes").text().replace(/\d+/, upvotes) + votes.find(".downvotes").text votes.find(".downvotes").text().replace(/\d+/, downvotes) + +@NotesVotes = NotesVotes diff --git a/app/assets/javascripts/pager.js.coffee b/app/assets/javascripts/pager.js.coffee index 5bd11d273a..1f763e8b95 100644 --- a/app/assets/javascripts/pager.js.coffee +++ b/app/assets/javascripts/pager.js.coffee @@ -19,8 +19,9 @@ data: "limit=" + @limit + "&offset=" + @offset complete: -> $(".loading").hide() - - dataType: "script" + success: (data) -> + Pager.append(data.count, data.html) + dataType: "json" append: (count, html) -> $(".content_list").append html diff --git a/app/assets/javascripts/profile.js.coffee b/app/assets/javascripts/profile.js.coffee index 744f3086d5..b37a78ac19 100644 --- a/app/assets/javascripts/profile.js.coffee +++ b/app/assets/javascripts/profile.js.coffee @@ -26,3 +26,5 @@ $ -> form = $(this).closest("form") filename = $(this).val().replace(/^.*[\\\/]/, '') form.find(".js-avatar-filename").text(filename) + + $('.profile-groups-avatars').tooltip("placement": "top") \ No newline at end of file diff --git a/app/assets/javascripts/project.js.coffee b/app/assets/javascripts/project.js.coffee index bdb18574b6..4262418fd5 100644 --- a/app/assets/javascripts/project.js.coffee +++ b/app/assets/javascripts/project.js.coffee @@ -35,8 +35,14 @@ $ -> $('a, button', scope).removeClass 'active' $(@).addClass 'active' $('#project_clone', scope).val $(@).data 'clone' - $(".clone").text("").append 'git remote add origin ' + $(@).data 'clone' + $(".clone").text("").append $(@).data 'clone' # Ref switcher $('.project-refs-select').on 'change', -> $(@).parents('form').submit() + + $('.hide-no-ssh-message').on 'click', (e) -> + path = '/' + $.cookie('hide_no_ssh_message', 'false', { path: path }) + $(@).parents('.no-ssh-key-message').hide() + e.preventDefault() diff --git a/app/assets/javascripts/project_users_select.js.coffee b/app/assets/javascripts/project_users_select.js.coffee new file mode 100644 index 0000000000..b0e39610fe --- /dev/null +++ b/app/assets/javascripts/project_users_select.js.coffee @@ -0,0 +1,63 @@ +@projectUsersSelect = + init: -> + $('.ajax-project-users-select').each (i, select) -> + project_id = $(select).data('project-id') || $('body').data('project-id') + + $(select).select2 + placeholder: $(select).data('placeholder') || "Search for a user" + multiple: $(select).hasClass('multiselect') + minimumInputLength: 0 + query: (query) -> + Api.projectUsers project_id, query.term, (users) -> + data = { results: users } + + nullUser = { + name: 'Unassigned', + avatar: null, + username: 'none', + id: '' + } + + data.results.unshift(nullUser) + + query.callback(data) + + initSelection: (element, callback) -> + id = $(element).val() + if id isnt "" + Api.user(id, callback) + + + formatResult: projectUsersSelect.projectUserFormatResult + formatSelection: projectUsersSelect.projectUserFormatSelection + dropdownCssClass: "ajax-project-users-dropdown" + dropdownAutoWidth: true + escapeMarkup: (m) -> # we do not want to escape markup since we are displaying html in results + m + + projectUserFormatResult: (user) -> + if user.avatar_url + avatar = user.avatar_url + else if gon.gravatar_enabled + avatar = gon.gravatar_url + avatar = avatar.replace('%{hash}', md5(user.email)) + avatar = avatar.replace('%{size}', '24') + else + avatar = gon.relative_url_root + "/assets/no_avatar.png" + + if user.id == '' + avatarMarkup = '' + else + avatarMarkup = "
    " + + "
    + #{avatarMarkup} +
    #{user.name}
    +
    #{user.username}
    +
    " + + projectUserFormatSelection: (user) -> + user.name + +$ -> + projectUsersSelect.init() diff --git a/app/assets/javascripts/search_autocomplete.js.coffee b/app/assets/javascripts/search_autocomplete.js.coffee index 3418690e10..e144dfa1d6 100644 --- a/app/assets/javascripts/search_autocomplete.js.coffee +++ b/app/assets/javascripts/search_autocomplete.js.coffee @@ -1,7 +1,12 @@ class SearchAutocomplete - constructor: (json) -> + constructor: (search_autocomplete_path, project_id, project_ref) -> + project_id = '' unless project_id + project_ref = '' unless project_ref + query = "?project_id=" + project_id + "&project_ref=" + project_ref + $("#search").autocomplete - source: json + source: search_autocomplete_path + query + minLength: 1 select: (event, ui) -> location.href = ui.item.url diff --git a/app/assets/javascripts/stat_graph_contributors_graph.js.coffee b/app/assets/javascripts/stat_graph_contributors_graph.js.coffee index 4844364416..834c7e5dab 100644 --- a/app/assets/javascripts/stat_graph_contributors_graph.js.coffee +++ b/app/assets/javascripts/stat_graph_contributors_graph.js.coffee @@ -46,11 +46,7 @@ class window.ContributorsGraph class window.ContributorsMasterGraph extends ContributorsGraph constructor: (@data) -> - if $(window).width() > 1214 - @width = 1100 - else - @width = 870 - + @width = $('.container').width() - 70 @height = 200 @x = null @y = null @@ -88,7 +84,6 @@ class window.ContributorsMasterGraph extends ContributorsGraph x(d.date) ).y0(@height).y1((d) -> xa = d.commits = d.commits ? d.additions ? d.deletions - console.log(xa) y(xa) ).interpolate("basis") create_brush: -> @@ -124,11 +119,7 @@ class window.ContributorsMasterGraph extends ContributorsGraph class window.ContributorsAuthorGraph extends ContributorsGraph constructor: (@data) -> - if $(window).width() > 1214 - @width = 490 - else - @width = 380 - + @width = $('.container').width()/2 - 100 @height = 200 @x = null @y = null diff --git a/app/assets/javascripts/users_select.js.coffee b/app/assets/javascripts/users_select.js.coffee index 327667fede..ce9a505b1e 100644 --- a/app/assets/javascripts/users_select.js.coffee +++ b/app/assets/javascripts/users_select.js.coffee @@ -1,17 +1,19 @@ $ -> userFormatResult = (user) -> - if user.avatar - avatar = user.avatar.url - else + if user.avatar_url + avatar = user.avatar_url + else if gon.gravatar_enabled avatar = gon.gravatar_url avatar = avatar.replace('%{hash}', md5(user.email)) avatar = avatar.replace('%{size}', '24') - markup = "
    " - markup += "
    " - markup += "
    " + user.name + "
    " - markup += "
    " + user.username + "
    " - markup += "
    " - markup + else + avatar = gon.relative_url_root + "/assets/no_avatar.png" + + "
    +
    +
    #{user.name}
    +
    #{user.username}
    +
    " userFormatSelection = (user) -> user.name diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index b1a23427ad..c53873f95a 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,59 +2,50 @@ * This is a manifest file that'll automatically include all the stylesheets available in this directory * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at * the top of the compiled file, but it's generally better to create a new file per style scope. - *= require jquery.ui.gitlab + *= require jquery.ui.datepicker + *= require jquery.ui.autocomplete *= require jquery.atwho - *= require chosen *= require select2 + *= require highlightjs.min *= require_self + *= require nprogress + *= require nprogress-bootstrap */ +@import "main/*"; + /** - * GitLab bootstrap: + * Customized Twitter bootstrap */ -@import "gitlab_bootstrap.scss"; +@import 'gl_bootstrap'; -@import "common.scss"; -@import "selects.scss"; +/** + * Font icons + * + */ +@import "font-awesome"; -@import "sections/header.scss"; -@import "sections/nav.scss"; -@import "sections/commits.scss"; -@import "sections/issues.scss"; -@import "sections/projects.scss"; -@import "sections/snippets.scss"; -@import "sections/votes.scss"; -@import "sections/merge_requests.scss"; -@import "sections/graph.scss"; -@import "sections/events.scss"; -@import "sections/themes.scss"; -@import "sections/tree.scss"; -@import "sections/notes.scss"; -@import "sections/profile.scss"; -@import "sections/login.scss"; -@import "sections/editor.scss"; -@import "sections/admin.scss"; -@import "sections/wiki.scss"; -@import "sections/wall.scss"; -@import "sections/dashboard.scss"; -@import "sections/stat_graph.scss"; +/** + * Generic css (forms, nav etc): + */ +@import "generic/*"; -@import "highlight/white.scss"; -@import "highlight/dark.scss"; -@import "highlight/solarized_dark.scss"; -@import "highlight/monokai.scss"; +/** + * Page specific styles (issues, projects etc): + */ +@import "sections/*"; + +/** + * Code highlight + */ +@import "highlight/*"; /** * UI themes: */ -@import "themes/ui_basic.scss"; -@import "themes/ui_mars.scss"; -@import "themes/ui_modern.scss"; -@import "themes/ui_gray.scss"; -@import "themes/ui_color.scss"; +@import "themes/*"; /** * Styles for JS behaviors. */ @import "behaviors.scss"; - diff --git a/app/assets/stylesheets/gitlab_bootstrap/avatar.scss b/app/assets/stylesheets/generic/avatar.scss similarity index 100% rename from app/assets/stylesheets/gitlab_bootstrap/avatar.scss rename to app/assets/stylesheets/generic/avatar.scss diff --git a/app/assets/stylesheets/generic/blocks.scss b/app/assets/stylesheets/generic/blocks.scss new file mode 100644 index 0000000000..3536a68f41 --- /dev/null +++ b/app/assets/stylesheets/generic/blocks.scss @@ -0,0 +1,19 @@ +.light-well { + background: #f9f9f9; + padding: 15px; +} + +.centered-light-block { + text-align: center; + color: #888; + margin: 20px; +} + +.nothing-here-block { + text-align: center; + padding: 20px; + color: #666; + font-weight: normal; + font-size: 16px; + line-height: 36px; +} diff --git a/app/assets/stylesheets/generic/buttons.scss b/app/assets/stylesheets/generic/buttons.scss new file mode 100644 index 0000000000..dd0a2938cf --- /dev/null +++ b/app/assets/stylesheets/generic/buttons.scss @@ -0,0 +1,191 @@ +.btn { + display: inline-block; + margin-bottom: 0; + font-weight: normal; + text-align: center; + vertical-align: middle; + cursor: pointer; + background-image: none; + border: 1px solid transparent; + white-space: nowrap; + padding: 6px 12px; + font-size: 13px; + line-height: 18px; + border-radius: 4px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + -o-user-select: none; + user-select: none; + color: #444444; + background-color: #fff; + border-color: #ccc; + text-shadow: none; + + &.hover, + &:hover { + color: #444444; + text-decoration: none; + background-color: #ebebeb; + border-color: #adadad; + } + + &.focus, + &:focus { + color: #444444; + text-decoration: none; + outline: thin dotted #333; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; + } + + &.active, + &:active { + outline: 0; + background-image: none; + -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); + box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); + } + + &.disabled, + &[disabled] { + cursor: not-allowed; + pointer-events: none; + opacity: 0.65; + filter: alpha(opacity=65); + -webkit-box-shadow: none; + box-shadow: none; + } + + &.btn-primary { + color: #ffffff; + background-color: #429bca; + border-color: #358ebd; + + &.hover, + &:hover, + &.disabled, + &[disabled] { + color: #ffffff; + background-color: #3286b1; + border-color: #286e8e; + } + } + + &.btn-success { + color: #ffffff; + background-color: #5cb85c; + border-color: #4cae4c; + + + &.hover, + &:hover, + &.disabled, + &[disabled] { + color: #ffffff; + background-color: #47a447; + border-color: #398439; + } + } + + &.btn-danger { + color: #ffffff; + background-color: #d9534f; + border-color: #d43f3a; + + + &.hover, + &:hover, + &.disabled, + &[disabled] { + color: #ffffff; + background-color: #d2322d; + border-color: #ac2925; + } + } + + &.btn-new { + @extend .btn-success; + } + + &.btn-create { + @extend .wide; + @extend .btn-success; + } + + &.btn-save { + @extend .wide; + @extend .btn-primary; + } + + &.btn-remove { + @extend .btn-danger; + } + + &.btn-cancel { + float: right; + } + + &.wide { + padding-left: 20px; + padding-right: 20px; + } + + &.btn-small { + padding: 2px 10px; + font-size: 12px; + } + + &.btn-tiny { + font-size: 11px; + padding: 2px 6px; + line-height: 16px; + margin: 2px; + } + + &.btn-close { + color: #B94A48; + font-weight: bold; + &:hover { + color: #B94A48; + } + } + + &.btn-reopen { + color: #468847; + font-weight: bold; + &:hover { + color: #468847; + } + } + + &.btn-grouped { + margin-right: 7px; + float: left; + &:last-child { + margin-right: 0px; + } + } +} + +.btn-block { + width: 100%; + margin: 0; + margin-bottom: 15px; + &.btn { + padding: 6px 0; + } +} + +.btn-group { + &.btn-grouped { + margin-right: 7px; + float: left; + &:last-child { + margin-right: 0px; + } + } +} + +.btn-group-small > .btn { @extend .btn.btn-small; } +.btn-group-tiny > .btn { @extend .btn.btn-tiny; } diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/generic/common.scss similarity index 60% rename from app/assets/stylesheets/common.scss rename to app/assets/stylesheets/generic/common.scss index dbd50b4dcc..4e660d0b1e 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/generic/common.scss @@ -1,22 +1,85 @@ -html { - overflow-y: scroll; +/** COLORS **/ +.cgray { color: gray } +.clgray { color: #BBB } +.cred { color: #D12F19 } +.cgreen { color: #4a2 } +.cblue { color: #29A } +.cblack { color: #111 } +.cdark { color: #444 } +.camber { color: #ffc000 } +.cwhite { color: #fff!important } +.bgred { background: #F2DEDE!important } + +/** COMMON CLASSES **/ +.prepend-top-10 { margin-top:10px } +.prepend-top-20 { margin-top:20px } +.prepend-left-10 { margin-left:10px } +.prepend-left-20 { margin-left:20px } +.append-right-10 { margin-right:10px } +.append-right-20 { margin-right:20px } +.append-bottom-10 { margin-bottom:10px } +.append-bottom-15 { margin-bottom:15px } +.append-bottom-20 { margin-bottom:20px } +.inline { display: inline-block } + +.underlined-link { text-decoration: underline; } +.hint { font-style: italic; color: #999; } +.light { color: #888 } + +.slead { + color: #666; + font-size: 14px; + margin-bottom: 12px; + font-weight: normal; + line-height: 24px; } -/** LAYOUT **/ - -body { - margin-bottom: 20px; +.tab-content { + overflow: visible; } -.container { - padding-top: 0; - z-index: 5; +pre { + &.clean { + background: none; + border: none; + margin: 0; + padding: 0; + } + + &.well-pre { + border: 1px solid #EEE; + background: #f9f9f9; + border-radius: 0; + color: #555; + } } -.container .content { - margin: 0 0; +.dropdown-menu > li > a { + text-shadow: none; } +.dropdown-menu > li > a:hover, +.dropdown-menu > li > a:focus { + background: #29b; + color: #FFF +} + +.breadcrumb > li + li:before { + content: "/"; + padding: 0; + color: #666; +} + +.str-truncated { + display: inline-block; + overflow: hidden; + text-overflow: ellipsis; + vertical-align: top; + white-space: nowrap; + max-width: 82%; +} + +/** FLASH message **/ .author_link { color: $link_color; } @@ -35,39 +98,10 @@ table a code { .loading { margin: 20px auto; - background: url(ajax_loader.gif) no-repeat center center; - width: 40px; height: 40px; - &.loading-gray { - background: url(ajax_loader_gray.gif) no-repeat center center; - } -} - -/** FLASH message **/ -.flash-container { - display: none; - cursor: pointer; - margin: 0; + color: #555; + font-size: 32px; text-align: center; - color: #fff; - font-size: 14px; - position: fixed; - bottom: 0; - width: 100%; - opacity: 0.8; - z-index: 100; - - .flash-notice { - background: #49C; - padding: 10px; - text-shadow: 0 1px 1px #178; - } - - .flash-alert { - background: #C67; - text-shadow: 0 1px 1px #945; - padding: 10px; - } } span.update-author { @@ -90,19 +124,6 @@ span.update-author { display: inline; } -ul.breadcrumb { - background: white; - border: none; - li { - display: inline; - text-shadow: 0 1px 0 white - } - - a { - font-size: 16px; - } -} - .line_holder { &:hover { td { @@ -117,18 +138,6 @@ p.time { margin: 30px 3px 3px 2px; } -.search-holder { - label, input { - height: 30px; - padding: 0; - font-size: 14px; - } - label { - line-height: 30px; - color: #666; - } -} - .highlight { text-shadow: none; } @@ -190,24 +199,8 @@ li.note { cursor: pointer; } -.merge-request, -.issue { - &.today{ - background: #EFE; - border-color: #CEC; - } - &.closed { - background: #F5f5f5; - border-color: #E5E5E5; - } - &.merged { - background: #F5f5f5; - border-color: #E5E5E5; - } -} - .git_error_tips { - @extend .span6; + @extend .col-md-6; text-align: left; margin-top: 40px; pre { @@ -220,7 +213,6 @@ li.note { .error-message { padding: 10px; background: #C67; - padding-left: 20px; margin: 0; color: #FFF; @@ -228,8 +220,25 @@ li.note { color: #fff; text-decoration: underline; } - &.centered { +} + +.no-ssh-key-message { + padding: 10px 0; + background: #C67; + margin: 0; + color: #FFF; + margin-top: -1px; + text-align: center; + + a { + color: #fff; + text-decoration: underline; + } + + .links-xs { text-align: center; + font-size: 16px; + padding: 5px; } } @@ -253,15 +262,6 @@ li.note { } } -pre { - &.clean { - background: none; - border: none; - margin: 0; - padding: 0; - } -} - .milestone { &.milestone-closed { background: #eee; @@ -298,10 +298,6 @@ img.emoji { width: 20px; } -.appear-data { - display: none; -} - .chart { overflow: hidden; height: 220px; @@ -317,11 +313,6 @@ img.emoji { margin-bottom: 10px; } -.group-name { - font-size: 14px; - line-height: 24px; -} - table { td.permission-x { background: #D9EDF7 !important; @@ -338,7 +329,33 @@ table { min-height: 100px; } -.navbar-gitlab .navbar-inner .nav > li .btn-sign-in { - @extend .btn-new; - padding: 5px 15px; +.broadcast-message { + padding: 10px; + text-align: center; + background: #555; + color: #BBB; +} + +.broadcast-message-preview { + @extend .broadcast-message; + margin-bottom: 20px; +} + +.btn-sign-in { + margin-top: 7px; + text-shadow: none; +} + +.side-filters { + fieldset { + margin-bottom: 15px; + } +} + +@media (max-width: $screen-xs-max) { + .container .content { margin-top: 20px; } +} + +.wiki .highlight, .note-body .highlight { + margin-bottom: 9px; } diff --git a/app/assets/stylesheets/gitlab_bootstrap/files.scss b/app/assets/stylesheets/generic/files.scss similarity index 56% rename from app/assets/stylesheets/gitlab_bootstrap/files.scss rename to app/assets/stylesheets/generic/files.scss index a286e530cd..9e4207965f 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/files.scss +++ b/app/assets/stylesheets/generic/files.scss @@ -11,29 +11,32 @@ } .file-title { - border-bottom: 1px solid #bbb; - @include bg-dark-gray-gradient; + background: #EEE; + border-bottom: 1px solid #CCC; text-shadow: 0 1px 1px #fff; margin: 0; - font-weight: normal; - font-weight: bold; text-align: left; - color: $style_color; padding: 9px 10px; - height: 18px; .options { float: right; margin-top: -5px; } + .left-options { + margin-top: -3px; + } + .file_name { - color: $style_color; + font-weight: bold; + padding-left: 3px; font-size: 14px; - text-shadow: 0 1px 1px #fff; + small { - color: #999; + color: #888; font-size: 13px; + font-weight: normal; + padding-left: 10px; } } } @@ -46,14 +49,14 @@ text-align: center; img { padding: 100px; - max-width: 300px; + max-width: 50%; } } &.wiki { - padding: 20px; font-size: 14px; line-height: 1.6; + padding: 25px; .highlight { margin-bottom: 9px; @@ -144,75 +147,6 @@ */ &.code { padding: 0; - - table.lines { - border: none; - box-shadow: none; - margin: 0px; - padding: 0px; - table-layout: fixed; - - pre { - border: none; - border-radius: 0; - font-family: $monospace_font; - font-size: 12px !important; - line-height: 16px !important; - margin: 0; - padding: 10px 0; - } - td { - border: none; - margin: 0; - padding: 0; - vertical-align: top; - - &:first-child { - background: #eee; - width: 50px; - } - &:last-child { - } - } - tr:hover { - background: none; - } - - pre.line_numbers { - color: #666; - padding: 10px 6px 10px 0; - text-align: right; - background: #EEE; - - a { - color: #666; - - i { - display: none; - font-size: 14px; - line-height: 14px; - } - &:hover i { - display: inherit; - } - } - } - - .highlight { - border-left: 1px solid #DEE2E3; - overflow: auto; - overflow-y: hidden; - - pre { - white-space: pre; - word-wrap: normal; - - .line { - padding: 0 10px; - } - } - } - } } } } diff --git a/app/assets/stylesheets/generic/flash.scss b/app/assets/stylesheets/generic/flash.scss new file mode 100644 index 0000000000..95d28aaef6 --- /dev/null +++ b/app/assets/stylesheets/generic/flash.scss @@ -0,0 +1,25 @@ +.flash-container { + display: none; + cursor: pointer; + margin: 0; + text-align: center; + color: #fff; + font-size: 14px; + position: fixed; + bottom: 0; + width: 100%; + opacity: 0.8; + z-index: 100; + + .flash-notice { + background: #49C; + padding: 10px; + text-shadow: 0 1px 1px #178; + } + + .flash-alert { + background: #C67; + text-shadow: 0 1px 1px #945; + padding: 10px; + } +} diff --git a/app/assets/stylesheets/generic/forms.scss b/app/assets/stylesheets/generic/forms.scss new file mode 100644 index 0000000000..36551f85b6 --- /dev/null +++ b/app/assets/stylesheets/generic/forms.scss @@ -0,0 +1,100 @@ +input[type='search'].search-text-input { + background-image: image-url("icon-search.png"); + background-repeat: no-repeat; + background-position: 10px; + padding-left: 25px; +} + +input[type='text'].danger { + background: #F2DEDE!important; + border-color: #D66; + text-shadow: 0 1px 1px #fff +} + +fieldset legend { + font-size: 16px; +} + +.datetime-controls { + select { + width: 100px; + } +} + +.form-actions { + padding: 17px 20px 18px; + margin-top: 18px; + margin-bottom: 18px; + background-color: whitesmoke; + border-top: 1px solid #e5e5e5; + padding-left: 17%; +} + +label { + &.control-label { + @extend .col-sm-2; + } + + &.inline-label { + margin: 0; + } +} + +.inline-input-group { + width: 250px; +} + +.input-mx-250 { + max-width: 250px; +} + +.input-mn-300 { + min-width: 300px; +} + +.custom-form-control { + width: 150px; +} + +@media (min-width: $screen-sm-min) { + .custom-form-control { + width: 150px; + } +} + +/* Medium devices (desktops, 992px and up) */ +@media (min-width: $screen-md-min) { + .custom-form-control { + width: 170px; + } +} + +/* Large devices (large desktops, 1200px and up) */ +@media (min-width: $screen-lg-min) { + .custom-form-control { + width: 200px; + } +} + +.commit-message-container { + background-color: $body-bg; + position: relative; + font-family: $monospace_font; + $left: 12px; + .max-width-marker { + color: rgba(0, 0, 0, 0.0); + font-family: inherit; + left: $left; + height: 100%; + border-right: 1px solid mix($input-border, white); + position: absolute; + z-index: 1; + } + > textarea { + background-color: rgba(0, 0, 0, 0.0); + font-family: inherit; + padding-left: $left; + position: relative; + z-index: 2; + } +} diff --git a/app/assets/stylesheets/generic/highlight.scss b/app/assets/stylesheets/generic/highlight.scss new file mode 100644 index 0000000000..4110bddf4f --- /dev/null +++ b/app/assets/stylesheets/generic/highlight.scss @@ -0,0 +1,64 @@ +.highlighted-data { + border: none; + box-shadow: none; + margin: 0px; + padding: 0px; + table-layout: fixed; + + pre { + padding: 10px; + border: none; + border-radius: 0; + font-family: $monospace_font; + font-size: 12px !important; + line-height: 16px !important; + margin: 0; + + code { + white-space: pre; + word-wrap: normal; + padding: 0; + + .line { + display: inline; + } + } + } + + .hljs { + padding: 0; + } + + .line-numbers { + padding: 10px; + text-align: right; + float: left; + + a { + font-family: $monospace_font; + display: block; + font-size: 12px !important; + line-height: 16px !important; + white-space: nowrap; + + i { + visibility: hidden; + @extend .pull-left; + } + + &:hover i { + visibility: visible; + } + } + } + + .highlight { + overflow: auto; + overflow-y: hidden; + + pre { + white-space: pre; + word-wrap: normal; + } + } +} diff --git a/app/assets/stylesheets/generic/issue_box.scss b/app/assets/stylesheets/generic/issue_box.scss new file mode 100644 index 0000000000..d4d3361bc7 --- /dev/null +++ b/app/assets/stylesheets/generic/issue_box.scss @@ -0,0 +1,128 @@ +/** + * Issue box: + * Huge block (one per page) for storing title, descripion and other information. + * Used for Issue#show page, MergeRequest#show page etc + * + * CLasses: + * .issue-box - Regular box + */ + +.issue-box { + color: #666; + margin:20px 0; + background: #FFF; + border: 1px solid #EEE; + @include box-shadow(0 1px 1px rgba(0, 0, 0, 0.05)); + + &.issue-box-closed { + border-color: #DA4E49; + .state { + background-color: #f2dede; + border-color: #ebccd1; + color: #a94442; + .state-label { + background: #DA4E49; + color: #FFF; + } + } + } + + &.issue-box-merged { + border-color: #31708f; + .state { + background-color: #d9edf7; + border-color: #bce8f1; + color: #31708f; + .state-label { + background: #31708f; + color: #FFF; + } + } + } + + &.issue-box-open { + border-color: #4A4; + .state { + background-color: #dff0d8; + border-color: #d6e9c6; + color: #3c763d; + .state-label { + background: #4A4; + color: #FFF; + } + } + } + + &.issue-box-expired { + border-color: #cea61b; + .state { + background-color: #fcf8e3; + border-color: #faebcc; + color: #8a6d3b; + .state-label { + background: #cea61b; + color: #FFF; + } + } + } + + .control-group { + margin-bottom: 0; + } + + .state { + border-bottom: 1px solid #DDD; + line-height: 32px; + } + + .title { + font-size: 22px; + font-weight: 500; + line-height: 1.5; + margin: 0; + color: #333; + padding-bottom: 0; + padding: 15px 25px; + } + + .context { + border: none; + border-top: 1px solid #eee; + padding: 15px 25px; + + // Reset text align for children + .text-right > * { text-align: left; } + + @media (max-width: $screen-xs-max) { + // Don't right align on mobile + .text-right { text-align: left; } + + .row .col-md-6 { + padding-top: 5px; + } + } + } + + .description { + padding: 0 25px 15px 25px; + } + + .title, .context, .description { + .clearfix { + margin: 0; + } + } + + .state-label { + font-size: 14px; + padding: 1px 25px; + text-align: center; + text-shadow: none; + display: inline-block; + line-height: 34px; + } + + .creator { + padding: 2px 15px; + } +} diff --git a/app/assets/stylesheets/generic/jquery.scss b/app/assets/stylesheets/generic/jquery.scss new file mode 100644 index 0000000000..6b29accb31 --- /dev/null +++ b/app/assets/stylesheets/generic/jquery.scss @@ -0,0 +1,55 @@ +.ui-widget { + font-family: $regular_font; + font-size: $font-size-base; + + &.ui-datepicker-inline { + border: 1px solid #DDD; + padding: 10px; + width: 270px; + + .ui-datepicker-header { + background: #FFF; + border-color: #DDD; + } + + .ui-datepicker-calendar td a { + padding: 5px; + text-align: center; + } + } + + &.ui-autocomplete { + border-color: #DDD; + padding: 0; + margin-top: 2px; + z-index: 1001; + + .ui-menu-item a { + padding: 4px 10px; + } + } + + .ui-state-default { + border: 1px solid #FFF; + background: #FFF; + color: #777; + } + + .ui-state-highlight { + border: 1px solid #EEE; + background: #EEE; + } + + .ui-state-active { + border: 1px solid $bg_style_color; + background: $bg_style_color; + color: #FFF; + } + + .ui-state-hover, + .ui-state-focus { + border: 1px solid $hover; + background: $hover; + color: #333; + } +} diff --git a/app/assets/stylesheets/gitlab_bootstrap/lists.scss b/app/assets/stylesheets/generic/lists.scss similarity index 82% rename from app/assets/stylesheets/gitlab_bootstrap/lists.scss rename to app/assets/stylesheets/generic/lists.scss index 83066b5bee..963768044d 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/lists.scss +++ b/app/assets/stylesheets/generic/lists.scss @@ -4,13 +4,21 @@ */ .well-list { margin: 0; + padding: 0; list-style: none; + li { padding: 10px; min-height: 20px; border-bottom: 1px solid #eee; border-bottom: 1px solid rgba(0, 0, 0, 0.05); + &:after { + content: " "; + display: table; + clear: both; + } + &.disabled { color: #888; } @@ -21,6 +29,12 @@ } } + &.warning-row { + background-color: #fcf8e3; + border-color: #faebcc; + color: #8a6d3b; + } + &.smoke { background-color: #f5f5f5; } &:hover { @@ -38,6 +52,12 @@ .author { color: #999; } + .list-item-name { + float: left; + position: relative; + top: 3px; + } + p { padding-top: 1px; margin: 0; diff --git a/app/assets/stylesheets/generic/selects.scss b/app/assets/stylesheets/generic/selects.scss new file mode 100644 index 0000000000..03597c1fc7 --- /dev/null +++ b/app/assets/stylesheets/generic/selects.scss @@ -0,0 +1,123 @@ +/** Select2 selectbox style override **/ +.select2-container, .select2-container.select2-drop-above { + .select2-choice { + background: #FFF; + border-color: #BBB; + + .select2-arrow { + background: #FFF; + } + } +} + +.select2-drop-active { + border: 1px solid #BBB !important; + margin-top: 4px; + + &.select2-drop-above { + margin-bottom: 8px; + } + + .select2-search input { + background: #fafafa; + border-color: #DDD; + } + + .select2-results { + max-height: 350px; + .select2-highlighted { + background: $bg_style_color; + } + } +} + +select { + &.select2 { + width: 100px; + } + + &.select2-sm { + width: 100px; + } +} + +@media (min-width: $screen-sm-min) { + select { + &.select2 { + width: 150px; + } + &.select2-sm { + width: 120px; + } + } +} + +/* Medium devices (desktops, 992px and up) */ +@media (min-width: $screen-md-min) { + select { + &.select2 { + width: 170px; + } + &.select2-sm { + width: 140px; + } + } +} + +/* Large devices (large desktops, 1200px and up) */ +@media (min-width: $screen-lg-min) { + select { + &.select2 { + width: 200px; + } + &.select2-sm { + width: 150px; + } + } +} + + +/** Branch/tag selector **/ +.project-refs-form .select2-container { + margin-right: 10px; +} + +.ajax-users-dropdown, .ajax-project-users-dropdown { + .select2-search { + padding-top: 4px; + } +} + +.ajax-users-select { + width: 400px; + + &.input-large { + width: 210px; + } + + &.input-clamp { + max-width: 100%; + } +} + +.user-result { + .user-image { + float: left; + } + .user-name { + } + .user-username { + color: #999; + } +} + +.namespace-result { + .namespace-kind { + color: #AAA; + font-weight: normal; + } + .namespace-path { + margin-left: 10px; + font-weight: bolder; + } +} diff --git a/app/assets/stylesheets/gitlab_bootstrap/typography.scss b/app/assets/stylesheets/generic/typography.scss similarity index 64% rename from app/assets/stylesheets/gitlab_bootstrap/typography.scss rename to app/assets/stylesheets/generic/typography.scss index d398655637..8cc72d7f07 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/typography.scss +++ b/app/assets/stylesheets/generic/typography.scss @@ -2,11 +2,6 @@ * Headers * */ -h1, h2, h3, h4, h5, h6 { - font-weight: 500; - line-height: 1.1; -} - h1.page-title { @include page-title; font-size: 28px; @@ -52,7 +47,7 @@ a { text-decoration: underline; } - &.dark { + &.darken { color: $style_color; } @@ -93,12 +88,28 @@ a:focus { .wiki { @include md-typography; - font-size: 14px; - line-height: 1.6; - .white .highlight pre { - background: #f5f5f5; + /* Link to current header. */ + h1, h2, h3, h4, h5, h6 { + position: relative; + &:hover > :last-child { + $size: 16px; + position: absolute; + right: 100%; + top: 50%; + margin-top: -$size/2; + margin-right: 0px; + padding-right: 20px; + display: inline-block; + width: $size; + height: $size; + background-image: image-url("icon-link.png"); + background-size: contain; + background-repeat: no-repeat; + } } + ul { + padding: 0; margin: 0 0 9px 25px !important; } } @@ -106,3 +117,11 @@ a:focus { .md { @include md-typography; } + +/** + * Textareas intended for GFM + * + */ +textarea.js-gfm-input { + font-family: $monospace_font; +} diff --git a/app/assets/stylesheets/gitlab_bootstrap/blocks.scss b/app/assets/stylesheets/generic/ui_box.scss similarity index 54% rename from app/assets/stylesheets/gitlab_bootstrap/blocks.scss rename to app/assets/stylesheets/generic/ui_box.scss index 53de8067ab..7a977eae70 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/blocks.scss +++ b/app/assets/stylesheets/generic/ui_box.scss @@ -1,106 +1,55 @@ /** - * =================================== - * Contain UI block elements: + * UI box: + * Block element for separating information on page. + * Used for storing issues lists, grouped data. + * You can have multiple ui boxes on one page + * + * Classes: * .ui-box - for any block & widgets - * =================================== - */ - -/** - * UI Block + * .ui-box.ui-box-small - same but with smaller title + * .ui-box.ui-box-danger - with red title + * + * Ex. 1: List + * .ui-box + * .title + * # title here + * %ul + * # content here + * + * Ex. 2: Block data + * .ui-box + * .title + * # title here + * .body + * # content here * */ + .ui-box { background: #FFF; margin-bottom: 20px; border: 1px solid #DDD; word-wrap: break-word; - &.small-box { - margin-bottom: 10px; - - .title { - font-size: 13px; - line-height: 30px; - - a { - color: #666; - &:hover { - text-decoration: underline; - } - } - } + img { + max-width: 100%; } - &.ui-box-show { - color: #666; - margin:20px 0; - background: #FFF; - box-shadow: inset 0 1px 0 #fff, 0 1px 5px #f1f1f1; - @include linear-gradient(#fafafa, #f1f1f1); - - .control-group { - margin-bottom: 0; - } - } - - &.ui-box-danger { - .title { - @include linear-gradient(#F26E5E, #bd362f); - color: #fff; - text-shadow: 0 1px 1px #900; - font-weight: bold; - } - } - - img { max-width: 100%; } - pre { code { background: none !important; } } - .ui-box-head, - .ui-box-body, - .ui-box-bottom { - padding: 15px; - - .clearfix { - margin: 0; - } - } - - .ui-box-head { - .box-title { - font-size: 18px; - font-weight: normal; - line-height: 28px; - margin: 0; - } - h3 { - margin: 0; - } - } - - .ui-box-body { - border: none; - background-color: #f5f5f5; - border: none; - border-top: 1px solid #eee; - } - - .ui-box-bottom { - border-top: 1px solid #eee; - } - ul { margin: 0; + padding: 0; } .title { - @include bg-gray-gradient; - border-bottom: 1px solid #CCC; - color: #456; + background-color: #EEE; + border-bottom: 1px solid #DDD; + color: #666; font-size: 16px; text-shadow: 0 1px 1px #fff; padding: 0 10px; @@ -145,6 +94,10 @@ } } + .body { + padding: 10px; + } + &.padded { h5, .title { margin: -20px; @@ -154,7 +107,7 @@ } .row_title { - font-weight: bold; + font-weight: 500; color: #444; &:hover { color: #444; @@ -176,13 +129,45 @@ } } +/* + * Small box + */ +.ui-box.ui-box-small { + margin-bottom: 10px; + + .title { + font-size: 13px; + line-height: 30px; + + a { + color: #666; + &:hover { + text-decoration: underline; + } + } + } +} + +/* + * Danger box + */ +.ui-box.ui-box-danger { + background: #f7f7f7; + border: none; + + .title { + background: #D65; + color: #fff; + text-shadow: none; + font-weight: 500; + } +} + +/* + * Block under tw-bootstrap tabs + */ .tab-pane { .ui-box { margin: 3px 3px 25px 3px; } } - -.light-well { - background: #f9f9f9; - padding: 15px; -} diff --git a/app/assets/stylesheets/gitlab_bootstrap.scss b/app/assets/stylesheets/gitlab_bootstrap.scss deleted file mode 100644 index faf36b702c..0000000000 --- a/app/assets/stylesheets/gitlab_bootstrap.scss +++ /dev/null @@ -1,66 +0,0 @@ -/** Override bootstrap variables **/ -$baseFontSize: 13px !default; -$baseLineHeight: 18px !default; - -/** - * BOOTSTRAP - */ -@import "bootstrap/variables"; -@import "bootstrap/mixins"; -@import "bootstrap/reset"; -@import "bootstrap/scaffolding"; -@import "bootstrap/grid"; -@import "bootstrap/layouts"; -@import "bootstrap/type"; -@import "bootstrap/code"; -@import "bootstrap/forms"; -@import "bootstrap/tables"; -@import "bootstrap/sprites"; -@import "bootstrap/dropdowns"; -@import "bootstrap/wells"; -@import "bootstrap/component-animations"; -@import "bootstrap/close"; -@import "bootstrap/button-groups"; -@import "bootstrap/alerts"; -@import "bootstrap/navs"; -@import "bootstrap/navbar"; -@import "bootstrap/breadcrumbs"; -@import "bootstrap/pagination"; -@import "bootstrap/pager"; -@import "bootstrap/modals"; -@import "bootstrap/tooltip"; -@import "bootstrap/popovers"; -@import "bootstrap/thumbnails"; -@import "bootstrap/media"; -@import "bootstrap/labels-badges"; -@import "bootstrap/progress-bars"; -@import "bootstrap/accordion"; -@import "bootstrap/carousel"; -@import "bootstrap/hero-unit"; -@import "bootstrap/utilities"; -@import "bootstrap/responsive-utilities"; -@import "bootstrap/responsive-1200px-min"; - -/** - * Font icons - * - */ -@import "font-awesome"; - -/** - * GitLab bootstrap. - * Overrides some styles of twitter bootstrap. - * Also give some common classes for GitLab app - */ -@import "gitlab_bootstrap/variables.scss"; -@import "gitlab_bootstrap/fonts.scss"; -@import "gitlab_bootstrap/mixins.scss"; -@import "gitlab_bootstrap/avatar.scss"; -@import "gitlab_bootstrap/nav.scss"; -@import "gitlab_bootstrap/common.scss"; -@import "gitlab_bootstrap/typography.scss"; -@import "gitlab_bootstrap/buttons.scss"; -@import "gitlab_bootstrap/blocks.scss"; -@import "gitlab_bootstrap/files.scss"; -@import "gitlab_bootstrap/lists.scss"; -@import "gitlab_bootstrap/forms.scss"; diff --git a/app/assets/stylesheets/gitlab_bootstrap/buttons.scss b/app/assets/stylesheets/gitlab_bootstrap/buttons.scss deleted file mode 100644 index 9c547cc1ce..0000000000 --- a/app/assets/stylesheets/gitlab_bootstrap/buttons.scss +++ /dev/null @@ -1,148 +0,0 @@ -.btn { - display: inline-block; - padding: 6px 12px; - margin-bottom: 0; - font-size: 13px; - line-height: $baseLineHeight; - text-align: center; - vertical-align: middle; - cursor: pointer; - border: 1px solid #BBB; - color: $style_color; - @include border-radius($baseBorderRadius); - @include box-shadow(inset 0 1px 0 rgba(255,255,255,.2)); - @include linear-gradient(#f1f1f1, #e1e1e1); - text-shadow: 0 1px 1px #FFF; - text-decoration: none; - - &.hover, - &:hover { - color: $style_color; - background: #f1f1f1; - border-color: #AAA; - text-decoration: none; - @include linear-gradient(#fAfAfA, #f1f1f1); - } - - &.focus, - &:focus { - text-decoration: none; - @include box-shadow(inset 0 2px 4px rgba(0,0,0,.15)); - } - - &.active, - &:active { - background-image: none; - outline: 0; - text-decoration: none; - @include box-shadow(inset 0 2px 4px rgba(0,0,0,.15)); - } - - &.disabled, - &[disabled] { - cursor: default; - background-image: none; - @include opacity(65); - @include box-shadow(none); - } - - &.btn-primary { - color: #FFF; - border-color: #189; - text-shadow: 0 1px 1px #189; - @include linear-gradient(#4AC, #289); - - &.hover, - &:hover, - &.disabled, - &[disabled] { - color: #FFF; - background: #389; - } - } - - &.btn-success { - color: #FFF; - border-color: #1A1; - text-shadow: 0 1px 1px #FFF; - text-shadow: 0 1px 1px #181; - @include linear-gradient(#62C452, #51a351); - - - &.hover, - &:hover, - &.disabled, - &[disabled] { - color: #FFF; - background: #2A2; - } - } - - &.btn-danger { - color: #FFF; - text-shadow: 0 1px 1px #811; - border-color: #BD362F; - @include linear-gradient(#EE5F5B, #BD362F); - - - &.hover, - &:hover, - &.disabled, - &[disabled] { - color: #FFF; - background: #A22; - } - } - - &.btn-new { - @extend .btn-success; - } - - &.btn-create { - @extend .wide; - @extend .btn-success; - } - - &.btn-save { - @extend .wide; - @extend .btn-primary; - } - - &.btn-close, - &.btn-remove { - @extend .btn-danger; - } - - &.btn-cancel { - float: right; - } - - &.wide { - padding-left: 20px; - padding-right: 20px; - } - - &.btn-small { - padding: 2px 10px; - font-size: 12px; - } - - &.btn-tiny { - font-size: 11px; - padding: 2px 6px; - line-height: 16px; - margin: 2px; - } - - &.grouped { - margin-right: 7px; - float: left; - } - - &.btn-block { - width: 100%; - margin: 0; - padding: 6px 0; - margin-bottom: 15px; - } -} diff --git a/app/assets/stylesheets/gitlab_bootstrap/common.scss b/app/assets/stylesheets/gitlab_bootstrap/common.scss deleted file mode 100644 index 2ca60178df..0000000000 --- a/app/assets/stylesheets/gitlab_bootstrap/common.scss +++ /dev/null @@ -1,118 +0,0 @@ -/** COLORS **/ -.cgray { color: gray } -.cred { color: #D12F19 } -.cgreen { color: #4a2 } -.cblue { color: #29A } -.cblack { color: #111 } -.cdark { color: #444 } -.cwhite { color: #fff!important } -.bgred { background: #F2DEDE!important } - -/** COMMON CLASSES **/ -.left { float:left } - -.prepend-top-10 { margin-top:10px } -.prepend-top-20 { margin-top:20px } -.prepend-left-10 { margin-left:10px } -.prepend-left-20 { margin-left:20px } -.append-right-10 { margin-right:10px } -.append-right-20 { margin-right:20px } -.append-bottom-10 { margin-bottom:10px } -.append-bottom-20 { margin-bottom:20px } -.inline { display: inline-block } - -.padded { padding:20px } -.ipadded { padding:20px!important } -.lborder { border-left:1px solid #eee } -.underlined_link { text-decoration: underline; } -.hint { font-style: italic; color: #999; } -.light { color: #888 } -.tiny { font-weight: normal } -.vtop { vertical-align: top !important; } - - -/** ALERT MESSAGES **/ -.alert.alert-disabled { - background: #EEE; - color: #777; - border-color: #DDD; -} - -/** HELPERS **/ -.nothing_here_message { - text-align: center; - padding: 20px; - color: #666; - font-weight: normal; - font-size: 16px; - line-height: 36px; -} - -.slead { - color: #666; - font-size: 14px; - margin-bottom: 12px; - font-weight: normal; - line-height: 24px; -} - - -.tab-content { - overflow: visible; -} - -@media (max-width: 1200px) { - .only-wide { - display: none; - } -} - -.pagination ul > li > a, .pagination ul > li >span { - @include linear-gradient(#f1f1f1, #e1e1e1); - color: #333; - text-shadow: 0 1px 1px #FFF; -} - -pre.well-pre { - border: 1px solid #EEE; - background: #f9f9f9; - border-radius: 0; - color: #555; -} - -.input-append .btn.active, .input-prepend .btn.active { - background: #CCC; - border-color: #BBB; - text-shadow: 0 1px 1px #fff; - font-weight: bold; - @include box-shadow(inset 0 2px 4px rgba(0,0,0,.15)); -} - -.label { - padding: 2px 4px; - font-size: 12px; - font-style: normal; - font-weight: normal; -} - -/** Big Labels **/ -.state-label { - font-size: 14px; - padding: 5px 15px; - text-align: center; - float: right; - position: relative; - top: -5px; - @include border-radius(4px); - text-shadow: none; - - &.state-label-green { - background: #4A4; - color: #FFF; - } - - &.state-label-red { - background: #DA4E49; - color: #FFF; - } -} diff --git a/app/assets/stylesheets/gitlab_bootstrap/forms.scss b/app/assets/stylesheets/gitlab_bootstrap/forms.scss deleted file mode 100644 index a2612166c7..0000000000 --- a/app/assets/stylesheets/gitlab_bootstrap/forms.scss +++ /dev/null @@ -1,51 +0,0 @@ -form { - @extend .form-horizontal; - - label { - @extend .control-label; - } -} - -input.input-xpadding, -.add-on.input-xpadding { - padding: 6px 10px; -} - -.control-group { - .control-label { - padding-top: 6px; - } - .controls { - input, textarea { - padding: 6px 10px; - } - - input[type="radio"], input[type="checkbox"] { - margin-top: 6px; - } - - .add-on { - padding: 6px; - } - } -} - -input[type='search'].search-text-input { - background-image: url("icon-search.png"); - background-repeat: no-repeat; - background-position: 10px; - padding-left: 25px; - @include border-radius(4px); - border: 1px solid #ccc; -} - -input[type='text'].danger { - background: #F2DEDE!important; - border-color: #D66; - text-shadow: 0 1px 1px #fff -} - -fieldset legend { - font-size: 16px; - margin-bottom: 10px; -} diff --git a/app/assets/stylesheets/gitlab_bootstrap/nav.scss b/app/assets/stylesheets/gitlab_bootstrap/nav.scss deleted file mode 100644 index aa4cb1ed5f..0000000000 --- a/app/assets/stylesheets/gitlab_bootstrap/nav.scss +++ /dev/null @@ -1,92 +0,0 @@ -/** - * nav-pills - * - */ -.nav-pills { - .active a { - background: $primary_color; - } - - > li > a { - @include border-radius(0); - } - - &.nav-stacked { - > li > a { - border-left: 4px solid #EEE; - padding: 12px; - } - > .active > a { - border-color: $primary_color; - border-radius: 0; - background: #F1F1F1; - color: $style_color; - font-weight: bold; - text-shadow: 0 1px 1px #fff; - } - - &.nav-stacked-menu { - background: #FAFAFA; - li > a { - padding: 16px; - } - } - } - - &.nav-pills-small { - > li > a { - padding: 8px 12px; - } - } -} - -.nav-pills > .active > a > i[class^="icon-"] { background: inherit; } - - - -/** - * nav-tabs - * - */ -.nav-tabs > li > a, .nav-pills > li > a { color: $style_color; } -.nav.nav-tabs { - li { - > a { - padding: 8px 20px; - margin-right: 7px; - line-height: 20px; - border-color: #EEE; - color: #888; - border-bottom: 1px solid #ddd; - .badge { - background-color: #eee; - color: #888; - text-shadow: 0 1px 1px #fff; - } - i[class^="icon-"] { - line-height: 14px; - } - } - &.active { - > a { - border-color: #CCC; - border-bottom: 1px solid #fff; - color: #333; - font-weight: bold; - } - } - } - - &.nav-small-tabs > li > a { padding: 6px 9px; } -} - - - -/** - * fix to keep tooltips position in top navigation bar - * - */ -.navbar .nav > li { - position: relative; - white-space: nowrap; -} diff --git a/app/assets/stylesheets/gl_bootstrap.scss b/app/assets/stylesheets/gl_bootstrap.scss new file mode 100644 index 0000000000..8676f07b1a --- /dev/null +++ b/app/assets/stylesheets/gl_bootstrap.scss @@ -0,0 +1,223 @@ +/* + * Twitter bootstrap with GitLab customizations/additions + * + * Some unused bootstrap compontents like panels are not included. + * Other components like tabs are modified to GitLab style. + * + */ + +$font-size-base: 13px !default; +$nav-pills-active-link-hover-bg: $bg_style_color; +$pagination-active-bg: $bg_style_color; + +// Core variables and mixins +@import "bootstrap/variables"; +@import "bootstrap/mixins"; + +// Reset +@import "bootstrap/normalize"; +@import "bootstrap/print"; + +// Core CSS +@import "bootstrap/scaffolding"; +@import "bootstrap/type"; +@import "bootstrap/code"; +@import "bootstrap/grid"; +@import "bootstrap/tables"; +@import "bootstrap/forms"; + +// Components +@import "bootstrap/component-animations"; +@import "bootstrap/dropdowns"; +@import "bootstrap/button-groups"; +@import "bootstrap/input-groups"; +@import "bootstrap/navs"; +@import "bootstrap/navbar"; +@import "bootstrap/breadcrumbs"; +@import "bootstrap/pagination"; +@import "bootstrap/pager"; +@import "bootstrap/labels"; +@import "bootstrap/badges"; +@import "bootstrap/jumbotron"; +@import "bootstrap/thumbnails"; +@import "bootstrap/alerts"; +@import "bootstrap/progress-bars"; +@import "bootstrap/list-group"; +@import "bootstrap/wells"; +@import "bootstrap/close"; +@import "bootstrap/panels"; + +// Components w/ JavaScript +@import "bootstrap/modals"; +@import "bootstrap/tooltip"; +@import "bootstrap/popovers"; +@import "bootstrap/carousel"; + +// Utility classes +.clearfix { + @include clearfix(); +} +.center-block { + @include center-block(); +} +.pull-right { + float: right !important; +} +.pull-left { + float: left !important; +} +.hide { + display: none; +} +.show { + display: block !important; +} +.invisible { + visibility: hidden; +} +.text-hide { + @include text-hide(); +} +.hidden { + display: none !important; + visibility: hidden !important; +} +.affix { + position: fixed; +} + +@import "bootstrap/responsive-utilities"; + +// Labels +.label { + padding: 2px 4px; + font-size: 12px; + font-style: normal; + font-weight: normal; + display: inline-block; + + &.label-gray { + background-color: #eee; + color: #999; + text-shadow: none; + } + + &.label-inverse { + background-color: #333333; + } +} + +// Nav tabs +.nav.nav-tabs { + margin-bottom: 15px; + + li { + > a { + padding: 8px 20px; + margin-right: 7px; + line-height: 20px; + border-color: #EEE; + color: #888; + border-bottom: 1px solid #ddd; + .badge { + background-color: #eee; + color: #888; + text-shadow: 0 1px 1px #fff; + } + i[class^="icon-"] { + line-height: 14px; + } + } + &.active { + > a { + border-color: #CCC; + border-bottom: 1px solid #fff; + color: #333; + font-weight: bold; + } + } + } + + &.nav-small-tabs > li > a { + padding: 6px 9px; + } +} + +.nav-tabs > li > a, +.nav-pills > li > a { + color: #666; +} + +.nav-small > li > a { + padding: 3px 5px; + font-size: 12px; +} + + +/* + * Callouts from Bootstrap3 docs + * + * Not quite alerts, but custom and helpful notes for folks reading the docs. + * Requires a base and modifier class. + */ + +/* Common styles for all types */ +.bs-callout { + margin: 20px 0; + padding: 20px; + border-left: 3px solid #eee; + color: #666; + background: #f9f9f9; +} +.bs-callout h4 { + margin-top: 0; + margin-bottom: 5px; +} +.bs-callout p:last-child { + margin-bottom: 0; +} + +/* Variations */ +.bs-callout-danger { + background-color: #fdf7f7; + border-color: #eed3d7; + color: #b94a48; +} +.bs-callout-warning { + background-color: #faf8f0; + border-color: #faebcc; + color: #8a6d3b; +} +.bs-callout-info { + background-color: #f4f8fa; + border-color: #bce8f1; + color: #34789a; +} +.bs-callout-success { + background-color: #dff0d8; + border-color: #5cA64d; + color: #3c763d; +} + +// Breadcrumb +ul.breadcrumb { + background: white; + border: none; + li { + display: inline; + text-shadow: 0 1px 0 white + } + + a { + font-size: 16px; + } +} + +/** + * fix to keep tooltips position in top navigation bar + * + */ +.navbar .nav > li { + position: relative; + white-space: nowrap; +} diff --git a/app/assets/stylesheets/highlight/dark.scss b/app/assets/stylesheets/highlight/dark.scss index 129d33dcac..ca51da3fdd 100644 --- a/app/assets/stylesheets/highlight/dark.scss +++ b/app/assets/stylesheets/highlight/dark.scss @@ -1,71 +1,199 @@ -.dark .highlight { +.dark { + background-color: #232323; - background-color: #333; - - pre { - background-color: #333; - color: #eee; + .line.hll { + background: #558; } - .hll { display: block; background-color: darken($hover, 65%) } - .c { color: #888888; font-style: italic } /* Comment */ - .err { color: #a61717; background-color: #e3d2d2 } /* Error */ - .k { color: #CDA869; font-weight: bold } /* Keyword */ - .kp { color: #CDA869; font-weight: bold } /* Keyword */ - .cm { color: #888888 } /* Comment.Multiline */ - .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ - .c1 { color: #888888 } /* Comment.Single */ - .cs { color: #cc0000; font-weight: bold; background-color: transparent } /* Comment.Special */ - .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ - .ge { font-style: italic } /* Generic.Emph */ - .gr { color: #aa0000 } /* Generic.Error */ - .gh { color: #303030 } /* Generic.Heading */ - .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ - .go { color: #888888 } /* Generic.Output */ - .gp { color: #555555 } /* Generic.Prompt */ - .gs { font-weight: bold } /* Generic.Strong */ - .gu { color: #606060 } /* Generic.Subheading */ - .gt { color: #aa0000 } /* Generic.Traceback */ - .kc{font-weight: bold;} /* Keyword.Constant */ - .kd{font-weight: bold;} /* Keyword.Declaration */ - .kn{font-weight: bold;} /* Keyword.Namespace */ - .kp{font-weight: bold;} /* Keyword.Pseudo */ - .kr{font-weight: bold;} /* Keyword.Reserved */ - .kt{color: #458;font-weight: bold;} /* Keyword.Type */ - .m { color: #0000DD; font-weight: bold } /* Literal.Number */ - .p { color: #eee; } - .s { color: #0AD; background-color: transparent } /* Literal.String */ - .na{color: #008080;} /* Name.Attribute */ - .nb{color: #0086B3;} /* Name.Builtin */ - .nc{color: #ccc;font-weight: bold;} /* Name.Class */ - .no{color: turquoise;} /* Name.Constant */ - .ni{color: #800080;} - .ne{color: #900;font-weight: bold;} /* Name.Exception */ - .nf{color: #ccc;font-weight: bold;} /* Name.Function */ - .nn{color: #79C3E0;font-weight: bold;} /* Name.Namespace */ - .nt{color: #fc5;} /* Name.Tag */ - .nv{color: #FA4;} /* Name.Variable */ - .py { color: #336699; font-weight: bold } /* Name.Property */ - .ow { color: #008800 } /* Operator.Word */ - .w { color: #bbbbbb } /* Text.Whitespace */ - .mf { color: #7AC; font-weight: bold } /* Literal.Number.Float */ - .mh { color: #7AC; font-weight: bold } /* Literal.Number.Hex */ - .mi {color: #099;} /* Literal.Number.Integer */ - .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ - .sb { color: #dd2200; background-color: transparent; } /* Literal.String.Backtick */ - .sc{color: #d14;} /* Literal.String.Char */ - .sd { color: #dd2200; background-color: transparent; } /* Literal.String.Doc */ - .s2{color: orange;} /* Literal.String.Double */ - .se{color: orange;} /* Literal.String.Escape */ - .sh{color: orange;} /* Literal.String.Heredoc */ - .si{color: orange;} /* Literal.String.Interpol */ - .sx{color: orange;} /* Literal.String.Other */ - .sr{color: orange;} /* Literal.String.Regex */ - .s1{color: orange;} /* Literal.String.Single */ - .ss{color: orange;} /* Literal.String.Symbol */ - .bp { color: #D58 } /* Name.Builtin.Pseudo */ - .vc { color: #336699 } /* Name.Variable.Class */ - .vg { color: #dd7700 } /* Name.Variable.Global */ - .vi { color: cyan } -} + .highlight{ + border-left: 1px solid #444; + } + .no-highlight { + color: #DDD; + } + + .line-numbers a { + color: #666; + } + + pre { + background-color: #232323; + } + + .hljs { + display: block; + background: #232323; + color: #E6E1DC; + } + + .hljs-comment, + .hljs-template_comment, + .hljs-javadoc, + .hljs-shebang { + color: #BC9458; + font-style: italic; + } + + .hljs-keyword, + .ruby .hljs-function .hljs-keyword, + .hljs-request, + .hljs-status, + .nginx .hljs-title, + .method, + .hljs-list .hljs-title { + color: #C26230; + } + + .hljs-string, + .hljs-number, + .hljs-regexp, + .hljs-tag .hljs-value, + .hljs-cdata, + .hljs-filter .hljs-argument, + .hljs-attr_selector, + .apache .hljs-cbracket, + .hljs-date, + .tex .hljs-command, + .markdown .hljs-link_label { + color: #A5C261; + } + + .hljs-subst { + color: #519F50; + } + + .hljs-tag, + .hljs-tag .hljs-keyword, + .hljs-tag .hljs-title, + .hljs-doctype, + .hljs-sub .hljs-identifier, + .hljs-pi, + .input_number { + color: #E8BF6A; + } + + .hljs-identifier { + color: #D0D0FF; + } + + .hljs-class .hljs-title, + .haskell .hljs-type, + .smalltalk .hljs-class, + .hljs-javadoctag, + .hljs-yardoctag, + .hljs-phpdoc { + text-decoration: none; + } + + .hljs-constant { + color: #DA4939; + } + + + .hljs-symbol, + .hljs-built_in, + .ruby .hljs-symbol .hljs-string, + .ruby .hljs-symbol .hljs-identifier, + .markdown .hljs-link_url, + .hljs-attribute { + color: #6D9CBE; + } + + .markdown .hljs-link_url { + text-decoration: underline; + } + + + + .hljs-params, + .hljs-variable, + .clojure .hljs-attribute { + color: #D0D0FF; + } + + .css .hljs-tag, + .hljs-rules .hljs-property, + .hljs-pseudo, + .tex .hljs-special { + color: #CDA869; + } + + .css .hljs-class { + color: #9B703F; + } + + .hljs-rules .hljs-keyword { + color: #C5AF75; + } + + .hljs-rules .hljs-value { + color: #CF6A4C; + } + + .css .hljs-id { + color: #8B98AB; + } + + .hljs-annotation, + .apache .hljs-sqbracket, + .nginx .hljs-built_in { + color: #9B859D; + } + + .hljs-preprocessor, + .hljs-preprocessor *, + .hljs-pragma { + color: #8996A8 !important; + } + + .hljs-hexcolor, + .css .hljs-value .hljs-number { + color: #A5C261; + } + + .hljs-title, + .hljs-decorator, + .css .hljs-function { + color: #FFC66D; + } + + .diff .hljs-header, + .hljs-chunk { + background-color: #2F33AB; + color: #E6E1DC; + display: inline-block; + width: 100%; + } + + .diff .hljs-change { + background-color: #4A410D; + color: #F8F8F8; + display: inline-block; + width: 100%; + } + + .hljs-addition { + background-color: #144212; + color: #E6E1DC; + display: inline-block; + width: 100%; + } + + .hljs-deletion { + background-color: #600; + color: #E6E1DC; + display: inline-block; + width: 100%; + } + + .coffeescript .javascript, + .javascript .xml, + .tex .hljs-formula, + .xml .javascript, + .xml .vbscript, + .xml .css, + .xml .hljs-cdata { + opacity: 0.7; + } +} diff --git a/app/assets/stylesheets/highlight/monokai.scss b/app/assets/stylesheets/highlight/monokai.scss index c9709fa7f1..36bc5df2f4 100644 --- a/app/assets/stylesheets/highlight/monokai.scss +++ b/app/assets/stylesheets/highlight/monokai.scss @@ -1,89 +1,148 @@ -$monokai-fg: #f8f8f2; -$monokai-comment: #75715e; -$monokai-pink: #f92672; -$monokai-blue: #66d9ef; -$monokai-green: #a6e22e; -$monokai-gold: #e6db74; -$monokai-dark: #3b3a32; -$monokai-purple: #ae81ff; - -.monokai .highlight { - +.monokai { background-color: #272822; + .highlight{ + border-left: 1px solid #444; + } + + .line.hll { + background: #558; + } + + .no-highlight { + color: #DDD; + } + + .line-numbers a { + color: #666; + } + pre { background-color: #272822; - color: $monokai-fg; + color: #f8f8f2; } - .hll { background-color: darken($hover, 65%) } - .c { color: $monokai-comment } /* Comment */ - .err { color: $monokai-fg } /* Error */ - .g { color: $monokai-fg } /* Generic */ - .k { color: $monokai-pink } /* Keyword */ - .l { color: $monokai-fg } /* Literal */ - .n { color: $monokai-blue } /* Name */ - .o { color: $monokai-fg } /* Operator */ - .x { color: $monokai-fg } /* Other */ - .p { color: $monokai-fg } /* Punctuation */ - .cm { color: $monokai-comment } /* Comment.Multiline */ - .cp { color: $monokai-comment } /* Comment.Preproc */ - .c1 { color: $monokai-comment } /* Comment.Single */ - .cs { color: $monokai-comment } /* Comment.Special */ - .gd { color: #8b0807 } /* Generic.Deleted */ - .ge { color: $monokai-fg; text-decoration: underline } /* Generic.Emph */ - .gr { color: $monokai-fg } /* Generic.Error */ - .gh { color: $monokai-fg; font-weight: bold } /* Generic.Heading */ - .gi { color: $monokai-fg; font-weight: bold; background-color: #46830c } /* Generic.Inserted */ - .go { color: $monokai-dark; background-color: #31322c } /* Generic.Output */ - .gp { color: $monokai-fg } /* Generic.Prompt */ - .gs { color: $monokai-fg } /* Generic.Strong */ - .gu { color: $monokai-fg; font-weight: bold } /* Generic.Subheading */ - .gt { color: #f8f8f0; background-color: $monokai-pink } /* Generic.Traceback */ - .kc { color: $monokai-purple } /* Keyword.Constant */ - .kd { color: $monokai-pink } /* Keyword.Declaration */ - .kn { color: $monokai-pink } /* Keyword.Namespace */ - .kp { color: $monokai-pink } /* Keyword.Pseudo */ - .kr { color: $monokai-pink } /* Keyword.Reserved */ - .kt { color: $monokai-fg } /* Keyword.Type */ - .ld { color: $monokai-fg } /* Literal.Date */ - .m { color: $monokai-purple } /* Literal.Number */ - .s { color: $monokai-gold } /* Literal.String */ - .na { color: $monokai-purple } /* Name.Attribute */ - .nb { color: $monokai-blue } /* Name.Builtin */ - .nc { color: $monokai-fg } /* Name.Class */ - .no { color: $monokai-fg } /* Name.Constant */ - .nd { color: $monokai-fg } /* Name.Decorator */ - .ni { color: $monokai-fg } /* Name.Entity */ - .ne { color: $monokai-fg } /* Name.Exception */ - .nf { color: $monokai-green } /* Name.Function */ - .nl { color: $monokai-gold } /* Name.Label */ - .nn { color: $monokai-fg } /* Name.Namespace */ - .nx { color: $monokai-fg } /* Name.Other */ - .nt { color: $monokai-pink } /* Name.Tag */ - .nv { color: $monokai-blue; font-style: italic } /* Name.Variable */ - .py { color: $monokai-fg } /* Name.Property */ - .ow { color: $monokai-pink } /* Operator.Word */ - .w { color: $monokai-fg } /* Text.Whitespace */ - .mf { color: $monokai-purple } /* Literal.Number.Float */ - .mh { color: $monokai-purple } /* Literal.Number.Hex */ - .mi { color: $monokai-purple } /* Literal.Number.Integer */ - .mo { color: $monokai-purple } /* Literal.Number.Oct */ - .sb { color: $monokai-gold } /* Literal.String.Backtick */ - .sc { color: $monokai-gold } /* Literal.String.Char */ - .sd { color: $monokai-gold } /* Literal.String.Doc */ - .s2 { color: $monokai-gold } /* Literal.String.Double */ - .se { color: $monokai-gold } /* Literal.String.Escape */ - .sh { color: $monokai-gold } /* Literal.String.Heredoc */ - .si { color: $monokai-gold } /* Literal.String.Interpol */ - .sx { color: $monokai-gold } /* Literal.String.Other */ - .sr { color: $monokai-gold } /* Literal.String.Regex */ - .s1 { color: $monokai-gold } /* Literal.String.Single */ - .ss { color: $monokai-gold } /* Literal.String.Symbol */ - .bp { color: $monokai-fg } /* Name.Builtin.Pseudo */ - .vc { color: $monokai-blue; font-style: italic } /* Name.Variable.Class */ - .vg { color: $monokai-blue; font-style: italic } /* Name.Variable.Global */ - .vi { color: $monokai-blue; font-style: italic } /* Name.Variable.Instance */ - .il { color: $monokai-purple } /* Literal.Number.Integer.Long */ -} + .hljs { + display: block; + background: #272822; + } + .hljs-tag, + .hljs-tag .hljs-title, + .hljs-keyword, + .hljs-literal, + .hljs-strong, + .hljs-change, + .hljs-winutils, + .hljs-flow, + .lisp .hljs-title, + .clojure .hljs-built_in, + .nginx .hljs-title, + .tex .hljs-special { + color: #F92672; + } + + .hljs { + color: #DDD; + } + + .hljs .hljs-constant, + .asciidoc .hljs-code { + color: #66D9EF; + } + + .hljs-code, + .hljs-class .hljs-title, + .hljs-header { + color: white; + } + + .hljs-link_label, + .hljs-attribute, + .hljs-symbol, + .hljs-symbol .hljs-string, + .hljs-value, + .hljs-regexp { + color: #BF79DB; + } + + .hljs-link_url, + .hljs-tag .hljs-value, + .hljs-string, + .hljs-bullet, + .hljs-subst, + .hljs-title, + .hljs-emphasis, + .haskell .hljs-type, + .hljs-preprocessor, + .hljs-pragma, + .ruby .hljs-class .hljs-parent, + .hljs-built_in, + .sql .hljs-aggregate, + .django .hljs-template_tag, + .django .hljs-variable, + .smalltalk .hljs-class, + .hljs-javadoc, + .django .hljs-filter .hljs-argument, + .smalltalk .hljs-localvars, + .smalltalk .hljs-array, + .hljs-attr_selector, + .hljs-pseudo, + .hljs-addition, + .hljs-stream, + .hljs-envvar, + .apache .hljs-tag, + .apache .hljs-cbracket, + .tex .hljs-command, + .hljs-prompt { + color: #A6E22E; + } + + .hljs-comment, + .java .hljs-annotation, + .smartquote, + .hljs-blockquote, + .hljs-horizontal_rule, + .python .hljs-decorator, + .hljs-template_comment, + .hljs-pi, + .hljs-doctype, + .hljs-deletion, + .hljs-shebang, + .apache .hljs-sqbracket, + .tex .hljs-formula { + color: #75715E; + } + + .hljs-keyword, + .hljs-literal, + .css .hljs-id, + .hljs-phpdoc, + .hljs-title, + .hljs-header, + .haskell .hljs-type, + .vbscript .hljs-built_in, + .sql .hljs-aggregate, + .rsl .hljs-built_in, + .smalltalk .hljs-class, + .diff .hljs-header, + .hljs-chunk, + .hljs-winutils, + .bash .hljs-variable, + .apache .hljs-tag, + .tex .hljs-special, + .hljs-request, + .hljs-status { + font-weight: bold; + } + + .coffeescript .javascript, + .javascript .xml, + .tex .hljs-formula, + .xml .javascript, + .xml .vbscript, + .xml .css, + .xml .hljs-cdata { + opacity: 0.5; + } +} diff --git a/app/assets/stylesheets/highlight/solarized_dark.scss b/app/assets/stylesheets/highlight/solarized_dark.scss index cc82f39ac9..b9bec22518 100644 --- a/app/assets/stylesheets/highlight/solarized_dark.scss +++ b/app/assets/stylesheets/highlight/solarized_dark.scss @@ -1,80 +1,125 @@ -.solarized-dark .highlight { - +.solarized-dark { background-color: #002B36; - + + .highlight{ + border-left: 1px solid #113b46; + } + + .line.hll { + background: #000; + } + + .no-highlight { + color: #DDD; + } + pre { background-color: #002B36; color: #eee; } - .hll { background-color: #073642 } - .c { color: #586E75 } /* Comment */ - .err { color: #93A1A1 } /* Error */ - .g { color: #93A1A1 } /* Generic */ - .k { color: #859900 } /* Keyword */ - .l { color: #93A1A1 } /* Literal */ - .n { color: #93A1A1 } /* Name */ - .o { color: #859900 } /* Operator */ - .x { color: #CB4B16 } /* Other */ - .p { color: #93A1A1 } /* Punctuation */ - .cm { color: #586E75 } /* Comment.Multiline */ - .cp { color: #859900 } /* Comment.Preproc */ - .c1 { color: #586E75 } /* Comment.Single */ - .cs { color: #859900 } /* Comment.Special */ - .gd { color: #2AA198 } /* Generic.Deleted */ - .ge { color: #93A1A1; font-style: italic } /* Generic.Emph */ - .gr { color: #DC322F } /* Generic.Error */ - .gh { color: #CB4B16 } /* Generic.Heading */ - .gi { color: #859900 } /* Generic.Inserted */ - .go { color: #93A1A1 } /* Generic.Output */ - .gp { color: #93A1A1 } /* Generic.Prompt */ - .gs { color: #93A1A1; font-weight: bold } /* Generic.Strong */ - .gu { color: #CB4B16 } /* Generic.Subheading */ - .gt { color: #93A1A1 } /* Generic.Traceback */ - .kc { color: #CB4B16 } /* Keyword.Constant */ - .kd { color: #268BD2 } /* Keyword.Declaration */ - .kn { color: #859900 } /* Keyword.Namespace */ - .kp { color: #859900 } /* Keyword.Pseudo */ - .kr { color: #268BD2 } /* Keyword.Reserved */ - .kt { color: #DC322F } /* Keyword.Type */ - .ld { color: #93A1A1 } /* Literal.Date */ - .m { color: #2AA198 } /* Literal.Number */ - .s { color: #2AA198 } /* Literal.String */ - .na { color: #93A1A1 } /* Name.Attribute */ - .nb { color: #B58900 } /* Name.Builtin */ - .nc { color: #268BD2 } /* Name.Class */ - .no { color: #CB4B16 } /* Name.Constant */ - .nd { color: #268BD2 } /* Name.Decorator */ - .ni { color: #CB4B16 } /* Name.Entity */ - .ne { color: #CB4B16 } /* Name.Exception */ - .nf { color: #268BD2 } /* Name.Function */ - .nl { color: #93A1A1 } /* Name.Label */ - .nn { color: #93A1A1 } /* Name.Namespace */ - .nx { color: #93A1A1 } /* Name.Other */ - .py { color: #93A1A1 } /* Name.Property */ - .nt { color: #268BD2 } /* Name.Tag */ - .nv { color: #268BD2 } /* Name.Variable */ - .ow { color: #859900 } /* Operator.Word */ - .w { color: #93A1A1 } /* Text.Whitespace */ - .mf { color: #2AA198 } /* Literal.Number.Float */ - .mh { color: #2AA198 } /* Literal.Number.Hex */ - .mi { color: #2AA198 } /* Literal.Number.Integer */ - .mo { color: #2AA198 } /* Literal.Number.Oct */ - .sb { color: #586E75 } /* Literal.String.Backtick */ - .sc { color: #2AA198 } /* Literal.String.Char */ - .sd { color: #93A1A1 } /* Literal.String.Doc */ - .s2 { color: #2AA198 } /* Literal.String.Double */ - .se { color: #CB4B16 } /* Literal.String.Escape */ - .sh { color: #93A1A1 } /* Literal.String.Heredoc */ - .si { color: #2AA198 } /* Literal.String.Interpol */ - .sx { color: #2AA198 } /* Literal.String.Other */ - .sr { color: #DC322F } /* Literal.String.Regex */ - .s1 { color: #2AA198 } /* Literal.String.Single */ - .ss { color: #2AA198 } /* Literal.String.Symbol */ - .bp { color: #268BD2 } /* Name.Builtin.Pseudo */ - .vc { color: #268BD2 } /* Name.Variable.Class */ - .vg { color: #268BD2 } /* Name.Variable.Global */ - .vi { color: #268BD2 } /* Name.Variable.Instance */ - .il { color: #2AA198 } /* Literal.Number.Integer.Long */ -} + .line-numbers a { + color: #666; + } + .hljs { + display: block; + background: #002b36; + color: #839496; + } + + .hljs-comment, + .hljs-template_comment, + .diff .hljs-header, + .hljs-doctype, + .hljs-pi, + .lisp .hljs-string, + .hljs-javadoc { + color: #586e75; + } + + /* Solarized Green */ + .hljs-keyword, + .hljs-winutils, + .method, + .hljs-addition, + .css .hljs-tag, + .hljs-request, + .hljs-status, + .nginx .hljs-title { + color: #859900; + } + + /* Solarized Cyan */ + .hljs-number, + .hljs-command, + .hljs-string, + .hljs-tag .hljs-value, + .hljs-rules .hljs-value, + .hljs-phpdoc, + .tex .hljs-formula, + .hljs-regexp, + .hljs-hexcolor, + .hljs-link_url { + color: #2aa198; + } + + /* Solarized Blue */ + .hljs-title, + .hljs-localvars, + .hljs-chunk, + .hljs-decorator, + .hljs-built_in, + .hljs-identifier, + .vhdl .hljs-literal, + .hljs-id, + .css .hljs-function { + color: #268bd2; + } + + /* Solarized Yellow */ + .hljs-attribute, + .hljs-variable, + .lisp .hljs-body, + .smalltalk .hljs-number, + .hljs-constant, + .hljs-class .hljs-title, + .hljs-parent, + .haskell .hljs-type, + .hljs-link_reference { + color: #b58900; + } + + /* Solarized Orange */ + .hljs-preprocessor, + .hljs-preprocessor .hljs-keyword, + .hljs-pragma, + .hljs-shebang, + .hljs-symbol, + .hljs-symbol .hljs-string, + .diff .hljs-change, + .hljs-special, + .hljs-attr_selector, + .hljs-subst, + .hljs-cdata, + .clojure .hljs-title, + .css .hljs-pseudo, + .hljs-header { + color: #cb4b16; + } + + /* Solarized Red */ + .hljs-deletion, + .hljs-important { + color: #dc322f; + } + + /* Solarized Violet */ + .hljs-link_label { + color: #6c71c4; + } + + .tex .hljs-formula { + background: #073642; + } +} diff --git a/app/assets/stylesheets/highlight/white.scss b/app/assets/stylesheets/highlight/white.scss index df127a7c49..c06bed3c21 100644 --- a/app/assets/stylesheets/highlight/white.scss +++ b/app/assets/stylesheets/highlight/white.scss @@ -1,72 +1,186 @@ -.white .highlight { - +.white { background-color: #fff; - + + .line.hll { + background: #FFA; + } + + .highlight{ + border-left: 1px solid #eee; + } + pre { background-color: #fff; color: #333; } - .hll { display: block; background-color: $hover } - .c { color: #888888; font-style: italic } /* Comment */ - .err { color: #a61717; background-color: #e3d2d2 } /* Error */ - .k { color: #000000; font-weight: bold } /* Keyword */ - .cm { color: #888888 } /* Comment.Multiline */ - .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ - .c1 { color: #888888 } /* Comment.Single */ - .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ - .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ - .ge { font-style: italic } /* Generic.Emph */ - .gr { color: #aa0000 } /* Generic.Error */ - .gh { color: #303030 } /* Generic.Heading */ - .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ - .go { color: #888888 } /* Generic.Output */ - .gp { color: #555555 } /* Generic.Prompt */ - .gs { font-weight: bold } /* Generic.Strong */ - .gu { color: #606060 } /* Generic.Subheading */ - .gt { color: #aa0000 } /* Generic.Traceback */ - .kc{font-weight: bold;} /* Keyword.Constant */ - .kd{font-weight: bold;} /* Keyword.Declaration */ - .kn{font-weight: bold;} /* Keyword.Namespace */ - .kp{font-weight: bold;} /* Keyword.Pseudo */ - .kr{font-weight: bold;} /* Keyword.Reserved */ - .kt{color: #458;font-weight: bold;} /* Keyword.Type */ - .m { color: #0000DD; font-weight: bold } /* Literal.Number */ - .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ - .na{color: #008080;} /* Name.Attribute */ - .nb{color: #0086B3;} /* Name.Builtin */ - .nc{color: #458;font-weight: bold;} /* Name.Class */ - .no{color: #008080;} /* Name.Constant */ - .ni{color: #800080;} - .ne{color: #900;font-weight: bold;} /* Name.Exception */ - .nf{color: #900;font-weight: bold;} /* Name.Function */ - .nn{color: #005;font-weight: bold;} /* Name.Namespace */ - .nt{color: #000080;} /* Name.Tag */ - .nv{color: #008080;} /* Name.Variable */ - .py { color: #336699; font-weight: bold } /* Name.Property */ - .ow { color: #008800 } /* Operator.Word */ - .w { color: #bbbbbb } /* Text.Whitespace */ - .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ - .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ - .mi {color: #099;} /* Literal.Number.Integer */ - .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ - .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ - .sc{color: #d14;} /* Literal.String.Char */ - .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ - .s2{color: #d14;} /* Literal.String.Double */ - .se{color: #d14;} /* Literal.String.Escape */ - .sh{color: #d14;} /* Literal.String.Heredoc */ - .si{color: #d14;} /* Literal.String.Interpol */ - .sx{color: #d14;} /* Literal.String.Other */ - .sr{color: #d14;} /* Literal.String.Regex */ - .s1{color: #d14;} /* Literal.String.Single */ - .ss{color: #d14;} /* Literal.String.Symbol */ - .bp { color: #003388 } /* Name.Builtin.Pseudo */ - .vc { color: #336699 } /* Name.Variable.Class */ - .vg { color: #dd7700 } /* Name.Variable.Global */ - .vi { color: #3333bb } + .hljs { + background: #FFF; + } + + .line-numbers a { + color: #999; + } + + .hljs { + display: block; + background: #fff; color: black; + } + + .hljs-comment, + .hljs-template_comment, + .hljs-javadoc, + .hljs-comment * { + color: #006a00; + } + + .hljs-keyword, + .hljs-literal, + .nginx .hljs-title { + color: #aa0d91; + } + .method, + .hljs-list .hljs-title, + .hljs-tag .hljs-title, + .setting .hljs-value, + .hljs-winutils, + .tex .hljs-command, + .http .hljs-title, + .hljs-request, + .hljs-status { + color: #008; + } + + .hljs-envvar, + .tex .hljs-special { + color: #660; + } + + .hljs-string { + color: #c41a16; + } + .hljs-tag .hljs-value, + .hljs-cdata, + .hljs-filter .hljs-argument, + .hljs-attr_selector, + .apache .hljs-cbracket, + .hljs-date, + .hljs-regexp { + color: #080; + } + + .hljs-sub .hljs-identifier, + .hljs-pi, + .hljs-tag, + .hljs-tag .hljs-keyword, + .hljs-decorator, + .ini .hljs-title, + .hljs-shebang, + .hljs-prompt, + .hljs-hexcolor, + .hljs-rules .hljs-value, + .hljs-symbol, + .hljs-symbol .hljs-string, + .hljs-number, + .css .hljs-function, + .clojure .hljs-title, + .clojure .hljs-built_in, + .hljs-function .hljs-title, + .coffeescript .hljs-attribute { + color: #1c00cf; + } + + .hljs-class .hljs-title, + .haskell .hljs-type, + .smalltalk .hljs-class, + .hljs-javadoctag, + .hljs-yardoctag, + .hljs-phpdoc, + .hljs-typename, + .hljs-tag .hljs-attribute, + .hljs-doctype, + .hljs-class .hljs-id, + .hljs-built_in, + .setting, + .hljs-params, + .clojure .hljs-attribute { + color: #5c2699; + } + + .hljs-variable { + color: #3f6e74; + } + .css .hljs-tag, + .hljs-rules .hljs-property, + .hljs-pseudo, + .hljs-subst { + color: #000; + } + + .css .hljs-class, + .css .hljs-id { + color: #9B703F; + } + + .hljs-value .hljs-important { + color: #ff7700; + font-weight: bold; + } + + .hljs-rules .hljs-keyword { + color: #C5AF75; + } + + .hljs-annotation, + .apache .hljs-sqbracket, + .nginx .hljs-built_in { + color: #9B859D; + } + + .hljs-preprocessor, + .hljs-preprocessor *, + .hljs-pragma { + color: #643820; + } + + .tex .hljs-formula { + background-color: #EEE; + font-style: italic; + } + + .diff .hljs-header, + .hljs-chunk { + color: #808080; + font-weight: bold; + } + + .diff .hljs-change { + background-color: #BCCFF9; + } + + .hljs-addition { + background-color: #BAEEBA; + } + + .hljs-deletion { + background-color: #FFC8BD; + } + + .hljs-comment .hljs-yardoctag { + font-weight: bold; + } + + .method .hljs-id { + color: #000; + } } .shadow { @include box-shadow(0 5px 15px #000); } + +.wiki, .note-body { + .highlight { + border: 1px solid #DDD; + } +} diff --git a/app/assets/stylesheets/jquery.ui.gitlab.css b/app/assets/stylesheets/jquery.ui.gitlab.css deleted file mode 100644 index 5c51600ba6..0000000000 --- a/app/assets/stylesheets/jquery.ui.gitlab.css +++ /dev/null @@ -1,257 +0,0 @@ -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { cursor: default !important; } - - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - - -/* - * jQuery UI CSS Framework 1.8.7 - * - * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - * - * To view and modify this theme, visit http://jqueryui.com/themeroller/?ctl=themeroller - */ - - -/* Component containers -----------------------------------*/ -.ui-widget { font-family: Arial,sans-serif; font-size: 1.1em; } -.ui-widget .ui-widget { font-size: 1em; } -.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Arial,sans-serif; font-size: 1em; } -.ui-widget-content { border: 1px solid #CCC; background: #ffffff; color: #4F4F4F; } -.ui-widget-content a { color: #4F4F4F; } -.ui-widget-header { border: 1px solid #B6B6B6; color: #4F4F4F; font-weight: bold; } -.ui-widget-header { - background: #ededed url(bg_fallback.png) 0 0 repeat-x; /* Old browsers */ - background: -moz-linear-gradient(top, #ededed 0%, #c4c4c4 100%); /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ededed), color-stop(100%,#c4c4c4)); /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* Opera11.10+ */ - background: -ms-linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* IE10+ */ - background: linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* W3C */ -} -.ui-widget-header a { color: #4F4F4F; } - -/* Interaction states -----------------------------------*/ -.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #B6B6B6; font-weight: normal; color: #4F4F4F; } -.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { - background: #ededed url(bg_fallback.png) 0 0 repeat-x; /* Old browsers */ - background: -moz-linear-gradient(top, #ededed 0%, #c4c4c4 100%); /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ededed), color-stop(100%,#c4c4c4)); /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* Opera11.10+ */ - background: -ms-linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* IE10+ */ - background: linear-gradient(top, #ededed 0%,#c4c4c4 100%); /* W3C */ - -webkit-box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset; - -moz-box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset; - box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset; -} -.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #4F4F4F; text-decoration: none; } -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #9D9D9D; font-weight: normal; color: #313131; } -.ui-state-hover a, .ui-state-hover a:hover { color: #313131; text-decoration: none; } -.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { - outline: none; - color: #1c4257; border: 1px solid #7096ab; - background: #ededed url(bg_fallback.png) 0 -50px repeat-x; /* Old browsers */ - background: -moz-linear-gradient(top, #b9e0f5 0%, #92bdd6 100%); /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b9e0f5), color-stop(100%,#92bdd6)); /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* Opera11.10+ */ - background: -ms-linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* IE10+ */ - background: linear-gradient(top, #b9e0f5 0%,#92bdd6 100%); /* W3C */ - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; -} -.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #313131; text-decoration: none; } -.ui-widget :active { outline: none; } - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight { border: 1px solid #d2dbf4; background: #f4f8fd; color: #0d2054; -moz-border-radius: 0 !important; -webkit-border-radius: 0 !important; border-radius: 0 !important; } -.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; } -.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error { border: 1px solid #e2d0d0; background: #fcf0f0; color: #280b0b; -moz-border-radius: 0 !important; -webkit-border-radius: 0 !important; border-radius: 0 !important; } -.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a; } -.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a; } -.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } -.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } -.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } - -/* Icons -----------------------------------*/ - -/* states and images */ -.ui-icon { width: 16px; height: 16px; background-image: url(ui-icons_222222_256x240.png); } -.ui-widget-content .ui-icon {background-image: url(ui-icons_222222_256x240.png); } -.ui-widget-header .ui-icon {background-image: url(ui-icons_222222_256x240.png); } -.ui-state-default .ui-icon { background-image: url(ui-icons_454545_256x240.png); } -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(ui-icons_454545_256x240.png); } -.ui-state-active .ui-icon {background-image: url(ui-icons_454545_256x240.png); } -.ui-state-highlight .ui-icon {background-image: url(ui-icons_454545_256x240.png); } -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon { background: url(icon_sprite.png) -16px 0 no-repeat !important; } -.ui-state-highlight .ui-icon, .ui-state-error .ui-icon { margin-top: -1px; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { background: #262b33; opacity: .70;filter:Alpha(Opacity=70); } -.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #000000; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; } -/* - * jQuery UI Selectable 1.8.7 - * - * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Selectable#theming - */ -.ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; } -/* - * jQuery UI Autocomplete 1.8.7 - * - * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Autocomplete#theming - */ -.ui-autocomplete { - position: absolute; cursor: default; z-index: 3; - -moz-border-radius: 0; - -webkit-border-radius: 0; - border-radius: 0; - -moz-box-shadow: 0 1px 5px rgba(0,0,0,0.3); - -webkit-box-shadow: 0 1px 5px rgba(0,0,0,0.3); - box-shadow: 0 1px 5px rgba(0,0,0,0.3); -} - -/* workarounds */ -* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */ - -/* - * jQuery UI Menu 1.8.7 - * - * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Menu#theming - */ -.ui-menu { - list-style:none; - padding: 1px; - margin: 0; - display:block; - float: left; -} -.ui-menu .ui-menu { - margin-top: -3px; -} -.ui-menu .ui-menu-item { - margin:0; - padding: 0; - zoom: 1; - float: left; - clear: left; - width: 100%; -} -.ui-menu .ui-menu-item a { - text-decoration:none; - display:block; - padding:.2em .4em; - line-height:1.5; - zoom:1; - color: #666; - font-size: 13px; -} -.ui-menu .ui-menu-item a.ui-state-hover, -.ui-menu .ui-menu-item a.ui-state-active { - font-weight: normal; - margin: -1px; - background: #D9EDF7; - color: #3A89A3; - text-shadow: 0px 1px 1px #fff; - border: none; - border: 1px solid #ADE; - cursor: pointer; - font-weight: bold; -} - -/* - * jQuery UI Datepicker 1.8.7 - * - * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Datepicker#theming - */ -.ui-datepicker { - width: 17em; - padding: 0; - display: none; - border-color: #DDDDDD; - border: none; - box-shadow: none; -} -.ui-datepicker .ui-datepicker-header { - position:relative; - padding:.35em 0; - border: none; - border-bottom: 1px solid #B6B6B6; - -moz-border-radius: 0; - -webkit-border-radius: 0; - border-radius: 0; - margin-bottom: 10px; - border: 1px solid #bbb; - -webkit-box-shadow: 0 0 0 3px #F1F1F1; - -moz-box-shadow: 0 0 0 3px #f1f1f1; - -ms-box-shadow: 0 0 0 3px #f1f1f1; - -o-box-shadow: 0 0 0 3px #f1f1f1; - box-shadow: 0 0 0 3px #F1F1F1; -} - -.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 6px; width: 1.8em; height: 1.8em; } -.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { border: 1px none; } -.ui-datepicker .ui-datepicker-prev { left:2px; } -.ui-datepicker .ui-datepicker-next { right:2px; } -.ui-datepicker .ui-datepicker-prev span { background-position: 0px -32px !important; } -.ui-datepicker .ui-datepicker-next span { background-position: -16px -32px !important; } -.ui-datepicker .ui-datepicker-prev-hover span { background-position: 0px -48px !important; } -.ui-datepicker .ui-datepicker-next-hover span { background-position: -16px -48px !important; } -.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; background: url(icon_sprite.png) no-repeat; } -.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; font-size: 12px; text-shadow: 0 1px 0 rgba(255,255,255,0.6); } -.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; } -.ui-datepicker select.ui-datepicker-month-year {width: 100%;} -.ui-datepicker select.ui-datepicker-month, -.ui-datepicker select.ui-datepicker-year { width: 49%;} -.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } -.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } -.ui-datepicker td { border: 0; padding: 1px; line-height: 24px; background-color: #FFF!important; } -.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } -.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } -.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } -.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } -.ui-datepicker table .ui-state-highlight { border-color: #ADE; } -.ui-datepicker-calendar .ui-state-default { background: transparent; border-color: #FFF; } -.ui-datepicker-calendar .ui-state-active { background: #D9EDF7; border-color: #ADE; color: #3A89A3; font-weight: bold; text-shadow: 0 1px 1px #fff; } diff --git a/app/assets/stylesheets/gitlab_bootstrap/fonts.scss b/app/assets/stylesheets/main/fonts.scss similarity index 67% rename from app/assets/stylesheets/gitlab_bootstrap/fonts.scss rename to app/assets/stylesheets/main/fonts.scss index 8cc9986415..d90274a0db 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/fonts.scss +++ b/app/assets/stylesheets/main/fonts.scss @@ -1,2 +1,3 @@ /** Typo **/ $monospace_font: 'Menlo', 'Liberation Mono', 'Consolas', 'Courier New', 'andale mono', 'lucida console', monospace; +$regular_font: "Helvetica Neue", Helvetica, Arial, sans-serif; diff --git a/app/assets/stylesheets/main/layout.scss b/app/assets/stylesheets/main/layout.scss new file mode 100644 index 0000000000..e28da65c01 --- /dev/null +++ b/app/assets/stylesheets/main/layout.scss @@ -0,0 +1,18 @@ +html { + overflow-y: scroll; + + &.touch .tooltip { display: none !important; } +} + +body { + padding-bottom: 20px; +} + +.container { + padding-top: 0; + z-index: 5; +} + +.container .content { + margin: 0 0; +} diff --git a/app/assets/stylesheets/gitlab_bootstrap/mixins.scss b/app/assets/stylesheets/main/mixins.scss similarity index 59% rename from app/assets/stylesheets/gitlab_bootstrap/mixins.scss rename to app/assets/stylesheets/main/mixins.scss index 8b975a12cf..8143cfa2c8 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/mixins.scss +++ b/app/assets/stylesheets/main/mixins.scss @@ -25,6 +25,7 @@ background-image: -webkit-gradient(linear, 0 0, 0 100%, from($from), to($to)); background-image: -webkit-linear-gradient($from, $to); background-image: -moz-linear-gradient($from, $to); + background-image: -ms-linear-gradient($from, $to); background-image: -o-linear-gradient($from, $to); } @@ -40,28 +41,6 @@ * Prefilled mixins * Mixins with fixed values */ -@mixin bg-light-gray-gradient { - background: #f1f1f1; - background-image: -webkit-gradient(linear, 0 0, 0 30, color-stop(0.066, #f5f5f5), to(#e1e1e1)); - background-image: -webkit-linear-gradient(#f5f5f5 6.6%, #e1e1e1); - background-image: -moz-linear-gradient(#f5f5f5 6.6%, #e1e1e1); - background-image: -o-linear-gradient(#f5f5f5 6.6%, #e1e1e1); -} - -@mixin bg-gray-gradient { - background: #eee; - background-image: -webkit-gradient(linear, 0 0, 0 30, color-stop(0.066, #eee), to(#dfdfdf)); - background-image: -webkit-linear-gradient(#eee 6.6%, #dfdfdf); - background-image: -moz-linear-gradient(#eee 6.6%, #dfdfdf); - background-image: -o-linear-gradient(#eee 6.6%, #dfdfdf); -} - -@mixin bg-dark-gray-gradient { - background: #eee; - background-image: -webkit-linear-gradient(#e9e9e9, #d7d7d7); - background-image: -moz-linear-gradient(#e9e9e9, #d7d7d7); - background-image: -o-linear-gradient(#e9e9e9, #d7d7d7); -} @mixin shade { @include box-shadow(0 0 3px #ddd); @@ -73,22 +52,44 @@ @mixin header-font { color: $style_color; - text-shadow: 0 1px 1px #FFF; font-size: 16px; - line-height: 40px; + line-height: 44px; font-weight: normal; } @mixin md-typography { + font-size: 14px; + line-height: 1.6; + + img { + max-width: 100%; + } + *:first-child { margin-top: 0; } code { padding: 0 4px; } - h1 { margin-top: 30px;} - h2 { margin-top: 25px;} - h3 { margin-top: 20px;} - h4 { margin-top: 15px;} + + h1 { + margin-top: 45px; + font-size: 2.5em; + } + + h2 { + margin-top: 40px; + font-size: 2em; + } + + h3 { + margin-top: 35px; + font-size: 1.5em; + } + + h4 { + margin-top: 30px; + font-size: 1.2em; + } blockquote p { color: #888; @@ -103,10 +104,20 @@ background: #EEE; } } + + p > code { + font-size: inherit; + font-weight: inherit; + color: #555; + } + + li { + line-height: 1.5; + } } @mixin page-title { - color: $style_color; + color: #333; font-size: 20px; line-height: 1.5; margin-top: 0px; diff --git a/app/assets/stylesheets/gitlab_bootstrap/variables.scss b/app/assets/stylesheets/main/variables.scss similarity index 72% rename from app/assets/stylesheets/gitlab_bootstrap/variables.scss rename to app/assets/stylesheets/main/variables.scss index aeabe7ad2e..4b5fa0979b 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/variables.scss +++ b/app/assets/stylesheets/main/variables.scss @@ -4,6 +4,8 @@ $primary_color: #2FA0BB; $link_color: #3A89A3; $style_color: #474D57; +$bg_style_color: #2299BB; +$list-group-active-bg: $bg_style_color; $hover: #D9EDF7; /** diff --git a/app/assets/stylesheets/print.scss b/app/assets/stylesheets/print.scss new file mode 100644 index 0000000000..42dbf4d6ef --- /dev/null +++ b/app/assets/stylesheets/print.scss @@ -0,0 +1,13 @@ +/* Generic print styles */ +header, nav, nav.main-nav, nav.navbar-collapse, nav.navbar-collapse.collapse {display: none!important;} +.profiler-results {display: none;} + +/* Styles targeted specifically at printing files */ +.tree-ref-holder, .tree-holder .breadcrumb, .blob-commit-info {display: none;} +.file-title {display: none;} +.file-holder {border: none;} + +.wiki h1, .wiki h2, .wiki h3, .wiki h4, .wiki h5, .wiki h6 {margin-top: 17px; } +.wiki h1 {font-size: 30px;} +.wiki h2 {font-size: 22px;} +.wiki h3 {font-size: 18px; font-weight: bold; } diff --git a/app/assets/stylesheets/sections/admin.scss b/app/assets/stylesheets/sections/admin.scss index e189fd27ac..a558633d11 100644 --- a/app/assets/stylesheets/sections/admin.scss +++ b/app/assets/stylesheets/sections/admin.scss @@ -2,7 +2,7 @@ * Admin area * */ -.admin_dash { +.admin-dashboard { .data { a { h1 { @@ -14,10 +14,29 @@ } } } + + .str-truncated { + max-width: 60%; + } } .admin-filter form { label { width: 110px; } .controls { margin-left: 130px; } .form-actions { padding-left: 130px; background: #fff } + .visibility-levels { + .controls { + margin-bottom: 9px; + } + + i { + color: inherit; + } + } +} + +.broadcast-messages { + .message { + line-height: 2; + } } diff --git a/app/assets/stylesheets/sections/commits.scss b/app/assets/stylesheets/sections/commits.scss index 45a83cb608..855bb4ea01 100644 --- a/app/assets/stylesheets/sections/commits.scss +++ b/app/assets/stylesheets/sections/commits.scss @@ -10,323 +10,6 @@ } } -.file { - border: 1px solid #CCC; - margin-bottom: 1em; - - .header { - @extend .clearfix; - padding: 5px 5px 5px 10px; - color: #555; - border-bottom: 1px solid #CCC; - background: #eee; - // TODO Replace with linear-gradient mixin - background-image: -webkit-gradient(linear, 0 0, 0 30, color-stop(0.066, #eee), to(#dfdfdf)); - background-image: -webkit-linear-gradient(#eee 6.6%, #dfdfdf); - background-image: -moz-linear-gradient(#eee 6.6%, #dfdfdf); - background-image: -o-linear-gradient(#eee 6.6%, #dfdfdf); - - a{ - color: $style_color; - } - - > span { - font-family: $monospace_font; - font-size: 14px; - line-height: 30px; - } - - a.view-file{ - font-weight: bold; - } - - .commit-short-id{ - font-family: $monospace_font; - font-size: smaller; - } - - .file-mode{ - font-family: $monospace_font; - } - } - .content { - overflow: auto; - overflow-y: hidden; - background: #FFF; - color: #333; - font-size: 12px; - .old{ - span.idiff{ - background-color: #FAA; - } - } - .new{ - span.idiff{ - background-color: #AFA; - } - } - - table { - width: 100%; - font-family: $monospace_font; - border: none; - margin: 0px; - padding: 0px; - td { - line-height: 18px; - font-size: 12px; - } - } - .old_line, .new_line { - margin: 0px; - padding: 0px; - border: none; - background: #EEE; - color: #666; - padding: 0px 5px; - border-right: 1px solid #ccc; - text-align: right; - min-width: 35px; - max-width: 35px; - width: 35px; - @include user-select(none); - a { - float: left; - width: 35px; - font-weight: normal; - color: #666; - &:hover { - text-decoration: underline; - } - } - } - .line_holder { - &.old .old_line, - &.old .new_line { - background: #FCC; - border-color: #E7BABA; - } - &.new .old_line, - &.new .new_line { - background: #CFC; - border-color: #B9ECB9; - } - } - .line_content { - display: block; - white-space: pre; - height: 18px; - margin: 0px; - padding: 0px 0.5em; - border: none; - &.new { - background: #CFD; - } - &.old { - background: #FDD; - } - &.matched { - color: #ccc; - background: #fafafa; - } - } - } - .image { - background: #ddd; - text-align: center; - padding: 30px; - .wrap{ - display: inline-block; - } - - .frame { - display: inline-block; - background-color: #fff; - line-height: 0; - img{ - border: 1px solid #FFF; - background: url('trans_bg.gif'); - } - &.deleted { - border: 1px solid $deleted; - } - - &.added { - border: 1px solid $added; - } - } - .image-info{ - font-size: 12px; - margin: 5px 0 0 0; - color: grey; - } - - .view.swipe{ - position: relative; - - .swipe-frame{ - display: block; - margin: auto; - position: relative; - } - .swipe-wrap{ - overflow: hidden; - border-left: 1px solid #999; - position: absolute; - display: block; - top: 13px; - right: 7px; - } - .frame{ - top: 0; - right: 0; - position: absolute; - &.deleted{ - margin: 0; - display: block; - top: 13px; - right: 7px; - } - } - .swipe-bar{ - display: block; - height: 100%; - width: 15px; - z-index: 100; - position: absolute; - cursor: pointer; - &:hover{ - .top-handle{ - background-position: -15px 3px; - } - .bottom-handle{ - background-position: -15px -11px; - } - }; - .top-handle{ - display: block; - height: 14px; - width: 15px; - position: absolute; - top: 0px; - background: url('swipemode_sprites.gif') 0 3px no-repeat; - } - .bottom-handle{ - display: block; - height: 14px; - width: 15px; - position: absolute; - bottom: 0px; - background: url('swipemode_sprites.gif') 0 -11px no-repeat; - } - } - } //.view.swipe - .view.onion-skin{ - .onion-skin-frame{ - display: block; - margin: auto; - position: relative; - } - .frame.added, .frame.deleted { - position: absolute; - display: block; - top: 0px; - left: 0px; - } - .controls{ - display: block; - height: 14px; - width: 300px; - z-index: 100; - position: absolute; - bottom: 0px; - left: 50%; - margin-left: -150px; - - .drag-track{ - display: block; - position: absolute; - left: 12px; - height: 10px; - width: 276px; - background: url('onion_skin_sprites.gif') -4px -20px repeat-x; - } - - .dragger { - display: block; - position: absolute; - left: 0px; - top: 0px; - height: 14px; - width: 14px; - background: url('onion_skin_sprites.gif') 0px -34px repeat-x; - cursor: pointer; - } - - .transparent { - display: block; - position: absolute; - top: 2px; - right: 0px; - height: 10px; - width: 10px; - background: url('onion_skin_sprites.gif') -2px 0px no-repeat; - } - - .opaque { - display: block; - position: absolute; - top: 2px; - left: 0px; - height: 10px; - width: 10px; - background: url('onion_skin_sprites.gif') -2px -10px no-repeat; - } - } - } //.view.onion-skin - } - .view-modes{ - - padding: 10px; - text-align: center; - - background-image: -webkit-gradient(linear, 0 0, 0 30, color-stop(0.066, #eee), to(#dfdfdf)); - background-image: -webkit-linear-gradient(#eee 6.6%, #dfdfdf); - background-image: -moz-linear-gradient(#eee 6.6%, #dfdfdf); - background-image: -o-linear-gradient(#eee 6.6%, #dfdfdf); - - ul, li{ - list-style: none; - margin: 0; - padding: 0; - display: inline-block; - } - - li{ - color: grey; - border-left: 1px solid #c1c1c1; - padding: 0 12px 0 16px; - cursor: pointer; - &:first-child{ - border-left: none; - } - &:hover{ - text-decoration: underline; - } - &.active{ - &:hover{ - text-decoration: none; - } - cursor: default; - color: #333; - } - &.disabled{ - display: none; - } - } - } -} - /** COMMIT BLOCK **/ .commit-title{ display: block; @@ -390,9 +73,9 @@ .commits-compare-switch{ - background: url("switch_icon.png") no-repeat center center; - width: 22px; - height: 22px; + background: image-url("switch_icon.png") no-repeat center center; + width: 32px; + height: 32px; text-indent: -9999px; float: left; margin-right: 9px; @@ -473,24 +156,48 @@ li.commit { font-family: $monospace_font; } + .str-truncated { + max-width: 70%; + } + .commit-row-message { - color: #555; - font-weight: bolder; + color: #333; + font-weight: 500; &:hover { color: #444; text-decoration: underline; } } + + .text-expander { + background: #eee; + color: #555; + padding: 0 5px; + cursor: pointer; + margin-left: 4px; + &:hover { + background-color: #ddd; + } + } + } + + .commit-row-description { + font-size: 14px; + border-left: 1px solid #e5e5e5; + padding: 0 15px 0 7px; + margin: 5px 0 10px 5px; + display: none; } .commit-row-info { + color: #777; + a { color: #777; } .committed_ago { float: right; - @extend .cgray; } } diff --git a/app/assets/stylesheets/sections/dashboard.scss b/app/assets/stylesheets/sections/dashboard.scss index 61043147fc..e70757e040 100644 --- a/app/assets/stylesheets/sections/dashboard.scss +++ b/app/assets/stylesheets/sections/dashboard.scss @@ -1,11 +1,5 @@ .dashboard { - @extend .row; - .activities { - } - .side { - @extend .pull-right; - .ui-box { margin: 0px; box-shadow: none; @@ -20,7 +14,7 @@ .search-text-input { float:left; - @extend .span2; + @extend .col-md-2; } .btn { margin-left: 5px; @@ -32,26 +26,27 @@ .dash-filter { margin: 7px 0; padding: 4px 6px; - width: 202px; + width: 220px; float: left; + height: inherit; } } @media (max-width: 1200px) { .dashboard .dash-filter { - width: 132px; + width: 150px; } } .dash-sidebar-tabs { margin-bottom: 2px; border: none; - margin: 0; + margin: 0 !important; li { &.active { a { - @include linear-gradient(#f5f5f5, #eee); + background-color: #EEE; border-bottom: 1px solid #EEE !important; &:hover { background: #eee; @@ -66,37 +61,57 @@ } .project-row, .group-row { - padding: 10px 15px !important; + padding: 8px 12px !important; + font-size: 14px; + line-height: 24px; - .namespace-name { - color: #666; - font-weight: bold; + a { + display: block; } .project-name, .group-name { - font-size: 15px; + font-weight: 500; } .arrow { float: right; - padding: 10px 5px; + padding: 0px 5px; margin: 0; font-size: 20px; color: #666; } .last-activity { + float: right; + font-size: 12px; color: #AAA; display: block; - margin-top: 5px; .date { color: #777; } } } -.group-row { - .arrow { - padding: 2px 5px; +.project-access-icon { + margin-left: 10px; + float: left; + margin-right: 15px; + font-size: 20px; + margin-bottom: 15px; + border: 1px solid #EEE; + padding: 8px 12px; + border-radius: 50px; + background: #f5f5f5; + text-align: center; + + i { + color: #BBB; } } + +.dash-project-access-icon { + float: left; + margin-right: 3px; + color: #999; + width: 16px; +} diff --git a/app/assets/stylesheets/sections/diff.scss b/app/assets/stylesheets/sections/diff.scss new file mode 100644 index 0000000000..af44654d5d --- /dev/null +++ b/app/assets/stylesheets/sections/diff.scss @@ -0,0 +1,332 @@ +.diff-file { + border: 1px solid #CCC; + margin-bottom: 1em; + + .diff-header { + @extend .clearfix; + background: #EEE; + border-bottom: 1px solid #CCC; + padding: 5px 5px 5px 10px; + color: #555; + + > span { + font-family: $monospace_font; + font-size: 14px; + line-height: 2; + } + + .diff-btn-group { + float: right; + + .btn { + background-color: #EEE; + color: #666; + font-weight: bolder; + } + } + + .commit-short-id { + font-family: $monospace_font; + font-size: smaller; + } + + .file-mode { + font-family: $monospace_font; + } + } + .diff-content { + overflow: auto; + overflow-y: hidden; + background: #FFF; + color: #333; + font-size: 12px; + .old { + span.idiff { + background-color: #FAA; + } + } + .new { + span.idiff { + background-color: #AFA; + } + } + + table { + width: 100%; + font-family: $monospace_font; + border: none; + margin: 0px; + padding: 0px; + td { + line-height: 18px; + font-size: 12px; + } + } + + tr.line_holder.parallel{ + .old_line, .new_line, .diff_line { + min-width: 50px; + } + + td.line_content.parallel{ + width: 50%; + } + } + + .old_line, .new_line, .diff_line { + margin: 0px; + padding: 0px; + border: none; + background: #F5F5F5; + color: #666; + padding: 0px 5px; + border-right: 1px solid #ccc; + text-align: right; + min-width: 35px; + max-width: 50px; + width: 35px; + @include user-select(none); + a { + float: left; + width: 35px; + font-weight: normal; + color: #666; + &:hover { + text-decoration: underline; + } + } + &.new { + background: #CFD; + } + &.old { + background: #FDD; + } + } + .diff_line { + padding: 0; + } + .line_holder { + &.old .old_line, + &.old .new_line { + background: #FCC; + border-color: #E7BABA; + } + &.new .old_line, + &.new .new_line { + background: #CFC; + border-color: #B9ECB9; + } + } + .line_content { + display: block; + white-space: pre; + height: 18px; + margin: 0px; + padding: 0px 0.5em; + border: none; + &.new { + background: #CFD; + } + &.old { + background: #FDD; + } + &.matched { + color: #ccc; + background: #fafafa; + } + &.parallel { + display: table-cell; + } + } + } + .image { + background: #ddd; + text-align: center; + padding: 30px; + .wrap{ + display: inline-block; + } + + .frame { + display: inline-block; + background-color: #fff; + line-height: 0; + img{ + border: 1px solid #FFF; + background: image-url('trans_bg.gif'); + max-width: 100%; + } + &.deleted { + border: 1px solid $deleted; + } + + &.added { + border: 1px solid $added; + } + } + .image-info{ + font-size: 12px; + margin: 5px 0 0 0; + color: grey; + } + + .view.swipe{ + position: relative; + + .swipe-frame{ + display: block; + margin: auto; + position: relative; + } + .swipe-wrap{ + overflow: hidden; + border-left: 1px solid #999; + position: absolute; + display: block; + top: 13px; + right: 7px; + } + .frame{ + top: 0; + right: 0; + position: absolute; + &.deleted{ + margin: 0; + display: block; + top: 13px; + right: 7px; + } + } + .swipe-bar{ + display: block; + height: 100%; + width: 15px; + z-index: 100; + position: absolute; + cursor: pointer; + &:hover{ + .top-handle{ + background-position: -15px 3px; + } + .bottom-handle{ + background-position: -15px -11px; + } + }; + .top-handle{ + display: block; + height: 14px; + width: 15px; + position: absolute; + top: 0px; + background: image-url('swipemode_sprites.gif') 0 3px no-repeat; + } + .bottom-handle{ + display: block; + height: 14px; + width: 15px; + position: absolute; + bottom: 0px; + background: image-url('swipemode_sprites.gif') 0 -11px no-repeat; + } + } + } //.view.swipe + .view.onion-skin{ + .onion-skin-frame{ + display: block; + margin: auto; + position: relative; + } + .frame.added, .frame.deleted { + position: absolute; + display: block; + top: 0px; + left: 0px; + } + .controls{ + display: block; + height: 14px; + width: 300px; + z-index: 100; + position: absolute; + bottom: 0px; + left: 50%; + margin-left: -150px; + + .drag-track{ + display: block; + position: absolute; + left: 12px; + height: 10px; + width: 276px; + background: image-url('onion_skin_sprites.gif') -4px -20px repeat-x; + } + + .dragger { + display: block; + position: absolute; + left: 0px; + top: 0px; + height: 14px; + width: 14px; + background: image-url('onion_skin_sprites.gif') 0px -34px repeat-x; + cursor: pointer; + } + + .transparent { + display: block; + position: absolute; + top: 2px; + right: 0px; + height: 10px; + width: 10px; + background: image-url('onion_skin_sprites.gif') -2px 0px no-repeat; + } + + .opaque { + display: block; + position: absolute; + top: 2px; + left: 0px; + height: 10px; + width: 10px; + background: image-url('onion_skin_sprites.gif') -2px -10px no-repeat; + } + } + } //.view.onion-skin + } + .view-modes{ + padding: 10px; + text-align: center; + background: #EEE; + + ul, li{ + list-style: none; + margin: 0; + padding: 0; + display: inline-block; + } + + li{ + color: grey; + border-left: 1px solid #c1c1c1; + padding: 0 12px 0 16px; + cursor: pointer; + &:first-child{ + border-left: none; + } + &:hover{ + text-decoration: underline; + } + &.active{ + &:hover{ + text-decoration: none; + } + cursor: default; + color: #333; + } + &.disabled{ + display: none; + } + } + } +} diff --git a/app/assets/stylesheets/sections/editor.scss b/app/assets/stylesheets/sections/editor.scss index a71e543893..f62f46ee16 100644 --- a/app/assets/stylesheets/sections/editor.scss +++ b/app/assets/stylesheets/sections/editor.scss @@ -26,23 +26,9 @@ float: left; } - .commit-btn { - @extend .save-btn; - } .message { display: inline-block; margin: 5px 8px 0 8px; } } - .commit_message-group { - margin-top: 20px; - - label { - font-size: 16px; - line-height: 20px; - } - textarea { - @extend .span8; - } - } } diff --git a/app/assets/stylesheets/sections/events.scss b/app/assets/stylesheets/sections/events.scss index 966282750d..b68f882220 100644 --- a/app/assets/stylesheets/sections/events.scss +++ b/app/assets/stylesheets/sections/events.scss @@ -37,12 +37,12 @@ &.event-inline { .avatar { - width: 16px; - height: 16px; + position: relative; + top: -2px; } } - padding: 14px 0px; + padding: 12px 0px; border-bottom: 1px solid #eee; .event-title { color: #333; @@ -63,6 +63,10 @@ color: #666; margin-top: 5px; + .md { + font-size: 13px; + } + pre { border: none; background: #f9f9f9; @@ -75,6 +79,7 @@ margin-top: 4px; margin-left: 0px; max-width: 200px; + float: none; } p:last-child { @@ -112,6 +117,7 @@ &.commit { background: transparent; padding: 3px; + padding-left: 0; border: none; color: #666; .commit-row-title { @@ -121,6 +127,7 @@ &.commits-stat { display: block; padding: 3px; + padding-left: 0; &:hover { background: none; @@ -147,7 +154,7 @@ float: left; padding: 9px 6px; font-size: 18px; - width: 26px; + width: 40px; @include border-radius(3px); } diff --git a/app/assets/stylesheets/sections/graph.scss b/app/assets/stylesheets/sections/graph.scss index 1e22d161bf..8a337a5e20 100644 --- a/app/assets/stylesheets/sections/graph.scss +++ b/app/assets/stylesheets/sections/graph.scss @@ -1,17 +1,16 @@ .project-network { - border: 1px solid #aaa; - padding: 1px; + border: 1px solid #CCC; .tip { color: #888; font-size: 14px; padding: 10px; border-bottom: 1px solid #bbb; - @include bg-gray-gradient; + background: #EEE; } .network-graph { - background: #f1f1f1; + background: #FFF; height: 500px; overflow-y: scroll; overflow-x: hidden; diff --git a/app/assets/stylesheets/sections/groups.scss b/app/assets/stylesheets/sections/groups.scss new file mode 100644 index 0000000000..60ec79acad --- /dev/null +++ b/app/assets/stylesheets/sections/groups.scss @@ -0,0 +1,9 @@ +.new-group-member-holder { + margin-top: 50px; + background: #f9f9f9; + padding-top: 20px; +} + +.member-search-form { + float: left; +} diff --git a/app/assets/stylesheets/sections/header.scss b/app/assets/stylesheets/sections/header.scss index bd72d08295..1adbdfd979 100644 --- a/app/assets/stylesheets/sections/header.scss +++ b/app/assets/stylesheets/sections/header.scss @@ -4,17 +4,23 @@ */ header { &.navbar-gitlab { + margin-bottom: 0; + min-height: 40px; + .navbar-inner { - height: 40px; - padding: 3px; background: #F1F1F1; + border-bottom: 1px solid #DDD; filter: none; .nav > li > a { color: $style_color; - text-shadow: 0 1px 0 #fff; font-size: 14px; - padding: 10px; + line-height: 32px; + padding: 6px 10px; + + &:hover, &:focus, &:active { + background: none; + } } /** NAV block with links and profile **/ @@ -22,6 +28,64 @@ header { float: right; margin-right: 0; } + + .navbar-toggle { + color: $style_color; + margin: 0 -15px 0 0; + padding: 10px; + border-radius: 0; + + button i { font-size: 22px; } + + &.collapsed { background-color: transparent !important;} + + &:hover { + background-color: #EEE; + } + } + } + + .turbolink-spinner { + font-size: 20px; + margin-right: 10px; + } + + @media (max-width: $screen-xs-max) { + border-width: 0; + font-size: 18px; + + .app_logo { margin-left: -15px; } + .title { + display: inline-block; + overflow: hidden; + text-overflow: ellipsis; + vertical-align: top; + white-space: nowrap; + max-width: 70%; + } + + .navbar-collapse { + padding-right: 0; + padding-left: 0; + } + + .navbar-nav { + margin: 5px 0; + + .visible-xs, .visable-sm { + display: table-cell !important; + } + } + + li { + display: table-cell; + width: 1%; + + a { + text-align: center; + font-size: 18px !important; + } + } } } @@ -35,9 +99,6 @@ header { .app_logo { float: left; margin-right: 9px; - position: relative; - top: -5px; - padding-top: 5px; a { float: left; @@ -46,10 +107,10 @@ header { h1 { margin: 0; - background: url('logo-black.png') no-repeat center 1px; - background-size: 38px; + background: image-url('logo-black.png') no-repeat center center; + background-size: 32px; float: left; - height: 40px; + height: 46px; width: 40px; @include header-font; text-indent: -9999px; @@ -65,7 +126,7 @@ header { * Project / Area name * */ - .project_name { + .title { position: relative; float: left; margin: 0; @@ -75,7 +136,7 @@ header { .profile-pic { position: relative; - top: -4px; + top: -1px; img { width: 26px; height: 26px; @@ -91,21 +152,25 @@ header { .search { margin-right: 10px; margin-left: 10px; + margin-top: 8px; + + form { + margin: 0; + padding: 0; + } .search-input { - @extend .span3; - background-image: url("icon-search.png"); + background-image: image-url("icon-search.png"); background-repeat: no-repeat; background-position: 10px; + height: inherit; + padding: 4px 6px; padding-left: 25px; font-size: 13px; @include border-radius(3px); border: 1px solid #c6c6c6; box-shadow: none; @include transition(all 0.15s ease-in 0s); - &:focus { - @extend .span4; - } } } @@ -120,11 +185,13 @@ header { background: #708090; border-bottom: 1px solid #AAA; + .navbar-toggle { color: #fff; } + .nav > li > a { color: #AAA; - text-shadow: 0 1px 0 #444; - &:hover { + &:hover, &:focus, &:active { + background: none; color: #FFF; } } @@ -152,22 +219,20 @@ header { .app_logo { a { h1 { - background: url('logo-white.png') no-repeat center 1px; - background-size: 38px; + background: image-url('logo-white.png') no-repeat center center; + background-size: 32px; color: #fff; - text-shadow: 0 1px 1px #444; } } } - .project_name { + .title { a { - color: #BBB; + color: #FFF; &:hover { - color: #FFF; + text-decoration: underline; } } color: #fff; - text-shadow: 0 1px 1px #444; } } @@ -181,12 +246,32 @@ header { .separator { float: left; height: 46px; - width: 1px; + width: 2px; background: white; border-left: 1px solid #DDD; - margin-top: -3px; margin-left: 10px; margin-right: 10px; } } +.search .search-input { + width: 300px; + &:focus { + width: 400px; + } +} + +@media (max-width: 1200px) { + .search .search-input { + width: 200px; + &:focus { + width: 300px; + } + } +} + +@media (max-width: $screen-xs-max) { + #nprogress .spinner { + right: 35px !important; + } +} diff --git a/app/assets/stylesheets/sections/issues.scss b/app/assets/stylesheets/sections/issues.scss index e384aebc76..02c9123178 100644 --- a/app/assets/stylesheets/sections/issues.scss +++ b/app/assets/stylesheets/sections/issues.scss @@ -14,8 +14,8 @@ .issue-check { float: left; - padding: 8px 0; padding-right: 8px; + margin-bottom: 10px; min-width: 15px; } @@ -38,13 +38,13 @@ } } -input.check_all_issues { +.check-all-holder { + height: 32px; float: left; - padding: 0; - margin: 0; - margin-right: 10px; - position: relative; - top: 13px; + margin-right: 12px; + padding: 6px 10px; + border: 1px solid #ccc; + @include border-radius(4px); } .issues_content { @@ -57,28 +57,11 @@ input.check_all_issues { } } -.btn.close_issue { - color: #B94A48; - font-weight: bold; - @include shade; - &:hover { - color: #B94A48; - } -} -.btn.reopen_issue { - color: #468847; - font-weight: bold; - @include shade; - &:hover { - color: #468847; - } -} - @media (min-width: 800px) { .issues_filters select { width: 160px; } } @media (min-width: 1200px) { .issues_filters select { width: 220px; } } -@media (min-width: 800px) { .issues_bulk_update select { width: 120px; } } -@media (min-width: 1200px) { .issues_bulk_update select { width: 160px; } } +@media (min-width: 800px) { .issues_bulk_update .select2-container { min-width: 120px; } } +@media (min-width: 1200px) { .issues_bulk_update .select2-container { min-width: 160px; } } .issues-holder { .issues_filters { @@ -93,6 +76,13 @@ input.check_all_issues { .update_selected_issues { margin-left: 4px; } + + .select2-container .select2-choice { + height: 32px; + line-height: 28px; + color: #444 !important; + font-weight: 500; + } } } @@ -103,3 +93,78 @@ input.check_all_issues { .participants { margin-bottom: 10px; } + +.issues_bulk_update { + .select2-container { + text-shadow: none; + } +} + +.issue-search-form { + margin: 0; + height: 24px; + + .issue_search { + border: 1px solid #DDD !important; + background-color: #f4f4f4; + } +} + +.issue-show-labels .label { + padding: 6px 10px; +} + +form.edit-issue { + margin: 0; +} + +.merge-request, +.issue { + &.today { + background: #EFE; + border-color: #CEC; + } + + &.closed { + background: #F5f5f5; + border-color: #E5E5E5; + } + + &.merged { + background: #F5f5f5; + border-color: #E5E5E5; + } +} + +@media (max-width: $screen-xs-max) { + .issue-btn-group { + width: 100%; + margin-top: 5px; + + .btn-group { + width: 100%; + + ul { + width: 100%; + text-align: center; + } + } + + .btn { + width: 100%; + margin-top: -1px; + + &:first-child:not(:last-child) { + border-radius: 4px 4px 0 0; + } + + &:not(:first-child):not(:last-child) { + border-radius: 0; + } + + &:last-child:not(:first-child) { + border-radius: 0 0 4px 4px; + } + } + } +} diff --git a/app/assets/stylesheets/sections/login.scss b/app/assets/stylesheets/sections/login.scss index 33bef59c08..a78a9cd487 100644 --- a/app/assets/stylesheets/sections/login.scss +++ b/app/assets/stylesheets/sections/login.scss @@ -1,48 +1,57 @@ /* Login Page */ -body.login-page{ - .container > .content { - padding-top: 20px; +.login-page { + h1 { + font-size: 3em; + font-weight: 200; } -} - -.login-box{ - width: 304px; - position: relative; - @include border-radius(5px); - margin: auto; - padding: 20px; - background: white; -} - -.login-box .login-logo{ - margin: 10px 0 30px 0; - display: block; -} - -.login-box input.text{background-color: #f1f1f1; font-size: 16px; @include border-radius(0); padding: 14px 10px; width: 280px} - -.login-box input.text.top{ - @include border-radius(5px 5px 0 0); - margin-bottom: 0px; -} - -.login-box input.text.bottom{ - @include border-radius(0 0 5px 5px); - border-top: 0; - margin-bottom: 20px; -} - -.login-box input.text.middle{ - border-top: 0; - margin-bottom:0px; -} - -.login-box a.forgot{float: right; padding-top: 6px} - -.remember_me { - text-align: left; - - input { - margin: 2px; + + .login-box{ + max-width: 304px; + position: relative; + @include border-radius(5px); + margin: auto; + background: white; + } + + .login-logo{ + margin: 10px 0 30px 0; + display: block; + } + + .form-control { + background-color: #f1f1f1; + font-size: 16px; + padding: 14px 10px; + width: 100%; + height: auto; + + &.top { + @include border-radius(5px 5px 0 0); + margin-bottom: 0px; + } + + &.bottom { + @include border-radius(0 0 5px 5px); + border-top: 0; + margin-bottom: 20px; + } + + &.middle { + border-top: 0; + margin-bottom:0px; + @include border-radius(0); + } + } + + .login-box a.forgot { + float: right; + padding-top: 6px + } + + .devise-errors { + h2 { + font-size: 14px; + color: #a00; + } } } diff --git a/app/assets/stylesheets/sections/merge_requests.scss b/app/assets/stylesheets/sections/merge_requests.scss index aa61cae4b9..2d9a5e4bbe 100644 --- a/app/assets/stylesheets/sections/merge_requests.scss +++ b/app/assets/stylesheets/sections/merge_requests.scss @@ -4,10 +4,6 @@ * */ .automerge_widget { - &.can_be_merged { - background: #DFF0D8; - } - form { margin-bottom: 0; .clearfix { @@ -15,32 +11,12 @@ } } - .accept_group { - float: left; - border: 1px solid #ADA; - padding: 2px; - @include border-radius(5px); - background: #CEB; - - .accept_merge_request { - font-size: 13px; - float: left; - } - .remove_branch_holder { - margin-left: 20px; - margin-right: 10px; - float: left; - } + .accept-group { label { - color: #444; - text-align: left + margin: 5px; + margin-left: 20px; } } - - - .how_to_merge_link { - @extend .primary; - } } .merge-request .nav-tabs{ @@ -53,17 +29,11 @@ } } -.merge-in-progress { - @extend .padded; - @extend .append-bottom-10; -} - .mr_source_commit, .mr_target_commit { .commit { margin: 0; - padding: 0; - padding: 5px 0; + padding: 2px 0; list-style: none; &:hover { background: none; @@ -73,10 +43,9 @@ .label-branch { @include border-radius(4px); - padding: 3px 4px; + padding: 2px 4px; border: none; - font-size: 14px; - background: #474D57; + background: #555; color: #fff; font-family: $monospace_font; font-weight: normal; @@ -104,15 +73,49 @@ .merge-request-info { color: #999; + + .merge-request-labels { + display: inline-block; + } } } } .merge-request-angle { text-align: center; - margin: 0; + margin: 0 auto; + font-size: 2em; + line-height: 1.1; } .merge-request-form-info { - padding: 15px 0; + padding-top: 15px; +} + +// hide mr close link for inline diff comment form +.diff-file .close-mr-link, +.diff-file .reopen-mr-link { + display: none; +} + +.mr-state-widget { + @include border-radius(0px); + + .panel-heading { + @include border-radius(0px); + } + + .panel-body { + h4 { + margin-top: 0px; + } + + p:last-child { + margin-bottom: 0; + } + } +} + +.merge-request-show-labels .label { + padding: 6px 10px; } diff --git a/app/assets/stylesheets/sections/nav.scss b/app/assets/stylesheets/sections/nav.scss index 54263523e8..88f16a2159 100644 --- a/app/assets/stylesheets/sections/nav.scss +++ b/app/assets/stylesheets/sections/nav.scss @@ -6,6 +6,7 @@ border-bottom: 1px solid #E1E1E1; ul { + padding: 0; margin: auto; height: 40px; overflow: hidden; @@ -34,9 +35,8 @@ width: 1%; &.active { a { - color: $style_color; - font-weight: bolder; - + color: #333; + font-weight: bold; &:after { content: ''; display: block; @@ -45,7 +45,7 @@ left: 50%; width: 0; height: 0; - border-color: transparent transparent #777 transparent; + border-color: transparent transparent #333 transparent; border-style: solid; border-width: 6px; margin-left: -6px; @@ -55,7 +55,20 @@ &:hover { a { - color: $style_color; + color: $link_color; + &:after { + content: ''; + display: block; + position: relative; + bottom: 8px; + left: 50%; + width: 0; + height: 0; + border-color: transparent transparent #29b transparent; + border-style: solid; + border-width: 6px; + margin-left: -6px; + } } } @@ -72,7 +85,7 @@ a { display: block; text-align: center; - font-weight: normal; + font-weight: 500; height: 38px; line-height: 34px; color: #777; @@ -82,4 +95,38 @@ padding-top: 2px; } } + + @media (max-width: $screen-xs-max) { + font-size: 18px; + margin: 0; + + max-height: none; + + &, .container { + padding: 0; + border-top: 0; + } + + ul { + height: auto; + + li { + display: list-item; + width: auto; + padding: 5px 0; + + &.active { + background-color: $primary_color; + + a { + color: #fff; + font-weight: normal; + text-shadow: none; + + &:after { display: none; } + } + } + } + } + } } diff --git a/app/assets/stylesheets/sections/notes.scss b/app/assets/stylesheets/sections/notes.scss index 94b9ca3b18..7e56781f56 100644 --- a/app/assets/stylesheets/sections/notes.scss +++ b/app/assets/stylesheets/sections/notes.scss @@ -2,7 +2,7 @@ * Notes */ -@-webkit-keyframes target-note { +@-webkit-keyframes targe3-note { from { background:#fffff0; } 50% { background:#ffffd3; } to { background:#fffff0; } @@ -27,11 +27,15 @@ ul.notes { .discussion-last-update, .note-last-update { - font-style: italic; + &:before { + content: "\00b7"; + } + font-size: 13px; } .author { - color: $style_color; + color: #555; font-weight: bold; + font-size: 14px; &:hover { color: $primary_color; } @@ -47,13 +51,12 @@ ul.notes { .discussion-body { margin-left: 50px; - .file, + .diff-file, .discussion-hidden, .notes { - @extend .borders; background-color: #F9F9F9; } - .file .notes { + .diff-file .notes { /* reset */ background: inherit; border: none; @@ -87,18 +90,13 @@ ul.notes { } .attachment { font-size: 14px; - margin-top: -20px; } .note-body { @include md-typography; - margin-left: 45px; - - .highlight { - @include border-radius(4px); - } + margin-left: 43px; } .note-header { - padding-bottom: 5px; + padding-bottom: 3px; } } @@ -118,10 +116,10 @@ ul.notes { } } -.file .notes_holder { - font-family: $sansFontFamily; +.diff-file .notes_holder { font-size: 13px; line-height: 18px; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; td { border: 1px solid #ddd; @@ -130,11 +128,18 @@ ul.notes { &.notes_line { text-align: center; padding: 10px 0; + background: #eee; + } + &.notes_line2 { + text-align: center; + padding: 10px 0; + border-left: 1px solid #ddd !important; } &.notes_content { - background-color: $white; + background-color: #fff; border-width: 1px 0; padding-top: 0; + vertical-align: top; li { padding: 5px; @@ -182,20 +187,19 @@ ul.notes { } } } -.file .note .note-actions { +.diff-file .note .note-actions { right: 0; top: 0; } - /** * Line note button on the side of diffs */ -.file tr.line_holder { +.diff-file tr.line_holder { .add-diff-note { - background: url("diff_note_add.png") no-repeat left 0; + background: image-url("diff_note_add.png") no-repeat left 0; height: 22px; margin-left: -65px; position: absolute; @@ -233,30 +237,33 @@ ul.notes { .reply-btn { @extend .btn-primary; } -.file .content tr.line_holder:hover { - &> td.line_content { - background: $hover !important; - border-color: darken($hover, 10%) !important; +.diff-file .diff-content { + tr.line_holder:hover { + &> td.line_content { + background: $hover !important; + border-color: darken($hover, 10%) !important; + } + &> td.new_line, + &> td.old_line { + background: darken($hover, 4%) !important; + border-color: darken($hover, 10%) !important; + } } - &> td.new_line, - &> td.old_line { - background: darken($hover, 4%) !important; - border-color: darken($hover, 10%) !important; + + tr.line_holder:hover > td .line_note_link { + opacity: 1.0; + filter: alpha(opacity=100); } } -.file .content tr.line_holder:hover > td .line_note_link { - opacity: 1.0; - filter: alpha(opacity=100); -} -.file, +.diff-file, .discussion { .new_note { - margin: 8px 5px 8px 0; + margin: 0; + border: none; } } .new_note { display: none; - .buttons { float: left; margin-top: 8px; @@ -270,10 +277,9 @@ ul.notes { // preview/edit buttons > a { - font-size: 24px; - padding: 4px; position: absolute; - right: 10px; + right: 5px; + bottom: -60px; } .note_preview { background: #f5f5f5; @@ -287,7 +293,7 @@ ul.notes { box-shadow: none; font-size: 14px; height: 80px; - width: 98.6%; + width: 100%; } } } @@ -298,18 +304,17 @@ ul.notes { } .note-image-attach { - @extend .span4; + @extend .col-md-4; @extend .thumbnail; margin-left: 45px; + float: none; } .common-note-form { margin: 0; - height: 140px; background: #F9F9F9; padding: 3px; - padding-bottom: 25px; border: 1px solid #DDD; } @@ -320,7 +325,7 @@ ul.notes { padding: 0 5px; .note-form-option { - margin-top: 10px; + margin-top: 8px; margin-left: 30px; @extend .pull-left; } @@ -338,7 +343,7 @@ ul.notes { box-shadow: none; font-size: 14px; height: 80px; - width: 98.6%; + width: 100%; } .form-actions { @@ -358,3 +363,7 @@ ul.notes { .js-note-attachment-delete { display: none; } + +.parallel-comment { + padding: 6px; +} diff --git a/app/assets/stylesheets/sections/profile.scss b/app/assets/stylesheets/sections/profile.scss index 21f4ed0577..67aaa36938 100644 --- a/app/assets/stylesheets/sections/profile.scss +++ b/app/assets/stylesheets/sections/profile.scss @@ -1,7 +1,6 @@ .update-notifications { - margin-bottom: 0; - label { - margin-bottom: 0; + .radio-inline { + margin-right: 9%; } } @@ -17,7 +16,7 @@ legend { border: none; - margin: 0; + margin-bottom: 10px; } } } @@ -42,3 +41,87 @@ margin-right: 12px; } +.profile-avatar-form-option { + hr { + margin: 10px 0; + } +} + +.user-show-username { + font-weight: 200; + color: #666; +} + +/* + * Appearance settings + * + */ +.themes_opts { + label { + margin-right: 20px; + text-align: center; + + .prev { + @extend .thumbnail; + height: 30px; + width: 175px; + margin-bottom: 10px; + + &.classic { + background: #31363e; + } + + &.default { + background: #f1f1f1; + } + + &.modern { + background: #009871; + } + + &.gray { + background: #373737; + } + + &.violet { + background: #548; + } + } + } +} + +.code_highlight_opts { + margin-top: 10px; + + label { + margin-right: 20px; + text-align: center; + + .prev { + @extend .thumbnail; + height: 151px; + width: 220px; + margin-bottom: 10px; + } + } +} + +.profile-groups-avatars { + margin: 0 5px 10px 0; + + img { + width: 50px; + height: 50px; + } +} + +.global-notifications-form .level-title { + font-size: 15px; + color: #333; + font-weight: bold; +} + +.notification-icon-holder { + width: 20px; + float: left; +} diff --git a/app/assets/stylesheets/sections/projects.scss b/app/assets/stylesheets/sections/projects.scss index 0e5f99d4b7..5757858a1c 100644 --- a/app/assets/stylesheets/sections/projects.scss +++ b/app/assets/stylesheets/sections/projects.scss @@ -16,12 +16,18 @@ .project-home-panel { border-bottom: 1px solid #DDD; - padding-bottom: 30px; + padding-bottom: 15px; margin-bottom: 30px; + &.empty-project { + border-bottom: 0px; + padding-bottom: 15px; + margin-bottom: 0px; + } + .project-home-title { font-size: 18px; - color: #777; + color: #444; margin: 0; line-height: 32px; } @@ -34,40 +40,52 @@ .project-home-desc { float: left; - color: #999; + color: #777; + margin-bottom: 10px; } .project-home-links { float: right; a { margin-left: 10px; + font-weight: 500; } } } - .public-label { - font-size: 14px; + .visibility-level-label { + font-size: 17px; background: #f1f1f1; - padding: 8px 10px; border-radius: 4px; - margin-left: 10px; color: #888; + position: absolute; + margin-left: -55px; text-shadow: 0 1px 1px #FFF; + width: 40px; + text-align: center; + padding: 6px; + + i { + color: inherit; + } } } .git-clone-holder { - float: right; - border: 1px solid #E1E1E1; - @include border-radius(4px); + .project-home-dropdown + & { + margin-right: 45px; + } + + .btn, + .form-control { + border: 1px solid #E1E1E1; + box-shadow: none; + padding: 6px 9px; + } .btn { - margin-left: 3px; - border: none; background: none; - box-shadow: none; color: #29b; - padding: 6px; &.active { color: #333; @@ -75,33 +93,39 @@ } } - input[type="text"] { - margin-left: 2px; - border: none; - border-radius: 0; - border-left: 1px solid #E1E1E1; + .form-control { + cursor: auto; @extend .monospace; - box-shadow: none; background: #FAFAFA; - padding: 6px 10px; + width: 100%; } } -.project-public-holder { - .help-inline { - padding-top: 7px; +.project-visibility-level-holder { + .radio { + margin-bottom: 10px; + + i { + margin: 0 3px; + font-size: 20px; + } + + .option-title { + font-weight: bold; + display: inline-block; + } + + .option-descr { + margin-left: 24px; + color: #666; + } } } .save-project-loader { - img { - margin-top: 50px; - margin-bottom: 50px; - } - h3 { - @extend .page-title; - } - + margin-top: 50px; + margin-bottom: 50px; + color: #555; } ul.nav.nav-projects-tabs { @@ -130,7 +154,8 @@ ul.nav.nav-projects-tabs { margin: 0px; } -.my-projects { +.my-projects, +.public-projects { li { .project-info { margin-bottom: 10px; @@ -166,3 +191,44 @@ ul.nav.nav-projects-tabs { color: #777; } } + +.project-side { + .btn-block { + background-image: none; + .btn, + &.btn, + &.btn-group ul.dropdown-menu { + background-color: #F1f1f1; + border-color: #EEE; + &:hover { + background-color: #eee; + border-color: #DDD; + } + } + &.btn-group-justified { + .btn { + width: 100%; + } + .dropdown-toggle { + width: 26px; + } + } + ul { + width: 100%; + } + } + .project-fork-icon { + float: left; + font-size: 26px; + margin-right: 10px; + line-height: 1.5; + } +} + +.transfer-project .select2-container { + min-width: 200px; +} + +.deploy-project-label { + margin: 1px; +} diff --git a/app/assets/stylesheets/sections/snippets.scss b/app/assets/stylesheets/sections/snippets.scss index e67ca794f2..84404b6ee3 100644 --- a/app/assets/stylesheets/sections/snippets.scss +++ b/app/assets/stylesheets/sections/snippets.scss @@ -1,14 +1,3 @@ -.snippet.file-holder { - .file-title { - .snippet-file-name { - padding: 4px 10px; - position: relative; - top: -4px; - left: -4px; - } - } -} - .my-snippets li:first-child { h4 { margin-top: 0; } padding-top: 0; diff --git a/app/assets/stylesheets/sections/themes.scss b/app/assets/stylesheets/sections/themes.scss index cd1aa2b011..e69de29bb2 100644 --- a/app/assets/stylesheets/sections/themes.scss +++ b/app/assets/stylesheets/sections/themes.scss @@ -1,53 +0,0 @@ -.themes_opts { - padding-left: 20px; - - label { - width: 175px; - margin-right: 40px; - - .prev { - @extend .thumbnail; - height: 30px; - width: 175px; - margin-bottom: 10px; - - &.classic { - background: #31363e; - } - - &.default { - background: #f1f1f1; - } - - &.modern { - background: #345; - } - - &.gray { - background: #373737; - } - - &.violet { - background: #547; - } - } - } -} - -.code_highlight_opts { - padding-left: 20px; - - label { - width: 220px; - margin-right: 40px; - - .prev { - @extend .thumbnail; - height: 151px; - width: 220px; - margin-bottom: 10px; - } - } -} - - diff --git a/app/assets/stylesheets/sections/tree.scss b/app/assets/stylesheets/sections/tree.scss index 96f2a5711f..86e2a51641 100644 --- a/app/assets/stylesheets/sections/tree.scss +++ b/app/assets/stylesheets/sections/tree.scss @@ -24,10 +24,10 @@ th { font-weight: normal; font-size: 15px; - border-bottom: 1px solid #CCC; + border-bottom: 1px solid #CCC !important; } td { - border-color: #F1F1F1; + border-color: #F1F1F1 !important; } &:hover { td { @@ -49,6 +49,7 @@ .tree-item { .tree-item-file-name { + max-width: 320px; vertical-align: middle; a { &:hover { @@ -61,6 +62,14 @@ top:-1px; } } + + .tree_commit { + max-width: 320px; + } + + .tree_time_ago { + min-width: 135px; + } } .tree_author { @@ -111,5 +120,36 @@ .tree-ref-holder { float: left; - margin-top: 5px; + margin-top: 8px; } + +.readme-holder { + border-top: 1px dashed #CCC; + padding-top: 10px; + + .readme-file-title { + font-size: 14px; + margin-bottom: 20px; + color: #777; + } +} + +.blob-commit-info { + list-style: none; + margin: 0; + padding: 0; + margin-bottom: 10px; + + .commit { + .commit-row-title { + font-size: 13px; + + .commit-row-message { + font-weight: normal; + color: #555; + } + } + } +} + +#modal-remove-blob > .modal-dialog { width: 850px; } diff --git a/app/assets/stylesheets/sections/votes.scss b/app/assets/stylesheets/sections/votes.scss index 49489babab..d683e33e1f 100644 --- a/app/assets/stylesheets/sections/votes.scss +++ b/app/assets/stylesheets/sections/votes.scss @@ -36,3 +36,14 @@ display: inline-block; margin: 0 8px; } + +.votes-holder { + float: right; + width: 250px; + + @media (max-width: $screen-xs-max) { + width: 100%; + margin-top: 5px; + margin-bottom: 10px; + } +} diff --git a/app/assets/stylesheets/sections/wall.scss b/app/assets/stylesheets/sections/wall.scss index d6ac08fcf6..3705afdb87 100644 --- a/app/assets/stylesheets/sections/wall.scss +++ b/app/assets/stylesheets/sections/wall.scss @@ -1,6 +1,6 @@ .wall-page { .wall-note-form { - @extend .span12; + @extend .col-md-12; margin: 0; height: 140px; diff --git a/app/assets/stylesheets/sections/wiki.scss b/app/assets/stylesheets/sections/wiki.scss index ed3a432ded..dfaeba41cf 100644 --- a/app/assets/stylesheets/sections/wiki.scss +++ b/app/assets/stylesheets/sections/wiki.scss @@ -1,4 +1,4 @@ -h3.page-title .edit-wiki-header { +.title .edit-wiki-header { width: 780px; margin-left: auto; margin-right: auto; diff --git a/app/assets/stylesheets/selects.scss b/app/assets/stylesheets/selects.scss deleted file mode 100644 index 09ae57b669..0000000000 --- a/app/assets/stylesheets/selects.scss +++ /dev/null @@ -1,153 +0,0 @@ -/* CHZN reset few styles */ -.chosen-container-single .chosen-single { - background: #FFF; - border: 1px solid #bbb; - box-shadow: none; -} -.chosen-container-active .chosen-single { - background: #fff; -} - -.ajax-users-select { - width: 400px; - - &.input-large { - width: 210px; - } -} - -.user-result { - .user-image { - float: left; - } - .user-name { - } - .user-username { - color: #999; - } -} - -/** Branch/tag selector **/ -.project-refs-form { - margin: 0; - span { - background:none !important; - position:static !important; - width:auto !important; - height:auto !important; - } -} -.project-refs-select { - width: 120px; -} - -.project-refs-form .chosen-container { - position: relative; - top: 0; - left: 0; - margin-right: 10px; - - .chosen-drop { - min-width: 400px; - .chosen-results { - max-height: 300px; - } - .chosen-search input { - min-width: 365px; - } - } -} - -/** Fix for Search Dropdown Border **/ -.chosen-container { - min-width: 100px; - - .chosen-search { - input:focus { - @include box-shadow(none); - } - } - - .chosen-drop { - margin: 7px 0; - min-width: 200px; - border: 1px solid #bbb; - @include border-radius(0); - - .chosen-results { - margin-top: 5px; - max-height: 300px; - - .group-result { - color: $style_color; - border-bottom: 1px solid #EEE; - padding: 8px; - } - .active-result { - @include border-radius(0); - - &.highlighted { - background: $hover; - color: $style_color; - } - &.result-selected { - background: #EEE; - border-left: 4px solid #CCC; - } - } - } - - .chosen-search { - @include bg-gray-gradient; - input { - min-width: 165px; - border-color: #CCC; - } - } - } -} - -.chosen-container .chosen-single, -.chosen-container.chosen-with-drop .chosen-single { - @include bg-light-gray-gradient; - - div { - background: transparent; - border-left: none; - } - - span { - font-weight: normal; - } -} - -/** Select2 styling **/ -.select2-container .select2-choice { - background: #f1f1f1; - background-image: -webkit-gradient(linear, 0 0, 0 30, color-stop(0.066, whitesmoke), to(#e1e1e1)); - background-image: -webkit-linear-gradient(whitesmoke 6.6%, #e1e1e1); - background-image: -moz-linear-gradient(whitesmoke 6.6%, #e1e1e1); - background-image: -o-linear-gradient(whitesmoke 6.6%, #e1e1e1); -} - -.select2-container .select2-choice div { - border: none; - background: none; -} - -.select2-drop { - padding-top: 8px; -} - -.select2-no-results, .select2-searching { - padding: 7px; - color: #666; -} - -.chosen-container .chosen-single div b { - background-position-y: 0px !important; -} - -.chosen-container .chosen-drop .chosen-search input { - background-position-y: -24px !important; -} diff --git a/app/assets/stylesheets/themes/ui_color.scss b/app/assets/stylesheets/themes/ui_color.scss index 1fd54ff18a..a08f3ff3d4 100644 --- a/app/assets/stylesheets/themes/ui_color.scss +++ b/app/assets/stylesheets/themes/ui_color.scss @@ -16,18 +16,28 @@ @extend .header-dark; &.navbar-gitlab { .navbar-inner { - background: #547; - border-bottom: 1px solid #435; - .app_logo { + background: #548; + border-bottom: 1px solid #436; + .app_logo, .navbar-toggle { &:hover { - background-color: #435; + background-color: #436; } } .separator { - background: #435; - border-left: 1px solid #658; + background: #436; + border-left: 1px solid #659; + } + .nav > li > a { + color: #98C; + } + .search-input { + border-color: #98C; } } } } + + .nav-pills > li.active > a, .nav-pills > li.active > a:hover, .nav-pills > li.active > a:focus { + background: #659; + } } diff --git a/app/assets/stylesheets/themes/ui_gray.scss b/app/assets/stylesheets/themes/ui_gray.scss index 41c08c840e..959febad6f 100644 --- a/app/assets/stylesheets/themes/ui_gray.scss +++ b/app/assets/stylesheets/themes/ui_gray.scss @@ -18,7 +18,7 @@ .navbar-inner { background: #373737; border-bottom: 1px solid #272727; - .app_logo { + .app_logo, .navbar-toggle { &:hover { background-color: #272727; } diff --git a/app/assets/stylesheets/themes/ui_mars.scss b/app/assets/stylesheets/themes/ui_mars.scss index a2b8c21ea1..9af5adbf10 100644 --- a/app/assets/stylesheets/themes/ui_mars.scss +++ b/app/assets/stylesheets/themes/ui_mars.scss @@ -18,17 +18,22 @@ .navbar-inner { background: #474D57; border-bottom: 1px solid #373D47; - .app_logo { + .app_logo, .navbar-toggle { &:hover { background-color: #373D47; } } + .separator { + background: #373D47; + border-left: 1px solid #575D67; + } + .nav > li > a { + color: #979DA7; + } + .search-input { + border-color: #979DA7; + } } } - - .separator { - background: #31363E; - border-left: 1px solid #666; - } } } diff --git a/app/assets/stylesheets/themes/ui_modern.scss b/app/assets/stylesheets/themes/ui_modern.scss index 6173757082..67616a4a10 100644 --- a/app/assets/stylesheets/themes/ui_modern.scss +++ b/app/assets/stylesheets/themes/ui_modern.scss @@ -16,18 +16,28 @@ @extend .header-dark; &.navbar-gitlab { .navbar-inner { - background: #345; - border-bottom: 1px solid #234; - .app_logo { + background: #00AC7E; + border-bottom: 1px solid #00AC7E; + .app_logo, .navbar-toggle { &:hover { - background-color: #234; + background-color: #009C6E; } } .separator { - background: #234; - border-left: 1px solid #456; + background: #009C6F; + border-left: 1px solid #10BC8E; + } + .nav > li > a { + color: #ADC; + } + .search-input { + border-color: #7fd5be; } } } } + + .nav-pills > li.active > a, .nav-pills > li.active > a:hover, .nav-pills > li.active > a:focus { + background: #00AC7E; + } } diff --git a/app/contexts/commit_load_context.rb b/app/contexts/commit_load_context.rb deleted file mode 100644 index 0c684976b6..0000000000 --- a/app/contexts/commit_load_context.rb +++ /dev/null @@ -1,34 +0,0 @@ -class CommitLoadContext < BaseContext - def execute - result = { - commit: nil, - suppress_diff: false, - line_notes: [], - notes_count: 0, - note: nil, - status: :ok - } - - commit = project.repository.commit(params[:id]) - - if commit - line_notes = project.notes.for_commit_id(commit.id).inline - - result[:commit] = commit - result[:note] = project.build_commit_note(commit) - result[:line_notes] = line_notes - result[:notes_count] = project.notes.for_commit_id(commit.id).count - result[:branches] = project.repository.branch_names_contains(commit.id) - - begin - result[:suppress_diff] = true if commit.diff_suppress? && !params[:force_show_diff] - result[:force_suppress_diff] = commit.diff_force_suppress? - rescue Grit::Git::GitTimeout - result[:suppress_diff] = true - result[:status] = :huge_commit - end - end - - result - end -end diff --git a/app/contexts/filter_context.rb b/app/contexts/filter_context.rb deleted file mode 100644 index 2607b12b4a..0000000000 --- a/app/contexts/filter_context.rb +++ /dev/null @@ -1,31 +0,0 @@ -class FilterContext - attr_accessor :items, :params - - def initialize(items, params) - @items = items - @params = params - end - - def execute - apply_filter(items) - end - - def apply_filter items - if params[:project_id].present? - items = items.of_projects(params[:project_id]) - end - - if params[:search].present? - items = items.search(params[:search]) - end - - case params[:status] - when 'closed' - items.closed - when 'all' - items - else - items.opened - end - end -end diff --git a/app/contexts/issues/list_context.rb b/app/contexts/issues/list_context.rb deleted file mode 100644 index da2eed0e25..0000000000 --- a/app/contexts/issues/list_context.rb +++ /dev/null @@ -1,36 +0,0 @@ -module Issues - class ListContext < BaseContext - attr_accessor :issues - - def execute - @issues = @project.issues - - @issues = case params[:state] - when 'all' then @issues - when 'closed' then @issues.closed - else @issues.opened - end - - @issues = case params[:scope] - when 'assigned-to-me' then @issues.assigned_to(current_user) - when 'created-by-me' then @issues.authored(current_user) - else @issues - end - - @issues = @issues.tagged_with(params[:label_name]) if params[:label_name].present? - @issues = @issues.includes(:author, :project) - - # 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 -end diff --git a/app/contexts/merge_requests_load_context.rb b/app/contexts/merge_requests_load_context.rb deleted file mode 100644 index c3408db6e1..0000000000 --- a/app/contexts/merge_requests_load_context.rb +++ /dev/null @@ -1,35 +0,0 @@ -# Build collection of Merge Requests -# based on filtering passed via params for @project -class MergeRequestsLoadContext < BaseContext - def execute - merge_requests = @project.merge_requests - - merge_requests = case params[:state] - when 'all' then merge_requests - when 'closed' then merge_requests.closed - else merge_requests.opened - end - - merge_requests = case params[:scope] - when 'assigned-to-me' then merge_requests.assigned_to(current_user) - when 'created-by-me' then merge_requests.authored(current_user) - else merge_requests - end - - - merge_requests = merge_requests.page(params[:page]).per(20) - merge_requests = merge_requests.includes(:author, :source_project, :target_project).order("created_at desc") - - # Filter by specific assignee_id (or lack thereof)? - if params[:assignee_id].present? - merge_requests = merge_requests.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? - merge_requests = merge_requests.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id])) - end - - merge_requests - end -end diff --git a/app/contexts/notes/load_context.rb b/app/contexts/notes/load_context.rb deleted file mode 100644 index 234e9ac3cd..0000000000 --- a/app/contexts/notes/load_context.rb +++ /dev/null @@ -1,20 +0,0 @@ -module Notes - class LoadContext < BaseContext - def execute - target_type = params[:target_type] - target_id = params[:target_id] - - - @notes = case target_type - when "commit" - project.notes.for_commit_id(target_id).not_inline.fresh - when "issue" - project.issues.find(target_id).notes.inc_author.fresh - when "merge_request" - project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh - when "snippet" - project.snippets.find(target_id).notes.fresh - end - end - end -end diff --git a/app/contexts/projects/update_context.rb b/app/contexts/projects/update_context.rb deleted file mode 100644 index 40385fa65b..0000000000 --- a/app/contexts/projects/update_context.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Projects - class UpdateContext < BaseContext - def execute(role = :default) - params[:project].delete(:namespace_id) - params[:project].delete(:public) unless can?(current_user, :change_public_mode, project) - project.update_attributes(params[:project], as: role) - end - end -end diff --git a/app/contexts/search_context.rb b/app/contexts/search_context.rb deleted file mode 100644 index fa41da6823..0000000000 --- a/app/contexts/search_context.rb +++ /dev/null @@ -1,43 +0,0 @@ -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] - query = Shellwords.shellescape(query) if query.present? - - return result unless query.present? - result[:projects] = Project.where("projects.id in (?) OR projects.public = true", project_ids).search(query).limit(20) - - # Search inside single project - single_project_search(Project.where(id: project_ids), query) - result - end - - def single_project_search(projects, query) - project = projects.first if projects.length == 1 - - if params[:search_code].present? - result[:blobs] = project.repository.search_files(query, params[:repository_ref]) unless project.empty_repo? - else - result[:merge_requests] = MergeRequest.in_projects(project_ids).search(query).order('updated_at DESC').limit(20) - result[:issues] = Issue.where(project_id: project_ids).where("title like :query OR description like :query ", query: "%#{query}%").order('updated_at DESC').limit(20) - result[:notes] = Note.where(noteable_type: 'issue').where(project_id: project_ids).where("note like :query", query: "%#{query}%").order('updated_at DESC').limit(20) - result[:wiki_pages] = [] - end - end - - def result - @result ||= { - projects: [], - merge_requests: [], - issues: [], - notes: [], - wiki_pages: [], - blobs: [] - } - end -end diff --git a/app/contexts/test_hook_context.rb b/app/contexts/test_hook_context.rb deleted file mode 100644 index 63eda6c7d0..0000000000 --- a/app/contexts/test_hook_context.rb +++ /dev/null @@ -1,7 +0,0 @@ -class TestHookContext < BaseContext - def execute - hook = project.hooks.find(params[:id]) - data = GitPushService.new.sample_data(project, current_user) - hook.execute(data) - end -end diff --git a/app/controllers/admin/background_jobs_controller.rb b/app/controllers/admin/background_jobs_controller.rb index 159ab2027c..4c1d0df411 100644 --- a/app/controllers/admin/background_jobs_controller.rb +++ b/app/controllers/admin/background_jobs_controller.rb @@ -1,5 +1,6 @@ class Admin::BackgroundJobsController < Admin::ApplicationController def show - @sidekiq_processes = `ps -U #{Settings.gitlab.user} -o euser,pid,pcpu,pmem,stat,start,command | grep sidekiq | grep -v grep` + ps_output, _ = Gitlab::Popen.popen(%W(ps -U #{Settings.gitlab.user} -o pid,pcpu,pmem,stat,start,command)) + @sidekiq_processes = ps_output.split("\n").grep(/sidekiq/) end end diff --git a/app/controllers/admin/broadcast_messages_controller.rb b/app/controllers/admin/broadcast_messages_controller.rb new file mode 100644 index 0000000000..9a70ef9d19 --- /dev/null +++ b/app/controllers/admin/broadcast_messages_controller.rb @@ -0,0 +1,32 @@ +class Admin::BroadcastMessagesController < Admin::ApplicationController + before_filter :broadcast_messages + + def index + @broadcast_message = BroadcastMessage.new + end + + def create + @broadcast_message = BroadcastMessage.new(params[:broadcast_message]) + + if @broadcast_message.save + redirect_to admin_broadcast_messages_path, notice: 'Broadcast Message was successfully created.' + else + render :index + end + end + + def destroy + BroadcastMessage.find(params[:id]).destroy + + respond_to do |format| + format.html { redirect_to :back } + format.js { render nothing: true } + end + end + + protected + + def broadcast_messages + @broadcast_messages ||= BroadcastMessage.order("starts_at DESC").page(params[:page]) + end +end diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index 3c80b6503f..be19139c9b 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -2,5 +2,6 @@ class Admin::DashboardController < Admin::ApplicationController def index @projects = Project.order("created_at DESC").limit(10) @users = User.order("created_at DESC").limit(10) + @groups = Group.order("created_at DESC").limit(10) end end diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 89b395786b..4bb3cf07da 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -52,6 +52,6 @@ class Admin::GroupsController < Admin::ApplicationController private def group - @group = Group.find_by_path(params[:id]) + @group = Group.find_by(path: params[:id]) end end diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb index 088174fd3b..92ef596337 100644 --- a/app/controllers/admin/projects_controller.rb +++ b/app/controllers/admin/projects_controller.rb @@ -1,21 +1,32 @@ class Admin::ProjectsController < Admin::ApplicationController - before_filter :project, only: [:edit, :show, :update, :destroy, :team_update] + before_filter :project, only: [:show, :transfer] + before_filter :group, only: [:show, :transfer] + before_filter :repository, only: [:show, :transfer] def index owner_id = params[:owner_id] - user = User.find_by_id(owner_id) + user = User.find_by(id: owner_id) - @projects = user ? user.owned_projects : Project.scoped - @projects = @projects.where(public: true) if params[:public_only].present? + @projects = user ? user.owned_projects : Project.all + @projects = @projects.where("visibility_level IN (?)", params[:visibility_levels]) if params[:visibility_levels].present? @projects = @projects.with_push if params[:with_push].present? @projects = @projects.abandoned if params[:abandoned].present? @projects = @projects.search(params[:name]) if params[:name].present? + @projects = @projects.sort(@sort = params[:sort]) @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) end def show - @repository = @project.repository - @group = @project.group + end + + def transfer + result = ::Projects::TransferService.new(@project, current_user, project: params).execute(:admin) + + if result + redirect_to [:admin, @project] + else + render :show + end end protected @@ -26,4 +37,12 @@ class Admin::ProjectsController < Admin::ApplicationController @project = Project.find_with_namespace(id) @project || render_404 end + + def group + @group ||= project.group + end + + def repository + @repository ||= project.repository + end end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index c9875b9632..5b06af79d5 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -2,8 +2,7 @@ class Admin::UsersController < Admin::ApplicationController before_filter :user, only: [:show, :edit, :update, :destroy] def index - @users = User.scoped - @users = @users.filter(params[:filter]) + @users = User.filter(params[:filter]) @users = @users.search(params[:name]) if params[:name].present? @users = @users.alphabetically.page(params[:page]) end @@ -48,7 +47,7 @@ class Admin::UsersController < Admin::ApplicationController @user.admin = (admin && admin.to_i > 0) @user.created_by_id = current_user.id @user.generate_password - @user.confirm! + @user.skip_confirmation! respond_to do |format| if @user.save @@ -69,7 +68,9 @@ class Admin::UsersController < Admin::ApplicationController params[:user].delete(:password_confirmation) end - user.admin = (admin && admin.to_i > 0) + if admin.present? + user.admin = !admin.to_i.zero? + end respond_to do |format| if user.update_attributes(params[:user], as: :admin) @@ -101,6 +102,6 @@ class Admin::UsersController < Admin::ApplicationController protected def user - @user ||= User.find_by_username!(params[:id]) + @user ||= User.find_by!(username: params[:id]) end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index cfa3cac5e8..2730e9942e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,12 +1,17 @@ +require 'gon' + class ApplicationController < ActionController::Base before_filter :authenticate_user! before_filter :reject_blocked! before_filter :check_password_expiration around_filter :set_current_user_for_thread before_filter :add_abilities + before_filter :ldap_security_check before_filter :dev_tools if Rails.env == 'development' before_filter :default_headers before_filter :add_gon_variables + before_filter :configure_permitted_parameters, if: :devise_controller? + before_filter :require_email, unless: :devise_controller? protect_from_forgery @@ -81,6 +86,9 @@ class ApplicationController < ActionController::Base if @project and can?(current_user, :read_project, @project) @project + elsif current_user.nil? + @project = nil + authenticate_user! else @project = nil render_404 and return @@ -102,13 +110,18 @@ class ApplicationController < ActionController::Base end def authorize_code_access! - return access_denied! unless can?(current_user, :download_code, project) or project.public? + return access_denied! unless can?(current_user, :download_code, project) end def authorize_push! return access_denied! unless can?(current_user, :push_code, project) end + def authorize_labels! + # Labels should be accessible for issues and/or merge requests + authorize_read_issue! || authorize_read_merge_request! + end + def access_denied! render "errors/access_denied", layout: "errors", status: 404 end @@ -129,12 +142,12 @@ class ApplicationController < ActionController::Base end end - def render_404 - render file: Rails.root.join("public", "404"), layout: false, status: "404" + def render_403 + head :forbidden end - def render_403 - render file: Rails.root.join("public", "403"), layout: false, status: "403" + def render_404 + render file: Rails.root.join("public", "404"), layout: false, status: "404" end def require_non_empty_project @@ -148,12 +161,14 @@ class ApplicationController < ActionController::Base end def dev_tools - Rack::MiniProfiler.authorize_request end def default_headers headers['X-Frame-Options'] = 'DENY' headers['X-XSS-Protection'] = '1; mode=block' + headers['X-UA-Compatible'] = 'IE=edge' + headers['X-Content-Type-Options'] = 'nosniff' + headers['Strict-Transport-Security'] = 'max-age=31536000' if Gitlab.config.gitlab.https end def add_gon_variables @@ -162,6 +177,7 @@ class ApplicationController < ActionController::Base gon.api_token = current_user.private_token if current_user gon.gravatar_url = request.ssl? || Gitlab.config.gitlab.https ? Gitlab.config.gravatar.ssl_url : Gitlab.config.gravatar.plain_url gon.relative_url_root = Gitlab.config.gitlab.relative_url_root + gon.gravatar_enabled = Gitlab.config.gravatar.enabled end def check_password_expiration @@ -170,8 +186,64 @@ class ApplicationController < ActionController::Base end end + def ldap_security_check + if current_user && current_user.requires_ldap_check? + gitlab_ldap_access do |access| + if access.allowed?(current_user) + current_user.last_credential_check_at = Time.now + current_user.save + else + sign_out current_user + flash[:alert] = "Access denied for your LDAP account." + redirect_to new_user_session_path + end + end + end + end + def event_filter filters = cookies['event_filter'].split(',') if cookies['event_filter'].present? @event_filter ||= EventFilter.new(filters) end + + def gitlab_ldap_access(&block) + Gitlab::LDAP::Access.open { |access| block.call(access) } + end + + # JSON for infinite scroll via Pager object + def pager_json(partial, count) + html = render_to_string( + partial, + layout: false, + formats: [:html] + ) + + render json: { + html: html, + count: count + } + end + + def view_to_html_string(partial) + render_to_string( + partial, + layout: false, + formats: [:html] + ) + end + + def configure_permitted_parameters + devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:username, :email, :password, :login, :remember_me) } + devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :name, :password, :password_confirmation) } + end + + def hexdigest(string) + Digest::SHA1.hexdigest string + end + + def require_email + if current_user && current_user.temp_oauth_email? + redirect_to profile_path, notice: 'Please complete your profile with email address' and return + end + end end diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index ac31938443..233b91680f 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -3,6 +3,8 @@ class DashboardController < ApplicationController before_filter :load_projects, except: [:projects] before_filter :event_filter, only: :show + before_filter :default_filter, only: [:issues, :merge_requests] + def show # Fetch only 30 projects. @@ -20,9 +22,11 @@ class DashboardController < ApplicationController @last_push = current_user.recent_push + @publicish_project_count = Project.publicish(current_user).count + respond_to do |format| format.html - format.js + format.json { pager_json("events/_events", @events.count) } format.atom { render layout: false } end end @@ -39,29 +43,27 @@ class DashboardController < ApplicationController current_user.authorized_projects end - @projects = @projects.where(namespace_id: Group.find_by_name(params[:group])) if params[:group].present? - @projects = @projects.includes(:namespace).sorted_by_activity + @projects = @projects.where(namespace_id: Group.find_by(name: params[:group])) if params[:group].present? + @projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].present? + @projects = @projects.includes(:namespace) + @projects = @projects.tagged_with(params[:label]) if params[:label].present? + @projects = @projects.sort(@sort = params[:sort]) + @projects = @projects.page(params[:page]).per(30) @labels = current_user.authorized_projects.tags_on(:labels) @groups = current_user.authorized_groups - - @projects = @projects.tagged_with(params[:label]) if params[:label].present? - @projects = @projects.page(params[:page]).per(30) end - # Get authored or assigned open merge requests def merge_requests - @merge_requests = current_user.cared_merge_requests - @merge_requests = FilterContext.new(@merge_requests, params).execute - @merge_requests = @merge_requests.recent.page(params[:page]).per(20) + @merge_requests = MergeRequestsFinder.new.execute(current_user, params) + @merge_requests = @merge_requests.page(params[:page]).per(20) + @merge_requests = @merge_requests.preload(:author, :target_project) end - # Get only assigned issues def issues - @issues = current_user.assigned_issues - @issues = FilterContext.new(@issues, params).execute - @issues = @issues.recent.page(params[:page]).per(20) - @issues = @issues.includes(:author, :project) + @issues = IssuesFinder.new.execute(current_user, params) + @issues = @issues.page(params[:page]).per(20) + @issues = @issues.preload(:author, :project) respond_to do |format| format.html @@ -72,6 +74,12 @@ class DashboardController < ApplicationController protected def load_projects - @projects = current_user.authorized_projects.sorted_by_activity + @projects = current_user.authorized_projects.sorted_by_activity.non_archived + end + + def default_filter + params[:scope] = 'assigned-to-me' if params[:scope].blank? + params[:state] = 'opened' if params[:state].blank? + params[:authorized_only] = true end end diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb deleted file mode 100644 index a0c8a000fc..0000000000 --- a/app/controllers/errors_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class ErrorsController < ApplicationController -end diff --git a/app/controllers/groups/avatars_controller.rb b/app/controllers/groups/avatars_controller.rb new file mode 100644 index 0000000000..38071410f4 --- /dev/null +++ b/app/controllers/groups/avatars_controller.rb @@ -0,0 +1,12 @@ +class Groups::AvatarsController < ApplicationController + layout "profile" + + def destroy + @group = Group.find_by(path: params[:group_id]) + @group.remove_avatar! + + @group.save + + redirect_to edit_group_path(@group) + end +end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index bb46af14d5..a3019b3ac7 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,4 +1,5 @@ class GroupsController < ApplicationController + skip_before_filter :authenticate_user!, only: [:show, :issues, :members, :merge_requests] respond_to :html before_filter :group, except: [:new, :create] @@ -10,6 +11,8 @@ class GroupsController < ApplicationController # Load group projects before_filter :projects, except: [:new, :create] + before_filter :default_filter, only: [:issues, :merge_requests] + layout :determine_layout before_filter :set_title, only: [:new, :create] @@ -34,28 +37,25 @@ class GroupsController < ApplicationController @events = Event.in_projects(project_ids) @events = event_filter.apply_filter(@events) @events = @events.limit(20).offset(params[:offset] || 0) - @last_push = current_user.recent_push + @last_push = current_user.recent_push if current_user respond_to do |format| format.html - format.js + format.json { pager_json("events/_events", @events.count) } format.atom { render layout: false } end end - # Get authored or assigned open merge requests def merge_requests - @merge_requests = current_user.cared_merge_requests.of_group(@group) - @merge_requests = FilterContext.new(@merge_requests, params).execute - @merge_requests = @merge_requests.recent.page(params[:page]).per(20) + @merge_requests = MergeRequestsFinder.new.execute(current_user, params) + @merge_requests = @merge_requests.page(params[:page]).per(20) + @merge_requests = @merge_requests.preload(:author, :target_project) end - # Get only assigned issues def issues - @issues = current_user.assigned_issues.of_group(@group) - @issues = FilterContext.new(@issues, params).execute - @issues = @issues.recent.page(params[:page]).per(20) - @issues = @issues.includes(:author, :project) + @issues = IssuesFinder.new.execute(current_user, params) + @issues = @issues.page(params[:page]).per(20) + @issues = @issues.preload(:author, :project) respond_to do |format| format.html @@ -65,7 +65,14 @@ class GroupsController < ApplicationController def members @project = group.projects.find(params[:project_id]) if params[:project_id] - @members = group.users_groups.order('group_access DESC') + @members = group.users_groups + + if params[:search].present? + users = group.users.search(params[:search]) + @members = @members.where(user_id: users) + end + + @members = @members.order('group_access DESC').page(params[:page]).per(50) @users_group = UsersGroup.new end @@ -89,21 +96,25 @@ class GroupsController < ApplicationController protected def group - @group ||= Group.find_by_path(params[:id]) + @group ||= Group.find_by(path: params[:id]) end def projects - @projects ||= current_user.authorized_projects.where(namespace_id: group.id).sorted_by_activity + @projects ||= ProjectsFinder.new.execute(current_user, group: group).sorted_by_activity.non_archived end def project_ids - projects.map(&:id) + projects.pluck(:id) end # Dont allow unauthorized access to group def authorize_read_group! unless @group and (projects.present? or can?(current_user, :read_group, @group)) - return render_404 + if current_user.nil? + return authenticate_user! + else + return render_404 + end end end @@ -126,8 +137,22 @@ class GroupsController < ApplicationController def determine_layout if [:new, :create].include?(action_name.to_sym) 'navless' - else + elsif current_user 'group' + else + 'public_group' end end + + def default_filter + if params[:scope].blank? + if current_user + params[:scope] = 'assigned-to-me' + else + params[:scope] = 'all' + end + end + params[:state] = 'opened' if params[:state].blank? + params[:group_id] = @group.id + end end diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb new file mode 100644 index 0000000000..988ede3007 --- /dev/null +++ b/app/controllers/passwords_controller.rb @@ -0,0 +1,18 @@ +class PasswordsController < Devise::PasswordsController + + def create + email = resource_params[:email] + resource_found = resource_class.find_by_email(email) + if resource_found && resource_found.ldap_user? + flash[:alert] = "Cannot reset password for LDAP user." + respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name)) and return + end + + self.resource = resource_class.send_reset_password_instructions(resource_params) + if successfully_sent?(resource) + respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name)) + else + respond_with(resource) + end + end +end diff --git a/app/controllers/profiles/avatars_controller.rb b/app/controllers/profiles/avatars_controller.rb new file mode 100644 index 0000000000..57f3bbf062 --- /dev/null +++ b/app/controllers/profiles/avatars_controller.rb @@ -0,0 +1,13 @@ +class Profiles::AvatarsController < ApplicationController + layout "profile" + + def destroy + @user = current_user + @user.remove_avatar! + + @user.save + @user.reset_events_cache + + redirect_to profile_path + end +end diff --git a/app/controllers/profiles/emails_controller.rb b/app/controllers/profiles/emails_controller.rb new file mode 100644 index 0000000000..40c352dab0 --- /dev/null +++ b/app/controllers/profiles/emails_controller.rb @@ -0,0 +1,26 @@ +class Profiles::EmailsController < ApplicationController + layout "profile" + + def index + @primary = current_user.email + @emails = current_user.emails + end + + def create + @email = current_user.emails.new(params[:email]) + + flash[:alert] = @email.errors.full_messages.first unless @email.save + + redirect_to profile_emails_url + end + + def destroy + @email = current_user.emails.find(params[:id]) + @email.destroy + + respond_to do |format| + format.html { redirect_to profile_emails_url } + format.js { render nothing: true } + end + end +end diff --git a/app/controllers/profiles/groups_controller.rb b/app/controllers/profiles/groups_controller.rb index 378ff6bcf3..9a4d088651 100644 --- a/app/controllers/profiles/groups_controller.rb +++ b/app/controllers/profiles/groups_controller.rb @@ -7,18 +7,17 @@ class Profiles::GroupsController < ApplicationController def leave @users_group = group.users_groups.where(user_id: current_user.id).first - - if group.last_owner?(current_user) - redirect_to(profile_groups_path, alert: "You can't leave group. You must add at least one more owner to it.") - else + if can?(current_user, :destroy, @users_group) @users_group.destroy redirect_to(profile_groups_path, info: "You left #{group.name} group.") + else + return render_403 end end private def group - @group ||= Group.find_by_path(params[:id]) + @group ||= Group.find_by(path: params[:id]) end end diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb index c36dae2abd..6713cd7c8c 100644 --- a/app/controllers/profiles/keys_controller.rb +++ b/app/controllers/profiles/keys_controller.rb @@ -1,8 +1,9 @@ class Profiles::KeysController < ApplicationController layout "profile" + skip_before_filter :authenticate_user!, only: [:get_keys] def index - @keys = current_user.keys.order('id DESC').all + @keys = current_user.keys.order('id DESC') end def show @@ -32,4 +33,24 @@ class Profiles::KeysController < ApplicationController format.js { render nothing: true } end end + + # Get all keys of a user(params[:username]) in a text format + # Helpful for sysadmins to put in respective servers + def get_keys + if params[:username].present? + begin + user = User.find_by_username(params[:username]) + if user.present? + render text: user.all_ssh_keys.join("\n"), content_type: "text/plain" + else + render_404 and return + end + rescue => e + render text: e.message + end + else + render_404 and return + end + end + end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 47cfc5e63f..9c9a129b26 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -3,6 +3,7 @@ class ProfilesController < ApplicationController before_filter :user before_filter :authorize_change_username!, only: :update_username + skip_before_filter :require_email, only: [:show, :update] layout 'profile' @@ -13,6 +14,8 @@ class ProfilesController < ApplicationController end def update + params[:user].delete(:email) if @user.ldap_user? + if @user.update_attributes(params[:user]) flash[:notice] = "Profile was successfully updated" else diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 8fd4565f36..7e4580017d 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -10,7 +10,7 @@ class Projects::ApplicationController < ApplicationController id = params[:project_id] || params[:id] @project = Project.find_with_namespace(id) - return if @project && @project.public + return if @project && @project.public? end super @@ -23,4 +23,10 @@ class Projects::ApplicationController < ApplicationController 'public_projects' end end + + def require_branch_head + unless @repository.branch_names.include?(@ref) + redirect_to project_tree_path(@project, @ref), notice: "This action is not allowed unless you are on top of a branch" + end + end end diff --git a/app/controllers/projects/base_tree_controller.rb b/app/controllers/projects/base_tree_controller.rb new file mode 100644 index 0000000000..5e30593443 --- /dev/null +++ b/app/controllers/projects/base_tree_controller.rb @@ -0,0 +1,8 @@ +class Projects::BaseTreeController < Projects::ApplicationController + include ExtractsPath + + before_filter :authorize_read_project! + before_filter :authorize_code_access! + before_filter :require_non_empty_project +end + diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index ba466251b2..a1a8bed09f 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -6,10 +6,32 @@ class Projects::BlobController < Projects::ApplicationController before_filter :authorize_read_project! before_filter :authorize_code_access! before_filter :require_non_empty_project + before_filter :authorize_push!, only: [:destroy] + + before_filter :blob def show - @blob = @repository.blob_at(@commit.id, @path) + end - not_found! unless @blob + def destroy + result = Files::DeleteService.new(@project, current_user, params, @ref, @path).execute + + if result[:status] == :success + flash[:notice] = "Your changes have been successfully committed" + redirect_to project_tree_path(@project, @ref) + else + flash[:alert] = result[:error] + render :show + end + end + + private + + def blob + @blob ||= @repository.blob_at(@commit.id, @path) + + return not_found! unless @blob + + @blob end end diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index aa6914414c..6a6cbe4818 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -16,11 +16,7 @@ class Projects::BranchesController < Projects::ApplicationController end def create - @repository.add_branch(params[:branch_name], params[:ref]) - - if new_branch = @repository.find_branch(params[:branch_name]) - Event.create_ref_event(@project, current_user, new_branch, 'add') - end + CreateBranchService.new.execute(project, params[:branch_name], params[:ref], current_user) redirect_to project_branches_path(@project) end diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 242aa41182..c56df65dcb 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -6,34 +6,35 @@ class Projects::CommitController < Projects::ApplicationController before_filter :authorize_read_project! before_filter :authorize_code_access! before_filter :require_non_empty_project + before_filter :commit def show - result = CommitLoadContext.new(project, current_user, params).execute + return git_not_found! unless @commit - @commit = result[:commit] + @line_notes = project.notes.for_commit_id(commit.id).inline + @branches = project.repository.branch_names_contains(commit.id) - if @commit.nil? - git_not_found! - return + begin + @suppress_diff = true if commit.diff_suppress? && !params[:force_show_diff] + @force_suppress_diff = commit.diff_force_suppress? + rescue Grit::Git::GitTimeout + @suppress_diff = true + @status = :huge_commit end - @suppress_diff = result[:suppress_diff] - @force_suppress_diff = result[:force_suppress_diff] - - @note = result[:note] - @line_notes = result[:line_notes] - @branches = result[:branches] - @notes_count = result[:notes_count] - @target_type = :commit - @target_id = @commit.id - + @note = project.build_commit_note(commit) + @notes_count = project.notes.for_commit_id(commit.id).count + @notes = project.notes.for_commit_id(@commit.id).not_inline.fresh + @noteable = @commit @comments_allowed = @reply_allowed = true - @comments_target = { noteable_type: 'Commit', - commit_id: @commit.id } + @comments_target = { + noteable_type: 'Commit', + commit_id: @commit.id + } respond_to do |format| format.html do - if result[:status] == :huge_commit + if @status == :huge_commit render "huge_commit" and return end end @@ -42,4 +43,8 @@ class Projects::CommitController < Projects::ApplicationController format.patch { render text: @commit.to_patch } end end + + def commit + @commit ||= project.repository.commit(params[:id]) + end end diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index bdffc940ea..12856191c2 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -16,7 +16,7 @@ class Projects::CommitsController < Projects::ApplicationController respond_to do |format| format.html # index.html.erb - format.js + format.json { pager_json("projects/commits/_commits", @commits.size) } format.atom { render layout: false } end end diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb index b7531e2cef..234b6058ff 100644 --- a/app/controllers/projects/compare_controller.rb +++ b/app/controllers/projects/compare_controller.rb @@ -8,13 +8,14 @@ class Projects::CompareController < Projects::ApplicationController end def show - compare = Gitlab::Git::Compare.new(@repository.raw_repository, params[:from], params[:to]) + compare = Gitlab::Git::Compare.new(@repository.raw_repository, params[:from], params[:to], MergeRequestDiff::COMMITS_SAFE_SIZE) @commits = compare.commits @commit = compare.commit @diffs = compare.diffs @refs_are_same = compare.same @line_notes = [] + @timeout = compare.timeout diff_line_count = Commit::diff_line_count(@diffs) @suppress_diff = Commit::diff_suppress?(@diffs, diff_line_count) && !params[:force_show_diff] diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb index 0750e0a146..6e1a76ff41 100644 --- a/app/controllers/projects/deploy_keys_controller.rb +++ b/app/controllers/projects/deploy_keys_controller.rb @@ -7,7 +7,7 @@ class Projects::DeployKeysController < Projects::ApplicationController layout "project_settings" def index - @enabled_keys = @project.deploy_keys.all + @enabled_keys = @project.deploy_keys @available_keys = available_keys - @enabled_keys end diff --git a/app/controllers/projects/edit_tree_controller.rb b/app/controllers/projects/edit_tree_controller.rb index 0e51ff59f3..be611892bb 100644 --- a/app/controllers/projects/edit_tree_controller.rb +++ b/app/controllers/projects/edit_tree_controller.rb @@ -1,53 +1,61 @@ -# Controller for edit a repository's file -class Projects::EditTreeController < Projects::ApplicationController - include ExtractsPath - - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - - before_filter :edit_requirements, only: [:show, :update] +class Projects::EditTreeController < Projects::BaseTreeController + before_filter :require_branch_head + before_filter :blob + before_filter :authorize_push! + before_filter :from_merge_request + before_filter :after_edit_path def show @last_commit = Gitlab::Git::Commit.last_for_path(@repository, @ref, @path).sha end def update - edit_file_action = Gitlab::Satellite::EditFileAction.new(current_user, @project, @ref, @path) - updated_successfully = edit_file_action.commit!( - params[:content], - params[:commit_message], - params[:last_commit] - ) + result = Files::UpdateService.new(@project, current_user, params, @ref, @path).execute - if updated_successfully - redirect_to project_blob_path(@project, @id), notice: "Your changes have been successfully commited" + if result[:status] == :success + flash[:notice] = "Your changes have been successfully committed" + + if from_merge_request + from_merge_request.reload_code + end + + redirect_to after_edit_path else - flash[:notice] = "Your changes could not be commited, because the file has been changed" + flash[:alert] = result[:error] render :show end end + def preview + @content = params[:content] + #FIXME workaround https://github.com/gitlabhq/gitlabhq/issues/5936 + @content += "\n" if @blob.data.end_with?("\n") + + diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', + include_diff_info: true) + @diff = Gitlab::DiffParser.new(diffy.diff.scan(/.*\n/)) + + render layout: false + end + private - def edit_requirements - @blob = @repository.blob_at(@commit.id, @path) + def blob + @blob ||= @repository.blob_at(@commit.id, @path) + end - unless @blob - redirect_to project_blob_path(@project, @id), notice: "You can only edit text files" - end + def after_edit_path + @after_edit_path ||= + if from_merge_request + diffs_project_merge_request_path(from_merge_request.target_project, from_merge_request) + + "#file-path-#{hexdigest(@path)}" + else + project_blob_path(@project, @id) + end + end - allowed = if project.protected_branch? @ref - can?(current_user, :push_code_to_protected_branches, project) - else - can?(current_user, :push_code, project) - end - - return access_denied! unless allowed - - unless @repository.branch_names.include?(@ref) - redirect_to project_blob_path(@project, @id), notice: "You can only edit this file if you are on top of a branch" - end + def from_merge_request + # If blob edit was initiated from merge request page + @from_merge_request ||= MergeRequest.find_by(id: params[:from_merge_request_id]) end end diff --git a/app/controllers/projects/hooks_controller.rb b/app/controllers/projects/hooks_controller.rb index 1a94dbab5e..c43d26385f 100644 --- a/app/controllers/projects/hooks_controller.rb +++ b/app/controllers/projects/hooks_controller.rb @@ -7,7 +7,7 @@ class Projects::HooksController < Projects::ApplicationController layout "project_settings" def index - @hooks = @project.hooks.all + @hooks = @project.hooks @hook = ProjectHook.new end @@ -18,21 +18,26 @@ class Projects::HooksController < Projects::ApplicationController if @hook.valid? redirect_to project_hooks_path(@project) else - @hooks = @project.hooks.all + @hooks = @project.hooks.select(&:persisted?) render :index end end def test - TestHookContext.new(project, current_user, params).execute + TestHookService.new.execute(hook, current_user) redirect_to :back end def destroy - @hook = @project.hooks.find(params[:id]) - @hook.destroy + hook.destroy redirect_to project_hooks_path(@project) end + + private + + def hook + @hook ||= @project.hooks.find(params[:id]) + end end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index e8f845b2d1..4e7a716bfe 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -11,7 +11,10 @@ class Projects::IssuesController < Projects::ApplicationController # Allow modify issue before_filter :authorize_modify_issue!, only: [:edit, :update] - respond_to :js, :html + # Allow issues bulk update + before_filter :authorize_admin_issues!, only: [:bulk_update] + + respond_to :html def index terms = params['issue_search'] @@ -23,11 +26,18 @@ class Projects::IssuesController < Projects::ApplicationController assignee_id, milestone_id = params[:assignee_id], params[:milestone_id] @assignee = @project.team.find(assignee_id) if assignee_id.present? && !assignee_id.to_i.zero? @milestone = @project.milestones.find(milestone_id) if milestone_id.present? && !milestone_id.to_i.zero? + sort_param = params[:sort] || 'newest' + @sort = sort_param.humanize unless sort_param.empty? + @assignees = User.where(id: @project.issues.pluck(:assignee_id)) respond_to do |format| - format.html # index.html.erb - format.js + format.html format.atom { render layout: false } + format.json do + render json: { + html: view_to_html_string("projects/issues/_issues") + } + end end end @@ -42,19 +52,14 @@ class Projects::IssuesController < Projects::ApplicationController def show @note = @project.notes.new(noteable: @issue) - @target_type = :issue - @target_id = @issue.id + @notes = @issue.notes.inc_author.fresh + @noteable = @issue - respond_to do |format| - format.html - format.js - end + respond_with(@issue) end def create - @issue = @project.issues.new(params[:issue]) - @issue.author = current_user - @issue.save + @issue = Issues::CreateService.new(project, current_user, params[:issue]).execute respond_to do |format| format.html do @@ -69,7 +74,7 @@ class Projects::IssuesController < Projects::ApplicationController end def update - @issue.update_attributes(params[:issue].merge(author_id_of_changes: current_user.id)) + @issue = Issues::UpdateService.new(project, current_user, params[:issue]).execute(issue) respond_to do |format| format.js @@ -84,7 +89,7 @@ class Projects::IssuesController < Projects::ApplicationController end def bulk_update - result = Issues::BulkUpdateContext.new(project, current_user, params).execute + result = Issues::BulkUpdateService.new(project, current_user, params).execute redirect_to :back, notice: "#{result[:count]} issues updated" end @@ -92,7 +97,7 @@ class Projects::IssuesController < Projects::ApplicationController def issue @issue ||= begin - @project.issues.find_by_iid!(params[:id]) + @project.issues.find_by!(iid: params[:id]) rescue ActiveRecord::RecordNotFound redirect_old end @@ -102,8 +107,8 @@ class Projects::IssuesController < Projects::ApplicationController return render_404 unless can?(current_user, :modify_issue, @issue) end - def authorize_admin_issue! - return render_404 unless can?(current_user, :admin_issue, @issue) + def authorize_admin_issues! + return render_404 unless can?(current_user, :admin_issue, @project) end def module_enabled @@ -111,7 +116,9 @@ class Projects::IssuesController < Projects::ApplicationController end def issues_filtered - @issues = Issues::ListContext.new(project, current_user, params).execute + params[:scope] = 'all' if params[:scope].blank? + params[:state] = 'opened' if params[:state].blank? + @issues = IssuesFinder.new.execute(current_user, params.merge(project_id: @project.id)) end # Since iids are implemented only in 6.1 @@ -120,7 +127,7 @@ class Projects::IssuesController < Projects::ApplicationController # To prevent 404 errors we provide a redirect to correct iids until 7.0 release # def redirect_old - issue = @project.issues.find_by_id(params[:id]) + issue = @project.issues.find_by(id: params[:id]) if issue redirect_to project_issue_path(@project, issue) diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 65f9e2b9d5..b037cf5650 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -1,8 +1,7 @@ class Projects::LabelsController < Projects::ApplicationController before_filter :module_enabled - # Allow read any issue - before_filter :authorize_read_issue! + before_filter :authorize_labels! respond_to :js, :html @@ -13,12 +12,18 @@ class Projects::LabelsController < Projects::ApplicationController def generate Gitlab::IssuesLabels.generate(@project) - redirect_to project_labels_path(@project) + if params[:redirect] == 'issues' + redirect_to project_issues_path(@project) + elsif params[:redirect] == 'merge_requests' + redirect_to project_merge_requests_path(@project) + end end protected def module_enabled - return render_404 unless @project.issues_enabled + unless @project.issues_enabled || @project.merge_requests_enabled + return render_404 + end end end diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 0cc09caf1d..d8551db7b0 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -2,8 +2,8 @@ require 'gitlab/satellite/satellite' class Projects::MergeRequestsController < Projects::ApplicationController before_filter :module_enabled - before_filter :merge_request, only: [:edit, :update, :show, :commits, :diffs, :automerge, :automerge_check, :ci_status] - before_filter :closes_issues, only: [:edit, :update, :show, :commits, :diffs] + before_filter :merge_request, only: [:edit, :update, :show, :diffs, :automerge, :automerge_check, :ci_status] + before_filter :closes_issues, only: [:edit, :update, :show, :diffs] before_filter :validates_merge_request, only: [:show, :diffs] before_filter :define_show_vars, only: [:show, :diffs] @@ -17,17 +17,23 @@ class Projects::MergeRequestsController < Projects::ApplicationController before_filter :authorize_modify_merge_request!, only: [:close, :edit, :update, :sort] def index - @merge_requests = MergeRequestsLoadContext.new(project, current_user, params).execute + params[:sort] ||= 'newest' + params[:scope] = 'all' if params[:scope].blank? + params[:state] = 'opened' if params[:state].blank? + + @merge_requests = MergeRequestsFinder.new.execute(current_user, params.merge(project_id: @project.id)) + @merge_requests = @merge_requests.page(params[:page]).per(20) + + @sort = params[:sort].humanize assignee_id, milestone_id = params[:assignee_id], params[:milestone_id] @assignee = @project.team.find(assignee_id) if assignee_id.present? && !assignee_id.to_i.zero? @milestone = @project.milestones.find(milestone_id) if milestone_id.present? && !milestone_id.to_i.zero? + @assignees = User.where(id: @project.merge_requests.pluck(:assignee_id)) end def show respond_to do |format| format.html - format.js - format.diff { render text: @merge_request.to_diff(current_user) } format.patch { render text: @merge_request.to_patch(current_user) } end @@ -44,15 +50,39 @@ class Projects::MergeRequestsController < Projects::ApplicationController diff_line_count = Commit::diff_line_count(@merge_request.diffs) @suppress_diff = Commit::diff_suppress?(@merge_request.diffs, diff_line_count) && !params[:force_show_diff] @force_suppress_diff = Commit::diff_force_suppress?(@merge_request.diffs, diff_line_count) + + respond_to do |format| + format.html + format.json { render json: { html: view_to_html_string("projects/merge_requests/show/_diffs") } } + end end def new @merge_request = MergeRequest.new(params[:merge_request]) @merge_request.source_project = @project unless @merge_request.source_project - @merge_request.target_project = @project unless @merge_request.target_project + @merge_request.target_project ||= (@project.forked_from_project || @project) @target_branches = @merge_request.target_project.nil? ? [] : @merge_request.target_project.repository.branch_names + @merge_request.target_branch ||= @merge_request.target_project.default_branch @source_project = @merge_request.source_project - @merge_request + + if @merge_request.target_branch && @merge_request.source_branch + compare_action = Gitlab::Satellite::CompareAction.new( + current_user, + @merge_request.target_project, + @merge_request.target_branch, + @merge_request.source_project, + @merge_request.source_branch + ) + + @commits = compare_action.commits + @commits.map! { |commit| Commit.new(commit) } + @commit = @commits.first + + @diffs = compare_action.diffs + @merge_request.title = @merge_request.source_branch.titleize.humanize + @target_project = @merge_request.target_project + @target_repo = @target_project.repository + end end def edit @@ -62,12 +92,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController end def create - @merge_request = MergeRequest.new(params[:merge_request]) - @merge_request.author = current_user @target_branches ||= [] - if @merge_request.save - @merge_request.reload_code - redirect_to [@merge_request.target_project, @merge_request], notice: 'Merge request was successfully created.' + @merge_request = MergeRequests::CreateService.new(project, current_user, params[:merge_request]).execute + + if @merge_request.valid? + redirect_to project_merge_request_path(@merge_request.target_project, @merge_request), notice: 'Merge request was successfully created.' else @source_project = @merge_request.source_project @target_project = @merge_request.target_project @@ -76,10 +105,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController end def update - if @merge_request.update_attributes(params[:merge_request].merge(author_id_of_changes: current_user.id)) - @merge_request.reload_code - @merge_request.mark_as_unchecked - redirect_to [@merge_request.target_project, @merge_request], notice: 'Merge request was successfully updated.' + @merge_request = MergeRequests::UpdateService.new(project, current_user, params[:merge_request]).execute(@merge_request) + + if @merge_request.valid? + respond_to do |format| + format.js + format.html do + redirect_to [@merge_request.target_project, @merge_request], notice: 'Merge request was successfully updated.' + end + end else render "edit" end @@ -90,16 +124,14 @@ class Projects::MergeRequestsController < Projects::ApplicationController @merge_request.check_if_can_be_merged end render json: {merge_status: @merge_request.merge_status_name} - rescue Gitlab::SatelliteNotExistError - render json: {merge_status: :no_satellite} end def automerge return access_denied! unless allowed_to_merge? - if @merge_request.opened? && @merge_request.can_be_merged? + if @merge_request.open? && @merge_request.can_be_merged? @merge_request.should_remove_source_branch = params[:should_remove_source_branch] - @merge_request.automerge!(current_user) + @merge_request.automerge!(current_user, params[:merge_commit_message]) @status = true else @status = false @@ -121,10 +153,14 @@ class Projects::MergeRequestsController < Projects::ApplicationController @target_project = selected_target_project @target_branches = @target_project.repository.branch_names @target_branches + + respond_to do |format| + format.js + end end def ci_status - status = project.gitlab_ci_service.commit_status(merge_request.last_commit.sha) + status = @merge_request.source_project.gitlab_ci_service.commit_status(merge_request.last_commit.sha) response = {status: status} render json: response @@ -133,11 +169,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController protected def selected_target_project - ((@project.id.to_s == params[:target_project_id]) || @project.forked_project_link.nil?) ? @project : @project.forked_project_link.forked_from_project + if @project.id.to_s == params[:target_project_id] || @project.forked_project_link.nil? + @project + else + @project.forked_project_link.forked_from_project + end end def merge_request - @merge_request ||= @project.merge_requests.find_by_iid!(params[:id]) + @merge_request ||= @project.merge_requests.find_by!(iid: params[:id]) end def closes_issues @@ -157,44 +197,59 @@ class Projects::MergeRequestsController < Projects::ApplicationController end def validates_merge_request + # If source project was removed (Ex. mr from fork to origin) + return invalid_mr unless @merge_request.source_project + # Show git not found page # if there is no saved commits between source & target branch if @merge_request.commits.blank? - # and if source target doesn't exist - return invalid_mr unless @merge_request.target_project.repository.branch_names.include?(@merge_request.target_branch) + # and if target branch doesn't exist + return invalid_mr unless @merge_request.target_branch_exists? - # or if source branch doesn't exist - return invalid_mr unless @merge_request.source_project.repository.branch_names.include?(@merge_request.source_branch) + # or if source branch doesn't exist + return invalid_mr unless @merge_request.source_branch_exists? end end def define_show_vars # Build a note object for comment form @note = @project.notes.new(noteable: @merge_request) + @notes = @merge_request.mr_and_commit_notes.inc_author.fresh + @discussions = Note.discussions_from_notes(@notes) + @noteable = @merge_request # Get commits from repository # or from cache if already merged @commits = @merge_request.commits + @merge_request_diff = @merge_request.merge_request_diff @allowed_to_merge = allowed_to_merge? - @show_merge_controls = @merge_request.opened? && @commits.any? && @allowed_to_merge - - @target_type = :merge_request - @target_id = @merge_request.id + @show_merge_controls = @merge_request.open? && @commits.any? && @allowed_to_merge + @allowed_to_remove_source_branch = allowed_to_remove_source_branch? + @source_branch = @merge_request.source_project.repository.find_branch(@merge_request.source_branch).try(:name) end def allowed_to_merge? - action = if project.protected_branch?(@merge_request.target_branch) - :push_code_to_protected_branches - else - :push_code - end - - can?(current_user, action, @project) + allowed_to_push_code?(project, @merge_request.target_branch) end def invalid_mr # Render special view for MR with removed source or target branch render 'invalid' end + + def allowed_to_remove_source_branch? + allowed_to_push_code?(@merge_request.source_project, @merge_request.source_branch) && + !@merge_request.disallow_source_branch_removal? + end + + def allowed_to_push_code?(project, branch) + action = if project.protected_branch?(branch) + :push_code_to_protected_branches + else + :push_code + end + + can?(current_user, action, project) + end end diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb index 3e88656cdf..05237bbd2d 100644 --- a/app/controllers/projects/milestones_controller.rb +++ b/app/controllers/projects/milestones_controller.rb @@ -34,16 +34,10 @@ class Projects::MilestonesController < Projects::ApplicationController @issues = @milestone.issues @users = @milestone.participants.uniq @merge_requests = @milestone.merge_requests - - respond_to do |format| - format.html - format.js - end end def create @milestone = @project.milestones.new(params[:milestone]) - @milestone.author_id_of_changes = current_user.id if @milestone.save redirect_to project_milestone_path(@project, @milestone) @@ -53,7 +47,7 @@ class Projects::MilestonesController < Projects::ApplicationController end def update - @milestone.update_attributes(params[:milestone].merge(author_id_of_changes: current_user.id)) + @milestone.update_attributes(params[:milestone]) respond_to do |format| format.js @@ -81,7 +75,7 @@ class Projects::MilestonesController < Projects::ApplicationController protected def milestone - @milestone ||= @project.milestones.find_by_iid!(params[:id]) + @milestone ||= @project.milestones.find_by!(iid: params[:id]) end def authorize_admin_milestone! diff --git a/app/controllers/projects/new_tree_controller.rb b/app/controllers/projects/new_tree_controller.rb new file mode 100644 index 0000000000..3a51a78ef6 --- /dev/null +++ b/app/controllers/projects/new_tree_controller.rb @@ -0,0 +1,20 @@ +class Projects::NewTreeController < Projects::BaseTreeController + before_filter :require_branch_head + before_filter :authorize_push! + + def show + end + + def update + file_path = File.join(@path, File.basename(params[:file_name])) + result = Files::CreateService.new(@project, current_user, params, @ref, file_path).execute + + if result[:status] == :success + flash[:notice] = "Your changes have been successfully committed" + redirect_to project_blob_path(@project, File.join(@ref, file_path)) + else + flash[:alert] = result[:error] + render :show + end + end +end diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 8214163c31..b5b0446b43 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -2,62 +2,55 @@ class Projects::NotesController < Projects::ApplicationController # Authorize before_filter :authorize_read_note! before_filter :authorize_write_note!, only: [:create] - - respond_to :js + before_filter :authorize_admin_note!, only: [:update, :destroy] def index - @notes = Notes::LoadContext.new(project, current_user, params).execute - @target_type = params[:target_type].camelize - @target_id = params[:target_id] + current_fetched_at = Time.now.to_i + @notes = NotesFinder.new.execute(project, current_user, params) - if params[:target_type] == "merge_request" - @discussions = discussions_from_notes + notes_json = { notes: [], last_fetched_at: current_fetched_at } + + @notes.each do |note| + notes_json[:notes] << { + id: note.id, + html: note_to_html(note) + } end - respond_with(@notes) + render json: notes_json end def create - @note = Notes::CreateContext.new(project, current_user, params).execute - @target_type = params[:target_type].camelize - @target_id = params[:target_id] + @note = Notes::CreateService.new(project, current_user, params).execute respond_to do |format| - format.html {redirect_to :back} - format.js + format.json { render_note_json(@note) } + format.html { redirect_to :back } + end + end + + def update + note.update_attributes(params[:note]) + note.reset_events_cache + + respond_to do |format| + format.json { render_note_json(note) } + format.html { redirect_to :back } end end def destroy - @note = @project.notes.find(params[:id]) - return access_denied! unless can?(current_user, :admin_note, @note) - @note.destroy + note.destroy + note.reset_events_cache respond_to do |format| format.js { render nothing: true } end end - def update - @note = @project.notes.find(params[:id]) - return access_denied! unless can?(current_user, :admin_note, @note) - - @note.update_attributes(params[:note]) - - respond_to do |format| - format.js do - render js: { success: @note.valid?, id: @note.id, note: view_context.markdown(@note.note) }.to_json - end - format.html do - redirect_to :back - end - end - end - def delete_attachment - @note = @project.notes.find(params[:id]) - @note.remove_attachment! - @note.update_attribute(:attachment, nil) + note.remove_attachment! + note.update_attribute(:attachment, nil) respond_to do |format| format.js { render nothing: true } @@ -68,35 +61,40 @@ class Projects::NotesController < Projects::ApplicationController render text: view_context.markdown(params[:note]) end - protected + private - def discussion_notes_for(note) - @notes.select do |other_note| - note.discussion_id == other_note.discussion_id - end + def note + @note ||= @project.notes.find(params[:id]) end - def discussions_from_notes - discussion_ids = [] - discussions = [] - - @notes.each do |note| - next if discussion_ids.include?(note.discussion_id) - - # don't group notes for the main target - if note_for_main_target?(note) - discussions << [note] - else - discussions << discussion_notes_for(note) - discussion_ids << note.discussion_id - end - end - - discussions + def note_to_html(note) + render_to_string( + "projects/notes/_note", + layout: false, + formats: [:html], + locals: { note: note } + ) end - # Helps to distinguish e.g. commit notes in mr notes list - def note_for_main_target?(note) - (@target_type.camelize == note.noteable_type && !note.for_diff_line?) + def note_to_discussion_html(note) + render_to_string( + "projects/notes/_diff_notes_with_reply", + layout: false, + formats: [:html], + locals: { notes: [note] } + ) + end + + def render_note_json(note) + render json: { + id: note.id, + discussion_id: note.discussion_id, + html: note_to_html(note), + discussion_html: note_to_discussion_html(note) + } + end + + def authorize_admin_note! + return access_denied! unless can?(current_user, :admin_note, note) end end diff --git a/app/controllers/projects/protected_branches_controller.rb b/app/controllers/projects/protected_branches_controller.rb index 81531bb0ac..cfc1bd99a2 100644 --- a/app/controllers/projects/protected_branches_controller.rb +++ b/app/controllers/projects/protected_branches_controller.rb @@ -6,7 +6,7 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController before_filter :authorize_admin_project!, only: [:destroy, :create] def index - @branches = @project.protected_branches.all + @branches = @project.protected_branches.to_a @protected_branch = @project.protected_branches.new end diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb index 18ace028b0..a6b7ae3f12 100644 --- a/app/controllers/projects/raw_controller.rb +++ b/app/controllers/projects/raw_controller.rb @@ -11,11 +11,7 @@ class Projects::RawController < Projects::ApplicationController @blob = @repository.blob_at(@commit.id, @path) if @blob - type = if @blob.mime_type =~ /html|javascript/ - 'text/plain; charset=utf-8' - else - @blob.mime_type - end + type = get_blob_type headers['X-Content-Type-Options'] = 'nosniff' @@ -29,5 +25,17 @@ class Projects::RawController < Projects::ApplicationController not_found! end end + + private + + def get_blob_type + if @blob.mime_type =~ /html|javascript/ + 'text/plain; charset=utf-8' + elsif @blob.name =~ /(?:msi|exe|rar|r0\d|7z|7zip|zip)$/ + 'application/octet-stream' + else + @blob.mime_type + end + end end diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb index 16621c0371..7b8026cff9 100644 --- a/app/controllers/projects/refs_controller.rb +++ b/app/controllers/projects/refs_controller.rb @@ -34,7 +34,7 @@ class Projects::RefsController < Projects::ApplicationController contents = tree.entries @logs = contents.map do |content| file = params[:path] ? File.join(params[:path], content.name) : content.name - last_commit = @repo.commits(@commit.id, file, 1).last + last_commit = @repo.last_commit_for_path(@commit.id, file) { file_name: content.name, commit: last_commit diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index 20e2a9311e..28fed8b0e3 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -14,9 +14,11 @@ class Projects::RepositoriesController < Projects::ApplicationController render_404 and return end - storage_path = Rails.root.join("tmp", "repositories") + storage_path = Gitlab.config.gitlab.repository_downloads_path - file_path = @repository.archive_repo(params[:ref], storage_path) + @repository.clean_old_archives + + file_path = @repository.archive_repo(params[:ref], storage_path, params[:format].downcase) if file_path # Send file to user diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb index dd0c1a5708..f93f2d5f9b 100644 --- a/app/controllers/projects/snippets_controller.rb +++ b/app/controllers/projects/snippets_controller.rb @@ -48,8 +48,8 @@ class Projects::SnippetsController < Projects::ApplicationController def show @note = @project.notes.new(noteable: @snippet) - @target_type = :snippet - @target_id = @snippet.id + @notes = @snippet.notes.fresh + @noteable = @snippet end def destroy diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb index 9dbb0d8188..0b99165bf6 100644 --- a/app/controllers/projects/tags_controller.rb +++ b/app/controllers/projects/tags_controller.rb @@ -8,7 +8,8 @@ class Projects::TagsController < Projects::ApplicationController before_filter :authorize_admin_project!, only: [:destroy] def index - @tags = Kaminari.paginate_array(@repository.tags).page(params[:page]).per(30) + sorted = VersionSorter.rsort(@repository.tag_names) + @tags = Kaminari.paginate_array(sorted).page(params[:page]).per(30) end def create diff --git a/app/controllers/projects/team_members_controller.rb b/app/controllers/projects/team_members_controller.rb index b4b318fa59..44068878cd 100644 --- a/app/controllers/projects/team_members_controller.rb +++ b/app/controllers/projects/team_members_controller.rb @@ -1,6 +1,6 @@ class Projects::TeamMembersController < Projects::ApplicationController # Authorize - before_filter :authorize_admin_project! + before_filter :authorize_admin_project!, except: :leave layout "project_settings" @@ -26,7 +26,7 @@ class Projects::TeamMembersController < Projects::ApplicationController end def update - @user_project_relation = project.users_projects.find_by_user_id(member) + @user_project_relation = project.users_projects.find_by(user_id: member) @user_project_relation.update_attributes(params[:team_member]) unless @user_project_relation.valid? @@ -36,7 +36,7 @@ class Projects::TeamMembersController < Projects::ApplicationController end def destroy - @user_project_relation = project.users_projects.find_by_user_id(member) + @user_project_relation = project.users_projects.find_by(user_id: member) @user_project_relation.destroy respond_to do |format| @@ -45,6 +45,15 @@ class Projects::TeamMembersController < Projects::ApplicationController end end + def leave + project.users_projects.find_by(user_id: current_user).destroy + + respond_to do |format| + format.html { redirect_to :back } + format.js { render nothing: true } + end + end + def apply_import giver = Project.find(params[:source_project_id]) status = @project.team.import(giver) @@ -56,6 +65,6 @@ class Projects::TeamMembersController < Projects::ApplicationController protected def member - @member ||= User.find_by_username(params[:id]) + @member ||= User.find_by(username: params[:id]) end end diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index 1150efbea9..30c94ec6da 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -1,12 +1,5 @@ # Controller for viewing a repository's file structure -class Projects::TreeController < Projects::ApplicationController - include ExtractsPath - - # Authorize - before_filter :authorize_read_project! - before_filter :authorize_code_access! - before_filter :require_non_empty_project - +class Projects::TreeController < Projects::BaseTreeController def show return not_found! if tree.entries.empty? diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index 797f3d3dd4..496064c9a6 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -1,62 +1,80 @@ +require 'project_wiki' + class Projects::WikisController < Projects::ApplicationController before_filter :authorize_read_wiki! before_filter :authorize_write_wiki!, only: [:edit, :create, :history] before_filter :authorize_admin_wiki!, only: :destroy - before_filter :load_gollum_wiki + before_filter :load_project_wiki def pages - @wiki_pages = @gollum_wiki.pages + @wiki_pages = Kaminari.paginate_array(@project_wiki.pages).page(params[:page]).per(30) end def show - @wiki = @gollum_wiki.find_page(params[:id], params[:version_id]) + @page = @project_wiki.find_page(params[:id], params[:version_id]) + gollum_wiki = @project_wiki.wiki + file = gollum_wiki.file(params[:id], gollum_wiki.ref, true) - if @wiki + if @page render 'show' + elsif file + if file.on_disk? + send_file file.on_disk_path, disposition: 'inline' + else + send_data( + file.raw_data, + type: file.mime_type, + disposition: 'inline', + filename: file.name + ) + end else return render('empty') unless can?(current_user, :write_wiki, @project) - @wiki = WikiPage.new(@gollum_wiki) - @wiki.title = params[:id] + @page = WikiPage.new(@project_wiki) + @page.title = params[:id] render 'edit' end end def edit - @wiki = @gollum_wiki.find_page(params[:id]) + @page = @project_wiki.find_page(params[:id]) end def update - @wiki = @gollum_wiki.find_page(params[:id]) + @page = @project_wiki.find_page(params[:id]) return render('empty') unless can?(current_user, :write_wiki, @project) - if @wiki.update(content, format, message) - redirect_to [@project, @wiki], notice: 'Wiki was successfully updated.' + if @page.update(content, format, message) + redirect_to [@project, @page], notice: 'Wiki was successfully updated.' else render 'edit' end end def create - @wiki = WikiPage.new(@gollum_wiki) + @page = WikiPage.new(@project_wiki) - if @wiki.create(wiki_params) - redirect_to project_wiki_path(@project, @wiki), notice: 'Wiki was successfully updated.' + if @page.create(wiki_params) + redirect_to project_wiki_path(@project, @page), notice: 'Wiki was successfully updated.' else render action: "edit" end end def history - @wiki = @gollum_wiki.find_page(params[:id]) + @page = @project_wiki.find_page(params[:id]) - redirect_to(project_wiki_path(@project, :home), notice: "Page not found") unless @wiki + unless @page + redirect_to(project_wiki_path(@project, :home), notice: "Page not found") + end end def destroy - @wiki = @gollum_wiki.find_page(params[:id]) - @wiki.delete if @wiki + @page = @project_wiki.find_page(params[:id]) + @page.delete if @page + redirect_to project_wiki_path(@project, :home), notice: "Page was successfully deleted" end @@ -65,12 +83,12 @@ class Projects::WikisController < Projects::ApplicationController private - def load_gollum_wiki - @gollum_wiki = GollumWiki.new(@project, current_user) + def load_project_wiki + @project_wiki = ProjectWiki.new(@project, current_user) # Call #wiki to make sure the Wiki Repo is initialized - @gollum_wiki.wiki - rescue GollumWiki::CouldNotCreateWikiError => ex + @project_wiki.wiki + rescue ProjectWiki::CouldNotCreateWikiError => ex flash[:notice] = "Could not create Wiki Repository at this time. Please try again later." redirect_to @project return false @@ -91,5 +109,4 @@ class Projects::WikisController < Projects::ApplicationController def message params[:wiki][:message] end - end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 7264128691..ebb8a90c63 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -5,7 +5,7 @@ class ProjectsController < ApplicationController # Authorize before_filter :authorize_read_project!, except: [:index, :new, :create] - before_filter :authorize_admin_project!, only: [:edit, :update, :destroy, :transfer] + before_filter :authorize_admin_project!, only: [:edit, :update, :destroy, :transfer, :archive, :unarchive, :retry_import] before_filter :require_non_empty_project, only: [:blob, :tree, :graph] layout 'navless', only: [:new, :create, :fork] @@ -20,23 +20,16 @@ class ProjectsController < ApplicationController end def create - @project = ::Projects::CreateContext.new(current_user, params[:project]).execute + @project = ::Projects::CreateService.new(current_user, params[:project]).execute + flash[:notice] = 'Project was successfully created.' if @project.saved? respond_to do |format| - flash[:notice] = 'Project was successfully created.' if @project.saved? - format.html do - if @project.saved? - redirect_to @project - else - render "new" - end - end format.js end end def update - status = ::Projects::UpdateContext.new(@project, current_user, params).execute + status = ::Projects::UpdateService.new(@project, current_user, params).execute respond_to do |format| if status @@ -51,36 +44,57 @@ class ProjectsController < ApplicationController end def transfer - ::Projects::TransferContext.new(project, current_user, params).execute + ::Projects::TransferService.new(project, current_user, params).execute end def show - return authenticate_user! unless @project.public || current_user + if @project.import_in_progress? + redirect_to import_project_path(@project) + return + end + + return authenticate_user! unless @project.public? || current_user limit = (params[:limit] || 20).to_i @events = @project.events.recent @events = event_filter.apply_filter(@events) @events = @events.limit(limit).offset(params[:offset] || 0) - # Ensure project default branch is set if it possible - # Normally it defined on push or during creation - @project.discover_default_branch - respond_to do |format| format.html do if @project.empty_repo? render "projects/empty", layout: user_layout else - if current_user - @last_push = current_user.recent_push(@project.id) - end + @last_push = current_user.recent_push(@project.id) if current_user render :show, layout: user_layout end end - format.js + format.json { pager_json("events/_events", @events.count) } end end + def import + if project.import_finished? + redirect_to @project + return + end + end + + def retry_import + unless @project.import_failed? + redirect_to import_project_path(@project) + end + + @project.import_url = params[:project][:import_url] + + if @project.save + @project.reload + @project.import_retry + end + + redirect_to import_project_path(@project) + end + def destroy return access_denied! unless can?(current_user, :remove_project, project) @@ -93,7 +107,7 @@ class ProjectsController < ApplicationController end def fork - @forked_project = ::Projects::ForkContext.new(project, current_user).execute + @forked_project = ::Projects::ForkService.new(project, current_user).execute respond_to do |format| format.html do @@ -109,10 +123,20 @@ class ProjectsController < ApplicationController end def autocomplete_sources + note_type = params['type'] + note_id = params['type_id'] + participating = if note_type && note_id + participants_in(note_type, note_id) + else + [] + end + team_members = sorted(@project.team.members) + participants = team_members + participating @suggestions = { - emojis: Emoji.names, + emojis: Emoji.names.map { |e| { name: e, path: view_context.image_url("emoji/#{e}.png") } }, issues: @project.issues.select([:iid, :title, :description]), - members: @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } } + mergerequests: @project.merge_requests.select([:iid, :title, :description]), + members: participants.uniq } respond_to do |format| @@ -120,6 +144,24 @@ class ProjectsController < ApplicationController end end + def archive + return access_denied! unless can?(current_user, :archive_project, project) + project.archive! + + respond_to do |format| + format.html { redirect_to @project } + end + end + + def unarchive + return access_denied! unless can?(current_user, :archive_project, project) + project.unarchive! + + respond_to do |format| + format.html { redirect_to @project } + end + end + private def set_title @@ -129,4 +171,25 @@ class ProjectsController < ApplicationController def user_layout current_user ? "projects" : "public_projects" end + + def participants_in(type, id) + users = case type + when "Issue" + issue = @project.issues.find_by_iid(id) + issue ? issue.participants : [] + when "MergeRequest" + merge_request = @project.merge_requests.find_by_iid(id) + merge_request ? merge_request.participants : [] + when "Commit" + author_ids = Note.for_commit_id(id).pluck(:author_id).uniq + User.where(id: author_ids) + else + [] + end + sorted(users) + end + + def sorted(users) + users.uniq.sort_by(&:username).map { |user| { username: user.username, name: user.name } } + end end diff --git a/app/controllers/public/projects_controller.rb b/app/controllers/public/projects_controller.rb index 87e903a1d2..d6238f7954 100644 --- a/app/controllers/public/projects_controller.rb +++ b/app/controllers/public/projects_controller.rb @@ -6,8 +6,9 @@ class Public::ProjectsController < ApplicationController layout 'public' def index - @projects = Project.public_only + @projects = Project.publicish(current_user) @projects = @projects.search(params[:search]) if params[:search].present? - @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) + @projects = @projects.sort(@sort = params[:sort]) + @projects = @projects.includes(:namespace).page(params[:page]).per(20) end end diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 6eaa976f75..8df84e9884 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,27 +1,24 @@ class SearchController < ApplicationController + include SearchHelper + def show - project_id = params[:project_id] - group_id = params[:group_id] + @project = Project.find_by(id: params[:project_id]) if params[:project_id].present? + @group = Group.find_by(id: params[:group_id]) if params[:group_id].present? - project_ids = current_user.authorized_projects.map(&:id) + if @project + return access_denied! unless can?(current_user, :download_code, @project) - if group_id.present? - @group = Group.find(group_id) - group_project_ids = @group.projects.map(&:id) - project_ids.select! { |id| group_project_ids.include?(id)} - elsif project_id.present? - @project = Project.find(params[:project_id]) - project_ids.select! { |id| id == project_id.to_i} + @search_results = Search::ProjectService.new(@project, current_user, params).execute + else + @search_results = Search::GlobalService.new(current_user, params).execute end + end - result = SearchContext.new(project_ids, params).execute + def autocomplete + term = params[:term] + @project = Project.find(params[:project_id]) if params[:project_id].present? + @ref = params[:project_ref] if params[:project_ref].present? - @projects = result[:projects] - @merge_requests = result[:merge_requests] - @issues = result[:issues] - @notes = result[:notes] - @wiki_pages = result[:wiki_pages] - @blobs = Kaminari.paginate_array(result[:blobs]).page(params[:page]).per(20) - @total_results = @projects.count + @merge_requests.count + @issues.count + @wiki_pages.count + @blobs.total_count + render json: search_autocomplete_opts(term).to_json end end diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index b91f68aab5..0dd941a48e 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -18,7 +18,10 @@ class SnippetsController < ApplicationController end def user_index - @user = User.find_by_username(params[:username]) + @user = User.find_by(username: params[:username]) + + render_404 and return unless @user + @snippets = @user.snippets.fresh.non_expired if @user == current_user diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4947c33f95..9461174b95 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,11 +1,23 @@ class UsersController < ApplicationController - layout 'navless' + skip_before_filter :authenticate_user!, only: [:show] + layout :determine_layout def show @user = User.find_by_username!(params[:username]) - @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id)) - @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20) - + @projects = @user.authorized_projects.accessible_to(current_user) + if !current_user && @projects.empty? + return authenticate_user! + end + @groups = @user.groups.accessible_to(current_user) + @events = @user.recent_events.where(project_id: @projects.pluck(:id)).limit(20) @title = @user.name end + + def determine_layout + if current_user + 'navless' + else + 'public_users' + end + end end diff --git a/app/controllers/users_groups_controller.rb b/app/controllers/users_groups_controller.rb index 749da1e141..b9bdc18952 100644 --- a/app/controllers/users_groups_controller.rb +++ b/app/controllers/users_groups_controller.rb @@ -19,18 +19,21 @@ class UsersGroupsController < ApplicationController def destroy @users_group = @group.users_groups.find(params[:id]) - @users_group.destroy - - respond_to do |format| - format.html { redirect_to members_group_path(@group), notice: 'User was successfully removed from group.' } - format.js { render nothing: true } + if can?(current_user, :destroy, @users_group) # May fail if last owner. + @users_group.destroy + respond_to do |format| + format.html { redirect_to members_group_path(@group), notice: 'User was successfully removed from group.' } + format.js { render nothing: true } + end + else + return render_403 end end protected def group - @group ||= Group.find_by_path(params[:group_id]) + @group ||= Group.find_by(path: params[:group_id]) end def authorize_admin_group! diff --git a/app/finders/README.md b/app/finders/README.md new file mode 100644 index 0000000000..47823c51ef --- /dev/null +++ b/app/finders/README.md @@ -0,0 +1,22 @@ +# Finders + +This type of classes responsible for collectiong items based on different conditions. +To prevent lookup methods in models like this: + +```ruby +class Project + def issues_for_user_filtered_by(user, filter) + # A lot of logic not related to project model itself + end +end + +issues = project.issues_for_user_filtered_by(user, params) +``` + +Better use this: + +```ruby +issues = IssuesFinder.new.execute(project, user, filter) +``` + +It will help keep models thiner diff --git a/app/finders/base_finder.rb b/app/finders/base_finder.rb new file mode 100644 index 0000000000..7fc5840561 --- /dev/null +++ b/app/finders/base_finder.rb @@ -0,0 +1,137 @@ +# BaseFinder +# +# Used to filter Issues and MergeRequests collections by set of params +# +# Arguments: +# klass - actual class like Issue or MergeRequest +# current_user - which user use +# params: +# scope: 'created-by-me' or 'assigned-to-me' or 'all' +# state: 'open' or 'closed' or 'all' +# group_id: integer +# project_id: integer +# milestone_id: integer +# assignee_id: integer +# search: string +# label_name: string +# sort: string +# +class BaseFinder + attr_accessor :current_user, :params + + def execute(current_user, params) + @current_user = current_user + @params = params + + items = init_collection + items = by_scope(items) + items = by_state(items) + items = by_group(items) + items = by_project(items) + items = by_search(items) + items = by_milestone(items) + items = by_assignee(items) + items = by_label(items) + items = sort(items) + end + + private + + def init_collection + table_name = klass.table_name + + if project + if project.public? || (current_user && current_user.can?(:read_project, project)) + project.send(table_name) + else + [] + end + elsif current_user && params[:authorized_only].presence + klass.of_projects(current_user.authorized_projects).references(:project) + else + klass.of_projects(Project.accessible_to(current_user)).references(:project) + end + end + + def by_scope(items) + case params[:scope] + when 'created-by-me', 'authored' then + items.where(author_id: current_user.id) + when 'all' then + items + when 'assigned-to-me' then + items.where(assignee_id: current_user.id) + else + raise 'You must specify default scope' + end + end + + def by_state(items) + case params[:state] + when 'closed' + items.closed + when 'all' + items + when 'opened' + items.opened + else + raise 'You must specify default state' + end + end + + def by_group(items) + if params[:group_id].present? + items = items.of_group(Group.find(params[:group_id])) + end + + items + end + + def by_project(items) + if params[:project_id].present? + items = items.of_projects(params[:project_id]) + end + + items + end + + def by_search(items) + if params[:search].present? + items = items.search(params[:search]) + end + + items + end + + def sort(items) + items.sort(params[:sort]) + end + + def by_milestone(items) + if params[:milestone_id].present? + items = items.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id])) + end + + items + end + + def by_assignee(items) + if params[:assignee_id].present? + items = items.where(assignee_id: (params[:assignee_id] == '0' ? nil : params[:assignee_id])) + end + + items + end + + def by_label(items) + if params[:label_name].present? + items = items.tagged_with(params[:label_name]) + end + + items + end + + def project + Project.where(id: params[:project_id]).first if params[:project_id].present? + end +end diff --git a/app/finders/issues_finder.rb b/app/finders/issues_finder.rb new file mode 100644 index 0000000000..8e0c606249 --- /dev/null +++ b/app/finders/issues_finder.rb @@ -0,0 +1,22 @@ +# Finders::Issues class +# +# Used to filter Issues collections by set of params +# +# Arguments: +# current_user - which user use +# params: +# scope: 'created-by-me' or 'assigned-to-me' or 'all' +# state: 'open' or 'closed' or 'all' +# group_id: integer +# project_id: integer +# milestone_id: integer +# assignee_id: integer +# search: string +# label_name: string +# sort: string +# +class IssuesFinder < BaseFinder + def klass + Issue + end +end diff --git a/app/finders/merge_requests_finder.rb b/app/finders/merge_requests_finder.rb new file mode 100644 index 0000000000..3727149c8f --- /dev/null +++ b/app/finders/merge_requests_finder.rb @@ -0,0 +1,22 @@ +# Finders::MergeRequest class +# +# Used to filter MergeRequests collections by set of params +# +# Arguments: +# current_user - which user use +# params: +# scope: 'created-by-me' or 'assigned-to-me' or 'all' +# state: 'open' or 'closed' or 'all' +# group_id: integer +# project_id: integer +# milestone_id: integer +# assignee_id: integer +# search: string +# label_name: string +# sort: string +# +class MergeRequestsFinder < BaseFinder + def klass + MergeRequest + end +end diff --git a/app/finders/notes_finder.rb b/app/finders/notes_finder.rb new file mode 100644 index 0000000000..ea055694cd --- /dev/null +++ b/app/finders/notes_finder.rb @@ -0,0 +1,26 @@ +class NotesFinder + FETCH_OVERLAP = 5.seconds + + def execute(project, current_user, params) + target_type = params[:target_type] + target_id = params[:target_id] + # Default to 0 to remain compatible with old clients + last_fetched_at = Time.at(params.fetch(:last_fetched_at, 0).to_i) + + notes = case target_type + when "commit" + project.notes.for_commit_id(target_id).not_inline.fresh + when "issue" + project.issues.find(target_id).notes.inc_author.fresh + when "merge_request" + project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh + when "snippet" + project.snippets.find(target_id).notes.fresh + else + raise 'invalid target_type' + end + + # Use overlapping intervals to avoid worrying about race conditions + notes.where('updated_at > ?', last_fetched_at - FETCH_OVERLAP) + end +end diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb new file mode 100644 index 0000000000..bfaba75878 --- /dev/null +++ b/app/finders/projects_finder.rb @@ -0,0 +1,63 @@ +class ProjectsFinder + def execute(current_user, options) + group = options[:group] + + if group + group_projects(current_user, group) + else + all_projects(current_user) + end + end + + private + + def group_projects(current_user, group) + if current_user + if group.users.include?(current_user) + # User is group member + # + # Return ALL group projects + group.projects + else + projects_members = UsersProject.where( + project_id: group.projects, + user_id: current_user + ) + + if projects_members.any? + # User is a project member + # + # Return only: + # public projects + # internal projects + # joined projects + # + group.projects.where( + "projects.id IN (?) OR projects.visibility_level IN (?)", + projects_members.pluck(:project_id), + Project.public_and_internal_levels + ) + else + # User has no access to group or group projects + # + # Return only: + # public projects + # internal projects + # + group.projects.public_and_internal_only + end + end + else + # Not authenticated + # + # Return only: + # public projects + group.projects.public_only + end + end + + def all_projects + # TODO: implement + raise 'Not implemented yet' + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e2d9790141..5f07cdf448 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -49,8 +49,17 @@ module ApplicationHelper args.any? { |v| v.to_s.downcase == action_name } end + def group_icon(group_path) + group = Group.find_by(path: group_path) + if group && group.avatar.present? + group.avatar.url + else + image_path('no_group_avatar.png') + end + end + def avatar_icon(user_email = '', size = nil) - user = User.find_by_email(user_email) + user = User.find_by(email: user_email) if user && user.avatar.present? user.avatar.url else @@ -62,17 +71,17 @@ module ApplicationHelper size = 40 if size.nil? || size <= 0 if !Gitlab.config.gravatar.enabled || user_email.blank? - 'no_avatar.png' + '/assets/no_avatar.png' else gravatar_url = request.ssl? || gitlab_config.https ? Gitlab.config.gravatar.ssl_url : Gitlab.config.gravatar.plain_url user_email.strip! - sprintf gravatar_url, hash: Digest::MD5.hexdigest(user_email.downcase), size: size + sprintf gravatar_url, hash: Digest::MD5.hexdigest(user_email.downcase), size: size, email: user_email end end def last_commit(project) if project.repo_exists? - time_ago_in_words(project.repository.commit.committed_date) + " ago" + time_ago_with_tooltip(project.repository.commit.committed_date) else "Never" end @@ -80,16 +89,15 @@ module ApplicationHelper "Never" end - def grouped_options_refs(destination = :tree) + def grouped_options_refs repository = @project.repository options = [ - ["Branch", repository.branch_names ], - [ "Tag", repository.tag_names ] + ["Branches", repository.branch_names], + ["Tags", VersionSorter.rsort(repository.tag_names)] ] - # If reference is commit id - - # we should add it to branch/tag selectbox + # If reference is commit id - we should add it to branch/tag selectbox if(@ref && !options.flatten.include?(@ref) && @ref =~ /^[0-9a-zA-Z]{6,52}$/) options << ["Commit", [@ref]] @@ -126,6 +134,9 @@ module ApplicationHelper # Skip if user already created appropriate MR return false if project.merge_requests.where(source_branch: event.branch_name).opened.any? + # Skip if user removed branch right after that + return false unless project.repository.branch_names.include?(event.branch_name) + true end @@ -133,18 +144,9 @@ module ApplicationHelper Digest::SHA1.hexdigest string end - def project_last_activity project - if project.last_activity_at - time_ago_in_words(project.last_activity_at) + " ago" - else - "Never" - end - end - def authbutton(provider, size = 64) file_name = "#{provider.to_s.split('_').first}_#{size}.png" - image_tag("authbuttons/#{file_name}", - alt: "Sign in with #{provider.to_s.titleize}") + image_tag(image_path("authbuttons/#{file_name}"), alt: "Sign in with #{provider.to_s.titleize}") end def simple_sanitize(str) @@ -158,15 +160,6 @@ module ApplicationHelper alias_method :url_to_image, :image_url - def users_select_tag(id, opts = {}) - css_class = "ajax-users-select " - css_class << "multiselect " if opts[:multiple] - css_class << (opts[:class] || '') - value = opts[:selected] || '' - - hidden_field_tag(id, value, class: css_class) - end - def body_data_page path = controller.controller_path.split('/') namespace = path.first if path.second @@ -184,14 +177,6 @@ module ApplicationHelper Gitlab.config.extra end - def public_icon - content_tag :i, nil, class: 'icon-globe cblue' - end - - def private_icon - content_tag :i, nil, class: 'icon-lock cgreen' - end - def search_placeholder if @project && @project.persisted? "Search in this project" @@ -208,4 +193,42 @@ module ApplicationHelper line += "..." if lines.size > 1 line end + + def broadcast_message + BroadcastMessage.current + end + + def highlight_js(&block) + string = capture(&block) + + content_tag :div, class: "highlighted-data #{user_color_scheme_class}" do + content_tag :div, class: 'highlight' do + content_tag :pre do + content_tag :code do + string.html_safe + end + end + end + end + end + + def time_ago_with_tooltip(date, placement = 'top', html_class = 'time_ago') + capture_haml do + haml_tag :time, date.to_s, + class: html_class, datetime: date.getutc.iso8601, title: date.stamp("Aug 21, 2011 9:23pm"), + data: { toggle: 'tooltip', placement: placement } + + haml_tag :script, "$('." + html_class + "').timeago().tooltip()" + end.html_safe + end + + def render_markup(file_name, file_content) + GitHub::Markup.render(file_name, file_content).html_safe + end + + def spinner(text = nil) + content_tag :div, class: 'loading hide' do + content_tag(:i, nil, class: 'icon-spinner icon-spin') + text + end + end end diff --git a/app/helpers/broadcast_messages_helper.rb b/app/helpers/broadcast_messages_helper.rb new file mode 100644 index 0000000000..29ff47663d --- /dev/null +++ b/app/helpers/broadcast_messages_helper.rb @@ -0,0 +1,9 @@ +module BroadcastMessagesHelper + def broadcast_styling(broadcast_message) + if(broadcast_message.color || broadcast_message.font) + "background-color:#{broadcast_message.color};color:#{broadcast_message.font}" + else + "" + end + end +end diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index c340eb30be..c4abdbdabc 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -16,9 +16,10 @@ module CommitsHelper end def each_diff_line(diff, index) - Gitlab::DiffParser.new(diff).each do |full_line, type, line_code, line_new, line_old| - yield(full_line, type, line_code, line_new, line_old) - end + Gitlab::DiffParser.new(diff.diff.lines.to_a, diff.new_path) + .each do |full_line, type, line_code, line_new, line_old| + yield(full_line, type, line_code, line_new, line_old) + end end def each_diff_line_near(diff, index, expected_line_code) @@ -105,6 +106,82 @@ module CommitsHelper branches.sort.map { |branch| link_to(branch, project_tree_path(project, branch)) }.join(", ").html_safe end + def parallel_diff_lines(project, commit, diff, file) + old_file = project.repository.blob_at(commit.parent_id, diff.old_path) if commit.parent_id + deleted_lines = {} + added_lines = {} + each_diff_line(diff, 0) do |line, type, line_code, line_new, line_old| + if type == "old" + deleted_lines[line_old] = { line_code: line_code, type: type, line: line } + elsif type == "new" + added_lines[line_new] = { line_code: line_code, type: type, line: line } + end + end + max_length = old_file ? [old_file.loc, file.loc].max : file.loc + + offset1 = 0 + offset2 = 0 + old_lines = [] + new_lines = [] + + max_length.times do |line_index| + line_index1 = line_index - offset1 + line_index2 = line_index - offset2 + deleted_line = deleted_lines[line_index1 + 1] + added_line = added_lines[line_index2 + 1] + old_line = old_file.lines[line_index1] if old_file + new_line = file.lines[line_index2] + + if deleted_line && added_line + elsif deleted_line + new_line = nil + offset2 += 1 + elsif added_line + old_line = nil + offset1 += 1 + end + + old_lines[line_index] = DiffLine.new + new_lines[line_index] = DiffLine.new + + # old + if line_index == 0 && diff.new_file + old_lines[line_index].type = :file_created + old_lines[line_index].content = 'File was created' + elsif deleted_line + old_lines[line_index].type = :deleted + old_lines[line_index].content = old_line + old_lines[line_index].num = line_index1 + 1 + old_lines[line_index].code = deleted_line[:line_code] + elsif old_line + old_lines[line_index].type = :no_change + old_lines[line_index].content = old_line + old_lines[line_index].num = line_index1 + 1 + else + old_lines[line_index].type = :added + end + + # new + if line_index == 0 && diff.deleted_file + new_lines[line_index].type = :file_deleted + new_lines[line_index].content = "File was deleted" + elsif added_line + new_lines[line_index].type = :added + new_lines[line_index].num = line_index2 + 1 + new_lines[line_index].content = new_line + new_lines[line_index].code = added_line[:line_code] + elsif new_line + new_lines[line_index].type = :no_change + new_lines[line_index].num = line_index2 + 1 + new_lines[line_index].content = new_line + else + new_lines[line_index].type = :deleted + end + end + + return old_lines, new_lines + end + protected # Private: Returns a link to a person. If the person has a matching user and @@ -118,15 +195,18 @@ module CommitsHelper def commit_person_link(commit, options = {}) source_name = commit.send "#{options[:source]}_name".to_sym source_email = commit.send "#{options[:source]}_email".to_sym + + user = User.find_for_commit(source_email, source_name) + person_name = user.nil? ? source_name : user.name + person_email = user.nil? ? source_email : user.email + text = if options[:avatar] - avatar = image_tag(avatar_icon(source_email, options[:size]), class: "avatar #{"s#{options[:size]}" if options[:size]}", width: options[:size], alt: "") - %Q{#{avatar} #{source_name}} + avatar = image_tag(avatar_icon(person_email, options[:size]), class: "avatar #{"s#{options[:size]}" if options[:size]}", width: options[:size], alt: "") + %Q{#{avatar} #{person_name}} else - source_name + person_name end - user = User.where('name like ? or email like ?', source_name, source_email).first - options = { class: "commit-#{options[:source]}-link has_tooltip", data: { :'original-title' => sanitize(source_email) } diff --git a/app/helpers/compare_helper.rb b/app/helpers/compare_helper.rb index ea2540bf38..5ff19b8829 100644 --- a/app/helpers/compare_helper.rb +++ b/app/helpers/compare_helper.rb @@ -1,6 +1,8 @@ module CompareHelper def compare_to_mr_button? - params[:from].present? && params[:to].present? && + @project.merge_requests_enabled && + params[:from].present? && + params[:to].present? && @repository.branch_names.include?(params[:from]) && @repository.branch_names.include?(params[:to]) && params[:from] != params[:to] && diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb index 35c7bcbd2c..d5712ab337 100644 --- a/app/helpers/dashboard_helper.rb +++ b/app/helpers/dashboard_helper.rb @@ -1,7 +1,8 @@ module DashboardHelper def filter_path(entity, options={}) exist_opts = { - status: params[:status], + state: params[:state], + scope: params[:scope], project_id: params[:project_id], } @@ -12,18 +13,26 @@ module DashboardHelper path end - def entities_per_project project, entity - items = project.items_for(entity) + def entities_per_project(project, entity) + case entity.to_sym + when :issue then @issues.where(project_id: project.id) + when :merge_request then @merge_requests.where(target_project_id: project.id) + else + [] + end.count + end - items = case params[:status] - when 'closed' - items.closed - when 'all' - items - else - items.opened - end + def projects_dashboard_filter_path(options={}) + exist_opts = { + sort: params[:sort], + scope: params[:scope], + group: params[:group], + } - items.cared(current_user).count + options = exist_opts.merge(options) + + path = request.path + path << "?#{options.to_param}" + path end end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 4aeb65752f..929f9a9c38 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -90,27 +90,23 @@ module EventsHelper if event.note? && event.note_commit? project_commit_path(event.project, event.note_target) else - url_for([event.project, event.note_target]) + polymorphic_path([event.project, event.note_target], anchor: dom_id(event.target)) end end def event_note_title_html(event) if event.note_target if event.note_commit? - link_to project_commit_path(event.project, event.note_commit_id), class: "commit_short_id" do + link_to project_commit_path(event.project, event.note_commit_id, anchor: dom_id(event.target)), class: "commit_short_id" do "#{event.note_target_type} #{event.note_short_commit_id}" end elsif event.note_project_snippet? link_to(project_snippet_path(event.project, event.note_target)) do - content_tag :strong do - "#{event.note_target_type} ##{truncate event.note_target_id}" - end + "#{event.note_target_type} ##{truncate event.note_target_id}" end else link_to event_note_target_path(event) do - content_tag :strong do - "#{event.note_target_type} ##{truncate event.note_target_iid}" - end + "#{event.note_target_type} ##{truncate event.note_target_iid}" end end elsif event.wall_note? diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index b34f703353..69425bc171 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -28,14 +28,15 @@ module GitlabMarkdownHelper link_to(gfm_body.html_safe, url, html_options) end - def markdown(text) - unless @markdown - gitlab_renderer = Redcarpet::Render::GitlabHTML.new(self, - # see https://github.com/vmg/redcarpet#darling-i-packed-you-a-couple-renderers-for-lunch- - filter_html: true, - with_toc_data: true, - hard_wrap: true, - safe_links_only: true) + def markdown(text, options={}) + unless (@markdown and options == @options) + @options = options + gitlab_renderer = Redcarpet::Render::GitlabHTML.new(self, { + # see https://github.com/vmg/redcarpet#darling-i-packed-you-a-couple-renderers-for-lunch- + filter_html: true, + with_toc_data: true, + safe_links_only: true + }.merge(options)) @markdown = Redcarpet::Markdown.new(gitlab_renderer, # see https://github.com/vmg/redcarpet#and-its-like-really-simple-to-use no_intra_emphasis: true, @@ -43,11 +44,10 @@ module GitlabMarkdownHelper fenced_code_blocks: true, autolink: true, strikethrough: true, - lax_html_blocks: true, + lax_spacing: true, space_after_headers: true, superscript: true) end - @markdown.render(text).html_safe end @@ -63,14 +63,22 @@ module GitlabMarkdownHelper # project_path_with_namespace - namespace/projectname, eg. gitlabhq/gitlabhq # ref - name of the branch or reference, eg. stable # requested_path - path of request, eg. doc/api/README.md, used in special case when path is pointing to the .md file were the original request is coming from - # wiki - whether the markdown is from wiki or not - def create_relative_links(text, project_path_with_namespace, ref, requested_path, wiki = false) + def create_relative_links(text, project, ref, requested_path) + @path_to_satellite = project.satellite.path + project_path_with_namespace = project.path_with_namespace paths = extract_paths(text) paths.each do |file_path| - new_path = rebuild_path(project_path_with_namespace, file_path, requested_path, ref) - # Replacing old string with a new one with brackets ]() to prevent replacing occurence of a word - # e.g. If we have a markdown like [test](test) this will replace ](test) and not the word test - text.gsub!("](#{file_path})", "](/#{new_path})") + original_file_path = extract(file_path) + new_path = rebuild_path(project_path_with_namespace, original_file_path, requested_path, ref) + if reference_path?(file_path) + # Replacing old string with a new one that contains updated path + # eg. [some document]: document.md will be replaced with [some document] /namespace/project/master/blob/document.md + text.gsub!(file_path, file_path.gsub(original_file_path, "/#{new_path}")) + else + # Replacing old string with a new one with brackets ]() to prevent replacing occurence of a word + # e.g. If we have a markdown like [test](test) this will replace ](test) and not the word test + text.gsub!("](#{file_path})", "](/#{new_path})") + end end text end @@ -81,9 +89,11 @@ module GitlabMarkdownHelper select_relative(paths) end - # Split the markdown text to each line and find all paths, this will match anything with - ]("some_text") + # Split the markdown text to each line and find all paths, this will match anything with - ]("some_text") and [some text]: file.md def pick_out_paths(markdown_text) - markdown_text.split("\n").map { |text| text.scan(/\]\(([^(]+)\)/) } + inline_paths = markdown_text.split("\n").map { |text| text.scan(/\]\(([^(]+)\)/) } + reference_paths = markdown_text.split("\n").map { |text| text.scan(/\[.*\]:.*/) } + inline_paths + reference_paths end # Removes any empty result produced by not matching the regexp @@ -91,32 +101,44 @@ module GitlabMarkdownHelper paths.reject{|l| l.empty? }.flatten end + # If a path is a reference style link we need to omit ]: + def extract(path) + path.split("]: ").last + end + # Reject any path that contains ignored protocol # eg. reject "https://gitlab.org} but accept "doc/api/README.md" def select_relative(paths) paths.reject{|path| ignored_protocols.map{|protocol| path.include?(protocol)}.any?} end + # Check whether a path is a reference-style link + def reference_path?(path) + path.include?("]: ") + end + def ignored_protocols ["http://","https://", "ftp://", "mailto:"] end def rebuild_path(path_with_namespace, path, requested_path, ref) + path.gsub!(/(#.*)/, "") + id = $1 || "" file_path = relative_file_path(path, requested_path) [ path_with_namespace, path_with_ref(file_path, ref), file_path - ].compact.join("/") + ].compact.join("/").gsub(/\/*$/, '') + id end # Checks if the path exists in the repo - # eg. checks if doc/README.md exists, if it doesn't then it is a wiki link + # eg. checks if doc/README.md exists, if not then link to blob def path_with_ref(path, ref) if file_exists?(path) "#{local_path(path)}/#{correct_ref(ref)}" else - "wikis" + "blob/#{correct_ref(ref)}" end end @@ -132,6 +154,7 @@ module GitlabMarkdownHelper # If we are at doc/api and the README.md shown in below the tree view # this takes the rquest path(doc/api) and adds users.md so the path looks like doc/api/users.md def build_nested_path(path, request_path) + return request_path if path == "" return path unless request_path if local_path(request_path) == "tree" base = request_path.split("/").push(path) @@ -144,14 +167,28 @@ module GitlabMarkdownHelper end def file_exists?(path) - return false if path.nil? || path.empty? - File.exists?(Rails.root.join(path)) + return false if path.nil? + return @repository.blob_at(current_sha, path).present? || @repository.tree(current_sha, path).entries.any? end # Check if the path is pointing to a directory(tree) or a file(blob) # eg. doc/api is directory and doc/README.md is file def local_path(path) - File.directory?(Rails.root.join(path)) ? "tree" : "blob" + return "tree" if @repository.tree(current_sha, path).entries.any? + return "raw" if @repository.blob_at(current_sha, path).image? + return "blob" + end + + def current_ref + @commit.nil? ? "master" : @commit.id + end + + def current_sha + if @commit + @commit.id + else + @repository.head_commit.sha + end end # We will assume that if no ref exists we can point to master diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 8573c59dc9..cfc9a572ca 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -1,5 +1,36 @@ module GroupsHelper def remove_user_from_group_message(group, user) - "You are going to remove #{user.name} from #{group.name} Group. Are you sure?" + "Are you sure you want to remove \"#{user.name}\" from \"#{group.name}\"?" + end + + def leave_group_message(group) + "Are you sure you want to leave \"#{group}\" group?" + end + + def should_user_see_group_roles?(user, group) + if user + user.is_admin? || group.members.exists?(user_id: user.id) + else + false + end + end + + def group_head_title + title = @group.name + + title = if current_action?(:issues) + "Issues - " + title + elsif current_action?(:merge_requests) + "Merge requests - " + title + elsif current_action?(:members) + "Members - " + title + elsif current_action?(:edit) + "Settings - " + title + else + title + end + + title + end end diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb new file mode 100644 index 0000000000..53d4a8f2e6 --- /dev/null +++ b/app/helpers/icons_helper.rb @@ -0,0 +1,21 @@ +module IconsHelper + def boolean_to_icon(value) + if value.to_s == "true" + content_tag :i, nil, class: 'icon-ok cgreen' + else + content_tag :i, nil, class: 'icon-off clgray' + end + end + + def public_icon + content_tag :i, nil, class: 'icon-globe' + end + + def internal_icon + content_tag :i, nil, class: 'icon-shield' + end + + def private_icon + content_tag :i, nil, class: 'icon-lock' + end +end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 2221583912..7c58908165 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -68,4 +68,32 @@ module IssuesHelper false end end + + def bulk_update_milestone_options + options_for_select(["None (backlog)"]) + options_from_collection_for_select(project_active_milestones, "id", "title", params[:milestone_id]) + end + + def bulk_update_assignee_options + options_for_select(["None (unassigned)"]) + options_from_collection_for_select(@project.team.members, "id", "name", params[:assignee_id]) + end + + def assignee_options object + options_from_collection_for_select(@project.team.members.sort_by(&:name), 'id', 'name', object.assignee_id) + end + + def milestone_options object + options_from_collection_for_select(object.project.milestones.active, 'id', 'title', object.milestone_id) + end + + def issue_box_class(item) + if item.respond_to?(:expired?) && item.expired? + 'issue-box-expired' + elsif item.respond_to?(:merged?) && item.merged? + 'issue-box-merged' + elsif item.closed? + 'issue-box-closed' + else + 'issue-box-open' + end + end end diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index 9a6aea85ee..4d20b827a0 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -12,15 +12,15 @@ module LabelsHelper def label_css_class(name) klass = Gitlab::IssuesLabels - case name + case name.downcase when *klass.warning_labels 'label-warning' when *klass.neutral_labels - 'label-inverse' + 'label-primary' when *klass.positive_labels 'label-success' when *klass.important_labels - 'label-important' + 'label-danger' else 'label-info' end diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index 4ba48aa433..00ec34ae54 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -1,8 +1,9 @@ module MergeRequestsHelper def new_mr_path_from_push_event(event) + target_project = event.project.forked_from_project || event.project new_project_merge_request_path( event.project, - new_mr_from_push_event(event, event.project) + new_mr_from_push_event(event, target_project) ) end @@ -19,7 +20,7 @@ module MergeRequestsHelper target_project_id: target_project.id, source_branch: event.branch_name, target_branch: target_project.repository.root_ref, - title: event.branch_name.titleize + title: event.branch_name.titleize.humanize } end @@ -36,7 +37,7 @@ module MergeRequestsHelper def merge_path_description(merge_request, separator) if merge_request.for_fork? - "Project:Branches: #{@merge_request.source_project.path_with_namespace}:#{@merge_request.source_branch} #{separator} #{@merge_request.target_project.path_with_namespace}:#{@merge_request.target_branch}" + "Project:Branches: #{@merge_request.source_project_path}:#{@merge_request.source_branch} #{separator} #{@merge_request.target_project.path_with_namespace}:#{@merge_request.target_branch}" else "Branches: #{@merge_request.source_branch} #{separator} #{@merge_request.target_branch}" end diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb index dc88e17836..c363c7ffd7 100644 --- a/app/helpers/namespaces_helper.rb +++ b/app/helpers/namespaces_helper.rb @@ -1,7 +1,7 @@ module NamespacesHelper def namespaces_options(selected = :current_user, scope = :default) - groups = current_user.owned_groups.select {|n| n.type == 'Group'} - users = current_user.namespaces.reject {|n| n.type == 'Group'} + groups = current_user.owned_groups + users = [current_user.namespace] group_opts = ["Groups", groups.sort_by(&:human_name).map {|g| [g.human_name, g.id]} ] users_opts = [ "Users", users.sort_by(&:human_name).map {|u| [u.human_name, u.id]} ] @@ -16,4 +16,13 @@ module NamespacesHelper grouped_options_for_select(options, selected) end + + def namespace_select_tag(id, opts = {}) + css_class = "ajax-namespace-select " + css_class << "multiselect " if opts[:multiple] + css_class << (opts[:class] || '') + value = opts[:selected] || '' + + hidden_field_tag(id, value, class: css_class) + end end diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index a3ec4cca59..7ae104b8fd 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -1,7 +1,7 @@ module NotesHelper # Helps to distinguish e.g. commit notes in mr notes list def note_for_main_target?(note) - (@target_type.camelize == note.noteable_type && !note.for_diff_line?) + (@noteable.class.name == note.noteable_type && !note.for_diff_line?) end def note_target_fields @@ -17,22 +17,29 @@ module NotesHelper def link_to_merge_request_diff_line_note(note) if note.for_merge_request_diff_line? and note.diff - link_to "#{note.diff_file_name}:L#{note.diff_new_line}", diffs_project_merge_request_path(note.project, note.noteable_id, anchor: note.line_code) + link_to "#{note.diff_file_name}:L#{note.diff_new_line}", diffs_project_merge_request_path(note.project, note.noteable, anchor: note.line_code) end end - def loading_more_notes? - params[:loading_more].present? - end - - def loading_new_notes? - params[:loading_new].present? - end - def note_timestamp(note) # Shows the created at time and the updated at time if different - ts = "#{time_ago_in_words(note.created_at)} ago" - ts << content_tag(:small, " (Edited #{time_ago_in_words(note.updated_at)} ago)") if note.updated_at != note.created_at + ts = "#{time_ago_with_tooltip(note.created_at, 'bottom', 'note_created_ago')}" + if note.updated_at != note.created_at + ts << capture_haml do + haml_tag :small do + haml_concat " (Edited #{time_ago_with_tooltip(note.updated_at, 'bottom', 'note_edited_ago')})" + end + end + end ts.html_safe end + + def noteable_json(noteable) + { + id: noteable.id, + class: noteable.class.name, + resources: noteable.class.table_name, + project_id: noteable.project.id, + }.to_json + end end diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index ae3402b261..b2399bb6db 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -1,11 +1,11 @@ module NotificationsHelper def notification_icon(notification) if notification.disabled? - content_tag :i, nil, class: 'icon-circle cred' + content_tag :i, nil, class: 'icon-volume-off cred' elsif notification.participating? - content_tag :i, nil, class: 'icon-circle cblue' + content_tag :i, nil, class: 'icon-volume-down cblue' elsif notification.watch? - content_tag :i, nil, class: 'icon-circle cgreen' + content_tag :i, nil, class: 'icon-volume-up cgreen' else content_tag :i, nil, class: 'icon-circle-blank cblue' end diff --git a/app/helpers/profile_helper.rb b/app/helpers/profile_helper.rb index dd9e03d95a..297ae83d89 100644 --- a/app/helpers/profile_helper.rb +++ b/app/helpers/profile_helper.rb @@ -10,7 +10,7 @@ module ProfileHelper end def show_profile_social_tab? - Gitlab.config.omniauth.enabled && !current_user.ldap_user? + enabled_social_providers.any? && !current_user.ldap_user? end def show_profile_remove_tab? diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 864f6c9af9..ef0460f872 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -5,7 +5,7 @@ module ProjectsHelper def link_to_project project link_to project do - title = content_tag(:span, project.name, class: 'projet-name') + title = content_tag(:span, project.name, class: 'project-name') if project.namespace namespace = content_tag(:span, "#{project.namespace.human_name} / ", class: 'namespace-name') @@ -45,7 +45,10 @@ module ProjectsHelper link_to(simple_sanitize(project.group.name), group_path(project.group)) + " / " + project.name end else - project.name + owner = project.namespace.owner + content_tag :span do + link_to(simple_sanitize(owner.name), user_path(owner)) + " / " + project.name + end end end @@ -61,12 +64,39 @@ module ProjectsHelper project_nav_tabs.include? name end + def selected_label?(label_name) + params[:label_name].to_s.split(',').include?(label_name) + end + + def labels_filter_path(label_name) + label_name = + if selected_label?(label_name) + params[:label_name].split(',').reject { |l| l == label_name }.join(',') + elsif params[:label_name].present? + "#{params[:label_name]},#{label_name}" + else + label_name + end + + project_filter_path(label_name: label_name) + end + + def label_filter_class(label_name) + if selected_label?(label_name) + 'label-filter-item active' + else + 'label-filter-item light' + end + end + def project_filter_path(options={}) exist_opts = { state: params[:state], scope: params[:scope], label_name: params[:label_name], milestone_id: params[:milestone_id], + assignee_id: params[:assignee_id], + sort: params[:sort], } options = exist_opts.merge(options) @@ -77,10 +107,10 @@ module ProjectsHelper end def project_active_milestones - @project.milestones.active.order("due_date, title ASC").all + @project.milestones.active.order("due_date, title ASC") end - def project_issues_trackers + def project_issues_trackers(current_tracker = nil) values = Project.issues_tracker.values.map do |tracker_key| if tracker_key.to_sym == :gitlab ['GitLab', tracker_key] @@ -89,7 +119,7 @@ module ProjectsHelper end end - options_for_select(values) + options_for_select(values, current_tracker) end private @@ -132,12 +162,63 @@ module ProjectsHelper end end - def repository_size - "#{@project.repository.size} MB" + def repository_size(project = nil) + "#{(project || @project).repository_size} MB" rescue # In order to prevent 500 error # when application cannot allocate memory # to calculate repo size - just show 'Unknown' 'unknown' end + + def project_head_title + title = @project.name_with_namespace + + title = if current_controller?(:tree) + "#{@project.path}\/#{@path} at #{@ref} - " + title + elsif current_controller?(:issues) + if current_action?(:show) + "Issue ##{@issue.iid} - #{@issue.title} - " + title + else + "Issues - " + title + end + elsif current_controller?(:blob) + "#{@project.path}\/#{@blob.path} at #{@ref} - " + title + elsif current_controller?(:commits) + "Commits at #{@ref} - " + title + elsif current_controller?(:merge_requests) + if current_action?(:show) + "Merge request ##{@merge_request.iid} - " + title + else + "Merge requests - " + title + end + elsif current_controller?(:wikis) + "Wiki - " + title + elsif current_controller?(:network) + "Network graph - " + title + elsif current_controller?(:graphs) + "Graphs - " + title + else + title + end + + title + end + + def default_url_to_repo(project = nil) + project = project || @project + current_user ? project.url_to_repo : project.http_url_to_repo + end + + def default_clone_protocol + current_user ? "ssh" : "http" + end + + def project_last_activity(project) + if project.last_activity_at + time_ago_with_tooltip(project.last_activity_at, 'bottom', 'last_activity_time_ago') + else + "Never" + end + end end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 33c5e4fb9d..d7f3da7e53 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -1,14 +1,21 @@ module SearchHelper - def search_autocomplete_source + def search_autocomplete_opts(term) return unless current_user + resources_results = [ + groups_autocomplete(term), + projects_autocomplete(term) + ].flatten + + generic_results = project_autocomplete + default_autocomplete + help_autocomplete + generic_results.select! { |result| result[:label] =~ Regexp.new(term, "i") } + [ - groups_autocomplete, - projects_autocomplete, - default_autocomplete, - project_autocomplete, - help_autocomplete - ].flatten.to_json + resources_results, + generic_results + ].flatten.uniq do |item| + item[:label] + end end private @@ -41,7 +48,7 @@ module SearchHelper # Autocomplete results for the current project, if it's defined def project_autocomplete if @project && @project.repository.exists? && @project.repository.root_ref - prefix = simple_sanitize(@project.name_with_namespace) + prefix = search_result_sanitize(@project.name_with_namespace) ref = @ref || @project.repository.root_ref [ @@ -63,16 +70,26 @@ module SearchHelper end # Autocomplete results for the current user's groups - def groups_autocomplete - current_user.authorized_groups.map do |group| - { label: "group: #{simple_sanitize(group.name)}", url: group_path(group) } + def groups_autocomplete(term, limit = 5) + current_user.authorized_groups.search(term).limit(limit).map do |group| + { + label: "group: #{search_result_sanitize(group.name)}", + url: group_path(group) + } end end # Autocomplete results for the current user's projects - def projects_autocomplete - current_user.authorized_projects.map do |p| - { label: "project: #{simple_sanitize(p.name_with_namespace)}", url: project_path(p) } + def projects_autocomplete(term, limit = 5) + Project.accessible_to(current_user).search_by_title(term).non_archived.limit(limit).map do |p| + { + label: "project: #{search_result_sanitize(p.name_with_namespace)}", + url: project_path(p) + } end end + + def search_result_sanitize(str) + Sanitize.clean(str) + end end diff --git a/app/helpers/selects_helper.rb b/app/helpers/selects_helper.rb new file mode 100644 index 0000000000..ab24367c45 --- /dev/null +++ b/app/helpers/selects_helper.rb @@ -0,0 +1,20 @@ +module SelectsHelper + def users_select_tag(id, opts = {}) + css_class = "ajax-users-select " + css_class << "multiselect " if opts[:multiple] + css_class << (opts[:class] || '') + value = opts[:selected] || '' + + hidden_field_tag(id, value, class: css_class) + end + + def project_users_select_tag(id, opts = {}) + css_class = "ajax-project-users-select " + css_class << "multiselect " if opts[:multiple] + css_class << (opts[:class] || '') + value = opts[:selected] || '' + placeholder = opts[:placeholder] || 'Select user' + project_id = opts[:project_id] || @project.id + hidden_field_tag(id, value, class: css_class, 'data-placeholder' => placeholder, 'data-project-id' => project_id) + end +end diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb new file mode 100755 index 0000000000..09e5c08e62 --- /dev/null +++ b/app/helpers/submodule_helper.rb @@ -0,0 +1,59 @@ +module SubmoduleHelper + include Gitlab::ShellAdapter + + # links to files listing for submodule if submodule is a project on this server + def submodule_links(submodule_item) + url = @repository.submodule_url_for(@ref, submodule_item.path) + + return url, nil unless url =~ /([^\/:]+\/[^\/]+\.git)\Z/ + + project = $1 + project.chomp!('.git') + + if self_url?(url, project) + return project_path(project), project_tree_path(project, submodule_item.id) + elsif relative_self_url?(url) + relative_self_links(url, submodule_item.id) + elsif github_dot_com_url?(url) + standard_links('github.com', project, submodule_item.id) + elsif gitlab_dot_com_url?(url) + standard_links('gitlab.com', project, submodule_item.id) + else + return url, nil + end + end + + protected + + def github_dot_com_url?(url) + url =~ /github\.com[\/:][^\/]+\/[^\/]+\Z/ + end + + def gitlab_dot_com_url?(url) + url =~ /gitlab\.com[\/:][^\/]+\/[^\/]+\Z/ + end + + def self_url?(url, project) + return true if url == [ Gitlab.config.gitlab.url, '/', project, '.git' ].join('') + url == gitlab_shell.url_to_repo(project) + end + + def relative_self_url?(url) + # (./)?(../repo.git) || (./)?(../../project/repo.git) ) + url =~ /^((\.\/)?(\.\.\/))(?!(\.\.)|(.*\/)).*\.git\Z/ || url =~ /^((\.\/)?(\.\.\/){2})(?!(\.\.))([^\/]*)\/(?!(\.\.)|(.*\/)).*\.git\Z/ + end + + def standard_links(host, project, commit) + base = [ 'https://', host, '/', project ].join('') + return base, [ base, '/tree/', commit ].join('') + end + + def relative_self_links(url, commit) + if url.scan(/(\.\.\/)/).size == 2 + base = url[/([^\/]*\/[^\/]*)\.git/, 1] + else + base = [ @project.group.path, '/', url[/([^\/]*)\.git/, 1] ].join('') + end + return project_path(base), project_tree_path(base, commit) + end +end diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index ce67587226..bd373c5f3c 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -92,7 +92,12 @@ module TabHelper def nav_tab key, value, &block o = {} o[:class] = "" - o[:class] << " active" if params[key] == value + + if value.nil? + o[:class] << " active" if params[key].blank? + else + o[:class] << " active" if params[key] == value + end if block_given? content_tag(:li, capture(&block), o) diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index 2dbc1cffb1..f39d0081dc 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -40,7 +40,7 @@ module TreeHelper # Returns boolean def markup?(filename) filename.downcase.end_with?(*%w(.textile .rdoc .org .creole - .mediawiki .rst .asciidoc .pod)) + .mediawiki .rst .adoc .asciidoc .pod)) end def gitlab_markdown?(filename) @@ -91,4 +91,12 @@ module TreeHelper def leave_edit_message "Leave edit mode?\nAll unsaved changes will be lost." end + + def editing_preview_title(filename) + if gitlab_markdown?(filename) || markup?(filename) + 'Preview' + else + 'Diff' + end + end end diff --git a/app/helpers/visibility_level_helper.rb b/app/helpers/visibility_level_helper.rb new file mode 100644 index 0000000000..81e10f3685 --- /dev/null +++ b/app/helpers/visibility_level_helper.rb @@ -0,0 +1,49 @@ +module VisibilityLevelHelper + def visibility_level_color(level) + case level + when Gitlab::VisibilityLevel::PRIVATE + 'cgreen' + when Gitlab::VisibilityLevel::INTERNAL + 'camber' + when Gitlab::VisibilityLevel::PUBLIC + 'cblue' + end + end + + def visibility_level_description(level) + capture_haml do + haml_tag :span do + case level + when Gitlab::VisibilityLevel::PRIVATE + haml_concat "Project access must be granted explicitly for each user." + when Gitlab::VisibilityLevel::INTERNAL + haml_concat "The project can be cloned by" + haml_concat "any logged in user." + when Gitlab::VisibilityLevel::PUBLIC + haml_concat "The project can be cloned" + haml_concat "without any" + haml_concat "authentication." + end + end + end + end + + def visibility_level_icon(level) + case level + when Gitlab::VisibilityLevel::PRIVATE + private_icon + when Gitlab::VisibilityLevel::INTERNAL + internal_icon + when Gitlab::VisibilityLevel::PUBLIC + public_icon + end + end + + def visibility_level_label(level) + Project.visibility_levels.key(level) + end + + def restricted_visibility_levels + current_user.is_admin? ? [] : gitlab_config.restricted_visibility_levels + end +end diff --git a/app/mailers/emails/groups.rb b/app/mailers/emails/groups.rb index 2e9d28981e..1654fc55bc 100644 --- a/app/mailers/emails/groups.rb +++ b/app/mailers/emails/groups.rb @@ -3,9 +3,9 @@ module Emails def group_access_granted_email(user_group_id) @membership = UsersGroup.find(user_group_id) @group = @membership.group - + @target_url = group_url(@group) mail(to: @membership.user.email, - subject: subject("access to group was granted")) + subject: subject("Access to group was granted")) end end end diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb index 6eda88c792..a096df9dc0 100644 --- a/app/mailers/emails/issues.rb +++ b/app/mailers/emails/issues.rb @@ -3,22 +3,33 @@ module Emails def new_issue_email(recipient_id, issue_id) @issue = Issue.find(issue_id) @project = @issue.project - mail(to: recipient(recipient_id), subject: subject("new issue ##{@issue.iid}", @issue.title)) + @target_url = project_issue_url(@project, @issue) + set_message_id("issue_#{issue_id}") + mail(from: sender(@issue.author_id), + to: recipient(recipient_id), + subject: subject("#{@issue.title} (##{@issue.iid})")) end - def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id) + def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id, updated_by_user_id) @issue = Issue.find(issue_id) - @previous_assignee = User.find_by_id(previous_assignee_id) if previous_assignee_id + @previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id @project = @issue.project - mail(to: recipient(recipient_id), subject: subject("changed issue ##{@issue.iid}", @issue.title)) + @target_url = project_issue_url(@project, @issue) + set_reference("issue_#{issue_id}") + mail(from: sender(updated_by_user_id), + to: recipient(recipient_id), + subject: subject("#{@issue.title} (##{@issue.iid})")) end def closed_issue_email(recipient_id, issue_id, updated_by_user_id) @issue = Issue.find issue_id @project = @issue.project @updated_by = User.find updated_by_user_id - mail(to: recipient(recipient_id), - subject: subject("Closed issue ##{@issue.iid}", @issue.title)) + @target_url = project_issue_url(@project, @issue) + set_reference("issue_#{issue_id}") + mail(from: sender(updated_by_user_id), + to: recipient(recipient_id), + subject: subject("#{@issue.title} (##{@issue.iid})")) end def issue_status_changed_email(recipient_id, issue_id, status, updated_by_user_id) @@ -26,8 +37,11 @@ module Emails @issue_status = status @project = @issue.project @updated_by = User.find updated_by_user_id - mail(to: recipient(recipient_id), - subject: subject("changed issue ##{@issue.iid}", @issue.title)) + @target_url = project_issue_url(@project, @issue) + set_reference("issue_#{issue_id}") + mail(from: sender(updated_by_user_id), + to: recipient(recipient_id), + subject: subject("#{@issue.title} (##{@issue.iid})")) end end end diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb index 57c1925fa4..ea5671c450 100644 --- a/app/mailers/emails/merge_requests.rb +++ b/app/mailers/emails/merge_requests.rb @@ -2,24 +2,44 @@ module Emails module MergeRequests def new_merge_request_email(recipient_id, merge_request_id) @merge_request = MergeRequest.find(merge_request_id) - mail(to: recipient(recipient_id), subject: subject("new merge request !#{@merge_request.iid}", @merge_request.title)) + @project = @merge_request.project + @target_url = project_merge_request_url(@project, @merge_request) + set_message_id("merge_request_#{merge_request_id}") + mail(from: sender(@merge_request.author_id), + to: recipient(recipient_id), + subject: subject("#{@merge_request.title} (##{@merge_request.iid})")) end - def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id) + def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id, updated_by_user_id) @merge_request = MergeRequest.find(merge_request_id) - @previous_assignee = User.find_by_id(previous_assignee_id) if previous_assignee_id - mail(to: recipient(recipient_id), subject: subject("changed merge request !#{@merge_request.iid}", @merge_request.title)) + @previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id + @project = @merge_request.project + @target_url = project_merge_request_url(@project, @merge_request) + set_reference("merge_request_#{merge_request_id}") + mail(from: sender(updated_by_user_id), + to: recipient(recipient_id), + subject: subject("#{@merge_request.title} (##{@merge_request.iid})")) end def closed_merge_request_email(recipient_id, merge_request_id, updated_by_user_id) @merge_request = MergeRequest.find(merge_request_id) @updated_by = User.find updated_by_user_id - mail(to: recipient(recipient_id), subject: subject("Closed merge request !#{@merge_request.iid}", @merge_request.title)) + @project = @merge_request.project + @target_url = project_merge_request_url(@project, @merge_request) + set_reference("merge_request_#{merge_request_id}") + mail(from: sender(updated_by_user_id), + to: recipient(recipient_id), + subject: subject("#{@merge_request.title} (##{@merge_request.iid})")) end - def merged_merge_request_email(recipient_id, merge_request_id) + def merged_merge_request_email(recipient_id, merge_request_id, updated_by_user_id) @merge_request = MergeRequest.find(merge_request_id) - mail(to: recipient(recipient_id), subject: subject("Accepted merge request !#{@merge_request.iid}", @merge_request.title)) + @project = @merge_request.project + @target_url = project_merge_request_url(@project, @merge_request) + set_reference("merge_request_#{merge_request_id}") + mail(from: sender(updated_by_user_id), + to: recipient(recipient_id), + subject: subject("#{@merge_request.title} (##{@merge_request.iid})")) end end @@ -53,7 +73,7 @@ module Emails # >> subject('Lorem ipsum', 'Dolor sit amet') # => "GitLab Merge Request | Lorem ipsum | Dolor sit amet" def subject(*extra) - subject = "GitLab Merge Request |" + subject = "Merge Request | " if @merge_request.for_fork? subject << "#{@merge_request.source_project.name_with_namespace}:#{merge_request.source_branch} >> #{@merge_request.target_project.name_with_namespace}:#{merge_request.target_branch}" else diff --git a/app/mailers/emails/notes.rb b/app/mailers/emails/notes.rb index ba4f0dd862..8d1f17b0f8 100644 --- a/app/mailers/emails/notes.rb +++ b/app/mailers/emails/notes.rb @@ -4,27 +4,41 @@ module Emails @note = Note.find(note_id) @commit = @note.noteable @project = @note.project - mail(to: recipient(recipient_id), subject: subject("note for commit #{@commit.short_id}", @commit.title)) + @target_url = project_commit_url(@project, @commit, anchor: "note_#{@note.id}") + mail(from: sender(@note.author_id), + to: recipient(recipient_id), + subject: subject("#{@commit.title} (#{@commit.short_id})")) end def note_issue_email(recipient_id, note_id) @note = Note.find(note_id) @issue = @note.noteable @project = @note.project - mail(to: recipient(recipient_id), subject: subject("note for issue ##{@issue.iid}")) + @target_url = project_issue_url(@project, @issue, anchor: "note_#{@note.id}") + set_reference("issue_#{@issue.id}") + mail(from: sender(@note.author_id), + to: recipient(recipient_id), + subject: subject("#{@issue.title} (##{@issue.iid})")) end def note_merge_request_email(recipient_id, note_id) @note = Note.find(note_id) @merge_request = @note.noteable @project = @note.project - mail(to: recipient(recipient_id), subject: subject("note for merge request ##{@merge_request.iid}")) + @target_url = project_merge_request_url(@project, @merge_request, anchor: "note_#{@note.id}") + set_reference("merge_request_#{@merge_request.id}") + mail(from: sender(@note.author_id), + to: recipient(recipient_id), + subject: subject("#{@merge_request.title} (##{@merge_request.iid})")) end def note_wall_email(recipient_id, note_id) @note = Note.find(note_id) @project = @note.project - mail(to: recipient(recipient_id), subject: subject("note on wall")) + @target_url = project_wall_url(@note.project, anchor: "note_#{@note.id}") + mail(from: sender(@note.author_id), + to: recipient(recipient_id), + subject: subject("Note on wall")) end end end diff --git a/app/mailers/emails/profile.rb b/app/mailers/emails/profile.rb index bcd44f9476..f02d95fd55 100644 --- a/app/mailers/emails/profile.rb +++ b/app/mailers/emails/profile.rb @@ -3,12 +3,20 @@ module Emails def new_user_email(user_id, password) @user = User.find(user_id) @password = password + @target_url = user_url(@user) mail(to: @user.email, subject: subject("Account was created for you")) end + def new_email_email(email_id) + @email = Email.find(email_id) + @user = @email.user + mail(to: @user.email, subject: subject("Email was added to your account")) + end + def new_ssh_key_email(key_id) @key = Key.find(key_id) @user = @key.user + @target_url = user_url(@user) mail(to: @user.email, subject: subject("SSH key was added to your account")) end end diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb index 4d5fe9ef61..9f99c11ea3 100644 --- a/app/mailers/emails/projects.rb +++ b/app/mailers/emails/projects.rb @@ -3,15 +3,35 @@ module Emails def project_access_granted_email(user_project_id) @users_project = UsersProject.find user_project_id @project = @users_project.project + @target_url = project_url(@project) mail(to: @users_project.user.email, - subject: subject("access to project was granted")) + subject: subject("Access to project was granted")) end def project_was_moved_email(project_id, user_id) @user = User.find user_id @project = Project.find project_id + @target_url = project_url(@project) mail(to: @user.email, - subject: subject("project was moved")) + subject: subject("Project was moved")) + end + + def repository_push_email(project_id, recipient, author_id, branch, compare) + @project = Project.find(project_id) + @author = User.find(author_id) + @compare = compare + @commits = Commit.decorate(compare.commits) + @diffs = compare.diffs + @branch = branch + if @commits.length > 1 + @target_url = project_compare_url(@project, from: @commits.first, to: @commits.last) + else + @target_url = project_commit_url(@project, @commits.first) + end + + mail(from: sender(author_id), + to: recipient, + subject: subject("New push to repository")) end end end diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 2f7be00c33..84a0da0129 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -12,18 +12,36 @@ class Notify < ActionMailer::Base default_url_options[:host] = Gitlab.config.gitlab.host default_url_options[:protocol] = Gitlab.config.gitlab.protocol - default_url_options[:port] = Gitlab.config.gitlab.port if Gitlab.config.gitlab_on_non_standard_port? + default_url_options[:port] = Gitlab.config.gitlab.port unless Gitlab.config.gitlab_on_standard_port? default_url_options[:script_name] = Gitlab.config.gitlab.relative_url_root - default from: Gitlab.config.gitlab.email_from + default from: Proc.new { default_sender_address.format } + default reply_to: "noreply@#{Gitlab.config.gitlab.host}" - # Just send email with 3 seconds delay + # Just send email with 2 seconds delay def self.delay delay_for(2.seconds) end private + # The default email address to send emails from + def default_sender_address + address = Mail::Address.new(Gitlab.config.gitlab.email_from) + address.display_name = "GitLab" + address + end + + # Return an email address that displays the name of the sender. + # Only the displayed name changes; the actual email address is always the same. + def sender(sender_id) + if sender = User.find(sender_id) + address = default_sender_address + address.display_name = sender.name + address.format + end + end + # Look up a User by their ID and return their email address # # recipient_id - User ID @@ -35,6 +53,22 @@ class Notify < ActionMailer::Base end end + # Set the Message-ID header field + # + # local_part - The local part of the message ID + # + def set_message_id(local_part) + headers["Message-ID"] = "<#{local_part}@#{Gitlab.config.gitlab.host}>" + end + + # Set the References header field + # + # local_part - The local part of the referenced message ID + # + def set_reference(local_part) + headers["References"] = "<#{local_part}@#{Gitlab.config.gitlab.host}>" + end + # Formats arguments into a String suitable for use as an email subject # # extra - Extra Strings to be inserted into the subject @@ -42,21 +76,21 @@ class Notify < ActionMailer::Base # Examples # # >> subject('Lorem ipsum') - # => "GitLab | Lorem ipsum" + # => "Lorem ipsum" # # # Automatically inserts Project name when @project is set # >> @project = Project.last # => # # >> subject('Lorem ipsum') - # => "GitLab | Ruby on Rails | Lorem ipsum " + # => "Ruby on Rails | Lorem ipsum " # # # Accepts multiple arguments # >> subject('Lorem ipsum', 'Dolor sit amet') - # => "GitLab | Lorem ipsum | Dolor sit amet" + # => "Lorem ipsum | Dolor sit amet" def subject(*extra) - subject = "GitLab" - subject << (@project ? " | #{@project.name_with_namespace}" : "") - subject << " | " + extra.join(' | ') if extra.present? + subject = "" + subject << "#{@project.name} | " if @project + subject << extra.join(' | ') if extra.present? subject end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 8547608914..1afe8a4638 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -14,6 +14,7 @@ class Ability when "MergeRequest" then merge_request_abilities(user, subject) when "Group" then group_abilities(user, subject) when "Namespace" then namespace_abilities(user, subject) + when "UsersGroup" then users_group_abilities(user, subject) else [] end.concat(global_abilities(user)) end @@ -29,7 +30,7 @@ class Ability nil end - if project && project.public + if project && project.public? [ :read_project, :read_wiki, @@ -42,7 +43,19 @@ class Ability :download_code ] else - [] + group = if subject.kind_of?(Group) + subject + elsif subject.respond_to?(:group) + subject.group + else + nil + end + + if group && group.has_projects_accessible_to?(nil) + [:read_group] + else + [] + end end end @@ -59,37 +72,41 @@ class Ability # Rules based on role in project if team.masters.include?(user) - rules << project_master_rules + rules += project_master_rules elsif team.developers.include?(user) - rules << project_dev_rules + rules += project_dev_rules elsif team.reporters.include?(user) - rules << project_report_rules + rules += project_report_rules elsif team.guests.include?(user) - rules << project_guest_rules + rules += project_guest_rules end - if project.public? - rules << public_project_rules + if project.public? || project.internal? + rules += public_project_rules end if project.owner == user || user.admin? - rules << project_admin_rules + rules += project_admin_rules end if project.group && project.group.has_owner?(user) - rules << project_admin_rules + rules += project_admin_rules end - rules.flatten + if project.archived? + rules -= project_archived_rules + end + + rules end def public_project_rules project_guest_rules + [ :download_code, - :fork_project, + :fork_project ] end @@ -121,10 +138,22 @@ class Ability project_report_rules + [ :write_merge_request, :write_wiki, + :modify_issue, + :admin_issue, :push_code ] end + def project_archived_rules + [ + :write_merge_request, + :push_code, + :push_code_to_protected_branches, + :modify_merge_request, + :admin_merge_request + ] + end + def project_master_rules project_dev_rules + [ :push_code_to_protected_branches, @@ -145,22 +174,23 @@ class Ability def project_admin_rules project_master_rules + [ :change_namespace, - :change_public_mode, + :change_visibility_level, :rename_project, - :remove_project + :remove_project, + :archive_project ] end def group_abilities user, group rules = [] - if group.users.include?(user) || user.admin? + if user.admin? || group.users.include?(user) || ProjectsFinder.new.execute(user, group: group).any? rules << :read_group end # Only group owner and administrators can manage group if group.has_owner?(user) || user.admin? - rules << [ + rules += [ :manage_group, :manage_namespace ] @@ -174,7 +204,7 @@ class Ability # Only namespace owner and administrators can manage it if namespace.owner == user || user.admin? - rules << [ + rules += [ :manage_namespace ] end @@ -202,5 +232,20 @@ class Ability end end end + + def users_group_abilities(user, subject) + rules = [] + target_user = subject.user + group = subject.group + can_manage = group_abilities(user, group).include?(:manage_group) + if can_manage && (user != target_user) + rules << :modify + rules << :destroy + end + if !group.last_owner?(user) && (can_manage || (user == target_user)) + rules << :destroy + end + rules + end end end diff --git a/app/models/broadcast_message.rb b/app/models/broadcast_message.rb new file mode 100644 index 0000000000..85ab7ed6ae --- /dev/null +++ b/app/models/broadcast_message.rb @@ -0,0 +1,29 @@ +# == Schema Information +# +# Table name: broadcast_messages +# +# id :integer not null, primary key +# message :text not null +# starts_at :datetime +# ends_at :datetime +# alert_type :integer +# created_at :datetime +# updated_at :datetime +# color :string(255) +# font :string(255) +# + +class BroadcastMessage < ActiveRecord::Base + attr_accessible :alert_type, :color, :ends_at, :font, :message, :starts_at + + validates :message, presence: true + validates :starts_at, presence: true + validates :ends_at, presence: true + + validates :color, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true + validates :font, format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ }, allow_blank: true + + def self.current + where("ends_at > :now AND starts_at < :now", now: Time.zone.now).last + end +end diff --git a/app/models/commit.rb b/app/models/commit.rb index dd1f980187..c313aeb757 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -16,29 +16,31 @@ class Commit DIFF_HARD_LIMIT_FILES = 500 DIFF_HARD_LIMIT_LINES = 10000 - def self.decorate(commits) - commits.map { |c| self.new(c) } - end + class << self + def decorate(commits) + commits.map { |c| self.new(c) } + end - # Calculate number of lines to render for diffs - def self.diff_line_count(diffs) - diffs.reduce(0){|sum, d| sum + d.diff.lines.count} - end + # Calculate number of lines to render for diffs + def diff_line_count(diffs) + diffs.reduce(0){|sum, d| sum + d.diff.lines.count} + end - def self.diff_suppress?(diffs, line_count = nil) - # optimize - check file count first - return true if diffs.size > DIFF_SAFE_FILES + def diff_suppress?(diffs, line_count = nil) + # optimize - check file count first + return true if diffs.size > DIFF_SAFE_FILES - line_count ||= Commit::diff_line_count(diffs) - line_count > DIFF_SAFE_LINES - end + line_count ||= Commit::diff_line_count(diffs) + line_count > DIFF_SAFE_LINES + end - def self.diff_force_suppress?(diffs, line_count = nil) - # optimize - check file count first - return true if diffs.size > DIFF_HARD_LIMIT_FILES + def diff_force_suppress?(diffs, line_count = nil) + # optimize - check file count first + return true if diffs.size > DIFF_HARD_LIMIT_FILES - line_count ||= Commit::diff_line_count(diffs) - line_count > DIFF_HARD_LIMIT_LINES + line_count ||= Commit::diff_line_count(diffs) + line_count > DIFF_HARD_LIMIT_LINES + end end attr_accessor :raw @@ -97,14 +99,16 @@ class Commit # # cut off, ellipses (`&hellp;`) are prepended to the commit message. def description - description = safe_message + title_end = safe_message.index(/\n/) + @description ||= if (!title_end && safe_message.length > 100) || (title_end && title_end > 100) + "…".html_safe << safe_message[80..-1] + else + safe_message.split(/\n/, 2)[1].try(:chomp) + end + end - title_end = description.index(/\n/) - if (!title_end && description.length > 100) || (title_end && title_end > 100) - "…".html_safe << description[80..-1] - else - description.split(/\n/, 2)[1].try(:chomp) - end + def description? + description.present? end # Regular expression that identifies commit message clauses that trigger issue closing. diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 7f820f950b..de167f8803 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -23,7 +23,8 @@ module Issuable scope :assigned, -> { where("assignee_id IS NOT NULL") } scope :unassigned, -> { where("assignee_id IS NULL") } scope :of_projects, ->(ids) { where(project_id: ids) } - + scope :opened, -> { with_state(:opened, :reopened) } + scope :closed, -> { with_state(:closed) } delegate :name, :email, @@ -36,8 +37,6 @@ module Issuable allow_nil: true, prefix: true - attr_accessor :author_id_of_changes - attr_mentionable :title, :description end @@ -45,6 +44,18 @@ module Issuable def search(query) where("title like :query", query: "%#{query}%") end + + def sort(method) + case method.to_s + when 'newest' then reorder("#{table_name}.created_at DESC") + when 'oldest' then reorder("#{table_name}.created_at ASC") + when 'recently_updated' then reorder("#{table_name}.updated_at DESC") + when 'last_updated' then reorder("#{table_name}.updated_at ASC") + when 'milestone_due_soon' then joins(:milestone).reorder("milestones.due_date ASC") + when 'milestone_due_later' then joins(:milestone).reorder("milestones.due_date DESC") + else reorder("#{table_name}.created_at DESC") + end + end end def today? @@ -111,4 +122,11 @@ module Issuable end users.concat(mentions.reduce([], :|)).uniq end + + def to_hook_data + { + object_kind: self.class.name.underscore, + object_attributes: self.attributes + } + end end diff --git a/app/models/deploy_key.rb b/app/models/deploy_key.rb index 47aeb93a41..570f5e91c1 100644 --- a/app/models/deploy_key.rb +++ b/app/models/deploy_key.rb @@ -4,8 +4,8 @@ # # id :integer not null, primary key # user_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # key :text # title :string(255) # type :string(255) diff --git a/app/models/deploy_keys_project.rb b/app/models/deploy_keys_project.rb index 6f109e4831..739d749830 100644 --- a/app/models/deploy_keys_project.rb +++ b/app/models/deploy_keys_project.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # deploy_key_id :integer not null # project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # class DeployKeysProject < ActiveRecord::Base diff --git a/app/models/diff_line.rb b/app/models/diff_line.rb new file mode 100644 index 0000000000..ad37945874 --- /dev/null +++ b/app/models/diff_line.rb @@ -0,0 +1,3 @@ +class DiffLine + attr_accessor :type, :content, :num, :code +end diff --git a/app/models/email.rb b/app/models/email.rb new file mode 100644 index 0000000000..9068c2b87b --- /dev/null +++ b/app/models/email.rb @@ -0,0 +1,41 @@ +# == Schema Information +# +# Table name: emails +# +# id :integer not null, primary key +# user_id :integer not null +# email :string(255) not null +# created_at :datetime +# updated_at :datetime +# + +class Email < ActiveRecord::Base + attr_accessible :email, :user_id + + # + # Relations + # + belongs_to :user + + # + # Validations + # + validates :user_id, presence: true + validates :email, presence: true, email: { strict_mode: true }, uniqueness: true + validate :unique_email, if: ->(email) { email.email_changed? } + + after_create :notify + before_validation :cleanup_email + + def cleanup_email + self.email = self.email.downcase.strip + end + + def unique_email + self.errors.add(:email, 'has already been taken') if User.exists?(email: self.email) + end + + def notify + NotificationService.new.new_email(self) + end +end diff --git a/app/models/event.rb b/app/models/event.rb index 095a06c956..cf88e9f4af 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -8,8 +8,8 @@ # title :string(255) # data :text # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # action :integer # author_id :integer # @@ -18,7 +18,7 @@ class Event < ActiveRecord::Base attr_accessible :project, :action, :data, :author_id, :project_id, :target_id, :target_type - default_scope where("author_id IS NOT NULL") + default_scope { where.not(author_id: nil) } CREATED = 1 UPDATED = 2 @@ -47,20 +47,14 @@ class Event < ActiveRecord::Base scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent } class << self - def determine_action(record) - if [Issue, MergeRequest].include? record.class - Event::CREATED - elsif record.kind_of? Note - Event::COMMENTED - end - end - def create_ref_event(project, user, ref, action = 'add', prefix = 'refs/heads') + commit = project.repository.commit(ref.target) + if action.to_s == 'add' before = '00000000' - after = ref.commit.id + after = commit.id else - before = ref.commit.id + before = commit.id after = '00000000' end @@ -168,7 +162,7 @@ class Event < ActiveRecord::Base end def valid_push? - data[:ref] + data[:ref] && ref_name.present? rescue => ex false end @@ -223,7 +217,7 @@ class Event < ActiveRecord::Base # Max 20 commits from push DESC def commits - @commits ||= data[:commits].reverse + @commits ||= (data[:commits] || []).reverse end def commits_count diff --git a/app/models/forked_project_link.rb b/app/models/forked_project_link.rb index aaa527a114..17add270f6 100644 --- a/app/models/forked_project_link.rb +++ b/app/models/forked_project_link.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # forked_to_project_id :integer not null # forked_from_project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # class ForkedProjectLink < ActiveRecord::Base diff --git a/app/models/group.rb b/app/models/group.rb index 0ee058be15..3cbf30a20d 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -6,16 +6,33 @@ # name :string(255) not null # path :string(255) not null # owner_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # type :string(255) # description :string(255) default(""), not null +# avatar :string(255) # +require 'carrierwave/orm/activerecord' +require 'file_size_validator' + class Group < Namespace has_many :users_groups, dependent: :destroy has_many :users, through: :users_groups + attr_accessible :avatar + + validate :avatar_type, if: ->(user) { user.avatar_changed? } + validates :avatar, file_size: { maximum: 100.kilobytes.to_i } + + mount_uploader :avatar, AttachmentUploader + + def self.accessible_to(user) + accessible_ids = Project.accessible_to(user).pluck(:namespace_id) + accessible_ids += user.groups.pluck(:id) if user + where(id: accessible_ids) + end + def human_name name end @@ -26,7 +43,7 @@ class Group < Namespace def add_users(user_ids, group_access) user_ids.compact.each do |user_id| - user = self.users_groups.find_or_initialize_by_user_id(user_id) + user = self.users_groups.find_or_initialize_by(user_id: user_id) user.update_attributes(group_access: group_access) end end @@ -50,4 +67,10 @@ class Group < Namespace def members users_groups end + + def avatar_type + unless self.avatar.image? + self.errors.add :avatar, "only images allowed" + end + end end diff --git a/app/models/issue.rb b/app/models/issue.rb index f3ec322126..16d51345e5 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -7,8 +7,8 @@ # assignee_id :integer # author_id :integer # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # position :integer default(0) # branch_name :string(255) # description :text @@ -21,17 +21,16 @@ class Issue < ActiveRecord::Base include Issuable include InternalId + ActsAsTaggableOn.strict_case_match = true + belongs_to :project validates :project, presence: true scope :of_group, ->(group) { where(project_id: group.project_ids) } scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) } - scope :opened, -> { with_state(:opened) } - scope :closed, -> { with_state(:closed) } attr_accessible :title, :assignee_id, :position, :description, - :milestone_id, :label_list, :author_id_of_changes, - :state_event + :milestone_id, :label_list, :state_event acts_as_taggable_on :labels @@ -48,18 +47,27 @@ class Issue < ActiveRecord::Base end state :opened - state :reopened - state :closed end - # Both open and reopened issues should be listed as opened - scope :opened, -> { with_state(:opened, :reopened) } - # Mentionable overrides. def gfm_reference "issue ##{iid}" end + + # Reset issue events cache + # + # Since we do cache @event we need to reset cache in special cases: + # * when an issue is updated + # Events cache stored like events/23-20130109142513. + # The cache key includes updated_at timestamp. + # Thus it will automatically generate a new fragment + # when the event is updated because the key changes. + def reset_events_cache + Event.where(target_id: self.id, target_type: 'Issue'). + order('id DESC').limit(100). + update_all(updated_at: Time.now) + end end diff --git a/app/models/key.rb b/app/models/key.rb index 79f7bbd259..035c9efa01 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -4,8 +4,8 @@ # # id :integer not null, primary key # user_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # key :text # title :string(255) # type :string(255) @@ -29,6 +29,10 @@ class Key < ActiveRecord::Base delegate :name, :email, to: :user, prefix: true + after_create :add_to_shell + after_create :notify_user + after_destroy :remove_from_shell + def strip_white_space self.key = key.strip unless key.blank? end @@ -42,6 +46,26 @@ class Key < ActiveRecord::Base "key-#{id}" end + def add_to_shell + GitlabShellWorker.perform_async( + :add_key, + shell_id, + key + ) + end + + def notify_user + NotificationService.new.new_key(self) + end + + def remove_from_shell + GitlabShellWorker.perform_async( + :remove_key, + shell_id, + key, + ) + end + private def generate_fingerpint @@ -53,7 +77,7 @@ class Key < ActiveRecord::Base Tempfile.open('gitlab_key_file') do |file| file.puts key file.rewind - cmd_output, cmd_status = popen("ssh-keygen -lf #{file.path}", '/tmp') + cmd_output, cmd_status = popen(%W(ssh-keygen -lf #{file.path}), '/tmp') end if cmd_status.zero? diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index b164ea1107..061537132b 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -9,10 +9,8 @@ # author_id :integer # assignee_id :integer # title :string(255) -# created_at :datetime not null -# updated_at :datetime not null -# st_commits :text(2147483647) -# st_diffs :text(2147483647) +# created_at :datetime +# updated_at :datetime # milestone_id :integer # state :string(255) # merge_status :string(255) @@ -31,30 +29,52 @@ class MergeRequest < ActiveRecord::Base belongs_to :target_project, foreign_key: :target_project_id, class_name: "Project" belongs_to :source_project, foreign_key: :source_project_id, class_name: "Project" - attr_accessible :title, :assignee_id, :source_project_id, :source_branch, :target_project_id, :target_branch, :milestone_id, :author_id_of_changes, :state_event, :description + has_one :merge_request_diff, dependent: :destroy + + after_create :create_merge_request_diff + after_update :update_merge_request_diff + + delegate :commits, :diffs, :last_commit, :last_commit_short_sha, to: :merge_request_diff, prefix: nil + + attr_accessible :title, :assignee_id, :source_project_id, :source_branch, + :target_project_id, :target_branch, :milestone_id, + :state_event, :description, :label_list attr_accessor :should_remove_source_branch + # When this attribute is true some MR validation is ignored + # It allows us to close or modify broken merge requests + attr_accessor :allow_broken + + ActsAsTaggableOn.strict_case_match = true + acts_as_taggable_on :labels + state_machine :state, initial: :opened do event :close do transition [:reopened, :opened] => :closed end event :merge do - transition [:reopened, :opened] => :merged + transition [:reopened, :opened, :locked] => :merged end event :reopen do transition closed: :reopened end + event :lock do + transition [:reopened, :opened] => :locked + end + + event :unlock do + transition locked: :reopened + end + state :opened - state :reopened - state :closed - state :merged + state :locked end state_machine :merge_status, initial: :unchecked do @@ -71,25 +91,19 @@ class MergeRequest < ActiveRecord::Base end state :unchecked - state :can_be_merged - state :cannot_be_merged end - serialize :st_commits - serialize :st_diffs - - validates :source_project, presence: true + validates :source_project, presence: true, unless: :allow_broken validates :source_branch, presence: true validates :target_project, presence: true validates :target_branch, presence: true validate :validate_branches + validate :validate_fork scope :of_group, ->(group) { where("source_project_id in (:group_project_ids) OR target_project_id in (:group_project_ids)", group_project_ids: group.project_ids) } scope :of_user_team, ->(team) { where("(source_project_id in (:team_project_ids) OR target_project_id in (:team_project_ids) AND assignee_id in (:team_member_ids))", team_project_ids: team.project_ids, team_member_ids: team.member_ids) } - scope :opened, -> { with_state(:opened) } - scope :closed, -> { with_state(:closed) } scope :merged, -> { with_state(:merged) } scope :by_branch, ->(branch_name) { where("(source_branch LIKE :branch) OR (target_branch LIKE :branch)", branch: branch_name) } scope :cared, ->(user) { where('assignee_id = :user OR author_id = :user', user: user.id) } @@ -101,7 +115,7 @@ class MergeRequest < ActiveRecord::Base scope :closed, -> { with_states(:closed, :merged) } def validate_branches - if target_project==source_project && target_branch == source_branch + if target_project == source_project && target_branch == source_branch errors.add :branch_conflict, "You can not use same project/branch for source and target" end @@ -115,9 +129,33 @@ class MergeRequest < ActiveRecord::Base end end + def validate_fork + return true unless target_project && source_project + + if target_project == source_project + true + else + # If source and target projects are different + # we should check if source project is actually a fork of target project + if source_project.forked_from?(target_project) + true + else + errors.add :base, "Source project is not a fork of target project" + end + end + end + + def update_merge_request_diff + if source_branch_changed? || target_branch_changed? + reload_code + mark_as_unchecked + end + end + def reload_code - self.reloaded_commits - self.reloaded_diffs + if merge_request_diff && open? + merge_request_diff.reload_content + end end def check_if_can_be_merged @@ -128,42 +166,6 @@ class MergeRequest < ActiveRecord::Base end end - def diffs - @diffs ||= (load_diffs(st_diffs) || []) - end - - def reloaded_diffs - if opened? && unmerged_diffs.any? - self.st_diffs = dump_diffs(unmerged_diffs) - self.save - end - end - - def broken_diffs? - diffs == broken_diffs - rescue - true - end - - def valid_diffs? - !broken_diffs? - end - - def unmerged_diffs - diffs = if for_fork? - Gitlab::Satellite::MergeAction.new(author, self).diffs_between_satellite - else - Gitlab::Git::Diff.between(target_project.repository, source_branch, target_branch) - end - - diffs ||= [] - diffs - end - - def last_commit - commits.first - end - def merge_event self.target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::MERGED).last end @@ -172,56 +174,19 @@ class MergeRequest < ActiveRecord::Base self.target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::CLOSED).last end - def commits - load_commits(st_commits || []) + def automerge!(current_user, commit_message = nil) + MergeRequests::AutoMergeService.new.execute(self, current_user, commit_message) end - def probably_merged? - unmerged_commits.empty? && - commits.any? && opened? - end - - def reloaded_commits - if opened? && unmerged_commits.any? - self.st_commits = dump_commits(unmerged_commits) - save - - end - commits - end - - def unmerged_commits - if for_fork? - commits = Gitlab::Satellite::MergeAction.new(self.author, self).commits_between - else - commits = target_project.repository.commits_between(self.target_branch, self.source_branch) - end - - if commits.present? - commits = Commit.decorate(commits). - sort_by(&:created_at). - reverse - end - commits - end - - def merge!(user_id) - self.author_id_of_changes = user_id - self.merge - end - - def automerge!(current_user) - if Gitlab::Satellite::MergeAction.new(current_user, self).merge! && self.unmerged_commits.empty? - self.merge!(current_user.id) - true - end - rescue - mark_as_unmergeable - false + def open? + opened? || reopened? end def mr_and_commit_notes - commit_ids = commits.map(&:id) + # Fetch comments only from last 100 commits + commits_for_notes_limit = 100 + commit_ids = commits.last(commits_for_notes_limit).map(&:id) + project.notes.where( "(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND commit_id IN (:commit_ids))", mr_id: id, @@ -243,16 +208,12 @@ class MergeRequest < ActiveRecord::Base Gitlab::Satellite::MergeAction.new(current_user, self).format_patch end - def last_commit_short_sha - @last_commit_short_sha ||= last_commit.sha[0..10] - end - def for_fork? target_project != source_project end def disallow_source_branch_removal? - (source_project.root_ref? source_branch) || for_fork? + source_project.root_ref?(source_branch) || source_project.protected_branches.include?(source_branch) end def project @@ -262,7 +223,7 @@ class MergeRequest < ActiveRecord::Base # Return the set of issues that will be closed if this merge request is accepted. def closes_issues if target_branch == project.default_branch - unmerged_commits.map { |c| c.closes_issues(project) }.flatten.uniq.sort_by(&:id) + commits.map { |c| c.closes_issues(project) }.flatten.uniq.sort_by(&:id) else [] end @@ -273,33 +234,90 @@ class MergeRequest < ActiveRecord::Base "merge request !#{iid}" end - private - - def dump_commits(commits) - commits.map(&:to_hash) - end - - def load_commits(array) - array.map { |hash| Commit.new(Gitlab::Git::Commit.new(hash)) } - end - - def dump_diffs(diffs) - if diffs == broken_diffs - broken_diffs - elsif diffs.respond_to?(:map) - diffs.map(&:to_hash) + def target_project_path + if target_project + target_project.path_with_namespace + else + "(removed)" end end - def load_diffs(raw) - if raw == broken_diffs - broken_diffs - elsif raw.respond_to?(:map) - raw.map { |hash| Gitlab::Git::Diff.new(hash) } + def source_project_path + if source_project + source_project.path_with_namespace + else + "(removed)" end end - def broken_diffs - [Gitlab::Git::Diff::BROKEN_DIFF] + def source_project_namespace + if source_project && source_project.namespace + source_project.namespace.path + else + "(removed)" + end + end + + def target_project_namespace + if target_project && target_project.namespace + target_project.namespace.path + else + "(removed)" + end + end + + def source_branch_exists? + return false unless self.source_project + + self.source_project.repository.branch_names.include?(self.source_branch) + end + + def target_branch_exists? + return false unless self.target_project + + self.target_project.repository.branch_names.include?(self.target_branch) + end + + # Reset merge request events cache + # + # Since we do cache @event we need to reset cache in special cases: + # * when a merge request is updated + # Events cache stored like events/23-20130109142513. + # The cache key includes updated_at timestamp. + # Thus it will automatically generate a new fragment + # when the event is updated because the key changes. + def reset_events_cache + Event.where(target_id: self.id, target_type: 'MergeRequest'). + order('id DESC').limit(100). + update_all(updated_at: Time.now) + end + + def merge_commit_message + message = "Merge branch '#{source_branch}' into '#{target_branch}'" + message << "\n\n" + message << title.to_s + message << "\n\n" + message << description.to_s + message + end + + # Return array of possible target branches + # dependes on target project of MR + def target_branches + if target_project.nil? + [] + else + target_project.repository.branch_names + end + end + + # Return array of possible source branches + # dependes on source project of MR + def source_branches + if source_project.nil? + [] + else + source_project.repository.branch_names + end end end diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb new file mode 100644 index 0000000000..7dce71a677 --- /dev/null +++ b/app/models/merge_request_diff.rb @@ -0,0 +1,180 @@ +# == Schema Information +# +# Table name: merge_request_diffs +# +# id :integer not null, primary key +# state :string(255) default("collected"), not null +# st_commits :text +# st_diffs :text +# merge_request_id :integer not null +# created_at :datetime +# updated_at :datetime +# + +require Rails.root.join("app/models/commit") + +class MergeRequestDiff < ActiveRecord::Base + # Prevent store of diff + # if commits amount more then 200 + COMMITS_SAFE_SIZE = 200 + + attr_reader :commits, :diffs + + belongs_to :merge_request + + attr_accessible :state, :st_commits, :st_diffs + + delegate :target_branch, :source_branch, to: :merge_request, prefix: nil + + state_machine :state, initial: :empty do + state :collected + state :timeout + state :overflow_commits_safe_size + state :overflow_diff_files_limit + state :overflow_diff_lines_limit + end + + serialize :st_commits + serialize :st_diffs + + after_create :reload_content + + def reload_content + reload_commits + reload_diffs + end + + def diffs + @diffs ||= (load_diffs(st_diffs) || []) + end + + def commits + @commits ||= load_commits(st_commits || []) + end + + def last_commit + commits.first + end + + def last_commit_short_sha + @last_commit_short_sha ||= last_commit.sha[0..10] + end + + private + + def dump_commits(commits) + commits.map(&:to_hash) + end + + def load_commits(array) + array.map { |hash| Commit.new(Gitlab::Git::Commit.new(hash)) } + end + + def dump_diffs(diffs) + if diffs.respond_to?(:map) + diffs.map(&:to_hash) + end + end + + def load_diffs(raw) + if raw.respond_to?(:map) + raw.map { |hash| Gitlab::Git::Diff.new(hash) } + end + end + + # Collect array of Git::Commit objects + # between target and source branches + def unmerged_commits + commits = if merge_request.for_fork? + compare_action.commits + else + repository.commits_between(target_branch, source_branch) + end + + if commits.present? + commits = Commit.decorate(commits). + sort_by(&:created_at). + reverse + end + + commits + end + + # Reload all commits related to current merge request from repo + # and save it as array of hashes in st_commits db field + def reload_commits + commit_objects = unmerged_commits + + if commit_objects.present? + self.st_commits = dump_commits(commit_objects) + end + + save + end + + # Reload diffs between branches related to current merge request from repo + # and save it as array of hashes in st_diffs db field + def reload_diffs + new_diffs = [] + + if commits.size.zero? + self.state = :empty + elsif commits.size > COMMITS_SAFE_SIZE + self.state = :overflow_commits_safe_size + else + new_diffs = unmerged_diffs + end + + if new_diffs.any? + if new_diffs.size > Commit::DIFF_HARD_LIMIT_FILES + self.state = :overflow_diff_files_limit + new_diffs = [] + end + + if new_diffs.sum { |diff| diff.diff.lines.count } > Commit::DIFF_HARD_LIMIT_LINES + self.state = :overflow_diff_lines_limit + new_diffs = [] + end + end + + if new_diffs.present? + new_diffs = dump_commits(new_diffs) + self.state = :collected + end + + self.st_diffs = new_diffs + self.save + end + + # Collect array of Git::Diff objects + # between target and source branches + def unmerged_diffs + diffs = if merge_request.for_fork? + compare_action.diffs + else + Gitlab::Git::Diff.between(repository, source_branch, target_branch) + end + + diffs ||= [] + diffs + rescue Gitlab::Git::Diff::TimeoutError => ex + self.state = :timeout + diffs = [] + end + + def repository + merge_request.target_project.repository + end + + private + + def compare_action + Gitlab::Satellite::CompareAction.new( + merge_request.author, + merge_request.target_project, + merge_request.target_branch, + merge_request.source_project, + merge_request.source_branch + ) + end +end diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 1a73fa71e4..39ab0b536a 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -7,8 +7,8 @@ # project_id :integer not null # description :text # due_date :date -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # state :string(255) # iid :integer # @@ -16,8 +16,7 @@ class Milestone < ActiveRecord::Base include InternalId - attr_accessible :title, :description, :due_date, :state_event, :author_id_of_changes - attr_accessor :author_id_of_changes + attr_accessible :title, :description, :due_date, :state_event belongs_to :project has_many :issues @@ -26,6 +25,7 @@ class Milestone < ActiveRecord::Base scope :active, -> { with_state(:active) } scope :closed, -> { with_state(:closed) } + scope :of_projects, ->(ids) { where(project_id: ids) } validates :title, presence: true validates :project, presence: true @@ -89,6 +89,6 @@ class Milestone < ActiveRecord::Base end def author_id - author_id_of_changes + nil end end diff --git a/app/models/namespace.rb b/app/models/namespace.rb index fde06649c7..7973eef7e1 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -6,10 +6,11 @@ # name :string(255) not null # path :string(255) not null # owner_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # type :string(255) # description :string(255) default(""), not null +# avatar :string(255) # class Namespace < ActiveRecord::Base @@ -26,7 +27,7 @@ class Namespace < ActiveRecord::Base format: { with: Gitlab::Regex.name_regex, message: "only letters, digits, spaces & '_' '-' '.' allowed." } validates :description, length: { within: 0..255 } - validates :path, uniqueness: true, presence: true, length: { within: 1..255 }, + validates :path, uniqueness: { case_sensitive: false }, presence: true, length: { within: 1..255 }, exclusion: { in: Gitlab::Blacklist.path }, format: { with: Gitlab::Regex.path_regex, message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } @@ -46,6 +47,14 @@ class Namespace < ActiveRecord::Base def self.global_id 'GLN' end + + def projects_accessible_to(user) + projects.accessible_to(user) + end + + def has_projects_accessible_to?(user) + projects_accessible_to(user).present? + end def to_param path @@ -87,4 +96,8 @@ class Namespace < ActiveRecord::Base def send_update_instructions projects.each(&:send_move_instructions) end + + def kind + type == 'Group' ? 'group' : 'user' + end end diff --git a/app/models/note.rb b/app/models/note.rb index 7e7387abed..cee10ec90d 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -6,15 +6,15 @@ # note :text # noteable_type :string(255) # author_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # project_id :integer # attachment :string(255) # line_code :string(255) # commit_id :string(255) # noteable_id :integer -# st_diff :text # system :boolean default(FALSE), not null +# st_diff :text # require 'carrierwave/orm/activerecord' @@ -23,6 +23,8 @@ require 'file_size_validator' class Note < ActiveRecord::Base include Mentionable + default_value_for :system, false + attr_accessible :note, :noteable, :noteable_id, :noteable_type, :project_id, :attachment, :line_code, :commit_id attr_mentionable :note @@ -56,29 +58,70 @@ class Note < ActiveRecord::Base serialize :st_diff before_create :set_diff, if: ->(n) { n.line_code.present? } - def self.create_status_change_note(noteable, project, author, status, source) - body = "_Status changed to #{status}#{' by ' + source.gfm_reference if source}_" + class << self + def create_status_change_note(noteable, project, author, status, source) + body = "_Status changed to #{status}#{' by ' + source.gfm_reference if source}_" - create({ - noteable: noteable, - project: project, - author: author, - note: body, - system: true - }, without_protection: true) - end + create({ + noteable: noteable, + project: project, + author: author, + note: body, + system: true + }, without_protection: true) + end - # +noteable+ was referenced from +mentioner+, by including GFM in either +mentioner+'s description or an associated Note. - # Create a system Note associated with +noteable+ with a GFM back-reference to +mentioner+. - def self.create_cross_reference_note(noteable, mentioner, author, project) - create({ - noteable: noteable, - commit_id: (noteable.sha if noteable.respond_to? :sha), - project: project, - author: author, - note: "_mentioned in #{mentioner.gfm_reference}_", - system: true - }, without_protection: true) + # +noteable+ was referenced from +mentioner+, by including GFM in either +mentioner+'s description or an associated Note. + # Create a system Note associated with +noteable+ with a GFM back-reference to +mentioner+. + def create_cross_reference_note(noteable, mentioner, author, project) + note_options = { + project: project, + author: author, + note: "_mentioned in #{mentioner.gfm_reference}_", + system: true + } + + if noteable.kind_of?(Commit) + note_options.merge!(noteable_type: 'Commit', commit_id: noteable.id) + else + note_options.merge!(noteable: noteable) + end + + create(note_options, without_protection: true) + end + + def create_assignee_change_note(noteable, project, author, assignee) + body = assignee.nil? ? '_Assignee removed_' : "_Reassigned to @#{assignee.username}_" + + create({ + noteable: noteable, + project: project, + author: author, + note: body, + system: true + }, without_protection: true) + end + + def discussions_from_notes(notes) + discussion_ids = [] + discussions = [] + + notes.each do |note| + next if discussion_ids.include?(note.discussion_id) + + # don't group notes for the main target + if !note.for_diff_line? && note.noteable_type == "MergeRequest" + discussions << [note] + else + discussions << notes.select do |other_note| + note.discussion_id == other_note.discussion_id + end + discussion_ids << note.discussion_id + end + end + + discussions + end end # Determine whether or not a cross-reference note already exists. @@ -88,8 +131,8 @@ class Note < ActiveRecord::Base def commit_author @commit_author ||= - project.users.find_by_email(noteable.author_email) || - project.users.find_by_name(noteable.author_name) + project.users.find_by(email: noteable.author_email) || + project.users.find_by(name: noteable.author_name) rescue nil end @@ -141,9 +184,10 @@ class Note < ActiveRecord::Base return @diff_line if @diff_line if diff - Gitlab::DiffParser.new(diff).each do |full_line, type, line_code, line_new, line_old| - @diff_line = full_line if line_code == self.line_code - end + Gitlab::DiffParser.new(diff.diff.lines.to_a, diff.new_path) + .each do |full_line, type, line_code, line_new, line_old| + @diff_line = full_line if line_code == self.line_code + end end @diff_line @@ -157,7 +201,9 @@ class Note < ActiveRecord::Base # otherwise false is returned def downvote? votable? && (note.start_with?('-1') || - note.start_with?(':-1:') + note.start_with?(':-1:') || + note.start_with?(':thumbsdown:') || + note.start_with?(':thumbs_down_sign:') ) end @@ -206,7 +252,9 @@ class Note < ActiveRecord::Base # otherwise false is returned def upvote? votable? && (note.start_with?('+1') || - note.start_with?(':+1:') + note.start_with?(':+1:') || + note.start_with?(':thumbsup:') || + note.start_with?(':thumbs_up_sign:') ) end @@ -237,4 +285,19 @@ class Note < ActiveRecord::Base def noteable_type=(sType) super(sType.to_s.classify.constantize.base_class.to_s) end + + # Reset notes events cache + # + # Since we do cache @event we need to reset cache in special cases: + # * when a note is updated + # * when a note is removed + # Events cache stored like events/23-20130109142513. + # The cache key includes updated_at timestamp. + # Thus it will automatically generate a new fragment + # when the event is updated because the key changes. + def reset_events_cache + Event.where(target_id: self.id, target_type: 'Note'). + order('id DESC').limit(100). + update_all(updated_at: Time.now) + end end diff --git a/app/models/notification.rb b/app/models/notification.rb index ff6a18d6a5..b0f8ed6a4e 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -9,12 +9,23 @@ class Notification attr_accessor :target - def self.notification_levels - [N_DISABLED, N_PARTICIPATING, N_WATCH] - end + class << self + def notification_levels + [N_DISABLED, N_PARTICIPATING, N_WATCH] + end - def self.project_notification_levels - [N_DISABLED, N_PARTICIPATING, N_WATCH, N_GLOBAL] + def options_with_labels + { + disabled: N_DISABLED, + participating: N_PARTICIPATING, + watch: N_WATCH, + global: N_GLOBAL + } + end + + def project_notification_levels + [N_DISABLED, N_PARTICIPATING, N_WATCH, N_GLOBAL] + end end def initialize(target) @@ -36,4 +47,8 @@ class Notification def global? target.notification_level == N_GLOBAL end + + def level + target.notification_level + end end diff --git a/app/models/personal_snippet.rb b/app/models/personal_snippet.rb index ef2000ad05..a3c0d201ee 100644 --- a/app/models/personal_snippet.rb +++ b/app/models/personal_snippet.rb @@ -4,11 +4,11 @@ # # id :integer not null, primary key # title :string(255) -# content :text(2147483647) +# content :text # author_id :integer not null # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # file_name :string(255) # expires_at :datetime # private :boolean default(TRUE), not null diff --git a/app/models/project.rb b/app/models/project.rb index 6b8e54d5b2..45e950f480 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -6,64 +6,79 @@ # name :string(255) # path :string(255) # description :text -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # creator_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 # namespace_id :integer -# public :boolean default(FALSE), not null # issues_tracker :string(255) default("gitlab"), not null # issues_tracker_id :string(255) # snippets_enabled :boolean default(TRUE), not null # last_activity_at :datetime -# imported :boolean default(FALSE), not null # import_url :string(255) +# visibility_level :integer default(0), not null +# archived :boolean default(FALSE), not null +# import_status :string(255) # class Project < ActiveRecord::Base include Gitlab::ShellAdapter + include Gitlab::VisibilityLevel extend Enumerize - attr_accessible :name, :path, :description, :default_branch, :issues_tracker, :label_list, + default_value_for :archived, false + default_value_for :issues_enabled, true + default_value_for :wall_enabled, true + default_value_for :merge_requests_enabled, true + default_value_for :wiki_enabled, true + default_value_for :snippets_enabled, true + + ActsAsTaggableOn.strict_case_match = true + + attr_accessible :name, :path, :description, :issues_tracker, :label_list, :issues_enabled, :wall_enabled, :merge_requests_enabled, :snippets_enabled, :issues_tracker_id, - :wiki_enabled, :public, :import_url, :last_activity_at, as: [:default, :admin] + :wiki_enabled, :visibility_level, :import_url, :last_activity_at, as: [:default, :admin] attr_accessible :namespace_id, :creator_id, as: :admin acts_as_taggable_on :labels, :issues_default_labels + attr_accessor :new_default_branch + # Relations belongs_to :creator, foreign_key: "creator_id", class_name: "User" - belongs_to :group, foreign_key: "namespace_id", conditions: "type = 'Group'" + belongs_to :group, -> { where(type: Group) }, foreign_key: "namespace_id" belongs_to :namespace - has_one :last_event, class_name: 'Event', order: 'events.created_at DESC', foreign_key: 'project_id' + has_one :last_event, -> {order 'events.created_at DESC'}, class_name: 'Event', foreign_key: 'project_id' has_one :gitlab_ci_service, dependent: :destroy has_one :campfire_service, dependent: :destroy + has_one :emails_on_push_service, dependent: :destroy has_one :pivotaltracker_service, dependent: :destroy has_one :hipchat_service, dependent: :destroy has_one :flowdock_service, dependent: :destroy + has_one :assembla_service, dependent: :destroy + has_one :gemnasium_service, dependent: :destroy + has_one :slack_service, dependent: :destroy has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id" has_one :forked_from_project, through: :forked_project_link - + # Merge Requests for target project should be removed with it + has_many :merge_requests, dependent: :destroy, foreign_key: "target_project_id" + # Merge requests from source project should be kept when source project was removed + has_many :fork_merge_requests, foreign_key: "source_project_id", class_name: MergeRequest + has_many :issues, -> { order "state DESC, created_at DESC" }, dependent: :destroy has_many :services, dependent: :destroy has_many :events, dependent: :destroy - has_many :merge_requests, dependent: :destroy, foreign_key: "target_project_id" - has_many :fork_merge_requests,dependent: :destroy, foreign_key: "source_project_id", class_name: MergeRequest - has_many :issues, dependent: :destroy, order: "state DESC, created_at DESC" has_many :milestones, dependent: :destroy has_many :notes, dependent: :destroy has_many :snippets, dependent: :destroy, class_name: "ProjectSnippet" has_many :hooks, dependent: :destroy, class_name: "ProjectHook" has_many :protected_branches, dependent: :destroy - has_many :users_projects, dependent: :destroy has_many :users, through: :users_projects - has_many :deploy_keys_projects, dependent: :destroy has_many :deploy_keys, through: :deploy_keys_projects @@ -71,8 +86,8 @@ class Project < ActiveRecord::Base delegate :members, to: :team, prefix: true # Validations - validates :creator, presence: true - validates :description, length: { within: 0..2000 } + validates :creator, presence: true, on: :create + validates :description, length: { maximum: 2000 }, allow_blank: true validates :name, presence: true, length: { within: 0..255 }, format: { with: Gitlab::Regex.project_name_regex, message: "only letters, digits, spaces & '_' '-' '.' allowed. Letter or digit should be first" } @@ -82,16 +97,13 @@ class Project < ActiveRecord::Base message: "only letters, digits & '_' '-' '.' allowed. Letter or digit should be first" } validates :issues_enabled, :wall_enabled, :merge_requests_enabled, :wiki_enabled, inclusion: { in: [true, false] } - validates :issues_tracker_id, length: { within: 0..255 } - + validates :issues_tracker_id, length: { maximum: 255 }, allow_blank: true validates :namespace, presence: true validates_uniqueness_of :name, scope: :namespace_id validates_uniqueness_of :path, scope: :namespace_id - validates :import_url, format: { with: URI::regexp(%w(git http https)), message: "should be a valid url" }, if: :import? - validate :check_limit, on: :create # Scopes @@ -104,15 +116,57 @@ class Project < ActiveRecord::Base scope :sorted_by_activity, -> { reorder("projects.last_activity_at DESC") } scope :personal, ->(user) { where(namespace_id: user.namespace_id) } scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } - scope :public_only, -> { where(public: true) } + scope :public_only, -> { where(visibility_level: Project::PUBLIC) } + scope :public_and_internal_only, -> { where(visibility_level: Project.public_and_internal_levels) } + scope :non_archived, -> { where(archived: false) } enumerize :issues_tracker, in: (Gitlab.config.issues_tracker.keys).append(:gitlab), default: :gitlab + state_machine :import_status, initial: :none do + event :import_start do + transition :none => :started + end + + event :import_finish do + transition :started => :finished + end + + event :import_fail do + transition :started => :failed + end + + event :import_retry do + transition :failed => :started + end + + state :started + state :finished + state :failed + + after_transition any => :started, :do => :add_import_job + end + class << self + def public_and_internal_levels + [Project::PUBLIC, Project::INTERNAL] + end + def abandoned where('projects.last_activity_at < ?', 6.months.ago) end + def publicish(user) + visibility_levels = [Project::PUBLIC] + visibility_levels += [Project::INTERNAL] if user + where(visibility_level: visibility_levels) + end + + def accessible_to(user) + accessible_ids = publicish(user).pluck(:id) + accessible_ids += user.authorized_projects.pluck(:id) if user + where(id: accessible_ids) + end + def with_push includes(:events).where('events.action = ?', Event::PUSHED) end @@ -122,18 +176,35 @@ class Project < ActiveRecord::Base end def search query - joins(:namespace).where("projects.name LIKE :query OR projects.path LIKE :query OR namespaces.name LIKE :query", query: "%#{query}%") + joins(:namespace).where("projects.archived = ?", false).where("projects.name LIKE :query OR projects.path LIKE :query OR namespaces.name LIKE :query OR projects.description LIKE :query", query: "%#{query}%") + end + + def search_by_title query + where("projects.archived = ?", false).where("LOWER(projects.name) LIKE :query", query: "%#{query.downcase}%") end def find_with_namespace(id) - if id.include?("/") - id = id.split("/") - namespace = Namespace.find_by_path(id.first) - return nil unless namespace + return nil unless id.include?("/") - where(namespace_id: namespace.id).find_by_path(id.second) - else - where(path: id, namespace_id: nil).last + id = id.split("/") + namespace = Namespace.find_by(path: id.first) + return nil unless namespace + + where(namespace_id: namespace.id).find_by(path: id.second) + end + + def visibility_levels + Gitlab::VisibilityLevel.options + end + + def sort(method) + case method.to_s + when 'newest' then reorder('projects.created_at DESC') + when 'oldest' then reorder('projects.created_at ASC') + when 'recently_updated' then reorder('projects.updated_at DESC') + when 'last_updated' then reorder('projects.updated_at ASC') + when 'largest_repository' then reorder('projects.repository_size DESC') + else reorder("namespaces.path, projects.name ASC") end end end @@ -143,24 +214,40 @@ class Project < ActiveRecord::Base end def repository - @repository ||= Repository.new(path_with_namespace, default_branch) + @repository ||= Repository.new(path_with_namespace) end def saved? id && persisted? end + def add_import_job + RepositoryImportWorker.perform_in(2.seconds, id) + end + def import? import_url.present? end def imported? - imported + import_finished? + end + + def import_in_progress? + import? && import_status == 'started' + end + + def import_failed? + import_status == 'failed' + end + + def import_finished? + import_status == 'finished' end def check_limit unless creator.can_create_project? - errors[:limit_reached] << ("Your own projects limit is #{creator.projects_limit}! Please contact administrator to increase it") + errors[:limit_reached] << ("Your project limit is #{creator.projects_limit} projects! Please contact your administrator to increase it") end rescue errors[:base] << ("Can't check your ability to create project") @@ -174,6 +261,10 @@ class Project < ActiveRecord::Base [Gitlab.config.gitlab.url, path_with_namespace].join("/") end + def web_url_without_protocol + web_url.split("://")[1] + end + def build_commit_note(commit) notes.new(commit_id: commit.id, noteable_type: "Commit") end @@ -190,8 +281,11 @@ class Project < ActiveRecord::Base self.id end + # Tags are shared by issues and merge requests def issues_labels - @issues_labels ||= (issues_default_labels + issues.tags_on(:labels)).uniq.sort_by(&:name) + @issues_labels ||= (issues_default_labels + + merge_requests.tags_on(:labels) + + issues.tags_on(:labels)).uniq.sort_by(&:name) end def issue_exists?(issue_id) @@ -221,7 +315,7 @@ class Project < ActiveRecord::Base end def available_services_names - %w(gitlab_ci campfire hipchat pivotaltracker flowdock) + %w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium slack) end def gitlab_ci? @@ -243,9 +337,7 @@ class Project < ActiveRecord::Base end def send_move_instructions - team.members.each do |user| - Notify.delay.project_was_moved_email(self.id, user.id) - end + NotificationService.new.project_was_moved(self) end def owner @@ -263,7 +355,7 @@ class Project < ActiveRecord::Base # Get Team Member record by user id def team_member_by_id(user_id) - users_projects.find_by_user_id(user_id) + users_projects.find_by(user_id: user_id) end def name_with_namespace @@ -288,8 +380,10 @@ class Project < ActiveRecord::Base ProjectTransferService.new.transfer(self, new_namespace) end - def execute_hooks(data) - hooks.each { |hook| hook.async_execute(data) } + def execute_hooks(data, hooks_scope = :push_hooks) + hooks.send(hooks_scope).each do |hook| + hook.async_execute(data) + end end def execute_services(data) @@ -300,30 +394,21 @@ class Project < ActiveRecord::Base end end - def discover_default_branch - # Discover the default branch, but only if it hasn't already been set to - # something else - if repository.exists? && default_branch.nil? - update_attributes(default_branch: self.repository.discover_default_branch) - end - end - def update_merge_requests(oldrev, newrev, ref, user) return true unless ref =~ /heads/ branch_name = ref.gsub("refs/heads/", "") c_ids = self.repository.commits_between(oldrev, newrev).map(&:id) - # Update code for merge requests into project between project branches - mrs = self.merge_requests.opened.by_branch(branch_name).all - # Update code for merge requests between project and project fork - mrs += self.fork_merge_requests.opened.by_branch(branch_name).all - - mrs.each { |merge_request| merge_request.reload_code; merge_request.mark_as_unchecked } - # Close merge requests - mrs = self.merge_requests.opened.where(target_branch: branch_name).all + mrs = self.merge_requests.opened.where(target_branch: branch_name).to_a mrs = mrs.select(&:last_commit).select { |mr| c_ids.include?(mr.last_commit.id) } - mrs.each { |merge_request| merge_request.merge!(user.id) } + mrs.each { |merge_request| MergeRequests::MergeService.new.execute(merge_request, user, nil) } + + # Update code for merge requests into project between project branches + mrs = self.merge_requests.opened.by_branch(branch_name).to_a + # Update code for merge requests between project and project fork + mrs += self.fork_merge_requests.opened.by_branch(branch_name).to_a + mrs.each { |merge_request| merge_request.reload_code; merge_request.mark_as_unchecked } true end @@ -390,7 +475,7 @@ class Project < ActiveRecord::Base end def http_url_to_repo - http_url = [Gitlab.config.gitlab.url, "/", path_with_namespace, ".git"].join('') + [Gitlab.config.gitlab.url, "/", path_with_namespace, ".git"].join('') end # Check if current branch name is marked as protected in the system @@ -447,4 +532,42 @@ class Project < ActiveRecord::Base order('id DESC').limit(100). update_all(updated_at: Time.now) end + + def project_member(user) + users_projects.where(user_id: user).first + end + + def default_branch + @default_branch ||= repository.root_ref if repository.exists? + end + + def reload_default_branch + @default_branch = nil + default_branch + end + + def visibility_level_field + visibility_level + end + + def archive! + update_attribute(:archived, true) + end + + def unarchive! + update_attribute(:archived, false) + end + + def change_head(branch) + gitlab_shell.update_repository_head(self.path_with_namespace, branch) + reload_default_branch + end + + def forked_from?(project) + forked? && project == forked_from_project + end + + def update_repository_size + update_attribute(:repository_size, repository.size) + end end diff --git a/app/models/project_hook.rb b/app/models/project_hook.rb index 2576fc979d..6db6767a88 100644 --- a/app/models/project_hook.rb +++ b/app/models/project_hook.rb @@ -2,15 +2,26 @@ # # 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") -# service_id :integer +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# type :string(255) default("ProjectHook") +# service_id :integer +# push_events :boolean default(TRUE), not null +# issues_events :boolean default(FALSE), not null +# merge_requests_events :boolean default(FALSE), not null +# tag_push_events :boolean default(FALSE) # class ProjectHook < WebHook belongs_to :project + + attr_accessible :push_events, :issues_events, :merge_requests_events, :tag_push_events + + scope :push_hooks, -> { where(push_events: true) } + scope :tag_push_hooks, -> { where(tag_push_events: true) } + scope :issue_hooks, -> { where(issues_events: true) } + scope :merge_request_hooks, -> { where(merge_requests_events: true) } end diff --git a/app/models/project_services/assembla_service.rb b/app/models/project_services/assembla_service.rb new file mode 100644 index 0000000000..06e9d6118d --- /dev/null +++ b/app/models/project_services/assembla_service.rb @@ -0,0 +1,50 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# token :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# project_url :string(255) +# subdomain :string(255) +# room :string(255) +# recipients :text +# api_key :string(255) +# + +class AssemblaService < Service + attr_accessible :subdomain + + include HTTParty + + validates :token, presence: true, if: :activated? + + def title + 'Assembla' + end + + def description + 'Project Management Software (Source Commits Endpoint)' + end + + def to_param + 'assembla' + end + + def fields + [ + { type: 'text', name: 'token', placeholder: '' }, + { type: 'text', name: 'subdomain', placeholder: '' } + ] + end + + def execute(push) + url = "https://atlas.assembla.com/spaces/#{subdomain}/github_tool?secret_key=#{token}" + AssemblaService.post(url, body: { payload: push }.to_json, headers: { 'Content-Type' => 'application/json' }) + end +end diff --git a/app/models/campfire_service.rb b/app/models/project_services/campfire_service.rb similarity index 94% rename from app/models/campfire_service.rb rename to app/models/project_services/campfire_service.rb index fb2a49fd58..19030ecffa 100644 --- a/app/models/campfire_service.rb +++ b/app/models/project_services/campfire_service.rb @@ -7,12 +7,14 @@ # title :string(255) # token :string(255) # project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # active :boolean default(FALSE), not null # project_url :string(255) # subdomain :string(255) # room :string(255) +# recipients :text +# api_key :string(255) # class CampfireService < Service diff --git a/app/models/project_services/emails_on_push_service.rb b/app/models/project_services/emails_on_push_service.rb new file mode 100644 index 0000000000..04775c4f2b --- /dev/null +++ b/app/models/project_services/emails_on_push_service.rb @@ -0,0 +1,46 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# token :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# project_url :string(255) +# subdomain :string(255) +# room :string(255) +# recipients :text +# api_key :string(255) +# + +class EmailsOnPushService < Service + attr_accessible :recipients + + validates :recipients, presence: true, if: :activated? + + def title + 'Emails on push' + end + + def description + 'Email the commits and diff of each push to a list of recipients.' + end + + def to_param + 'emails_on_push' + end + + def execute(push_data) + EmailsOnPushWorker.perform_async(project_id, recipients, push_data) + end + + def fields + [ + { type: 'textarea', name: 'recipients', placeholder: 'Emails separated by whitespace' }, + ] + end +end diff --git a/app/models/flowdock_service.rb b/app/models/project_services/flowdock_service.rb similarity index 88% rename from app/models/flowdock_service.rb rename to app/models/project_services/flowdock_service.rb index 6ec431d4a1..6cdd04a864 100644 --- a/app/models/flowdock_service.rb +++ b/app/models/project_services/flowdock_service.rb @@ -7,10 +7,14 @@ # title :string(255) # token :string(255) # project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # active :boolean default(FALSE), not null # project_url :string(255) +# subdomain :string(255) +# room :string(255) +# recipients :text +# api_key :string(255) # require "flowdock-git-hook" diff --git a/app/models/project_services/gemnasium_service.rb b/app/models/project_services/gemnasium_service.rb new file mode 100644 index 0000000000..b363d7f57d --- /dev/null +++ b/app/models/project_services/gemnasium_service.rb @@ -0,0 +1,55 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# token :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# project_url :string(255) +# subdomain :string(255) +# room :string(255) +# recipients :text +# api_key :string(255) +# + +require "gemnasium/gitlab_service" + +class GemnasiumService < Service + validates :token, :api_key, presence: true, if: :activated? + + def title + 'Gemnasium' + end + + def description + 'Gemnasium monitors your project dependencies and alerts you about updates and security vulnerabilities.' + end + + def to_param + 'gemnasium' + end + + def fields + [ + { type: 'text', name: 'api_key', placeholder: 'Your personal API KEY on gemnasium.com ' }, + { type: 'text', name: 'token', placeholder: 'The project\'s slug on gemnasium.com' } + ] + end + + def execute(push_data) + repo_path = File.join(Gitlab.config.gitlab_shell.repos_path, "#{project.path_with_namespace}.git") + Gemnasium::GitlabService.execute( + ref: push_data[:ref], + before: push_data[:before], + after: push_data[:after], + token: token, + api_key: api_key, + repo: repo_path + ) + end +end diff --git a/app/models/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb similarity index 90% rename from app/models/gitlab_ci_service.rb rename to app/models/project_services/gitlab_ci_service.rb index 7f5380a455..ed1944f337 100644 --- a/app/models/gitlab_ci_service.rb +++ b/app/models/project_services/gitlab_ci_service.rb @@ -7,12 +7,14 @@ # title :string(255) # token :string(255) # project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # active :boolean default(FALSE), not null # project_url :string(255) # subdomain :string(255) # room :string(255) +# recipients :text +# api_key :string(255) # class GitlabCiService < Service @@ -36,7 +38,7 @@ class GitlabCiService < Service end def commit_status sha - response = HTTParty.get(commit_status_path(sha)) + response = HTTParty.get(commit_status_path(sha), verify: false) if response.code == 200 and response["status"] response["status"] diff --git a/app/models/hipchat_service.rb b/app/models/project_services/hipchat_service.rb similarity index 86% rename from app/models/hipchat_service.rb rename to app/models/project_services/hipchat_service.rb index 7fec5c4fbe..d62f61856d 100644 --- a/app/models/hipchat_service.rb +++ b/app/models/project_services/hipchat_service.rb @@ -7,12 +7,14 @@ # title :string(255) # token :string(255) # project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # active :boolean default(FALSE), not null # project_url :string(255) # subdomain :string(255) # room :string(255) +# recipients :text +# api_key :string(255) # class HipchatService < Service @@ -25,7 +27,7 @@ class HipchatService < Service end def description - 'Simple web-based real-time group chat' + 'Private group chat and IM' end def to_param @@ -40,7 +42,7 @@ class HipchatService < Service end def execute(push_data) - gate[room].send('Gitlab', create_message(push_data)) + gate[room].send('GitLab', create_message(push_data)) end private @@ -61,7 +63,7 @@ class HipchatService < Service elsif after =~ /000000/ message << "removed branch #{ref} from #{project.name_with_namespace.gsub!(/\s/,'')} \n" else - message << "#pushed to branch #{ref} " + message << "pushed to branch #{ref} " message << "of #{project.name_with_namespace.gsub!(/\s/,'')} " message << "(Compare changes)" for commit in push[:commits] do diff --git a/app/models/pivotaltracker_service.rb b/app/models/project_services/pivotaltracker_service.rb similarity index 92% rename from app/models/pivotaltracker_service.rb rename to app/models/project_services/pivotaltracker_service.rb index c5b1b9ab8d..aa2bcc5def 100644 --- a/app/models/pivotaltracker_service.rb +++ b/app/models/project_services/pivotaltracker_service.rb @@ -7,12 +7,14 @@ # title :string(255) # token :string(255) # project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # active :boolean default(FALSE), not null # project_url :string(255) # subdomain :string(255) # room :string(255) +# recipients :text +# api_key :string(255) # class PivotaltrackerService < Service diff --git a/app/models/project_services/slack_message.rb b/app/models/project_services/slack_message.rb new file mode 100644 index 0000000000..28204e5ea6 --- /dev/null +++ b/app/models/project_services/slack_message.rb @@ -0,0 +1,110 @@ +require 'slack-notifier' + +class SlackMessage + def initialize(params) + @after = params.fetch(:after) + @before = params.fetch(:before) + @commits = params.fetch(:commits, []) + @project_name = params.fetch(:project_name) + @project_url = params.fetch(:project_url) + @ref = params.fetch(:ref).gsub('refs/heads/', '') + @username = params.fetch(:user_name) + end + + def pretext + format(message) + end + + def attachments + return [] if new_branch? || removed_branch? + + commit_message_attachments + end + + private + + attr_reader :after + attr_reader :before + attr_reader :commits + attr_reader :project_name + attr_reader :project_url + attr_reader :ref + attr_reader :username + + def message + if new_branch? + new_branch_message + elsif removed_branch? + removed_branch_message + else + push_message + end + end + + def format(string) + Slack::Notifier::LinkFormatter.format(string) + end + + def new_branch_message + "#{username} pushed new branch #{branch_link} to #{project_link}" + end + + def removed_branch_message + "#{username} removed branch #{ref} from #{project_link}" + end + + def push_message + "#{username} pushed to branch #{branch_link} of #{project_link} (#{compare_link})" + end + + def commit_messages + commits.each_with_object('') do |commit, str| + str << compose_commit_message(commit) + end.chomp + end + + def commit_message_attachments + [{ text: format(commit_messages), color: attachment_color }] + end + + def compose_commit_message(commit) + author = commit.fetch(:author).fetch(:name) + id = commit.fetch(:id)[0..8] + message = commit.fetch(:message) + url = commit.fetch(:url) + + "[#{id}](#{url}): #{message} - #{author}\n" + end + + def new_branch? + before =~ /000000/ + end + + def removed_branch? + after =~ /000000/ + end + + def branch_url + "#{project_url}/commits/#{ref}" + end + + def compare_url + "#{project_url}/compare/#{before}...#{after}" + end + + def branch_link + "[#{ref}](#{branch_url})" + end + + def project_link + "[#{project_name}](#{project_url})" + end + + def compare_link + "[Compare changes](#{compare_url})" + end + + def attachment_color + '#345' + end +end diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb new file mode 100644 index 0000000000..50fd62def1 --- /dev/null +++ b/app/models/project_services/slack_service.rb @@ -0,0 +1,69 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# token :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# project_url :string(255) +# subdomain :string(255) +# room :string(255) +# recipients :text +# api_key :string(255) +# + +class SlackService < Service + attr_accessible :room + attr_accessible :subdomain + + validates :room, presence: true, if: :activated? + validates :subdomain, presence: true, if: :activated? + validates :token, presence: true, if: :activated? + + def title + 'Slack' + end + + def description + 'A team communication tool for the 21st century' + end + + def to_param + 'slack' + end + + def fields + [ + { type: 'text', name: 'subdomain', placeholder: '' }, + { type: 'text', name: 'token', placeholder: '' }, + { type: 'text', name: 'room', placeholder: 'Ex. #general' }, + ] + end + + def execute(push_data) + message = SlackMessage.new(push_data.merge( + project_url: project_url, + project_name: project_name + )) + + notifier = Slack::Notifier.new(subdomain, token) + notifier.channel = room + notifier.username = 'GitLab' + notifier.ping(message.pretext, attachments: message.attachments) + end + + private + + def project_name + project.name_with_namespace.gsub(/\s/, '') + end + + def project_url + project.web_url + end +end diff --git a/app/models/project_snippet.rb b/app/models/project_snippet.rb index f38aa07059..14c8804642 100644 --- a/app/models/project_snippet.rb +++ b/app/models/project_snippet.rb @@ -4,11 +4,11 @@ # # id :integer not null, primary key # title :string(255) -# content :text(2147483647) +# content :text # author_id :integer not null # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # file_name :string(255) # expires_at :datetime # private :boolean default(TRUE), not null diff --git a/app/models/project_team.rb b/app/models/project_team.rb index bc35c4041b..eca13e5606 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -22,22 +22,22 @@ class ProjectTeam end def find(user_id) - user = project.users.find_by_id(user_id) + user = project.users.find_by(id: user_id) if group - user ||= group.users.find_by_id(user_id) + user ||= group.users.find_by(id: user_id) end user end def find_tm(user_id) - tm = project.users_projects.find_by_user_id(user_id) + tm = project.users_projects.find_by(user_id: user_id) # If user is not in project members # we should check for group membership if group && !tm - tm = group.users_groups.find_by_user_id(user_id) + tm = group.users_groups.find_by(user_id: user_id) end tm @@ -64,6 +64,10 @@ class ProjectTeam UsersProject.truncate_team(project) end + def users + members + end + def members @members ||= fetch_members end @@ -87,9 +91,8 @@ class ProjectTeam def import(source_project) target_project = project - source_team = source_project.users_projects.all - target_team = target_project.users_projects.all - target_user_ids = target_team.map(&:user_id) + source_team = source_project.users_projects.to_a + target_user_ids = target_project.users_projects.pluck(:user_id) source_team.reject! do |tm| # Skip if user already present in team diff --git a/app/models/gollum_wiki.rb b/app/models/project_wiki.rb similarity index 85% rename from app/models/gollum_wiki.rb rename to app/models/project_wiki.rb index 05fc2a745b..08a5278247 100644 --- a/app/models/gollum_wiki.rb +++ b/app/models/project_wiki.rb @@ -1,4 +1,5 @@ -class GollumWiki +class ProjectWiki + include Gitlab::ShellAdapter MARKUPS = { "Markdown" => :markdown, @@ -33,14 +34,14 @@ class GollumWiki end def http_url_to_repo - http_url = [Gitlab.config.gitlab.url, "/", path_with_namespace, ".git"].join('') + [Gitlab.config.gitlab.url, "/", path_with_namespace, ".git"].join('') end # Returns the Gollum::Wiki object. def wiki @wiki ||= begin Gollum::Wiki.new(path_to_repo) - rescue Grit::NoSuchPathError + rescue Gollum::NoSuchPathError create_repo! end end @@ -63,7 +64,8 @@ class GollumWiki # # Returns an initialized WikiPage instance or nil def find_page(title, version = nil) - if page = wiki.page(title, version) + page_title, page_dir = page_title_and_dir(title) + if page = wiki.page(page_title, version, page_dir) WikiPage.new(self, page, true) else nil @@ -89,6 +91,12 @@ class GollumWiki wiki.delete_page(page, commit_details(:deleted, message, page.title)) end + def page_title_and_dir(title) + title_array = title.split("/") + title = title_array.pop + [title.gsub(/\.[^.]*$/, ""), title_array.join("/")] + end + private def create_repo! @@ -113,10 +121,6 @@ class GollumWiki "#{@user.username} #{action} page: #{title}" end - def gitlab_shell - @gitlab_shell ||= Gitlab::Shell.new - end - def path_to_repo @path_to_repo ||= File.join(Gitlab.config.gitlab_shell.repos_path, "#{path_with_namespace}.git") end diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index 16379720e5..d2b2b1218d 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -5,8 +5,8 @@ # 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 +# created_at :datetime +# updated_at :datetime # class ProtectedBranch < ActiveRecord::Base diff --git a/app/models/repository.rb b/app/models/repository.rb index 97b4330092..eadc34127c 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -3,7 +3,7 @@ class Repository attr_accessor :raw_repository, :path_with_namespace - def initialize(path_with_namespace, default_branch) + def initialize(path_with_namespace, default_branch = nil) @path_with_namespace = path_with_namespace @raw_repository = Gitlab::Git::Repository.new(path_to_repo) if path_with_namespace rescue Gitlab::Git::Repository::NoRepository @@ -57,7 +57,7 @@ class Repository def recent_branches(limit = 20) branches.sort do |a, b| - a.commit.committed_date <=> b.commit.committed_date + commit(b.target).committed_date <=> commit(a.target).committed_date end[0..limit] end @@ -133,6 +133,8 @@ class Repository Rails.cache.delete(cache_key(:tag_names)) Rails.cache.delete(cache_key(:commit_count)) Rails.cache.delete(cache_key(:graph_log)) + Rails.cache.delete(cache_key(:readme)) + Rails.cache.delete(cache_key(:contribution_guide)) end def graph_log @@ -159,4 +161,63 @@ class Repository def blob_at(sha, path) Gitlab::Git::Blob.find(self, sha, path) end + + def readme + Rails.cache.fetch(cache_key(:readme)) do + tree(:head).readme + end + end + + def contribution_guide + Rails.cache.fetch(cache_key(:contribution_guide)) do + tree(:head).contribution_guide + end + end + + def head_commit + commit(self.root_ref) + end + + def tree(sha = :head, path = nil) + if sha == :head + sha = head_commit.sha + end + + Tree.new(self, sha, path) + end + + def blob_at_branch(branch_name, path) + last_commit = commit(branch_name) + + if last_commit + blob_at(last_commit.sha, path) + else + nil + end + end + + # Returns url for submodule + # + # Ex. + # @repository.submodule_url_for('master', 'rack') + # # => git@localhost:rack.git + # + def submodule_url_for(ref, path) + if submodules(ref).any? + submodule = submodules(ref)[path] + + if submodule + submodule['url'] + end + end + end + + def last_commit_for_path(sha, path) + commits(sha, path, 1).last + end + + # Remove archives older than 2 hours + def clean_old_archives + Gitlab::Popen.popen(%W(find #{Gitlab.config.gitlab.repository_downloads_path} -mmin +120 -delete)) + end end diff --git a/app/models/service.rb b/app/models/service.rb index 540aaad1ce..ea00039521 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -7,18 +7,22 @@ # title :string(255) # token :string(255) # project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # active :boolean default(FALSE), not null # project_url :string(255) # subdomain :string(255) # room :string(255) +# recipients :text +# api_key :string(255) # # To add new service you should build a class inherited from Service # and implement a set of methods class Service < ActiveRecord::Base - attr_accessible :title, :token, :type, :active + default_value_for :active, false + + attr_accessible :title, :token, :type, :active, :api_key belongs_to :project has_one :service_hook diff --git a/app/models/service_hook.rb b/app/models/service_hook.rb index 4cd2b272ee..2e11239c40 100644 --- a/app/models/service_hook.rb +++ b/app/models/service_hook.rb @@ -2,13 +2,17 @@ # # 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") -# service_id :integer +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# type :string(255) default("ProjectHook") +# service_id :integer +# push_events :boolean default(TRUE), not null +# issues_events :boolean default(FALSE), not null +# merge_requests_events :boolean default(FALSE), not null +# tag_push_events :boolean default(FALSE) # class ServiceHook < WebHook diff --git a/app/models/snippet.rb b/app/models/snippet.rb index edc179b20f..720accd73d 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -4,11 +4,11 @@ # # id :integer not null, primary key # title :string(255) -# content :text(2147483647) +# content :text # author_id :integer not null # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # file_name :string(255) # expires_at :datetime # private :boolean default(TRUE), not null @@ -20,6 +20,8 @@ class Snippet < ActiveRecord::Base attr_accessible :title, :content, :file_name, :expires_at, :private + default_value_for :private, true + belongs_to :author, class_name: "User" has_many :notes, as: :noteable, dependent: :destroy diff --git a/app/models/system_hook.rb b/app/models/system_hook.rb index 5cdf046644..ee32b49bc6 100644 --- a/app/models/system_hook.rb +++ b/app/models/system_hook.rb @@ -2,13 +2,17 @@ # # 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") -# service_id :integer +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# type :string(255) default("ProjectHook") +# service_id :integer +# push_events :boolean default(TRUE), not null +# issues_events :boolean default(FALSE), not null +# merge_requests_events :boolean default(FALSE), not null +# tag_push_events :boolean default(FALSE) # class SystemHook < WebHook diff --git a/app/models/tree.rb b/app/models/tree.rb index ed06cb1a12..ac2183be44 100644 --- a/app/models/tree.rb +++ b/app/models/tree.rb @@ -1,5 +1,5 @@ class Tree - attr_accessor :entries, :readme + attr_accessor :entries, :readme, :contribution_guide def initialize(repository, sha, path = '/') path = '/' if path.blank? @@ -10,6 +10,11 @@ class Tree readme_path = path == '/' ? readme_tree.name : File.join(path, readme_tree.name) @readme = Gitlab::Git::Blob.find(git_repo, sha, readme_path) end + + if contribution_tree = @entries.find(&:contributing?) + contribution_path = path == '/' ? contribution_tree.name : File.join(path, contribution_tree.name) + @contribution_guide = Gitlab::Git::Blob.find(git_repo, sha, contribution_path) + end end def trees @@ -23,4 +28,8 @@ class Tree def submodules @entries.select(&:submodule?) end + + def sorted_entries + trees + blobs + submodules + end end diff --git a/app/models/user.rb b/app/models/user.rb index df14cf34e8..16961e5413 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,52 +2,65 @@ # # Table name: users # -# id :integer not null, primary key -# email :string(255) default(""), not null -# encrypted_password :string(255) 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) -# theme_id :integer default(1), not null -# bio :string(255) -# failed_attempts :integer default(0) -# locked_at :datetime -# extern_uid :string(255) -# provider :string(255) -# username :string(255) -# can_create_group :boolean default(TRUE), not null -# can_create_team :boolean default(TRUE), not null -# state :string(255) -# color_scheme_id :integer default(1), not null -# notification_level :integer default(1), not null -# password_expires_at :datetime -# created_by_id :integer +# id :integer not null, primary key +# email :string(255) default(""), not null +# encrypted_password :string(255) 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 +# updated_at :datetime +# 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) +# theme_id :integer default(1), not null +# bio :string(255) +# failed_attempts :integer default(0) +# locked_at :datetime +# extern_uid :string(255) +# provider :string(255) +# username :string(255) +# can_create_group :boolean default(TRUE), not null +# can_create_team :boolean default(TRUE), not null +# state :string(255) +# color_scheme_id :integer default(1), not null +# notification_level :integer default(1), not null +# password_expires_at :datetime +# created_by_id :integer +# last_credential_check_at :datetime +# avatar :string(255) +# confirmation_token :string(255) +# confirmed_at :datetime +# confirmation_sent_at :datetime +# unconfirmed_email :string(255) +# hide_no_ssh_key :boolean default(FALSE) +# website_url :string(255) default(""), not null # require 'carrierwave/orm/activerecord' require 'file_size_validator' class User < ActiveRecord::Base + default_value_for :admin, false + default_value_for :can_create_group, true + default_value_for :can_create_team, false + default_value_for :hide_no_ssh_key, false + devise :database_authenticatable, :token_authenticatable, :lockable, :async, :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :confirmable, :registerable attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :username, - :skype, :linkedin, :twitter, :color_scheme_id, :theme_id, :force_random_password, - :extern_uid, :provider, :password_expires_at, :avatar, + :skype, :linkedin, :twitter, :website_url, :color_scheme_id, :theme_id, :force_random_password, + :extern_uid, :provider, :password_expires_at, :avatar, :hide_no_ssh_key, as: [:default, :admin] attr_accessible :projects_limit, :can_create_group, @@ -67,55 +80,50 @@ class User < ActiveRecord::Base # # Namespace for personal projects - has_one :namespace, dependent: :destroy, foreign_key: :owner_id, class_name: "Namespace", conditions: 'type IS NULL' - - # Namespaces (owned groups and own namespace) - has_many :namespaces, foreign_key: :owner_id + has_one :namespace, -> { where type: nil }, dependent: :destroy, foreign_key: :owner_id, class_name: "Namespace" # Profile has_many :keys, dependent: :destroy + has_many :emails, dependent: :destroy # Groups - has_many :own_groups, class_name: "Group", foreign_key: :owner_id - has_many :owned_groups, through: :users_groups, source: :group, conditions: { users_groups: { group_access: UsersGroup::OWNER } } - has_many :users_groups, dependent: :destroy has_many :groups, through: :users_groups - + has_many :owned_groups, -> { where users_groups: { group_access: UsersGroup::OWNER } }, through: :users_groups, source: :group # Projects + has_many :groups_projects, through: :groups, source: :projects + has_many :personal_projects, through: :namespace, source: :projects + has_many :projects, through: :users_projects + has_many :created_projects, foreign_key: :creator_id, class_name: 'Project' + has_many :snippets, dependent: :destroy, foreign_key: :author_id, class_name: "Snippet" has_many :users_projects, dependent: :destroy has_many :issues, dependent: :destroy, foreign_key: :author_id has_many :notes, dependent: :destroy, foreign_key: :author_id has_many :merge_requests, dependent: :destroy, foreign_key: :author_id has_many :events, dependent: :destroy, foreign_key: :author_id, class_name: "Event" - has_many :recent_events, foreign_key: :author_id, class_name: "Event", order: "id DESC" + has_many :recent_events, -> { order "id DESC" }, foreign_key: :author_id, class_name: "Event" has_many :assigned_issues, dependent: :destroy, foreign_key: :assignee_id, class_name: "Issue" has_many :assigned_merge_requests, dependent: :destroy, foreign_key: :assignee_id, class_name: "MergeRequest" - has_many :groups_projects, through: :groups, source: :projects - has_many :personal_projects, through: :namespace, source: :projects - has_many :projects, through: :users_projects - has_many :own_projects, foreign_key: :creator_id, class_name: 'Project' - has_many :owned_projects, through: :namespaces, source: :projects # # Validations # validates :name, presence: true - validates :email, presence: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/ } - validates :bio, length: { within: 0..255 } + validates :email, presence: true, email: {strict_mode: true}, uniqueness: true + validates :bio, length: { maximum: 255 }, allow_blank: true validates :extern_uid, allow_blank: true, uniqueness: {scope: :provider} validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0} - validates :username, presence: true, uniqueness: true, + validates :username, presence: true, uniqueness: { case_sensitive: false }, exclusion: { in: Gitlab::Blacklist.path }, format: { with: Gitlab::Regex.username_regex, message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } validates :notification_level, inclusion: { in: Notification.notification_levels }, presence: true - validate :namespace_uniq, if: ->(user) { user.username_changed? } - + validate :avatar_type, if: ->(user) { user.avatar_changed? } + validate :unique_email, if: ->(user) { user.email_changed? } validates :avatar, file_size: { maximum: 100.kilobytes.to_i } before_validation :generate_password, on: :create @@ -164,7 +172,7 @@ class User < ActiveRecord::Base scope :alphabetically, -> { order('name ASC') } scope :in_team, ->(team){ where(id: team.member_ids) } scope :not_in_team, ->(team){ where('users.id NOT IN (:ids)', ids: team.member_ids) } - scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : scoped } + scope :not_in_project, ->(project) { project.users.present? ? where("id not in (:ids)", ids: project.users.map(&:id) ) : all } scope :without_projects, -> { where('id NOT IN (SELECT DISTINCT(user_id) FROM users_projects)') } scope :ldap, -> { where(provider: 'ldap') } @@ -184,6 +192,13 @@ class User < ActiveRecord::Base end end + def find_for_commit(email, name) + # Prefer email match over name match + User.where(email: email).first || + User.joins(:emails).where(emails: { email: email }).first || + User.where(name: name).first + end + def filter filter_name case filter_name when "admins"; self.admins @@ -195,11 +210,11 @@ class User < ActiveRecord::Base end def search query - where("name LIKE :query OR email LIKE :query OR username LIKE :query", query: "%#{query}%") + where("lower(name) LIKE :query OR lower(email) LIKE :query OR lower(username) LIKE :query", query: "%#{query.downcase}%") end def by_username_or_id(name_or_id) - where('username = ? OR id = ?', name_or_id, name_or_id).first + where('users.username = ? OR users.id = ?', name_or_id.to_s, name_or_id.to_i).first end def build_user(attrs = {}, options= {}) @@ -239,15 +254,25 @@ class User < ActiveRecord::Base def namespace_uniq namespace_name = self.username - if Namespace.find_by_path(namespace_name) - self.errors.add :username, "already exist" + if Namespace.find_by(path: namespace_name) + self.errors.add :username, "already exists" end end + def avatar_type + unless self.avatar.image? + self.errors.add :avatar, "only images allowed" + end + end + + def unique_email + self.errors.add(:email, 'has already been taken') if Email.exists?(email: self.email) + end + # Groups user has access to def authorized_groups @authorized_groups ||= begin - group_ids = (groups.pluck(:id) + own_groups.pluck(:id) + authorized_projects.pluck(:namespace_id)) + group_ids = (groups.pluck(:id) + authorized_projects.pluck(:namespace_id)) Group.where(id: group_ids).order('namespaces.name ASC') end end @@ -256,11 +281,19 @@ class User < ActiveRecord::Base # Projects user has access to def authorized_projects @authorized_projects ||= begin - project_ids = (owned_projects.pluck(:id) + groups_projects.pluck(:id) + projects.pluck(:id)).uniq + project_ids = personal_projects.pluck(:id) + project_ids += groups_projects.pluck(:id) + project_ids += projects.pluck(:id).uniq Project.where(id: project_ids).joins(:namespace).order('namespaces.name ASC') end end + def owned_projects + @owned_projects ||= begin + Project.where(namespace_id: owned_groups.pluck(:id).push(namespace.id)).joins(:namespace) + end + end + # Team membership in authorized projects def tm_in_authorized_projects UsersProject.where(project_id: authorized_projects.map(&:id), user_id: self.id) @@ -333,7 +366,7 @@ class User < ActiveRecord::Base end def several_namespaces? - namespaces.many? || owned_groups.any? + owned_groups.any? end def namespace_id @@ -367,11 +400,11 @@ class User < ActiveRecord::Base end def accessible_deploy_keys - DeployKey.in_projects(self.authorized_projects).uniq + DeployKey.in_projects(self.authorized_projects.pluck(:id)).uniq end def created_by - User.find_by_id(created_by_id) if created_by_id + User.find_by(id: created_by_id) if created_by_id end def sanitize_attrs @@ -381,6 +414,14 @@ class User < ActiveRecord::Base end end + def requires_ldap_check? + if ldap_user? + !last_credential_check_at || (last_credential_check_at + 1.hour) < Time.now + else + false + end + end + def solo_owned_groups @solo_owned_groups ||= owned_groups.select do |group| group.owners == [self] @@ -394,4 +435,45 @@ class User < ActiveRecord::Base self end + + def can_leave_project?(project) + project.namespace != namespace && + project.project_member(self) + end + + # Reset project events cache related to this user + # + # Since we do cache @event we need to reset cache in special cases: + # * when the user changes their avatar + # Events cache stored like events/23-20130109142513. + # The cache key includes updated_at timestamp. + # Thus it will automatically generate a new fragment + # when the event is updated because the key changes. + def reset_events_cache + Event.where(author_id: self.id). + order('id DESC').limit(1000). + update_all(updated_at: Time.now) + end + + def full_website_url + return "http://#{website_url}" if website_url !~ /^https?:\/\// + + website_url + end + + def short_website_url + website_url.gsub(/https?:\/\//, '') + end + + def all_ssh_keys + keys.map(&:key) + end + + def temp_oauth_email? + email =~ /\Atemp-email-for-oauth/ + end + + def generate_tmp_oauth_email + self.email = "temp-email-for-oauth-#{username}@gitlab.localhost" + end end diff --git a/app/models/users_group.rb b/app/models/users_group.rb index 181bf32228..5f8b832d51 100644 --- a/app/models/users_group.rb +++ b/app/models/users_group.rb @@ -6,8 +6,8 @@ # group_access :integer not null # group_id :integer not null # user_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # notification_level :integer default(3), not null # diff --git a/app/models/users_project.rb b/app/models/users_project.rb index 6f147859a5..e8810f56de 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -5,8 +5,8 @@ # 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 +# created_at :datetime +# updated_at :datetime # project_access :integer default(0), not null # notification_level :integer default(3), not null # diff --git a/app/models/web_hook.rb b/app/models/web_hook.rb index 3f22b1082f..76854da5c3 100644 --- a/app/models/web_hook.rb +++ b/app/models/web_hook.rb @@ -2,18 +2,26 @@ # # 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") -# service_id :integer +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# type :string(255) default("ProjectHook") +# service_id :integer +# push_events :boolean default(TRUE), not null +# issues_events :boolean default(FALSE), not null +# merge_requests_events :boolean default(FALSE), not null +# tag_push_events :boolean default(FALSE) # class WebHook < ActiveRecord::Base include HTTParty + default_value_for :push_events, true + default_value_for :issues_events, false + default_value_for :merge_requests_events, false + attr_accessible :url # HTTParty timeout @@ -25,7 +33,7 @@ class WebHook < ActiveRecord::Base 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" }) + WebHook.post(url, body: data.to_json, headers: { "Content-Type" => "application/json" }, verify: false) else post_url = url.gsub("#{parsed_url.userinfo}@", "") auth = { @@ -35,6 +43,7 @@ class WebHook < ActiveRecord::Base WebHook.post(post_url, body: data.to_json, headers: {"Content-Type" => "application/json"}, + verify: false, basic_auth: auth) end end diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index a7e6fea5ad..b8a0a9eb58 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -19,7 +19,7 @@ class WikiPage validates :title, presence: true validates :content, presence: true - # The Gitlab GollumWiki instance. + # The Gitlab ProjectWiki instance. attr_reader :wiki # The raw Gollum::Page instance. @@ -47,7 +47,11 @@ class WikiPage # The formatted title of this page. def title - @attributes[:title] || "" + if @attributes[:title] + @attributes[:title].gsub(/-+/, ' ') + else + "" + end end # Sets the title of this page. @@ -57,12 +61,16 @@ class WikiPage # The raw content of this page. def content - @attributes[:content] + @attributes[:content] ||= if @page + @page.raw_data + end end # The processed/formatted content of this page. def formatted_content - @attributes[:formatted_content] + @attributes[:formatted_content] ||= if @page + @page.formatted_data + end end # The markup format for the page. @@ -118,7 +126,7 @@ class WikiPage # :content - The raw markup content. # :format - Optional symbol representing the # content format. Can be any type - # listed in the GollumWiki::MARKUPS + # listed in the ProjectWiki::MARKUPS # Hash. # :message - Optional commit message to set on # the new page. @@ -135,7 +143,7 @@ class WikiPage # # new_content - The raw markup content to replace the existing. # format - Optional symbol representing the content format. - # See GollumWiki::MARKUPS Hash for available formats. + # See ProjectWiki::MARKUPS Hash for available formats. # message - Optional commit message to set on the new version. # # Returns the String SHA1 of the newly created page @@ -163,23 +171,30 @@ class WikiPage def set_attributes attributes[:slug] = @page.escaped_url_path attributes[:title] = @page.title - attributes[:content] = @page.raw_data - attributes[:formatted_content] = @page.formatted_data attributes[:format] = @page.format end def save(method, *args) - if valid? && wiki.send(method, *args) - @page = wiki.wiki.paged(title) + project_wiki = wiki + if valid? && project_wiki.send(method, *args) + + page_details = if method == :update_page + @page.path + else + title + end + + page_title, page_dir = project_wiki.page_title_and_dir(page_details) + gollum_wiki = project_wiki.wiki + @page = gollum_wiki.paged(page_title, page_dir) set_attributes @persisted = true else - errors.add(:base, wiki.error_message) if wiki.error_message + errors.add(:base, project_wiki.error_message) if project_wiki.error_message @persisted = false end @persisted end - end diff --git a/app/observers/activity_observer.rb b/app/observers/activity_observer.rb deleted file mode 100644 index d754ac8185..0000000000 --- a/app/observers/activity_observer.rb +++ /dev/null @@ -1,39 +0,0 @@ -class ActivityObserver < BaseObserver - observe :issue, :note, :milestone - - def after_create(record) - event_author_id = record.author_id - - if record.kind_of?(Note) - # Skip system notes, like status changes and cross-references. - return true if record.system? - - # Skip wall notes to prevent spamming of dashboard - return true if record.noteable_type.blank? - end - - if event_author_id - create_event(record, Event.determine_action(record)) - end - end - - def after_close(record, transition) - create_event(record, Event::CLOSED) - end - - def after_reopen(record, transition) - create_event(record, Event::REOPENED) - end - - protected - - def create_event(record, status) - Event.create( - project: record.project, - target_id: record.id, - target_type: record.class.name, - action: status, - author_id: current_user.id - ) - end -end diff --git a/app/observers/base_observer.rb b/app/observers/base_observer.rb index f9a0242ce7..d685bd5d81 100644 --- a/app/observers/base_observer.rb +++ b/app/observers/base_observer.rb @@ -3,6 +3,10 @@ class BaseObserver < ActiveRecord::Observer NotificationService.new end + def event_service + EventCreateService.new + end + def log_info message Gitlab::AppLogger.info message end diff --git a/app/observers/issue_observer.rb b/app/observers/issue_observer.rb deleted file mode 100644 index 886d8b776f..0000000000 --- a/app/observers/issue_observer.rb +++ /dev/null @@ -1,32 +0,0 @@ -class IssueObserver < BaseObserver - def after_create(issue) - notification.new_issue(issue, current_user) - - issue.create_cross_references!(issue.project, current_user) - end - - def after_close(issue, transition) - notification.close_issue(issue, current_user) - - create_note(issue) - end - - def after_reopen(issue, transition) - create_note(issue) - end - - def after_update(issue) - if issue.is_being_reassigned? - notification.reassigned_issue(issue, current_user) - end - - issue.notice_added_references(issue.project, current_user) - end - - protected - - # Create issue note with service comment like 'Status changed to closed' - def create_note(issue) - Note.create_status_change_note(issue, issue.project, current_user, issue.state, current_commit) - end -end diff --git a/app/observers/key_observer.rb b/app/observers/key_observer.rb deleted file mode 100644 index c013594e78..0000000000 --- a/app/observers/key_observer.rb +++ /dev/null @@ -1,19 +0,0 @@ -class KeyObserver < BaseObserver - def after_create(key) - GitlabShellWorker.perform_async( - :add_key, - key.shell_id, - key.key - ) - - notification.new_key(key) - end - - def after_destroy(key) - GitlabShellWorker.perform_async( - :remove_key, - key.shell_id, - key.key, - ) - end -end diff --git a/app/observers/merge_request_observer.rb b/app/observers/merge_request_observer.rb deleted file mode 100644 index d70da514cd..0000000000 --- a/app/observers/merge_request_observer.rb +++ /dev/null @@ -1,56 +0,0 @@ -class MergeRequestObserver < ActivityObserver - observe :merge_request - - def after_create(merge_request) - if merge_request.author_id - create_event(merge_request, Event.determine_action(merge_request)) - end - - notification.new_merge_request(merge_request, current_user) - - merge_request.create_cross_references!(merge_request.project, current_user) - end - - def after_close(merge_request, transition) - create_event(merge_request, Event::CLOSED) - Note.create_status_change_note(merge_request, merge_request.target_project, current_user, merge_request.state, nil) - - notification.close_mr(merge_request, current_user) - end - - def after_merge(merge_request, transition) - notification.merge_mr(merge_request) - # Since MR can be merged via sidekiq - # to prevent event duplication do this check - return true if merge_request.merge_event - - Event.create( - project: merge_request.target_project, - target_id: merge_request.id, - target_type: merge_request.class.name, - action: Event::MERGED, - author_id: merge_request.author_id_of_changes - ) - end - - def after_reopen(merge_request, transition) - create_event(merge_request, Event::REOPENED) - Note.create_status_change_note(merge_request, merge_request.target_project, current_user, merge_request.state, nil) - end - - def after_update(merge_request) - notification.reassigned_merge_request(merge_request, current_user) if merge_request.is_being_reassigned? - - merge_request.notice_added_references(merge_request.project, current_user) - end - - def create_event(record, status) - Event.create( - project: record.target_project, - target_id: record.id, - target_type: record.class.name, - action: status, - author_id: current_user.id - ) - end -end diff --git a/app/observers/milestone_observer.rb b/app/observers/milestone_observer.rb new file mode 100644 index 0000000000..a1a62a99a8 --- /dev/null +++ b/app/observers/milestone_observer.rb @@ -0,0 +1,13 @@ +class MilestoneObserver < BaseObserver + def after_create(milestone) + event_service.open_milestone(milestone, current_user) + end + + def after_close(milestone, transition) + event_service.close_milestone(milestone, current_user) + end + + def after_reopen(milestone, transition) + event_service.reopen_milestone(milestone, current_user) + end +end diff --git a/app/observers/note_observer.rb b/app/observers/note_observer.rb index d31b6e8d7c..337bb1dc5a 100644 --- a/app/observers/note_observer.rb +++ b/app/observers/note_observer.rb @@ -2,6 +2,12 @@ class NoteObserver < BaseObserver def after_create(note) notification.new_note(note) + # Skip system notes, like status changes and cross-references. + # Skip wall notes to prevent spamming of dashboard + if note.noteable_type.present? && !note.system + event_service.leave_note(note, current_user) + end + unless note.system? # Create a cross-reference note if this Note contains GFM that names an # issue, merge request, or commit. diff --git a/app/observers/project_observer.rb b/app/observers/project_observer.rb index f301f30645..ad41ddad58 100644 --- a/app/observers/project_observer.rb +++ b/app/observers/project_observer.rb @@ -1,41 +1,11 @@ class ProjectObserver < BaseObserver def after_create(project) - project.update_column(:last_activity_at, project.created_at) - - return true if project.forked? - - if project.import? - RepositoryImportWorker.perform_in(5.seconds, project.id) - else - GitlabShellWorker.perform_async( - :add_repository, - project.path_with_namespace - ) - - log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"") - end - - if project.wiki_enabled? - begin - # force the creation of a wiki, - GollumWiki.new(project, project.owner).wiki - rescue GollumWiki::CouldNotCreateWikiError => ex - # Prevent project observer crash - # if failed to create wiki - nil - end - end + log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"") end def after_update(project) project.send_move_instructions if project.namespace_id_changed? project.rename_repo if project.path_changed? - - GitlabShellWorker.perform_async( - :update_repository_head, - project.path_with_namespace, - project.default_branch - ) if project.default_branch_changed? end def before_destroy(project) diff --git a/app/observers/system_hook_observer.rb b/app/observers/system_hook_observer.rb index 3a649fd590..80de177b9a 100644 --- a/app/observers/system_hook_observer.rb +++ b/app/observers/system_hook_observer.rb @@ -2,10 +2,16 @@ class SystemHookObserver < BaseObserver observe :user, :project, :users_project def after_create(model) - SystemHooksService.execute_hooks_for(model, :create) + system_hook_service.execute_hooks_for(model, :create) end def after_destroy(model) - SystemHooksService.execute_hooks_for(model, :destroy) + system_hook_service.execute_hooks_for(model, :destroy) + end + + private + + def system_hook_service + SystemHooksService.new end end diff --git a/app/observers/users_group_observer.rb b/app/observers/users_group_observer.rb index ecdbede89d..42a05b5e17 100644 --- a/app/observers/users_group_observer.rb +++ b/app/observers/users_group_observer.rb @@ -4,6 +4,6 @@ class UsersGroupObserver < BaseObserver end def after_update(membership) - notification.update_group_member(membership) + notification.update_group_member(membership) if membership.group_access_changed? end end diff --git a/app/observers/users_project_observer.rb b/app/observers/users_project_observer.rb index ca9649c76a..44c72b3018 100644 --- a/app/observers/users_project_observer.rb +++ b/app/observers/users_project_observer.rb @@ -1,8 +1,4 @@ class UsersProjectObserver < BaseObserver - def after_commit(users_project) - return if users_project.destroyed? - end - def after_create(users_project) Event.create( project_id: users_project.project.id, @@ -14,7 +10,7 @@ class UsersProjectObserver < BaseObserver end def after_update(users_project) - notification.update_team_member(users_project) + notification.update_team_member(users_project) if users_project.project_access_changed? end def after_destroy(users_project) diff --git a/app/contexts/base_context.rb b/app/services/base_service.rb similarity index 69% rename from app/contexts/base_context.rb rename to app/services/base_service.rb index 101be50d54..9ad8092315 100644 --- a/app/contexts/base_context.rb +++ b/app/services/base_service.rb @@ -1,4 +1,4 @@ -class BaseContext +class BaseService attr_accessor :project, :current_user, :params def initialize(project, user, params) @@ -16,5 +16,16 @@ class BaseContext def can?(object, action, subject) abilities.allowed?(object, action, subject) end -end + def notification_service + NotificationService.new + end + + def event_service + EventCreateService.new + end + + def log_info message + Gitlab::AppLogger.info message + end +end diff --git a/app/services/create_branch_service.rb b/app/services/create_branch_service.rb new file mode 100644 index 0000000000..98beeee835 --- /dev/null +++ b/app/services/create_branch_service.rb @@ -0,0 +1,13 @@ +class CreateBranchService + def execute(project, branch_name, ref, current_user) + repository = project.repository + repository.add_branch(branch_name, ref) + new_branch = repository.find_branch(branch_name) + + if new_branch + Event.create_ref_event(project, current_user, new_branch, 'add') + end + + new_branch + end +end diff --git a/app/services/event_create_service.rb b/app/services/event_create_service.rb new file mode 100644 index 0000000000..8d8a5873e6 --- /dev/null +++ b/app/services/event_create_service.rb @@ -0,0 +1,64 @@ +# EventCreateService class +# +# Used for creating events feed on dashboard after certain user action +# +# Ex. +# EventCreateService.new.new_issue(issue, current_user) +# +class EventCreateService + def open_issue(issue, current_user) + create_event(issue, current_user, Event::CREATED) + end + + def close_issue(issue, current_user) + create_event(issue, current_user, Event::CLOSED) + end + + def reopen_issue(issue, current_user) + create_event(issue, current_user, Event::REOPENED) + end + + def open_mr(merge_request, current_user) + create_event(merge_request, current_user, Event::CREATED) + end + + def close_mr(merge_request, current_user) + create_event(merge_request, current_user, Event::CLOSED) + end + + def reopen_mr(merge_request, current_user) + create_event(merge_request, current_user, Event::REOPENED) + end + + def merge_mr(merge_request, current_user) + create_event(merge_request, current_user, Event::MERGED) + end + + def open_milestone(milestone, current_user) + create_event(milestone, current_user, Event::CREATED) + end + + def close_milestone(milestone, current_user) + create_event(milestone, current_user, Event::CLOSED) + end + + def reopen_milestone(milestone, current_user) + create_event(milestone, current_user, Event::REOPENED) + end + + def leave_note(note, current_user) + create_event(note, current_user, Event::COMMENTED) + end + + private + + def create_event(record, current_user, status) + Event.create( + project: record.project, + target_id: record.id, + target_type: record.class.name, + action: status, + author_id: current_user.id + ) + end +end diff --git a/app/services/files/base_service.rb b/app/services/files/base_service.rb new file mode 100644 index 0000000000..f1765d3897 --- /dev/null +++ b/app/services/files/base_service.rb @@ -0,0 +1,31 @@ +module Files + class BaseService < ::BaseService + attr_reader :ref, :path + + def initialize(project, user, params, ref, path = nil) + @project, @current_user, @params = project, user, params.dup + @ref = ref + @path = path + end + + private + + def error(message) + { + error: message, + status: :error + } + end + + def success + { + error: '', + status: :success + } + end + + def repository + project.repository + end + end +end diff --git a/app/services/files/create_service.rb b/app/services/files/create_service.rb new file mode 100644 index 0000000000..1998fb79e7 --- /dev/null +++ b/app/services/files/create_service.rb @@ -0,0 +1,47 @@ +require_relative "base_service" + +module Files + class CreateService < BaseService + def execute + allowed = if project.protected_branch?(ref) + can?(current_user, :push_code_to_protected_branches, project) + else + can?(current_user, :push_code, project) + end + + unless allowed + return error("You are not allowed to create file in this branch") + end + + unless repository.branch_names.include?(ref) + return error("You can only create files if you are on top of a branch") + end + + file_name = File.basename(path) + file_path = path + + unless file_name =~ Gitlab::Regex.path_regex + return error("Your changes could not be committed, because file name contains not allowed characters") + end + + blob = repository.blob_at_branch(ref, file_path) + + if blob + return error("Your changes could not be committed, because file with such name exists") + end + + new_file_action = Gitlab::Satellite::NewFileAction.new(current_user, project, ref, file_path) + created_successfully = new_file_action.commit!( + params[:content], + params[:commit_message], + params[:encoding] + ) + + if created_successfully + success + else + error("Your changes could not be committed, because the file has been changed") + end + end + end +end diff --git a/app/services/files/delete_service.rb b/app/services/files/delete_service.rb new file mode 100644 index 0000000000..ff5dc6ef34 --- /dev/null +++ b/app/services/files/delete_service.rb @@ -0,0 +1,40 @@ +require_relative "base_service" + +module Files + class DeleteService < BaseService + def execute + allowed = if project.protected_branch?(ref) + can?(current_user, :push_code_to_protected_branches, project) + else + can?(current_user, :push_code, project) + end + + unless allowed + return error("You are not allowed to push into this branch") + end + + unless repository.branch_names.include?(ref) + return error("You can only create files if you are on top of a branch") + end + + blob = repository.blob_at_branch(ref, path) + + unless blob + return error("You can only edit text files") + end + + delete_file_action = Gitlab::Satellite::DeleteFileAction.new(current_user, project, ref, path) + + deleted_successfully = delete_file_action.commit!( + nil, + params[:commit_message] + ) + + if deleted_successfully + success + else + error("Your changes could not be committed, because the file has been changed") + end + end + end +end diff --git a/app/services/files/update_service.rb b/app/services/files/update_service.rb new file mode 100644 index 0000000000..c631f28749 --- /dev/null +++ b/app/services/files/update_service.rb @@ -0,0 +1,40 @@ +require_relative "base_service" + +module Files + class UpdateService < BaseService + def execute + allowed = if project.protected_branch?(ref) + can?(current_user, :push_code_to_protected_branches, project) + else + can?(current_user, :push_code, project) + end + + unless allowed + return error("You are not allowed to push into this branch") + end + + unless repository.branch_names.include?(ref) + return error("You can only create files if you are on top of a branch") + end + + blob = repository.blob_at_branch(ref, path) + + unless blob + return error("You can only edit text files") + end + + edit_file_action = Gitlab::Satellite::EditFileAction.new(current_user, project, ref, path) + created_successfully = edit_file_action.commit!( + params[:content], + params[:commit_message], + params[:encoding] + ) + + if created_successfully + success + else + error("Your changes could not be committed, because the file has been changed") + end + end + end +end diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb index 3ad41de397..715b569075 100644 --- a/app/services/git_push_service.rb +++ b/app/services/git_push_service.rb @@ -24,8 +24,8 @@ class GitPushService create_push_event project.ensure_satellite_exists - project.discover_default_branch project.repository.expire_cache + project.update_repository_size if push_to_existing_branch?(ref, oldrev) project.update_merge_requests(oldrev, newrev, ref, @user) @@ -33,7 +33,7 @@ class GitPushService end if push_to_branch?(ref) - project.execute_hooks(@push_data.dup) + project.execute_hooks(@push_data.dup, :push_hooks) project.execute_services(@push_data.dup) end @@ -87,10 +87,9 @@ class GitPushService author = commit_user(commit) if !issues_to_close.empty? && is_default_branch - Thread.current[:current_user] = author - Thread.current[:current_commit] = commit - - issues_to_close.each { |i| i.close && i.save } + issues_to_close.each do |issue| + Issues::CloseService.new(project, author, {}).execute(issue, commit) + end end # Create cross-reference notes for any other references. Omit any issues that were referenced in an @@ -189,8 +188,6 @@ class GitPushService end def commit_user commit - User.where(email: commit.author_email).first || - User.where(name: commit.author_name).first || - user + User.find_for_commit(commit.author_email, commit.author_name) || user end end diff --git a/app/services/git_tag_push_service.rb b/app/services/git_tag_push_service.rb new file mode 100644 index 0000000000..62eaf9b4f5 --- /dev/null +++ b/app/services/git_tag_push_service.rb @@ -0,0 +1,40 @@ +class GitTagPushService + attr_accessor :project, :user, :push_data + + def execute(project, user, oldrev, newrev, ref) + @project, @user = project, user + @push_data = create_push_data(oldrev, newrev, ref) + + create_push_event + project.repository.expire_cache + project.execute_hooks(@push_data.dup, :tag_push_hooks) + end + + private + + def create_push_data(oldrev, newrev, ref) + data = { + ref: ref, + before: oldrev, + after: newrev, + user_id: user.id, + user_name: user.name, + project_id: project.id, + repository: { + name: project.name, + url: project.url_to_repo, + description: project.description, + homepage: project.web_url + } + } + end + + def create_push_event + Event.create!( + project: project, + action: Event::PUSHED, + data: push_data, + author_id: push_data[:user_id] + ) + end +end diff --git a/app/services/issues/base_service.rb b/app/services/issues/base_service.rb new file mode 100644 index 0000000000..2e1e1f7e0f --- /dev/null +++ b/app/services/issues/base_service.rb @@ -0,0 +1,14 @@ +module Issues + class BaseService < ::BaseService + + private + + def create_assignee_note(issue) + Note.create_assignee_change_note(issue, issue.project, current_user, issue.assignee) + end + + def execute_hooks(issue) + issue.project.execute_hooks(issue.to_hook_data, :issue_hooks) + end + end +end diff --git a/app/contexts/issues/bulk_update_context.rb b/app/services/issues/bulk_update_service.rb similarity index 91% rename from app/contexts/issues/bulk_update_context.rb rename to app/services/issues/bulk_update_service.rb index 73a3c35352..f72a346af6 100644 --- a/app/contexts/issues/bulk_update_context.rb +++ b/app/services/issues/bulk_update_service.rb @@ -1,5 +1,5 @@ module Issues - class BulkUpdateContext < BaseContext + class BulkUpdateService < BaseService def execute update_data = params[:update] @@ -22,7 +22,7 @@ module Issues opts[:milestone_id] = milestone_id if milestone_id.present? opts[:assignee_id] = assignee_id if assignee_id.present? - issues = Issue.where(id: issues_ids).all + issues = Issue.where(id: issues_ids) issues = issues.select { |issue| can?(current_user, :modify_issue, issue) } issues.each do |issue| diff --git a/app/services/issues/close_service.rb b/app/services/issues/close_service.rb new file mode 100644 index 0000000000..85c0226cca --- /dev/null +++ b/app/services/issues/close_service.rb @@ -0,0 +1,20 @@ +module Issues + class CloseService < Issues::BaseService + def execute(issue, commit = nil) + if issue.close + notification_service.close_issue(issue, current_user) + event_service.close_issue(issue, current_user) + create_note(issue, commit) + execute_hooks(issue) + end + + issue + end + + private + + def create_note(issue, current_commit) + Note.create_status_change_note(issue, issue.project, current_user, issue.state, current_commit) + end + end +end diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb new file mode 100644 index 0000000000..d6137833bb --- /dev/null +++ b/app/services/issues/create_service.rb @@ -0,0 +1,17 @@ +module Issues + class CreateService < Issues::BaseService + def execute + issue = project.issues.new(params) + issue.author = current_user + + if issue.save + notification_service.new_issue(issue, current_user) + event_service.open_issue(issue, current_user) + issue.create_cross_references!(issue.project, current_user) + execute_hooks(issue) + end + + issue + end + end +end diff --git a/app/services/issues/reopen_service.rb b/app/services/issues/reopen_service.rb new file mode 100644 index 0000000000..a931398aff --- /dev/null +++ b/app/services/issues/reopen_service.rb @@ -0,0 +1,19 @@ +module Issues + class ReopenService < Issues::BaseService + def execute(issue) + if issue.reopen + event_service.reopen_issue(issue, current_user) + create_note(issue) + execute_hooks(issue) + end + + issue + end + + private + + def create_note(issue) + Note.create_status_change_note(issue, issue.project, current_user, issue.state, nil) + end + end +end diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb new file mode 100644 index 0000000000..b562c401fd --- /dev/null +++ b/app/services/issues/update_service.rb @@ -0,0 +1,28 @@ +module Issues + class UpdateService < Issues::BaseService + def execute(issue) + state = params.delete('state_event') + + case state + when 'reopen' + Issues::ReopenService.new(project, current_user, {}).execute(issue) + when 'close' + Issues::CloseService.new(project, current_user, {}).execute(issue) + end + + if params.present? && issue.update_attributes(params) + issue.reset_events_cache + + if issue.previous_changes.include?('assignee_id') + notification_service.reassigned_issue(issue, current_user) + create_assignee_note(issue) + end + + issue.notice_added_references(issue.project, current_user) + execute_hooks(issue) + end + + issue + end + end +end diff --git a/app/services/merge_requests/auto_merge_service.rb b/app/services/merge_requests/auto_merge_service.rb new file mode 100644 index 0000000000..e35c03275f --- /dev/null +++ b/app/services/merge_requests/auto_merge_service.rb @@ -0,0 +1,29 @@ +module MergeRequests + # AutoMergeService class + # + # Do git merge in satellite and in case of success + # mark merge request as merged and execute all hooks and notifications + # Called when you do merge via GitLab UI + class AutoMergeService < BaseMergeService + def execute(merge_request, current_user, commit_message) + merge_request.lock + + if Gitlab::Satellite::MergeAction.new(current_user, merge_request).merge!(commit_message) + merge_request.merge + + notification.merge_mr(merge_request, current_user) + create_merge_event(merge_request, current_user) + execute_project_hooks(merge_request) + + true + else + merge_request.unlock + false + end + rescue + merge_request.unlock if merge_request.locked? + merge_request.mark_as_unmergeable + false + end + end +end diff --git a/app/services/merge_requests/base_merge_service.rb b/app/services/merge_requests/base_merge_service.rb new file mode 100644 index 0000000000..9bc50d3d16 --- /dev/null +++ b/app/services/merge_requests/base_merge_service.rb @@ -0,0 +1,20 @@ +module MergeRequests + class BaseMergeService + + private + + def notification + NotificationService.new + end + + def create_merge_event(merge_request, current_user) + EventCreateService.new.merge_mr(merge_request, current_user) + end + + def execute_project_hooks(merge_request) + if merge_request.project + merge_request.project.execute_hooks(merge_request.to_hook_data, :merge_request_hooks) + end + end + end +end diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb new file mode 100644 index 0000000000..c77f5d664e --- /dev/null +++ b/app/services/merge_requests/base_service.rb @@ -0,0 +1,20 @@ +module MergeRequests + class BaseService < ::BaseService + + private + + def create_assignee_note(merge_request) + Note.create_assignee_change_note(merge_request, merge_request.project, current_user, merge_request.assignee) + end + + def create_note(merge_request) + Note.create_status_change_note(merge_request, merge_request.target_project, current_user, merge_request.state, nil) + end + + def execute_hooks(merge_request) + if merge_request.project + merge_request.project.execute_hooks(merge_request.to_hook_data, :merge_request_hooks) + end + end + end +end diff --git a/app/services/merge_requests/close_service.rb b/app/services/merge_requests/close_service.rb new file mode 100644 index 0000000000..64e37a23e6 --- /dev/null +++ b/app/services/merge_requests/close_service.rb @@ -0,0 +1,18 @@ +module MergeRequests + class CloseService < MergeRequests::BaseService + def execute(merge_request, commit = nil) + # If we close MergeRequest we want to ignore validation + # so we can close broken one (Ex. fork project removed) + merge_request.allow_broken = true + + if merge_request.close + event_service.close_mr(merge_request, current_user) + notification_service.close_mr(merge_request, current_user) + create_note(merge_request) + execute_hooks(merge_request) + end + + merge_request + end + end +end diff --git a/app/services/merge_requests/create_service.rb b/app/services/merge_requests/create_service.rb new file mode 100644 index 0000000000..d1bf827f3f --- /dev/null +++ b/app/services/merge_requests/create_service.rb @@ -0,0 +1,19 @@ +module MergeRequests + class CreateService < MergeRequests::BaseService + def execute + merge_request = MergeRequest.new(params) + merge_request.source_project = project + merge_request.target_project ||= project + merge_request.author = current_user + + if merge_request.save + event_service.open_mr(merge_request, current_user) + notification_service.new_merge_request(merge_request, current_user) + merge_request.create_cross_references!(merge_request.project, current_user) + execute_hooks(merge_request) + end + + merge_request + end + end +end diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb new file mode 100644 index 0000000000..680766140b --- /dev/null +++ b/app/services/merge_requests/merge_service.rb @@ -0,0 +1,21 @@ +module MergeRequests + # MergeService class + # + # Mark existing merge request as merged + # and execute all hooks and notifications + # Called when you do merge via command line and push code + # to target branch + class MergeService < BaseMergeService + def execute(merge_request, current_user, commit_message) + merge_request.merge + + notification.merge_mr(merge_request, current_user) + create_merge_event(merge_request, current_user) + execute_project_hooks(merge_request) + + true + rescue + false + end + end +end diff --git a/app/services/merge_requests/reopen_service.rb b/app/services/merge_requests/reopen_service.rb new file mode 100644 index 0000000000..2eb13d3e0e --- /dev/null +++ b/app/services/merge_requests/reopen_service.rb @@ -0,0 +1,15 @@ +module MergeRequests + class ReopenService < MergeRequests::BaseService + def execute(merge_request) + if merge_request.reopen + event_service.reopen_mr(merge_request, current_user) + create_note(merge_request) + execute_hooks(merge_request) + merge_request.reload_code + merge_request.mark_as_unchecked + end + + merge_request + end + end +end diff --git a/app/services/merge_requests/update_service.rb b/app/services/merge_requests/update_service.rb new file mode 100644 index 0000000000..bbedca6ffd --- /dev/null +++ b/app/services/merge_requests/update_service.rb @@ -0,0 +1,37 @@ +require_relative 'base_service' +require_relative 'reopen_service' +require_relative 'close_service' + +module MergeRequests + class UpdateService < MergeRequests::BaseService + def execute(merge_request) + # We dont allow change of source/target projects + # after merge request was created + params.delete(:source_project_id) + params.delete(:target_project_id) + + state = params.delete('state_event') + + case state + when 'reopen' + MergeRequests::ReopenService.new(project, current_user, {}).execute(merge_request) + when 'close' + MergeRequests::CloseService.new(project, current_user, {}).execute(merge_request) + end + + if params.present? && merge_request.update_attributes(params) + merge_request.reset_events_cache + + if merge_request.previous_changes.include?('assignee_id') + notification_service.reassigned_merge_request(merge_request, current_user) + create_assignee_note(merge_request) + end + + merge_request.notice_added_references(merge_request.project, current_user) + execute_hooks(merge_request) + end + + merge_request + end + end +end diff --git a/app/contexts/notes/create_context.rb b/app/services/notes/create_service.rb similarity index 71% rename from app/contexts/notes/create_context.rb rename to app/services/notes/create_service.rb index 36ea76ff94..ff6dfb6113 100644 --- a/app/contexts/notes/create_context.rb +++ b/app/services/notes/create_service.rb @@ -1,8 +1,9 @@ module Notes - class CreateContext < BaseContext + class CreateService < BaseService def execute note = project.notes.new(params[:note]) note.author = current_user + note.system = false note.save note end diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index 750a71aea6..06140c5afe 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -17,9 +17,16 @@ class NotificationService end end + # Always notify user about email added to profile + def new_email(email) + if email.user + mailer.new_email_email(email.id) + end + end + # When create an issue we should send next emails: # - # * issue assignee if his notification level is not Disabled + # * issue assignee if their notification level is not Disabled # * project team members with notification level higher then Participating # def new_issue(issue, current_user) @@ -28,8 +35,8 @@ class NotificationService # When we close an issue we should send next emails: # - # * issue author if his notification level is not Disabled - # * issue assignee if his notification level is not Disabled + # * issue author if their notification level is not Disabled + # * issue assignee if their notification level is not Disabled # * project team members with notification level higher then Participating # def close_issue(issue, current_user) @@ -38,8 +45,8 @@ class NotificationService # When we reassign an issue we should send next emails: # - # * issue old assignee if his notification level is not Disabled - # * issue new assignee if his notification level is not Disabled + # * issue old assignee if their notification level is not Disabled + # * issue new assignee if their notification level is not Disabled # def reassigned_issue(issue, current_user) reassign_resource_email(issue, issue.project, current_user, 'reassigned_issue_email') @@ -48,7 +55,7 @@ class NotificationService # When create a merge request we should send next emails: # - # * mr assignee if his notification level is not Disabled + # * mr assignee if their notification level is not Disabled # def new_merge_request(merge_request, current_user) new_resource_email(merge_request, merge_request.target_project, 'new_merge_request_email') @@ -56,8 +63,8 @@ class NotificationService # When we reassign a merge_request we should send next emails: # - # * merge_request old assignee if his notification level is not Disabled - # * merge_request assignee if his notification level is not Disabled + # * merge_request old assignee if their notification level is not Disabled + # * merge_request assignee if their notification level is not Disabled # def reassigned_merge_request(merge_request, current_user) reassign_resource_email(merge_request, merge_request.target_project, current_user, 'reassigned_merge_request_email') @@ -65,8 +72,8 @@ class NotificationService # When we close a merge request we should send next emails: # - # * merge_request author if his notification level is not Disabled - # * merge_request assignee if his notification level is not Disabled + # * merge_request author if their notification level is not Disabled + # * merge_request assignee if their notification level is not Disabled # * project team members with notification level higher then Participating # def close_mr(merge_request, current_user) @@ -75,16 +82,16 @@ class NotificationService # When we merge a merge request we should send next emails: # - # * merge_request author if his notification level is not Disabled - # * merge_request assignee if his notification level is not Disabled + # * merge_request author if their notification level is not Disabled + # * merge_request assignee if their notification level is not Disabled # * project team members with notification level higher then Participating # - def merge_mr(merge_request) + def merge_mr(merge_request, current_user) recipients = reject_muted_users([merge_request.author, merge_request.assignee], merge_request.target_project) recipients = recipients.concat(project_watchers(merge_request.target_project)).uniq recipients.each do |recipient| - mailer.merged_merge_request_email(recipient.id, merge_request.id) + mailer.merged_merge_request_email(recipient.id, merge_request.id, current_user.id) end end @@ -104,6 +111,7 @@ class NotificationService # ignore gitlab service messages return true if note.note =~ /\A_Status changed to closed_/ + return true if note.note =~ /\A_mentioned in / && note.system == true opts = { noteable_type: note.noteable_type, project_id: note.project_id } @@ -157,25 +165,90 @@ class NotificationService mailer.group_access_granted_email(users_group.id) end + def project_was_moved(project) + recipients = project.team.members + recipients = reject_muted_users(recipients, project) + + recipients.each do |recipient| + mailer.project_was_moved_email(project.id, recipient.id) + end + end + protected # Get project users with WATCH notification level def project_watchers(project) - project_watchers = [] - member_methods = { project => :users_projects } - member_methods.merge!(project.group => :users_groups) if project.group + project_members = users_project_notification(project) - member_methods.each do |object, member_method| - # Get project notification settings since it has higher priority - user_ids = object.send(member_method).where(notification_level: Notification::N_WATCH).pluck(:user_id) - project_watchers += User.where(id: user_ids) + users_with_project_level_global = users_project_notification(project, Notification::N_GLOBAL) + users_with_group_level_global = users_group_notification(project, Notification::N_GLOBAL) + users = users_with_global_level_watch([users_with_project_level_global, users_with_group_level_global].flatten.uniq) - # next collect users who use global settings with watch state - user_ids = object.send(member_method).where(notification_level: Notification::N_GLOBAL).pluck(:user_id) - project_watchers += User.where(id: user_ids, notification_level: Notification::N_WATCH) + users_with_project_setting = select_users_project_setting(project, users_with_project_level_global, users) + users_with_group_setting = select_users_group_setting(project, project_members, users_with_group_level_global, users) + + User.where(id: users_with_project_setting.concat(users_with_group_setting).uniq).to_a + end + + def users_project_notification(project, notification_level=nil) + project_members = project.users_projects + + if notification_level + project_members.where(notification_level: notification_level).pluck(:user_id) + else + project_members.pluck(:user_id) + end + end + + def users_group_notification(project, notification_level) + if project.group + project.group.users_groups.where(notification_level: notification_level).pluck(:user_id) + else + [] + end + end + + def users_with_global_level_watch(ids) + User.where( + id: ids, + notification_level: Notification::N_WATCH + ).pluck(:id) + end + + # Build a list of users based on project notifcation settings + def select_users_project_setting(project, global_setting, users_global_level_watch) + users = users_project_notification(project, Notification::N_WATCH) + + # If project setting is global, add to watch list if global setting is watch + global_setting.each do |user_id| + if users_global_level_watch.include?(user_id) + users << user_id + end end - project_watchers.uniq + users + end + + # Build a list of users based on group notifcation settings + def select_users_group_setting(project, project_members, global_setting, users_global_level_watch) + uids = users_group_notification(project, Notification::N_WATCH) + + # Group setting is watch, add to users list if user is not project member + users = [] + uids.each do |user_id| + if project_members.exclude?(user_id) + users << user_id + end + end + + # Group setting is global, add to users list if global setting is watch + global_setting.each do |user_id| + if project_members.exclude?(user_id) && users_global_level_watch.include?(user_id) + users << user_id + end + end + + users end # Remove users with disabled notifications from array @@ -186,10 +259,10 @@ class NotificationService users.reject do |user| next user.notification.disabled? unless project - tm = project.users_projects.find_by_user_id(user.id) + tm = project.users_projects.find_by(user_id: user.id) if !tm && project.group - tm = project.group.users_groups.find_by_user_id(user.id) + tm = project.group.users_groups.find_by(user_id: user.id) end # reject users who globally disabled notification and has no membership @@ -241,7 +314,7 @@ class NotificationService recipients.delete(current_user) recipients.each do |recipient| - mailer.send(method, recipient.id, target.id, target.assignee_id_was) + mailer.send(method, recipient.id, target.id, target.assignee_id_was, current_user.id) end end diff --git a/app/services/project_transfer_service.rb b/app/services/project_transfer_service.rb index 7150c1c78c..7055ef32ae 100644 --- a/app/services/project_transfer_service.rb +++ b/app/services/project_transfer_service.rb @@ -18,6 +18,10 @@ class ProjectTransferService raise TransferError.new("Project with same path in target namespace already exists") end + # Remove old satellite + project.satellite.destroy + + # Apply new namespace id project.namespace = new_namespace project.save! @@ -29,8 +33,8 @@ class ProjectTransferService # Move wiki repo also if present gitlab_shell.mv_repository("#{old_path}.wiki", "#{new_path}.wiki") - # create satellite repo - project.ensure_satellite_exists + # Create a new satellite (reload project from DB) + Project.find(project.id).ensure_satellite_exists # clear project cached events project.reset_events_cache diff --git a/app/contexts/projects/create_context.rb b/app/services/projects/create_service.rb similarity index 66% rename from app/contexts/projects/create_context.rb rename to app/services/projects/create_service.rb index 1c60a5de14..11b6525650 100644 --- a/app/contexts/projects/create_context.rb +++ b/app/services/projects/create_service.rb @@ -1,5 +1,5 @@ module Projects - class CreateContext < BaseContext + class CreateService < BaseService def initialize(user, params) @current_user, @params = user, params.dup end @@ -8,6 +8,11 @@ module Projects # get namespace id namespace_id = params.delete(:namespace_id) + # check that user is allowed to set specified visibility_level + unless Gitlab::VisibilityLevel.allowed_for?(current_user, params[:visibility_level]) + params.delete(:visibility_level) + end + # Load default feature settings default_features = Gitlab.config.gitlab.default_projects_features @@ -17,7 +22,7 @@ module Projects wall_enabled: default_features.wall, snippets_enabled: default_features.snippets, merge_requests_enabled: default_features.merge_requests, - public: default_features.public + visibility_level: default_features.visibility_level }.stringify_keys @project = Project.new(default_opts.merge(params)) @@ -47,14 +52,35 @@ module Projects @project.creator = current_user if @project.save - @project.discover_default_branch - unless @project.group @project.users_projects.create( project_access: UsersProject::MASTER, user: current_user ) end + + @project.update_column(:last_activity_at, @project.created_at) + + if @project.import? + @project.import_start + else + GitlabShellWorker.perform_async( + :add_repository, + @project.path_with_namespace + ) + + end + + if @project.wiki_enabled? + begin + # force the creation of a wiki, + ProjectWiki.new(@project, @project.owner).wiki + rescue ProjectWiki::CouldNotCreateWikiError => ex + # Prevent project observer crash + # if failed to create wiki + nil + end + end end @project @@ -70,7 +96,7 @@ module Projects end def allowed_namespace?(user, namespace_id) - namespace = Namespace.find_by_id(namespace_id) + namespace = Namespace.find_by(id: namespace_id) current_user.can?(:manage_namespace, namespace) end end diff --git a/app/contexts/projects/fork_context.rb b/app/services/projects/fork_service.rb similarity index 97% rename from app/contexts/projects/fork_context.rb rename to app/services/projects/fork_service.rb index fbc67220d5..2f1c7b18aa 100644 --- a/app/contexts/projects/fork_context.rb +++ b/app/services/projects/fork_service.rb @@ -1,5 +1,5 @@ module Projects - class ForkContext < BaseContext + class ForkService < BaseService include Gitlab::ShellAdapter def initialize(project, user) diff --git a/app/contexts/projects/transfer_context.rb b/app/services/projects/transfer_service.rb similarity index 94% rename from app/contexts/projects/transfer_context.rb rename to app/services/projects/transfer_service.rb index 3011984e3f..f8e27f6f1c 100644 --- a/app/contexts/projects/transfer_context.rb +++ b/app/services/projects/transfer_service.rb @@ -1,5 +1,5 @@ module Projects - class TransferContext < BaseContext + class TransferService < BaseService def execute(role = :default) namespace_id = params[:project].delete(:namespace_id) allowed_transfer = can?(current_user, :change_namespace, project) || role == :admin diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb new file mode 100644 index 0000000000..d9d371da5c --- /dev/null +++ b/app/services/projects/update_service.rb @@ -0,0 +1,19 @@ +module Projects + class UpdateService < BaseService + def execute(role = :default) + params[:project].delete(:namespace_id) + # check that user is allowed to set specified visibility_level + unless can?(current_user, :change_visibility_level, project) && Gitlab::VisibilityLevel.allowed_for?(current_user, params[:project][:visibility_level]) + params[:project].delete(:visibility_level) + end + + new_branch = params[:project].delete(:default_branch) + + if project.repository.exists? && new_branch && new_branch != project.default_branch + project.change_head(new_branch) + end + + project.update_attributes(params[:project], as: role) + end + end +end diff --git a/app/services/search/global_service.rb b/app/services/search/global_service.rb new file mode 100644 index 0000000000..8a1fce17ce --- /dev/null +++ b/app/services/search/global_service.rb @@ -0,0 +1,35 @@ +module Search + class GlobalService + attr_accessor :current_user, :params + + def initialize(user, params) + @current_user, @params = user, params.dup + end + + def execute + query = params[:search] + query = Shellwords.shellescape(query) if query.present? + return result unless query.present? + + group = Group.find_by(id: params[:group_id]) if params[:group_id].present? + projects = Project.accessible_to(current_user) + projects = projects.where(namespace_id: group.id) if group + project_ids = projects.pluck(:id) + + result[:projects] = projects.search(query).limit(20) + result[:merge_requests] = MergeRequest.in_projects(project_ids).search(query).order('updated_at DESC').limit(20) + result[:issues] = Issue.where(project_id: project_ids).search(query).order('updated_at DESC').limit(20) + result[:total_results] = %w(projects issues merge_requests).sum { |items| result[items.to_sym].size } + result + end + + def result + @result ||= { + projects: [], + merge_requests: [], + issues: [], + total_results: 0, + } + end + end +end diff --git a/app/services/search/project_service.rb b/app/services/search/project_service.rb new file mode 100644 index 0000000000..3ebaafc752 --- /dev/null +++ b/app/services/search/project_service.rb @@ -0,0 +1,37 @@ +module Search + class ProjectService + attr_accessor :project, :current_user, :params + + def initialize(project, user, params) + @project, @current_user, @params = project, user, params.dup + end + + def execute + query = params[:search] + query = Shellwords.shellescape(query) if query.present? + return result unless query.present? + + if params[:search_code].present? + blobs = project.repository.search_files(query, params[:repository_ref]) unless project.empty_repo? + blobs = Kaminari.paginate_array(blobs).page(params[:page]).per(20) + result[:blobs] = blobs + result[:total_results] = blobs.total_count + else + result[:merge_requests] = project.merge_requests.search(query).order('updated_at DESC').limit(20) + result[:issues] = project.issues.search(query).order('updated_at DESC').limit(20) + result[:total_results] = %w(issues merge_requests).sum { |items| result[items.to_sym].size } + end + + result + end + + def result + @result ||= { + merge_requests: [], + issues: [], + blobs: [], + total_results: 0, + } + end + end +end diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index de4fa9b79e..41014f199d 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -1,21 +1,21 @@ class SystemHooksService - def self.execute_hooks_for(model, event) + def execute_hooks_for(model, event) execute_hooks(build_event_data(model, event)) end private - def self.execute_hooks(data) + def execute_hooks(data) SystemHook.all.each do |sh| async_execute_hook sh, data end end - def self.async_execute_hook(hook, data) + def async_execute_hook(hook, data) Sidekiq::Client.enqueue(SystemHookWorker, hook.id, data) end - def self.build_event_data(model, event) + def build_event_data(model, event) data = { event_name: build_event_name(model, event), created_at: model.created_at @@ -31,7 +31,8 @@ class SystemHooksService path_with_namespace: model.path_with_namespace, project_id: model.id, owner_name: owner.name, - owner_email: owner.respond_to?(:email) ? owner.email : nil + owner_email: owner.respond_to?(:email) ? owner.email : nil, + project_visibility: Project.visibility_levels.key(model.visibility_level_field).downcase }) when User data.merge!({ @@ -46,12 +47,13 @@ class SystemHooksService project_id: model.project_id, user_name: model.user.name, user_email: model.user.email, - project_access: model.human_access + project_access: model.human_access, + project_visibility: Project.visibility_levels.key(model.project.visibility_level_field).downcase }) end end - def self.build_event_name(model, event) + def build_event_name(model, event) case model when UsersProject return "user_add_to_team" if event == :create diff --git a/app/services/test_hook_service.rb b/app/services/test_hook_service.rb new file mode 100644 index 0000000000..17d86a7a27 --- /dev/null +++ b/app/services/test_hook_service.rb @@ -0,0 +1,6 @@ +class TestHookService + def execute(hook, current_user) + data = GitPushService.new.sample_data(hook.project, current_user) + hook.execute(data) + end +end diff --git a/app/uploaders/attachment_uploader.rb b/app/uploaders/attachment_uploader.rb index 98794c9470..b122b6c865 100644 --- a/app/uploaders/attachment_uploader.rb +++ b/app/uploaders/attachment_uploader.rb @@ -3,6 +3,8 @@ class AttachmentUploader < CarrierWave::Uploader::Base storage :file + after :store, :reset_events_cache + def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end @@ -27,4 +29,8 @@ class AttachmentUploader < CarrierWave::Uploader::Base def file_storage? self.class.storage == CarrierWave::Storage::File end + + def reset_events_cache(file) + model.reset_events_cache if model.is_a?(User) + end end diff --git a/app/views/admin/background_jobs/show.html.haml b/app/views/admin/background_jobs/show.html.haml index 431a9cbcd3..32f77cc1a7 100644 --- a/app/views/admin/background_jobs/show.html.haml +++ b/app/views/admin/background_jobs/show.html.haml @@ -1,11 +1,11 @@ %h3.page-title Background Jobs -%p.light GitLab use #{link_to "sidekiq", "http://sidekiq.org/"} library for async job processing +%p.light GitLab uses #{link_to "sidekiq", "http://sidekiq.org/"} library for async job processing %hr .ui-box .title Sidekiq running processes - .ui-box-body + .body - if @sidekiq_processes.empty? %h4.cred %i.icon-warning-sign @@ -14,27 +14,21 @@ %table.table %thead %th USER - %th %th PID - %th %th CPU - %th %th MEM - %th %th STATE - %th %th START - %th %th COMMAND - %th - - @sidekiq_processes.split("\n").each do |process| + %tbody + - @sidekiq_processes.each do |process| - next unless process.match(/(sidekiq \d+\.\d+\.\d+.+$)/) - - data = process.gsub!(/\s+/m, '|').strip.split('|') + - data = process.strip.split(' ') %tr - - 6.times do + %td= Settings.gitlab.user + - 5.times do %td= data.shift - %td - %td= data.join(" ") + %td= data.join(' ') .clearfix %p diff --git a/app/views/admin/broadcast_messages/index.html.haml b/app/views/admin/broadcast_messages/index.html.haml new file mode 100644 index 0000000000..c58ca2c9a3 --- /dev/null +++ b/app/views/admin/broadcast_messages/index.html.haml @@ -0,0 +1,61 @@ +%h3.page-title + Broadcast Messages +%p.light + Broadcast messages are displayed for every user and can be used to notify users about scheduled maintenance, recent upgrades and more. +.broadcast-message-preview + %i.icon-bullhorn + %span Your message here + += form_for [:admin, @broadcast_message], html: { class: 'broadcast-message-form form-horizontal'} do |f| + -if @broadcast_message.errors.any? + .alert.alert-danger + - @broadcast_message.errors.full_messages.each do |msg| + %p= msg + .form-group + = f.label :message, class: 'control-label' + .col-sm-10 + = f.text_area :message, class: "form-control", rows: 2, required: true + %div + = link_to '#', class: 'js-toggle-colors-link' do + Customize colors + .form-group.js-toggle-colors-container.hide + = f.label :color, "Background Color", class: 'control-label' + .col-sm-10 + = f.text_field :color, placeholder: "#AA33EE", class: "form-control" + .light 6 character hex values starting with a # sign. + .form-group.js-toggle-colors-container.hide + = f.label :font, "Font Color", class: 'control-label' + .col-sm-10 + = f.text_field :font, placeholder: "#224466", class: "form-control" + .light 6 character hex values starting with a # sign. + .form-group + = f.label :starts_at, class: 'control-label' + .col-sm-10.datetime-controls + = f.datetime_select :starts_at + .form-group + = f.label :ends_at, class: 'control-label' + .col-sm-10.datetime-controls + = f.datetime_select :ends_at + .form-actions + = f.submit "Add broadcast message", class: "btn btn-create" + +-if @broadcast_messages.any? + %ul.bordered-list.broadcast-messages + - @broadcast_messages.each do |broadcast_message| + %li + .pull-right + - if broadcast_message.starts_at + %strong + #{broadcast_message.starts_at.to_s(:short)} + \... + - if broadcast_message.ends_at + %strong + #{broadcast_message.ends_at.to_s(:short)} +   + = link_to [:admin, broadcast_message], method: :delete, remote: true, class: 'remove-row btn btn-tiny' do + %i.icon-remove.cred + + .message= broadcast_message.message + + + = paginate @broadcast_messages diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index 3064763b99..41760f8b1e 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -3,82 +3,141 @@ %p.light You can manage projects, users and other GitLab data from here. %hr -.admin_dash.row - .span4 - .light-well - %h4 Projects - .data - = link_to admin_projects_path do - %h1= Project.count - %hr - = link_to 'New Project', new_project_path, class: "btn btn-new" - .span4 - .light-well - %h4 Users - .data - = link_to admin_users_path do - %h1= User.count - %hr - = link_to 'New User', new_admin_user_path, class: "btn btn-new" - .span4 - .light-well - %h4 Groups - .data - = link_to admin_groups_path do - %h1= Group.count - %hr - = link_to 'New Group', new_admin_group_path, class: "btn btn-new" +.admin-dashboard + .row + .col-sm-4 + .light-well + %h4 Projects + .data + = link_to admin_projects_path do + %h1= Project.count + %hr + = link_to 'New Project', new_project_path, class: "btn btn-new" + .col-sm-4 + .light-well + %h4 Users + .data + = link_to admin_users_path do + %h1= User.count + %hr + = link_to 'New User', new_admin_user_path, class: "btn btn-new" + .col-sm-4 + .light-well + %h4 Groups + .data + = link_to admin_groups_path do + %h1= Group.count + %hr + = link_to 'New Group', new_admin_group_path, class: "btn btn-new" -.row.prepend-top-10 - .span4 - %h4 Latest projects - %hr - - @projects.each do |project| + .row.prepend-top-10 + .col-md-4 + %h4 Latest projects + %hr + - @projects.each do |project| + %p + = link_to project.name_with_namespace, [:admin, project], class: 'str-truncated' + %span.light.pull-right + #{time_ago_with_tooltip(project.created_at)} + + .col-md-4 + %h4 Latest users + %hr + - @users.each do |user| + %p + = link_to [:admin, user], class: 'str-truncated' do + = user.name + %span.light.pull-right + #{time_ago_with_tooltip(user.created_at)} + + .col-md-4 + %h4 Latest groups + %hr + - @groups.each do |group| + %p + = link_to [:admin, group], class: 'str-truncated' do + = group.name + %span.light.pull-right + #{time_ago_with_tooltip(group.created_at)} + + %br + .row + .col-md-4 + %h4 Stats + %hr %p - = link_to project.name_with_namespace, [:admin, project] + Forks %span.light.pull-right - = time_ago_in_words project.created_at - ago - - .span4 - %h4 Latest users - %hr - - @users.each do |user| + = ForkedProjectLink.count %p - = link_to [:admin, user] do - = user.name + Issues %span.light.pull-right - = time_ago_in_words user.created_at - ago + = Issue.count + %p + Merge Requests + %span.light.pull-right + = MergeRequest.count + %p + Notes + %span.light.pull-right + = Note.count + %p + Snippets + %span.light.pull-right + = Snippet.count + %p + SSH Keys + %span.light.pull-right + = Key.count + %p + Milestones + %span.light.pull-right + = Milestone.count + %p + Monthly active users + %span.light.pull-right + = User.where("current_sign_in_at > ?", 30.days.ago).count + .col-md-4 + %h4 + Features + %hr + %p + Sign up + %span.light.pull-right + = boolean_to_icon gitlab_config.signup_enabled + %p + LDAP + %span.light.pull-right + = boolean_to_icon Gitlab.config.ldap.enabled + %p + Gravatar + %span.light.pull-right + = boolean_to_icon Gitlab.config.gravatar.enabled + %p + OmniAuth + %span.light.pull-right + = boolean_to_icon Gitlab.config.omniauth.enabled + .col-md-4 + %h4 Components + %hr + %p + GitLab + %span.pull-right + = Gitlab::VERSION + %p + GitLab Shell + %span.pull-right + = Gitlab::Shell.new.version + %p + GitLab API + %span.pull-right + = API::API::version + %p + Ruby + %span.pull-right + #{RUBY_VERSION}p#{RUBY_PATCHLEVEL} - .span4 - %h4 Stats - %hr - %p - Forks - %span.light.pull-right - = ForkedProjectLink.count - %p - Issues - %span.light.pull-right - = Issue.count - %p - Merge Requests - %span.light.pull-right - = MergeRequest.count - %p - Notes - %span.light.pull-right - = Note.count - %p - Snippets - %span.light.pull-right - = Snippet.count - %p - SSH Keys - %span.light.pull-right - = Key.count - %p - Milestones - %span.light.pull-right - = Milestone.count + %p + Rails + %span.pull-right + #{Rails::VERSION::STRING} diff --git a/app/views/admin/groups/edit.html.haml b/app/views/admin/groups/edit.html.haml index 3918bf981a..eb5c91050a 100644 --- a/app/views/admin/groups/edit.html.haml +++ b/app/views/admin/groups/edit.html.haml @@ -1,25 +1,25 @@ %h3.page-title Edit Group %hr -= form_for [:admin, @group] do |f| += form_for [:admin, @group], html: { class: "form-horizontal" } do |f| - if @group.errors.any? - .alert.alert-error + .alert.alert-danger %span= @group.errors.full_messages.first - .control-group.group_name_holder - = f.label :name do + .form-group.group_name_holder + = f.label :name, class: 'control-label' do Group name - .controls - = f.text_field :name, placeholder: "Example Group", class: "input-xxlarge" + .col-sm-10 + = f.text_field :name, placeholder: "Example Group", class: "form-control" - .control-group.group-description-holder - = f.label :description, "Details" - .controls - = f.text_area :description, maxlength: 250, class: "input-xxlarge js-gfm-input", rows: 4 + .form-group.group-description-holder + = f.label :description, "Details", class: 'control-label' + .col-sm-10 + = f.text_area :description, maxlength: 250, class: "form-control js-gfm-input", rows: 4 - .control-group.group_name_holder - = f.label :path do + .form-group.group_name_holder + = f.label :path, class: 'control-label' do %span.cred Group path - .controls - = f.text_field :path, placeholder: "example-group", class: "input-xxlarge danger" + .col-sm-10 + = f.text_field :path, placeholder: "example-group", class: "form-control danger" %ul.cred %li Changing group path can have unintended side effects. %li Renaming group path will rename directory for all related projects diff --git a/app/views/admin/groups/index.html.haml b/app/views/admin/groups/index.html.haml index c9d7c24f20..9a0d596792 100644 --- a/app/views/admin/groups/index.html.haml +++ b/app/views/admin/groups/index.html.haml @@ -1,13 +1,15 @@ %h3.page-title Groups (#{@groups.total_count}) - %small - allows you to keep projects organized. - Use groups for uniting related projects. - = link_to 'New Group', new_admin_group_path, class: "btn btn-new pull-right" -%br + +%p.light + Group allows you to keep projects organized. + Use groups for uniting related projects. + +%hr = form_tag admin_groups_path, method: :get, class: 'form-inline' do - = text_field_tag :name, params[:name], class: "span6" + .form-group + = text_field_tag :name, params[:name], class: "form-control input-mn-300" = submit_tag "Search", class: "btn submit btn-primary" %hr @@ -18,28 +20,22 @@ .clearfix .pull-right.prepend-top-10 = link_to 'Edit', edit_admin_group_path(group), id: "edit_#{dom_id(group)}", class: "btn btn-small" - = link_to 'Destroy', [:admin, group], confirm: "REMOVE #{group.name}? Are you sure?", method: :delete, class: "btn btn-small btn-remove" + = link_to 'Destroy', [:admin, group], data: {confirm: "REMOVE #{group.name}? Are you sure?"}, method: :delete, class: "btn btn-small btn-remove" %h4 = link_to [:admin, group] do + %i.icon-folder-close = group.name → %span.monospace - %i.icon-folder-close %strong #{group.path}/ - - .clearfix.light.append-bottom-10 - %span - %b Members: - %span.badge= group.members.size - \| - %span - %b Projects: - %span.badge= group.projects.count - .clearfix %p = truncate group.description, length: 150 + .clearfix + %p.light + #{pluralize(group.members.size, 'member')}, #{pluralize(group.projects.count, 'project')} + = paginate @groups, theme: "gitlab" diff --git a/app/views/admin/groups/new.html.haml b/app/views/admin/groups/new.html.haml index cfbe6b5ee5..ae0604cf98 100644 --- a/app/views/admin/groups/new.html.haml +++ b/app/views/admin/groups/new.html.haml @@ -1,27 +1,31 @@ %h3.page-title New Group %hr -= form_for [:admin, @group] do |f| += form_for [:admin, @group], html: { class: 'group-form form-horizontal' } do |f| - if @group.errors.any? - .alert.alert-error + .alert.alert-danger %span= @group.errors.full_messages.first - .control-group - = f.label :name do + .form-group + = f.label :name, class: 'control-label' do Group name - .controls - = f.text_field :name, placeholder: "Ex. OpenSource", class: "input-xxlarge left" - .control-group.group-description-holder - = f.label :description, "Details" - .controls - = f.text_area :description, maxlength: 250, class: "input-xxlarge js-gfm-input", rows: 4 + .col-sm-10 + = f.text_field :name, placeholder: "Ex. OpenSource", class: "form-control" + + .form-group.group-description-holder + = f.label :description, "Details", class: 'control-label' + .col-sm-10 + = f.text_area :description, maxlength: 250, class: "form-control js-gfm-input", rows: 4 + + .form-group + .col-sm-2 + .col-sm-10 + %ul + %li A group is a collection of several projects + %li Groups are private by default + %li Members of a group may only view projects they have permission to access + %li Group project URLs are prefixed with the group namespace + %li Existing projects may be moved into a group .form-actions = f.submit 'Create group', class: "btn btn-create" - %hr - .padded - %ul - %li Group is kind of directory for several projects - %li All created groups are private - %li People within a group see only projects they have access to - %li All projects of group will be stored in a group directory - %li You will be able to move existing projects into group + diff --git a/app/views/admin/groups/show.html.haml b/app/views/admin/groups/show.html.haml index ca51a57000..6055865b4c 100644 --- a/app/views/admin/groups/show.html.haml +++ b/app/views/admin/groups/show.html.haml @@ -6,7 +6,7 @@ Edit %hr .row - .span6 + .col-md-6 .ui-box .title Group info: @@ -39,14 +39,16 @@ %li %strong = link_to project.name_with_namespace, [:admin, project] + %span.label.label-gray + = repository_size(project) %span.pull-right.light %span.monospace= project.path_with_namespace + ".git" - .span6 + .col-md-6 .ui-box .title Add user(s) to the group: - .ui-box-body.form-holder + .body.form-holder %p.light Read more about project permissions %strong= link_to "here", help_permissions_path, class: "vlink" @@ -55,7 +57,7 @@ %div = users_select_tag(:user_ids, multiple: true) %div.prepend-top-10 - = select_tag :group_access, options_for_select(UsersGroup.group_access_roles), class: "project-access-select chosen" + = select_tag :group_access, options_for_select(UsersGroup.group_access_roles), class: "project-access-select select2" %hr = submit_tag 'Add users into group', class: "btn btn-create" .ui-box @@ -68,9 +70,10 @@ - @group.users_groups.order('group_access DESC').each do |member| - user = member.user %li{class: dom_class(user)} - %strong - = link_to user.name, admin_user_path(user) + .list-item-name + %strong + = link_to user.name, admin_user_path(user) %span.pull-right.light = member.human_access - = link_to group_users_group_path(@group, member), confirm: remove_user_from_group_message(@group, user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do + = link_to group_users_group_path(@group, member), data: { confirm: remove_user_from_group_message(@group, user) }, method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do %i.icon-minus.icon-white diff --git a/app/views/admin/hooks/_data_ex.html.erb b/app/views/admin/hooks/_data_ex.html.erb deleted file mode 100644 index 5b16dfb398..0000000000 --- a/app/views/admin/hooks/_data_ex.html.erb +++ /dev/null @@ -1,71 +0,0 @@ -<% data_ex_str = < -<% js_lexer = Pygments::Lexer[:js] %> -<%= raw js_lexer.highlight(data_ex_str) %> diff --git a/app/views/admin/hooks/index.html.haml b/app/views/admin/hooks/index.html.haml index 1bd7b8eac6..60773c2009 100644 --- a/app/views/admin/hooks/index.html.haml +++ b/app/views/admin/hooks/index.html.haml @@ -1,5 +1,5 @@ %h3.page-title - System Hooks + System hooks %p.light #{link_to "System hooks ", help_system_hooks_path, class: "vlink"} can be @@ -8,35 +8,30 @@ %hr -= form_for @hook, as: :hook, url: admin_hooks_path, html: { class: 'form-inline' } do |f| += form_for @hook, as: :hook, url: admin_hooks_path, html: { class: 'form-horizontal' } do |f| -if @hook.errors.any? - .alert.alert-error + .alert.alert-danger - @hook.errors.full_messages.each do |msg| %p= msg - .control-group - = f.label :url, "URL:" - .controls - = f.text_field :url, class: "text_field input-xxlarge input-xpadding" -   - = f.submit "Add System Hook", class: "btn btn-create" + .form-group + = f.label :url, "URL:", class: 'control-label' + .col-sm-10 + = f.text_field :url, class: "form-control" + .form-actions + = f.submit "Add System Hook", class: "btn btn-create" %hr -if @hooks.any? - %h3 - Hooks - %small (#{@hooks.count}) - %br - %table - %tr - %th URL - %th Method - %th - - @hooks.each do |hook| - %tr - %td - = link_to admin_hook_path(hook) do - %strong= hook.url - = link_to 'Test Hook', admin_hook_test_path(hook), class: "btn btn-small pull-right" - %td POST - %td - = link_to 'Remove', admin_hook_path(hook), confirm: 'Are you sure?', method: :delete, class: "btn btn-remove btn-small pull-right" + .ui-box + .title + System hooks (#{@hooks.count}) + %ul.well-list + - @hooks.each do |hook| + %li + .list-item-name + = link_to admin_hook_path(hook) do + %strong= hook.url + + .pull-right + = link_to 'Test Hook', admin_hook_test_path(hook), class: "btn btn-small" + = link_to 'Remove', admin_hook_path(hook), data: { confirm: 'Are you sure?' }, method: :delete, class: "btn btn-remove btn-small" diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml index bc297209ae..51ad702154 100644 --- a/app/views/admin/projects/index.html.haml +++ b/app/views/admin/projects/index.html.haml @@ -1,55 +1,81 @@ .row - .span4 + .col-md-4 .admin-filter - = form_tag admin_projects_path, method: :get, class: 'form-inline' do - .control-group - = label_tag :name, 'Name:', class: 'control-label' - .controls - = text_field_tag :name, params[:name], class: "span2" - - .control-group - = label_tag :owner_id, 'Owner:', class: 'control-label' - .controls - = users_select_tag :owner_id, selected: params[:owner_id], class: 'input-large' - .control-group - = label_tag :public_only, 'Public Only', class: 'control-label' - .controls - = check_box_tag :public_only, 1, params[:public_only] - .control-group - = label_tag :with_push, 'Not empty', class: 'control-label' - .controls - = check_box_tag :with_push, 1, params[:with_push] -   - %span.light Projects with push events - .control-group - = label_tag :abandoned, 'Abandoned', class: 'control-label' - .controls - = check_box_tag :abandoned, 1, params[:abandoned] -   - %span.light No activity over 6 month - + = form_tag admin_projects_path, method: :get, class: '' do + .form-group + = label_tag :name, 'Name:' + = text_field_tag :name, params[:name], class: "form-control" + .form-group + = label_tag :owner_id, 'Owner:' + %div + = users_select_tag :owner_id, selected: params[:owner_id], class: 'input-large input-clamp' + .checkbox + = label_tag :with_push, 'Not empty' + = check_box_tag :with_push, 1, params[:with_push] +   + %span.light Projects with push events + .checkbox + = label_tag :abandoned, 'Abandoned' + = check_box_tag :abandoned, 1, params[:abandoned] +   + %span.light No activity over 6 month + %fieldset + %strong Visibility level: + .visibility-levels + - Project.visibility_levels.each do |label, level| + .checkbox + %label + = check_box_tag 'visibility_levels[]', level, params[:visibility_levels].present? && params[:visibility_levels].include?(level.to_s) + %span.descr + = visibility_level_icon(level) + = label .form-actions + = hidden_field_tag :sort, params[:sort] = submit_tag "Search", class: "btn submit btn-primary" = link_to "Reset", admin_projects_path, class: "btn" - .span8 + + .col-md-8 .ui-box .title Projects (#{@projects.total_count}) .pull-right + .dropdown.inline + %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"} + %span.light sort: + - if @sort.present? + = @sort.humanize + - else + Name + %b.caret + %ul.dropdown-menu + %li + = link_to admin_projects_path(sort: nil) do + Name + = link_to admin_projects_path(sort: 'newest') do + Newest + = link_to admin_projects_path(sort: 'oldest') do + Oldest + = link_to admin_projects_path(sort: 'recently_updated') do + Recently updated + = link_to admin_projects_path(sort: 'last_updated') do + Last updated + = link_to admin_projects_path(sort: 'largest_repository') do + Largest repository = link_to 'New Project', new_project_path, class: "btn btn-new" %ul.well-list - @projects.each do |project| %li - - if project.public - = public_icon - - else - = private_icon - = link_to project.name_with_namespace, [:admin, project] + .list-item-name + %span{ class: visibility_level_color(project.visibility_level) } + = visibility_level_icon(project.visibility_level) + = link_to project.name_with_namespace, [:admin, project] .pull-right + %span.label.label-gray + = repository_size(project) = link_to 'Edit', edit_project_path(project), id: "edit_#{dom_id(project)}", class: "btn btn-small" - = link_to 'Destroy', [project], confirm: remove_project_message(project), method: :delete, class: "btn btn-small btn-remove" + = link_to 'Destroy', [project], data: { confirm: remove_project_message(project) }, method: :delete, class: "btn btn-small btn-remove" - if @projects.blank? - %p.nothing_here_message 0 projects matches + .nothing-here-block 0 projects matches = paginate @projects, theme: "gitlab" diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index 65b9911dc4..11f07743ac 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -5,7 +5,7 @@ Edit %hr .row - .span6 + .col-md-6 .ui-box .title Project info: @@ -53,6 +53,11 @@ %strong = @repository.path_to_repo + %li + %span.light Size + %strong + = repository_size(@project) + %li %span.light last commit: %strong @@ -66,15 +71,26 @@ %li %span.light access: %strong - - if @project.public - %span.cblue - %i.icon-share - Public - - else - %span.cgreen - %i.icon-lock - Private - .span6 + %span{ class: visibility_level_color(@project.visibility_level) } + = visibility_level_icon(@project.visibility_level) + = visibility_level_label(@project.visibility_level) + + .ui-box + .title + Transfer project + .body + = form_for @project, url: transfer_admin_project_path(@project), method: :put, html: { class: 'form-horizontal' } do |f| + .form-group + = f.label :namespace_id, "Namespace", class: 'control-label' + .col-sm-10 + = namespace_select_tag :namespace_id, selected: params[:namespace_id], class: 'input-large' + + .form-group + .col-sm-2 + .col-sm-10 + = f.submit 'Transfer', class: 'btn btn-primary' + + .col-md-6 - if @group .ui-box .title @@ -100,12 +116,13 @@ - @project.users_projects.each do |users_project| - user = users_project.user %li.users_project - %strong - = link_to user.name, admin_user_path(user) + .list-item-name + %strong + = link_to user.name, admin_user_path(user) .pull-right - if users_project.owner? %span.light Owner - else %span.light= users_project.human_access - = link_to project_team_member_path(@project, user), confirm: remove_from_project_team_message(@project, user), method: :delete, remote: true, class: "btn btn-small btn-remove" do + = link_to project_team_member_path(@project, user), data: { confirm: remove_from_project_team_message(@project, user)}, method: :delete, remote: true, class: "btn btn-small btn-remove" do %i.icon-remove diff --git a/app/views/admin/users/_form.html.haml b/app/views/admin/users/_form.html.haml index 3f930c45fa..881a043f36 100644 --- a/app/views/admin/users/_form.html.haml +++ b/app/views/admin/users/_form.html.haml @@ -1,35 +1,35 @@ .user_new - = form_for [:admin, @user] do |f| + = form_for [:admin, @user], html: { class: 'form-horizontal' } do |f| -if @user.errors.any? #error_explanation - %ul.unstyled.alert.alert-error + %ul.unstyled.alert.alert-danger - @user.errors.full_messages.each do |msg| %li= msg %fieldset %legend Account - .control-group - = f.label :name - .controls - = f.text_field :name, required: true, autocomplete: "off" + .form-group + = f.label :name, class: 'control-label' + .col-sm-10 + = f.text_field :name, required: true, autocomplete: "off", class: 'form-control' %span.help-inline * required - .control-group - = f.label :username - .controls - = f.text_field :username, required: true, autocomplete: "off" + .form-group + = f.label :username, class: 'control-label' + .col-sm-10 + = f.text_field :username, required: true, autocomplete: "off", class: 'form-control' %span.help-inline * required - .control-group - = f.label :email - .controls - = f.text_field :email, required: true, autocomplete: "off" + .form-group + = f.label :email, class: 'control-label' + .col-sm-10 + = f.text_field :email, required: true, autocomplete: "off", class: 'form-control' %span.help-inline * required - if @user.new_record? %fieldset %legend Password - .control-group - = f.label :password - .controls + .form-group + = f.label :password, class: 'control-label' + .col-sm-10 %strong A temporary password will be generated and sent to user. %br @@ -37,49 +37,52 @@ - else %fieldset %legend Password - .control-group - = f.label :password - .controls= f.password_field :password, disabled: f.object.force_random_password - .control-group - = f.label :password_confirmation - .controls= f.password_field :password_confirmation, disabled: f.object.force_random_password + .form-group + = f.label :password, class: 'control-label' + .col-sm-10= f.password_field :password, disabled: f.object.force_random_password, class: 'form-control' + .form-group + = f.label :password_confirmation, class: 'control-label' + .col-sm-10= f.password_field :password_confirmation, disabled: f.object.force_random_password, class: 'form-control' %fieldset %legend Access - .row - .span8 - .control-group - = f.label :projects_limit - .controls= f.number_field :projects_limit + .form-group + = f.label :projects_limit, class: 'control-label' + .col-sm-10= f.number_field :projects_limit, class: 'form-control' - .control-group - = f.label :can_create_group - .controls= f.check_box :can_create_group + .form-group + = f.label :can_create_group, class: 'control-label' + .col-sm-10= f.check_box :can_create_group - .control-group - = f.label :admin do - %strong.cred Administrator - .controls= f.check_box :admin - .span4 - - unless @user.new_record? - .alert.alert-error - - if @user.blocked? - %p This user is blocked and is not able to login to GitLab - = link_to 'Unblock User', unblock_admin_user_path(@user), method: :put, class: "btn btn-small" - - else - %p Blocked users will be removed from all projects & will not be able to login to GitLab. - = link_to 'Block User', block_admin_user_path(@user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-small btn-remove" + .form-group + = f.label :admin, class: 'control-label' + - if current_user == @user + .col-sm-10= f.check_box :admin, disabled: true + .col-sm-10 You cannot remove your own admin rights + - else + .col-sm-10= f.check_box :admin + - unless @user.new_record? || current_user == @user + .alert.alert-danger + - if @user.blocked? + %p This user is blocked and is not able to login to GitLab + = link_to 'Unblock User', unblock_admin_user_path(@user), method: :put, class: "btn btn-small" + - else + %p Blocked users will be removed from all projects & will not be able to login to GitLab. + = link_to 'Block User', block_admin_user_path(@user), data: {confirm: 'USER WILL BE BLOCKED! Are you sure?'}, method: :put, class: "btn btn-small btn-remove" %fieldset %legend Profile - .control-group - = f.label :skype - .controls= f.text_field :skype - .control-group - = f.label :linkedin - .controls= f.text_field :linkedin - .control-group - = f.label :twitter - .controls= f.text_field :twitter + .form-group + = f.label :skype, class: 'control-label' + .col-sm-10= f.text_field :skype, class: 'form-control' + .form-group + = f.label :linkedin, class: 'control-label' + .col-sm-10= f.text_field :linkedin, class: 'form-control' + .form-group + = f.label :twitter, class: 'control-label' + .col-sm-10= f.text_field :twitter, class: 'form-control' + .form-group + = f.label :website_url, 'Website', class: 'control-label' + .col-sm-10= f.text_field :website_url, class: 'form-control' .form-actions - if @user.new_record? diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml index b32f0ae87c..f42ae7c6a0 100644 --- a/app/views/admin/users/index.html.haml +++ b/app/views/admin/users/index.html.haml @@ -1,10 +1,6 @@ .row - .span3 + .col-md-3 .admin-filter - = form_tag admin_users_path, method: :get, class: 'form-inline' do - = search_field_tag :name, params[:name], placeholder: 'Name, email or username', class: 'search-text-input span2' - = button_tag type: 'submit', class: 'btn' do - %i.icon-search %ul.nav.nav-pills.nav-stacked %li{class: "#{'active' unless params[:filter]}"} = link_to admin_users_path do @@ -23,9 +19,15 @@ Without projects %small.pull-right= User.without_projects.count %hr + = form_tag admin_users_path, method: :get, class: 'form-inline' do + .form-group + = search_field_tag :name, params[:name], placeholder: 'Name, email or username', class: 'form-control' + = button_tag type: 'submit', class: 'btn btn-primary' do + %i.icon-search + %hr = link_to 'Reset', admin_users_path, class: "btn btn-cancel" - .span9 + .col-md-9 .ui-box .title Users (#{@users.total_count}) @@ -34,15 +36,16 @@ %ul.well-list - @users.each do |user| %li - - if user.blocked? - %i.icon-lock.cred - - else - %i.icon-user.cgreen - = link_to user.name, [:admin, user] - - if user.admin? - %strong.cred (Admin) - - if user == current_user - %span.cred It's you! + .list-item-name + - if user.blocked? + %i.icon-lock.cred + - else + %i.icon-user.cgreen + = link_to user.name, [:admin, user] + - if user.admin? + %strong.cred (Admin) + - if user == current_user + %span.cred It's you! .pull-right %span.light %i.icon-envelope @@ -53,6 +56,6 @@ - if user.blocked? = link_to 'Unblock', unblock_admin_user_path(user), method: :put, class: "btn btn-small success" - else - = link_to 'Block', block_admin_user_path(user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-small btn-remove" - = link_to 'Destroy', [:admin, user], confirm: "USER #{user.name} WILL BE REMOVED! Are you sure?", method: :delete, class: "btn btn-small btn-remove" + = link_to 'Block', block_admin_user_path(user), data: {confirm: 'USER WILL BE BLOCKED! Are you sure?'}, method: :put, class: "btn btn-small btn-remove" + = link_to 'Destroy', [:admin, user], data: { confirm: "USER #{user.name} WILL BE REMOVED! All tickets linked to this user will also be removed! Maybe block the user instead? Are you sure?" }, method: :delete, class: "btn btn-small btn-remove" = paginate @users, theme: "gitlab" diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index 655ed5f7f7..764b34499a 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -7,13 +7,13 @@ %span.cred (Admin) .pull-right - = link_to edit_admin_user_path(@user), class: "btn grouped" do + = link_to edit_admin_user_path(@user), class: "btn btn-grouped" do %i.icon-edit Edit %hr .row - .span6 + .col-md-6 .ui-box .title Account: @@ -43,6 +43,16 @@ %span.light Member since: %strong = @user.created_at.stamp("Nov 12, 2031") + - if @user.confirmed_at + %li + %span.light Confirmed at: + %strong + = @user.confirmed_at.stamp("Nov 12, 2031") + - else + %li + %span.light Confirmed: + %strong.cred + No %li %span.light Last sign-in at: @@ -68,7 +78,6 @@ - if @user.blocked? .alert.alert-info %h4 This user is blocked - %br %p Blocking user has the following effects: %ul %li User will not be able to login @@ -76,11 +85,11 @@ %li User will be removed from joined projects and groups %li Personal projects will be left %li Owned groups will be left - = link_to 'Unblock user', unblock_admin_user_path(@user), method: :put, class: "btn btn-new", confirm: 'Are you sure?' + %br + = link_to 'Unblock user', unblock_admin_user_path(@user), method: :put, class: "btn btn-new", data: { confirm: 'Are you sure?' } - else - .alert + .alert.alert-warning %h4 Block this user - %br %p Blocking user has the following effects: %ul %li User will not be able to login @@ -88,12 +97,12 @@ %li User will be removed from joined projects and groups %li Personal projects will be left %li Owned groups will be left - = link_to 'Block user', block_admin_user_path(@user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-remove" + %br + = link_to 'Block user', block_admin_user_path(@user), data: { confirm: 'USER WILL BE BLOCKED! Are you sure?' }, method: :put, class: "btn btn-remove" - .alert.alert-error + .alert.alert-danger %h4 Remove user - %br %p Deleting a user has the following effects: %ul %li All user content like authored issues, snippets, comments will be removed @@ -104,9 +113,10 @@ %li Next groups with all content will be removed: %strong #{@user.solo_owned_groups.map(&:name).join(', ')} - = link_to 'Remove user', [:admin, @user], confirm: "USER #{@user.name} WILL BE REMOVED! Are you sure?", method: :delete, class: "btn btn-remove" + %br + = link_to 'Remove user', [:admin, @user], data: { confirm: "USER #{@user.name} WILL BE REMOVED! Are you sure?" }, method: :delete, class: "btn btn-remove" - .span6 + .col-md-6 - if @user.users_groups.present? .ui-box .title Groups: @@ -114,11 +124,12 @@ - @user.users_groups.each do |user_group| - group = user_group.group %li.users_group - %strong= link_to group.name, admin_group_path(group) + %span{class: ("list-item-name" unless user_group.owner?)} + %strong= link_to group.name, admin_group_path(group) .pull-right %span.light= user_group.human_access - unless user_group.owner? - = link_to group_users_group_path(group, user_group), confirm: remove_user_from_group_message(group, @user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do + = link_to group_users_group_path(group, user_group), data: { confirm: remove_user_from_group_message(group, @user) }, method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do %i.icon-remove.icon-white .ui-box @@ -138,7 +149,5 @@ %span.light= tm.human_access - if tm.respond_to? :project - = link_to project_team_member_path(project, @user), confirm: remove_from_project_team_message(project, @user), remote: true, method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from project' do + = link_to project_team_member_path(project, @user), data: { confirm: remove_from_project_team_message(project, @user) }, remote: true, method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from project' do %i.icon-remove - - diff --git a/app/views/dashboard/_activities.html.haml b/app/views/dashboard/_activities.html.haml index 8911772631..fdf96dd6f5 100644 --- a/app/views/dashboard/_activities.html.haml +++ b/app/views/dashboard/_activities.html.haml @@ -4,5 +4,6 @@ - if @events.any? .content_list - else - %p.nothing_here_message Projects activity will be displayed here -.loading.hide + .nothing-here-block Projects activity will be displayed here + += spinner diff --git a/app/views/dashboard/_groups.html.haml b/app/views/dashboard/_groups.html.haml index b4f3866228..a6bc946bed 100644 --- a/app/views/dashboard/_groups.html.haml +++ b/app/views/dashboard/_groups.html.haml @@ -1,6 +1,6 @@ .ui-box .title.clearfix - = search_field_tag :filter_group, nil, placeholder: 'Filter by name', class: 'dash-filter' + = search_field_tag :filter_group, nil, placeholder: 'Filter by name', class: 'dash-filter form-control' - if current_user.can_create_group? %span.pull-right = link_to new_group_path, class: "btn btn-new" do @@ -10,10 +10,11 @@ - groups.each do |group| %li.group-row = link_to group_path(id: group.path), class: dom_class(group) do + = image_tag group_icon(group.path), class: "avatar s24" %span.group-name.filter-title = truncate(group.name, length: 35) %span.arrow %i.icon-angle-right - if groups.blank? %li - %h3.nothing_here_message You have no groups yet. + .nothing-here-block You have no groups yet. diff --git a/app/views/dashboard/_project.html.haml b/app/views/dashboard/_project.html.haml index 50b833f3d8..e326bee53a 100644 --- a/app/views/dashboard/_project.html.haml +++ b/app/views/dashboard/_project.html.haml @@ -1,12 +1,12 @@ = link_to project_path(project), class: dom_class(project) do - %span.namespace-name - - if project.namespace - = project.namespace.human_name - \/ - %span.project-name.filter-title - = truncate(project.name, length: 25) + .dash-project-access-icon + = visibility_level_icon(project.visibility_level) + %span.str-truncated + %span.namespace-name + - if project.namespace + = project.namespace.human_name + \/ + %span.project-name.filter-title + = project.name %span.arrow %i.icon-angle-right - %span.last-activity - %span Last activity: - %span.date= project_last_activity(project) diff --git a/app/views/dashboard/_projects.html.haml b/app/views/dashboard/_projects.html.haml index b79b27fc95..44c7a4b8c8 100644 --- a/app/views/dashboard/_projects.html.haml +++ b/app/views/dashboard/_projects.html.haml @@ -1,6 +1,6 @@ .ui-box .title.clearfix - = search_field_tag :filter_projects, nil, placeholder: 'Filter by name', class: 'dash-filter' + = search_field_tag :filter_projects, nil, placeholder: 'Filter by name', class: 'dash-filter form-control' - if current_user.can_create_project? %span.pull-right = link_to new_project_path, class: "btn btn-new" do @@ -14,7 +14,7 @@ - if projects.blank? %li - %h3.nothing_here_message There are no projects here. + .nothing-here-block There are no projects here. - if @projects_count > @projects_limit %li.bottom %span.light diff --git a/app/views/dashboard/_projects_filter.html.haml b/app/views/dashboard/_projects_filter.html.haml new file mode 100644 index 0000000000..8c9893ba84 --- /dev/null +++ b/app/views/dashboard/_projects_filter.html.haml @@ -0,0 +1,55 @@ +%fieldset + %ul.nav.nav-pills.nav-stacked + = nav_tab :scope, nil do + = link_to projects_dashboard_filter_path(scope: nil) do + All + %span.pull-right + = current_user.authorized_projects.count + = nav_tab :scope, 'personal' do + = link_to projects_dashboard_filter_path(scope: 'personal') do + Personal + %span.pull-right + = current_user.personal_projects.count + = nav_tab :scope, 'joined' do + = link_to projects_dashboard_filter_path(scope: 'joined') do + Joined + %span.pull-right + = current_user.authorized_projects.joined(current_user).count + = nav_tab :scope, 'owned' do + = link_to projects_dashboard_filter_path(scope: 'owned') do + Owned + %span.pull-right + = current_user.owned_projects.count + +%fieldset + %legend Visibility + %ul.nav.nav-pills.nav-stacked.nav-small.visibility-filter + - Gitlab::VisibilityLevel.values.each do |level| + %li{ class: (level.to_s == params[:visibility_level]) ? 'active' : 'light' } + = link_to projects_dashboard_filter_path(visibility_level: level) do + = visibility_level_icon(level) + = visibility_level_label(level) + +- if @groups.present? + %fieldset + %legend Groups + %ul.nav.nav-pills.nav-stacked.nav-small + - @groups.each do |group| + %li{ class: (group.name == params[:group]) ? 'active' : 'light' } + = link_to projects_dashboard_filter_path(group: group.name) do + %i.icon-folder-close-alt + = group.name + %small.pull-right + = group.projects.count + + + +- if @labels.present? + %fieldset + %legend Labels + %ul.nav.nav-pills.nav-stacked.nav-small + - @labels.each do |label| + %li{ class: (label.name == params[:label]) ? 'active' : 'light' } + = link_to projects_dashboard_filter_path(scope: params[:scope], label: label.name) do + %i.icon-tag + = label.name diff --git a/app/views/dashboard/_zero_authorized_projects.html.haml b/app/views/dashboard/_zero_authorized_projects.html.haml index 79d5dca884..e0993293ea 100644 --- a/app/views/dashboard/_zero_authorized_projects.html.haml +++ b/app/views/dashboard/_zero_authorized_projects.html.haml @@ -29,8 +29,23 @@ %p.slead You can create a group for several dependent projects. %br - Group is the best way to manage projects and members + Groups are the best way to manage projects and members .link_holder = link_to new_group_path, class: "btn btn-new" do New group » +-if @publicish_project_count > 0 + %hr + %div + .dashboard-intro-icon + %i.icon-globe + %div + %p.slead + There are + %strong= @publicish_project_count + public projects on this server. + %br + Public projects are an easy way to allow everyone to have read-only access. + .link_holder + = link_to public_projects_path, class: "btn btn-new" do + Browse public projects » diff --git a/app/views/dashboard/issues.html.haml b/app/views/dashboard/issues.html.haml old mode 100644 new mode 100755 index 82880d5ef6..af627588ad --- a/app/views/dashboard/issues.html.haml +++ b/app/views/dashboard/issues.html.haml @@ -1,13 +1,13 @@ %h3.page-title - Issues assigned to me + Issues %span.pull-right #{@issues.total_count} issues %p.light - For all issues you should visit the project's issues page, or use the search panel to find a specific issue. + List all issues from all projects you have access to. %hr .row - .span3 + .col-md-3 = render 'shared/filter', entity: 'issue' - .span9 + .col-md-9 = render 'shared/issues' diff --git a/app/views/dashboard/merge_requests.html.haml b/app/views/dashboard/merge_requests.html.haml old mode 100644 new mode 100755 index 9c96edeefd..550a93e178 --- a/app/views/dashboard/merge_requests.html.haml +++ b/app/views/dashboard/merge_requests.html.haml @@ -4,10 +4,10 @@ %p.light - Only merge requests created by you or assigned to you are listed here. + List all merge requests from all projects you have access to. %hr .row - .span3 + .col-md-3 = render 'shared/filter', entity: 'merge_request' - .span9 + .col-md-9 = render 'shared/merge_requests' diff --git a/app/views/dashboard/projects.html.haml b/app/views/dashboard/projects.html.haml index 785eb61333..e1c9a5941e 100644 --- a/app/views/dashboard/projects.html.haml +++ b/app/views/dashboard/projects.html.haml @@ -1,67 +1,47 @@ -%h3.page-title My Projects +%h3.page-title + My Projects +.pull-right + .dropdown.inline + %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"} + %span.light sort: + - if @sort.present? + = @sort.humanize + - else + Name + %b.caret + %ul.dropdown-menu + %li + = link_to projects_dashboard_filter_path(sort: nil) do + Name + = link_to projects_dashboard_filter_path(sort: 'newest') do + Newest + = link_to projects_dashboard_filter_path(sort: 'oldest') do + Oldest + = link_to projects_dashboard_filter_path(sort: 'recently_updated') do + Recently updated + = link_to projects_dashboard_filter_path(sort: 'last_updated') do + Last updated %p.light All projects you have access to are listed here. Public projects are not included here unless you are a member %hr .row - .span3 - %ul.nav.nav-pills.nav-stacked - = nav_tab :scope, nil do - = link_to projects_dashboard_path do - All - %span.pull-right - = current_user.authorized_projects.count - = nav_tab :scope, 'personal' do - = link_to projects_dashboard_path(scope: 'personal') do - Personal - %span.pull-right - = current_user.personal_projects.count - = nav_tab :scope, 'joined' do - = link_to projects_dashboard_path(scope: 'joined') do - Joined - %span.pull-right - = current_user.authorized_projects.joined(current_user).count - = nav_tab :scope, 'owned' do - = link_to projects_dashboard_path(scope: 'owned') do - Owned - %span.pull-right - = current_user.owned_projects.count - - - - if @groups.present? - %fieldset - %legend Groups - %ul.bordered-list - - @groups.each do |group| - %li{ class: (group.name == params[:group]) ? 'active' : 'light' } - = link_to projects_dashboard_path(group: group.name) do - %i.icon-folder-close-alt - = group.name - %small.pull-right - = group.projects.count - - - - - if @labels.present? - %fieldset - %legend Labels - %ul.bordered-list - - @labels.each do |label| - %li{ class: (label.name == params[:label]) ? 'active' : 'light' } - = link_to projects_dashboard_path(scope: params[:scope], label: label.name) do - %i.icon-tag - = label.name - - .span9 + .col-md-3.hidden-sm.hidden-xs.side-filters + = render "projects_filter" + .col-md-9 %ul.bordered-list.my-projects.top-list - @projects.each do |project| - %li + %li.my-project-row %h4.project-title + .project-access-icon + = visibility_level_icon(project.visibility_level) = link_to project_path(project), class: dom_class(project) do = project.name_with_namespace - - if project.public - %small.access-icon - = public_icon - Public + + - if current_user.can_leave_project?(project) + .pull-right + = link_to leave_project_team_members_path(project), data: { confirm: "Leave project?"}, method: :delete, remote: true, class: "btn-tiny btn remove-row", title: 'Leave project' do + %i.icon-signout + Leave - if project.forked_from_project %small.pull-right @@ -70,6 +50,10 @@ = link_to project.forked_from_project.name_with_namespace, project_path(project.forked_from_project) .project-info .pull-right + - if project.archived? + %span.label + %i.icon-archive + Archived - project.labels.each do |label| %span.label.label-info %i.icon-tag @@ -80,9 +64,10 @@ %span.light Last activity: %span.date= project_last_activity(project) + - if @projects.blank? %li - %h3.nothing_here_message There are no projects here. + .nothing-here-block There are no projects here. .bottom = paginate @projects, theme: "gitlab" diff --git a/app/views/dashboard/show.html.haml b/app/views/dashboard/show.html.haml index 2305eae1f7..e5b7fbf097 100644 --- a/app/views/dashboard/show.html.haml +++ b/app/views/dashboard/show.html.haml @@ -1,8 +1,8 @@ - if @has_authorized_projects - .dashboard - .activities.span8 + .dashboard.row + .activities.col-md-8 = render 'activities' - .side.span4 + .side.col-md-4.hidden-sm.hidden-xs = render 'sidebar' - else diff --git a/app/views/dashboard/show.js.haml b/app/views/dashboard/show.js.haml deleted file mode 100644 index 7e5a148e5e..0000000000 --- a/app/views/dashboard/show.js.haml +++ /dev/null @@ -1,2 +0,0 @@ -:plain - Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}"); diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb deleted file mode 100644 index adc9b67209..0000000000 --- a/app/views/devise/confirmations/new.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -

    Resend confirmation instructions

    - -<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> - <%= devise_error_messages! %> - -
    <%= f.label :email %>
    - <%= f.email_field :email %>
    - -
    <%= f.submit "Resend confirmation instructions" %>
    -<% end %> - -<%= render partial: "devise/shared/links" %> diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.html.haml new file mode 100755 index 0000000000..bf634d9de6 --- /dev/null +++ b/app/views/devise/confirmations/new.html.haml @@ -0,0 +1,15 @@ +.login-box + %h3.page-title Resend confirmation instructions + = form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| + .devise-errors + = devise_error_messages! + .clearfix.append-bottom-20 + = f.email_field :email, placeholder: 'Email', class: "form-control", required: true + .clearfix.append-bottom-10 + = f.submit "Resend confirmation instructions", class: 'btn btn-success' + %hr + %p + %span.light + Already have login and password? + %strong + = link_to "Sign in", new_session_path(resource_name) diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb index 7b4fd52696..553d08369e 100644 --- a/app/views/devise/mailer/confirmation_instructions.html.erb +++ b/app/views/devise/mailer/confirmation_instructions.html.erb @@ -1,5 +1,9 @@ -

    Welcome <%= @resource.email %>!

    +

    Welcome <%= @resource.name %>!

    -

    You can confirm your account through the link below:

    +<% if @resource.unconfirmed_email.present? %> +

    You can confirm your email (<%= @resource.unconfirmed_email %>) through the link below:

    +<% else %> +

    You can confirm your account through the link below:

    +<% end %>

    <%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @resource.confirmation_token) %>

    diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.html.haml index 3e4a4a0f1c..95c52608e1 100644 --- a/app/views/devise/passwords/edit.html.haml +++ b/app/views/devise/passwords/edit.html.haml @@ -1,11 +1,12 @@ = form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put, class: "login-box" }) do |f| %h3 Change your password - = devise_error_messages! + .devise-errors + = devise_error_messages! = f.hidden_field :reset_password_token %div - = f.password_field :password, class: "text top", placeholder: "New password" + = f.password_field :password, class: "form-control top", placeholder: "New password", required: true %div - = f.password_field :password_confirmation, class: "text bottom", placeholder: "Confirm new password" + = f.password_field :password_confirmation, class: "form-control bottom", placeholder: "Confirm new password", required: true %div .clearfix.append-bottom-10 = f.submit "Change my password", class: "btn btn-primary" diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml old mode 100644 new mode 100755 index 3df65d037a..040821ca32 --- a/app/views/devise/passwords/new.html.haml +++ b/app/views/devise/passwords/new.html.haml @@ -1,10 +1,14 @@ = form_for(resource, as: resource_name, url: password_path(resource_name), html: { class: "login-box", method: :post }) do |f| %h3.page-title Reset password - = devise_error_messages! - = f.email_field :email, placeholder: "Email", class: "text" - %br/ - %br/ - = f.submit "Reset password", class: "btn-primary btn" - .pull-right - = link_to "Sign in", new_session_path(resource_name), class: "btn" - %br/ + .devise-errors + = devise_error_messages! + .clearfix.append-bottom-20 + = f.email_field :email, placeholder: "Email", class: "form-control", required: true + .clearfix.append-bottom-10 + = f.submit "Reset password", class: "btn-primary btn" + %hr + %p + %span.light + Already have login and password? + %strong + = link_to "Sign in", new_session_path(resource_name) diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 139acf28a9..b11817af95 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -23,6 +23,6 @@

    Cancel my account

    -

    Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), confirm: "Are you sure?", method: :delete %>.

    +

    Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>.

    <%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index d749d7bac0..24bc040654 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -1,19 +1,24 @@ = form_for(resource, as: resource_name, url: registration_path(resource_name), html: { class: "login-box" }) do |f| %h3.page-title Sign Up - %br - = devise_error_messages! + .devise-errors + = devise_error_messages! %div - = f.text_field :name, class: "text top", placeholder: "Name", required: true + = f.text_field :name, class: "form-control top", placeholder: "Name", required: true %div - = f.text_field :username, class: "text middle", placeholder: "Username", required: true + = f.text_field :username, class: "form-control middle", placeholder: "Username", required: true %div - = f.email_field :email, class: "text middle", placeholder: "Email", required: true + = f.email_field :email, class: "form-control middle", placeholder: "Email", required: true %div - = f.password_field :password, class: "text middle", placeholder: "Password", required: true + = f.password_field :password, class: "form-control middle", placeholder: "Password", required: true %div - = f.password_field :password_confirmation, class: "text bottom", placeholder: "Confirm password", required: true + = f.password_field :password_confirmation, class: "form-control bottom", placeholder: "Confirm password", required: true %div = f.submit "Sign up", class: "btn-create btn" %hr - = link_to "Sign in", new_session_path(resource_name) - = link_to "Forgot your password?", new_password_path(resource_name), class: "pull-right" + %p + %span.light + Have an account? + %strong + = link_to "Sign in", new_session_path(resource_name) + %p + = link_to "Forgot your password?", new_password_path(resource_name) diff --git a/app/views/devise/sessions/_new_base.html.haml b/app/views/devise/sessions/_new_base.html.haml index 0c8be9d5c4..a2f85fa3fe 100644 --- a/app/views/devise/sessions/_new_base.html.haml +++ b/app/views/devise/sessions/_new_base.html.haml @@ -1,6 +1,6 @@ = form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| - = f.text_field :login, class: "text top", placeholder: "Username or Email", autofocus: "autofocus" - = f.password_field :password, class: "text bottom", placeholder: "Password" + = f.text_field :login, class: "form-control top", placeholder: "Username or Email", autofocus: "autofocus" + = f.password_field :password, class: "form-control bottom", placeholder: "Password" - if devise_mapping.rememberable? .clearfix.append-bottom-10 %label.checkbox.remember_me{for: "user_remember_me"} diff --git a/app/views/devise/sessions/_new_ldap.html.haml b/app/views/devise/sessions/_new_ldap.html.haml index 575d33949b..bb1d0a4001 100644 --- a/app/views/devise/sessions/_new_ldap.html.haml +++ b/app/views/devise/sessions/_new_ldap.html.haml @@ -1,5 +1,5 @@ = form_tag(user_omniauth_callback_path(:ldap), id: 'new_ldap_user' ) do - = text_field_tag :username, nil, {class: "text top", placeholder: "LDAP Login", autofocus: "autofocus"} - = password_field_tag :password, nil, {class: "text bottom", placeholder: "Password"} + = text_field_tag :username, nil, {class: "form-control top", placeholder: "LDAP Login", autofocus: "autofocus"} + = password_field_tag :password, nil, {class: "form-control bottom", placeholder: "Password"} %br/ = submit_tag "LDAP Sign in", class: "btn-create btn" diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 15854effbf..31221ae9c3 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,6 +1,6 @@ .login-box %h3.page-title Sign in - - if ldap_enabled? + - if ldap_enabled? && gitlab_config.signin_enabled %ul.nav.nav-tabs %li.active = link_to 'LDAP', '#tab-ldap', 'data-toggle' => 'tab' @@ -12,19 +12,32 @@ %div#tab-signin.tab-pane = render partial: 'devise/sessions/new_base' - - else + - elsif ldap_enabled? + = render partial: 'devise/sessions/new_ldap' + + - elsif gitlab_config.signin_enabled = render partial: 'devise/sessions/new_base' + - else + %div + No authentication methods configured. - = render 'devise/sessions/oauth_providers' if devise_mapping.omniauthable? + + = render 'devise/sessions/oauth_providers' if Gitlab.config.omniauth.enabled && devise_mapping.omniauthable? + %hr - if gitlab_config.signup_enabled - %hr - %div - Don't have an account? + %p + %span.light + Don't have an account? %strong = link_to "Sign up", new_registration_path(resource_name) + %p + %span.light Did not receive confirmation email? + = link_to "Send again", new_confirmation_path(resource_name) + + - if extra_config.has_key?('sign_in_text') %hr = markdown(extra_config.sign_in_text) diff --git a/app/views/events/_event.html.haml b/app/views/events/_event.html.haml index 892dacafa6..8cf26671e3 100644 --- a/app/views/events/_event.html.haml +++ b/app/views/events/_event.html.haml @@ -1,10 +1,10 @@ - if event.proper? .event-item{class: "#{event.body? ? "event-block" : "event-inline" }"} %span.cgray.pull-right - #{time_ago_in_words(event.created_at)} ago. + #{time_ago_with_tooltip(event.created_at)} = cache event do - = image_tag avatar_icon(event.author_email), class: "avatar s24", alt:'' + = image_tag avatar_icon(event.author_email, 24), class: "avatar s24", alt:'' - if event.push? = render "events/event/push", event: event diff --git a/app/views/events/_event_last_push.html.haml b/app/views/events/_event_last_push.html.haml index de5634d3c5..6db05a1a5a 100644 --- a/app/views/events/_event_last_push.html.haml +++ b/app/views/events/_event_last_push.html.haml @@ -5,9 +5,8 @@ %strong= truncate(event.ref_name, length: 28) at %strong= link_to_project event.project - %span - = time_ago_in_words(event.created_at) - ago. + #{time_ago_with_tooltip(event.created_at)} + .pull-right = link_to new_mr_path_from_push_event(event), title: "New Merge Request", class: "btn btn-create btn-small" do Create Merge Request diff --git a/app/views/events/_events.html.haml b/app/views/events/_events.html.haml new file mode 100644 index 0000000000..3d62d47886 --- /dev/null +++ b/app/views/events/_events.html.haml @@ -0,0 +1 @@ += render @events diff --git a/app/views/events/event/_note.html.haml b/app/views/events/event/_note.html.haml index db5f3ebb00..ad2afbce14 100644 --- a/app/views/events/event/_note.html.haml +++ b/app/views/events/event/_note.html.haml @@ -14,8 +14,8 @@ - note = event.target - if note.attachment.url - if note.attachment.image? - = link_to note.attachment.url, target: '_blank' do - = image_tag note.attachment.url, class: 'note-image-attach' + = link_to note.attachment.secure_url, target: '_blank' do + = image_tag note.attachment.secure_url, class: 'note-image-attach' - else = link_to note.attachment.secure_url, target: "_blank", class: 'note-file-attach' do %i.icon-paper-clip diff --git a/app/views/groups/_filter.html.haml b/app/views/groups/_filter.html.haml index 9fbc6c190c..fe8c0669c0 100644 --- a/app/views/groups/_filter.html.haml +++ b/app/views/groups/_filter.html.haml @@ -21,7 +21,7 @@ = project.name_with_namespace %small.pull-right= entities_per_project(project, entity) - if @projects.blank? - %p.nothing_here_message This group has no projects yet + .nothing-here-block This group has no projects yet %fieldset %hr diff --git a/app/views/groups/_new_group_member.html.haml b/app/views/groups/_new_group_member.html.haml index 234392c03e..3ab9276c54 100644 --- a/app/views/groups/_new_group_member.html.haml +++ b/app/views/groups/_new_group_member.html.haml @@ -1,20 +1,11 @@ -= form_for @users_group, url: group_users_groups_path(@group) do |f| - %fieldset - %legend - New member(s) for - %strong #{@group.name} - group += form_for @users_group, url: group_users_groups_path(@group), html: { class: 'form-horizontal users-group-form' } do |f| + .form-group + = f.label :user_ids, "People", class: 'control-label' + .col-sm-10= users_select_tag(:user_ids, multiple: true, class: 'input-large') - %p 1. Choose users you want in the group - .control-group - = f.label :user_ids, "People" - .controls= users_select_tag(:user_ids, multiple: true, class: 'input-large') - - %p 2. Set access level for them - .control-group - = f.label :group_access, "Group Access" - .controls= select_tag :group_access, options_for_select(UsersGroup.group_access_roles, @users_group.group_access), class: "project-access-select chosen" - - .form-actions - = f.submit 'Add users into group', class: "btn btn-create" + .form-group + = f.label :group_access, "Group Access", class: 'control-label' + .col-sm-10= select_tag :group_access, options_for_select(UsersGroup.group_access_roles, @users_group.group_access), class: "project-access-select select2" + .form-actions + = f.submit 'Add users into group', class: "btn btn-create" diff --git a/app/views/groups/_projects.html.haml b/app/views/groups/_projects.html.haml index 16a3c60f66..bd4e3156af 100644 --- a/app/views/groups/_projects.html.haml +++ b/app/views/groups/_projects.html.haml @@ -8,14 +8,14 @@ New project %ul.well-list - if projects.blank? - %p.nothing_here_message This groups has no projects yet + .nothing-here-block This groups has no projects yet - projects.each do |project| %li.project-row = link_to project_path(project), class: dom_class(project) do - %span.project-name - = truncate(project.name, length: 25) + .dash-project-access-icon + = visibility_level_icon(project.visibility_level) + %span.str-truncated + %span.project-name + = truncate(project.name, length: 25) %span.arrow %i.icon-angle-right - %span.last-activity - %span Last activity: - %span.date= project_last_activity(project) diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml index 10b974ea22..500c37ab71 100644 --- a/app/views/groups/edit.html.haml +++ b/app/views/groups/edit.html.haml @@ -1,18 +1,20 @@ .row - .span2 + .col-md-2 %ul.nav.nav-pills.nav-stacked.nav-stacked-menu %li.active = link_to '#tab-edit', 'data-toggle' => 'tab' do %i.icon-edit - Edit Group + Group %li = link_to '#tab-projects', 'data-toggle' => 'tab' do %i.icon-folder-close Projects %li - = link_to 'Remove', '#tab-remove', 'data-toggle' => 'tab' + = link_to '#tab-remove', 'data-toggle' => 'tab' do + %i.icon-remove-sign + Remove - .span10 + .col-md-10 .tab-content .tab-pane.active#tab-edit .ui-box @@ -20,20 +22,40 @@ %strong= @group.name group settings: %div.form-holder - = form_for @group do |f| + = form_for @group, html: { multipart: true, class: "form-horizontal" }, authenticity_token: true do |f| - if @group.errors.any? - .alert.alert-error + .alert.alert-danger %span= @group.errors.full_messages.first - .control-group - = f.label :name do + .form-group + = f.label :name, class: 'control-label' do Group name - .controls - = f.text_field :name, placeholder: "Ex. OpenSource", class: "input-xxlarge left" + .col-sm-10 + = f.text_field :name, placeholder: "Ex. OpenSource", class: "form-control left" - .control-group.group-description-holder - = f.label :description, "Details" - .controls - = f.text_area :description, maxlength: 250, class: "input-xxlarge js-gfm-input", rows: 4 + .form-group.group-description-holder + = f.label :description, "Details", class: 'control-label' + .col-sm-10 + = f.text_area :description, maxlength: 250, class: "form-control js-gfm-input", rows: 4 + + .form-group + .col-sm-2 + .col-sm-10 + = image_tag group_icon(@group.to_param), alt: '', class: 'avatar s160' + %p.light + - if @group.avatar? + You can change your group avatar here + - else + You can upload an group avatar here + %a.choose-btn.btn.btn-small.js-choose-group-avatar-button + %i.icon-paper-clip + %span Choose File ... +   + %span.file_name.js-avatar-filename File name... + = f.file_field :avatar, class: "js-group-avatar-input hidden" + .light The maximum file size allowed is 100KB. + - if @group.avatar? + %hr + = link_to 'Remove avatar', group_avatar_path(@group.to_param), data: { confirm: "Group avatar will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-small remove-avatar" .form-actions = f.submit 'Save group', class: "btn btn-save" @@ -51,25 +73,23 @@ %ul.well-list - @group.projects.each do |project| %li - - if project.public - = public_icon - - else - = private_icon - = link_to project.name_with_namespace, project + .list-item-name + = visibility_level_icon(project.visibility_level) + = link_to project.name_with_namespace, project .pull-right = link_to 'Members', project_team_index_path(project), id: "edit_#{dom_id(project)}", class: "btn btn-small" = link_to 'Edit', edit_project_path(project), id: "edit_#{dom_id(project)}", class: "btn btn-small" - = link_to 'Remove', project, confirm: remove_project_message(project), method: :delete, class: "btn btn-small btn-remove" + = link_to 'Remove', project, data: { confirm: remove_project_message(project)}, method: :delete, class: "btn btn-small btn-remove" - if @group.projects.blank? - %p.nothing_here_message This group has no projects yet + .nothing-here-block This group has no projects yet .tab-pane#tab-remove .ui-box.ui-box-danger .title Remove group - .ui-box-body + .body %p Removing group will cause all child projects and resources to be removed. %p %strong Removed group can not be restored! - = link_to 'Remove Group', @group, confirm: 'Removed group can not be restored! Are you sure?', method: :delete, class: "btn btn-remove" + = link_to 'Remove Group', @group, data: {confirm: 'Removed group can not be restored! Are you sure?'}, method: :delete, class: "btn btn-remove" diff --git a/app/views/groups/issues.html.haml b/app/views/groups/issues.html.haml index 482613f172..4b11d91dc9 100644 --- a/app/views/groups/issues.html.haml +++ b/app/views/groups/issues.html.haml @@ -1,15 +1,17 @@ %h3.page-title - Issues assigned to me + Issues %span.pull-right #{@issues.total_count} issues %p.light Only issues from %strong #{@group.name} - group are listed here. To see all issues you should visit #{link_to 'dashboard', issues_dashboard_path} page. + group are listed here. + - if current_user + To see all issues you should visit #{link_to 'dashboard', issues_dashboard_path} page. %hr .row - .span3 + .col-md-3 = render 'shared/filter', entity: 'issue' - .span9 + .col-md-9 = render 'shared/issues' diff --git a/app/views/groups/members.html.haml b/app/views/groups/members.html.haml index 124560e478..fa44ee2ae1 100644 --- a/app/views/groups/members.html.haml +++ b/app/views/groups/members.html.haml @@ -1,20 +1,41 @@ +- show_roles = should_user_see_group_roles?(current_user, @group) %h3.page-title Group members -%p.light - Members of group have access to all group projects. - Read more about permissions - %strong= link_to "here", help_permissions_path, class: "vlink" +- if show_roles + %p.light + Members of group have access to all group projects. + Read more about permissions + %strong= link_to "here", help_permissions_path, class: "vlink" %hr -- can_manage_group = current_user.can? :manage_group, @group -.ui-box + +.clearfix.js-toggle-container + = form_tag members_group_path(@group), method: :get, class: 'form-inline member-search-form' do + .form-group + = search_field_tag :search, params[:search], { placeholder: 'Find existing member by name', class: 'form-control search-text-input input-mn-300' } + = submit_tag 'Search', class: 'btn' + + - if current_user && current_user.can?(:manage_group, @group) + .pull-right + = link_to '#', class: 'btn btn-new js-toggle-button' do + Add members + %i.icon-chevron-down + + .js-toggle-content.hide.new-group-member-holder + = render "new_group_member" + +.ui-box.prepend-top-20 .title %strong #{@group.name} group members %small - (#{@members.count}) + (#{@members.total_count}) %ul.well-list - @members.each do |member| - = render 'users_groups/users_group', member: member, show_controls: can_manage_group -- if can_manage_group - = render "new_group_member" + = render 'users_groups/users_group', member: member, show_roles: show_roles, show_controls: true += paginate @members, theme: 'gitlab' + +:coffeescript + $('form.member-search-form').on 'submit', (event) -> + event.preventDefault() + Turbolinks.visit @.action + '?' + $(@).serialize() diff --git a/app/views/groups/merge_requests.html.haml b/app/views/groups/merge_requests.html.haml index 8a9b03535b..209130ec44 100644 --- a/app/views/groups/merge_requests.html.haml +++ b/app/views/groups/merge_requests.html.haml @@ -3,12 +3,14 @@ %span.pull-right #{@merge_requests.total_count} merge requests %p.light - Authored or assigned to you from + Only merge requests from %strong #{@group.name} - group. To see all merge requests you should visit #{link_to 'dashboard', merge_requests_dashboard_path} page. + group are listed here. + - if current_user + To see all merge requests you should visit #{link_to 'dashboard', merge_requests_dashboard_path} page. %hr .row - .span3 + .col-md-3 = render 'shared/filter', entity: 'merge_request' - .span9 + .col-md-9 = render 'shared/merge_requests' diff --git a/app/views/groups/new.html.haml b/app/views/groups/new.html.haml index d6d514e9b1..955a107e54 100644 --- a/app/views/groups/new.html.haml +++ b/app/views/groups/new.html.haml @@ -1,20 +1,21 @@ -= form_for @group do |f| += form_for @group, html: { class: 'group-form form-horizontal' } do |f| - if @group.errors.any? - .alert.alert-error + .alert.alert-danger %span= @group.errors.full_messages.first - .control-group - = f.label :name do + .form-group + = f.label :name, class: 'control-label' do Group name - .controls - = f.text_field :name, placeholder: "Ex. OpenSource", class: "input-xxlarge left" + .col-sm-10 + = f.text_field :name, placeholder: "Ex. OpenSource", class: "form-control" - .control-group.group-description-holder - = f.label :description, "Details" - .controls - = f.text_area :description, maxlength: 250, class: "input-xxlarge js-gfm-input", rows: 4 + .form-group.group-description-holder + = f.label :description, "Details", class: 'control-label' + .col-sm-10 + = f.text_area :description, maxlength: 250, class: "form-control js-gfm-input", rows: 4 - .control-group - .controls + .form-group + .col-sm-2 + .col-sm-10 %ul %li A group is a collection of several projects %li Groups are private by default diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index e613ed3eaa..0c62772a5c 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -1,27 +1,33 @@ .dashboard - .activities.span8 - = render "events/event_last_push", event: @last_push - = link_to dashboard_path, class: 'btn btn-tiny' do - ← To dashboard -   + .activities.col-md-8.hidden-sm.hidden-xs + - if current_user + = render "events/event_last_push", event: @last_push + = link_to dashboard_path, class: 'btn btn-tiny' do + ← To dashboard +   %span.cgray You will only see events from projects in this group %hr = render 'shared/event_filter' - if @events.any? .content_list - else - %p.nothing_here_message Project activity will be displayed here - .loading.hide - .side.span4 - - if @group.description.present? - .description-block - = @group.description + .nothing-here-block Project activity will be displayed here + = spinner + .side.col-md-4 + .light-well.append-bottom-20 + = image_tag group_icon(@group.path), class: "avatar s90" + .clearfix.light + %h3.page-title + = @group.name + - if @group.description.present? + %p= @group.description = render "projects", projects: @projects - .prepend-top-20 - = link_to group_path(@group, { format: :atom, private_token: current_user.private_token }), title: "Feed" do - %strong - %i.icon-rss - News Feed + - if current_user + .prepend-top-20 + = link_to group_path(@group, { format: :atom, private_token: current_user.private_token }), title: "Feed" do + %strong + %i.icon-rss + News Feed %hr = render 'shared/promo' diff --git a/app/views/groups/show.js.haml b/app/views/groups/show.js.haml deleted file mode 100644 index 7e5a148e5e..0000000000 --- a/app/views/groups/show.js.haml +++ /dev/null @@ -1,2 +0,0 @@ -:plain - Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}"); diff --git a/app/views/help/_api_layout.html.haml b/app/views/help/_api_layout.html.haml index 502cc31a80..af723f906d 100644 --- a/app/views/help/_api_layout.html.haml +++ b/app/views/help/_api_layout.html.haml @@ -1,13 +1,13 @@ .row - .span3 + .col-md-3 .append-bottom-20 = link_to help_path, class: 'btn btn-small' do %i.icon-angle-left Back to help %ul.nav.nav-pills.nav-stacked - - %w(README projects project_snippets repositories deploy_keys users groups session issues milestones merge_requests notes system_hooks).each do |file| + - %w(README projects project_snippets repositories repository_files commits deploy_keys users groups session issues milestones merge_requests notes system_hooks).each do |file| %li{class: file == @category ? 'active' : nil} = link_to file.titleize, help_api_file_path(file) - .span9.pull-right + .col-md-9.pull-right = yield diff --git a/app/views/help/_layout.html.haml b/app/views/help/_layout.html.haml index da917888ee..201d63ca24 100644 --- a/app/views/help/_layout.html.haml +++ b/app/views/help/_layout.html.haml @@ -1,37 +1,12 @@ .row - .span3{:"data-spy" => 'affix'} - .ui-box - .title - Help - %ul.well-list - %li - %strong= link_to "Workflow", help_workflow_path - %li - %strong= link_to "SSH keys", help_ssh_path + .col-md-3 + %h3.page-title Help + %ul.nav.nav-pills.nav-stacked + - links = {:"Workflow" => help_workflow_path, :"SSH Keys" => help_ssh_path, :"GitLab Markdown" => help_markdown_path, :"Permissions" => help_permissions_path, :"API" => help_api_path, :"Web Hooks" => help_web_hooks_path, :"Rake Tasks" => help_raketasks_path, :"System Hooks" => help_system_hooks_path, :"Public Access" => help_public_access_path, :"Security" => help_security_path} + - links.each do |title,path| + %li{class: current_page?(path) ? 'active' : nil} + = link_to title, path - %li - %strong= link_to "GitLab Markdown", help_markdown_path - - %li - %strong= link_to "Permissions", help_permissions_path - - %li - %strong= link_to "API", help_api_path - - %li - %strong= link_to "Web Hooks", help_web_hooks_path - - %li - %strong= link_to "Rake Tasks", help_raketasks_path - - %li - %strong= link_to "System Hooks", help_system_hooks_path - - %li - %strong= link_to "Public Access", help_public_access_path - - %li - %strong= link_to "Security", help_security_path - - .span9.pull-right - = yield + .col-md-9 + .wiki + = yield diff --git a/app/views/help/_shortcuts.html.haml b/app/views/help/_shortcuts.html.haml index e979e7c0d0..500e5dc65e 100644 --- a/app/views/help/_shortcuts.html.haml +++ b/app/views/help/_shortcuts.html.haml @@ -1,30 +1,32 @@ -#modal-shortcuts.modal.hide - .modal-header - %a.close{href: "#", "data-dismiss" => "modal"} × - %h3 Keyboard Shortcuts - .modal-body - %h5 Global Shortcuts - %p - %span.label.label-inverse s - – - Focus Search - %p - %span.label.label-inverse ? - – - Show this dialog +#modal-shortcuts.modal.hide{tabindex: -1} + .modal-dialog + .modal-content + .modal-header + %a.close{href: "#", "data-dismiss" => "modal"} × + %h3 Keyboard Shortcuts + .modal-body + %h5 Global Shortcuts + %p + %span.label.label-inverse s + – + Focus Search + %p + %span.label.label-inverse ? + – + Show this dialog - %h5 Project Files browsing - %p - %span.label.label-inverse - %i.icon-arrow-up - – - Move selection up - %p - %span.label.label-inverse - %i.icon-arrow-down - – - Move selection down - %p - %span.label.label-inverse Enter - – - Open selection + %h5 Project Files browsing + %p + %span.label.label-inverse + %i.icon-arrow-up + – + Move selection up + %p + %span.label.label-inverse + %i.icon-arrow-down + – + Move selection down + %p + %span.label.label-inverse Enter + – + Open selection diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index 869f87df4d..724fe1d6b3 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -1,4 +1,4 @@ -.hero-unit +.jumbotron %h2 GitLab %span= Gitlab::VERSION @@ -6,19 +6,25 @@ %p.slead GitLab is open source software to collaborate on code. %br - Create projects and repositories, manage access and do code reviews. + Manage git repositories with fine grained access controls that keep your code secure. %br - Read more about GitLab at #{link_to "gitlab.org", "http://gitlab.org/", target: "_blank"}. + Perform code reviews and enhance collaboration with merge requests. + %br + Each project can also have an issue tracker and a wiki. + %br + Used by more than 100,000 organizations, GitLab is the most popular solution to manage git repositories on-premises. + %br + Read more about GitLab at #{link_to "www.gitlab.com", "https://www.gitlab.com/", target: "_blank"}. .row - .span4 + .col-md-4 .ui-box .title Quick help %ul.well-list %li - Email your - = mail_to gitlab_config.support_email, "support contact" + See our website for + = link_to "getting help", "https://www.gitlab.com/getting-help/" %li Use the = link_to "search bar", '#', onclick: "$('#search').focus();" @@ -26,16 +32,8 @@ %li Use = link_to "shortcuts", '#', onclick: "new Shortcuts()" - %li - Ask in our - = link_to "mailing list", "https://groups.google.com/forum/#!forum/gitlabhq" - or on - = link_to "Stack Overflow", "http://stackoverflow.com/questions/tagged/gitlab" - %li - Browse our - = link_to "issue tracker", "https://github.com/gitlabhq/gitlabhq/issues" - .span4 + .col-md-4 .ui-box .title User documentation @@ -64,7 +62,7 @@ %strong= link_to "Web Hooks", help_web_hooks_path %p Let GitLab notify you when new code has been pushed to your project. - .span4 + .col-md-4 .ui-box .title Admin documentation diff --git a/app/views/help/permissions.html.haml b/app/views/help/permissions.html.haml index df35f41fc9..5d3ee4526f 100644 --- a/app/views/help/permissions.html.haml +++ b/app/views/help/permissions.html.haml @@ -1,212 +1,6 @@ = render layout: 'help/layout' do - %h3.page-title Permissions - %p.light Users have different abilities depending on the access level they have in particular group or project. - %p.light If a user is both in a project group and in the project itself the highest permission level is used. - %p.light If a user is a GitLab administrator they receive all permissions. - %hr + %h3.page-title Permissions - %h4 Project: - %table.table - %thead - %tr - %th Action - %th Guest - %th Reporter - %th Developer - %th Master - %th Owner - %tbody - %tr - %td Create new issue - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Leave comments - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Write on project wall - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Pull project code - %td - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Download project - %td - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Create code snippets - %td - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Create new merge request - %td - %td - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Create new branches - %td - %td - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Push to non-protected branches - %td - %td - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Remove non-protected branches - %td - %td - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Add tags - %td - %td - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Write a wiki - %td - %td - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Add new team members - %td - %td - %td - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Push to protected branches - %td - %td - %td - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Remove protected branches - %td - %td - %td - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Edit project - %td - %td - %td - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Add Deploy Keys to project - %td - %td - %td - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Configure Project Hooks - %td - %td - %td - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Switch public mode - %td - %td - %td - %td - %td.permission-x ✓ - %tr - %td Transfer project to another namespace - %td - %td - %td - %td - %td.permission-x ✓ - %tr - %td Remove project - %td - %td - %td - %td - %td.permission-x ✓ - - %h4 Group - %table.table - %thead - %tr - %th Action - %th Guest - %th Reporter - %th Developer - %th Master - %th Owner - %tbody - %tr - %td Browse group - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %td.permission-x ✓ - %tr - %td Edit group - %td - %td - %td - %td - %td.permission-x ✓ - %tr - %td Create project in group - %td - %td - %td - %td - %td.permission-x ✓ - %tr - %td Manage group members - %td - %td - %td - %td - %td.permission-x ✓ - %tr - %td Remove group - %td - %td - %td - %td - %td.permission-x ✓ + .help_body + = preserve do + = markdown File.read(Rails.root.join("doc", "permissions", "permissions.md")) diff --git a/app/views/help/public_access.html.haml b/app/views/help/public_access.html.haml index c67402ee31..d1ec3f5d5c 100644 --- a/app/views/help/public_access.html.haml +++ b/app/views/help/public_access.html.haml @@ -1,15 +1,6 @@ = render layout: 'help/layout' do - %h3.page-title Public Access - - %p - GitLab allows you to open selected projects to be accessed publicly. - These projects will be cloneable - %em without any - authentication. - Also they will be listed on the #{link_to "public access directory", public_root_path}. - - %ol - %li Go to your project dashboard - %li Click on the "Edit" tab - %li Select "Public clone access" + %h3.page-title Public Access + .help_body + = preserve do + = markdown File.read(Rails.root.join("doc", "public_access", "public_access.md")) diff --git a/app/views/help/ssh.html.haml b/app/views/help/ssh.html.haml index 72a21b89ca..75419c3dd0 100644 --- a/app/views/help/ssh.html.haml +++ b/app/views/help/ssh.html.haml @@ -1,22 +1,6 @@ = render layout: 'help/layout' do - %h3.page-title SSH Keys + %h3.page-title SSH Keys - %p.slead - SSH key allows you to establish a secure connection between your computer and GitLab - - %p.slead - To generate a new SSH key just open your terminal and use code below. - - %pre.dark - ssh-keygen -t rsa -C "#{current_user.email}" - - \# Creates a new ssh key using the provided email - \# Generating public/private rsa key pair... - - %p.slead - Next just use code below to dump your public key and add to GitLab SSH Keys - - %pre.dark - cat ~/.ssh/id_rsa.pub - - \# ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc.... + .help_body + = preserve do + = markdown File.read(Rails.root.join("doc", "ssh", "ssh.md")).gsub("$your_email", current_user.email) diff --git a/app/views/help/system_hooks.html.haml b/app/views/help/system_hooks.html.haml index 3e401a6e19..e24f566121 100644 --- a/app/views/help/system_hooks.html.haml +++ b/app/views/help/system_hooks.html.haml @@ -1,11 +1,6 @@ = render layout: 'help/layout' do - %h3.page-title System hooks + %h3.page-title System hooks - %p.slead - Your GitLab instance can perform HTTP POST requests on the following events: create_project, delete_project, create_user, delete_user, change_team_member. - %br - %br - System Hooks can be used, e.g. for logging or changing information in a LDAP server. - %br - %h5 Hooks request example: - = render "admin/hooks/data_ex" + .help_body + = preserve do + = markdown File.read(Rails.root.join("doc", "system_hooks", "system_hooks.md")) diff --git a/app/views/help/web_hooks.html.haml b/app/views/help/web_hooks.html.haml index 25865251de..9e2b54ab6e 100644 --- a/app/views/help/web_hooks.html.haml +++ b/app/views/help/web_hooks.html.haml @@ -1,12 +1,6 @@ = render layout: 'help/layout' do - %h3.page-title Web hooks - - %p.slead - Every GitLab project can trigger a web server whenever the repo is pushed to. - %br - Web Hooks can be used to update an external issue tracker, trigger CI builds, update a backup mirror, or even deploy to your production server. - %br - GitLab will send POST request with commits information on every push. - %h5 Hooks request example: - = render "projects/hooks/data_ex" + %h3.page-title Project web hooks + .help_body + = preserve do + = markdown File.read(Rails.root.join("doc", "web_hooks", "web_hooks.md")) diff --git a/app/views/help/workflow.html.haml b/app/views/help/workflow.html.haml index 2b8950cd5c..47de4ad796 100644 --- a/app/views/help/workflow.html.haml +++ b/app/views/help/workflow.html.haml @@ -1,37 +1,6 @@ = render layout: 'help/layout' do - %h3.page-title Workflow - - %ol.help - %li - %p Clone project - .bash - %pre.dark - git clone git@example.com:project-name.git - - %li - %p Create branch with your feature - .bash - %pre.dark - git checkout -b $feature_name - - %li - %p Write code. Commit changes - .bash - %pre.dark - git commit -am "My feature is ready" - - %li - %p Push your branch to GitLab - .bash - %pre.dark - git push origin $feature_name - - %li - %p Review your code on Commits page - - %li - %p Create a merge request - - %li - %p Your team lead will review code & merge it to main branch + %h3.page-title Workflow + .help_body + = preserve do + = markdown File.read(Rails.root.join("doc", "workflow", "workflow.md")) diff --git a/app/views/kaminari/gitlab/_paginator.html.haml b/app/views/kaminari/gitlab/_paginator.html.haml index 6f9fb33226..4f7996e499 100644 --- a/app/views/kaminari/gitlab/_paginator.html.haml +++ b/app/views/kaminari/gitlab/_paginator.html.haml @@ -6,8 +6,8 @@ -# remote: data-remote -# paginator: the paginator that renders the pagination tags inside = paginator.render do - %div.pagination - %ul + %div.gl-pagination + %ul.pagination = prev_page_tag unless current_page.first? - each_page do |page| - if page.left_outer? || page.right_outer? || page.inside_window? diff --git a/app/views/layouts/_broadcast.html.haml b/app/views/layouts/_broadcast.html.haml new file mode 100644 index 0000000000..5794e3de33 --- /dev/null +++ b/app/views/layouts/_broadcast.html.haml @@ -0,0 +1,4 @@ +- if broadcast_message.present? + .broadcast-message{ style: broadcast_styling(broadcast_message) } + %i.icon-bullhorn + = broadcast_message.message diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 0775abea3d..d9a7a2d31c 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -4,12 +4,16 @@ = "#{title} | " if defined?(title) GitLab = favicon_link_tag 'favicon.ico' - = stylesheet_link_tag "application" + = stylesheet_link_tag "application", :media => "all" + = stylesheet_link_tag "print", :media => "print" = javascript_include_tag "application" = csrf_meta_tags = include_gon + :erb + = render 'layouts/google_analytics' if extra_config.has_key?('google_analytics_id') + = render 'layouts/piwik' if extra_config.has_key?('piwik_url') && extra_config.has_key?('piwik_site_id') -# Atom feed - if current_user @@ -20,3 +24,8 @@ = 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") + + -# Go repository retrieval support. + - if controller_name == 'projects' && action_name == 'show' + %meta{name: "go-import", content: "#{@project.web_url_without_protocol} git #{@project.web_url}.git"} + diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml index 80c42fe638..fba56b5dc3 100644 --- a/app/views/layouts/_head_panel.html.haml +++ b/app/views/layouts/_head_panel.html.haml @@ -6,35 +6,43 @@ = link_to root_path, class: "home has_bottom_tooltip", title: "Dashboard" do %h1 GITLAB %span.separator - %h1.project_name= title - %ul.nav - %li - %a - %div.hide.turbolink-spinner - %i.icon-refresh.icon-spin - Loading... - %li - = render "layouts/search" - %li - = link_to public_root_path, title: "Public area", class: 'has_bottom_tooltip', 'data-original-title' => 'Public area' do - %i.icon-globe - %li - = link_to user_snippets_path(current_user), title: "My snippets", class: 'has_bottom_tooltip', 'data-original-title' => 'Public area' do - %i.icon-paste - - if current_user.is_admin? + %h1.title= title + + %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"} + %span.sr-only Toggle navigation + %i.icon-reorder + + .navbar-collapse.collapse + %ul.nav.navbar-nav + %li.hidden-sm.hidden-xs + = render "layouts/search" + %li.visible-sm.visible-xs + = link_to search_path, title: "Search", class: 'has_bottom_tooltip', 'data-original-title' => 'Search area' do + %i.icon-search %li - = link_to admin_root_path, title: "Admin area", class: 'has_bottom_tooltip', 'data-original-title' => 'Admin area' do - %i.icon-cogs - - if current_user.can_create_project? + = link_to help_path, title: 'Help', class: 'has_bottom_tooltip', + 'data-original-title' => 'Help' do + %i.icon-question-sign %li - = link_to new_project_path, title: "New project", class: 'has_bottom_tooltip', 'data-original-title' => 'New project' do - %i.icon-plus - %li - = link_to profile_path, title: "Profile settings", class: 'has_bottom_tooltip', 'data-original-title' => 'Profile settings"' do - %i.icon-user - %li - = link_to destroy_user_session_path, class: "logout", method: :delete, title: "Logout", class: 'has_bottom_tooltip', 'data-original-title' => 'Logout' do - %i.icon-signout - %li - = link_to current_user, class: "profile-pic", id: 'profile-pic' do - = image_tag avatar_icon(current_user.email, 26), alt: 'User activity' + = link_to public_root_path, title: "Public area", class: 'has_bottom_tooltip', 'data-original-title' => 'Public area' do + %i.icon-globe + %li + = link_to user_snippets_path(current_user), title: "My snippets", class: 'has_bottom_tooltip', 'data-original-title' => 'My snippets' do + %i.icon-paste + - if current_user.is_admin? + %li + = link_to admin_root_path, title: "Admin area", class: 'has_bottom_tooltip', 'data-original-title' => 'Admin area' do + %i.icon-cogs + - if current_user.can_create_project? + %li + = link_to new_project_path, title: "New project", class: 'has_bottom_tooltip', 'data-original-title' => 'New project' do + %i.icon-plus + %li + = link_to profile_path, title: "Profile settings", class: 'has_bottom_tooltip', 'data-original-title' => 'Profile settings"' do + %i.icon-user + %li + = link_to destroy_user_session_path, class: "logout", method: :delete, title: "Logout", class: 'has_bottom_tooltip', 'data-original-title' => 'Logout' do + %i.icon-signout + %li.hidden-xs + = link_to current_user, class: "profile-pic", id: 'profile-pic' do + = image_tag avatar_icon(current_user.email, 26), alt: 'User activity' diff --git a/app/views/layouts/_init_auto_complete.html.haml b/app/views/layouts/_init_auto_complete.html.haml index 7d16a75af6..353f7ce34f 100644 --- a/app/views/layouts/_init_auto_complete.html.haml +++ b/app/views/layouts/_init_auto_complete.html.haml @@ -1,4 +1,3 @@ :javascript - GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_project_path(@project)}" - GitLab.GfmAutoComplete.Emoji.assetBase = '#{image_path("emoji")}' + GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_project_path(@project, type: @noteable.class, type_id: params[:id])}" GitLab.GfmAutoComplete.setup(); diff --git a/app/views/layouts/_piwik.html.haml b/app/views/layouts/_piwik.html.haml new file mode 100644 index 0000000000..135e8daca2 --- /dev/null +++ b/app/views/layouts/_piwik.html.haml @@ -0,0 +1,12 @@ +:javascript + var _paq = _paq || []; + _paq.push(["trackPageView"]); + _paq.push(["enableLinkTracking"]); + + (function() { + var u=(("https:" == document.location.protocol) ? "https" : "http") + "://#{extra_config.piwik_url}/"; + _paq.push(["setTrackerUrl", u+"piwik.php"]); + _paq.push(["setSiteId", "#{extra_config.piwik_site_id}"]); + var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript"; + g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s); + })(); diff --git a/app/views/layouts/_public_head_panel.html.haml b/app/views/layouts/_public_head_panel.html.haml index 3c4bd857c2..63992a22f3 100644 --- a/app/views/layouts/_public_head_panel.html.haml +++ b/app/views/layouts/_public_head_panel.html.haml @@ -6,17 +6,17 @@ = link_to public_root_path, class: "home" do %h1 GITLAB %span.separator - %h1.project_name - - if @project - = project_title(@project) - - else - Public Projects + %h1.title= title + + %button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"} + %span.sr-only Toggle navigation + %i.icon-reorder + + .pull-right.hidden-xs + = link_to "Sign in", new_session_path(:user), class: 'btn btn-sign-in btn-new' + + .navbar-collapse.collapse + %ul.nav.navbar-nav + %li.visible-xs + = link_to "Sign in", new_session_path(:user) - %ul.nav - %li - %a - %div.hide.turbolink-spinner - %i.icon-refresh.icon-spin - Loading... - %li - = link_to "Sign in", new_session_path(:user), class: 'btn btn-sign-in' diff --git a/app/views/layouts/_search.html.haml b/app/views/layouts/_search.html.haml index 9a0db99332..a0e55b21c3 100644 --- a/app/views/layouts/_search.html.haml +++ b/app/views/layouts/_search.html.haml @@ -7,4 +7,4 @@ = hidden_field_tag :search_code, true = hidden_field_tag :repository_ref, @ref = submit_tag 'Go' if ENV['RAILS_ENV'] == 'test' - .search-autocomplete-json.hide{:'data-autocomplete-opts' => search_autocomplete_source } + .search-autocomplete-opts.hide{:'data-autocomplete-path' => search_autocomplete_path, :'data-autocomplete-project-id' => @project.try(:id), :'data-autocomplete-project-ref' => @ref } diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 3a23cbdb37..53e0dbaef9 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -2,9 +2,10 @@ %html{ lang: "en"} = render "layouts/head", title: "Admin area" %body{class: "#{app_theme} admin", :'data-page' => body_data_page} + = render "layouts/broadcast" = render "layouts/head_panel", title: "Admin area" = render "layouts/flash" - %nav.main-nav + %nav.main-nav.navbar-collapse.collapse .container= render 'layouts/nav/admin' .container diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 792fe5e4a2..511db389e0 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,9 +2,10 @@ %html{ lang: "en"} = render "layouts/head", title: "Dashboard" %body{class: "#{app_theme} application", :'data-page' => body_data_page } + = render "layouts/broadcast" = render "layouts/head_panel", title: "Dashboard" = render "layouts/flash" - %nav.main-nav + %nav.main-nav.navbar-collapse.collapse .container= render 'layouts/nav/dashboard' .container diff --git a/app/views/layouts/devise.html.haml b/app/views/layouts/devise.html.haml index c4729836fa..5d93ffa50a 100644 --- a/app/views/layouts/devise.html.haml +++ b/app/views/layouts/devise.html.haml @@ -10,6 +10,8 @@ %p.light GitLab is open source software to collaborate on code. %br - #{link_to "Sign in", new_user_session_path} or browse for #{link_to "public projects", public_projects_path}. - %hr + Sign in or browse for #{link_to "public projects", public_projects_path}. + %hr + .container + .content = yield diff --git a/app/views/layouts/group.html.haml b/app/views/layouts/group.html.haml index 0e955d59ff..fb4a3a3ba9 100644 --- a/app/views/layouts/group.html.haml +++ b/app/views/layouts/group.html.haml @@ -1,10 +1,11 @@ !!! 5 %html{ lang: "en"} - = render "layouts/head", title: "#{@group.name}" + = render "layouts/head", title: group_head_title %body{class: "#{app_theme} application", :'data-page' => body_data_page} + = render "layouts/broadcast" = render "layouts/head_panel", title: "group: #{@group.name}" = render "layouts/flash" - %nav.main-nav + %nav.main-nav.navbar-collapse.collapse .container= render 'layouts/nav/group' .container diff --git a/app/views/layouts/nav/_admin.html.haml b/app/views/layouts/nav/_admin.html.haml index 73946f9988..48c569f868 100644 --- a/app/views/layouts/nav/_admin.html.haml +++ b/app/views/layouts/nav/_admin.html.haml @@ -10,6 +10,8 @@ = link_to "Users", admin_users_path = nav_link(controller: :logs) do = link_to "Logs", admin_logs_path + = nav_link(controller: :broadcast_messages) do + = link_to "Messages", admin_broadcast_messages_path = nav_link(controller: :hooks) do = link_to "Hooks", admin_hooks_path = nav_link(controller: :background_jobs) do diff --git a/app/views/layouts/nav/_dashboard.html.haml b/app/views/layouts/nav/_dashboard.html.haml index cae24c3170..12fd49e609 100644 --- a/app/views/layouts/nav/_dashboard.html.haml +++ b/app/views/layouts/nav/_dashboard.html.haml @@ -12,7 +12,7 @@ = nav_link(path: 'dashboard#merge_requests') do = link_to merge_requests_dashboard_path do Merge Requests - %span.count= current_user.cared_merge_requests.opened.count + %span.count= current_user.assigned_merge_requests.opened.count = nav_link(controller: :help) do = link_to "Help", help_path diff --git a/app/views/layouts/nav/_group.html.haml b/app/views/layouts/nav/_group.html.haml index a8bb3b9155..36b102dc25 100644 --- a/app/views/layouts/nav/_group.html.haml +++ b/app/views/layouts/nav/_group.html.haml @@ -5,11 +5,13 @@ = nav_link(path: 'groups#issues') do = link_to issues_group_path(@group) do Issues - %span.count= current_user.assigned_issues.opened.of_group(@group).count + - if current_user + %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.opened.of_group(@group).count + - if current_user + %span.count= current_user.cared_merge_requests.opened.of_group(@group).count = nav_link(path: 'groups#members') do = link_to "Members", members_group_path(@group) diff --git a/app/views/layouts/nav/_profile.html.haml b/app/views/layouts/nav/_profile.html.haml index d44cb975ea..35d0d41750 100644 --- a/app/views/layouts/nav/_profile.html.haml +++ b/app/views/layouts/nav/_profile.html.haml @@ -4,6 +4,10 @@ %i.icon-home = nav_link(controller: :accounts) do = link_to "Account", profile_account_path + = nav_link(controller: :emails) do + = link_to profile_emails_path do + Emails + %span.count= current_user.emails.count + 1 - unless current_user.ldap_user? = nav_link(controller: :passwords) do = link_to "Password", edit_profile_password_path diff --git a/app/views/layouts/nav/_project.html.haml b/app/views/layouts/nav/_project.html.haml index e9d535f697..1f70cf1798 100644 --- a/app/views/layouts/nav/_project.html.haml +++ b/app/views/layouts/nav/_project.html.haml @@ -4,7 +4,7 @@ %i.icon-home - if project_nav_tab? :files - = nav_link(controller: %w(tree blob blame edit_tree)) do + = nav_link(controller: %w(tree blob blame edit_tree new_tree)) do = link_to 'Files', project_tree_path(@project, @ref || @repository.root_ref) - if project_nav_tab? :commits diff --git a/app/views/layouts/navless.html.haml b/app/views/layouts/navless.html.haml index 7325664bc1..c43d688a2c 100644 --- a/app/views/layouts/navless.html.haml +++ b/app/views/layouts/navless.html.haml @@ -2,6 +2,7 @@ %html{ lang: "en"} = render "layouts/head", title: @title %body{class: "#{app_theme} application", :'data-page' => body_data_page} + = render "layouts/broadcast" = render "layouts/head_panel", title: @title = render "layouts/flash" diff --git a/app/views/layouts/notify.html.haml b/app/views/layouts/notify.html.haml index f88abeca88..991d4f0c6d 100644 --- a/app/views/layouts/notify.html.haml +++ b/app/views/layouts/notify.html.haml @@ -3,20 +3,24 @@ %meta{content: "text/html; charset=utf-8", "http-equiv" => "Content-Type"} %title GitLab + :css + p.details { + font-style:italic; + color:#777 + } + .footer p { + font-size:small; + color:#777 + } %body - %h1{style: "background: #EEE; border-bottom: 1px solid #DDD; color: #474D57; font: normal 20px Helvetica, Arial, sans-serif; margin: 0; padding: 5px 10px; line-height: 32px; font-size: 16px;"} - GitLab - - if @project - \| - = link_to @project.name_with_namespace, project_url(@project), style: 'color: #29B; text-decoration: none' - %table{align: "left", border: "0", cellpadding: "0", cellspacing: "0", style: "padding: 10px 0;", width: "100%"} - %tr - %td{align: "left", style: "margin: 0; padding: 10px;"} - = yield - %br - %tr - %td{align: "left", style: "margin: 0; padding: 10px;"} - %p{style: "font-size:small;color:#777"} - - if @project - You're receiving this notification because you are a member of the #{@project.name_with_namespace} project team. + %div.content + = yield + %div.footer{style: "margin-top: 10px;"} + %p + \— + %br + - if @project + You're receiving this notification because you are a member of the #{link_to_unless @target_url, @project.name_with_namespace, project_url(@project)} project team. + - if @target_url + #{link_to "View it on GitLab", @target_url} diff --git a/app/views/layouts/profile.html.haml b/app/views/layouts/profile.html.haml index 30a0532bc2..2d869a6cdc 100644 --- a/app/views/layouts/profile.html.haml +++ b/app/views/layouts/profile.html.haml @@ -2,9 +2,10 @@ %html{ lang: "en"} = render "layouts/head", title: "Profile" %body{class: "#{app_theme} profile", :'data-page' => body_data_page} + = render "layouts/broadcast" = render "layouts/head_panel", title: "Profile" = render "layouts/flash" - %nav.main-nav + %nav.main-nav.navbar-collapse.collapse .container= render 'layouts/nav/profile' .container diff --git a/app/views/layouts/project_settings.html.haml b/app/views/layouts/project_settings.html.haml index ea739da73d..5659cfab31 100644 --- a/app/views/layouts/project_settings.html.haml +++ b/app/views/layouts/project_settings.html.haml @@ -2,19 +2,20 @@ %html{ lang: "en"} = render "layouts/head", title: @project.name_with_namespace %body{class: "#{app_theme} project", :'data-page' => body_data_page, :'data-project-id' => @project.id } + = render "layouts/broadcast" = render "layouts/head_panel", title: project_title(@project) = render "layouts/init_auto_complete" = render "layouts/flash" - if can?(current_user, :download_code, @project) = render 'shared/no_ssh' - %nav.main-nav + %nav.main-nav.navbar-collapse.collapse .container= render 'layouts/nav/project' .container .content .row - .span2 + .col-md-2 = render "projects/settings_nav" - .span10 + .col-md-10 = yield diff --git a/app/views/layouts/projects.html.haml b/app/views/layouts/projects.html.haml index 6d8bf9b710..3ae4961b13 100644 --- a/app/views/layouts/projects.html.haml +++ b/app/views/layouts/projects.html.haml @@ -1,14 +1,15 @@ !!! 5 %html{ lang: "en"} - = render "layouts/head", title: @project.name_with_namespace + = render "layouts/head", title: project_head_title %body{class: "#{app_theme} project", :'data-page' => body_data_page, :'data-project-id' => @project.id } + = render "layouts/broadcast" = render "layouts/head_panel", title: project_title(@project) = render "layouts/init_auto_complete" = render "layouts/flash" - if can?(current_user, :download_code, @project) = render 'shared/no_ssh' - %nav.main-nav + %nav.main-nav.navbar-collapse.collapse .container= render 'layouts/nav/project' .container diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml index f922dcc420..3c76bbb957 100644 --- a/app/views/layouts/public.html.haml +++ b/app/views/layouts/public.html.haml @@ -1,11 +1,11 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: "Public Projects" - %body{class: "ui_mars application", :'data-page' => body_data_page} + %body{class: "#{app_theme} application", :'data-page' => body_data_page} + = render "layouts/broadcast" - if current_user = render "layouts/head_panel", title: "Public Projects" - else - = render "layouts/public_head_panel" - + = render "layouts/public_head_panel", title: "Public Projects" .container.navless-container .content= yield diff --git a/app/views/layouts/public_group.html.haml b/app/views/layouts/public_group.html.haml new file mode 100644 index 0000000000..a289b78472 --- /dev/null +++ b/app/views/layouts/public_group.html.haml @@ -0,0 +1,10 @@ +!!! 5 +%html{ lang: "en"} + = render "layouts/head", title: group_head_title + %body{class: "#{app_theme} application", :'data-page' => body_data_page} + = render "layouts/broadcast" + = render "layouts/public_head_panel", title: "group: #{@group.name}" + %nav.main-nav.navbar-collapse.collapse + .container= render 'layouts/nav/group' + .container + .content= yield diff --git a/app/views/layouts/public_projects.html.haml b/app/views/layouts/public_projects.html.haml index cfe6a63055..2a9230244f 100644 --- a/app/views/layouts/public_projects.html.haml +++ b/app/views/layouts/public_projects.html.haml @@ -1,9 +1,10 @@ !!! 5 %html{ lang: "en"} = render "layouts/head", title: @project.name_with_namespace - %body{class: "ui_mars application", :'data-page' => body_data_page} - = render "layouts/public_head_panel" - %nav.main-nav + %body{class: "#{app_theme} application", :'data-page' => body_data_page} + = render "layouts/broadcast" + = render "layouts/public_head_panel", title: project_title(@project) + %nav.main-nav.navbar-collapse.collapse .container= render 'layouts/nav/project' .container .content= yield diff --git a/app/views/layouts/public_users.html.haml b/app/views/layouts/public_users.html.haml new file mode 100644 index 0000000000..4aa258fea0 --- /dev/null +++ b/app/views/layouts/public_users.html.haml @@ -0,0 +1,8 @@ +!!! 5 +%html{ lang: "en"} + = render "layouts/head", title: @title + %body{class: "#{app_theme} application", :'data-page' => body_data_page} + = render "layouts/broadcast" + = render "layouts/public_head_panel", title: @title + .container.navless-container + .content= yield diff --git a/app/views/layouts/search.html.haml b/app/views/layouts/search.html.haml index 177b3a4f8f..97ed8ba12d 100644 --- a/app/views/layouts/search.html.haml +++ b/app/views/layouts/search.html.haml @@ -2,6 +2,7 @@ %html{ lang: "en"} = render "layouts/head", title: "Search" %body{class: "#{app_theme} application", :'data-page' => body_data_page} + = render "layouts/broadcast" = render "layouts/head_panel", title: "Search" = render "layouts/flash" diff --git a/app/views/layouts/user_team.html.haml b/app/views/layouts/user_team.html.haml index e64e68d244..ce13853ed7 100644 --- a/app/views/layouts/user_team.html.haml +++ b/app/views/layouts/user_team.html.haml @@ -2,9 +2,10 @@ %html{ lang: "en"} = render "layouts/head", title: "#{@team.name}" %body{class: "#{app_theme} application", :'data-page' => body_data_page} + = render "layouts/broadcast" = render "layouts/head_panel", title: "team: #{@team.name}" = render "layouts/flash" - %nav.main-nav + %nav.main-nav.navbar-collapse.collapse .container= render 'layouts/nav/team' .container diff --git a/app/views/notify/_note_message.html.haml b/app/views/notify/_note_message.html.haml index 88c4df55b7..5272dfa0ed 100644 --- a/app/views/notify/_note_message.html.haml +++ b/app/views/notify/_note_message.html.haml @@ -1,6 +1,2 @@ -%p - %strong #{@note.author_name} - left next message: - -%cite{style: 'color: #666'} +%div = markdown(@note.note) diff --git a/app/views/notify/closed_issue_email.html.haml b/app/views/notify/closed_issue_email.html.haml index 325cd44eb4..56c18cd83c 100644 --- a/app/views/notify/closed_issue_email.html.haml +++ b/app/views/notify/closed_issue_email.html.haml @@ -1,5 +1,2 @@ %p = "Issue was closed by #{@updated_by.name}" -%p - = "Issue ##{@issue.iid}" - = link_to_gfm truncate(@issue.title, length: 45), project_issue_url(@issue.project, @issue), title: @issue.title diff --git a/app/views/notify/closed_merge_request_email.html.haml b/app/views/notify/closed_merge_request_email.html.haml index 45770cc85d..574e8bfef2 100644 --- a/app/views/notify/closed_merge_request_email.html.haml +++ b/app/views/notify/closed_merge_request_email.html.haml @@ -1,9 +1,2 @@ %p - = "Merge Request #{@merge_request.iid} was closed by #{@updated_by.name}" -%p - = link_to_gfm truncate(@merge_request.title, length: 40), project_merge_request_url(@merge_request.target_project, @merge_request) -%p - != merge_path_description(@merge_request, '→') -%p - Assignee: #{@merge_request.author_name} → #{@merge_request.assignee_name} - + = "Merge Request ##{@merge_request.iid} was closed by #{@updated_by.name}" diff --git a/app/views/notify/closed_merge_request_email.text.haml b/app/views/notify/closed_merge_request_email.text.haml index ee434ec8cb..d6b76e906c 100644 --- a/app/views/notify/closed_merge_request_email.text.haml +++ b/app/views/notify/closed_merge_request_email.text.haml @@ -1,4 +1,4 @@ -= "Merge Request #{@merge_request.iid} was closed by #{@updated_by.name}" += "Merge Request ##{@merge_request.iid} was closed by #{@updated_by.name}" Merge Request url: #{project_merge_request_url(@merge_request.target_project, @merge_request)} diff --git a/app/views/notify/group_access_granted_email.html.haml b/app/views/notify/group_access_granted_email.html.haml index 5023ec737a..823ebf7734 100644 --- a/app/views/notify/group_access_granted_email.html.haml +++ b/app/views/notify/group_access_granted_email.html.haml @@ -1,5 +1,4 @@ %p = "You have been granted #{@membership.human_access} access to group" -%p = link_to group_url(@group) do = @group.name diff --git a/app/views/notify/issue_status_changed_email.html.haml b/app/views/notify/issue_status_changed_email.html.haml index 7706b3f751..482c884a9d 100644 --- a/app/views/notify/issue_status_changed_email.html.haml +++ b/app/views/notify/issue_status_changed_email.html.haml @@ -1,5 +1,2 @@ %p = "Issue was #{@issue_status} by #{@updated_by.name}" -%p - = "Issue ##{@issue.iid}" - = link_to_gfm truncate(@issue.title, length: 45), project_issue_url(@issue.project, @issue), title: @issue.title diff --git a/app/views/notify/merged_merge_request_email.html.haml b/app/views/notify/merged_merge_request_email.html.haml index e2bc9cf5c0..6762fae7f6 100644 --- a/app/views/notify/merged_merge_request_email.html.haml +++ b/app/views/notify/merged_merge_request_email.html.haml @@ -1,9 +1,2 @@ %p - = "Merge Request #{@merge_request.iid} was merged" -%p - = link_to_gfm truncate(@merge_request.title, length: 40), project_merge_request_url(@merge_request.target_project, @merge_request) -%p - != merge_path_description(@merge_request, '→') -%p - Assignee: #{@merge_request.author_name} → #{@merge_request.assignee_name} - + = "Merge Request ##{@merge_request.iid} was merged" diff --git a/app/views/notify/merged_merge_request_email.text.haml b/app/views/notify/merged_merge_request_email.text.haml index 550f677fed..360da60bc3 100644 --- a/app/views/notify/merged_merge_request_email.text.haml +++ b/app/views/notify/merged_merge_request_email.text.haml @@ -1,4 +1,4 @@ -= "Merge Request #{@merge_request.iid} was merged" += "Merge Request ##{@merge_request.iid} was merged" Merge Request Url: #{project_merge_request_url(@merge_request.target_project, @merge_request)} diff --git a/app/views/notify/new_email_email.html.haml b/app/views/notify/new_email_email.html.haml new file mode 100644 index 0000000000..4a0448a573 --- /dev/null +++ b/app/views/notify/new_email_email.html.haml @@ -0,0 +1,10 @@ +%p + Hi #{@user.name}! +%p + A new email was added to your account: +%p + email: + %code= @email.email +%p + If this email was added in error, you can remove it here: + = link_to "Emails", profile_emails_url diff --git a/app/views/notify/new_email_email.text.erb b/app/views/notify/new_email_email.text.erb new file mode 100644 index 0000000000..51cba99ad0 --- /dev/null +++ b/app/views/notify/new_email_email.text.erb @@ -0,0 +1,7 @@ +Hi <%= @user.name %>! + +A new email was added to your account: + +email.................. <%= @email.email %> + +If this email was added in error, you can remove it here: <%= profile_emails_url %> diff --git a/app/views/notify/new_issue_email.html.haml b/app/views/notify/new_issue_email.html.haml index 3b3c148517..f2f8eee18c 100644 --- a/app/views/notify/new_issue_email.html.haml +++ b/app/views/notify/new_issue_email.html.haml @@ -1,9 +1,6 @@ -%p - New Issue was created. -%p - = "Issue ##{@issue.iid}" - = link_to_gfm truncate(@issue.title, length: 45), project_issue_url(@issue.project, @issue), title: @issue.title -%p - Author: #{@issue.author_name} -%p - Assignee: #{@issue.assignee_name} +-if @issue.description + = markdown(@issue.description) + +- if @issue.assignee_id.present? + %p + Assignee: #{@issue.assignee_name} diff --git a/app/views/notify/new_merge_request_email.html.haml b/app/views/notify/new_merge_request_email.html.haml index 6b2782ebb0..f02d5111b2 100644 --- a/app/views/notify/new_merge_request_email.html.haml +++ b/app/views/notify/new_merge_request_email.html.haml @@ -1,9 +1,9 @@ -%p - = "New Merge Request !#{@merge_request.iid}" -%p - = link_to_gfm truncate(@merge_request.title, length: 40), project_merge_request_url(@merge_request.target_project, @merge_request) -%p +%p.details != merge_path_description(@merge_request, '→') -%p - Assignee: #{@merge_request.author_name} → #{@merge_request.assignee_name} +- if @merge_request.assignee_id.present? + %p + Assignee: #{@merge_request.author_name} → #{@merge_request.assignee_name} + +-if @merge_request.description + = markdown(@merge_request.description) diff --git a/app/views/notify/new_merge_request_email.text.erb b/app/views/notify/new_merge_request_email.text.erb index 2d27350486..16be4bb619 100644 --- a/app/views/notify/new_merge_request_email.text.erb +++ b/app/views/notify/new_merge_request_email.text.erb @@ -1,4 +1,4 @@ -New Merge Request <%= @merge_request.iid %> +New Merge Request #<%= @merge_request.iid %> <%= url_for(project_merge_request_url(@merge_request.target_project, @merge_request)) %> diff --git a/app/views/notify/note_commit_email.html.haml b/app/views/notify/note_commit_email.html.haml index 620b258fc1..1d961e4424 100644 --- a/app/views/notify/note_commit_email.html.haml +++ b/app/views/notify/note_commit_email.html.haml @@ -1,5 +1,2 @@ -%p - = "New comment for Commit #{@commit.short_id}" - = link_to_gfm truncate(@commit.title, length: 16), project_commit_url(@note.project, id: @commit.id, anchor: "note_#{@note.id}") = render 'note_message' diff --git a/app/views/notify/note_issue_email.html.haml b/app/views/notify/note_issue_email.html.haml index b3230953e7..2fa2f78466 100644 --- a/app/views/notify/note_issue_email.html.haml +++ b/app/views/notify/note_issue_email.html.haml @@ -1,4 +1 @@ -%p - = "New comment for Issue ##{@issue.iid}" - = link_to_gfm truncate(@issue.title, length: 35), project_issue_url(@issue.project, @issue, anchor: "note_#{@note.id}") = render 'note_message' diff --git a/app/views/notify/note_merge_request_email.html.haml b/app/views/notify/note_merge_request_email.html.haml index d587b06848..65f0e4c406 100644 --- a/app/views/notify/note_merge_request_email.html.haml +++ b/app/views/notify/note_merge_request_email.html.haml @@ -1,8 +1,7 @@ -%p - - if @note.for_diff_line? - = link_to "New comment on diff", diffs_project_merge_request_url(@merge_request.target_project, @merge_request, anchor: "note_#{@note.id}") - - else - = link_to "New comment", project_merge_request_url(@merge_request.target_project, @merge_request, anchor: "note_#{@note.id}") - for Merge Request ##{@merge_request.iid} - %cite "#{truncate(@merge_request.title, length: 20)}" +- if @note.diff_file_name + %p.details + New comment on diff for + = link_to @note.diff_file_name, @target_url + \: + = render 'note_message' diff --git a/app/views/notify/note_wall_email.html.haml b/app/views/notify/note_wall_email.html.haml index 92200e83ef..2fa2f78466 100644 --- a/app/views/notify/note_wall_email.html.haml +++ b/app/views/notify/note_wall_email.html.haml @@ -1,5 +1 @@ -%p - New message on - = link_to "Project Wall", project_wall_url(@note.project, anchor: "note_#{@note.id}") - = render 'note_message' diff --git a/app/views/notify/reassigned_issue_email.html.haml b/app/views/notify/reassigned_issue_email.html.haml index b0edff44ce..07227a3e68 100644 --- a/app/views/notify/reassigned_issue_email.html.haml +++ b/app/views/notify/reassigned_issue_email.html.haml @@ -1,6 +1,3 @@ -%p - = "Reassigned Issue ##{@issue.iid}" - = link_to_gfm truncate(@issue.title, length: 30), project_issue_url(@issue.project, @issue) %p Assignee changed - if @previous_assignee diff --git a/app/views/notify/reassigned_merge_request_email.html.haml b/app/views/notify/reassigned_merge_request_email.html.haml index 3a615f86e6..00aee6bc95 100644 --- a/app/views/notify/reassigned_merge_request_email.html.haml +++ b/app/views/notify/reassigned_merge_request_email.html.haml @@ -1,6 +1,3 @@ -%p - = "Reassigned Merge Request !#{@merge_request.iid}" - = link_to_gfm truncate(@merge_request.title, length: 30), project_merge_request_url(@merge_request.target_project, @merge_request) %p Assignee changed - if @previous_assignee diff --git a/app/views/notify/reassigned_merge_request_email.text.erb b/app/views/notify/reassigned_merge_request_email.text.erb index eecf055ff6..87a7847e06 100644 --- a/app/views/notify/reassigned_merge_request_email.text.erb +++ b/app/views/notify/reassigned_merge_request_email.text.erb @@ -1,4 +1,4 @@ -Reassigned Merge Request <%= @merge_request.iid %> +Reassigned Merge Request #<%= @merge_request.iid %> <%= url_for(project_merge_request_url(@merge_request.target_project, @merge_request)) %> diff --git a/app/views/notify/repository_push_email.html.haml b/app/views/notify/repository_push_email.html.haml new file mode 100644 index 0000000000..85a01a567f --- /dev/null +++ b/app/views/notify/repository_push_email.html.haml @@ -0,0 +1,28 @@ +%h3 #{@author.name} pushed to #{@branch} at #{@project.name_with_namespace} + +%h4 Commits: + +%ul + - @commits.each do |commit| + %li + #{commit.short_id} - #{commit.title} + +%h4 Changes: +- @diffs.each do |diff| + %li + %strong + - if diff.old_path == diff.new_path + = diff.new_path + - elsif diff.new_path && diff.old_path + #{diff.old_path} → #{diff.new_path} + - else + = diff.new_path || diff.old_path + %hr + %pre + = diff.diff + %br + +- if @compare.timeout + %h5 To prevent performance issues changes are hidden +- elsif @compare.commits_over_limit? + %h5 Changes are not shown due to large amount of commits diff --git a/app/views/notify/repository_push_email.text.haml b/app/views/notify/repository_push_email.text.haml new file mode 100644 index 0000000000..a15b8efe1f --- /dev/null +++ b/app/views/notify/repository_push_email.text.haml @@ -0,0 +1,25 @@ +#{@author.name} pushed to #{@branch} at #{@project.name_with_namespace} + +\ +Commits: +- @commits.each do |commit| + #{commit.short_id} - #{truncate(commit.title, length: 40)} +\ +\ +Changes: +- @diffs.each do |diff| + \ + \===================================== + - if diff.old_path == diff.new_path + = diff.new_path + - elsif diff.new_path && diff.old_path + #{diff.old_path} → #{diff.new_path} + - else + = diff.new_path || diff.old_path + \===================================== + != diff.diff +\ +- if @compare.timeout + Huge diff. To prevent performance issues it was hidden +- elsif @compare.commits_over_limit? + Changes are not shown due to large amount of commits diff --git a/app/views/profiles/accounts/show.html.haml b/app/views/profiles/accounts/show.html.haml index b76339027a..c60e1ca929 100644 --- a/app/views/profiles/accounts/show.html.haml +++ b/app/views/profiles/accounts/show.html.haml @@ -23,8 +23,9 @@ %p.cgray - if current_user.private_token - = text_field_tag "token", current_user.private_token, class: "input-xlarge input-xpadding pull-left" - = f.submit 'Reset', confirm: "Are you sure?", class: "btn btn-primary btn-build-token prepend-left-10" + = text_field_tag "token", current_user.private_token, class: "form-control" + %div + = f.submit 'Reset', data: { confirm: "Are you sure?" }, class: "btn btn-primary btn-build-token" - else %span You don`t have one yet. Click generate to fix it. = f.submit 'Generate', class: "btn success btn-build-token" @@ -47,9 +48,12 @@ %p Changing your username will change path to all personal projects! %div - = f.text_field :username, required: true, class: 'input-xlarge input-xpadding' + = f.text_field :username, required: true, class: 'form-control'   - %span.loading-gif.hide= image_tag "ajax_loader.gif" + .loading-gif.hide + %p + %i.icon-spinner.icon-spin + Saving new username %p.light = user_url(@user) %div @@ -70,4 +74,4 @@ %li The following groups will be abandoned. You should transfer or remove them: %strong #{current_user.solo_owned_groups.map(&:name).join(', ')} - = link_to 'Delete account', user_registration_path, confirm: "REMOVE #{current_user.name}? Are you sure?", method: :delete, class: "btn btn-remove" + = link_to 'Delete account', user_registration_path, data: { confirm: "REMOVE #{current_user.name}? Are you sure?" }, method: :delete, class: "btn btn-remove" diff --git a/app/views/profiles/emails/index.html.haml b/app/views/profiles/emails/index.html.haml new file mode 100644 index 0000000000..b5f1e438cc --- /dev/null +++ b/app/views/profiles/emails/index.html.haml @@ -0,0 +1,33 @@ +%h3.page-title + My email addresses +%p.light + Your + %b Primary Email + will be used for account notifications, avatar detection and web based operations, such as edits and merges. + %br + All email addresses will be used to identify your commits. + +%hr + +.ui-box + .title + Emails (#{@emails.count + 1}) + %ul.well-list#emails-table + %li + %strong= @primary + %span.label.label-success Primary Email + - @emails.each do |email| + %li + %strong= email.email + %span.cgray + added #{time_ago_with_tooltip(email.created_at)} + = link_to 'Remove', profile_email_path(email), data: { confirm: 'Are you sure?'}, method: :delete, class: 'btn btn-small btn-remove pull-right' + +%h4 Add email address += form_for 'email', url: profile_emails_path, html: { class: 'form-horizontal' } do |f| + .form-group + = f.label :email, class: 'control-label' + .col-sm-10 + = f.text_field :email, class: 'form-control' + .form-actions + = f.submit 'Add', class: 'btn btn-create' diff --git a/app/views/profiles/groups/index.html.haml b/app/views/profiles/groups/index.html.haml index 6fc27be5db..cebc0b6bcc 100644 --- a/app/views/profiles/groups/index.html.haml +++ b/app/views/profiles/groups/index.html.haml @@ -18,13 +18,14 @@ %li .pull-right - if can?(current_user, :manage_group, group) - = link_to edit_group_path(group), class: "btn-small btn grouped" do + = link_to edit_group_path(group), class: "btn-small btn btn-grouped" do %i.icon-cogs Settings - = link_to leave_profile_group_path(group), confirm: "Are you sure you want to leave #{group.name} group?", method: :delete, class: "btn-small btn grouped", title: 'Remove user from group' do - %i.icon-signout - Leave + - if can?(current_user, :destroy, user_group) + = link_to leave_profile_group_path(group), data: { confirm: leave_group_message(group.name) }, method: :delete, class: "btn-small btn btn-grouped", title: 'Remove user from group' do + %i.icon-signout + Leave = link_to group, class: 'group-name' do %strong= group.name diff --git a/app/views/profiles/keys/_form.html.haml b/app/views/profiles/keys/_form.html.haml index 158979c0ee..f905417f0e 100644 --- a/app/views/profiles/keys/_form.html.haml +++ b/app/views/profiles/keys/_form.html.haml @@ -1,20 +1,18 @@ %div - = form_for [:profile, @key] do |f| + = form_for [:profile, @key], html: { class: 'form-horizontal' } do |f| - if @key.errors.any? - .alert.alert-error + .alert.alert-danger %ul - @key.errors.full_messages.each do |msg| %li= msg - .control-group - = f.label :title - .controls= f.text_field :title, class: "input-xlarge" - .control-group - = f.label :key - .controls - %p.light - Paste your public key here. Read more about how to generate a key on #{link_to "the SSH help page", help_ssh_path}. - = f.text_area :key, class: "input-xxlarge thin_area" + .form-group + = f.label :title, class: 'control-label' + .col-sm-10= f.text_field :title, class: "form-control" + .form-group + = f.label :key, class: 'control-label' + .col-sm-10 + = f.text_area :key, class: "form-control", rows: 8 .form-actions diff --git a/app/views/profiles/keys/_key.html.haml b/app/views/profiles/keys/_key.html.haml index d0a3fe32c3..81411a7565 100644 --- a/app/views/profiles/keys/_key.html.haml +++ b/app/views/profiles/keys/_key.html.haml @@ -4,8 +4,6 @@ %span (#{key.fingerprint}) %span.cgray - added - = time_ago_in_words(key.created_at) - ago + added #{time_ago_with_tooltip(key.created_at)} - = link_to 'Remove', profile_key_path(key), confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-remove delete-key pull-right" + = link_to 'Remove', profile_key_path(key), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-small btn-remove delete-key pull-right" diff --git a/app/views/profiles/keys/index.html.haml b/app/views/profiles/keys/index.html.haml index 79fdb16408..71a4ca91d4 100644 --- a/app/views/profiles/keys/index.html.haml +++ b/app/views/profiles/keys/index.html.haml @@ -17,6 +17,6 @@ = render @keys - if @keys.blank? %li - %h3.nothing_here_message There are no SSH keys with access to your account. + .nothing-here-block There are no SSH keys with access to your account. diff --git a/app/views/profiles/keys/new.html.haml b/app/views/profiles/keys/new.html.haml index f1b8fe08d5..3d5a947948 100644 --- a/app/views/profiles/keys/new.html.haml +++ b/app/views/profiles/keys/new.html.haml @@ -1,4 +1,6 @@ %h3.page-title Add an SSH Key +%p.light + Paste your public key here. Read more about how to generate a key on #{link_to "the SSH help page", help_ssh_path}. %hr = render 'form' diff --git a/app/views/profiles/keys/show.html.haml b/app/views/profiles/keys/show.html.haml index 2852c338af..b6724a7cb5 100644 --- a/app/views/profiles/keys/show.html.haml +++ b/app/views/profiles/keys/show.html.haml @@ -1,5 +1,5 @@ .row - .span4 + .col-md-4 .ui-box .title SSH Key @@ -11,7 +11,7 @@ %span.light Created on: %strong= @key.created_at.stamp("Aug 21, 2011") - .span8 + .col-md-8 %p %span.light Fingerprint: %strong= @key.fingerprint @@ -19,4 +19,4 @@ = @key.key .pull-right - = link_to 'Remove', profile_key_path(@key), confirm: 'Are you sure?', method: :delete, class: "btn btn-remove delete-key" + = link_to 'Remove', profile_key_path(@key), data: {confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove delete-key" diff --git a/app/views/profiles/notifications/_settings.html.haml b/app/views/profiles/notifications/_settings.html.haml index 5f62c8099d..218d51d31a 100644 --- a/app/views/profiles/notifications/_settings.html.haml +++ b/app/views/profiles/notifications/_settings.html.haml @@ -1,31 +1,17 @@ %li - .row - .span4 - %span - = notification_icon(notification) - - - if membership.kind_of? UsersGroup - = link_to membership.group.name, membership.group - - else - = link_to_project(membership.project) - .span7 - = form_tag profile_notifications_path, method: :put, remote: true, class: 'update-notifications' do - = hidden_field_tag :notification_type, type, id: dom_id(membership, 'notification_type') - = hidden_field_tag :notification_id, membership.id, id: dom_id(membership, 'notification_id') - - = label_tag do - = radio_button_tag :notification_level, Notification::N_GLOBAL, notification.global?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' - %span Use global setting - - = label_tag do - = radio_button_tag :notification_level, Notification::N_DISABLED, notification.disabled?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' - %span Disabled - - = label_tag do - = radio_button_tag :notification_level, Notification::N_PARTICIPATING, notification.participating?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' - %span Participating - - = label_tag do - = radio_button_tag :notification_level, Notification::N_WATCH, notification.watch?, id: dom_id(membership, 'notification_level'), class: 'trigger-submit' - %span Watch + %span.notification-icon-holder + - if notification.global? + = notification_icon(@notification) + - else + = notification_icon(notification) + %span.str-truncated + - if membership.kind_of? UsersGroup + = link_to membership.group.name, membership.group + - else + = link_to_project(membership.project) + .pull-right + = form_tag profile_notifications_path, method: :put, remote: true, class: 'update-notifications' do + = hidden_field_tag :notification_type, type, id: dom_id(membership, 'notification_type') + = hidden_field_tag :notification_id, membership.id, id: dom_id(membership, 'notification_id') + = select_tag :notification_level, options_for_select(Notification.options_with_labels, notification.level), class: 'trigger-submit' diff --git a/app/views/profiles/notifications/show.html.haml b/app/views/profiles/notifications/show.html.haml index 8353b2f5f2..efe9c03219 100644 --- a/app/views/profiles/notifications/show.html.haml +++ b/app/views/profiles/notifications/show.html.haml @@ -3,56 +3,49 @@ %p.light GitLab uses the email specified in your profile for notifications %hr -.alert.alert-info - %p - %i.icon-circle.cred - %strong Disabled - – You will not get any notifications via email - %p - %i.icon-circle.cblue - %strong Participating - – You will only receive notifications from related resources (e.g. from your commits or assigned issues) - %p - %i.icon-circle.cgreen - %strong Watch - – You will receive all notifications from projects in which you participate += form_tag profile_notifications_path, method: :put, remote: true, class: 'update-notifications form-horizontal global-notifications-form' do + = hidden_field_tag :notification_type, 'global' -.row - .span4 - %h4 - = notification_icon(@notification) - Global setting - .span7 - = form_tag profile_notifications_path, method: :put, remote: true, class: 'update-notifications' do - = hidden_field_tag :notification_type, 'global' - - = label_tag do + = label_tag :notification_level, 'Notification level', class: 'control-label' + .col-sm-10 + .radio + = label_tag nil, class: '' do = radio_button_tag :notification_level, Notification::N_DISABLED, @notification.disabled?, class: 'trigger-submit' - %span Disabled + .level-title + Disabled + %p You will not get any notifications via email - = label_tag do + .radio + = label_tag nil, class: '' do = radio_button_tag :notification_level, Notification::N_PARTICIPATING, @notification.participating?, class: 'trigger-submit' - %span Participating + .level-title + Participating + %p You will only receive notifications from related resources (e.g. from your commits or assigned issues) - = label_tag do + .radio + = label_tag nil, class: '' do = radio_button_tag :notification_level, Notification::N_WATCH, @notification.watch?, class: 'trigger-submit' - %span Watch + .level-title + Watch + %p You will receive all notifications from projects in which you participate -%br -= link_to '#', class: 'js-toggle-visibility-link' do - %span.btn.btn-tiny - %i.icon-chevron-down - %span Advanced notifications settings -.js-toggle-visibility-container.hide +.clearfix %hr - %h4 Groups: - %ul.bordered-list - - @users_groups.each do |users_group| - - notification = Notification.new(users_group) - = render 'settings', type: 'group', membership: users_group, notification: notification + %p + You can also specify notification level per group or per project + %br + By default all projects and groups uses notification level set above +.row.all-notifications + .col-md-6 + %h4 Groups: + %ul.bordered-list + - @users_groups.each do |users_group| + - notification = Notification.new(users_group) + = render 'settings', type: 'group', membership: users_group, notification: notification - %h4 Projects: - %ul.bordered-list - - @users_projects.each do |users_project| - - notification = Notification.new(users_project) - = render 'settings', type: 'project', membership: users_project, notification: notification + .col-md-6 + %h4 Projects: + %ul.bordered-list + - @users_projects.each do |users_project| + - notification = Notification.new(users_project) + = render 'settings', type: 'project', membership: users_project, notification: notification diff --git a/app/views/profiles/passwords/edit.html.haml b/app/views/profiles/passwords/edit.html.haml index a5fa6e7f18..2a7d317aa3 100644 --- a/app/views/profiles/passwords/edit.html.haml +++ b/app/views/profiles/passwords/edit.html.haml @@ -3,30 +3,31 @@ Change your password or recover your current one. %hr .update-password - = form_for @user, url: profile_password_path, method: :put do |f| + = form_for @user, url: profile_password_path, method: :put, html: { class: 'form-horizontal' } do |f| %div %p.slead You must provide current password in order to change it. %br After a successful password update you will be redirected to login page where you should login with your new password -if @user.errors.any? - .alert.alert-error + .alert.alert-danger %ul - @user.errors.full_messages.each do |msg| %li= msg - .control-group - = f.label :current_password - .controls - = f.password_field :current_password, required: true + .form-group + = f.label :current_password, class: 'control-label' + .col-sm-10 + = f.password_field :current_password, required: true, class: 'form-control' %div = link_to "Forgot your password?", reset_profile_password_path, method: :put - .control-group - = f.label :password, 'New password' - .controls= f.password_field :password, required: true - .control-group - = f.label :password_confirmation - .controls - = f.password_field :password_confirmation, required: true + .form-group + = f.label :password, 'New password', class: 'control-label' + .col-sm-10 + = f.password_field :password, required: true, class: 'form-control' + .form-group + = f.label :password_confirmation, class: 'control-label' + .col-sm-10 + = f.password_field :password_confirmation, required: true, class: 'form-control' .form-actions = f.submit 'Save password', class: "btn btn-save" diff --git a/app/views/profiles/passwords/new.html.haml b/app/views/profiles/passwords/new.html.haml index a4e7dadd16..b72232ee36 100644 --- a/app/views/profiles/passwords/new.html.haml +++ b/app/views/profiles/passwords/new.html.haml @@ -1,22 +1,22 @@ -= form_for @user, url: profile_password_path, method: :post do |f| - .light-well.padded - %p.slead - Please set new password before proceed. - %br - After successful password update you will be redirected to login screen - -if @user.errors.any? - .alert.alert-error - %ul - - @user.errors.full_messages.each do |msg| - %li= msg +%h3.page-title Setup new password +%hr += form_for @user, url: profile_password_path, method: :post, html: { class: 'form-horizontal '} do |f| + %p.slead + Please set a new password before proceeding. + %br + After a successful password update you will be redirected to login screen. + -if @user.errors.any? + .alert.alert-danger + %ul + - @user.errors.full_messages.each do |msg| + %li= msg - .control-group - = f.label :password - .controls= f.password_field :password, required: true - .control-group - = f.label :password_confirmation - .controls - = f.password_field :password_confirmation, required: true - .control-group - .controls - = f.submit 'Set new password', class: "btn btn-create" + .form-group + = f.label :password, class: 'control-label' + .col-sm-10= f.password_field :password, required: true, class: 'form-control' + .form-group + = f.label :password_confirmation, class: 'control-label' + .col-sm-10 + = f.password_field :password_confirmation, required: true, class: 'form-control' + .form-actions + = f.submit 'Set new password', class: "btn btn-create" diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index d382d2d70c..69598e799e 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -8,62 +8,83 @@ -= form_for @user, url: profile_path, method: :put, html: { multipart: true, class: "edit_user form-horizontal" } do |f| += form_for @user, url: profile_path, method: :put, html: { multipart: true, class: "edit_user form-horizontal" }, authenticity_token: true do |f| -if @user.errors.any? - %div.alert.alert-error + %div.alert.alert-danger %ul - @user.errors.full_messages.each do |msg| %li= msg .row - .span7 - .control-group + .col-md-7 + .form-group = f.label :name, class: "control-label" - .controls - = f.text_field :name, class: "input-xlarge", required: true + .col-sm-10 + = f.text_field :name, class: "form-control", required: true %span.help-block Enter your name, so people you know can recognize you. - .control-group + + .form-group = f.label :email, class: "control-label" - .controls - = f.text_field :email, class: "input-xlarge", required: true - - if @user.unconfirmed_email.present? - %span.help-block - We sent confirmation email to - %strong #{@user.unconfirmed_email} + .col-sm-10 + - if @user.ldap_user? + = f.text_field :email, class: "form-control", required: true, readonly: true + %span.help-block.light + Email is read-only for LDAP user - else - %span.help-block We also use email for avatar detection if no avatar is uploaded. - .control-group + - if @user.temp_oauth_email? + = f.text_field :email, class: "form-control", required: true, value: nil + - else + = f.text_field :email, class: "form-control", required: true + - if @user.unconfirmed_email.present? + %span.help-block + Please click the link in the confirmation email before continuing, it was send to + %strong #{@user.unconfirmed_email} + + - else + %span.help-block We also use email for avatar detection if no avatar is uploaded. + .form-group = f.label :skype, class: "control-label" - .controls= f.text_field :skype, class: "input-xlarge" - .control-group + .col-sm-10= f.text_field :skype, class: "form-control" + .form-group = f.label :linkedin, class: "control-label" - .controls= f.text_field :linkedin, class: "input-xlarge" - .control-group + .col-sm-10= f.text_field :linkedin, class: "form-control" + .form-group = f.label :twitter, class: "control-label" - .controls= f.text_field :twitter, class: "input-xlarge" - .control-group + .col-sm-10= f.text_field :twitter, class: "form-control" + .form-group + = f.label :website_url, 'Website', class: "control-label" + .col-sm-10= f.text_field :website_url, class: "form-control" + .form-group = f.label :bio, class: "control-label" - .controls - = f.text_area :bio, rows: 6, class: "input-xlarge", maxlength: 250 + .col-sm-10 + = f.text_area :bio, rows: 6, class: "form-control", maxlength: 250 %span.help-block Tell us about yourself in fewer than 250 characters. - .span5.pull-right + .col-md-5 .light-well = image_tag avatar_icon(@user.email, 160), alt: '', class: 'avatar s160' .clearfix .profile-avatar-form-option %p.light - You can upload an avatar here - %br - or change it at #{link_to "gravatar.com", "http://gravatar.com"} + - if @user.avatar? + You can change your avatar here + %br + or remove the current avatar to revert to #{link_to "gravatar.com", "http://gravatar.com"} + - else + You can upload an avatar here + %br + or change it at #{link_to "gravatar.com", "http://gravatar.com"} %hr %a.choose-btn.btn.btn-small.js-choose-user-avatar-button %i.icon-paper-clip %span Choose File ...   %span.file_name.js-avatar-filename File name... - = f.file_field :avatar, class: "js-user-avatar-input hide" - %span.help-block The maximum file size allowed is 100KB. + = f.file_field :avatar, class: "js-user-avatar-input hidden" + .light The maximum file size allowed is 100KB. + - if @user.avatar? + %hr + = link_to 'Remove avatar', profile_avatar_path, data: { confirm: "Avatar will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-small remove-avatar" .form-actions = f.submit 'Save changes', class: "btn btn-save" diff --git a/app/views/projects/_dropdown.html.haml b/app/views/projects/_dropdown.html.haml index e646d04282..e283bd2bf1 100644 --- a/app/views/projects/_dropdown.html.haml +++ b/app/views/projects/_dropdown.html.haml @@ -6,15 +6,19 @@ - if @project.issues_enabled && can?(current_user, :write_issue, @project) %li = link_to url_for_new_issue, title: "New Issue" do - Issue + New issue - if @project.merge_requests_enabled && can?(current_user, :write_merge_request, @project) %li = link_to new_project_merge_request_path(@project), title: "New Merge Request" do - Merge Request + New merge request - if @project.snippets_enabled && can?(current_user, :write_snippet, @project) %li = link_to new_project_snippet_path(@project), title: "New Snippet" do - Snippet + New snippet + - if can?(current_user, :admin_team_member, @project) + %li + = link_to new_project_team_member_path(@project), title: "New project member" do + New project member - if can? current_user, :push_code, @project %li.divider %li @@ -26,9 +30,4 @@ %i.icon-tag Git tag - - if can?(current_user, :admin_team_member, @project) - %li.divider - %li - = link_to new_project_team_member_path(@project), title: "New project member" do - Project member diff --git a/app/views/projects/_errors.html.haml b/app/views/projects/_errors.html.haml index bb9759353a..7c8bb33ed7 100644 --- a/app/views/projects/_errors.html.haml +++ b/app/views/projects/_errors.html.haml @@ -1,4 +1,4 @@ - if @project.errors.any? - .alert.alert-error + .alert.alert-danger %button{ type: "button", class: "close", "data-dismiss" => "alert"} × = @project.errors.full_messages.first diff --git a/app/views/projects/_home_panel.html.haml b/app/views/projects/_home_panel.html.haml new file mode 100644 index 0000000000..82ec68c916 --- /dev/null +++ b/app/views/projects/_home_panel.html.haml @@ -0,0 +1,31 @@ +- empty_repo = @project.empty_repo? +.project-home-panel{:class => ("empty-project" if empty_repo)} + .visibility-level-label.has_tooltip{'data-title' => "#{visibility_level_label(@project.visibility_level)} project" } + = visibility_level_icon(@project.visibility_level) + .row + .col-sm-6 + %h4.project-home-title + = @project.name_with_namespace + + .col-sm-6 + - unless empty_repo + .project-home-dropdown + = render "dropdown" + = render "shared/clone_panel" + + .project-home-extra.row + .col-md-8 + .project-home-desc + - if @project.description.present? + = @project.description + - if can?(current_user, :admin_project, @project) + – + %strong= link_to 'Edit', edit_project_path + + - unless empty_repo + .col-md-4 + .project-home-links + = link_to pluralize(number_with_delimiter(@repository.commit_count), 'commit'), project_commits_path(@project, @ref || @repository.root_ref) + = link_to pluralize(number_with_delimiter(@repository.branch_names.count), 'branch'), project_branches_path(@project) + = link_to pluralize(number_with_delimiter(@repository.tag_names.count), 'tag'), project_tags_path(@project) + %span.light.prepend-left-20= repository_size diff --git a/app/views/projects/_settings_nav.html.haml b/app/views/projects/_settings_nav.html.haml index f59e2871aa..4c7b088ae9 100644 --- a/app/views/projects/_settings_nav.html.haml +++ b/app/views/projects/_settings_nav.html.haml @@ -1,21 +1,21 @@ -%ul.nav.nav-pills.nav-stacked.nav-stacked-menu +%ul.nav.nav-pills.nav-stacked.nav-stacked-menu.append-bottom-20.project-settings-nav = nav_link(path: 'projects#edit') do = link_to edit_project_path(@project), class: "stat-tab tab " do %i.icon-edit - Edit Project + Project = nav_link(controller: [:team_members, :teams]) do = link_to project_team_index_path(@project), class: "team-tab tab" do %i.icon-group Members = nav_link(controller: :deploy_keys) do = link_to project_deploy_keys_path(@project) do - %span + %i.icon-key Deploy Keys = nav_link(controller: :hooks) do = link_to project_hooks_path(@project) do - %span + %i.icon-link Web Hooks = nav_link(controller: :services) do = link_to project_services_path(@project) do - %span + %i.icon-cogs Services diff --git a/app/views/projects/_visibility_level.html.haml b/app/views/projects/_visibility_level.html.haml new file mode 100644 index 0000000000..eb38fce0ec --- /dev/null +++ b/app/views/projects/_visibility_level.html.haml @@ -0,0 +1,27 @@ +.form-group.project-visibility-level-holder + = f.label :visibility_level, class: 'control-label' do + Visibility Level + = link_to "(?)", help_public_access_path + .col-sm-10 + - if can_change_visibility_level + - Gitlab::VisibilityLevel.values.each do |level| + .radio + - restricted = restricted_visibility_levels.include?(level) + = f.radio_button :visibility_level, level, checked: (visibility_level == level), disabled: restricted + = label :project_visibility_level, level do + = visibility_level_icon(level) + .option-title + = visibility_level_label(level) + .option-descr + = visibility_level_description(level) + - unless restricted_visibility_levels.empty? + .col-sm-10 + %span.info + Some visibility level settings have been restricted by the administrator. + - else + .col-sm-10 + %span.info + = visibility_level_icon(visibility_level) + %strong + = visibility_level_label(visibility_level) + .light= visibility_level_description(visibility_level) diff --git a/app/views/projects/blob/_actions.html.haml b/app/views/projects/blob/_actions.html.haml index f6cc62e707..2f82bfe52f 100644 --- a/app/views/projects/blob/_actions.html.haml +++ b/app/views/projects/blob/_actions.html.haml @@ -4,7 +4,7 @@ - if allowed_tree_edit? = link_to "edit", project_edit_tree_path(@project, @id), class: "btn btn-small" - else - %span.btn.btn-small.disabled Edit + %span.btn.btn-small.disabled edit = link_to "raw", project_raw_path(@project, @id), class: "btn btn-small", target: "_blank" -# only show normal/blame view links for text files - if @blob.text? @@ -13,3 +13,7 @@ - else = link_to "blame", project_blame_path(@project, @id), class: "btn btn-small" unless @blob.empty? = link_to "history", project_commits_path(@project, @id), class: "btn btn-small" + + - if allowed_tree_edit? + = link_to '#modal-remove-blob', class: "remove-blob btn btn-small btn-remove", "data-toggle" => "modal" do + remove diff --git a/app/views/projects/blob/_blob.html.haml b/app/views/projects/blob/_blob.html.haml index 6524aaeef4..863e4e3de5 100644 --- a/app/views/projects/blob/_blob.html.haml +++ b/app/views/projects/blob/_blob.html.haml @@ -4,7 +4,6 @@ = link_to project_tree_path(@project, @ref) do = @project.path - tree_breadcrumbs(@tree, 6) do |title, path| - \/ %li - if path - if path.end_with?(@path) @@ -16,14 +15,18 @@ - else = link_to title, '#' +%ul.blob-commit-info.bs-callout.bs-callout-info.hidden-xs + - blob_commit = @repository.last_commit_for_path(@commit.id, @blob.path) + = render blob_commit, project: @project + %div#tree-content-holder.tree-content-holder .file-holder - .file-title + .file-title.clearfix %i.icon-file %span.file_name = blob.name %small= number_to_human_size blob.size - %span.options= render "actions" + %span.options.hidden-xs= render "actions" - if blob.text? = render "text", blob: blob - elsif blob.image? diff --git a/app/views/projects/blob/_remove.html.haml b/app/views/projects/blob/_remove.html.haml new file mode 100644 index 0000000000..692248dd23 --- /dev/null +++ b/app/views/projects/blob/_remove.html.haml @@ -0,0 +1,23 @@ +#modal-remove-blob.modal.hide + .modal-dialog + .modal-content + .modal-header + %a.close{href: "#", "data-dismiss" => "modal"} × + %h3.page-title Remove #{@blob.name} + %p.light + From branch + %strong= @ref + + .modal-body + = form_tag project_blob_path(@project, @id), method: :delete, class: 'form-horizontal' do + .form-group.commit_message-group + = label_tag 'commit_message', class: "control-label" do + Commit message + .col-sm-10 + = render 'shared/commit_message_container', {textarea: text_area_tag('commit_message', + params[:commit_message], placeholder: "Removed this file because...", required: true, rows: 3, class: 'form-control')} + .form-group + .col-sm-2 + .col-sm-10 + = submit_tag 'Remove file', class: 'btn btn-remove' + = link_to "Cancel", '#', class: "btn btn-cancel", "data-dismiss" => "modal" diff --git a/app/views/projects/blob/_text.html.haml b/app/views/projects/blob/_text.html.haml index bed493d6d8..7cbea7c3eb 100644 --- a/app/views/projects/blob/_text.html.haml +++ b/app/views/projects/blob/_text.html.haml @@ -4,11 +4,10 @@ = markdown(blob.data) - elsif markup?(blob.name) .file-content.wiki - = raw GitHub::Markup.render(blob.name, blob.data) + = render_markup(blob.name, blob.data) - else .file-content.code - unless blob.empty? - %div{class: user_color_scheme_class} - = raw blob.colorize(formatter: :gitlab) + = render 'shared/file_hljs', blob: blob - else - %p.nothing_here_message Empty file + .nothing-here-block Empty file diff --git a/app/views/projects/blob/show.html.haml b/app/views/projects/blob/show.html.haml index d96595bc7f..69167654c3 100644 --- a/app/views/projects/blob/show.html.haml +++ b/app/views/projects/blob/show.html.haml @@ -1,4 +1,8 @@ %div.tree-ref-holder = render 'shared/ref_switcher', destination: 'blob', path: @path + %div#tree-holder.tree-holder = render 'blob', blob: @blob + +- if allowed_tree_edit? + = render 'projects/blob/remove' diff --git a/app/views/projects/branches/_branch.html.haml b/app/views/projects/branches/_branch.html.haml index 4372647a41..f073197709 100644 --- a/app/views/projects/branches/_branch.html.haml +++ b/app/views/projects/branches/_branch.html.haml @@ -1,4 +1,4 @@ -- commit = Commit.new(Gitlab::Git::Commit.new(branch.commit)) +- commit = @repository.commit(branch.target) %li %h4 = link_to project_commits_path(@project, branch.name) do @@ -10,23 +10,24 @@ %i.icon-lock .pull-right - if can?(current_user, :download_code, @project) - = link_to archive_project_repository_path(@project, ref: branch.name), class: 'btn grouped btn-small' do - %i.icon-download-alt - Download - = link_to project_compare_index_path(@project, from: branch.name, to: branch.name), class: 'btn grouped btn-small', title: "Compare" do - %i.icon-copy - Compare + = render 'projects/repositories/download_archive', ref: branch.name, btn_class: 'btn-grouped btn-group-small' + - if branch.name != @repository.root_ref + = link_to project_compare_index_path(@project, from: @repository.root_ref, to: branch.name), class: 'btn btn-grouped btn-small', method: :post, title: "Compare" do + %i.icon-copy + Compare - if can?(current_user, :admin_project, @project) && branch.name != @repository.root_ref - = link_to project_branch_path(@project, branch.name), class: 'btn grouped btn-small remove-row', method: :delete, confirm: 'Removed branch cannot be restored. Are you sure?', remote: true do + = link_to project_branch_path(@project, branch.name), class: 'btn btn-grouped btn-small remove-row', method: :delete, data: { confirm: 'Removed branch cannot be restored. Are you sure?'}, remote: true do %i.icon-trash - %p - = link_to project_commit_path(@project, commit.id), class: 'commit_short_id' do - = commit.short_id - = image_tag avatar_icon(commit.author_email), class: "avatar s16", alt: '' - %span.light - = gfm escape_once(truncate(commit.title, length: 40)) - %span - = time_ago_in_words(commit.committed_date) - ago + - if commit + %p + = link_to project_commit_path(@project, commit.id), class: 'commit_short_id' do + = commit.short_id + = image_tag avatar_icon(commit.author_email), class: "avatar s16", alt: '' + %span.light + = gfm escape_once(truncate(commit.title, length: 40)) + #{time_ago_with_tooltip(commit.committed_date)} + - else + %p + Cant find HEAD commit for this branch diff --git a/app/views/projects/branches/_filter.html.haml b/app/views/projects/branches/_filter.html.haml index 7ea11a74a2..7e1478292e 100644 --- a/app/views/projects/branches/_filter.html.haml +++ b/app/views/projects/branches/_filter.html.haml @@ -1,12 +1,22 @@ %ul.nav.nav-pills.nav-stacked = nav_link(path: 'branches#recent') do - = link_to 'Recent', recent_project_branches_path(@project) + = link_to recent_project_branches_path(@project) do + Recent + .pull-right + = @repository.recent_branches.count + = nav_link(path: 'protected_branches#index') do = link_to project_protected_branches_path(@project) do Protected %i.icon-lock + .pull-right + = @project.protected_branches.count + = nav_link(path: 'branches#index') do - = link_to 'All branches', project_branches_path(@project) + = link_to project_branches_path(@project) do + All branches + .pull-right + = @repository.branch_names.count %hr diff --git a/app/views/projects/branches/index.html.haml b/app/views/projects/branches/index.html.haml index 45b9c6c852..bee04eb013 100644 --- a/app/views/projects/branches/index.html.haml +++ b/app/views/projects/branches/index.html.haml @@ -1,10 +1,10 @@ = render "projects/commits/head" .row - .span3 + .col-md-3 = render "filter" - .span9 + .col-md-9 - unless @branches.empty? - %ul.bordered-list.top-list + %ul.bordered-list.top-list.all-branches - @branches.each do |branch| = render "projects/branches/branch", branch: branch - = paginate @branches, theme: 'gitlab' \ No newline at end of file + = paginate @branches, theme: 'gitlab' diff --git a/app/views/projects/branches/new.html.haml b/app/views/projects/branches/new.html.haml index 37612d3fd7..5da2ede293 100644 --- a/app/views/projects/branches/new.html.haml +++ b/app/views/projects/branches/new.html.haml @@ -1,16 +1,15 @@ %h3.page-title %i.icon-code-fork New branch -= form_tag project_branches_path, method: :post do - .control-group += form_tag project_branches_path, method: :post, class: "form-horizontal" do + .form-group = label_tag :branch_name, 'Name for new branch', class: 'control-label' - .controls - = text_field_tag :branch_name, nil, placeholder: 'feature/dashboard', required: true, tabindex: 1 - .control-group + .col-sm-10 + = text_field_tag :branch_name, nil, placeholder: 'enter new branch name', required: true, tabindex: 1, class: 'form-control' + .form-group = label_tag :ref, 'Create from', class: 'control-label' - .controls - = text_field_tag :ref, nil, placeholder: 'master', required: true, tabindex: 2 - .light branch name or commit SHA + .col-sm-10 + = text_field_tag :ref, nil, placeholder: 'existing branch name, tag or commit SHA', required: true, tabindex: 2, class: 'form-control' .form-actions = submit_tag 'Create branch', class: 'btn btn-create', tabindex: 3 = link_to 'Cancel', project_branches_path(@project), class: 'btn btn-cancel' diff --git a/app/views/projects/branches/recent.html.haml b/app/views/projects/branches/recent.html.haml index 25f416c78f..37d7919121 100644 --- a/app/views/projects/branches/recent.html.haml +++ b/app/views/projects/branches/recent.html.haml @@ -1,8 +1,8 @@ = render "projects/commits/head" .row - .span3 + .col-md-3 = render "filter" - .span9 + .col-md-9 %ul.bordered-list.top-list - @branches.each do |branch| - = render "projects/branches/branch", branch: branch \ No newline at end of file + = render "projects/branches/branch", branch: branch diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml index 111446db58..f2b0699f13 100644 --- a/app/views/projects/commit/_commit_box.html.haml +++ b/app/views/projects/commit/_commit_box.html.haml @@ -1,18 +1,18 @@ .pull-right %div - if @notes_count > 0 - %span.btn.disabled.grouped + %span.btn.disabled.btn-grouped %i.icon-comment = @notes_count .pull-left.btn-group - %a.btn.grouped.dropdown-toggle{ data: {toggle: :dropdown} } + %a.btn.btn-grouped.dropdown-toggle{ data: {toggle: :dropdown} } %i.icon-download-alt Download as %span.caret %ul.dropdown-menu %li= link_to "Email Patches", project_commit_path(@project, @commit, format: :patch) %li= link_to "Plain Diff", project_commit_path(@project, @commit, format: :diff) - = link_to project_tree_path(@project, @commit), class: "btn btn-primary grouped" do + = link_to project_tree_path(@project, @commit), class: "btn btn-primary btn-grouped" do %span Browse Code » %div @@ -23,16 +23,14 @@ %span.light Authored by %strong = commit_author_link(@commit, avatar: true, size: 24) - %time{title: @commit.authored_date.stamp("Aug 21, 2011 9:23pm")} - #{time_ago_in_words(@commit.authored_date)} ago + #{time_ago_with_tooltip(@commit.authored_date)} - if @commit.different_committer? .commit-info-row %span.light Committed by %strong = commit_committer_link(@commit, avatar: true, size: 24) - %time{title: @commit.committed_date.stamp("Aug 21, 2011 9:23pm")} - #{time_ago_in_words(@commit.committed_date)} ago + #{time_ago_with_tooltip(@commit.committed_date)} .commit-info-row %span.cgray= pluralize(@commit.parents.count, "parent") @@ -49,7 +47,7 @@ - if @branches.any? and in = link_to("#{pluralize(@branches.count, "other branch")}", "#", class: "js-details-expand") - %span.js-details-contain.hide + %span.js-details-content.hide = commit_branches_links(@project, @branches) .commit-box diff --git a/app/views/projects/commit/huge_commit.html.haml b/app/views/projects/commit/huge_commit.html.haml index 210d8d9e20..398ce77142 100644 --- a/app/views/projects/commit/huge_commit.html.haml +++ b/app/views/projects/commit/huge_commit.html.haml @@ -1,3 +1,3 @@ = render "projects/commit/commit_box" -.alert.alert-error +.alert.alert-danger %h4 Commit diffs are too big to be displayed diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml index d70fd96acc..a060666280 100644 --- a/app/views/projects/commits/_commit.html.haml +++ b/app/views/projects/commits/_commit.html.haml @@ -1,19 +1,25 @@ -%li.commit +%li.commit.js-toggle-container .commit-row-title = link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id"   - = link_to_gfm truncate(commit.title, length: 70), project_commit_path(project, commit.id), class: "commit-row-message" + %span.str-truncated + = link_to_gfm commit.title, project_commit_path(project, commit.id), class: "commit-row-message" + - if commit.description? + %a.text-expander.js-toggle-button ... + = link_to "Browse Code »", project_tree_path(project, commit), class: "pull-right" .notes_count - notes = project.notes.for_commit_id(commit.id) - if notes.any? - %span.badge.badge-info + %span.label.label-gray %i.icon-comment = notes.count + - if commit.description? + .commit-row-description.js-toggle-content + = simple_format(commit.description) + .commit-row-info = commit_author_link(commit, avatar: true, size: 16) - %time.committed_ago{ datetime: commit.committed_date, title: commit.committed_date.stamp("Aug 21, 2011 9:23pm") } - = time_ago_in_words(commit.committed_date) - ago -   + .committed_ago + #{time_ago_with_tooltip(commit.committed_date)}   diff --git a/app/views/projects/commits/_commits.html.haml b/app/views/projects/commits/_commits.html.haml index b640477807..e3411b62eb 100644 --- a/app/views/projects/commits/_commits.html.haml +++ b/app/views/projects/commits/_commits.html.haml @@ -1,11 +1,11 @@ - @commits.group_by { |c| c.committed_date.to_date }.sort.reverse.each do |day, commits| .row.commits-row - .span2 + .col-md-2 %h4 %i.icon-calendar %span= day.stamp("28 Aug, 2010") %p= pluralize(commits.count, 'commit') - .span10 + .col-md-10 %ul.well-list = render commits, project: @project %hr.lists-separator diff --git a/app/views/projects/commits/_diffs.html.haml b/app/views/projects/commits/_diffs.html.haml index 2e61b9ece1..466085139f 100644 --- a/app/views/projects/commits/_diffs.html.haml +++ b/app/views/projects/commits/_diffs.html.haml @@ -1,6 +1,6 @@ - @suppress_diff ||= @suppress_diff || @force_suppress_diff - if @suppress_diff - .alert.alert-block + .alert.alert-warning %p %strong Warning! This is a large diff. %p @@ -8,18 +8,18 @@ - if current_controller?(:commit) or current_controller?(:merge_requests) Please, download the diff as - if current_controller?(:commit) - = link_to "plain diff", project_commit_path(@project, @commit, format: :diff), class: "underlined_link" + = link_to "plain diff", project_commit_path(@project, @commit, format: :diff), class: "underlined-link" or - = link_to "email patch", project_commit_path(@project, @commit, format: :patch), class: "underlined_link" + = link_to "email patch", project_commit_path(@project, @commit, format: :patch), class: "underlined-link" - else - = link_to "plain diff", project_merge_request_path(@project, @merge_request, format: :diff), class: "underlined_link" + = link_to "plain diff", project_merge_request_path(@project, @merge_request, format: :diff), class: "underlined-link" or - = link_to "email patch", project_merge_request_path(@project, @merge_request, format: :patch), class: "underlined_link" + = link_to "email patch", project_merge_request_path(@project, @merge_request, format: :patch), class: "underlined-link" instead. - unless @force_suppress_diff %p If you still want to see the diff - = link_to "click this link", url_for(force_show_diff: true), class: "underlined_link" + = link_to "click this link", url_for(force_show_diff: true), class: "underlined-link" %p.commit-stat-summary Showing @@ -30,6 +30,10 @@ %strong.cgreen #{@commit.stats.additions} additions and %strong.cred #{@commit.stats.deletions} deletions + - if params[:view] == 'parallel' + = link_to "Inline Diff", url_for(view: 'inline'), {id: "commit-diff-viewtype", class: 'btn btn-tiny pull-right'} + - else + = link_to "Side-by-side Diff", url_for(view: 'parallel'), {id: "commit-diff-viewtype", class: 'btn btn-tiny pull-right'} .file-stats = render "projects/commits/diff_head", diffs: diffs @@ -40,31 +44,47 @@ - file = project.repository.blob_at(@commit.id, diff.new_path) - file = project.repository.blob_at(@commit.parent_id, diff.old_path) unless file - next unless file - .file{id: "diff-#{i}"} - .header + .diff-file.js-toggle-container{id: "diff-#{i}"} + .diff-header{id: "file-path-#{hexdigest(diff.new_path || diff.old_path)}"} - if diff.deleted_file %span= diff.old_path - - if @commit.parent_ids.present? - = link_to project_blob_path(project, tree_join(@commit.parent_id, diff.new_path)), {:class => 'btn btn-tiny pull-right view-file'} do - View file @ - %span.commit-short-id= @commit.short_id(6) + .diff-btn-group + - if @commit.parent_ids.present? + = link_to project_blob_path(project, tree_join(@commit.parent_id, diff.new_path)), { class: 'btn btn-small view-file' } do + View file @ + %span.commit-short-id= @commit.short_id(6) - else %span= diff.new_path - if diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode %span.file-mode= "#{diff.a_mode} → #{diff.b_mode}" - = link_to project_blob_path(project, tree_join(@commit.id, diff.new_path)), {:class => 'btn btn-tiny pull-right view-file'} do - View file @ - %span.commit-short-id= @commit.short_id(6) + .diff-btn-group + = link_to "#", class: "js-toggle-button btn btn-small" do + %i.icon-chevron-down + Diff comments +   - .content + - if @merge_request && @merge_request.source_project + = link_to project_edit_tree_path(@merge_request.source_project, tree_join(@merge_request.source_branch, diff.new_path), from_merge_request_id: @merge_request.id), { class: 'btn btn-small' } do + Edit +   + + = link_to project_blob_path(project, tree_join(@commit.id, diff.new_path)), { class: 'btn btn-small view-file' } do + View file @ + %span.commit-short-id= @commit.short_id(6) + + + .diff-content -# Skipp all non non-supported blobs - next unless file.respond_to?('text?') - if file.text? - = render "projects/commits/text_file", diff: diff, index: i + - if params[:view] == 'parallel' + = render "projects/commits/parallel_view", diff: diff, project: project, file: file, index: i + - else + = render "projects/commits/text_file", diff: diff, index: i - elsif file.image? - old_file = project.repository.blob_at(@commit.parent_id, diff.old_path) if @commit.parent_id = render "projects/commits/image", diff: diff, old_file: old_file, file: file, index: i - else - %p.nothing_here_message No preview for this file type + .nothing-here-block No preview for this file type diff --git a/app/views/projects/commits/_head.html.haml b/app/views/projects/commits/_head.html.haml index c2da9f273b..81e3374391 100644 --- a/app/views/projects/commits/_head.html.haml +++ b/app/views/projects/commits/_head.html.haml @@ -22,6 +22,6 @@ - if current_user && current_controller?(:commits) && current_user.private_token - %li.pull-right + %li.pull-right.hidden-sm = link_to project_commits_path(@project, @ref, {format: :atom, private_token: current_user.private_token}), title: "Feed" do %i.icon-rss diff --git a/app/views/projects/commits/_image.html.haml b/app/views/projects/commits/_image.html.haml index 73f87289d3..6d9ef5964d 100644 --- a/app/views/projects/commits/_image.html.haml +++ b/app/views/projects/commits/_image.html.haml @@ -15,7 +15,7 @@ %span.meta-filesize= "#{number_to_human_size old_file.size}" | %b W: - %span.meta-width + %span.meta-width | %b H: %span.meta-height @@ -27,7 +27,7 @@ %span.meta-filesize= "#{number_to_human_size file.size}" | %b W: - %span.meta-width + %span.meta-width | %b H: %span.meta-height @@ -60,4 +60,4 @@ %ul.view-modes-menu %li.two-up{data: {mode: 'two-up'}} 2-up %li.swipe{data: {mode: 'swipe'}} Swipe - %li.onion-skin{data: {mode: 'onion-skin'}} Onion skin \ No newline at end of file + %li.onion-skin{data: {mode: 'onion-skin'}} Onion skin diff --git a/app/views/projects/commits/_inline_commit.html.haml b/app/views/projects/commits/_inline_commit.html.haml index 5be8460e06..b36369b428 100644 --- a/app/views/projects/commits/_inline_commit.html.haml +++ b/app/views/projects/commits/_inline_commit.html.haml @@ -2,8 +2,7 @@ .commit-row-title = link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id"   - = link_to_gfm truncate(commit.title, length: 40), project_commit_path(project, commit.id), class: "commit-row-message" - %time.committed_ago{ datetime: commit.committed_date, title: commit.committed_date.stamp("Aug 21, 2011 9:23pm") } - = time_ago_in_words(commit.committed_date) - ago -   + %span.str-truncated + = link_to_gfm commit.title, project_commit_path(project, commit.id), class: "commit-row-message" + .pull-right + #{time_ago_with_tooltip(commit.committed_date)} diff --git a/app/views/projects/commits/_parallel_view.html.haml b/app/views/projects/commits/_parallel_view.html.haml new file mode 100644 index 0000000000..80f5be98f2 --- /dev/null +++ b/app/views/projects/commits/_parallel_view.html.haml @@ -0,0 +1,38 @@ +/ Side-by-side diff view +- old_lines, new_lines = parallel_diff_lines(project, @commit, diff, file) +- num_lines = old_lines.length + +%div.text-file + %table + - num_lines.times do |index| + - new_line = new_lines[index] + - old_line = old_lines[index] + %tr.line_holder.parallel + -# For old line + - if old_line.type == :file_created + %td.old_line= old_line.num + %td.line_content.parallel= "File was created" + - elsif old_line.type == :deleted + %td.old_line.old= old_line.num + %td.line_content{class: "parallel noteable_line old #{old_line.code}", "line_code" => old_line.code}= old_line.content + - else old_line.type == :no_change + %td.old_line= old_line.num + %td.line_content.parallel= old_line.content + + -# For new line + - if new_line.type == :file_deleted + %td.new_line= new_line.num + %td.line_content.parallel= "File was deleted" + - elsif new_line.type == :added + %td.new_line.new= new_line.num + %td.line_content{class: "parallel noteable_line new #{new_line.code}", "line_code" => new_line.code}= new_line.content + - else new_line.type == :no_change + %td.new_line= new_line.num + %td.line_content.parallel= new_line.content + + - if @reply_allowed + - comments1 = @line_notes.select { |n| n.line_code == old_line.code }.sort_by(&:created_at) + - comments2 = @line_notes.select { |n| n.line_code == new_line.code }.sort_by(&:created_at) + - unless comments1.empty? and comments2.empty? + = render "projects/notes/diff_notes_with_reply_parallel", notes1: comments1, notes2: comments2 + diff --git a/app/views/projects/commits/_text_file.html.haml b/app/views/projects/commits/_text_file.html.haml index c724213878..ba83d2e5a0 100644 --- a/app/views/projects/commits/_text_file.html.haml +++ b/app/views/projects/commits/_text_file.html.haml @@ -1,6 +1,6 @@ - too_big = diff.diff.lines.count > 1000 - if too_big - %a.supp_diff_link Diff suppressed. Click to show + %a.supp_diff_link Changes suppressed. Click to show %table.text-file{class: "#{'hide' if too_big}"} - each_diff_line(diff, index) do |line, type, line_code, line_new, line_old, raw_line| @@ -21,3 +21,4 @@ - comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at) - unless comments.empty? = render "projects/notes/diff_notes_with_reply", notes: comments, line: line + diff --git a/app/views/projects/commits/show.atom.builder b/app/views/projects/commits/show.atom.builder index 27c8fa6da7..32c82edb24 100644 --- a/app/views/projects/commits/show.atom.builder +++ b/app/views/projects/commits/show.atom.builder @@ -3,7 +3,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://sear xml.title "Recent commits to #{@project.name}:#{@ref}" 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.id project_commits_url(@project, @ref) xml.updated @commits.first.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") if @commits.any? @commits.each do |commit| diff --git a/app/views/projects/commits/show.html.haml b/app/views/projects/commits/show.html.haml index 723c5a1c34..3a4f304a25 100644 --- a/app/views/projects/commits/show.html.haml +++ b/app/views/projects/commits/show.html.haml @@ -9,7 +9,7 @@ %div{id: dom_id(@project)} #commits-list= render "commits" .clear -.loading{ style: "display:none;"} += spinner - if @commits.count == @limit :javascript diff --git a/app/views/projects/commits/show.js.haml b/app/views/projects/commits/show.js.haml deleted file mode 100644 index 045c9dd83d..0000000000 --- a/app/views/projects/commits/show.js.haml +++ /dev/null @@ -1,3 +0,0 @@ -:plain - CommitsList.append(#{@commits.count}, "#{escape_javascript(render('projects/commits/commits'))}"); - diff --git a/app/views/projects/compare/_form.html.haml b/app/views/projects/compare/_form.html.haml index ca1ea4073e..da6157cf1b 100644 --- a/app/views/projects/compare/_form.html.haml +++ b/app/views/projects/compare/_form.html.haml @@ -1,21 +1,21 @@ -= form_tag project_compare_index_path(@project), method: :post do - .clearfix - .pull-left - - if params[:to] && params[:from] - = link_to 'switch', {from: params[:to], to: params[:from]}, {class: 'commits-compare-switch has_tooltip', title: 'Switch base of comparison'} - .input-prepend - %span.add-on.input-xpadding from - = text_field_tag :from, params[:from], class: "span3 input-xpadding" - = "..." - .input-prepend - %span.add-on.input-xpadding to - = text_field_tag :to, params[:to], class: "span3 input-xpadding" - .pull-left -   - = submit_tag "Compare", class: "btn btn-create commits-compare-btn" - - if compare_to_mr_button? - = link_to compare_mr_path, class: 'prepend-left-10' do - %strong Make a merge request += form_tag project_compare_index_path(@project), method: :post, class: 'form-inline' do + .clearfix.append-bottom-20 + - if params[:to] && params[:from] + = link_to 'switch', {from: params[:to], to: params[:from]}, {class: 'commits-compare-switch has_tooltip', title: 'Switch base of comparison'} + .form-group + .input-group.inline-input-group + %span.input-group-addon from + = text_field_tag :from, params[:from], class: "form-control" + = "..." + .form-group + .input-group.inline-input-group + %span.input-group-addon to + = text_field_tag :to, params[:to], class: "form-control" +   + = submit_tag "Compare", class: "btn btn-create commits-compare-btn" + - if compare_to_mr_button? + = link_to compare_mr_path, class: 'prepend-left-10 btn' do + %strong Make a merge request :javascript diff --git a/app/views/projects/compare/show.html.haml b/app/views/projects/compare/show.html.haml index 4be62d3691..57331bff31 100644 --- a/app/views/projects/compare/show.html.haml +++ b/app/views/projects/compare/show.html.haml @@ -5,21 +5,32 @@ = render "form" -- if @commits.size > 100 - .alert.alert-block - %p - %strong Warning! This comparison includes more than 100 commits. - %p To preserve performance the line diff is not shown. - - if @commits.present? %div.ui-box .title Commits (#{@commits.count}) - %ul.well-list= render Commit.decorate(@commits), project: @project + - if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE + %ul.well-list + - Commit.decorate(@commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE)).each do |commit| + = render "projects/commits/inline_commit", commit: commit, project: @project + %li.warning-row.unstyled + other #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} commits hidden to prevent performance issues. + - else + %ul.well-list= render Commit.decorate(@commits), project: @project - - unless @diffs.empty? - %h4 Diff + %h4 Changes + - if @diffs.present? = render "projects/commits/diffs", diffs: @diffs, project: @project + - elsif @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE + .bs-callout.bs-callout-danger + %h4 This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits. + %p To preserve performance the line changes are not shown. + - elsif @timeout + .bs-callout.bs-callout-danger + %h4 Number of changed files for this comparison is extremely large. + %p Use command line to browse through changes for this comparison. + + - else .light-well %center diff --git a/app/views/projects/create.js.haml b/app/views/projects/create.js.haml index a444b8b59a..89710d3a09 100644 --- a/app/views/projects/create.js.haml +++ b/app/views/projects/create.js.haml @@ -1,6 +1,10 @@ - if @project.saved? - :plain - location.href = "#{project_path(@project)}"; + - if @project.import? + :plain + location.href = "#{import_project_path(@project)}"; + - else + :plain + location.href = "#{project_path(@project)}"; - else :plain $(".project-edit-errors").html("#{escape_javascript(render('errors'))}"); diff --git a/app/views/projects/deploy_keys/_deploy_key.html.haml b/app/views/projects/deploy_keys/_deploy_key.html.haml index 45f80ecd55..2b4f36fb4b 100644 --- a/app/views/projects/deploy_keys/_deploy_key.html.haml +++ b/app/views/projects/deploy_keys/_deploy_key.html.haml @@ -10,7 +10,7 @@ %i.icon-off Disable - else - = link_to 'Remove', project_deploy_key_path(@project, deploy_key), confirm: 'You are going to remove deploy key. Are you sure?', method: :delete, class: "btn btn-remove delete-key btn-small pull-right" + = link_to 'Remove', project_deploy_key_path(@project, deploy_key), data: { confirm: 'You are going to remove deploy key. Are you sure?'}, method: :delete, class: "btn btn-remove delete-key btn-small pull-right" = link_to project_deploy_key_path(deploy_key.projects.include?(@project) ? @project : deploy_key.projects.first, deploy_key) do @@ -19,7 +19,6 @@ %p.light.prepend-top-10 - deploy_key.projects.map(&:name_with_namespace).each do |project_name| - %span.label= project_name + %span.label.label-gray.deploy-project-label= project_name %small.pull-right - Created #{time_ago_in_words(deploy_key.created_at)} ago - + Created #{time_ago_with_tooltip(deploy_key.created_at)} diff --git a/app/views/projects/deploy_keys/_form.html.haml b/app/views/projects/deploy_keys/_form.html.haml index d49b220453..ebb92b36b4 100644 --- a/app/views/projects/deploy_keys/_form.html.haml +++ b/app/views/projects/deploy_keys/_form.html.haml @@ -1,21 +1,21 @@ %div - = form_for [@project, @key], url: project_deploy_keys_path do |f| + = form_for [@project, @key], url: project_deploy_keys_path, html: { class: 'deploy-key-form form-horizontal' } do |f| -if @key.errors.any? - .alert.alert-error + .alert.alert-danger %ul - @key.errors.full_messages.each do |msg| %li= msg - .control-group - = f.label :title - .controls= f.text_field :title, class: 'input-xlarge' - .control-group - = f.label :key - .controls + .form-group + = f.label :title, class: "control-label" + .col-sm-10= f.text_field :title, class: 'form-control' + .form-group + = f.label :key, class: "control-label" + .col-sm-10 %p.light Paste a machine public key here. Read more about how to generate it = link_to "here", help_ssh_path - = f.text_area :key, class: "input-xxlarge thin_area" + = f.text_area :key, class: "form-control thin_area", rows: 5 .form-actions = f.submit 'Create', class: "btn-create btn" diff --git a/app/views/projects/deploy_keys/index.html.haml b/app/views/projects/deploy_keys/index.html.haml index 53d6e36c62..f50aeba337 100644 --- a/app/views/projects/deploy_keys/index.html.haml +++ b/app/views/projects/deploy_keys/index.html.haml @@ -12,7 +12,7 @@ %hr.clearfix .row - .span5.enabled-keys + .col-md-6.enabled-keys %h5 %strong.cgreen Enabled deploy keys for this project @@ -20,8 +20,8 @@ = render @enabled_keys - if @enabled_keys.blank? .light-well - %p.nothing_here_message Create a #{link_to 'new deploy key', new_project_deploy_key_path(@project)} or add an existing one - .span5.available-keys + .nothing-here-block Create a #{link_to 'new deploy key', new_project_deploy_key_path(@project)} or add an existing one + .col-md-6.available-keys %h5 %strong Deploy keys from projects available to you @@ -29,4 +29,4 @@ = render @available_keys - if @available_keys.blank? .light-well - %p.nothing_here_message Deploy keys from projects you have access to will be displayed here + .nothing-here-block Deploy keys from projects you have access to will be displayed here diff --git a/app/views/projects/deploy_keys/show.html.haml b/app/views/projects/deploy_keys/show.html.haml index 49566f83d2..c66e6bc69c 100644 --- a/app/views/projects/deploy_keys/show.html.haml +++ b/app/views/projects/deploy_keys/show.html.haml @@ -2,7 +2,7 @@ Deploy key: = @key.title %small - created at + created on = @key.created_at.stamp("Aug 21, 2011") .back-link = link_to project_deploy_keys_path(@project) do @@ -10,4 +10,4 @@ %hr %pre= @key.key .pull-right - = link_to 'Remove', project_deploy_key_path(@project, @key), confirm: 'Are you sure?', method: :delete, class: "btn-remove btn delete-key" + = link_to 'Remove', project_deploy_key_path(@project, @key), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn-remove btn delete-key" diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index d13ae937be..10674ccae4 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -7,95 +7,85 @@ %p.light Some settings, such as "Transfer Project", are hidden inside the danger area below %hr .form-holder - = form_for(@project, remote: true) do |f| + = form_for @project, remote: true, html: { class: "edit_project form-horizontal" } do |f| %fieldset - .control-group.project_name_holder - = f.label :name do + .form-group.project_name_holder + = f.label :name, class: 'control-label' do Project name - .controls - = f.text_field :name, placeholder: "Example Project", class: "span5" + .col-sm-10 + = f.text_field :name, placeholder: "Example Project", class: "form-control" - .control-group - = f.label :description do + .form-group + = f.label :description, class: 'control-label' do Project description %span.light (optional) - .controls - = f.text_area :description, placeholder: "Awesome project", class: "span5", rows: 3, maxlength: 250 + .col-sm-10 + = f.text_area :description, placeholder: "Awesome project", class: "form-control", rows: 3, maxlength: 250 - if @project.repository.exists? && @project.repository.branch_names.any? - .control-group - = f.label :default_branch, "Default Branch" - .controls= f.select(:default_branch, @repository.branch_names, {}, {class: 'chosen'}) + .form-group + = f.label :default_branch, "Default Branch", class: 'control-label' + .col-sm-10= f.select(:default_branch, @repository.branch_names, {}, {class: 'select2 select-wide'}) - - if can?(current_user, :change_public_mode, @project) - %fieldset.public-mode - %legend - Public mode: - .control-group - = f.label :public, class: 'control-label' do - %span Public access - .controls - = f.check_box :public - %span.descr - If checked, this project can be cloned - %em without any - authentication. - It will also be listed on the #{link_to "public access directory", public_root_path}. - %em Any - user will have #{link_to "Guest", help_permissions_path} permissions on the repository. + = render "visibility_level", f: f, visibility_level: @project.visibility_level, can_change_visibility_level: can?(current_user, :change_visibility_level, @project) %fieldset.features %legend Labels: - .control-group + .form-group = f.label :label_list, "Labels", class: 'control-label' - .controls - = f.text_field :label_list, maxlength: 2000, class: "span5" + .col-sm-10 + = f.text_field :label_list, maxlength: 2000, class: "form-control" %p.hint Separate labels with commas. %fieldset.features %legend Features: - .control-group + .form-group = f.label :issues_enabled, "Issues", class: 'control-label' - .controls - = f.check_box :issues_enabled - %span.descr Lightweight issue tracking system for this project + .col-sm-10 + .checkbox + = f.check_box :issues_enabled + %span.descr Lightweight issue tracking system for this project - if Project.issues_tracker.values.count > 1 - .control-group + .form-group = f.label :issues_tracker, "Issues tracker", class: 'control-label' - .controls= f.select(:issues_tracker, project_issues_trackers, {}, { disabled: !@project.issues_enabled }) + .col-sm-10= f.select(:issues_tracker, project_issues_trackers(@project.issues_tracker), {}, { disabled: !@project.issues_enabled }) - .control-group + .form-group = f.label :issues_tracker_id, "Project name or id in issues tracker", class: 'control-label' - .controls= f.text_field :issues_tracker_id, disabled: !@project.can_have_issues_tracker_id? + .col-sm-10= f.text_field :issues_tracker_id, disabled: !@project.can_have_issues_tracker_id?, class: 'form-control' - .control-group + .form-group = f.label :merge_requests_enabled, "Merge Requests", class: 'control-label' - .controls - = f.check_box :merge_requests_enabled - %span.descr Submit changes to be merged upstream. + .col-sm-10 + .checkbox + = f.check_box :merge_requests_enabled + %span.descr Submit changes to be merged upstream. - .control-group + .form-group = f.label :wiki_enabled, "Wiki", class: 'control-label' - .controls - = f.check_box :wiki_enabled - %span.descr Pages for project documentation + .col-sm-10 + .checkbox + = f.check_box :wiki_enabled + %span.descr Pages for project documentation - .control-group + .form-group = f.label :wall_enabled, "Wall", class: 'control-label' - .controls - = f.check_box :wall_enabled - %span.descr Simple chat system for broadcasting inside project + .col-sm-10 + .checkbox + = f.check_box :wall_enabled + %span.descr Simple chat system for broadcasting inside project - .control-group + .form-group = f.label :snippets_enabled, "Snippets", class: 'control-label' - .controls - = f.check_box :snippets_enabled - %span.descr Share code pastes with others out of git repository + .col-sm-10 + .checkbox + = f.check_box :snippets_enabled + %span.descr Share code pastes with others out of git repository .form-actions @@ -103,69 +93,105 @@ - %center.light.prepend-top-20.padded - %h3 - %i.icon-warning-sign - Dangerous settings - %p Project settings below may result in data loss! - = link_to '#', class: 'btn js-toggle-visibility-link' do - Show it to me - %i.icon-chevron-down + .danger-settings.js-toggle-container + .centered-light-block + %h3 + %i.icon-warning-sign + Dangerous settings + + %p Project settings below may result in data loss! + = link_to '#', class: 'btn js-toggle-button' do + Show it to me + %i.icon-chevron-down + + .js-toggle-content.hide + - if can? current_user, :archive_project, @project + .ui-box.ui-box-danger + .title + - if @project.archived? + Unarchive project + - else + Archive project + .body + - if @project.archived? + %p + Unarchiving the project will mark its repository as active. + %br + The project can be committed to. + %br + %strong Once active this project shows up in the search and on the dashboard. + = link_to 'Unarchive', unarchive_project_path(@project), + data: { confirm: "Are you sure that you want to unarchive this project?\nWhen this project is unarchived it is active and can be comitted to again." }, + method: :post, class: "btn btn-remove" + - else + %p + Archiving the project will mark its repository as read-only. + %br + It is hidden from the dashboard and doesn't show up in searches. + %br + %strong Archived projects cannot be committed to! + = link_to 'Archive', archive_project_path(@project), + data: { confirm: "Are you sure that you want to archive this project?\nAn archived project cannot be committed to." }, + method: :post, class: "btn btn-remove" + - else + .nothing-here-block Only the project owner can archive a project + + - if can?(current_user, :change_namespace, @project) + .ui-box.ui-box-danger + .title Transfer project + .errors-holder + .form-holder + = form_for(@project, url: transfer_project_path(@project), method: :put, remote: true, html: { class: 'transfer-project form-horizontal' }) do |f| + .form-group + = f.label :namespace_id, class: 'control-label' do + %span Namespace + .col-sm-10 + .form-group + = f.select :namespace_id, namespaces_options(@project.namespace_id), { prompt: 'Choose a project namespace' }, { class: 'select2' } + %ul + %li Be careful. Changing the project's namespace can have unintended side effects. + %li You can only transfer the project to namespaces you manage. + %li You will need to update your local repositories to point to the new location. + .form-actions + = f.submit 'Transfer', class: "btn btn-remove" + - else + .nothing-here-block Only the project owner can transfer a project - .js-toggle-visibility-container.hide - - if can?(current_user, :change_namespace, @project) .ui-box.ui-box-danger - .title Transfer project + .title Rename repository .errors-holder .form-holder - = form_for(@project, url: transfer_project_path(@project), remote: true, html: { class: 'transfer-project' }) do |f| - .control-group - = f.label :namespace_id do - %span Namespace - .controls - .control-group - = f.select :namespace_id, namespaces_options(@project.namespace_id), {prompt: 'Choose a project namespace'}, {class: 'chosen'} + = form_for(@project, html: { class: 'form-horizontal' }) do |f| + .form-group + = f.label :path, class: 'control-label' do + %span Path + .col-sm-9 + .form-group + .input-group + = f.text_field :path, class: 'form-control' + %span.input-group-addon .git %ul - %li Be careful. Changing the project's namespace can have unintended side effects. - %li You can only transfer the project to namespaces you manage. + %li Be careful. Renaming a project's repository can have unintended side effects. %li You will need to update your local repositories to point to the new location. .form-actions - = f.submit 'Transfer', class: "btn btn-remove" - - else - %p.nothing_here_message Only the project owner can transfer a project + = f.submit 'Rename', class: "btn btn-remove" - .ui-box.ui-box-danger - .title Rename repository - .errors-holder - .form-holder - = form_for(@project) do |f| - .control-group - = f.label :path do - %span Path - .controls - .control-group - = f.text_field :path - %ul - %li Be careful. Renaming a project's repository can have unintended side effects. - %li You will need to update your local repositories to point to the new location. - .form-actions - = f.submit 'Rename', class: "btn btn-remove" + - if can?(current_user, :remove_project, @project) + .ui-box.ui-box-danger + .title Remove project + .body + %p + Removing the project will delete its repository and all related resources including issues, merge requests etc. + %br + %strong Removed projects cannot be restored! - - if can?(current_user, :remove_project, @project) - .ui-box.ui-box-danger - .title Remove project - .ui-box-body - %p - Removing the project will delete its repository and all related resources including issues, merge requests etc. - %br - %strong Removed projects cannot be restored! - - = link_to 'Remove project', @project, confirm: remove_project_message(@project), method: :delete, class: "btn btn-remove" - - else - %p.nothing_here_message Only project owner can remove a project + = link_to 'Remove project', @project, data: { confirm: remove_project_message(@project) }, method: :delete, class: "btn btn-remove" + - else + .nothing-here-block Only project owner can remove a project .save-project-loader.hide %center - = image_tag "ajax_loader.gif" - %h3 Saving project. + %h2 + %i.icon-spinner.icon-spin + Saving project. %p Please wait a moment, this page will automatically refresh when ready. diff --git a/app/views/projects/edit_tree/_diff.html.haml b/app/views/projects/edit_tree/_diff.html.haml new file mode 100644 index 0000000000..cf044feb9a --- /dev/null +++ b/app/views/projects/edit_tree/_diff.html.haml @@ -0,0 +1,13 @@ +%table.text-file + - each_diff_line(diff, 1) do |line, type, line_code, line_new, line_old, raw_line| + %tr.line_holder{ id: line_code, class: "#{type}" } + - if type == "match" + %td.old_line= "..." + %td.new_line= "..." + %td.line_content.matched= line + - else + %td.old_line + = link_to raw(type == "new" ? " " : line_old), "##{line_code}", id: line_code + %td.new_line= link_to raw(type == "old" ? " " : line_new) , "##{line_code}", id: line_code + %td.line_content{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw diff_line_content(line) + diff --git a/app/views/projects/edit_tree/preview.html.haml b/app/views/projects/edit_tree/preview.html.haml new file mode 100644 index 0000000000..fc6d3bfbc2 --- /dev/null +++ b/app/views/projects/edit_tree/preview.html.haml @@ -0,0 +1,26 @@ +.diff-file + .diff-content + - if gitlab_markdown?(@blob.name) + .file-content.wiki + = preserve do + = markdown(@content) + - elsif markup?(@blob.name) + .file-content.wiki + = raw GitHub::Markup.render(@blob.name, @content) + - else + .file-content.code + - unless @diff.empty? + %table.text-file + - @diff.each do |line, type, line_code, line_new, line_old, raw_line| + %tr.line_holder{ id: line_code, class: "#{type}" } + - if type == "match" + %td.old_line= "..." + %td.new_line= "..." + %td.line_content.matched= line + - else + %td.old_line + = link_to raw(type == "new" ? " " : line_old), "##{line_code}", id: line_code + %td.new_line= link_to raw(type == "old" ? " " : line_new) , "##{line_code}", id: line_code + %td.line_content{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw diff_line_content(line) + - else + %p.nothing_here_message No changes. diff --git a/app/views/projects/edit_tree/show.html.haml b/app/views/projects/edit_tree/show.html.haml index b1fb4f8637..93037ef958 100644 --- a/app/views/projects/edit_tree/show.html.haml +++ b/app/views/projects/edit_tree/show.html.haml @@ -1,8 +1,11 @@ %h3.page-title Edit mode .file-editor = form_tag(project_edit_tree_path(@project, @id), method: :put, class: "form-horizontal") do - .file-holder + .file-holder.file .file-title + .btn-group.js-edit-mode.left-options + = link_to 'Edit', '#editor', class: 'active hover btn btn-tiny' + = link_to editing_preview_title(@blob.name), '#preview', class: 'btn btn-tiny', 'data-preview-url' => preview_project_edit_tree_path(@project, @id) %i.icon-file %span.file_name = @path @@ -11,27 +14,30 @@ %strong= @ref %span.options .btn-group.tree-btn-group - = link_to "Cancel", project_blob_path(@project, @id), class: "btn btn-tiny btn-cancel", confirm: leave_edit_message + = link_to "Cancel", @after_edit_path, class: "btn btn-tiny btn-cancel", data: { confirm: leave_edit_message } .file-content.code - %pre#editor= @blob.data + %pre.js-edit-mode-pane#editor= @blob.data + .js-edit-mode-pane#preview.hide - .control-group.commit_message-group + .form-group.commit_message-group = label_tag 'commit_message', class: "control-label" do Commit message - .controls - = text_area_tag 'commit_message', '', placeholder: "Update #{@blob.name}", required: true, rows: 3 + .col-sm-10 + = render 'shared/commit_message_container', {textarea: text_area_tag('commit_message', '', + placeholder: "Update #{@blob.name}", required: true, rows: 3, class: 'form-control')} .form-actions = hidden_field_tag 'last_commit', @last_commit = hidden_field_tag 'content', '', id: "file-content" + = hidden_field_tag 'from_merge_request_id', params[:from_merge_request_id] .commit-button-annotation = button_tag "Commit changes", class: 'btn commit-btn js-commit-button btn-primary' .message to branch %strong= @ref - = link_to "Cancel", project_blob_path(@project, @id), class: "btn btn-cancel", confirm: leave_edit_message + = link_to "Cancel", @after_edit_path, class: "btn btn-cancel", data: { confirm: leave_edit_message} :javascript - ace.config.set("modePath", gon.relative_url_root + "#{Gitlab::Application.config.assets.prefix}/ace-src-noconflict") + ace.config.set("modePath", gon.relative_url_root + "#{Gitlab::Application.config.assets.prefix}/ace") var ace_mode = "#{@blob.language.try(:ace_mode)}"; var editor = ace.edit("editor"); if (ace_mode) { @@ -44,3 +50,28 @@ $("#file-content").val(editor.getValue()); $(".file-editor form").submit(); }); + + var editModePanes = $('.js-edit-mode-pane'), + editModeLinks = $('.js-edit-mode a'); + + editModeLinks.click(function(event) { + event.preventDefault(); + + var currentLink = $(this), + paneId = currentLink.attr('href'), + currentPane = editModePanes.filter(paneId); + + editModeLinks.removeClass('active hover'); + currentLink.addClass('active hover'); + editModePanes.hide(); + + if (paneId == '#preview') { + $.post(currentLink.data('preview-url'), { content: editor.getValue() }, function(response) { + currentPane.empty().append(response); + currentPane.fadeIn(200); + }) + } else { + currentPane.fadeIn(200); + editor.focus() + } + }) diff --git a/app/views/projects/empty.html.haml b/app/views/projects/empty.html.haml index 04fc0c3173..97dc73bce1 100644 --- a/app/views/projects/empty.html.haml +++ b/app/views/projects/empty.html.haml @@ -1,50 +1,34 @@ -%h3.page-title - = @project.name_with_namespace - .form-horizontal.pull-right - = render "shared/clone_panel" += render "home_panel" -- if @project.import? && !@project.imported - .save-project-loader - %center - = image_tag "ajax_loader.gif" - %h3 Importing repository. - %p.monospace git clone --bare #{@project.import_url} - %p Please wait while we import the repository for you. Refresh at will. - :javascript - new ProjectImport(); +%div.git-empty + %fieldset + %legend Git global setup: + %pre.dark + :preserve + git config --global user.name "#{git_user_name}" + git config --global user.email "#{git_user_email}" -- else - %div.git-empty - %fieldset - %legend Git global setup: - %pre.dark - :preserve - git config --global user.name "#{git_user_name}" - git config --global user.email "#{git_user_email}" + %fieldset + %legend Create Repository + %pre.dark + :preserve + mkdir #{@project.path} + cd #{@project.path} + git init + touch README + git add README + git commit -m 'first commit' + git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'clone')} + git push -u origin master - %fieldset - %legend Create Repository - %pre.dark - :preserve - mkdir #{@project.path} - cd #{@project.path} - git init - touch README - git add README - git commit -m 'first commit' - %span.clone= "git remote add origin #{@project.url_to_repo}" - :preserve - git push -u origin master + %fieldset + %legend Existing Git Repo? + %pre.dark + :preserve + cd existing_git_repo + git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'clone')} + git push -u origin master - %fieldset - %legend Existing Git Repo? - %pre.dark - :preserve - cd existing_git_repo - %span.clone= "git remote add origin #{@project.url_to_repo}" - :preserve - git push -u origin master - - - if can? current_user, :remove_project, @project - .prepend-top-20 - = link_to 'Remove project', @project, confirm: remove_project_message(@project), method: :delete, class: "btn btn-remove pull-right" +- if can? current_user, :remove_project, @project + .prepend-top-20 + = link_to 'Remove project', @project, data: { confirm: remove_project_message(@project)}, method: :delete, class: "btn btn-remove pull-right" diff --git a/app/views/projects/fork.html.haml b/app/views/projects/fork.html.haml index a1c109e5d6..bdd75de447 100644 --- a/app/views/projects/fork.html.haml +++ b/app/views/projects/fork.html.haml @@ -1,11 +1,11 @@ -.alert.alert-error.alert-block +.alert.alert-danger.alert-block %h4 %i.icon-code-fork Fork Error! %p - You are trying to fork + You tried to fork = link_to_project @project - but it fails due to next reason: + but it failed for the following reason: - if @forked_project && @forked_project.errors.any? diff --git a/app/views/projects/graphs/show.html.haml b/app/views/projects/graphs/show.html.haml index a21cb9e786..27348232ba 100644 --- a/app/views/projects/graphs/show.html.haml +++ b/app/views/projects/graphs/show.html.haml @@ -1,7 +1,8 @@ .loading-graph %center - .loading - %h3.page-title Building repository graph. + %h3.page-title + %i.icon-spinner.icon-spin + Building repository graph. %p Please wait a moment, this page will automatically refresh when ready. .stat-graph diff --git a/app/views/projects/graphs/show.js.haml b/app/views/projects/graphs/show.js.haml index 43e776e533..dcf6cacdce 100644 --- a/app/views/projects/graphs/show.js.haml +++ b/app/views/projects/graphs/show.js.haml @@ -16,4 +16,4 @@ }) - else :plain - $('.stat-graph').replaceWith('
    Failed to load graph
    ') + $('.stat-graph').replaceWith('
    Failed to load graph
    ') diff --git a/app/views/projects/hooks/_data_ex.html.erb b/app/views/projects/hooks/_data_ex.html.erb deleted file mode 100644 index 5092aaf675..0000000000 --- a/app/views/projects/hooks/_data_ex.html.erb +++ /dev/null @@ -1,44 +0,0 @@ -<% data_ex_str = < -
    - <%= raw Pygments::Lexer[:js].highlight(data_ex_str) %> -
    diff --git a/app/views/projects/hooks/index.html.haml b/app/views/projects/hooks/index.html.haml index f748eb2929..866fd6f606 100644 --- a/app/views/projects/hooks/index.html.haml +++ b/app/views/projects/hooks/index.html.haml @@ -1,35 +1,68 @@ %h3.page-title - Post-receive hooks + Web hooks %p.light - #{link_to "Post-receive hooks ", help_web_hooks_path, class: "vlink"} can be - used for binding events when someone pushes to the repository. + #{link_to "Web hooks ", help_web_hooks_path, class: "vlink"} can be + used for binding events when something is happening within the project. %hr.clearfix -= form_for [@project, @hook], as: :hook, url: project_hooks_path(@project), html: { class: 'form-inline' } do |f| += form_for [@project, @hook], as: :hook, url: project_hooks_path(@project), html: { class: 'form-horizontal' } do |f| -if @hook.errors.any? - .alert.alert-error + .alert.alert-danger - @hook.errors.full_messages.each do |msg| %p= msg - .control-group - = f.label :url, "URL:" - .controls - = f.text_field :url, class: "text_field input-xxlarge input-xpadding", placeholder: 'http://example.com/trigger-ci.json' -   - = f.submit "Add Web Hook", class: "btn btn-create" -%hr + .form-group + = f.label :url, "URL", class: 'control-label' + .col-sm-10 + = f.text_field :url, class: "form-control", placeholder: 'http://example.com/trigger-ci.json' + .form-group + = f.label :url, "Trigger", class: 'control-label' + .col-sm-10 + %div + = f.check_box :push_events, class: 'pull-left' + .prepend-left-20 + = f.label :push_events, class: 'list-label' do + %strong Push events + %p.light + This url will be triggered by a push to the repository + %div + = f.check_box :tag_push_events, class: 'pull-left' + .prepend-left-20 + = f.label :tag_push_events, class: 'list-label' do + %strong Tag push events + %p.light + This url will be triggered when a new tag is pushed to the repository + %div + = f.check_box :issues_events, class: 'pull-left' + .prepend-left-20 + = f.label :issues_events, class: 'list-label' do + %strong Issues events + %p.light + This url will be triggered when an issue is created + %div + = f.check_box :merge_requests_events, class: 'pull-left' + .prepend-left-20 + = f.label :merge_requests_events, class: 'list-label' do + %strong Merge Request events + %p.light + This url will be triggered when a merge request is created + .form-actions + = f.submit "Add Web Hook", class: "btn btn-create" -if @hooks.any? .ui-box .title - Hooks (#{@hooks.count}) + Web hooks (#{@hooks.count}) %ul.well-list - @hooks.each do |hook| %li - %span.badge.badge-info POST - → - %span.monospace= hook.url .pull-right - = link_to 'Test Hook', test_project_hook_path(@project, hook), class: "btn btn-small grouped" - = link_to 'Remove', project_hook_path(@project, hook), confirm: 'Are you sure?', method: :delete, class: "btn btn-remove btn-small grouped" + = link_to 'Test Hook', test_project_hook_path(@project, hook), class: "btn btn-small btn-grouped" + = link_to 'Remove', project_hook_path(@project, hook), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove btn-small btn-grouped" + .clearfix + %span.monospace= hook.url + %p + - %w(push_events tag_push_events issues_events merge_requests_events).each do |trigger| + - if hook.send(trigger) + %span.label.label-gray= trigger.titleize diff --git a/app/views/projects/import.html.haml b/app/views/projects/import.html.haml new file mode 100644 index 0000000000..d11372be61 --- /dev/null +++ b/app/views/projects/import.html.haml @@ -0,0 +1,30 @@ +- if @project.import_in_progress? + .save-project-loader + %center + %h2 + %i.icon-spinner.icon-spin + Import in progress. + %p.monospace git clone --bare #{@project.import_url} + %p Please wait while we import the repository for you. Refresh at will. + :javascript + new ProjectImport(); + +- elsif @project.import_failed? + .save-project-loader + %center + %h2 + Import failed. Retry? + %hr + - if can?(current_user, :admin_project, @project) + = form_for @project, url: retry_import_project_path(@project), method: :put, html: { class: 'form-horizontal' } do |f| + .form-group.import-url-data + = f.label :import_url, class: 'control-label' do + %span Import existing repo + .col-sm-10 + = f.text_field :import_url, class: 'form-control', placeholder: 'https://github.com/randx/six.git' + .bs-callout.bs-callout-info + This url must be publicly accessible or you can add a username and password like this: https://username:password@gitlab.com/company/project.git. + %br + The import will time out after 2 minutes. For big repositories, use a clone/push combination. + .form-actions + = f.submit 'Retry import', class: "btn btn-create", tabindex: 4 diff --git a/app/views/projects/issues/_form.html.haml b/app/views/projects/issues/_form.html.haml index 05cfb2788b..84703229fe 100644 --- a/app/views/projects/issues/_form.html.haml +++ b/app/views/projects/issues/_form.html.haml @@ -1,50 +1,51 @@ %div.issue-form-holder %h3.page-title= @issue.new_record? ? "New Issue" : "Edit Issue ##{@issue.iid}" - = form_for [@project, @issue] do |f| + %hr + - if @repository.exists? && !@repository.empty? && @repository.contribution_guide && !@issue.persisted? + - contribution_guide_url = project_blob_path(@project, tree_join(@repository.root_ref, @repository.contribution_guide.name)) + .alert.alert-info.col-sm-10.col-sm-offset-2 + ="Please review the #{link_to "guidelines for contribution", contribution_guide_url} to this repository.".html_safe + = form_for [@project, @issue], html: { class: 'form-horizontal issue-form' } do |f| -if @issue.errors.any? - .alert.alert-error + .alert.alert-danger - @issue.errors.full_messages.each do |msg| %span= msg %br - .ui-box.ui-box-show - .ui-box-head - .control-group - = f.label :title do - %strong= "Subject *" - .controls - = f.text_field :title, maxlength: 255, class: "input-xxlarge js-gfm-input", autofocus: true, required: true - .ui-box-body - .control-group - .issue_assignee.pull-left - = f.label :assignee_id do - %i.icon-user - Assign to - .controls - .pull-left - = f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Select a user" }, {class: 'chosen'}) - .pull-right -   - = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' - .issue_milestone.pull-left - = f.label :milestone_id do - %i.icon-time - Milestone - .controls= f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) + .form-group + = f.label :title, class: 'control-label' do + %strong= 'Title *' + .col-sm-10 + = f.text_field :title, maxlength: 255, class: "form-control js-gfm-input", autofocus: true, required: true + .form-group + = f.label :description, 'Description', class: 'control-label' + .col-sm-10 + = f.text_area :description, class: "form-control js-gfm-input", rows: 14 + %p.hint Issues are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. + %hr + .form-group + .issue-assignee + = f.label :assignee_id, class: 'control-label' do + %i.icon-user + Assign to + .col-sm-10 + = project_users_select_tag('issue[assignee_id]', placeholder: 'Select a user', class: 'custom-form-control', selected: @issue.assignee_id) +   + = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' + .form-group + .issue-milestone + = f.label :milestone_id, class: 'control-label' do + %i.icon-time + Milestone + .col-sm-10= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'select2'}) - .ui-box-bottom - .control-group - = f.label :label_list do - %i.icon-tag - Labels - .controls - = f.text_field :label_list, maxlength: 2000, class: "input-xxlarge" - %p.hint Separate labels with commas. + .form-group + = f.label :label_list, class: 'control-label' do + %i.icon-tag + Labels + .col-sm-10 + = f.text_field :label_list, maxlength: 2000, class: "form-control" + %p.hint Separate labels with commas. - .control-group - = f.label :description, "Details" - .controls - = f.text_area :description, class: "input-xxlarge js-gfm-input", rows: 14 - %p.hint Issues are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. .form-actions @@ -90,6 +91,6 @@ }); $('.assign-to-me-link').on('click', function(e){ - $('#issue_assignee_id').val("#{current_user.id}").trigger("chosen:updated"); + $('#issue_assignee_id').val("#{current_user.id}").trigger("change"); e.preventDefault(); }); diff --git a/app/views/projects/issues/_head.html.haml b/app/views/projects/issues/_head.html.haml index 438cc02b47..f1e866c8e9 100644 --- a/app/views/projects/issues/_head.html.haml +++ b/app/views/projects/issues/_head.html.haml @@ -1,11 +1,31 @@ %ul.nav.nav-tabs = nav_link(controller: :issues) do - = link_to 'Browse Issues', project_issues_path(@project), class: "tab" + = link_to project_issues_path(@project), class: "tab" do + Browse Issues + - if current_controller?(:issues) + %span.badge.issue_counter #{@issues.total_count} = 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" - - if current_user + + - if current_controller?(:issues) + - if current_user + %li + = link_to project_issues_path(@project, :atom, { private_token: current_user.private_token }) do + %i.icon-rss + %li.pull-right - = link_to project_issues_path(@project, :atom, { private_token: current_user.private_token }) do - %i.icon-rss + .pull-right + = form_tag project_issues_path(@project), method: :get, id: "issue_search_form", class: 'pull-left issue-search-form' do + .append-right-10.hidden-xs.hidden-sm + = search_field_tag :issue_search, nil, { placeholder: 'Filter by title or description', class: 'form-control issue_search search-text-input input-mn-300' } + = hidden_field_tag :state, params['state'] + = hidden_field_tag :scope, params['scope'] + = hidden_field_tag :assignee_id, params['assignee_id'] + = hidden_field_tag :milestone_id, params['milestone_id'] + = hidden_field_tag :label_id, params['label_id'] + - if can? current_user, :write_issue, @project + = link_to new_project_issue_path(@project, issue: { assignee_id: params[:assignee_id], milestone_id: params[:milestone_id]}), class: "btn btn-new pull-left", title: "New Issue", id: "new_issue_link" do + %i.icon-plus + New Issue diff --git a/app/views/projects/issues/_issue.html.haml b/app/views/projects/issues/_issue.html.haml index effad718c8..3fc04c26cf 100644 --- a/app/views/projects/issues/_issue.html.haml +++ b/app/views/projects/issues/_issue.html.haml @@ -5,7 +5,8 @@ .issue-title %span.light= "##{issue.iid}" - = link_to_gfm truncate(issue.title, length: 100), project_issue_path(issue.project, issue), class: "row_title" + %span.str-truncated + = link_to_gfm issue.title, project_issue_path(issue.project, issue), class: "row_title" - if issue.closed? %small.pull-right = "CLOSED" @@ -26,7 +27,7 @@ %i.icon-time = issue.milestone.title .pull-right - %small updated #{time_ago_in_words(issue.updated_at)} ago + %small updated #{time_ago_with_tooltip(issue.updated_at, 'bottom', 'issue_update_ago')} .issue-labels - issue.labels.each do |label| @@ -37,10 +38,10 @@ .issue-actions - if can? current_user, :modify_issue, issue - if issue.closed? - = link_to 'Reopen', project_issue_path(issue.project, issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn btn-small grouped reopen_issue", remote: true + = link_to 'Reopen', project_issue_path(issue.project, issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn btn-small btn-grouped reopen_issue", remote: true - else - = link_to 'Close', project_issue_path(issue.project, issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn btn-small grouped close_issue", remote: true - = link_to edit_project_issue_path(issue.project, issue), class: "btn btn-small edit-issue-link grouped" do + = link_to 'Close', project_issue_path(issue.project, issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn btn-small btn-grouped close_issue", remote: true + = link_to edit_project_issue_path(issue.project, issue), class: "btn btn-small edit-issue-link btn-grouped" do %i.icon-edit Edit diff --git a/app/views/projects/issues/_issue_context.html.haml b/app/views/projects/issues/_issue_context.html.haml new file mode 100644 index 0000000000..425dcb45dd --- /dev/null +++ b/app/views/projects/issues/_issue_context.html.haml @@ -0,0 +1,24 @@ += form_for [@project, @issue], remote: true, html: {class: 'edit-issue inline-update'} do |f| + .row + .col-md-6 + %strong.append-right-10 + Assignee: + + - if can?(current_user, :modify_issue, @issue) + = project_users_select_tag('issue[assignee_id]', placeholder: 'Select assignee', class: 'custom-form-control', selected: @issue.assignee_id) + - elsif issue.assignee + = link_to_member(@project, @issue.assignee) + - else + None + + .col-md-6.text-right + %strong.append-right-10 + Milestone: + - if can?(current_user, :modify_issue, @issue) + = f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'select2 select2-compact'}) + = hidden_field_tag :issue_context + = f.submit class: 'btn' + - elsif issue.milestone + = link_to issue.milestone.title, project_milestone_path + - else + None diff --git a/app/views/projects/issues/_issues.html.haml b/app/views/projects/issues/_issues.html.haml index 427d653313..e85ff3a786 100644 --- a/app/views/projects/issues/_issues.html.haml +++ b/app/views/projects/issues/_issues.html.haml @@ -1,93 +1,76 @@ -.ui-box - .title +.append-bottom-10 + .check-all-holder = check_box_tag "check_all_issues", nil, false, class: "check_all_issues left" - .clearfix - .issues_bulk_update.hide - = form_tag bulk_update_project_issues_path(@project), method: :post do - %span Update selected issues with   - = select_tag('update[status]', options_for_select(['open', 'closed']), prompt: "Status") - = select_tag('update[assignee_id]', options_from_collection_for_select(@project.team.members, "id", "name", params[:assignee_id]), prompt: "Assignee") - = select_tag('update[milestone_id]', options_from_collection_for_select(project_active_milestones, "id", "title", params[:milestone_id]), prompt: "Milestone") - = hidden_field_tag 'update[issues_ids]', [] - = hidden_field_tag :status, params[:status] - = button_tag "Save", class: "btn update_selected_issues btn-small btn-save" - .issues-filters - %span Filter by - .dropdown.inline.prepend-left-10 - %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"} - %i.icon-tags - %span.light labels: - - if params[:label_name].present? - %strong= params[:label_name] - - else - Any - %b.caret - %ul.dropdown-menu - %li - = link_to project_filter_path(label_name: nil) do - Any - - issue_label_names.each do |label_name| - %li - = link_to project_filter_path(label_name: label_name) do - %span{class: "label #{label_css_class(label_name)}"} - %i.icon-tag - = label_name - .dropdown.inline.prepend-left-10 - %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"} - %i.icon-user - %span.light assignee: - - if @assignee.present? - %strong= @assignee.name - - elsif params[:assignee_id] == "0" - Unassigned - - else - Any - %b.caret - %ul.dropdown-menu - %li - = link_to project_filter_path(assignee_id: nil) do - Any - = link_to project_filter_path(assignee_id: 0) do - Unassigned - - @project.team.members.sort_by(&:name).each do |user| - %li - = link_to project_filter_path(assignee_id: user.id) do - = image_tag avatar_icon(user.email), class: "avatar s16", alt: '' - = user.name + .issues-filters + .dropdown.inline + %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"} + %i.icon-user + %span.light assignee: + - if @assignee.present? + %strong= @assignee.name + - elsif params[:assignee_id] == "0" + Unassigned + - else + Any + %b.caret + %ul.dropdown-menu + %li + = link_to project_filter_path(assignee_id: nil) do + Any + = link_to project_filter_path(assignee_id: 0) do + Unassigned + - @assignees.sort_by(&:name).each do |user| + %li + = link_to project_filter_path(assignee_id: user.id) do + = image_tag avatar_icon(user.email), class: "avatar s16", alt: '' + = user.name - .dropdown.inline.prepend-left-10 - %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"} - %i.icon-time - %span.light milestone: - - if @milestone.present? - %strong= @milestone.title - - elsif params[:milestone_id] == "0" - None (backlog) - - else - Any - %b.caret - %ul.dropdown-menu - %li - = link_to project_filter_path(milestone_id: nil) do - Any - = link_to project_filter_path(milestone_id: 0) do - None (backlog) - - project_active_milestones.each do |milestone| - %li - = link_to project_filter_path(milestone_id: milestone.id) do - %strong= milestone.title - %small.light= milestone.expires_at + .dropdown.inline.prepend-left-10 + %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"} + %i.icon-time + %span.light milestone: + - if @milestone.present? + %strong= @milestone.title + - elsif params[:milestone_id] == "0" + None (backlog) + - else + Any + %b.caret + %ul.dropdown-menu + %li + = link_to project_filter_path(milestone_id: nil) do + Any + = link_to project_filter_path(milestone_id: 0) do + None (backlog) + - project_active_milestones.each do |milestone| + %li + = link_to project_filter_path(milestone_id: milestone.id) do + %strong= milestone.title + %small.light= milestone.expires_at + .pull-right + = render 'shared/sort_dropdown' + .clearfix + .issues_bulk_update.hide + = form_tag bulk_update_project_issues_path(@project), method: :post do + = select_tag('update[status]', options_for_select([['Open', 'open'], ['Closed', 'closed']]), prompt: "Status") + = project_users_select_tag('update[assignee_id]', placeholder: 'Assignee') + = select_tag('update[milestone_id]', bulk_update_milestone_options, prompt: "Milestone") + = hidden_field_tag 'update[issues_ids]', [] + = hidden_field_tag :status, params[:status] + = button_tag "Update issues", class: "btn update_selected_issues btn-save" + +.ui-box %ul.well-list.issues-list = render @issues - if @issues.blank? %li - %h4.nothing_here_message No issues to show + .nothing-here-block No issues to show - if @issues.present? .pull-right %span.issue_counter #{@issues.total_count} issues for this filter - = paginate @issues, remote: true, theme: "gitlab" + = paginate @issues, theme: "gitlab" diff --git a/app/views/projects/issues/index.html.haml b/app/views/projects/issues/index.html.haml index 81594b4972..51a8c911af 100644 --- a/app/views/projects/issues/index.html.haml +++ b/app/views/projects/issues/index.html.haml @@ -1,23 +1,7 @@ = render "head" -.issues_content - %h3.page-title - Issues - %span (#{@issues.total_count}) - .pull-right - .span6 - - if can? current_user, :write_issue, @project - = link_to new_project_issue_path(@project, issue: { assignee_id: params[:assignee_id], milestone_id: params[:milestone_id]}), class: "btn btn-new pull-right", title: "New Issue", id: "new_issue_link" do - %i.icon-plus - New Issue - = form_tag project_issues_path(@project), method: :get, remote: true, id: "issue_search_form", class: 'pull-right' do - = hidden_field_tag :status, params[:status], id: 'search_status' - = hidden_field_tag :assignee_id, params[:assignee_id], id: 'search_assignee_id' - = hidden_field_tag :milestone_id, params[:milestone_id], id: 'search_milestone_id' - = hidden_field_tag :label_name, params[:label_name], id: 'search_label_name' - = search_field_tag :issue_search, nil, { placeholder: 'Filter by title or description', class: 'input-xpadding issue_search input-xlarge append-right-10 search-text-input' } - .row - .span3 - = render 'shared/project_filter', project_entities_path: project_issues_path(@project) - .span9.issues-holder + .col-md-3 + = render 'shared/project_filter', project_entities_path: project_issues_path(@project), + labels: true, redirect: 'issues' + .col-md-9.issues-holder = render "issues" diff --git a/app/views/projects/issues/index.js.haml b/app/views/projects/issues/index.js.haml deleted file mode 100644 index 1be6a64f53..0000000000 --- a/app/views/projects/issues/index.js.haml +++ /dev/null @@ -1,4 +0,0 @@ -:plain - $('.issues-holder').html("#{escape_javascript(render('issues'))}"); - History.replaceState({path: "#{request.url}"}, document.title, "#{request.url}"); - Issues.reload(); diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml index d08a8af2bb..b6d3a8edf4 100644 --- a/app/views/projects/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -1,74 +1,76 @@ %h3.page-title Issue ##{@issue.iid} - %small - created at - = @issue.created_at.stamp("Aug 21, 2011") - - %span.pull-right + %span.pull-right.issue-btn-group - if can?(current_user, :write_issue, @project) - = link_to new_project_issue_path(@project), class: "btn grouped", title: "New Issue", id: "new_issue_link" do + = link_to new_project_issue_path(@project), class: "btn btn-grouped", title: "New Issue", id: "new_issue_link" do %i.icon-plus New Issue - if can?(current_user, :modify_issue, @issue) - if @issue.closed? - = link_to 'Reopen', project_issue_path(@project, @issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn grouped reopen_issue" + = link_to 'Reopen', project_issue_path(@project, @issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn btn-grouped btn-reopen" - else - = link_to 'Close', project_issue_path(@project, @issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn grouped close_issue", title: "Close Issue" + = link_to 'Close', project_issue_path(@project, @issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn btn-grouped btn-close", title: "Close Issue" - = link_to edit_project_issue_path(@project, @issue), class: "btn grouped" do + = link_to edit_project_issue_path(@project, @issue), class: "btn btn-grouped" do %i.icon-edit Edit -.pull-right - .span3#votes= render 'votes/votes_block', votable: @issue +.clearfix + .votes-holder + #votes= render 'votes/votes_block', votable: @issue -.back-link - = link_to project_issues_path(@project) do - ← To issues list + .back-link + = link_to project_issues_path(@project) do + ← To issues list + %span.milestone-nav-link + - if @issue.milestone + | + %span.light Milestone + = link_to project_milestone_path(@project, @issue.milestone) do + = @issue.milestone.title - -.ui-box.ui-box-show - .ui-box-head - %h4.box-title +.issue-box{ class: issue_box_class(@issue) } + .state.clearfix + .state-label.col-sm-2.col-xs-12 - if @issue.closed? - .state-label.state-label-red Closed - = gfm escape_once(@issue.title) + Closed + - else + Open - .ui-box-body - %cite.cgray - Created by #{link_to_member(@project, @issue.author)} - - if @issue.assignee - \ and currently assigned to #{link_to_member(@project, @issue.assignee)} + %span.creator.col-sm-9.col-xs-12 + Created by #{link_to_member(@project, @issue.author)} #{time_ago_with_tooltip(@issue.created_at)} - - if @issue.milestone - - milestone = @issue.milestone - %cite.cgray and attached to milestone - %strong= link_to_gfm truncate(milestone.title, length: 20), project_milestone_path(milestone.project, milestone) - - .pull-right - - @issue.labels.each do |label| - %span{class: "label #{label_css_class(label.name)}"} - %i.icon-tag - = label.name -   + %h4.title + = gfm escape_once(@issue.title) - if @issue.description.present? - .ui-box-bottom + .description .wiki = preserve do = markdown @issue.description + .context + %cite.cgray + = render partial: 'issue_context', locals: { issue: @issue } + - content_for :note_actions do - if can?(current_user, :modify_issue, @issue) - if @issue.closed? - = link_to 'Reopen Issue', project_issue_path(@project, @issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn grouped reopen_issue" + = link_to 'Reopen Issue', project_issue_path(@project, @issue, issue: {state_event: :reopen }, status_only: true), method: :put, class: "btn btn-grouped btn-reopen" - else - = link_to 'Close Issue', project_issue_path(@project, @issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn grouped close_issue", title: "Close Issue" + = link_to 'Close Issue', project_issue_path(@project, @issue, issue: {state_event: :close }, status_only: true), method: :put, class: "btn btn-grouped btn-close", title: "Close Issue" .participants %cite.cgray #{@issue.participants.count} participants - @issue.participants.each do |participant| = link_to_member(@project, participant, name: false, size: 24) + .issue-show-labels.pull-right + - @issue.labels.each do |label| + %span{class: "label #{label_css_class(label.name)}"} + %i.icon-tag + = label.name +   + .voting_notes#notes= render "projects/notes/notes_with_form" diff --git a/app/views/projects/issues/update.js.haml b/app/views/projects/issues/update.js.haml index 7f66022a2d..5199e9fc61 100644 --- a/app/views/projects/issues/update.js.haml +++ b/app/views/projects/issues/update.js.haml @@ -2,3 +2,9 @@ - if @issue.valid? :plain $("##{dom_id(@issue)}").fadeOut(); +- elsif params[:issue_context] + $('.issue-box .context').effect('highlight'); + - if @issue.milestone + $('.milestone-nav-link').replaceWith("| Milestone #{escape_javascript(link_to @issue.milestone.title, project_milestone_path(@issue.project, @issue.milestone))}") + - else + $('.milestone-nav-link').html('') diff --git a/app/views/projects/labels/index.html.haml b/app/views/projects/labels/index.html.haml index a058d09a1c..329cf9ceba 100644 --- a/app/views/projects/labels/index.html.haml +++ b/app/views/projects/labels/index.html.haml @@ -7,4 +7,4 @@ - else .light-well - %h3.nothing_here_message Add first label to your issues or #{link_to 'generate', generate_project_labels_path(@project), method: :post} default set of labels + .nothing-here-block Add first label to your issues or #{link_to 'generate', generate_project_labels_path(@project), method: :post} default set of labels diff --git a/app/views/projects/merge_requests/_form.html.haml b/app/views/projects/merge_requests/_form.html.haml index ce72756303..290a15e266 100644 --- a/app/views/projects/merge_requests/_form.html.haml +++ b/app/views/projects/merge_requests/_form.html.haml @@ -1,59 +1,56 @@ -= form_for [@project, @merge_request], html: { class: "#{controller.action_name}-merge-request form-horizontal" } do |f| - -if @merge_request.errors.any? - .alert.alert-error - %ul - - @merge_request.errors.full_messages.each do |msg| - %li= msg += form_for [@project, @merge_request], html: { class: "merge-request-form form-horizontal" } do |f| + .row + .col-sm-2 + .col-sm-10 + - if @repository.contribution_guide && !@merge_request.persisted? + - contribution_guide_url = project_blob_path(@project, tree_join(@repository.root_ref, @repository.contribution_guide.name)) + .alert.alert-info + Please review the + %strong #{link_to "guidelines for contribution", contribution_guide_url} + to this repository. - .merge-request-branches - .row - .span5 - .clearfix - .pull-left - = f.select(:source_project_id,[[@merge_request.source_project.path_with_namespace,@merge_request.source_project.id]] , {}, {class: 'source_project chosen span3'}) - .pull-left -   - %i.icon-code-fork - = f.select(:source_branch, @merge_request.source_project.repository.branch_names, { include_blank: "Select branch" }, {class: 'source_branch chosen span2'}) - .mr_source_commit.prepend-top-10 - .span2 - %h2.merge-request-angle.light - %i.icon-long-arrow-right - .span5 - .clearfix - .pull-left - - projects = @project.forked_from_project.nil? ? [@project] : [ @project,@project.forked_from_project] - = f.select(:target_project_id, projects.map { |proj| [proj.path_with_namespace,proj.id] }, {include_blank: "Select Target Project" }, {class: 'target_project chosen span3'}) - .pull-left -   - %i.icon-code-fork - = f.select(:target_branch, @target_branches, { include_blank: "Select branch" }, {class: 'target_branch chosen span2'}) - .mr_target_commit.prepend-top-10 + -if @merge_request.errors.any? + .alert.alert-danger + - @merge_request.errors.full_messages.each do |msg| + %div= msg - %hr .merge-request-form-info - .control-group - = f.label :title do + .form-group + = f.label :title, class: 'control-label' do %strong= "Title *" - .controls= f.text_field :title, class: "input-xxlarge pad js-gfm-input", maxlength: 255, rows: 5, required: true - .control-group - .left - = f.label :assignee_id do + .col-sm-10= f.text_field :title, class: "form-control pad js-gfm-input", maxlength: 255, rows: 5, required: true + .form-group + = f.label :description, "Description", class: 'control-label' + .col-sm-10 + = f.text_area :description, class: "form-control js-gfm-input", rows: 14 + %p.hint Description is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. + %hr + .form-group + .issue-assignee + = f.label :assignee_id, class: 'control-label' do %i.icon-user Assign to - .controls= f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'}) - .left - = f.label :milestone_id do + .col-sm-10 + = project_users_select_tag('merge_request[assignee_id]', placeholder: 'Select a user', class: 'custom-form-control', selected: @merge_request.assignee_id) +   + = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' + .form-group + .issue-milestone + = f.label :milestone_id, class: 'control-label' do %i.icon-time Milestone - .controls= f.select(:milestone_id, @project.milestones.active.all.map {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) - .control-group - = f.label :description, "Description" - .controls - = f.text_area :description, class: "input-xxlarge js-gfm-input", rows: 14 - %p.hint Description is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. + .col-sm-10= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2'}) + - if @merge_request.persisted? # Only allow labels on edit to avoid fork vs upstream repo labels issue + .form-group + = f.label :label_list, class: 'control-label' do + %i.icon-tag + Labels + .col-sm-10 + = f.text_field :label_list, maxlength: 2000, class: "form-control" + %p.hint Separate labels with commas. + .form-actions - if @merge_request.new_record? = f.submit 'Submit merge request', class: "btn btn-create" @@ -68,20 +65,36 @@ :javascript disableButtonIfEmptyField("#merge_request_title", ".btn-save"); - - var source_branch = $("#merge_request_source_branch") - , target_branch = $("#merge_request_target_branch") - , target_project = $("#merge_request_target_project_id"); - - $.get("#{branch_from_project_merge_requests_path(@source_project)}", {ref: source_branch.val() }); - $.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: target_branch.val() }); - - target_project.on("change", function() { - $.get("#{update_branches_project_merge_requests_path(@source_project)}", {target_project_id: $(this).val() }); - }); - source_branch.on("change", function() { - $.get("#{branch_from_project_merge_requests_path(@source_project)}", {ref: $(this).val() }); - }); - target_branch.on("change", function() { - $.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: $(this).val() }); + $('.assign-to-me-link').on('click', function(e){ + $('#merge_request_assignee_id').val("#{current_user.id}").trigger("change"); + e.preventDefault(); }); + + $("#merge_request_label_list") + .bind( "keydown", function( event ) { + if ( event.keyCode === $.ui.keyCode.TAB && + $( this ).data( "autocomplete" ).menu.active ) { + event.preventDefault(); + } + }) + .bind("click", function(event) { + $(this).autocomplete("search", ""); + }) + .autocomplete({ + minLength: 0, + source: function( request, response ) { + response( $.ui.autocomplete.filter( + #{raw labels_autocomplete_source}, extractLast( request.term ) ) ); + }, + focus: function() { + return false; + }, + select: function(event, ui) { + var terms = split( this.value ); + terms.pop(); + terms.push( ui.item.value ); + terms.push( "" ); + this.value = terms.join( ", " ); + return false; + } + }); diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml index 933d78bcbf..c9a80ec22e 100644 --- a/app/views/projects/merge_requests/_merge_request.html.haml +++ b/app/views/projects/merge_requests/_merge_request.html.haml @@ -10,14 +10,10 @@ %span.pull-right - if merge_request.for_fork? %span.light - = "#{merge_request.source_project.path_with_namespace}" - = "#{merge_request.source_branch}" - %i.icon-angle-right.light - = "#{merge_request.target_branch}" - - else - = "#{merge_request.source_branch}" - %i.icon-angle-right.light - = "#{merge_request.target_branch}" + #{merge_request.source_project_namespace}: + = truncate merge_request.source_branch, length: 25 + %i.icon-angle-right.light + = merge_request.target_branch .merge-request-info - if merge_request.author authored by #{link_to_member(merge_request.source_project, merge_request.author)} @@ -34,4 +30,10 @@ .pull-right - %small updated #{time_ago_in_words(merge_request.updated_at)} ago + %small updated #{time_ago_with_tooltip(merge_request.updated_at, 'bottom', 'merge_request_updated_ago')} + + .merge-request-labels + - merge_request.labels.each do |label| + %span{class: "label #{label_css_class(label.name)}"} + %i.icon-tag + = label.name diff --git a/app/views/projects/merge_requests/_new_compare.html.haml b/app/views/projects/merge_requests/_new_compare.html.haml new file mode 100644 index 0000000000..a8b774a3cd --- /dev/null +++ b/app/views/projects/merge_requests/_new_compare.html.haml @@ -0,0 +1,84 @@ +%h3.page-title Compare branches for new Merge Request +%hr + += form_for [@project, @merge_request], url: new_project_merge_request_path(@project), method: :get, html: { class: "merge-request-form form-inline" } do |f| + .hide.alert.alert-danger.mr-compare-errors + .merge-request-branches.row + .col-md-6 + .panel.panel-default + .panel-heading + %strong Source branch + .panel-body + = f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project select2 span3', disabled: @merge_request.persisted? }) +   + = f.select(:source_branch, @merge_request.source_branches, { include_blank: "Select branch" }, {class: 'source_branch select2 span2'}) + .panel-footer + .mr_source_commit + + .col-md-6 + .panel.panel-default + .panel-heading + %strong Target branch + .panel-body + - projects = @project.forked_from_project.nil? ? [@project] : [@project, @project.forked_from_project] + = f.select(:target_project_id, options_from_collection_for_select(projects, 'id', 'path_with_namespace', f.object.target_project_id), {}, { class: 'target_project select2 span3', disabled: @merge_request.persisted? }) +   + = f.select(:target_branch, @merge_request.target_branches, { include_blank: "Select branch" }, {class: 'target_branch select2 span2'}) + .panel-footer + .mr_target_commit + + -if @merge_request.errors.any? + .alert.alert-danger + - @merge_request.errors.full_messages.each do |msg| + %div= msg + + - if @merge_request.source_branch.present? && @merge_request.target_branch.present? + .light-well + %center + %h4 + There isn't anything to merge. + %p.slead + - if @merge_request.source_branch == @merge_request.target_branch + You'll need to use different branch names to get a valid comparison. + - else + %span.label-branch #{@merge_request.source_branch} + and + %span.label-branch #{@merge_request.target_branch} + are the same. + + + %hr + = f.submit 'Compare branches', class: "btn btn-primary mr-compare-btn" + +:javascript + var source_branch = $("#merge_request_source_branch") + , target_branch = $("#merge_request_target_branch") + , target_project = $("#merge_request_target_project_id"); + + $.get("#{branch_from_project_merge_requests_path(@source_project)}", {ref: source_branch.val() }); + $.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: target_branch.val() }); + + target_project.on("change", function() { + $.get("#{update_branches_project_merge_requests_path(@source_project)}", {target_project_id: $(this).val() }); + }); + source_branch.on("change", function() { + $.get("#{branch_from_project_merge_requests_path(@source_project)}", {ref: $(this).val() }); + $(".mr-compare-errors").fadeOut(); + $(".mr-compare-btn").enable(); + }); + target_branch.on("change", function() { + $.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: $(this).val() }); + $(".mr-compare-errors").fadeOut(); + $(".mr-compare-btn").enable(); + }); + + +:coffeescript + + $(".merge-request-form").on 'submit', -> + if $("#merge_request_source_branch").val() is "" or $('#merge_request_target_branch').val() is "" + $(".mr-compare-errors").html("You must select source and target branch to proceed") + $(".mr-compare-errors").fadeIn() + event.preventDefault() + return + diff --git a/app/views/projects/merge_requests/_new_submit.html.haml b/app/views/projects/merge_requests/_new_submit.html.haml new file mode 100644 index 0000000000..b5479be708 --- /dev/null +++ b/app/views/projects/merge_requests/_new_submit.html.haml @@ -0,0 +1,82 @@ +%h3.page-title + New merge request +%p.slead + From + %strong.monospace + #{@merge_request.source_project_namespace}:#{@merge_request.source_branch} + into + %strong.monospace + #{@merge_request.target_project_namespace}:#{@merge_request.target_branch} + + %span.pull-right + = link_to 'Change branches', new_project_merge_request_path(@project) + += form_for [@project, @merge_request], html: { class: "merge-request-form" } do |f| + .panel.panel-default + + .panel-body + .form-group + .light + = f.label :title do + = "Title *" + = f.text_field :title, class: "form-control input-lg js-gfm-input", maxlength: 255, rows: 5, required: true + .form-group + .light + = f.label :description, "Description" + = f.text_area :description, class: "form-control js-gfm-input", rows: 10 + %p.hint Description is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. + .form-group + .issue-assignee + = f.label :assignee_id do + %i.icon-user + Assign to + %div + = project_users_select_tag('merge_request[assignee_id]', placeholder: 'Select a user', class: 'custom-form-control', selected: @merge_request.assignee_id, project_id: @merge_request.target_project_id) +   + = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' + .form-group + .issue-milestone + = f.label :milestone_id do + %i.icon-time + Milestone + %div= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2'}) + .panel-footer + - if @target_repo.contribution_guide + - contribution_guide_url = project_blob_path(@target_project, tree_join(@target_repo.root_ref, @target_repo.contribution_guide.name)) + %p + Please review the + %strong #{link_to "guidelines for contribution", contribution_guide_url} + to this repository. + = f.hidden_field :source_project_id + = f.hidden_field :target_project_id + = f.hidden_field :target_branch + = f.hidden_field :source_branch + = f.submit 'Submit merge request', class: "btn btn-create" + +.mr-compare + %div.ui-box + .title + Commits (#{@commits.count}) + - if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE + %ul.well-list + - Commit.decorate(@commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE)).each do |commit| + = render "projects/commits/inline_commit", commit: commit, project: @project + %li.warning-row.unstyled + other #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} commits hidden to prevent performance issues. + - else + %ul.well-list= render Commit.decorate(@commits), project: @project + + %h4 Changes + - if @diffs.present? + = render "projects/commits/diffs", diffs: @diffs, project: @project + - elsif @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE + .bs-callout.bs-callout-danger + %h4 This comparison includes more than #{MergeRequestDiff::COMMITS_SAFE_SIZE} commits. + %p To preserve performance the line changes are not shown. + + +:javascript + $('.assign-to-me-link').on('click', function(e){ + $('#merge_request_assignee_id').val("#{current_user.id}").trigger("change"); + e.preventDefault(); + }); diff --git a/app/views/projects/merge_requests/_show.html.haml b/app/views/projects/merge_requests/_show.html.haml index 47c14abded..193c600f77 100644 --- a/app/views/projects/merge_requests/_show.html.haml +++ b/app/views/projects/merge_requests/_show.html.haml @@ -2,10 +2,9 @@ = render "projects/merge_requests/show/mr_title" = render "projects/merge_requests/show/how_to_merge" = render "projects/merge_requests/show/mr_box" - = render "projects/merge_requests/show/mr_accept" - - if @merge_request.source_project.gitlab_ci? - = render "projects/merge_requests/show/mr_ci" + = render "projects/merge_requests/show/state_widget" = render "projects/merge_requests/show/commits" + = render "projects/merge_requests/show/participants" - if @commits.present? %ul.nav.nav-tabs @@ -16,7 +15,14 @@ %li.diffs-tab{data: {action: 'diffs'}} = link_to diffs_project_merge_request_path(@project, @merge_request) do %i.icon-list-alt - Diff + Changes + + - content_for :note_actions do + - if can?(current_user, :modify_merge_request, @merge_request) + - unless @merge_request.closed? || @merge_request.merged? + = link_to 'Close', project_merge_request_path(@project, @merge_request, merge_request: {state_event: :close }), method: :put, class: "btn btn-grouped btn-close close-mr-link", title: "Close merge request" + - if @merge_request.closed? + = link_to 'Reopen', project_merge_request_path(@project, @merge_request, merge_request: {state_event: :reopen }), method: :put, class: "btn btn-grouped btn-reopen reopen-mr-link", title: "Close merge request" .notes.tab-content.voting_notes#notes{ class: (controller.action_name == 'show') ? "" : "hide" } = render "projects/notes/notes_with_form" diff --git a/app/views/projects/merge_requests/branch_from.js.haml b/app/views/projects/merge_requests/branch_from.js.haml index ec4d7f2121..8372afa61b 100644 --- a/app/views/projects/merge_requests/branch_from.js.haml +++ b/app/views/projects/merge_requests/branch_from.js.haml @@ -1,7 +1,2 @@ :plain - $(".mr_source_commit").html("#{commit_to_html(@commit, @source_project)}"); - var mrTitle = $('#merge_request_title'); - - if(mrTitle.val().length == 0) { - mrTitle.val("#{params[:ref].titleize}"); - } + $(".mr_source_commit").html("#{commit_to_html(@commit, @source_project, false)}"); diff --git a/app/views/projects/merge_requests/branch_to.js.haml b/app/views/projects/merge_requests/branch_to.js.haml index f4e2886ee4..f7ede0ded5 100644 --- a/app/views/projects/merge_requests/branch_to.js.haml +++ b/app/views/projects/merge_requests/branch_to.js.haml @@ -1,2 +1,2 @@ :plain - $(".mr_target_commit").html("#{commit_to_html(@commit, @target_project)}"); + $(".mr_target_commit").html("#{commit_to_html(@commit, @target_project, false)}"); diff --git a/app/views/projects/merge_requests/commits.js.haml b/app/views/projects/merge_requests/commits.js.haml deleted file mode 100644 index 923b1ea032..0000000000 --- a/app/views/projects/merge_requests/commits.js.haml +++ /dev/null @@ -1,4 +0,0 @@ -:plain - merge_request.$(".commits").html("#{escape_javascript(render(partial: "commits"))}"); - - diff --git a/app/views/projects/merge_requests/diffs.js.haml b/app/views/projects/merge_requests/diffs.js.haml deleted file mode 100644 index 2964f0ec46..0000000000 --- a/app/views/projects/merge_requests/diffs.js.haml +++ /dev/null @@ -1,2 +0,0 @@ -:plain - merge_request.$(".diffs").html("#{escape_javascript(render(partial: "projects/merge_requests/show/diffs"))}"); diff --git a/app/views/projects/merge_requests/index.html.haml b/app/views/projects/merge_requests/index.html.haml index e256ee2153..12a72edb22 100644 --- a/app/views/projects/merge_requests/index.html.haml +++ b/app/views/projects/merge_requests/index.html.haml @@ -5,67 +5,68 @@ %h3.page-title Merge Requests %span (#{@merge_requests.total_count}) - - +%hr .row - .span3 - = render 'shared/project_filter', project_entities_path: project_merge_requests_path(@project) - .span9 + .col-md-3 + = render 'shared/project_filter', project_entities_path: project_merge_requests_path(@project), + labels: true, redirect: 'merge_requests' + .col-md-9 + .mr-filters.append-bottom-10 + .dropdown.inline + %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"} + %i.icon-user + %span.light assignee: + - if @assignee.present? + %strong= @assignee.name + - elsif params[:assignee_id] == "0" + Unassigned + - else + Any + %b.caret + %ul.dropdown-menu + %li + = link_to project_filter_path(assignee_id: nil) do + Any + = link_to project_filter_path(assignee_id: 0) do + Unassigned + - @assignees.sort_by(&:name).each do |user| + %li + = link_to project_filter_path(assignee_id: user.id) do + = image_tag avatar_icon(user.email), class: "avatar s16", alt: '' + = user.name + + .dropdown.inline.prepend-left-10 + %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"} + %i.icon-time + %span.light milestone: + - if @milestone.present? + %strong= @milestone.title + - elsif params[:milestone_id] == "0" + None (backlog) + - else + Any + %b.caret + %ul.dropdown-menu + %li + = link_to project_filter_path(milestone_id: nil) do + Any + = link_to project_filter_path(milestone_id: 0) do + None (backlog) + - project_active_milestones.each do |milestone| + %li + = link_to project_filter_path(milestone_id: milestone.id) do + %strong= milestone.title + %small.light= milestone.expires_at + + .pull-right + = render 'shared/sort_dropdown' + .ui-box - .title - .mr-filters - %span Filter by - .dropdown.inline.prepend-left-10 - %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"} - %i.icon-user - %span.light assignee: - - if @assignee.present? - %strong= @assignee.name - - elsif params[:assignee_id] == "0" - Unassigned - - else - Any - %b.caret - %ul.dropdown-menu - %li - = link_to project_filter_path(assignee_id: nil) do - Any - = link_to project_filter_path(assignee_id: 0) do - Unassigned - - @project.team.members.sort_by(&:name).each do |user| - %li - = link_to project_filter_path(assignee_id: user.id) do - = image_tag avatar_icon(user.email), class: "avatar s16", alt: '' - = user.name - - .dropdown.inline.prepend-left-10 - %a.dropdown-toggle.btn.btn-small{href: '#', "data-toggle" => "dropdown"} - %i.icon-time - %span.light milestone: - - if @milestone.present? - %strong= @milestone.title - - elsif params[:milestone_id] == "0" - None (backlog) - - else - Any - %b.caret - %ul.dropdown-menu - %li - = link_to project_filter_path(milestone_id: nil) do - Any - = link_to project_filter_path(milestone_id: 0) do - None (backlog) - - project_active_milestones.each do |milestone| - %li - = link_to project_filter_path(milestone_id: milestone.id) do - %strong= milestone.title - %small.light= milestone.expires_at - %ul.well-list.mr-list = render @merge_requests - if @merge_requests.blank? %li - %h4.nothing_here_message No merge requests to show + .nothing-here-block No merge requests to show - if @merge_requests.present? .pull-right %span.cgray.pull-right #{@merge_requests.total_count} merge requests for this filter diff --git a/app/views/projects/merge_requests/invalid.html.haml b/app/views/projects/merge_requests/invalid.html.haml index c962811a3e..b9c466657d 100644 --- a/app/views/projects/merge_requests/invalid.html.haml +++ b/app/views/projects/merge_requests/invalid.html.haml @@ -2,16 +2,22 @@ = render "projects/merge_requests/show/mr_title" = render "projects/merge_requests/show/mr_box" - .alert.alert-error - %h5 - %i.icon-exclamation-sign - We cannot find - %span.label-branch= @merge_request.source_branch - or - %span.label-branch= @merge_request.target_branch - branches in the repository. - %p - Maybe it was removed or never pushed. + .alert.alert-danger %p + We cannot render this merge request properly because + - if @merge_request.for_fork? && !@merge_request.source_project + fork project was removed + - elsif !@merge_request.source_branch_exists? + %span.label.label-inverse= @merge_request.source_branch + does not exist in + %span.label.label-info= @merge_request.source_project_path + - elsif !@merge_request.target_branch_exists? + %span.label.label-inverse= @merge_request.target_branch + does not exist in + %span.label.label-info= @merge_request.target_project_path + - else + of internal error + + %strong Please close Merge Request or change branches with existing one diff --git a/app/views/projects/merge_requests/new.html.haml b/app/views/projects/merge_requests/new.html.haml index 8ee0e1a8d4..c24e591672 100644 --- a/app/views/projects/merge_requests/new.html.haml +++ b/app/views/projects/merge_requests/new.html.haml @@ -1,3 +1,4 @@ -%h3.page-title New Merge Request -%hr -= render 'form' +- if @commits.present? + = render 'new_submit' +- else + = render 'new_compare' diff --git a/app/views/projects/merge_requests/show.js.haml b/app/views/projects/merge_requests/show.js.haml deleted file mode 100644 index 2ce6eb6329..0000000000 --- a/app/views/projects/merge_requests/show.js.haml +++ /dev/null @@ -1,2 +0,0 @@ -:plain - merge_request.$(".notes").html("#{escape_javascript(render "notes/notes_with_form")}"); diff --git a/app/views/projects/merge_requests/show/_commits.html.haml b/app/views/projects/merge_requests/show/_commits.html.haml index 7b0e67053a..f69146e1a3 100644 --- a/app/views/projects/merge_requests/show/_commits.html.haml +++ b/app/views/projects/merge_requests/show/_commits.html.haml @@ -12,19 +12,19 @@ 8 of #{@commits.count} commits displayed. %strong %a.show-all-commits Click here to show all - %ul.all-commits.hide.well-list - - @commits.each do |commit| - = render "projects/commits/commit", commit: commit, project: @merge_request.source_project + - if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE + %ul.all-commits.hide.well-list + - @commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE).each do |commit| + = render "projects/commits/inline_commit", commit: commit, project: @merge_request.source_project + %li + other #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} commits hidden top prevent performance issues. + - else + %ul.all-commits.hide.well-list + - @commits.each do |commit| + = render "projects/commits/inline_commit", commit: commit, project: @merge_request.source_project - else %ul.well-list - @commits.each do |commit| = render "projects/commits/commit", commit: commit, project: @merge_request.source_project -- else - %h4.nothing_here_message - Nothing to merge from - %span.label-branch #{@merge_request.source_branch} - to - %span.label-branch #{@merge_request.target_branch} - %br diff --git a/app/views/projects/merge_requests/show/_context.html.haml b/app/views/projects/merge_requests/show/_context.html.haml new file mode 100644 index 0000000000..5c6734fd24 --- /dev/null +++ b/app/views/projects/merge_requests/show/_context.html.haml @@ -0,0 +1,24 @@ += form_for [@project, @merge_request], remote: true, html: {class: 'edit-merge_request inline-update'} do |f| + .row + .col-md-6 + %strong.append-right-10 + Assignee: + + - if can?(current_user, :modify_merge_request, @merge_request) + = project_users_select_tag('merge_request[assignee_id]', placeholder: 'Select assignee', class: 'custom-form-control', selected: @merge_request.assignee_id) + - elsif merge_request.assignee + = link_to_member(@project, @merge_request.assignee) + - else + None + + .col-md-6.text-right + %strong.append-right-10 + Milestone: + - if can?(current_user, :modify_merge_request, @merge_request) + = f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2 select2-compact'}) + = hidden_field_tag :merge_request_context + = f.submit class: 'btn' + - elsif merge_request.milestone + = link_to merge_request.milestone.title, project_milestone_path + - else + None diff --git a/app/views/projects/merge_requests/show/_diffs.html.haml b/app/views/projects/merge_requests/show/_diffs.html.haml index 25f6380485..eb63b68106 100644 --- a/app/views/projects/merge_requests/show/_diffs.html.haml +++ b/app/views/projects/merge_requests/show/_diffs.html.haml @@ -1,10 +1,12 @@ -- if @merge_request.valid_diffs? +- if @merge_request_diff.collected? = render "projects/commits/diffs", diffs: @merge_request.diffs, project: @merge_request.source_project -- elsif @merge_request.broken_diffs? - %h4.nothing_here_message - Can't load diff. - You can - = link_to "download it", project_merge_request_path(@merge_request.source_project, @merge_request), format: :diff, class: "vlink" - instead. +- elsif @merge_request_diff.empty? + .nothing-here-block Nothing to merge from #{@merge_request.source_branch} into #{@merge_request.target_branch} - else - %h4.nothing_here_message Nothing to merge + .bs-callout.bs-callout-warning + %h4 + Changes view for this comparison is extremely large. + %p + You can + = link_to "download it", project_merge_request_path(@merge_request.target_project, @merge_request, format: :diff), class: "vlink" + instead. diff --git a/app/views/projects/merge_requests/show/_how_to_merge.html.haml b/app/views/projects/merge_requests/show/_how_to_merge.html.haml index 030ac285f2..9540453ce3 100644 --- a/app/views/projects/merge_requests/show/_how_to_merge.html.haml +++ b/app/views/projects/merge_requests/show/_how_to_merge.html.haml @@ -1,42 +1,44 @@ %div#modal_merge_info.modal.hide - .modal-header - %a.close{href: "#", "data-dismiss" => "modal"} × - %h3 How to merge - .modal-body - - if @merge_request.for_fork? - - source_remote = @merge_request.source_project.namespace.nil? ? "source" :@merge_request.source_project.namespace.path - - target_remote = @merge_request.target_project.namespace.nil? ? "target" :@merge_request.target_project.namespace.path - %p - %strong Step 1. - Checkout target branch and get recent objects from GitLab - Assuming remote for #{@merge_request.target_project.path_with_namespace} is called #{target_remote} - remote for #{@merge_request.source_project.path_with_namespace} is called #{source_remote} - %pre.dark - :preserve - git checkout #{target_remote} #{@merge_request.target_branch} - git fetch #{source_remote} - %p - %strong Step 2. - Merge source branch into target branch and push changes to GitLab - %pre.dark - :preserve - git merge #{source_remote}/#{@merge_request.source_branch} - git push #{target_remote} #{@merge_request.target_branch} - - else - %p - %strong Step 1. - Checkout target branch and get recent objects from GitLab - %pre.dark - :preserve - git checkout #{@merge_request.target_branch} - git fetch origin - %p - %strong Step 2. - Merge source branch into target branch and push changes to GitLab - %pre.dark - :preserve - git merge origin/#{@merge_request.source_branch} - git push origin #{@merge_request.target_branch} + .modal-dialog + .modal-content + .modal-header + %a.close{href: "#", "data-dismiss" => "modal"} × + %h3 How to merge + .modal-body + - if @merge_request.for_fork? + - source_remote = @merge_request.source_project.namespace.nil? ? "source" :@merge_request.source_project.namespace.path + - target_remote = @merge_request.target_project.namespace.nil? ? "target" :@merge_request.target_project.namespace.path + %p + %strong Step 1. + Checkout the branch we are going to merge and pull in the code + %pre.dark + :preserve + git checkout -b #{@merge_request.source_project_path}-#{@merge_request.source_branch} #{@merge_request.target_branch} + git pull #{@merge_request.source_project.http_url_to_repo} #{@merge_request.source_branch} + %p + %strong Step 2. + Merge the branch and push the changes to GitLab + %pre.dark + :preserve + git checkout #{@merge_request.target_branch} + git merge --no-ff #{@merge_request.source_project_path}-#{@merge_request.source_branch} + git push origin #{@merge_request.target_branch} + - else + %p + %strong Step 1. + Update the repo and checkout the branch we are going to merge + %pre.dark + :preserve + git fetch origin + git checkout -b #{@merge_request.source_branch} origin/#{@merge_request.source_branch} + %p + %strong Step 2. + Merge the branch and push the changes to GitLab + %pre.dark + :preserve + git checkout #{@merge_request.target_branch} + git merge --no-ff #{@merge_request.source_branch} + git push origin #{@merge_request.target_branch} :javascript diff --git a/app/views/projects/merge_requests/show/_mr_accept.html.haml b/app/views/projects/merge_requests/show/_mr_accept.html.haml index 299e1bc1e0..1276489c2d 100644 --- a/app/views/projects/merge_requests/show/_mr_accept.html.haml +++ b/app/views/projects/merge_requests/show/_mr_accept.html.haml @@ -1,53 +1,75 @@ - unless @allowed_to_merge - .alert - %strong You don't have permission to merge this MR + - if @project.archived? + %p + %strong Archived projects cannot be committed to! + - else + .automerge_widget.cannot_be_merged.hide + %strong This can't be merged automatically, even if it could be merged you don't have the permission to do so. + .automerge_widget.can_be_merged.hide + %strong This can be merged automatically but you don't have the permission to do so. - if @show_merge_controls - .automerge_widget.can_be_merged{style: "display:none"} - .alert.alert-success - %span - = form_for [:automerge, @project, @merge_request], remote: true, method: :get do |f| + .automerge_widget.can_be_merged.hide + .clearfix + = form_for [:automerge, @project, @merge_request], remote: true, method: :post do |f| + %h4 + You can accept this request automatically. + %div + If you still want to do it manually - + %strong + = link_to "click here", "#modal_merge_info", class: "how_to_merge_link vlink", title: "How To Merge", "data-toggle" => "modal" + for instructions. + + .js-toggle-container %p - You can accept this request automatically. - If you still want to do it manually - + If you want to modify merge commit message - %strong - = link_to "click here", "#modal_merge_info", class: "how_to_merge_link vlink", title: "How To Merge", "data-toggle" => "modal" - for instructions - .accept_group + = link_to "click here", "#", class: "modify-merge-commit-link js-toggle-button", title: "Modify merge commit message" + .js-toggle-content.hide + .form-group + = label_tag :merge_commit_message, "Commit message", class: 'control-label' + .col-sm-10 + = render 'shared/commit_message_container', {textarea: text_area_tag(:merge_commit_message, + @merge_request.merge_commit_message, class: "form-control js-gfm-input", rows: 14, required: true)} + %p.hint + The recommended maximum line length is 52 characters for the first line and 72 characters for all following lines. + + .accept-group + .pull-left = f.submit "Accept Merge Request", class: "btn btn-create accept_merge_request" - - unless @merge_request.disallow_source_branch_removal? - .remove_branch_holder - = label_tag :should_remove_source_branch, class: "checkbox" do - = check_box_tag :should_remove_source_branch - Remove source-branch - .clearfix + - unless @merge_request.disallow_source_branch_removal? + .remove_branch_holder.pull-left + = label_tag :should_remove_source_branch, class: "checkbox" do + = check_box_tag :should_remove_source_branch + Remove source-branch - .automerge_widget.no_satellite{style: "display:none"} - .alert.alert-error + .automerge_widget.no_satellite.hide + %p %span %strong This repository does not have satellite. Ask an administrator to fix this issue - .automerge_widget.cannot_be_merged{style: "display:none"} - .alert.alert-disabled - %span - = link_to "Show how to merge", "#modal_merge_info", class: "how_to_merge_link btn padded", title: "How To Merge", "data-toggle" => "modal" -   - %strong This request can't be merged with GitLab. You should do it manually + .automerge_widget.cannot_be_merged.hide + %h4 + This request can't be merged with GitLab. + %p + You should do it manually with + %strong + = link_to "command line", "#modal_merge_info", class: "how_to_merge_link", title: "How To Merge", "data-toggle" => "modal" .automerge_widget.unchecked - .alert + %p %strong - %i.icon-refresh + %i.icon-spinner.icon-spin Checking for ability to automatically merge… - .automerge_widget.already_cannot_be_merged{style: "display:none"} - .alert.alert-info - %strong This merge request already can not be merged. Try to reload page. + .automerge_widget.already_cannot_be_merged.hide + %p + %strong This merge request can not be merged. Try to reload the page. .merge-in-progress.hide - %span.cgray - %i.icon-refresh.icon-spin + %p + %i.icon-spinner.icon-spin   Merge is in progress. Please wait. Page will be automatically reloaded.   diff --git a/app/views/projects/merge_requests/show/_mr_box.html.haml b/app/views/projects/merge_requests/show/_mr_box.html.haml index e1d0c7c11e..435e916c6d 100644 --- a/app/views/projects/merge_requests/show/_mr_box.html.haml +++ b/app/views/projects/merge_requests/show/_mr_box.html.haml @@ -1,49 +1,25 @@ -.ui-box.ui-box-show - .ui-box-head - %h4.box-title - = gfm escape_once(@merge_request.title) +.issue-box{ class: issue_box_class(@merge_request) } + .state.clearfix + %span.state-label.col-sm-2.col-xs-12 - if @merge_request.merged? - .state-label.state-label-green - %i.icon-ok - Merged + Merged - elsif @merge_request.closed? - .state-label.state-label-red - Closed + Closed + - else + Open - .ui-box-body - %div - %cite.cgray - Created on #{@merge_request.created_at.stamp("Aug 21, 2011")} by #{link_to_member(@project, @merge_request.author)} - - if @merge_request.assignee - \, currently assigned to #{link_to_member(@project, @merge_request.assignee)} - - if @merge_request.milestone - - milestone = @merge_request.milestone - %cite.cgray and attached to milestone - %strong= link_to_gfm truncate(milestone.title, length: 20), project_milestone_path(milestone.project, milestone) + %span.creator.col-sm-9.col-xs-12 + Created by #{link_to_member(@project, @merge_request.author)} #{time_ago_with_tooltip(@merge_request.created_at)} + %h4.title + = gfm escape_once(@merge_request.title) - if @merge_request.description.present? - .ui-box-bottom + .description .wiki = preserve do = markdown @merge_request.description - - if @merge_request.closed? - .ui-box-bottom.alert-error - %span - %i.icon-remove - Closed by #{link_to_member(@project, @merge_request.closed_event.author)} - %span #{time_ago_in_words(@merge_request.closed_event.created_at)} ago. - - if @merge_request.merged? - .ui-box-bottom.alert-success - %span - %i.icon-ok - Merged by #{link_to_member(@project, @merge_request.merge_event.author)} - #{time_ago_in_words(@merge_request.merge_event.created_at)} ago. - - if !@closes_issues.empty? && @merge_request.opened? - .ui-box-bottom.alert-info - %span - %i.icon-ok - Accepting this merge request will close #{@closes_issues.size == 1 ? 'issue' : 'issues'} - = succeed '.' do - != gfm(@closes_issues.map { |i| "##{i.iid}" }.to_sentence) + .context + %cite.cgray + = render partial: 'projects/merge_requests/show/context', locals: { merge_request: @merge_request } diff --git a/app/views/projects/merge_requests/show/_mr_ci.html.haml b/app/views/projects/merge_requests/show/_mr_ci.html.haml index 9b15c4526e..507a9e507f 100644 --- a/app/views/projects/merge_requests/show/_mr_ci.html.haml +++ b/app/views/projects/merge_requests/show/_mr_ci.html.haml @@ -1,35 +1,29 @@ - if @commits.any? .ci_widget.ci-success{style: "display:none"} - .alert.alert-success - %i.icon-ok - %strong CI build passed - for #{@merge_request.last_commit_short_sha}. - = link_to "Build page", ci_build_details_path(@merge_request) + %i.icon-ok + %strong CI build passed + for #{@merge_request.last_commit_short_sha}. + = link_to "Build page", ci_build_details_path(@merge_request) .ci_widget.ci-failed{style: "display:none"} - .alert.alert-error - %i.icon-remove - %strong CI build failed - for #{@merge_request.last_commit_short_sha}. - = link_to "Build page", ci_build_details_path(@merge_request) + %i.icon-remove + %strong CI build failed + for #{@merge_request.last_commit_short_sha}. + = link_to "Build page", ci_build_details_path(@merge_request) - [:running, :pending].each do |status| .ci_widget{class: "ci-#{status}", style: "display:none"} - .alert - %i.icon-time - %strong CI build #{status} - for #{@merge_request.last_commit_short_sha}. - = link_to "Build page", ci_build_details_path(@merge_request) + %i.icon-time + %strong CI build #{status} + for #{@merge_request.last_commit_short_sha}. + = link_to "Build page", ci_build_details_path(@merge_request) .ci_widget - .alert - %strong - %i.icon-refresh - Checking for CI status for #{@merge_request.last_commit_short_sha} + %strong + %i.icon-spinner + Checking for CI status for #{@merge_request.last_commit_short_sha} .ci_widget.ci-error{style: "display:none"} - .alert.alert-error - %i.icon-remove - %strong Cannot connect to CI server. Please check your setting - + %i.icon-remove + %strong Cannot connect to the CI server. Please check your settings and try again. diff --git a/app/views/projects/merge_requests/show/_mr_title.html.haml b/app/views/projects/merge_requests/show/_mr_title.html.haml index 096a916764..2c905413bc 100644 --- a/app/views/projects/merge_requests/show/_mr_title.html.haml +++ b/app/views/projects/merge_requests/show/_mr_title.html.haml @@ -1,22 +1,11 @@ %h3.page-title - = "Merge Request ##{@merge_request.iid}:" -   - -if @merge_request.for_fork? - %span.label-branch - %span.label-project= truncate(@merge_request.source_project.path_with_namespace, length: 25) - #{@merge_request.source_branch} - → - %span.label-branch= @merge_request.target_branch - - else - %span.label-branch= @merge_request.source_branch - → - %span.label-branch= @merge_request.target_branch + = "Merge Request ##{@merge_request.iid}" - %span.pull-right + %span.pull-right.issue-btn-group - if can?(current_user, :modify_merge_request, @merge_request) - - if @merge_request.opened? - .left.btn-group - %a.btn.grouped.dropdown-toggle{ data: {toggle: :dropdown} } + - if @merge_request.open? + .btn-group.pull-left + %a.btn.btn-grouped.dropdown-toggle{ data: {toggle: :dropdown} } %i.icon-download-alt Download as %span.caret @@ -24,15 +13,30 @@ %li= link_to "Email Patches", project_merge_request_path(@project, @merge_request, format: :patch) %li= link_to "Plain Diff", project_merge_request_path(@project, @merge_request, format: :diff) - = link_to 'Close', project_merge_request_path(@project, @merge_request, merge_request: {state_event: :close }), method: :put, class: "btn grouped btn-close", title: "Close merge request" + = link_to 'Close', project_merge_request_path(@project, @merge_request, merge_request: { state_event: :close }), method: :put, class: "btn btn-grouped btn-close", title: "Close merge request" - = link_to edit_project_merge_request_path(@project, @merge_request), class: "btn grouped", id:"edit_merge_request" do + = link_to edit_project_merge_request_path(@project, @merge_request), class: "btn btn-grouped", id:"edit_merge_request" do %i.icon-edit Edit + - if @merge_request.closed? + = link_to 'Reopen', project_merge_request_path(@project, @merge_request, merge_request: {state_event: :reopen }), method: :put, class: "btn btn-grouped btn-reopen reopen-mr-link", title: "Close merge request" -.pull-right - .span3#votes= render 'votes/votes_block', votable: @merge_request +.votes-holder.hidden-sm.hidden-xs + #votes= render 'votes/votes_block', votable: @merge_request .back-link = link_to project_merge_requests_path(@project) do ← To merge requests + + %span.prepend-left-20.monospace + -if @merge_request.for_fork? + %span + %strong + #{truncate(@merge_request.source_project_path, length: 25)}: + #{@merge_request.source_branch} + → + %span= @merge_request.target_branch + - else + %span= @merge_request.source_branch + → + %span= @merge_request.target_branch diff --git a/app/views/projects/merge_requests/show/_no_accept.html.haml b/app/views/projects/merge_requests/show/_no_accept.html.haml new file mode 100644 index 0000000000..423fcd48e2 --- /dev/null +++ b/app/views/projects/merge_requests/show/_no_accept.html.haml @@ -0,0 +1,14 @@ +%h4 + Can't be merged +%p + This merge request can not be accepted because branch + - unless @merge_request.source_branch_exists? + %span.label.label-inverse= @merge_request.source_branch + does not exist in + %span.label.label-info= @merge_request.source_project_path + - else + %span.label.label-inverse= @merge_request.target_branch + does not exist in + %span.label.label-info= @merge_request.target_project_path + %br + %strong Please close this merge request or change branches with existing one diff --git a/app/views/projects/merge_requests/show/_participants.html.haml b/app/views/projects/merge_requests/show/_participants.html.haml new file mode 100644 index 0000000000..0dabd965e5 --- /dev/null +++ b/app/views/projects/merge_requests/show/_participants.html.haml @@ -0,0 +1,11 @@ +.participants + %cite.cgray #{@merge_request.participants.count} participants + - @merge_request.participants.each do |participant| + = link_to_member(@project, participant, name: false, size: 24) + + .merge-request-show-labels.pull-right + - @merge_request.labels.each do |label| + %span{class: "label #{label_css_class(label.name)}"} + %i.icon-tag + = label.name +   diff --git a/app/views/projects/merge_requests/show/_remove_source_branch.html.haml b/app/views/projects/merge_requests/show/_remove_source_branch.html.haml new file mode 100644 index 0000000000..f8f8b71f21 --- /dev/null +++ b/app/views/projects/merge_requests/show/_remove_source_branch.html.haml @@ -0,0 +1,17 @@ +- if @source_branch.blank? + Source branch has been removed + +- elsif @allowed_to_remove_source_branch && @merge_request.merged? + .remove_source_branch_widget + %p Changes merged into #{@merge_request.target_branch}. You can remove source branch now + = link_to project_branch_path(@merge_request.source_project, @source_branch), remote: true, method: :delete, class: "btn btn-primary btn-small remove_source_branch" do + %i.icon-remove + Remove Source Branch + + .remove_source_branch_widget.failed.hide + Failed to remove source branch '#{@merge_request.source_branch}' + + .remove_source_branch_in_progress.hide + %i.icon-refresh.icon-spin +   + Removing source branch '#{@merge_request.source_branch}'. Please wait. Page will be automatically reloaded.   diff --git a/app/views/projects/merge_requests/show/_state_widget.html.haml b/app/views/projects/merge_requests/show/_state_widget.html.haml new file mode 100644 index 0000000000..80fe540489 --- /dev/null +++ b/app/views/projects/merge_requests/show/_state_widget.html.haml @@ -0,0 +1,41 @@ +.panel.mr-state-widget.panel-default + - if @merge_request.source_project.gitlab_ci? && @commits.any? + .panel-heading + = render "projects/merge_requests/show/mr_ci" + .panel-body + - if @merge_request.open? + - if @merge_request.source_branch_exists? && @merge_request.target_branch_exists? + = render "projects/merge_requests/show/mr_accept" + - else + = render "projects/merge_requests/show/no_accept" + + - if @merge_request.closed? + %h4 + Closed by #{link_to_member(@project, @merge_request.closed_event.author, avatar: false)} + #{time_ago_with_tooltip(@merge_request.closed_event.created_at)} + %p Changes was not merged into target branch + + - if @merge_request.merged? + %h4 + Merged by #{link_to_member(@project, @merge_request.merge_event.author, avatar: false)} + #{time_ago_with_tooltip(@merge_request.merge_event.created_at)} + = render "projects/merge_requests/show/remove_source_branch" + + - unless @commits.any? + %h4 Nothing to merge + %p + Nothing to merge from + %span.label-branch #{@merge_request.source_branch} + to + %span.label-branch #{@merge_request.target_branch} + %br + Try to use different branches or push new code. + + - if !@closes_issues.empty? && @merge_request.open? + .panel-footer + %span + %i.icon-ok + Accepting this merge request will close #{@closes_issues.size == 1 ? 'issue' : 'issues'} + = succeed '.' do + != gfm(@closes_issues.map { |i| "##{i.iid}" }.to_sentence) + diff --git a/app/views/projects/merge_requests/update.js.haml b/app/views/projects/merge_requests/update.js.haml new file mode 100644 index 0000000000..6452cc6382 --- /dev/null +++ b/app/views/projects/merge_requests/update.js.haml @@ -0,0 +1,2 @@ +- if params[:merge_request_context] + $('.issue-box .context').effect('highlight'); diff --git a/app/views/projects/merge_requests/update_branches.js.haml b/app/views/projects/merge_requests/update_branches.js.haml index dfccb586ec..ca21b3bc0d 100644 --- a/app/views/projects/merge_requests/update_branches.js.haml +++ b/app/views/projects/merge_requests/update_branches.js.haml @@ -1,5 +1,9 @@ :plain $(".target_branch").html("#{escape_javascript(options_for_select(@target_branches))}"); - $(".target_branch").trigger("chosen:updated"); + + $('select.target_branch').select2({ + width: 'resolve', + dropdownAutoWidth: true + }); + $(".mr_target_commit").html(""); - $(".target_branch").trigger("change"); diff --git a/app/views/projects/milestones/_form.html.haml b/app/views/projects/milestones/_form.html.haml index b2fd1a9284..d770bb5b37 100644 --- a/app/views/projects/milestones/_form.html.haml +++ b/app/views/projects/milestones/_form.html.haml @@ -7,27 +7,27 @@ = form_for [@project, @milestone], html: {class: "new_milestone form-horizontal"} do |f| -if @milestone.errors.any? - .alert.alert-error + .alert.alert-danger %ul - @milestone.errors.full_messages.each do |msg| %li= msg .row - .span6 - .control-group + .col-md-6 + .form-group = f.label :title, "Title", class: "control-label" - .controls - = f.text_field :title, maxlength: 255, class: "input-xlarge" + .col-sm-10 + = f.text_field :title, maxlength: 255, class: "form-control" %p.hint Required - .control-group + .form-group = f.label :description, "Description", class: "control-label" - .controls - = f.text_area :description, maxlength: 2000, class: "input-xlarge", rows: 10 + .col-sm-10 + = f.text_area :description, maxlength: 2000, class: "form-control", rows: 10 %p.hint Milestones are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. - .span6 - .control-group + .col-md-6 + .form-group = f.label :due_date, "Due Date", class: "control-label" - .controls= f.hidden_field :due_date - .controls + .col-sm-10= f.hidden_field :due_date + .col-sm-10 .datepicker .form-actions diff --git a/app/views/projects/milestones/_issues.html.haml b/app/views/projects/milestones/_issues.html.haml index 21939ad013..c277dcc536 100644 --- a/app/views/projects/milestones/_issues.html.haml +++ b/app/views/projects/milestones/_issues.html.haml @@ -4,7 +4,7 @@ - issues.each do |issue| %li = link_to [@project, issue] do - %span.badge{class: issue.closed? ? 'badge-important' : 'badge-info'} ##{issue.iid} + %span.label{class: issue.closed? ? 'label-danger' : 'label-info'} ##{issue.iid} = link_to_gfm truncate(issue.title, length: 40), [@project, issue] - if issue.assignee .pull-right diff --git a/app/views/projects/milestones/_merge_request.html.haml b/app/views/projects/milestones/_merge_request.html.haml index 8e30a42a60..faa35a25f2 100644 --- a/app/views/projects/milestones/_merge_request.html.haml +++ b/app/views/projects/milestones/_merge_request.html.haml @@ -1,5 +1,5 @@ %li = link_to [@project, merge_request] do - %span.badge.badge-info ##{merge_request.iid} + %span.label.label-info ##{merge_request.iid} – = link_to_gfm truncate(merge_request.title, length: 60), [@project, merge_request] diff --git a/app/views/projects/milestones/_milestone.html.haml b/app/views/projects/milestones/_milestone.html.haml index bc3368b765..5579659d60 100644 --- a/app/views/projects/milestones/_milestone.html.haml +++ b/app/views/projects/milestones/_milestone.html.haml @@ -1,7 +1,7 @@ %li{class: "milestone milestone-#{milestone.closed? ? 'closed' : 'open'}", id: dom_id(milestone) } .pull-right - if can?(current_user, :admin_milestone, milestone.project) and milestone.active? - = link_to edit_project_milestone_path(milestone.project, milestone), class: "btn btn-small edit-milestone-link grouped" do + = link_to edit_project_milestone_path(milestone.project, milestone), class: "btn btn-small edit-milestone-link btn-grouped" do %i.icon-edit Edit = link_to 'Close Milestone', project_milestone_path(@project, milestone, milestone: {state_event: :close }), method: :put, remote: true, class: "btn btn-small btn-remove" @@ -24,4 +24,4 @@   %span.light #{milestone.percent_complete}% complete .progress.progress-info - .bar{style: "width: #{milestone.percent_complete}%;"} + .progress-bar{style: "width: #{milestone.percent_complete}%;"} diff --git a/app/views/projects/milestones/index.html.haml b/app/views/projects/milestones/index.html.haml index ddb46bcb5c..3537650ad4 100644 --- a/app/views/projects/milestones/index.html.haml +++ b/app/views/projects/milestones/index.html.haml @@ -8,7 +8,7 @@ New Milestone .row - .span3 + .col-md-3.hidden-sm %ul.nav.nav-pills.nav-stacked %li{class: ("active" if (params[:f] == "active" || !params[:f]))} = link_to project_milestones_path(@project, f: "active") do @@ -19,13 +19,13 @@ %li{class: ("active" if params[:f] == "all")} = link_to project_milestones_path(@project, f: "all") do All - .span9 + .col-md-9 .ui-box %ul.well-list = render @milestones - if @milestones.blank? %li - %h3.nothing_here_message No milestones to show + .nothing-here-block No milestones to show = paginate @milestones, theme: "gitlab" diff --git a/app/views/projects/milestones/show.html.haml b/app/views/projects/milestones/show.html.haml index a5bd7a2901..5c5df46d33 100644 --- a/app/views/projects/milestones/show.html.haml +++ b/app/views/projects/milestones/show.html.haml @@ -5,13 +5,13 @@ = @milestone.expires_at .pull-right - if can?(current_user, :admin_milestone, @project) - = link_to edit_project_milestone_path(@project, @milestone), class: "btn grouped" do + = link_to edit_project_milestone_path(@project, @milestone), class: "btn btn-grouped" do %i.icon-edit Edit - if @milestone.active? - = link_to 'Close Milestone', project_milestone_path(@project, @milestone, milestone: {state_event: :close }), method: :put, class: "btn btn-remove" + = link_to 'Close Milestone', project_milestone_path(@project, @milestone, milestone: {state_event: :close }), method: :put, class: "btn btn-remove btn-grouped" - else - = link_to 'Reopen Milestone', project_milestone_path(@project, @milestone, milestone: {state_event: :activate }), method: :put, class: "btn" + = link_to 'Reopen Milestone', project_milestone_path(@project, @milestone, milestone: {state_event: :activate }), method: :put, class: "btn btn-grouped" - if @milestone.issues.any? && @milestone.can_be_closed? .alert.alert-success @@ -22,17 +22,20 @@ ← To milestones list -.ui-box.ui-box-show - .ui-box-head - %h4.box-title +.issue-box{ class: issue_box_class(@milestone) } + .state + %span.state-label - if @milestone.closed? - .state-label.state-label-red Closed + Closed - elsif @milestone.expired? - .state-label.state-label-red Expired + Expired + - else + Open - = gfm escape_once(@milestone.title) + %h4.title + = gfm escape_once(@milestone.title) - .ui-box-body + .context %p Progress: #{@milestone.closed_items_count} closed @@ -40,14 +43,13 @@ #{@milestone.open_items_count} open %span.pull-right= @milestone.expires_at .progress.progress-info - .bar{style: "width: #{@milestone.percent_complete}%;"} - + .progress-bar{style: "width: #{@milestone.percent_complete}%;"} - if @milestone.description.present? - .ui-box-bottom - = preserve do - = markdown @milestone.description - + .description + .wiki + = preserve do + = markdown @milestone.description %ul.nav.nav-tabs %li.active @@ -64,30 +66,30 @@ %span.badge= @users.count .pull-right - = link_to new_project_issue_path(@project, issue: { milestone_id: @milestone.id }), class: "btn btn-small grouped", title: "New Issue" do + = link_to new_project_issue_path(@project, issue: { milestone_id: @milestone.id }), class: "btn btn-small btn-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 btn-small edit-milestone-link grouped" + = link_to 'Browse Issues', project_issues_path(@milestone.project, milestone_id: @milestone.id), class: "btn btn-small edit-milestone-link btn-grouped" .tab-content .tab-pane.active#tab-issues .row - .span4 + .col-md-4 = render('issues', title: 'Unstarted Issues (open and unassigned)', issues: @issues.opened.unassigned) - .span4 + .col-md-4 = render('issues', title: 'Ongoing Issues (open and assigned)', issues: @issues.opened.assigned) - .span4 + .col-md-4 = render('issues', title: 'Completed Issues (closed)', issues: @issues.closed) .tab-pane#tab-merge-requests .row - .span6 + .col-md-6 .ui-box .title Open %ul.well-list - @merge_requests.opened.each do |merge_request| = render 'merge_request', merge_request: merge_request - .span6 + .col-md-6 .ui-box .title Closed %ul.well-list @@ -98,7 +100,7 @@ %ul.bordered-list - @users.each do |user| %li - = link_to user, title: user.name, class: "dark" do + = link_to user, title: user.name, class: "darken" do = image_tag avatar_icon(user.email, 32), class: "avatar s32" %strong= truncate(user.name, lenght: 40) %br diff --git a/app/views/projects/network/_head.html.haml b/app/views/projects/network/_head.html.haml index 2790ed6f59..d61ff789b6 100644 --- a/app/views/projects/network/_head.html.haml +++ b/app/views/projects/network/_head.html.haml @@ -1,23 +1,15 @@ -.clearfix - .pull-left +.row.append-bottom-20 + .col-md-2.append-bottom-10 = render partial: 'shared/ref_switcher', locals: {destination: 'graph'} - .pull-left - = form_tag project_network_path(@project, @id), method: :get do |f| - .control-group - = label_tag :filter_ref, "Begin with the selected commit", class: 'control-label light' - .controls - = check_box_tag :filter_ref, 1, @options[:filter_ref] - - @options.each do |key, value| - = hidden_field_tag(key, value, id: nil) unless key == "filter_ref" - - .search.pull-right - = form_tag project_network_path(@project, @id), method: :get do |f| - .control-group - = label_tag :search , "Looking for commit:", class: 'control-label light' - .controls - = text_field_tag :extended_sha1, @options[:extended_sha1], placeholder: "Input an extended SHA1 syntax", class: "search-input input-xlarge" - = button_tag type: 'submit', class: 'btn vtop' do - %i.icon-search - - @options.each do |key, value| - = hidden_field_tag(key, value, id: nil) unless key == "extended_sha1" + .col-md-10 + = form_tag project_network_path(@project, @id), method: :get, class: 'form-inline network-form' do |f| + = label_tag :extended_sha1 , "Looking for", class: 'light inline-label' + = text_field_tag :extended_sha1, @options[:extended_sha1], placeholder: "Input an extended SHA1 syntax", class: "search-input form-control input-mx-250" + = button_tag type: 'submit', class: 'btn btn-success' do + %i.icon-search + .inline.prepend-left-20 + .checkbox.light + = label_tag :filter_ref do + = check_box_tag :filter_ref, 1, @options[:filter_ref] + %span Begin with the selected commit diff --git a/app/views/projects/network/show.html.haml b/app/views/projects/network/show.html.haml index 492f77341f..da0cfa84c2 100644 --- a/app/views/projects/network/show.html.haml +++ b/app/views/projects/network/show.html.haml @@ -3,7 +3,7 @@ .tip You can move around the graph by using the arrow keys. .network-graph - .loading.loading-gray + = spinner :javascript new Network({ diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml index 466a63dee8..5d5637c158 100644 --- a/app/views/projects/new.html.haml +++ b/app/views/projects/new.html.haml @@ -3,69 +3,77 @@ = render 'projects/errors' .project-edit-content - = form_for @project, remote: true do |f| - .control-group.project-name-holder - = f.label :name do + = form_for @project, remote: true, html: { class: 'new_project form-horizontal' } do |f| + .form-group.project-name-holder + = f.label :name, class: 'control-label' do %strong Project name - .controls - = f.text_field :name, placeholder: "Example Project", class: "input-xlarge", tabindex: 1, autofocus: true - %span.help-inline - = link_to "#", class: 'js-toggle-visibility-link' do - %span Customize repository name? - - .control-group.js-toggle-visibility-container.hide - = f.label :path do - %span Repository name - .controls - .input-append - = f.text_field :path - %span.add-on .git - + .col-sm-10 + = f.text_field :name, placeholder: "Example Project", class: "form-control", tabindex: 1, autofocus: true - if current_user.can_select_namespace? - .control-group - = f.label :namespace_id do + .form-group + = f.label :namespace_id, class: 'control-label' do %span Namespace - .controls - = f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'chosen', tabindex: 2} + .col-sm-10 + = f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'select2', tabindex: 2} - .control-group - .controls - = link_to "#", class: 'appear-link' do - %i.icon-upload-alt - %span Import existing repository? - .control-group.appear-data.import-url-data - = f.label :import_url do - %span Import existing repo - .controls - = f.text_field :import_url, class: 'input-xlarge', placeholder: 'https://github.com/randx/six.git' - .light - URL must be cloneable - .control-group - = f.label :description do + %hr + .js-toggle-container + .form-group + .col-sm-2 + .col-sm-10 + = link_to "#", class: 'js-toggle-button' do + %i.icon-edit + %span Customize repository name? + .js-toggle-content.hide + .form-group + = f.label :path, class: 'control-label' do + %span Repository name + .col-sm-10 + .input-group + = f.text_field :path, class: 'form-control' + %span.input-group-addon .git + + .js-toggle-container + .form-group + .col-sm-2 + .col-sm-10 + = link_to "#", class: 'js-toggle-button' do + %i.icon-upload-alt + %span Import existing repository? + .js-toggle-content.hide + .form-group.import-url-data + = f.label :import_url, class: 'control-label' do + %span Import existing repo + .col-sm-10 + = f.text_field :import_url, class: 'form-control', placeholder: 'https://github.com/randx/six.git' + .bs-callout.bs-callout-info + This url must be publicly accessible or you can add a username and password like this: https://username:password@gitlab.com/company/project.git. + %br + The import will time out after 2 minutes. For big repositories, use a clone/push combination. + %hr + + .form-group + = f.label :description, class: 'control-label' do Description %span.light (optional) - .controls - = f.text_area :description, placeholder: "Awesome project", class: "input-xlarge", rows: 3, maxlength: 250, tabindex: 3 - .control-group.project-public-holder - = f.label :public do - %span Public project - .controls - = f.check_box :public, { checked: gitlab_config.default_projects_features.public }, true, false - %span.help-inline Make project visible to everyone + .col-sm-10 + = f.text_area :description, placeholder: "Awesome project", class: "form-control", rows: 3, maxlength: 250, tabindex: 3 + = render "visibility_level", f: f, visibility_level: gitlab_config.default_projects_features.visibility_level, can_change_visibility_level: true .form-actions = f.submit 'Create project', class: "btn btn-create project-submit", tabindex: 4 - if current_user.can_create_group? .pull-right - .controls.light + .light Need a group for several dependent projects? = link_to new_group_path, class: "btn btn-tiny" do Create a group .save-project-loader.hide %center - = image_tag "ajax_loader.gif" - %h3 Creating project & repository. + %h2 + %i.icon-spinner.icon-spin + Creating project & repository. %p Please wait a moment, this page will automatically refresh when ready. diff --git a/app/views/projects/new_tree/show.html.haml b/app/views/projects/new_tree/show.html.haml new file mode 100644 index 0000000000..9ecbbe7508 --- /dev/null +++ b/app/views/projects/new_tree/show.html.haml @@ -0,0 +1,54 @@ +%h3.page-title New file +%hr +.file-editor + = form_tag(project_new_tree_path(@project, @id), method: :put, class: "form-horizontal") do + .form-group.commit_message-group + = label_tag 'file_name', class: "control-label" do + File name + .col-sm-10 + .input-group + %span.input-group-addon + = @path[-1] == "/" ? @path : @path + "/" + = text_field_tag 'file_name', params[:file_name], placeholder: "sample.rb", required: true, class: 'form-control' + %span.input-group-addon + on + %span= @ref + + .form-group.commit_message-group + = label_tag :encoding, class: "control-label" do + Encoding + .col-sm-10 + = select_tag :encoding, options_for_select([ "base64", "text" ], "text"), class: 'form-control' + + .form-group.commit_message-group + = label_tag 'commit_message', class: "control-label" do + Commit message + .col-sm-10 + = render 'shared/commit_message_container', {textarea: text_area_tag('commit_message', + params[:commit_message], placeholder: "Added new file", required: true, rows: 3, class: 'form-control')} + + .file-holder + .file-title + %i.icon-file + .file-content.code + %pre#editor= params[:content] + + .form-actions + = hidden_field_tag 'content', '', id: "file-content" + .commit-button-annotation + = button_tag "Commit changes", class: 'btn commit-btn js-commit-button btn-create' + .message + to branch + %strong= @ref + = link_to "Cancel", project_tree_path(@project, @id), class: "btn btn-cancel", data: { confirm: leave_edit_message} + +:javascript + ace.config.set("modePath", gon.relative_url_root + "#{Gitlab::Application.config.assets.prefix}/ace-src-noconflict") + var editor = ace.edit("editor"); + + disableButtonIfEmptyField("#commit_message", ".js-commit-button"); + + $(".js-commit-button").click(function(){ + $("#file-content").val(editor.getValue()); + $(".file-editor form").submit(); + }); diff --git a/app/views/projects/notes/_diff_notes_with_reply.html.haml b/app/views/projects/notes/_diff_notes_with_reply.html.haml index 9537ab18ca..9acadc6a14 100644 --- a/app/views/projects/notes/_diff_notes_with_reply.html.haml +++ b/app/views/projects/notes/_diff_notes_with_reply.html.haml @@ -1,7 +1,7 @@ - note = notes.first # example note -# Check if line want not changed since comment was left - if !defined?(line) || line == note.diff_line - %tr.notes_holder + %tr.notes_holder.js-toggle-content %td.notes_line{ colspan: 2 } %span.btn.disabled %i.icon-comment diff --git a/app/views/projects/notes/_diff_notes_with_reply_parallel.html.haml b/app/views/projects/notes/_diff_notes_with_reply_parallel.html.haml new file mode 100644 index 0000000000..399ce30d1a --- /dev/null +++ b/app/views/projects/notes/_diff_notes_with_reply_parallel.html.haml @@ -0,0 +1,33 @@ +- note1 = notes1.first # example note +- note2 = notes2.first # example note +-# Check if line want not changed since comment was left +/- if !defined?(line) || line == note.diff_line +%tr.notes_holder.js-toggle-content + - if note1 + %td.notes_line + %span.btn.disabled + %i.icon-comment + = notes1.count + %td.notes_content + %ul.notes{ rel: note1.discussion_id } + = render notes1 + + = render "projects/notes/discussion_reply_button", note: note1 + - else + %td= "" + %td= "" + + - if note2 + %td.notes_line + %span.btn.disabled + %i.icon-comment + = notes2.count + %td.notes_content + %ul.notes{ rel: note2.discussion_id } + = render notes2 + + = render "projects/notes/discussion_reply_button", note: note2 + - else + %td= "" + %td= "" + diff --git a/app/views/projects/notes/_discussion.html.haml b/app/views/projects/notes/_discussion.html.haml index e0aad0cc95..78793eb860 100644 --- a/app/views/projects/notes/_discussion.html.haml +++ b/app/views/projects/notes/_discussion.html.haml @@ -1,13 +1,10 @@ - note = discussion_notes.first -.discussion.js-details-container.js-toggler-container.open{ class: note.discussion_id } +.discussion.js-toggle-container{ class: note.discussion_id } .discussion-header .discussion-actions - = link_to "javascript:;", class: "js-details-target turn-on js-toggler-target" do - %i.icon-eye-close - Hide discussion - = link_to "javascript:;", class: "js-details-target turn-off js-toggler-target" do - %i.icon-eye-open - Show discussion + = link_to "#", class: "js-toggle-button" do + %i.icon-chevron-up + Show/hide discussion = image_tag avatar_icon(note.author_email), class: "avatar s32" %div = link_to_member(@project, note.author, avatar: false) @@ -32,32 +29,18 @@ last updated by = link_to_member(@project, last_note.author, avatar: false) %span.discussion-last-update - = time_ago_in_words(last_note.updated_at) - ago - .discussion-body + #{time_ago_with_tooltip(last_note.updated_at, 'bottom', 'discussion_updated_ago')} + .discussion-body.js-toggle-content - if note.for_diff_line? - if note.active? - .content - .file= render "projects/notes/discussion_diff", discussion_notes: discussion_notes, note: note + = render "projects/notes/discussion_diff", discussion_notes: discussion_notes, note: note - else = link_to 'show outdated discussion', '#', class: 'js-show-outdated-discussion' %div.hide.outdated-discussion - .content - .notes{ rel: discussion_notes.first.discussion_id } - = render discussion_notes - + .notes{ rel: discussion_notes.first.discussion_id } + = render discussion_notes - else - .content - .notes{ rel: discussion_notes.first.discussion_id } - = render discussion_notes - = render "projects/notes/discussion_reply_button", note: discussion_notes.first - - -# will be shown when the other one is hidden - .discussion-hidden.content.hide - .note - %em Hidden discussion. - = link_to "javascript:;", class: "js-details-target js-toggler-target" do - %i.icon-eye-open - Show - + .notes{ rel: discussion_notes.first.discussion_id } + = render discussion_notes + = render "projects/notes/discussion_reply_button", note: discussion_notes.first diff --git a/app/views/projects/notes/_discussion_diff.html.haml b/app/views/projects/notes/_discussion_diff.html.haml index c3f41a1b6b..26c5494f46 100644 --- a/app/views/projects/notes/_discussion_diff.html.haml +++ b/app/views/projects/notes/_discussion_diff.html.haml @@ -1,24 +1,26 @@ - diff = note.diff -.header - - if diff.deleted_file - %span= diff.old_path - - else - %span= diff.new_path - - if diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode - %span.file-mode= "#{diff.a_mode} → #{diff.b_mode}" - %br/ -.content - %table - - each_diff_line_near(diff, note.diff_file_index, note.line_code) do |line, type, line_code, line_new, line_old| - %tr.line_holder{ id: line_code } - - if type == "match" - %td.old_line= "..." - %td.new_line= "..." - %td.line_content.matched= line - - else - %td.old_line= raw(type == "new" ? " " : line_old) - %td.new_line= raw(type == "old" ? " " : line_new) - %td.line_content{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw "#{line}  " +- if diff + .diff-file + .diff-header + - if diff.deleted_file + %span= diff.old_path + - else + %span= diff.new_path + - if diff.a_mode && diff.b_mode && diff.a_mode != diff.b_mode + %span.file-mode= "#{diff.a_mode} → #{diff.b_mode}" + %br/ + .diff-content + %table + - each_diff_line_near(diff, note.diff_file_index, note.line_code) do |line, type, line_code, line_new, line_old| + %tr.line_holder{ id: line_code } + - if type == "match" + %td.old_line= "..." + %td.new_line= "..." + %td.line_content.matched= line + - else + %td.old_line= raw(type == "new" ? " " : line_old) + %td.new_line= raw(type == "old" ? " " : line_new) + %td.line_content{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw "#{line}  " - - if line_code == note.line_code - = render "projects/notes/diff_notes_with_reply", notes: discussion_notes + - if line_code == note.line_code + = render "projects/notes/diff_notes_with_reply", notes: discussion_notes diff --git a/app/views/projects/notes/_form.html.haml b/app/views/projects/notes/_form.html.haml index 7add292183..3db551e993 100644 --- a/app/views/projects/notes/_form.html.haml +++ b/app/views/projects/notes/_form.html.haml @@ -1,5 +1,4 @@ -= form_for [@project, @note], remote: true, html: { multipart: true, id: nil, class: "new_note js-new-note-form common-note-form" } do |f| - += form_for [@project, @note], remote: true, html: { :'data-type' => 'json', multipart: true, id: nil, class: "new_note js-new-note-form common-note-form" }, authenticity_token: true do |f| = note_target_fields = f.hidden_field :commit_id = f.hidden_field :line_code @@ -7,10 +6,12 @@ = f.hidden_field :noteable_type .note_text_and_preview.js-toggler-container - %a.js-note-preview-button.js-toggler-target.turn-off{ href: "javascript:;", title: "Preview", data: {url: preview_project_notes_path(@project)} } + %a.btn.js-note-preview-button.js-toggler-target.turn-off{ href: "javascript:;", data: {url: preview_project_notes_path(@project)} } %i.icon-eye-open - %a.js-note-edit-button.js-toggler-target.turn-off{ href: "javascript:;", title: "Edit" } + Preview + %a.btn.btn-primary.js-note-edit-button.js-toggler-target.turn-off{ href: "javascript:;" } %i.icon-edit + Write = f.text_area :note, size: 255, class: 'note_text js-note-text js-gfm-input turn-on' .note_preview.js-note-preview.turn-off @@ -21,17 +22,17 @@ .note-form-actions .buttons - = f.submit 'Add Comment', class: "btn comment-btn grouped js-comment-button" + = f.submit 'Add Comment', class: "btn comment-btn btn-grouped js-comment-button" = yield(:note_actions) %a.btn.grouped.js-close-discussion-note-form Cancel .note-form-option - %a.choose-btn.btn.btn-small.js-choose-note-attachment-button + %a.choose-btn.btn.js-choose-note-attachment-button %i.icon-paper-clip %span Choose File ...   %span.file_name.js-attachment-filename File name... - = f.file_field :attachment, class: "js-note-attachment-input hide" + = f.file_field :attachment, class: "js-note-attachment-input hidden" .clearfix diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml index e56e9153c2..2fd8cb6d48 100644 --- a/app/views/projects/notes/_note.html.haml +++ b/app/views/projects/notes/_note.html.haml @@ -10,7 +10,7 @@ %i.icon-edit Edit   - = link_to project_note_path(@project, note), title: "Remove comment", method: :delete, confirm: 'Are you sure you want to remove this comment?', remote: true, class: "danger js-note-delete" do + = link_to project_note_path(@project, note), title: "Remove comment", method: :delete, data: { confirm: 'Are you sure you want to remove this comment?' }, remote: true, class: "danger js-note-delete" do %i.icon-trash.cred Remove = image_tag avatar_icon(note.author_email), class: "avatar s32" @@ -23,7 +23,7 @@ %i.icon-thumbs-up \+1 - if note.downvote? - %span.vote.downvote.label.label-error + %span.vote.downvote.label.label-danger %i.icon-thumbs-down \-1 @@ -31,13 +31,13 @@ .note-body .note-text = preserve do - = markdown(note.note) + = markdown(note.note, {no_header_anchors: true}) .note-edit-form - = form_for note, url: project_note_path(@project, note), method: :put, remote: true do |f| + = form_for note, url: project_note_path(@project, note), method: :put, remote: true, authenticity_token: true do |f| = f.text_area :note, class: 'note_text js-note-text js-gfm-input turn-on' - .form-actions + .form-actions.clearfix = f.submit 'Save changes', class: "btn btn-primary btn-save" .note-form-option @@ -46,7 +46,7 @@ %span Choose File ...   %span.file_name.js-attachment-filename File name... - = f.file_field :attachment, class: "js-note-attachment-input hide" + = f.file_field :attachment, class: "js-note-attachment-input hidden" = link_to 'Cancel', "#", class: "btn btn-cancel note-edit-cancel" @@ -54,13 +54,13 @@ - if note.attachment.url .note-attachment - if note.attachment.image? - = link_to note.attachment.url, target: '_blank' do - = image_tag note.attachment.url, class: 'note-image-attach' + = link_to note.attachment.secure_url, target: '_blank' do + = image_tag note.attachment.secure_url, class: 'note-image-attach' .attachment.pull-right = link_to note.attachment.secure_url, target: "_blank" do %i.icon-paper-clip = note.attachment_identifier = link_to delete_attachment_project_note_path(@project, note), - title: "Delete this attachment", method: :delete, remote: true, confirm: 'Are you sure you want to remove the attachment?', class: "danger js-note-attachment-delete" do + title: "Delete this attachment", method: :delete, remote: true, data: { confirm: 'Are you sure you want to remove the attachment?' }, class: "danger js-note-attachment-delete" do %i.icon-trash.cred .clear diff --git a/app/views/projects/notes/_notes.html.haml b/app/views/projects/notes/_notes.html.haml index ac8901fe70..ca60dd239b 100644 --- a/app/views/projects/notes/_notes.html.haml +++ b/app/views/projects/notes/_notes.html.haml @@ -4,7 +4,7 @@ - if note_for_main_target?(note) = render discussion_notes - else - = render 'discussion', discussion_notes: discussion_notes + = render 'projects/notes/discussion', discussion_notes: discussion_notes - else - @notes.each do |note| - next unless note.author diff --git a/app/views/projects/notes/_notes_with_form.html.haml b/app/views/projects/notes/_notes_with_form.html.haml index ac28c7432e..052661962e 100644 --- a/app/views/projects/notes/_notes_with_form.html.haml +++ b/app/views/projects/notes/_notes_with_form.html.haml @@ -1,4 +1,5 @@ -%ul#notes-list.notes +%ul#notes-list.notes.main-notes-list + = render "projects/notes/notes" .js-notes-busy .js-main-target-form @@ -6,4 +7,4 @@ = render "projects/notes/form" :javascript - NoteList.init("#{@target_id}", "#{@target_type}", "#{project_notes_path(@project)}"); + new Notes("#{project_notes_path(target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, #{Time.now.to_i}) diff --git a/app/views/projects/notes/create.js.haml b/app/views/projects/notes/create.js.haml deleted file mode 100644 index c113b3482e..0000000000 --- a/app/views/projects/notes/create.js.haml +++ /dev/null @@ -1,18 +0,0 @@ -- if @note.valid? - var noteHtml = "#{escape_javascript(render @note)}"; - - - if note_for_main_target?(@note) - NoteList.appendNewNote(#{@note.id}, noteHtml); - - else - :plain - var firstDiscussionNoteHtml = "#{escape_javascript(render "projects/notes/diff_notes_with_reply", notes: [@note])}"; - NoteList.appendNewDiscussionNote("#{@note.discussion_id}", - firstDiscussionNoteHtml, - noteHtml); - -- else - var errorsHtml = "#{escape_javascript(render 'projects/notes/form_errors', note: @note)}"; - - if note_for_main_target?(@note) - NoteList.errorsOnForm(errorsHtml); - - else - NoteList.errorsOnForm(errorsHtml, "#{@note.discussion_id}"); diff --git a/app/views/projects/notes/index.js.haml b/app/views/projects/notes/index.js.haml deleted file mode 100644 index 6c4ed20349..0000000000 --- a/app/views/projects/notes/index.js.haml +++ /dev/null @@ -1,4 +0,0 @@ -- unless @notes.blank? - var notesHtml = "#{escape_javascript(render 'projects/notes/notes')}"; - - new_note_ids = @notes.map(&:id) - NoteList.setContent(#{new_note_ids}, notesHtml); diff --git a/app/views/projects/protected_branches/index.html.haml b/app/views/projects/protected_branches/index.html.haml index 8930ec4b30..4a6e8943a9 100644 --- a/app/views/projects/protected_branches/index.html.haml +++ b/app/views/projects/protected_branches/index.html.haml @@ -1,29 +1,30 @@ = render "projects/commits/head" .row - .span3 + .col-md-3 = render "projects/branches/filter" - .span9 - .alert.alert-info + .col-md-9 + .bs-callout.bs-callout-info %p Protected branches designed to prevent push for all except #{link_to "masters", help_permissions_path, class: "vlink"}. %p This ability allows: %ul %li keep stable branches secured %li forced code review before merge to protected branches - %p Read more about project permissions #{link_to "here", help_permissions_path, class: "underlined_link"} + %li prevents branch from force push + %p Read more about project permissions #{link_to "here", help_permissions_path, class: "underlined-link"} - if can? current_user, :admin_project, @project - = form_for [@project, @protected_branch] do |f| + = form_for [@project, @protected_branch], html: { class: 'form-horizontal' } do |f| -if @protected_branch.errors.any? - .alert.alert-error + .alert.alert-danger %ul - @protected_branch.errors.full_messages.each do |msg| %li= msg - .entry.clearfix - = f.label :name, "Branch" - .span3 - = f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: "Select branch"}, {class: "chosen span3"}) -   + .form-group + = f.label :name, "Branch", class: 'control-label' + .col-sm-10 + = f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: "Select branch"}, {class: "select2"}) + .form-actions = f.submit 'Protect', class: "btn-create btn" - unless @branches.empty? %h5 Already Protected: @@ -39,15 +40,13 @@ %i.icon-lock .pull-right - if can? current_user, :admin_project, @project - = link_to 'Unprotect', [@project, branch], confirm: 'Branch will be writable for developers. Are you sure?', method: :delete, class: "btn btn-remove btn-small" + = link_to 'Unprotect', [@project, branch], data: { confirm: 'Branch will be writable for developers. Are you sure?' }, method: :delete, class: "btn btn-remove btn-small" - if commit = branch.commit = link_to project_commit_path(@project, commit.id), class: 'commit_short_id' do = commit.short_id %span.light = gfm escape_once(truncate(commit.title, length: 40)) - %span - = time_ago_in_words(commit.committed_date) - ago + #{time_ago_with_tooltip(commit.committed_date)} - else (branch was removed from repository) diff --git a/app/views/projects/refs/logs_tree.js.haml b/app/views/projects/refs/logs_tree.js.haml index 213c54f5f7..e7343e0997 100644 --- a/app/views/projects/refs/logs_tree.js.haml +++ b/app/views/projects/refs/logs_tree.js.haml @@ -5,5 +5,5 @@ :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(commit.committed_date)} ago'); + row.find("td.tree_time_ago").html('#{escape_javascript time_ago_with_tooltip(commit.committed_date)}'); row.find("td.tree_commit").html('#{escape_javascript render("projects/tree/tree_commit_column", commit: commit)}'); diff --git a/app/views/projects/repositories/_download_archive.html.haml b/app/views/projects/repositories/_download_archive.html.haml new file mode 100644 index 0000000000..88c1cfa28e --- /dev/null +++ b/app/views/projects/repositories/_download_archive.html.haml @@ -0,0 +1,37 @@ +- ref = ref || nil +- btn_class = btn_class || '' +- split_button = split_button || false +- if split_button == true + %span.btn-group{class: btn_class} + = link_to archive_project_repository_path(@project, ref: ref, format: 'zip'), class: 'btn', rel: 'nofollow' do + %i.icon-download-alt + %span Download zip + %a.btn.dropdown-toggle{ 'data-toggle' => 'dropdown' } + %span.caret + %span.sr-only + Select Archive Format + %ul.dropdown-menu{ role: 'menu' } + %li + = link_to archive_project_repository_path(@project, ref: ref, format: 'zip'), rel: 'nofollow' do + %i.icon-download-alt + %span Download zip + %li + = link_to archive_project_repository_path(@project, ref: ref, format: 'tar.gz'), rel: 'nofollow' do + %i.icon-download-alt + %span Download tar.gz + %li + = link_to archive_project_repository_path(@project, ref: ref, format: 'tar.bz2'), rel: 'nofollow' do + %i.icon-download-alt + %span Download tar.bz2 + %li + = link_to archive_project_repository_path(@project, ref: ref, format: 'tar'), rel: 'nofollow' do + %i.icon-download-alt + %span Download tar +- else + %span.btn-group{class: btn_class} + = link_to archive_project_repository_path(@project, ref: ref, format: 'zip'), class: 'btn', rel: 'nofollow' do + %i.icon-download-alt + %span zip + = link_to archive_project_repository_path(@project, ref: ref, format: 'tar.gz'), class: 'btn', rel: 'nofollow' do + %i.icon-download-alt + %span tar.gz \ No newline at end of file diff --git a/app/views/projects/repositories/_feed.html.haml b/app/views/projects/repositories/_feed.html.haml index 6e537d2959..c77ffff43f 100644 --- a/app/views/projects/repositories/_feed.html.haml +++ b/app/views/projects/repositories/_feed.html.haml @@ -15,5 +15,4 @@ = gfm escape_once(truncate(commit.title, length: 40)) %td %span.pull-right.cgray - = time_ago_in_words(commit.committed_date) - ago + = time_ago_with_tooltip(commit.committed_date) diff --git a/app/views/projects/repositories/stats.html.haml b/app/views/projects/repositories/stats.html.haml index 679b4211cd..fd35397857 100644 --- a/app/views/projects/repositories/stats.html.haml +++ b/app/views/projects/repositories/stats.html.haml @@ -1,6 +1,6 @@ = render "projects/commits/head" .row - .span6 + .col-md-6 %div#activity-chart.chart %hr %p @@ -14,7 +14,7 @@ %span= @stats.authors_count - .span6 + .col-md-6 %h4 Top 50 Committers: %ol.styled - @stats.authors[0...50].each do |author| diff --git a/app/views/projects/services/_form.html.haml b/app/views/projects/services/_form.html.haml index a099193cb6..70b4537fd3 100644 --- a/app/views/projects/services/_form.html.haml +++ b/app/views/projects/services/_form.html.haml @@ -1,11 +1,6 @@ %h3.page-title - - if @service.activated? - %span.cgreen - %i.icon-circle - - else - %span.cgray - %i.icon-circle-blank = @service.title + = boolean_to_icon @service.activated? %p= @service.description @@ -15,17 +10,17 @@ %hr -= form_for(@service, as: :service, url: project_service_path(@project, @service.to_param), method: :put) do |f| += form_for(@service, as: :service, url: project_service_path(@project, @service.to_param), method: :put, html: { class: 'form-horizontal' }) do |f| - if @service.errors.any? - .alert.alert-error + .alert.alert-danger %ul - @service.errors.full_messages.each do |msg| %li= msg - .control-group + .form-group = f.label :active, "Active", class: "control-label" - .controls + .col-sm-10 = f.check_box :active - @service.fields.each do |field| @@ -33,11 +28,13 @@ - type = field[:type] - placeholder = field[:placeholder] - .control-group + .form-group = f.label name, class: "control-label" - .controls + .col-sm-10 - if type == 'text' - = f.text_field name, class: "input-xlarge", placeholder: placeholder + = f.text_field name, class: "form-control", placeholder: placeholder + - elsif type == 'textarea' + = f.text_area name, rows: 5, class: "form-control", placeholder: placeholder - elsif type == 'checkbox' = f.check_box name @@ -45,4 +42,4 @@ = f.submit 'Save', class: 'btn btn-save'   - if @service.valid? && @service.activated? && @service.can_test? - = link_to 'Test settings', test_project_service_path(@project, @service.to_param), class: 'btn btn-small' + = link_to 'Test settings', test_project_service_path(@project, @service.to_param), class: 'btn' diff --git a/app/views/projects/services/index.html.haml b/app/views/projects/services/index.html.haml index 82b85a18ac..7271dd830c 100644 --- a/app/views/projects/services/index.html.haml +++ b/app/views/projects/services/index.html.haml @@ -1,17 +1,13 @@ -%h3.page-title Services -%p.light Services allow you to integrate GitLab with other applications +%h3.page-title Project services +%p.light Project services allow you to integrate GitLab with other applications %hr %ul.bordered-list - - @services.each do |service| + - @services.sort_by(&:title).each do |service| %li %h4 - - if service.activated? - %span.cgreen - %i.icon-circle - - else - %span.cgray - %i.icon-circle-blank = link_to edit_project_service_path(@project, service.to_param) do = service.title + .pull-right + = boolean_to_icon service.activated? %p= service.description diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index cad072a83d..7e9f1122aa 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -1,70 +1,57 @@ -.project-home-panel - .row - .span4 - %h4.project-home-title - = @project.name_with_namespace - - if @project.public - %span.public-label Public - - else - %span.public-label Private - - .span8 - .project-home-dropdown - = render "dropdown" - .form-horizontal - = render "shared/clone_panel" - - .project-home-extra.clearfix - .project-home-desc - - if @project.description.present? - = @project.description - - if can?(current_user, :admin_project, @project) - – - %strong= link_to 'Edit', edit_project_path - - .project-home-links - = link_to pluralize(@repository.round_commit_count, 'commit'), project_commits_path(@project, @ref || @repository.root_ref) - = link_to pluralize(@repository.branch_names.count, 'branch'), project_branches_path(@project) - = link_to pluralize(@repository.tag_names.count, 'tag'), project_tags_path(@project) - %span.light.prepend-left-20= repository_size += render "home_panel" .row - .span9 + .col-md-9 = render "events/event_last_push", event: @last_push = render 'shared/event_filter' .content_list - .loading.hide - .span3 + = spinner + .col-md-3.project-side.hidden-sm.hidden-xs .clearfix + - if @project.archived? + .alert.alert-warning + %h4 + %i.icon-warning-sign + Archived project! + %p Repository is read-only + + - if @project.forked_from_project .alert.alert-success - %i.icon-code-fork + %i.icon-code-fork.project-fork-icon Forked from: + %br = link_to @project.forked_from_project.name_with_namespace, project_path(@project.forked_from_project) - unless @project.empty_repo? - if current_user && can?(current_user, :fork_project, @project) && @project.namespace != current_user.namespace - if current_user.already_forked?(@project) = link_to project_path(current_user.fork_of(@project)), class: 'btn btn-block' do - %i.icon-ok - Already forked + %i.icon-compass + Go to fork - else = link_to fork_project_path(@project), title: "Fork", class: "btn btn-block", method: "POST" do %i.icon-code-fork Fork repository - if can? current_user, :download_code, @project - = link_to archive_project_repository_path(@project), class: "btn btn-block" do - %i.icon-download-alt - %span Download - %br - .light-well + = render 'projects/repositories/download_archive', btn_class: 'btn-block btn-group-justified', split_button: true + + = link_to project_compare_index_path(@project, from: @repository.root_ref, to: @ref || @repository.root_ref), class: 'btn btn-block' do + Compare code + + - if @repository.readme + - readme = @repository.readme + = link_to project_blob_path(@project, tree_join(@repository.root_ref, readme.name)), class: 'btn btn-block' do + = readme.name + + .prepend-top-10 %p %span.light Created on #{@project.created_at.stamp('Aug 22, 2013')} %p %span.light Owned by - if @project.group - #{link_to @project.group.name, @project.group} Group + #{link_to @project.group.name, @project.group} group - else #{link_to @project.owner_name, @project.owner} diff --git a/app/views/projects/show.js.haml b/app/views/projects/show.js.haml deleted file mode 100644 index 511f278929..0000000000 --- a/app/views/projects/show.js.haml +++ /dev/null @@ -1,2 +0,0 @@ -:plain - Pager.append(#{@events.count}, "#{escape_javascript(render(@events))}"); diff --git a/app/views/projects/snippets/_blob.html.haml b/app/views/projects/snippets/_blob.html.haml index f14a2bd4ec..af326a1a99 100644 --- a/app/views/projects/snippets/_blob.html.haml +++ b/app/views/projects/snippets/_blob.html.haml @@ -6,10 +6,5 @@ .btn-group.tree-btn-group.pull-right - if can?(current_user, :admin_project_snippet, @project) || @snippet.author == current_user = link_to "Edit", edit_project_snippet_path(@project, @snippet), class: "btn btn-tiny", title: 'Edit Snippet' - = link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn btn-tiny", target: "_blank" - .file-content.code - - unless @snippet.content.empty? - %div{class: user_color_scheme_class} - = raw @snippet.colorize(formatter: :gitlab) - - else - %p.nothing_here_message Empty file + = link_to "Raw", raw_project_snippet_path(@project, @snippet), class: "btn btn-tiny", target: "_blank" + = render 'snippets/blob_content' diff --git a/app/views/projects/snippets/_form.html.haml b/app/views/projects/snippets/_form.html.haml index d414ee2d1e..866346990d 100644 --- a/app/views/projects/snippets/_form.html.haml +++ b/app/views/projects/snippets/_form.html.haml @@ -2,26 +2,23 @@ = @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}" %hr .snippet-form-holder - = form_for [@project, @snippet], as: :project_snippet, url: url do |f| + = form_for [@project, @snippet], as: :project_snippet, url: url, html: {class: "form-horizontal snippet-form"} do |f| -if @snippet.errors.any? - .alert.alert-error + .alert.alert-danger %ul - @snippet.errors.full_messages.each do |msg| %li= msg - .control-group - = f.label :title - .controls= f.text_field :title, placeholder: "Example Snippet", class: 'input-xlarge', required: true - .control-group - = f.label "Lifetime" - .controls= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'} - .control-group + .form-group + = f.label :title, class: 'control-label' + .col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true + .form-group .file-editor - = f.label :file_name, "File" - .controls + = f.label :file_name, "File", class: 'control-label' + .col-sm-10 .file-holder.snippet .file-title - = f.text_field :file_name, placeholder: "example.rb", class: 'snippet-file-name', required: true + = f.text_field :file_name, placeholder: "example.rb", class: 'form-control snippet-file-name', required: true .file-content.code %pre#editor= @snippet.content = f.hidden_field :content, class: 'snippet-file-content' @@ -31,10 +28,11 @@ = f.submit 'Create snippet', class: "btn-create btn" - else = f.submit 'Save', class: "btn-save btn" - = link_to "Cancel", project_snippets_path(@project), class: "btn btn-cancel" - - unless @snippet.new_record? - = link_to 'Remove snippet', project_snippet_path(@project, @snippet), confirm: 'Are you sure?', method: :delete, class: "btn pull-right btn-remove delete-snippet prepend-left-10", id: "destroy_snippet_#{@snippet.id}" + - unless @snippet.new_record? + .pull-right.prepend-left-20 + = link_to 'Remove snippet', project_snippet_path(@project, @snippet), data: { confirm: 'Are you sure?' }, method: :delete, class: "btn pull-right btn-remove delete-snippet prepend-left-10", id: "destroy_snippet_#{@snippet.id}" + = link_to "Cancel", project_snippets_path(@project), class: "btn btn-cancel" :javascript var editor = ace.edit("editor"); diff --git a/app/views/projects/snippets/_snippet.html.haml b/app/views/projects/snippets/_snippet.html.haml index 6185e35cf6..b2c35edc44 100644 --- a/app/views/projects/snippets/_snippet.html.haml +++ b/app/views/projects/snippets/_snippet.html.haml @@ -5,17 +5,11 @@ %span.cgray.monospace.tiny.pull-right = snippet.file_name - %small.pull-right.cgray - Expires: - - if snippet.expires_at - = snippet.expires_at.to_date.to_s(:short) - - else - Never - .snippet-info = "##{snippet.id}" %span by = image_tag avatar_icon(snippet.author_email), class: "avatar avatar-inline s16" = snippet.author_name - %span.light #{time_ago_in_words(snippet.created_at)} ago + %span.light + #{time_ago_with_tooltip(snippet.created_at)} diff --git a/app/views/projects/snippets/index.html.haml b/app/views/projects/snippets/index.html.haml index c40f63d05b..e60f9a4432 100644 --- a/app/views/projects/snippets/index.html.haml +++ b/app/views/projects/snippets/index.html.haml @@ -12,4 +12,4 @@ = render partial: "projects/snippets/snippet", collection: @snippets - if @snippets.empty? %li - %h3.nothing_here_message Nothing here. + .nothing-here-block Nothing here. diff --git a/app/views/projects/tags/_tag.html.haml b/app/views/projects/tags/_tag.html.haml new file mode 100644 index 0000000000..6629e47ad3 --- /dev/null +++ b/app/views/projects/tags/_tag.html.haml @@ -0,0 +1,22 @@ +- commit = @repository.commit(tag.target) +%li + %h4 + = link_to project_commits_path(@project, tag.name), class: "" do + %i.icon-tag + = tag.name + .pull-right + %small.cdark + %i.icon-calendar + #{time_ago_with_tooltip(commit.committed_date)} + %p.prepend-left-20 + = link_to commit.short_id(8), project_commit_path(@project, commit), class: "monospace" + – + = link_to_gfm truncate(commit.title, length: 70), project_commit_path(@project, commit.id), class: "cdark" + + %span.pull-right + - if can? current_user, :download_code, @project + = render 'projects/repositories/download_archive', ref: tag.name, btn_class: 'btn-grouped btn-group-small' + - if can?(current_user, :admin_project, @project) + = link_to project_tag_path(@project, tag.name), class: 'btn btn-small remove-row grouped', method: :delete, data: { confirm: 'Removed tag cannot be restored. Are you sure?'}, remote: true do + %i.icon-trash + diff --git a/app/views/projects/tags/index.html.haml b/app/views/projects/tags/index.html.haml index 5361517b2f..08122fb884 100644 --- a/app/views/projects/tags/index.html.haml +++ b/app/views/projects/tags/index.html.haml @@ -7,43 +7,18 @@ New tag %p - Tags give ability to mark specific points in history as being important + Tags give the ability to mark specific points in history as being important %hr - unless @tags.empty? %ul.bordered-list - @tags.each do |tag| - - commit = Commit.new(Gitlab::Git::Commit.new(tag.commit)) - %li - %h4 - = link_to project_commits_path(@project, tag.name), class: "" do - %i.icon-tag - = tag.name - %small - = truncate(tag.message || '', length: 70) - .pull-right - %small.cdark - %i.icon-calendar - = time_ago_in_words(commit.committed_date) - ago - %p.prepend-left-20 - = link_to commit.short_id(8), project_commit_path(@project, commit), class: "monospace" - – - = link_to_gfm truncate(commit.title, length: 70), project_commit_path(@project, commit.id), class: "cdark" - - %span.pull-right - - if can? current_user, :download_code, @project - = link_to archive_project_repository_path(@project, ref: tag.name), class: 'btn grouped btn-small' do - %i.icon-download-alt - Download - - if can?(current_user, :admin_project, @project) - = link_to project_tag_path(@project, tag.name), class: 'btn btn-small remove-row', method: :delete, confirm: 'Removed tag cannot be restored. Are you sure?', remote: true do - %i.icon-trash + = render 'tag', tag: @repository.find_tag(tag) = paginate @tags, theme: 'gitlab' - else - %h3.nothing_here_message + .nothing-here-block Repository has no tags yet. %br %small diff --git a/app/views/projects/tags/new.html.haml b/app/views/projects/tags/new.html.haml index 67030785e0..a9fd97f891 100644 --- a/app/views/projects/tags/new.html.haml +++ b/app/views/projects/tags/new.html.haml @@ -1,15 +1,15 @@ %h3.page-title %i.icon-code-fork New tag -= form_tag project_tags_path, method: :post do - .control-group += form_tag project_tags_path, method: :post, class: "form-horizontal" do + .form-group = label_tag :tag_name, 'Name for new tag', class: 'control-label' - .controls - = text_field_tag :tag_name, nil, placeholder: 'v3.0.1', required: true, tabindex: 1 - .control-group + .col-sm-10 + = text_field_tag :tag_name, nil, placeholder: 'v3.0.1', required: true, tabindex: 1, class: 'form-control' + .form-group = label_tag :ref, 'Create from', class: 'control-label' - .controls - = text_field_tag :ref, nil, placeholder: 'master', required: true, tabindex: 2 + .col-sm-10 + = text_field_tag :ref, nil, placeholder: 'master', required: true, tabindex: 2, class: 'form-control' .light Branch name or commit SHA .form-actions = submit_tag 'Create tag', class: 'btn btn-create', tabindex: 3 diff --git a/app/views/projects/team_members/_form.html.haml b/app/views/projects/team_members/_form.html.haml index 5214a54e90..dd059fb99d 100644 --- a/app/views/projects/team_members/_form.html.haml +++ b/app/views/projects/team_members/_form.html.haml @@ -1,23 +1,23 @@ %h3.page-title = "New project member(s)" -= form_for @user_project_relation, as: :team_member, url: project_team_members_path(@project) do |f| += form_for @user_project_relation, as: :team_member, url: project_team_members_path(@project), html: { class: "form-horizontal users-project-form" } do |f| -if @user_project_relation.errors.any? - .alert.alert-error + .alert.alert-danger %ul - @user_project_relation.errors.full_messages.each do |msg| %li= msg %p 1. Choose people you want in the project - .control-group - = f.label :user_ids, "People" - .controls + .form-group + = f.label :user_ids, "People", class: 'control-label' + .col-sm-10 = users_select_tag(:user_ids, multiple: true) %p 2. Set access level for them - .control-group - = f.label :project_access, "Project Access" - .controls= select_tag :project_access, options_for_select(Gitlab::Access.options, @user_project_relation.project_access), class: "project-access-select chosen" + .form-group + = f.label :project_access, "Project Access", class: 'control-label' + .col-sm-10= select_tag :project_access, options_for_select(Gitlab::Access.options, @user_project_relation.project_access), class: "project-access-select select2" .form-actions = f.submit 'Add users', class: "btn btn-create" diff --git a/app/views/projects/team_members/_group_members.html.haml b/app/views/projects/team_members/_group_members.html.haml index 68f0800685..eceec6627b 100644 --- a/app/views/projects/team_members/_group_members.html.haml +++ b/app/views/projects/team_members/_group_members.html.haml @@ -1,10 +1,14 @@ +- group_users_count = @group.users_groups.count .ui-box .title %strong #{@group.name} - group members (#{@group.users_groups.count}) + group members (#{group_users_count}) .pull-right = link_to members_group_path(@group), class: 'btn btn-small' do %i.icon-edit %ul.well-list - - @group.users_groups.order('group_access DESC').each do |member| + - @group.users_groups.order('group_access DESC').limit(20).each do |member| = render 'users_groups/users_group', member: member, show_controls: false + - if group_users_count > 20 + %li + and #{group_users_count - 20} more. For full list visit #{link_to 'group members page', members_group_path(@group)} diff --git a/app/views/projects/team_members/_team_member.html.haml b/app/views/projects/team_members/_team_member.html.haml index 5c93e6e3ea..d93bb44ab9 100644 --- a/app/views/projects/team_members/_team_member.html.haml +++ b/app/views/projects/team_members/_team_member.html.haml @@ -7,7 +7,7 @@ = form_for(member, as: :team_member, url: project_team_member_path(@project, member.user)) do |f| = f.select :project_access, options_for_select(UsersProject.access_roles, member.project_access), {}, class: "medium project-access-select span2 trigger-submit"   - = link_to project_team_member_path(@project, user), confirm: remove_from_project_team_message(@project, user), method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from team' do + = link_to project_team_member_path(@project, user), data: { confirm: remove_from_project_team_message(@project, user)}, method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from team' do %i.icon-minus.icon-white = image_tag avatar_icon(user.email, 32), class: "avatar s32" %p diff --git a/app/views/projects/team_members/import.html.haml b/app/views/projects/team_members/import.html.haml index 1d98b98621..d3e4a76201 100644 --- a/app/views/projects/team_members/import.html.haml +++ b/app/views/projects/team_members/import.html.haml @@ -3,10 +3,10 @@ %p.light Only project members will be imported. Group members will be skipped. %hr -= form_tag apply_import_project_team_members_path(@project), method: 'post' do - .padded - = label_tag :source_project_id, "Project" - .controls= select_tag(:source_project_id, options_from_collection_for_select(current_user.authorized_projects, :id, :name_with_namespace), prompt: "Select project", class: "chosen xxlarge", required: true) += form_tag apply_import_project_team_members_path(@project), method: 'post', class: 'form-horizontal' do + .form-group + = label_tag :source_project_id, "Project", class: 'control-label' + .col-sm-10= select_tag(:source_project_id, options_from_collection_for_select(current_user.authorized_projects, :id, :name_with_namespace), prompt: "Select project", class: "select2 lg", required: true) .form-actions = submit_tag 'Import project members', class: "btn btn-create" diff --git a/app/views/projects/team_members/index.html.haml b/app/views/projects/team_members/index.html.haml index acbe82919f..6eccaafe3d 100644 --- a/app/views/projects/team_members/index.html.haml +++ b/app/views/projects/team_members/index.html.haml @@ -3,9 +3,9 @@ - if can? current_user, :admin_team_member, @project %span.pull-right - = link_to new_project_team_member_path(@project), class: "btn btn-new grouped", title: "New project member" do + = link_to new_project_team_member_path(@project), class: "btn btn-new btn-grouped", title: "New project member" do New project member - = link_to import_project_team_members_path(@project), class: "btn grouped", title: "Import members from another project" do + = link_to import_project_team_members_path(@project), class: "btn btn-grouped", title: "Import members from another project" do Import members %p.light diff --git a/app/views/projects/tree/_blob_item.html.haml b/app/views/projects/tree/_blob_item.html.haml index b179ad7d24..6fee604b55 100644 --- a/app/views/projects/tree/_blob_item.html.haml +++ b/app/views/projects/tree/_blob_item.html.haml @@ -1,9 +1,8 @@ %tr{ class: "tree-item #{tree_hex_class(blob_item)}" } %td.tree-item-file-name = tree_icon(type) - %span= link_to truncate(blob_item.name, length: 40), project_blob_path(@project, tree_join(@id || @commit.id, blob_item.name)) + %span.str-truncated + = link_to blob_item.name, project_blob_path(@project, tree_join(@id || @commit.id, blob_item.name)) %td.tree_time_ago.cgray - %span.log_loading.hide - Loading commit data... - = image_tag "ajax_loader_tree.gif", width: 14 + = render 'spinner' %td.tree_commit{ colspan: 2 } diff --git a/app/views/projects/tree/_readme.html.haml b/app/views/projects/tree/_readme.html.haml index 98bacb4956..0c19109445 100644 --- a/app/views/projects/tree/_readme.html.haml +++ b/app/views/projects/tree/_readme.html.haml @@ -1,13 +1,13 @@ -.file-holder#README - .file-title +.readme-holder#README + %h4.readme-file-title %i.icon-file = readme.name - .file-content.wiki + .wiki - if gitlab_markdown?(readme.name) = preserve do = markdown(readme.data) - elsif plain_text_readme?(readme.name) %pre.clean = readme.data - - else - = raw GitHub::Markup.render(readme.name, readme.data) + - elsif markup?(readme.name) + = render_markup(readme.name, readme.data) diff --git a/app/views/projects/tree/_spinner.html.haml b/app/views/projects/tree/_spinner.html.haml new file mode 100644 index 0000000000..5a9e77b63d --- /dev/null +++ b/app/views/projects/tree/_spinner.html.haml @@ -0,0 +1,3 @@ +%span.log_loading.hide + %i.icon-spinner.icon-spin + Loading commit data... diff --git a/app/views/projects/tree/_submodule_item.html.haml b/app/views/projects/tree/_submodule_item.html.haml index badc7d992b..ae87dbde67 100644 --- a/app/views/projects/tree/_submodule_item.html.haml +++ b/app/views/projects/tree/_submodule_item.html.haml @@ -1,10 +1,15 @@ +- tree, commit = submodule_links(submodule_item) %tr{ class: "tree-item" } %td.tree-item-file-name = image_tag "submodule.png" %span - = link_to truncate(submodule_item.name, length: 40), submodule_item.submodule_url + = link_to truncate(submodule_item.name, length: 40), tree @ - %span.monospace #{submodule_item.id[0..10]} + %span.monospace + - if commit.nil? + #{submodule_item.id[0..10]} + - else + = link_to "#{submodule_item.id[0..10]}", commit %td %td %td diff --git a/app/views/projects/tree/_tree.html.haml b/app/views/projects/tree/_tree.html.haml index eadfd33bd3..ee850e2bc1 100644 --- a/app/views/projects/tree/_tree.html.haml +++ b/app/views/projects/tree/_tree.html.haml @@ -4,12 +4,16 @@ = link_to project_tree_path(@project, @ref) do = @project.path - tree_breadcrumbs(tree, 6) do |title, path| - \/ %li - if path = link_to truncate(title, length: 40), project_tree_path(@project, path) - else = link_to title, '#' + - if current_user && @repository.branch_names.include?(@ref) && current_user.can?(:push_code, @project) + %li + = link_to project_new_tree_path(@project, @id), title: 'New file', id: 'new-file-link' do + %small + %i.icon-plus.light %div#tree-content-holder.tree-content-holder %table#tree-slider{class: "table_#{@hex_path} tree-table" } @@ -17,15 +21,16 @@ %tr %th Name %th Last Update - %th + %th.hidden-sm Last Commit -   - %i.icon-angle-right -   - %small.light - = link_to @commit.short_id, project_commit_path(@project, @commit) - – - = truncate(@commit.title, length: 50) + %span.last-commit +   + %i.icon-angle-right +   + %small.light + = link_to @commit.short_id, project_commit_path(@project, @commit) + – + = truncate(@commit.title, length: 50) %th= link_to "history", project_commits_path(@project, @id), class: "pull-right" - if @path.present? diff --git a/app/views/projects/tree/_tree_commit_column.html.haml b/app/views/projects/tree/_tree_commit_column.html.haml index 67b5b2b96e..bd50dd4d9a 100644 --- a/app/views/projects/tree/_tree_commit_column.html.haml +++ b/app/views/projects/tree/_tree_commit_column.html.haml @@ -1,2 +1,3 @@ -%span.tree_author= commit_author_link(commit, avatar: true, size: 16) -= link_to_gfm truncate(commit.title, length: 80), project_commit_path(@project, commit.id), class: "tree-commit-link" +%span.str-truncated + %span.tree_author= commit_author_link(commit, avatar: true, size: 16) + = link_to_gfm commit.title, project_commit_path(@project, commit.id), class: "tree-commit-link" diff --git a/app/views/projects/tree/_tree_item.html.haml b/app/views/projects/tree/_tree_item.html.haml index f8856afc86..1b3900bcba 100644 --- a/app/views/projects/tree/_tree_item.html.haml +++ b/app/views/projects/tree/_tree_item.html.haml @@ -1,9 +1,8 @@ %tr{ class: "tree-item #{tree_hex_class(tree_item)}" } %td.tree-item-file-name = tree_icon(type) - %span= link_to truncate(tree_item.name, length: 40), project_tree_path(@project, tree_join(@id || @commit.id, tree_item.name)) + %span.str-truncated + = link_to tree_item.name, project_tree_path(@project, tree_join(@id || @commit.id, tree_item.name)) %td.tree_time_ago.cgray - %span.log_loading.hide - Loading commit data... - = image_tag "ajax_loader_tree.gif", width: 14 + = render 'spinner' %td.tree_commit{ colspan: 2 } diff --git a/app/views/projects/tree/show.html.haml b/app/views/projects/tree/show.html.haml index 0f7692aba7..6b33493b7d 100644 --- a/app/views/projects/tree/show.html.haml +++ b/app/views/projects/tree/show.html.haml @@ -1,4 +1,6 @@ %div.tree-ref-holder = render 'shared/ref_switcher', destination: 'tree', path: @path +- if can? current_user, :download_code, @project + = render 'projects/repositories/download_archive', ref: @ref, btn_class: 'btn-group-small tree-ref-holder pull-right', split_button: true %div#tree-holder.tree-holder = render "tree", tree: @tree diff --git a/app/views/projects/walls/show.html.haml b/app/views/projects/walls/show.html.haml index 88aecee081..3e3c7c4f8d 100644 --- a/app/views/projects/walls/show.html.haml +++ b/app/views/projects/walls/show.html.haml @@ -3,13 +3,13 @@ - if can? current_user, :write_note, @project .note-form-holder - = form_for [@project, @note], remote: true, html: { multipart: true, id: nil, class: "new_note wall-note-form" } do |f| + = form_for [@project, @note], remote: true, html: { multipart: true, id: nil, class: "new_note wall-note-form" }, authenticity_token: true do |f| = note_target_fields .note_text_and_preview = f.text_area :note, size: 255, class: 'note_text js-note-text js-gfm-input turn-on' .note-form-actions .buttons - = f.submit 'Add Comment', class: "btn comment-btn grouped js-comment-button" + = f.submit 'Add Comment', class: "btn comment-btn btn-grouped js-comment-button" .note-form-option %a.choose-btn.btn.btn-small.js-choose-note-attachment-button @@ -17,7 +17,7 @@ %span Choose File ...   %span.file_name.js-attachment-filename File name... - = f.file_field :attachment, class: "js-note-attachment-input hide" + = f.file_field :attachment, class: "js-note-attachment-input hidden" .hint.pull-right CTRL + Enter to send message .clearfix diff --git a/app/views/projects/wikis/_form.html.haml b/app/views/projects/wikis/_form.html.haml index 16061c9dcb..c77ed3433d 100644 --- a/app/views/projects/wikis/_form.html.haml +++ b/app/views/projects/wikis/_form.html.haml @@ -1,39 +1,39 @@ -= form_for [@project, @wiki] do |f| - -if @wiki.errors.any? += form_for [@project, @page], method: @page.persisted? ? :put : :post, html: { class: 'form-horizontal' } do |f| + -if @page.errors.any? #error_explanation - %h2= "#{pluralize(@wiki.errors.count, "error")} prohibited this wiki from being saved:" + %h2= "#{pluralize(@page.errors.count, "error")} prohibited this wiki from being saved:" %ul - - @wiki.errors.full_messages.each do |msg| + - @page.errors.full_messages.each do |msg| %li= msg - .ui-box.ui-box-show - .ui-box-head - %h3.page-title - .edit-wiki-header - = @wiki.title.titleize - = f.hidden_field :title, value: @wiki.title - = f.select :format, options_for_select(GollumWiki::MARKUPS, {selected: @wiki.format}), {}, class: "pull-right input-medium" - = f.label :format, class: "pull-right", style: "padding-right: 20px;" - .ui-box-body - .controls - %span.cgray - Wiki content is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. - To link to a (new) page you can just type - %code [Link Title](page-slug) - \. + = f.hidden_field :title, value: @page.title + .form-group + = f.label :format, class: 'control-label' + .col-sm-10 + = f.select :format, options_for_select(ProjectWiki::MARKUPS, {selected: @page.format}), {}, class: "form-control" + + .row + .col-sm-2 + .col-sm-10 + %p.cgray + Wiki content is parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. + To link to a (new) page you can just type + %code [Link Title](page-slug) + \. + + .form-group + = f.label :content, class: 'control-label' + .col-sm-10 + = f.text_area :content, class: 'form-control js-gfm-input', rows: 18 + + .form-group + = f.label :commit_message, class: 'control-label' + .col-sm-10= f.text_field :message, class: 'form-control', rows: 18 - .ui-box-bottom - .control-group - = f.label :content - .controls= f.text_area :content, class: 'span8 js-gfm-input' - .ui-box-bottom - .control-group - = f.label :commit_message - .controls= f.text_field :message, class: 'span8' .form-actions - - if @wiki && @wiki.persisted? + - if @page && @page.persisted? = f.submit 'Save changes', class: "btn-save btn" - = link_to "Cancel", project_wiki_path(@project, @wiki), class: "btn btn-cancel" + = link_to "Cancel", project_wiki_path(@project, @page), class: "btn btn-cancel" - else = f.submit 'Create page', class: "btn-create btn" = link_to "Cancel", project_wiki_path(@project, :home), class: "btn btn-cancel" diff --git a/app/views/projects/wikis/_main_links.html.haml b/app/views/projects/wikis/_main_links.html.haml index 1001bb10c4..68d7087323 100644 --- a/app/views/projects/wikis/_main_links.html.haml +++ b/app/views/projects/wikis/_main_links.html.haml @@ -1,8 +1,8 @@ %span.pull-right - - if (@wiki && @wiki.persisted?) - = link_to history_project_wiki_path(@project, @wiki), class: "btn grouped" do + - if (@page && @page.persisted?) + = link_to history_project_wiki_path(@project, @page), class: "btn btn-grouped" do Page History - if can?(current_user, :write_wiki, @project) - = link_to edit_project_wiki_path(@project, @wiki), class: "btn grouped" do + = link_to edit_project_wiki_path(@project, @page), class: "btn btn-grouped" do %i.icon-edit Edit diff --git a/app/views/projects/wikis/_new.html.haml b/app/views/projects/wikis/_new.html.haml index f64772b200..1ce292a02d 100644 --- a/app/views/projects/wikis/_new.html.haml +++ b/app/views/projects/wikis/_new.html.haml @@ -1,12 +1,14 @@ %div#modal-new-wiki.modal.hide - .modal-header - %a.close{href: "#", "data-dismiss" => "modal"} × - %h3.page-title New Wiki Page - .modal-body - = label_tag :new_wiki_path do - %span Page slug - = text_field_tag :new_wiki_path, nil, placeholder: 'how-to-setup', class: 'input-xlarge', required: true, :'data-wikis-path' => project_wikis_path(@project) - %p.hint - Please don't use spaces and slashes - .modal-footer - = link_to 'Build', '#', class: 'build-new-wiki btn btn-create' + .modal-dialog + .modal-content + .modal-header + %a.close{href: "#", "data-dismiss" => "modal"} × + %h3.page-title New Wiki Page + .modal-body + = label_tag :new_wiki_path do + %span Page slug + = text_field_tag :new_wiki_path, nil, placeholder: 'how-to-setup', class: 'form-control', required: true, :'data-wikis-path' => project_wikis_path(@project) + %p.hint + Please don't use spaces. + .modal-footer + = link_to 'Build', '#', class: 'build-new-wiki btn btn-create' diff --git a/app/views/projects/wikis/edit.html.haml b/app/views/projects/wikis/edit.html.haml index 66be82777c..5347caf000 100644 --- a/app/views/projects/wikis/edit.html.haml +++ b/app/views/projects/wikis/edit.html.haml @@ -1,10 +1,13 @@ = render 'nav' -%h3.page-title - Editing page +.pull-right = render 'main_links' +%h3.page-title + Editing - + %span.light #{@page.title} +%hr = render 'form' .pull-right - - if @wiki.persisted? && can?(current_user, :admin_wiki, @project) - = link_to project_wiki_path(@project, @wiki), confirm: "Are you sure you want to delete this page?", method: :delete, class: "btn btn-small btn-remove" do + - if @page.persisted? && can?(current_user, :admin_wiki, @project) + = link_to project_wiki_path(@project, @page), data: { confirm: "Are you sure you want to delete this page?"}, method: :delete, class: "btn btn-small btn-remove" do Delete this page diff --git a/app/views/projects/wikis/git_access.html.haml b/app/views/projects/wikis/git_access.html.haml index 692eda4e53..365edb524f 100644 --- a/app/views/projects/wikis/git_access.html.haml +++ b/app/views/projects/wikis/git_access.html.haml @@ -1,13 +1,12 @@ = render 'nav' -%h3.page-title - Git access for - %strong= @gollum_wiki.path_with_namespace +.row + .col-sm-6 + %h3.page-title + Git access for + %strong= @project_wiki.path_with_namespace - .form-horizontal.pull-right - .git-clone-holder - %button{class: "btn active", :"data-clone" => @gollum_wiki.ssh_url_to_repo} SSH - %button{class: "btn", :"data-clone" => @gollum_wiki.http_url_to_repo}= gitlab_config.protocol.upcase - = text_field_tag :project_clone, @gollum_wiki.url_to_repo, class: "one_click_select input-xxlarge", readonly: true + .col-sm-6 + = render "shared/clone_panel", project: @project_wiki .git-empty %fieldset @@ -19,8 +18,8 @@ %legend Clone Your Wiki: %pre.dark :preserve - git clone #{@gollum_wiki.ssh_url_to_repo} - cd #{@gollum_wiki.path} + git clone #{ content_tag(:span, default_url_to_repo(@project_wiki), class: 'clone')} + cd #{@project_wiki.path} %legend Start Gollum And Edit Locally: %pre.dark diff --git a/app/views/projects/wikis/history.html.haml b/app/views/projects/wikis/history.html.haml index 344a5e88e6..7bc566cf7f 100644 --- a/app/views/projects/wikis/history.html.haml +++ b/app/views/projects/wikis/history.html.haml @@ -1,9 +1,9 @@ = render 'nav' %h3.page-title %span.light History for - = link_to @wiki.title.titleize, project_wiki_path(@project, @wiki) + = link_to @page.title, project_wiki_path(@project, @page) -%table +%table.table %thead %tr %th Page version @@ -12,19 +12,18 @@ %th Last updated %th Format %tbody - - @wiki.versions.each do |version| + - @page.versions.each do |version| - commit = version %tr %td - = link_to project_wiki_path(@project, @wiki, version_id: commit.id) do + = link_to project_wiki_path(@project, @page, version_id: commit.id) do = commit.short_id %td = commit_author_link(commit, avatar: true, size: 24) %td = commit.title %td - = time_ago_in_words(version.date) - ago + #{time_ago_with_tooltip(version.date)} %td %strong - = @wiki.page.wiki.page(@wiki.page.name, commit.id).try(:format) + = @page.page.wiki.page(@page.page.name, commit.id).try(:format) diff --git a/app/views/projects/wikis/pages.html.haml b/app/views/projects/wikis/pages.html.haml index 59d104a985..74317faf9d 100644 --- a/app/views/projects/wikis/pages.html.haml +++ b/app/views/projects/wikis/pages.html.haml @@ -5,7 +5,8 @@ - @wiki_pages.each do |wiki_page| %li %h4 - = link_to wiki_page.title.titleize, project_wiki_path(@project, wiki_page) + = link_to wiki_page.title, project_wiki_path(@project, wiki_page) %small (#{wiki_page.format}) .pull-right - %small Last edited #{time_ago_in_words(wiki_page.commit.created_at)} ago + %small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)} += paginate @wiki_pages, theme: 'gitlab' diff --git a/app/views/projects/wikis/show.html.haml b/app/views/projects/wikis/show.html.haml index 63e7f12b7f..cb923e4ca3 100644 --- a/app/views/projects/wikis/show.html.haml +++ b/app/views/projects/wikis/show.html.haml @@ -1,15 +1,20 @@ = render 'nav' %h3.page-title - = @wiki.title.titleize + = @page.title = render 'main_links' -- if @wiki.historical? +- if @page.historical? .warning_message This is an old version of this page. - You can view the #{link_to "most recent version", project_wiki_path(@project, @wiki)} or browse the #{link_to "history", history_project_wiki_path(@project, @wiki)}. + You can view the #{link_to "most recent version", project_wiki_path(@project, @page)} or browse the #{link_to "history", history_project_wiki_path(@project, @page)}. -.file-holder - .file-content.wiki +%hr + +.wiki-holder + .wiki = preserve do - = render_wiki_content(@wiki) + = render_wiki_content(@page) -%p.time Last edited by #{commit_author_link(@wiki.commit, avatar: true, size: 16)} #{time_ago_in_words @wiki.commit.created_at} ago +%hr + +.wiki-last-edit-by + Last edited by #{commit_author_link(@page.commit, avatar: true, size: 16)} #{time_ago_with_tooltip(@page.commit.created_at)} diff --git a/app/views/public/projects/index.html.haml b/app/views/public/projects/index.html.haml index 21aee64457..624ec0b9b9 100644 --- a/app/views/public/projects/index.html.haml +++ b/app/views/public/projects/index.html.haml @@ -1,16 +1,38 @@ -.row - .span6 - %h3.page-title - Projects (#{@projects.total_count}) - .light - You can browse public projects in read-only mode until signed in. +%h3.page-title + Projects (#{@projects.total_count}) +.light + You can browse public projects in read-only mode until signed in. +%hr +.clearfix + .pull-left + = form_tag public_projects_path, method: :get, class: 'form-inline form-tiny' do |f| + .form-group + = search_field_tag :search, params[:search], placeholder: "Filter by name", class: "form-control search-text-input input-mn-300", id: "projects_search" + .form-group + = submit_tag 'Search', class: "btn btn-primary wide" + + .pull-right + .dropdown.inline + %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"} + %span.light sort: + - if @sort.present? + = @sort.humanize + - else + Name + %b.caret + %ul.dropdown-menu + %li + = link_to public_projects_path(sort: nil) do + Name + = link_to public_projects_path(sort: 'newest') do + Newest + = link_to public_projects_path(sort: 'oldest') do + Oldest + = link_to public_projects_path(sort: 'recently_updated') do + Recently updated + = link_to public_projects_path(sort: 'last_updated') do + Last updated - .span6 - .pull-right - = form_tag public_projects_path, method: :get, class: 'form-inline' do |f| - .search-holder - = search_field_tag :search, params[:search], placeholder: "Filter by name", class: "span3 search-text-input", id: "projects_search" - = submit_tag 'Search', class: "btn btn-primary wide" %hr .public-projects %ul.bordered-list.top-list @@ -19,6 +41,10 @@ %h4 = link_to project_path(project) do = project.name_with_namespace + - if project.internal? + %small.access-icon + = internal_icon + Internal .pull-right %pre.public-clone git clone #{project.http_url_to_repo} @@ -37,6 +63,6 @@ %i.icon-warning-sign Empty repository - unless @projects.present? - %h3.nothing_here_message No public projects + .nothing-here-block No public projects = paginate @projects, theme: "gitlab" diff --git a/app/views/search/_filter.html.haml b/app/views/search/_filter.html.haml index f7a00b2348..979b18e385 100644 --- a/app/views/search/_filter.html.haml +++ b/app/views/search/_filter.html.haml @@ -9,7 +9,7 @@ %b.caret %ul.dropdown-menu %li - = link_to search_path(group_id: nil) do + = link_to search_path(group_id: nil, search: params[:search]) do Any - current_user.authorized_groups.sort_by(&:name).each do |group| %li @@ -27,7 +27,7 @@ %b.caret %ul.dropdown-menu %li - = link_to search_path(project_id: nil) do + = link_to search_path(project_id: nil, search: params[:search]) do Any - current_user.authorized_projects.sort_by(&:name_with_namespace).each do |project| %li diff --git a/app/views/search/_global_results.html.haml b/app/views/search/_global_results.html.haml new file mode 100644 index 0000000000..7f4f0e5e00 --- /dev/null +++ b/app/views/search/_global_results.html.haml @@ -0,0 +1,5 @@ +.search_results + %ul.bordered-list + = render partial: "search/results/project", collection: @search_results[:projects] + = render partial: "search/results/merge_request", collection: @search_results[:merge_requests] + = render partial: "search/results/issue", collection: @search_results[:issues] diff --git a/app/views/search/_project_results.html.haml b/app/views/search/_project_results.html.haml new file mode 100644 index 0000000000..f285bda573 --- /dev/null +++ b/app/views/search/_project_results.html.haml @@ -0,0 +1,17 @@ +%ul.nav.nav-tabs + %li{class: ("active" if params[:search_code].present?)} + = link_to search_path(params.merge(search_code: true)) do + Repository Code + %li{class: ("active" if params[:search_code].blank?)} + = link_to search_path(params.merge(search_code: nil)) do + Issues and Merge requests + +.search_results + - if params[:search_code].present? + .blob-results + = render partial: "search/results/blob", collection: @search_results[:blobs] + = paginate @search_results[:blobs], theme: 'gitlab' + - else + %ul.bordered-list + = render partial: "search/results/merge_request", collection: @search_results[:merge_requests] + = render partial: "search/results/issue", collection: @search_results[:issues] diff --git a/app/views/search/_result.html.haml b/app/views/search/_result.html.haml deleted file mode 100644 index a55ac1a759..0000000000 --- a/app/views/search/_result.html.haml +++ /dev/null @@ -1,73 +0,0 @@ -%fieldset - %legend - Search results - %span.cgray (#{@total_results}) - -- if @project - %ul.nav.nav-pills - %li{class: ("active" if params[:search_code].present?)} - = link_to search_path(params.merge(search_code: true)) do - Repository Code - %li{class: ("active" if params[:search_code].blank?)} - = link_to search_path(params.merge(search_code: nil)) do - Everything else - -.search_results - %ul.bordered-list - - @projects.each do |project| - %li - project: - = link_to project do - %strong.term= project.name_with_namespace - - @merge_requests.each do |merge_request| - %li - merge request: - = link_to [merge_request.target_project, merge_request] do - %span ##{merge_request.iid} - %strong.term - = truncate merge_request.title, length: 50 - - if merge_request.for_fork? - %span.light (#{merge_request.source_project.name_with_namespace}:#{merge_request.source_branch} → #{merge_request.target_project.name_with_namespace}:#{merge_request.target_branch}) - - else - %span.light (#{merge_request.source_branch} → #{merge_request.target_branch}) - - if merge_request.closed? - %span.label Closed - - - @issues.each do |issue| - %li - issue: - = link_to [issue.project, issue] do - %span ##{issue.iid} - %strong.term - = truncate issue.title, length: 50 - %span.light (#{issue.project.name_with_namespace}) - - if issue.closed? - %span.label Closed - - - @notes.each do |note| - %li - note on issue: - = link_to [note.project, note.noteable] do - %span ##{note.noteable.iid} - %strong.term - = truncate note.noteable.title, length: 50 - %span.light (#{note.project.name_with_namespace}) - - if note.noteable.closed? - %span.label Closed - - - @wiki_pages.each do |wiki_page| - %li - wiki: - = link_to project_wiki_path(wiki_page.project, wiki_page) do - %strong.term - = truncate wiki_page.title, length: 50 - %span.light (#{wiki_page.project.name_with_namespace}) - - - @blobs.each do |blob| - = render 'blob', blob: blob - - = paginate @blobs, theme: 'gitlab' - -:javascript - $(".search_results .term").highlight("#{escape_javascript(params[:search])}"); - diff --git a/app/views/search/_results.html.haml b/app/views/search/_results.html.haml new file mode 100644 index 0000000000..2336d0f71d --- /dev/null +++ b/app/views/search/_results.html.haml @@ -0,0 +1,17 @@ +%h4 + #{@search_results[:total_results]} results found + - if @project + for #{link_to @project.name_with_namespace, @project} + - elsif @group + for #{link_to @group.name, @group} + +%hr + +- if @project + = render "project_results" +- else + = render "global_results" + +:javascript + $(".search_results .term").highlight("#{escape_javascript(params[:search])}"); + diff --git a/app/views/search/_blob.html.haml b/app/views/search/results/_blob.html.haml similarity index 62% rename from app/views/search/_blob.html.haml rename to app/views/search/results/_blob.html.haml index 559fdd794f..f9d217e840 100644 --- a/app/views/search/_blob.html.haml +++ b/app/views/search/results/_blob.html.haml @@ -1,4 +1,4 @@ -%li +.blob-result .file-holder .file-title = link_to project_blob_path(@project, tree_join(blob.ref, blob.filename), :anchor => "L" + blob.startline.to_s) do @@ -6,5 +6,4 @@ %strong = blob.filename .file-content.code.term - %div{class: user_color_scheme_class} - = raw blob.colorize( formatter: :gitlab, options: { first_line_number: blob.startline } ) + = render 'shared/file_hljs', blob: blob, first_line_number: blob.startline diff --git a/app/views/search/results/_issue.html.haml b/app/views/search/results/_issue.html.haml new file mode 100644 index 0000000000..7a24b76bce --- /dev/null +++ b/app/views/search/results/_issue.html.haml @@ -0,0 +1,9 @@ +%li + issue: + = link_to [issue.project, issue] do + %span ##{issue.iid} + %strong.term + = truncate issue.title, length: 50 + %span.light (#{issue.project.name_with_namespace}) + - if issue.closed? + %span.label Closed diff --git a/app/views/search/results/_merge_request.html.haml b/app/views/search/results/_merge_request.html.haml new file mode 100644 index 0000000000..22d7587f6c --- /dev/null +++ b/app/views/search/results/_merge_request.html.haml @@ -0,0 +1,12 @@ +%li + merge request: + = link_to [merge_request.target_project, merge_request] do + %span ##{merge_request.iid} + %strong.term + = truncate merge_request.title, length: 50 + - if merge_request.for_fork? + %span.light (#{merge_request.source_project.name_with_namespace}:#{merge_request.source_branch} → #{merge_request.target_project.name_with_namespace}:#{merge_request.target_branch}) + - else + %span.light (#{merge_request.source_branch} → #{merge_request.target_branch}) + - if merge_request.closed? + %span.label Closed diff --git a/app/views/search/results/_project.html.haml b/app/views/search/results/_project.html.haml new file mode 100644 index 0000000000..abc86c72be --- /dev/null +++ b/app/views/search/results/_project.html.haml @@ -0,0 +1,7 @@ +%li + project: + = link_to project do + %strong.term= project.name_with_namespace + - if project.description.present? + – + %span.light.term= project.description diff --git a/app/views/search/show.html.haml b/app/views/search/show.html.haml index f1f65981b3..3b6f10d4d9 100644 --- a/app/views/search/show.html.haml +++ b/app/views/search/show.html.haml @@ -1,16 +1,20 @@ -= form_tag search_path, method: :get, class: 'form-inline' do |f| - .search-holder - = label_tag :search do - %span Looking for - .controls - = search_field_tag :search, params[:search], placeholder: "issue 143", class: "input-xxlarge search-text-input", id: "dashboard_search" += form_tag search_path, method: :get, class: 'form-horizontal' do |f| + .search-holder.clearfix + .form-group + = label_tag :search, class: 'control-label' do + %span Looking for + .col-sm-6 + = search_field_tag :search, params[:search], placeholder: "issue 143", class: "form-control search-text-input", id: "dashboard_search" + .col-sm-4 + = submit_tag 'Search', class: "btn btn-create" + .form-group + .col-sm-2 + .col-sm-10 + = render 'filter', f: f = hidden_field_tag :project_id, params[:project_id] = hidden_field_tag :group_id, params[:group_id] = hidden_field_tag :search_code, params[:search_code] - = submit_tag 'Search', class: "btn btn-create" - .prepend-top-10 - = render 'filter', f: f .results.prepend-top-10 - if params[:search].present? - = render 'search/result' + = render 'search/results' diff --git a/app/views/shared/_clone_panel.html.haml b/app/views/shared/_clone_panel.html.haml index ac7b9ee7f2..8cd426c71e 100644 --- a/app/views/shared/_clone_panel.html.haml +++ b/app/views/shared/_clone_panel.html.haml @@ -1,4 +1,6 @@ -.git-clone-holder - %button{class: "btn active", :"data-clone" => @project.ssh_url_to_repo} SSH - %button{class: "btn", :"data-clone" => @project.http_url_to_repo}= gitlab_config.protocol.upcase - = text_field_tag :project_clone, @project.url_to_repo, class: "one_click_select span5", readonly: true +- project = project || @project +.git-clone-holder.input-group + .input-group-btn + %button{class: "btn #{ 'active' if default_clone_protocol == 'ssh' }", :"data-clone" => project.ssh_url_to_repo} SSH + %button{class: "btn #{ 'active' if default_clone_protocol == 'http' }", :"data-clone" => project.http_url_to_repo}= gitlab_config.protocol.upcase + = text_field_tag :project_clone, default_url_to_repo(project), class: "one_click_select form-control", readonly: true diff --git a/app/views/shared/_commit_message_container.html.haml b/app/views/shared/_commit_message_container.html.haml new file mode 100644 index 0000000000..cca7a0efc9 --- /dev/null +++ b/app/views/shared/_commit_message_container.html.haml @@ -0,0 +1,5 @@ +.commit-message-container + .max-width-marker + -# When the `ch` CSS length unit becomes widely supported `http://www.quirksmode.org/css/units-values` remove this workaround. + = 'a' * 72 + = textarea diff --git a/app/views/shared/_file_hljs.html.haml b/app/views/shared/_file_hljs.html.haml new file mode 100644 index 0000000000..338236c075 --- /dev/null +++ b/app/views/shared/_file_hljs.html.haml @@ -0,0 +1,12 @@ +%div.highlighted-data{class: user_color_scheme_class} + .line-numbers + - blob.data.lines.to_a.size.times do |index| + - offset = defined?(first_line_number) ? first_line_number : 1 + - i = index + offset + = link_to "#L#{i}", id: "L#{i}", rel: "#L#{i}" do + %i.icon-link + = i + .highlight + %pre + %code + = blob.data diff --git a/app/views/shared/_filter.html.haml b/app/views/shared/_filter.html.haml index 2f051cea48..0becf531cc 100644 --- a/app/views/shared/_filter.html.haml +++ b/app/views/shared/_filter.html.haml @@ -1,29 +1,44 @@ -= form_tag filter_path(entity), method: 'get' do - %fieldset - %ul.nav.nav-pills.nav-stacked - %li{class: ("active" if params[:status].blank?)} - = link_to filter_path(entity, status: nil) do - Open - %li{class: ("active" if params[:status] == 'closed')} - = link_to filter_path(entity, status: 'closed') do - Closed - %li{class: ("active" if params[:status] == 'all')} - = link_to filter_path(entity, status: 'all') do - All +.side-filters.hidden-xs.hidden-sm + = form_tag filter_path(entity), method: 'get' do + - if current_user + %fieldset.scope-filter + %ul.nav.nav-pills.nav-stacked + %li{class: ("active" if params[:scope] == 'assigned-to-me')} + = link_to filter_path(entity, scope: 'assigned-to-me') do + Assigned to me + %li{class: ("active" if params[:scope] == 'authored')} + = link_to filter_path(entity, scope: 'authored') do + Created by me + %li{class: ("active" if params[:scope] == 'all')} + = link_to filter_path(entity, scope: 'all') do + Everyone's - %fieldset - %legend Projects - %ul.nav.nav-pills.nav-pills-small.nav-stacked - - @projects.each do |project| - - unless entities_per_project(project, entity).zero? - %li{class: ("active" if params[:project_id] == project.id.to_s)} - = link_to filter_path(entity, project_id: project.id) do - = project.name_with_namespace - %small.pull-right= entities_per_project(project, entity) + %fieldset.status-filter + %legend State + %ul.nav.nav-pills + %li{class: ("active" if params[:state] == 'opened')} + = link_to filter_path(entity, state: 'opened') do + Open + %li{class: ("active" if params[:state] == 'closed')} + = link_to filter_path(entity, state: 'closed') do + Closed + %li{class: ("active" if params[:state] == 'all')} + = link_to filter_path(entity, state: 'all') do + All - %fieldset - - if params[:status].present? || params[:project_id].present? - = link_to filter_path(entity, status: nil, project_id: nil), class: 'pull-right cgray' do - %i.icon-remove - %strong Clear filter + %fieldset + %legend Projects + %ul.nav.nav-pills.nav-stacked.nav-small + - @projects.each do |project| + - unless entities_per_project(project, entity).zero? + %li{class: ("active" if params[:project_id] == project.id.to_s)} + = link_to filter_path(entity, project_id: project.id) do + = project.name_with_namespace + %small.pull-right= entities_per_project(project, entity) + + %fieldset + - if params[:state].present? || params[:project_id].present? + = link_to filter_path(entity, state: nil, project_id: nil), class: 'pull-right cgray' do + %i.icon-remove + %strong Clear filter diff --git a/app/views/shared/_issues.html.haml b/app/views/shared/_issues.html.haml index 3b3888a50e..087b6632e8 100644 --- a/app/views/shared/_issues.html.haml +++ b/app/views/shared/_issues.html.haml @@ -1,6 +1,6 @@ - if @issues.any? - @issues.group_by(&:project).each do |group| - .ui-box.small-box + .ui-box.ui-box-small - project = group[0] .title = link_to_project project @@ -11,5 +11,5 @@ = render 'projects/issues/issue', issue: issue = paginate @issues, theme: "gitlab" - else - %p.nothing_here_message No issues to show + .nothing-here-block No issues to show diff --git a/app/views/shared/_merge_requests.html.haml b/app/views/shared/_merge_requests.html.haml index b7a7ca8fcc..f40b7be486 100644 --- a/app/views/shared/_merge_requests.html.haml +++ b/app/views/shared/_merge_requests.html.haml @@ -1,13 +1,14 @@ - if @merge_requests.any? - @merge_requests.group_by(&:target_project).each do |group| - .ui-box.small-box + .ui-box.ui-box-small - project = group[0] .title = link_to_project project + = link_to 'show all', project_merge_requests_path(project), class: 'pull-right' %ul.well-list.mr-list - group[1].each do |merge_request| = render 'projects/merge_requests/merge_request', merge_request: merge_request = paginate @merge_requests, theme: "gitlab" - else - %h3.nothing_here_message No merge requests to show + .nothing-here-block No merge requests to show diff --git a/app/views/shared/_no_ssh.html.haml b/app/views/shared/_no_ssh.html.haml index 6d363807d6..e70eb4d01b 100644 --- a/app/views/shared/_no_ssh.html.haml +++ b/app/views/shared/_no_ssh.html.haml @@ -1,3 +1,14 @@ -- if current_user.require_ssh_key? && alert.blank? && notice.blank? - %p.error-message.centered - You won't be able to pull or push project code via SSH until you #{link_to 'add an SSH key', new_profile_key_path} to your profile +- if cookies[:hide_no_ssh_message].blank? && current_user.require_ssh_key? && !current_user.hide_no_ssh_key + .no-ssh-key-message + .container + You won't be able to pull or push project code via SSH until you #{link_to 'add an SSH key', new_profile_key_path} to your profile + .pull-right.hidden-xs + = link_to "Don't show again", profile_path(user: {hide_no_ssh_key: true}), method: :put, class: 'hide-no-ssh-message', remote: true + | + = link_to 'Remind later', '#', class: 'hide-no-ssh-message' + .links-xs.visible-xs + = link_to "Add key", new_profile_key_path + | + = link_to "Don't show again", profile_path(user: {hide_no_ssh_key: true}), method: :put, class: 'hide-no-ssh-message', remote: true + | + = link_to 'Later', '#', class: 'hide-no-ssh-message' diff --git a/app/views/shared/_project_filter.html.haml b/app/views/shared/_project_filter.html.haml index f3d032ef98..7936a038be 100644 --- a/app/views/shared/_project_filter.html.haml +++ b/app/views/shared/_project_filter.html.haml @@ -1,32 +1,55 @@ -= form_tag project_entities_path, method: 'get' do - %fieldset +.side-filters.hidden-xs.hidden-sm + = form_tag project_entities_path, method: 'get' do - if current_user - %ul.nav.nav-pills.nav-stacked - %li{class: ("active" if params[:scope].blank?)} - = link_to project_filter_path(scope: nil) do - Everyone's - %li{class: ("active" if params[:scope] == 'assigned-to-me')} - = link_to project_filter_path(scope: 'assigned-to-me') do - Assigned to me - %li{class: ("active" if params[:scope] == 'created-by-me')} - = link_to project_filter_path(scope: 'created-by-me') do - Created by me + %fieldset + %ul.nav.nav-pills.nav-stacked + %li{class: ("active" if params[:scope] == 'all')} + = link_to project_filter_path(scope: 'all') do + Everyone's + %li{class: ("active" if params[:scope] == 'assigned-to-me')} + = link_to project_filter_path(scope: 'assigned-to-me') do + Assigned to me + %li{class: ("active" if params[:scope] == 'created-by-me')} + = link_to project_filter_path(scope: 'created-by-me') do + Created by me - %ul.nav.nav-pills.nav-stacked - %li{class: ("active" if params[:state].blank?)} - = link_to project_filter_path(state: nil) do - Open - %li{class: ("active" if params[:state] == 'closed')} - = link_to project_filter_path(state: 'closed') do - Closed - %li{class: ("active" if params[:state] == 'all')} - = link_to project_filter_path(state: 'all') do - All + %fieldset + %legend State + %ul.nav.nav-pills + %li{class: ("active" if params[:state] == 'opened')} + = link_to project_filter_path(state: 'opened') do + Open + %li{class: ("active" if params[:state] == 'closed')} + = link_to project_filter_path(state: 'closed') do + Closed + %li{class: ("active" if params[:state] == 'all')} + = link_to project_filter_path(state: 'all') do + All - %fieldset - - if %w(state scope milestone_id assignee_id label_name).select { |k| params[k].present? }.any? - = link_to project_entities_path, class: 'cgray pull-right' do - %i.icon-remove - %strong Clear filter + - if defined?(labels) + %fieldset + %legend Labels + %ul.nav.nav-pills.nav-stacked.nav-small.labels-filter + - issue_label_names.each do |label_name| + %li{class: label_filter_class(label_name)} + = link_to labels_filter_path(label_name) do + %span{class: "label #{label_css_class(label_name)}"} + %i.icon-tag + = label_name + - if selected_label?(label_name) + .pull-right + %i.icon-remove + + - if issue_label_names.empty? + .light-well + Add first label to your issues + %br + or #{link_to 'generate', generate_project_labels_path(@project, redirect: redirect), method: :post} default set of labels + + %fieldset + - if %w(state scope milestone_id assignee_id label_name).select { |k| params[k].present? }.any? + = link_to project_entities_path, class: 'cgray pull-right' do + %i.icon-remove + %strong Clear filter diff --git a/app/views/shared/_promo.html.haml b/app/views/shared/_promo.html.haml index c97f8ba0f0..7dec48e658 100644 --- a/app/views/shared/_promo.html.haml +++ b/app/views/shared/_promo.html.haml @@ -1,4 +1,4 @@ .gitlab-promo - = link_to "Homepage", "http://gitlab.org" - = link_to "Blog", "http://blog.gitlab.org" + = link_to "Homepage", "https://www.gitlab.com/" + = link_to "Blog", "https://www.gitlab.com/blog/" = link_to "@gitlabhq", "https://twitter.com/gitlabhq" diff --git a/app/views/shared/_ref_switcher.html.haml b/app/views/shared/_ref_switcher.html.haml index dc8c656e12..4d9534f49b 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" + = select_tag "ref", grouped_options_refs, class: "project-refs-select select2 select2-sm" = hidden_field_tag :destination, destination - if defined?(path) = hidden_field_tag :path, path diff --git a/app/views/shared/_sort_dropdown.html.haml b/app/views/shared/_sort_dropdown.html.haml new file mode 100644 index 0000000000..7b37b39780 --- /dev/null +++ b/app/views/shared/_sort_dropdown.html.haml @@ -0,0 +1,22 @@ +.dropdown.inline.prepend-left-10 + %a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"} + %span.light sort: + - if @sort.present? + = @sort + - else + Newest + %b.caret + %ul.dropdown-menu + %li + = link_to project_filter_path(sort: 'newest') do + Newest + = link_to project_filter_path(sort: 'oldest') do + Oldest + = link_to project_filter_path(sort: 'recently_updated') do + Recently updated + = link_to project_filter_path(sort: 'last_updated') do + Last updated + = link_to project_filter_path(sort: 'milestone_due_soon') do + Milestone due soon + = link_to project_filter_path(sort: 'milestone_due_later') do + Milestone due later diff --git a/app/views/snippets/_blob.html.haml b/app/views/snippets/_blob.html.haml index c2e0d97a11..15867f071e 100644 --- a/app/views/snippets/_blob.html.haml +++ b/app/views/snippets/_blob.html.haml @@ -6,11 +6,6 @@ .btn-group.tree-btn-group.pull-right - if @snippet.author == current_user = link_to "Edit", edit_snippet_path(@snippet), class: "btn btn-tiny", title: 'Edit Snippet' - = link_to "Delete", snippet_path(@snippet), method: :delete, confirm: "Are you sure?", class: "btn btn-tiny", title: 'Delete Snippet' + = link_to "Delete", snippet_path(@snippet), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-tiny", title: 'Delete Snippet' = link_to "Raw", raw_snippet_path(@snippet), class: "btn btn-tiny", target: "_blank" - .file-content.code - - unless @snippet.content.empty? - %div{class: user_color_scheme_class} - = raw @snippet.colorize(formatter: :gitlab) - - else - %p.nothing_here_message Empty file + = render 'snippets/blob_content' diff --git a/app/views/snippets/_blob_content.html.haml b/app/views/snippets/_blob_content.html.haml new file mode 100644 index 0000000000..8cec6168ab --- /dev/null +++ b/app/views/snippets/_blob_content.html.haml @@ -0,0 +1,14 @@ +- unless @snippet.content.empty? + - if gitlab_markdown?(@snippet.file_name) + .file-content.wiki + = preserve do + = markdown(@snippet.data) + - elsif markup?(@snippet.file_name) + .file-content.wiki + = render_markup(@snippet.file_name, @snippet.data) + - else + .file-content.code + = render 'shared/file_hljs', blob: @snippet +- else + .file-content.code + .nothing-here-block Empty file diff --git a/app/views/snippets/_form.html.haml b/app/views/snippets/_form.html.haml index e77550e7be..d466dc1af1 100644 --- a/app/views/snippets/_form.html.haml +++ b/app/views/snippets/_form.html.haml @@ -2,27 +2,38 @@ = @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}" %hr .snippet-form-holder - = form_for @snippet, as: :personal_snippet, url: url do |f| + = form_for @snippet, as: :personal_snippet, url: url, html: { class: "form-horizontal snippet-form" } do |f| -if @snippet.errors.any? - .alert.alert-error + .alert.alert-danger %ul - @snippet.errors.full_messages.each do |msg| %li= msg - .control-group - = f.label :title - .controls= f.text_field :title, placeholder: "Example Snippet", class: 'input-xlarge', required: true - .control-group - = f.label "Private?" - .controls - = f.check_box :private, {class: ''} - .control-group + .form-group + = f.label :title, class: 'control-label' + .col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true + .form-group + = f.label "Access", class: 'control-label' + .col-sm-10 + = f.label :private_true, class: 'radio-label' do + = f.radio_button :private, true + %span + %strong Private + (only you can see this snippet) + %br + = f.label :private_false, class: 'radio-label' do + = f.radio_button :private, false + %span + %strong Public + (GitLab users can see this snippet) + + .form-group .file-editor - = f.label :file_name, "File" - .controls + = f.label :file_name, "File", class: 'control-label' + .col-sm-10 .file-holder.snippet .file-title - = f.text_field :file_name, placeholder: "example.rb", class: 'snippet-file-name', required: true + = f.text_field :file_name, placeholder: "example.rb", class: 'form-control snippet-file-name', required: true .file-content.code %pre#editor= @snippet.content = f.hidden_field :content, class: 'snippet-file-content' @@ -33,9 +44,10 @@ - else = f.submit 'Save', class: "btn-save btn" - = link_to "Cancel", snippets_path(@project), class: "btn btn-cancel" - unless @snippet.new_record? - .pull-right= link_to 'Destroy', snippet_path(@snippet), confirm: 'Removed snippet cannot be restored! Are you sure?', method: :delete, class: "btn pull-right danger delete-snippet", id: "destroy_snippet_#{@snippet.id}" + .pull-right.prepend-left-20 + = link_to 'Remove', snippet_path(@snippet), data: { confirm: 'Removed snippet cannot be restored! Are you sure?'}, method: :delete, class: "btn btn-remove delete-snippet", id: "destroy_snippet_#{@snippet.id}" + = link_to "Cancel", snippets_path(@project), class: "btn btn-cancel" :javascript diff --git a/app/views/snippets/_snippet.html.haml b/app/views/snippets/_snippet.html.haml index 8514bc3ddd..e6f8316733 100644 --- a/app/views/snippets/_snippet.html.haml +++ b/app/views/snippets/_snippet.html.haml @@ -3,7 +3,7 @@ = link_to reliable_snippet_path(snippet) do = truncate(snippet.title, length: 60) - if snippet.private? - %span.label.label-success + %span.label.label-gray %i.icon-lock private %span.cgray.monospace.tiny.pull-right @@ -20,4 +20,4 @@ = link_to user_snippets_path(snippet.author) do = image_tag avatar_icon(snippet.author_email), class: "avatar avatar-inline s16", alt: '' = snippet.author_name - %span.light #{time_ago_in_words(snippet.created_at)} ago + %span.light #{time_ago_with_tooltip(snippet.created_at)} diff --git a/app/views/snippets/_snippets.html.haml b/app/views/snippets/_snippets.html.haml index 05365dd8b8..40df42b6cf 100644 --- a/app/views/snippets/_snippets.html.haml +++ b/app/views/snippets/_snippets.html.haml @@ -2,6 +2,6 @@ = render partial: 'snippet', collection: @snippets - if @snippets.empty? %li - %h3.nothing_here_message Nothing here. + .nothing-here-block Nothing here. = paginate @snippets, theme: 'gitlab' diff --git a/app/views/snippets/current_user_index.html.haml b/app/views/snippets/current_user_index.html.haml index 51030f965a..90ddc7198f 100644 --- a/app/views/snippets/current_user_index.html.haml +++ b/app/views/snippets/current_user_index.html.haml @@ -1,9 +1,9 @@ %h3.page-title My Snippets .pull-right - = link_to new_snippet_path, class: "btn btn-new grouped", title: "New Snippet" do + = link_to new_snippet_path, class: "btn btn-new btn-grouped", title: "New Snippet" do Add new snippet - = link_to snippets_path, class: "btn grouped" do + = link_to snippets_path, class: "btn btn-grouped" do Discover snippets %p.light @@ -11,7 +11,7 @@ %hr .row - .span3 + .col-md-3 %ul.nav.nav-pills.nav-stacked = nav_tab :scope, nil do = link_to user_snippets_path(@user) do @@ -29,6 +29,6 @@ %span.pull-right = @user.snippets.public.count - .span9.my-snippets + .col-md-9.my-snippets = render 'snippets' diff --git a/app/views/snippets/index.html.haml b/app/views/snippets/index.html.haml index 2f6c914a15..cea2517a8e 100644 --- a/app/views/snippets/index.html.haml +++ b/app/views/snippets/index.html.haml @@ -2,9 +2,9 @@ Public snippets .pull-right - = link_to new_snippet_path, class: "btn btn-new grouped", title: "New Snippet" do + = link_to new_snippet_path, class: "btn btn-new btn-grouped", title: "New Snippet" do Add new snippet - = link_to user_snippets_path(current_user), class: "btn grouped" do + = link_to user_snippets_path(current_user), class: "btn btn-grouped" do My snippets %p.light diff --git a/app/views/users/_groups.html.haml b/app/views/users/_groups.html.haml new file mode 100644 index 0000000000..412df943fc --- /dev/null +++ b/app/views/users/_groups.html.haml @@ -0,0 +1,3 @@ +- groups.each do |group| + = link_to group, class: 'profile-groups-avatars', :title => group.name do + = image_tag group_icon(group.path) \ No newline at end of file diff --git a/app/views/users/_profile.html.haml b/app/views/users/_profile.html.haml index 4cd1eebdf9..7ffd43e837 100644 --- a/app/views/users/_profile.html.haml +++ b/app/views/users/_profile.html.haml @@ -8,7 +8,7 @@ - unless user.skype.blank? %li %span.light Skype: - %strong= user.skype + %strong= link_to user.skype, "skype:#{user.skype}" - unless user.linkedin.blank? %li %span.light LinkedIn: @@ -16,7 +16,11 @@ - unless user.twitter.blank? %li %span.light Twitter: - %strong= user.twitter + %strong= link_to user.twitter, "http://www.twitter.com/#{user.twitter}" + - unless user.website_url.blank? + %li + %span.light Website: + %strong= link_to user.short_website_url, user.full_website_url - unless user.bio.blank? %li %span.light Bio: diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 53a0a9232a..edcaf3acf9 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -1,5 +1,5 @@ .row - .span8 + .col-md-8 %h3.page-title = image_tag avatar_icon(@user.email, 90), class: "avatar s90", alt: '' = @user.name @@ -9,13 +9,15 @@ %i.icon-edit Edit Profile settings %br - %small #{@user.username} + %span.user-show-username #{@user.username} %br %small member since #{@user.created_at.stamp("Nov 12, 2031")} .clearfix + %h4 Groups: + = render 'groups', groups: @groups %hr %h4 User Activity: = render @events - .span4 + .col-md-4 = render 'profile', user: @user - = render 'projects', user: @user + = render 'projects' diff --git a/app/views/users_groups/_users_group.html.haml b/app/views/users_groups/_users_group.html.haml index 5934ff72e8..ad363eaba2 100644 --- a/app/views/users_groups/_users_group.html.haml +++ b/app/views/users_groups/_users_group.html.haml @@ -1,23 +1,31 @@ - user = member.user - return unless user +- show_roles = true if show_roles.nil? %li{class: "#{dom_class(member)} js-toggle-container", id: dom_id(member)} - = image_tag avatar_icon(user.email, 16), class: "avatar s16" - %strong= user.name - %span.cgray= user.username - - if user == current_user - %span.label.label-success It's you + %span{class: ("list-item-name" if show_controls)} + = image_tag avatar_icon(user.email, 16), class: "avatar s16" + %strong= user.name + %span.cgray= user.username + - if user == current_user + %span.label.label-success It's you - %span.pull-right - %strong= member.human_access + - if show_roles + %span.pull-right + %strong= member.human_access + - if show_controls + - if can?(current_user, :modify, member) + = link_to '#', class: "btn-tiny btn js-toggle-button", title: 'Edit access level' do + %i.icon-edit + - if can?(current_user, :destroy, member) + - if current_user == member.user + = link_to leave_profile_group_path(@group), data: { confirm: leave_group_message(@group.name)}, method: :delete, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do + %i.icon-minus.icon-white + - else + = link_to group_users_group_path(@group, member), data: { confirm: remove_user_from_group_message(@group, user) }, method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do + %i.icon-minus.icon-white - - if show_controls && can?(current_user, :manage_group, @group) && current_user != user - = link_to '#', class: "btn-tiny btn js-toggle-button", title: 'Edit access level' do - %i.icon-edit - = link_to group_users_group_path(@group, member), confirm: remove_user_from_group_message(@group, user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do - %i.icon-minus.icon-white - - .edit-member.hide.js-toggle-content - = form_for [@group, member], remote: true do |f| - .alert.prepend-top-20 - = f.select :group_access, options_for_select(UsersGroup.group_access_roles, member.group_access) - = f.submit 'Save', class: 'btn btn-save btn-small' + .edit-member.hide.js-toggle-content + = form_for [@group, member], remote: true do |f| + .alert.prepend-top-20 + = f.select :group_access, options_for_select(UsersGroup.group_access_roles, member.group_access) + = f.submit 'Save', class: 'btn btn-save btn-small' diff --git a/app/views/votes/_votes_block.html.haml b/app/views/votes/_votes_block.html.haml index bded53b2f2..788d9065a7 100644 --- a/app/views/votes/_votes_block.html.haml +++ b/app/views/votes/_votes_block.html.haml @@ -1,6 +1,6 @@ .votes.votes-block .progress - .bar.bar-success{style: "width: #{votable.upvotes_in_percent}%;"} - .bar.bar-danger{style: "width: #{votable.downvotes_in_percent}%;"} + .progress-bar.progress-bar-success{style: "width: #{votable.upvotes_in_percent}%;"} + .progress-bar.progress-bar-danger{style: "width: #{votable.downvotes_in_percent}%;"} .upvotes= "#{votable.upvotes} up" .downvotes= "#{votable.downvotes} down" diff --git a/app/workers/emails_on_push_worker.rb b/app/workers/emails_on_push_worker.rb new file mode 100644 index 0000000000..5e81810cbd --- /dev/null +++ b/app/workers/emails_on_push_worker.rb @@ -0,0 +1,25 @@ +class EmailsOnPushWorker + include Sidekiq::Worker + + def perform(project_id, recipients, push_data) + project = Project.find(project_id) + before_sha = push_data["before"] + after_sha = push_data["after"] + branch = push_data["ref"] + author_id = push_data["user_id"] + + if before_sha =~ /^000000/ || after_sha =~ /^000000/ + # skip if new branch was pushed or branch was removed + return true + end + + compare = Gitlab::Git::Compare.new(project.repository.raw_repository, before_sha, after_sha, MergeRequestDiff::COMMITS_SAFE_SIZE) + + # Do not send emails if git compare failed + return false unless compare && compare.commits.present? + + recipients.split(" ").each do |recipient| + Notify.repository_push_email(project_id, recipient, author_id, branch, compare).deliver + end + end +end diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb index 6416aa608e..3b0cf77d42 100644 --- a/app/workers/post_receive.rb +++ b/app/workers/post_receive.rb @@ -29,10 +29,20 @@ class PostReceive return false end - GitPushService.new.execute(project, user, oldrev, newrev, ref) + if tag?(ref) + GitTagPushService.new.execute(project, user, oldrev, newrev, ref) + else + GitPushService.new.execute(project, user, oldrev, newrev, ref) + end end def log(message) Gitlab::GitLogger.error("POST-RECEIVE: #{message}") end + + private + + def tag?(ref) + !!(/refs\/tags\/(.*)/.match(ref)) + end end diff --git a/app/workers/repository_import_worker.rb b/app/workers/repository_import_worker.rb index a3b4bd0c9b..e66df8c4db 100644 --- a/app/workers/repository_import_worker.rb +++ b/app/workers/repository_import_worker.rb @@ -11,12 +11,11 @@ class RepositoryImportWorker project.import_url) if result - project.imported = true + project.import_finish project.save project.satellite.create unless project.satellite.exists? - project.discover_default_branch else - project.imported = false + project.import_fail end end end diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 0000000000..66e9889e8b --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/pkgr_before_precompile.sh b/bin/pkgr_before_precompile.sh new file mode 100755 index 0000000000..283abb6a0c --- /dev/null +++ b/bin/pkgr_before_precompile.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +for file in config/*.yml.example; do + cp ${file} config/$(basename ${file} .example) +done + +# Allow to override the Gitlab URL from an environment variable, as this will avoid having to change the configuration file for simple deployments. +config=$(echo '<% gitlab_url = URI(ENV["GITLAB_URL"] || "http://localhost:80") %>' | cat - config/gitlab.yml) +echo "$config" > config/gitlab.yml +sed -i "s/host: localhost/host: <%= gitlab_url.host %>/" config/gitlab.yml +sed -i "s/port: 80/port: <%= gitlab_url.port %>/" config/gitlab.yml +sed -i "s/https: false/https: <%= gitlab_url.scheme == 'https' %>/" config/gitlab.yml + +# No need for config file. Will be taken care of by REDIS_URL env variable +rm config/resque.yml + +# Set default unicorn.rb file +echo "" > config/unicorn.rb + +# Required for assets precompilation +sudo service postgresql start diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000000..7feb6a30e6 --- /dev/null +++ b/bin/rails @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000000..8017a0271d --- /dev/null +++ b/bin/rake @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 0000000000..41e37089ac --- /dev/null +++ b/bin/rspec @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end +require 'bundler/setup' +load Gem.bin_path('rspec', 'rspec') diff --git a/bin/spinach b/bin/spinach new file mode 100755 index 0000000000..a080e286cf --- /dev/null +++ b/bin/spinach @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end +require 'bundler/setup' +load Gem.bin_path('spinach', 'spinach') diff --git a/bin/spring b/bin/spring new file mode 100755 index 0000000000..253ec37c34 --- /dev/null +++ b/bin/spring @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby + +# This file loads spring without using Bundler, in order to be fast +# It gets overwritten when you run the `spring binstub` command + +unless defined?(Spring) + require "rubygems" + require "bundler" + + if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) + ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) + ENV["GEM_HOME"] = "" + Gem.paths = ENV + + gem "spring", match[1] + require "spring/binstub" + end +end diff --git a/config.ru b/config.ru index dfd2d86223..e90863a5c2 100644 --- a/config.ru +++ b/config.ru @@ -1,5 +1,14 @@ # This file is used by Rack-based servers to start the application. +if defined?(Unicorn) + require 'unicorn' + # Unicorn self-process killer + require 'unicorn/worker_killer' + + # Max memory size (RSS) per worker + use Unicorn::WorkerKiller::Oom, (200 * (1 << 20)), (250 * (1 << 20)) +end + require ::File.expand_path('../config/environment', __FILE__) map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do diff --git a/config/application.rb b/config/application.rb index d85bcab788..f087d3507b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,13 +1,9 @@ require File.expand_path('../boot', __FILE__) require 'rails/all' +require 'devise' -if defined?(Bundler) - # If you precompile assets before deploying to production, use this line - # Bundler.require(*Rails.groups(assets: %w(development test))) - # If you want your assets lazily compiled in production, use this line - Bundler.require(:default, :assets, Rails.env) -end +Bundler.require(:default, Rails.env) module Gitlab class Application < Rails::Application @@ -16,18 +12,15 @@ module Gitlab # -- all .rb files in that directory are automatically loaded. # Custom directories with classes and modules you want to be autoloadable. - config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/models/concerns) + config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/finders #{config.root}/app/models/concerns #{config.root}/app/models/project_services) # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named. # config.plugins = [ :exception_notification, :ssl_requirement, :all ] # Activate observers that should always be running. - config.active_record.observers = :activity_observer, + config.active_record.observers = :milestone_observer, :project_activity_cache_observer, - :issue_observer, - :key_observer, - :merge_request_observer, :note_observer, :project_observer, :system_hook_observer, @@ -42,6 +35,7 @@ module Gitlab # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de + config.i18n.enforce_available_locales = false # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" @@ -65,20 +59,35 @@ module Gitlab # Enable the asset pipeline config.assets.enabled = true + config.assets.paths << Emoji.images_path + config.assets.precompile << "emoji/*.png" + config.assets.precompile << "print.css" # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' + # Relative url support # Uncomment and customize the last line to run in a non-root path - # WARNING: This feature is known to work, but unsupported - # Note that three settings need to be changed for this to work. + # WARNING: We recommend creating a FQDN to host GitLab in a root path instead of this. + # Note that following settings need to be changed for this to work. # 1) In your application.rb file: config.relative_url_root = "/gitlab" # 2) In your gitlab.yml file: relative_url_root: /gitlab # 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab" + # 4) In ../gitlab-shell/config.yml: gitlab_url: "http://127.0.0.1/gitlab" + # 5) In lib/support/nginx/gitlab : do not use asset gzipping, remove block starting with "location ~ ^/(assets)/" + # + # To update the path, run: sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production # # config.relative_url_root = "/gitlab" - # Uncomment to enable rack attack middleware - # config.middleware.use Rack::Attack + config.middleware.use Rack::Attack + + # Allow access to GitLab API from other domains + config.middleware.use Rack::Cors do + allow do + origins '*' + resource '/api/*', headers: :any, methods: [:get, :post, :options, :put, :delete] + end + end end end diff --git a/config/database.yml.mysql b/config/database.yml.mysql index e7a9227e41..55ac088bc1 100644 --- a/config/database.yml.mysql +++ b/config/database.yml.mysql @@ -7,7 +7,7 @@ production: reconnect: false database: gitlabhq_production pool: 10 - username: gitlab + username: git password: "secure password" # host: localhost # socket: /tmp/mysql.sock diff --git a/config/environments/development.rb b/config/environments/development.rb index 6cba17f6ea..e4c7649fda 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -6,9 +6,6 @@ Gitlab::Application.configure do # since you don't have to restart the web server when you make code changes. config.cache_classes = false - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true - # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false @@ -25,10 +22,6 @@ 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 - # Do not compress assets config.assets.compress = false @@ -39,4 +32,6 @@ Gitlab::Application.configure do config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } # Open sent mails in browser config.action_mailer.delivery_method = :letter_opener + + config.eager_load = false end diff --git a/config/environments/production.rb b/config/environments/production.rb index e3476be8fb..47f7e17aeb 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -33,6 +33,12 @@ Gitlab::Application.configure do # See everything in the log (default is :info) # config.log_level = :debug + # Suppress 'Rendered template ...' messages in the log + # source: http://stackoverflow.com/a/16369363 + %w{render_template render_partial render_collection}.each do |event| + ActiveSupport::Notifications.unsubscribe "#{event}.action_view" + end + # Prepend all log lines with the following tags # config.log_tags = [ :subdomain, :uuid ] @@ -47,7 +53,7 @@ Gitlab::Application.configure do else "redis://localhost:6379" end - config.cache_store = :redis_store, resque_url + config.cache_store = :redis_store, resque_url, {namespace: 'cache:gitlab'} # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" @@ -80,4 +86,9 @@ Gitlab::Application.configure do # # } config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true + + config.eager_load = true + config.assets.js_compressor = :uglifier + + config.allow_concurrency = false end diff --git a/config/environments/test.rb b/config/environments/test.rb index b626986299..3860dc5c74 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -11,9 +11,6 @@ Gitlab::Application.configure do config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" - # Log error messages when you accidentally call methods on nil - config.whiny_nils = true - # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false @@ -34,4 +31,6 @@ Gitlab::Application.configure do # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + + config.eager_load = false end diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 163af226aa..07c9681f9a 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -14,18 +14,18 @@ production: &base ## GitLab settings gitlab: - ## Web server settings + ## Web server settings (note: host is the FQDN, do not include http://) host: localhost port: 80 https: false - # Uncomment and customize the last line to run in a non-root path - # WARNING: This feature is known to work, but unsupported - # Note that three settings need to be changed for this to work. - # 1) In your application.rb file: config.relative_url_root = "/gitlab" - # 2) In your gitlab.yml file: relative_url_root: /gitlab - # 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab" - # + # Uncommment this line below if your ssh host is different from HTTP/HTTPS one + # (you'd obviously need to replace ssh.host_example.com with your own host). + # Otherwise, ssh host will be set to the `host:` value above + # ssh_host: ssh.host_example.com + + # WARNING: See config/application.rb under "Relative url support" for the list of + # other files that need to be changed for relative url support # relative_url_root: /gitlab # Uncomment and customize if you can't use the default user to run GitLab (default: 'git') @@ -52,14 +52,22 @@ production: &base ## Users management - # default: false - Account passwords are not sent via the email if signup is enabled. + # default: false - Account passwords are not sent via the email if signup is enabled. # signup_enabled: true + # + # default: true - If set to false, standard login form won't be shown on the sign-in page + # signin_enabled: false + + + # Restrict setting visibility levels for non-admin users. + # The default is to allow all levels. + #restricted_visibility_levels: [ "public" ] ## Automatic issue closing # If a commit message matches this regular expression, all issues referenced from the matched text will be closed. - # This happends when the commit is pushed or merged into the default branch of a project. + # This happens when the commit is pushed or merged into the default branch of a project. # When not specified the default issue_closing_pattern as specified below will be used. - # issue_closing_pattern: ([Cc]loses|[Ff]ixes) +#\d+ + # issue_closing_pattern: '([Cc]lose[sd]|[Ff]ixe[sd]) #(\d+)' ## Default project features settings default_projects_features: @@ -68,7 +76,12 @@ production: &base wiki: true wall: false snippets: false - public: false + visibility_level: "private" # can be "private" | "internal" | "public" + + ## Repository downloads directory + # When a user clicks e.g. 'Download zip' on a project, a temporary zip file is created in the following directory. + # The default is 'tmp/repositories' relative to the root of the Rails app. + # repository_downloads_path: tmp/repositories ## External issues trackers issues_tracker: @@ -87,12 +100,12 @@ production: &base # ## :id - Issue id (from commit messages) # issues_url: "http://redmine.sample/issues/:id" # - # ## If not nil, linkis to creating new issues will be replaced with this + # ## If not nil, links to creating new issues will be replaced with this # ## Use placeholders: # ## :project_id - GitLab project identifier # ## :issues_tracker_id - Project Name or Id in external issue tracker # new_issue_url: "http://redmine.sample/projects/:issues_tracker_id/issues/new" - # + # # jira: # title: "Atlassian Jira" # project_url: "http://jira.sample/issues/?jql=project=:issues_tracker_id" @@ -102,6 +115,7 @@ production: &base ## Gravatar gravatar: enabled: true # Use user avatar image from Gravatar.com (default: true) + # gravatar urls: possible placeholders: %{hash} %{size} %{email} # plain_url: "http://..." # default: http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm # ssl_url: "https://..." # default: https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm @@ -110,17 +124,41 @@ production: &base # ========================== ## LDAP settings + # You can inspect a sample of the LDAP users with login access by running: + # bundle exec rake gitlab:ldap:check RAILS_ENV=production ldap: enabled: false host: '_your_ldap_server' - base: '_the_base_where_you_search_for_users' port: 636 uid: 'sAMAccountName' - method: 'ssl' # "ssl" or "plain" + method: 'ssl' # "tls" or "ssl" or "plain" bind_dn: '_the_full_dn_of_the_user_you_will_bind_with' password: '_the_password_of_the_bind_user' + # If allow_username_or_email_login is enabled, GitLab will ignore everything + # after the first '@' in the LDAP username submitted by the user on login. + # + # Example: + # - the user enters 'jane.doe@example.com' and 'p@ssw0rd' as LDAP credentials; + # - GitLab queries the LDAP server with 'jane.doe' and 'p@ssw0rd'. + # + # If you are using "uid: 'userPrincipalName'" on ActiveDirectory you need to + # disable this setting, because the userPrincipalName contains an '@'. allow_username_or_email_login: true + # Base where we can search for users + # + # Ex. ou=People,dc=gitlab,dc=example + # + base: '' + + # Filter LDAP users + # + # Format: RFC 4515 + # Ex. (employeeType=developer) + # + user_filter: '' + + ## OmniAuth settings omniauth: # Allow login via Twitter, Google, etc. using OmniAuth providers @@ -136,9 +174,10 @@ production: &base ## Auth providers # Uncomment the following lines and fill in the data of the auth provider you want to use # If your favorite auth provider is not listed you can use others: - # see https://github.com/gitlabhq/gitlabhq/wiki/Using-Custom-Omniauth-Providers + # see https://github.com/gitlabhq/gitlab-public-wiki/wiki/Custom-omniauth-provider-configurations # The 'app_id' and 'app_secret' parameters are always passed as the first two # arguments, followed by optional 'args' which can be either a hash or an array. + # Documentation for this is available at http://doc.gitlab.com/ce/integration/omniauth.html providers: # - { name: 'google_oauth2', app_id: 'YOUR APP ID', # app_secret: 'YOUR APP SECRET', @@ -146,7 +185,8 @@ production: &base # - { name: 'twitter', app_id: 'YOUR APP ID', # app_secret: 'YOUR APP SECRET'} # - { name: 'github', app_id: 'YOUR APP ID', - # app_secret: 'YOUR APP SECRET' } + # app_secret: 'YOUR APP SECRET', + # args: { scope: 'user:email' } } @@ -166,6 +206,8 @@ production: &base ## GitLab Shell settings gitlab_shell: + path: /home/git/gitlab-shell/ + # REPOS_PATH MUST NOT BE A SYMLINK!!! repos_path: /home/git/repositories/ hooks_path: /home/git/gitlab-shell/hooks/ @@ -182,7 +224,8 @@ production: &base # Use the default values unless you really know what you are doing git: bin_path: /usr/bin/git - # Max size of a git object (e.g. a commit), in bytes + # The next value is the maximum memory size grit can use + # Given in number of bytes per git object (e.g. a commit) # This value can be increased if you have very large commits max_size: 5242880 # 5.megabytes # Git timeout to read a commit, in seconds @@ -196,6 +239,10 @@ production: &base ## Google analytics. Uncomment if you want it # google_analytics_id: '_your_tracking_id' + ## Piwik analytics. + # piwik_url: '_your_piwik_url' + # piwik_site_id: '_your_piwik_site_id' + ## Text under sign-in page (Markdown enabled) # sign_in_text: | # ![Company Logo](http://www.companydomain.com/logo.png) @@ -206,6 +253,11 @@ development: test: <<: *base + gravatar: + enabled: true + gitlab: + host: localhost + port: 80 issues_tracker: redmine: title: "Redmine" diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 942b77ffd2..97f2954640 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -1,10 +1,10 @@ class Settings < Settingslogic - source "#{Rails.root}/config/gitlab.yml" + source ENV.fetch('GITLAB_CONFIG') { "#{Rails.root}/config/gitlab.yml" } namespace Rails.env class << self - def gitlab_on_non_standard_port? - ![443, 80].include?(gitlab.port.to_i) + def gitlab_on_standard_port? + gitlab.port.to_i == (gitlab.https ? 443 : 80) end private @@ -18,11 +18,7 @@ class Settings < Settingslogic end def build_gitlab_url - if gitlab_on_non_standard_port? - custom_port = ":#{gitlab.port}" - else - custom_port = nil - end + custom_port = gitlab_on_standard_port? ? nil : ":#{gitlab.port}" [ gitlab.protocol, "://", gitlab.host, @@ -30,6 +26,29 @@ class Settings < Settingslogic gitlab.relative_url_root ].join('') end + + # check that values in `current` (string or integer) is a contant in `modul`. + def verify_constant_array(modul, current, default) + values = default || [] + if !current.nil? + values = [] + current.each do |constant| + values.push(verify_constant(modul, constant, nil)) + end + values.delete_if { |value| value.nil? } + end + values + end + + # check that `current` (string or integer) is a contant in `modul`. + def verify_constant(modul, current, default) + constant = modul.constants.find{ |name| modul.const_get(name) == current } + value = constant.nil? ? default : modul.const_get(constant) + if current.is_a? String + value = modul.const_get(current.upcase) rescue default + end + value + end end end @@ -54,6 +73,7 @@ Settings.gitlab['default_projects_limit'] ||= 10 Settings.gitlab['default_can_create_group'] = true if Settings.gitlab['default_can_create_group'].nil? Settings.gitlab['default_theme'] = Gitlab::Theme::MARS if Settings.gitlab['default_theme'].nil? Settings.gitlab['host'] ||= 'localhost' +Settings.gitlab['ssh_host'] ||= Settings.gitlab.host Settings.gitlab['https'] = false if Settings.gitlab['https'].nil? Settings.gitlab['port'] ||= Settings.gitlab.https ? 443 : 80 Settings.gitlab['relative_url_root'] ||= ENV['RAILS_RELATIVE_URL_ROOT'] || '' @@ -68,15 +88,18 @@ rescue ArgumentError # no user configured '/home/' + Settings.gitlab['user'] end Settings.gitlab['signup_enabled'] ||= false +Settings.gitlab['signin_enabled'] ||= true if Settings.gitlab['signin_enabled'].nil? +Settings.gitlab['restricted_visibility_levels'] = Settings.send(:verify_constant_array, Gitlab::VisibilityLevel, Settings.gitlab['restricted_visibility_levels'], []) Settings.gitlab['username_changing_enabled'] = true if Settings.gitlab['username_changing_enabled'].nil? -Settings.gitlab['issue_closing_pattern'] = '([Cc]loses|[Ff]ixes) #(\d+)' if Settings.gitlab['issue_closing_pattern'].nil? +Settings.gitlab['issue_closing_pattern'] = '([Cc]lose[sd]|[Ff]ixe[sd]) #(\d+)' if Settings.gitlab['issue_closing_pattern'].nil? Settings.gitlab['default_projects_features'] ||= {} Settings.gitlab.default_projects_features['issues'] = true if Settings.gitlab.default_projects_features['issues'].nil? Settings.gitlab.default_projects_features['merge_requests'] = true if Settings.gitlab.default_projects_features['merge_requests'].nil? Settings.gitlab.default_projects_features['wiki'] = true if Settings.gitlab.default_projects_features['wiki'].nil? Settings.gitlab.default_projects_features['wall'] = false if Settings.gitlab.default_projects_features['wall'].nil? Settings.gitlab.default_projects_features['snippets'] = false if Settings.gitlab.default_projects_features['snippets'].nil? -Settings.gitlab.default_projects_features['public'] = false if Settings.gitlab.default_projects_features['public'].nil? +Settings.gitlab.default_projects_features['visibility_level'] = Settings.send(:verify_constant, Gitlab::VisibilityLevel, Settings.gitlab.default_projects_features['visibility_level'], Gitlab::VisibilityLevel::PRIVATE) +Settings.gitlab['repository_downloads_path'] = File.absolute_path(Settings.gitlab['repository_downloads_path'] || 'tmp/repositories', Rails.root) # # Gravatar @@ -90,11 +113,12 @@ Settings.gravatar['ssl_url'] ||= 'https://secure.gravatar.com/avatar/%{hash}? # GitLab Shell # Settings['gitlab_shell'] ||= Settingslogic.new({}) +Settings.gitlab_shell['path'] ||= Settings.gitlab['user_home'] + '/gitlab-shell/' Settings.gitlab_shell['hooks_path'] ||= Settings.gitlab['user_home'] + '/gitlab-shell/hooks/' Settings.gitlab_shell['receive_pack'] = true if Settings.gitlab_shell['receive_pack'].nil? Settings.gitlab_shell['upload_pack'] = true if Settings.gitlab_shell['upload_pack'].nil? Settings.gitlab_shell['repos_path'] ||= Settings.gitlab['user_home'] + '/repositories/' -Settings.gitlab_shell['ssh_host'] ||= (Settings.gitlab.host || 'localhost') +Settings.gitlab_shell['ssh_host'] ||= Settings.gitlab.ssh_host Settings.gitlab_shell['ssh_port'] ||= 22 Settings.gitlab_shell['ssh_user'] ||= Settings.gitlab.user Settings.gitlab_shell['owner_group'] ||= Settings.gitlab.user diff --git a/config/initializers/2_app.rb b/config/initializers/2_app.rb index e2f9800234..655590dff0 100644 --- a/config/initializers/2_app.rb +++ b/config/initializers/2_app.rb @@ -1,6 +1,6 @@ module Gitlab VERSION = File.read(Rails.root.join("VERSION")).strip - REVISION = `git log --pretty=format:'%h' -n 1` + REVISION = Gitlab::Popen.popen(%W(git log --pretty=format:%h -n 1)).first.chomp def self.config Settings diff --git a/config/initializers/3_grit_ext.rb b/config/initializers/3_grit_ext.rb index 8b298e821e..6540ac839c 100644 --- a/config/initializers/3_grit_ext.rb +++ b/config/initializers/3_grit_ext.rb @@ -1,5 +1,4 @@ require 'grit' -require 'pygments' Grit::Git.git_binary = Gitlab.config.git.bin_path Grit::Git.git_timeout = Gitlab.config.git.timeout diff --git a/config/initializers/6_rack_profiler.rb b/config/initializers/6_rack_profiler.rb new file mode 100644 index 0000000000..a7ee3c5982 --- /dev/null +++ b/config/initializers/6_rack_profiler.rb @@ -0,0 +1,6 @@ +if Rails.env == 'development' + require 'rack-mini-profiler' + + # initialization is skipped so trigger it + Rack::MiniProfilerRails.initialize!(Rails.application) +end diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index 45bc68f322..d0065b63e5 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -15,5 +15,19 @@ if File.exists?(aws_file) config.fog_directory = AWS_CONFIG['bucket'] # required config.fog_public = false # optional, defaults to true config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {} + config.fog_authenticated_url_expiration = 1 << 29 # optional time (in seconds) that authenticated urls will be valid. + # when fog_public is false and provider is AWS or Google, defaults to 600 + end + + # Mocking Fog requests, based on: https://github.com/carrierwaveuploader/carrierwave/wiki/How-to%3A-Test-Fog-based-uploaders + if Rails.env.test? + Fog.mock! + connection = ::Fog::Storage.new( + :aws_access_key_id => AWS_CONFIG['access_key_id'], + :aws_secret_access_key => AWS_CONFIG['secret_access_key'], + :provider => 'AWS', + :region => AWS_CONFIG['region'] + ) + connection.directories.create(:key => AWS_CONFIG['bucket']) end end diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index b7cb808d2e..d5cb110e88 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -4,7 +4,8 @@ Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class with default "from" parameter. - config.mailer_sender = Gitlab.config.gitlab.email_from + config.mailer_sender = "GitLab <#{Gitlab.config.gitlab.email_from}>" + # Configure the class responsible to send e-mails. # config.mailer = "Devise::Mailer" @@ -74,13 +75,13 @@ Devise.setup do |config| # config.pepper = "2ef62d549c4ff98a5d3e0ba211e72cff592060247e3bbbb9f499af1222f876f53d39b39b823132affb32858168c79c1d7741d26499901b63c6030a42129924ef" # ==> Configuration for :confirmable - # The time you want to give your user to confirm his account. During this time - # he will be able to access your application without confirming. Default is 0.days - # When confirm_within is zero, the user won't be able to sign in without confirming. + # The time you want to give a user to confirm their account. During this time + # they will be able to access your application without confirming. Default is 0.days + # When allow_unconfirmed_access_for is zero, the user won't be able to sign in without confirming. # You can use this to let your user access some features of your application # without confirming the account, but blocking it after a certain period # (ie 2 days). - # config.confirm_within = 2.days + # config.allow_unconfirmed_access_for = 2.days # Defines which key will be used when confirming an account # config.confirmation_keys = [ :email ] @@ -101,7 +102,7 @@ Devise.setup do |config| # ==> Configuration for :validatable # Range for password length. Default is 6..128. - config.password_length = 6..128 + config.password_length = 8..128 # Email regex used to validate email formats. It simply asserts that # an one (and only one) @ exists in the given string. This is mainly @@ -222,19 +223,26 @@ Devise.setup do |config| method: Gitlab.config.ldap['method'], bind_dn: Gitlab.config.ldap['bind_dn'], password: Gitlab.config.ldap['password'], + filter: Gitlab.config.ldap['user_filter'], name_proc: email_stripping_proc end Gitlab.config.omniauth.providers.each do |provider| + provider_arguments = [] + + %w[app_id app_secret].each do |argument| + provider_arguments << provider[argument] if provider[argument] + end + case provider['args'] when Array # An Array from the configuration will be expanded. - config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret'], *provider['args'] + provider_arguments.concat provider['args'] when Hash # A Hash from the configuration will be passed as is. - config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret'], provider['args'] - else - config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret'] + provider_arguments << provider['args'] end + + config.omniauth provider['name'].to_sym, *provider_arguments end -end +end \ No newline at end of file diff --git a/config/initializers/devise_password_length.rb.example b/config/initializers/devise_password_length.rb.example new file mode 100644 index 0000000000..97305825e0 --- /dev/null +++ b/config/initializers/devise_password_length.rb.example @@ -0,0 +1,6 @@ +Devise.setup do |config| + # The following line changes the password length limits for new users. In the + # example below the minimum length is 12 characters, and the maximum length + # is 128 characters. + config.password_length = 12..128 +end diff --git a/config/initializers/gemoji.rb b/config/initializers/gemoji.rb deleted file mode 100644 index 8c85aad5d3..0000000000 --- a/config/initializers/gemoji.rb +++ /dev/null @@ -1,2 +0,0 @@ -# Workaround for https://github.com/github/gemoji/pull/18 -Gitlab::Application.config.assets.paths << Emoji.images_path diff --git a/config/initializers/rack_attack.rb.example b/config/initializers/rack_attack.rb.example index 76fa7ad282..bc3234bf0b 100644 --- a/config/initializers/rack_attack.rb.example +++ b/config/initializers/rack_attack.rb.example @@ -1,16 +1,18 @@ -# To enable rack-attack for your GitLab instance do the following: -# 1. In config/application.rb find and uncomment the following line: -# config.middleware.use Rack::Attack -# 2. Rename this file to rack_attack.rb -# 3. Review the paths_to_be_protected and add any other path you need protecting -# 4. Restart GitLab instance +# 1. Rename this file to rack_attack.rb +# 2. Review the paths_to_be_protected and add any other path you need protecting # paths_to_be_protected = [ "#{Rails.application.config.relative_url_root}/users/password", "#{Rails.application.config.relative_url_root}/users/sign_in", - "#{Rails.application.config.relative_url_root}/users" + "#{Rails.application.config.relative_url_root}/api/#{API::API.version}/session.json", + "#{Rails.application.config.relative_url_root}/api/#{API::API.version}/session", + "#{Rails.application.config.relative_url_root}/users", + "#{Rails.application.config.relative_url_root}/users/confirmation" ] -Rack::Attack.throttle('protected paths', limit: 6, period: 60.seconds) do |req| - req.ip if paths_to_be_protected.include?(req.path) && req.post? + +unless Rails.env.test? + Rack::Attack.throttle('protected paths', limit: 10, period: 60.seconds) do |req| + req.ip if paths_to_be_protected.include?(req.path) && req.post? + end end diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index 16d1d4a9fd..62a54bc8c6 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -9,7 +9,9 @@ require 'securerandom' def find_secure_token token_file = Rails.root.join('.secret') - if File.exist? token_file + if ENV.key?('SECRET_KEY_BASE') + ENV['SECRET_KEY_BASE'] + elsif File.exist? token_file # Use the existing token. File.read(token_file).chomp else @@ -21,3 +23,4 @@ def find_secure_token end Gitlab::Application.config.secret_token = find_secure_token +Gitlab::Application.config.secret_key_base = find_secure_token diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 467f947739..5fe5270236 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -2,9 +2,9 @@ Gitlab::Application.config.session_store( :redis_store, # Using the cookie_store would enable session replay attacks. - servers: Gitlab::Application.config.cache_store.last, # re-use the Redis config from the Rails cache store + servers: Gitlab::Application.config.cache_store[1], # re-use the Redis config from the Rails cache store key: '_gitlab_session', - secure: Gitlab::Application.config.force_ssl, + secure: Gitlab.config.gitlab.https, httponly: true, path: (Rails.application.config.relative_url_root.nil?) ? '/' : Rails.application.config.relative_url_root ) diff --git a/config/routes.rb b/config/routes.rb index 78f75d1183..7641fe4308 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,11 +6,15 @@ Gitlab::Application.routes.draw do # Search # get 'search' => "search#show" + get 'search/autocomplete' => "search#autocomplete", as: :search_autocomplete # API API::API.logger Rails.logger mount API::API => '/api' + # Get all keys of user + get ':username.keys' => 'profiles/keys#get_keys' , constraints: { username: /.*/ } + constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? } constraints constraint do mount Sidekiq::Web, at: "/admin/sidekiq", as: :sidekiq @@ -22,7 +26,7 @@ Gitlab::Application.routes.draw do project_root: Gitlab.config.gitlab_shell.repos_path, upload_pack: Gitlab.config.gitlab_shell.upload_pack, receive_pack: Gitlab.config.gitlab_shell.receive_pack - }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) } + }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post] # # Help @@ -86,14 +90,19 @@ Gitlab::Application.routes.draw do get :test end + resources :broadcast_messages, only: [:index, :create, :destroy] resource :logs, only: [:show] resource :background_jobs, controller: 'background_jobs', only: [:show] - resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] + + resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] do + member do + put :transfer + end + end + root to: "dashboard#index" end - get "errors/githost" - # # Profile Area # @@ -115,15 +124,17 @@ Gitlab::Application.routes.draw do end end resources :keys + resources :emails, only: [:index, :create, :destroy] resources :groups, only: [:index] do member do delete :leave end end + resource :avatar, only: [:destroy] end end - match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ } + match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ }, via: :get @@ -149,11 +160,14 @@ Gitlab::Application.routes.draw do end resources :users_groups, only: [:create, :update, :destroy] + scope module: :groups do + resource :avatar, only: [:destroy] + end end resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create] - devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations } + devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords} # # Project Area @@ -162,20 +176,28 @@ Gitlab::Application.routes.draw do member do put :transfer post :fork + post :archive + post :unarchive get :autocomplete_sources + get :import + put :retry_import end scope module: :projects do - resources :blob, only: [:show], constraints: {id: /.+/} - resources :raw, only: [:show], constraints: {id: /.+/} - resources :tree, only: [:show], constraints: {id: /.+/, format: /(html|js)/ } - resources :edit_tree, only: [:show, :update], constraints: {id: /.+/}, path: 'edit' - resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} - resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} - resources :compare, only: [:index, :create] - resources :blame, only: [:show], constraints: {id: /.+/} + resources :blob, only: [:show, :destroy], constraints: {id: /.+/} + resources :raw, only: [:show], constraints: {id: /.+/} + resources :tree, only: [:show], constraints: {id: /.+/, format: /(html|js)/ } + resources :edit_tree, only: [:show, :update], constraints: { id: /.+/ }, path: 'edit' do + post :preview, on: :member + end + resources :new_tree, only: [:show, :update], constraints: {id: /.+/}, path: 'new' + resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} + resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} + resources :compare, only: [:index, :create] + resources :blame, only: [:show], constraints: {id: /.+/} resources :network, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} - resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} + resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} + match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/} resources :snippets, constraints: {id: /\d+/} do @@ -184,7 +206,7 @@ Gitlab::Application.routes.draw do end end - resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-]+/} do + resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-\/]+/} do collection do get :pages put ':id' => 'wikis#update' @@ -205,7 +227,7 @@ Gitlab::Application.routes.draw do resource :repository, only: [:show] do member do get "stats" - get "archive" + get "archive", constraints: { format: Gitlab::Regex.archive_formats_regex } end end @@ -251,7 +273,7 @@ Gitlab::Application.routes.draw do resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do member do get :diffs - get :automerge + post :automerge get :automerge_check get :ci_status end @@ -286,6 +308,7 @@ Gitlab::Application.routes.draw do resources :team_members, except: [:index, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do collection do + delete :leave # Used for import team # from another project @@ -306,5 +329,7 @@ Gitlab::Application.routes.draw do end end + get ':id' => "groups#show", constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} + root to: "dashboard#show" end diff --git a/config/unicorn.rb.example b/config/unicorn.rb.example index e4e1342683..f6c0f09b51 100644 --- a/config/unicorn.rb.example +++ b/config/unicorn.rb.example @@ -8,12 +8,8 @@ # See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete # documentation. -# Uncomment and customize the last line to run in a non-root path -# WARNING: This feature is known to work, but unsupported -# Note that three settings need to be changed for this to work. -# 1) In your application.rb file: config.relative_url_root = "/gitlab" -# 2) In your gitlab.yml file: relative_url_root: /gitlab -# 3) In your unicorn.rb: ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab" +# WARNING: See config/application.rb under "Relative url support" for the list of +# other files that need to be changed for relative url support # # ENV['RAILS_RELATIVE_URL_ROOT'] = "/gitlab" diff --git a/config/unicorn.rb.example.development b/config/unicorn.rb.example.development new file mode 100644 index 0000000000..94a7061451 --- /dev/null +++ b/config/unicorn.rb.example.development @@ -0,0 +1,2 @@ +worker_processes 2 +timeout 30 diff --git a/db/fixtures/development/01_admin.rb b/db/fixtures/development/01_admin.rb index 3e76d76e83..42d1843534 100644 --- a/db/fixtures/development/01_admin.rb +++ b/db/fixtures/development/01_admin.rb @@ -8,8 +8,7 @@ User.seed(:id, [ password_confirmation: "5iveL!fe", admin: true, projects_limit: 100, - theme_id: Gitlab::Theme::MARS + theme_id: Gitlab::Theme::MARS, + confirmed_at: DateTime.now } ]) - -User.find(1).confirm! diff --git a/db/fixtures/development/04_project.rb b/db/fixtures/development/04_project.rb index 6fdb163c27..164bb63780 100644 --- a/db/fixtures/development/04_project.rb +++ b/db/fixtures/development/04_project.rb @@ -1,51 +1,56 @@ -project_urls = [ - 'https://github.com/documentcloud/underscore.git', - 'https://github.com/diaspora/diaspora.git', - 'https://github.com/diaspora/diaspora-project-site.git', - 'https://github.com/diaspora/diaspora-client.git', - 'https://github.com/brightbox/brightbox-cli.git', - 'https://github.com/brightbox/puppet.git', - 'https://github.com/gitlabhq/gitlabhq.git', - 'https://github.com/gitlabhq/gitlab-ci.git', - 'https://github.com/gitlabhq/gitlab-recipes.git', - 'https://github.com/gitlabhq/gitlab-shell.git', - 'https://github.com/gitlabhq/grack.git', - 'https://github.com/twitter/flight.git', - 'https://github.com/twitter/typeahead.js.git', - 'https://github.com/h5bp/html5-boilerplate.git', - 'https://github.com/h5bp/mobile-boilerplate.git', -] +Gitlab::Seeder.quiet do + project_urls = [ + 'https://github.com/documentcloud/underscore.git', + 'https://github.com/diaspora/diaspora.git', + 'https://github.com/diaspora/diaspora-project-site.git', + 'https://github.com/diaspora/diaspora-client.git', + 'https://github.com/brightbox/brightbox-cli.git', + 'https://github.com/brightbox/puppet.git', + 'https://github.com/gitlabhq/gitlabhq.git', + 'https://github.com/gitlabhq/gitlab-ci.git', + 'https://github.com/gitlabhq/gitlab-recipes.git', + 'https://github.com/gitlabhq/gitlab-shell.git', + 'https://github.com/gitlabhq/grack.git', + 'https://github.com/gitlabhq/testme.git', + 'https://github.com/twitter/flight.git', + 'https://github.com/twitter/typeahead.js.git', + 'https://github.com/h5bp/html5-boilerplate.git', + 'https://github.com/h5bp/mobile-boilerplate.git', + ] -project_urls.each_with_index do |url, i| - group_path, project_path = url.split('/')[-2..-1] + project_urls.each_with_index do |url, i| + group_path, project_path = url.split('/')[-2..-1] - group = Group.find_by_path(group_path) + group = Group.find_by(path: group_path) - unless group - group = Group.new( - name: group_path.titleize, - path: group_path - ) - group.description = Faker::Lorem.sentence - group.owner = User.first - group.save - end + unless group + group = Group.new( + name: group_path.titleize, + path: group_path + ) + group.description = Faker::Lorem.sentence + group.save - project_path.gsub!(".git", "") + group.add_owner(User.first) + end - params = { - import_url: url, - namespace_id: group.id, - name: project_path.titleize, - description: Faker::Lorem.sentence - } + project_path.gsub!(".git", "") - project = Projects::CreateContext.new(User.first, params).execute + params = { + import_url: url, + namespace_id: group.id, + name: project_path.titleize, + description: Faker::Lorem.sentence, + visibility_level: Gitlab::VisibilityLevel.values.sample + } - if project.valid? - print '.' - else - puts project.errors.full_messages - print 'F' + project = Projects::CreateService.new(User.first, params).execute + + if project.valid? + print '.' + else + puts project.errors.full_messages + print 'F' + end end end diff --git a/db/fixtures/development/05_users.rb b/db/fixtures/development/05_users.rb index cbb3e636ac..d736408dbf 100644 --- a/db/fixtures/development/05_users.rb +++ b/db/fixtures/development/05_users.rb @@ -1,11 +1,12 @@ Gitlab::Seeder.quiet do - (2..50).each do |i| + (2..10).each do |i| begin User.seed(:id, [{ id: i, username: Faker::Internet.user_name, name: Faker::Name.name, email: Faker::Internet.email, + confirmed_at: DateTime.now }]) print '.' rescue ActiveRecord::RecordNotSaved diff --git a/db/fixtures/development/06_teams.rb b/db/fixtures/development/06_teams.rb index a1e01879db..dfbe75fd20 100644 --- a/db/fixtures/development/06_teams.rb +++ b/db/fixtures/development/06_teams.rb @@ -1,5 +1,3 @@ -ActiveRecord::Base.observers.disable :all - Gitlab::Seeder.quiet do Group.all.each do |group| User.all.sample(4).each do |user| diff --git a/db/fixtures/development/07_milestones.rb b/db/fixtures/development/07_milestones.rb index 6fe7e24677..72e6b3ad3d 100644 --- a/db/fixtures/development/07_milestones.rb +++ b/db/fixtures/development/07_milestones.rb @@ -1,3 +1,5 @@ +ActiveRecord::Base.observers.disable(:milestone_observer) + Milestone.seed(:id, [ { id: 1, project_id: 1, title: 'v' + Faker::Address.zip_code }, { id: 2, project_id: 1, title: 'v' + Faker::Address.zip_code }, @@ -16,3 +18,5 @@ Milestone.all.map do |ml| ml.set_iid ml.save end + +ActiveRecord::Base.observers.enable(:milestone_observer) diff --git a/db/fixtures/development/09_issues.rb b/db/fixtures/development/09_issues.rb index 85e309b633..635878622d 100644 --- a/db/fixtures/development/09_issues.rb +++ b/db/fixtures/development/09_issues.rb @@ -1,20 +1,16 @@ -ActiveRecord::Base.observers.disable :all - Gitlab::Seeder.quiet do (1..300).each do |i| # Random Project project = Project.all.sample # Random user - user = project.users.sample + user = project.team.users.sample next unless user user_id = user.id - begin - Thread.current[:current_user] = user - + Gitlab::Seeder.by_user(user) do Issue.seed(:id, [{ id: i, project_id: project.id, @@ -25,8 +21,6 @@ Gitlab::Seeder.quiet do title: Faker::Lorem.sentence(6), description: Faker::Lorem.sentence }]) - ensure - Thread.current[:current_user] = nil end print('.') end diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb index 75f6e56985..62fd0d84ea 100644 --- a/db/fixtures/development/10_merge_requests.rb +++ b/db/fixtures/development/10_merge_requests.rb @@ -1,50 +1,33 @@ -ActiveRecord::Base.observers.disable :all - Gitlab::Seeder.quiet do - (1..100).each do |i| - # Random Project - project = Project.all.sample + Project.all.reject(&:empty_repo?).each do |project| + branches = project.repository.branch_names - # Random user - user = project.users.sample + branches.each do |branch_name| + break if branches.size < 2 + source_branch = branches.pop + target_branch = branches.pop - next unless user + # Random user + user = project.team.users.sample + next unless user - next if project.empty_repo? + params = { + source_branch: source_branch, + target_branch: target_branch, + title: Faker::Lorem.sentence(6), + description: Faker::Lorem.sentences(3).join(" ") + } - branches = project.repository.branch_names.sample(2) + merge_request = MergeRequests::CreateService.new(project, user, params).execute - next if branches.uniq.size < 2 - - user_id = user.id - begin - Thread.current[:current_user] = user - - MergeRequest.seed(:id, [{ - id: i, - source_branch: branches.first, - target_branch: branches.last, - source_project_id: project.id, - target_project_id: project.id, - author_id: user_id, - assignee_id: user_id, - milestone: project.milestones.sample, - title: Faker::Lorem.sentence(6) - }]) - ensure - Thread.current[:current_user] = nil + if merge_request.valid? + merge_request.assignee = user + merge_request.milestone = project.milestones.sample + merge_request.save + print '.' + else + print 'F' + end end - print('.') end end - -MergeRequest.all.map do |mr| - mr.set_iid - mr.save -end - -puts 'Load diffs for Merge Requests (it will take some time)...' -MergeRequest.all.each do |mr| - mr.reload_code - print '.' -end diff --git a/db/fixtures/development/11_keys.rb b/db/fixtures/development/11_keys.rb index 4b53ff411f..61329f197c 100644 --- a/db/fixtures/development/11_keys.rb +++ b/db/fixtures/development/11_keys.rb @@ -1,10 +1,8 @@ -ActiveRecord::Base.observers.enable :all - Gitlab::Seeder.quiet do User.first(30).each_with_index do |user, i| Key.seed(:id, [ { - id: i, + id: i + 1, title: "Sample key #{i}", key: "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt#{i + 100}6k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", user_id: user.id, diff --git a/db/fixtures/development/12_snippets.rb b/db/fixtures/development/12_snippets.rb index 4ca8afe294..dced270626 100644 --- a/db/fixtures/development/12_snippets.rb +++ b/db/fixtures/development/12_snippets.rb @@ -1,5 +1,3 @@ -ActiveRecord::Base.observers.disable :all - Gitlab::Seeder.quiet do contents = [ `curl https://gist.github.com/randx/4275756/raw/da2f262920c96d1a970d48bf2e99147954b1f4bd/glus1204.sh`, diff --git a/db/fixtures/development/13_comments.rb b/db/fixtures/development/13_comments.rb new file mode 100644 index 0000000000..626aba200d --- /dev/null +++ b/db/fixtures/development/13_comments.rb @@ -0,0 +1,19 @@ +Gitlab::Seeder.quiet do + Issue.all.limit(10).each_with_index do |issue, i| + 5.times do + user = issue.project.team.users.sample + + Gitlab::Seeder.by_user(user) do + Note.seed(:id, [{ + project_id: issue.project.id, + author_id: user.id, + note: Faker::Lorem.sentence, + noteable_id: issue.id, + noteable_type: 'Issue' + }]) + + print '.' + end + end + end +end diff --git a/db/migrate/20110913200833_devise_create_users.rb b/db/migrate/20110913200833_devise_create_users.rb deleted file mode 100644 index e00f275c55..0000000000 --- a/db/migrate/20110913200833_devise_create_users.rb +++ /dev/null @@ -1,55 +0,0 @@ -class DeviseCreateUsers < ActiveRecord::Migration - def self.up - create_table(:users) do |t| - ## Database authenticatable - t.string :email, :null => false, :default => "" - t.string :encrypted_password, :null => false, :default => "" - - ## Recoverable - t.string :reset_password_token - t.datetime :reset_password_sent_at - - ## Rememberable - t.datetime :remember_created_at - - ## Trackable - t.integer :sign_in_count, :default => 0 - t.datetime :current_sign_in_at - t.datetime :last_sign_in_at - t.string :current_sign_in_ip - t.string :last_sign_in_ip - - ## Encryptable - # t.string :password_salt - - ## Confirmable - # t.string :confirmation_token - # t.datetime :confirmed_at - # t.datetime :confirmation_sent_at - # t.string :unconfirmed_email # Only if using reconfirmable - - ## Lockable - # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts - # t.string :unlock_token # Only if unlock strategy is :email or :both - # t.datetime :locked_at - - # Token authenticatable - # t.string :authentication_token - - ## Invitable - # t.string :invitation_token - - t.timestamps - end - - add_index :users, :email, :unique => true - add_index :users, :reset_password_token, :unique => true - # add_index :users, :confirmation_token, :unique => true - # add_index :users, :unlock_token, :unique => true - # add_index :users, :authentication_token, :unique => true - end - - def self.down - drop_table :users - end -end diff --git a/db/migrate/20110913204141_create_projects.rb b/db/migrate/20110913204141_create_projects.rb deleted file mode 100644 index 45b76f9556..0000000000 --- a/db/migrate/20110913204141_create_projects.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateProjects < ActiveRecord::Migration - def change - create_table :projects do |t| - t.string :name - t.string :path - t.text :description - - t.timestamps - end - end -end diff --git a/db/migrate/20110914221600_create_users_projects.rb b/db/migrate/20110914221600_create_users_projects.rb deleted file mode 100644 index a89798ae86..0000000000 --- a/db/migrate/20110914221600_create_users_projects.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateUsersProjects < ActiveRecord::Migration - def change - create_table :users_projects do |t| - t.integer :user_id, :null => false - t.integer :project_id, :null => false - t.boolean :read, :default => false - t.boolean :write, :default => false - t.boolean :admin, :default => false - - t.timestamps - end - end -end diff --git a/db/migrate/20110915205627_add_private_flag_to_project.rb b/db/migrate/20110915205627_add_private_flag_to_project.rb deleted file mode 100644 index 73c0b9df83..0000000000 --- a/db/migrate/20110915205627_add_private_flag_to_project.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddPrivateFlagToProject < ActiveRecord::Migration - def change - add_column :projects, :private_flag, :boolean, :default => true, :null => false - end -end diff --git a/db/migrate/20110915213352_create_keys.rb b/db/migrate/20110915213352_create_keys.rb deleted file mode 100644 index d4615b4bab..0000000000 --- a/db/migrate/20110915213352_create_keys.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateKeys < ActiveRecord::Migration - def change - create_table :keys do |t| - t.integer :user_id, :null => false - t.text :project_id, :null => false - t.timestamps - end - end -end diff --git a/db/migrate/20110916123731_add_name_to_user.rb b/db/migrate/20110916123731_add_name_to_user.rb deleted file mode 100644 index 74142b05cb..0000000000 --- a/db/migrate/20110916123731_add_name_to_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddNameToUser < ActiveRecord::Migration - def change - add_column :users, :name, :string - end -end diff --git a/db/migrate/20110916162511_add_key_title_to_key.rb b/db/migrate/20110916162511_add_key_title_to_key.rb deleted file mode 100644 index b2eaa51ccc..0000000000 --- a/db/migrate/20110916162511_add_key_title_to_key.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddKeyTitleToKey < ActiveRecord::Migration - def change - add_column :keys, :key, :text - add_column :keys, :title, :string - remove_column :keys, :project_id - end -end diff --git a/db/migrate/20110917212932_add_identifier_to_key.rb b/db/migrate/20110917212932_add_identifier_to_key.rb deleted file mode 100644 index e572793952..0000000000 --- a/db/migrate/20110917212932_add_identifier_to_key.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIdentifierToKey < ActiveRecord::Migration - def change - add_column :keys, :identifier, :string - end -end diff --git a/db/migrate/20110921192501_create_issues.rb b/db/migrate/20110921192501_create_issues.rb deleted file mode 100644 index 63b42ad998..0000000000 --- a/db/migrate/20110921192501_create_issues.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateIssues < ActiveRecord::Migration - def change - create_table :issues do |t| - t.string :title - t.text :content - t.integer :assignee_id - t.integer :author_id - t.integer :project_id - - t.timestamps - end - end -end diff --git a/db/migrate/20110922110156_add_code_to_project.rb b/db/migrate/20110922110156_add_code_to_project.rb deleted file mode 100644 index f54a02bd70..0000000000 --- a/db/migrate/20110922110156_add_code_to_project.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCodeToProject < ActiveRecord::Migration - def change - add_column :projects, :code, :string - end -end diff --git a/db/migrate/20110923211333_add_status_to_issue.rb b/db/migrate/20110923211333_add_status_to_issue.rb deleted file mode 100644 index c53bf46ef7..0000000000 --- a/db/migrate/20110923211333_add_status_to_issue.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddStatusToIssue < ActiveRecord::Migration - def change - add_column :issues, :closed, :boolean, :default => false, :null => false - end -end diff --git a/db/migrate/20110924214549_create_rails_admin_histories_table.rb b/db/migrate/20110924214549_create_rails_admin_histories_table.rb deleted file mode 100644 index 3c743aa287..0000000000 --- a/db/migrate/20110924214549_create_rails_admin_histories_table.rb +++ /dev/null @@ -1,18 +0,0 @@ -class CreateRailsAdminHistoriesTable < ActiveRecord::Migration - def self.up - create_table :rails_admin_histories do |t| - t.text :message # title, name, or object_id - t.string :username - t.integer :item - t.string :table - t.integer :month, :limit => 2 - t.integer :year, :limit => 5 - t.timestamps - end - add_index(:rails_admin_histories, [:item, :table, :month, :year], :name => 'index_rails_admin_histories' ) - end - - def self.down - drop_table :rails_admin_histories - end -end diff --git a/db/migrate/20110924215658_add_admin_field_to_user.rb b/db/migrate/20110924215658_add_admin_field_to_user.rb deleted file mode 100644 index 321587e695..0000000000 --- a/db/migrate/20110924215658_add_admin_field_to_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAdminFieldToUser < ActiveRecord::Migration - def change - add_column :users, :admin, :boolean, :default => false, :null => false - end -end diff --git a/db/migrate/20110926082616_remove_admin.rb b/db/migrate/20110926082616_remove_admin.rb deleted file mode 100644 index aac9ff7888..0000000000 --- a/db/migrate/20110926082616_remove_admin.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RemoveAdmin < ActiveRecord::Migration - def up - drop_table :rails_admin_histories - end - - def down - raise "No rollback" - end -end diff --git a/db/migrate/20110927130352_create_notes.rb b/db/migrate/20110927130352_create_notes.rb deleted file mode 100644 index 72a0e81761..0000000000 --- a/db/migrate/20110927130352_create_notes.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateNotes < ActiveRecord::Migration - def change - create_table :notes do |t| - t.string :note - t.integer :noteable_id - t.string :noteable_type - t.integer :author_id - - t.timestamps - end - end -end diff --git a/db/migrate/20110928140106_add_project_id_for_note.rb b/db/migrate/20110928140106_add_project_id_for_note.rb deleted file mode 100644 index 3e64108979..0000000000 --- a/db/migrate/20110928140106_add_project_id_for_note.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddProjectIdForNote < ActiveRecord::Migration - def up - add_column :notes, :project_id, :integer - end - - def down - remove_column :notes, :project_id, :integer - end -end diff --git a/db/migrate/20110928142747_change_noteable_id_for_note.rb b/db/migrate/20110928142747_change_noteable_id_for_note.rb deleted file mode 100644 index dc9d1f0171..0000000000 --- a/db/migrate/20110928142747_change_noteable_id_for_note.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ChangeNoteableIdForNote < ActiveRecord::Migration - def up - change_column :notes, :noteable_id, :string - end - - def down - change_column :notes, :noteable_id, :integer - end -end diff --git a/db/migrate/20110928161328_add_attachment_to_note.rb b/db/migrate/20110928161328_add_attachment_to_note.rb deleted file mode 100644 index 37d9cf1025..0000000000 --- a/db/migrate/20110928161328_add_attachment_to_note.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAttachmentToNote < ActiveRecord::Migration - def change - add_column :notes, :attachment, :string - end -end diff --git a/db/migrate/20111005193700_add_allow_repo_creation_for_user.rb b/db/migrate/20111005193700_add_allow_repo_creation_for_user.rb deleted file mode 100644 index 82bd94b808..0000000000 --- a/db/migrate/20111005193700_add_allow_repo_creation_for_user.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddAllowRepoCreationForUser < ActiveRecord::Migration - def up - add_column :users, :allowed_create_repo, :boolean, :default => true, :null => false - end - - def down - remove_column :users, :allowed_create_repo - end -end diff --git a/db/migrate/20111009101738_add_ownerto_project.rb b/db/migrate/20111009101738_add_ownerto_project.rb deleted file mode 100644 index 8d265533ad..0000000000 --- a/db/migrate/20111009101738_add_ownerto_project.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddOwnertoProject < ActiveRecord::Migration - def change - add_column :projects, :owner_id, :integer - end -end diff --git a/db/migrate/20111009110913_add_projects_limit_to_user.rb b/db/migrate/20111009110913_add_projects_limit_to_user.rb deleted file mode 100644 index 8eb8382b51..0000000000 --- a/db/migrate/20111009110913_add_projects_limit_to_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddProjectsLimitToUser < ActiveRecord::Migration - def change - add_column :users, :projects_limit, :integer, :default => 10 - end -end diff --git a/db/migrate/20111009111204_remove_allow_create_repo_from_user.rb b/db/migrate/20111009111204_remove_allow_create_repo_from_user.rb deleted file mode 100644 index 6145200639..0000000000 --- a/db/migrate/20111009111204_remove_allow_create_repo_from_user.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RemoveAllowCreateRepoFromUser < ActiveRecord::Migration - def up - remove_column :users, :allowed_create_repo - end - - def down - add_column :users, :allowed_create_repo, :boolean, :default => true, :null => false - end -end diff --git a/db/migrate/20111015154310_add_position_to_issues.rb b/db/migrate/20111015154310_add_position_to_issues.rb deleted file mode 100644 index 41451a0cab..0000000000 --- a/db/migrate/20111015154310_add_position_to_issues.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddPositionToIssues < ActiveRecord::Migration - def change - add_column :issues, :position, :integer, :default => 0 - end -end diff --git a/db/migrate/20111016183422_create_snippets.rb b/db/migrate/20111016183422_create_snippets.rb deleted file mode 100644 index 9b0bf201cb..0000000000 --- a/db/migrate/20111016183422_create_snippets.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateSnippets < ActiveRecord::Migration - def change - create_table :snippets do |t| - t.string :title - t.text :content - t.integer :author_id, :null => false - t.integer :project_id, :null => false - - t.timestamps - end - end -end diff --git a/db/migrate/20111016193417_add_content_type_to_snippets.rb b/db/migrate/20111016193417_add_content_type_to_snippets.rb deleted file mode 100644 index 511a6793f4..0000000000 --- a/db/migrate/20111016193417_add_content_type_to_snippets.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddContentTypeToSnippets < ActiveRecord::Migration - def change - add_column :snippets, :content_type, :string, :null => false, :default => "txt" - end -end diff --git a/db/migrate/20111016195506_add_file_name_to_snippets.rb b/db/migrate/20111016195506_add_file_name_to_snippets.rb deleted file mode 100644 index d378d225ec..0000000000 --- a/db/migrate/20111016195506_add_file_name_to_snippets.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddFileNameToSnippets < ActiveRecord::Migration - def change - add_column :snippets, :file_name, :string - remove_column :snippets, :content_type - end -end diff --git a/db/migrate/20111019212429_add_social_to_user.rb b/db/migrate/20111019212429_add_social_to_user.rb deleted file mode 100644 index b0ffe5366a..0000000000 --- a/db/migrate/20111019212429_add_social_to_user.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddSocialToUser < ActiveRecord::Migration - def change - add_column :users, :skype, :string - add_column :users, :linkedin, :string - add_column :users, :twitter, :string - end -end diff --git a/db/migrate/20111021101550_change_social_fields_in_users.rb b/db/migrate/20111021101550_change_social_fields_in_users.rb deleted file mode 100644 index 6e506c1cf9..0000000000 --- a/db/migrate/20111021101550_change_social_fields_in_users.rb +++ /dev/null @@ -1,14 +0,0 @@ -class ChangeSocialFieldsInUsers < ActiveRecord::Migration - def up - remove_column :users, :skype - remove_column :users, :linkedin - remove_column :users, :twitter - - add_column :users, :skype, :string, {:null => false, :default => ''} - add_column :users, :linkedin, :string, {:null => false, :default => ''} - add_column :users, :twitter, :string, {:null => false, :default => ''} - end - - def down - end -end diff --git a/db/migrate/20111025134235_add_high_label_to_issue.rb b/db/migrate/20111025134235_add_high_label_to_issue.rb deleted file mode 100644 index 676eaaf8c1..0000000000 --- a/db/migrate/20111025134235_add_high_label_to_issue.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddHighLabelToIssue < ActiveRecord::Migration - def change - add_column :issues, :critical, :boolean, :default => false, :null => false - end -end diff --git a/db/migrate/20111027051828_add_expires_at_to_snippets.rb b/db/migrate/20111027051828_add_expires_at_to_snippets.rb deleted file mode 100644 index 0d94b33376..0000000000 --- a/db/migrate/20111027051828_add_expires_at_to_snippets.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddExpiresAtToSnippets < ActiveRecord::Migration - def change - add_column :snippets, :expires_at, :datetime - end -end diff --git a/db/migrate/20111027142641_change_note_note_to_text.rb b/db/migrate/20111027142641_change_note_note_to_text.rb deleted file mode 100644 index d762d361ae..0000000000 --- a/db/migrate/20111027142641_change_note_note_to_text.rb +++ /dev/null @@ -1,8 +0,0 @@ -class ChangeNoteNoteToText < ActiveRecord::Migration - def up - change_column :notes, :note, :text - end - - def down - end -end diff --git a/db/migrate/20111027152724_issue_conten_to_note.rb b/db/migrate/20111027152724_issue_conten_to_note.rb deleted file mode 100644 index 0677fee6b9..0000000000 --- a/db/migrate/20111027152724_issue_conten_to_note.rb +++ /dev/null @@ -1,34 +0,0 @@ -class IssueContenToNote < ActiveRecord::Migration - def up - puts "Issue content is deprecated -> move to notes" - Issue.find_each(:batch_size => 100) do |issue| - next if issue.content.blank? - note = Note.new( - :note => issue.content, - :project_id => issue.project_id, - :noteable => issue, - :created_at => issue.created_at, - :updated_at => issue.created_at - ) - note.author_id = issue.author_id - - if note.save - issue.update_attributes(:content => nil) - print "." - else - print "F" - end - end - - total = Issue.where("content is not null").count - - if total > 0 - puts "content of #{total} issues were not migrated" - else - puts "Done" - end - end - - def down - end -end diff --git a/db/migrate/20111101222453_acts_as_taggable_on_migration.rb b/db/migrate/20111101222453_acts_as_taggable_on_migration.rb deleted file mode 100644 index 16610615f9..0000000000 --- a/db/migrate/20111101222453_acts_as_taggable_on_migration.rb +++ /dev/null @@ -1,28 +0,0 @@ -class ActsAsTaggableOnMigration < ActiveRecord::Migration - def self.up - create_table :tags do |t| - t.string :name - end - - create_table :taggings do |t| - t.references :tag - - # You should make sure that the column created is - # long enough to store the required class names. - t.references :taggable, :polymorphic => true - t.references :tagger, :polymorphic => true - - t.string :context - - t.datetime :created_at - end - - add_index :taggings, :tag_id - add_index :taggings, [:taggable_id, :taggable_type, :context] - end - - def self.down - drop_table :taggings - drop_table :tags - end -end diff --git a/db/migrate/20111111093150_remove_content_from_issues.rb b/db/migrate/20111111093150_remove_content_from_issues.rb deleted file mode 100644 index 30bcdfb543..0000000000 --- a/db/migrate/20111111093150_remove_content_from_issues.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RemoveContentFromIssues < ActiveRecord::Migration - def up - remove_column :issues, :content - end - - def down - add_column :issues, :content, :text - end -end diff --git a/db/migrate/20111115063954_add_authentication_token_to_users.rb b/db/migrate/20111115063954_add_authentication_token_to_users.rb deleted file mode 100644 index 84433656d6..0000000000 --- a/db/migrate/20111115063954_add_authentication_token_to_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAuthenticationTokenToUsers < ActiveRecord::Migration - def change - add_column :users, :authentication_token, :string - end -end diff --git a/db/migrate/20111124115339_add_extra_field_to_issue.rb b/db/migrate/20111124115339_add_extra_field_to_issue.rb deleted file mode 100644 index 4946c6fb0b..0000000000 --- a/db/migrate/20111124115339_add_extra_field_to_issue.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddExtraFieldToIssue < ActiveRecord::Migration - def change - add_column :issues, :branch_name, :string, :null => true - end -end diff --git a/db/migrate/20111127155345_create_merge_requests.rb b/db/migrate/20111127155345_create_merge_requests.rb deleted file mode 100644 index 1555ae8404..0000000000 --- a/db/migrate/20111127155345_create_merge_requests.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CreateMergeRequests < ActiveRecord::Migration - def change - create_table :merge_requests do |t| - t.string :target_branch, :null => false - t.string :source_branch, :null => false - t.integer :project_id, :null => false - t.integer :author_id - t.integer :assignee_id - t.string :title - t.boolean :closed, :default => false, :null => false - - t.timestamps - end - end -end diff --git a/db/migrate/20111206213842_add_advanced_rights_to_team_member.rb b/db/migrate/20111206213842_add_advanced_rights_to_team_member.rb deleted file mode 100644 index e2695fdafa..0000000000 --- a/db/migrate/20111206213842_add_advanced_rights_to_team_member.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddAdvancedRightsToTeamMember < ActiveRecord::Migration - def change - add_column :users_projects, :repo_access, :integer, :default => 0, :null => false - add_column :users_projects, :project_access, :integer, :default => 0, :null => false - end -end diff --git a/db/migrate/20111206222316_migrate_to_new_rights.rb b/db/migrate/20111206222316_migrate_to_new_rights.rb deleted file mode 100644 index 22e0c1ce99..0000000000 --- a/db/migrate/20111206222316_migrate_to_new_rights.rb +++ /dev/null @@ -1,20 +0,0 @@ -class MigrateToNewRights < ActiveRecord::Migration - def up - # Repository access - UsersProject.update_all("repo_access = 2", :write => true) - UsersProject.update_all("repo_access = 1", :read => true, :write => false) - - # Project access - UsersProject.update_all("project_access = 1", :read => true, :write => false, :admin => false) - UsersProject.update_all("project_access = 2", :read => true, :write => true, :admin => false) - UsersProject.update_all("project_access = 3", :read => true, :write => true, :admin => true) - - # Remove old fields - remove_column :users_projects, :read - remove_column :users_projects, :write - remove_column :users_projects, :admin - end - - def down - end -end diff --git a/db/migrate/20111207211728_add_default_branch_to_project.rb b/db/migrate/20111207211728_add_default_branch_to_project.rb deleted file mode 100644 index 5c2107f7aa..0000000000 --- a/db/migrate/20111207211728_add_default_branch_to_project.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDefaultBranchToProject < ActiveRecord::Migration - def change - add_column :projects, :default_branch, :string, :null => false, :default => "master" - end -end diff --git a/db/migrate/20111214091851_create_web_hooks.rb b/db/migrate/20111214091851_create_web_hooks.rb deleted file mode 100644 index c6ba89c10e..0000000000 --- a/db/migrate/20111214091851_create_web_hooks.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateWebHooks < ActiveRecord::Migration - def change - create_table :web_hooks do |t| - t.string :url - t.integer :project_id - t.timestamps - end - end -end diff --git a/db/migrate/20111220190817_add_coloscheme_option_to_user.rb b/db/migrate/20111220190817_add_coloscheme_option_to_user.rb deleted file mode 100644 index fe06c3aa34..0000000000 --- a/db/migrate/20111220190817_add_coloscheme_option_to_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddColoschemeOptionToUser < ActiveRecord::Migration - def change - add_column :users, :dark_scheme, :boolean, :default => false, :null => false - end -end diff --git a/db/migrate/20111231111825_add_project_id_to_key.rb b/db/migrate/20111231111825_add_project_id_to_key.rb deleted file mode 100644 index dc80cbdb71..0000000000 --- a/db/migrate/20111231111825_add_project_id_to_key.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddProjectIdToKey < ActiveRecord::Migration - def change - add_column :keys, :project_id, :integer, :null => true - change_column :keys, :user_id, :integer, :null => true - end -end diff --git a/db/migrate/20120110180749_add_line_number_to_note.rb b/db/migrate/20120110180749_add_line_number_to_note.rb deleted file mode 100644 index 9bdcce3c47..0000000000 --- a/db/migrate/20120110180749_add_line_number_to_note.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLineNumberToNote < ActiveRecord::Migration - def change - add_column :notes, :line_code, :string, :null => true - end -end diff --git a/db/migrate/20120119202326_add_indexes.rb b/db/migrate/20120119202326_add_indexes.rb deleted file mode 100644 index ee07176a26..0000000000 --- a/db/migrate/20120119202326_add_indexes.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddIndexes < ActiveRecord::Migration - def change - add_index :issues, :project_id - add_index :merge_requests, :project_id - add_index :notes, :noteable_id - add_index :notes, :noteable_type - end - -end diff --git a/db/migrate/20120121122616_fix_noteable_id.rb b/db/migrate/20120121122616_fix_noteable_id.rb deleted file mode 100644 index d110e8cd63..0000000000 --- a/db/migrate/20120121122616_fix_noteable_id.rb +++ /dev/null @@ -1,8 +0,0 @@ -class FixNoteableId < ActiveRecord::Migration - def up - change_column :notes, :noteable_id, :string, :limit => 255 - end - - def down - end -end diff --git a/db/migrate/20120206170141_add_modularity_fields_to_project.rb b/db/migrate/20120206170141_add_modularity_fields_to_project.rb deleted file mode 100644 index d63de0c2be..0000000000 --- a/db/migrate/20120206170141_add_modularity_fields_to_project.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddModularityFieldsToProject < ActiveRecord::Migration - def change - add_column :projects, :issues_enabled, :boolean, :null => false, :default => true - add_column :projects, :wall_enabled, :boolean, :null => false, :default => true - add_column :projects, :merge_requests_enabled, :boolean, :null => false, :default => true - end -end diff --git a/db/migrate/20120215182305_create_protected_branches.rb b/db/migrate/20120215182305_create_protected_branches.rb deleted file mode 100644 index 841d08c33d..0000000000 --- a/db/migrate/20120215182305_create_protected_branches.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateProtectedBranches < ActiveRecord::Migration - def change - create_table :protected_branches do |t| - t.integer :project_id, :null => false - t.string :name, :null => false - - t.timestamps - end - end -end diff --git a/db/migrate/20120216085842_move_to_roles_permissions.rb b/db/migrate/20120216085842_move_to_roles_permissions.rb deleted file mode 100644 index 36d02cf972..0000000000 --- a/db/migrate/20120216085842_move_to_roles_permissions.rb +++ /dev/null @@ -1,22 +0,0 @@ -class MoveToRolesPermissions < ActiveRecord::Migration - def up - repo_n = 0 - repo_r = 1 - repo_rw = 2 - project_rwa = 3 - - - # Build masters and reset repo_access - UsersProject.update_all({:project_access => UsersProject::MASTER, :repo_access => 99 }, ["project_access = ?", project_rwa]) - - # Build other roles based on repo access - UsersProject.update_all ["project_access = ?", UsersProject::DEVELOPER], ["repo_access = ?", repo_rw] - UsersProject.update_all ["project_access = ?", UsersProject::REPORTER], ["repo_access = ?", repo_r] - UsersProject.update_all ["project_access = ?", UsersProject::GUEST], ["repo_access = ?", repo_n] - - remove_column :users_projects, :repo_access - end - - def down - end -end diff --git a/db/migrate/20120216215008_create_wikis.rb b/db/migrate/20120216215008_create_wikis.rb deleted file mode 100644 index 38947df389..0000000000 --- a/db/migrate/20120216215008_create_wikis.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateWikis < ActiveRecord::Migration - def change - create_table :wikis do |t| - t.string :title - t.text :content - t.integer :project_id - - t.timestamps - end - end -end diff --git a/db/migrate/20120219130957_add_slug_to_wiki.rb b/db/migrate/20120219130957_add_slug_to_wiki.rb deleted file mode 100644 index 5f2d5970a8..0000000000 --- a/db/migrate/20120219130957_add_slug_to_wiki.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddSlugToWiki < ActiveRecord::Migration - def change - add_column :wikis, :slug, :string - - end -end diff --git a/db/migrate/20120219140810_add_wiki_enabled_to_project.rb b/db/migrate/20120219140810_add_wiki_enabled_to_project.rb deleted file mode 100644 index ebd71bea84..0000000000 --- a/db/migrate/20120219140810_add_wiki_enabled_to_project.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddWikiEnabledToProject < ActiveRecord::Migration - def change - add_column :projects, :wiki_enabled, :boolean, :default => true, :null => false - - end -end diff --git a/db/migrate/20120219193300_add_user_to_wiki.rb b/db/migrate/20120219193300_add_user_to_wiki.rb deleted file mode 100644 index 8a6c0a06ef..0000000000 --- a/db/migrate/20120219193300_add_user_to_wiki.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddUserToWiki < ActiveRecord::Migration - def change - add_column :wikis, :user_id, :integer - - end -end diff --git a/db/migrate/20120228130210_create_events.rb b/db/migrate/20120228130210_create_events.rb deleted file mode 100644 index c01f557aaa..0000000000 --- a/db/migrate/20120228130210_create_events.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateEvents < ActiveRecord::Migration - def change - create_table :events do |t| - t.string :target_type, :null => true - t.integer :target_id, :null => true - - t.string :title, :null => true - t.text :data, :null => true - t.integer :project_id, :null => true - - t.timestamps - end - end -end diff --git a/db/migrate/20120228134252_add_action_to_event.rb b/db/migrate/20120228134252_add_action_to_event.rb deleted file mode 100644 index aade3d90a8..0000000000 --- a/db/migrate/20120228134252_add_action_to_event.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddActionToEvent < ActiveRecord::Migration - def change - add_column :events, :action, :integer, :null => true - end -end diff --git a/db/migrate/20120301185805_add_theme_to_user.rb b/db/migrate/20120301185805_add_theme_to_user.rb deleted file mode 100644 index 7c2e55692b..0000000000 --- a/db/migrate/20120301185805_add_theme_to_user.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddThemeToUser < ActiveRecord::Migration - def change - add_column :users, :theme_id, :integer, :null => false, :default => 1 - - end -end diff --git a/db/migrate/20120307095918_add_author_id_to_event.rb b/db/migrate/20120307095918_add_author_id_to_event.rb deleted file mode 100644 index 1d24d41e42..0000000000 --- a/db/migrate/20120307095918_add_author_id_to_event.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAuthorIdToEvent < ActiveRecord::Migration - def change - add_column :events, :author_id, :integer, :null => true - end -end diff --git a/db/migrate/20120315111711_add_commits_diff_store_to_merge_request.rb b/db/migrate/20120315111711_add_commits_diff_store_to_merge_request.rb deleted file mode 100644 index 2dc1dfb4b6..0000000000 --- a/db/migrate/20120315111711_add_commits_diff_store_to_merge_request.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddCommitsDiffStoreToMergeRequest < ActiveRecord::Migration - def change - add_column :merge_requests, :st_commits, :text, :null => true - add_column :merge_requests, :st_diffs, :text, :null => true - end -end diff --git a/db/migrate/20120315132931_add_merged_to_merge_request.rb b/db/migrate/20120315132931_add_merged_to_merge_request.rb deleted file mode 100644 index 2deb59e442..0000000000 --- a/db/migrate/20120315132931_add_merged_to_merge_request.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMergedToMergeRequest < ActiveRecord::Migration - def change - add_column :merge_requests, :merged, :boolean, :null => false, :default => false - end -end diff --git a/db/migrate/20120317095543_add_description_to_issues.rb b/db/migrate/20120317095543_add_description_to_issues.rb deleted file mode 100644 index e47e3f8e89..0000000000 --- a/db/migrate/20120317095543_add_description_to_issues.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDescriptionToIssues < ActiveRecord::Migration - def change - add_column :issues, :description, :text - end -end diff --git a/db/migrate/20120323221339_add_bio_field_to_user.rb b/db/migrate/20120323221339_add_bio_field_to_user.rb deleted file mode 100644 index 80a4dec597..0000000000 --- a/db/migrate/20120323221339_add_bio_field_to_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddBioFieldToUser < ActiveRecord::Migration - def change - add_column :users, :bio, :string, :null => true - end -end diff --git a/db/migrate/20120329170745_add_automerge_to_merge_request.rb b/db/migrate/20120329170745_add_automerge_to_merge_request.rb deleted file mode 100644 index de7c68ee1c..0000000000 --- a/db/migrate/20120329170745_add_automerge_to_merge_request.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAutomergeToMergeRequest < ActiveRecord::Migration - def change - add_column :merge_requests, :state, :integer, :null => false, :default => 1 - end -end diff --git a/db/migrate/20120405211750_increase_mr_text_column_size.rb b/db/migrate/20120405211750_increase_mr_text_column_size.rb deleted file mode 100644 index 4fbef622da..0000000000 --- a/db/migrate/20120405211750_increase_mr_text_column_size.rb +++ /dev/null @@ -1,10 +0,0 @@ -class IncreaseMrTextColumnSize < ActiveRecord::Migration - def up - # MYSQL LARGETEXT for merge request - change_column :merge_requests, :st_diffs, :text, :limit => 4294967295 - change_column :merge_requests, :st_commits, :text, :limit => 4294967295 - end - - def down - end -end diff --git a/db/migrate/20120408180246_create_milestones.rb b/db/migrate/20120408180246_create_milestones.rb deleted file mode 100644 index ed3a510d66..0000000000 --- a/db/migrate/20120408180246_create_milestones.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateMilestones < ActiveRecord::Migration - def change - create_table :milestones do |t| - t.string :title, :null => false - t.integer :project_id, :null => false - t.text :description - t.date :due_date - t.boolean :closed, :default => false, :null => false - t.timestamps - end - end -end diff --git a/db/migrate/20120408181910_add_milestone_id_to_issue.rb b/db/migrate/20120408181910_add_milestone_id_to_issue.rb deleted file mode 100644 index a6b44090c1..0000000000 --- a/db/migrate/20120408181910_add_milestone_id_to_issue.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMilestoneIdToIssue < ActiveRecord::Migration - def change - add_column :issues, :milestone_id, :integer, :null => true - end -end diff --git a/db/migrate/20120413135904_add_blocked_field_to_user.rb b/db/migrate/20120413135904_add_blocked_field_to_user.rb deleted file mode 100644 index 050450bf03..0000000000 --- a/db/migrate/20120413135904_add_blocked_field_to_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddBlockedFieldToUser < ActiveRecord::Migration - def change - add_column :users, :blocked, :boolean, :null => false, :default => false - end -end diff --git a/db/migrate/20120627145613_remove_critical_from_issue.rb b/db/migrate/20120627145613_remove_critical_from_issue.rb deleted file mode 100644 index f8d0797197..0000000000 --- a/db/migrate/20120627145613_remove_critical_from_issue.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RemoveCriticalFromIssue < ActiveRecord::Migration - def up - remove_column :issues, :critical - end - - def down - add_column :issues, :critical, :boolean, :null => true, :default => false - end -end diff --git a/db/migrate/20120706065612_add_lockable_to_users.rb b/db/migrate/20120706065612_add_lockable_to_users.rb deleted file mode 100644 index cf86e66087..0000000000 --- a/db/migrate/20120706065612_add_lockable_to_users.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddLockableToUsers < ActiveRecord::Migration - def change - add_column :users, :failed_attempts, :integer, :default => 0 - add_column :users, :locked_at, :datetime - end -end diff --git a/db/migrate/20120712080407_add_type_to_web_hook.rb b/db/migrate/20120712080407_add_type_to_web_hook.rb deleted file mode 100644 index 18ab024c81..0000000000 --- a/db/migrate/20120712080407_add_type_to_web_hook.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTypeToWebHook < ActiveRecord::Migration - def change - add_column :web_hooks, :type, :string, :default => "ProjectHook" - end -end diff --git a/db/migrate/20120729131232_add_extern_auth_provider_to_users.rb b/db/migrate/20120729131232_add_extern_auth_provider_to_users.rb deleted file mode 100644 index d5e66ba4d3..0000000000 --- a/db/migrate/20120729131232_add_extern_auth_provider_to_users.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddExternAuthProviderToUsers < ActiveRecord::Migration - def change - add_column :users, :extern_uid, :string - add_column :users, :provider, :string - - add_index :users, [:extern_uid, :provider], :unique => true - end -end diff --git a/db/migrate/20120905043334_set_default_branch_default_to_nil.rb b/db/migrate/20120905043334_set_default_branch_default_to_nil.rb deleted file mode 100644 index f5956fe875..0000000000 --- a/db/migrate/20120905043334_set_default_branch_default_to_nil.rb +++ /dev/null @@ -1,12 +0,0 @@ -class SetDefaultBranchDefaultToNil < ActiveRecord::Migration - def up - # Set the default_branch to allow nil, and default it to nil - change_column_null(:projects, :default_branch, true) - change_column_default(:projects, :default_branch, nil) - end - - def down - change_column_null(:projects, :default_branch, false) - change_column_default(:projects, :default_branch, 'master') - end -end diff --git a/db/migrate/20121002150926_create_groups.rb b/db/migrate/20121002150926_create_groups.rb deleted file mode 100644 index ac178294c0..0000000000 --- a/db/migrate/20121002150926_create_groups.rb +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index 683fbfec51..0000000000 --- a/db/migrate/20121002151033_add_group_id_to_project.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddGroupIdToProject < ActiveRecord::Migration - def change - add_column :projects, :group_id, :integer - end -end diff --git a/db/migrate/20121009205010_postgres_create_integer_cast.rb b/db/migrate/20121009205010_postgres_create_integer_cast.rb deleted file mode 100644 index b9a971387d..0000000000 --- a/db/migrate/20121009205010_postgres_create_integer_cast.rb +++ /dev/null @@ -1,15 +0,0 @@ -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 diff --git a/db/migrate/20121026114600_add_milestone_id_to_merge_requests.rb b/db/migrate/20121026114600_add_milestone_id_to_merge_requests.rb deleted file mode 100644 index b516772434..0000000000 --- a/db/migrate/20121026114600_add_milestone_id_to_merge_requests.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMilestoneIdToMergeRequests < ActiveRecord::Migration - def change - add_column :merge_requests, :milestone_id, :integer, :null => true - end -end diff --git a/db/migrate/20121119170638_create_services.rb b/db/migrate/20121119170638_create_services.rb deleted file mode 100644 index f7cac1445a..0000000000 --- a/db/migrate/20121119170638_create_services.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateServices < ActiveRecord::Migration - def change - create_table :services do |t| - t.string :type - t.string :title - t.string :token - t.integer :project_id, null: false - - t.timestamps - end - end -end diff --git a/db/migrate/20121120051432_add_service_id_to_web_hook.rb b/db/migrate/20121120051432_add_service_id_to_web_hook.rb deleted file mode 100644 index 77adf92578..0000000000 --- a/db/migrate/20121120051432_add_service_id_to_web_hook.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddServiceIdToWebHook < ActiveRecord::Migration - def change - add_column :web_hooks, :service_id, :integer, null: true - end -end diff --git a/db/migrate/20121120103700_add_active_to_service.rb b/db/migrate/20121120103700_add_active_to_service.rb deleted file mode 100644 index f45ef52e6f..0000000000 --- a/db/migrate/20121120103700_add_active_to_service.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddActiveToService < ActiveRecord::Migration - def change - add_column :services, :active, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20121120113838_add_project_url_to_service.rb b/db/migrate/20121120113838_add_project_url_to_service.rb deleted file mode 100644 index 13ffbdb192..0000000000 --- a/db/migrate/20121120113838_add_project_url_to_service.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddProjectUrlToService < ActiveRecord::Migration - def change - add_column :services, :project_url, :string, null: true - end -end diff --git a/db/migrate/20121122145155_convert_group_to_namespace.rb b/db/migrate/20121122145155_convert_group_to_namespace.rb deleted file mode 100644 index fc8b023d81..0000000000 --- a/db/migrate/20121122145155_convert_group_to_namespace.rb +++ /dev/null @@ -1,13 +0,0 @@ -class ConvertGroupToNamespace < ActiveRecord::Migration - def up - rename_table 'groups', 'namespaces' - add_column :namespaces, :type, :string, null: true - - # Migrate old groups - Namespace.update_all(type: 'Group') - end - - def down - raise 'Rollback is not allowed' - end -end diff --git a/db/migrate/20121122150932_add_namespace_id_to_project.rb b/db/migrate/20121122150932_add_namespace_id_to_project.rb deleted file mode 100644 index 904f3aa32b..0000000000 --- a/db/migrate/20121122150932_add_namespace_id_to_project.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddNamespaceIdToProject < ActiveRecord::Migration - def change - rename_column :projects, :group_id, :namespace_id - end -end diff --git a/db/migrate/20121123104937_add_username_to_user.rb b/db/migrate/20121123104937_add_username_to_user.rb deleted file mode 100644 index 04232a119d..0000000000 --- a/db/migrate/20121123104937_add_username_to_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddUsernameToUser < ActiveRecord::Migration - def change - add_column :users, :username, :string, null: true - end -end diff --git a/db/migrate/20121123164910_rename_code_to_path.rb b/db/migrate/20121123164910_rename_code_to_path.rb deleted file mode 100644 index fb10baf58c..0000000000 --- a/db/migrate/20121123164910_rename_code_to_path.rb +++ /dev/null @@ -1,11 +0,0 @@ -class RenameCodeToPath < ActiveRecord::Migration - def up - remove_column :projects, :code - rename_column :namespaces, :code, :path - end - - def down - add_column :projects, :code, :string - rename_column :namespaces, :path, :code - end -end diff --git a/db/migrate/20121203154450_add_events_indices.rb b/db/migrate/20121203154450_add_events_indices.rb deleted file mode 100644 index 502a2ccbcd..0000000000 --- a/db/migrate/20121203154450_add_events_indices.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddEventsIndices < ActiveRecord::Migration - def change - add_index :events, :project_id - add_index :events, :author_id - add_index :events, :action - add_index :events, :target_type - end -end diff --git a/db/migrate/20121203160507_more_indices.rb b/db/migrate/20121203160507_more_indices.rb deleted file mode 100644 index 52170a7c59..0000000000 --- a/db/migrate/20121203160507_more_indices.rb +++ /dev/null @@ -1,26 +0,0 @@ -class MoreIndices < ActiveRecord::Migration - def change - add_index :notes, :project_id - add_index :namespaces, :owner_id - add_index :keys, :user_id - - add_index :projects, :namespace_id - add_index :projects, :owner_id - - add_index :services, :project_id - add_index :snippets, :project_id - - add_index :users_projects, :project_id - - # Issues - add_index :issues, :assignee_id - add_index :issues, :milestone_id - add_index :issues, :author_id - - # Merge Requests - add_index :merge_requests, :assignee_id - add_index :merge_requests, :milestone_id - add_index :merge_requests, :author_id - - end -end diff --git a/db/migrate/20121205201726_add_more_indexes.rb b/db/migrate/20121205201726_add_more_indexes.rb deleted file mode 100644 index a2b36f7fdf..0000000000 --- a/db/migrate/20121205201726_add_more_indexes.rb +++ /dev/null @@ -1,44 +0,0 @@ -class AddMoreIndexes < ActiveRecord::Migration - def change - add_index :events, :created_at - add_index :events, :target_id - - add_index :issues, :closed - add_index :issues, :created_at - add_index :issues, :title - - add_index :keys, :identifier - # FIXME: MySQL can't index text columns - #add_index :keys, :key - add_index :keys, :project_id - - add_index :merge_requests, :closed - add_index :merge_requests, :created_at - add_index :merge_requests, :source_branch - add_index :merge_requests, :target_branch - add_index :merge_requests, :title - - add_index :milestones, :due_date - add_index :milestones, :project_id - - add_index :namespaces, :name - add_index :namespaces, :path - add_index :namespaces, :type - - add_index :notes, :created_at - - add_index :snippets, :created_at - add_index :snippets, :expires_at - - add_index :users, :admin - add_index :users, :blocked - add_index :users, :name - add_index :users, :username - - add_index :users_projects, :project_access - add_index :users_projects, :user_id - - add_index :wikis, :project_id - add_index :wikis, :slug - end -end diff --git a/db/migrate/20121218164840_move_noteable_commit_to_own_field.rb b/db/migrate/20121218164840_move_noteable_commit_to_own_field.rb deleted file mode 100644 index 6f2da4136a..0000000000 --- a/db/migrate/20121218164840_move_noteable_commit_to_own_field.rb +++ /dev/null @@ -1,20 +0,0 @@ -class MoveNoteableCommitToOwnField < ActiveRecord::Migration - def up - add_column :notes, :commit_id, :string, null: true - add_column :notes, :new_noteable_id, :integer, null: true - Note.where(noteable_type: 'Commit').update_all('commit_id = noteable_id') - - if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' - Note.where("noteable_type != 'Commit'").update_all('new_noteable_id = CAST (noteable_id AS INTEGER)') - else - Note.where("noteable_type != 'Commit'").update_all('new_noteable_id = noteable_id') - end - - remove_column :notes, :noteable_id - rename_column :notes, :new_noteable_id, :noteable_id - end - - def down - raise ActiveRecord::IrreversibleMigration - end -end diff --git a/db/migrate/20121219095402_indices_for_notes.rb b/db/migrate/20121219095402_indices_for_notes.rb deleted file mode 100644 index 4c5d041ce8..0000000000 --- a/db/migrate/20121219095402_indices_for_notes.rb +++ /dev/null @@ -1,6 +0,0 @@ -class IndicesForNotes < ActiveRecord::Migration - def change - add_index :notes, :commit_id - add_index :notes, [:project_id, :noteable_type] - end -end diff --git a/db/migrate/20121219183753_create_user_teams.rb b/db/migrate/20121219183753_create_user_teams.rb deleted file mode 100644 index 65c4d05398..0000000000 --- a/db/migrate/20121219183753_create_user_teams.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateUserTeams < ActiveRecord::Migration - def change - create_table :user_teams do |t| - t.string :name - t.string :path - t.integer :owner_id - - t.timestamps - end - end -end diff --git a/db/migrate/20121220064104_create_user_team_project_relationships.rb b/db/migrate/20121220064104_create_user_team_project_relationships.rb deleted file mode 100644 index 8eb654c872..0000000000 --- a/db/migrate/20121220064104_create_user_team_project_relationships.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateUserTeamProjectRelationships < ActiveRecord::Migration - def change - create_table :user_team_project_relationships do |t| - t.integer :project_id - t.integer :user_team_id - t.integer :greatest_access - - t.timestamps - end - end -end diff --git a/db/migrate/20121220064453_create_user_team_user_relationships.rb b/db/migrate/20121220064453_create_user_team_user_relationships.rb deleted file mode 100644 index 7783b0ae43..0000000000 --- a/db/migrate/20121220064453_create_user_team_user_relationships.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateUserTeamUserRelationships < ActiveRecord::Migration - def change - create_table :user_team_user_relationships do |t| - t.integer :user_id - t.integer :user_team_id - t.boolean :group_admin - t.integer :permission - - t.timestamps - end - end -end diff --git a/db/migrate/20121220064453_init_schema.rb b/db/migrate/20121220064453_init_schema.rb new file mode 100644 index 0000000000..90f5eb08e8 --- /dev/null +++ b/db/migrate/20121220064453_init_schema.rb @@ -0,0 +1,306 @@ +class InitSchema < ActiveRecord::Migration + def up + + create_table "events", force: true do |t| + t.string "target_type" + t.integer "target_id" + t.string "title" + t.text "data" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "action" + t.integer "author_id" + end + + add_index "events", ["action"], name: "index_events_on_action", using: :btree + add_index "events", ["author_id"], name: "index_events_on_author_id", using: :btree + add_index "events", ["created_at"], name: "index_events_on_created_at", using: :btree + add_index "events", ["project_id"], name: "index_events_on_project_id", using: :btree + add_index "events", ["target_id"], name: "index_events_on_target_id", using: :btree + add_index "events", ["target_type"], name: "index_events_on_target_type", using: :btree + + create_table "issues", force: true do |t| + t.string "title" + t.integer "assignee_id" + t.integer "author_id" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "closed", default: false, null: false + t.integer "position", default: 0 + t.string "branch_name" + t.text "description" + t.integer "milestone_id" + end + + add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree + add_index "issues", ["author_id"], name: "index_issues_on_author_id", using: :btree + add_index "issues", ["closed"], name: "index_issues_on_closed", using: :btree + add_index "issues", ["created_at"], name: "index_issues_on_created_at", using: :btree + add_index "issues", ["milestone_id"], name: "index_issues_on_milestone_id", using: :btree + add_index "issues", ["project_id"], name: "index_issues_on_project_id", using: :btree + add_index "issues", ["title"], name: "index_issues_on_title", using: :btree + + create_table "keys", force: true do |t| + t.integer "user_id" + t.datetime "created_at" + t.datetime "updated_at" + t.text "key" + t.string "title" + t.string "identifier" + t.integer "project_id" + end + + add_index "keys", ["identifier"], name: "index_keys_on_identifier", using: :btree + add_index "keys", ["project_id"], name: "index_keys_on_project_id", using: :btree + add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree + + create_table "merge_requests", force: true do |t| + t.string "target_branch", null: false + t.string "source_branch", null: false + t.integer "project_id", null: false + t.integer "author_id" + t.integer "assignee_id" + t.string "title" + t.boolean "closed", default: false, null: false + t.datetime "created_at" + t.datetime "updated_at" + t.text "st_commits", limit: 2147483647 + t.text "st_diffs", limit: 2147483647 + t.boolean "merged", default: false, null: false + t.integer "state", default: 1, null: false + t.integer "milestone_id" + end + + add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree + add_index "merge_requests", ["author_id"], name: "index_merge_requests_on_author_id", using: :btree + add_index "merge_requests", ["closed"], name: "index_merge_requests_on_closed", using: :btree + add_index "merge_requests", ["created_at"], name: "index_merge_requests_on_created_at", using: :btree + add_index "merge_requests", ["milestone_id"], name: "index_merge_requests_on_milestone_id", using: :btree + add_index "merge_requests", ["project_id"], name: "index_merge_requests_on_project_id", using: :btree + add_index "merge_requests", ["source_branch"], name: "index_merge_requests_on_source_branch", using: :btree + add_index "merge_requests", ["target_branch"], name: "index_merge_requests_on_target_branch", using: :btree + add_index "merge_requests", ["title"], name: "index_merge_requests_on_title", using: :btree + + create_table "milestones", force: true do |t| + t.string "title", null: false + t.integer "project_id", null: false + t.text "description" + t.date "due_date" + t.boolean "closed", default: false, null: false + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "milestones", ["due_date"], name: "index_milestones_on_due_date", using: :btree + add_index "milestones", ["project_id"], name: "index_milestones_on_project_id", using: :btree + + create_table "namespaces", force: true do |t| + t.string "name", null: false + t.string "path", null: false + t.integer "owner_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "type" + end + + add_index "namespaces", ["name"], name: "index_namespaces_on_name", using: :btree + add_index "namespaces", ["owner_id"], name: "index_namespaces_on_owner_id", using: :btree + add_index "namespaces", ["path"], name: "index_namespaces_on_path", using: :btree + add_index "namespaces", ["type"], name: "index_namespaces_on_type", using: :btree + + create_table "notes", force: true do |t| + t.text "note" + t.string "noteable_type" + t.integer "author_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "project_id" + t.string "attachment" + t.string "line_code" + t.string "commit_id" + t.integer "noteable_id" + end + + add_index "notes", ["commit_id"], name: "index_notes_on_commit_id", using: :btree + add_index "notes", ["created_at"], name: "index_notes_on_created_at", using: :btree + add_index "notes", ["noteable_type"], name: "index_notes_on_noteable_type", using: :btree + add_index "notes", ["project_id", "noteable_type"], name: "index_notes_on_project_id_and_noteable_type", using: :btree + add_index "notes", ["project_id"], name: "index_notes_on_project_id", using: :btree + + create_table "projects", force: true do |t| + t.string "name" + t.string "path" + t.text "description" + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "private_flag", default: true, null: false + t.integer "owner_id" + t.string "default_branch" + t.boolean "issues_enabled", default: true, null: false + 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 "namespace_id" + end + + add_index "projects", ["namespace_id"], name: "index_projects_on_namespace_id", using: :btree + add_index "projects", ["owner_id"], name: "index_projects_on_owner_id", using: :btree + + create_table "protected_branches", force: true do |t| + t.integer "project_id", null: false + t.string "name", null: false + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "services", force: true do |t| + t.string "type" + t.string "title" + t.string "token" + t.integer "project_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "active", default: false, null: false + t.string "project_url" + end + + add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree + + create_table "snippets", force: true do |t| + t.string "title" + t.text "content" + t.integer "author_id", null: false + t.integer "project_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.string "file_name" + t.datetime "expires_at" + end + + add_index "snippets", ["created_at"], name: "index_snippets_on_created_at", using: :btree + add_index "snippets", ["expires_at"], name: "index_snippets_on_expires_at", using: :btree + add_index "snippets", ["project_id"], name: "index_snippets_on_project_id", using: :btree + + create_table "taggings", force: true do |t| + t.integer "tag_id" + t.integer "taggable_id" + t.string "taggable_type" + t.integer "tagger_id" + t.string "tagger_type" + t.string "context" + t.datetime "created_at" + end + + add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id", using: :btree + add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree + + create_table "tags", force: true do |t| + t.string "name" + end + + create_table "user_team_project_relationships", force: true do |t| + t.integer "project_id" + t.integer "user_team_id" + t.integer "greatest_access" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "user_team_user_relationships", force: true do |t| + t.integer "user_id" + t.integer "user_team_id" + t.boolean "group_admin" + t.integer "permission" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "user_teams", force: true do |t| + t.string "name" + t.string "path" + t.integer "owner_id" + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "users", force: true do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.integer "sign_in_count", default: 0 + t.datetime "current_sign_in_at" + t.datetime "last_sign_in_at" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.datetime "created_at" + t.datetime "updated_at" + t.string "name" + t.boolean "admin", default: false, null: false + t.integer "projects_limit", default: 10 + t.string "skype", default: "", null: false + t.string "linkedin", default: "", null: false + t.string "twitter", default: "", null: false + t.string "authentication_token" + t.boolean "dark_scheme", default: false, null: false + t.integer "theme_id", default: 1, null: false + t.string "bio" + t.boolean "blocked", default: false, null: false + t.integer "failed_attempts", default: 0 + t.datetime "locked_at" + t.string "extern_uid" + t.string "provider" + t.string "username" + end + + add_index "users", ["admin"], name: "index_users_on_admin", using: :btree + add_index "users", ["blocked"], name: "index_users_on_blocked", using: :btree + add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree + add_index "users", ["extern_uid", "provider"], name: "index_users_on_extern_uid_and_provider", unique: true, using: :btree + add_index "users", ["name"], name: "index_users_on_name", using: :btree + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree + add_index "users", ["username"], name: "index_users_on_username", using: :btree + + create_table "users_projects", force: true do |t| + t.integer "user_id", null: false + t.integer "project_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "project_access", default: 0, null: false + end + + add_index "users_projects", ["project_access"], name: "index_users_projects_on_project_access", using: :btree + add_index "users_projects", ["project_id"], name: "index_users_projects_on_project_id", using: :btree + add_index "users_projects", ["user_id"], name: "index_users_projects_on_user_id", using: :btree + + create_table "web_hooks", force: true do |t| + t.string "url" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.string "type", default: "ProjectHook" + t.integer "service_id" + end + + create_table "wikis", force: true do |t| + t.string "title" + t.text "content" + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.string "slug" + t.integer "user_id" + end + + add_index "wikis", ["project_id"], name: "index_wikis_on_project_id", using: :btree + add_index "wikis", ["slug"], name: "index_wikis_on_slug", using: :btree + + end + + def down + raise "Can not revert initial migration" + end +end diff --git a/db/migrate/20130506095501_remove_project_id_from_key.rb b/db/migrate/20130506095501_remove_project_id_from_key.rb index 4214fd45d1..6b794cfb5c 100644 --- a/db/migrate/20130506095501_remove_project_id_from_key.rb +++ b/db/migrate/20130506095501_remove_project_id_from_key.rb @@ -4,7 +4,7 @@ class RemoveProjectIdFromKey < ActiveRecord::Migration Key.where('project_id IS NOT NULL').update_all(type: 'DeployKey') DeployKey.all.each do |key| - project = Project.find_by_id(key.project_id) + project = Project.find_by(id: key.project_id) if project project.deploy_keys << key print '.' diff --git a/db/migrate/20130809124851_add_permission_check_to_user.rb b/db/migrate/20130809124851_add_permission_check_to_user.rb new file mode 100644 index 0000000000..c26157904c --- /dev/null +++ b/db/migrate/20130809124851_add_permission_check_to_user.rb @@ -0,0 +1,5 @@ +class AddPermissionCheckToUser < ActiveRecord::Migration + def change + add_column :users, :last_credential_check_at, :datetime + end +end diff --git a/db/migrate/20131106151520_remove_default_branch.rb b/db/migrate/20131106151520_remove_default_branch.rb new file mode 100644 index 0000000000..88a890eb3e --- /dev/null +++ b/db/migrate/20131106151520_remove_default_branch.rb @@ -0,0 +1,9 @@ +class RemoveDefaultBranch < ActiveRecord::Migration + def up + remove_column :projects, :default_branch + end + + def down + add_column :projects, :default_branch, :string + end +end diff --git a/db/migrate/20131112114325_create_broadcast_messages.rb b/db/migrate/20131112114325_create_broadcast_messages.rb new file mode 100644 index 0000000000..147178e9dc --- /dev/null +++ b/db/migrate/20131112114325_create_broadcast_messages.rb @@ -0,0 +1,12 @@ +class CreateBroadcastMessages < ActiveRecord::Migration + def change + create_table :broadcast_messages do |t| + t.text :message, null: false + t.datetime :starts_at + t.datetime :ends_at + t.integer :alert_type + + t.timestamps + end + end +end diff --git a/db/migrate/20131112220935_add_visibility_level_to_projects.rb b/db/migrate/20131112220935_add_visibility_level_to_projects.rb new file mode 100644 index 0000000000..cf1e9f912a --- /dev/null +++ b/db/migrate/20131112220935_add_visibility_level_to_projects.rb @@ -0,0 +1,13 @@ +class AddVisibilityLevelToProjects < ActiveRecord::Migration + def self.up + add_column :projects, :visibility_level, :integer, :default => 0, :null => false + Project.where(public: true).update_all(visibility_level: Gitlab::VisibilityLevel::PUBLIC) + remove_column :projects, :public + end + + def self.down + add_column :projects, :public, :boolean, :default => false, :null => false + Project.where(visibility_level: Gitlab::VisibilityLevel::PUBLIC).update_all(public: true) + remove_column :projects, :visibility_level + end +end diff --git a/db/migrate/20131129154016_add_archived_to_projects.rb b/db/migrate/20131129154016_add_archived_to_projects.rb new file mode 100644 index 0000000000..917e690ba4 --- /dev/null +++ b/db/migrate/20131129154016_add_archived_to_projects.rb @@ -0,0 +1,5 @@ +class AddArchivedToProjects < ActiveRecord::Migration + def change + add_column :projects, :archived, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20131130165425_add_color_and_font_to_broadcast_messages.rb b/db/migrate/20131130165425_add_color_and_font_to_broadcast_messages.rb new file mode 100644 index 0000000000..473f355ece --- /dev/null +++ b/db/migrate/20131130165425_add_color_and_font_to_broadcast_messages.rb @@ -0,0 +1,6 @@ +class AddColorAndFontToBroadcastMessages < ActiveRecord::Migration + def change + add_column :broadcast_messages, :color, :string + add_column :broadcast_messages, :font, :string + end +end diff --git a/db/migrate/20131202192556_add_event_fields_for_web_hook.rb b/db/migrate/20131202192556_add_event_fields_for_web_hook.rb new file mode 100644 index 0000000000..d29e996852 --- /dev/null +++ b/db/migrate/20131202192556_add_event_fields_for_web_hook.rb @@ -0,0 +1,7 @@ +class AddEventFieldsForWebHook < ActiveRecord::Migration + def change + add_column :web_hooks, :push_events, :boolean, default: true, null: false + add_column :web_hooks, :issues_events, :boolean, default: false, null: false + add_column :web_hooks, :merge_requests_events, :boolean, default: false, null: false + end +end diff --git a/db/migrate/20131214224427_add_hide_no_ssh_key_to_users.rb b/db/migrate/20131214224427_add_hide_no_ssh_key_to_users.rb new file mode 100644 index 0000000000..7cec79e7ee --- /dev/null +++ b/db/migrate/20131214224427_add_hide_no_ssh_key_to_users.rb @@ -0,0 +1,5 @@ +class AddHideNoSshKeyToUsers < ActiveRecord::Migration + def change + add_column :users, :hide_no_ssh_key, :boolean, :default => false + end +end diff --git a/db/migrate/20131217102743_add_recipients_to_service.rb b/db/migrate/20131217102743_add_recipients_to_service.rb new file mode 100644 index 0000000000..9695c25135 --- /dev/null +++ b/db/migrate/20131217102743_add_recipients_to_service.rb @@ -0,0 +1,5 @@ +class AddRecipientsToService < ActiveRecord::Migration + def change + add_column :services, :recipients, :text + end +end diff --git a/db/migrate/20140116231608_add_website_url_to_users.rb b/db/migrate/20140116231608_add_website_url_to_users.rb new file mode 100644 index 0000000000..0996fdcad7 --- /dev/null +++ b/db/migrate/20140116231608_add_website_url_to_users.rb @@ -0,0 +1,5 @@ +class AddWebsiteUrlToUsers < ActiveRecord::Migration + def change + add_column :users, :website_url, :string, {:null => false, :default => ''} + end +end diff --git a/db/migrate/20140122112253_create_merge_request_diffs.rb b/db/migrate/20140122112253_create_merge_request_diffs.rb new file mode 100644 index 0000000000..ef592305a2 --- /dev/null +++ b/db/migrate/20140122112253_create_merge_request_diffs.rb @@ -0,0 +1,12 @@ +class CreateMergeRequestDiffs < ActiveRecord::Migration + def change + create_table :merge_request_diffs do |t| + t.string :state, null: false, default: 'collected' + t.text :st_commits, null: true, limit: 2147483647 + t.text :st_diffs, null: true, limit: 2147483647 + t.integer :merge_request_id, null: false + + t.timestamps + end + end +end diff --git a/db/migrate/20140122114406_migrate_mr_diffs.rb b/db/migrate/20140122114406_migrate_mr_diffs.rb new file mode 100644 index 0000000000..1595e2b647 --- /dev/null +++ b/db/migrate/20140122114406_migrate_mr_diffs.rb @@ -0,0 +1,9 @@ +class MigrateMrDiffs < ActiveRecord::Migration + def self.up + execute "INSERT INTO merge_request_diffs ( merge_request_id, st_commits, st_diffs ) SELECT id, st_commits, st_diffs FROM merge_requests" + end + + def self.down + MergeRequestDiff.delete_all + end +end diff --git a/db/migrate/20140122122549_remove_m_rdiff_fields.rb b/db/migrate/20140122122549_remove_m_rdiff_fields.rb new file mode 100644 index 0000000000..8f863d85a6 --- /dev/null +++ b/db/migrate/20140122122549_remove_m_rdiff_fields.rb @@ -0,0 +1,21 @@ +class RemoveMRdiffFields < ActiveRecord::Migration + def up + remove_column :merge_requests, :st_commits + remove_column :merge_requests, :st_diffs + end + + def down + add_column :merge_requests, :st_commits, :text, null: true, limit: 2147483647 + add_column :merge_requests, :st_diffs, :text, null: true, limit: 2147483647 + + if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' + execute "UPDATE merge_requests mr + SET (st_commits, st_diffs) = (md.st_commits, md.st_diffs) + FROM merge_request_diffs md + WHERE md.merge_request_id = mr.id" + else + execute "UPDATE merge_requests mr, merge_request_diffs md SET mr.st_commits = md.st_commits WHERE md.merge_request_id = mr.id" + execute "UPDATE merge_requests mr, merge_request_diffs md SET mr.st_diffs = md.st_diffs WHERE md.merge_request_id = mr.id" + end + end +end diff --git a/db/migrate/20140127170938_add_group_avatars.rb b/db/migrate/20140127170938_add_group_avatars.rb new file mode 100644 index 0000000000..2911096dd5 --- /dev/null +++ b/db/migrate/20140127170938_add_group_avatars.rb @@ -0,0 +1,5 @@ +class AddGroupAvatars < ActiveRecord::Migration + def change + add_column :namespaces, :avatar, :string + end +end diff --git a/db/migrate/20140209025651_create_emails.rb b/db/migrate/20140209025651_create_emails.rb new file mode 100644 index 0000000000..cb78c4af11 --- /dev/null +++ b/db/migrate/20140209025651_create_emails.rb @@ -0,0 +1,13 @@ +class CreateEmails < ActiveRecord::Migration + def change + create_table :emails do |t| + t.integer :user_id, null: false + t.string :email, null: false + + t.timestamps + end + + add_index :emails, :user_id + add_index :emails, :email, unique: true + end +end diff --git a/db/migrate/20140214102325_add_api_key_to_services.rb b/db/migrate/20140214102325_add_api_key_to_services.rb new file mode 100644 index 0000000000..30eeca2c1f --- /dev/null +++ b/db/migrate/20140214102325_add_api_key_to_services.rb @@ -0,0 +1,5 @@ +class AddApiKeyToServices < ActiveRecord::Migration + def change + add_column :services, :api_key, :string + end +end diff --git a/db/migrate/20140304005354_add_index_merge_request_diffs_on_merge_request_id.rb b/db/migrate/20140304005354_add_index_merge_request_diffs_on_merge_request_id.rb new file mode 100644 index 0000000000..65d28e8cb0 --- /dev/null +++ b/db/migrate/20140304005354_add_index_merge_request_diffs_on_merge_request_id.rb @@ -0,0 +1,5 @@ +class AddIndexMergeRequestDiffsOnMergeRequestId < ActiveRecord::Migration + def change + add_index :merge_request_diffs, :merge_request_id, unique: true + end +end diff --git a/db/migrate/20140305193308_add_tag_push_hooks_to_project_hook.rb b/db/migrate/20140305193308_add_tag_push_hooks_to_project_hook.rb new file mode 100644 index 0000000000..7017148702 --- /dev/null +++ b/db/migrate/20140305193308_add_tag_push_hooks_to_project_hook.rb @@ -0,0 +1,5 @@ +class AddTagPushHooksToProjectHook < ActiveRecord::Migration + def change + add_column :web_hooks, :tag_push_events, :boolean, default: false + end +end diff --git a/db/migrate/20140312145357_add_import_status_to_project.rb b/db/migrate/20140312145357_add_import_status_to_project.rb new file mode 100644 index 0000000000..ef972e8342 --- /dev/null +++ b/db/migrate/20140312145357_add_import_status_to_project.rb @@ -0,0 +1,5 @@ +class AddImportStatusToProject < ActiveRecord::Migration + def change + add_column :projects, :import_status, :string + end +end diff --git a/db/migrate/20140313092127_migrate_already_imported_projects.rb b/db/migrate/20140313092127_migrate_already_imported_projects.rb new file mode 100644 index 0000000000..f4392c0f05 --- /dev/null +++ b/db/migrate/20140313092127_migrate_already_imported_projects.rb @@ -0,0 +1,12 @@ +class MigrateAlreadyImportedProjects < ActiveRecord::Migration + def up + Project.where(imported: true).update_all(import_status: "finished") + Project.where(imported: false).update_all(import_status: "none") + remove_column :projects, :imported + end + + def down + add_column :projects, :imported, :boolean, default: false + Project.where(import_status: 'finished').update_all(imported: true) + end +end diff --git a/db/migrate/20140407135544_fix_namespaces.rb b/db/migrate/20140407135544_fix_namespaces.rb new file mode 100644 index 0000000000..8c4f2b0f6b --- /dev/null +++ b/db/migrate/20140407135544_fix_namespaces.rb @@ -0,0 +1,10 @@ +class FixNamespaces < ActiveRecord::Migration + def up + Namespace.where('name <> path and type is null').each do |namespace| + namespace.update_attribute(:name, namespace.path) + end + end + + def down + end +end \ No newline at end of file diff --git a/db/migrate/20140414131055_change_state_to_allow_empty_merge_request_diffs.rb b/db/migrate/20140414131055_change_state_to_allow_empty_merge_request_diffs.rb new file mode 100644 index 0000000000..1f6d85d5f6 --- /dev/null +++ b/db/migrate/20140414131055_change_state_to_allow_empty_merge_request_diffs.rb @@ -0,0 +1,11 @@ +class ChangeStateToAllowEmptyMergeRequestDiffs < ActiveRecord::Migration + def up + change_column :merge_request_diffs, :state, :string, null: true, + default: nil + end + + def down + change_column :merge_request_diffs, :state, :string, null: false, + default: 'collected' + end +end diff --git a/db/migrate/20140415124820_limits_to_mysql.rb b/db/migrate/20140415124820_limits_to_mysql.rb new file mode 100644 index 0000000000..3f6e62617c --- /dev/null +++ b/db/migrate/20140415124820_limits_to_mysql.rb @@ -0,0 +1 @@ +require_relative 'limits_to_mysql' diff --git a/db/migrate/20140416074002_add_index_on_iid.rb b/db/migrate/20140416074002_add_index_on_iid.rb new file mode 100644 index 0000000000..85269e2a03 --- /dev/null +++ b/db/migrate/20140416074002_add_index_on_iid.rb @@ -0,0 +1,32 @@ +class AddIndexOnIid < ActiveRecord::Migration + def change + RemoveDuplicateIid.clean(Issue) + RemoveDuplicateIid.clean(MergeRequest, 'target_project_id') + RemoveDuplicateIid.clean(Milestone) + + add_index :issues, [:project_id, :iid], unique: true + add_index :merge_requests, [:target_project_id, :iid], unique: true + add_index :milestones, [:project_id, :iid], unique: true + end +end + +class RemoveDuplicateIid + def self.clean(klass, project_field = 'project_id') + duplicates = klass.find_by_sql("SELECT iid, #{project_field} FROM #{klass.table_name} GROUP BY #{project_field}, iid HAVING COUNT(*) > 1") + + duplicates.each do |duplicate| + project_id = duplicate.send(project_field) + iid = duplicate.iid + items = klass.of_projects(project_id).where(iid: iid) + + if items.size > 1 + puts "Remove #{klass.name} duplicates for iid: #{iid} and project_id: #{project_id}" + items.shift + items.each do |item| + item.destroy + puts '.' + end + end + end + end +end diff --git a/db/migrate/20140416185734_index_on_current_sign_in_at.rb b/db/migrate/20140416185734_index_on_current_sign_in_at.rb new file mode 100644 index 0000000000..0bf80ce154 --- /dev/null +++ b/db/migrate/20140416185734_index_on_current_sign_in_at.rb @@ -0,0 +1,5 @@ +class IndexOnCurrentSignInAt < ActiveRecord::Migration + def change + add_index :users, :current_sign_in_at + end +end diff --git a/db/migrate/20140428105831_add_notes_index_updated_at.rb b/db/migrate/20140428105831_add_notes_index_updated_at.rb new file mode 100644 index 0000000000..6c25570f12 --- /dev/null +++ b/db/migrate/20140428105831_add_notes_index_updated_at.rb @@ -0,0 +1,5 @@ +class AddNotesIndexUpdatedAt < ActiveRecord::Migration + def change + add_index :notes, :updated_at + end +end diff --git a/db/migrate/20140502115131_add_repo_size_to_db.rb b/db/migrate/20140502115131_add_repo_size_to_db.rb new file mode 100644 index 0000000000..7361d1a944 --- /dev/null +++ b/db/migrate/20140502115131_add_repo_size_to_db.rb @@ -0,0 +1,5 @@ +class AddRepoSizeToDb < ActiveRecord::Migration + def change + add_column :projects, :repository_size, :float, default: 0 + end +end diff --git a/db/migrate/20140502125220_migrate_repo_size.rb b/db/migrate/20140502125220_migrate_repo_size.rb new file mode 100644 index 0000000000..eed6d36681 --- /dev/null +++ b/db/migrate/20140502125220_migrate_repo_size.rb @@ -0,0 +1,21 @@ +class MigrateRepoSize < ActiveRecord::Migration + def up + Project.reset_column_information + Project.find_each(batch_size: 500) do |project| + begin + if project.empty_repo? + print '-' + else + project.update_repository_size + print '.' + end + rescue + print 'F' + end + end + puts 'Done' + end + + def down + end +end diff --git a/db/migrate/limits_to_mysql.rb b/db/migrate/limits_to_mysql.rb new file mode 100644 index 0000000000..2b7afae6d7 --- /dev/null +++ b/db/migrate/limits_to_mysql.rb @@ -0,0 +1,10 @@ +class LimitsToMysql < ActiveRecord::Migration + def up + return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/ + + change_column :merge_request_diffs, :st_commits, :text, limit: 2147483647 + change_column :merge_request_diffs, :st_diffs, :text, limit: 2147483647 + change_column :snippets, :content, :text, limit: 2147483647 + change_column :notes, :st_diff, :text, limit: 2147483647 + end +end diff --git a/db/schema.rb b/db/schema.rb index d6acb2f90e..93837337af 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,55 +9,79 @@ # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # -# It's strongly recommended to check this file into your version control system. +# It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(:version => 20131009115346) do +ActiveRecord::Schema.define(version: 20140502125220) do - create_table "deploy_keys_projects", :force => true do |t| - t.integer "deploy_key_id", :null => false - t.integer "project_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "broadcast_messages", force: true do |t| + t.text "message", null: false + t.datetime "starts_at" + t.datetime "ends_at" + t.integer "alert_type" + t.datetime "created_at" + t.datetime "updated_at" + t.string "color" + t.string "font" end - add_index "deploy_keys_projects", ["project_id"], :name => "index_deploy_keys_projects_on_project_id" + create_table "deploy_keys_projects", force: true do |t| + t.integer "deploy_key_id", null: false + t.integer "project_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + end - create_table "events", :force => true do |t| + add_index "deploy_keys_projects", ["project_id"], name: "index_deploy_keys_projects_on_project_id", using: :btree + + create_table "emails", force: true do |t| + t.integer "user_id", null: false + t.string "email", null: false + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "emails", ["email"], name: "index_emails_on_email", unique: true, using: :btree + add_index "emails", ["user_id"], name: "index_emails_on_user_id", using: :btree + + create_table "events", force: true do |t| t.string "target_type" t.integer "target_id" t.string "title" t.text "data" t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "action" t.integer "author_id" end - add_index "events", ["action"], :name => "index_events_on_action" - add_index "events", ["author_id"], :name => "index_events_on_author_id" - add_index "events", ["created_at"], :name => "index_events_on_created_at" - add_index "events", ["project_id"], :name => "index_events_on_project_id" - add_index "events", ["target_id"], :name => "index_events_on_target_id" - add_index "events", ["target_type"], :name => "index_events_on_target_type" + add_index "events", ["action"], name: "index_events_on_action", using: :btree + add_index "events", ["author_id"], name: "index_events_on_author_id", using: :btree + add_index "events", ["created_at"], name: "index_events_on_created_at", using: :btree + add_index "events", ["project_id"], name: "index_events_on_project_id", using: :btree + add_index "events", ["target_id"], name: "index_events_on_target_id", using: :btree + add_index "events", ["target_type"], name: "index_events_on_target_type", using: :btree - create_table "forked_project_links", :force => true do |t| - t.integer "forked_to_project_id", :null => false - t.integer "forked_from_project_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + create_table "forked_project_links", force: true do |t| + t.integer "forked_to_project_id", null: false + t.integer "forked_from_project_id", null: false + t.datetime "created_at" + t.datetime "updated_at" end - add_index "forked_project_links", ["forked_to_project_id"], :name => "index_forked_project_links_on_forked_to_project_id", :unique => true + add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree - create_table "issues", :force => true do |t| + create_table "issues", force: true do |t| t.string "title" t.integer "assignee_id" t.integer "author_id" t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "position", :default => 0 + t.datetime "created_at" + t.datetime "updated_at" + t.integer "position", default: 0 t.string "branch_name" t.text "description" t.integer "milestone_id" @@ -65,174 +89,191 @@ ActiveRecord::Schema.define(:version => 20131009115346) do t.integer "iid" end - add_index "issues", ["assignee_id"], :name => "index_issues_on_assignee_id" - add_index "issues", ["author_id"], :name => "index_issues_on_author_id" - add_index "issues", ["created_at"], :name => "index_issues_on_created_at" - add_index "issues", ["milestone_id"], :name => "index_issues_on_milestone_id" - add_index "issues", ["project_id"], :name => "index_issues_on_project_id" - add_index "issues", ["title"], :name => "index_issues_on_title" + add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree + add_index "issues", ["author_id"], name: "index_issues_on_author_id", using: :btree + add_index "issues", ["created_at"], name: "index_issues_on_created_at", using: :btree + add_index "issues", ["milestone_id"], name: "index_issues_on_milestone_id", using: :btree + add_index "issues", ["project_id", "iid"], name: "index_issues_on_project_id_and_iid", unique: true, using: :btree + add_index "issues", ["project_id"], name: "index_issues_on_project_id", using: :btree + add_index "issues", ["title"], name: "index_issues_on_title", using: :btree - create_table "keys", :force => true do |t| + create_table "keys", force: true do |t| t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.text "key" t.string "title" t.string "type" t.string "fingerprint" end - add_index "keys", ["user_id"], :name => "index_keys_on_user_id" + add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree - create_table "merge_requests", :force => true do |t| - t.string "target_branch", :null => false - t.string "source_branch", :null => false - t.integer "source_project_id", :null => false + create_table "merge_request_diffs", force: true do |t| + t.string "state" + t.text "st_commits" + t.text "st_diffs" + t.integer "merge_request_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "merge_request_diffs", ["merge_request_id"], name: "index_merge_request_diffs_on_merge_request_id", unique: true, using: :btree + + create_table "merge_requests", force: true do |t| + t.string "target_branch", null: false + t.string "source_branch", null: false + t.integer "source_project_id", null: false t.integer "author_id" t.integer "assignee_id" t.string "title" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "st_commits", :limit => 2147483647 - t.text "st_diffs", :limit => 2147483647 + t.datetime "created_at" + t.datetime "updated_at" t.integer "milestone_id" t.string "state" t.string "merge_status" - t.integer "target_project_id", :null => false + t.integer "target_project_id", null: false t.integer "iid" t.text "description" end - add_index "merge_requests", ["assignee_id"], :name => "index_merge_requests_on_assignee_id" - add_index "merge_requests", ["author_id"], :name => "index_merge_requests_on_author_id" - add_index "merge_requests", ["created_at"], :name => "index_merge_requests_on_created_at" - add_index "merge_requests", ["milestone_id"], :name => "index_merge_requests_on_milestone_id" - add_index "merge_requests", ["source_branch"], :name => "index_merge_requests_on_source_branch" - add_index "merge_requests", ["source_project_id"], :name => "index_merge_requests_on_project_id" - add_index "merge_requests", ["target_branch"], :name => "index_merge_requests_on_target_branch" - add_index "merge_requests", ["title"], :name => "index_merge_requests_on_title" + add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree + add_index "merge_requests", ["author_id"], name: "index_merge_requests_on_author_id", using: :btree + add_index "merge_requests", ["created_at"], name: "index_merge_requests_on_created_at", using: :btree + add_index "merge_requests", ["milestone_id"], name: "index_merge_requests_on_milestone_id", using: :btree + add_index "merge_requests", ["source_branch"], name: "index_merge_requests_on_source_branch", using: :btree + add_index "merge_requests", ["source_project_id"], name: "index_merge_requests_on_source_project_id", using: :btree + add_index "merge_requests", ["target_branch"], name: "index_merge_requests_on_target_branch", using: :btree + add_index "merge_requests", ["target_project_id", "iid"], name: "index_merge_requests_on_target_project_id_and_iid", unique: true, using: :btree + add_index "merge_requests", ["title"], name: "index_merge_requests_on_title", using: :btree - create_table "milestones", :force => true do |t| - t.string "title", :null => false - t.integer "project_id", :null => false + create_table "milestones", force: true do |t| + t.string "title", null: false + t.integer "project_id", null: false t.text "description" t.date "due_date" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "state" t.integer "iid" end - add_index "milestones", ["due_date"], :name => "index_milestones_on_due_date" - add_index "milestones", ["project_id"], :name => "index_milestones_on_project_id" + add_index "milestones", ["due_date"], name: "index_milestones_on_due_date", using: :btree + add_index "milestones", ["project_id", "iid"], name: "index_milestones_on_project_id_and_iid", unique: true, using: :btree + add_index "milestones", ["project_id"], name: "index_milestones_on_project_id", using: :btree - create_table "namespaces", :force => true do |t| - t.string "name", :null => false - t.string "path", :null => false + create_table "namespaces", force: true do |t| + t.string "name", null: false + t.string "path", null: false t.integer "owner_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "type" - t.string "description", :default => "", :null => false + t.string "description", default: "", null: false + t.string "avatar" end - add_index "namespaces", ["name"], :name => "index_namespaces_on_name" - add_index "namespaces", ["owner_id"], :name => "index_namespaces_on_owner_id" - add_index "namespaces", ["path"], :name => "index_namespaces_on_path" - add_index "namespaces", ["type"], :name => "index_namespaces_on_type" + add_index "namespaces", ["name"], name: "index_namespaces_on_name", using: :btree + add_index "namespaces", ["owner_id"], name: "index_namespaces_on_owner_id", using: :btree + add_index "namespaces", ["path"], name: "index_namespaces_on_path", using: :btree + add_index "namespaces", ["type"], name: "index_namespaces_on_type", using: :btree - create_table "notes", :force => true do |t| + create_table "notes", force: true do |t| t.text "note" t.string "noteable_type" t.integer "author_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "project_id" t.string "attachment" t.string "line_code" t.string "commit_id" t.integer "noteable_id" + t.boolean "system", default: false, null: false t.text "st_diff" - t.boolean "system", :default => false, :null => false end - add_index "notes", ["author_id"], :name => "index_notes_on_author_id" - add_index "notes", ["commit_id"], :name => "index_notes_on_commit_id" - add_index "notes", ["created_at"], :name => "index_notes_on_created_at" - add_index "notes", ["noteable_id", "noteable_type"], :name => "index_notes_on_noteable_id_and_noteable_type" - add_index "notes", ["noteable_type"], :name => "index_notes_on_noteable_type" - add_index "notes", ["project_id", "noteable_type"], :name => "index_notes_on_project_id_and_noteable_type" - add_index "notes", ["project_id"], :name => "index_notes_on_project_id" + add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree + add_index "notes", ["commit_id"], name: "index_notes_on_commit_id", using: :btree + add_index "notes", ["created_at"], name: "index_notes_on_created_at", using: :btree + add_index "notes", ["noteable_id", "noteable_type"], name: "index_notes_on_noteable_id_and_noteable_type", using: :btree + add_index "notes", ["noteable_type"], name: "index_notes_on_noteable_type", using: :btree + add_index "notes", ["project_id", "noteable_type"], name: "index_notes_on_project_id_and_noteable_type", using: :btree + add_index "notes", ["project_id"], name: "index_notes_on_project_id", using: :btree + add_index "notes", ["updated_at"], name: "index_notes_on_updated_at", using: :btree - create_table "projects", :force => true do |t| + create_table "projects", force: true do |t| t.string "name" t.string "path" t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.integer "creator_id" - t.string "default_branch" - t.boolean "issues_enabled", :default => true, :null => false - 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.boolean "issues_enabled", default: true, null: false + 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 "namespace_id" - t.boolean "public", :default => false, :null => false - t.string "issues_tracker", :default => "gitlab", :null => false + t.string "issues_tracker", default: "gitlab", null: false t.string "issues_tracker_id" - t.boolean "snippets_enabled", :default => true, :null => false + t.boolean "snippets_enabled", default: true, null: false t.datetime "last_activity_at" - t.boolean "imported", :default => false, :null => false t.string "import_url" + t.integer "visibility_level", default: 0, null: false + t.boolean "archived", default: false, null: false + t.string "import_status" + t.float "repository_size", default: 0.0 end - add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id" - add_index "projects", ["last_activity_at"], :name => "index_projects_on_last_activity_at" - add_index "projects", ["namespace_id"], :name => "index_projects_on_namespace_id" + add_index "projects", ["creator_id"], name: "index_projects_on_creator_id", using: :btree + add_index "projects", ["last_activity_at"], name: "index_projects_on_last_activity_at", using: :btree + add_index "projects", ["namespace_id"], name: "index_projects_on_namespace_id", using: :btree - create_table "protected_branches", :force => true do |t| - t.integer "project_id", :null => false - t.string "name", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + create_table "protected_branches", force: true do |t| + t.integer "project_id", null: false + t.string "name", null: false + t.datetime "created_at" + t.datetime "updated_at" end - add_index "protected_branches", ["project_id"], :name => "index_protected_branches_on_project_id" + add_index "protected_branches", ["project_id"], name: "index_protected_branches_on_project_id", using: :btree - create_table "services", :force => true do |t| + create_table "services", force: true do |t| t.string "type" t.string "title" t.string "token" - t.integer "project_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "active", :default => false, :null => false + t.integer "project_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.boolean "active", default: false, null: false t.string "project_url" t.string "subdomain" t.string "room" + t.text "recipients" + t.string "api_key" end - add_index "services", ["project_id"], :name => "index_services_on_project_id" + add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree - create_table "snippets", :force => true do |t| + create_table "snippets", force: true do |t| t.string "title" - t.text "content", :limit => 2147483647 - t.integer "author_id", :null => false + t.text "content" + t.integer "author_id", null: false t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "file_name" t.datetime "expires_at" - t.boolean "private", :default => true, :null => false + t.boolean "private", default: true, null: false t.string "type" end - add_index "snippets", ["author_id"], :name => "index_snippets_on_author_id" - add_index "snippets", ["created_at"], :name => "index_snippets_on_created_at" - add_index "snippets", ["expires_at"], :name => "index_snippets_on_expires_at" - add_index "snippets", ["project_id"], :name => "index_snippets_on_project_id" + add_index "snippets", ["author_id"], name: "index_snippets_on_author_id", using: :btree + add_index "snippets", ["created_at"], name: "index_snippets_on_created_at", using: :btree + add_index "snippets", ["expires_at"], name: "index_snippets_on_expires_at", using: :btree + add_index "snippets", ["project_id"], name: "index_snippets_on_project_id", using: :btree - create_table "taggings", :force => true do |t| + create_table "taggings", force: true do |t| t.integer "tag_id" t.integer "taggable_id" t.string "taggable_type" @@ -242,45 +283,45 @@ ActiveRecord::Schema.define(:version => 20131009115346) do t.datetime "created_at" end - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" + add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id", using: :btree + add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree - create_table "tags", :force => true do |t| + create_table "tags", force: true do |t| t.string "name" end - create_table "users", :force => true do |t| - t.string "email", :default => "", :null => false - t.string "encrypted_password", :default => "", :null => false + create_table "users", force: true do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", :default => 0 + t.integer "sign_in_count", default: 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" t.string "name" - t.boolean "admin", :default => false, :null => false - t.integer "projects_limit", :default => 10 - t.string "skype", :default => "", :null => false - t.string "linkedin", :default => "", :null => false - t.string "twitter", :default => "", :null => false + t.boolean "admin", default: false, null: false + t.integer "projects_limit", default: 10 + t.string "skype", default: "", null: false + t.string "linkedin", default: "", null: false + t.string "twitter", default: "", null: false t.string "authentication_token" - t.integer "theme_id", :default => 1, :null => false + t.integer "theme_id", default: 1, null: false t.string "bio" - t.integer "failed_attempts", :default => 0 + t.integer "failed_attempts", default: 0 t.datetime "locked_at" t.string "extern_uid" t.string "provider" t.string "username" - t.boolean "can_create_group", :default => true, :null => false - t.boolean "can_create_team", :default => true, :null => false + t.boolean "can_create_group", default: true, null: false + t.boolean "can_create_team", default: true, null: false t.string "state" - t.integer "color_scheme_id", :default => 1, :null => false - t.integer "notification_level", :default => 1, :null => false + t.integer "color_scheme_id", default: 1, null: false + t.integer "notification_level", default: 1, null: false t.datetime "password_expires_at" t.integer "created_by_id" t.string "avatar" @@ -288,50 +329,58 @@ ActiveRecord::Schema.define(:version => 20131009115346) do t.datetime "confirmed_at" t.datetime "confirmation_sent_at" t.string "unconfirmed_email" + t.boolean "hide_no_ssh_key", default: false + t.string "website_url", default: "", null: false + t.datetime "last_credential_check_at" end - add_index "users", ["admin"], :name => "index_users_on_admin" - add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true - add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true - add_index "users", ["email"], :name => "index_users_on_email", :unique => true - add_index "users", ["extern_uid", "provider"], :name => "index_users_on_extern_uid_and_provider", :unique => true - add_index "users", ["name"], :name => "index_users_on_name" - add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true - add_index "users", ["username"], :name => "index_users_on_username" + add_index "users", ["admin"], name: "index_users_on_admin", using: :btree + add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true, using: :btree + add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree + add_index "users", ["current_sign_in_at"], name: "index_users_on_current_sign_in_at", using: :btree + add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree + add_index "users", ["extern_uid", "provider"], name: "index_users_on_extern_uid_and_provider", unique: true, using: :btree + add_index "users", ["name"], name: "index_users_on_name", using: :btree + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree + add_index "users", ["username"], name: "index_users_on_username", using: :btree - create_table "users_groups", :force => true do |t| - t.integer "group_access", :null => false - t.integer "group_id", :null => false - t.integer "user_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "notification_level", :default => 3, :null => false + create_table "users_groups", force: true do |t| + t.integer "group_access", null: false + t.integer "group_id", null: false + t.integer "user_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "notification_level", default: 3, null: false end - add_index "users_groups", ["user_id"], :name => "index_users_groups_on_user_id" + add_index "users_groups", ["user_id"], name: "index_users_groups_on_user_id", using: :btree - create_table "users_projects", :force => true do |t| - t.integer "user_id", :null => false - t.integer "project_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_access", :default => 0, :null => false - t.integer "notification_level", :default => 3, :null => false + create_table "users_projects", force: true do |t| + t.integer "user_id", null: false + t.integer "project_id", null: false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "project_access", default: 0, null: false + t.integer "notification_level", default: 3, null: false end - add_index "users_projects", ["project_access"], :name => "index_users_projects_on_project_access" - add_index "users_projects", ["project_id"], :name => "index_users_projects_on_project_id" - add_index "users_projects", ["user_id"], :name => "index_users_projects_on_user_id" + add_index "users_projects", ["project_access"], name: "index_users_projects_on_project_access", using: :btree + add_index "users_projects", ["project_id"], name: "index_users_projects_on_project_id", using: :btree + add_index "users_projects", ["user_id"], name: "index_users_projects_on_user_id", using: :btree - create_table "web_hooks", :force => true do |t| + create_table "web_hooks", force: true do |t| t.string "url" t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "type", :default => "ProjectHook" + t.datetime "created_at" + t.datetime "updated_at" + t.string "type", default: "ProjectHook" t.integer "service_id" + t.boolean "push_events", default: true, null: false + t.boolean "issues_events", default: false, null: false + t.boolean "merge_requests_events", default: false, null: false + t.boolean "tag_push_events", default: false end - add_index "web_hooks", ["project_id"], :name => "index_web_hooks_on_project_id" + add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree end diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 0000000000..b73d7bb38e --- /dev/null +++ b/doc/README.md @@ -0,0 +1,24 @@ +**User documentation** + ++ [API](api/README.md) Explore how you can access GitLab via a simple and powerful API. ++ [Markdown](markdown/markdown.md) Learn what you can do with GitLab's advanced formatting system. ++ [Permissions](permissions/permissions.md) Learn what each role in a project (guest/reporter/developer/master/owner) can do. ++ [Public access](public_access/public_access.md) Learn how you can allow public and internal access to a project. ++ [SSH](ssh/README.md) Setup your ssh keys and deploy keys for secure access to your projects. ++ [Web hooks](web_hooks/web_hooks.md) Let GitLab notify you when new code has been pushed to your project. ++ [Workflow](workflow/README.md) Learn how to use Git and GitLab together. + +**Administrator documentation** + ++ [Install](install/README.md) Requirements, directory structures and manual installation. ++ [Integration](integration/README.md) How to integrate with systems such as JIRA, Redmine, LDAP and Twitter. ++ [Raketasks](raketasks/README.md) Explore what GitLab has in store for you to make administration easier. ++ [System hooks](system_hooks/system_hooks.md) Let GitLab notify you when certain management tasks need to be carried out. ++ [Security](security/README.md) Learn what you can do to further secure your GitLab instance. ++ [Update](update/README.md) Update guides to upgrade your installation. + +**Contributor documentation** + ++ [Development](development/README.md) Explains the architecture and the guidelines for shell commands. ++ [Legal](legal/README.md) Contributor license agreements. ++ [Release](release/README.md) How to make the monthly and security releases. diff --git a/doc/api/README.md b/doc/api/README.md index 517a9fae6f..4c40589fd4 100644 --- a/doc/api/README.md +++ b/doc/api/README.md @@ -1,5 +1,34 @@ # GitLab API +## Resources + ++ [Users](users.md) ++ [Session](session.md) ++ [Projects](projects.md) ++ [Project Snippets](project_snippets.md) ++ [Repositories](repositories.md) ++ [Repository Files](repository_files.md) ++ [Commits](commits.md) ++ [Branches](branches.md) ++ [Merge Requests](merge_requests.md) ++ [Issues](issues.md) ++ [Milestones](milestones.md) ++ [Notes](notes.md) (comments) ++ [Deploy Keys](deploy_keys.md) ++ [System Hooks](system_hooks.md) ++ [Groups](groups.md) + +## Clients + ++ [php-gitlab-api](https://github.com/m4tthumphrey/php-gitlab-api) - PHP ++ [Laravel API Wrapper for GitLab CE](https://github.com/adamgoose/gitlab) - PHP / [Laravel](http://laravel.com) ++ [Ruby Wrapper](https://github.com/NARKOZ/gitlab) - Ruby ++ [python-gitlab](https://github.com/Itxaka/python-gitlab) - Python ++ [java-gitlab-api](https://github.com/timols/java-gitlab-api) - Java ++ [node-gitlab](https://github.com/moul/node-gitlab) - Node.js + +## Introduction + All API requests require authentication. You need to pass a `private_token` parameter by url or header. If passed as header, the header name must be "PRIVATE-TOKEN" (capital and with dash instead of underscore). 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: @@ -103,6 +132,10 @@ When listing resources you can pass the following parameters: + `page` (default: `1`) - page number + `per_page` (default: `20`, max: `100`) - number of items to list per page +[Link headers](http://www.w3.org/wiki/LinkHeader) are send back with each response. +These have `rel` prev/next/first/last and contain the relevant url. +Please use these instead of generating your own urls. + ## id vs iid When you work with API you may notice two similar fields in api entites: id and iid. @@ -117,28 +150,3 @@ Issue So if you want to get issue with api you use `http://host/api/v3/.../issues/:id.json` But when you want to create a link to web page - use `http:://host/project/issues/:iid.json` - - - -## Contents - -+ [Users](users.md) -+ [Session](session.md) -+ [Projects](projects.md) -+ [Project Snippets](project_snippets.md) -+ [Repositories](repositories.md) -+ [Merge Requests](merge_requests.md) -+ [Issues](issues.md) -+ [Milestones](milestones.md) -+ [Notes](notes.md) -+ [Deploy Keys](deploy_keys.md) -+ [System Hooks](system_hooks.md) -+ [Groups](groups.md) - - -## Clients - -+ [php-gitlab-api](https://github.com/m4tthumphrey/php-gitlab-api) - PHP -+ [Ruby Wrapper](https://github.com/NARKOZ/gitlab) - Ruby -+ [python-gitlab](https://github.com/Itxaka/python-gitlab) - Python -+ [java-gitlab-api](https://github.com/timols/java-gitlab-api) - Java diff --git a/doc/api/branches.md b/doc/api/branches.md new file mode 100644 index 0000000000..da9d4193f2 --- /dev/null +++ b/doc/api/branches.md @@ -0,0 +1,201 @@ +# Branches + +## List repository branches + +Get a list of repository branches from a project, sorted by name alphabetically. + +``` +GET /projects/:id/repository/branches +``` + +Parameters: + ++ `id` (required) - The ID of a project + +```json +[ + { + "name": "master", + "commit": { + "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c", + "parents": [ + { + "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8" + } + ], + "tree": "46e82de44b1061621357f24c05515327f2795a95", + "message": "add projects API", + "author": { + "name": "John Smith", + "email": "john@example.com" + }, + "committer": { + "name": "John Smith", + "email": "john@example.com" + }, + "authored_date": "2012-06-27T05:51:39-07:00", + "committed_date": "2012-06-28T03:44:20-07:00" + }, + "protected": true + } +] +``` + + +## Get single repository branch + +Get a single project repository branch. + +``` +GET /projects/:id/repository/branches/:branch +``` + +Parameters: + ++ `id` (required) - The ID of a project ++ `branch` (required) - The name of the branch + +```json +{ + "name": "master", + "commit": { + "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c", + "parents": [ + { + "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8" + } + ], + "tree": "46e82de44b1061621357f24c05515327f2795a95", + "message": "add projects API", + "author": { + "name": "John Smith", + "email": "john@example.com" + }, + "committer": { + "name": "John Smith", + "email": "john@example.com" + }, + "authored_date": "2012-06-27T05:51:39-07:00", + "committed_date": "2012-06-28T03:44:20-07:00" + }, + "protected": true +} +``` + + +## Protect repository branch + +Protects a single project repository branch. This is an idempotent function, protecting an already +protected repository branch still returns a `200 Ok` status code. + +``` +PUT /projects/:id/repository/branches/:branch/protect +``` + +Parameters: + ++ `id` (required) - The ID of a project ++ `branch` (required) - The name of the branch + +```json +{ + "name": "master", + "commit": { + "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c", + "parents": [ + { + "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8" + } + ], + "tree": "46e82de44b1061621357f24c05515327f2795a95", + "message": "add projects API", + "author": { + "name": "John Smith", + "email": "john@example.com" + }, + "committer": { + "name": "John Smith", + "email": "john@example.com" + }, + "authored_date": "2012-06-27T05:51:39-07:00", + "committed_date": "2012-06-28T03:44:20-07:00" + }, + "protected": true +} +``` + + +## Unprotect repository branch + +Unprotects a single project repository branch. This is an idempotent function, unprotecting an already +unprotected repository branch still returns a `200 Ok` status code. + +``` +PUT /projects/:id/repository/branches/:branch/unprotect +``` + +Parameters: + ++ `id` (required) - The ID of a project ++ `branch` (required) - The name of the branch + +```json +{ + "name": "master", + "commit": { + "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c", + "parents": [ + { + "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8" + } + ], + "tree": "46e82de44b1061621357f24c05515327f2795a95", + "message": "add projects API", + "author": { + "name": "John Smith", + "email": "john@example.com" + }, + "committer": { + "name": "John Smith", + "email": "john@example.com" + }, + "authored_date": "2012-06-27T05:51:39-07:00", + "committed_date": "2012-06-28T03:44:20-07:00" + }, + "protected": false +} +``` + +## Create repository branch + + +``` +POST /projects/:id/repository/branches +``` + +Parameters: + ++ `id` (required) - The ID of a project ++ `branch_name` (required) - The name of the branch ++ `ref` (required) - Create branch from commit sha or existing branch + +```json +{ + "name": "my-new-branch", + "commit": { + "id": "8848c0e90327a0b70f1865b843fb2fbfb9345e57", + "message": "Merge pull request #54 from brightbox/use_fog_brightbox_module\n\nUpdate to use fog-brightbox module", + "parent_ids": [ + "fff449e0bf453576f16c91d6544f00a2664009d8", + "f93a93626fec20fd659f4ed3ab2e64019b6169ae" + ], + "authored_date": "2014-02-20T19:54:55+02:00", + "author_name": "john smith", + "author_email": "john@example.com", + "committed_date": "2014-02-20T19:54:55+02:00", + "committer_name": "john smith", + "committer_email": "john@example.com" + }, + "protected": false +} +``` diff --git a/doc/api/commits.md b/doc/api/commits.md new file mode 100644 index 0000000000..241fe0e585 --- /dev/null +++ b/doc/api/commits.md @@ -0,0 +1,95 @@ +# Commits API + +## List repository commits + +Get a list of repository commits in a project. + +``` +GET /projects/:id/repository/commits +``` + +Parameters: + ++ `id` (required) - The ID of a project ++ `ref_name` (optional) - The name of a repository branch or tag or if not given the default branch + +```json +[ + { + "id": "ed899a2f4b50b4370feeea94676502b42383c746", + "short_id": "ed899a2f4b5", + "title": "Replace sanitize with escape once", + "author_name": "Dmitriy Zaporozhets", + "author_email": "dzaporozhets@sphereconsultinginc.com", + "created_at": "2012-09-20T11:50:22+03:00" + }, + { + "id": "6104942438c14ec7bd21c6cd5bd995272b3faff6", + "short_id": "6104942438c", + "title": "Sanitize for network graph", + "author_name": "randx", + "author_email": "dmitriy.zaporozhets@gmail.com", + "created_at": "2012-09-20T09:06:12+03:00" + } +] +``` + +## Get a single commit + +Get a specific commit identified by the commit hash or name of a branch or tag. + +``` +GET /projects/:id/repository/commits/:sha +``` + +Parameters: + ++ `id` (required) - The ID of a project ++ `sha` (required) - The commit hash or name of a repository branch or tag + +```json +{ + "id": "6104942438c14ec7bd21c6cd5bd995272b3faff6", + "short_id": "6104942438c", + "title": "Sanitize for network graph", + "author_name": "randx", + "author_email": "dmitriy.zaporozhets@gmail.com", + "created_at": "2012-09-20T09:06:12+03:00", + "committed_date": "2012-09-20T09:06:12+03:00", + "authored_date": "2012-09-20T09:06:12+03:00", + "parent_ids": [ + "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba" + ] +} +``` + + +## Get the diff of a commit + +Get the diff of a commit in a project. + +``` +GET /projects/:id/repository/commits/:sha/diff +``` + +Parameters: + ++ `id` (required) - The ID of a project ++ `sha` (required) - The name of a repository branch or tag or if not given the default branch + +```json +[ + { + "diff": "--- a/doc/update/5.4-to-6.0.md\n+++ b/doc/update/5.4-to-6.0.md\n@@ -71,6 +71,8 @@\n sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production\n sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production\n \n+sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production\n+\n ```\n \n ### 6. Update config files", + "new_path": "doc/update/5.4-to-6.0.md", + "old_path": "doc/update/5.4-to-6.0.md", + "a_mode": null, + "b_mode": "100644", + "new_file": false, + "renamed_file": false, + "deleted_file": false + } +] +``` + + diff --git a/doc/api/deploy_keys.md b/doc/api/deploy_keys.md index 50d2b82c36..d6c0e624df 100644 --- a/doc/api/deploy_keys.md +++ b/doc/api/deploy_keys.md @@ -16,19 +16,15 @@ Parameters: [ { "id": 1, - "title" : "Public key", - "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 - 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 - soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", - "created_at":"2013-10-02T10:12:29Z" + "title": "Public key", + "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", + "created_at": "2013-10-02T10:12:29Z" }, { "id": 3, - "title" : "Another Public key", - "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 - 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 - soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", - "created_at":"2013-10-02T11:12:29Z" + "title": "Another Public key", + "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", + "created_at": "2013-10-02T11:12:29Z" } ] ``` @@ -50,11 +46,9 @@ Parameters: ```json { "id": 1, - "title" : "Public key", - "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 - 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 - soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", - "created_at":"2013-10-02T10:12:29Z" + "title": "Public key", + "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", + "created_at": "2013-10-02T10:12:29Z" } ``` diff --git a/doc/api/issues.md b/doc/api/issues.md index ef37940faf..d18506f9ce 100644 --- a/doc/api/issues.md +++ b/doc/api/issues.md @@ -15,7 +15,7 @@ GET /issues "project_id": 8, "title": "4xx/5xx pages", "description": "", - "labels": [ ], + "labels": [], "milestone": null, "assignee": null, "author": { @@ -193,3 +193,7 @@ Parameters: + `id` (required) - The project ID + `issue_id` (required) - The ID of the issue + +## Comments on issues + +Comments are done via the notes resource. diff --git a/doc/api/merge_requests.md b/doc/api/merge_requests.md index 2ddaea5a58..d68f34971f 100644 --- a/doc/api/merge_requests.md +++ b/doc/api/merge_requests.md @@ -1,45 +1,51 @@ ## List merge requests -Get all merge requests for this project. This function takes pagination parameters -`page` and `per_page` to restrict the list of merge requests. +Get all merge requests for this project. +The `state` parameter can be used to get only merge requests with a +given state (`opened`, `closed`, or `merged`) or all of them (`all`). +The pagination parameters `page` and `per_page` can be used to restrict the +list of merge requests. ``` GET /projects/:id/merge_requests +GET /projects/:id/merge_requests?state=opened +GET /projects/:id/merge_requests?state=all ``` Parameters: + `id` (required) - The ID of a project ++ `state` (optional) - Return `all` requests or just those that are `merged`, `opened` or `closed` ```json [ - { - "id":1, - "iid":1, - "target_branch":"master", - "source_branch":"test1", - "project_id":3, - "title":"test1", - "state":"opened", - "upvotes":0, - "downvotes":0, - "author":{ - "id":1, - "username": "admin", - "email":"admin@local.host", - "name":"Administrator", - "state":"active", - "created_at":"2012-04-29T08:46:00Z" - }, - "assignee":{ - "id":1, - "username": "admin", - "email":"admin@local.host", - "name":"Administrator", - "state":"active", - "created_at":"2012-04-29T08:46:00Z" - } + { + "id": 1, + "iid": 1, + "target_branch": "master", + "source_branch": "test1", + "project_id": 3, + "title": "test1", + "state": "opened", + "upvotes": 0, + "downvotes": 0, + "author": { + "id": 1, + "username": "admin", + "email": "admin@local.host", + "name": "Administrator", + "state": "active", + "created_at": "2012-04-29T08:46:00Z" + }, + "assignee": { + "id": 1, + "username": "admin", + "email": "admin@local.host", + "name": "Administrator", + "state": "active", + "created_at": "2012-04-29T08:46:00Z" } + } ] ``` @@ -59,31 +65,31 @@ Parameters: ```json { - "id":1, - "iid":1, - "target_branch":"master", - "source_branch":"test1", - "project_id":3, - "title":"test1", - "state":"merged", - "upvotes":0, - "downvotes":0, - "author":{ - "id":1, - "username": "admin", - "email":"admin@local.host", - "name":"Administrator", - "state":"active", - "created_at":"2012-04-29T08:46:00Z" - }, - "assignee":{ - "id":1, - "username": "admin", - "email":"admin@local.host", - "name":"Administrator", - "state":"active", - "created_at":"2012-04-29T08:46:00Z" - } + "id": 1, + "iid": 1, + "target_branch": "master", + "source_branch": "test1", + "project_id": 3, + "title": "test1", + "state": "merged", + "upvotes": 0, + "downvotes": 0, + "author": { + "id": 1, + "username": "admin", + "email": "admin@local.host", + "name": "Administrator", + "state": "active", + "created_at": "2012-04-29T08:46:00Z" + }, + "assignee": { + "id": 1, + "username": "admin", + "email": "admin@local.host", + "name": "Administrator", + "state": "active", + "created_at": "2012-04-29T08:46:00Z" + } } ``` @@ -99,37 +105,38 @@ POST /projects/:id/merge_requests Parameters: + `id` (required) - The ID of a project -+ `source_branch` (required) - The source branch -+ `target_branch` (required) - The target branch -+ `assignee_id` (optional) - Assignee user ID -+ `title` (required) - Title of MR ++ `source_branch` (required) - The source branch ++ `target_branch` (required) - The target branch ++ `assignee_id` (optional) - Assignee user ID ++ `title` (required) - Title of MR ++ `target_project_id` (optional) - The target project (numeric id) ```json { - "id":1, - "target_branch":"master", - "source_branch":"test1", - "project_id":3, - "title":"test1", - "state":"opened", - "upvotes":0, - "downvotes":0, - "author":{ - "id":1, - "username": "admin", - "email":"admin@local.host", - "name":"Administrator", - "state":"active", - "created_at":"2012-04-29T08:46:00Z" - }, - "assignee":{ - "id":1, - "username": "admin", - "email":"admin@local.host", - "name":"Administrator", - "state":"active", - "created_at":"2012-04-29T08:46:00Z" - } + "id": 1, + "target_branch": "master", + "source_branch": "test1", + "project_id": 3, + "title": "test1", + "state": "opened", + "upvotes": 0, + "downvotes": 0, + "author": { + "id": 1, + "username": "admin", + "email": "admin@local.host", + "name": "Administrator", + "state": "active", + "created_at": "2012-04-29T08:46:00Z" + }, + "assignee": { + "id": 1, + "username": "admin", + "email": "admin@local.host", + "name": "Administrator", + "state": "active", + "created_at": "2012-04-29T08:46:00Z" + } } ``` @@ -150,34 +157,82 @@ Parameters: + `target_branch` - The target branch + `assignee_id` - Assignee user ID + `title` - Title of MR ++ `state_event` - New state (close|reopen|merge) ```json - { - "id":1, - "target_branch":"master", - "source_branch":"test1", - "project_id":3, - "title":"test1", - "state":"opened", - "upvotes":0, - "downvotes":0, - "author":{ - "id":1, - "username": "admin", - "email":"admin@local.host", - "name":"Administrator", - "state":"active", - "created_at":"2012-04-29T08:46:00Z" - }, - "assignee":{ - "id":1, - "username": "admin", - "email":"admin@local.host", - "name":"Administrator", - "state":"active", - "created_at":"2012-04-29T08:46:00Z" - } + "id": 1, + "target_branch": "master", + "source_branch": "test1", + "project_id": 3, + "title": "test1", + "state": "opened", + "upvotes": 0, + "downvotes": 0, + "author": { + "id": 1, + "username": "admin", + "email": "admin@local.host", + "name": "Administrator", + "state": "active", + "created_at": "2012-04-29T08:46:00Z" + }, + "assignee": { + "id": 1, + "username": "admin", + "email": "admin@local.host", + "name": "Administrator", + "state": "active", + "created_at": "2012-04-29T08:46:00Z" + } +} +``` + + +## Accept MR + +Merge changes submitted with MR usign this API. +If merge success you get 200 OK. +If it has some conflicts and can not be merged - you get 405 and error message 'Branch cannot be merged' +If merge request is already merged or closed - you get 405 and error message 'Method Not Allowed' +If you dont have permissions to accept this merge request - you get 401 + +``` +PUT /projects/:id/merge_request/:merge_request_id/merge +``` + +Parameters: + ++ `id` (required) - The ID of a project ++ `merge_request_id` (required) - ID of MR ++ `merge_commit_message` (optional) - Custom merge commit message + +```json +{ + "id": 1, + "target_branch": "master", + "source_branch": "test1", + "project_id": 3, + "title": "test1", + "state": "merged", + "upvotes": 0, + "downvotes": 0, + "author": { + "id": 1, + "username": "admin", + "email": "admin@local.host", + "name": "Administrator", + "state": "active", + "created_at": "2012-04-29T08:46:00Z" + }, + "assignee": { + "id": 1, + "username": "admin", + "email": "admin@local.host", + "name": "Administrator", + "state": "active", + "created_at": "2012-04-29T08:46:00Z" + } } ``` @@ -199,14 +254,59 @@ Parameters: ```json { - "author":{ - "id":1, - "username": "admin", - "email":"admin@local.host", - "name":"Administrator", - "blocked":false, - "created_at":"2012-04-29T08:46:00Z" - }, - "note":"text1" + "author": { + "id": 1, + "username": "admin", + "email": "admin@local.host", + "name": "Administrator", + "blocked": false, + "created_at": "2012-04-29T08:46:00Z" + }, + "note": "text1" } ``` + + +## Get the comments on a MR + +Gets all the comments associated with a merge request. + +``` +GET /projects/:id/merge_request/:merge_request_id/comments +``` + +Parameters: + ++ `id` (required) - The ID of a project ++ `merge_request_id` (required) - ID of merge request + +```json +[ + { + "note": "this is the 1st comment on the 2merge merge request", + "author": { + "id": 11, + "username": "admin", + "email": "admin@local.host", + "name": "Administrator", + "state": "active", + "created_at": "2014-03-06T08:17:35.000Z" + } + }, + { + "note": "_Status changed to closed_", + "author": { + "id": 11, + "username": "admin", + "email": "admin@local.host", + "name": "Administrator", + "state": "active", + "created_at": "2014-03-06T08:17:35.000Z" + } + } +] +``` + +## Comments on issues + +Comments are done via the notes resource. diff --git a/doc/api/milestones.md b/doc/api/milestones.md index e899e28d21..2a2ef4b79b 100644 --- a/doc/api/milestones.md +++ b/doc/api/milestones.md @@ -9,15 +9,15 @@ GET /projects/:id/milestones ```json [ { - "id":12, - "iid":3, - "project_id":16, - "title":"10.0", - "description":"Version", - "due_date":"2013-11-29", - "state":"active", - "updated_at":"2013-10-02T09:24:18Z", - "created_at":"2013-10-02T09:24:18Z" + "id": 12, + "iid": 3, + "project_id": 16, + "title": "10.0", + "description": "Version", + "due_date": "2013-11-29", + "state": "active", + "updated_at": "2013-10-02T09:24:18Z", + "created_at": "2013-10-02T09:24:18Z" } ] ``` diff --git a/doc/api/notes.md b/doc/api/notes.md index 397aa87aad..e9ad6e00c7 100644 --- a/doc/api/notes.md +++ b/doc/api/notes.md @@ -1,3 +1,5 @@ +Notes can be wall notes or comments on snippets, issues or merge requests. + ## Wall ### List project wall notes @@ -17,7 +19,7 @@ Parameters: { "id": 522, "body": "The solution is rather tricky", - "attachment":null, + "attachment": null, "author": { "id": 1, "username": "john_smith", @@ -77,32 +79,32 @@ Parameters: ```json [ { - "id":302, - "body":"_Status changed to closed_", - "attachment":null, - "author":{ - "id":1, - "username":"pipin", - "email":"admin@example.com", - "name":"Pip", - "state":"active", - "created_at":"2013-09-30T13:46:01Z" + "id": 302, + "body": "_Status changed to closed_", + "attachment": null, + "author": { + "id": 1, + "username": "pipin", + "email": "admin@example.com", + "name": "Pip", + "state": "active", + "created_at": "2013-09-30T13:46:01Z" }, - "created_at":"2013-10-02T09:22:45Z" + "created_at": "2013-10-02T09:22:45Z" }, { - "id":305, - "body":"Text of the comment\r\n", - "attachment":null, - "author":{ - "id":1, - "username":"pipin", - "email":"admin@example.com", - "name":"Pip", - "state":"active", - "created_at":"2013-09-30T13:46:01Z" + "id": 305, + "body": "Text of the comment\r\n", + "attachment": null, + "author": { + "id": 1, + "username": "pipin", + "email": "admin@example.com", + "name": "Pip", + "state": "active", + "created_at": "2013-09-30T13:46:01Z" }, - "created_at":"2013-10-02T09:56:03Z" + "created_at": "2013-10-02T09:56:03Z" } ] ``` @@ -169,20 +171,20 @@ Parameters: ```json { - "id":52, - "title":"Snippet", - "file_name":"snippet.rb", - "author":{ - "id":1, - "username":"pipin", - "email":"admin@example.com", - "name":"Pip", - "state":"active", - "created_at":"2013-09-30T13:46:01Z" + "id": 52, + "title": "Snippet", + "file_name": "snippet.rb", + "author": { + "id": 1, + "username": "pipin", + "email": "admin@example.com", + "name": "Pip", + "state": "active", + "created_at": "2013-09-30T13:46:01Z" }, - "expires_at":null, - "updated_at":"2013-10-02T07:34:20Z", - "created_at":"2013-10-02T07:34:20Z" + "expires_at": null, + "updated_at": "2013-10-02T07:34:20Z", + "created_at": "2013-10-02T07:34:20Z" } ``` @@ -233,18 +235,18 @@ Parameters: ```json { - "id":301, - "body":"Comment for MR", - "attachment":null, - "author":{ - "id":1, - "username":"pipin", - "email":"admin@example.com", - "name":"Pip", - "state":"active", - "created_at":"2013-09-30T13:46:01Z" + "id": 301, + "body": "Comment for MR", + "attachment": null, + "author": { + "id": 1, + "username": "pipin", + "email": "admin@example.com", + "name": "Pip", + "state": "active", + "created_at": "2013-09-30T13:46:01Z" }, - "created_at":"2013-10-02T08:57:14Z" + "created_at": "2013-10-02T08:57:14Z" } ``` diff --git a/doc/api/project_snippets.md b/doc/api/project_snippets.md index f7b7fc8fbb..e16e1e8459 100644 --- a/doc/api/project_snippets.md +++ b/doc/api/project_snippets.md @@ -57,7 +57,6 @@ Parameters: + `id` (required) - The ID of a project + `title` (required) - The title of a snippet + `file_name` (required) - The name of a snippet file -+ `lifetime` (optional) - The expiration date of a snippet + `code` (required) - The content of a snippet @@ -75,7 +74,6 @@ Parameters: + `snippet_id` (required) - The ID of a project's snippet + `title` (optional) - The title of a snippet + `file_name` (optional) - The name of a snippet file -+ `lifetime` (optional) - The expiration date of a snippet + `code` (optional) - The content of a snippet diff --git a/doc/api/projects.md b/doc/api/projects.md index 3ae9af59fc..ffaba0af7f 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -2,7 +2,7 @@ ### List projects -Get a list of projects owned by the authenticated user. +Get a list of projects accessible by the authenticated user. ``` GET /projects @@ -15,6 +15,7 @@ GET /projects "description": null, "default_branch": "master", "public": false, + "visibility_level": 0, "ssh_url_to_repo": "git@example.com:diaspora/diaspora-client.git", "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git", "web_url": "http://example.com/diaspora/diaspora-client", @@ -42,17 +43,19 @@ GET /projects "owner_id": 1, "path": "diaspora", "updated_at": "2013-09-30T13: 46: 02Z" - } + }, + "archived": false }, { "id": 6, "description": null, "default_branch": "master", "public": false, + "visibility_level": 0, "ssh_url_to_repo": "git@example.com:brightbox/puppet.git", "http_url_to_repo": "http://example.com/brightbox/puppet.git", "web_url": "http://example.com/brightbox/puppet", - "owner": { + "owner": { "id": 4, "name": "Brightbox", "created_at": "2013-09-30T13:46:02Z" @@ -68,7 +71,7 @@ GET /projects "snippets_enabled": false, "created_at": "2013-09-30T13:46:02Z", "last_activity_at": "2013-09-30T13:46:02Z", - "namespace": { + "namespace": { "created_at": "2013-09-30T13:46:02Z", "description": "", "id": 4, @@ -76,12 +79,29 @@ GET /projects "owner_id": 1, "path": "brightbox", "updated_at": "2013-09-30T13:46:02Z" - } + }, + "archived": false } ] ``` +#### List owned projects + +Get a list of projects owned by the authenticated user. + +``` +GET /projects/owned +``` + +#### List ALL projects + +Get a list of all GitLab projects (admin only). + +``` +GET /projects/all +``` + ### Get single project Get a specific project, identified by project ID or NAMESPACE/PROJECT_NAME , which is owned by the authentication user. @@ -101,6 +121,7 @@ Parameters: "description": null, "default_branch": "master", "public": false, + "visibility_level": 0, "ssh_url_to_repo": "git@example.com:diaspora/diaspora-project-site.git", "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", @@ -128,7 +149,18 @@ Parameters: "owner_id": 1, "path": "diaspora", "updated_at": "2013-09-30T13: 46: 02Z" - } + }, + "permissions": { + "project_access": { + "access_level": 10, + "notification_level": 3 + }, + "group_access": { + "access_level": 50, + "notification_level": 3 + } + }, + "archived": false } ``` @@ -143,61 +175,66 @@ GET /projects/:id/events Parameters: -+ `id` (required) - The ID or NAME of a project ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project ```json - -[{ - "title": null, - "project_id": 15, - "action_name": "closed", - "target_id": 830, - "target_type": "Issue", - "author_id": 1, - "data": null, - "target_title": "Public project search field" -}, { - "title": null, - "project_id": 15, - "action_name": "opened", - "target_id": null, - "target_type": null, - "author_id": 1, - "data": { - "before": "50d4420237a9de7be1304607147aec22e4a14af7", - "after": "c5feabde2d8cd023215af4d2ceeb7a64839fc428", - "ref": "refs/heads/master", - "user_id": 1, - "user_name": "Dmitriy Zaporozhets", - "repository": { - "name": "gitlabhq", - "url": "git@dev.gitlab.org:gitlab/gitlabhq.git", - "description": "GitLab: self hosted Git management software. \r\nDistributed under the MIT License.", - "homepage": "https://dev.gitlab.org/gitlab/gitlabhq" - }, - "commits": [{ - "id": "c5feabde2d8cd023215af4d2ceeb7a64839fc428", - "message": "Add simple search to projects in public area", - "timestamp": "2013-05-13T18:18:08+00:00", - "url": "https://dev.gitlab.org/gitlab/gitlabhq/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428", - "author": { - "name": "Dmitriy Zaporozhets", - "email": "dmitriy.zaporozhets@gmail.com" - } - }], - "total_commits_count": 1 +[ + { + "title": null, + "project_id": 15, + "action_name": "closed", + "target_id": 830, + "target_type": "Issue", + "author_id": 1, + "data": null, + "target_title": "Public project search field" }, - "target_title": null -}, { - "title": null, - "project_id": 15, - "action_name": "closed", - "target_id": 840, - "target_type": "Issue", - "author_id": 1, - "data": null, - "target_title": "Finish & merge Code search PR" -}] + { + "title": null, + "project_id": 15, + "action_name": "opened", + "target_id": null, + "target_type": null, + "author_id": 1, + "data": { + "before": "50d4420237a9de7be1304607147aec22e4a14af7", + "after": "c5feabde2d8cd023215af4d2ceeb7a64839fc428", + "ref": "refs/heads/master", + "user_id": 1, + "user_name": "Dmitriy Zaporozhets", + "repository": { + "name": "gitlabhq", + "url": "git@dev.gitlab.org:gitlab/gitlabhq.git", + "description": "GitLab: self hosted Git management software. \r\nDistributed under the MIT License.", + "homepage": "https://dev.gitlab.org/gitlab/gitlabhq" + }, + "commits": [ + { + "id": "c5feabde2d8cd023215af4d2ceeb7a64839fc428", + "message": "Add simple search to projects in public area", + "timestamp": "2013-05-13T18:18:08+00:00", + "url": "https://dev.gitlab.org/gitlab/gitlabhq/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428", + "author": { + "name": "Dmitriy Zaporozhets", + "email": "dmitriy.zaporozhets@gmail.com" + } + } + ], + "total_commits_count": 1 + }, + "target_title": null + }, + { + "title": null, + "project_id": 15, + "action_name": "closed", + "target_id": 840, + "target_type": "Issue", + "author_id": 1, + "data": null, + "target_title": "Finish & merge Code search PR" + } +] ``` @@ -212,14 +249,16 @@ POST /projects Parameters: + `name` (required) - new project name ++ `namespace_id` (optional) - namespace for the new project (defaults to user) + `description` (optional) - short project description -+ `default_branch` (optional) - 'master' by default + `issues_enabled` (optional) + `wall_enabled` (optional) + `merge_requests_enabled` (optional) + `wiki_enabled` (optional) + `snippets_enabled` (optional) -+ `public` (optional) ++ `public` (optional) - if `true` same as setting visibility_level = 20 ++ `visibility_level` (optional) +* `import_url` (optional) ### Create project for user @@ -241,7 +280,8 @@ Parameters: + `merge_requests_enabled` (optional) + `wiki_enabled` (optional) + `snippets_enabled` (optional) -+ `public` (optional) ++ `public` (optional) - if `true` same as setting visibility_level = 20 ++ `visibility_level` (optional) ## Remove project @@ -269,7 +309,7 @@ GET /projects/:id/members Parameters: -+ `id` (required) - The ID or NAME of a project ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + `query` (optional) - Query string to search for members @@ -283,7 +323,7 @@ GET /projects/:id/members/:user_id Parameters: -+ `id` (required) - The ID or NAME of a project ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + `user_id` (required) - The ID of a user ```json @@ -311,7 +351,7 @@ POST /projects/:id/members Parameters: -+ `id` (required) - The ID or NAME of a project ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + `user_id` (required) - The ID of a user to add + `access_level` (required) - Project access level @@ -326,7 +366,7 @@ PUT /projects/:id/members/:user_id Parameters: -+ `id` (required) - The ID or NAME of a project ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + `user_id` (required) - The ID of a team member + `access_level` (required) - Project access level @@ -341,7 +381,7 @@ DELETE /projects/:id/members/:user_id Parameters: -+ `id` (required) - The ID or NAME of a project ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + `user_id` (required) - The ID of a team member This method is idempotent and can be called multiple times with the same parameters. @@ -362,7 +402,7 @@ GET /projects/:id/hooks Parameters: -+ `id` (required) - The ID or NAME of a project ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project ### Get project hook @@ -375,13 +415,17 @@ GET /projects/:id/hooks/:hook_id Parameters: -+ `id` (required) - The ID or NAME of a project ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + `hook_id` (required) - The ID of a project hook ```json { "id": 1, "url": "http://example.com/hook", + "project_id": 3, + "push_events": "true", + "issues_events": "true", + "merge_requests_events": "true", "created_at": "2012-10-12T17:04:47Z" } ``` @@ -397,8 +441,11 @@ POST /projects/:id/hooks Parameters: -+ `id` (required) - The ID or NAME of a project ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + `url` (required) - The hook URL ++ `push_events` - Trigger hook on push events ++ `issues_events` - Trigger hook on issues events ++ `merge_requests_events` - Trigger hook on merge_requests events ### Edit project hook @@ -411,9 +458,12 @@ PUT /projects/:id/hooks/:hook_id Parameters: -+ `id` (required) - The ID or NAME of a project ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + `hook_id` (required) - The ID of a project hook + `url` (required) - The hook URL ++ `push_events` - Trigger hook on push events ++ `issues_events` - Trigger hook on issues events ++ `merge_requests_events` - Trigger hook on merge_requests events ### Delete project hook @@ -427,7 +477,7 @@ DELETE /projects/:id/hooks/:hook_id Parameters: -+ `id` (required) - The ID or NAME of a project ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + `hook_id` (required) - The ID of hook to delete Note the JSON response differs if the hook is available or not. If the project hook @@ -446,39 +496,43 @@ GET /projects/:id/repository/branches Parameters: -+ `id` (required) - The ID of the project ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project ```json [ { - "name":"async", + "name": "async", "commit": { - "id":"a2b702edecdf41f07b42653eb1abe30ce98b9fca", - "parents": [{ - "id":"3f94fc7c85061973edc9906ae170cc269b07ca55" - }], + "id": "a2b702edecdf41f07b42653eb1abe30ce98b9fca", + "parents": [ + { + "id": "3f94fc7c85061973edc9906ae170cc269b07ca55" + } + ], "tree": "c68537c6534a02cc2b176ca1549f4ffa190b58ee", - "message":"give caolan his credit where it's due (up top)", + "message": "give caolan credit where it's due (up top)", "author": { - "name":"Jeremy Ashkenas", - "email":"jashkenas@example.com" + "name": "Jeremy Ashkenas", + "email": "jashkenas@example.com" }, "committer": { - "name":"Jeremy Ashkenas", - "email":"jashkenas@example.com" + "name": "Jeremy Ashkenas", + "email": "jashkenas@example.com" }, - "authored_date":"2010-12-08T21:28:50+00:00", - "committed_date":"2010-12-08T21:28:50+00:00" + "authored_date": "2010-12-08T21:28:50+00:00", + "committed_date": "2010-12-08T21:28:50+00:00" }, - "protected":false + "protected": false }, { "name": "gh-pages", "commit": { "id": "101c10a60019fe870d21868835f65c25d64968fc", - "parents": [{ - "id": "9c15d2e26945a665131af5d7b6d30a06ba338aaa" - }], + "parents": [ + { + "id": "9c15d2e26945a665131af5d7b6d30a06ba338aaa" + } + ], "tree": "fb5cc9d45da3014b17a876ad539976a0fb9b352a", "message": "Underscore.js 1.5.2", "author": { @@ -495,7 +549,6 @@ Parameters: "protected": false } ] - ``` ### List single branch @@ -508,7 +561,7 @@ GET /projects/:id/repository/branches/:branch Parameters: -+ `id` (required) - The ID of the project. ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + `branch` (required) - The name of the branch. @@ -522,7 +575,7 @@ PUT /projects/:id/repository/branches/:branch/protect Parameters: -+ `id` (required) - The ID of the project. ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + `branch` (required) - The name of the branch. @@ -536,7 +589,7 @@ PUT /projects/:id/repository/branches/:branch/unprotect Parameters: -+ `id` (required) - The ID of the project. ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + `branch` (required) - The name of the branch. @@ -579,3 +632,29 @@ Parameters: + query (required) - A string contained in the project name + per_page (optional) - number of projects to return per page + page (optional) - the page to retrieve + + +## Labels + +### List project labels + +Get a list of project labels. + +``` +GET /projects/:id/labels +``` + +Parameters: + ++ `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project + +```json +[ + { + "name": "feature" + }, + { + "name": "bug" + } +] +``` diff --git a/doc/api/repositories.md b/doc/api/repositories.md index 2769c22d6a..858fad0a0b 100644 --- a/doc/api/repositories.md +++ b/doc/api/repositories.md @@ -1,170 +1,3 @@ -## List repository branches - -Get a list of repository branches from a project, sorted by name alphabetically. - -``` -GET /projects/:id/repository/branches -``` - -Parameters: - -+ `id` (required) - The ID of a project - -```json -[ - { - "name": "master", - "commit": { - "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c", - "parents": [ - { - "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8" - } - ], - "tree": "46e82de44b1061621357f24c05515327f2795a95", - "message": "add projects API", - "author": { - "name": "John Smith", - "email": "john@example.com" - }, - "committer": { - "name": "John Smith", - "email": "john@example.com" - }, - "authored_date": "2012-06-27T05:51:39-07:00", - "committed_date": "2012-06-28T03:44:20-07:00" - }, - "protected": true - } -] -``` - - -## Get single repository branch - -Get a single project repository branch. - -``` -GET /projects/:id/repository/branches/:branch -``` - -Parameters: - -+ `id` (required) - The ID of a project -+ `branch` (required) - The name of the branch - -```json -{ - "name": "master", - "commit": { - "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c", - "parents": [ - { - "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8" - } - ], - "tree": "46e82de44b1061621357f24c05515327f2795a95", - "message": "add projects API", - "author": { - "name": "John Smith", - "email": "john@example.com" - }, - "committer": { - "name": "John Smith", - "email": "john@example.com" - }, - "authored_date": "2012-06-27T05:51:39-07:00", - "committed_date": "2012-06-28T03:44:20-07:00" - }, - "protected": true -} -``` - - -## Protect repository branch - -Protects a single project repository branch. This is an idempotent function, protecting an already -protected repository branch still returns a `200 Ok` status code. - -``` -PUT /projects/:id/repository/branches/:branch/protect -``` - -Parameters: - -+ `id` (required) - The ID of a project -+ `branch` (required) - The name of the branch - -```json -{ - "name": "master", - "commit": { - "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c", - "parents": [ - { - "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8" - } - ], - "tree": "46e82de44b1061621357f24c05515327f2795a95", - "message": "add projects API", - "author": { - "name": "John Smith", - "email": "john@example.com" - }, - "committer": { - "name": "John Smith", - "email": "john@example.com" - }, - "authored_date": "2012-06-27T05:51:39-07:00", - "committed_date": "2012-06-28T03:44:20-07:00" - }, - "protected": true -} -``` - - -## Unprotect repository branch - -Unprotects a single project repository branch. This is an idempotent function, unprotecting an already -unprotected repository branch still returns a `200 Ok` status code. - -``` -PUT /projects/:id/repository/branches/:branch/unprotect -``` - -Parameters: - -+ `id` (required) - The ID of a project -+ `branch` (required) - The name of the branch - -```json -{ - "name": "master", - "commit": { - "id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c", - "parents": [ - { - "id": "4ad91d3c1144c406e50c7b33bae684bd6837faf8" - } - ], - "tree": "46e82de44b1061621357f24c05515327f2795a95", - "message": "add projects API", - "author": { - "name": "John Smith", - "email": "john@example.com" - }, - "committer": { - "name": "John Smith", - "email": "john@example.com" - }, - "authored_date": "2012-06-27T05:51:39-07:00", - "committed_date": "2012-06-28T03:44:20-07:00" - }, - "protected": false -} -``` - - ## List project repository tags Get a list of repository tags from a project, sorted by name in reverse alphabetical order. @@ -183,9 +16,7 @@ Parameters: "name": "v1.0.0", "commit": { "id": "2695effb5807a22ff3d138d593fd856244e155e7", - "parents": [ - - ], + "parents": [], "tree": "38017f2f189336fe4497e9d230c5bb1bf873f08d", "message": "Initial commit", "author": { @@ -204,94 +35,6 @@ Parameters: ] ``` - -## List repository commits - -Get a list of repository commits in a project. - -``` -GET /projects/:id/repository/commits -``` - -Parameters: - -+ `id` (required) - The ID of a project -+ `ref_name` (optional) - The name of a repository branch or tag or if not given the default branch - -```json -[ - { - "id": "ed899a2f4b50b4370feeea94676502b42383c746", - "short_id": "ed899a2f4b5", - "title": "Replace sanitize with escape once", - "author_name": "Dmitriy Zaporozhets", - "author_email": "dzaporozhets@sphereconsultinginc.com", - "created_at": "2012-09-20T11:50:22+03:00" - }, - { - "id": "6104942438c14ec7bd21c6cd5bd995272b3faff6", - "short_id": "6104942438c", - "title": "Sanitize for network graph", - "author_name": "randx", - "author_email": "dmitriy.zaporozhets@gmail.com", - "created_at": "2012-09-20T09:06:12+03:00" - } -] -``` - -## Get a single commit - -Get a specific commit identified by the commit hash or name of a branch or tag. - -``` -GET /projects/:id/repository/commits/:sha -``` - -Parameters: - -+ `id` (required) - The ID of a project -+ `sha` (required) - The commit hash or name of a repository branch or tag - -```json -{ - "id": "6104942438c14ec7bd21c6cd5bd995272b3faff6", - "short_id": "6104942438c", - "title": "Sanitize for network graph", - "author_name": "randx", - "author_email": "dmitriy.zaporozhets@gmail.com", - "created_at": "2012-09-20T09:06:12+03:00" -} -``` - - -## Get the diff of a commit - -Get the diff of a commit in a project. - -``` -GET /projects/:id/repository/commits/:sha/diff -``` - -Parameters: - -+ `id` (required) - The ID of a project -+ `sha` (required) - The name of a repository branch or tag or if not given the default branch - -```json -[ - { - "diff": "--- a/doc/update/5.4-to-6.0.md\n+++ b/doc/update/5.4-to-6.0.md\n@@ -71,6 +71,8 @@\n sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production\n sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production\n \n+sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production\n+\n ```\n \n ### 6. Update config files", - "new_path": "doc/update/5.4-to-6.0.md", - "old_path": "doc/update/5.4-to-6.0.md", - "a_mode": null, - "b_mode": "100644", - "new_file": false, - "renamed_file": false, - "deleted_file": false - } -] -``` - ## List repository tree Get a list of repository files and directories in a project. @@ -307,45 +50,50 @@ Parameters: + `ref_name` (optional) - The name of a repository branch or tag or if not given the default branch ```json - -[{ - "name": "assets", - "type": "tree", - "mode": "040000", - "id": "6229c43a7e16fcc7e95f923f8ddadb8281d9c6c6" -}, { - "name": "contexts", - "type": "tree", - "mode": "040000", - "id": "faf1cdf33feadc7973118ca42d35f1e62977e91f" -}, { - "name": "controllers", - "type": "tree", - "mode": "040000", - "id": "95633e8d258bf3dfba3a5268fb8440d263218d74" -}, { - "name": "Rakefile", - "type": "blob", - "mode": "100644", - "id": "35b2f05cbb4566b71b34554cf184a9d0bd9d46d6" -}, { - "name": "VERSION", - "type": "blob", - "mode": "100644", - "id": "803e4a4f3727286c3093c63870c2b6524d30ec4f" -}, { - "name": "config.ru", - "type": "blob", - "mode": "100644", - "id": "dfd2d862237323aa599be31b473d70a8a817943b" -}] - +[ + { + "name": "assets", + "type": "tree", + "mode": "040000", + "id": "6229c43a7e16fcc7e95f923f8ddadb8281d9c6c6" + }, + { + "name": "contexts", + "type": "tree", + "mode": "040000", + "id": "faf1cdf33feadc7973118ca42d35f1e62977e91f" + }, + { + "name": "controllers", + "type": "tree", + "mode": "040000", + "id": "95633e8d258bf3dfba3a5268fb8440d263218d74" + }, + { + "name": "Rakefile", + "type": "blob", + "mode": "100644", + "id": "35b2f05cbb4566b71b34554cf184a9d0bd9d46d6" + }, + { + "name": "VERSION", + "type": "blob", + "mode": "100644", + "id": "803e4a4f3727286c3093c63870c2b6524d30ec4f" + }, + { + "name": "config.ru", + "type": "blob", + "mode": "100644", + "id": "dfd2d862237323aa599be31b473d70a8a817943b" + } +] ``` -## Raw blob content +## Raw file content -Get the raw file contents for a file. +Get the raw file contents for a file by commit sha and path. ``` GET /projects/:id/repository/blobs/:sha @@ -358,6 +106,20 @@ Parameters: + `filepath` (required) - The path the file +## Raw blob content + +Get the raw file contents for a blob by blob sha. + +``` +GET /projects/:id/repository/raw_blobs/:sha +``` + +Parameters: + ++ `id` (required) - The ID of a project ++ `sha` (required) - The blob sha + + ## Get file archive Get a an archive of the repository @@ -368,4 +130,4 @@ GET /projects/:id/repository/archive Parameters: + `id` (required) - The ID of a project -+ `sha` (optional) - The commit sha to download defaults to the tip of the default branch \ No newline at end of file ++ `sha` (optional) - The commit sha to download defaults to the tip of the default branch diff --git a/doc/api/repository_files.md b/doc/api/repository_files.md new file mode 100644 index 0000000000..b215cc2500 --- /dev/null +++ b/doc/api/repository_files.md @@ -0,0 +1,102 @@ +# CRUD for repository files + +## Create, read, update and delete repository files using this API + +- - - + +## Get file from repository + +Allows you to receive information about file in repository like name, size, content. +Note that file content is Base64 encoded. + +``` +GET /projects/:id/repository/files +``` + +Example response: + +```json +{ + "file_name": "key.rb", + "file_path": "app/models/key.rb", + "size": 1476, + "encoding": "base64", + "content": "IyA9PSBTY2hlbWEgSW5mb3...", + "ref": "master", + "blob_id": "79f7bbd25901e8334750839545a9bd021f0e4c83", + "commit_id": "d5a3ff139356ce33e37e73add446f16869741b50" +} +``` + +Parameters: + ++ `file_path` (required) - Full path to new file. Ex. lib/class.rb ++ `ref` (required) - The name of branch, tag or commit + +## Create new file in repository + +``` +POST /projects/:id/repository/files +``` + +Example response: + +```json +{ + "file_name": "app/project.rb", + "branch_name": "master" +} +``` + +Parameters: + ++ `file_path` (required) - Full path to new file. Ex. lib/class.rb ++ `branch_name` (required) - The name of branch ++ `encoding` (optional) - 'text' or 'base64'. Text is default. ++ `content` (required) - File content ++ `commit_message` (required) - Commit message + +## Update existing file in repository + +``` +PUT /projects/:id/repository/files +``` + +Example response: + +```json +{ + "file_name": "app/project.rb", + "branch_name": "master" +} +``` + +Parameters: + ++ `file_path` (required) - Full path to file. Ex. lib/class.rb ++ `branch_name` (required) - The name of branch ++ `encoding` (optional) - 'text' or 'base64'. Text is default. ++ `content` (required) - New file content ++ `commit_message` (required) - Commit message + +## Delete existing file in repository + +``` +DELETE /projects/:id/repository/files +``` + +Example response: + +```json +{ + "file_name": "app/project.rb", + "branch_name": "master" +} +``` + +Parameters: + ++ `file_path` (required) - Full path to file. Ex. lib/class.rb ++ `branch_name` (required) - The name of branch ++ `commit_message` (required) - Commit message + diff --git a/doc/api/session.md b/doc/api/session.md index 162d4c8bf7..0be5af79da 100644 --- a/doc/api/session.md +++ b/doc/api/session.md @@ -26,11 +26,12 @@ __You can login with both GitLab and LDAP credentials now__ "skype": "", "linkedin": "", "twitter": "", + "website_url": "", "dark_scheme": false, "theme_id": 1, "is_admin": false, - "can_create_group" : true, - "can_create_team" : true, - "can_create_project" : true + "can_create_group": true, + "can_create_team": true, + "can_create_project": true } ``` diff --git a/doc/api/system_hooks.md b/doc/api/system_hooks.md index 355ce31c12..d4c45ea9bb 100644 --- a/doc/api/system_hooks.md +++ b/doc/api/system_hooks.md @@ -1,70 +1,70 @@ -All methods require admin authorization. - -The url endpoint of the system hooks can be configured in [the admin area under hooks](/admin/hooks). - -## List system hooks - -Get list of system hooks - -``` -GET /hooks -``` - -Parameters: - -+ **none** - -```json -[ - { - "id":3, - "url":"http://example.com/hook", - "created_at":"2013-10-02T10:15:31Z" - } -] -``` - -## Add new system hook hook - -``` -POST /hooks -``` - -Parameters: - -+ `url` (required) - The hook URL - - -## Test system hook - -``` -GET /hooks/:id -``` - -Parameters: - -+ `id` (required) - The ID of hook - -```json -{ - "event_name":"project_create", - "name":"Ruby", - "path":"ruby", - "project_id":1, - "owner_name":"Someone", - "owner_email":"example@gitlabhq.com" -} -``` - -## Delete system hook - -Deletes a system hook. This is an idempotent API function and returns `200 Ok` even if the hook -is not available. If the hook is deleted it is also returned as JSON. - -``` -DELETE /hooks/:id -``` - -Parameters: - -+ `id` (required) - The ID of hook +All methods require admin authorization. + +The url endpoint of the system hooks can be configured in [the admin area under hooks](/admin/hooks). + +## List system hooks + +Get list of system hooks + +``` +GET /hooks +``` + +Parameters: + ++ **none** + +```json +[ + { + "id": 3, + "url": "http://example.com/hook", + "created_at": "2013-10-02T10:15:31Z" + } +] +``` + +## Add new system hook hook + +``` +POST /hooks +``` + +Parameters: + ++ `url` (required) - The hook URL + + +## Test system hook + +``` +GET /hooks/:id +``` + +Parameters: + ++ `id` (required) - The ID of hook + +```json +{ + "event_name": "project_create", + "name": "Ruby", + "path": "ruby", + "project_id": 1, + "owner_name": "Someone", + "owner_email": "example@gitlabhq.com" +} +``` + +## Delete system hook + +Deletes a system hook. This is an idempotent API function and returns `200 Ok` even if the hook +is not available. If the hook is deleted it is also returned as JSON. + +``` +DELETE /hooks/:id +``` + +Parameters: + ++ `id` (required) - The ID of hook diff --git a/doc/api/users.md b/doc/api/users.md index 16479ea6e0..2b927c3077 100644 --- a/doc/api/users.md +++ b/doc/api/users.md @@ -20,6 +20,7 @@ GET /users "skype": "", "linkedin": "", "twitter": "", + "website_url": "", "extern_uid": "john.smith", "provider": "provider_name", "theme_id": 1, @@ -38,6 +39,7 @@ GET /users "skype": "", "linkedin": "", "twitter": "", + "website_url": "", "extern_uid": "jack.smith", "provider": "provider_name", "theme_id": 1, @@ -49,6 +51,10 @@ GET /users ] ``` +You can search for a users by email or username with: +`/users?search=John` + +Also see `def search query` in `app/models/user.rb`. ## Single user @@ -74,6 +80,7 @@ Parameters: "skype": "", "linkedin": "", "twitter": "", + "website_url": "", "extern_uid": "john.smith", "provider": "provider_name", "theme_id": 1, @@ -102,6 +109,7 @@ Parameters: + `skype` (optional) - Skype ID + `linkedin` (optional) - Linkedin + `twitter` (optional) - Twitter account ++ `website_url` (optional) - Website url + `projects_limit` (optional) - Number of projects user can create + `extern_uid` (optional) - External UID + `provider` (optional) - External provider name @@ -127,6 +135,7 @@ Parameters: + `skype` - Skype ID + `linkedin` - Linkedin + `twitter` - Twitter account ++ `website_url` - Website url + `projects_limit` - Limit projects each user can create + `extern_uid` - External UID + `provider` - External provider name @@ -174,11 +183,12 @@ GET /user "skype": "", "linkedin": "", "twitter": "", + "website_url": "", "theme_id": 1, "color_scheme_id": 2, "is_admin": false, - "can_create_group" : true, - "can_create_project" : true + "can_create_group": true, + "can_create_project": true } ``` @@ -195,17 +205,13 @@ GET /user/keys [ { "id": 1, - "title" : "Public key", - "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 - 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 - soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=", + "title": "Public key", + "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" }, { "id": 3, - "title" : "Another Public key", - "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 - 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 - soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" + "title": "Another Public key", + "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" } ] ``` @@ -214,6 +220,18 @@ Parameters: + **none** +## List SSH keys for user + +Get a list of a specified user's SSH keys. Available only for admin + +``` +GET /users/:uid/keys +``` + +Parameters: + ++ `uid` (required) - id of specified user + ## Single SSH key @@ -230,10 +248,8 @@ Parameters: ```json { "id": 1, - "title" : "Public key", - "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4 - 596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4 - soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" + "title": "Public key", + "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0=" } ``` @@ -282,3 +298,18 @@ Parameters: + `id` (required) - SSH key ID +## Delete SSH key + +Deletes key owned by a specified user. Available only for admin. + +``` +DELETE /users/:uid/keys/:id +``` + +Parameters: + ++ `uid` (required) - id of specified user ++ `id` (required) - SSH key ID + +Will return `200 Ok` on success, or `404 Not found` if either user or key cannot be found. + diff --git a/doc/development/README.md b/doc/development/README.md new file mode 100644 index 0000000000..eb88b6c860 --- /dev/null +++ b/doc/development/README.md @@ -0,0 +1,5 @@ +## Development + ++ [Architecture](architecture.md) of GitLab ++ [Shell commands](shell_commands.md) in the GitLab codebase ++ [Rake tasks](rake_tasks.md) for development diff --git a/doc/development/architecture.md b/doc/development/architecture.md new file mode 100644 index 0000000000..f2f7a3d5f0 --- /dev/null +++ b/doc/development/architecture.md @@ -0,0 +1,183 @@ +# GitLab Architecture Overview +--- + +# Software delivery + +There are two editions of GitLab: [Enterprise Edition](https://www.gitlab.com/gitlab-ee/) (EE) and [Community Edition](https://www.gitlab.com/gitlab-ce/) (CE). +GitLab CE is delivered via git from the [gitlabhq repository](https://gitlab.com/gitlab-org/gitlab-ce/tree/master). +New versions of GitLab are released in stable branches and the master branch is for bleeding edge development. + +EE releases are available not long after CE releases. +To obtain the GitLab EE there is a [repository at gitlab.com](https://gitlab.com/subscribers/gitlab-ee). +For more information about the release process see the section 'New versions and upgrading' in the readme. + +Both EE and CE require an add-on component called gitlab-shell. +It is obtained from the [gitlab-shell repository](https://gitlab.com/gitlab-org/gitlab-shell/tree/master). +New versions are usually tags but staying on the master branch will give you the latest stable version. +New releases are generally around the same time as GitLab CE releases with exception for informal security updates deemed critical. + +# System Layout + +When referring to ~git in the pictures it means the home directory of the git user which is typically /home/git. + +GitLab is primarily installed within the `/home/git` user home directory as `git` user. +Within the home directory is where the gitlabhq server software resides as well as the repositories (though the repository location is configurable). +The bare repositories are located in `/home/git/repositories`. +GitLab is a ruby on rails application so the particulars of the inner workings can be learned by studying how a ruby on rails application works. +To serve repositories over SSH there's an add-on application called gitlab-shell which is installed in `/home/git/gitlab-shell`. + +## Components + +![GitLab Diagram Overview](gitlab_diagram_overview.png) + +A typical install of GitLab will be on Ubuntu Linux or RHEL/CentOS. +It uses Nginx or Apache as a web front end to proxypass the Unicorn web server. +By default, communication between Unicorn and the front end is via a Unix domain socket but forwarding requests via TCP is also supported. +The web front end accesses `/home/git/gitlab/public` bypassing the Unicorn server to serve static pages, uploads (e.g. avatar images or attachments), and precompiled assets. +GitLab serves web pages and a [GitLab API](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/api) using the Unicorn web server. +It uses Sidekiq as a job queue which, in turn, uses redis as a non-persistent database backend for job information, meta data, and incomming jobs. +The GitLab web app uses MySQL or PostgreSQL for persistent database information (e.g. users, permissions, issues, other meta data). +GitLab stores the bare git repositories it serves in `/home/git/repositories` by default. +It also keeps default branch and hook information with the bare repository. +`/home/git/gitlab-satellites` keeps checked out repositories when performing actions such as a merge request, editing files in the web interface, etc. +The satellite repository is used by the web interface for editing repositories and the wiki which is also a git repository. +When serving repositories over HTTP/HTTPS GitLab utilizes the GitLab API to resolve authorization and access as well as serving git objects. + +The add-on component gitlab-shell serves repositories over SSH. +It manages the SSH keys within `/home/git/.ssh/authorized_keys` which should not be manually edited. +gitlab-shell accesses the bare repositories directly to serve git objects and communicates with redis to submit jobs to Sidekiq for GitLab to process. + gitlab-shell queries the GitLab API to determine authorization and access. + +## Installation Folder Summary + +To summarize here's the [directory structure of the `git` user home directory](../install/structure.md). + + +## Processes + + ps aux | grep '^git' + +GitLab has several components to operate. +As a system user (i.e. any user that is not the `git` user) it requires a persistent database (MySQL/PostreSQL) and redis database. +It also uses Apache httpd or nginx to proxypass Unicorn. +As the `git` user it starts Sidekiq and Unicorn (a simple ruby HTTP server running on port `8080` by default). +Under the gitlab user there are normally 4 processes: `unicorn_rails master` (1 process), `unicorn_rails worker` (2 processes), `sidekiq` (1 process). + +## Repository access + +Repositories get accessed via HTTP or SSH. +HTTP cloning/push/pull utilizes the GitLab API and SSH cloning is handled by gitlab-shell (previously explained). + +# Troubleshooting + +See the README for more information. + +## Init scripts of the services + +The GitLab init script starts and stops Unicorn and Sidekiq. + +``` +/etc/init.d/gitlab +Usage: service gitlab {start|stop|restart|reload|status} +``` + +Redis (key-value store/non-persistent database) + +``` +/etc/init.d/redis +Usage: /etc/init.d/redis {start|stop|status|restart|condrestart|try-restart} +``` + +SSH daemon + +``` +/etc/init.d/sshd +Usage: /etc/init.d/sshd {start|stop|restart|reload|force-reload|condrestart|try-restart|status} +``` + +Web server (one of the following) + +``` +/etc/init.d/httpd +Usage: httpd {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest} + +$ /etc/init.d/nginx +Usage: nginx {start|stop|restart|reload|force-reload|status|configtest} +``` + +Persistent database (one of the following) + +``` +/etc/init.d/mysqld +Usage: /etc/init.d/mysqld {start|stop|status|restart|condrestart|try-restart|reload|force-reload} + +$ /etc/init.d/postgresql +Usage: /etc/init.d/postgresql {start|stop|restart|reload|force-reload|status} [version ..] +``` + +## Log locations of the services + +Note: `/home/git/` is shorthand for `/home/git`. + +gitlabhq (includes Unicorn and Sidekiq logs) + +* `/home/git/gitlab/log/` contains `application.log`, `production.log`, `sidekiq.log`, `unicorn.stdout.log`, `githost.log`, `satellites.log`, and `unicorn.stderr.log` normally. + +gitlab-shell + +* `/home/git/gitlab-shell/gitlab-shell.log` + +ssh + +* `/var/log/auth.log` auth log (on Ubuntu). +* `/var/log/secure` auth log (on RHEL). + +nginx + +* `/var/log/nginx/` contains error and access logs. + +Apache httpd + +* [Explanation of apache logs](http://httpd.apache.org/docs/2.2/logs.html). +* `/var/log/apache2/` contains error and output logs (on Ubuntu). +* `/var/log/httpd/` contains error and output logs (on RHEL). + +redis + +* `/var/log/redis/redis.log` there are also logrotated logs there. + +PostgreSQL + +* `/var/log/postgresql/*` + +MySQL + +* `/var/log/mysql/*` +* `/var/log/mysql.*` + +## GitLab specific config files + +GitLab has configuration files located in `/home/git/gitlab/config/*`. +Commonly referenced config files include: + +* `gitlab.yml` - GitLab configuration. +* `unicorn.rb` - Unicorn web server settings. +* `database.yml` - Database connection settings. + +gitlab-shell has a configuration file at `/home/git/gitlab-shell/config.yml`. + +## Maintenance Tasks + +[GitLab](https://gitlab.com/gitlab-org/gitlab-ce/tree/master) provides rake tasks with which you see version information and run a quick check on your configuration to ensure it is configured properly within the application. +See [maintenance rake tasks](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/maintenance.md). +In a nutshell, do the following: + +``` +sudo -i -u git +cd gitlab +bundle exec rake gitlab:env:info RAILS_ENV=production +bundle exec rake gitlab:check RAILS_ENV=production +``` + +Note: It is recommended to log into the `git` user using `sudo -i -u git` or `sudo su - git`. +While the sudo commands provided by gitlabhq work in Ubuntu they do not always work in RHEL. \ No newline at end of file diff --git a/doc/development/gitlab_diagram_overview.odg b/doc/development/gitlab_diagram_overview.odg new file mode 100644 index 0000000000..b7e02f8fa7 Binary files /dev/null and b/doc/development/gitlab_diagram_overview.odg differ diff --git a/doc/development/gitlab_diagram_overview.png b/doc/development/gitlab_diagram_overview.png new file mode 100644 index 0000000000..b5831cf0a4 Binary files /dev/null and b/doc/development/gitlab_diagram_overview.png differ diff --git a/doc/development/rake_tasks.md b/doc/development/rake_tasks.md new file mode 100644 index 0000000000..9e75b3a627 --- /dev/null +++ b/doc/development/rake_tasks.md @@ -0,0 +1,25 @@ +# Rake tasks for developers + +## Setup db with developer seeds: + +Note that if your db user does not have advanced privilegies you must create db manually before run this command + +``` +bundle exec rake setup +``` + +## Run tests + +This runs all test suite present in GitLab + +``` +bundle exec rake test +``` + +## Generate searchable docs for source code + +You can find results under `doc/code` directory + +``` +bundle exec rake gitlab:generate_docs +``` diff --git a/doc/development/shell_commands.md b/doc/development/shell_commands.md new file mode 100644 index 0000000000..af0d5ca442 --- /dev/null +++ b/doc/development/shell_commands.md @@ -0,0 +1,117 @@ +# Guidelines for shell commands in the GitLab codebase + +## References + +- [Google Ruby Security Reviewer's Guide](https://code.google.com/p/ruby-security/wiki/Guide) +- [OWASP Command Injection](https://www.owasp.org/index.php/Command_Injection) +- [Ruby on Rails Security Guide Command Line Injection](http://guides.rubyonrails.org/security.html#command-line-injection) + +## Use File and FileUtils instead of shell commands + +Sometimes we invoke basic Unix commands via the shell when there is also a Ruby API for doing it. +Use the Ruby API if it exists. +http://www.ruby-doc.org/stdlib-2.0.0/libdoc/fileutils/rdoc/FileUtils.html#module-FileUtils-label-Module+Functions + +```ruby +# Wrong +system "mkdir -p tmp/special/directory" +# Better (separate tokens) +system *%W(mkdir -p tmp/special/directory) +# Best (do not use a shell command) +FileUtils.mkdir_p "tmp/special/directory" + +# Wrong +contents = `cat #{filename}` +# Correct +contents = File.read(filename) +``` + +This coding style could have prevented CVE-2013-4490. + +## Bypass the shell by splitting commands into separate tokens + +When we pass shell commands as a single string to Ruby, Ruby will let `/bin/sh` evaluate the entire string. +Essentially, we are asking the shell to evaluate a one-line script. +This creates a risk for shell injection attacks. +It is better to split the shell command into tokens ourselves. +Sometimes we use the scripting capabilities of the shell to change the working directory or set environment variables. +All of this can also be achieved securely straight from Ruby + +```ruby +# Wrong +system "cd /home/git/gitlab && bundle exec rake db:#{something} RAILS_ENV=production" +# Correct +system({'RAILS_ENV' => 'production'}, *%W(bundle exec rake db:#{something}), chdir: '/home/git/gitlab') + +# Wrong +system "touch #{myfile}" +# Better +system "touch", myfile +# Best (do not run a shell command at all) +FileUtils.touch myfile +``` + +This coding style could have prevented CVE-2013-4546. + +## Separate options from arguments with -- + +Make the difference between options and arguments clear to the argument parsers of system commands with `--`. +This is supported by many but not all Unix commands. + +To understand what `--` does, consider the problem below. + +``` +# Example +$ echo hello > -l +$ cat -l +cat: illegal option -- l +usage: cat [-benstuv] [file ...] +``` + +In the example above, the argument parser of `cat` assumes that `-l` is an option. +The solution in the example above is to make it clear to `cat` that `-l` is really an argument, not an option. +Many Unix command line tools follow the convention of separating options from arguments with `--`. + +``` +# Example (continued) +$ cat -- -l +hello +``` + +In the GitLab codebase, we avoid the option/argument ambiguity by _always_ using `--`. + +```ruby +# Wrong +system(*%W(git branch -d #{branch_name})) +# Correct +system(*%W(git branch -d -- #{branch_name})) +``` + +This coding style could have prevented CVE-2013-4582. + +## Do not use the backticks + +Capturing the output of shell commands with backticks reads nicely, but you are forced to pass the command as one string to the shell. +We explained above that this is unsafe. +In the main GitLab codebase, the solution is to use `Gitlab::Popen.popen` instead. + +```ruby +# Wrong +logs = `cd #{repo_dir} && git log` +# Correct +logs, exit_status = Gitlab::Popen.popen(%W(git log), repo_dir) + +# Wrong +user = `whoami` +# Correct +user, exit_status = Gitlab::Popen.popen(%W(whoami)) +``` + +In other repositories, such as gitlab-shell you can also use `IO.popen`. + +```ruby +# Safe IO.popen example +logs = IO.popen(%W(git log), chdir: repo_dir).read +``` + +Note that unlike `Gitlab::Popen.popen`, `IO.popen` does not capture standard error. diff --git a/doc/install/README.md b/doc/install/README.md new file mode 100644 index 0000000000..ec80e3cd62 --- /dev/null +++ b/doc/install/README.md @@ -0,0 +1,4 @@ ++ [Installation](installation.md) ++ [Requirements](requirements.md) ++ [Structure](structure.md) ++ [Database MySQL](database_mysql.md) diff --git a/doc/install/databases.md b/doc/install/database_mysql.md similarity index 57% rename from doc/install/databases.md rename to doc/install/database_mysql.md index be7bc0aad2..bf8183729e 100644 --- a/doc/install/databases.md +++ b/doc/install/database_mysql.md @@ -1,22 +1,21 @@ -# Setup Database - -GitLab supports the following databases: - -* MySQL (preferred) -* PostgreSQL +## Note +We do not recommend using MySQL due to various issues. For example, case [(in)sensitivity](https://dev.mysql.com/doc/refman/5.0/en/case-sensitivity.html) and [problems](http://bugs.mysql.com/bug.php?id=65830) that [suggested](http://bugs.mysql.com/bug.php?id=50909) [fixes](http://bugs.mysql.com/bug.php?id=65830) [have](http://bugs.mysql.com/bug.php?id=63164). ## MySQL # Install the database packages sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev + + # Ensure you have MySQL version 5.5.14 or later + mysql --version # Pick a database root password (can be anything), type it and press enter # Retype the database root password and press enter # Secure your installation. sudo mysql_secure_installation - + # Login to MySQL mysql -u root -p @@ -25,19 +24,23 @@ GitLab supports the following databases: # Create a user for GitLab # do not type the 'mysql>', this is part of the prompt # change $password in the command below to a real password you pick - mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password'; + mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '$password'; + # Ensure you can use the InnoDB engine which is necessary to support long indexes. + # If this fails, check your MySQL config files (e.g. `/etc/mysql/*.cnf`, `/etc/mysql/conf.d/*`) for the setting "innodb = off" + mysql> SET storage_engine=INNODB; + # Create the GitLab production database mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; # Grant the GitLab user necessary permissions on the table. - mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost'; + mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost'; # Quit the database session mysql> \q # Try connecting to the new database with the new user - sudo -u git -H mysql -u gitlab -p -D gitlabhq_production + sudo -u git -H mysql -u git -p -D gitlabhq_production # Type the password you replaced $password with earlier @@ -47,25 +50,3 @@ GitLab supports the following databases: mysql> \q # You are done installing the database and can go back to the rest of the installation. - - -## PostgreSQL - - # Install the database packages - sudo apt-get install -y postgresql-9.1 libpq-dev - - # Login to PostgreSQL - sudo -u postgres psql -d template1 - - # Create a user for GitLab. (change $password to a real password) - template1=# CREATE USER git; - - # Create the GitLab production database & grant all privileges on database - template1=# CREATE DATABASE gitlabhq_production OWNER git; - - # Quit the database session - template1=# \q - - # Try connecting to the new database with the new user - sudo -u git -H psql -d gitlabhq_production - diff --git a/doc/install/installation.md b/doc/install/installation.md index 134ec3c1ec..eea5c763fc 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -1,20 +1,22 @@ # Select Version to Install -Make sure you view this installation guide from the branch (version) of GitLab you would like to install. In most cases -this should be the highest numbered stable branch (example shown below). +Make sure you view [this installation guide](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md) from the branch (version) of GitLab you would like to install. In most cases +this should be the highest numbered stable branch (example shown below). -![capture](https://f.cloud.github.com/assets/1192780/564911/2f9f3e1e-c5b7-11e2-9f89-98e527d1adec.png) +![capture](http://i.imgur.com/d2AlIVj.png) -If this is unclear check the [GitLab Blog](http://blog.gitlab.org/) for installation guide links by version. +If the highest number stable branch is unclear please check the [GitLab Blog](https://www.gitlab.com/blog/) for installation guide links by version. # Important notes -This installation guide was created for and tested on **Debian/Ubuntu** operating systems. Please read [`doc/install/requirements.md`](./requirements.md) for hardware and operating system requirements. +This guide is long because it covers many cases and includes all commands you need, this is [one of the few installation scripts that actually works out of the box](https://twitter.com/robinvdvleuten/status/424163226532986880). -This is the official installation guide to set up a production server. To set up a **development installation** or for many other installation options please consult [the installation section in the readme](https://github.com/gitlabhq/gitlabhq#installation). +This installation guide was created for and tested on **Debian/Ubuntu** operating systems. Please read [doc/install/requirements.md](./requirements.md) for hardware and operating system requirements. If you want to install on RHEL/CentOS we recommend using the [Omnibus packages](https://www.gitlab.com/downloads/). + +This is the official installation guide to set up a production server. To set up a **development installation** or for many other installation options please see [the installation section of the readme](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/README.md#installation). The following steps have been known to work. Please **use caution when you deviate** from this guide. Make sure you don't violate any assumptions GitLab makes about its environment. For example many people run into permission problems because they changed the location of directories or run services as the wrong user. -If you find a bug/error in this guide please **submit a pull request** following the [contributing guide](../../CONTRIBUTING.md). +If you find a bug/error in this guide please **submit a merge request** following the [contributing guide](../../CONTRIBUTING.md). - - - @@ -25,10 +27,9 @@ The GitLab installation consists of setting up the following components: 1. Packages / Dependencies 2. Ruby 3. System Users -4. GitLab shell -5. Database -6. GitLab -7. Nginx +4. Database +5. GitLab +6. Nginx # 1. Packages / Dependencies @@ -50,30 +51,10 @@ If you are not familiar with vim please skip this and keep using the default edi sudo apt-get install -y vim sudo update-alternatives --set editor /usr/bin/vim.basic -Install the required packages: +Install the required packages (needed to compile Ruby and native extensions to Ruby gems): sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate -Make sure you have the right version of Python installed. - - # Install Python - sudo apt-get install -y python - - # Make sure that Python is 2.5+ (3.x is not supported at the moment) - python --version - - # If it's Python 3 you might need to install Python 2 separately - sudo apt-get install -y python2.7 - - # Make sure you can access Python via python2 - python2 --version - - # If you get a "command not found" error create a link to the python binary - sudo ln -s /usr/bin/python /usr/bin/python2 - - # For reStructuredText markup language support install required package: - sudo apt-get install -y python-docutils - Make sure you have the right version of Git installed # Install Git @@ -92,8 +73,8 @@ Is the system packaged Git too old? Remove it and compile from source. # Download and compile from source cd /tmp - curl --progress https://git-core.googlecode.com/files/git-1.8.4.1.tar.gz | tar xz - cd git-1.8.4.1/ + curl --progress https://git-core.googlecode.com/files/git-1.8.5.2.tar.gz | tar xz + cd git-1.8.5.2/ make prefix=/usr/local all # Install into /usr/local/bin @@ -105,12 +86,14 @@ Is the system packaged Git too old? Remove it and compile from source. mail server. By default, Debian is shipped with exim4 whereas Ubuntu does not ship with one. The recommended mail server is postfix and you can install it with: - sudo apt-get install -y postfix + sudo apt-get install -y postfix Then select 'Internet Site' and press enter to confirm the hostname. # 2. Ruby +The use of ruby version managers such as [RVM](http://rvm.io/), [rbenv](https://github.com/sstephenson/rbenv) or [chruby](https://github.com/postmodern/chruby) with GitLab in production frequently leads to hard to diagnose problems. For example, GitLab Shell is called from OpenSSH and having a version manager can prevent pushing and pulling over SSH. Version managers are not supported and we stronly advise everyone to follow the instructions below to use a system ruby. + Remove the old Ruby 1.8 if present sudo apt-get remove ruby1.8 @@ -118,8 +101,8 @@ Remove the old Ruby 1.8 if present Download Ruby and compile it: mkdir /tmp/ruby && cd /tmp/ruby - curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz | tar xz - cd ruby-2.0.0-p247 + curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz + cd ruby-2.0.0-p353 ./configure --disable-install-rdoc make sudo make install @@ -135,38 +118,31 @@ Create a `git` user for Gitlab: sudo adduser --disabled-login --gecos 'GitLab' git +# 4. Database -# 4. GitLab shell +We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](database_mysql.md). +NOTE: because we need to make use of extensions you need at least pgsql 9.1. -GitLab Shell is an ssh access and repository management software developed specially for GitLab. + # Install the database packages + sudo apt-get install -y postgresql-9.1 postgresql-client libpq-dev - # Go to home directory - cd /home/git + # Login to PostgreSQL + sudo -u postgres psql -d template1 - # Clone gitlab shell - sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git + # Create a user for GitLab. + template1=# CREATE USER git CREATEDB; - cd gitlab-shell + # Create the GitLab production database & grant all privileges on database + template1=# CREATE DATABASE gitlabhq_production OWNER git; - # switch to right version - sudo -u git -H git checkout v1.7.4 + # Quit the database session + template1=# \q - sudo -u git -H cp config.yml.example config.yml - - # Edit config and replace gitlab_url - # with something like 'http://domain.com/' - sudo -u git -H editor config.yml - - # Do setup - sudo -u git -H ./bin/install + # Try connecting to the new database with the new user + sudo -u git -H psql -d gitlabhq_production -# 5. Database - -To setup the MySQL/PostgreSQL database and dependencies please see [`doc/install/databases.md`](./databases.md). - - -# 6. GitLab +# 5. GitLab # We'll install GitLab into home directory of the user "git" cd /home/git @@ -174,16 +150,13 @@ To setup the MySQL/PostgreSQL database and dependencies please see [`doc/install ## Clone the Source # Clone GitLab repository - sudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab + sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-8-stable gitlab # Go to gitlab dir cd /home/git/gitlab - # Checkout to stable release - sudo -u git -H git checkout 6-2-stable - **Note:** -You can change `6-2-stable` to `master` if you want the *bleeding edge* version, but never install master on a production server! +You can change `6-8-stable` to `master` if you want the *bleeding edge* version, but never install master on a production server! ## Configure it @@ -201,20 +174,18 @@ You can change `6-2-stable` to `master` if you want the *bleeding edge* version, # Make sure GitLab can write to the log/ and tmp/ directories sudo chown -R git log/ sudo chown -R git tmp/ - sudo chmod -R u+rwX log/ - sudo chmod -R u+rwX tmp/ + sudo chmod -R u+rwX log/ + sudo chmod -R u+rwX tmp/ # Create directory for satellites sudo -u git -H mkdir /home/git/gitlab-satellites + sudo chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites - # Create directories for sockets/pids and make sure GitLab can write to them - sudo -u git -H mkdir tmp/pids/ - sudo -u git -H mkdir tmp/sockets/ - sudo chmod -R u+rwX tmp/pids/ - sudo chmod -R u+rwX tmp/sockets/ + # Make sure GitLab can write to the tmp/pids/ and tmp/sockets/ directories + sudo chmod -R u+rwX tmp/pids/ + sudo chmod -R u+rwX tmp/sockets/ - # Create public/uploads directory otherwise backup will fail - sudo -u git -H mkdir public/uploads + # Make sure GitLab can write to the public/uploads/ directory sudo chmod -R u+rwX public/uploads # Copy the example Unicorn config @@ -227,10 +198,6 @@ You can change `6-2-stable` to `master` if you want the *bleeding edge* version, # Copy the example Rack attack config sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb - # Enable rack attack middleware - # Find and uncomment the line 'config.middleware.use Rack::Attack' - sudo -u git -H editor config/application.rb - # Configure Git global settings for git user, useful when editing via web # Edit user.email according to what is set in gitlab.yml sudo -u git -H git config --global user.name "GitLab" @@ -242,53 +209,74 @@ Make sure to edit both `gitlab.yml` and `unicorn.rb` to match your setup. ## Configure GitLab DB settings - # Mysql + # PostgreSQL only: + sudo -u git cp config/database.yml.postgresql config/database.yml + + # MySQL only: sudo -u git cp config/database.yml.mysql config/database.yml - # Make sure to update username/password in config/database.yml. + # MySQL and remote PostgreSQL only: + # Update username/password in config/database.yml. # You only need to adapt the production settings (first part). # If you followed the database guide then please do as follows: # Change 'secure password' with the value you have given to $password # You can keep the double quotes around the password sudo -u git -H editor config/database.yml - or - - # PostgreSQL - sudo -u git cp config/database.yml.postgresql config/database.yml - - + # PostgreSQL and MySQL: # Make config/database.yml readable to git only sudo -u git -H chmod o-rwx config/database.yml ## Install Gems +**Note:** As of bundler 1.5.2, you can invoke `bundle install -jN` +(where `N` the number of your processor cores) and enjoy the parallel gems installation with measurable +difference in completion time (~60% faster). Check the number of your cores with `nproc`. +For more information check this [post](http://robots.thoughtbot.com/parallel-gem-installing-using-bundler). +First make sure you have bundler >= 1.5.2 (run `bundle -v`) as it addresses some [issues](https://devcenter.heroku.com/changelog-items/411) +that were [fixed](https://github.com/bundler/bundler/pull/2817) in 1.5.2. + cd /home/git/gitlab - sudo gem install charlock_holmes --version '0.6.9.4' - - # For MySQL (note, the option says "without ... postgres") - sudo -u git -H bundle install --deployment --without development test postgres aws - - # Or for PostgreSQL (note, the option says "without ... mysql") + # For PostgreSQL (note, the option says "without ... mysql") sudo -u git -H bundle install --deployment --without development test mysql aws + # Or if you use MySQL (note, the option says "without ... postgres") + sudo -u git -H bundle install --deployment --without development test postgres aws + ## Initialize Database and Activate Advanced Features sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production - # Type 'yes' to create the database. + # Type 'yes' to create the database tables. # When done you see 'Administrator account created:' +## Install GitLab shell + +GitLab Shell is an ssh access and repository management software developed specially for GitLab. + + # Go to the Gitlab installation folder: + cd /home/git/gitlab + + # Run the installation task for gitlab-shell (replace `REDIS_URL` if needed): + sudo -u git -H bundle exec rake gitlab:shell:install[v1.9.3] REDIS_URL=redis://localhost:6379 RAILS_ENV=production + + # By default, the gitlab-shell config is generated from your main gitlab config. You can review (and modify) it as follows: + sudo -u git -H editor /home/git/gitlab-shell/config.yml ## Install Init Script Download the init script (will be /etc/init.d/gitlab): sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab - sudo chmod +x /etc/init.d/gitlab + +And if you are installing with a non-default folder or user copy and edit the defaults file: + + sudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab + +If you installed gitlab in another directory or as a user other than the default you should change these settings in /etc/default/gitlab. Do not edit /etc/init.d/gitlab as it will be changed on upgrade. Make GitLab start on boot: @@ -304,27 +292,22 @@ Check if GitLab and its environment are configured correctly: sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production +## Compile assets + + sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production + ## Start Your GitLab Instance sudo service gitlab start # or sudo /etc/init.d/gitlab restart -## Double-check Application Status -To make sure you didn't miss anything run a more thorough check with: - - sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production - -If all items are green, then congratulations on successfully installing GitLab! -However there are still a few steps left. - - -# 7. Nginx +# 6. Nginx **Note:** Nginx is the officially supported web server for GitLab. If you cannot or do not want to use Nginx as your web server, have a look at the -[GitLab recipes](https://github.com/gitlabhq/gitlab-recipes). +[GitLab recipes](https://gitlab.com/gitlab-org/gitlab-recipes/). ## Installation sudo apt-get install -y nginx @@ -349,10 +332,20 @@ Make sure to edit the config file to match your setup: # Done! -Visit YOUR_SERVER for your first GitLab login. +## Double-check Application Status + +To make sure you didn't miss anything run a more thorough check with: + + sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production + +If all items are green, then congratulations on successfully installing GitLab! + +## Initial Login + +Visit YOUR_SERVER in your web browser for your first GitLab login. The setup has created an admin account for you. You can use it to log in: - admin@local.host + root 5iveL!fe **Important Note:** @@ -367,6 +360,15 @@ nobody can access your GitLab by using this login information later on. # Advanced Setup Tips +## Additional markup styles + +Apart from the always supported markdown style there are other rich text files that GitLab can display. +But you might have to install a dependency to do so. +Please see the [github-markup gem readme](https://github.com/gitlabhq/markup#markups) for more information. +For example, reStructuredText markup language support requires python-docutils: + + sudo apt-get install -y python-docutils + ## Custom Redis Connection If you'd like Resque to connect to a Redis server on a non-standard port or on @@ -376,7 +378,7 @@ a different host, you can configure its connection string via the # example production: redis://redis.example.tld:6379 -If you want to connect the Redis server via socket, then use the "unix:" URL scheme +If you want to connect the Redis server via socket, then use the "unix:" URL scheme and the path to the Redis socket file in the `config/resque.yml` file. # example @@ -409,10 +411,10 @@ These steps are fairly general and you will need to figure out the exact details * Stop GitLab `sudo service gitlab stop` -* Add provider specific configuration options to your `config/gitlab.yml` (you can use the [auth providers section of the example config](https://github.com/gitlabhq/gitlabhq/blob/master/config/gitlab.yml.example) as a reference) +* Add provider specific configuration options to your `config/gitlab.yml` (you can use the [auth providers section of the example config](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/gitlab.yml.example) as a reference) -* Add the gem to your [Gemfile](https://github.com/gitlabhq/gitlabhq/blob/master/Gemfile) - `gem "omniauth-your-auth-provider"` +* Add the gem to your [Gemfile](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/Gemfile) + `gem "omniauth-your-auth-provider"` * If you're using MySQL, install the new Omniauth provider gem by running the following command: `sudo -u git -H bundle install --without development test postgres --path vendor/bundle --no-deployment` @@ -428,5 +430,5 @@ These steps are fairly general and you will need to figure out the exact details ### Examples If you have successfully set up a provider that is not shipped with GitLab itself, please let us know. -You can help others by reporting successful configurations and probably share a few insights or provide warnings for common errors or pitfalls by sharing your experience [in the public Wiki](https://github.com/gitlabhq/gitlab-public-wiki/wiki/Working-Custom-Omniauth-Provider-Configurations). +You can help others by reporting successful configurations and probably share a few insights or provide warnings for common errors or pitfalls by sharing your experience [in the public Wiki](https://github.com/gitlabhq/gitlab-public-wiki/wiki/Custom-omniauth-provider-configurations). While we can't officially support every possible auth mechanism out there, we'd like to at least help those with special needs. diff --git a/doc/install/requirements.md b/doc/install/requirements.md index 30a9564674..fd2dd16cd8 100644 --- a/doc/install/requirements.md +++ b/doc/install/requirements.md @@ -1,58 +1,66 @@ # Operating Systems -## Linux +GitLab is developed for the Linux operating system. For the installations options and instructions please see [the installation section of the readme](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/README.md#installation). -GitLab is developed for the Linux operating system. +## Supported Linux distributions -GitLab officially supports (recent versions of) these Linux distributions: - -- Ubuntu Linux -- Debian/GNU Linux - -It should also work on (though they are not officially supported): - -- Arch +- Ubuntu +- Debian - CentOS +- RedHat Enterprise Linux +- Scientific Linux +- Oracle Linux + +## Unsupported Linux distributions + +- Arch Linux - Fedora - Gentoo -- RedHat -## Other Unix Systems +But on the above unsupported distributions is stll possible to install GitLab yourself with the [manual installation guide](https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md). -There is nothing that prevents GitLab from running on other Unix operating -systems. This means you may get it to work on systems running FreeBSD or OS X. -**If you want to try, please proceed with caution!** +## Unsupported Unix operating systems -## Windows +There is nothing that prevents GitLab from running on other Unix operating systems. +This means you may get it to work on systems running FreeBSD or OS X. +If you want to do this, please be aware it could be a lot of work. +Please consider using a virtual machine to run GitLab. -GitLab does **not** run on Windows and we have no plans of supporting it in the -near future. Please consider using a virtual machine to run GitLab. +## Other operating systems such as Windows + +GitLab does **not** run on Windows and we have no plans of supporting it in the near future. +Please consider using a virtual machine to run GitLab. -# Rubies +# Ruby versions -GitLab requires Ruby (MRI) 1.9.3 and several Gems with native components. -While it is generally possible to use other Rubies (like -[JRuby](http://jruby.org/) or [Rubinius](http://rubini.us/)) it might require -some work on your part. +GitLab requires Ruby (MRI) 1.9.3 or 2.0+. +You will have to use the standard MRI implementation of Ruby. +We love [JRuby](http://jruby.org/) and [Rubinius](http://rubini.us/)) but GitLab needs several Gems that have native extensions. # Hardware requirements ## CPU -- 1 core works for under 100 users but the responsiveness might suffer -- **2 cores** is the **recommended** number of cores and supports up to 100 users -- 4 cores supports about 1,000 users -- 8 cores supports up to 10,000 users +- 1 core works supports up to 100 users but the application will not be responsive +- **2 cores** is the **recommended** number of cores and supports up to 500 users +- 4 cores supports up to 2,000 users +- 8 cores supports up to 5,000 users +- 16 cores supports up to 10,0000 users +- 32 cores supports up to 20,0000 users +- 64 cores supports up to 40,0000 users ## Memory -- 512MB is too little memory, GitLab will be very slow and you will need 250MB of swap -- 768MB is the minimal memory size but we advise against this -- 1GB supports up to 100 users if you do not have individual repo's over 250MB -- **2GB** is the **recommended** memory size and supports up to 1,000 users -- 4GB supports up to 10,000 users +- 512MB is the absolute minimum, you need 256MB of swap, you can configure only one slow unicorn worker, only ssh access will work, we do not recommend this +- 1GB supports up to 100 users (with individual repositories under 250MB, otherwise git memory usage necessitates using swap space) +- **2GB** is the **recommended** memory size and supports up to 500 users +- 4GB supports up to 2,000 users +- 8GB supports up to 5,000 users +- 16GB supports up to 10,000 users +- 32GB supports up to 20,000 users +- 64GB supports up to 40,000 users ## Storage @@ -66,8 +74,14 @@ Apart from a local hard drive you can also mount a volume that supports the netw If you have enough RAM memory and a recent CPU the speed of GitLab is mainly limited by hard drive seek times. Having a fast drive (7200 RPM and up) or a solid state drive (SSD) will improve the responsiveness of GitLab. -# Installation troubles and reporting success or failure +## Database -If you have troubles installing GitLab following the [official installation guide](installation.md) -or want to share your experience installing GitLab on a not officially supported -platform, please follow the the [contribution guide](/CONTRIBUTING.md). +If you want to run the database separately, the **recommended** database size is **1 MB per user** + +# Supported webbrowsers + +- Chrome (Latest stable version) +- Firefox (Latest released version) +- Safari 7+ (known problem: required fields in html5 do not work) +- Opera (Latest released version) +- IE 10+ diff --git a/doc/install/structure.md b/doc/install/structure.md index f580ea159a..67ca189537 100644 --- a/doc/install/structure.md +++ b/doc/install/structure.md @@ -10,18 +10,12 @@ This is the directory structure you will end up with following the instructions | |-- gitlab-shell | |-- repositories +* `/home/git/.ssh` - contains openssh settings. Specifically the `authorized_keys` file managed by gitlab-shell. +* `/home/git/gitlab` - GitLab core software. +* `/home/git/gitlab-satellites` - checked out repositories for merge requests and file editing from web UI. This can be treated as a temporary files directory. +* `/home/git/gitlab-shell` - Core add-on component of gitlab. Maintains SSH cloning and other functionality. +* `/home/git/repositories` - bare repositories for all projects organized by namespace. This is where the git repositories which are pushed/pulled are maintained for all projects. **This area is critical data for projects. [Keep a backup](../raketasks/backup_restore.md)** -**/home/git/.ssh** +*Note: the default locations for gitlab-satellites and repositories can be configured in `config/gitlab.yml` of gitlab and `config.yml` of gitlab-shell.* -**/home/git/gitlab** - This is where GitLab lives. - -**/home/git/gitlab-satellites** - Contains a copy of all repositories with a working tree. - It's used for merge requests, editing files, etc. - -**/home/git/repositories** - Holds all your repositories in bare format. - This is the place Git uses when you pull/push to your projects. - -You can change them in your `config/gitlab.yml` file. +To see a more in-depth overview see the [GitLab architecture doc](../development/architecture.md). diff --git a/doc/integration/README.md b/doc/integration/README.md new file mode 100644 index 0000000000..8318113ce9 --- /dev/null +++ b/doc/integration/README.md @@ -0,0 +1,9 @@ +# GitLab Integration + +GitLab integrates with multiple third-party services to allow external issue trackers and external authentication. +See the documentation below for details on how to configure these services. + ++ [External issue tracker](external-issue-tracker.md) Redmine, JIRA, etc. ++ [LDAP](ldap.md) Set up sign in via LDAP ++ [OmniAuth](omniauth.md) Sign in via Twitter, GitHub, and Google via OAuth. ++ [Slack](slack.md) Integrate with the Slack chat service diff --git a/doc/integration/external-issue-tracker.md b/doc/integration/external-issue-tracker.md new file mode 100644 index 0000000000..e490b2f884 --- /dev/null +++ b/doc/integration/external-issue-tracker.md @@ -0,0 +1,9 @@ +GitLab has a great issue tracker but you can also use an external issue tracker such as JIRA or Redmine. This is something that you can turn on per GitLab project. If for example you configure JIRA it provides the following functionality: + +- the 'Issues' link on the GitLab project pages takes you to the appropriate JIRA issue index; +- clicking 'New issue' on the project dashboard creates a new JIRA issue; +- To reference JIRA issue PROJECT-1234 in comments, use syntax PROJECT-1234. Commit messages get turned into HTML links to the corresponding JIRA issue. + +![jira screenshot](jira-integration-points.png) + +You can configure the integration in the gitlab.yml configuration file. diff --git a/doc/integration/github.md b/doc/integration/github.md new file mode 100644 index 0000000000..672536b4da --- /dev/null +++ b/doc/integration/github.md @@ -0,0 +1,38 @@ +# GitHub OAuth2 OmniAuth Provider + +To enable the GitHub OmniAuth provider you must register your application with GitHub. GitHub will generate a client ID and secret key for you to use. + +1. Sign in to GitHub. +2. Navigate to your individual user settings or an organization's settings, depending on how you want the application registered. It does not matter if the application is registered as an individual or an organization - that is entirely up to you. +3. Select "Applications" in the left menu. +4. Select "Register new application". +5. Provide the required details. + * Application name: This can be anything. Consider something like "\'s GitLab" or "\'s GitLab" or something else descriptive. + * Homepage URL: The URL to your GitLab installation. 'https://gitlab.company.com' + * Application description: Fill this in if you wish. + * Authorization callback URL: 'https://gitlab.company.com/users/auth/github/callback' +6. Select "Register application". +7. You should now see a Client ID and Client Secret near the top right of the page (see screenshot). Keep this page open as you continue configuration. ![GitHub app](github_app.png) +8. On your GitLab server, open the configuration file. + + ```sh + cd /home/git/gitlab + + sudo -u git -H editor config/gitlab.yml + ``` + +9. Find the section dealing with OmniAuth. See [Initial OmniAuth Configuration](README.md#initial-omniauth-configuration) for more details. +10. Under `providers:` uncomment (or add) lines that look like the following: + + ``` + - { name: 'github', app_id: 'YOUR APP ID', + app_secret: 'YOUR APP SECRET', + args: { scope: 'user:email' } } + ``` + +11. Change 'YOUR APP ID' to the client ID from the GitHub application page from step 7. +12. Change 'YOUR APP SECRET' to the client secret from the GitHub application page from step 7. +13. Save the configuration file. +14. Restart GitLab for the changes to take effect. + +On the sign in page there should now be a GitHub icon below the regular sign in form. Click the icon to begin the authentication process. GitHub will ask the user to sign in and authorize the GitLab application. If everything goes well the user will be returned to GitLab and will be signed in. diff --git a/doc/integration/github_app.png b/doc/integration/github_app.png new file mode 100644 index 0000000000..c0873b2e20 Binary files /dev/null and b/doc/integration/github_app.png differ diff --git a/doc/integration/google.md b/doc/integration/google.md new file mode 100644 index 0000000000..50f63502e7 --- /dev/null +++ b/doc/integration/google.md @@ -0,0 +1,49 @@ +# Google OAuth2 OmniAuth Provider + +To enable the Google OAuth2 OmniAuth provider you must register your application with Google. Google will generate a client ID and secret key for you to use. + +1. Sign in to the [Google Developers Console](https://console.developers.google.com/) with the Google account you want to use to register GitLab. +2. Select "Create Project". +3. Provide the project information + * Project name: 'GitLab' works just fine here. + * Project ID: Must be unique to all Google Developer registered applications. Google provides a randomly generated Project ID by default. You can use the randomly generated ID or choose a new one. +4. Refresh the page. You should now see your new project in the list. Click on the project. +5. Select "APIs & auth" in the left menu. +6. Select "Credentials" in the submenu. +7. Select "Create New Client ID". +8. Fill in the required information + * Application type: "Web Application" + * Authorized JavaScript origins: This isn't really used by GitLab but go ahead and put 'https://gitlab.example.com' here. + * Authorized redirect URI: 'https://gitlab.example.com/users/auth/google_oauth2/callback' +9. Under the heading "Client ID for web application" you should see a Client ID and Client secret (see screenshot). Keep this page open as you continue configuration. ![Google app](google_app.png) +10. On your GitLab server, open the configuration file. + ```sh + cd /home/git/gitlab + + sudo -u git -H editor config/gitlab.yml + ``` +11. Find the section dealing with OmniAuth. See [Initial OmniAuth Configuration](README.md#initial-omniauth-configuration) for more details. +12. Under `providers:` uncomment (or add) lines that look like the following: + + ``` + - { name: 'google_oauth2', app_id: 'YOUR APP ID', + app_secret: 'YOUR APP SECRET', + args: { access_type: 'offline', approval_prompt: '' } } + ``` + +13. Change 'YOUR APP ID' to the client ID from the GitHub application page from step 7. +14. Change 'YOUR APP SECRET' to the client secret from the GitHub application page from step 7. +15. Save the configuration file. +16. Restart GitLab for the changes to take effect. + +On the sign in page there should now be a Google icon below the regular sign in form. Click the icon to begin the authentication process. Google will ask the user to sign in and authorize the GitLab application. If everything goes well the user will be returned to GitLab and will be signed in. + +## Further Configuration + +This further configuration is not required for Google authentication to function but it is strongly recommended. Taking these steps will increase usability for users by providing a little more recognition and branding. + +At this point, when users first try to authenticate to your GitLab installation with Google they will see a generic application name on the prompt screen. The prompt informs the user that "Project Default Service Account" would like to access their account. "Project Default Service Account" isn't very recognizable and may confuse or cause users to be concerned. This is easily changeable. + +1. Select 'Consent screen' in the left menu. (See steps 1, 4 and 5 above for instructions on how to get here if you closed your window). +2. Scroll down until you find "Product Name". Change the product name to something more descriptive. +3. Add any additional information as you wish - homepage, logo, privacy policy, etc. None of this is required, but it may help your users. diff --git a/doc/integration/google_app.png b/doc/integration/google_app.png new file mode 100644 index 0000000000..5a62ad3500 Binary files /dev/null and b/doc/integration/google_app.png differ diff --git a/doc/integration/jira-integration-points.png b/doc/integration/jira-integration-points.png new file mode 100644 index 0000000000..0692a7b458 Binary files /dev/null and b/doc/integration/jira-integration-points.png differ diff --git a/doc/integration/ldap.md b/doc/integration/ldap.md new file mode 100644 index 0000000000..b52c4a4b5e --- /dev/null +++ b/doc/integration/ldap.md @@ -0,0 +1,14 @@ +# GitLab LDAP integration + +GitLab can be configured to allow your users to sign with their LDAP credentials to integrate with e.g. Active Directory. +The first time a user signs in with LDAP credentials, GitLab will create a new GitLab user associated with the LDAP Distinguished Name (DN) of the LDAP user. +GitLab user attributes such as nickname and email will be copied from the LDAP user entry. + +## Enabling LDAP sign-in for existing GitLab users + +When a user signs in to GitLab with LDAP for the first time, and their LDAP email address is the primary email address of an existing GitLab user, then the LDAP DN will be associated with the existing user. +If the LDAP email attribute is not found in GitLab's database, a new user is created. + +In other words, if an existing GitLab user wants to enable LDAP sign-in for themselves, they should check that their GitLab email address matches their LDAP email address, and then sign into GitLab via their LDAP credentials. +GitLab recognizes the following LDAP attributes as email addresses: `mail`, `email` and `userPrincipalName`. +If multiple LDAP email attributes are present, e.g. `mail: foo@bar.com` and `email: foo@example.com`, then the first attribute found wins -- in this case `foo@bar.com`. diff --git a/doc/integration/omniauth.md b/doc/integration/omniauth.md new file mode 100644 index 0000000000..84a5a8e8c2 --- /dev/null +++ b/doc/integration/omniauth.md @@ -0,0 +1,83 @@ +# OmniAuth + +GitLab leverages OmniAuth to allow users to sign in using Twitter, GitHub, and other popular services. Configuring +OmniAuth does not prevent standard GitLab authentication or LDAP (if configured) from continuing to work. Users can +choose to sign in using any of the configured mechanisms. + ++ [Initial OmniAuth Configuration](#initial-omniauth-configuration) ++ [Supported Providers](#supported-providers) ++ [Enable OmniAuth for an Existing User](#enable-omniauth-for-an-existing-user) + +### Initial OmniAuth Configuration + +Before configuring individual OmniAuth providers there are a few global settings that need to be verified. + +1. Open the configuration file
    + + ```sh + cd /home/git/gitlab + + sudo -u git -H editor config/gitlab.yml + ``` + +2. Find the section dealing with OmniAuth. The section will look similar to the following.
    + + ``` + ## OmniAuth settings + omniauth: + # Allow login via Twitter, Google, etc. using OmniAuth providers + enabled: false + + # CAUTION! + # This allows users to login without having a user account first (default: false). + # User accounts will be created automatically when authentication was successful. + allow_single_sign_on: false + # Locks down those users until they have been cleared by the admin (default: true). + block_auto_created_users: true + + ## Auth providers + # Uncomment the following lines and fill in the data of the auth provider you want to use + # If your favorite auth provider is not listed you can use others: + # see https://github.com/gitlabhq/gitlab-public-wiki/wiki/Custom-omniauth-provider-configurations + # The 'app_id' and 'app_secret' parameters are always passed as the first two + # arguments, followed by optional 'args' which can be either a hash or an array. + providers: + # - { name: 'google_oauth2', app_id: 'YOUR APP ID', + # app_secret: 'YOUR APP SECRET', + # args: { access_type: 'offline', approval_prompt: '' } } + # - { name: 'twitter', app_id: 'YOUR APP ID', + # app_secret: 'YOUR APP SECRET'} + # - { name: 'github', app_id: 'YOUR APP ID', + # app_secret: 'YOUR APP SECRET', + # args: { scope: 'user:email' } } + ``` + +3. Change `enabled` to `true`. +4. Consider the next two configuration options: `allow_single_sign_on` and `block_auto_created_users`. + * `allow_single_sign_on` defaults to `false`. If `false` users must be created manually or they will not be able to + sign in via OmniAuth. + * `block_auto_created_users` defaults to `true`. If `true` auto created users will be blocked by default and will + have to be unblocked by an administrator before they are able to sign in. + * **Note:** If you set `allow_single_sign_on` to `true` and `block_auto_created_users` to `false` please be aware + that any user on the Internet will be able to successfully sign in to your GitLab without administrative approval. +5. Choose one or more of the Supported Providers below to continue configuration. + +### Supported Providers + ++ [GitHub](github.md) ++ [Google](google.md) ++ [Twitter](twitter.md) + +### Enable OmniAuth for an Existing User + +Existing users can enable OmniAuth for specific providers after the account is created. For example, if the user +originally signed in with LDAP an OmniAuth provider such as Twitter can be enabled. Follow the steps below to enable an +OmniAuth provider for an existing user. + +1. Sign in normally - whether standard sign in, LDAP, or another OmniAuth provider. +2. Go to profile settings (the silhouette icon in the top right corner). +3. Select the "Account" tab. +4. Under "Social Accounts" select the desired OmniAuth provider, such as Twitter. +5. The user will be redirected to the provider. Once the user authorized GitLab they will be redirected back to GitLab. + +The chosen OmniAuth provider is now active and can be used to sign in to GitLab from then on. diff --git a/doc/integration/slack.md b/doc/integration/slack.md new file mode 100644 index 0000000000..057871a4b8 --- /dev/null +++ b/doc/integration/slack.md @@ -0,0 +1,34 @@ +# Slack integration + +### On Slack + +To enable Slack integration you must create an Incoming WebHooks integration on Slack; + + +1. Sign in to [Slack](https://slack.com) (https://YOURSUBDOMAIN.slack.com/services) +2. Click on the Integrations menu at the top of the page. +3. Add a new Integration. +4. Pick Incoming WebHooks +5. Choose the channel name you want to send notifications to, in the Settings section +6. Add Integrations. + * Optional step; You can change bot's name and avatar by clicking "change the name of your bot", and "change the icon" after that you have to click "Save settings". + +Now, Slack is ready to get external hooks. Before you leave this page don't forget to get the Token that you'll need on GitLab. You can find it by clicking Expand button, located in the "Instructions for creating Incoming WebHooks" section. It's a random alpha-numeric text 24 characters long. + +### On GitLab + +After Slack is ready we need to setup GitLab. Here are the steps to achieve this. + + +1. Sign in to GitLab +2. Pick the repository you want. +3. Navigate to Settings -> Services -> Slack +4. Fill in your Slack details + * Mark as active it + * Type your subdomain's prefix (If your subdomain is https://somedomain.slack.com you only have to type the somedomain) + * Type in the token you got from Slack + * Type in the channel name you want to use (eg. #announcements) + +Have fun :) + +_P.S. You can set "branch,pushed,Compare changes" as highlight words on your Slack profile settings, so that you can be aware of new commits when somebody pushes them._ diff --git a/doc/integration/twitter.md b/doc/integration/twitter.md new file mode 100644 index 0000000000..0440e2f21f --- /dev/null +++ b/doc/integration/twitter.md @@ -0,0 +1,47 @@ +# Twitter OAuth2 OmniAuth Provider + +To enable the Twitter OmniAuth provider you must register your application with Twitter. Twitter will generate a client +ID and secret key for you to use. + +1. Sign in to [Twitter Developers](https://dev.twitter.com/) area. +2. Hover over the avatar in the top right corner and select "My applications." +3. Select "Create new app" +4. Fill in the application details. + * Name: This can be anything. Consider something like "\'s GitLab" or "\'s GitLab" or + something else descriptive. + * Description: Create a description. + * Website: The URL to your GitLab installation. 'https://gitlab.example.com' + * Callback URL: 'https://gitlab.example.com/users/auth/github/callback' + * Agree to the "Rules of the Road." + ![Twitter App Details](twitter_app_details.png) +6. Select "Create your Twitter application." +7. Select the "Settings" tab. +8. Underneath the Callback URL check the box next to "Allow this application to be used to Sign in the Twitter." +9. Select "Update settings" at the bottom to save changes. +10. Select the "API Keys" tab. +11. You should now see an API key and API secret (see screenshot). Keep this page open as you continue configuration. +![Twitter app](twitter_app_api_keys.png) +12. On your GitLab server, open the configuration file. + + ```sh + cd /home/git/gitlab + + sudo -u git -H editor config/gitlab.yml + ``` + +13. Find the section dealing with OmniAuth. See [Initial OmniAuth Configuration](README.md#initial-omniauth-configuration) +for more details. +14. Under `providers:` uncomment (or add) lines that look like the following: + + ``` + - { name: 'twitter', app_id: 'YOUR APP ID', + app_secret: 'YOUR APP SECRET' } + ``` + +15. Change 'YOUR APP ID' to the API key from Twitter page in step 11. +16. Change 'YOUR APP SECRET' to the API secret from the Twitter page in step 11. +17. Save the configuration file. +18. Restart GitLab for the changes to take effect. + +On the sign in page there should now be a Twitter icon below the regular sign in form. Click the icon to begin the +authentication process. Twitter will ask the user to sign in and authorize the GitLab application. If everything goes well the user will be returned to GitLab and will be signed in. diff --git a/doc/integration/twitter_app_api_keys.png b/doc/integration/twitter_app_api_keys.png new file mode 100644 index 0000000000..1076337172 Binary files /dev/null and b/doc/integration/twitter_app_api_keys.png differ diff --git a/doc/integration/twitter_app_details.png b/doc/integration/twitter_app_details.png new file mode 100644 index 0000000000..b95e8af8a7 Binary files /dev/null and b/doc/integration/twitter_app_details.png differ diff --git a/doc/legal/README.md b/doc/legal/README.md new file mode 100644 index 0000000000..ebfdad1354 --- /dev/null +++ b/doc/legal/README.md @@ -0,0 +1,2 @@ ++ [Corporate contributor license agreement](corporate_contributor_license_agreement.md) ++ [Individual contributor license agreement](individual_contributor_license_agreement.md) diff --git a/doc/legal/corporate_contributor_license_agreement.md b/doc/legal/corporate_contributor_license_agreement.md new file mode 100644 index 0000000000..bbc274f3b0 --- /dev/null +++ b/doc/legal/corporate_contributor_license_agreement.md @@ -0,0 +1,25 @@ +You accept and agree to the following terms and conditions for Your present and future Contributions submitted to GitLab.com. Except for the license granted herein to GitLab.com and recipients of software distributed by GitLab.com, You reserve all right, title, and interest in and to Your Contributions. + +1. Definitions. + + "You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with GitLab.com. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + "Contribution" shall mean the code, documentation or other original works of authorship expressly identified in Schedule B, as well as any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to GitLab.com for inclusion in, or documentation of, any of the products owned or managed by GitLab.com (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to GitLab.com or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, GitLab.com for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution." + +2. Grant of Copyright License. Subject to the terms and conditions of this Agreement, You hereby grant to GitLab.com and to recipients of software distributed by GitLab.com a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works. + +3. Grant of Patent License. Subject to the terms and conditions of this Agreement, You hereby grant to GitLab.com and to recipients of software distributed by GitLab.com a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed. + +4. You represent that You are legally entitled to grant the above license. You represent further that each employee of the Corporation designated on Schedule A below (or in a subsequent written modification to that Schedule) is authorized to submit Contributions on behalf of the Corporation. + +5. You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of others). + +6. You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. + +7. Should You wish to submit work that is not Your original creation, You may submit it to GitLab.com separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as "Submitted on behalf of a third-party: [named here]". + +8. It is your responsibility to notify GitLab.com when any change is required to the list of designated employees authorized to submit Contributions on behalf of the Corporation, or to the Corporation's Point of Contact with GitLab.com. + +--------------------------------------- + +This text is licensed under the [Creative Commons Attribution 3.0 License](http://creativecommons.org/licenses/by/3.0/) and the original source is the Google Open Source Programs Office. diff --git a/doc/legal/individual_contributor_license_agreement.md b/doc/legal/individual_contributor_license_agreement.md new file mode 100644 index 0000000000..eaf5812ca4 --- /dev/null +++ b/doc/legal/individual_contributor_license_agreement.md @@ -0,0 +1,25 @@ +You accept and agree to the following terms and conditions for Your present and future Contributions submitted to GitLab.com. Except for the license granted herein to GitLab.com and recipients of software distributed by GitLab.com, You reserve all right, title, and interest in and to Your Contributions. + +1. Definitions. + + "You" (or "Your") shall mean the copyright owner or legal entity authorized by the copyright owner that is making this Agreement with GitLab.com. For legal entities, the entity making a Contribution and all other entities that control, are controlled by, or are under common control with that entity are considered to be a single Contributor. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + "Contribution" shall mean any original work of authorship, including any modifications or additions to an existing work, that is intentionally submitted by You to GitLab.com for inclusion in, or documentation of, any of the products owned or managed by GitLab.com (the "Work"). For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to GitLab.com or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, GitLab.com for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by You as "Not a Contribution." + +2. Grant of Copyright License. Subject to the terms and conditions of this Agreement, You hereby grant to GitLab.com and to recipients of software distributed by GitLab.com a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your Contributions and such derivative works. + +3. Grant of Patent License. Subject to the terms and conditions of this Agreement, You hereby grant to GitLab.com and to recipients of software distributed by GitLab.com a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that your Contribution, or the Work to which you have contributed, constitutes direct or contributory patent infringement, then any patent licenses granted to that entity under this Agreement for that Contribution or Work shall terminate as of the date such litigation is filed. + +4. You represent that you are legally entitled to grant the above license. If your employer(s) has rights to intellectual property that you create that includes your Contributions, you represent that you have received permission to make Contributions on behalf of that employer, that your employer has waived such rights for your Contributions to GitLab.com, or that your employer has executed a separate Corporate CLA with GitLab.com. + +5. You represent that each of Your Contributions is Your original creation (see section 7 for submissions on behalf of others). You represent that Your Contribution submissions include complete details of any third-party license or other restriction (including, but not limited to, related patents and trademarks) of which you are personally aware and which are associated with any part of Your Contributions. + +6. You are not expected to provide support for Your Contributions, except to the extent You desire to provide support. You may provide support for free, for a fee, or not at all. Unless required by applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON- INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. + +7. Should You wish to submit work that is not Your original creation, You may submit it to GitLab.com separately from any Contribution, identifying the complete details of its source and of any license or other restriction (including, but not limited to, related patents, trademarks, and license agreements) of which you are personally aware, and conspicuously marking the work as "Submitted on behalf of a third-party: [[]named here]". + +8. You agree to notify GitLab.com of any facts or circumstances of which you become aware that would make these representations inaccurate in any respect. + +--------------------------------------- + +This text is licensed under the [Creative Commons Attribution 3.0 License](http://creativecommons.org/licenses/by/3.0/) and the original source is the Google Open Source Programs Office. diff --git a/doc/make_release.md b/doc/make_release.md deleted file mode 100644 index 7d1115eca5..0000000000 --- a/doc/make_release.md +++ /dev/null @@ -1,76 +0,0 @@ -# Things to do when creating new release -NOTE: This is a guide for GitLab developers. If you are trying to install GitLab see the latest stable [installation guide](install/installation.md) and if you are trying to upgrade, see the [upgrade guides](update). - -## Install guide up to date? - -* References correct GitLab branch `x-x-stable` and correct GitLab shell tag? - -## Make upgrade guide - -### From x.x to x.x - -#### 0. Any major changes? Database updates? Web server change? File structure changes? - -#### 1. Make backup - -#### 2. Stop server - -#### 3. Do users need to update dependencies like `git`? - -#### 4. Get latest code - -#### 5. Does GitLab shell need to be updated? - -#### 6. Install libs, migrations, etc. - -#### 7. Any config files updated since last release? - -Check if any of these changed since last release (~22nd of last month depending on when last release branch was created): - -* https://github.com/gitlabhq/gitlabhq/commits/master/lib/support/nginx/gitlab -* https://github.com/gitlabhq/gitlab-shell/commits/master/config.yml.example -* https://github.com/gitlabhq/gitlabhq/commits/master/config/gitlab.yml.example -* https://github.com/gitlabhq/gitlabhq/commits/master/config/unicorn.rb.example -* https://github.com/gitlabhq/gitlabhq/commits/master/config/database.yml.mysql -* https://github.com/gitlabhq/gitlabhq/commits/master/config/database.yml.postgresql - -#### 8. Need to update init script? - -Check if changed since last release (~22nd of last month depending on when last release branch was created): https://github.com/gitlabhq/gitlabhq/commits/master/lib/support/init.d/gitlab - -#### 9. Start application - -#### 10. Check application status - -## Make sure the code quality indicatiors are good - -* [![build status](http://ci.gitlab.org/projects/1/status.png?ref=master)](http://ci.gitlab.org/projects/1?ref=master) on ci.gitlab.org (master branch) - -* [![build status](https://secure.travis-ci.org/gitlabhq/gitlabhq.png)](https://travis-ci.org/gitlabhq/gitlabhq) on travis-ci.org (master branch) - -* [![Code Climate](https://codeclimate.com/github/gitlabhq/gitlabhq.png)](https://codeclimate.com/github/gitlabhq/gitlabhq) - -* [![Dependency Status](https://gemnasium.com/gitlabhq/gitlabhq.png)](https://gemnasium.com/gitlabhq/gitlabhq) this button can be yellow (small updates are available) but must not be red (a security fix or an important update is available) - -* [![Coverage Status](https://coveralls.io/repos/gitlabhq/gitlabhq/badge.png?branch=master)](https://coveralls.io/r/gitlabhq/gitlabhq) - -## Make a release branch - -After making the release branch new commits are cherry-picked from master. When the release gets closer we get more selective what is cherry-picked. - -* 5 days before release: feature freeze -* 3 days before release: UI freeze -* 1 day before release: code freeze - -# Write a blog post - -* Mention what GitLab is on the second line: GitLab is open source software to collaborate on code. -* Select and thank the the Most Valuable Person (MVP) of this release. -* Note if there are security fixes: This release fixes an important security issue and we advise everyone to upgrade as soon as possible. - -## Last actions - -1. Update VERSION and CHANGELOG -1. Create a git tag vX.X.X -1. Publish the blog post -1. Tweet about the release diff --git a/doc/markdown/markdown.md b/doc/markdown/markdown.md index a84222f9fc..e7ebc61343 100644 --- a/doc/markdown/markdown.md +++ b/doc/markdown/markdown.md @@ -1,43 +1,55 @@ ---------------------------------------------- -Table of Contents +Table of Contents ================= ---------------------------------------------- -[GitLab Flavored Markdown](#toc_3) -------------------------------- -[Newlines](#toc_4) -[Multiple underscores in words](#toc_5) -[URL autolinking](#toc_6) -[Code and Syntax Highlighting](#toc_7) -[Emoji](#toc_8) -[Special GitLab references](#toc_9) +**[GitLab Flavored Markdown](#gitlab-flavored-markdown-gfm)** + +[Newlines](#newlines) + +[Multiple underscores in words](#multiple-underscores-in-words) + +[URL autolinking](#url-autolinking) + +[Code and Syntax Highlighting](#code-and-syntax-highlighting) + +[Emoji](#emoji) + +[Special GitLab references](#special-gitlab-references) +**[Standard Markdown](#standard-markdown)** -[Standard Markdown](#toc_10) ------------------------------- -[Headers](#toc_11) -[Emphasis](#toc_20) -[Lists](#toc_21) -[Links](#toc_22) -[Images](#toc_23) -[Blockquotes](#toc_24) -[Inline HTML](#toc_25) -[Horizontal Rule](#toc_26) -[Line Breaks](#toc_27) -[Tables](#toc_28) +[Headers](#headers) -[References](#toc_29) ---------------------- +[Emphasis](#emphasis) + +[Lists](#lists) + +[Links](#links) + +[Images](#images) + +[Blockquotes](#blockquotes) + +[Inline HTML](#inline-html) + +[Horizontal Rule](#horizontal-rule) + +[Line Breaks](#line-breaks) + +[Tables](#tables) + +**[References](#references)** ---------------------------------------------- - -GitLab Flavored Markdown (GFM) +GitLab Flavored Markdown (GFM) ============================== -For GitLab we developed something we call "GitLab Flavored Markdown" (GFM). It extends the standard Markdown in a few significant ways to add some useful functionality. +For GitLab we developed something we call "GitLab Flavored Markdown" (GFM). +It extends the standard Markdown in a few significant ways to add some useful functionality. You can use GFM in @@ -49,20 +61,26 @@ You can use GFM in * milestones * wiki pages - +You can also use other rich text files in GitLab. +You might have to install a depency to do so. +Please see the [github-markup gem readme](https://github.com/gitlabhq/markup#markups) for more information. + Newlines -------- -The biggest difference that GFM introduces is in the handling of linebreaks. With traditional Markdown you can hard wrap paragraphs of text and they will be combined into a single paragraph. We find this to be the cause of a huge number of unintentional formatting errors. GFM treats newlines in paragraph-like content as real line breaks, which is probably what you intended. +GFM honors the markdown specification in how [paragraphs and line breaks are handled](http://daringfireball.net/projects/markdown/syntax#p). -The next paragraph contains two phrases separated by a single newline character: +A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines.: Roses are red Violets are blue + Sugar is sweet + Roses are red Violets are blue - - + +Sugar is sweet + Multiple underscores in words ----------------------------- It is not reasonable to italicize just _part_ of a word, especially when you're dealing with code and names that often appear with multiple underscores. Therefore, GFM ignores multiple underscores in words. @@ -73,7 +91,6 @@ It is not reasonable to italicize just _part_ of a word, especially when you're perform_complicated_task do_this_and_do_that_and_another_thing - URL autolinking --------------- GFM will autolink standard URLs you copy and paste into your text. @@ -83,12 +100,10 @@ So if you want to link to a URL (instead of a textural link), you can simply put http://www.google.com - ## Code and Syntax Highlighting Blocks of code are either fenced by lines with three back-ticks ```, or are indented with four spaces. Only the fenced code blocks support syntax highlighting. - ```no-highlight Inline `code` has `back-ticks around` it. ``` @@ -101,14 +116,14 @@ Example: var s = "JavaScript syntax highlighting"; alert(s); ``` - + ```python def function(): #indenting works just fine in the fenced code block s = "Python syntax highlighting" print s ``` - + ```ruby require 'redcarpet' markdown = Redcarpet.new("Hello World!") @@ -116,7 +131,7 @@ Example: ``` ``` - No language indicated, so no syntax highlighting. + No language indicated, so no syntax highlighting. s = "There is no highlighting for this." But let's throw in a tag. ``` @@ -147,7 +162,6 @@ s = "There is no highlighting for this." But let's throw in a tag. ``` - Emoji ----- @@ -159,7 +173,7 @@ Emoji If you are :new: to this, don't be :fearful:. You can easily join the emoji :circus_tent:. All you need to do is to :book: up on the supported codes. - Consult the [Emoji Cheat Sheet](http://www.emoji-cheat-sheet.com/) for a list of all supported emoji codes. :thumbsup: + Consult the [Emoji Cheat Sheet](http://www.emoji-cheat-sheet.com/) for a list of all supported emoji codes. :thumbsup: Sometimes you want to be :cool: and add some :sparkles: to your :speech_balloon:. Well we have a :gift: for you: @@ -169,9 +183,8 @@ You can use it to point out a :bug: or warn about :monkey:patches. And if someon If you are :new: to this, don't be :fearful:. You can easily join the emoji :circus_tent:. All you need to do is to :book: up on the supported codes. -Consult the [Emoji Cheat Sheet](http://www.emoji-cheat-sheet.com/) for a list of all supported emoji codes. :thumbsup: +Consult the [Emoji Cheat Sheet](http://www.emoji-cheat-sheet.com/) for a list of all supported emoji codes. :thumbsup: - Special GitLab References ----- @@ -179,7 +192,6 @@ GFM recognized special references. You can easily reference e.g. a team member, an issue, or a commit within a project. GFM will turn that reference into a link so you can navigate between them easily. - GFM will recognize the following: * @foo : for team members @@ -187,15 +199,12 @@ GFM will recognize the following: * !123 : for merge requests * $123 : for snippets * 1234567 : for commits -* [file](path/to/file) : for file references - - +* \[file\](path/to/file) : for file references ---------------------------------- # Standard Markdown ---------------------------------- - ## Headers ```no-highlight @@ -230,7 +239,54 @@ Alt-H1 Alt-H2 ------ - +### Header IDs and links + +All markdown rendered headers automatically get IDs, except for comments. + +On hover a link to those IDs becomes visible to make it easier to copy the link to the header to give it to someone else. + +The IDs are generated from the content of the header according to the following rules: + +1) remove the heading hashes `#` and process the rest of the line as it would be processed if it were not a header +2) from the result, remove all HTML tags, but keep their inner content +3) convert all characters to lowercase +4) convert all characters except `[a-z0-9_-]` into hyphens `-` +5) transform multiple adjacent hyphens into a single hyphen +6) remove trailing and heading hyphens + +For example: + +``` +###### ..Ab_c-d. e [anchor](url) ![alt text](url).. +``` + +which renders as: + +###### ..Ab_c-d. e [anchor](url) ![alt text](url).. + +will first be converted by step 1) into a string like: + +``` +..Ab_c-d. e <a href="url">anchor</a> <img src="url" alt="alt text"/>.. +``` + +After removing the tags in step 2) we get: + +``` +..Ab_c-d. e anchor .. +``` + +And applying all the other steps gives the id: + +``` +ab_c-d-e-anchor +``` + +Note in particular how: + +- for markdown anchors `[text](url)`, only the `text` is used +- markdown images `![alt](url)` are completely ignored + ## Emphasis ```no-highlight @@ -251,18 +307,16 @@ Combined emphasis with **asterisks and _underscores_**. Strikethrough uses two tildes. ~~Scratch this.~~ - - ## Lists ```no-highlight 1. First ordered list item 2. Another item - * Unordered sub-list. + * Unordered sub-list. 1. Actual numbers don't matter, just that it's a number 1. Ordered sub-list -4. And another item. - +4. And another item. + Some text that should be aligned with the above item. * Unordered list can use asterisks @@ -272,27 +326,26 @@ Strikethrough uses two tildes. ~~Scratch this.~~ 1. First ordered list item 2. Another item - * Unordered sub-list. + * Unordered sub-list. 1. Actual numbers don't matter, just that it's a number 1. Ordered sub-list -4. And another item. - +4. And another item. + Some text that should be aligned with the above item. * Unordered list can use asterisks - Or minuses + Or pluses - ## Links -There are two ways to create links. +There are two ways to create links, inline-style and reference-style. [I'm an inline-style link](https://www.google.com) [I'm a reference-style link][Arbitrary case-insensitive reference text] - [I'm a relative reference to a repository file](../blob/master/LICENSE) + [I'm a relative reference to a repository file](LICENSE) [You can use numbers for reference-style link definitions][1] @@ -308,7 +361,7 @@ There are two ways to create links. [I'm a reference-style link][Arbitrary case-insensitive reference text] -[I'm a relative reference to a repository file](../blob/master/LICENSE) +[I'm a relative reference to a repository file](LICENSE) [You can use numbers for reference-style link definitions][1] @@ -320,30 +373,37 @@ Some text to show that the reference links can follow later. [1]: http://slashdot.org [link text itself]: http://www.reddit.com - +**Note** + +Relative links do not allow referencing project files in a wiki page or wiki page in a project file. +The reason for this is that, in GitLab, wiki is always a separate git repository. For example: + +`[I'm a reference-style link][style]` + +will point the link to `wikis/style` when the link is inside of a wiki markdown file. + ## Images Here's our logo (hover to see the title text): - Inline-style: - ![alt text](/assets/logo-white.png "Logo Title Text 1") + Inline-style: + ![alt text](assets/logo-white.png) - Reference-style: - ![alt text][logo] + Reference-style: + ![alt text1][logo] - [logo]: /assets/logo-white.png "Logo Title Text 2" + [logo]: assets/logo-white.png -Here's our logo (hover to see the title text): +Here's our logo: -Inline-style: -![alt text](/assets/logo-white.png "Logo Title Text 1") +Inline-style: +![alt text](/assets/logo-white.png) -Reference-style: +Reference-style: ![alt text][logo] -[logo]: /assets/logo-white.png "Logo Title Text 2" +[logo]: /assets/logo-white.png - ## Blockquotes ```no-highlight @@ -352,7 +412,7 @@ Reference-style: Quote break. -> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote. +> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote. ``` > Blockquotes are very handy in email to emulate reply text. @@ -360,12 +420,11 @@ Quote break. Quote break. -> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote. +> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote. - ## Inline HTML -You can also use raw HTML in your Markdown, and it'll mostly work pretty well. +You can also use raw HTML in your Markdown, and it'll mostly work pretty well. ```no-highlight
    @@ -385,7 +444,6 @@ You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
    Does *not* work **very** well. Use HTML tags.
    -
    ## Horizontal Rule ``` @@ -418,10 +476,9 @@ ___ Underscores - ## Line Breaks -My basic recommendation for learning how line breaks work is to experiment and discover -- hit <Enter> once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You'll soon learn to get what you want. "Markdown Toggle" is your friend. +My basic recommendation for learning how line breaks work is to experiment and discover -- hit <Enter> once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You'll soon learn to get what you want. "Markdown Toggle" is your friend. Here are some things to try out: @@ -438,11 +495,9 @@ Here's a line for us to start with. This line is separated from the one above by two newlines, so it will be a *separate paragraph*. -This line is also begins a separate paragraph, but... +This line is also begins a separate paragraph, but... This line is only separated by a single newline, so it's a separate line in the *same paragraph*. - - ## Tables Tables aren't part of the core Markdown spec, but they are part of GFM and Markdown Here supports them. @@ -461,10 +516,8 @@ Code above produces next output: | cell 1 | cell 2 | | cell 3 | cell 4 | - ------------ - ## References * This document leveraged heavily from the [Markdown-Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet). diff --git a/doc/permissions/permissions.md b/doc/permissions/permissions.md new file mode 100644 index 0000000000..9be6423f66 --- /dev/null +++ b/doc/permissions/permissions.md @@ -0,0 +1,45 @@ +Users have different abilities depending on the access level they have in a particular group or project. +If a user is both in a project group and in the project itself, the highest permission level is used. +If a user is a GitLab administrator they receive all permissions. + +--- + +#### Project: + + +| Action| Guest | Reporter | Developer | Master | Owner| +|-------|-------|----------|-----------|--------|------| +|Create new issue|✓|✓|✓|✓|✓| +|Leave comments|✓|✓|✓|✓|✓| +|Write on project wall|✓|✓|✓|✓|✓| +|Pull project code| |✓|✓|✓|✓| +|Download project| |✓|✓|✓|✓| +|Create code snippets| |✓|✓|✓|✓| +|Create new merge request| ||✓|✓|✓| +|Create new branches| ||✓|✓|✓| +|Push to non-protected branches| ||✓|✓|✓| +|Remove non-protected branches| ||✓|✓|✓| +|Add tags| ||✓|✓|✓| +|Write a wiki| ||✓|✓|✓| +|Manage issue tracker| ||✓|✓|✓| +|Add new team members| |||✓|✓| +|Push to protected branches| |||✓|✓| +|Remove protected branches| |||✓|✓| +|Edit project| |||✓|✓| +|Add Deploy Keys to project| |||✓|✓| +|Configure Project Hooks| |||✓|✓| +|Switch visibility level| ||||✓| +|Transfer project to another namespace| ||||✓| +|Remove project| ||||✓| + +#### Group + +|Action|Guest|Reporter|Developer|Master|Owner| +|------|-----|--------|---------|------|-----| +|Browse group|✓|✓|✓|✓|✓| +|Edit group|||||✓| +|Create project in group|||||✓| +|Manage group members|||||✓| +|Remove group|||||✓| + +Any user can remove himself from a group, unless he is the last Owner of the group. diff --git a/doc/public_access/public_access.md b/doc/public_access/public_access.md new file mode 100644 index 0000000000..76d83e6f3b --- /dev/null +++ b/doc/public_access/public_access.md @@ -0,0 +1,28 @@ +Gitlab allows you to open selected projects to be accessed **publicly** or **internally**. +Projects with either of these visibility levels will be listen in the [public access directory](/public). +Internal projects will only be available to authenticated users. + +#### Public projects +Public projects can be cloned **without any** authentication. +It will also be listed on the [public access directory](/public). +**Any logged in user** will have [Guest](/help/permissions) permissions on the repository. + +#### Internal projects +Internal projects can be cloned by any logged in user. +It will also be listed on the [public access directory](/public) for logged in users. +Any logged in user will have [Guest](/help/permissions) permissions on the repository. + +#### How to change project visibility +1. Go to your project dashboard +2. Click on the "Edit" tab +3. Change "Visibility Level" + +#### Visibility of users +The public page of users, located at `/u/username` is visible if either: + +* You are logged in. +* You are logged out, and the target user is authorized to (is Guest, Reporter, etc.) at least one public project. + +Otherwise, you will be redirected to the sign in page. + +When visiting the public page of an user, you will only see listed projects which you can view yourself. diff --git a/doc/raketasks/README.md b/doc/raketasks/README.md new file mode 100644 index 0000000000..6be24f0102 --- /dev/null +++ b/doc/raketasks/README.md @@ -0,0 +1,7 @@ ++ [Backup restore](backup_restore.md) ++ [Cleanup](cleanup.md) ++ [Features](features.md) ++ [Maintenance](maintenance.md) and self-checks ++ [User management](user_management.md) ++ [Web hooks](web_hooks.md) ++ [Import](import.md) of git repositories in bulk diff --git a/doc/raketasks/backup_restore.md b/doc/raketasks/backup_restore.md index d2da64f3d3..bdff6ad5da 100644 --- a/doc/raketasks/backup_restore.md +++ b/doc/raketasks/backup_restore.md @@ -78,3 +78,18 @@ Restoring repositories: - Restoring repository abcd... [DONE] Deleting tmp directories...[DONE] ``` + +### Configure cron to make daily backups + +``` +cd /home/git/gitlab +sudo -u git -H editor config/gitlab.yml # Enable keep_time in the backup section to automatically delete old backups +sudo -u git crontab -e # Edit the crontab for the git user +``` + +Add the following lines at the bottom: + +``` +# Create a full backup of the GitLab repositories and SQL database every day at 2am +0 2 * * * cd /home/git/gitlab && PATH=/usr/local/bin:/usr/bin:/bin bundle exec rake gitlab:backup:create RAILS_ENV=production +``` diff --git a/doc/raketasks/import.md b/doc/raketasks/import.md new file mode 100644 index 0000000000..e11328dc5c --- /dev/null +++ b/doc/raketasks/import.md @@ -0,0 +1,28 @@ +### Import bare repositories into GitLab project instance + +Notes: + +* project owner will be a first admin +* groups will be created as needed +* group owner will be the first admin +* existing projects will be skipped + +How to use: + +1. copy your bare repos under git repos_path (see `config/gitlab.yml` gitlab_shell -> repos_path) +2. run the command below + +``` +bundle exec rake gitlab:import:repos RAILS_ENV=production +``` + +Example output: + +``` +Processing abcd.git + * Created abcd (abcd.git) +Processing group/xyz.git + * Created Group group (2) + * Created xyz (group/xyz.git) +[...] +``` diff --git a/doc/raketasks/maintenance.md b/doc/raketasks/maintenance.md index 3033d8c46b..2783c4153c 100644 --- a/doc/raketasks/maintenance.md +++ b/doc/raketasks/maintenance.md @@ -110,32 +110,3 @@ If necessary, remove the `tmp/repo_satellites` directory and rerun the command b ``` bundle exec rake gitlab:satellites:create RAILS_ENV=production ``` - -### Import bare repositories into GitLab project instance - -Notes: - -* project owner will be a first admin -* groups will be created as needed -* group owner will be the first admin -* existing projects will be skipped - -How to use: - -1. copy your bare repos under git repos_path (see `config/gitlab.yml` gitlab_shell -> repos_path) -2. run the command below - -``` -bundle exec rake gitlab:import:repos RAILS_ENV=production -``` - -Example output: - -``` -Processing abcd.git - * Created abcd (abcd.git) -Processing group/xyz.git - * Created Group group (2) - * Created xyz (group/xyz.git) -[...] -``` diff --git a/doc/raketasks/user_management.md b/doc/raketasks/user_management.md index 8fa2ed1311..e823208291 100644 --- a/doc/raketasks/user_management.md +++ b/doc/raketasks/user_management.md @@ -1,6 +1,6 @@ ### Add user as a developer to all projects -``` +```bash bundle exec rake gitlab:import:user_to_projects[username@domain.tld] ``` @@ -11,6 +11,22 @@ Notes: * admin users are added as masters -``` +```bash bundle exec rake gitlab:import:all_users_to_all_projects ``` + +### Add user as a developer to all groups + +``` +bundle exec rake gitlab:import:user_to_groups[username@domain.tld] +``` + +### Add all users to all groups + +Notes: + +* admin users are added as owners so they can add additional users to the group + +``` +bundle exec rake gitlab:import:all_users_to_all_groups +``` diff --git a/doc/release/README.md b/doc/release/README.md new file mode 100644 index 0000000000..22510be3f1 --- /dev/null +++ b/doc/release/README.md @@ -0,0 +1,2 @@ ++ [Monthly](monthly.md) ++ [Security](security.md) diff --git a/doc/release/monthly.md b/doc/release/monthly.md new file mode 100644 index 0000000000..514d73517b --- /dev/null +++ b/doc/release/monthly.md @@ -0,0 +1,167 @@ +# Monthly Release +NOTE: This is a guide for GitLab developers. + +# **15th - Code Freeze & Release Manager** + +### **1. Stop merging in code, except for important bugfixes** + +### **2. Release Manager** + +A release manager is selected that coordinates the entire release of this version. The release manager has to make sure all the steps below are done and delegated where necessary. This person should also make sure this document is kept up to date and issues are created and updated. + +# **18th - Releasing RC1** + +The RC1 release comes with the task to update the installation and upgrade docs. Be mindful that there might already be merge requests for this on GitLab or GitHub. + +### **1. Create an issue for RC1 release** + +### **2. Update the installation guide** + +1. Check if it references the correct branch `x-x-stable` (doesn't exist yet, but that is okay) +2. Check the [GitLab Shell version](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/tasks/gitlab/check.rake#L782) +3. Check the [Git version](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/tasks/gitlab/check.rake#L794) +4. There might be other changes. Ask around. + +### **3. Create an update guide** + +It's best to copy paste the previous guide and make changes where necessary. The typical steps are listed below with any points you should specifically look at. + +#### 0. Any major changes? +List any major changes here, so the user is aware of them before starting to upgrade. For instance: +- Database updates +- Web server changes +- File structure changes + +#### 1. Make backup + +#### 2. Stop server + +#### 3. Do users need to update dependencies like `git`? + +- Check if the [GitLab Shell version](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/tasks/gitlab/check.rake#L782) changed since the last release. + +- Check if the [Git version](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/tasks/gitlab/check.rake#L794) changed since the last release. + +#### 4. Get latest code + +#### 5. Does GitLab shell need to be updated? + +#### 6. Install libs, migrations, etc. + +#### 7. Any config files updated since last release? + +Check if any of these changed since last release: + +* https://gitlab.com/gitlab-org/gitlab-ce/commits/master/lib/support/nginx/gitlab +* https://gitlab.com/gitlab-org/gitlab-shell/commits/master/config.yml.example +* https://gitlab.com/gitlab-org/gitlab-ce/commits/master/config/gitlab.yml.example +* https://gitlab.com/gitlab-org/gitlab-ce/commits/master/config/unicorn.rb.example +* https://gitlab.com/gitlab-org/gitlab-ce/commits/master/config/database.yml.mysql +* https://gitlab.com/gitlab-org/gitlab-ce/commits/master/config/database.yml.postgresql + +#### 8. Need to update init script? + +Check if the init.d/gitlab script changed since last release: https://gitlab.com/gitlab-org/gitlab-ce/commits/master/lib/support/init.d/gitlab + +#### 9. Start application + +#### 10. Check application status + +### **4. Code quality indicatiors** +Make sure the code quality indicators are green / good. + +* [![build status](http://ci.gitlab.org/projects/1/status.png?ref=master)](http://ci.gitlab.org/projects/1?ref=master) on ci.gitlab.org (master branch) + +* [![build status](https://secure.travis-ci.org/gitlabhq/gitlabhq.png)](https://travis-ci.org/gitlabhq/gitlabhq) on travis-ci.org (master branch) + +* [![Code Climate](https://codeclimate.com/github/gitlabhq/gitlabhq.png)](https://codeclimate.com/github/gitlabhq/gitlabhq) + +* [![Dependency Status](https://gemnasium.com/gitlabhq/gitlabhq.png)](https://gemnasium.com/gitlabhq/gitlabhq) this button can be yellow (small updates are available) but must not be red (a security fix or an important update is available) + +* [![Coverage Status](https://coveralls.io/repos/gitlabhq/gitlabhq/badge.png?branch=master)](https://coveralls.io/r/gitlabhq/gitlabhq) + +### **5. Set VERSION** + +Set VERSION tot x.x.0.rc1 + + +### **6. Tag** + +Create an annotated tag that points to the version change commit. +``` +git tag -a vx.x.0.rc1 -m 'Version x.x.0.rc1' +``` + +### **7. Tweet** + +Tweet about the RC release: + +> GitLab x.x.x.rc1 is out. This is a release candidate intended for testing only. Please let us know if you find regressions. + +### **8. Update Cloud** + +Merge the RC1 code into Cloud. Once the build is green, deploy in the morning. + +It is important to do this as soon as possible, so we can catch any errors before we release the full version. + + +# **22nd - Release CE and EE** + +For GitLab EE, append -ee to the branches and tags. + +`x-x-stable-ee` + +`v.x.x.0-ee` + +### **1. Create x-x-stable branch and push to the repositories** + +``` +git checkout master +git pull +git checkout -b x-x-stable +git push x-x-stable +``` + +### **2. Build the Omnibus packages** +[Follow this guide](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/release.md) + +### **3. QA** +Use the omnibus packages to test using [this guide](https://dev.gitlab.org/gitlab/gitlab-ee/blob/master/doc/release/manual_testing.md) + + +### **4. Fix anything coming out of the QA** + +### **5. Set VERSION to x.x.0** + +### **6. Create annotated tag vx.x.0** +``` +git tag -a vx.x.0 -m 'Version x.x.0' +``` + +### **7. Push VERSION + Tag to master, merge into x-x-stable** +``` +git push origin master +``` + +Next, merge the VERSION into the x-x-stable branch. + +### **8. Push to remotes** + +For GitLab CE, push to dev, GitLab.com and GitHub. + +For GitLab EE, push to the subscribers repo. + +NOTE: You might not have the rights to push to master on dev. Ask Dmitriy. + +### **9. Publish blog for new release** +* Mention what GitLab is on the second line: GitLab is open source software to collaborate on code. +* Select and thank the the Most Valuable Person (MVP) of this release. +* Add a note if there are security fixes: This release fixes an important security issue and we advise everyone to upgrade as soon as possible. + +### **10. Tweet to blog** + +Send out a tweet to share the good news with the world. List the features in short and link to the blog post. + +# **23rd - Optional Patch Release** + +# **25th - Release GitLab CI** diff --git a/doc/release/patch.md b/doc/release/patch.md new file mode 100644 index 0000000000..30bb39b4e4 --- /dev/null +++ b/doc/release/patch.md @@ -0,0 +1,25 @@ +# Things to do when doing a patch release +NOTE: This is a guide for GitLab developers. If you are trying to install GitLab see the latest stable [installation guide](install/installation.md) and if you are trying to upgrade, see the [upgrade guides](update). + +## When to do a patch release + +Do a patch release when there is a critical regression that needs to be adresses before the next monthly release. +Otherwise include it in the monthly release and note there was a regression fix in the release announcement. + +## Release Procedure + +1. Verify that the issue can be repoduced +1. Create an issue on private GitLab development server +1. Name the issue "Release X.X.X CE and X.X.X EE", this will make searching easier +1. Fix the issue on a feature branch, do this on the private GitLab development server +1. Consider creating and testing workarounds +1. After the branch is merged into master, cherry pick the commit(s) into the current stable branch +1. In a separate commit in the stable branch, update the VERSION and CHANGELOG +1. For EE, update the CHANGELOG-EE if it is EE specific fix. Otherwise, merge the stable CE branch and add to CHANGELOG-EE "Merge community edition changes for version X.X.X" +1. Create an annotated tag vX.X.X for CE and another patch release for EE +1. Make sure that the build has passed and no tests are failing +1. Push the code and the tags to all the CE and EE repositories +1. Apply the patch to GitLab Cloud and the private GitLab development server +1. Send tweets about the release from @gitlabhq, tweet should include the most important feature that the release is addressing as well as the link to the changelog +1. Build new packages with the latest version + diff --git a/doc/release/security.md b/doc/release/security.md new file mode 100644 index 0000000000..2fe0a948ad --- /dev/null +++ b/doc/release/security.md @@ -0,0 +1,70 @@ +# Things to do when doing an out-of-bound security release +NOTE: This is a guide for GitLab developers. If you are trying to install GitLab see the latest stable [installation guide](install/installation.md) and if you are trying to upgrade, see the [upgrade guides](update). + +## When to do a security release + +Do a security release when there is a critical issue that needs to be adresses before the next monthly release. Otherwise include it in the monthly release and note there was a security fix in the release announcement. + +## Security vulnerability disclosure + +Please report suspected security vulnerabilities in private to support@gitlab.com, also see the [disclosure section on the GitLab.com website](http://www.gitlab.com/disclosure/). Please do NOT create publicly viewable issues for suspected security vulnerabilities. + +## Release Procedure + +1. Verify that the issue can be repoduced +1. Acknowledge the issue to the researcher that disclosed it +1. Do the steps from [patch release document](doc/release/patch.md), starting with "Create an issue on private GitLab development server" +1. Create feature branches for the blog post on GitLab.com and link them from the code branch +1. Merge and publish the blog posts +1. Send tweets about the release from @gitlabhq +1. Send out an email to the subscribers mailing list on MailChimp +1. Send out an email to [the community google mailing list](https://groups.google.com/forum/#!forum/gitlabhq) +1. Send out an email to [the GitLab newsletter list](http://gitlab.us5.list-manage.com/subscribe?u=498dccd07cf3e9482bee33ba4&id=98a9a4992c) +1. Post a signed copy of our complete announcement to [oss-security](http://www.openwall.com/lists/oss-security/) and request a CVE number +1. Add the security researcher to the [Security Researcher Acknowledgments list](http://www.gitlab.com/vulnerability-acknowledgements/) +1. Thank the security researcher in an email for their cooperation +1. Update the blogpost and the CHANGELOG when we receive the CVE number + +The timing of the code merge into master should be coordinated in advance. +After the merge we strive to publish the announcements within 60 minutes. + +## Blog post template + +XXX Security Advisory for GitLab + +A recently discovered critical vulnerability in GitLab allows [unauthenticated API access|remote code execution|unauthorized access to repositories|XXX|PICKSOMETHING]. All users should update GitLab and gitlab-shell immediately. +We [have|haven't|XXX|PICKSOMETHING|] heard of this vulnerability being actively exploited. + +### Version affected + +GitLab Community Edition XXX and lower +GitLab Enterprise Edition XXX and lower + +### Fixed versions + +GitLab Community Edition XXX and up +GitLab Enterprise Edition XXX and up + +### Impact + +On GitLab installations which use MySQL as their database backend it is possible for an attacker to assume the identity of any existing GitLab user in certain API calls. This attack can be performed by [unauthenticated|authenticated|XXX|PICKSOMETHING] users. + +### Workarounds + +If you are unable to upgrade you should apply the following patch and restart GitLab. + +XXX + +### Credit + +We want to thank XXX of XXX for the reponsible disclosure of this vulnerability. + +## Email template + +We just announced a security advisory for GitLab at XXX + +Please contact us at support@gitlab.com if you have any questions. + +## Tweet template + +We just announced a security advisory for GitLab at XXX diff --git a/doc/security/README.md b/doc/security/README.md new file mode 100644 index 0000000000..f8dd1291b9 --- /dev/null +++ b/doc/security/README.md @@ -0,0 +1,2 @@ ++ [Password length limits](password_length_limits.md) ++ [Rack attack](rack_attack.md) diff --git a/doc/security/password_length_limits.md b/doc/security/password_length_limits.md new file mode 100644 index 0000000000..c8d66e9636 --- /dev/null +++ b/doc/security/password_length_limits.md @@ -0,0 +1,10 @@ +# Custom password length limits + +If you want to enforce longer user passwords you can create an extra Devise initializer with the steps below. +If you do not use the `devise_password_length.rb` initializer the password length is set to a minimum of 8 characters in `config/initializers/devise.rb`. + +```bash +cd /home/git/gitlab +sudo -u git -H cp config/initializers/devise_password_length.rb.example config/initializers/devise_password_length.rb +sudo -u git -H editor config/initializers/devise_password_length.rb # inspect and edit the new password length limits +``` diff --git a/doc/ssh/README.md b/doc/ssh/README.md new file mode 100644 index 0000000000..76d9e8bb07 --- /dev/null +++ b/doc/ssh/README.md @@ -0,0 +1,2 @@ ++ [Deploy keys](deploy_keys.md) ++ [SSH](ssh.md) diff --git a/doc/ssh/deploy_keys.md b/doc/ssh/deploy_keys.md new file mode 100644 index 0000000000..c7125b7949 --- /dev/null +++ b/doc/ssh/deploy_keys.md @@ -0,0 +1,12 @@ +Deploy keys allow read-only access one or multiple projects with a single SSH key. + +This is really useful for cloning repositories to your Continuous Integration (CI) server. +By using a deploy keys you don't have to setup a dummy user account. + +If you are a project master or owner you can add a deploy key in the project settings under the section Deploy Keys. +Press the 'New Deploy Key' button and upload a public ssh key. +After this the machine that uses the corresponding private key has read-only access to the project. + +You can't add the same deploy key twice with the 'New Deploy Key' option. +If you want to add the same key to another project please enable it in the list that says 'Deploy keys from projects available to you'. +All the deploy keys of all the projects you have access to are available. This project access can happen through being a direct member of the project or through a group. See `def accessible_deploy_keys` in `app/models/user.rb` for more information. diff --git a/doc/ssh/ssh.md b/doc/ssh/ssh.md new file mode 100644 index 0000000000..0a38bc16b4 --- /dev/null +++ b/doc/ssh/ssh.md @@ -0,0 +1,24 @@ +SSH key allows you to establish a secure connection between your computer and GitLab + + +Before generating an SSH key, check if your system already has one by running `cat ~/.ssh/id_rsa.pub` +If your see a long string starting with `ssh-rsa` or `ssh-dsa`, you can skip the ssh-keygen step. + + +To generate a new SSH key just open your terminal and use code below. The ssh-keygen command prompts you for a location and filename to store the key pair and for a password. +When prompted for the location and filename you can press enter to use the default. +It is a best practice to use a password for an SSH key but it is not required and you can skip creating a password by pressing enter. +Note that the password you choose here can't be altered or retrieved. + +```bash +ssh-keygen -t rsa -C "$your_email" +``` + +Use the code below to show your public key. + +```bash +cat ~/.ssh/id_rsa.pub +``` + +Copy-paste the key to the 'My SSH Keys' section under the 'SSH' tab in your user profile. +Please copy the complete key starting with `ssh-` and ending with your username and host. diff --git a/doc/system_hooks/system_hooks.md b/doc/system_hooks/system_hooks.md new file mode 100644 index 0000000000..5c8daf466a --- /dev/null +++ b/doc/system_hooks/system_hooks.md @@ -0,0 +1,93 @@ +Your GitLab instance can perform HTTP POST requests on the following events: `create_project`, `delete_project`, `create_user`, `delete_user` and `change_team_member`. + +System hooks can be used, e.g. for logging or changing information in a LDAP server. + +#### Hooks request example: + +**Project created:** + +```json +{ + "created_at": "2012-07-21T07:30:54Z", + "event_name": "project_create", + "name": "StoreCloud", + "owner_email": "johnsmith@gmail.com", + "owner_name": "John Smith", + "path": "stormcloud", + "path_with_namespace": "jsmith/stormcloud", + "project_id": 74, + "project_visibility": "private", +} +``` + +**Project destroyed:** + +```json +{ + "created_at": "2012-07-21T07:30:58Z", + "event_name": "project_destroy", + "name": "Underscore", + "owner_email": "johnsmith@gmail.com", + "owner_name": "John Smith", + "path": "underscore", + "path_with_namespace": "jsmith/underscore", + "project_id": 73, + "project_visibility": "internal", +} +``` + +**New Team Member:** + +```json +{ + "created_at": "2012-07-21T07:30:56Z", + "event_name": "user_add_to_team", + "project_access": "Master", + "project_id": 74, + "project_name": "StoreCloud", + "project_path": "storecloud", + "user_email": "johnsmith@gmail.com", + "user_name": "John Smith", + "project_visibility": "private", +} +``` + +**Team Member Removed:** + +```json +{ + "created_at": "2012-07-21T07:30:56Z", + "event_name": "user_remove_from_team", + "project_access": "Master", + "project_id": 74, + "project_name": "StoreCloud", + "project_path": "storecloud", + "user_email": "johnsmith@gmail.com", + "user_name": "John Smith", + "project_visibility": "private", +} +``` + +**User created:** + +```json +{ + "created_at": "2012-07-21T07:44:07Z", + "email": "js@gitlabhq.com", + "event_name": "user_create", + "name": "John Smith", + "user_id": 41 +} +``` + +**User removed:** + +```json +{ + "created_at": "2012-07-21T07:44:07Z", + "email": "js@gitlabhq.com", + "event_name": "user_destroy", + "name": "John Smith", + "user_id": 41 +} +``` diff --git a/doc/update/4.2-to-5.0.md b/doc/update/4.2-to-5.0.md index 90f59e1fd1..f8fb607e01 100644 --- a/doc/update/4.2-to-5.0.md +++ b/doc/update/4.2-to-5.0.md @@ -1,5 +1,8 @@ # From 4.2 to 5.0 +## Warning +GitLab 5.0 is affected by critical security vulnerability CVE-2013-4490. + ## Important changes * We don't use `gitlab` user any more. Everything will be moved to `git` user diff --git a/doc/update/5.0-to-5.1.md b/doc/update/5.0-to-5.1.md index 45fc3436eb..ba56507dd8 100644 --- a/doc/update/5.0-to-5.1.md +++ b/doc/update/5.0-to-5.1.md @@ -1,5 +1,8 @@ # From 5.0 to 5.1 +## Warning +GitLab 5.1 is affected by critical security vulnerability CVE-2013-4490. + ## Release notes: * `unicorn` replaced with `puma` diff --git a/doc/update/5.1-to-5.2.md b/doc/update/5.1-to-5.2.md index 27f992ecfe..466c815195 100644 --- a/doc/update/5.1-to-5.2.md +++ b/doc/update/5.1-to-5.2.md @@ -1,5 +1,8 @@ # From 5.1 to 5.2 +## Warning +GitLab 5.2 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. + ### 0. Backup It's useful to make a backup just in case things go south: @@ -48,8 +51,8 @@ sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production ### 5. Update config files -* Make `/home/git/gitlab/config/gitlab.yml` same as https://github.com/gitlabhq/gitlabhq/blob/5-2-stable/config/gitlab.yml.example but with your settings. -* Make `/home/git/gitlab/config/puma.rb` same as https://github.com/gitlabhq/gitlabhq/blob/5-2-stable/config/puma.rb.example but with your settings. +* Make `/home/git/gitlab/config/gitlab.yml` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/5-2-stable/config/gitlab.yml.example but with your settings. +* Make `/home/git/gitlab/config/puma.rb` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/5-2-stable/config/puma.rb.example but with your settings. ### 6. Update Init script diff --git a/doc/update/5.1-to-5.4.md b/doc/update/5.1-to-5.4.md new file mode 100644 index 0000000000..56f4854daf --- /dev/null +++ b/doc/update/5.1-to-5.4.md @@ -0,0 +1,100 @@ +# From 5.1 to 5.4 +Also works starting from 5.2. + +### 0. Backup + +It's useful to make a backup just in case things go south: +(With MySQL, this may require granting "LOCK TABLES" privileges to the GitLab user on the database version) + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production +``` + +### 1. Stop server + + sudo service gitlab stop + +### 2. Get latest code + +```bash +cd /home/git/gitlab +sudo -u git -H git fetch +sudo -u git -H git checkout 5-4-stable # Latest version of 5-4-stable addresses CVE-2013-4489 +``` + +### 3. Update gitlab-shell + +```bash +cd /home/git/gitlab-shell +sudo -u git -H git fetch +sudo -u git -H git checkout v1.7.9 # Addresses multiple critical security vulnerabilities +``` + +### 4. Install libs, migrations, etc. + +```bash +cd /home/git/gitlab + +# MySQL +sudo -u git -H bundle install --without development test postgres --deployment + +#PostgreSQL +sudo -u git -H bundle install --without development test mysql --deployment + +sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production + +sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production +``` + +### 5. Update config files + +* Make `/home/git/gitlab/config/gitlab.yml` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/5-4-stable/config/gitlab.yml.example but with your settings. +* Make `/home/git/gitlab/config/puma.rb` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/5-4-stable/config/puma.rb.example but with your settings. + +### 6. Update Init script + +```bash +sudo rm /etc/init.d/gitlab +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab +sudo chmod +x /etc/init.d/gitlab +``` + +### 7. Create uploads directory + +```bash +cd /home/git/gitlab +sudo -u git -H mkdir public/uploads +sudo chmod -R u+rwX public/uploads +``` + + +### 8. Start application + + sudo service gitlab start + sudo service nginx restart + +### 9. Check application status + +Check if GitLab and its environment are configured correctly: + + sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production + +To make sure you didn't miss anything run a more thorough check with: + + sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production + +If all items are green, then congratulations upgrade complete! + +## Things went south? Revert to previous version (5.3) + +### 1. Revert the code to the previous version +Follow the [`upgrade guide from 5.2 to 5.3`](5.2-to-5.3.md), except for the database migration +(The backup is already migrated to the previous version) + +### 2. Restore from the backup: + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production +``` diff --git a/doc/update/5.1-to-6.0.md b/doc/update/5.1-to-6.0.md index 6105d4b53b..5b74b1f893 100644 --- a/doc/update/5.1-to-6.0.md +++ b/doc/update/5.1-to-6.0.md @@ -1,5 +1,8 @@ # From 5.1 to 6.0 +## Warning +GitLab 6.0 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. + ### Deprecations #### Global projects @@ -44,7 +47,7 @@ sudo -u git -H git checkout 6-0-stable ```bash cd /home/git/gitlab-shell sudo -u git -H git fetch -sudo -u git -H git checkout v1.7.0 +sudo -u git -H git checkout v1.7.9 ``` ### 4. Install additional packages @@ -84,8 +87,8 @@ sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production Note: We switched from Puma in GitLab 5.x to unicorn in GitLab 6.0. -* Make `/home/git/gitlab/config/gitlab.yml` the same as https://github.com/gitlabhq/gitlabhq/blob/master/config/gitlab.yml.example but with your settings. -* Make `/home/git/gitlab/config/unicorn.rb` the same as https://github.com/gitlabhq/gitlabhq/blob/master/config/unicorn.rb.example but with your settings. +* Make `/home/git/gitlab/config/gitlab.yml` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/masterconfig/gitlab.yml.example but with your settings. +* Make `/home/git/gitlab/config/unicorn.rb` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/masterconfig/unicorn.rb.example but with your settings. ### 7. Update Init script diff --git a/doc/update/5.2-to-5.3.md b/doc/update/5.2-to-5.3.md index a8bb530902..e3c3016db6 100644 --- a/doc/update/5.2-to-5.3.md +++ b/doc/update/5.2-to-5.3.md @@ -1,5 +1,8 @@ # From 5.2 to 5.3 +## Warning +GitLab 5.3 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. + ### 0. Backup It's useful to make a backup just in case things go south: @@ -40,8 +43,8 @@ sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production ### 4. Update config files -* Make `/home/git/gitlab/config/gitlab.yml` same as https://github.com/gitlabhq/gitlabhq/blob/5-3-stable/config/gitlab.yml.example but with your settings. -* Make `/home/git/gitlab/config/puma.rb` same as https://github.com/gitlabhq/gitlabhq/blob/5-3-stable/config/puma.rb.example but with your settings. +* Make `/home/git/gitlab/config/gitlab.yml` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/5-3-stable/config/gitlab.yml.example but with your settings. +* Make `/home/git/gitlab/config/puma.rb` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/5-3-stable/config/puma.rb.example but with your settings. ### 5. Update Init script diff --git a/doc/update/5.3-to-5.4.md b/doc/update/5.3-to-5.4.md index 315bf03a6d..213ce77ec3 100644 --- a/doc/update/5.3-to-5.4.md +++ b/doc/update/5.3-to-5.4.md @@ -19,7 +19,7 @@ sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production ```bash cd /home/git/gitlab sudo -u git -H git fetch -sudo -u git -H git checkout 5-4-stable +sudo -u git -H git checkout 5-4-stable # Latest version of 5-4-stable addresses CVE-2013-4489 ``` ### 3. Update gitlab-shell @@ -27,7 +27,7 @@ sudo -u git -H git checkout 5-4-stable ```bash cd /home/git/gitlab-shell sudo -u git -H git fetch -sudo -u git -H git checkout v1.5.0 +sudo -u git -H git checkout v1.7.9 # Addresses multiple critical security vulnerabilities ``` ### 4. Install libs, migrations, etc. @@ -48,8 +48,8 @@ sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production ### 5. Update config files -* Make `/home/git/gitlab/config/gitlab.yml` same as https://github.com/gitlabhq/gitlabhq/blob/5-4-stable/config/gitlab.yml.example but with your settings. -* Make `/home/git/gitlab/config/puma.rb` same as https://github.com/gitlabhq/gitlabhq/blob/5-4-stable/config/puma.rb.example but with your settings. +* Make `/home/git/gitlab/config/gitlab.yml` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/5-4-stable/config/gitlab.yml.example but with your settings. +* Make `/home/git/gitlab/config/puma.rb` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/5-4-stable/config/puma.rb.example but with your settings. ### 6. Update Init script diff --git a/doc/update/5.4-to-6.0.md b/doc/update/5.4-to-6.0.md index 3072a1da71..c289fcb57f 100644 --- a/doc/update/5.4-to-6.0.md +++ b/doc/update/5.4-to-6.0.md @@ -1,5 +1,8 @@ # From 5.4 to 6.0 +## Warning +GitLab 6.0 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. + ### Deprecations #### Global projects @@ -44,7 +47,7 @@ sudo -u git -H git checkout 6-0-stable ```bash cd /home/git/gitlab-shell sudo -u git -H git fetch -sudo -u git -H git checkout v1.7.0 +sudo -u git -H git checkout v1.7.9 ``` ### 4. Install additional packages @@ -84,14 +87,14 @@ sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production Note: We switched from Puma in GitLab 5.4 to unicorn in GitLab 6.0. -* Make `/home/git/gitlab/config/gitlab.yml` the same as https://github.com/gitlabhq/gitlabhq/blob/master/config/gitlab.yml.example but with your settings. -* Make `/home/git/gitlab/config/unicorn.rb` the same as https://github.com/gitlabhq/gitlabhq/blob/master/config/unicorn.rb.example but with your settings. +* Make `/home/git/gitlab/config/gitlab.yml` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/gitlab.yml.example but with your settings. +* Make `/home/git/gitlab/config/unicorn.rb` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/unicorn.rb.example but with your settings. ### 7. Update Init script ```bash sudo rm /etc/init.d/gitlab -sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlabhq/6-0-stable/lib/support/init.d/gitlab +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab sudo chmod +x /etc/init.d/gitlab ``` diff --git a/doc/update/6.0-to-6.1.md b/doc/update/6.0-to-6.1.md index 67770bd93d..b4cc920358 100644 --- a/doc/update/6.0-to-6.1.md +++ b/doc/update/6.0-to-6.1.md @@ -1,5 +1,8 @@ # From 6.0 to 6.1 +## Warning +GitLab 6.1 is affected by critical security vulnerabilities CVE-2013-4490 and CVE-2013-4489. + # In 6.1 we remove a lot of deprecated code. # You should update to 6.0 before installing 6.1 so all the necessary conversions are run. @@ -27,8 +30,9 @@ sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production ```bash cd /home/git/gitlab -sudo -u git -H git fetch +sudo -u git -H git fetch --all sudo -u git -H git checkout 6-1-stable +# For GitLab Enterprise Edition: sudo -u git -H git checkout 6-1-stable-ee ``` ### 3. Update gitlab-shell @@ -36,7 +40,7 @@ sudo -u git -H git checkout 6-1-stable ```bash cd /home/git/gitlab-shell sudo -u git -H git fetch -sudo -u git -H git checkout v1.7.4 +sudo -u git -H git checkout v1.7.9 ``` ### 4. Install libs, migrations, etc. @@ -60,14 +64,14 @@ sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production ### 5. Update config files -* Make `/home/git/gitlab/config/gitlab.yml` same as https://github.com/gitlabhq/gitlabhq/blob/6-1-stable/config/gitlab.yml.example but with your settings. -* Make `/home/git/gitlab/config/unicorn.rb` same as https://github.com/gitlabhq/gitlabhq/blob/6-1-stable/config/unicorn.rb.example but with your settings. +* Make `/home/git/gitlab/config/gitlab.yml` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-1-stable/config/gitlab.yml.example but with your settings. +* Make `/home/git/gitlab/config/unicorn.rb` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-1-stable/config/unicorn.rb.example but with your settings. ### 6. Update Init script ```bash sudo rm /etc/init.d/gitlab -sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlabhq/6-1-stable/lib/support/init.d/gitlab +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab sudo chmod +x /etc/init.d/gitlab ``` diff --git a/doc/update/6.0-to-6.2.md b/doc/update/6.0-to-6.8.md similarity index 63% rename from doc/update/6.0-to-6.2.md rename to doc/update/6.0-to-6.8.md index 656bcaffdd..5c71e99aa5 100644 --- a/doc/update/6.0-to-6.2.md +++ b/doc/update/6.0-to-6.8.md @@ -1,4 +1,4 @@ -# From 6.0 to 6.2 +# From 6.0 to 6.8 # In 6.1 we remove a lot of deprecated code. # You should update to 6.0 before installing 6.1 or higher so all the necessary conversions are run. @@ -27,8 +27,21 @@ sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production ```bash cd /home/git/gitlab -sudo -u git -H git fetch -sudo -u git -H git checkout 6-2-stable +sudo -u git -H git fetch --all +``` + +For Gitlab Community Edition: + +```bash +sudo -u git -H git checkout 6-8-stable +``` + +OR + +For GitLab Enterprise Edition: + +```bash +sudo -u git -H git checkout 6-8-stable-ee ``` @@ -44,7 +57,7 @@ sudo apt-get install logrotate ```bash cd /home/git/gitlab-shell sudo -u git -H git fetch -sudo -u git -H git checkout v1.7.4 +sudo -u git -H git checkout v1.9.3 # Addresses multiple critical security vulnerabilities ``` ### 5. Install libs, migrations, etc. @@ -52,18 +65,24 @@ sudo -u git -H git checkout v1.7.4 ```bash cd /home/git/gitlab -# MySQL +# MySQL installations (note: the line below states '--without ... postgres') sudo -u git -H bundle install --without development test postgres --deployment -#PostgreSQL +# PostgreSQL installations (note: the line below states '--without ... mysql') sudo -u git -H bundle install --without development test mysql --deployment +# Run database migrations sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production + +# Enable internal issue IDs (introduced in GitLab 6.1) sudo -u git -H bundle exec rake migrate_iids RAILS_ENV=production -sudo -u git -H bundle exec rake assets:clean RAILS_ENV=production -sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production -sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production + +# Clean up assets and cache +sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production + +# Close access to gitlab-satellites for others +sudo chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites ``` ### 6. Update config files @@ -71,17 +90,18 @@ sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production TIP: to see what changed in gitlab.yml.example in this release use next command: ``` -git diff 6-1-stable:config/gitlab.yml.example 6-2-stable:config/gitlab.yml.example +git diff 6-0-stable:config/gitlab.yml.example 6-8-stable:config/gitlab.yml.example ``` -* Make `/home/git/gitlab/config/gitlab.yml` same as https://github.com/gitlabhq/gitlabhq/blob/6-2-stable/config/gitlab.yml.example but with your settings. -* Make `/home/git/gitlab/config/unicorn.rb` same as https://github.com/gitlabhq/gitlabhq/blob/6-2-stable/config/unicorn.rb.example but with your settings. +* Make `/home/git/gitlab/config/gitlab.yml` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-8-stable/config/gitlab.yml.example but with your settings. +* Make `/home/git/gitlab/config/unicorn.rb` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-8-stable/config/unicorn.rb.example but with your settings. +* Make `/etc/nginx/sites-available/nginx` the same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-8-stable/lib/support/nginx/gitlab but with your settings. * Copy rack attack middleware config ```bash sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb ``` -* Uncomment `config.middleware.use Rack::Attack` in `/home/git/gitlab/config/application.rb` + * Set up logrotate ```bash @@ -91,9 +111,7 @@ sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab ### 7. Update Init script ```bash -sudo rm /etc/init.d/gitlab -sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlabhq/6-2-stable/lib/support/init.d/gitlab -sudo chmod +x /etc/init.d/gitlab +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab ``` ### 8. Start application @@ -126,3 +144,6 @@ Follow the [`upgrade guide from 5.4 to 6.0`](5.4-to-6.0.md), except for the data cd /home/git/gitlab sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production ``` + +## Login issues after upgrade? +If running in https mode, be sure to read [Can't Verify csrf token authenticity](https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide#cant-verify-csrf-token-authenticitycant-get-past-login-pageredirected-to-login-page) diff --git a/doc/update/6.1-to-6.2.md b/doc/update/6.1-to-6.2.md index 6f0514a861..c618e599dc 100644 --- a/doc/update/6.1-to-6.2.md +++ b/doc/update/6.1-to-6.2.md @@ -20,18 +20,27 @@ sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production ```bash cd /home/git/gitlab -sudo -u git -H git fetch -sudo -u git -H git checkout 6-2-stable +sudo -u git -H git fetch --all +sudo -u git -H git checkout 6-2-stable # Latest version of 6-2-stable addresses CVE-2013-4489 +# For GitLab Enterprise Edition: sudo -u git -H git checkout 6-2-stable-ee ``` -### 3. Install additional packages +### 3. Update gitlab-shell + +```bash +cd /home/git/gitlab-shell +sudo -u git -H git fetch +sudo -u git -H git checkout v1.7.9 # Addresses multiple critical security vulnerabilities +``` + +### 4. Install additional packages ```bash # Add support for lograte for better log file handling sudo apt-get install logrotate ``` -### 4. Install libs, migrations, etc. +### 5. Install libs, migrations, etc. ```bash cd /home/git/gitlab @@ -49,7 +58,7 @@ sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production ``` -### 5. Update config files +### 6. Update config files TIP: to see what changed in gitlab.yml.example in this release use next command: @@ -57,8 +66,8 @@ TIP: to see what changed in gitlab.yml.example in this release use next command: git diff 6-1-stable:config/gitlab.yml.example 6-2-stable:config/gitlab.yml.example ``` -* Make `/home/git/gitlab/config/gitlab.yml` same as https://github.com/gitlabhq/gitlabhq/blob/6-2-stable/config/gitlab.yml.example but with your settings. -* Make `/home/git/gitlab/config/unicorn.rb` same as https://github.com/gitlabhq/gitlabhq/blob/6-2-stable/config/unicorn.rb.example but with your settings. +* Make `/home/git/gitlab/config/gitlab.yml` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-2-stable/config/gitlab.yml.example but with your settings. +* Make `/home/git/gitlab/config/unicorn.rb` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-2-stable/config/unicorn.rb.example but with your settings. * Copy rack attack middleware config ```bash @@ -71,20 +80,20 @@ sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab ``` -### 6. Update Init script +### 7. Update Init script ```bash sudo rm /etc/init.d/gitlab -sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlabhq/6-2-stable/lib/support/init.d/gitlab +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab sudo chmod +x /etc/init.d/gitlab ``` -### 7. Start application +### 8. Start application sudo service gitlab start sudo service nginx restart -### 8. Check application status +### 9. Check application status Check if GitLab and its environment are configured correctly: diff --git a/doc/update/6.2-to-6.3.md b/doc/update/6.2-to-6.3.md new file mode 100644 index 0000000000..7f91604736 --- /dev/null +++ b/doc/update/6.2-to-6.3.md @@ -0,0 +1,109 @@ +# From 6.2 to 6.3 + +## Requires version: 6.1 or 6.2 + +### 0. Backup + +It's useful to make a backup just in case things go south: +(With MySQL, this may require granting "LOCK TABLES" privileges to the GitLab user on the database version) + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production +``` + +### 1. Stop server + + sudo service gitlab stop + +### 2. Get latest code + +```bash +cd /home/git/gitlab +sudo -u git -H git fetch --all +sudo -u git -H git checkout 6-3-stable +# For GitLab Enterprise Edition: sudo -u git -H git checkout 6-3-stable-ee +``` + +### 3. Update gitlab-shell (and its config) + +```bash +cd /home/git/gitlab-shell +sudo -u git -H git fetch +sudo -u git -H git checkout v1.7.9 # Addresses multiple critical security vulnerabilities +``` + +The Gitlab-shell config changed recently, so check for config file changes and make `/home/git/gitlab-shell/config.yml` the same as https://github.com/gitlabhq/gitlab-shell/blob/master/config.yml.example + +### 4. Install libs, migrations, etc. + +```bash +cd /home/git/gitlab + +# MySQL +sudo -u git -H bundle install --without development test postgres --deployment + +# PostgreSQL +sudo -u git -H bundle install --without development test mysql --deployment + + +# Run database migrations +sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production + +# Clean up assets and cache +sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production +``` + +### 5. Update config files + +TIP: to see what changed in gitlab.yml.example in this release use next command: + +``` +git diff 6-2-stable:config/gitlab.yml.example 6-3-stable:config/gitlab.yml.example +``` + +* Make `/home/git/gitlab/config/gitlab.yml` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-3-stable/config/gitlab.yml.example but with your settings. +* Make `/home/git/gitlab/config/unicorn.rb` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-3-stable/config/unicorn.rb.example but with your settings. + +```bash +# Copy rack attack middleware config +cd /home/git/gitlab +sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb +``` + +### 6. Update Init script + +```bash +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab +sudo chmod +x /etc/init.d/gitlab +``` + +### 7. Start application + + sudo service gitlab start + sudo service nginx restart + +### 8. Check application status + +Check if GitLab and its environment are configured correctly: + + sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production + +To make sure you didn't miss anything run a more thorough check with: + + sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production + +If all items are green, then congratulations upgrade complete! + +## Things went south? Revert to previous version (6.2) + +### 1. Revert the code to the previous version +Follow the [`upgrade guide from 6.1 to 6.2`](6.1-to-6.2.md), except for the database migration +(The backup is already migrated to the previous version) + +### 2. Restore from the backup: + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production +``` diff --git a/doc/update/6.3-to-6.4.md b/doc/update/6.3-to-6.4.md new file mode 100644 index 0000000000..cfe75a6f14 --- /dev/null +++ b/doc/update/6.3-to-6.4.md @@ -0,0 +1,89 @@ +# From 6.3 to 6.4 + +### 0. Backup + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production +``` + +### 1. Stop server + +```bash +sudo service gitlab stop +```` + +### 2. Get latest code + +```bash +cd /home/git/gitlab +sudo -u git -H git fetch --all +sudo -u git -H git checkout 6-4-stable +# For GitLab Enterprise Edition: sudo -u git -H git checkout 6-4-stable-ee +``` + +### 3. Update gitlab-shell (and its config) + +```bash +cd /home/git/gitlab-shell +sudo -u git -H git fetch +sudo -u git -H git checkout v1.8.0 +``` + +### 4. Install libs, migrations, etc. + +```bash +cd /home/git/gitlab + +# MySQL +sudo -u git -H bundle install --without development test postgres --deployment + +# PostgreSQL +sudo -u git -H bundle install --without development test mysql --deployment + + +# Run database migrations +sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production + +# Clean up assets and cache +sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production + +# Update init.d script +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab +``` + +### 5. Start application + +```bash +sudo service gitlab start +sudo service nginx restart +``` + +### 6. Check application status + +Check if GitLab and its environment are configured correctly: + +```bash +sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production +``` + +To make sure you didn't miss anything run a more thorough check with: + +```bash +sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production +``` + +If all items are green, then congratulations upgrade complete! + +## Things went south? Revert to previous version (6.3) + +### 1. Revert the code to the previous version +Follow the [`upgrade guide from 6.2 to 6.3`](6.2-to-6.3.md), except for the database migration +(The backup is already migrated to the previous version) + +### 2. Restore from the backup: + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production +``` diff --git a/doc/update/6.4-to-6.5.md b/doc/update/6.4-to-6.5.md new file mode 100644 index 0000000000..c88be3582c --- /dev/null +++ b/doc/update/6.4-to-6.5.md @@ -0,0 +1,94 @@ +# From 6.4 to 6.5 + +### 0. Backup + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production +``` + +### 1. Stop server + + sudo service gitlab stop + +### 2. Get latest code + +```bash +cd /home/git/gitlab +sudo -u git -H git fetch --all +``` + +For Gitlab Community Edition: + +```bash +sudo -u git -H git checkout 6-5-stable +``` + +OR + +For GitLab Enterprise Edition: + +```bash +sudo -u git -H git checkout 6-5-stable-ee +``` + +### 3. Update gitlab-shell (and its config) + +```bash +cd /home/git/gitlab-shell +sudo -u git -H git fetch +sudo -u git -H git checkout v1.8.0 +``` + +### 4. Install libs, migrations, etc. + +```bash +cd /home/git/gitlab + +# MySQL installations (note: the line below states '--without ... postgres') +sudo -u git -H bundle install --without development test postgres --deployment + +# PostgreSQL installations (note: the line below states '--without ... mysql') +sudo -u git -H bundle install --without development test mysql --deployment + + +# Run database migrations +sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production + +# Clean up assets and cache +sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production + +# Update init.d script +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab +``` + +### 5. Start application + + sudo service gitlab start + sudo service nginx restart + +### 6. Check application status + +Check if GitLab and its environment are configured correctly: + + sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production + +To make sure you didn't miss anything run a more thorough check with: + + sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production + +If all items are green, then congratulations upgrade is complete! + +## Things went south? Revert to previous version (6.4) + +### 1. Revert the code to the previous version +Follow the [`upgrade guide from 6.3 to 6.4`](6.3-to-6.4.md), except for the database migration +(The backup is already migrated to the previous version) + +### 2. Restore from the backup: + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production +``` +If you have more than one backup *.tar file(s) please add `BACKUP=timestamp_of_backup` to the command above. diff --git a/doc/update/6.5-to-6.6.md b/doc/update/6.5-to-6.6.md new file mode 100644 index 0000000000..589c18c27c --- /dev/null +++ b/doc/update/6.5-to-6.6.md @@ -0,0 +1,94 @@ +# From 6.5 to 6.6 + +### 0. Backup + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production +``` + +### 1. Stop server + + sudo service gitlab stop + +### 2. Get latest code + +```bash +cd /home/git/gitlab +sudo -u git -H git fetch --all +``` + +For Gitlab Community Edition: + +```bash +sudo -u git -H git checkout 6-6-stable +``` + +OR + +For GitLab Enterprise Edition: + +```bash +sudo -u git -H git checkout 6-6-stable-ee +``` + +### 3. Update gitlab-shell (and its config) + +```bash +cd /home/git/gitlab-shell +sudo -u git -H git fetch +sudo -u git -H git checkout v1.8.0 +``` + +### 4. Install libs, migrations, etc. + +```bash +cd /home/git/gitlab + +# MySQL installations (note: the line below states '--without ... postgres') +sudo -u git -H bundle install --without development test postgres --deployment + +# PostgreSQL installations (note: the line below states '--without ... mysql') +sudo -u git -H bundle install --without development test mysql --deployment + + +# Run database migrations +sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production + +# Clean up assets and cache +sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production + +# Update init.d script +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab +``` + +### 5. Start application + + sudo service gitlab start + sudo service nginx restart + +### 6. Check application status + +Check if GitLab and its environment are configured correctly: + + sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production + +To make sure you didn't miss anything run a more thorough check with: + + sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production + +If all items are green, then congratulations upgrade is complete! + +## Things went south? Revert to previous version (6.5) + +### 1. Revert the code to the previous version +Follow the [`upgrade guide from 6.4 to 6.5`](6.4-to-6.5.md), except for the database migration +(The backup is already migrated to the previous version) + +### 2. Restore from the backup: + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production +``` +If you have more than one backup *.tar file(s) please add `BACKUP=timestamp_of_backup` to the command above. diff --git a/doc/update/6.6-to-6.7.md b/doc/update/6.6-to-6.7.md new file mode 100644 index 0000000000..0f39c037c9 --- /dev/null +++ b/doc/update/6.6-to-6.7.md @@ -0,0 +1,101 @@ +# From 6.6 to 6.7 + +### 0. Backup + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production +``` + +### 1. Stop server + + sudo service gitlab stop + +### 2. Get latest code + +```bash +cd /home/git/gitlab +sudo -u git -H git fetch --all +``` + +For Gitlab Community Edition: + +```bash +sudo -u git -H git checkout 6-7-stable +``` + +OR + +For GitLab Enterprise Edition: + +```bash +sudo -u git -H git checkout 6-7-stable-ee +``` + +### 3. Update gitlab-shell (and its config) + +```bash +cd /home/git/gitlab-shell +sudo -u git -H git fetch +sudo -u git -H git checkout v1.9.1 +``` + +### 4. Install libs, migrations, etc. + +```bash +cd /home/git/gitlab + +# MySQL installations (note: the line below states '--without ... postgres') +sudo -u git -H bundle install --without development test postgres --deployment + +# PostgreSQL installations (note: the line below states '--without ... mysql') +sudo -u git -H bundle install --without development test mysql --deployment + + +# Run database migrations +sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production + +# Clean up assets and cache +sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production + +# Update init.d script +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab + +# Update the logrotate configuration (keep logs for 90 days instead of 52 weeks) +sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab + +# Close access to gitlab-satellites for others +sudo chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites +``` + + +### 5. Start application + + sudo service gitlab start + sudo service nginx restart + +### 6. Check application status + +Check if GitLab and its environment are configured correctly: + + sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production + +To make sure you didn't miss anything run a more thorough check with: + + sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production + +If all items are green, then congratulations upgrade is complete! + +## Things went south? Revert to previous version (6.6) + +### 1. Revert the code to the previous version +Follow the [`upgrade guide from 6.5 to 6.6`](6.5-to-6.6.md), except for the database migration +(The backup is already migrated to the previous version) + +### 2. Restore from the backup: + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production +``` +If you have more than one backup *.tar file(s) please add `BACKUP=timestamp_of_backup` to the command above. diff --git a/doc/update/6.7-to-6.8.md b/doc/update/6.7-to-6.8.md new file mode 100644 index 0000000000..457433c648 --- /dev/null +++ b/doc/update/6.7-to-6.8.md @@ -0,0 +1,125 @@ +# From 6.7 to 6.8 + +### 0. Backup + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production +``` + +### 1. Stop server + +```bash +sudo service gitlab stop +``` + +### 2. Get latest code + +```bash +cd /home/git/gitlab +sudo -u git -H git fetch --all +``` + +For Gitlab Community Edition: + +```bash +sudo -u git -H git checkout 6-8-stable +``` + +OR + +For GitLab Enterprise Edition: + +```bash +sudo -u git -H git checkout 6-8-stable-ee +``` + +### 3. Update gitlab-shell (and its config) + +```bash +cd /home/git/gitlab-shell +sudo -u git -H git fetch +sudo -u git -H git checkout v1.9.3 +``` + +### 4. Install libs, migrations, etc. + +```bash +cd /home/git/gitlab + +# MySQL installations (note: the line below states '--without ... postgres') +sudo -u git -H bundle install --without development test postgres --deployment + +# PostgreSQL installations (note: the line below states '--without ... mysql') +sudo -u git -H bundle install --without development test mysql --deployment + + +# Run database migrations +sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production + +# Clean up assets and cache +sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production + +# Update init.d script +sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab +sudo chmod +x /etc/init.d/gitlab + +# Update the logrotate configuration (keep logs for 90 days instead of 52 weeks) +sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab + +# Close access to gitlab-satellites for others +sudo chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites +``` + +### 5. Update config files + +#### New configuration options for gitlab.yml + +There are new configuration options available for gitlab.yml. View them with the command below and apply them to your current gitlab.yml if desired. + +``` +git diff 6-7-stable:config/gitlab.yml.example 6-8-stable:config/gitlab.yml.example +``` + +#### MySQL? Remove reaping frequency + +If you are using MySQL as a database, remove `reaping_frequency` from you database.yml to prevent crashes. [Relevant commit](https://gitlab.com/gitlab-org/gitlab-ce/commit/5163a8fcb9cfd63435560fda00173b76df2ccc93). + +#### HTTPS? Disable gzip + +If you are using HTTPS, disable gzip as in [this commit](https://gitlab.com/gitlab-org/gitlab-ce/commit/563fec734912d81cd7caea6fa8ec2b397fb72a9b) to prevent BREACH attacks. + +#### Turn on asset compression + +To improve performance, enable gzip asset compression as seen [in this commit](https://gitlab.com/gitlab-org/gitlab-ce/commit/8af94ed75505f0253823b9b2d44320fecea5b5fb). + +### 6. Start application + + sudo service gitlab start + sudo service nginx restart + +### 7. Check application status + +Check if GitLab and its environment are configured correctly: + + sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production + +To make sure you didn't miss anything run a more thorough check with: + + sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production + +If all items are green, then congratulations upgrade is complete! + +## Things went south? Revert to previous version (6.7) + +### 1. Revert the code to the previous version +Follow the [`upgrade guide from 6.6 to 6.7`](6.6-to-6.7.md), except for the database migration +(The backup is already migrated to the previous version) + +### 2. Restore from the backup: + +```bash +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production +``` +If you have more than one backup *.tar file(s) please add `BACKUP=timestamp_of_backup` to the command above. diff --git a/doc/update/README.md b/doc/update/README.md new file mode 100644 index 0000000000..9ce48a019e --- /dev/null +++ b/doc/update/README.md @@ -0,0 +1,5 @@ ++ [The individual upgrade guides](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/update) ++ [Upgrader](upgrader.md) ++ [Ruby](ruby.md) ++ [Patch versions](patch_versions.md) ++ [MySQL to PostgreSQL](mysql_to_postgresql.md) diff --git a/doc/update/mysql_to_postgresql.md b/doc/update/mysql_to_postgresql.md new file mode 100644 index 0000000000..5b9209d7df --- /dev/null +++ b/doc/update/mysql_to_postgresql.md @@ -0,0 +1,68 @@ +# Migrating GitLab from MySQL to Postgres + +If you are replacing MySQL with Postgres while keeping GitLab on the same +server all you need to do is to export from MySQL and import into Postgres as +described below. If you are also moving GitLab to another server, or if you are +switching to omnibus-gitlab, you may want to use a GitLab backup file. The +second part of this documents explains the procedure to do this. + +## Export from MySQL and import into Postgres + +Use this if you are keeping GitLab on the same server. + +``` +sudo service gitlab stop + +# Update /home/git/gitlab/config/database.yml + +git clone https://github.com/lanyrd/mysql-postgresql-converter.git +cd mysql-postgresql-converter +mysqldump --compatible=postgresql --default-character-set=utf8 -r databasename.mysql -u root gitlabhq_production +python db_converter.py databasename.mysql databasename.psql +psql -f databasename.psql -d gitlabhq_production + +sudo service gitlab start +``` + +## Converting a GitLab backup file from MySQL to Postgres + +GitLab backup files (_gitlab_backup.tar) contain a SQL dump. Using +the lanyrd database converter we can replace a MySQL database dump inside the +tar file with a Postgres database dump. This can be useful if you are moving to +another server. + +``` +# Stop GitLab +sudo service gitlab stop + +# Create the backup +cd /home/git/gitlab +sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production + +# Note the filename of the backup that was created. We will call it +# TIMESTAMP_gitlab_backup.tar below. + +# Move the backup file we will convert to its own directory +sudo -u git -H mkdir -p tmp/backups/postgresql +sudo -u git -H mv tmp/backups/TIMESTAMP_gitlab_backup.tar tmp/backups/postgresql/ + +# Create a separate database dump with PostgreSQL compatibility +cd tmp/backups/postgresql +sudo -u git -H mysqldump --compatible=postgresql --default-character-set=utf8 -r gitlabhq_production.mysql -u root gitlabhq_production + +# Clone the database converter +sudo -u git -H git clone https://github.com/lanyrd/mysql-postgresql-converter.git + +# Convert gitlabhq_production.mysql +sudo -u git -H mkdir db +sudo -u git -H python mysql-postgresql-converter/db_converter.py gitlabhq_production.mysql db/database.sql + +# Replace the MySQL dump in TIMESTAMP_gitlab_backup.tar. + +# Warning: if you forget to replace TIMESTAMP below, tar will create a new file +# 'TIMESTAMP_gitlab_backup.tar' without giving an error. + +sudo -u git -H tar rf TIMESTAMP_gitlab_backup.tar db/database.sql + +# Done! TIMESTAMP_gitlab_backup.tar can now be restored into a Postgres GitLab installation. +``` diff --git a/doc/update/patch_versions.md b/doc/update/patch_versions.md index 797fc81c92..2b947adaa1 100644 --- a/doc/update/patch_versions.md +++ b/doc/update/patch_versions.md @@ -1,4 +1,4 @@ -# Universal update guide for patch versions. Ex. from From 6.2.0 to 6.2.1 +# Universal update guide for patch versions. For example from 6.2.0 to 6.2.1, also see the [semantic versioning specification](http://semver.org/). ### 0. Backup @@ -14,36 +14,49 @@ sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production sudo service gitlab stop -### 2. Get latest code for your current stable branch +### 2. Get latest code for the stable branch ```bash cd /home/git/gitlab -sudo -u git -H git pull origin 6-2-stable +sudo -u git -H git fetch --all +sudo -u git -H git checkout LATEST_TAG ``` -### 3. Install libs, migrations, etc. +Replace LATEST_TAG with the latest GitLab tag you want to upgrade to, for example `v6.6.3`. + +### 3. Update gitlab-shell if it is not the latest version + +```bash +cd /home/git/gitlab-shell +sudo -u git -H git fetch +sudo -u git -H git checkout LATEST_TAG +``` + +Replace LATEST_TAG with the latest GitLab Shell tag you want to upgrade to, for example `v1.7.9`. + +### 4. Install libs, migrations, etc. ```bash cd /home/git/gitlab -# MySQL -sudo -u git -H bundle install --without development test postgres --deployment - #PostgreSQL sudo -u git -H bundle install --without development test mysql --deployment +# MySQL +sudo -u git -H bundle install --without development test postgres --deployment + sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production sudo -u git -H bundle exec rake assets:clean RAILS_ENV=production sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production ``` -### 4. Start application +### 5. Start application sudo service gitlab start sudo service nginx restart -### 5. Check application status +### 6. Check application status Check if GitLab and its environment are configured correctly: diff --git a/doc/update/ruby.md b/doc/update/ruby.md new file mode 100644 index 0000000000..e98167f6b6 --- /dev/null +++ b/doc/update/ruby.md @@ -0,0 +1,54 @@ +# Updating Ruby from source + +This guide explains how to update Ruby in case you installed it from source according to the [instructions](../install/installation.md#2-ruby). + +### 1. Look for Ruby versions +This guide will only update `/usr/local/bin/ruby`. You can see which Ruby binaries are installed on your system by running: + +```bash +ls -l $(which -a ruby) +``` + +### 2. Stop GitLab + +```bash +sudo service gitlab stop +``` + +### 3. Install or update dependencies +Here we are assuming you are using Debian/Ubuntu. + +```bash +sudo apt-get install build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl +``` + +### 4. Download, compile and install Ruby +Find the latest stable version of Ruby 1.9 or 2.0 at https://www.ruby-lang.org/en/downloads/ . We recommend at least 2.0.0-p353, which is patched against [CVE-2013-4164](https://www.ruby-lang.org/en/news/2013/11/22/heap-overflow-in-floating-point-parsing-cve-2013-4164/). + +```bash +cd /tmp +curl --progress http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz +cd ruby-2.0.0-p353 +./configure --disable-install-rdoc +make +sudo make install # overwrite the existing Ruby in /usr/local/bin +sudo gem install bundler +``` + +### 5. Reinstall GitLab gem bundle +Just to be sure we will reinstall the gems used by GitLab. Note that the `bundle install` command [depends on your choice of database](../install/installation.md#install-gems). + +```bash +cd /home/git/gitlab +sudo -u git -H rm -rf vendor/bundle # remove existing Gem bundle +sudo -u git -H bundle install --deployment --without development test mysql aws # Assuming PostgreSQL +``` + +### 6. Start GitLab +We are now ready to restart GitLab. + +```bash +sudo service gitlab start +``` + +### Done diff --git a/doc/update/upgrader.md b/doc/update/upgrader.md new file mode 100644 index 0000000000..72a94f67b3 --- /dev/null +++ b/doc/update/upgrader.md @@ -0,0 +1,53 @@ +# GitLab Upgrader + +GitLab Upgrader - a ruby script that allows you easily upgrade GitLab to latest minor version. +For example it can update your application from 6.4 to latest GitLab 6 version (like 6.6.1). +You still need to create a a backup and manually restart GitLab after runnning the script but all other operations are done by this upgrade script. +If you have local changes to your GitLab repository the script will stash them and you need to use `git stash pop` after running the script. + +__GitLab Upgrader is available only for GitLab version 6.4.2 or higher__ + +### 0. Backup + + cd /home/git/gitlab + sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production + +### 1. Stop server + + sudo service gitlab stop + +### 2. Run gitlab upgrade tool + + cd /home/git/gitlab + sudo -u git -H ruby script/upgrade.rb + + # to perform a non-interactive install (no user input required) you can add -y + # sudo -u git -H ruby script/upgrade.rb -y + +### 3. Start application + + sudo service gitlab start + sudo service nginx restart + +### 4. Check application status + +Check if GitLab and its environment are configured correctly: + + sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production + +To make sure you didn't miss anything run a more thorough check with: + + sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production + +If all items are green, then congratulations upgrade is complete! + + +### One line upgrade command + +You've read through the entire guide, and probably did all the steps manually. Here is a one liner for convenience, the next time you upgrade: + +```bash +cd /home/git/gitlab; sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production; \ + sudo service gitlab stop; sudo -u git -H ruby script/upgrade.rb -y; sudo service gitlab start; \ + sudo service nginx restart; sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production +``` diff --git a/doc/web_hooks/web_hooks.md b/doc/web_hooks/web_hooks.md new file mode 100644 index 0000000000..a223d83da3 --- /dev/null +++ b/doc/web_hooks/web_hooks.md @@ -0,0 +1,145 @@ +Project web hooks allow you to trigger an URL if new code is pushed or a new issue is created. + +--- + +You can configure web hooks to listen for specific events like pushes, issues or merge requests. +GitLab will send a POST request with data to the web hook URL. +Web hooks can be used to update an external issue tracker, trigger CI builds, update a backup mirror, or even deploy to your production server. +If you send a web hook to an SSL endpoint [the certificate will not be verified](https://gitlab.com/gitlab-org/gitlab-ce/blob/ccd617e58ea71c42b6b073e692447d0fe3c00be6/app/models/web_hook.rb#L35) since many people use self-signed certificates. + +--- + +#### Push events + +Triggered when you push to the repository except when pushing tags. + +**Request body:** + +```json +{ + "before": "95790bf891e76fee5e1747ab589903a6a1f80f22", + "after": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", + "ref": "refs/heads/master", + "user_id": 4, + "user_name": "John Smith", + "project_id": 15, + "repository": { + "name": "Diaspora", + "url": "git@localhost:diaspora.git", + "description": "", + "homepage": "http://localhost/diaspora" + }, + "commits": [ + { + "id": "b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327", + "message": "Update Catalan translation to e38cb41.", + "timestamp": "2011-12-12T14:27:31+02:00", + "url": "http://localhost/diaspora/commits/b6568db1bc1dcd7f8b4d5a946b0b91f9dacd7327", + "author": { + "name": "Jordi Mallach", + "email": "jordi@softcatala.org" + } + }, + { + "id": "da1560886d4f094c3e6c9ef40349f7d38b5d27d7", + "message": "fixed readme", + "timestamp": "2012-01-03T23:36:29+02:00", + "url": "http://localhost/diaspora/commits/da1560886d4f094c3e6c9ef40349f7d38b5d27d7", + "author": { + "name": "GitLab dev user", + "email": "gitlabdev@dv6700.(none)" + } + } + ], + "total_commits_count": 4 +} +``` + +#### Issues events + +Triggered when a new issue is created or an existing issue was updated/closed/reopened. + +**Request body:** + +```json +{ + "object_kind": "issue", + "object_attributes": { + "id": 301, + "title": "New API: create/update/delete file", + "assignee_id": 51, + "author_id": 51, + "project_id": 14, + "created_at": "2013-12-03T17:15:43Z", + "updated_at": "2013-12-03T17:15:43Z", + "position": 0, + "branch_name": null, + "description": "Create new API for manipulations with repository", + "milestone_id": null, + "state": "opened", + "iid": 23 + } +} +``` + +#### Merge request events + +Triggered when a new merge request is created or an existing merge request was updated/merged/closed. + +**Request body:** + +```json +{ + "object_kind": "merge_request", + "object_attributes": { + "id": 99, + "target_branch": "master", + "source_branch": "ms-viewport", + "source_project_id": 14, + "author_id": 51, + "assignee_id": 6, + "title": "MS-Viewport", + "created_at": "2013-12-03T17:23:34Z", + "updated_at": "2013-12-03T17:23:34Z", + "st_commits": null, + "st_diffs": null, + "milestone_id": null, + "state": "opened", + "merge_status": "unchecked", + "target_project_id": 14, + "iid": 1, + "description": "" + } +} +``` + +#### Example webhook receiver + +If you want to see GitLab's webhooks in action for testing purposes you can use +a simple echo script running in a console session. + +Save the following file as `print_http_body.rb`. + +```ruby +require 'webrick' + +server = WEBrick::HTTPServer.new(Port: ARGV.first) +server.mount_proc '/' do |req, res| + puts req.body +end + +trap 'INT' do server.shutdown end +server.start +``` + +Pick an unused port (e.g. 8000) and start the script: `ruby print_http_body.rb +8000`. Then add your server as a webhook receiver in GitLab as +`http://my.host:8000/`. + +When you press 'Test Hook' in GitLab, you should see something like this in the console. + +``` +{"before":"077a85dd266e6f3573ef7e9ef8ce3343ad659c4e","after":"95cd4a99e93bc4bbabacfa2cd10e6725b1403c60",} +localhost - - [14/May/2014:07:45:26 EDT] "POST / HTTP/1.1" 200 0 +- -> / +``` diff --git a/doc/workflow/README.md b/doc/workflow/README.md new file mode 100644 index 0000000000..efc28d06e7 --- /dev/null +++ b/doc/workflow/README.md @@ -0,0 +1,2 @@ ++ [Workflow](workflow/workflow.md) ++ [Project Features](workflow/project_features.md) diff --git a/doc/workflow/authorization_for_merge_requests.md b/doc/workflow/authorization_for_merge_requests.md new file mode 100644 index 0000000000..4e07d7c04c --- /dev/null +++ b/doc/workflow/authorization_for_merge_requests.md @@ -0,0 +1,32 @@ +There are two main ways to have a merge request flow with GitLab: working with protected branches in a single repository, or working with forks of an authoritative project. + +## Protected branch flow + +With the protected branch flow everybody works within the same GitLab project. +The project maintainers get Master access and the regular developers get Developer access. +The maintainers mark the authoritative branches as 'Protected'. +The developers push feature branches to the project and create merge requests to have their feature branches reviewed and merged into one of the protected branches. +Only users with Master access can merge changes into a protected branch. + +### Advantages + +- fewer projects means less clutter +- developers need to consider only one remote repository + +### Disadvantages + +- manual setup of protected branch required for each new project + +## Forking workflow + +With the forking workflow the maintainers get Master access and the regular developers get Reporter access to the authoritative repository, which prohibits them from pushing any changes to it. +Developers create forks of the authoritative project and push their feature branches to their own forks. +To get their changes into master they need to create a merge request across forks. + +### Advantages + +- in an appropriately configured GitLab group, new projects automatically get the required access restrictions for regular developers: fewer manual steps to configure authorization for new projects + +### Disadvantages + +- the project need to keep their forks up to date, which requires more advanced Git skills (managing multiple remotes) diff --git a/doc/workflow/project_features.md b/doc/workflow/project_features.md new file mode 100644 index 0000000000..25fe403257 --- /dev/null +++ b/doc/workflow/project_features.md @@ -0,0 +1,35 @@ +When in a Project -> Settings, you will find Features on the bottom of the page that you can toggle. +Below you will find a more elaborate explanation of each of these. + + +## Issues + +Issues is a really powerful, but lightweight issue tracking system. +You can make tickets, assign them to people, file them under milestones, order them with labels and have discussion in them. +They integrate deeply into GitLab and are easily referenced from anywhere by using # and the issuenumber. +At GitLab.com, we use this for all our project management needs. + +## Merge Requests + +Using a merge request, you can review and discuss code before it is merged in the branch of your code. +As with issues, it can be assigned; people, issues, etc. can be refereced; milestones attached. +We see it as an integral part of working together on code and couldn't work without it. + + +## Wiki + +This is a separate system for documentation, built right into GitLab. +It is source controlled and is very convenient if you don't want to keep you documentation in your source code, but you do want to keep it in your GitLab project. + + +## Wall + +For simple, project specific conversations, the wall can be used. +It's very lightweight and simple and works well if you're not interested in using issues, but still want to occasionally communicate within a project. + + +## Snippets + +Snippets are little bits of code or text. +This is a nice place to put code or text that is used semi-regularly within the project, but does not belong in source control. +For example, a specific config file that is used by > the team that is only valid for the people that work on the code. diff --git a/doc/workflow/workflow.md b/doc/workflow/workflow.md new file mode 100644 index 0000000000..bb232e9d5c --- /dev/null +++ b/doc/workflow/workflow.md @@ -0,0 +1,27 @@ +1. Clone project + + ```bash + git clone git@example.com:project-name.git + ``` + +2. Create branch with your feature + + ```bash + git checkout -b $feature_name + ``` + +3. Write code. Commit changes + + ```bash + git commit -am "My feature is ready" + ``` + +4. Push your branch to GitLab + + ```bash + git push origin $feature_name + ``` + +5. Review your code on commits page +6. Create a merge request +7. Your team lead will review the code & merge it to the main branch diff --git a/features/admin/active_tab.feature b/features/admin/active_tab.feature index 226d3d5d5b..15fcda45e4 100644 --- a/features/admin/active_tab.feature +++ b/features/admin/active_tab.feature @@ -27,6 +27,11 @@ Feature: Admin active tab Then the active main tab should be Logs And no other main tabs should be active + Scenario: On Admin Messages + Given I visit admin messages page + Then the active main tab should be Messages + 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 diff --git a/features/admin/broadcast_messages.feature b/features/admin/broadcast_messages.feature new file mode 100644 index 0000000000..5f16120b7c --- /dev/null +++ b/features/admin/broadcast_messages.feature @@ -0,0 +1,20 @@ +Feature: Admin Broadcast Messages + Background: + Given I sign in as an admin + And application already has admin messages + And I visit admin messages page + + Scenario: See broadcast messages list + Then I should be all broadcast messages + + Scenario: Create a broadcast message + When submit form with new broadcast message + Then I should be redirected to admin messages page + And I should see newly created broadcast message + + Scenario: Create a customized broadcast message + When submit form with new customized broadcast message + Then I should be redirected to admin messages page + And I should see newly created broadcast message + Then I visit dashboard page + And I should see a customized broadcast message diff --git a/features/admin/groups.feature b/features/admin/groups.feature index 6fed9a3486..352c1b3803 100644 --- a/features/admin/groups.feature +++ b/features/admin/groups.feature @@ -2,7 +2,7 @@ Feature: Admin Groups Background: Given I sign in as an admin And I have group with projects - And Create gitlab user "John" + And User "John Doe" exists And I visit admin groups page Scenario: See group list @@ -17,5 +17,5 @@ Feature: Admin Groups @javascript Scenario: Add user into projects in group When I visit admin group page - When I select user "John" from user list as "Reporter" - Then I should see "John" in team list in every project as "Reporter" + When I select user "John Doe" from user list as "Reporter" + Then I should see "John Doe" in team list in every project as "Reporter" diff --git a/features/admin/users.feature b/features/admin/users.feature index 7f503cf923..ce9f32f50d 100644 --- a/features/admin/users.feature +++ b/features/admin/users.feature @@ -14,3 +14,9 @@ Feature: Admin Users And Click save Then See username error message And Not changed form action url + + Scenario: Edit my user attributes + Given I visit admin users page + And click edit on my user + When I submit modified user + Then I see user attributes changed diff --git a/features/dashboard/archived_projects.feature b/features/dashboard/archived_projects.feature new file mode 100644 index 0000000000..399c9b53d8 --- /dev/null +++ b/features/dashboard/archived_projects.feature @@ -0,0 +1,16 @@ +Feature: Dashboard with archived projects + Background: + Given I sign in as a user + And I own project "Shop" + And I own project "Forum" + And project "Forum" is archived + And I visit dashboard page + + Scenario: I should see non-archived projects on dashboard + Then I should see "Shop" project link + And I should not see "Forum" project link + + Scenario: I should see all projects on projects page + And I visit dashboard projects page + Then I should see "Shop" project link + And I should see "Forum" project link diff --git a/features/dashboard/help.feature b/features/dashboard/help.feature new file mode 100644 index 0000000000..02ec688f80 --- /dev/null +++ b/features/dashboard/help.feature @@ -0,0 +1,8 @@ +Feature: Help + Background: + Given I sign in as a user + And I visit the "Rake Tasks" help page + + Scenario: The markdown should be rendered correctly + Then I should see "Rake Tasks" page markdown rendered + And Header "Rebuild project satellites" should have correct ids and links diff --git a/features/dashboard/issues.feature b/features/dashboard/issues.feature index 895b89aa38..d316b2d920 100644 --- a/features/dashboard/issues.feature +++ b/features/dashboard/issues.feature @@ -1,8 +1,18 @@ Feature: Dashboard Issues Background: Given I sign in as a user + And I have authored issues And I have assigned issues + And I have other issues And I visit dashboard issues page - Scenario: I should see issues list + Scenario: I should see assigned issues Then I should see issues assigned to me + + Scenario: I should see authored issues + When I click "Authored by me" link + Then I should see issues authored by me + + Scenario: I should see all issues + When I click "All" link + Then I should see all issues diff --git a/features/dashboard/merge_requests.feature b/features/dashboard/merge_requests.feature index cad65b0d79..de56030073 100644 --- a/features/dashboard/merge_requests.feature +++ b/features/dashboard/merge_requests.feature @@ -2,7 +2,17 @@ Feature: Dashboard Merge Requests Background: Given I sign in as a user And I have authored merge requests + And I have assigned merge requests + And I have other merge requests And I visit dashboard merge requests page - Scenario: I should see projects list - Then I should see my merge requests + Scenario: I should see assigned merge_requests + Then I should see merge requests assigned to me + + Scenario: I should see authored merge_requests + When I click "Authored by me" link + Then I should see merge requests authored by me + + Scenario: I should see all merge_requests + When I click "All" link + Then I should see all merge requests diff --git a/features/group.feature b/features/group.feature new file mode 100644 index 0000000000..4e11bcba93 --- /dev/null +++ b/features/group.feature @@ -0,0 +1,115 @@ +Feature: Groups + Background: + Given I sign in as "John Doe" + And "John Doe" is owner of group "Owned" + And "John Doe" is guest of group "Guest" + + @javascript + Scenario: I should see group "Owned" dashboard list + When I visit group "Owned" page + Then I should see group "Owned" projects list + And I should see projects activity feed + + Scenario: Create a group from dasboard + When I visit group "Owned" page + And I visit dashboard page + And I click new group link + And submit form with new group "Samurai" info + Then I should be redirected to group "Samurai" page + And I should see newly created group "Samurai" + + Scenario: I should see group "Owned" issues list + Given project from group "Owned" has issues assigned to me + When I visit group "Owned" issues page + Then I should see issues from group "Owned" assigned to me + + Scenario: I should see group "Owned" merge requests list + Given project from group "Owned" has merge requests assigned to me + When I visit group "Owned" merge requests page + Then I should see merge requests from group "Owned" assigned to me + + @javascript + Scenario: I should add user to projects in group "Owned" + Given User "Mary Jane" exists + When I visit group "Owned" members page + And I select user "Mary Jane" from list with role "Reporter" + Then I should see user "Mary Jane" in team list + + Scenario: I should see edit group "Owned" page + When I visit group "Owned" settings page + And I change group "Owned" name to "new-name" + Then I should see new group "Owned" name + + Scenario: I edit group "Owned" avatar + When I visit group "Owned" settings page + And I change group "Owned" avatar + And I visit group "Owned" settings page + Then I should see new group "Owned" avatar + And I should see the "Remove avatar" button + + Scenario: I remove group "Owned" avatar + When I visit group "Owned" settings page + And I have group "Owned" avatar + And I visit group "Owned" settings page + And I remove group "Owned" avatar + Then I should not see group "Owned" avatar + And I should not see the "Remove avatar" button + + # Leave + + @javascript + Scenario: Owner should be able to remove himself from group if he is not the last owner + Given "Mary Jane" is owner of group "Owned" + When I visit group "Owned" members page + Then I should see user "John Doe" in team list + Then I should see user "Mary Jane" in team list + When I click on the "Remove User From Group" button for "John Doe" + And I visit group "Owned" members page + Then I should not see user "John Doe" in team list + Then I should see user "Mary Jane" in team list + + @javascript + Scenario: Owner should not be able to remove himself from group if he is the last owner + Given "Mary Jane" is guest of group "Owned" + When I visit group "Owned" members page + Then I should see user "John Doe" in team list + Then I should see user "Mary Jane" in team list + Then I should not see the "Remove User From Group" button for "John Doe" + + @javascript + Scenario: Guest should be able to remove himself from group + Given "Mary Jane" is guest of group "Guest" + When I visit group "Guest" members page + Then I should see user "John Doe" in team list + Then I should see user "Mary Jane" in team list + When I click on the "Remove User From Group" button for "John Doe" + When I visit group "Guest" members page + Then I should not see user "John Doe" in team list + Then I should see user "Mary Jane" in team list + + @javascript + Scenario: Guest should be able to remove himself from group even if he is the only user in the group + When I visit group "Guest" members page + Then I should see user "John Doe" in team list + When I click on the "Remove User From Group" button for "John Doe" + When I visit group "Guest" members page + Then I should not see user "John Doe" in team list + + # Remove others + + Scenario: Owner should be able to remove other users from group + Given "Mary Jane" is owner of group "Owned" + When I visit group "Owned" members page + Then I should see user "John Doe" in team list + Then I should see user "Mary Jane" in team list + When I click on the "Remove User From Group" button for "Mary Jane" + When I visit group "Owned" members page + Then I should see user "John Doe" in team list + Then I should not see user "Mary Jane" in team list + + Scenario: Guest should not be able to remove other users from group + Given "Mary Jane" is guest of group "Guest" + When I visit group "Guest" members page + Then I should see user "John Doe" in team list + Then I should see user "Mary Jane" in team list + Then I should not see the "Remove User From Group" button for "Mary Jane" diff --git a/features/group/create_group.feature b/features/group/create_group.feature deleted file mode 100644 index b77f3599e6..0000000000 --- a/features/group/create_group.feature +++ /dev/null @@ -1,11 +0,0 @@ -Feature: Groups - Background: - Given I sign in as a user - - Scenario: Create a group from dasboard - Given I have group with projects - And I visit dashboard page - When I click new group link - And submit form with new group info - Then I should be redirected to group page - And I should see newly created group diff --git a/features/group/group.feature b/features/group/group.feature deleted file mode 100644 index 9fec19a4dc..0000000000 --- a/features/group/group.feature +++ /dev/null @@ -1,33 +0,0 @@ -Feature: Groups - Background: - Given I sign in as a user - And I have group with projects - - @javascript - 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 - - Scenario: I should see group issues list - Given project from group has issues assigned to me - When I visit group issues page - Then I should see issues from this group assigned to me - - Scenario: I should see group merge requests list - Given project from group has merge requests assigned to me - When I visit group merge requests page - Then I should see merge requests from this group assigned to me - - @javascript - Scenario: I should add user to projects in Group - Given I have new user "John" - When I visit group members page - And I select user "John" from list with role "Reporter" - Then I should see user "John" in team list - - Scenario: I should see edit group page - When I visit group settings page - And I change group name - Then I should see new group name - diff --git a/features/profile/emails.feature b/features/profile/emails.feature new file mode 100644 index 0000000000..148fc76608 --- /dev/null +++ b/features/profile/emails.feature @@ -0,0 +1,25 @@ +Feature: Profile Emails + Background: + Given I sign in as a user + And I visit profile emails page + + Scenario: I should see emails + Then I should see my emails + + Scenario: Add new email + Given I submit new email "my@email.com" + Then I should see new email "my@email.com" + And I should see my emails + + Scenario: Add duplicate email + Given I submit duplicate email @user.email + Then I should not have @user.email added + And I should see my emails + + Scenario: Remove email + Given I submit new email "my@email.com" + Then I should see new email "my@email.com" + And I should see my emails + Then I click link "Remove" for "my@email.com" + Then I should not see email "my@email.com" + And I should see my emails diff --git a/features/profile/group.feature b/features/profile/group.feature new file mode 100644 index 0000000000..70b682e291 --- /dev/null +++ b/features/profile/group.feature @@ -0,0 +1,47 @@ +Feature: Profile Group + Background: + Given I sign in as "John Doe" + And "John Doe" is owner of group "Owned" + And "John Doe" is guest of group "Guest" + + # Leave groups + + @javascript + Scenario: Owner should be able to leave from group if he is not the last owner + Given "Mary Jane" is owner of group "Owned" + When I visit profile groups page + Then I should see group "Owned" in group list + Then I should see group "Guest" in group list + When I click on the "Leave" button for group "Owned" + And I visit profile groups page + Then I should not see group "Owned" in group list + Then I should see group "Guest" in group list + + @javascript + Scenario: Owner should not be able to leave from group if he is the last owner + Given "Mary Jane" is guest of group "Owned" + When I visit profile groups page + Then I should see group "Owned" in group list + Then I should see group "Guest" in group list + Then I should not see the "Leave" button for group "Owned" + + @javascript + Scenario: Guest should be able to leave from group + Given "Mary Jane" is guest of group "Guest" + When I visit profile groups page + Then I should see group "Owned" in group list + Then I should see group "Guest" in group list + When I click on the "Leave" button for group "Guest" + When I visit profile groups page + Then I should see group "Owned" in group list + Then I should not see group "Guest" in group list + + @javascript + Scenario: Guest should be able to leave from group even if he is the only user in the group + When I visit profile groups page + Then I should see group "Owned" in group list + Then I should see group "Guest" in group list + When I click on the "Leave" button for group "Guest" + When I visit profile groups page + Then I should see group "Owned" in group list + Then I should not see group "Guest" in group list diff --git a/features/profile/profile.feature b/features/profile/profile.feature index 6198fd2b30..44bb190f62 100644 --- a/features/profile/profile.feature +++ b/features/profile/profile.feature @@ -6,10 +6,17 @@ Feature: Profile Given I visit profile page Then I should see my profile info + Scenario: I can see groups I belong to + Given I have group with projects + When I visit profile page + And I click on my profile picture + Then I should see my user page + And I should see groups I belong to + Scenario: I edit profile Given I visit profile page - Then I change my contact info - And I should see new contact info + Then I change my profile info + And I should see new profile info Scenario: I change my password without old one Given I visit profile password page @@ -26,6 +33,14 @@ Feature: Profile Given I visit profile page Then I change my avatar And I should see new avatar + And I should see the "Remove avatar" button + + Scenario: I remove my avatar + Given I visit profile page + And I have an avatar + When I remove my avatar + Then I should see my gravatar + And I should not see the "Remove avatar" button Scenario: My password is expired Given my password is expired diff --git a/features/project/archived.feature b/features/project/archived.feature new file mode 100644 index 0000000000..9aac29384b --- /dev/null +++ b/features/project/archived.feature @@ -0,0 +1,39 @@ +Feature: Project Archived + Background: + Given I sign in as a user + And I own project "Shop" + And I own project "Forum" + + Scenario: I should not see archived on project page of not-archive project + And project "Forum" is archived + And I visit project "Shop" page + Then I should not see "Archived" + + Scenario: I should see archived on project page of archive project + And project "Forum" is archived + And I visit project "Forum" page + Then I should see "Archived" + + Scenario: I should not see archived on projects page with no archived projects + And I visit dashboard projects page + Then I should not see "Archived" + + Scenario: I should see archived on projects page with archived projects + And project "Forum" is archived + And I visit dashboard projects page + Then I should see "Archived" + + Scenario: I archive project + When project "Shop" has push event + And I visit project "Shop" page + And I visit edit project "Shop" page + And I set project archived + Then I should see "Archived" + + Scenario: I unarchive project + When project "Shop" has push event + And project "Shop" is archived + And I visit project "Shop" page + And I visit edit project "Shop" page + And I set project unarchived + Then I should not see "Archived" diff --git a/features/project/commits/branches.feature b/features/project/commits/branches.feature index 4fa4dc26a1..fcf8b7694f 100644 --- a/features/project/commits/branches.feature +++ b/features/project/commits/branches.feature @@ -16,11 +16,7 @@ Feature: Project Browse branches Given I click link "Protected" Then I should see "Shop" protected branches list - # @wip - # Scenario: I can download project by branch - - # @wip - # Scenario: I can view protected branches - - # @wip - # Scenario: I can manage protected branches + Scenario: I create a branch + Given I click new branch link + When I submit new branch form + Then I should see new branch created diff --git a/features/project/commits/commit_comments.feature b/features/project/commits/comments.feature similarity index 100% rename from features/project/commits/commit_comments.feature rename to features/project/commits/comments.feature diff --git a/features/project/commits/commits.feature b/features/project/commits/commits.feature index fe470f5ac9..cbe8b32150 100644 --- a/features/project/commits/commits.feature +++ b/features/project/commits/commits.feature @@ -14,6 +14,12 @@ Feature: Project Browse commits Scenario: I browse commit from list Given I click on commit link Then I see commit info + And I see side-by-side diff button + + Scenario: I browse commit with side-by-side diff view + Given I click on commit link + And I click side-by-side diff button + Then I see inline diff button Scenario: I compare refs Given I visit compare refs page diff --git a/features/project/commits/commit_diff_comments.feature b/features/project/commits/diff_comments.feature similarity index 100% rename from features/project/commits/commit_diff_comments.feature rename to features/project/commits/diff_comments.feature diff --git a/features/project/commits/user_lookup.feature b/features/project/commits/user_lookup.feature new file mode 100644 index 0000000000..f3864c0ab3 --- /dev/null +++ b/features/project/commits/user_lookup.feature @@ -0,0 +1,14 @@ +Feature: Project Browse Commits User Lookup + Background: + Given I sign in as a user + And I own a project + And I have the user that authored the commits + And I visit my project's commits page + + Scenario: I browse commit from list + Given I click on commit link + Then I see commit info + + Scenario: I browse another commit from list + Given I click on another commit link + Then I see other commit info \ No newline at end of file diff --git a/features/project/create_project.feature b/features/project/create.feature similarity index 91% rename from features/project/create_project.feature rename to features/project/create.feature index 395a3218b2..bb8e3a368e 100644 --- a/features/project/create_project.feature +++ b/features/project/create.feature @@ -3,6 +3,7 @@ Feature: Create Project A user with ability to create a project Should be able to create a new one + @javascript Scenario: User create a project Given I sign in as a user When I visit new project page @@ -19,4 +20,4 @@ Feature: Create Project And I click on HTTP Then Remote url should update to http link And If I click on SSH - Then Remote url should update to ssh link \ No newline at end of file + Then Remote url should update to ssh link diff --git a/features/project/edit_issuetracker.feature b/features/project/edit_issuetracker.feature new file mode 100644 index 0000000000..b5477d3c7a --- /dev/null +++ b/features/project/edit_issuetracker.feature @@ -0,0 +1,18 @@ +Feature: Project Issue Tracker + Background: + Given I sign in as a user + And I own project "Shop" + And project "Shop" has issues enabled + And I visit project "Shop" page + + Scenario: I set the issue tracker to "GitLab" + When I visit edit project "Shop" page + And change the issue tracker to "GitLab" + And I save project + Then I the project should have "GitLab" as issue tracker + + Scenario: I set the issue tracker to "Redmine" + When I visit edit project "Shop" page + And change the issue tracker to "Redmine" + And I save project + Then I the project should have "Redmine" as issue tracker \ No newline at end of file diff --git a/features/project/fork_project.feature b/features/project/fork.feature similarity index 100% rename from features/project/fork_project.feature rename to features/project/fork.feature diff --git a/features/project/forked_merge_requests.feature b/features/project/forked_merge_requests.feature index 966905645a..5832b729de 100644 --- a/features/project/forked_merge_requests.feature +++ b/features/project/forked_merge_requests.feature @@ -30,5 +30,10 @@ Feature: Project Forked Merge Requests Given I visit project "Forked Shop" merge requests page And I click link "New Merge Request" And I fill out an invalid "Merge Request On Forked Project" merge request - And I submit the merge request Then I should see validation errors + + @javascript + Scenario: Merge request should target fork repository by default + Given I visit project "Forked Shop" merge requests page + And I click link "New Merge Request" + Then the target repository should be the original repository diff --git a/features/project/issues/filter_labels.feature b/features/project/issues/filter_labels.feature new file mode 100644 index 0000000000..8df7a119e8 --- /dev/null +++ b/features/project/issues/filter_labels.feature @@ -0,0 +1,26 @@ +Feature: Project Filter Labels + Background: + Given I sign in as a user + And I own project "Shop" + And project "Shop" has issue "Bugfix1" with tags: "bug", "feature" + And project "Shop" has issue "Bugfix2" with tags: "bug", "enhancement" + And project "Shop" has issue "Feature1" with tags: "feature" + Given I visit project "Shop" issues page + + Scenario: I should see project issues + Then I should see "bug" in labels filter + And I should see "feature" in labels filter + And I should see "enhancement" in labels filter + + Scenario: I filter by one label + Given I click link "bug" + Then I should see "Bugfix1" in issues list + And I should see "Bugfix2" in issues list + And I should not see "Feature1" in issues list + + Scenario: I filter by two labels + Given I click link "bug" + And I click link "feature" + Then I should see "Bugfix1" in issues list + And I should not see "Bugfix2" in issues list + And I should not see "Feature1" in issues list diff --git a/features/project/issues/issues.feature b/features/project/issues/issues.feature index 67986784bc..c5311544ef 100644 --- a/features/project/issues/issues.feature +++ b/features/project/issues/issues.feature @@ -55,3 +55,24 @@ Feature: Project Issues And I fill in issue search with ".3" Then I should see "Release 0.3" in issues And I should not see "Release 0.4" in issues + + # Markdown + + Scenario: Headers inside the description should have ids generated for them. + Given I visit issue page "Release 0.4" + Then Header "Description header" should have correct id and link + + @javascript + Scenario: Headers inside comments should not have ids generated for them. + Given I visit issue page "Release 0.4" + And I leave a comment with a header containing "Comment with a header" + Then The comment with the header should not have an ID + + Scenario: Issues on empty project + Given empty project "Empty Project" + When I visit empty project page + And I see empty project details with ssh clone info + When I visit empty project's issues page + Given I click link "New Issue" + And I submit new issue "500 error on profile" + Then I should see issue "500 error on profile" diff --git a/features/project/issues/milestones.feature b/features/project/issues/milestones.feature index 2f38acf14d..e67b5d2d86 100644 --- a/features/project/issues/milestones.feature +++ b/features/project/issues/milestones.feature @@ -22,3 +22,9 @@ Feature: Project Milestones Given the milestone has open and closed issues And I click link "v2.2" Then I should see 3 issues + + # Markdown + + Scenario: Headers inside the description should have ids generated for them. + Given I click link "v2.2" + Then Header "Description header" should have correct id and link diff --git a/features/project/merge_requests.feature b/features/project/merge_requests.feature index 63f27c3acc..6a2ba7e3b2 100644 --- a/features/project/merge_requests.feature +++ b/features/project/merge_requests.feature @@ -29,7 +29,13 @@ Feature: Project Merge Requests And I click link "Close" Then I should see closed merge request "Bug NS-04" - @javascript + Scenario: I reopen merge request page + Given I click link "Bug NS-04" + And I click link "Close" + Then I should see closed merge request "Bug NS-04" + When I click link "Reopen" + Then I should see reopened merge request "Bug NS-04" + Scenario: I submit new unassigned merge request Given I click link "New Merge Request" And I submit new merge request "Wiki Feature" @@ -55,15 +61,81 @@ Feature: Project Merge Requests Given project "Shop" have "Bug NS-05" open merge request with diffs inside And I visit merge request page "Bug NS-05" And I click on the first commit in the merge request - And I leave a comment like "Line is wrong" on line 185 of the first file + And I leave a comment like "Line is wrong" on line 185 of the first file in commit And I switch to the merge request's comments tab - Then I should see a discussion has started on commit bcf03b5de6c:L185 + Then I should see a discussion has started on commit b1e6a9dbf1:L185 @javascript Scenario: I comment on a commit in merge request Given project "Shop" have "Bug NS-05" open merge request with diffs inside And I visit merge request page "Bug NS-05" And I click on the first commit in the merge request - And I leave a comment on the diff page + And I leave a comment on the diff page in commit And I switch to the merge request's comments tab - Then I should see a discussion has started on commit bcf03b5de6c + Then I should see a discussion has started on commit b1e6a9dbf1 + + @javascript + Scenario: I accept merge request with custom commit message + Given project "Shop" have "Bug NS-05" open merge request with diffs inside + And merge request "Bug NS-05" is mergeable + And I visit merge request page "Bug NS-05" + And merge request is mergeable + Then I modify merge commit message + And I accept this merge request + Then I should see merged request + + # Markdown + + Scenario: Headers inside the description should have ids generated for them. + When I visit merge request page "Bug NS-04" + Then Header "Description header" should have correct id and link + + @javascript + Scenario: Headers inside comments should not have ids generated for them. + Given I visit merge request page "Bug NS-04" + And I leave a comment with a header containing "Comment with a header" + Then The comment with the header should not have an ID + + # Toggling inline comments + + @javascript + Scenario: I hide comments on a merge request diff with comments in a single file + Given project "Shop" have "Bug NS-05" open merge request with diffs inside + And I visit merge request page "Bug NS-05" + And I switch to the diff tab + And I leave a comment like "Line is wrong" on line 39 of the second file + And I click link "Hide inline discussion" of the second file + Then I should not see a comment like "Line is wrong" in the second file + + @javascript + Scenario: I show comments on a merge request diff with comments in a single file + Given project "Shop" have "Bug NS-05" open merge request with diffs inside + And I visit merge request page "Bug NS-05" + And I switch to the diff tab + And I leave a comment like "Line is wrong" on line 39 of the second file + And I click link "Hide inline discussion" of the second file + And I click link "Show inline discussion" of the second file + Then I should see a comment like "Line is wrong" in the second file + + @javascript + Scenario: I hide comments on a merge request diff with comments in multiple files + Given project "Shop" have "Bug NS-05" open merge request with diffs inside + And I visit merge request page "Bug NS-05" + And I switch to the diff tab + And I leave a comment like "Line is correct" on line 12 of the first file + And I leave a comment like "Line is wrong" on line 39 of the second file + And I click link "Hide inline discussion" of the second file + Then I should not see a comment like "Line is wrong" in the second file + And I should still see a comment like "Line is correct" in the first file + + @javascript + Scenario: I show comments on a merge request diff with comments in multiple files + Given project "Shop" have "Bug NS-05" open merge request with diffs inside + And I visit merge request page "Bug NS-05" + And I switch to the diff tab + And I leave a comment like "Line is correct" on line 12 of the first file + And I leave a comment like "Line is wrong" on line 39 of the second file + And I click link "Hide inline discussion" of the second file + And I click link "Show inline discussion" of the second file + Then I should see a comment like "Line is wrong" in the second file + And I should still see a comment like "Line is correct" in the first file diff --git a/features/project/network.feature b/features/project/network.feature index ceae08c107..22beb1c50b 100644 --- a/features/project/network.feature +++ b/features/project/network.feature @@ -29,11 +29,11 @@ Feature: Project Network Graph @javascript Scenario: I should filter selected tag When I switch ref to "v2.1.0" - Then page should have content not cotaining "v2.1.0" + Then page should have content not containing "v2.1.0" When click "Show only selected branch" checkbox - Then page should not have content not cotaining "v2.1.0" + Then page should not have content not containing "v2.1.0" When click "Show only selected branch" checkbox - Then page should have content not cotaining "v2.1.0" + Then page should have content not containing "v2.1.0" Scenario: I should fail to look for a commit When I look for a commit by ";" diff --git a/features/project/project.feature b/features/project/project.feature index 59eda4a781..d8bb1d55e2 100644 --- a/features/project/project.feature +++ b/features/project/project.feature @@ -19,3 +19,8 @@ Feature: Project Feature And change project settings And I save project Then I should see project with new settings + + Scenario: I change project path + When I visit edit project "Shop" page + And change project path settings + Then I should see project with new path settings diff --git a/features/project/public_projects.feature b/features/project/public.feature similarity index 100% rename from features/project/public_projects.feature rename to features/project/public.feature diff --git a/features/project/redirects.feature b/features/project/redirects.feature new file mode 100644 index 0000000000..ce197912f6 --- /dev/null +++ b/features/project/redirects.feature @@ -0,0 +1,26 @@ +Feature: Project Redirects + Background: + Given public project "Community" + And private project "Enterprise" + + Scenario: I visit public project page + When I visit project "Community" page + Then I should see project "Community" home page + + Scenario: I visit private project page + When I visit project "Enterprise" page + Then I should be redirected to sign in page + + Scenario: I visit a non-existent project page + When I visit project "CommunityDoesNotExist" page + Then I should be redirected to sign in page + + Scenario: I visit a non-existent project page as user + Given I sign in as a user + When I visit project "CommunityDoesNotExist" page + Then page status code should be 404 + + Scenario: I visit unauthorized project page as user + Given I sign in as a user + When I visit project "Enterprise" page + Then page status code should be 404 diff --git a/features/project/service.feature b/features/project/service.feature index 4805d2befb..a5af065c9e 100644 --- a/features/project/service.feature +++ b/features/project/service.feature @@ -30,3 +30,21 @@ Feature: Project Services And I click Flowdock service link And I fill Flowdock settings Then I should see Flowdock service settings saved + + Scenario: Activate Assembla service + When I visit project "Shop" services page + And I click Assembla service link + And I fill Assembla settings + Then I should see Assembla service settings saved + + Scenario: Activate Slack service + When I visit project "Shop" services page + And I click Slack service link + And I fill Slack settings + Then I should see Slack service settings saved + + Scenario: Activate email on push service + When I visit project "Shop" services page + And I click email on push service link + And I fill email on push settings + Then I should see email on push service settings saved diff --git a/features/project/source/browse_files.feature b/features/project/source/browse_files.feature index ee26f5371a..a204c3e10c 100644 --- a/features/project/source/browse_files.feature +++ b/features/project/source/browse_files.feature @@ -20,8 +20,22 @@ Feature: Project Browse files And I click link "raw" Then I should see raw file content + Scenario: I can create file + Given I click on "new file" link in repo + Then I can see new file page + @javascript Scenario: I can edit file Given I click on "Gemfile.lock" file in repo And I click button "edit" Then I can edit code + + @javascript + Scenario: I can see editing preview + Given I click on "Gemfile.lock" file in repo + And I click button "edit" + And I edit code + And I click link "Diff" + Then I see diff + + diff --git a/features/project/source/markdown_render.feature b/features/project/source/markdown_render.feature index 8b4b89e85a..970a9e5786 100644 --- a/features/project/source/markdown_render.feature +++ b/features/project/source/markdown_render.feature @@ -4,6 +4,13 @@ Feature: Project markdown render And I own project "Delta" Given I visit project source page + # Tree README + + Scenario: Tree view should have correct links in README + Given I go directory which contains README file + And I click on a relative link in README + Then I should see the correct markdown + Scenario: I browse files from master branch Then I should see files from repository in master And I should see rendered README which contains correct links @@ -16,6 +23,24 @@ Feature: Project markdown render And I click on Rake tasks in README Then I should see correct directory rendered + Scenario: I view README in master branch to see reference links to directory + Then I should see files from repository in master + And I should see rendered README which contains correct links + And I click on GitLab API doc directory in README + Then I should see correct doc/api directory rendered + + Scenario: I view README in master branch to see reference links to file + Then I should see files from repository in master + And I should see rendered README which contains correct links + And I click on Maintenance in README + Then I should see correct maintenance file rendered + + Scenario: README headers should have header links + Then I should see rendered README which contains correct links + And Header "Application details" should have correct id and link + + # Blob + Scenario: I navigate to doc directory to view documentation in master And I navigate to the doc/api/README And I see correct file rendered @@ -28,6 +53,12 @@ Feature: Project markdown render And I click on raketasks in doc/api/README Then I should see correct directory rendered + Scenario: I navigate to doc directory to view user doc in master + And I navigate to the doc/api/README + And Header "GitLab API" should have correct id and link + + # Markdown branch + Scenario: I browse files from markdown branch When I visit markdown branch Then I should see files from repository in markdown branch @@ -56,6 +87,32 @@ Feature: Project markdown render And I click on raketasks in doc/api/README Then I should see correct directory rendered for markdown branch + Scenario: Tree markdown links view empty urls should have correct urls + When I visit markdown branch + Then The link with text "empty" should have url "tree/markdown" + When I visit markdown branch "README.md" blob + Then The link with text "empty" should have url "blob/markdown/README.md" + When I visit markdown branch "d" tree + Then The link with text "empty" should have url "tree/markdown/d" + When I visit markdown branch "d/README.md" blob + Then The link with text "empty" should have url "blob/markdown/d/README.md" + + # "ID" means "#id" on the tests below, because we are unable to escape the hash sign. + # which Spinach interprets as the start of a comment. + Scenario: All markdown links with ids should have correct urls + When I visit markdown branch + Then The link with text "ID" should have url "tree/markdownID" + Then The link with text "/ID" should have url "tree/markdownID" + Then The link with text "README.mdID" should have url "blob/markdown/README.mdID" + Then The link with text "d/README.mdID" should have url "blob/markdown/d/README.mdID" + When I visit markdown branch "README.md" blob + Then The link with text "ID" should have url "blob/markdown/README.mdID" + Then The link with text "/ID" should have url "blob/markdown/README.mdID" + Then The link with text "README.mdID" should have url "blob/markdown/README.mdID" + Then The link with text "d/README.mdID" should have url "blob/markdown/d/README.mdID" + + # Wiki + Scenario: I create a wiki page with different links Given I go to wiki page And I add various links to the wiki page @@ -69,12 +126,7 @@ Feature: Project markdown render And I click on Rake tasks link Then I see Rake tasks directory - Scenario: I visit the help page with markdown - Given I visit to the help page - And I select a page with markdown - Then I should see a help page with markdown - - Scenario: Tree view should have correct links in README - Given I go directory which contains README file - And I click on a relative link in README - Then I should see the correct markdown + Scenario: Wiki headers should have should have ids generated for them. + Given I go to wiki page + And I add a header to the wiki page + Then Wiki header should have correct id and link diff --git a/features/project/source/multiselect_blob.feature b/features/project/source/multiselect_blob.feature new file mode 100644 index 0000000000..3038c0814a --- /dev/null +++ b/features/project/source/multiselect_blob.feature @@ -0,0 +1,86 @@ +Feature: Project Multiselect Blob + Background: + Given I sign in as a user + And I own project "Shop" + And I visit project source page + And I click on "Gemfile.lock" file in repo + + @javascript + Scenario: I click line 1 in file + When I click line 1 in file + Then I should see "L1" as URI fragment + And I should see line 1 highlighted + + @javascript + Scenario: I shift-click line 1 in file + When I shift-click line 1 in file + Then I should see "L1" as URI fragment + And I should see line 1 highlighted + + @javascript + Scenario: I click line 1 then click line 2 in file + When I click line 1 in file + Then I should see "L1" as URI fragment + And I should see line 1 highlighted + Then I click line 2 in file + Then I should see "L2" as URI fragment + And I should see line 2 highlighted + + @javascript + Scenario: I click various line numbers to test multiselect + Then I click line 1 in file + Then I should see "L1" as URI fragment + And I should see line 1 highlighted + Then I shift-click line 2 in file + Then I should see "L1-2" as URI fragment + And I should see lines 1-2 highlighted + Then I shift-click line 3 in file + Then I should see "L1-3" as URI fragment + And I should see lines 1-3 highlighted + Then I click line 3 in file + Then I should see "L3" as URI fragment + And I should see line 3 highlighted + Then I shift-click line 1 in file + Then I should see "L1-3" as URI fragment + And I should see lines 1-3 highlighted + Then I shift-click line 5 in file + Then I should see "L1-5" as URI fragment + And I should see lines 1-5 highlighted + Then I shift-click line 4 in file + Then I should see "L1-4" as URI fragment + And I should see lines 1-4 highlighted + Then I click line 5 in file + Then I should see "L5" as URI fragment + And I should see line 5 highlighted + Then I shift-click line 3 in file + Then I should see "L3-5" as URI fragment + And I should see lines 3-5 highlighted + Then I shift-click line 1 in file + Then I should see "L1-3" as URI fragment + And I should see lines 1-3 highlighted + Then I shift-click line 1 in file + Then I should see "L1" as URI fragment + And I should see line 1 highlighted + + @javascript + Scenario: I multiselect lines 1-5 and then go back and forward in history + When I click line 1 in file + And I shift-click line 3 in file + And I shift-click line 2 in file + And I shift-click line 5 in file + Then I should see "L1-5" as URI fragment + And I should see lines 1-5 highlighted + Then I go back in history + Then I should see "L1-2" as URI fragment + And I should see lines 1-2 highlighted + Then I go back in history + Then I should see "L1-3" as URI fragment + And I should see lines 1-3 highlighted + Then I go back in history + Then I should see "L1" as URI fragment + And I should see line 1 highlighted + Then I go forward in history + And I go forward in history + And I go forward in history + Then I should see "L1-5" as URI fragment + And I should see lines 1-5 highlighted \ No newline at end of file diff --git a/features/project/wiki.feature b/features/project/wiki.feature index 90eb2b79c6..4a8c771dda 100644 --- a/features/project/wiki.feature +++ b/features/project/wiki.feature @@ -45,3 +45,20 @@ Feature: Project Wiki And I browse to that Wiki page And I click on the "Pages" button Then I should see the existing page in the pages list + + Scenario: File exists in wiki repo + Given I have an existing Wiki page with images linked on page + And I browse to wiki page with images + And I click on existing image link + Then I should see the image from wiki repo + + Scenario: Image in wiki repo shown on the page + Given I have an existing Wiki page with images linked on page + And I browse to wiki page with images + Then Image should be shown on the page + + Scenario: File does not exist in wiki repo + Given I have an existing Wiki page with images linked on page + And I browse to wiki page with images + And I click on image link + Then I should see the new wiki page form diff --git a/features/public/projects.feature b/features/public/projects.feature new file mode 100644 index 0000000000..57fe834b4b --- /dev/null +++ b/features/public/projects.feature @@ -0,0 +1,101 @@ +Feature: Public Projects Feature + Background: + Given public project "Community" + And internal project "Internal" + And private project "Enterprise" + + Scenario: I visit public area + When I visit the public projects area + Then I should see project "Community" + And I should not see project "Internal" + And I should not see project "Enterprise" + + Scenario: I visit public project page + When I visit project "Community" page + Then I should see project "Community" home page + + Scenario: I visit internal project page + When I visit project "Internal" page + Then I should be redirected to sign in page + + Scenario: I visit private project page + When I visit project "Enterprise" page + Then I should be redirected to sign in page + + Scenario: I visit an empty public project page + Given public empty project "Empty Public Project" + When I visit empty project page + Then I should see empty public project details + And I should see empty public project details with http clone info + + Scenario: I visit an empty public project page as user + Given I sign in as a user + And public empty project "Empty Public Project" + When I visit empty project page + Then I should see empty public project details + And I should see empty public project details with ssh clone info + + Scenario: I visit public area as user + Given I sign in as a user + When I visit the public projects area + Then I should see project "Community" + And I should see project "Internal" + And I should not see project "Enterprise" + + Scenario: I visit internal project page as user + Given I sign in as a user + When I visit project "Internal" page + Then I should see project "Internal" home page + + Scenario: I visit public project page + When I visit project "Community" page + Then I should see project "Community" home page + And I should see an http link to the repository + + Scenario: I visit public project page as user + Given I sign in as a user + When I visit project "Community" page + Then I should see project "Community" home page + And I should see an ssh link to the repository + + Scenario: I visit an empty public project page + Given public empty project "Empty Public Project" + When I visit empty project page + Then I should see empty public project details + + Scenario: I visit public project issues page as a non authorized user + Given I visit project "Community" page + And I visit "Community" issues page + Then I should see list of issues for "Community" project + + Scenario: I visit public project issues page as authorized user + Given I sign in as a user + Given I visit project "Community" page + And I visit "Community" issues page + Then I should see list of issues for "Community" project + + Scenario: I visit internal project issues page as authorized user + Given I sign in as a user + Given I visit project "Internal" page + And I visit "Internal" issues page + Then I should see list of issues for "Internal" project + + Scenario: I visit public project merge requests page as an authorized user + Given I sign in as a user + Given I visit project "Community" page + And I visit "Community" merge requests page + And project "Community" has "Bug fix" open merge request + Then I should see list of merge requests for "Community" project + + Scenario: I visit public project merge requests page as a non authorized user + Given I visit project "Community" page + And I visit "Community" merge requests page + And project "Community" has "Bug fix" open merge request + Then I should see list of merge requests for "Community" project + + Scenario: I visit internal project merge requests page as an authorized user + Given I sign in as a user + Given I visit project "Internal" page + And I visit "Internal" merge requests page + And project "Internal" has "Feature implemented" open merge request + Then I should see list of merge requests for "Internal" project diff --git a/features/public/public_groups.feature b/features/public/public_groups.feature new file mode 100644 index 0000000000..7f1ec718e3 --- /dev/null +++ b/features/public/public_groups.feature @@ -0,0 +1,118 @@ +Feature: Public Projects Feature + Background: + Given group "TestGroup" has private project "Enterprise" + + Scenario: I should not see group with private projects as visitor + When I visit group "TestGroup" page + Then I should be redirected to sign in page + + Scenario: I should not see group with private projects group as user + When I sign in as a user + And I visit group "TestGroup" page + Then page status code should be 404 + + Scenario: I should not see group with private and internal projects as visitor + Given group "TestGroup" has internal project "Internal" + When I visit group "TestGroup" page + Then I should be redirected to sign in page + + Scenario: I should see group with private and internal projects as user + Given group "TestGroup" has internal project "Internal" + When I sign in as a user + And I visit group "TestGroup" page + Then I should see project "Internal" items + And I should not see project "Enterprise" items + + Scenario: I should see group issues for internal project as user + Given group "TestGroup" has internal project "Internal" + When I sign in as a user + And I visit group "TestGroup" issues page + And I change filter to Everyone's + Then I should see project "Internal" items + And I should not see project "Enterprise" items + + Scenario: I should see group merge requests for internal project as user + Given group "TestGroup" has internal project "Internal" + When I sign in as a user + And I visit group "TestGroup" merge requests page + And I change filter to Everyone's + Then I should see project "Internal" items + And I should not see project "Enterprise" items + + Scenario: I should see group's members as user + Given group "TestGroup" has internal project "Internal" + And "John Doe" is owner of group "TestGroup" + When I sign in as a user + And I visit group "TestGroup" members page + Then I should see group member "John Doe" + And I should not see member roles + + Scenario: I should see group with private, internal and public projects as visitor + Given group "TestGroup" has internal project "Internal" + Given group "TestGroup" has public project "Community" + When I visit group "TestGroup" page + Then I should see project "Community" items + And I should not see project "Internal" items + And I should not see project "Enterprise" items + + Scenario: I should see group issues for public project as visitor + Given group "TestGroup" has internal project "Internal" + Given group "TestGroup" has public project "Community" + When I visit group "TestGroup" issues page + Then I should see project "Community" items + And I should not see project "Internal" items + And I should not see project "Enterprise" items + + Scenario: I should see group merge requests for public project as visitor + Given group "TestGroup" has internal project "Internal" + Given group "TestGroup" has public project "Community" + When I visit group "TestGroup" merge requests page + Then I should see project "Community" items + And I should not see project "Internal" items + And I should not see project "Enterprise" items + + Scenario: I should see group's members as visitor + Given group "TestGroup" has internal project "Internal" + Given group "TestGroup" has public project "Community" + And "John Doe" is owner of group "TestGroup" + When I visit group "TestGroup" members page + Then I should see group member "John Doe" + And I should not see member roles + + Scenario: I should see group with private, internal and public projects as user + Given group "TestGroup" has internal project "Internal" + Given group "TestGroup" has public project "Community" + When I sign in as a user + And I visit group "TestGroup" page + Then I should see project "Community" items + And I should see project "Internal" items + And I should not see project "Enterprise" items + + Scenario: I should see group issues for internal and public projects as user + Given group "TestGroup" has internal project "Internal" + Given group "TestGroup" has public project "Community" + When I sign in as a user + And I visit group "TestGroup" issues page + And I change filter to Everyone's + Then I should see project "Community" items + And I should see project "Internal" items + And I should not see project "Enterprise" items + + Scenario: I should see group merge requests for internal and public projects as user + Given group "TestGroup" has internal project "Internal" + Given group "TestGroup" has public project "Community" + When I sign in as a user + And I visit group "TestGroup" merge requests page + And I change filter to Everyone's + Then I should see project "Community" items + And I should see project "Internal" items + And I should not see project "Enterprise" items + + Scenario: I should see group's members as user + Given group "TestGroup" has internal project "Internal" + Given group "TestGroup" has public project "Community" + And "John Doe" is owner of group "TestGroup" + When I sign in as a user + And I visit group "TestGroup" members page + Then I should see group member "John Doe" + And I should not see member roles diff --git a/features/public/public_projects.feature b/features/public/public_projects.feature deleted file mode 100644 index 178a769194..0000000000 --- a/features/public/public_projects.feature +++ /dev/null @@ -1,18 +0,0 @@ -Feature: Public Projects Feature - Background: - Given public project "Community" - And private project "Enterprise" - - Scenario: I visit public area - When I visit the public projects area - Then I should see project "Community" - And I should not see project "Enterprise" - - Scenario: I visit public project page - When I visit project "Community" page - Then I should see project "Community" home page - - Scenario: I visit an empty public project page - Given public empty project "Empty Public Project" - When I visit empty project page - Then I should see empty public project details diff --git a/features/snippets/discover_snippets.feature b/features/snippets/discover.feature similarity index 100% rename from features/snippets/discover_snippets.feature rename to features/snippets/discover.feature diff --git a/features/snippets/user_snippets.feature b/features/snippets/user.feature similarity index 100% rename from features/snippets/user_snippets.feature rename to features/snippets/user.feature diff --git a/features/steps/admin/admin_active_tab.rb b/features/steps/admin/active_tab.rb similarity index 88% rename from features/steps/admin/admin_active_tab.rb rename to features/steps/admin/active_tab.rb index f14c5f396b..ccafe09c18 100644 --- a/features/steps/admin/admin_active_tab.rb +++ b/features/steps/admin/active_tab.rb @@ -30,4 +30,8 @@ class AdminActiveTab < Spinach::FeatureSteps Then 'the active main tab should be Resque' do ensure_active_main_tab('Background Jobs') end + + Then 'the active main tab should be Messages' do + ensure_active_main_tab('Messages') + end end diff --git a/features/steps/admin/broadcast_messages.rb b/features/steps/admin/broadcast_messages.rb new file mode 100644 index 0000000000..a35fa34a3a --- /dev/null +++ b/features/steps/admin/broadcast_messages.rb @@ -0,0 +1,41 @@ +class Spinach::Features::AdminBroadcastMessages < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedAdmin + + step 'application already has admin messages' do + FactoryGirl.create(:broadcast_message, message: "Migration to new server") + end + + step 'I should be all broadcast messages' do + page.should have_content "Migration to new server" + end + + step 'submit form with new broadcast message' do + fill_in 'broadcast_message_message', with: 'Application update from 4:00 CST to 5:00 CST' + select '2018', from: "broadcast_message_ends_at_1i" + click_button "Add broadcast message" + end + + step 'I should be redirected to admin messages page' do + current_path.should == admin_broadcast_messages_path + end + + step 'I should see newly created broadcast message' do + page.should have_content 'Application update from 4:00 CST to 5:00 CST' + end + + step 'submit form with new customized broadcast message' do + fill_in 'broadcast_message_message', with: 'Application update from 4:00 CST to 5:00 CST' + click_link "Customize colors" + fill_in 'broadcast_message_color', with: '#f2dede' + fill_in 'broadcast_message_font', with: '#b94a48' + select '2018', from: "broadcast_message_ends_at_1i" + click_button "Add broadcast message" + end + + step 'I should see a customized broadcast message' do + page.should have_content 'Application update from 4:00 CST to 5:00 CST' + page.should have_selector %(div[style="background-color:#f2dede;color:#b94a48"]) + end +end diff --git a/features/steps/admin/admin_groups.rb b/features/steps/admin/groups.rb similarity index 83% rename from features/steps/admin/admin_groups.rb rename to features/steps/admin/groups.rb index b4591f227e..9c1bcfefb9 100644 --- a/features/steps/admin/admin_groups.rb +++ b/features/steps/admin/groups.rb @@ -1,6 +1,7 @@ class AdminGroups < Spinach::FeatureSteps include SharedAuthentication include SharedPaths + include SharedUser include SharedActiveTab include Select2Helper @@ -20,10 +21,6 @@ class AdminGroups < Spinach::FeatureSteps @project.team << [current_user, :master] end - And 'Create gitlab user "John"' do - create(:user, name: "John") - end - And 'submit form with new group info' do fill_in 'group_name', with: 'gitlab' fill_in 'group_description', with: 'Group description' @@ -39,8 +36,8 @@ class AdminGroups < Spinach::FeatureSteps current_path.should == admin_group_path(Group.last) end - When 'I select user "John" from user list as "Reporter"' do - user = User.find_by_name("John") + When 'I select user "John Doe" from user list as "Reporter"' do + user = User.find_by(name: "John Doe") select2(user.id, from: "#user_ids", multiple: true) within "#new_team_member" do select "Reporter", from: "group_access" @@ -48,9 +45,9 @@ class AdminGroups < Spinach::FeatureSteps click_button "Add users into group" end - Then 'I should see "John" in team list in every project as "Reporter"' do + Then 'I should see "John Doe" in team list in every project as "Reporter"' do within ".group-users-list" do - page.should have_content "John" + page.should have_content "John Doe" page.should have_content "Reporter" end end diff --git a/features/steps/admin/admin_logs.rb b/features/steps/admin/logs.rb similarity index 100% rename from features/steps/admin/admin_logs.rb rename to features/steps/admin/logs.rb diff --git a/features/steps/admin/admin_projects.rb b/features/steps/admin/projects.rb similarity index 100% rename from features/steps/admin/admin_projects.rb rename to features/steps/admin/projects.rb diff --git a/features/steps/admin/admin_users.rb b/features/steps/admin/users.rb similarity index 71% rename from features/steps/admin/admin_users.rb rename to features/steps/admin/users.rb index 33c1344eae..659008dd87 100644 --- a/features/steps/admin/admin_users.rb +++ b/features/steps/admin/users.rb @@ -31,4 +31,17 @@ class AdminUsers < Spinach::FeatureSteps And 'Not changed form action url' do page.should have_selector %(form[action="/admin/users/#{@user.username}"]) end + + step 'I submit modified user' do + check :user_can_create_group + click_button 'Save' + end + + step 'I see user attributes changed' do + page.should have_content 'Can create groups: Yes' + end + + step 'click edit on my user' do + find("#edit_user_#{current_user.id}").click + end end diff --git a/features/steps/dashboard/dashboard_active_tab.rb b/features/steps/dashboard/active_tab.rb similarity index 100% rename from features/steps/dashboard/dashboard_active_tab.rb rename to features/steps/dashboard/active_tab.rb diff --git a/features/steps/dashboard/dashboard.rb b/features/steps/dashboard/dashboard.rb index bde32128b9..706c9babce 100644 --- a/features/steps/dashboard/dashboard.rb +++ b/features/steps/dashboard/dashboard.rb @@ -25,7 +25,6 @@ class Dashboard < Spinach::FeatureSteps find("#merge_request_target_project_id").value.should == @project.id.to_s find("#merge_request_source_branch").value.should == "new_design" find("#merge_request_target_branch").value.should == "master" - find("#merge_request_title").value.should == "New Design" end Given 'user with name "John Doe" joined project "Shop"' do @@ -43,7 +42,7 @@ class Dashboard < Spinach::FeatureSteps end And 'user with name "John Doe" left project "Shop"' do - user = User.find_by_name "John Doe" + user = User.find_by(name: "John Doe") Event.create( project: project, author_id: user.id, @@ -85,6 +84,6 @@ class Dashboard < Spinach::FeatureSteps end def project - @project ||= Project.find_by_name "Shop" + @project ||= Project.find_by(name: "Shop") end end diff --git a/features/steps/dashboard/dashboard_issues.rb b/features/steps/dashboard/dashboard_issues.rb deleted file mode 100644 index fcf4296ad1..0000000000 --- a/features/steps/dashboard/dashboard_issues.rb +++ /dev/null @@ -1,20 +0,0 @@ -class DashboardIssues < Spinach::FeatureSteps - include SharedAuthentication - include SharedPaths - - Then 'I should see issues assigned to me' do - issues = @user.issues - issues.each do |issue| - page.should have_content(issue.title[0..10]) - page.should have_content(issue.project.name) - page.should have_link(issue.project.name) - end - end - - And 'I have assigned issues' do - project = create :project - project.team << [@user, :master] - - 2.times { create :issue, author: @user, assignee: @user, project: project } - end -end diff --git a/features/steps/dashboard/dashboard_merge_requests.rb b/features/steps/dashboard/dashboard_merge_requests.rb deleted file mode 100644 index 6c1fa39f08..0000000000 --- a/features/steps/dashboard/dashboard_merge_requests.rb +++ /dev/null @@ -1,29 +0,0 @@ -class DashboardMergeRequests < Spinach::FeatureSteps - include SharedAuthentication - include SharedPaths - - Then 'I should see my merge requests' do - merge_requests = @user.merge_requests - merge_requests.each do |mr| - page.should have_content(mr.title[0..10]) - page.should have_content(mr.target_project.name) - page.should have_content(mr.source_project.name) - end - end - - And 'I have authored merge requests' do - project1_source = create :project - project1_target= create :project - project2_source = create :project - project2_target = create :project - - - project1_source.team << [@user, :master] - project1_target.team << [@user, :master] - project2_source.team << [@user, :master] - project2_target.team << [@user, :master] - - merge_request1 = create :merge_request, author: @user, source_project: project1_source, target_project: project1_target - merge_request2 = create :merge_request, author: @user, source_project: project2_source, target_project: project2_target - end -end diff --git a/features/steps/dashboard/dashboard_event_filters.rb b/features/steps/dashboard/event_filters.rb similarity index 100% rename from features/steps/dashboard/dashboard_event_filters.rb rename to features/steps/dashboard/event_filters.rb diff --git a/features/steps/dashboard/issues.rb b/features/steps/dashboard/issues.rb new file mode 100644 index 0000000000..1344edfa80 --- /dev/null +++ b/features/steps/dashboard/issues.rb @@ -0,0 +1,74 @@ +class DashboardIssues < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + + step 'I should see issues assigned to me' do + should_see(assigned_issue) + should_not_see(authored_issue) + should_not_see(other_issue) + end + + step 'I should see issues authored by me' do + should_see(authored_issue) + should_not_see(assigned_issue) + should_not_see(other_issue) + end + + step 'I should see all issues' do + should_see(authored_issue) + should_see(assigned_issue) + should_see(other_issue) + end + + step 'I have authored issues' do + authored_issue + end + + step 'I have assigned issues' do + assigned_issue + end + + step 'I have other issues' do + other_issue + end + + step 'I click "Authored by me" link' do + within ".scope-filter" do + click_link 'Created by me' + end + end + + step 'I click "All" link' do + within ".scope-filter" do + click_link "Everyone's" + end + end + + def should_see(issue) + page.should have_content(issue.title[0..10]) + end + + def should_not_see(issue) + page.should_not have_content(issue.title[0..10]) + end + + def assigned_issue + @assigned_issue ||= create :issue, assignee: current_user, project: project + end + + def authored_issue + @authored_issue ||= create :issue, author: current_user, project: project + end + + def other_issue + @other_issue ||= create :issue, project: project + end + + def project + @project ||= begin + project =create :project + project.team << [current_user, :master] + project + end + end +end diff --git a/features/steps/dashboard/merge_requests.rb b/features/steps/dashboard/merge_requests.rb new file mode 100644 index 0000000000..e198bc0cf9 --- /dev/null +++ b/features/steps/dashboard/merge_requests.rb @@ -0,0 +1,74 @@ +class DashboardMergeRequests < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + + step 'I should see merge requests assigned to me' do + should_see(assigned_merge_request) + should_not_see(authored_merge_request) + should_not_see(other_merge_request) + end + + step 'I should see merge requests authored by me' do + should_see(authored_merge_request) + should_not_see(assigned_merge_request) + should_not_see(other_merge_request) + end + + step 'I should see all merge requests' do + should_see(authored_merge_request) + should_see(assigned_merge_request) + should_see(other_merge_request) + end + + step 'I have authored merge requests' do + authored_merge_request + end + + step 'I have assigned merge requests' do + assigned_merge_request + end + + step 'I have other merge requests' do + other_merge_request + end + + step 'I click "Authored by me" link' do + within ".scope-filter" do + click_link 'Created by me' + end + end + + step 'I click "All" link' do + within ".scope-filter" do + click_link "Everyone's" + end + end + + def should_see(merge_request) + page.should have_content(merge_request.title[0..10]) + end + + def should_not_see(merge_request) + page.should_not have_content(merge_request.title[0..10]) + end + + def assigned_merge_request + @assigned_merge_request ||= create :merge_request, assignee: current_user, target_project: project, source_project: project + end + + def authored_merge_request + @authored_merge_request ||= create :merge_request, source_branch: 'simple_merge_request', author: current_user, target_project: project, source_project: project + end + + def other_merge_request + @other_merge_request ||= create :merge_request, source_branch: '2_3_notes_fix', target_project: project, source_project: project + end + + def project + @project ||= begin + project =create :project + project.team << [current_user, :master] + project + end + end +end diff --git a/features/steps/dashboard/dashboard_projects.rb b/features/steps/dashboard/projects.rb similarity index 100% rename from features/steps/dashboard/dashboard_projects.rb rename to features/steps/dashboard/projects.rb diff --git a/features/steps/dashboard/dashboard_search.rb b/features/steps/dashboard/search.rb similarity index 100% rename from features/steps/dashboard/dashboard_search.rb rename to features/steps/dashboard/search.rb diff --git a/features/steps/dashboard/with_archived_projects.rb b/features/steps/dashboard/with_archived_projects.rb new file mode 100644 index 0000000000..1bc69555b5 --- /dev/null +++ b/features/steps/dashboard/with_archived_projects.rb @@ -0,0 +1,22 @@ +class DashboardWithArchivedProjects < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedProject + + When 'project "Forum" is archived' do + project = Project.find_by(name: "Forum") + project.update_attribute(:archived, true) + end + + Then 'I should see "Shop" project link' do + page.should have_link "Shop" + end + + Then 'I should not see "Forum" project link' do + page.should_not have_link "Forum" + end + + Then 'I should see "Forum" project link' do + page.should have_link "Forum" + end +end diff --git a/features/steps/group/group.rb b/features/steps/group/group.rb index 99ec77a761..81472d1ca3 100644 --- a/features/steps/group/group.rb +++ b/features/steps/group/group.rb @@ -1,65 +1,70 @@ class Groups < Spinach::FeatureSteps include SharedAuthentication include SharedPaths + include SharedGroup + include SharedUser include Select2Helper - Then 'I should see projects list' do - current_user.authorized_projects.each do |project| + Then 'I should see group "Owned" projects list' do + Group.find_by(name: "Owned").projects.each do |project| page.should have_link project.name end end - And 'I have group with projects' do - @group = create(:group) - @group.add_owner(current_user) - @project = create(:project, namespace: @group) - @event = create(:closed_issue_event, project: @project) - - @project.team << [current_user, :master] - end - And 'I should see projects activity feed' do page.should have_content 'closed issue' end - Then 'I should see issues from this group assigned to me' do + Then 'I should see issues from group "Owned" assigned to me' do assigned_to_me(:issues).each do |issue| page.should have_content issue.title end end - Then 'I should see merge requests from this group assigned to me' do + Then 'I should see merge requests from group "Owned" assigned to me' do assigned_to_me(:merge_requests).each do |issue| page.should have_content issue.title[0..80] end end - Given 'I have new user "John"' do - create(:user, name: "John") - end - - And 'I select user "John" from list with role "Reporter"' do - user = User.find_by_name("John") - within ".new_users_group" do + And 'I select user "Mary Jane" from list with role "Reporter"' do + user = User.find_by(name: "Mary Jane") || create(:user, name: "Mary Jane") + click_link 'Add members' + within ".users-group-form" do select2(user.id, from: "#user_ids", multiple: true) select "Reporter", from: "group_access" end click_button "Add users into group" end - Then 'I should see user "John" in team list' do + Then 'I should see user "John Doe" in team list' do projects_with_access = find(".ui-box .well-list") - projects_with_access.should have_content("John") + projects_with_access.should have_content("John Doe") end - Given 'project from group has issues assigned to me' do + Then 'I should not see user "John Doe" in team list' do + projects_with_access = find(".ui-box .well-list") + projects_with_access.should_not have_content("John Doe") + end + + Then 'I should see user "Mary Jane" in team list' do + projects_with_access = find(".ui-box .well-list") + projects_with_access.should have_content("Mary Jane") + end + + Then 'I should not see user "Mary Jane" in team list' do + projects_with_access = find(".ui-box .well-list") + projects_with_access.should_not have_content("Mary Jane") + end + + Given 'project from group "Owned" has issues assigned to me' do create :issue, project: project, assignee: current_user, author: current_user end - Given 'project from group has merge requests assigned to me' do + Given 'project from group "Owned" has merge requests assigned to me' do create :merge_request, source_project: project, target_project: project, @@ -71,44 +76,94 @@ class Groups < Spinach::FeatureSteps click_link "New group" end - And 'submit form with new group info' do + And 'submit form with new group "Samurai" info' do fill_in 'group_name', with: 'Samurai' fill_in 'group_description', with: 'Tokugawa Shogunate' click_button "Create group" end - Then 'I should see newly created group' do + Then 'I should be redirected to group "Samurai" page' do + current_path.should == group_path(Group.last) + end + + Then 'I should see newly created group "Samurai"' do page.should have_content "Samurai" page.should have_content "Tokugawa Shogunate" page.should have_content "You will only see events from projects in this group" end - Then 'I should be redirected to group page' do - current_path.should == group_path(Group.last) - end - - And 'I change group name' do + And 'I change group "Owned" name to "new-name"' do fill_in 'group_name', with: 'new-name' click_button "Save group" end - Then 'I should see new group name' do + Then 'I should see new group "Owned" name' do within ".navbar-gitlab" do page.should have_content "group: new-name" end end + step 'I change group "Owned" avatar' do + attach_file(:group_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png')) + click_button "Save group" + Group.find_by(name: "Owned").reload + end + + step 'I should see new group "Owned" avatar' do + Group.find_by(name: "Owned").avatar.should be_instance_of AttachmentUploader + Group.find_by(name: "Owned").avatar.url.should == "/uploads/group/avatar/#{ Group.find_by(name:"Owned").id }/gitlab_logo.png" + end + + step 'I should see the "Remove avatar" button' do + page.should have_link("Remove avatar") + end + + step 'I have group "Owned" avatar' do + attach_file(:group_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png')) + click_button "Save group" + Group.find_by(name: "Owned").reload + end + + step 'I remove group "Owned" avatar' do + click_link "Remove avatar" + Group.find_by(name: "Owned").reload + end + + step 'I should not see group "Owned" avatar' do + Group.find_by(name: "Owned").avatar?.should be_false + end + + step 'I should not see the "Remove avatar" button' do + page.should_not have_link("Remove avatar") + end + + step 'I click on the "Remove User From Group" button for "John Doe"' do + find(:css, 'li', text: "John Doe").find(:css, 'a.btn-remove').click + # poltergeist always confirms popups. + end + + step 'I click on the "Remove User From Group" button for "Mary Jane"' do + find(:css, 'li', text: "Mary Jane").find(:css, 'a.btn-remove').click + # poltergeist always confirms popups. + end + + step 'I should not see the "Remove User From Group" button for "John Doe"' do + find(:css, 'li', text: "John Doe").should_not have_selector(:css, 'a.btn-remove') + # poltergeist always confirms popups. + end + + step 'I should not see the "Remove User From Group" button for "Mary Jane"' do + find(:css, 'li', text: "Mary Jane").should_not have_selector(:css, 'a.btn-remove') + # poltergeist always confirms popups. + end + protected - def current_group - @group ||= Group.first - end - - def project - current_group.projects.first - end - def assigned_to_me key project.send(key).where(assignee_id: current_user.id) end + + def project + Group.find_by(name: "Owned").projects.first + end end diff --git a/features/steps/help.rb b/features/steps/help.rb new file mode 100644 index 0000000000..aa147fd65c --- /dev/null +++ b/features/steps/help.rb @@ -0,0 +1,21 @@ +class Spinach::Features::Help < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedMarkdown + + step 'I visit the help page' do + visit help_path + end + + step 'I visit the "Rake Tasks" help page' do + visit help_raketasks_path + end + + step 'I should see "Rake Tasks" page markdown rendered' do + page.should have_content "GitLab provides some specific rake tasks to enable special features or perform maintenance tasks" + end + + step 'Header "Rebuild project satellites" should have correct ids and links' do + header_should_have_correct_id_and_link(3, 'Rebuild project satellites', 'rebuild-project-satellites') + end +end diff --git a/features/steps/profile/profile_active_tab.rb b/features/steps/profile/active_tab.rb similarity index 100% rename from features/steps/profile/profile_active_tab.rb rename to features/steps/profile/active_tab.rb diff --git a/features/steps/profile/emails.rb b/features/steps/profile/emails.rb new file mode 100644 index 0000000000..99588c8599 --- /dev/null +++ b/features/steps/profile/emails.rb @@ -0,0 +1,48 @@ +class ProfileEmails < Spinach::FeatureSteps + include SharedAuthentication + + Then 'I visit profile emails page' do + visit profile_emails_path + end + + Then 'I should see my emails' do + page.should have_content(@user.email) + @user.emails.each do |email| + page.should have_content(email.email) + end + end + + And 'I submit new email "my@email.com"' do + fill_in "email_email", with: "my@email.com" + click_button "Add" + end + + Then 'I should see new email "my@email.com"' do + email = @user.emails.find_by(email: "my@email.com") + email.should_not be_nil + page.should have_content("my@email.com") + end + + Then 'I should not see email "my@email.com"' do + email = @user.emails.find_by(email: "my@email.com") + email.should be_nil + page.should_not have_content("my@email.com") + end + + Then 'I click link "Remove" for "my@email.com"' do + # there should only be one remove button at this time + click_link "Remove" + # force these to reload as they have been cached + @user.emails.reload + end + + And 'I submit duplicate email @user.email' do + fill_in "email_email", with: @user.email + click_button "Add" + end + + Then 'I should not have @user.email added' do + email = @user.emails.find_by(email: @user.email) + email.should be_nil + end +end diff --git a/features/steps/profile/group.rb b/features/steps/profile/group.rb new file mode 100644 index 0000000000..03144104c7 --- /dev/null +++ b/features/steps/profile/group.rb @@ -0,0 +1,44 @@ +class ProfileGroup < Spinach::FeatureSteps + include SharedAuthentication + include SharedGroup + include SharedPaths + include SharedUser + + # Leave + + step 'I click on the "Leave" button for group "Owned"' do + find(:css, 'li', text: "Owner").find(:css, 'i.icon-signout').click + # poltergeist always confirms popups. + end + + step 'I click on the "Leave" button for group "Guest"' do + find(:css, 'li', text: "Guest").find(:css, 'i.icon-signout').click + # poltergeist always confirms popups. + end + + step 'I should not see the "Leave" button for group "Owned"' do + find(:css, 'li', text: "Owner").should_not have_selector(:css, 'i.icon-signout') + # poltergeist always confirms popups. + end + + step 'I should not see the "Leave" button for groupr "Guest"' do + find(:css, 'li', text: "Guest").should_not have_selector(:css, 'i.icon-signout') + # poltergeist always confirms popups. + end + + step 'I should see group "Owned" in group list' do + page.should have_content("Owned") + end + + step 'I should not see group "Owned" in group list' do + page.should_not have_content("Owned") + end + + step 'I should see group "Guest" in group list' do + page.should have_content("Guest") + end + + step 'I should not see group "Guest" in group list' do + page.should_not have_content("Guest") + end +end diff --git a/features/steps/profile/profile_notifications.rb b/features/steps/profile/notifications.rb similarity index 87% rename from features/steps/profile/profile_notifications.rb rename to features/steps/profile/notifications.rb index 7a41687dfd..e884df3098 100644 --- a/features/steps/profile/profile_notifications.rb +++ b/features/steps/profile/notifications.rb @@ -8,6 +8,5 @@ class ProfileNotifications < Spinach::FeatureSteps step 'I should see global notifications settings' do page.should have_content "Notifications settings" - page.should have_content "Global setting" end end diff --git a/features/steps/profile/profile.rb b/features/steps/profile/profile.rb index 753e2c19bc..879bcf41b4 100644 --- a/features/steps/profile/profile.rb +++ b/features/steps/profile/profile.rb @@ -6,18 +6,20 @@ class Profile < Spinach::FeatureSteps page.should have_content "Profile settings" end - step 'I change my contact info' do + step 'I change my profile info' do fill_in "user_skype", with: "testskype" fill_in "user_linkedin", with: "testlinkedin" fill_in "user_twitter", with: "testtwitter" + fill_in "user_website_url", with: "testurl" click_button "Save changes" @user.reload end - step 'I should see new contact info' do + step 'I should see new profile info' do @user.skype.should == 'testskype' @user.linkedin.should == 'testlinkedin' @user.twitter.should == 'testtwitter' + @user.website_url.should == 'testurl' end step 'I change my avatar' do @@ -31,26 +33,49 @@ class Profile < Spinach::FeatureSteps @user.avatar.url.should == "/uploads/user/avatar/#{ @user.id }/gitlab_logo.png" end + step 'I should see the "Remove avatar" button' do + page.should have_link("Remove avatar") + end + + step 'I have an avatar' do + attach_file(:user_avatar, File.join(Rails.root, 'public', 'gitlab_logo.png')) + click_button "Save changes" + @user.reload + end + + step 'I remove my avatar' do + click_link "Remove avatar" + @user.reload + end + + step 'I should see my gravatar' do + @user.avatar?.should be_false + end + + step 'I should not see the "Remove avatar" button' do + page.should_not have_link("Remove avatar") + end + step 'I try change my password w/o old one' do within '.update-password' do - fill_in "user_password", with: "222333" - fill_in "user_password_confirmation", with: "222333" + fill_in "user_password", with: "22233344" + fill_in "user_password_confirmation", with: "22233344" click_button "Save" end end step 'I change my password' do within '.update-password' do - fill_in "user_current_password", with: "123456" - fill_in "user_password", with: "222333" - fill_in "user_password_confirmation", with: "222333" + fill_in "user_current_password", with: "12345678" + fill_in "user_password", with: "22233344" + fill_in "user_password_confirmation", with: "22233344" click_button "Save" end end step 'I unsuccessfully change my password' do within '.update-password' do - fill_in "user_current_password", with: "123456" + fill_in "user_current_password", with: "12345678" fill_in "user_password", with: "password" fill_in "user_password_confirmation", with: "confirmation" click_button "Save" @@ -62,11 +87,7 @@ class Profile < Spinach::FeatureSteps end step "I should see a password error message" do - page.should have_content "Password doesn't match confirmation" - end - - step 'I should be redirected to sign in page' do - current_path.should == new_user_session_path + page.should have_content "Password confirmation doesn't match" end step 'I reset my token' do @@ -152,4 +173,17 @@ class Profile < Spinach::FeatureSteps page.should have_content current_user.name end end + + step 'I have group with projects' do + @group = create(:group) + @group.add_owner(current_user) + @project = create(:project, namespace: @group) + @event = create(:closed_issue_event, project: @project) + + @project.team << [current_user, :master] + end + + step 'I should see groups I belong to' do + page.should have_css('.profile-groups-avatars', visible: true) + end end diff --git a/features/steps/profile/profile_ssh_keys.rb b/features/steps/profile/ssh_keys.rb similarity index 97% rename from features/steps/profile/profile_ssh_keys.rb rename to features/steps/profile/ssh_keys.rb index 65bfc505d8..65ca824bb5 100644 --- a/features/steps/profile/profile_ssh_keys.rb +++ b/features/steps/profile/ssh_keys.rb @@ -18,7 +18,7 @@ class ProfileSshKeys < Spinach::FeatureSteps end Then 'I should see new ssh key "Laptop"' do - key = Key.find_by_title("Laptop") + key = Key.find_by(title: "Laptop") page.should have_content(key.title) page.should have_content(key.key) current_path.should == profile_key_path(key) diff --git a/features/steps/project/project_active_tab.rb b/features/steps/project/active_tab.rb similarity index 96% rename from features/steps/project/project_active_tab.rb rename to features/steps/project/active_tab.rb index e04a17168b..dcc252f476 100644 --- a/features/steps/project/project_active_tab.rb +++ b/features/steps/project/active_tab.rb @@ -57,7 +57,9 @@ class ProjectActiveTab < Spinach::FeatureSteps end Given 'I click the "Edit" tab' do - click_link('Edit') + within '.project-settings-nav' do + click_link('Project') + end end Given 'I click the "Hooks" tab' do @@ -73,7 +75,7 @@ class ProjectActiveTab < Spinach::FeatureSteps end Then 'the active sub nav should be Edit' do - ensure_active_sub_nav('Edit Project') + ensure_active_sub_nav('Project') end Then 'the active sub nav should be Hooks' do diff --git a/features/steps/project/archived.rb b/features/steps/project/archived.rb new file mode 100644 index 0000000000..dfbe762c43 --- /dev/null +++ b/features/steps/project/archived.rb @@ -0,0 +1,37 @@ +class ProjectArchived < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + When 'project "Forum" is archived' do + project = Project.find_by(name: "Forum") + project.update_attribute(:archived, true) + end + + When 'project "Shop" is archived' do + project = Project.find_by(name: "Shop") + project.update_attribute(:archived, true) + end + + When 'I visit project "Forum" page' do + project = Project.find_by(name: "Forum") + visit project_path(project) + end + + Then 'I should not see "Archived"' do + page.should_not have_content "Archived" + end + + Then 'I should see "Archived"' do + page.should have_content "Archived" + end + + When 'I set project archived' do + click_link "Archive" + end + + When 'I set project unarchived' do + click_link "Unarchive" + end + +end \ No newline at end of file diff --git a/features/steps/project/browse_branches.rb b/features/steps/project/browse_branches.rb new file mode 100644 index 0000000000..30c8cef80c --- /dev/null +++ b/features/steps/project/browse_branches.rb @@ -0,0 +1,51 @@ +class ProjectBrowseBranches < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + step 'I should see "Shop" recent branches list' do + page.should have_content "Branches" + page.should have_content "master" + end + + step 'I click link "All"' do + click_link "All" + end + + step 'I should see "Shop" all branches list' do + page.should have_content "Branches" + page.should have_content "master" + end + + step 'I click link "Protected"' do + click_link "Protected" + end + + step 'I should see "Shop" protected branches list' do + within ".protected-branches-list" do + page.should have_content "stable" + page.should_not have_content "master" + end + end + + step 'project "Shop" has protected branches' do + project = Project.find_by(name: "Shop") + project.protected_branches.create(name: "stable") + end + + step 'I click new branch link' do + click_link "New branch" + end + + step 'I submit new branch form' do + fill_in 'branch_name', with: 'deploy_keys' + fill_in 'ref', with: 'master' + click_button 'Create branch' + end + + step 'I should see new branch created' do + within '.all-branches' do + page.should have_content 'deploy_keys' + end + end +end diff --git a/features/steps/project/project_browse_commits.rb b/features/steps/project/browse_commits.rb similarity index 92% rename from features/steps/project/project_browse_commits.rb rename to features/steps/project/browse_commits.rb index 650bc3a16f..d667b58240 100644 --- a/features/steps/project/project_browse_commits.rb +++ b/features/steps/project/browse_commits.rb @@ -88,4 +88,17 @@ class ProjectBrowseCommits < Spinach::FeatureSteps links[0]['href'].should =~ %r{blob/bc3735004cb45cec5e0e4fa92710897a910a5957} links[1]['href'].should =~ %r{blob/cc1ba255d6c5ffdce87a357ba7ccc397a4f4026b} end + + Given 'I click side-by-side diff button' do + click_link "Side-by-side Diff" + end + + Then 'I see side-by-side diff button' do + page.should have_content "Side-by-side Diff" + end + + Then 'I see inline diff button' do + page.should have_content "Inline Diff" + end + end diff --git a/features/steps/project/browse_commits_user_lookup.rb b/features/steps/project/browse_commits_user_lookup.rb new file mode 100644 index 0000000000..328be37355 --- /dev/null +++ b/features/steps/project/browse_commits_user_lookup.rb @@ -0,0 +1,35 @@ +class ProjectBrowseCommitsUserLookup < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + Given 'I have the user that authored the commits' do + @user = create(:user, email: 'dmitriy.zaporozhets@gmail.com') + create(:email, { user: @user, email: 'dzaporozhets@sphereconsultinginc.com' }) + end + + Given 'I click on commit link' do + visit project_commit_path(@project, ValidCommit::ID) + end + + Given 'I click on another commit link' do + visit project_commit_path(@project, ValidCommitWithAltEmail::ID) + end + + Then 'I see commit info' do + page.should have_content ValidCommit::MESSAGE + check_author_link(ValidCommit::AUTHOR_EMAIL) + end + + Then 'I see other commit info' do + page.should have_content ValidCommitWithAltEmail::MESSAGE + check_author_link(ValidCommitWithAltEmail::AUTHOR_EMAIL) + end + + def check_author_link(email) + author_link = find('.commit-author-link') + author_link['href'].should == user_path(@user) + author_link['data-original-title'].should == email + find('.commit-author-name').text.should == @user.name + end +end diff --git a/features/steps/project/browse_files.rb b/features/steps/project/browse_files.rb new file mode 100644 index 0000000000..7cdd1101ac --- /dev/null +++ b/features/steps/project/browse_files.rb @@ -0,0 +1,65 @@ +class ProjectBrowseFiles < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + step 'I should see files from repository' do + page.should have_content "app" + page.should have_content "history" + page.should have_content "Gemfile" + end + + step 'I should see files from repository for "8470d70"' do + current_path.should == project_tree_path(@project, "8470d70") + page.should have_content "app" + page.should have_content "history" + page.should have_content "Gemfile" + end + + step 'I click on "Gemfile.lock" file in repo' do + click_link "Gemfile.lock" + end + + step 'I should see it content' do + page.should have_content "DEPENDENCIES" + end + + step 'I click link "raw"' do + click_link "raw" + end + + step 'I should see raw file content' do + page.source.should == ValidCommit::BLOB_FILE + end + + step 'I click button "edit"' do + click_link 'edit' + end + + step 'I can edit code' do + page.execute_script('editor.setValue("GitlabFileEditor")') + page.evaluate_script('editor.getValue()').should == "GitlabFileEditor" + end + + step 'I edit code' do + page.execute_script('editor.setValue("GitlabFileEditor")') + end + + step 'I click link "Diff"' do + click_link 'Diff' + end + + step 'I see diff' do + page.should have_css '.line_holder.new' + end + + step 'I click on "new file" link in repo' do + click_link 'new-file-link' + end + + step 'I can see new file page' do + page.should have_content "New file" + page.should have_content "File name" + page.should have_content "Commit message" + end +end diff --git a/features/steps/project/project_browse_git_repo.rb b/features/steps/project/browse_git_repo.rb similarity index 100% rename from features/steps/project/project_browse_git_repo.rb rename to features/steps/project/browse_git_repo.rb diff --git a/features/steps/project/project_browse_tags.rb b/features/steps/project/browse_tags.rb similarity index 100% rename from features/steps/project/project_browse_tags.rb rename to features/steps/project/browse_tags.rb diff --git a/features/steps/project/create_project.rb b/features/steps/project/create.rb similarity index 100% rename from features/steps/project/create_project.rb rename to features/steps/project/create.rb index b59345e707..b42e5bd362 100644 --- a/features/steps/project/create_project.rb +++ b/features/steps/project/create.rb @@ -8,8 +8,8 @@ class CreateProject < Spinach::FeatureSteps end Then 'I should see project page' do - current_path.should == project_path(Project.last) page.should have_content "Empty" + current_path.should == project_path(Project.last) end And 'I should see empty project instuctions' do diff --git a/features/steps/project/deploy_keys.rb b/features/steps/project/deploy_keys.rb index 7f7492bfd6..914da31322 100644 --- a/features/steps/project/deploy_keys.rb +++ b/features/steps/project/deploy_keys.rb @@ -34,7 +34,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps end step 'other project has deploy key' do - @second_project = create :project, namespace: current_user.namespace + @second_project = create :project, namespace: create(:group) @second_project.team << [current_user, :master] create(:deploy_keys_project, project: @second_project) end diff --git a/features/steps/project/filter_labels.rb b/features/steps/project/filter_labels.rb new file mode 100644 index 0000000000..5926d69d6c --- /dev/null +++ b/features/steps/project/filter_labels.rb @@ -0,0 +1,70 @@ +class ProjectFilterLabels < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + Then 'I should see "bug" in labels filter' do + within ".labels-filter" do + page.should have_content "bug" + end + end + + And 'I should see "feature" in labels filter' do + within ".labels-filter" do + page.should have_content "feature" + end + end + + And 'I should see "enhancement" in labels filter' do + within ".labels-filter" do + page.should have_content "enhancement" + end + end + + Then 'I should see "Bugfix1" in issues list' do + within ".issues-list" do + page.should have_content "Bugfix1" + end + end + + And 'I should see "Bugfix2" in issues list' do + within ".issues-list" do + page.should have_content "Bugfix2" + end + end + + And 'I should not see "Bugfix2" in issues list' do + within ".issues-list" do + page.should_not have_content "Bugfix2" + end + end + + And 'I should not see "Feature1" in issues list' do + within ".issues-list" do + page.should_not have_content "Feature1" + end + end + + Given 'I click link "bug"' do + click_link "bug" + end + + Given 'I click link "feature"' do + click_link "feature" + end + + And 'project "Shop" has issue "Bugfix1" with tags: "bug", "feature"' do + project = Project.find_by(name: "Shop") + create(:issue, title: "Bugfix1", project: project, label_list: ['bug', 'feature']) + end + + And 'project "Shop" has issue "Bugfix2" with tags: "bug", "enhancement"' do + project = Project.find_by(name: "Shop") + create(:issue, title: "Bugfix2", project: project, label_list: ['bug', 'enhancement']) + end + + And 'project "Shop" has issue "Feature1" with tags: "feature"' do + project = Project.find_by(name: "Shop") + create(:issue, title: "Feature1", project: project, label_list: 'feature') + end +end diff --git a/features/steps/project/project_fork.rb b/features/steps/project/fork.rb similarity index 76% rename from features/steps/project/project_fork.rb rename to features/steps/project/fork.rb index 858c7d11b3..c00d9014b1 100644 --- a/features/steps/project/project_fork.rb +++ b/features/steps/project/fork.rb @@ -11,22 +11,22 @@ class ForkProject < Spinach::FeatureSteps end step 'I am a member of project "Shop"' do - @project = Project.find_by_name "Shop" - @project ||= create(:project_with_code, name: "Shop", group: create(:group)) + @project = Project.find_by(name: "Shop") + @project ||= create(:project, name: "Shop", group: create(:group)) @project.team << [@user, :reporter] end step 'I should see the forked project page' do page.should have_content "Project was successfully forked." current_path.should include current_user.namespace.path - @forked_project = Project.find_by_namespace_id(current_user.namespace.path) + @forked_project = Project.find_by(namespace_id: current_user.namespace.path) end step 'I already have a project named "Shop" in my namespace' do current_user.namespace ||= create(:namespace) current_user.namespace.should_not be_nil current_user.namespace.path.should_not be_nil - @my_project = create(:project_with_code, name: "Shop", namespace: current_user.namespace) + @my_project = create(:project, name: "Shop", namespace: current_user.namespace) end step 'I should see a "Name has already been taken" warning' do diff --git a/features/steps/project/project_forked_merge_requests.rb b/features/steps/project/forked_merge_requests.rb similarity index 79% rename from features/steps/project/project_forked_merge_requests.rb rename to features/steps/project/forked_merge_requests.rb index f7bf085a42..3c497638d9 100644 --- a/features/steps/project/project_forked_merge_requests.rb +++ b/features/steps/project/forked_merge_requests.rb @@ -3,19 +3,19 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps include SharedProject include SharedNote include SharedPaths - include ChosenHelper + include Select2Helper step 'I am a member of project "Shop"' do - @project = Project.find_by_name "Shop" - @project ||= create(:project_with_code, name: "Shop") + @project = Project.find_by(name: "Shop") + @project ||= create(:project, name: "Shop") @project.team << [@user, :reporter] end step 'I have a project forked off of "Shop" called "Forked Shop"' do @forking_user = @user forked_project_link = build(:forked_project_link) - @forked_project = Project.find_by_name "Forked Shop" - @forked_project ||= create(:source_project_with_code, name: "Forked Shop", forked_project_link: forked_project_link, creator_id: @forking_user.id , namespace: @forking_user.namespace) + @forked_project = Project.find_by(name: "Forked Shop") + @forked_project ||= create(:project, name: "Forked Shop", forked_project_link: forked_project_link, creator_id: @forking_user.id , namespace: @forking_user.namespace) forked_project_link.forked_from_project = @project forked_project_link.forked_to_project = @forked_project @@ -42,17 +42,18 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps end step 'I fill out a "Merge Request On Forked Project" merge request' do - chosen @forked_project.id, from: "#merge_request_source_project_id" - chosen @project.id, from: "#merge_request_target_project_id" + select2 @forked_project.id, from: "#merge_request_source_project_id" + select2 @project.id, from: "#merge_request_target_project_id" find(:select, "merge_request_source_project_id", {}).value.should == @forked_project.id.to_s find(:select, "merge_request_target_project_id", {}).value.should == @project.id.to_s - chosen "master", from: "#merge_request_source_branch" - chosen "stable", from: "#merge_request_target_branch" + select2 "master", from: "#merge_request_source_branch" + select2 "stable", from: "#merge_request_target_branch" find(:select, "merge_request_source_branch", {}).value.should == 'master' find(:select, "merge_request_target_branch", {}).value.should == 'stable' + click_button "Compare branches" fill_in "merge_request_title", with: "Merge Request On Forked Project" end @@ -114,7 +115,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps end step 'project "Forked Shop" has push event' do - @forked_project = Project.find_by_name("Forked Shop") + @forked_project = Project.find_by(name: "Forked Shop") data = { before: "0000000000000000000000000000000000000000", @@ -148,31 +149,27 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps current_path.should == edit_project_merge_request_path(@project, @merge_request) page.should have_content "Edit merge request ##{@merge_request.id}" find("#merge_request_title").value.should == "Merge Request On Forked Project" - find("#merge_request_source_project_id").value.should == @forked_project.id.to_s - find("#merge_request_target_project_id").value.should == @project.id.to_s - find("#merge_request_source_branch").value.should have_content "master" - verify_commit_link(".mr_source_commit",@forked_project) - find("#merge_request_target_branch").value.should have_content "stable" - verify_commit_link(".mr_target_commit",@project) end step 'I fill out an invalid "Merge Request On Forked Project" merge request' do - #If this isn't filled in the rest of the validations won't be triggered - fill_in "merge_request_title", with: "Merge Request On Forked Project" + select "Select branch", from: "merge_request_target_branch" find(:select, "merge_request_source_project_id", {}).value.should == @forked_project.id.to_s - find(:select, "merge_request_target_project_id", {}).value.should == @forked_project.id.to_s + find(:select, "merge_request_target_project_id", {}).value.should == project.id.to_s find(:select, "merge_request_source_branch", {}).value.should == "" find(:select, "merge_request_target_branch", {}).value.should == "" + click_button "Compare branches" end step 'I should see validation errors' do - page.should have_content "Source branch can't be blank" - page.should have_content "Target branch can't be blank" - page.should have_content "Branch conflict You can not use same project/branch for source and target" + page.should have_content "You must select source and target branch" + end + + step 'the target repository should be the original repository' do + page.should have_select("merge_request_target_project_id", selected: project.path_with_namespace) end def project - @project ||= Project.find_by_name!("Shop") + @project ||= Project.find_by!(name: "Shop") end # Verify a link is generated against the correct project diff --git a/features/steps/project/project_graph.rb b/features/steps/project/graph.rb similarity index 86% rename from features/steps/project/project_graph.rb rename to features/steps/project/graph.rb index 50942b3cbb..89fe5fdead 100644 --- a/features/steps/project/project_graph.rb +++ b/features/steps/project/graph.rb @@ -7,7 +7,7 @@ class ProjectGraph < Spinach::FeatureSteps end When 'I visit project "Shop" graph page' do - project = Project.find_by_name("Shop") + project = Project.find_by(name: "Shop") visit project_graph_path(project, "master") end end diff --git a/features/steps/project/project_hooks.rb b/features/steps/project/hooks.rb similarity index 88% rename from features/steps/project/project_hooks.rb rename to features/steps/project/hooks.rb index 36555fb8e8..19ff324454 100644 --- a/features/steps/project/project_hooks.rb +++ b/features/steps/project/hooks.rb @@ -1,9 +1,12 @@ +require 'webmock' + class ProjectHooks < Spinach::FeatureSteps include SharedAuthentication include SharedProject include SharedPaths include RSpec::Matchers include RSpec::Mocks::ExampleMethods + include WebMock::API Given 'project has hook' do @hook = create(:project_hook, project: current_project) @@ -25,8 +28,7 @@ class ProjectHooks < Spinach::FeatureSteps end When 'I click test hook button' do - test_hook_context = double(execute: true) - TestHookContext.should_receive(:new).and_return(test_hook_context) + stub_request(:post, @hook.url).to_return(status: 200) click_link 'Test Hook' end diff --git a/features/steps/project/issue_tracker.rb b/features/steps/project/issue_tracker.rb new file mode 100644 index 0000000000..c2fd4e15c9 --- /dev/null +++ b/features/steps/project/issue_tracker.rb @@ -0,0 +1,31 @@ +class ProjectIssueTracker < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + step 'project "Shop" has issues enabled' do + @project = Project.find_by(name: "Shop") + @project ||= create(:project, name: "Shop", namespace: @user.namespace) + @project.issues_enabled = true + end + + step 'change the issue tracker to "GitLab"' do + select 'GitLab', from: 'project_issues_tracker' + end + + step 'I the project should have "GitLab" as issue tracker' do + find_field('project_issues_tracker').value.should == 'gitlab' + end + + step 'change the issue tracker to "Redmine"' do + select 'Redmine', from: 'project_issues_tracker' + end + + step 'I the project should have "Redmine" as issue tracker' do + find_field('project_issues_tracker').value.should == 'redmine' + end + + And 'I save project' do + click_button 'Save changes' + end +end diff --git a/features/steps/project/project_issues.rb b/features/steps/project/issues.rb similarity index 75% rename from features/steps/project/project_issues.rb rename to features/steps/project/issues.rb index 801fff78a5..d1f3ba25a2 100644 --- a/features/steps/project/project_issues.rb +++ b/features/steps/project/issues.rb @@ -3,6 +3,7 @@ class ProjectIssues < Spinach::FeatureSteps include SharedProject include SharedNote include SharedPaths + include SharedMarkdown Given 'I should see "Release 0.4" in issues' do page.should have_content "Release 0.4" @@ -54,7 +55,7 @@ class ProjectIssues < Spinach::FeatureSteps end Then 'I should see issue "500 error on profile"' do - issue = Issue.find_by_title("500 error on profile") + issue = Issue.find_by(title: "500 error on profile") page.should have_content issue.title page.should have_content issue.author_name page.should have_content issue.project.name @@ -81,14 +82,14 @@ class ProjectIssues < Spinach::FeatureSteps end Given 'project "Shop" has milestone "v2.2"' do - project = Project.find_by_name("Shop") + project = Project.find_by(name: "Shop") milestone = create(:milestone, title: "v2.2", project: project) 3.times { create(:issue, project: project, milestone: milestone) } end And 'project "Shop" has milestone "v3.0"' do - project = Project.find_by_name("Shop") + project = Project.find_by(name: "Shop") milestone = create(:milestone, title: "v3.0", project: project) 3.times { create(:issue, project: project, milestone: milestone) } @@ -104,28 +105,30 @@ class ProjectIssues < Spinach::FeatureSteps end When 'I select first assignee from "Shop" project' do - project = Project.find_by_name "Shop" + project = Project.find_by(name: "Shop") first_assignee = project.users.first select first_assignee.name, from: "assignee_id" end Then 'I should see first assignee from "Shop" as selected assignee' do issues_assignee_selector = "#issue_assignee_id_chzn > a" - project = Project.find_by_name "Shop" + project = Project.find_by(name: "Shop") assignee_name = project.users.first.name page.find(issues_assignee_selector).should have_content(assignee_name) end And 'project "Shop" have "Release 0.4" open issue' do - project = Project.find_by_name("Shop") + project = Project.find_by(name: "Shop") create(:issue, title: "Release 0.4", project: project, - author: project.users.first) + author: project.users.first, + description: "# Description header" + ) end And 'project "Shop" have "Tweet control" open issue' do - project = Project.find_by_name("Shop") + project = Project.find_by(name: "Shop") create(:issue, title: "Tweet control", project: project, @@ -133,10 +136,31 @@ class ProjectIssues < Spinach::FeatureSteps end And 'project "Shop" have "Release 0.3" closed issue' do - project = Project.find_by_name("Shop") + project = Project.find_by(name: "Shop") create(:closed_issue, title: "Release 0.3", project: project, author: project.users.first) end + + Given 'empty project "Empty Project"' do + create :empty_project, name: 'Empty Project', namespace: @user.namespace + end + + When 'I visit empty project page' do + project = Project.find_by(name: 'Empty Project') + visit project_path(project) + end + + And 'I see empty project details with ssh clone info' do + project = Project.find_by(name: 'Empty Project') + page.all(:css, '.git-empty .clone').each do |element| + element.text.should include(project.url_to_repo) + end + end + + When "I visit empty project's issues page" do + project = Project.find_by(name: 'Empty Project') + visit project_issues_path(project) + end end diff --git a/features/steps/project/project_labels.rb b/features/steps/project/labels.rb similarity index 92% rename from features/steps/project/project_labels.rb rename to features/steps/project/labels.rb index 915190f3da..0907cdb526 100644 --- a/features/steps/project/project_labels.rb +++ b/features/steps/project/labels.rb @@ -16,7 +16,7 @@ class ProjectLabels < Spinach::FeatureSteps end And 'project "Shop" have issues tags: "bug", "feature"' do - project = Project.find_by_name("Shop") + project = Project.find_by(name: "Shop") ['bug', 'feature'].each do |label| create(:issue, project: project, label_list: label) end diff --git a/features/steps/project/project_markdown_render.rb b/features/steps/project/markdown_render.rb similarity index 52% rename from features/steps/project/project_markdown_render.rb rename to features/steps/project/markdown_render.rb index 95d73c9362..c94de28306 100644 --- a/features/steps/project/project_markdown_render.rb +++ b/features/steps/project/markdown_render.rb @@ -1,10 +1,14 @@ +# If you need to modify the existing seed repository for your tests, +# it is recommended that you make the changes on the `markdown` branch of the seed project repository, +# which should only be used by tests in this file. See `/spec/factories.rb#project` for more info. class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps include SharedAuthentication include SharedPaths + include SharedMarkdown And 'I own project "Delta"' do - @project = Project.find_by_name "Delta" - @project ||= create(:project_with_code, name: "Delta", namespace: @user.namespace) + @project = Project.find_by(name: "Delta") + @project ||= create(:project, name: "Delta", namespace: @user.namespace) @project.team << [@user, :master] end @@ -21,6 +25,8 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps page.should have_link "GitLab API website" page.should have_link "Rake tasks" page.should have_link "backup and restore procedure" + page.should have_link "GitLab API doc directory" + page.should have_link "Maintenance" end And 'I click on Gitlab API in README' do @@ -42,6 +48,37 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps page.should have_content "maintenance.md" end + And 'I click on GitLab API doc directory in README' do + click_link "GitLab API doc directory" + end + + Then 'I should see correct doc/api directory rendered' do + current_path.should == project_tree_path(@project, "master/doc/api") + page.should have_content "README.md" + page.should have_content "users.md" + end + + And 'I click on Maintenance in README' do + click_link "Maintenance" + end + + Then 'I should see correct maintenance file rendered' do + current_path.should == project_blob_path(@project, "master/doc/raketasks/maintenance.md") + page.should have_content "bundle exec rake gitlab:env:info RAILS_ENV=production" + end + + And 'I click on link "empty" in the README' do + within('.readme-holder') do + click_link "empty" + end + end + + And 'I click on link "id" in the README' do + within('.readme-holder') do + click_link "#id" + end + end + And 'I navigate to the doc/api/README' do click_link "doc" click_link "api" @@ -68,10 +105,24 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps click_link "Rake tasks" end + # Markdown branch + When 'I visit markdown branch' do visit project_tree_path(@project, "markdown") end + When 'I visit markdown branch "README.md" blob' do + visit project_blob_path(@project, "markdown/README.md") + end + + When 'I visit markdown branch "d" tree' do + visit project_tree_path(@project, "markdown/d") + end + + When 'I visit markdown branch "d/README.md" blob' do + visit project_blob_path(@project, "markdown/d/README.md") + end + Then 'I should see files from repository in markdown branch' do current_path.should == project_tree_path(@project, "markdown") page.should have_content "Gemfile" @@ -102,13 +153,57 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps page.should have_content "Get a list of users." end + # Expected link contents + + Then 'The link with text "empty" should have url "tree/markdown"' do + find('a', text: /^empty$/)['href'] == current_host + project_tree_path(@project, "markdown") + end + + Then 'The link with text "empty" should have url "blob/markdown/README.md"' do + find('a', text: /^empty$/)['href'] == current_host + project_blob_path(@project, "markdown/README.md") + end + + Then 'The link with text "empty" should have url "tree/markdown/d"' do + find('a', text: /^empty$/)['href'] == current_host + project_tree_path(@project, "markdown/d") + end + + Then 'The link with text "empty" should have url "blob/markdown/d/README.md"' do + find('a', text: /^empty$/)['href'] == current_host + project_blob_path(@project, "markdown/d/README.md") + end + + Then 'The link with text "ID" should have url "tree/markdownID"' do + find('a', text: /^#id$/)['href'] == current_host + project_tree_path(@project, "markdown") + '#id' + end + + Then 'The link with text "/ID" should have url "tree/markdownID"' do + find('a', text: /^\/#id$/)['href'] == current_host + project_tree_path(@project, "markdown") + '#id' + end + + Then 'The link with text "README.mdID" should have url "blob/markdown/README.mdID"' do + find('a', text: /^README.md#id$/)['href'] == current_host + project_blob_path(@project, "markdown/README.md") + '#id' + end + + Then 'The link with text "d/README.mdID" should have url "blob/markdown/d/README.mdID"' do + find('a', text: /^d\/README.md#id$/)['href'] == current_host + project_blob_path(@project, "d/markdown/README.md") + '#id' + end + + Then 'The link with text "ID" should have url "blob/markdown/README.mdID"' do + find('a', text: /^#id$/)['href'] == current_host + project_blob_path(@project, "markdown/README.md") + '#id' + end + + Then 'The link with text "/ID" should have url "blob/markdown/README.mdID"' do + find('a', text: /^\/#id$/)['href'] == current_host + project_blob_path(@project, "markdown/README.md") + '#id' + end + + # Wiki + Given 'I go to wiki page' do click_link "Wiki" current_path.should == project_wiki_path(@project, "home") end And 'I add various links to the wiki page' do - fill_in "wiki[content]", with: "[test](test)\n[GitLab API doc](doc/api/README.md)\n[Rake tasks](doc/raketasks)\n" + fill_in "wiki[content]", with: "[test](test)\n[GitLab API doc](api)\n[Rake tasks](raketasks)\n" fill_in "wiki[message]", with: "Adding links to wiki" click_button "Create page" end @@ -118,13 +213,23 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps page.should have_content "test GitLab API doc Rake tasks" end + step 'I add a header to the wiki page' do + fill_in "wiki[content]", with: "# Wiki header\n" + fill_in "wiki[message]", with: "Add header to wiki" + click_button "Create page" + end + + step 'Wiki header should have correct id and link' do + header_should_have_correct_id_and_link(1, 'Wiki header', 'wiki-header') + end + And 'I click on test link' do click_link "test" end Then 'I see new wiki page named test' do current_path.should == project_wiki_path(@project, "test") - page.should have_content "Editing page" + page.should have_content "Editing" end When 'I go back to wiki page home' do @@ -137,8 +242,8 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps end Then 'I see Gitlab API document' do - current_path.should == project_blob_path(@project, "master/doc/api/README.md") - page.should have_content "Status codes" + current_path.should == project_wiki_path(@project, "api") + page.should have_content "Editing" end And 'I click on Rake tasks link' do @@ -146,21 +251,8 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps end Then 'I see Rake tasks directory' do - current_path.should == project_tree_path(@project, "master/doc/raketasks") - page.should have_content "backup_restore.md" - page.should have_content "maintenance.md" - end - - Given 'I visit to the help page' do - visit help_path - end - - And 'I select a page with markdown' do - click_link "Rake Tasks" - end - - Then 'I should see a help page with markdown' do - page.should have_content "GitLab provides some specific rake tasks to enable special features or perform maintenance tasks" + current_path.should == project_wiki_path(@project, "raketasks") + page.should have_content "Editing" end Given 'I go directory which contains README file' do @@ -176,4 +268,12 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps current_path.should == project_blob_path(@project, "master/doc/api/users.md") page.should have_content "List users" end + + step 'Header "Application details" should have correct id and link' do + header_should_have_correct_id_and_link(2, 'Application details', 'application-details') + end + + step 'Header "GitLab API" should have correct id and link' do + header_should_have_correct_id_and_link(1, 'GitLab API', 'gitlab-api') + end end diff --git a/features/steps/project/merge_requests.rb b/features/steps/project/merge_requests.rb new file mode 100644 index 0000000000..e0aec699a5 --- /dev/null +++ b/features/steps/project/merge_requests.rb @@ -0,0 +1,276 @@ +class ProjectMergeRequests < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedNote + include SharedPaths + include SharedMarkdown + + step 'I click link "New Merge Request"' do + click_link "New Merge Request" + end + + step 'I click link "Bug NS-04"' do + click_link "Bug NS-04" + end + + step 'I click link "All"' do + click_link "All" + end + + step 'I click link "Closed"' do + click_link "Closed" + end + + step 'I should see merge request "Wiki Feature"' do + within '.merge-request' do + page.should have_content "Wiki Feature" + end + end + + step 'I should see closed merge request "Bug NS-04"' do + merge_request = MergeRequest.find_by!(title: "Bug NS-04") + merge_request.closed?.should be_true + page.should have_content "Closed by" + end + + step 'I should see merge request "Bug NS-04"' do + page.should have_content "Bug NS-04" + end + + step 'I should see "Bug NS-04" in merge requests' do + page.should have_content "Bug NS-04" + end + + step 'I should see "Feature NS-03" in merge requests' do + page.should have_content "Feature NS-03" + end + + step 'I should not see "Feature NS-03" in merge requests' do + page.should_not have_content "Feature NS-03" + end + + + step 'I should not see "Bug NS-04" in merge requests' do + page.should_not have_content "Bug NS-04" + end + + step 'I click link "Close"' do + within '.page-title' do + click_link "Close" + end + end + + step 'I submit new merge request "Wiki Feature"' do + select "master", from: "merge_request_source_branch" + select "notes_refactoring", from: "merge_request_target_branch" + click_button "Compare branches" + fill_in "merge_request_title", with: "Wiki Feature" + click_button "Submit merge request" + end + + step 'project "Shop" have "Bug NS-04" open merge request' do + create(:merge_request, + title: "Bug NS-04", + source_project: project, + target_project: project, + source_branch: 'stable', + target_branch: 'master', + author: project.users.first, + description: "# Description header" + ) + end + + step 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do + create(:merge_request_with_diffs, + title: "Bug NS-05", + source_project: project, + target_project: project, + author: project.users.first) + end + + step 'project "Shop" have "Feature NS-03" closed merge request' do + create(:closed_merge_request, + title: "Feature NS-03", + source_project: project, + target_project: project, + author: project.users.first) + end + + step 'I switch to the diff tab' do + visit diffs_project_merge_request_path(project, merge_request) + end + + step 'I switch to the merge request\'s comments tab' do + visit project_merge_request_path(project, merge_request) + end + + step 'I click on the first commit in the merge request' do + within '.first-commits' do + click_link merge_request.commits.first.short_id(8) + end + end + + step 'I leave a comment on the diff page' do + init_diff_note + leave_comment "One comment to rule them all" + end + + step 'I leave a comment on the diff page in commit' do + find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click + leave_comment "One comment to rule them all" + end + + step 'I leave a comment like "Line is wrong" on line 185 of the first file' do + init_diff_note + leave_comment "Line is wrong" + end + + step 'I leave a comment like "Line is wrong" on line 185 of the first file in commit' do + find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click + leave_comment "Line is wrong" + end + + step 'I should see a discussion has started on line 185' do + page.should have_content "#{current_user.name} started a discussion on this merge request diff" + page.should have_content "app/assets/stylesheets/tree.scss:L185" + page.should have_content "Line is wrong" + end + + step 'I should see a discussion has started on commit b1e6a9dbf1:L185' do + page.should have_content "#{current_user.name} started a discussion on commit" + page.should have_content "app/assets/stylesheets/tree.scss:L185" + page.should have_content "Line is wrong" + end + + step 'I should see a discussion has started on commit b1e6a9dbf1' do + page.should have_content "#{current_user.name} started a discussion on commit" + page.should have_content "One comment to rule them all" + page.should have_content "app/assets/stylesheets/tree.scss:L185" + end + + step 'merge request is mergeable' do + page.should have_content 'You can accept this request automatically' + end + + step 'I modify merge commit message' do + find('.modify-merge-commit-link').click + fill_in 'merge_commit_message', with: "wow such merge" + end + + step 'merge request "Bug NS-05" is mergeable' do + merge_request.mark_as_mergeable + end + + step 'I accept this merge request' do + click_button "Accept Merge Request" + end + + step 'I should see merged request' do + within '.issue-box' do + page.should have_content "Merged" + end + end + + step 'I click link "Reopen"' do + within '.page-title' do + click_link "Reopen" + end + end + + step 'I should see reopened merge request "Bug NS-04"' do + within '.state-label' do + page.should have_content "Open" + end + end + + step 'I click link "Hide inline discussion" of the second file' do + within '.files [id^=diff]:nth-child(2)' do + click_link "Diff comments" + end + end + + step 'I click link "Show inline discussion" of the second file' do + within '.files [id^=diff]:nth-child(2)' do + click_link "Diff comments" + end + end + + step 'I should not see a comment like "Line is wrong" in the second file' do + within '.files [id^=diff]:nth-child(2)' do + page.should_not have_visible_content "Line is wrong" + end + end + + step 'I should see a comment like "Line is wrong" in the second file' do + within '.files [id^=diff]:nth-child(2) .note-text' do + page.should have_visible_content "Line is wrong" + end + end + + step 'I leave a comment like "Line is correct" on line 12 of the first file' do + init_diff_note_first_file + + within(".js-discussion-note-form") do + fill_in "note_note", with: "Line is correct" + click_button "Add Comment" + end + + within ".files [id^=diff]:nth-child(1) .note-text" do + page.should have_content "Line is correct" + end + end + + step 'I leave a comment like "Line is wrong" on line 39 of the second file' do + init_diff_note_second_file + + within(".js-discussion-note-form") do + fill_in "note_note", with: "Line is wrong" + click_button "Add Comment" + end + + within ".files [id^=diff]:nth-child(2) .note-text" do + page.should have_content "Line is wrong" + end + end + + step 'I should still see a comment like "Line is correct" in the first file' do + within '.files [id^=diff]:nth-child(1) .note-text' do + page.should have_visible_content "Line is correct" + end + end + + def project + @project ||= Project.find_by!(name: "Shop") + end + + def merge_request + @merge_request ||= MergeRequest.find_by!(title: "Bug NS-05") + end + + def init_diff_note + find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click + end + + def leave_comment(message) + within(".js-discussion-note-form") do + fill_in "note_note", with: message + click_button "Add Comment" + end + + within ".note-text" do + page.should have_content message + end + end + + def init_diff_note_first_file + find('a[data-line-code="a5cc2925ca8258af241be7e5b0381edf30266302_12_12"]').click + end + + def init_diff_note_second_file + find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_28_39"]').click + end + + def have_visible_content (text) + have_css("*", text: text, visible: true) + end +end diff --git a/features/steps/project/project_milestones.rb b/features/steps/project/milestones.rb similarity index 72% rename from features/steps/project/project_milestones.rb rename to features/steps/project/milestones.rb index c4d0d176f3..9ce18fbaab 100644 --- a/features/steps/project/project_milestones.rb +++ b/features/steps/project/milestones.rb @@ -2,9 +2,10 @@ class ProjectMilestones < Spinach::FeatureSteps include SharedAuthentication include SharedProject include SharedPaths + include SharedMarkdown Then 'I should see milestone "v2.2"' do - milestone = @project.milestones.find_by_title("v2.2") + milestone = @project.milestones.find_by(title: "v2.2") page.should have_content(milestone.title[0..10]) page.should have_content(milestone.expires_at) page.should have_content("Browse Issues") @@ -24,22 +25,25 @@ class ProjectMilestones < Spinach::FeatureSteps end Then 'I should see milestone "v2.3"' do - milestone = @project.milestones.find_by_title("v2.3") + milestone = @project.milestones.find_by(title: "v2.3") page.should have_content(milestone.title[0..10]) page.should have_content(milestone.expires_at) page.should have_content("Browse Issues") end And 'project "Shop" has milestone "v2.2"' do - project = Project.find_by_name("Shop") - milestone = create(:milestone, title: "v2.2", project: project) - + project = Project.find_by(name: "Shop") + milestone = create(:milestone, + title: "v2.2", + project: project, + description: "# Description header" + ) 3.times { create(: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') + 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) diff --git a/features/steps/project/multiselect_blob.rb b/features/steps/project/multiselect_blob.rb new file mode 100644 index 0000000000..3d330e837c --- /dev/null +++ b/features/steps/project/multiselect_blob.rb @@ -0,0 +1,58 @@ +class ProjectMultiselectBlob < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + class << self + def click_line_steps(*line_numbers) + line_numbers.each do |line_number| + step "I click line #{line_number} in file" do + find("#L#{line_number}").click + end + + step "I shift-click line #{line_number} in file" do + script = "$('#L#{line_number}').trigger($.Event('click', { shiftKey: true }));" + page.evaluate_script(script) + end + end + end + + def check_state_steps(*ranges) + ranges.each do |range| + fragment = range.kind_of?(Array) ? "L#{range.first}-#{range.last}" : "L#{range}" + pluralization = range.kind_of?(Array) ? "s" : "" + + step "I should see \"#{fragment}\" as URI fragment" do + URI.parse(current_url).fragment.should == fragment + end + + step "I should see line#{pluralization} #{fragment[1..-1]} highlighted" do + ids = Array(range).map { |n| "LC#{n}" } + extra = false + + highlighted = all("#tree-content-holder .highlight .line.hll") + highlighted.each do |element| + extra ||= ids.delete(element[:id]).nil? + end + + extra.should be_false and ids.should be_empty + end + end + end + end + + click_line_steps *Array(1..5) + check_state_steps *Array(1..5), Array(1..2), Array(1..3), Array(1..4), Array(1..5), Array(3..5) + + step 'I go back in history' do + page.evaluate_script("window.history.back()") + end + + step 'I go forward in history' do + page.evaluate_script("window.history.forward()") + end + + step 'I click on "Gemfile.lock" file in repo' do + click_link "Gemfile.lock" + end +end \ No newline at end of file diff --git a/features/steps/project/project_network_graph.rb b/features/steps/project/network_graph.rb similarity index 77% rename from features/steps/project/project_network_graph.rb rename to features/steps/project/network_graph.rb index 127adecf7e..1c5cfcc6c6 100644 --- a/features/steps/project/project_network_graph.rb +++ b/features/steps/project/network_graph.rb @@ -1,5 +1,6 @@ class ProjectNetworkGraph < Spinach::FeatureSteps include SharedAuthentication + include SharedPaths include SharedProject Then 'page should have network graph' do @@ -10,16 +11,16 @@ class ProjectNetworkGraph < Spinach::FeatureSteps # Stub Graph max_size to speed up test (10 commits vs. 650) Network::Graph.stub(max_count: 10) - project = Project.find_by_name("Shop") + project = Project.find_by(name: "Shop") visit project_network_path(project, "master") end And 'page should select "master" in select box' do - page.should have_selector '.chosen-single span', text: "master" + page.should have_selector '.select2-chosen', text: "master" end And 'page should select "v2.1.0" in select box' do - page.should have_selector '.chosen-single span', text: "v2.1.0" + page.should have_selector '.select2-chosen', text: "v2.1.0" end And 'page should have "master" on graph' do @@ -43,24 +44,24 @@ class ProjectNetworkGraph < Spinach::FeatureSteps sleep 2 end - Then 'page should have content not cotaining "v2.1.0"' do + Then 'page should have content not containing "v2.1.0"' do within '.network-graph' do page.should have_content 'cleaning' end end - Then 'page should not have content not cotaining "v2.1.0"' do + Then 'page should not have content not containing "v2.1.0"' do within '.network-graph' do page.should_not have_content 'cleaning' end end And 'page should select "stable" in select box' do - page.should have_selector '.chosen-single span', text: "stable" + page.should have_selector '.select2-chosen', text: "stable" end And 'page should select "v2.1.0" in select box' do - page.should have_selector '.chosen-single span', text: "v2.1.0" + page.should have_selector '.select2-chosen', text: "v2.1.0" end And 'page should have "stable" on graph' do @@ -70,7 +71,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps end When 'I looking for a commit by SHA of "v2.1.0"' do - within ".content .search" do + within ".network-form" do fill_in 'extended_sha1', with: '98d6492' find('button').click end @@ -84,7 +85,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps end When 'I look for a commit by ";"' do - within ".content .search" do + within ".network-form" do fill_in 'extended_sha1', with: ';' find('button').click end diff --git a/features/steps/project/project.rb b/features/steps/project/project.rb index a96b086fae..92728d474b 100644 --- a/features/steps/project/project.rb +++ b/features/steps/project/project.rb @@ -3,16 +3,25 @@ class ProjectFeature < Spinach::FeatureSteps include SharedProject include SharedPaths - And 'change project settings' do + step 'change project settings' do fill_in 'project_name', with: 'NewName' uncheck 'project_issues_enabled' end - And 'I save project' do + step 'I save project' do click_button 'Save changes' end - Then 'I should see project with new settings' do + step 'I should see project with new settings' do find_field('project_name').value.should == 'NewName' end + + step 'change project path settings' do + fill_in "project_path", with: "new-path" + click_button "Rename" + end + + step 'I should see project with new path settings' do + project.path.should == "new-path" + end end diff --git a/features/steps/project/project_browse_branches.rb b/features/steps/project/project_browse_branches.rb deleted file mode 100644 index e77825411f..0000000000 --- a/features/steps/project/project_browse_branches.rb +++ /dev/null @@ -1,35 +0,0 @@ -class ProjectBrowseBranches < Spinach::FeatureSteps - include SharedAuthentication - include SharedProject - include SharedPaths - - Then 'I should see "Shop" recent branches list' do - page.should have_content "Branches" - page.should have_content "master" - end - - Given 'I click link "All"' do - click_link "All" - end - - Then 'I should see "Shop" all branches list' do - page.should have_content "Branches" - page.should have_content "master" - end - - Given 'I click link "Protected"' do - click_link "Protected" - end - - Then 'I should see "Shop" protected branches list' do - within ".protected-branches-list" do - page.should have_content "stable" - page.should_not have_content "master" - end - end - - And 'project "Shop" has protected branches' do - project = Project.find_by_name("Shop") - project.protected_branches.create(name: "stable") - end -end diff --git a/features/steps/project/project_browse_files.rb b/features/steps/project/project_browse_files.rb deleted file mode 100644 index 71360fb6bd..0000000000 --- a/features/steps/project/project_browse_files.rb +++ /dev/null @@ -1,44 +0,0 @@ -class ProjectBrowseFiles < Spinach::FeatureSteps - include SharedAuthentication - include SharedProject - include SharedPaths - - Then 'I should see files from repository' do - page.should have_content "app" - page.should have_content "history" - page.should have_content "Gemfile" - end - - Then 'I should see files from repository for "8470d70"' do - current_path.should == project_tree_path(@project, "8470d70") - page.should have_content "app" - page.should have_content "history" - page.should have_content "Gemfile" - end - - Given 'I click on "Gemfile.lock" file in repo' do - click_link "Gemfile.lock" - end - - Then 'I should see it content' do - page.should have_content "DEPENDENCIES" - end - - And 'I click link "raw"' do - click_link "raw" - end - - Then 'I should see raw file content' do - page.source.should == ValidCommit::BLOB_FILE - end - - Given 'I click button "edit"' do - click_link 'edit' - end - - Then 'I can edit code' do - page.execute_script('editor.setValue("GitlabFileEditor")') - page.evaluate_script('editor.getValue()').should == "GitlabFileEditor" - end - -end diff --git a/features/steps/project/project_merge_requests.rb b/features/steps/project/project_merge_requests.rb deleted file mode 100644 index 3dc934a611..0000000000 --- a/features/steps/project/project_merge_requests.rb +++ /dev/null @@ -1,163 +0,0 @@ -class ProjectMergeRequests < Spinach::FeatureSteps - include SharedAuthentication - include SharedProject - include SharedNote - include SharedPaths - - Given 'I click link "New Merge Request"' do - click_link "New Merge Request" - end - - Given 'I click link "Bug NS-04"' do - click_link "Bug NS-04" - end - - Given 'I click link "All"' do - click_link "All" - end - - Given 'I click link "Closed"' do - click_link "Closed" - end - - Then 'I should see merge request "Wiki Feature"' do - within '.merge-request' do - page.should have_content "Wiki Feature" - end - end - - Then 'I should see closed merge request "Bug NS-04"' do - merge_request = MergeRequest.find_by_title!("Bug NS-04") - merge_request.closed?.should be_true - page.should have_content "Closed by" - end - - Then 'I should see merge request "Bug NS-04"' do - page.should have_content "Bug NS-04" - end - - Then 'I should see "Bug NS-04" in merge requests' do - page.should have_content "Bug NS-04" - end - - Then 'I should see "Feature NS-03" in merge requests' do - page.should have_content "Feature NS-03" - end - - And 'I should not see "Feature NS-03" in merge requests' do - page.should_not have_content "Feature NS-03" - end - - - And 'I should not see "Bug NS-04" in merge requests' do - page.should_not have_content "Bug NS-04" - end - - And 'I click link "Close"' do - click_link "Close" - end - - And 'I submit new merge request "Wiki Feature"' do - fill_in "merge_request_title", with: "Wiki Feature" - - # this must come first, so that the target branch is set - # by the time the "select" for "notes_refactoring" is executed - select project.path_with_namespace, from: "merge_request_target_project_id" - select "master", from: "merge_request_source_branch" - - find(:select, "merge_request_target_project_id", {}).value.should == project.id.to_s - find(:select, "merge_request_source_project_id", {}).value.should == project.id.to_s - - # using "notes_refactoring" because "Bug NS-04" uses master/stable, - # this will fail merge_request validation if the branches are the same - find(:select, "merge_request_target_branch", {}).find(:option, "notes_refactoring", {}).value.should == "notes_refactoring" - select "notes_refactoring", from: "merge_request_target_branch" - - click_button "Submit merge request" - end - - And 'project "Shop" have "Bug NS-04" open merge request' do - create(:merge_request, - title: "Bug NS-04", - source_project: project, - target_project: project, - author: project.users.first) - end - - And 'project "Shop" have "Bug NS-05" open merge request with diffs inside' do - create(:merge_request_with_diffs, - title: "Bug NS-05", - source_project: project, - target_project: project, - author: project.users.first) - end - - And 'project "Shop" have "Feature NS-03" closed merge request' do - create(:closed_merge_request, - title: "Feature NS-03", - source_project: project, - target_project: project, - author: project.users.first) - end - - And 'I switch to the diff tab' do - visit diffs_project_merge_request_path(project, merge_request) - end - - And 'I switch to the merge request\'s comments tab' do - visit project_merge_request_path(project, merge_request) - end - - And 'I click on the first commit in the merge request' do - click_link merge_request.commits.first.short_id(8) - end - - And 'I leave a comment on the diff page' do - init_diff_note - - within('.js-temp-notes-holder') do - fill_in "note_note", with: "One comment to rule them all" - click_button "Add Comment" - end - end - - And 'I leave a comment like "Line is wrong" on line 185 of the first file' do - init_diff_note - - within(".js-temp-notes-holder") do - fill_in "note_note", with: "Line is wrong" - click_button "Add Comment" - sleep 0.05 - end - end - - Then 'I should see a discussion has started on line 185' do - page.should have_content "#{current_user.name} started a discussion on this merge request diff" - page.should have_content "app/assets/stylesheets/tree.scss:L185" - page.should have_content "Line is wrong" - end - - Then 'I should see a discussion has started on commit bcf03b5de6c:L185' do - page.should have_content "#{current_user.name} started a discussion on commit" - page.should have_content "app/assets/stylesheets/tree.scss:L185" - page.should have_content "Line is wrong" - end - - Then 'I should see a discussion has started on commit bcf03b5de6c' do - page.should have_content "#{current_user.name} started a discussion on commit bcf03b5de6c" - page.should have_content "One comment to rule them all" - page.should have_content "app/assets/stylesheets/tree.scss:L185" - end - - def project - @project ||= Project.find_by_name!("Shop") - end - - def merge_request - @merge_request ||= MergeRequest.find_by_title!("Bug NS-05") - end - - def init_diff_note - find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click - end -end diff --git a/features/steps/project/project_services.rb b/features/steps/project/project_services.rb deleted file mode 100644 index 70eafc875d..0000000000 --- a/features/steps/project/project_services.rb +++ /dev/null @@ -1,75 +0,0 @@ -class ProjectServices < Spinach::FeatureSteps - include SharedAuthentication - include SharedProject - include SharedPaths - - When 'I visit project "Shop" services page' do - visit project_services_path(@project) - end - - Then 'I should see list of available services' do - page.should have_content 'Services' - page.should have_content 'Campfire' - page.should have_content 'Hipchat' - page.should have_content 'GitLab CI' - end - - And 'I click gitlab-ci service link' do - click_link 'GitLab CI' - end - - And 'I fill gitlab-ci settings' do - check 'Active' - fill_in 'Project url', with: 'http://ci.gitlab.org/projects/3' - fill_in 'Token', with: 'verySecret' - click_button 'Save' - end - - Then 'I should see service settings saved' do - find_field('Project url').value.should == 'http://ci.gitlab.org/projects/3' - end - - And 'I click hipchat service link' do - click_link 'Hipchat' - end - - And 'I fill hipchat settings' do - check 'Active' - fill_in 'Room', with: 'gitlab' - fill_in 'Token', with: 'verySecret' - click_button 'Save' - end - - Then 'I should see hipchat service settings saved' do - find_field('Room').value.should == 'gitlab' - end - - - And 'I click pivotaltracker service link' do - click_link 'PivotalTracker' - end - - And 'I fill pivotaltracker settings' do - check 'Active' - fill_in 'Token', with: 'verySecret' - click_button 'Save' - end - - Then 'I should see pivotaltracker service settings saved' do - find_field('Token').value.should == 'verySecret' - end - - And 'I click Flowdock service link' do - click_link 'Flowdock' - end - - And 'I fill Flowdock settings' do - check 'Active' - fill_in 'Token', with: 'verySecret' - click_button 'Save' - end - - Then 'I should see Flowdock service settings saved' do - find_field('Token').value.should == 'verySecret' - end -end diff --git a/features/steps/project/public_projects.rb b/features/steps/project/public.rb similarity index 100% rename from features/steps/project/public_projects.rb rename to features/steps/project/public.rb diff --git a/features/steps/project/redirects.rb b/features/steps/project/redirects.rb new file mode 100644 index 0000000000..cfa4ce82be --- /dev/null +++ b/features/steps/project/redirects.rb @@ -0,0 +1,35 @@ +class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedProject + + step 'public project "Community"' do + create :project, :public, name: 'Community' + end + + step 'private project "Enterprise"' do + create :project, name: 'Enterprise' + end + + step 'I visit project "Community" page' do + project = Project.find_by(name: 'Community') + visit project_path(project) + end + + step 'I should see project "Community" home page' do + within '.project-home-title' do + page.should have_content 'Community' + end + end + + step 'I visit project "Enterprise" page' do + project = Project.find_by(name: 'Enterprise') + visit project_path(project) + end + + step 'I visit project "CommunityDoesNotExist" page' do + project = Project.find_by(name: 'Community') + visit project_path(project) + 'DoesNotExist' + end +end + diff --git a/features/steps/project/project_search_code.rb b/features/steps/project/search_code.rb similarity index 100% rename from features/steps/project/project_search_code.rb rename to features/steps/project/search_code.rb diff --git a/features/steps/project/services.rb b/features/steps/project/services.rb new file mode 100644 index 0000000000..0594a08a5e --- /dev/null +++ b/features/steps/project/services.rb @@ -0,0 +1,121 @@ +class ProjectServices < Spinach::FeatureSteps + include SharedAuthentication + include SharedProject + include SharedPaths + + step 'I visit project "Shop" services page' do + visit project_services_path(@project) + end + + step 'I should see list of available services' do + page.should have_content 'Project services' + page.should have_content 'Campfire' + page.should have_content 'Hipchat' + page.should have_content 'GitLab CI' + page.should have_content 'Assembla' + end + + step 'I click gitlab-ci service link' do + click_link 'GitLab CI' + end + + step 'I fill gitlab-ci settings' do + check 'Active' + fill_in 'Project url', with: 'http://ci.gitlab.org/projects/3' + fill_in 'Token', with: 'verySecret' + click_button 'Save' + end + + step 'I should see service settings saved' do + find_field('Project url').value.should == 'http://ci.gitlab.org/projects/3' + end + + step 'I click hipchat service link' do + click_link 'Hipchat' + end + + step 'I fill hipchat settings' do + check 'Active' + fill_in 'Room', with: 'gitlab' + fill_in 'Token', with: 'verySecret' + click_button 'Save' + end + + step 'I should see hipchat service settings saved' do + find_field('Room').value.should == 'gitlab' + end + + + step 'I click pivotaltracker service link' do + click_link 'PivotalTracker' + end + + step 'I fill pivotaltracker settings' do + check 'Active' + fill_in 'Token', with: 'verySecret' + click_button 'Save' + end + + step 'I should see pivotaltracker service settings saved' do + find_field('Token').value.should == 'verySecret' + end + + step 'I click Flowdock service link' do + click_link 'Flowdock' + end + + step 'I fill Flowdock settings' do + check 'Active' + fill_in 'Token', with: 'verySecret' + click_button 'Save' + end + + step 'I should see Flowdock service settings saved' do + find_field('Token').value.should == 'verySecret' + end + + step 'I click Assembla service link' do + click_link 'Assembla' + end + + step 'I fill Assembla settings' do + check 'Active' + fill_in 'Token', with: 'verySecret' + click_button 'Save' + end + + step 'I should see Assembla service settings saved' do + find_field('Token').value.should == 'verySecret' + end + + step 'I click email on push service link' do + click_link 'Emails on push' + end + + step 'I fill email on push settings' do + fill_in 'Recipients', with: 'qa@company.name' + click_button 'Save' + end + + step 'I should see email on push service settings saved' do + find_field('Recipients').value.should == 'qa@company.name' + end + + step 'I click Slack service link' do + click_link 'Slack' + end + + step 'I fill Slack settings' do + check 'Active' + fill_in 'Subdomain', with: 'gitlab' + fill_in 'Room', with: '#gitlab' + fill_in 'Token', with: 'verySecret' + click_button 'Save' + end + + step 'I should see Slack service settings saved' do + find_field('Subdomain').value.should == 'gitlab' + find_field('Room').value.should == '#gitlab' + find_field('Token').value.should == 'verySecret' + end +end diff --git a/features/steps/project/project_snippets.rb b/features/steps/project/snippets.rb similarity index 93% rename from features/steps/project/project_snippets.rb rename to features/steps/project/snippets.rb index 5082b31198..c3a76bea26 100644 --- a/features/steps/project/project_snippets.rb +++ b/features/steps/project/snippets.rb @@ -53,7 +53,6 @@ class ProjectSnippets < Spinach::FeatureSteps And 'I submit new snippet "Snippet three"' do fill_in "project_snippet_title", :with => "Snippet three" - select "forever", :from => "project_snippet_expires_at" fill_in "project_snippet_file_name", :with => "my_snippet.rb" within('.file-editor') do find(:xpath, "//input[@id='project_snippet_content']").set 'Content of snippet three' @@ -91,10 +90,10 @@ class ProjectSnippets < Spinach::FeatureSteps end def project - @project ||= Project.find_by_name!("Shop") + @project ||= Project.find_by!(name: "Shop") end def project_snippet - @project_snippet ||= ProjectSnippet.find_by_title!("Snippet One") + @project_snippet ||= ProjectSnippet.find_by!(title: "Snippet one") end end diff --git a/features/steps/project/project_team_management.rb b/features/steps/project/team_management.rb similarity index 82% rename from features/steps/project/project_team_management.rb rename to features/steps/project/team_management.rb index efebba1be2..ffc5016529 100644 --- a/features/steps/project/project_team_management.rb +++ b/features/steps/project/team_management.rb @@ -10,7 +10,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps end And 'I should see "Sam" in team list' do - user = User.find_by_name("Sam") + user = User.find_by(name: "Sam") page.should have_content(user.name) page.should have_content(user.username) end @@ -20,7 +20,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps end And 'I select "Mike" as "Reporter"' do - user = User.find_by_name("Mike") + user = User.find_by(name: "Mike") select2(user.id, from: "#user_ids", multiple: true) within "#new_team_member" do @@ -42,7 +42,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps end And 'I change "Sam" role to "Reporter"' do - user = User.find_by_name("Sam") + user = User.find_by(name: "Sam") within "#user_#{user.id}" do select "Reporter", from: "team_member_project_access" end @@ -59,7 +59,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps end And 'I should not see "Sam" in team list' do - user = User.find_by_name("Sam") + user = User.find_by(name: "Sam") page.should_not have_content(user.name) page.should_not have_content(user.username) end @@ -73,19 +73,19 @@ class ProjectTeamManagement < Spinach::FeatureSteps end And '"Sam" is "Shop" developer' do - user = User.find_by_name("Sam") - project = Project.find_by_name("Shop") + user = User.find_by(name: "Sam") + project = Project.find_by(name: "Shop") project.team << [user, :developer] end Given 'I own project "Website"' do - @project = create(:project, name: "Website", namespace: @user.namespace) + @project = create(:empty_project, name: "Website", namespace: @user.namespace) @project.team << [@user, :master] end And '"Mike" is "Website" reporter' do - user = User.find_by_name("Mike") - project = Project.find_by_name("Website") + user = User.find_by(name: "Mike") + project = Project.find_by(name: "Website") project.team << [user, :reporter] end @@ -94,13 +94,13 @@ class ProjectTeamManagement < Spinach::FeatureSteps end When 'I submit "Website" project for import team' do - project = Project.find_by_name("Website") + project = Project.find_by(name: "Website") select project.name_with_namespace, from: 'source_project_id' click_button 'Import' end step 'I click cancel link for "Sam"' do - within "#user_#{User.find_by_name('Sam').id}" do + within "#user_#{User.find_by(name: 'Sam').id}" do click_link('Remove user from team') end end diff --git a/features/steps/project/project_wall.rb b/features/steps/project/wall.rb similarity index 100% rename from features/steps/project/project_wall.rb rename to features/steps/project/wall.rb diff --git a/features/steps/project/project_wiki.rb b/features/steps/project/wiki.rb similarity index 54% rename from features/steps/project/project_wiki.rb rename to features/steps/project/wiki.rb index 7aba412d75..96f2505d24 100644 --- a/features/steps/project/project_wiki.rb +++ b/features/steps/project/wiki.rb @@ -1,4 +1,4 @@ -class ProjectWiki < Spinach::FeatureSteps +class Spinach::Features::ProjectWiki < Spinach::FeatureSteps include SharedAuthentication include SharedProject include SharedNote @@ -16,7 +16,7 @@ class ProjectWiki < Spinach::FeatureSteps end Given 'I create the Wiki Home page' do - fill_in "Content", with: '[link test](test)' + fill_in "wiki_content", with: '[link test](test)' click_on "Create page" end @@ -25,7 +25,7 @@ class ProjectWiki < Spinach::FeatureSteps page.should have_content "link test" click_link "link test" - page.should have_content "Editing page" + page.should have_content "Editing" end Given 'I have an existing Wiki page' do @@ -83,10 +83,51 @@ class ProjectWiki < Spinach::FeatureSteps Then 'I should see the existing page in the pages list' do page.should have_content current_user.name - page.should have_content @page.title.titleize + page.should have_content @page.title + end + + Given 'I have an existing Wiki page with images linked on page' do + wiki.create_page("pictures", "Look at this [image](image.jpg)\n\n ![image](image.jpg)", :markdown, "first commit") + @wiki_page = wiki.find_page("pictures") + end + + And 'I browse to wiki page with images' do + visit project_wiki_path(project, @wiki_page) + end + + And 'I click on existing image link' do + file = Gollum::File.new(wiki.wiki) + Gollum::Wiki.any_instance.stub(:file).with("image.jpg", "master", true).and_return(file) + Gollum::File.any_instance.stub(:mime_type).and_return("image/jpeg") + page.should have_link('image', href: "image.jpg") + click_on "image" + end + + Then 'I should see the image from wiki repo' do + url = URI.parse(current_url) + url.path.should match("wikis/image.jpg") + page.should_not have_xpath('/html') # Page should render the image which means there is no html involved + Gollum::Wiki.any_instance.unstub(:file) + Gollum::File.any_instance.unstub(:mime_type) + end + + Then 'Image should be shown on the page' do + page.should have_xpath("//img[@src=\"image.jpg\"]") + end + + And 'I click on image link' do + page.should have_link('image', href: "image.jpg") + click_on "image" + end + + Then 'I should see the new wiki page form' do + url = URI.parse(current_url) + url.path.should match("wikis/image.jpg") + page.should have_content('New Wiki Page') + page.should have_content('Editing - image.jpg') end def wiki - @gollum_wiki = GollumWiki.new(project, current_user) + @project_wiki = ProjectWiki.new(project, current_user) end end diff --git a/features/steps/public/groups_feature.rb b/features/steps/public/groups_feature.rb new file mode 100644 index 0000000000..015deca542 --- /dev/null +++ b/features/steps/public/groups_feature.rb @@ -0,0 +1,93 @@ +class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedGroup + include SharedProject + + step 'group "TestGroup" has private project "Enterprise"' do + group_has_project("TestGroup", "Enterprise", Gitlab::VisibilityLevel::PRIVATE) + end + + step 'group "TestGroup" has internal project "Internal"' do + group_has_project("TestGroup", "Internal", Gitlab::VisibilityLevel::INTERNAL) + end + + step 'group "TestGroup" has public project "Community"' do + group_has_project("TestGroup", "Community", Gitlab::VisibilityLevel::PUBLIC) + end + + step '"John Doe" is owner of group "TestGroup"' do + group = Group.find_by(name: "TestGroup") || create(:group, name: "TestGroup") + user = create(:user, name: "John Doe") + group.add_user(user, Gitlab::Access::OWNER) + end + + step 'I visit group "TestGroup" page' do + visit group_path(Group.find_by(name: "TestGroup")) + end + + step 'I visit group "TestGroup" issues page' do + visit issues_group_path(Group.find_by(name: "TestGroup")) + end + + step 'I visit group "TestGroup" merge requests page' do + visit merge_requests_group_path(Group.find_by(name: "TestGroup")) + end + + step 'I visit group "TestGroup" members page' do + visit members_group_path(Group.find_by(name: "TestGroup")) + end + + step 'I should not see project "Enterprise" items' do + page.should_not have_content "Enterprise" + end + + step 'I should see project "Internal" items' do + page.should have_content "Internal" + end + + step 'I should not see project "Internal" items' do + page.should_not have_content "Internal" + end + + step 'I should see project "Community" items' do + page.should have_content "Community" + end + + step 'I change filter to Everyone\'s' do + click_link "Everyone's" + end + + step 'I should see group member "John Doe"' do + page.should have_content "John Doe" + end + + step 'I should not see member roles' do + page.body.should_not match(%r{owner|developer|reporter|guest}i) + end + + protected + + def group_has_project(groupname, projectname, visibility_level) + group = Group.find_by(name: groupname) || create(:group, name: groupname) + project = create(:project, + namespace: group, + name: projectname, + path: "#{groupname}-#{projectname}", + visibility_level: visibility_level + ) + create(:issue, + title: "#{projectname} feature", + project: project + ) + create(:merge_request, + title: "#{projectname} feature implemented", + source_project: project, + target_project: project + ) + create(:closed_issue_event, + project: project + ) + end +end + diff --git a/features/steps/public/projects.rb b/features/steps/public/projects.rb new file mode 100644 index 0000000000..7c7311bb91 --- /dev/null +++ b/features/steps/public/projects.rb @@ -0,0 +1,172 @@ +class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedProject + + step 'public empty project "Empty Public Project"' do + create :empty_project, :public, name: 'Empty Public Project' + end + + step 'I should see project "Empty Public Project"' do + page.should have_content "Empty Public Project" + end + + step 'I should see public project details' do + page.should have_content '32 branches' + page.should have_content '16 tags' + end + + step 'I should see project readme' do + page.should have_content 'README.md' + end + + step 'I visit empty project page' do + project = Project.find_by(name: 'Empty Public Project') + visit project_path(project) + end + + step 'I visit project "Community" page' do + project = Project.find_by(name: 'Community') + visit project_path(project) + end + + step 'I should see empty public project details' do + page.should have_content 'Git global setup' + end + + step 'I should see empty public project details with http clone info' do + project = Project.find_by(name: 'Empty Public Project') + page.all(:css, '.git-empty .clone').each do |element| + element.text.should include(project.http_url_to_repo) + end + end + + step 'I should see empty public project details with ssh clone info' do + project = Project.find_by(name: 'Empty Public Project') + page.all(:css, '.git-empty .clone').each do |element| + element.text.should include(project.url_to_repo) + end + end + + step 'I visit project "Enterprise" page' do + project = Project.find_by(name: 'Enterprise') + visit project_path(project) + end + + step 'I should see project "Community" home page' do + within '.project-home-title' do + page.should have_content 'Community' + end + end + + step 'I visit project "Internal" page' do + project = Project.find_by(name: 'Internal') + visit project_path(project) + end + + step 'I should see project "Internal" home page' do + within '.project-home-title' do + page.should have_content 'Internal' + end + end + + step 'I should see an http link to the repository' do + project = Project.find_by(name: 'Community') + page.should have_field('project_clone', with: project.http_url_to_repo) + end + + step 'I should see an ssh link to the repository' do + project = Project.find_by(name: 'Community') + page.should have_field('project_clone', with: project.url_to_repo) + end + + step 'I visit "Community" issues page' do + create(:issue, + title: "Bug", + project: public_project + ) + create(:issue, + title: "New feature", + project: public_project + ) + visit project_issues_path(public_project) + end + + + step 'I should see list of issues for "Community" project' do + page.should have_content "Bug" + page.should have_content public_project.name + page.should have_content "New feature" + end + + step 'I visit "Internal" issues page' do + create(:issue, + title: "Internal Bug", + project: internal_project + ) + create(:issue, + title: "New internal feature", + project: internal_project + ) + visit project_issues_path(internal_project) + end + + + step 'I should see list of issues for "Internal" project' do + page.should have_content "Internal Bug" + page.should have_content internal_project.name + page.should have_content "New internal feature" + end + + step 'I visit "Community" merge requests page' do + visit project_merge_requests_path(public_project) + end + + step 'project "Community" has "Bug fix" open merge request' do + create(:merge_request, + title: "Bug fix for public project", + source_project: public_project, + target_project: public_project, + ) + end + + step 'I should see list of merge requests for "Community" project' do + page.should have_content public_project.name + page.should have_content public_merge_request.source_project.name + end + + step 'I visit "Internal" merge requests page' do + visit project_merge_requests_path(internal_project) + end + + step 'project "Internal" has "Feature implemented" open merge request' do + create(:merge_request, + title: "Feature implemented", + source_project: internal_project, + target_project: internal_project + ) + end + + step 'I should see list of merge requests for "Internal" project' do + page.should have_content internal_project.name + page.should have_content internal_merge_request.source_project.name + end + + def internal_project + @internal_project ||= Project.find_by!(name: 'Internal') + end + + def public_project + @public_project ||= Project.find_by!(name: 'Community') + end + + + def internal_merge_request + @internal_merge_request ||= MergeRequest.find_by!(title: 'Feature implemented') + end + + def public_merge_request + @public_merge_request ||= MergeRequest.find_by!(title: 'Bug fix for public project') + end +end + diff --git a/features/steps/public/projects_feature.rb b/features/steps/public/projects_feature.rb deleted file mode 100644 index 8abc6ae9f2..0000000000 --- a/features/steps/public/projects_feature.rb +++ /dev/null @@ -1,63 +0,0 @@ -class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps - include SharedPaths - - step 'I should see project "Community"' do - page.should have_content "Community" - end - - step 'I should not see project "Enterprise"' do - page.should_not have_content "Enterprise" - end - - step 'I should see project "Empty Public Project"' do - page.should have_content "Empty Public Project" - end - - step 'I should see public project details' do - page.should have_content '32 branches' - page.should have_content '16 tags' - end - - step 'I should see project readme' do - page.should have_content 'README.md' - end - - step 'public project "Community"' do - create :project_with_code, name: 'Community', public: true, default_branch: 'master' - end - - step 'public empty project "Empty Public Project"' do - create :project, name: 'Empty Public Project', public: true - end - - step 'I visit empty project page' do - project = Project.find_by_name('Empty Public Project') - visit project_path(project) - end - - step 'I visit project "Community" page' do - project = Project.find_by_name('Community') - visit project_path(project) - end - - step 'I should see empty public project details' do - page.should have_content 'Git global setup' - end - - step 'private project "Enterprise"' do - create :project, name: 'Enterprise' - end - - step 'I should see project "Community" home page' do - within '.project-home-title' do - page.should have_content 'Community' - end - end - - private - - def project - @project ||= Project.find_by_name("Community") - end -end - diff --git a/features/steps/shared/authentication.rb b/features/steps/shared/authentication.rb index 8c501bbc53..b8c11ce0a2 100644 --- a/features/steps/shared/authentication.rb +++ b/features/steps/shared/authentication.rb @@ -12,6 +12,18 @@ module SharedAuthentication login_as :admin end + step 'I sign in as "John Doe"' do + login_with(user_exists("John Doe")) + end + + step 'I sign in as "Mary Jane"' do + login_with(user_exists("Mary Jane")) + end + + step 'I should be redirected to sign in page' do + current_path.should == new_user_session_path + end + def current_user @user || User.first end diff --git a/features/steps/shared/diff_note.rb b/features/steps/shared/diff_note.rb index 9c39a226e1..f80d8d0647 100644 --- a/features/steps/shared/diff_note.rb +++ b/features/steps/shared/diff_note.rb @@ -2,7 +2,7 @@ module SharedDiffNote include Spinach::DSL Given 'I cancel the diff comment' do - within(".file") do + within(".diff-file") do find(".js-close-discussion-note-form").click end end @@ -13,14 +13,14 @@ module SharedDiffNote end Given 'I haven\'t written any diff comment text' do - within(".file") do + within(".diff-file") do fill_in "note[note]", with: "" end end Given 'I leave a diff comment like "Typo, please fix"' do find('a[data-line-code="586fb7c4e1add2d4d24e27566ed7064680098646_29_14"]').click - within(".file form[rel$='586fb7c4e1add2d4d24e27566ed7064680098646_29_14']") do + within(".diff-file form[rel$='586fb7c4e1add2d4d24e27566ed7064680098646_29_14']") do fill_in "note[note]", with: "Typo, please fix" find(".js-comment-button").trigger("click") sleep 0.05 @@ -29,7 +29,7 @@ module SharedDiffNote Given 'I preview a diff comment text like "Should fix it :smile:"' do find('a[data-line-code="586fb7c4e1add2d4d24e27566ed7064680098646_29_14"]').click - within(".file form[rel$='586fb7c4e1add2d4d24e27566ed7064680098646_29_14']") do + within(".diff-file form[rel$='586fb7c4e1add2d4d24e27566ed7064680098646_29_14']") do fill_in "note[note]", with: "Should fix it :smile:" find(".js-note-preview-button").trigger("click") end @@ -38,7 +38,7 @@ module SharedDiffNote Given 'I preview another diff comment text like "DRY this up"' do find('a[data-line-code="586fb7c4e1add2d4d24e27566ed7064680098646_57_41"]').click - within(".file form[rel$='586fb7c4e1add2d4d24e27566ed7064680098646_57_41']") do + within(".diff-file form[rel$='586fb7c4e1add2d4d24e27566ed7064680098646_57_41']") do fill_in "note[note]", with: "DRY this up" find(".js-note-preview-button").trigger("click") end @@ -53,13 +53,13 @@ module SharedDiffNote end Given 'I write a diff comment like ":-1: I don\'t like this"' do - within(".file") do + within(".diff-file") do fill_in "note[note]", with: ":-1: I don\'t like this" end end Given 'I submit the diff comment' do - within(".file") do + within(".diff-file") do click_button("Add Comment") end end @@ -67,49 +67,49 @@ module SharedDiffNote Then 'I should not see the diff comment form' do - within(".file") do + within(".diff-file") do page.should_not have_css("form.new_note") end end Then 'I should not see the diff comment preview button' do - within(".file") do + within(".diff-file") do page.should have_css(".js-note-preview-button", visible: false) end end Then 'I should not see the diff comment text field' do - within(".file") do + within(".diff-file") do page.should have_css(".js-note-text", visible: false) end end Then 'I should only see one diff form' do - within(".file") do + within(".diff-file") do page.should have_css("form.new_note", count: 1) end end Then 'I should see a diff comment form with ":-1: I don\'t like this"' do - within(".file") do + within(".diff-file") do page.should have_field("note[note]", with: ":-1: I don\'t like this") end end Then 'I should see a diff comment saying "Typo, please fix"' do - within(".file .note") do + within(".diff-file .note") do page.should have_content("Typo, please fix") end end Then 'I should see a discussion reply button' do - within(".file") do + within(".diff-file") do page.should have_link("Reply") end end Then 'I should see a temporary diff comment form' do - within(".file") do + within(".diff-file") do page.should have_css(".js-temp-notes-holder form.new_note") end end @@ -119,37 +119,37 @@ module SharedDiffNote end Then 'I should see an empty diff comment form' do - within(".file") do + within(".diff-file") do page.should have_field("note[note]", with: "") end end Then 'I should see the cancel comment button' do - within(".file form") do + within(".diff-file form") do page.should have_css(".js-close-discussion-note-form", text: "Cancel") end end Then 'I should see the diff comment preview' do - within(".file form") do + within(".diff-file form") do page.should have_css(".js-note-preview", visible: false) end end Then 'I should see the diff comment edit button' do - within(".file") do + within(".diff-file") do page.should have_css(".js-note-edit-button", visible: true) end end Then 'I should see the diff comment preview button' do - within(".file") do + within(".diff-file") do page.should have_css(".js-note-preview-button", visible: true) end end Then 'I should see two separate previews' do - within(".file") do + within(".diff-file") do page.should have_css(".js-note-preview", visible: true, count: 2) page.should have_content("Should fix it") page.should have_content("DRY this up") diff --git a/features/steps/shared/group.rb b/features/steps/shared/group.rb new file mode 100644 index 0000000000..6b4c47312a --- /dev/null +++ b/features/steps/shared/group.rb @@ -0,0 +1,36 @@ +module SharedGroup + include Spinach::DSL + + step '"John Doe" is owner of group "Owned"' do + is_member_of("John Doe", "Owned", Gitlab::Access::OWNER) + end + + step '"John Doe" is guest of group "Guest"' do + is_member_of("John Doe", "Guest", Gitlab::Access::GUEST) + end + + step '"Mary Jane" is owner of group "Owned"' do + is_member_of("Mary Jane", "Owned", Gitlab::Access::OWNER) + end + + step '"Mary Jane" is guest of group "Owned"' do + is_member_of("Mary Jane", "Owned", Gitlab::Access::GUEST) + end + + step '"Mary Jane" is guest of group "Guest"' do + is_member_of("Mary Jane", "Guest", Gitlab::Access::GUEST) + end + + protected + + def is_member_of(username, groupname, role) + @project_count ||= 0 + user = User.find_by(name: username) || create(:user, name: username) + group = Group.find_by(name: groupname) || create(:group, name: groupname) + group.add_user(user, role) + project ||= create(:project, namespace: group, path: "project#{@project_count}") + event ||= create(:closed_issue_event, project: project) + project.team << [user, :master] + @project_count += 1 + end +end diff --git a/features/steps/shared/markdown.rb b/features/steps/shared/markdown.rb new file mode 100644 index 0000000000..782f3f0920 --- /dev/null +++ b/features/steps/shared/markdown.rb @@ -0,0 +1,12 @@ +module SharedMarkdown + include Spinach::DSL + + def header_should_have_correct_id_and_link(level, text, id, parent = ".wiki") + page.find(:css, "#{parent} h#{level}##{id}").text.should == text + page.find(:css, "#{parent} h#{level}##{id} > :last-child")[:href].should =~ /##{id}$/ + end + + step 'Header "Description header" should have correct id and link' do + header_should_have_correct_id_and_link(1, 'Description header', 'description-header') + end +end diff --git a/features/steps/shared/note.rb b/features/steps/shared/note.rb index da08da9420..36b81b7418 100644 --- a/features/steps/shared/note.rb +++ b/features/steps/shared/note.rb @@ -102,4 +102,21 @@ module SharedNote page.should have_content("XML attached") end end + + # Markdown + + step 'I leave a comment with a header containing "Comment with a header"' do + within(".js-main-target-form") do + fill_in "note[note]", with: "# Comment with a header" + click_button "Add Comment" + sleep 0.05 + end + end + + step 'The comment with the header should not have an ID' do + within(".note-text") do + page.should have_content("Comment with a header") + page.should_not have_css("#comment-with-a-header") + end + end end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 156fa5bab4..a0213815a7 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -5,28 +5,56 @@ module SharedPaths visit new_project_path end + # ---------------------------------------- + # User + # ---------------------------------------- + + step 'I visit user "John Doe" page' do + visit user_path("john_doe") + end + # ---------------------------------------- # Group # ---------------------------------------- - step 'I visit group page' do - visit group_path(current_group) + step 'I visit group "Owned" page' do + visit group_path(Group.find_by(name:"Owned")) end - step 'I visit group issues page' do - visit issues_group_path(current_group) + step 'I visit group "Owned" issues page' do + visit issues_group_path(Group.find_by(name:"Owned")) end - step 'I visit group merge requests page' do - visit merge_requests_group_path(current_group) + step 'I visit group "Owned" merge requests page' do + visit merge_requests_group_path(Group.find_by(name:"Owned")) end - step 'I visit group members page' do - visit members_group_path(current_group) + step 'I visit group "Owned" members page' do + visit members_group_path(Group.find_by(name:"Owned")) end - step 'I visit group settings page' do - visit edit_group_path(current_group) + step 'I visit group "Owned" settings page' do + visit edit_group_path(Group.find_by(name:"Owned")) + end + + step 'I visit group "Guest" page' do + visit group_path(Group.find_by(name:"Guest")) + end + + step 'I visit group "Guest" issues page' do + visit issues_group_path(Group.find_by(name:"Guest")) + end + + step 'I visit group "Guest" merge requests page' do + visit merge_requests_group_path(Group.find_by(name:"Guest")) + end + + step 'I visit group "Guest" members page' do + visit members_group_path(Group.find_by(name:"Guest")) + end + + step 'I visit group "Guest" settings page' do + visit edit_group_path(Group.find_by(name:"Guest")) end # ---------------------------------------- @@ -85,6 +113,14 @@ module SharedPaths visit history_profile_path end + step 'I visit profile groups page' do + visit profile_groups_path + end + + step 'I should be redirected to the profile groups page' do + current_path.should == profile_groups_path + end + # ---------------------------------------- # Admin # ---------------------------------------- @@ -105,6 +141,10 @@ module SharedPaths visit admin_logs_path end + step 'I visit admin messages page' do + visit admin_broadcast_messages_path + end + step 'I visit admin hooks page' do visit admin_hooks_path end @@ -237,7 +277,7 @@ module SharedPaths end step 'I visit issue page "Release 0.4"' do - issue = Issue.find_by_title("Release 0.4") + issue = Issue.find_by(title: "Release 0.4") visit project_issue_path(issue.project, issue) end @@ -246,12 +286,12 @@ module SharedPaths end step 'I visit merge request page "Bug NS-04"' do - mr = MergeRequest.find_by_title("Bug NS-04") + mr = MergeRequest.find_by(title: "Bug NS-04") visit project_merge_request_path(mr.target_project, mr) end step 'I visit merge request page "Bug NS-05"' do - mr = MergeRequest.find_by_title("Bug NS-05") + mr = MergeRequest.find_by(title: "Bug NS-05") visit project_merge_request_path(mr.target_project, mr) end @@ -288,7 +328,7 @@ module SharedPaths end step 'I visit public page for "Community" project' do - visit public_project_path(Project.find_by_name("Community")) + visit public_project_path(Project.find_by(name: "Community")) end # ---------------------------------------- @@ -312,6 +352,14 @@ module SharedPaths end def project - project = Project.find_by_name!("Shop") + project = Project.find_by!(name: "Shop") + end + + # ---------------------------------------- + # Errors + # ---------------------------------------- + + Then 'page status code should be 404' do + page.status_code.should == 404 end end diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index cef66b038d..f8cb753b78 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -3,19 +3,26 @@ module SharedProject # Create a project without caring about what it's called And "I own a project" do - @project = create(:project_with_code, namespace: @user.namespace) + @project = create(:project, namespace: @user.namespace) @project.team << [@user, :master] end # Create a specific project called "Shop" And 'I own project "Shop"' do - @project = Project.find_by_name "Shop" - @project ||= create(:project_with_code, name: "Shop", namespace: @user.namespace) + @project = Project.find_by(name: "Shop") + @project ||= create(:project, name: "Shop", namespace: @user.namespace) + @project.team << [@user, :master] + end + + # Create another specific project called "Forum" + And 'I own project "Forum"' do + @project = Project.find_by(name: "Forum") + @project ||= create(:project, name: "Forum", namespace: @user.namespace, path: 'forum_project') @project.team << [@user, :master] end And 'project "Shop" has push event' do - @project = Project.find_by_name("Shop") + @project = Project.find_by(name: "Shop") data = { before: "0000000000000000000000000000000000000000", @@ -41,7 +48,7 @@ module SharedProject end Then 'I should see project "Shop" activity feed' do - project = Project.find_by_name("Shop") + project = Project.find_by(name: "Shop") page.should have_content "#{@user.name} pushed new branch new_design at #{project.name_with_namespace}" end @@ -51,11 +58,68 @@ module SharedProject page.should have_content("Features:") end - Then 'page status code should be 404' do - page.status_code.should == 404 - end - def current_project @project ||= Project.first end + + # ---------------------------------------- + # Visibility level + # ---------------------------------------- + + step 'private project "Enterprise"' do + create :project, name: 'Enterprise' + end + + step 'I should see project "Enterprise"' do + page.should have_content "Enterprise" + end + + step 'I should not see project "Enterprise"' do + page.should_not have_content "Enterprise" + end + + step 'internal project "Internal"' do + create :project, :internal, name: 'Internal' + end + + step 'I should see project "Internal"' do + page.should have_content "Internal" + end + + step 'I should not see project "Internal"' do + page.should_not have_content "Internal" + end + + step 'public project "Community"' do + create :project, :public, name: 'Community' + end + + step 'I should see project "Community"' do + page.should have_content "Community" + end + + step 'I should not see project "Community"' do + page.should_not have_content "Community" + end + + step '"John Doe" is authorized to private project "Enterprise"' do + user = user_exists("John Doe", username: "john_doe") + project = Project.find_by(name: "Enterprise") + project ||= create(:project, name: "Enterprise", namespace: user.namespace) + project.team << [user, :master] + end + + step '"John Doe" is authorized to internal project "Internal"' do + user = user_exists("John Doe", username: "john_doe") + project = Project.find_by(name: "Internal") + project ||= create :project, :internal, name: 'Internal' + project.team << [user, :master] + end + + step '"John Doe" is authorized to public project "Community"' do + user = user_exists("John Doe", username: "john_doe") + project = Project.find_by(name: "Community") + project ||= create :project, :public, name: 'Community' + project.team << [user, :master] + end end diff --git a/features/steps/shared/user.rb b/features/steps/shared/user.rb new file mode 100644 index 0000000000..209d77c7ac --- /dev/null +++ b/features/steps/shared/user.rb @@ -0,0 +1,17 @@ +module SharedUser + include Spinach::DSL + + step 'User "John Doe" exists' do + user_exists("John Doe", {username: "john_doe"}) + end + + step 'User "Mary Jane" exists' do + user_exists("Mary Jane", {username: "mary_jane"}) + end + + protected + + def user_exists(name, options = {}) + User.find_by(name: name) || create(:user, {name: name, admin: false}.merge(options)) + end +end diff --git a/features/steps/snippets/discover_snippets.rb b/features/steps/snippets/discover.rb similarity index 84% rename from features/steps/snippets/discover_snippets.rb rename to features/steps/snippets/discover.rb index 3afe019adf..0933793700 100644 --- a/features/steps/snippets/discover_snippets.rb +++ b/features/steps/snippets/discover.rb @@ -12,6 +12,6 @@ class DiscoverSnippets < Spinach::FeatureSteps end def snippet - @snippet ||= PersonalSnippet.find_by_title!("Personal snippet one") + @snippet ||= PersonalSnippet.find_by!(title: "Personal snippet one") end end diff --git a/features/steps/snippets/snippets.rb b/features/steps/snippets/snippets.rb index bbdf5b97c8..fed54659eb 100644 --- a/features/steps/snippets/snippets.rb +++ b/features/steps/snippets/snippets.rb @@ -19,7 +19,7 @@ class SnippetsFeature < Spinach::FeatureSteps end And 'I click link "Destroy"' do - click_link "Destroy" + click_link "Remove" end And 'I submit new snippet "Personal snippet three"' do @@ -46,7 +46,7 @@ class SnippetsFeature < Spinach::FeatureSteps end And 'I uncheck "Private" checkbox' do - find(:xpath, "//input[@id='personal_snippet_private']").set true + choose "Public" click_button "Save" end @@ -59,6 +59,6 @@ class SnippetsFeature < Spinach::FeatureSteps end def snippet - @snippet ||= PersonalSnippet.find_by_title!("Personal snippet one") + @snippet ||= PersonalSnippet.find_by!(title: "Personal snippet one") end end diff --git a/features/steps/snippets/user_snippets.rb b/features/steps/snippets/user.rb similarity index 92% rename from features/steps/snippets/user_snippets.rb rename to features/steps/snippets/user.rb index 15d6da6db3..2d7ffc866e 100644 --- a/features/steps/snippets/user_snippets.rb +++ b/features/steps/snippets/user.rb @@ -36,6 +36,6 @@ class UserSnippets < Spinach::FeatureSteps end def snippet - @snippet ||= PersonalSnippet.find_by_title!("Personal snippet one") + @snippet ||= PersonalSnippet.find_by!(title: "Personal snippet one") end end diff --git a/features/steps/user.rb b/features/steps/user.rb new file mode 100644 index 0000000000..5fb248ffcb --- /dev/null +++ b/features/steps/user.rb @@ -0,0 +1,10 @@ +class Spinach::Features::User < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedUser + include SharedProject + + step 'I should see user "John Doe" page' do + expect(page.title).to match(/^\s*John Doe/) + end +end diff --git a/features/support/env.rb b/features/support/env.rb index d27a73edab..a5b297775d 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -9,12 +9,13 @@ ENV['RAILS_ENV'] = 'test' require './config/environment' require 'rspec' +require 'rspec/expectations' require 'database_cleaner' require 'spinach/capybara' require 'sidekiq/testing/inline' -%w(valid_commit big_commits select2_helper chosen_helper test_env).each do |f| +%w(valid_commit valid_commit_with_alt_email big_commits select2_helper test_env).each do |f| require Rails.root.join('spec', 'support', f) end @@ -51,6 +52,4 @@ Spinach.hooks.before_run do RSpec::Mocks::setup self include FactoryGirl::Syntax::Methods - MergeRequestObserver.any_instance.stub(current_user: create(:user)) end - diff --git a/features/user.feature b/features/user.feature new file mode 100644 index 0000000000..d4198c08de --- /dev/null +++ b/features/user.feature @@ -0,0 +1,69 @@ +Feature: User + Background: + Given User "John Doe" exists + And "John Doe" is authorized to private project "Enterprise" + + # Signed out + + Scenario: I visit user "John Doe" page while not signed in when he is authorized to a public project + Given "John Doe" is authorized to internal project "Internal" + And "John Doe" is authorized to public project "Community" + When I visit user "John Doe" page + Then I should see user "John Doe" page + And I should not see project "Enterprise" + And I should not see project "Internal" + And I should see project "Community" + + Scenario: I visit user "John Doe" page while not signed in when he is not authorized to a public project + Given "John Doe" is authorized to internal project "Internal" + When I visit user "John Doe" page + Then I should be redirected to sign in page + + # Signed in as someone else + + Scenario: I visit user "John Doe" page while signed in as someone else when he is authorized to a public project + Given "John Doe" is authorized to public project "Community" + And "John Doe" is authorized to internal project "Internal" + And I sign in as a user + When I visit user "John Doe" page + Then I should see user "John Doe" page + And I should not see project "Enterprise" + And I should see project "Internal" + And I should see project "Community" + + Scenario: I visit user "John Doe" page while signed in as someone else when he is not authorized to a public project + Given "John Doe" is authorized to internal project "Internal" + And I sign in as a user + When I visit user "John Doe" page + Then I should see user "John Doe" page + And I should not see project "Enterprise" + And I should see project "Internal" + And I should not see project "Community" + + Scenario: I visit user "John Doe" page while signed in as someone else when he is not authorized to a project I can see + Given I sign in as a user + When I visit user "John Doe" page + Then I should see user "John Doe" page + And I should not see project "Enterprise" + And I should not see project "Internal" + And I should not see project "Community" + + # Signed in as the user himself + + Scenario: I visit user "John Doe" page while signed in as "John Doe" when he has a public project + Given "John Doe" is authorized to internal project "Internal" + And "John Doe" is authorized to public project "Community" + And I sign in as "John Doe" + When I visit user "John Doe" page + Then I should see user "John Doe" page + And I should see project "Enterprise" + And I should see project "Internal" + And I should see project "Community" + + Scenario: I visit user "John Doe" page while signed in as "John Doe" when he has no public project + Given I sign in as "John Doe" + When I visit user "John Doe" page + Then I should see user "John Doe" page + And I should see project "Enterprise" + And I should not see project "Internal" + And I should not see project "Community" diff --git a/lib/api/api.rb b/lib/api/api.rb index 4db81f42b4..ce4cc8b34f 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -22,6 +22,8 @@ module API end format :json + content_type :txt, "text/plain" + helpers APIHelpers mount Groups @@ -36,8 +38,13 @@ module API mount Internal mount SystemHooks mount ProjectSnippets + mount ProjectMembers mount DeployKeys mount ProjectHooks mount Services + mount Files + mount Commits + mount Namespaces + mount Branches end end diff --git a/lib/api/branches.rb b/lib/api/branches.rb new file mode 100644 index 0000000000..d54f9371fb --- /dev/null +++ b/lib/api/branches.rb @@ -0,0 +1,89 @@ +require 'mime/types' + +module API + # Projects API + class Branches < Grape::API + before { authenticate! } + before { authorize! :download_code, user_project } + + resource :projects do + # Get a project repository branches + # + # Parameters: + # id (required) - The ID of a project + # Example Request: + # GET /projects/:id/repository/branches + get ":id/repository/branches" do + present user_project.repo.heads.sort_by(&:name), with: Entities::RepoObject, project: user_project + end + + # Get a single branch + # + # Parameters: + # id (required) - The ID of a project + # branch (required) - The name of the branch + # Example Request: + # GET /projects/:id/repository/branches/:branch + get ':id/repository/branches/:branch', requirements: { branch: /.*/ } do + @branch = user_project.repo.heads.find { |item| item.name == params[:branch] } + not_found!("Branch does not exist") if @branch.nil? + present @branch, with: Entities::RepoObject, project: user_project + end + + # Protect a single branch + # + # Parameters: + # id (required) - The ID of a project + # branch (required) - The name of the branch + # Example Request: + # PUT /projects/:id/repository/branches/:branch/protect + put ':id/repository/branches/:branch/protect', + requirements: { branch: /.*/ } do + + authorize_admin_project + + @branch = user_project.repository.find_branch(params[:branch]) + not_found! unless @branch + protected_branch = user_project.protected_branches.find_by(name: @branch.name) + user_project.protected_branches.create(name: @branch.name) unless protected_branch + + present @branch, with: Entities::RepoObject, project: user_project + end + + # Unprotect a single branch + # + # Parameters: + # id (required) - The ID of a project + # branch (required) - The name of the branch + # Example Request: + # PUT /projects/:id/repository/branches/:branch/unprotect + put ':id/repository/branches/:branch/unprotect', + requirements: { branch: /.*/ } do + + authorize_admin_project + + @branch = user_project.repository.find_branch(params[:branch]) + not_found! unless @branch + protected_branch = user_project.protected_branches.find_by(name: @branch.name) + protected_branch.destroy if protected_branch + + present @branch, with: Entities::RepoObject, project: user_project + end + + # Create branch + # + # Parameters: + # id (required) - The ID of a project + # branch_name (required) - The name of the branch + # ref (required) - Create branch from commit sha or existing branch + # Example Request: + # POST /projects/:id/repository/branches + post ":id/repository/branches" do + authorize_push_project + @branch = CreateBranchService.new.execute(user_project, params[:branch_name], params[:ref], current_user) + + present @branch, with: Entities::RepoObject, project: user_project + end + end + end +end diff --git a/lib/api/commits.rb b/lib/api/commits.rb new file mode 100644 index 0000000000..4a67313430 --- /dev/null +++ b/lib/api/commits.rb @@ -0,0 +1,55 @@ +require 'mime/types' + +module API + # Projects commits API + class Commits < Grape::API + before { authenticate! } + before { authorize! :download_code, user_project } + + resource :projects do + # Get a project repository commits + # + # Parameters: + # id (required) - The ID of a project + # ref_name (optional) - The name of a repository branch or tag, if not given the default branch is used + # Example Request: + # GET /projects/:id/repository/commits + get ":id/repository/commits" do + page = (params[:page] || 0).to_i + per_page = (params[:per_page] || 20).to_i + ref = params[:ref_name] || user_project.try(:default_branch) || 'master' + + commits = user_project.repository.commits(ref, nil, per_page, page * per_page) + present commits, with: Entities::RepoCommit + end + + # Get a specific commit of a project + # + # Parameters: + # id (required) - The ID of a project + # sha (required) - The commit hash or name of a repository branch or tag + # Example Request: + # GET /projects/:id/repository/commits/:sha + get ":id/repository/commits/:sha" do + sha = params[:sha] + commit = user_project.repository.commit(sha) + not_found! "Commit" unless commit + present commit, with: Entities::RepoCommitDetail + end + + # Get the diff for a specific commit of a project + # + # Parameters: + # id (required) - The ID of a project + # sha (required) - The commit or branch name + # Example Request: + # GET /projects/:id/repository/commits/:sha/diff + get ":id/repository/commits/:sha/diff" do + sha = params[:sha] + commit = user_project.repository.commit(sha) + not_found! "Commit" unless commit + commit.diffs + end + end + end +end diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb index b599760899..7f5a125038 100644 --- a/lib/api/deploy_keys.rb +++ b/lib/api/deploy_keys.rb @@ -38,14 +38,14 @@ module API attrs[:key].strip! # check if key already exist in project - key = user_project.deploy_keys.find_by_key(attrs[:key]) + key = user_project.deploy_keys.find_by(key: attrs[:key]) if key present key, with: Entities::SSHKey return end # Check for available deploy keys in other projects - key = current_user.accessible_deploy_keys.find_by_key(attrs[:key]) + key = current_user.accessible_deploy_keys.find_by(key: attrs[:key]) if key user_project.deploy_keys << key present key, with: Entities::SSHKey diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 429083d75b..457af52fe9 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1,15 +1,21 @@ module API module Entities class User < Grape::Entity - expose :id, :username, :email, :name, :bio, :skype, :linkedin, :twitter, + expose :id, :username, :email, :name, :bio, :skype, :linkedin, :twitter, :website_url, :theme_id, :color_scheme_id, :state, :created_at, :extern_uid, :provider expose :is_admin?, as: :is_admin expose :can_create_group?, as: :can_create_group expose :can_create_project?, as: :can_create_project + + expose :avatar_url do |user, options| + if user.avatar.present? + user.avatar.url + end + end end class UserSafe < Grape::Entity - expose :name + expose :name, :username end class UserBasic < Grape::Entity @@ -24,6 +30,10 @@ module API expose :id, :url, :created_at end + class ProjectHook < Hook + expose :project_id, :push_events, :issues_events, :merge_requests_events + end + class ForkedFromProject < Grape::Entity expose :id expose :name, :name_with_namespace @@ -31,30 +41,21 @@ module API end class Project < Grape::Entity - expose :id, :description, :default_branch, :public, :ssh_url_to_repo, :http_url_to_repo, :web_url - expose :owner, using: Entities::UserBasic + expose :id, :description, :default_branch + expose :public?, as: :public + expose :archived?, as: :archived + expose :visibility_level, :ssh_url_to_repo, :http_url_to_repo, :web_url + expose :owner, using: Entities::UserBasic, unless: ->(project, options) { project.group } expose :name, :name_with_namespace expose :path, :path_with_namespace - expose :issues_enabled, :merge_requests_enabled, :wall_enabled, :wiki_enabled, :snippets_enabled, :created_at, :last_activity_at, :public + expose :issues_enabled, :merge_requests_enabled, :wall_enabled, :wiki_enabled, :snippets_enabled, :created_at, :last_activity_at expose :namespace expose :forked_from_project, using: Entities::ForkedFromProject, :if => lambda{ | project, options | project.forked? } end class ProjectMember < UserBasic expose :project_access, as: :access_level do |user, options| - options[:project].users_projects.find_by_user_id(user.id).project_access - end - end - - class TeamMember < UserBasic - expose :permission, as: :access_level do |user, options| - options[:user_team].user_team_user_relationships.find_by_user_id(user.id).permission - end - end - - class TeamProject < Project - expose :greatest_access, as: :greatest_access_level do |project, options| - options[:user_team].user_team_project_relationships.find_by_project_id(project.id).greatest_access + options[:project].users_projects.find_by(user_id: user.id).project_access end end @@ -68,12 +69,21 @@ module API class GroupMember < UserBasic expose :group_access, as: :access_level do |user, options| - options[:group].users_groups.find_by_user_id(user.id).group_access + options[:group].users_groups.find_by(user_id: user.id).group_access end end class RepoObject < Grape::Entity - expose :name, :commit + expose :name + + expose :commit do |repo_obj, options| + if repo_obj.respond_to?(:commit) + repo_obj.commit + elsif options[:project] + options[:project].repository.commit(repo_obj.target) + end + end + expose :protected do |repo, options| if options[:project] options[:project].protected_branch? repo.name @@ -81,10 +91,24 @@ module API end end + class RepoTreeObject < Grape::Entity + expose :id, :name, :type + + expose :mode do |obj, options| + filemode = obj.mode.to_s(8) + filemode = "0" + filemode if filemode.length < 6 + filemode + end + end + class RepoCommit < Grape::Entity expose :id, :short_id, :title, :author_name, :author_email, :created_at end + class RepoCommitDetail < RepoCommit + expose :parent_ids, :committed_date, :authored_date + end + class ProjectSnippet < Grape::Entity expose :id, :title, :file_name expose :author, using: Entities::UserBasic @@ -94,24 +118,25 @@ module API class ProjectEntity < Grape::Entity expose :id, :iid expose (:project_id) { |entity| entity.project.id } + expose :title, :description + expose :state, :created_at, :updated_at end class Milestone < ProjectEntity - expose :title, :description, :due_date, :state, :updated_at, :created_at + expose :due_date end class Issue < ProjectEntity - expose :title, :description expose :label_list, as: :labels expose :milestone, using: Entities::Milestone expose :assignee, :author, using: Entities::UserBasic - expose :state, :updated_at, :created_at end class MergeRequest < ProjectEntity - expose :target_branch, :source_branch, :title, :state, :upvotes, :downvotes + expose :target_branch, :source_branch, :upvotes, :downvotes expose :author, :assignee, using: Entities::UserBasic expose :source_project_id, :target_project_id + expose :label_list, as: :labels end class SSHKey < Grape::Entity @@ -135,6 +160,39 @@ module API expose :title, :project_id, :action_name expose :target_id, :target_type, :author_id expose :data, :target_title + expose :created_at + end + + class Namespace < Grape::Entity + expose :id, :path, :kind + end + + class ProjectAccess < Grape::Entity + expose :project_access, as: :access_level + expose :notification_level + end + + class GroupAccess < Grape::Entity + expose :group_access, as: :access_level + expose :notification_level + end + + class ProjectWithAccess < Project + expose :permissions do + expose :project_access, using: Entities::ProjectAccess do |project, options| + project.users_projects.find_by(user_id: options[:user].id) + end + + expose :group_access, using: Entities::GroupAccess do |project, options| + if project.group + project.group.users_groups.find_by(user_id: options[:user].id) + end + end + end + end + + class Label < Grape::Entity + expose :name end end end diff --git a/lib/api/files.rb b/lib/api/files.rb new file mode 100644 index 0000000000..e0c46f92b8 --- /dev/null +++ b/lib/api/files.rb @@ -0,0 +1,150 @@ +module API + # Projects API + class Files < Grape::API + before { authenticate! } + before { authorize! :push_code, user_project } + + resource :projects do + # Get file from repository + # File content is Base64 encoded + # + # Parameters: + # file_path (required) - The path to the file. Ex. lib/class.rb + # ref (required) - The name of branch, tag or commit + # + # Example Request: + # GET /projects/:id/repository/files + # + # Example response: + # { + # "file_name": "key.rb", + # "file_path": "app/models/key.rb", + # "size": 1476, + # "encoding": "base64", + # "content": "IyA9PSBTY2hlbWEgSW5mb3...", + # "ref": "master", + # "blob_id": "79f7bbd25901e8334750839545a9bd021f0e4c83", + # "commit_id": "d5a3ff139356ce33e37e73add446f16869741b50" + # } + # + get ":id/repository/files" do + required_attributes! [:file_path, :ref] + attrs = attributes_for_keys [:file_path, :ref] + ref = attrs.delete(:ref) + file_path = attrs.delete(:file_path) + + commit = user_project.repository.commit(ref) + not_found! "Commit" unless commit + + blob = user_project.repository.blob_at(commit.sha, file_path) + + if blob + status(200) + + { + file_name: blob.name, + file_path: blob.path, + size: blob.size, + encoding: "base64", + content: Base64.encode64(blob.data), + ref: ref, + blob_id: blob.id, + commit_id: commit.id, + } + else + render_api_error!('File not found', 404) + end + end + + # Create new file in repository + # + # Parameters: + # file_path (required) - The path to new file. Ex. lib/class.rb + # branch_name (required) - The name of branch + # content (required) - File content + # commit_message (required) - Commit message + # + # Example Request: + # POST /projects/:id/repository/files + # + post ":id/repository/files" do + required_attributes! [:file_path, :branch_name, :content, :commit_message] + attrs = attributes_for_keys [:file_path, :branch_name, :content, :commit_message, :encoding] + branch_name = attrs.delete(:branch_name) + file_path = attrs.delete(:file_path) + result = ::Files::CreateService.new(user_project, current_user, attrs, branch_name, file_path).execute + + if result[:status] == :success + status(201) + + { + file_path: file_path, + branch_name: branch_name + } + else + render_api_error!(result[:error], 400) + end + end + + # Update existing file in repository + # + # Parameters: + # file_path (optional) - The path to file. Ex. lib/class.rb + # branch_name (required) - The name of branch + # content (required) - File content + # commit_message (required) - Commit message + # + # Example Request: + # PUT /projects/:id/repository/files + # + put ":id/repository/files" do + required_attributes! [:file_path, :branch_name, :content, :commit_message] + attrs = attributes_for_keys [:file_path, :branch_name, :content, :commit_message, :encoding] + branch_name = attrs.delete(:branch_name) + file_path = attrs.delete(:file_path) + result = ::Files::UpdateService.new(user_project, current_user, attrs, branch_name, file_path).execute + + if result[:status] == :success + status(200) + + { + file_path: file_path, + branch_name: branch_name + } + else + render_api_error!(result[:error], 400) + end + end + + # Delete existing file in repository + # + # Parameters: + # file_path (optional) - The path to file. Ex. lib/class.rb + # branch_name (required) - The name of branch + # content (required) - File content + # commit_message (required) - Commit message + # + # Example Request: + # DELETE /projects/:id/repository/files + # + delete ":id/repository/files" do + required_attributes! [:file_path, :branch_name, :commit_message] + attrs = attributes_for_keys [:file_path, :branch_name, :commit_message] + branch_name = attrs.delete(:branch_name) + file_path = attrs.delete(:file_path) + result = ::Files::DeleteService.new(user_project, current_user, attrs, branch_name, file_path).execute + + if result[:status] == :success + status(200) + + { + file_path: file_path, + branch_name: branch_name + } + else + render_api_error!(result[:error], 400) + end + end + end + end +end diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 290b78d801..03f027706d 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -121,11 +121,11 @@ module API render_api_error!("Wrong access level", 422) end group = find_group(params[:id]) - if group.users_groups.find_by_user_id(params[:user_id]) + if group.users_groups.find_by(user_id: params[:user_id]) render_api_error!("Already exists", 409) end group.add_users([params[:user_id]], params[:access_level]) - member = group.users_groups.find_by_user_id(params[:user_id]) + member = group.users_groups.find_by(user_id: params[:user_id]) present member.user, with: Entities::GroupMember, group: group end @@ -139,7 +139,7 @@ module API # DELETE /groups/:id/members/:user_id delete ":id/members/:user_id" do group = find_group(params[:id]) - member = group.users_groups.find_by_user_id(params[:user_id]) + member = group.users_groups.find_by(user_id: params[:user_id]) if member.nil? render_api_error!("404 Not Found - user_id:#{params[:user_id]} not a member of group #{group.name}",404) else diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index edc662eaaa..654c1f62c6 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -6,19 +6,28 @@ module API SUDO_PARAM = :sudo def current_user - @current_user ||= User.find_by_authentication_token(params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER]) + private_token = (params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER]).to_s + @current_user ||= User.find_by(authentication_token: private_token) + + unless @current_user && Gitlab::UserAccess.allowed?(@current_user) + return nil + end + identifier = sudo_identifier() + # If the sudo is the current user do nothing if (identifier && !(@current_user.id == identifier || @current_user.username == identifier)) render_api_error!('403 Forbidden: Must be admin to use sudo', 403) unless @current_user.is_admin? @current_user = User.by_username_or_id(identifier) not_found!("No user id or username for: #{identifier}") if @current_user.nil? end + @current_user end def sudo_identifier() identifier ||= params[SUDO_PARAM] ||= env[SUDO_HEADER] + # Regex for integers if (!!(identifier =~ /^[0-9]+$/)) identifier.to_i @@ -29,6 +38,7 @@ module API def set_current_user_for_thread Thread.current[:current_user] = current_user + begin yield ensure @@ -42,7 +52,7 @@ module API end def find_project(id) - project = Project.find_by_id(id) || Project.find_with_namespace(id) + project = Project.find_with_namespace(id) || Project.find_by(id: id) if project && can?(current_user, :read_project, project) project @@ -51,8 +61,12 @@ module API end end - def paginate(object) - object.page(params[:page]).per(params[:per_page].to_i) + def paginate(relation) + per_page = params[:per_page].to_i + paginated = relation.page(params[:page]).per(per_page) + add_pagination_headers(paginated, per_page) + + paginated end def authenticate! @@ -69,6 +83,10 @@ module API end end + def authorize_push_project + authorize! :push_code, user_project + end + def authorize_admin_project authorize! :admin_project, user_project end @@ -129,6 +147,18 @@ module API private + def add_pagination_headers(paginated, per_page) + request_url = request.url.split('?').first + + links = [] + links << %(<#{request_url}?page=#{paginated.current_page - 1}&per_page=#{per_page}>; rel="prev") unless paginated.first_page? + links << %(<#{request_url}?page=#{paginated.current_page + 1}&per_page=#{per_page}>; rel="next") unless paginated.last_page? + links << %(<#{request_url}?page=1&per_page=#{per_page}>; rel="first") + links << %(<#{request_url}?page=#{paginated.total_pages}&per_page=#{per_page}>; rel="last") + + header 'Link', links.join(', ') + end + def abilities @abilities ||= begin abilities = Six.new diff --git a/lib/api/internal.rb b/lib/api/internal.rb index ed6b50c3a6..06c66ba0b3 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -1,19 +1,16 @@ module API # Internal access API class Internal < Grape::API - - DOWNLOAD_COMMANDS = %w{ git-upload-pack git-upload-archive } - PUSH_COMMANDS = %w{ git-receive-pack } - namespace 'internal' do - # - # Check if ssh key has access to project code + # Check if git command is allowed to project # # Params: - # key_id - SSH Key id + # key_id - ssh key id for Git over SSH + # user_id - user id for Git over HTTP # project - project path with namespace # action - git action (git-upload-pack or git-receive-pack) # ref - branch name + # forced_push - forced_push # get "/allowed" do # Check for *.wiki repositories. @@ -22,35 +19,26 @@ module API # the wiki repository as well. project_path = params[:project] project_path.gsub!(/\.wiki/,'') if project_path =~ /\.wiki/ - - key = Key.find(params[:key_id]) project = Project.find_with_namespace(project_path) - git_cmd = params[:action] return false unless project + actor = if params[:key_id] + Key.find(params[:key_id]) + elsif params[:user_id] + User.find(params[:user_id]) + end - if key.is_a? DeployKey - key.projects.include?(project) && DOWNLOAD_COMMANDS.include?(git_cmd) - else - user = key.user + return false unless actor - return false if user.blocked? - return false if user.ldap_user? && Gitlab::LDAP::User.blocked?(user.extern_uid) - - action = case git_cmd - when *DOWNLOAD_COMMANDS - then :download_code - when *PUSH_COMMANDS - then - if project.protected_branch?(params[:ref]) - :push_code_to_protected_branches - else - :push_code - end - end - - user.can?(action, project) - end + Gitlab::GitAccess.new.allowed?( + actor, + params[:action], + project, + params[:ref], + params[:oldrev], + params[:newrev], + params[:forced_push] + ) end # diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 3d15c35b8c..f50be3a815 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -48,17 +48,15 @@ module API # Example Request: # POST /projects/:id/issues post ":id/issues" do - set_current_user_for_thread do - required_attributes! [:title] - attrs = attributes_for_keys [:title, :description, :assignee_id, :milestone_id] - attrs[:label_list] = params[:labels] if params[:labels].present? - @issue = user_project.issues.new attrs - @issue.author = current_user - if @issue.save - present @issue, with: Entities::Issue - else - not_found! - end + required_attributes! [:title] + attrs = attributes_for_keys [:title, :description, :assignee_id, :milestone_id] + attrs[:label_list] = params[:labels] if params[:labels].present? + issue = ::Issues::CreateService.new(user_project, current_user, attrs).execute + + if issue.valid? + present issue, with: Entities::Issue + else + not_found! end end @@ -76,18 +74,18 @@ module API # Example Request: # PUT /projects/:id/issues/:issue_id put ":id/issues/:issue_id" do - set_current_user_for_thread do - @issue = user_project.issues.find(params[:issue_id]) - authorize! :modify_issue, @issue + issue = user_project.issues.find(params[:issue_id]) + authorize! :modify_issue, issue - attrs = attributes_for_keys [:title, :description, :assignee_id, :milestone_id, :state_event] - attrs[:label_list] = params[:labels] if params[:labels].present? + attrs = attributes_for_keys [:title, :description, :assignee_id, :milestone_id, :state_event] + attrs[:label_list] = params[:labels] if params[:labels].present? - if @issue.update_attributes attrs - present @issue, with: Entities::Issue - else - not_found! - end + issue = ::Issues::UpdateService.new(user_project, current_user, attrs).execute(issue) + + if issue.valid? + present issue, with: Entities::Issue + else + not_found! end end diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 3f4bec895b..017cb1f562 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -13,28 +13,30 @@ module API end not_found! end - - def not_fork?(target_project_id, user_project) - target_project_id.nil? || target_project_id == user_project.id.to_s - end - - def target_matches_fork(target_project_id,user_project) - user_project.forked? && user_project.forked_from_project.id.to_s == target_project_id - end end # List merge requests # # Parameters: # id (required) - The ID of a project + # state (optional) - Return requests "merged", "opened" or "closed" # # Example: # GET /projects/:id/merge_requests + # GET /projects/:id/merge_requests?state=opened + # GET /projects/:id/merge_requests?state=closed # get ":id/merge_requests" do authorize! :read_merge_request, user_project - present paginate(user_project.merge_requests), with: Entities::MergeRequest + mrs = case params["state"] + when "opened" then user_project.merge_requests.opened + when "closed" then user_project.merge_requests.closed + when "merged" then user_project.merge_requests.merged + else user_project.merge_requests + end + + present paginate(mrs), with: Entities::MergeRequest end # Show MR @@ -64,35 +66,23 @@ module API # target_project - The target project of the merge request defaults to the :id of the project # assignee_id - Assignee user ID # title (required) - Title of MR + # description - Description of MR + # labels (optional) - Labels for MR as a comma-separated list # # Example: # POST /projects/:id/merge_requests # post ":id/merge_requests" do - set_current_user_for_thread do - authorize! :write_merge_request, user_project - required_attributes! [:source_branch, :target_branch, :title] - attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :target_project_id] - merge_request = user_project.merge_requests.new(attrs) - merge_request.author = current_user - merge_request.source_project = user_project - target_project_id = attrs[:target_project_id] - if not_fork?(target_project_id, user_project) - merge_request.target_project = user_project - else - if target_matches_fork(target_project_id,user_project) - merge_request.target_project = Project.find_by_id(attrs[:target_project_id]) - else - render_api_error!('(Bad Request) Specified target project that is not the source project, or the source fork of the project.', 400) - end - end + authorize! :write_merge_request, user_project + required_attributes! [:source_branch, :target_branch, :title] + attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :target_project_id, :description] + attrs[:label_list] = params[:labels] if params[:labels].present? + merge_request = ::MergeRequests::CreateService.new(user_project, current_user, attrs).execute - if merge_request.save - merge_request.reload_code - present merge_request, with: Entities::MergeRequest - else - handle_merge_request_errors! merge_request.errors - end + if merge_request.valid? + present merge_request, with: Entities::MergeRequest + else + handle_merge_request_errors! merge_request.errors end end @@ -106,26 +96,84 @@ module API # assignee_id - Assignee user ID # title - Title of MR # state_event - Status of MR. (close|reopen|merge) + # description - Description of MR + # labels (optional) - Labels for a MR as a comma-separated list # Example: # PUT /projects/:id/merge_request/:merge_request_id # put ":id/merge_request/:merge_request_id" do - set_current_user_for_thread do - attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :state_event] - merge_request = user_project.merge_requests.find(params[:merge_request_id]) + attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :state_event, :description] + attrs[:label_list] = params[:labels] if params[:labels].present? + merge_request = user_project.merge_requests.find(params[:merge_request_id]) + authorize! :modify_merge_request, merge_request + merge_request = ::MergeRequests::UpdateService.new(user_project, current_user, attrs).execute(merge_request) - authorize! :modify_merge_request, merge_request - - if merge_request.update_attributes attrs - merge_request.reload_code - merge_request.mark_as_unchecked - present merge_request, with: Entities::MergeRequest - else - handle_merge_request_errors! merge_request.errors - end + if merge_request.valid? + present merge_request, with: Entities::MergeRequest + else + handle_merge_request_errors! merge_request.errors end end + # Merge MR + # + # Parameters: + # id (required) - The ID of a project + # merge_request_id (required) - ID of MR + # merge_commit_message (optional) - Custom merge commit message + # Example: + # PUT /projects/:id/merge_request/:merge_request_id/merge + # + put ":id/merge_request/:merge_request_id/merge" do + merge_request = user_project.merge_requests.find(params[:merge_request_id]) + + action = if user_project.protected_branch?(merge_request.target_branch) + :push_code_to_protected_branches + else + :push_code + end + + if can?(current_user, action, user_project) + if merge_request.unchecked? + merge_request.check_if_can_be_merged + end + + if merge_request.open? + if merge_request.can_be_merged? + merge_request.automerge!(current_user, params[:merge_commit_message] || merge_request.merge_commit_message) + present merge_request, with: Entities::MergeRequest + else + render_api_error!('Branch cannot be merged', 405) + end + else + # Merge request can not be merged + # because it is already closed/merged + not_allowed! + end + else + # Merge request can not be merged + # because user dont have permissions to push into target branch + unauthorized! + end + end + + + # Get a merge request's comments + # + # Parameters: + # id (required) - The ID of a project + # merge_request_id (required) - ID of MR + # Examples: + # GET /projects/:id/merge_request/:merge_request_id/comments + # + get ":id/merge_request/:merge_request_id/comments" do + merge_request = user_project.merge_requests.find(params[:merge_request_id]) + + authorize! :read_merge_request, merge_request + + present paginate(merge_request.notes), with: Entities::MRNote + end + # Post comment to merge request # # Parameters: diff --git a/lib/api/namespaces.rb b/lib/api/namespaces.rb new file mode 100644 index 0000000000..f9f2ed90cc --- /dev/null +++ b/lib/api/namespaces.rb @@ -0,0 +1,23 @@ +module API + # namespaces API + class Namespaces < Grape::API + before { + authenticate! + authenticated_as_admin! + } + + resource :namespaces do + # Get a namespaces list + # + # Example Request: + # GET /namespaces + get do + @namespaces = Namespace.all + @namespaces = @namespaces.search(params[:search]) if params[:search].present? + @namespaces = paginate @namespaces + + present @namespaces, with: Entities::Namespace + end + end + end +end diff --git a/lib/api/project_hooks.rb b/lib/api/project_hooks.rb index 738974955f..79c3d122d3 100644 --- a/lib/api/project_hooks.rb +++ b/lib/api/project_hooks.rb @@ -5,15 +5,6 @@ module API before { authorize_admin_project } resource :projects do - helpers do - def handle_project_member_errors(errors) - if errors[:project_access].any? - error!(errors[:project_access], 422) - end - not_found! - end - end - # Get project hooks # # Parameters: @@ -22,7 +13,7 @@ module API # GET /projects/:id/hooks get ":id/hooks" do @hooks = paginate user_project.hooks - present @hooks, with: Entities::Hook + present @hooks, with: Entities::ProjectHook end # Get a project hook @@ -34,7 +25,7 @@ module API # 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 + present @hook, with: Entities::ProjectHook end @@ -47,10 +38,11 @@ module API # POST /projects/:id/hooks post ":id/hooks" do required_attributes! [:url] + attrs = attributes_for_keys [:url, :push_events, :issues_events, :merge_requests_events] + @hook = user_project.hooks.new(attrs) - @hook = user_project.hooks.new({"url" => params[:url]}) if @hook.save - present @hook, with: Entities::Hook + present @hook, with: Entities::ProjectHook else if @hook.errors[:url].present? error!("Invalid url given", 422) @@ -70,10 +62,10 @@ module API put ":id/hooks/:hook_id" do @hook = user_project.hooks.find(params[:hook_id]) required_attributes! [:url] + attrs = attributes_for_keys [:url, :push_events, :issues_events, :merge_requests_events] - attrs = attributes_for_keys [:url] if @hook.update_attributes attrs - present @hook, with: Entities::Hook + present @hook, with: Entities::ProjectHook else if @hook.errors[:url].present? error!("Invalid url given", 422) diff --git a/lib/api/project_members.rb b/lib/api/project_members.rb new file mode 100644 index 0000000000..47c4ddce16 --- /dev/null +++ b/lib/api/project_members.rb @@ -0,0 +1,114 @@ +module API + # Projects members API + class ProjectMembers < Grape::API + before { authenticate! } + + resource :projects do + helpers do + def handle_project_member_errors(errors) + if errors[:project_access].any? + error!(errors[:project_access], 422) + end + not_found! + end + end + + # Get a project team members + # + # Parameters: + # id (required) - The ID of a project + # query - Query string + # Example Request: + # GET /projects/:id/members + get ":id/members" do + if params[:query].present? + @members = paginate user_project.users.where("username LIKE ?", "%#{params[:query]}%") + else + @members = paginate user_project.users + end + present @members, with: Entities::ProjectMember, project: user_project + end + + # Get a project team members + # + # Parameters: + # id (required) - The ID of a project + # user_id (required) - The ID of a user + # Example Request: + # GET /projects/:id/members/:user_id + get ":id/members/:user_id" do + @member = user_project.users.find params[:user_id] + present @member, with: Entities::ProjectMember, project: user_project + end + + # Add a new project team member + # + # Parameters: + # id (required) - The ID of a project + # user_id (required) - The ID of a user + # access_level (required) - Project access level + # Example Request: + # POST /projects/:id/members + post ":id/members" do + authorize! :admin_project, user_project + required_attributes! [:user_id, :access_level] + + # either the user is already a team member or a new one + team_member = user_project.team_member_by_id(params[:user_id]) + if team_member.nil? + team_member = user_project.users_projects.new( + user_id: params[:user_id], + project_access: params[:access_level] + ) + end + + if team_member.save + @member = team_member.user + present @member, with: Entities::ProjectMember, project: user_project + else + handle_project_member_errors team_member.errors + end + end + + # Update project team member + # + # Parameters: + # id (required) - The ID of a project + # user_id (required) - The ID of a team member + # access_level (required) - Project access level + # Example Request: + # PUT /projects/:id/members/:user_id + put ":id/members/:user_id" do + authorize! :admin_project, user_project + required_attributes! [:access_level] + + team_member = user_project.users_projects.find_by(user_id: params[:user_id]) + not_found!("User can not be found") if team_member.nil? + + if team_member.update_attributes(project_access: params[:access_level]) + @member = team_member.user + present @member, with: Entities::ProjectMember, project: user_project + else + handle_project_member_errors team_member.errors + end + end + + # Remove a team member from project + # + # Parameters: + # id (required) - The ID of a project + # user_id (required) - The ID of a team member + # Example Request: + # DELETE /projects/:id/members/:user_id + delete ":id/members/:user_id" do + authorize! :admin_project, user_project + team_member = user_project.users_projects.find_by(user_id: params[:user_id]) + unless team_member.nil? + team_member.destroy + else + {message: "Access revoked", id: params[:user_id].to_i} + end + end + end + end +end diff --git a/lib/api/project_snippets.rb b/lib/api/project_snippets.rb index bee6544ea3..8e09fff684 100644 --- a/lib/api/project_snippets.rb +++ b/lib/api/project_snippets.rb @@ -41,7 +41,6 @@ module API # id (required) - The ID of a project # title (required) - The title of a snippet # file_name (required) - The name of a snippet file - # lifetime (optional) - The expiration date of a snippet # code (required) - The content of a snippet # Example Request: # POST /projects/:id/snippets @@ -50,7 +49,6 @@ module API required_attributes! [:title, :file_name, :code] attrs = attributes_for_keys [:title, :file_name] - attrs[:expires_at] = params[:lifetime] if params[:lifetime].present? attrs[:content] = params[:code] if params[:code].present? @snippet = user_project.snippets.new attrs @snippet.author = current_user @@ -69,7 +67,6 @@ module API # snippet_id (required) - The ID of a project snippet # title (optional) - The title of a snippet # file_name (optional) - The name of a snippet file - # lifetime (optional) - The expiration date of a snippet # code (optional) - The content of a snippet # Example Request: # PUT /projects/:id/snippets/:snippet_id @@ -78,7 +75,6 @@ module API authorize! :modify_project_snippet, @snippet attrs = attributes_for_keys [:title, :file_name] - attrs[:expires_at] = params[:lifetime] if params[:lifetime].present? attrs[:content] = params[:code] if params[:code].present? if @snippet.update_attributes attrs diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 221f1f1e23..9d290c75ba 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -5,11 +5,11 @@ module API resource :projects do helpers do - def handle_project_member_errors(errors) - if errors[:project_access].any? - error!(errors[:project_access], 422) - end - not_found! + def map_public_to_visibility_level(attrs) + publik = attrs.delete(:public) + publik = [ true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON' ].include?(publik) + attrs[:visibility_level] = Gitlab::VisibilityLevel::PUBLIC if !attrs[:visibility_level].present? && publik == true + attrs end end @@ -31,6 +31,16 @@ module API present @projects, with: Entities::Project end + # Get all projects for admin user + # + # Example Request: + # GET /projects/all + get '/all' do + authenticated_as_admin! + @projects = paginate Project + present @projects, with: Entities::Project + end + # Get a single project # # Parameters: @@ -38,7 +48,7 @@ module API # Example Request: # GET /projects/:id get ":id" do - present user_project, with: Entities::Project + present user_project, with: Entities::ProjectWithAccess, user: current_user end # Get a single project events @@ -60,14 +70,14 @@ module API # Parameters: # name (required) - name for new project # description (optional) - short project description - # default_branch (optional) - 'master' by default # issues_enabled (optional) # wall_enabled (optional) # merge_requests_enabled (optional) # wiki_enabled (optional) # snippets_enabled (optional) # namespace_id (optional) - defaults to user namespace - # public (optional) - false by default + # public (optional) - if true same as setting visibility_level = 20 + # visibility_level (optional) - 0 by default # Example Request # POST /projects post do @@ -75,15 +85,17 @@ module API attrs = attributes_for_keys [:name, :path, :description, - :default_branch, :issues_enabled, :wall_enabled, :merge_requests_enabled, :wiki_enabled, :snippets_enabled, :namespace_id, - :public] - @project = ::Projects::CreateContext.new(current_user, attrs).execute + :public, + :visibility_level, + :import_url] + attrs = map_public_to_visibility_level(attrs) + @project = ::Projects::CreateService.new(current_user, attrs).execute if @project.saved? present @project, with: Entities::Project else @@ -106,7 +118,8 @@ module API # merge_requests_enabled (optional) # wiki_enabled (optional) # snippets_enabled (optional) - # public (optional) + # public (optional) - if true same as setting visibility_level = 20 + # visibility_level (optional) # Example Request # POST /projects/user/:user_id post "user/:user_id" do @@ -120,8 +133,10 @@ module API :merge_requests_enabled, :wiki_enabled, :snippets_enabled, - :public] - @project = ::Projects::CreateContext.new(user, attrs).execute + :public, + :visibility_level] + attrs = map_public_to_visibility_level(attrs) + @project = ::Projects::CreateService.new(user, attrs).execute if @project.saved? present @project, with: Entities::Project else @@ -174,104 +189,6 @@ module API user_project.forked_project_link.destroy end end - - # Get a project team members - # - # Parameters: - # id (required) - The ID of a project - # query - Query string - # Example Request: - # GET /projects/:id/members - get ":id/members" do - if params[:query].present? - @members = paginate user_project.users.where("username LIKE ?", "%#{params[:query]}%") - else - @members = paginate user_project.users - end - present @members, with: Entities::ProjectMember, project: user_project - end - - # Get a project team members - # - # Parameters: - # id (required) - The ID of a project - # user_id (required) - The ID of a user - # Example Request: - # GET /projects/:id/members/:user_id - get ":id/members/:user_id" do - @member = user_project.users.find params[:user_id] - present @member, with: Entities::ProjectMember, project: user_project - end - - # Add a new project team member - # - # Parameters: - # id (required) - The ID of a project - # user_id (required) - The ID of a user - # access_level (required) - Project access level - # Example Request: - # POST /projects/:id/members - post ":id/members" do - authorize! :admin_project, user_project - required_attributes! [:user_id, :access_level] - - # either the user is already a team member or a new one - team_member = user_project.team_member_by_id(params[:user_id]) - if team_member.nil? - team_member = user_project.users_projects.new( - user_id: params[:user_id], - project_access: params[:access_level] - ) - end - - if team_member.save - @member = team_member.user - present @member, with: Entities::ProjectMember, project: user_project - else - handle_project_member_errors team_member.errors - end - end - - # Update project team member - # - # Parameters: - # id (required) - The ID of a project - # user_id (required) - The ID of a team member - # access_level (required) - Project access level - # Example Request: - # PUT /projects/:id/members/:user_id - put ":id/members/:user_id" do - authorize! :admin_project, user_project - required_attributes! [:access_level] - - team_member = user_project.users_projects.find_by_user_id(params[:user_id]) - not_found!("User can not be found") if team_member.nil? - - if team_member.update_attributes(project_access: params[:access_level]) - @member = team_member.user - present @member, with: Entities::ProjectMember, project: user_project - else - handle_project_member_errors team_member.errors - end - end - - # Remove a team member from project - # - # Parameters: - # id (required) - The ID of a project - # user_id (required) - The ID of a team member - # Example Request: - # DELETE /projects/:id/members/:user_id - delete ":id/members/:user_id" do - authorize! :admin_project, user_project - team_member = user_project.users_projects.find_by_user_id(params[:user_id]) - unless team_member.nil? - team_member.destroy - else - {message: "Access revoked", id: params[:user_id].to_i} - end - end - # search for projects current_user has access to # # Parameters: @@ -282,9 +199,33 @@ module API # GET /projects/search/:query get "/search/:query" do ids = current_user.authorized_projects.map(&:id) - projects = Project.where("(id in (?) OR public = true) AND (name LIKE (?))", ids, "%#{params[:query]}%") + visibility_levels = [ Gitlab::VisibilityLevel::INTERNAL, Gitlab::VisibilityLevel::PUBLIC ] + projects = Project.where("(id in (?) OR visibility_level in (?)) AND (name LIKE (?))", ids, visibility_levels, "%#{params[:query]}%") present paginate(projects), with: Entities::Project end + + + # Get a users list + # + # Example Request: + # GET /users + get ':id/users' do + @users = User.where(id: user_project.team.users.map(&:id)) + @users = @users.search(params[:search]) if params[:search].present? + @users = paginate @users + present @users, with: Entities::User + end + + # Get a project labels + # + # Parameters: + # id (required) - The ID of a project + # Example Request: + # GET /projects/:id/labels + get ':id/labels' do + @labels = user_project.issues_labels + present @labels, with: Entities::Label + end end end end diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb index c9422fdb16..076a9ceeb7 100644 --- a/lib/api/repositories.rb +++ b/lib/api/repositories.rb @@ -1,3 +1,5 @@ +require 'mime/types' + module API # Projects API class Repositories < Grape::API @@ -13,66 +15,6 @@ module API not_found! end end - - # Get a project repository branches - # - # Parameters: - # id (required) - The ID of a project - # Example Request: - # GET /projects/:id/repository/branches - get ":id/repository/branches" do - present user_project.repo.heads.sort_by(&:name), with: Entities::RepoObject, project: user_project - end - - # Get a single branch - # - # Parameters: - # id (required) - The ID of a project - # branch (required) - The name of the branch - # Example Request: - # GET /projects/:id/repository/branches/:branch - get ":id/repository/branches/:branch" do - @branch = user_project.repo.heads.find { |item| item.name == params[:branch] } - not_found!("Branch does not exist") if @branch.nil? - present @branch, with: Entities::RepoObject, project: user_project - end - - # Protect a single branch - # - # Parameters: - # id (required) - The ID of a project - # branch (required) - The name of the branch - # Example Request: - # PUT /projects/:id/repository/branches/:branch/protect - put ":id/repository/branches/:branch/protect" do - authorize_admin_project - - @branch = user_project.repository.find_branch(params[:branch]) - not_found! unless @branch - protected_branch = user_project.protected_branches.find_by_name(@branch.name) - user_project.protected_branches.create(name: @branch.name) unless protected_branch - - present @branch, with: Entities::RepoObject, project: user_project - end - - # Unprotect a single branch - # - # Parameters: - # id (required) - The ID of a project - # branch (required) - The name of the branch - # Example Request: - # PUT /projects/:id/repository/branches/:branch/unprotect - put ":id/repository/branches/:branch/unprotect" do - authorize_admin_project - - @branch = user_project.repository.find_branch(params[:branch]) - not_found! unless @branch - protected_branch = user_project.protected_branches.find_by_name(@branch.name) - protected_branch.destroy if protected_branch - - present @branch, with: Entities::RepoObject, project: user_project - end - # Get a project repository tags # # Parameters: @@ -80,51 +22,7 @@ module API # Example Request: # GET /projects/:id/repository/tags get ":id/repository/tags" do - present user_project.repo.tags.sort_by(&:name).reverse, with: Entities::RepoObject - end - - # Get a project repository commits - # - # Parameters: - # id (required) - The ID of a project - # ref_name (optional) - The name of a repository branch or tag, if not given the default branch is used - # Example Request: - # GET /projects/:id/repository/commits - get ":id/repository/commits" do - page = (params[:page] || 0).to_i - per_page = (params[:per_page] || 20).to_i - ref = params[:ref_name] || user_project.try(:default_branch) || 'master' - - commits = user_project.repository.commits(ref, nil, per_page, page * per_page) - present commits, with: Entities::RepoCommit - end - - # Get a specific commit of a project - # - # Parameters: - # id (required) - The ID of a project - # sha (required) - The commit hash or name of a repository branch or tag - # Example Request: - # GET /projects/:id/repository/commits/:sha - get ":id/repository/commits/:sha" do - sha = params[:sha] - commit = user_project.repository.commit(sha) - not_found! "Commit" unless commit - present commit, with: Entities::RepoCommit - end - - # Get the diff for a specific commit of a project - # - # Parameters: - # id (required) - The ID of a project - # sha (required) - The commit or branch name - # Example Request: - # GET /projects/:id/repository/commits/:sha/diff - get ":id/repository/commits/:sha/diff" do - sha = params[:sha] - result = CommitLoadContext.new(user_project, current_user, {id: sha}).execute - not_found! "Commit" unless result[:commit] - result[:commit].diffs + present user_project.repo.tags.sort_by(&:name).reverse, with: Entities::RepoObject, project: user_project end # Get a project repository tree @@ -139,15 +37,9 @@ module API path = params[:path] || nil commit = user_project.repository.commit(ref) - tree = Tree.new(user_project.repository, commit.id, path) + tree = user_project.repository.tree(commit.id, path) - trees = [] - - %w(trees blobs submodules).each do |type| - trees += tree.send(type).map { |t| {name: t.name, type: type.singularize, mode: t.mode, id: t.id} } - end - - trees + present tree.sorted_entries, with: Entities::RepoTreeObject end # Get a raw file contents @@ -171,6 +63,26 @@ module API blob = Gitlab::Git::Blob.find(repo, commit.id, params[:filepath]) not_found! "File" unless blob + content_type 'text/plain' + present blob.data + end + + # Get a raw blob contents by blob sha + # + # Parameters: + # id (required) - The ID of a project + # sha (required) - The blob's sha + # Example Request: + # GET /projects/:id/repository/raw_blobs/:sha + get ":id/repository/raw_blobs/:sha" do + ref = params[:sha] + + repo = user_project.repository + + blob = Gitlab::Git::Blob.raw(repo, ref) + + not_found! "Blob" unless blob + env['api.format'] = :txt content_type blob.mime_type @@ -184,18 +96,20 @@ module API # sha (optional) - the commit sha to download defaults to the tip of the default branch # Example Request: # GET /projects/:id/repository/archive - get ":id/repository/archive" do + get ":id/repository/archive", requirements: { format: Gitlab::Regex.archive_formats_regex } do authorize! :download_code, user_project repo = user_project.repository ref = params[:sha] - storage_path = Rails.root.join("tmp", "repositories") + format = params[:format] + storage_path = Gitlab.config.gitlab.repository_downloads_path - file_path = repo.archive_repo(ref, storage_path) + file_path = repo.archive_repo(ref, storage_path, format) if file_path && File.exists?(file_path) data = File.open(file_path, 'rb').read - header "Content-Disposition:", " infile; filename=\"#{File.basename(file_path)}\"" - content_type 'application/x-gzip' + header["Content-Disposition"] = "attachment; filename=\"#{File.basename(file_path)}\"" + + content_type MIME::Types.type_for(file_path).first.content_type env['api.format'] = :binary @@ -207,4 +121,3 @@ module API end end end - diff --git a/lib/api/users.rb b/lib/api/users.rb index 54d3aeecb7..6ed2740c33 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -9,7 +9,7 @@ module API # Example Request: # GET /users get do - @users = User.scoped + @users = User.all @users = @users.active if params[:active].present? @users = @users.search(params[:search]) if params[:search].present? @users = paginate @users @@ -36,6 +36,7 @@ module API # skype - Skype ID # linkedin - Linkedin # twitter - Twitter account + # website_url - Website url # projects_limit - Number of projects user can create # extern_uid - External authentication provider UID # provider - External provider @@ -67,6 +68,7 @@ module API # skype - Skype ID # linkedin - Linkedin # twitter - Twitter account + # website_url - Website url # projects_limit - Limit projects each user can create # extern_uid - External authentication provider UID # provider - External provider @@ -78,7 +80,7 @@ module API put ":id" do authenticated_as_admin! - attrs = attributes_for_keys [:email, :name, :password, :skype, :linkedin, :twitter, :projects_limit, :username, :extern_uid, :provider, :bio, :can_create_group, :admin] + attrs = attributes_for_keys [:email, :name, :password, :skype, :linkedin, :twitter, :website_url, :projects_limit, :username, :extern_uid, :provider, :bio, :can_create_group, :admin] user = User.find(params[:id]) not_found!("User not found") unless user @@ -111,13 +113,52 @@ module API end end + # Get ssh keys of a specified user. Only available to admin users. + # + # Parameters: + # uid (required) - The ID of a user + # Example Request: + # GET /users/:uid/keys + get ':uid/keys' do + authenticated_as_admin! + user = User.find_by(id: params[:uid]) + if user + present user.keys, with: Entities::SSHKey + else + not_found! + end + end + + # Delete existing ssh key of a specified user. Only available to admin + # users. + # + # Parameters: + # uid (required) - The ID of a user + # id (required) - SSH Key ID + # Example Request: + # DELETE /users/:uid/keys/:id + delete ':uid/keys/:id' do + authenticated_as_admin! + user = User.find_by(id: params[:uid]) + if user + begin + key = user.keys.find params[:id] + key.destroy + rescue ActiveRecord::RecordNotFound + not_found! + end + else + not_found! + end + end + # Delete user. Available only for admin # # Example Request: # DELETE /users/:id delete ":id" do authenticated_as_admin! - user = User.find_by_id(params[:id]) + user = User.find_by(id: params[:id]) if user user.destroy diff --git a/lib/backup/database.rb b/lib/backup/database.rb index c4fb2e2e15..7b6908ccad 100644 --- a/lib/backup/database.rb +++ b/lib/backup/database.rb @@ -11,23 +11,32 @@ module Backup end def dump - case config["adapter"] + success = case config["adapter"] when /^mysql/ then - system("mysqldump #{mysql_args} #{config['database']} > #{db_file_name}") + print "Dumping MySQL database #{config['database']} ... " + system('mysqldump', *mysql_args, config['database'], out: db_file_name) when "postgresql" then + print "Dumping PostgreSQL database #{config['database']} ... " pg_env - system("pg_dump #{config['database']} > #{db_file_name}") + system('pg_dump', config['database'], out: db_file_name) end + report_success(success) end def restore - case config["adapter"] + success = case config["adapter"] when /^mysql/ then - system("mysql #{mysql_args} #{config['database']} < #{db_file_name}") + print "Restoring MySQL database #{config['database']} ... " + system('mysql', *mysql_args, config['database'], in: db_file_name) when "postgresql" then + print "Restoring PostgreSQL database #{config['database']} ... " + # Drop all tables because PostgreSQL DB dumps do not contain DROP TABLE + # statements like MySQL. + Rake::Task["gitlab:db:drop_all_tables"].invoke pg_env - system("psql #{config['database']} -f #{db_file_name}") + system('psql', config['database'], '-f', db_file_name) end + report_success(success) end protected @@ -45,7 +54,7 @@ module Backup 'encoding' => '--default-character-set', 'password' => '--password' } - args.map { |opt, arg| "#{arg}='#{config[opt]}'" if config[opt] }.compact.join(' ') + args.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact end def pg_env @@ -54,5 +63,13 @@ module Backup ENV['PGPORT'] = config["port"].to_s if config["port"] ENV['PGPASSWORD'] = config["password"].to_s if config["password"] end + + def report_success(success) + if success + puts '[DONE]'.green + else + puts '[FAILED]'.red + end + end end end diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb index 258a0fb258..28e323fe30 100644 --- a/lib/backup/manager.rb +++ b/lib/backup/manager.rb @@ -1,12 +1,14 @@ module Backup class Manager + BACKUP_CONTENTS = %w{repositories/ db/ uploads/ backup_information.yml} + def pack # saving additional informations 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/,"") + s[:gitlab_version] = Gitlab::VERSION + s[:tar_version] = tar_version Dir.chdir(Gitlab.config.backup.path) @@ -16,7 +18,7 @@ module Backup # create archive print "Creating backup archive: #{s[:backup_created_at].to_i}_gitlab_backup.tar ... " - if Kernel.system("tar -cf #{s[:backup_created_at].to_i}_gitlab_backup.tar repositories/ db/ uploads/ backup_information.yml") + if Kernel.system('tar', '-cf', "#{s[:backup_created_at].to_i}_gitlab_backup.tar", *BACKUP_CONTENTS) puts "done".green else puts "failed".red @@ -25,7 +27,7 @@ module Backup def cleanup print "Deleting tmp directories ... " - if Kernel.system("rm -rf repositories/ db/ uploads/ backup_information.yml") + if Kernel.system('rm', '-rf', *BACKUP_CONTENTS) puts "done".green else puts "failed".red @@ -44,7 +46,7 @@ module Backup file_list.map! { |f| $1.to_i if f =~ /(\d+)_gitlab_backup.tar/ } file_list.sort.each do |timestamp| if Time.at(timestamp) < (Time.now - keep_time) - if system("rm #{timestamp}_gitlab_backup.tar") + if Kernel.system(*%W(rm #{timestamp}_gitlab_backup.tar)) removed += 1 end end @@ -75,7 +77,7 @@ module Backup end print "Unpacking backup ... " - unless Kernel.system("tar -xf #{tar_file}") + unless Kernel.system(*%W(tar -xf #{tar_file})) puts "failed".red exit 1 else @@ -85,22 +87,21 @@ module Backup settings = YAML.load_file("backup_information.yml") ENV["VERSION"] = "#{settings[:db_version]}" if settings[:db_version].to_i > 0 - # backups directory is not always sub of Rails root and able to execute the git rev-parse below - begin - Dir.chdir(Rails.root) - - # restoring mismatching backups can lead to unexpected problems - if settings[:gitlab_version] != %x{git rev-parse HEAD}.gsub(/\n/, "") - puts "GitLab version mismatch:".red - puts " Your current HEAD differs from the HEAD in the backup!".red - puts " Please switch to the following revision and try again:".red - puts " revision: #{settings[:gitlab_version]}".red - exit 1 - end - ensure - # chdir back to original intended dir - Dir.chdir(Gitlab.config.backup.path) + # restoring mismatching backups can lead to unexpected problems + if settings[:gitlab_version] != Gitlab::VERSION + puts "GitLab version mismatch:".red + puts " Your current GitLab version (#{Gitlab::VERSION}) differs from the GitLab version in the backup!".red + puts " Please switch to the following version and try again:".red + puts " version: #{settings[:gitlab_version]}".red + puts + puts "Hint: git checkout v#{settings[:gitlab_version]}" + exit 1 end end + + def tar_version + tar_version, _ = Gitlab::Popen.popen(%W(tar --version)) + tar_version.force_encoding('locale').split("\n").first + end end end diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb index 252201f11b..6f7c4f7c90 100644 --- a/lib/backup/repository.rb +++ b/lib/backup/repository.rb @@ -10,27 +10,24 @@ module Backup Project.find_each(batch_size: 1000) do |project| print " * #{project.path_with_namespace} ... " - if project.empty_repo? - puts "[SKIPPED]".cyan - next - end - # Create namespace dir if missing FileUtils.mkdir_p(File.join(backup_repos_path, project.namespace.path)) if project.namespace - if system("cd #{path_to_repo(project)} > /dev/null 2>&1 && git bundle create #{path_to_bundle(project)} --all > /dev/null 2>&1") + if project.empty_repo? + puts "[SKIPPED]".cyan + elsif system(*%W(git --git-dir=#{path_to_repo(project)} bundle create #{path_to_bundle(project)} --all), silent) puts "[DONE]".green else puts "[FAILED]".red end - wiki = GollumWiki.new(project) + wiki = ProjectWiki.new(project) if File.exists?(path_to_repo(wiki)) print " * #{wiki.path_with_namespace} ... " if wiki.empty? puts " [SKIPPED]".cyan - elsif system("cd #{path_to_repo(wiki)} > /dev/null 2>&1 && git bundle create #{path_to_bundle(wiki)} --all > /dev/null 2>&1") + elsif system(*%W(git --git-dir=#{path_to_repo(wiki)} bundle create #{path_to_bundle(wiki)} --all), silent) puts " [DONE]".green else puts " [FAILED]".red @@ -53,17 +50,17 @@ module Backup project.namespace.ensure_dir_exist if project.namespace - if system("git clone --bare #{path_to_bundle(project)} #{path_to_repo(project)} > /dev/null 2>&1") + if system(*%W(git clone --bare #{path_to_bundle(project)} #{path_to_repo(project)}), silent) puts "[DONE]".green else puts "[FAILED]".red end - wiki = GollumWiki.new(project) + wiki = ProjectWiki.new(project) if File.exists?(path_to_bundle(wiki)) print " * #{wiki.path_with_namespace} ... " - if system("git clone --bare #{path_to_bundle(wiki)} #{path_to_repo(wiki)} > /dev/null 2>&1") + if system(*%W(git clone --bare #{path_to_bundle(wiki)} #{path_to_repo(wiki)}), silent) puts " [DONE]".green else puts " [FAILED]".red @@ -72,8 +69,7 @@ module Backup end print 'Put GitLab hooks in repositories dirs'.yellow - gitlab_shell_user_home = File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}") - if system("#{gitlab_shell_user_home}/gitlab-shell/support/rewrite-hooks.sh #{Gitlab.config.gitlab_shell.repos_path}") + if system("#{Gitlab.config.gitlab_shell.path}/support/rewrite-hooks.sh", Gitlab.config.gitlab_shell.repos_path) puts " [DONE]".green else puts " [FAILED]".red @@ -103,5 +99,9 @@ module Backup FileUtils.rm_rf(backup_repos_path) FileUtils.mkdir_p(backup_repos_path) end + + def silent + {err: '/dev/null', out: '/dev/null'} + end end end diff --git a/lib/backup/uploads.rb b/lib/backup/uploads.rb index 462d3f1e27..e50e1ff4f1 100644 --- a/lib/backup/uploads.rb +++ b/lib/backup/uploads.rb @@ -3,7 +3,7 @@ module Backup attr_reader :app_uploads_dir, :backup_uploads_dir, :backup_dir def initialize - @app_uploads_dir = Rails.root.join('public', 'uploads') + @app_uploads_dir = File.realpath(Rails.root.join('public', 'uploads')) @backup_dir = Gitlab.config.backup.path @backup_uploads_dir = File.join(Gitlab.config.backup.path, 'uploads') end @@ -19,10 +19,11 @@ module Backup FileUtils.cp_r(backup_uploads_dir, app_uploads_dir) end - + def backup_existing_uploads_dir + timestamped_uploads_path = File.join(app_uploads_dir, '..', "uploads.#{Time.now.to_i}") if File.exists?(app_uploads_dir) - FileUtils.mv(app_uploads_dir, Rails.root.join('public', "uploads.#{Time.now.to_i}")) + FileUtils.mv(app_uploads_dir, timestamped_uploads_path) end end end diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb index 6e7872dcd0..e51cb30bdd 100644 --- a/lib/extracts_path.rb +++ b/lib/extracts_path.rb @@ -117,7 +117,7 @@ module ExtractsPath end def tree - @tree ||= Tree.new(@repo, @commit.id, @path) + @tree ||= @repo.tree(@commit.id, @path) end private diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb index 0f19629747..955abc1bed 100644 --- a/lib/gitlab/auth.rb +++ b/lib/gitlab/auth.rb @@ -1,7 +1,7 @@ module Gitlab class Auth def find(login, password) - user = User.find_by_email(login) || User.find_by_username(login) + user = User.find_by(email: login) || User.find_by(username: login) if user.nil? || user.ldap_user? # Second chance - try LDAP authentication diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index e09cf31197..c2f3b851c0 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -1,11 +1,9 @@ require_relative 'shell_env' -require_relative 'grack_helpers' module Grack class Auth < Rack::Auth::Basic - include Helpers - attr_accessor :user, :project, :ref, :env + attr_accessor :user, :project, :env def call(env) @env = env @@ -24,14 +22,16 @@ module Grack @env['SCRIPT_NAME'] = "" - auth! + if project + auth! + else + render_not_found + end end private def auth! - return render_not_found unless project - if @auth.provided? return bad_request unless @auth.basic? @@ -40,12 +40,8 @@ module Grack # Allow authentication for GitLab CI service # if valid token passed - if login == "gitlab-ci-token" && project.gitlab_ci? - token = project.gitlab_ci_service.token - - if token.present? && token == password && service_name == 'git-upload-pack' - return @app.call(env) - end + if gitlab_ci_request?(login, password) + return @app.call(env) end @user = authenticate_user(login, password) @@ -53,23 +49,26 @@ module Grack if @user Gitlab::ShellEnv.set_env(@user) @env['REMOTE_USER'] = @auth.username - else - return unauthorized end - - else - return unauthorized unless project.public end - if authorized_git_request? + if authorized_request? @app.call(env) else unauthorized end end - def authorized_git_request? - authorize_request(service_name) + def gitlab_ci_request?(login, password) + if login == "gitlab-ci-token" && project.gitlab_ci? + token = project.gitlab_ci_service.token + + if token.present? && token == password && git_cmd == 'git-upload-pack' + return true + end + end + + false end def authenticate_user(login, password) @@ -77,24 +76,31 @@ module Grack auth.find(login, password) end - def authorize_request(service) - case service - when 'git-upload-pack' - project.public || can?(user, :download_code, project) - when'git-receive-pack' - action = if project.protected_branch?(ref) - :push_code_to_protected_branches - else - :push_code - end - - can?(user, action, project) + def authorized_request? + case git_cmd + when *Gitlab::GitAccess::DOWNLOAD_COMMANDS + if user + Gitlab::GitAccess.new.download_allowed?(user, project) + elsif project.public? + # Allow clone/fetch for public projects + true + else + false + end + when *Gitlab::GitAccess::PUSH_COMMANDS + if user + # Skip user authorization on upload request. + # It will be serverd by update hook in repository + true + else + false + end else false end end - def service_name + def git_cmd if @request.get? @request.params['service'] elsif @request.post? @@ -108,20 +114,17 @@ module Grack @project ||= project_by_path(@request.path_info) end - def ref - @ref ||= parse_ref + def project_by_path(path) + if m = /^([\w\.\/-]+)\.git/.match(path).to_a + path_with_namespace = m.last + path_with_namespace.gsub!(/\.wiki$/, '') + + Project.find_with_namespace(path_with_namespace) + end end - def parse_ref - input = if @env["HTTP_CONTENT_ENCODING"] =~ /gzip/ - Zlib::GzipReader.new(@request.body).read - else - @request.body.read - end - - # Need to reset seek point - @request.body.rewind - /refs\/heads\/([\/\w\.-]+)/n.match(input.force_encoding('ascii-8bit')).to_a.last + def render_not_found + [404, {"Content-Type" => "text/plain"}, ["Not Found"]] end end end diff --git a/lib/gitlab/backend/grack_helpers.rb b/lib/gitlab/backend/grack_helpers.rb deleted file mode 100644 index 5ac9e9f325..0000000000 --- a/lib/gitlab/backend/grack_helpers.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Grack - module Helpers - def project_by_path(path) - if m = /^\/([\w\.\/-]+)\.git/.match(path).to_a - path_with_namespace = m.last - path_with_namespace.gsub!(/\.wiki$/, '') - - Project.find_with_namespace(path_with_namespace) - end - end - - def render_not_found - [404, {"Content-Type" => "text/plain"}, ["Not Found"]] - end - - def can?(object, action, subject) - abilities.allowed?(object, action, subject) - end - - def abilities - @abilities ||= begin - abilities = Six.new - abilities << Ability - abilities - end - end - end -end diff --git a/lib/gitlab/backend/shell.rb b/lib/gitlab/backend/shell.rb index c819ce56ac..b93800e235 100644 --- a/lib/gitlab/backend/shell.rb +++ b/lib/gitlab/backend/shell.rb @@ -2,6 +2,12 @@ module Gitlab class Shell class AccessDenied < StandardError; end + class KeyAdder < Struct.new(:io) + def add_key(id, key) + io.puts("#{id}\t#{key.strip}") + end + end + # Init new repository # # name - project path with namespace @@ -10,7 +16,7 @@ module Gitlab # add_repository("gitlab/gitlab-ci") # def add_repository(name) - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "add-project", "#{name}.git" + system "#{gitlab_shell_path}/bin/gitlab-projects", "add-project", "#{name}.git" end # Import repository @@ -21,7 +27,7 @@ module Gitlab # import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git") # def import_repository(name, url) - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "import-project", "#{name}.git", url + system "#{gitlab_shell_path}/bin/gitlab-projects", "import-project", "#{name}.git", url end # Move repository @@ -33,7 +39,7 @@ module Gitlab # mv_repository("gitlab/gitlab-ci", "randx/gitlab-ci-new.git") # def mv_repository(path, new_path) - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "mv-project", "#{path}.git", "#{new_path}.git" + system "#{gitlab_shell_path}/bin/gitlab-projects", "mv-project", "#{path}.git", "#{new_path}.git" end # Update HEAD for repository @@ -45,7 +51,7 @@ module Gitlab # update_repository_head("gitlab/gitlab-ci", "3-1-stable") # def update_repository_head(path, branch) - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "update-head", "#{path}.git", branch + system "#{gitlab_shell_path}/bin/gitlab-projects", "update-head", "#{path}.git", branch end # Fork repository to new namespace @@ -57,7 +63,7 @@ module Gitlab # fork_repository("gitlab/gitlab-ci", "randx") # def fork_repository(path, fork_namespace) - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "fork-project", "#{path}.git", fork_namespace + system "#{gitlab_shell_path}/bin/gitlab-projects", "fork-project", "#{path}.git", fork_namespace end # Remove repository from file system @@ -68,7 +74,7 @@ module Gitlab # remove_repository("gitlab/gitlab-ci") # def remove_repository(name) - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "rm-project", "#{name}.git" + system "#{gitlab_shell_path}/bin/gitlab-projects", "rm-project", "#{name}.git" end # Add repository branch from passed ref @@ -81,7 +87,7 @@ module Gitlab # add_branch("gitlab/gitlab-ci", "4-0-stable", "master") # def add_branch(path, branch_name, ref) - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "create-branch", "#{path}.git", branch_name, ref + system "#{gitlab_shell_path}/bin/gitlab-projects", "create-branch", "#{path}.git", branch_name, ref end # Remove repository branch @@ -93,7 +99,7 @@ module Gitlab # rm_branch("gitlab/gitlab-ci", "4-0-stable") # def rm_branch(path, branch_name) - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "rm-branch", "#{path}.git", branch_name + system "#{gitlab_shell_path}/bin/gitlab-projects", "rm-branch", "#{path}.git", branch_name end # Add repository tag from passed ref @@ -106,7 +112,7 @@ module Gitlab # add_tag("gitlab/gitlab-ci", "v4.0", "master") # def add_tag(path, tag_name, ref) - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "create-tag", "#{path}.git", tag_name, ref + system "#{gitlab_shell_path}/bin/gitlab-projects", "create-tag", "#{path}.git", tag_name, ref end # Remove repository tag @@ -118,7 +124,7 @@ module Gitlab # rm_tag("gitlab/gitlab-ci", "v4.0") # def rm_tag(path, tag_name) - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "rm-tag", "#{path}.git", tag_name + system "#{gitlab_shell_path}/bin/gitlab-projects", "rm-tag", "#{path}.git", tag_name end # Add new key to gitlab-shell @@ -127,7 +133,17 @@ module Gitlab # add_key("key-42", "sha-rsa ...") # def add_key(key_id, key_content) - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "add-key", key_id, key_content + system "#{gitlab_shell_path}/bin/gitlab-keys", "add-key", key_id, key_content + end + + # Batch-add keys to authorized_keys + # + # Ex. + # batch_add_keys { |adder| adder.add_key("key-42", "sha-rsa ...") } + def batch_add_keys(&block) + IO.popen(%W(#{gitlab_shell_path}/bin/gitlab-keys batch-add-keys), 'w') do |io| + block.call(KeyAdder.new(io)) + end end # Remove ssh key from gitlab shell @@ -136,7 +152,7 @@ module Gitlab # remove_key("key-342", "sha-rsa ...") # def remove_key(key_id, key_content) - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "rm-key", key_id, key_content + system "#{gitlab_shell_path}/bin/gitlab-keys", "rm-key", key_id, key_content end # Remove all ssh keys from gitlab shell @@ -145,7 +161,7 @@ module Gitlab # remove_all_keys # def remove_all_keys - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "clear" + system "#{gitlab_shell_path}/bin/gitlab-keys", "clear" end # Add empty directory for storing repositories @@ -196,8 +212,21 @@ module Gitlab Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git" end + # Return GitLab shell version + def version + gitlab_shell_version_file = "#{gitlab_shell_path}/VERSION" + + if File.readable?(gitlab_shell_version_file) + File.read(gitlab_shell_version_file) + end + end + protected + def gitlab_shell_path + Gitlab.config.gitlab_shell.path + end + def gitlab_shell_user_home File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}") end diff --git a/lib/gitlab/blacklist.rb b/lib/gitlab/blacklist.rb index 2f9091e07d..6bc2c3b487 100644 --- a/lib/gitlab/blacklist.rb +++ b/lib/gitlab/blacklist.rb @@ -3,7 +3,7 @@ module Gitlab extend self def path - %w(admin dashboard groups help profile projects search public assets u s teams merge_requests issues users snippets services repository hooks notes) + %w(admin dashboard files groups help profile projects search public assets u s teams merge_requests issues users snippets services repository hooks notes) end end end diff --git a/lib/gitlab/diff_parser.rb b/lib/gitlab/diff_parser.rb index fb27280c4a..14bbb32863 100644 --- a/lib/gitlab/diff_parser.rb +++ b/lib/gitlab/diff_parser.rb @@ -4,9 +4,9 @@ module Gitlab attr_reader :lines, :new_path - def initialize(diff) - @lines = diff.diff.lines.to_a - @new_path = diff.new_path + def initialize(lines, new_path = '') + @lines = lines + @new_path = new_path end def each @@ -18,10 +18,7 @@ module Gitlab lines_arr.each do |line| raw_line = line.dup - next if line.match(/^\-\-\- \/dev\/null/) - next if line.match(/^\+\+\+ \/dev\/null/) - next if line.match(/^\-\-\- a/) - next if line.match(/^\+\+\+ b/) + next if filename?(line) full_line = html_escape(line.gsub(/\n/, '')) full_line = ::Gitlab::InlineDiff.replace_markers full_line @@ -53,8 +50,17 @@ module Gitlab end end + def empty? + @lines.empty? + end + private + def filename?(line) + line.start_with?('--- /dev/null', '+++ /dev/null', '--- a', '+++ b', + '--- /tmp/diffy', '+++ /tmp/diffy') + end + def identification_type(line) if line[0] == "+" "new" diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb new file mode 100644 index 0000000000..4f49ca4189 --- /dev/null +++ b/lib/gitlab/git_access.rb @@ -0,0 +1,67 @@ +module Gitlab + class GitAccess + DOWNLOAD_COMMANDS = %w{ git-upload-pack git-upload-archive } + PUSH_COMMANDS = %w{ git-receive-pack } + + attr_reader :params, :project, :git_cmd, :user + + def allowed?(actor, cmd, project, ref = nil, oldrev = nil, newrev = nil, forced_push = false) + case cmd + when *DOWNLOAD_COMMANDS + if actor.is_a? User + download_allowed?(actor, project) + elsif actor.is_a? DeployKey + actor.projects.include?(project) + elsif actor.is_a? Key + download_allowed?(actor.user, project) + else + raise 'Wrong actor' + end + when *PUSH_COMMANDS + if actor.is_a? User + push_allowed?(actor, project, ref, oldrev, newrev, forced_push) + elsif actor.is_a? DeployKey + # Deploy key not allowed to push + return false + elsif actor.is_a? Key + push_allowed?(actor.user, project, ref, oldrev, newrev, forced_push) + else + raise 'Wrong actor' + end + else + false + end + end + + def download_allowed?(user, project) + if user && user_allowed?(user) + user.can?(:download_code, project) + else + false + end + end + + def push_allowed?(user, project, ref, oldrev, newrev, forced_push) + if user && user_allowed?(user) + action = if project.protected_branch?(ref) + if forced_push.to_s == 'true' + :force_push_code_to_protected_branches + else + :push_code_to_protected_branches + end + else + :push_code + end + user.can?(action, project) + else + false + end + end + + private + + def user_allowed?(user) + Gitlab::UserAccess.allowed?(user) + end + end +end diff --git a/lib/gitlab/identifier.rb b/lib/gitlab/identifier.rb index a1ff248a77..6e4de197ee 100644 --- a/lib/gitlab/identifier.rb +++ b/lib/gitlab/identifier.rb @@ -6,17 +6,17 @@ module Gitlab if identifier.blank? # Local push from gitlab email = project.repository.commit(newrev).author_email rescue nil - User.find_by_email(email) if email + User.find_by(email: email) if email elsif identifier =~ /\Auser-\d+\Z/ # git push over http user_id = identifier.gsub("user-", "") - User.find_by_id(user_id) + User.find_by(id: user_id) elsif identifier =~ /\Akey-\d+\Z/ # git push over ssh key_id = identifier.gsub("key-", "") - Key.find_by_id(key_id).try(:user) + Key.find_by(id: key_id).try(:user) end end end diff --git a/lib/gitlab/ldap/access.rb b/lib/gitlab/ldap/access.rb new file mode 100644 index 0000000000..4e48ff1187 --- /dev/null +++ b/lib/gitlab/ldap/access.rb @@ -0,0 +1,27 @@ +module Gitlab + module LDAP + class Access + attr_reader :adapter + + def self.open(&block) + Gitlab::LDAP::Adapter.open do |adapter| + block.call(self.new(adapter)) + end + end + + def initialize(adapter=nil) + @adapter = adapter + end + + def allowed?(user) + if Gitlab::LDAP::Person.find_by_dn(user.extern_uid, adapter) + !Gitlab::LDAP::Person.active_directory_disabled?(user.extern_uid, adapter) + else + false + end + rescue + false + end + end + end +end diff --git a/lib/gitlab/ldap/adapter.rb b/lib/gitlab/ldap/adapter.rb new file mode 100644 index 0000000000..e36616f0e6 --- /dev/null +++ b/lib/gitlab/ldap/adapter.rb @@ -0,0 +1,107 @@ +module Gitlab + module LDAP + class Adapter + attr_reader :ldap + + def self.open(&block) + Net::LDAP.open(adapter_options) do |ldap| + block.call(self.new(ldap)) + end + end + + def self.config + Gitlab.config.ldap + end + + def self.adapter_options + encryption = config['method'].to_s == 'ssl' ? :simple_tls : nil + + options = { + host: config['host'], + port: config['port'], + encryption: encryption + } + + auth_options = { + auth: { + method: :simple, + username: config['bind_dn'], + password: config['password'] + } + } + + if config['password'] || config['bind_dn'] + options.merge!(auth_options) + end + options + end + + + def initialize(ldap=nil) + @ldap = ldap || Net::LDAP.new(self.class.adapter_options) + end + + def users(field, value) + if field.to_sym == :dn + options = { + base: value, + scope: Net::LDAP::SearchScope_BaseObject + } + else + options = { + base: config['base'], + filter: Net::LDAP::Filter.eq(field, value) + } + end + + if config['user_filter'].present? + user_filter = Net::LDAP::Filter.construct(config['user_filter']) + + options[:filter] = if options[:filter] + Net::LDAP::Filter.join(options[:filter], user_filter) + else + user_filter + end + end + + entries = ldap_search(options).select do |entry| + entry.respond_to? config.uid + end + + entries.map do |entry| + Gitlab::LDAP::Person.new(entry) + end + end + + def user(*args) + users(*args).first + end + + def dn_matches_filter?(dn, filter) + ldap_search(base: dn, filter: filter, scope: Net::LDAP::SearchScope_BaseObject, attributes: %w{dn}).any? + end + + def ldap_search(*args) + results = ldap.search(*args) + + if results.nil? + response = ldap.get_operation_result + + unless response.code.zero? + Rails.logger.warn("LDAP search error: #{response.message}") + end + + [] + else + results + end + end + + private + + def config + @config ||= self.class.config + end + end + end +end diff --git a/lib/gitlab/ldap/person.rb b/lib/gitlab/ldap/person.rb new file mode 100644 index 0000000000..9ad6618bd4 --- /dev/null +++ b/lib/gitlab/ldap/person.rb @@ -0,0 +1,60 @@ +module Gitlab + module LDAP + class Person + # Active Directory-specific LDAP filter that checks if bit 2 of the + # userAccountControl attribute is set. + # Source: http://ctogonewild.com/2009/09/03/bitmask-searches-in-ldap/ + AD_USER_DISABLED = Net::LDAP::Filter.ex("userAccountControl:1.2.840.113556.1.4.803", "2") + + def self.find_by_uid(uid, adapter=nil) + adapter ||= Gitlab::LDAP::Adapter.new + adapter.user(config.uid, uid) + end + + def self.find_by_dn(dn, adapter=nil) + adapter ||= Gitlab::LDAP::Adapter.new + adapter.user('dn', dn) + end + + def self.active_directory_disabled?(dn, adapter=nil) + adapter ||= Gitlab::LDAP::Adapter.new + adapter.dn_matches_filter?(dn, AD_USER_DISABLED) + end + + def initialize(entry) + Rails.logger.debug { "Instantiating #{self.class.name} with LDIF:\n#{entry.to_ldif}" } + @entry = entry + end + + def name + entry.cn.first + end + + def uid + entry.send(config.uid).first + end + + def username + uid + end + + def dn + entry.dn + end + + private + + def entry + @entry + end + + def adapter + @adapter ||= Gitlab::LDAP::Adapter.new + end + + def config + @config ||= Gitlab.config.ldap + end + end + end +end diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb index 3d57f3a2e3..01d86430f0 100644 --- a/lib/gitlab/ldap/user.rb +++ b/lib/gitlab/ldap/user.rb @@ -13,8 +13,8 @@ module Gitlab def find_or_create(auth) @auth = auth - if uid.blank? || email.blank? - raise_error("Account must provide an uid and email address") + if uid.blank? || email.blank? || username.blank? + raise_error("Account must provide a dn, uid and email address") end user = find(auth) @@ -23,8 +23,8 @@ module Gitlab # Look for user with same emails # # Possible cases: - # * When user already has account and need to link his LDAP account. - # * LDAP uid changed for user with same email and we need to update his uid + # * When user already has account and need to link their LDAP account. + # * LDAP uid changed for user with same email and we need to update their uid # user = find_user(email) @@ -44,13 +44,13 @@ module Gitlab end def find_user(email) - user = model.find_by_email(email) + user = model.find_by(email: email) # If no user found and allow_username_or_email_login is true - # we look for user by extracting part of his email + # we look for user by extracting part of their email if !user && email && ldap_conf['allow_username_or_email_login'] uname = email.partition('@').first - user = model.find_by_username(uname) + user = model.find_by(username: uname) end user @@ -62,8 +62,16 @@ module Gitlab return nil unless ldap_conf.enabled && login.present? && password.present? ldap = OmniAuth::LDAP::Adaptor.new(ldap_conf) + filter = Net::LDAP::Filter.eq(ldap.uid, login) + + # Apply LDAP user filter if present + if ldap_conf['user_filter'].present? + user_filter = Net::LDAP::Filter.construct(ldap_conf['user_filter']) + filter = Net::LDAP::Filter.join(filter, user_filter) + end + ldap_user = ldap.bind_as( - filter: Net::LDAP::Filter.eq(ldap.uid, login), + filter: filter, size: 1, password: password ) @@ -71,20 +79,19 @@ module Gitlab find_by_uid(ldap_user.dn) if ldap_user end - # Check LDAP user existance by dn. User in git over ssh check - # - # It covers 2 cases: - # * when ldap account was removed - # * when ldap account was deactivated by change of OU membership in 'dn' - def blocked?(dn) - ldap = OmniAuth::LDAP::Adaptor.new(ldap_conf) - ldap.connection.search(base: dn, scope: Net::LDAP::SearchScope_BaseObject, size: 1).blank? - end - private + def find_by_uid_and_provider + find_by_uid(uid) + end + def find_by_uid(uid) - model.where(provider: provider, extern_uid: uid).last + # LDAP distinguished name is case-insensitive + model.where("provider = ? and lower(extern_uid) = ?", provider, uid.downcase).last + end + + def username + auth.info.nickname.to_s.force_encoding("utf-8") end def provider diff --git a/lib/gitlab/logger.rb b/lib/gitlab/logger.rb index 389eef3395..64cf3303ea 100644 --- a/lib/gitlab/logger.rb +++ b/lib/gitlab/logger.rb @@ -11,12 +11,14 @@ module Gitlab def self.read_latest path = Rails.root.join("log", file_name) self.build unless File.exist?(path) - logs = `tail -n 2000 #{path}`.split("\n") + tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path})) + tail_output.split("\n") end def self.read_latest_for filename path = Rails.root.join("log", filename) - logs = `tail -n 2000 #{path}`.split("\n") + tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path})) + tail_output.split("\n") end def self.build diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index dc9c0e0ab2..dca3d7a7be 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -98,7 +98,8 @@ module Gitlab (?\W)? # Prefix ( # Reference @(?[a-zA-Z][a-zA-Z0-9_\-\.]*) # User name - |\#(?([a-zA-Z]+-)?\d+) # Issue ID + |(?([A-Z\-]+-)\d+) # JIRA Issue ID + |\#(?([a-zA-Z\-]+-)?\d+) # Issue ID |!(?\d+) # MR ID |\$(?\d+) # Snippet ID |(?[\h]{6,40}) # Commit ID @@ -152,7 +153,7 @@ module Gitlab # # Returns boolean def valid_emoji?(emoji) - Emoji.names.include? emoji + Emoji.find_by_name emoji end # Private: Dispatches to a dedicated processing method based on reference @@ -166,17 +167,21 @@ module Gitlab end def reference_user(identifier) - if member = @project.team_members.find { |user| user.username == identifier } - link_to("@#{identifier}", user_url(identifier), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if member + if user = User.find_by_username(identifier) + link_to("@#{identifier}", user_url(identifier), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) end end def reference_issue(identifier) - if @project.issue_exists? identifier - url = url_for_issue(identifier) - title = title_for_issue(identifier) + if @project.used_default_issues_tracker? || !external_issues_tracker_enabled? + if @project.issue_exists? identifier + url = url_for_issue(identifier) + title = title_for_issue(identifier) - link_to("##{identifier}", url, html_options.merge(title: "Issue: #{title}", class: "gfm gfm-issue #{html_options[:class]}")) + link_to("##{identifier}", url, html_options.merge(title: "Issue: #{title}", class: "gfm gfm-issue #{html_options[:class]}")) + end + else + reference_jira_issue(identifier) if @project.issues_tracker == "jira" end end @@ -197,5 +202,12 @@ module Gitlab link_to(identifier, project_commit_url(@project, commit), html_options.merge(title: commit.link_title, class: "gfm gfm-commit #{html_options[:class]}")) end end + + def reference_jira_issue(identifier) + url = url_for_issue(identifier) + title = Gitlab.config.issues_tracker[@project.issues_tracker]["title"] + + link_to("#{identifier}", url, html_options.merge(title: "Issue in #{title}", class: "gfm gfm-issue #{html_options[:class]}")) + end end end diff --git a/lib/gitlab/oauth/user.rb b/lib/gitlab/oauth/user.rb index ea9badba2c..d154bd8600 100644 --- a/lib/gitlab/oauth/user.rb +++ b/lib/gitlab/oauth/user.rb @@ -28,8 +28,21 @@ module Gitlab } user = model.build_user(opts, as: :admin) + user.skip_confirmation! + + # Services like twitter and github does not return email via oauth + # In this case we generate temporary email and force user to fill it later + if user.email.blank? + user.generate_tmp_oauth_email + elsif provider != "ldap" + # Google oauth returns email but dont return nickname + # So we use part of email as username for new user + # For LDAP, username is already set to the user's + # uid/userid/sAMAccountName. + user.username = email.match(/^[^@]*/)[0] + end + user.save! - user.confirm! log.info "(OAuth) Creating user #{email} from login with extern_uid => #{uid}" if Gitlab.config.omniauth['block_auto_created_users'] && !ldap? @@ -54,11 +67,15 @@ module Gitlab end def name - auth.info.name.to_s.force_encoding("utf-8") + if auth.info.name.nil? + "#{auth.info.first_name} #{auth.info.last_name}".force_encoding('utf-8') + else + auth.info.name.to_s.force_encoding('utf-8') + end end def username - email.match(/^[^@]*/)[0] + auth.info.nickname.to_s.force_encoding("utf-8") end def provider diff --git a/lib/gitlab/popen.rb b/lib/gitlab/popen.rb index 2f30fde207..e2fbafb389 100644 --- a/lib/gitlab/popen.rb +++ b/lib/gitlab/popen.rb @@ -1,15 +1,29 @@ +require 'fileutils' +require 'open3' + module Gitlab module Popen - def popen(cmd, path) + extend self + + def popen(cmd, path=nil) + unless cmd.is_a?(Array) + raise "System commands must be given as an array of strings" + end + + path ||= Dir.pwd vars = { "PWD" => path } options = { chdir: path } + unless File.directory?(path) + FileUtils.mkdir_p(path) + end + @cmd_output = "" @cmd_status = 0 - Open3.popen3(vars, cmd, options) do |stdin, stdout, stderr, wait_thr| - @cmd_status = wait_thr.value.exitstatus + Open3.popen3(vars, *cmd, options) do |stdin, stdout, stderr, wait_thr| @cmd_output << stdout.read @cmd_output << stderr.read + @cmd_status = wait_thr.value.exitstatus end return @cmd_output, @cmd_status diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index 55aa240a9f..e932b64f4f 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -7,7 +7,7 @@ module Gitlab end def project_name_regex - /\A[a-zA-Z0-9][a-zA-Z0-9_\-\. ]*\z/ + /\A[a-zA-Z0-9_][a-zA-Z0-9_\-\. ]*\z/ end def name_regex @@ -18,33 +18,38 @@ module Gitlab default_regex end + def archive_formats_regex + #|zip|tar| tar.gz | tar.bz2 | + /(zip|tar|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2)/ + end + def git_reference_regex # Valid git ref regex, see: # https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html %r{ (?! - # doesn't begins with - \/| # (rule #6) - # doesn't contain + (?# doesn't begins with) + \/| (?# rule #6) + (?# doesn't contain) .*(?: - [\/.]\.| # (rule #1,3) - \/\/| # (rule #6) - @\{| # (rule #8) - \\ # (rule #9) + [\/.]\.| (?# rule #1,3) + \/\/| (?# rule #6) + @\{| (?# rule #8) + \\ (?# rule #9) ) ) - [^\000-\040\177~^:?*\[]+ # (rule #4-5) - # doesn't end with - (? ex + handle_exception(ex) + end + + # Retrieve an array of commits between the source and the target + def commits + in_locked_and_timed_satellite do |target_repo| + prepare_satellite!(target_repo) + update_satellite_source_and_target!(target_repo) + commits = target_repo.commits_between("origin/#{@target_branch}", "source/#{@source_branch}") + commits = commits.map { |commit| Gitlab::Git::Commit.new(commit, nil) } + commits + end + rescue Grit::Git::CommandFailed => ex + handle_exception(ex) + end + + private + + # Assumes a satellite exists that is a fresh clone of the projects repo, prepares satellite for diffs + def update_satellite_source_and_target!(target_repo) + target_repo.remote_add('source', @source_project.repository.path_to_repo) + target_repo.remote_fetch('source') + target_repo.git.checkout(default_options({b: true}), @target_branch, "origin/#{@target_branch}") + rescue Grit::Git::CommandFailed => ex + handle_exception(ex) + end + end + end +end diff --git a/lib/gitlab/satellite/files/delete_file_action.rb b/lib/gitlab/satellite/files/delete_file_action.rb new file mode 100644 index 0000000000..30462999aa --- /dev/null +++ b/lib/gitlab/satellite/files/delete_file_action.rb @@ -0,0 +1,50 @@ +require_relative 'file_action' + +module Gitlab + module Satellite + class DeleteFileAction < FileAction + # Deletes file and creates a new commit for it + # + # Returns false if committing the change fails + # Returns false if pushing from the satellite to bare repo failed or was rejected + # Returns true otherwise + def commit!(content, commit_message) + in_locked_and_timed_satellite do |repo| + prepare_satellite!(repo) + + # create target branch in satellite at the corresponding commit from bare repo + repo.git.checkout({raise: true, timeout: true, b: true}, ref, "origin/#{ref}") + + # update the file in the satellite's working dir + file_path_in_satellite = File.join(repo.working_dir, file_path) + + # Prevent relative links + unless safe_path?(file_path_in_satellite) + Gitlab::GitLogger.error("FileAction: Relative path not allowed") + return false + end + + File.delete(file_path_in_satellite) + + # add removed file + repo.remove(file_path_in_satellite) + + # commit the changes + # will raise CommandFailed when commit fails + repo.git.commit(raise: true, timeout: true, a: true, m: commit_message) + + + # push commit back to bare repo + # will raise CommandFailed when push fails + repo.git.push({raise: true, timeout: true}, :origin, ref) + + # everything worked + true + end + rescue Grit::Git::CommandFailed => ex + Gitlab::GitLogger.error(ex.message) + false + end + end + end +end diff --git a/lib/gitlab/satellite/edit_file_action.rb b/lib/gitlab/satellite/files/edit_file_action.rb similarity index 59% rename from lib/gitlab/satellite/edit_file_action.rb rename to lib/gitlab/satellite/files/edit_file_action.rb index d793d0ba8d..cbdf70f7d1 100644 --- a/lib/gitlab/satellite/edit_file_action.rb +++ b/lib/gitlab/satellite/files/edit_file_action.rb @@ -1,40 +1,40 @@ +require_relative 'file_action' + module Gitlab module Satellite # GitLab server-side file update and commit - class EditFileAction < Action - attr_accessor :file_path, :ref - - def initialize(user, project, ref, file_path) - super user, project, git_timeout: 10.seconds - @file_path = file_path - @ref = ref - end - + class EditFileAction < FileAction # Updates the files content and creates a new commit for it # # Returns false if the ref has been updated while editing the file # Returns false if committing the change fails - # Returns false if pushing from the satellite to Gitolite failed or was rejected + # Returns false if pushing from the satellite to bare repo failed or was rejected # Returns true otherwise - def commit!(content, commit_message, last_commit) - return false unless can_edit?(last_commit) - + def commit!(content, commit_message, encoding) in_locked_and_timed_satellite do |repo| prepare_satellite!(repo) - # create target branch in satellite at the corresponding commit from Gitolite + # create target branch in satellite at the corresponding commit from bare repo repo.git.checkout({raise: true, timeout: true, b: true}, ref, "origin/#{ref}") # update the file in the satellite's working dir file_path_in_satellite = File.join(repo.working_dir, file_path) - File.open(file_path_in_satellite, 'w') { |f| f.write(content) } + + # Prevent relative links + unless safe_path?(file_path_in_satellite) + Gitlab::GitLogger.error("FileAction: Relative path not allowed") + return false + end + + # Write file + write_file(file_path_in_satellite, content, encoding) # commit the changes # will raise CommandFailed when commit fails repo.git.commit(raise: true, timeout: true, a: true, m: commit_message) - # push commit back to Gitolite + # push commit back to bare repo # will raise CommandFailed when push fails repo.git.push({raise: true, timeout: true}, :origin, ref) @@ -45,13 +45,6 @@ module Gitlab Gitlab::GitLogger.error(ex.message) false end - - protected - - def can_edit?(last_commit) - current_last_commit = Gitlab::Git::Commit.last_for_path(@project.repository, ref, file_path).sha - last_commit == current_last_commit - end end end end diff --git a/lib/gitlab/satellite/files/file_action.rb b/lib/gitlab/satellite/files/file_action.rb new file mode 100644 index 0000000000..7701a6d5d6 --- /dev/null +++ b/lib/gitlab/satellite/files/file_action.rb @@ -0,0 +1,25 @@ +module Gitlab + module Satellite + class FileAction < Action + attr_accessor :file_path, :ref + + def initialize(user, project, ref, file_path) + super user, project, git_timeout: 10.seconds + @file_path = file_path + @ref = ref + end + + def safe_path?(path) + File.absolute_path(path) == path + end + + def write_file(abs_file_path, content, file_encoding = 'text') + if file_encoding == 'base64' + File.open(abs_file_path, 'wb') { |f| f.write(Base64.decode64(content)) } + else + File.open(abs_file_path, 'w') { |f| f.write(content) } + end + end + end + end +end diff --git a/lib/gitlab/satellite/files/new_file_action.rb b/lib/gitlab/satellite/files/new_file_action.rb new file mode 100644 index 0000000000..15e9b7a6f7 --- /dev/null +++ b/lib/gitlab/satellite/files/new_file_action.rb @@ -0,0 +1,55 @@ +require_relative 'file_action' + +module Gitlab + module Satellite + class NewFileAction < FileAction + # Updates the files content and creates a new commit for it + # + # Returns false if the ref has been updated while editing the file + # Returns false if committing the change fails + # Returns false if pushing from the satellite to bare repo failed or was rejected + # Returns true otherwise + def commit!(content, commit_message, encoding) + in_locked_and_timed_satellite do |repo| + prepare_satellite!(repo) + + # create target branch in satellite at the corresponding commit from bare repo + repo.git.checkout({raise: true, timeout: true, b: true}, ref, "origin/#{ref}") + + file_path_in_satellite = File.join(repo.working_dir, file_path) + dir_name_in_satellite = File.dirname(file_path_in_satellite) + + # Prevent relative links + unless safe_path?(file_path_in_satellite) + Gitlab::GitLogger.error("FileAction: Relative path not allowed") + return false + end + + # Create dir if not exists + FileUtils.mkdir_p(dir_name_in_satellite) + + # Write file + write_file(file_path_in_satellite, content, encoding) + + # add new file + repo.add(file_path_in_satellite) + + # commit the changes + # will raise CommandFailed when commit fails + repo.git.commit(raise: true, timeout: true, a: true, m: commit_message) + + + # push commit back to bare repo + # will raise CommandFailed when push fails + repo.git.push({raise: true, timeout: true}, :origin, ref) + + # everything worked + true + end + rescue Grit::Git::CommandFailed => ex + Gitlab::GitLogger.error(ex.message) + false + end + end + end +end diff --git a/lib/gitlab/satellite/merge_action.rb b/lib/gitlab/satellite/merge_action.rb index d74d4194ff..5f17aa60b8 100644 --- a/lib/gitlab/satellite/merge_action.rb +++ b/lib/gitlab/satellite/merge_action.rb @@ -24,11 +24,11 @@ module Gitlab # Returns false if the merge produced conflicts # Returns false if pushing from the satellite to the repository failed or was rejected # Returns true otherwise - def merge! + def merge!(merge_commit_message = nil) in_locked_and_timed_satellite do |merge_repo| prepare_satellite!(merge_repo) - if merge_in_satellite!(merge_repo) - # push merge back to Gitolite + if merge_in_satellite!(merge_repo, merge_commit_message) + # push merge back to bare repo # will raise CommandFailed when push fails merge_repo.git.push(default_options, :origin, merge_request.target_branch) # remove source branch @@ -49,14 +49,7 @@ module Gitlab in_locked_and_timed_satellite do |merge_repo| prepare_satellite!(merge_repo) update_satellite_source_and_target!(merge_repo) - - if merge_request.for_fork? - diff = merge_repo.git.native(:diff, default_options, "origin/#{merge_request.target_branch}", "source/#{merge_request.source_branch}") - else - diff = merge_repo.git.native(:diff, default_options, "#{merge_request.target_branch}", "#{merge_request.source_branch}") - end - - return diff + diff = merge_repo.git.native(:diff, default_options, "origin/#{merge_request.target_branch}", "source/#{merge_request.source_branch}") end rescue Grit::Git::CommandFailed => ex handle_exception(ex) @@ -88,14 +81,7 @@ module Gitlab in_locked_and_timed_satellite do |merge_repo| prepare_satellite!(merge_repo) update_satellite_source_and_target!(merge_repo) - - if (merge_request.for_fork?) - patch = merge_repo.git.format_patch(default_options({stdout: true}), "origin/#{merge_request.target_branch}..source/#{merge_request.source_branch}") - else - patch = merge_repo.git.format_patch(default_options({stdout: true}), "#{merge_request.target_branch}..#{merge_request.source_branch}") - end - - return patch + patch = merge_repo.git.format_patch(default_options({stdout: true}), "origin/#{merge_request.target_branch}..source/#{merge_request.source_branch}") end rescue Grit::Git::CommandFailed => ex handle_exception(ex) @@ -125,34 +111,26 @@ module Gitlab # # Returns false if the merge produced conflicts # Returns true otherwise - def merge_in_satellite!(repo) + def merge_in_satellite!(repo, message = nil) update_satellite_source_and_target!(repo) + message ||= "Merge branch '#{merge_request.source_branch}' into '#{merge_request.target_branch}'" + # merge the source branch into the satellite # will raise CommandFailed when merge fails - if merge_request.for_fork? - repo.git.pull(default_options({no_ff: true}), 'source', merge_request.source_branch) - else - repo.git.pull(default_options({no_ff: true}), 'origin', merge_request.source_branch) - end + repo.git.merge(default_options({no_ff: true}), "-m#{message}", "source/#{merge_request.source_branch}") rescue Grit::Git::CommandFailed => ex handle_exception(ex) end # Assumes a satellite exists that is a fresh clone of the projects repo, prepares satellite for merges, diffs etc def update_satellite_source_and_target!(repo) - if merge_request.for_fork? - repo.remote_add('source', merge_request.source_project.repository.path_to_repo) - repo.remote_fetch('source') - repo.git.checkout(default_options({b: true}), merge_request.target_branch, "origin/#{merge_request.target_branch}") - else - repo.git.checkout(default_options, "#{merge_request.source_branch}") - repo.git.checkout(default_options({t: true}), "origin/#{merge_request.target_branch}") - end + repo.remote_add('source', merge_request.source_project.repository.path_to_repo) + repo.remote_fetch('source') + repo.git.checkout(default_options({b: true}), merge_request.target_branch, "origin/#{merge_request.target_branch}") rescue Grit::Git::CommandFailed => ex handle_exception(ex) end - end end end diff --git a/lib/gitlab/satellite/satellite.rb b/lib/gitlab/satellite/satellite.rb index 6cb7814fae..05123ad9c4 100644 --- a/lib/gitlab/satellite/satellite.rb +++ b/lib/gitlab/satellite/satellite.rb @@ -1,6 +1,4 @@ module Gitlab - class SatelliteNotExistError < StandardError; end - module Satellite class Satellite include Gitlab::Popen @@ -17,14 +15,9 @@ module Gitlab Gitlab::Satellite::Logger.error(message) end - def raise_no_satellite - raise SatelliteNotExistError.new("Satellite doesn't exist") - end - def clear_and_update! - raise_no_satellite unless exists? + project.ensure_satellite_exists - File.exists? path @repo = nil clear_working_dir! delete_heads! @@ -33,7 +26,7 @@ module Gitlab end def create - output, status = popen("git clone #{project.repository.path_to_repo} #{path}", + output, status = popen(%W(git clone -- #{project.repository.path_to_repo} #{path}), Gitlab.config.satellites.path) log("PID: #{project.id}: git clone #{project.repository.path_to_repo} #{path}") @@ -55,7 +48,7 @@ module Gitlab # * Changes the current directory to the satellite's working dir # * Yields def lock - raise_no_satellite unless exists? + project.ensure_satellite_exists File.open(lock_file, "w+") do |f| begin @@ -77,7 +70,7 @@ module Gitlab end def repo - raise_no_satellite unless exists? + project.ensure_satellite_exists @repo ||= Grit::Repo.new(path) end @@ -91,6 +84,7 @@ module Gitlab # Clear the working directory def clear_working_dir! repo.git.reset(hard: true) + repo.git.clean(f: true, d: true, x: true) end # Deletes all branches except the parking branch @@ -123,7 +117,7 @@ module Gitlab remotes.each { |name| repo.git.remote(default_options,'rm', name)} end - # Updates the satellite from Gitolite + # Updates the satellite from bare repo # # Note: this will only update remote branches (i.e. origin/*) def update_from_source! diff --git a/lib/gitlab/seeder.rb b/lib/gitlab/seeder.rb index 3aa3b2ba1e..39de1223b1 100644 --- a/lib/gitlab/seeder.rb +++ b/lib/gitlab/seeder.rb @@ -1,10 +1,29 @@ module Gitlab class Seeder def self.quiet + mute_mailer SeedFu.quiet = true yield SeedFu.quiet = false puts "\nOK".green end + + def self.by_user(user) + begin + Thread.current[:current_user] = user + yield + ensure + Thread.current[:current_user] = nil + end + end + + def self.mute_mailer + code = <<-eos +def Notify.delay + self +end + eos + eval(code) + end end end diff --git a/lib/gitlab/theme.rb b/lib/gitlab/theme.rb index 8960416230..44237a062f 100644 --- a/lib/gitlab/theme.rb +++ b/lib/gitlab/theme.rb @@ -15,7 +15,7 @@ module Gitlab COLOR => "ui_color" } - id ||= 1 + id ||= Gitlab.config.gitlab.default_theme return themes[id] end diff --git a/lib/gitlab/upgrader.rb b/lib/gitlab/upgrader.rb new file mode 100644 index 0000000000..0846359f9b --- /dev/null +++ b/lib/gitlab/upgrader.rb @@ -0,0 +1,102 @@ +require_relative "popen" +require_relative "version_info" + +module Gitlab + class Upgrader + def execute + puts "GitLab #{current_version.major} upgrade tool" + puts "Your version is #{current_version}" + puts "Latest available version for GitLab #{current_version.major} is #{latest_version}" + + if latest_version? + puts "You are using the latest GitLab version" + else + puts "Newer GitLab version is available" + answer = if ARGV.first == "-y" + "yes" + else + prompt("Do you want to upgrade (yes/no)? ", %w{yes no}) + end + + if answer == "yes" + upgrade + else + exit 0 + end + end + end + + def latest_version? + current_version >= latest_version + end + + def current_version + @current_version ||= Gitlab::VersionInfo.parse(current_version_raw) + end + + def latest_version + @latest_version ||= Gitlab::VersionInfo.parse(latest_version_raw) + end + + def current_version_raw + File.read(File.join(gitlab_path, "VERSION")).strip + end + + def latest_version_raw + remote_tags, _ = Gitlab::Popen.popen(%W(git ls-remote --tags origin)) + git_tags = remote_tags.split("\n").grep(/tags\/v#{current_version.major}/) + git_tags = git_tags.select { |version| version =~ /v\d\.\d\.\d\Z/ } + last_tag = git_tags.last.match(/v\d\.\d\.\d/).to_s + end + + def update_commands + { + "Stash changed files" => %W(git stash), + "Get latest code" => %W(git fetch), + "Switch to new version" => %W(git checkout v#{latest_version}), + "Install gems" => %W(bundle), + "Migrate DB" => %W(bundle exec rake db:migrate), + "Recompile assets" => %W(bundle exec rake assets:clean assets:precompile), + "Clear cache" => %W(bundle exec rake cache:clear) + } + end + + def env + {'RAILS_ENV' => 'production'} + end + + def upgrade + update_commands.each do |title, cmd| + puts title + puts " -> #{cmd.join(' ')}" + if system(env, *cmd) + puts " -> OK" + else + puts " -> FAILED" + puts "Failed to upgrade. Try to repeat task or proceed with upgrade manually " + exit 1 + end + end + + puts "Done" + end + + def gitlab_path + File.expand_path(File.join(File.dirname(__FILE__), '../..')) + end + + # Prompt the user to input something + # + # message - the message to display before input + # choices - array of strings of acceptable answers or nil for any answer + # + # Returns the user's answer + def prompt(message, choices = nil) + begin + print(message) + answer = STDIN.gets.chomp + end while !choices.include?(answer) + answer + end + end +end diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb new file mode 100644 index 0000000000..16df21b49b --- /dev/null +++ b/lib/gitlab/user_access.rb @@ -0,0 +1,18 @@ +module Gitlab + module UserAccess + def self.allowed?(user) + return false if user.blocked? + + if Gitlab.config.ldap.enabled + if user.ldap_user? + # Check if LDAP user exists and match LDAP user_filter + Gitlab::LDAP::Access.open do |adapter| + return false unless adapter.allowed?(user) + end + end + end + + true + end + end +end diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb new file mode 100644 index 0000000000..eada9bcddf --- /dev/null +++ b/lib/gitlab/visibility_level.rb @@ -0,0 +1,42 @@ +# Gitlab::VisibilityLevel module +# +# Define allowed public modes that can be used for +# GitLab projects to determine project public mode +# +module Gitlab + module VisibilityLevel + PRIVATE = 0 + INTERNAL = 10 + PUBLIC = 20 + + class << self + def values + options.values + end + + def options + { + 'Private' => PRIVATE, + 'Internal' => INTERNAL, + 'Public' => PUBLIC + } + end + + def allowed_for?(user, level) + user.is_admin? || !Gitlab.config.gitlab.restricted_visibility_levels.include?(level) + end + end + + def private? + visibility_level_field == PRIVATE + end + + def internal? + visibility_level_field == INTERNAL + end + + def public? + visibility_level_field == PUBLIC + end + end +end diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb index b84c005524..7d9428ff27 100644 --- a/lib/redcarpet/render/gitlab_html.rb +++ b/lib/redcarpet/render/gitlab_html.rb @@ -8,14 +8,11 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML @project = @template.instance_variable_get("@project") @ref = @template.instance_variable_get("@ref") @request_path = @template.instance_variable_get("@path") + @options = options.dup super options end def block_code(code, language) - options = { options: {encoding: 'utf-8'} } - lexer = Pygments::Lexer.find(language) # language can be an alias - options.merge!(lexer: lexer.aliases[0].downcase) if lexer # downcase is required - # New lines are placed to fix an rendering issue # with code wrapped inside

    tag for next case: # @@ -25,7 +22,11 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML # <<-HTML -
    #{Pygments.highlight(code, options)}
    +
    +
    +
    #{h.send(:html_escape, code)}
    +
    +
    HTML end @@ -34,9 +35,21 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML h.link_to_gfm(content, link, title: title) end + def header(text, level) + if @options[:no_header_anchors] + "#{text}" + else + id = ActionController::Base.helpers.strip_tags(h.gfm(text)).downcase() \ + .gsub(/[^a-z0-9_-]/, '-').gsub(/-+/, '-').gsub(/^-/, '').gsub(/-$/, '') + "#{text}
    " + end + end + def preprocess(full_document) - if @project - h.create_relative_links(full_document, @project.path_with_namespace, @ref, @request_path, is_wiki?) + if is_wiki? + full_document + elsif @project + h.create_relative_links(full_document, @project, @ref, @request_path) else full_document end @@ -47,6 +60,8 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML end def is_wiki? - @template.instance_variable_get("@wiki") + if @template.instance_variable_get("@project_wiki") + @template.instance_variable_get("@page") + end end end diff --git a/lib/support/deploy/deploy.sh b/lib/support/deploy/deploy.sh index 0d2f8418bc..4684957233 100755 --- a/lib/support/deploy/deploy.sh +++ b/lib/support/deploy/deploy.sh @@ -28,17 +28,18 @@ sudo -u git -H git pull origin master echo 'Deploy: Bundle and migrate' # change it to your needs -sudo -u git -H bundle --without postgres +sudo -u git -H bundle --without aws development test mysql --deployment sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production +sudo -u git -H bundle exec rake assets:clean RAILS_ENV=production +sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production +sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production # return stashed changes (if necessary) # sudo -u git -H git stash pop - echo 'Deploy: Starting GitLab server...' sudo service gitlab start -sleep 10 sudo -u git -H rm /home/git/gitlab/public/index.html echo 'Deploy: Done' diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab index fbb7380ac4..3dd4465a6d 100755 --- a/lib/support/init.d/gitlab +++ b/lib/support/init.d/gitlab @@ -3,7 +3,6 @@ # GITLAB # Maintainer: @randx # Authors: rovanion.luckey@gmail.com, @randx -# App Version: 6.0 ### BEGIN INIT INFO # Provides: gitlab @@ -15,11 +14,20 @@ # Description: GitLab git repository management ### END INIT INFO + +### +# DO NOT EDIT THIS FILE! +# This file will be overwritten on update. +# Instead add/change your variables in /etc/default/gitlab +# An example defaults file can be found in lib/support/init.d/gitlab.default.example +### + + ### Environment variables RAILS_ENV="production" -# Script variable names should be lower-case not to conflict with internal -# /bin/sh variables such as PATH, EDITOR or SHELL. +# Script variable names should be lower-case not to conflict with +# internal /bin/sh variables such as PATH, EDITOR or SHELL. app_user="git" app_root="/home/$app_user/gitlab" pid_path="$app_root/tmp/pids" @@ -27,21 +35,20 @@ socket_path="$app_root/tmp/sockets" web_server_pid_path="$pid_path/unicorn.pid" sidekiq_pid_path="$pid_path/sidekiq.pid" - - -### Here ends user configuration ### - +# Read configuration variable file if it is present +test -f /etc/default/gitlab && . /etc/default/gitlab # Switch to the app_user if it is not he/she who is running the script. if [ "$USER" != "$app_user" ]; then - sudo -u "$app_user" -H -i $0 "$@"; exit; + eval su - "$app_user" -c $(echo \")$0 "$@"$(echo \"); exit; fi -# Switch to the gitlab path, if it fails exit with an error. +# Switch to the gitlab path, exit on failure. if ! cd "$app_root" ; then echo "Failed to cd into $app_root, exiting!"; exit 1 fi + ### Init Script functions ## Gets the pids from the files @@ -124,7 +131,7 @@ check_stale_pids(){ fi fi if [ "$spid" != "0" -a "$sidekiq_status" != "0" ]; then - echo "Removing stale Sidekiq web server pid. This is most likely caused by the Sidekiq crashing the last time it ran." + echo "Removing stale Sidekiq job dispatcher pid. This is most likely caused by Sidekiq crashing the last time it ran." if ! rm "$sidekiq_pid_path"; then echo "Unable to remove stale pid, exiting" exit 1 @@ -142,15 +149,15 @@ exit_if_not_running(){ } ## Starts Unicorn and Sidekiq if they're not running. -start() { +start_gitlab() { check_stale_pids if [ "$web_status" != "0" -a "$sidekiq_status" != "0" ]; then echo -n "Starting both the GitLab Unicorn and Sidekiq" elif [ "$web_status" != "0" ]; then - echo -n "Starting GitLab Sidekiq" - elif [ "$sidekiq_status" != "0" ]; then echo -n "Starting GitLab Unicorn" + elif [ "$sidekiq_status" != "0" ]; then + echo -n "Starting GitLab Sidekiq" fi # Then check if the service is running. If it is: don't start again. @@ -160,7 +167,7 @@ start() { # Remove old socket if it exists rm -f "$socket_path"/gitlab.socket 2>/dev/null # Start the web server - RAILS_ENV=$RAILS_ENV script/web start & + RAILS_ENV=$RAILS_ENV script/web start fi # If sidekiq is already running, don't start it again. @@ -177,15 +184,15 @@ start() { } ## Asks the Unicorn and the Sidekiq if they would be so kind as to stop, if not kills them. -stop() { +stop_gitlab() { exit_if_not_running if [ "$web_status" = "0" -a "$sidekiq_status" = "0" ]; then echo -n "Shutting down both Unicorn and Sidekiq" elif [ "$web_status" = "0" ]; then - echo -n "Shutting down Sidekiq" - elif [ "$sidekiq_status" = "0" ]; then echo -n "Shutting down Unicorn" + elif [ "$sidekiq_status" = "0" ]; then + echo -n "Shutting down Sidekiq" fi # If the Unicorn web server is running, tell it to stop; @@ -239,7 +246,7 @@ print_status() { } ## Tells unicorn to reload it's config and Sidekiq to restart -reload(){ +reload_gitlab(){ exit_if_not_running if [ "$wpid" = "0" ];then echo "The GitLab Unicorn Web server is not running thus its configuration can't be reloaded." @@ -256,12 +263,12 @@ reload(){ } ## Restarts Sidekiq and Unicorn. -restart(){ +restart_gitlab(){ check_status if [ "$web_status" = "0" -o "$sidekiq_status" = "0" ]; then - stop + stop_gitlab fi - start + start_gitlab } @@ -269,16 +276,16 @@ restart(){ case "$1" in start) - start + start_gitlab ;; stop) - stop + stop_gitlab ;; restart) - restart + restart_gitlab ;; reload|force-reload) - reload + reload_gitlab ;; status) print_status diff --git a/lib/support/init.d/gitlab.default.example b/lib/support/init.d/gitlab.default.example new file mode 100755 index 0000000000..9951bacedf --- /dev/null +++ b/lib/support/init.d/gitlab.default.example @@ -0,0 +1,31 @@ +# Copy this lib/support/init.d/gitlab.default.example file to +# /etc/default/gitlab in order for it to apply to your system. + +# RAILS_ENV defines the type of installation that is running. +# Normal values are "production", "test" and "development". +RAILS_ENV="production" + +# app_user defines the user that GitLab is run as. +# The default is "git". +app_user="git" + +# app_root defines the folder in which gitlab and it's components are installed. +# The default is "/home/$app_user/gitlab" +app_root="/home/$app_user/gitlab" + +# pid_path defines a folder in which the gitlab and it's components place their pids. +# This variable is also used below to define the relevant pids for the gitlab components. +# The default is "$app_root/tmp/pids" +pid_path="$app_root/tmp/pids" + +# socket_path defines the folder in which gitlab places the sockets +#The default is "$app_root/tmp/sockets" +socket_path="$app_root/tmp/sockets" + +# web_server_pid_path defines the path in which to create the pid file fo the web_server +# The default is "$pid_path/unicorn.pid" +web_server_pid_path="$pid_path/unicorn.pid" + +# sidekiq_pid_path defines the path in which to create the pid file for sidekiq +# The default is "$pid_path/sidekiq.pid" +sidekiq_pid_path="$pid_path/sidekiq.pid" diff --git a/lib/support/logrotate/gitlab b/lib/support/logrotate/gitlab index df9398d079..d9b07b61ec 100644 --- a/lib/support/logrotate/gitlab +++ b/lib/support/logrotate/gitlab @@ -2,21 +2,19 @@ # based on: http://stackoverflow.com/a/4883967 /home/git/gitlab/log/*.log { - weekly + daily missingok - rotate 52 + rotate 90 compress - delaycompress notifempty copytruncate } /home/git/gitlab-shell/gitlab-shell.log { - weekly + daily missingok - rotate 52 + rotate 90 compress - delaycompress notifempty copytruncate } diff --git a/lib/support/nginx/gitlab b/lib/support/nginx/gitlab index 3e929c5299..98c9163739 100644 --- a/lib/support/nginx/gitlab +++ b/lib/support/nginx/gitlab @@ -1,6 +1,19 @@ # GITLAB # Maintainer: @randx -# App Version: 5.0 + +# CHUNKED TRANSFER +# It is a known issue that Git-over-HTTP requires chunked transfer encoding [0] which is not +# supported by Nginx < 1.3.9 [1]. As a result, pushing a large object with Git (i.e. a single large file) +# can lead to a 411 error. In theory you can get around this by tweaking this configuration file and either +# - installing an old version of Nginx with the chunkin module [2] compiled in, or +# - using a newer version of Nginx. +# +# At the time of writing we do not know if either of these theoretical solutions works. As a workaround +# users can use Git over SSH to push large files. +# +# [0] https://git.kernel.org/cgit/git/git.git/tree/Documentation/technical/http-protocol.txt#n99 +# [1] https://github.com/agentzh/chunkin-nginx-module#status +# [2] https://github.com/agentzh/chunkin-nginx-module upstream gitlab { server unix:/home/git/gitlab/tmp/sockets/gitlab.socket; @@ -11,6 +24,10 @@ server { server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com; server_tokens off; # don't show the version number, a security best practice root /home/git/gitlab/public; + + # Increase this if you want to upload large attachments + # Or if you want to accept large git objects over http + client_max_body_size 20m; # individual nginx logs for this gitlab vhost access_log /var/log/nginx/gitlab_access.log; @@ -25,15 +42,32 @@ server { # if a file, which is not found in the root folder is requested, # then the proxy pass the request to the upsteam (gitlab unicorn) location @gitlab { - proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694 - proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694 + # If you use https make sure you disable gzip compression + # to be safe against BREACH attack + # gzip off; + + proxy_read_timeout 300; # Some requests take more than 30 seconds. + proxy_connect_timeout 300; # Some requests take more than 30 seconds. proxy_redirect off; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://gitlab; } -} + # Enable gzip compression as per rails guide: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression + # WARNING: If you are using relative urls do remove the block below + # See config/application.rb under "Relative url support" for the list of + # other files that need to be changed for relative url support + location ~ ^/(assets)/ { + root /home/git/gitlab/public; + gzip_static on; # to serve pre-gzipped version + expires max; + add_header Cache-Control public; + } + + error_page 502 /502.html; +} diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 7d3602211c..058c741704 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -1,10 +1,10 @@ +task dev: ["dev:setup"] + namespace :dev do desc "GITLAB | Setup developer environment (db, fixtures)" task :setup => :environment do ENV['force'] = 'yes' - Rake::Task["db:setup"].invoke - Rake::Task["db:seed_fu"].invoke + Rake::Task["gitlab:setup"].invoke Rake::Task["gitlab:shell:setup"].invoke end end - diff --git a/lib/tasks/gitlab/bulk_add_permission.rake b/lib/tasks/gitlab/bulk_add_permission.rake index c270232edb..0e1a3d071e 100644 --- a/lib/tasks/gitlab/bulk_add_permission.rake +++ b/lib/tasks/gitlab/bulk_add_permission.rake @@ -15,10 +15,34 @@ namespace :gitlab do desc "GITLAB | Add a specific user to all projects (as a developer)" task :user_to_projects, [:email] => :environment do |t, args| - user = User.find_by_email args.email + user = User.find_by(email: args.email) project_ids = Project.pluck(:id) puts "Importing #{user.email} users into #{project_ids.size} projects" UsersProject.add_users_into_projects(project_ids, Array.wrap(user.id), UsersProject::DEVELOPER) end + + desc "GITLAB | Add all users to all groups (admin users are added as owners)" + task all_users_to_all_groups: :environment do |t, args| + user_ids = User.where(admin: false).pluck(:id) + admin_ids = User.where(admin: true).pluck(:id) + groups = Group.all + + puts "Importing #{user_ids.size} users into #{groups.size} groups" + puts "Importing #{admin_ids.size} admins into #{groups.size} groups" + groups.each do |group| + group.add_users(user_ids, UsersGroup::DEVELOPER) + group.add_users(admin_ids, UsersGroup::OWNER) + end + end + + desc "GITLAB | Add a specific user to all groups (as a developer)" + task :user_to_groups, [:email] => :environment do |t, args| + user = User.find_by_email args.email + groups = Group.all + puts "Importing #{user.email} users into #{groups.size} groups" + groups.each do |group| + group.add_users(Array.wrap(user.id), UsersGroup::DEVELOPER) + end + end end end diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index f8c17f412b..bf015a1fe1 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -3,6 +3,7 @@ namespace :gitlab do task check: %w{gitlab:env:check gitlab:gitlab_shell:check gitlab:sidekiq:check + gitlab:ldap:check gitlab:app:check} @@ -16,6 +17,7 @@ namespace :gitlab do check_database_config_exists check_database_is_not_sqlite check_migrations_are_up + check_orphaned_users_groups check_gitlab_config_exists check_gitlab_config_not_outdated check_log_writable @@ -64,6 +66,7 @@ namespace :gitlab do puts "no".green else puts "yes".red + puts "Please fix this by removing the SQLite entry from the database.yml".blue for_more_information( "https://github.com/gitlabhq/gitlabhq/wiki/Migrate-from-SQLite-to-MySQL", see_database_guide @@ -167,7 +170,7 @@ namespace :gitlab do def check_migrations_are_up print "All migrations up? ... " - migration_status = `bundle exec rake db:migrate:status` + migration_status, _ = Gitlab::Popen.popen(%W(bundle exec rake db:migrate:status)) unless migration_status =~ /down\s+\d{14}/ puts "yes".green @@ -180,6 +183,19 @@ namespace :gitlab do end end + def check_orphaned_users_groups + print "Database contains orphaned UsersGroups? ... " + if UsersGroup.where("user_id not in (select id from users)").count > 0 + puts "yes".red + try_fixing_it( + "You can delete the orphaned records using something along the lines of:", + sudo_gitlab("bundle exec rails runner -e production 'UsersGroup.where(\"user_id NOT IN (SELECT id FROM users)\").delete_all'") + ) + else + puts "no".green + end + end + def check_satellites_exist print "Projects have satellites? ... " @@ -254,7 +270,7 @@ namespace :gitlab do def check_redis_version print "Redis version >= 2.0.0? ... " - if run_and_match("redis-cli --version", /redis-cli 2.\d.\d/) + if run_and_match(%W(redis-cli --version), /redis-cli 2.\d.\d/) puts "yes".green else puts "no".red @@ -278,8 +294,6 @@ namespace :gitlab do start_checking "Environment" check_gitlab_git_config - check_python2_exists - check_python2_version finished_checking "Environment" end @@ -296,7 +310,7 @@ namespace :gitlab do "user.email" => Gitlab.config.gitlab.email_from } correct_options = options.map do |name, value| - run("git config --global --get #{name}").try(:squish) == value + run(%W(git config --global --get #{name})).try(:squish) == value end if correct_options.all? @@ -313,52 +327,6 @@ namespace :gitlab do fix_and_rerun end end - - def check_python2_exists - print "Has python2? ... " - - # Python prints its version to STDERR - # so we can't just use run("python2 --version") - if run_and_match("which python2", /python2$/) - puts "yes".green - else - puts "no".red - try_fixing_it( - "Make sure you have Python 2.5+ installed", - "Link it to python2" - ) - for_more_information( - see_installation_guide_section "Packages / Dependencies" - ) - fix_and_rerun - end - end - - def check_python2_version - print "python2 is supported version? ... " - - # Python prints its version to STDERR - # so we can't just use run("python2 --version") - - unless run_and_match("which python2", /python2$/) - puts "can't check because of previous errors".magenta - return - end - - if `python2 --version 2>&1` =~ /2\.[567]\.\d/ - puts "yes".green - else - puts "no".red - try_fixing_it( - "Make sure you have Python 2.5+ installed", - "Link it to python2" - ) - for_more_information( - see_installation_guide_section "Packages / Dependencies" - ) - fix_and_rerun - end - end end @@ -374,6 +342,7 @@ namespace :gitlab do check_repo_base_is_not_symlink check_repo_base_user_and_group check_repo_base_permissions + check_satellites_permissions check_update_hook_is_up_to_date check_repos_update_hooks_is_link check_gitlab_shell_self_test @@ -475,6 +444,29 @@ namespace :gitlab do end end + def check_satellites_permissions + print "Satellites access is drwxr-x---? ... " + + satellites_path = Gitlab.config.satellites.path + unless File.exists?(satellites_path) + puts "can't check because of previous errors".magenta + return + end + + if File.stat(satellites_path).mode.to_s(8).ends_with?("0750") + puts "yes".green + else + puts "no".red + try_fixing_it( + "sudo chmod u+rwx,g+rx,o-rwx #{satellites_path}", + ) + for_more_information( + see_installation_guide_section "GitLab" + ) + fix_and_rerun + end + end + def check_repo_base_user_and_group gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user gitlab_shell_owner_group = Gitlab.config.gitlab_shell.owner_group @@ -536,7 +528,7 @@ namespace :gitlab do "sudo -u #{gitlab_shell_ssh_user} ln -sf #{gitlab_shell_hook_file} #{project_hook_file}" ) for_more_information( - "#{gitlab_shell_user_home}/gitlab-shell/support/rewrite-hooks.sh" + "#{gitlab_shell_path}/support/rewrite-hooks.sh" ) fix_and_rerun next @@ -560,7 +552,7 @@ namespace :gitlab do end def check_gitlab_shell_self_test - gitlab_shell_repo_base = File.expand_path('gitlab-shell', gitlab_shell_user_home) + gitlab_shell_repo_base = gitlab_shell_path check_cmd = File.expand_path('bin/check', gitlab_shell_repo_base) puts "Running #{check_cmd}" if system(check_cmd, chdir: gitlab_shell_repo_base) @@ -606,15 +598,12 @@ namespace :gitlab do # Helper methods ######################## - def gitlab_shell_user_home - File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}") + def gitlab_shell_path + Gitlab.config.gitlab_shell.path end def gitlab_shell_version - gitlab_shell_version_file = "#{gitlab_shell_user_home}/gitlab-shell/VERSION" - if File.readable?(gitlab_shell_version_file) - File.read(gitlab_shell_version_file) - end + Gitlab::Shell.new.version end def has_gitlab_shell3? @@ -678,10 +667,64 @@ namespace :gitlab do end def sidekiq_process_count - `ps ux`.scan(/sidekiq \d+\.\d+\.\d+/).count + ps_ux, _ = Gitlab::Popen.popen(%W(ps ux)) + ps_ux.scan(/sidekiq \d+\.\d+\.\d+/).count end end + namespace :ldap do + task :check, [:limit] => :environment do |t, args| + # Only show up to 100 results because LDAP directories can be very big. + # This setting only affects the `rake gitlab:check` script. + args.with_defaults(limit: 100) + warn_user_is_not_gitlab + start_checking "LDAP" + + if ldap_config.enabled + print_users(args.limit) + else + puts 'LDAP is disabled in config/gitlab.yml' + end + + finished_checking "LDAP" + end + + def print_users(limit) + puts "LDAP users with access to your GitLab server (only showing the first #{limit} results)" + ldap.search(attributes: attributes, filter: filter, size: limit, return_result: false) do |entry| + puts "DN: #{entry.dn}\t#{ldap_config.uid}: #{entry[ldap_config.uid]}" + end + end + + def attributes + [ldap_config.uid] + end + + def filter + uid_filter = Net::LDAP::Filter.present?(ldap_config.uid) + if user_filter + Net::LDAP::Filter.join(uid_filter, user_filter) + else + uid_filter + end + end + + def user_filter + if ldap_config['user_filter'] && ldap_config.user_filter.present? + Net::LDAP::Filter.construct(ldap_config.user_filter) + else + nil + end + end + + def ldap + @ldap ||= OmniAuth::LDAP::Adaptor.new(ldap_config).connection + end + + def ldap_config + @ldap_config ||= Gitlab.config.ldap + end + end # Helper methods ########################## @@ -736,7 +779,7 @@ namespace :gitlab do end def check_gitlab_shell - required_version = Gitlab::VersionInfo.new(1, 7, 4) + required_version = Gitlab::VersionInfo.new(1, 9, 3) current_version = Gitlab::VersionInfo.parse(gitlab_shell_version) print "GitLab Shell version >= #{required_version} ? ... " @@ -749,7 +792,7 @@ namespace :gitlab do def check_git_version required_version = Gitlab::VersionInfo.new(1, 7, 10) - current_version = Gitlab::VersionInfo.parse(run("#{Gitlab.config.git.bin_path} --version")) + current_version = Gitlab::VersionInfo.parse(run(%W(#{Gitlab.config.git.bin_path} --version))) puts "Your git bin path is \"#{Gitlab.config.git.bin_path}\"" print "Git version >= #{required_version} ? ... " diff --git a/lib/tasks/gitlab/db/drop_all_tables.rake b/lib/tasks/gitlab/db/drop_all_tables.rake new file mode 100644 index 0000000000..a66030ab93 --- /dev/null +++ b/lib/tasks/gitlab/db/drop_all_tables.rake @@ -0,0 +1,10 @@ +namespace :gitlab do + namespace :db do + task drop_all_tables: :environment do + connection = ActiveRecord::Base.connection + connection.tables.each do |table| + connection.drop_table(table) + end + end + end +end diff --git a/lib/tasks/gitlab/enable_automerge.rake b/lib/tasks/gitlab/enable_automerge.rake index 6822e5cf1a..aa9869daf2 100644 --- a/lib/tasks/gitlab/enable_automerge.rake +++ b/lib/tasks/gitlab/enable_automerge.rake @@ -27,11 +27,8 @@ namespace :gitlab do if project.satellite.exists? puts "exists already".green else - puts "" - project.satellite.create - - print "... " - if $?.success? + print "\n... " + if project.satellite.create puts "created".green else puts "error".red diff --git a/lib/tasks/gitlab/enable_namespaces.rake b/lib/tasks/gitlab/enable_namespaces.rake index 927748c0fd..201f34ab54 100644 --- a/lib/tasks/gitlab/enable_namespaces.rake +++ b/lib/tasks/gitlab/enable_namespaces.rake @@ -43,13 +43,13 @@ namespace :gitlab do username.gsub!("+", ".") # return username if no matches - return username unless User.find_by_username(username) + return username unless User.find_by(username: username) # look for same username (1..10).each do |i| suffixed_username = "#{username}#{i}" - return suffixed_username unless User.find_by_username(suffixed_username) + return suffixed_username unless User.find_by(username: suffixed_username) end end diff --git a/lib/tasks/gitlab/generate_docs.rake b/lib/tasks/gitlab/generate_docs.rake index 58795fac4a..332cd61f84 100644 --- a/lib/tasks/gitlab/generate_docs.rake +++ b/lib/tasks/gitlab/generate_docs.rake @@ -1,7 +1,7 @@ namespace :gitlab do desc "GITLAB | Generate sdocs for project" task generate_docs: :environment do - system("bundle exec sdoc -o doc/code app lib") + system(*%W(bundle exec sdoc -o doc/code app lib)) end end diff --git a/lib/tasks/gitlab/import.rake b/lib/tasks/gitlab/import.rake index 8fa8927085..cbfa736c84 100644 --- a/lib/tasks/gitlab/import.rake +++ b/lib/tasks/gitlab/import.rake @@ -2,12 +2,12 @@ namespace :gitlab do namespace :import do # How to use: # - # 1. copy your bare repos under git repos_path - # 2. run bundle exec rake gitlab:import:repos RAILS_ENV=production + # 1. copy the bare repos under the repos_path (commonly /home/git/repositories) + # 2. run: bundle exec rake gitlab:import:repos RAILS_ENV=production # # Notes: - # * project owner will be a first admin - # * existing projects will be skipped + # * The project owner will set to the first administator of the system + # * Existing projects will be skipped # desc "GITLAB | Import bare repositories from gitlab_shell -> repos_path into GitLab project instance" task repos: :environment do @@ -50,7 +50,7 @@ namespace :gitlab do # find group namespace if group_name - group = Group.find_by_path(group_name) + group = Group.find_by(path: group_name) # create group namespace if !group group = Group.new(:name => group_name) @@ -66,7 +66,7 @@ namespace :gitlab do project_params[:namespace_id] = group.id end - project = Projects::CreateContext.new(user, project_params).execute + project = Projects::CreateService.new(user, project_params).execute if project.valid? puts " * Created #{project.name} (#{repo_path})".green diff --git a/lib/tasks/gitlab/info.rake b/lib/tasks/gitlab/info.rake index ea83efcd88..72452e1d8e 100644 --- a/lib/tasks/gitlab/info.rake +++ b/lib/tasks/gitlab/info.rake @@ -4,26 +4,27 @@ namespace :gitlab do task info: :environment do # check if there is an RVM environment - rvm_version = run_and_match("rvm --version", /[\d\.]+/).try(:to_s) + rvm_version = run_and_match(%W(rvm --version), /[\d\.]+/).try(:to_s) # check Ruby version - ruby_version = run_and_match("ruby --version", /[\d\.p]+/).try(:to_s) + ruby_version = run_and_match(%W(ruby --version), /[\d\.p]+/).try(:to_s) # check Gem version - gem_version = run("gem --version") + gem_version = run(%W(gem --version)) # check Bundler version - bunder_version = run_and_match("bundle --version", /[\d\.]+/).try(:to_s) + bunder_version = run_and_match(%W(bundle --version), /[\d\.]+/).try(:to_s) # check Bundler version - rake_version = run_and_match("rake --version", /[\d\.]+/).try(:to_s) + rake_version = run_and_match(%W(rake --version), /[\d\.]+/).try(:to_s) puts "" puts "System information".yellow puts "System:\t\t#{os_name || "unknown".red}" - puts "Current User:\t#{`whoami`}" + puts "Current User:\t#{run(%W(whoami))}" puts "Using RVM:\t#{rvm_version.present? ? "yes".green : "no"}" puts "RVM Version:\t#{rvm_version}" if rvm_version.present? puts "Ruby Version:\t#{ruby_version || "unknown".red}" puts "Gem Version:\t#{gem_version || "unknown".red}" puts "Bundler Version:#{bunder_version || "unknown".red}" puts "Rake Version:\t#{rake_version || "unknown".red}" + puts "Sidekiq Version:#{Sidekiq::VERSION}" # check database adapter diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake index 2b730774e0..8b4ccdfc3f 100644 --- a/lib/tasks/gitlab/setup.rake +++ b/lib/tasks/gitlab/setup.rake @@ -15,6 +15,7 @@ namespace :gitlab do end Rake::Task["db:setup"].invoke + Rake::Task["add_limits_mysql"].invoke Rake::Task["db:seed_fu"].invoke rescue Gitlab::TaskAbortedByUserError puts "Quitting...".red diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake index 0d7a390bc9..dfc90bb333 100644 --- a/lib/tasks/gitlab/shell.rake +++ b/lib/tasks/gitlab/shell.rake @@ -1,5 +1,64 @@ namespace :gitlab do namespace :shell do + desc "GITLAB | Install or upgrade gitlab-shell" + task :install, [:tag, :repo] => :environment do |t, args| + warn_user_is_not_gitlab + + args.with_defaults(tag: "v1.9.3", repo: "https://gitlab.com/gitlab-org/gitlab-shell.git") + + user = Settings.gitlab.user + home_dir = Settings.gitlab.user_home + gitlab_url = Settings.gitlab.url + # gitlab-shell requires a / at the end of the url + gitlab_url += "/" unless gitlab_url.match(/\/$/) + repos_path = Gitlab.config.gitlab_shell.repos_path + target_dir = Gitlab.config.gitlab_shell.path + + # Clone if needed + unless File.directory?(target_dir) + sh "git clone '#{args.repo}' '#{target_dir}'" + end + + # Make sure we're on the right tag + Dir.chdir(target_dir) do + sh "git fetch origin && git reset --hard $(git describe #{args.tag} || git describe origin/#{args.tag})" + + redis_url = URI.parse(ENV['REDIS_URL'] || "redis://localhost:6379") + + config = { + user: user, + gitlab_url: gitlab_url, + http_settings: {self_signed_cert: false}.stringify_keys, + repos_path: repos_path, + auth_file: File.join(home_dir, ".ssh", "authorized_keys"), + redis: { + bin: %x{which redis-cli}.chomp, + host: redis_url.host, + port: redis_url.port, + namespace: "resque:gitlab" + }.stringify_keys, + log_level: "INFO", + audit_usernames: false + }.stringify_keys + + # Generate config.yml based on existing gitlab settings + File.open("config.yml", "w+") {|f| f.puts config.to_yaml} + + # Launch installation process + sh "bin/install" + end + + # Required for debian packaging with PKGR: Setup .ssh/environment with + # the current PATH, so that the correct ruby version gets loaded + # Requires to set "PermitUserEnvironment yes" in sshd config (should not + # be an issue since it is more than likely that there are no "normal" + # user accounts on a gitlab server). The alternative is for the admin to + # install a ruby (1.9.3+) in the global path. + File.open(File.join(home_dir, ".ssh", "environment"), "w+") do |f| + f.puts "PATH=#{ENV['PATH']}" + end + end + desc "GITLAB | Setup gitlab-shell" task setup: :environment do setup @@ -34,14 +93,18 @@ namespace :gitlab do Gitlab::Shell.new.remove_all_keys - Key.find_each(batch_size: 1000) do |key| - if Gitlab::Shell.new.add_key(key.shell_id, key.key) + Gitlab::Shell.new.batch_add_keys do |adder| + Key.find_each(batch_size: 1000) do |key| + adder.add_key(key.shell_id, key.key) print '.' - else - print 'F' end end + unless $?.success? + puts "Failed to add keys...".red + exit 1 + end + rescue Gitlab::TaskAbortedByUserError puts "Quitting...".red exit 1 diff --git a/lib/tasks/gitlab/task_helpers.rake b/lib/tasks/gitlab/task_helpers.rake index ac2c4577c7..da61c6e007 100644 --- a/lib/tasks/gitlab/task_helpers.rake +++ b/lib/tasks/gitlab/task_helpers.rake @@ -2,6 +2,16 @@ module Gitlab class TaskAbortedByUserError < StandardError; end end +unless STDOUT.isatty + module Colored + extend self + + def colorize(string, options={}) + string + end + end +end + namespace :gitlab do # Ask if the user wants to continue @@ -18,7 +28,7 @@ namespace :gitlab do # It will primarily use lsb_relase to determine the OS. # It has fallbacks to Debian, SuSE, OS X and systems running systemd. def os_name - os_name = run("lsb_release -irs") + os_name = run(%W(lsb_release -irs)) os_name ||= if File.readable?('/etc/system-release') File.read('/etc/system-release') end @@ -29,7 +39,7 @@ namespace :gitlab do os_name ||= if File.readable?('/etc/SuSE-release') File.read('/etc/SuSE-release') end - os_name ||= if os_x_version = run("sw_vers -productVersion") + os_name ||= if os_x_version = run(%W(sw_vers -productVersion)) "Mac OS X #{os_x_version}" end os_name ||= if File.readable?('/etc/os-release') @@ -70,13 +80,14 @@ namespace :gitlab do # # see also #run_and_match def run(command) - unless `#{command} 2>/dev/null`.blank? - `#{command}` - end + output, _ = Gitlab::Popen.popen(command) + output + rescue Errno::ENOENT + '' # if the command does not exist, return an empty string end def uid_for(user_name) - run("id -u #{user_name}").chomp.to_i + run(%W(id -u #{user_name})).chomp.to_i end def gid_for(group_name) @@ -90,7 +101,7 @@ namespace :gitlab do def warn_user_is_not_gitlab unless @warned_user_not_gitlab gitlab_user = Gitlab.config.gitlab.user - current_user = run("whoami").chomp + current_user = run(%W(whoami)).chomp unless current_user == gitlab_user puts "#{Colored.color(:black)+Colored.color(:on_yellow)} Warning #{Colored.extra(:clear)}" puts " You are running as user #{current_user.magenta}, we hope you know what you are doing." diff --git a/lib/tasks/gitlab/test.rake b/lib/tasks/gitlab/test.rake index 011748c971..9516210e20 100644 --- a/lib/tasks/gitlab/test.rake +++ b/lib/tasks/gitlab/test.rake @@ -2,17 +2,15 @@ namespace :gitlab do desc "GITLAB | Run all tests" task :test do cmds = [ - "rake db:setup", - "rake db:seed_fu", - "rake spinach", - "rake spec", - "rake jasmine:ci" + %W(rake spinach), + %W(rake spec), + %W(rake jasmine:ci) ] cmds.each do |cmd| - system(cmd + " RAILS_ENV=test") + result = system({'RAILS_ENV' => 'test', 'force' => 'yes'}, *cmd) - raise "#{cmd} failed!" unless $?.exitstatus.zero? + raise "#{cmd} failed!" unless result end end end diff --git a/lib/tasks/migrate/add_limits_mysql.rake b/lib/tasks/migrate/add_limits_mysql.rake new file mode 100644 index 0000000000..a1972a682d --- /dev/null +++ b/lib/tasks/migrate/add_limits_mysql.rake @@ -0,0 +1,7 @@ +require Rails.root.join('db/migrate/limits_to_mysql') + +desc "GITLAB | Add limits to strings in mysql database" +task add_limits_mysql: :environment do + puts "Adding limits to schema.rb for mysql" + LimitsToMysql.new.up +end diff --git a/lib/tasks/setup.rake b/lib/tasks/setup.rake new file mode 100644 index 0000000000..93701de8f6 --- /dev/null +++ b/lib/tasks/setup.rake @@ -0,0 +1,4 @@ +desc "GITLAB | Setup gitlab db" +task :setup do + Rake::Task["gitlab:setup"].invoke +end diff --git a/lib/tasks/sidekiq.rake b/lib/tasks/sidekiq.rake index e91678473a..ba806e53cc 100644 --- a/lib/tasks/sidekiq.rake +++ b/lib/tasks/sidekiq.rake @@ -1,21 +1,21 @@ namespace :sidekiq do desc "GITLAB | Stop sidekiq" task :stop do - system "script/background_jobs stop" + system *%W(script/background_jobs stop) end desc "GITLAB | Start sidekiq" task :start do - system "script/background_jobs start" + system *%W(script/background_jobs start) end desc 'GitLab | Restart sidekiq' task :restart do - system "script/background_jobs restart" + system *%W(script/background_jobs restart) end desc "GITLAB | Start sidekiq with launchd on Mac OS X" task :launchd do - system "script/background_jobs start_no_deamonize" + system *%W(script/background_jobs start_no_deamonize) end end diff --git a/lib/tasks/spec.rake b/lib/tasks/spec.rake new file mode 100644 index 0000000000..49fbe1bd47 --- /dev/null +++ b/lib/tasks/spec.rake @@ -0,0 +1,46 @@ +Rake::Task["spec"].clear if Rake::Task.task_defined?('spec') + +namespace :spec do + desc 'GITLAB | Run request specs' + task :api do + cmds = [ + %W(rake gitlab:setup), + %W(rspec spec --tag @api) + ] + run_commands(cmds) + end + + desc 'GITLAB | Run feature specs' + task :feature do + cmds = [ + %W(rake gitlab:setup), + %W(rspec spec --tag @feature) + ] + run_commands(cmds) + end + + desc 'GITLAB | Run other specs' + task :other do + cmds = [ + %W(rake gitlab:setup), + %W(rspec spec --tag ~@api --tag ~@feature) + ] + run_commands(cmds) + end +end + +desc "GITLAB | Run specs" +task :spec do + cmds = [ + %W(rake gitlab:setup), + %W(rspec spec), + ] + run_commands(cmds) +end + +def run_commands(cmds) + cmds.each do |cmd| + system({'RAILS_ENV' => 'test', 'force' => 'yes'}, *cmd) + raise "#{cmd} failed!" unless $?.exitstatus.zero? + end +end diff --git a/lib/tasks/spinach.rake b/lib/tasks/spinach.rake new file mode 100644 index 0000000000..c23d0e0e18 --- /dev/null +++ b/lib/tasks/spinach.rake @@ -0,0 +1,14 @@ +Rake::Task["spinach"].clear if Rake::Task.task_defined?('spinach') + +desc "GITLAB | Run spinach" +task :spinach do + cmds = [ + %W(rake gitlab:setup), + %W(spinach), + ] + + cmds.each do |cmd| + system({'RAILS_ENV' => 'test', 'force' => 'yes'}, *cmd) + raise "#{cmd} failed!" unless $?.exitstatus.zero? + end +end diff --git a/lib/tasks/test.rake b/lib/tasks/test.rake new file mode 100644 index 0000000000..f19da1bb43 --- /dev/null +++ b/lib/tasks/test.rake @@ -0,0 +1,6 @@ +Rake::Task["test"].clear + +desc "GITLAB | Run all tests" +task :test do + Rake::Task["gitlab:test"].invoke +end diff --git a/public/500.html b/public/500.html index 5b78e3e38c..c84b9e90e4 100644 --- a/public/500.html +++ b/public/500.html @@ -8,6 +8,6 @@

    500

    We're sorry, but something went wrong.


    -

    We've been notified about this issue and we'll take a look at it shortly.

    +

    Please contact your GitLab administrator if this problem persists.

    diff --git a/public/502.html b/public/502.html new file mode 100644 index 0000000000..d171eccc92 --- /dev/null +++ b/public/502.html @@ -0,0 +1,13 @@ + + + + GitLab is not responding (502) + + + +

    502

    +

    GitLab is not responding.

    +
    +

    Please contact your GitLab administrator if this problem persists.

    + + diff --git a/public/apple-touch-icon-precomposed.png b/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000000..6f2e0dd090 Binary files /dev/null and b/public/apple-touch-icon-precomposed.png differ diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png new file mode 100644 index 0000000000..6f2e0dd090 Binary files /dev/null and b/public/apple-touch-icon.png differ diff --git a/public/favicon.ico b/public/favicon.ico index 057f74ac7a..bfb74960c4 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/public/gitlab_logo.png b/public/gitlab_logo.png index e3cda5978a..dbe6dabb78 100644 Binary files a/public/gitlab_logo.png and b/public/gitlab_logo.png differ diff --git a/public/static.css b/public/static.css index aa834553a1..c6f92ac01d 100644 --- a/public/static.css +++ b/public/static.css @@ -2,7 +2,6 @@ body { color: #666; text-align: center; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - sans-serif; margin:0; width: 800px; margin: auto; diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-text.js b/public/uploads/.gitkeep similarity index 100% rename from vendor/assets/javascripts/ace-src-noconflict/mode-text.js rename to public/uploads/.gitkeep diff --git a/script/background_jobs b/script/background_jobs index 623e26a283..e0140e9689 100755 --- a/script/background_jobs +++ b/script/background_jobs @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash cd $(dirname $0)/.. app_root=$(pwd) @@ -6,6 +6,11 @@ sidekiq_pidfile="$app_root/tmp/pids/sidekiq.pid" sidekiq_logfile="$app_root/log/sidekiq.log" gitlab_user=$(ls -l config.ru | awk '{print $3}') +function warn +{ + echo "$@" 1>&2 +} + function stop { bundle exec sidekiqctl stop $sidekiq_pidfile >> $sidekiq_logfile 2>&1 @@ -32,7 +37,23 @@ function start_no_deamonize function start_sidekiq { - bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e $RAILS_ENV -P $sidekiq_pidfile $@ >> $sidekiq_logfile 2>&1 + bundle exec sidekiq -q post_receive -q mailer -q system_hook -q project_web_hook -q gitlab_shell -q common -q default -e $RAILS_ENV -P $sidekiq_pidfile $@ >> $sidekiq_logfile 2>&1 +} + +function load_ok +{ + sidekiq_pid=$(cat $sidekiq_pidfile) + if [[ -z $sidekiq_pid ]] ; then + warn "Could not find a PID in $sidekiq_pidfile" + exit 0 + fi + + if (ps -p $sidekiq_pid -o args | grep '\([0-9]\+\) of \1 busy' 1>&2) ; then + warn "Too many busy Sidekiq workers" + exit 1 + fi + + exit 0 } case "$1" in @@ -51,6 +72,9 @@ case "$1" in killall) killall ;; + load_ok) + load_ok + ;; *) - echo "Usage: RAILS_ENV=your_env $0 {stop|start|start_no_deamonize|restart|killall}" + echo "Usage: RAILS_ENV=your_env $0 {stop|start|start_no_deamonize|restart|killall|load_ok}" esac diff --git a/script/upgrade.rb b/script/upgrade.rb new file mode 100644 index 0000000000..a5caecf852 --- /dev/null +++ b/script/upgrade.rb @@ -0,0 +1,3 @@ +require_relative "../lib/gitlab/upgrader" + +Gitlab::Upgrader.new.execute diff --git a/script/web b/script/web index 5464ed040a..1ad3b5d24b 100755 --- a/script/web +++ b/script/web @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash cd $(dirname $0)/.. app_root=$(pwd) diff --git a/spec/contexts/filter_context_spec.rb b/spec/contexts/filter_context_spec.rb deleted file mode 100644 index db27742b9b..0000000000 --- a/spec/contexts/filter_context_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'spec_helper' - -describe FilterContext do - - let(:user) { create :user } - let(:user2) { create :user } - let(:project1) { create(:project, creator_id: user.id) } - let(:project2) { create(:project, creator_id: user.id) } - let(:merge_request1) { create(:merge_request, author_id: user.id, source_project: project1, target_project: project2) } - let(:merge_request2) { create(:merge_request, author_id: user.id, source_project: project2, target_project: project1) } - let(:merge_request3) { create(:merge_request, author_id: user.id, source_project: project2, target_project: project2) } - let(:merge_request4) { create(:merge_request, author_id: user2.id, source_project: project2, target_project: project2, target_branch:"notes_refactoring") } - let(:issue1) { create(:issue, assignee_id: user.id, project: project1) } - let(:issue2) { create(:issue, assignee_id: user.id, project: project2) } - let(:issue3) { create(:issue, assignee_id: user2.id, project: project2) } - - describe 'merge requests' do - before :each do - merge_request1 - merge_request2 - merge_request3 - merge_request4 - end - - it 'should by default filter properly' do - merge_requests = user.cared_merge_requests - params ={} - merge_requests = FilterContext.new(merge_requests, params).execute - merge_requests.size.should == 3 - end - - it 'should apply blocks passed in on creation to the filters' do - merge_requests = user.cared_merge_requests - params = {:project_id => project1.id} - merge_requests = FilterContext.new(merge_requests, params).execute - merge_requests.size.should == 1 - end - end - - describe 'issues' do - before :each do - issue1 - issue2 - issue3 - end - it 'should by default filter projects properly' do - issues = user.assigned_issues - params = {} - issues = FilterContext.new(issues, params).execute - issues.size.should == 2 - end - it 'should apply blocks passed in on creation to the filters' do - issues = user.assigned_issues - params = {:project_id => project1.id} - issues = FilterContext.new(issues, params).execute - issues.size.should == 1 - end - end -end diff --git a/spec/contexts/projects_create_context_spec.rb b/spec/contexts/projects_create_context_spec.rb deleted file mode 100644 index 8b2a49dbee..0000000000 --- a/spec/contexts/projects_create_context_spec.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'spec_helper' - -describe Projects::CreateContext do - before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } - after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } - - describe :create_by_user do - before do - @user = create :user - @opts = { - name: "GitLab", - namespace: @user.namespace - } - end - - context 'user namespace' do - before do - @project = create_project(@user, @opts) - end - - it { @project.should be_valid } - it { @project.owner.should == @user } - it { @project.namespace.should == @user.namespace } - end - - context 'group namespace' do - before do - @group = create :group - @group.add_owner(@user) - - @opts.merge!(namespace_id: @group.id) - @project = create_project(@user, @opts) - end - - it { @project.should be_valid } - it { @project.owner.should == @group } - it { @project.namespace.should == @group } - end - - context 'respect configured public setting' do - before(:each) do - @settings = double("settings") - @settings.stub(:issues) { true } - @settings.stub(:merge_requests) { true } - @settings.stub(:wiki) { true } - @settings.stub(:wall) { true } - @settings.stub(:snippets) { true } - stub_const("Settings", Class.new) - Settings.stub_chain(:gitlab, :default_projects_features).and_return(@settings) - end - - context 'should be public when setting is public' do - before do - @settings.stub(:public) { true } - @project = create_project(@user, @opts) - end - - it { @project.public.should be_true } - end - - context 'should be private when setting is not public' do - before do - @settings.stub(:public) { false } - @project = create_project(@user, @opts) - end - - it { @project.public.should be_false } - end - end - end - - def create_project(user, opts) - Projects::CreateContext.new(user, opts).execute - end -end diff --git a/spec/contexts/search_context_spec.rb b/spec/contexts/search_context_spec.rb deleted file mode 100644 index 58f747e872..0000000000 --- a/spec/contexts/search_context_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper' - -describe SearchContext do - let(:found_namespace) { create(:namespace, name: 'searchable namespace', path:'another_thing') } - let(:user) { create(:user, namespace: found_namespace) } - let!(:found_project) { create(:project, name: 'searchable_project', creator_id: user.id, namespace: found_namespace, public: false) } - - let(:unfound_namespace) { create(:namespace, name: 'unfound namespace', path: 'yet_something_else') } - let!(:unfound_project) { create(:project, name: 'unfound_project', creator_id: user.id, namespace: unfound_namespace, public: false) } - let(:public_namespace) { create(:namespace, path: 'something_else',name: 'searchable public namespace') } - let(:other_user) { create(:user, namespace: public_namespace) } - let!(:public_project) { create(:project, name: 'searchable_public_project', creator_id: other_user.id, namespace: public_namespace, public: true) } - - describe '#execute' do - it 'public projects should be searchable' do - context = SearchContext.new([found_project.id], {search_code: false, search: "searchable"}) - results = context.execute - results[:projects].should == [found_project, public_project] - end - - it 'namespace name should be searchable' do - context = SearchContext.new([found_project.id], {search_code: false, search: "searchable namespace"}) - results = context.execute - results[:projects].should == [found_project] - end - end -end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index d528d12c66..e1c0269b29 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -8,7 +8,7 @@ describe ApplicationController do it 'should redirect if the user is over their password expiry' do user.password_expires_at = Time.new(2002) user.ldap_user?.should be_false - controller.stub!(:current_user).and_return(user) + controller.stub(:current_user).and_return(user) controller.should_receive(:redirect_to) controller.should_receive(:new_profile_password_path) controller.send(:check_password_expiration) @@ -17,15 +17,15 @@ describe ApplicationController do it 'should not redirect if the user is under their password expiry' do user.password_expires_at = Time.now + 20010101 user.ldap_user?.should be_false - controller.stub!(:current_user).and_return(user) + controller.stub(:current_user).and_return(user) controller.should_not_receive(:redirect_to) controller.send(:check_password_expiration) end it 'should not redirect if the user is over their password expiry but they are an ldap user' do user.password_expires_at = Time.new(2002) - user.stub!(:ldap_user?).and_return(true) - controller.stub!(:current_user).and_return(user) + user.stub(:ldap_user?).and_return(true) + controller.stub(:current_user).and_return(user) controller.should_not_receive(:redirect_to) controller.send(:check_password_expiration) end diff --git a/spec/controllers/blob_controller_spec.rb b/spec/controllers/blob_controller_spec.rb index 479d8fc1a1..cea6922e1c 100644 --- a/spec/controllers/blob_controller_spec.rb +++ b/spec/controllers/blob_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Projects::BlobController do - let(:project) { create(:project_with_code) } + let(:project) { create(:project) } let(:user) { create(:user) } before do diff --git a/spec/controllers/commit_controller_spec.rb b/spec/controllers/commit_controller_spec.rb index fdf0884f4e..f5822157ea 100644 --- a/spec/controllers/commit_controller_spec.rb +++ b/spec/controllers/commit_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Projects::CommitController do - let(:project) { create(:project_with_code) } + let(:project) { create(:project) } let(:user) { create(:user) } let(:commit) { project.repository.commit("master") } diff --git a/spec/controllers/commits_controller_spec.rb b/spec/controllers/commits_controller_spec.rb index 8263afc97a..fbf4f29acf 100644 --- a/spec/controllers/commits_controller_spec.rb +++ b/spec/controllers/commits_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Projects::CommitsController do - let(:project) { create(:project_with_code) } + let(:project) { create(:project) } let(:user) { create(:user) } before do diff --git a/spec/controllers/merge_requests_controller_spec.rb b/spec/controllers/merge_requests_controller_spec.rb index 69708edd8b..1502bded97 100644 --- a/spec/controllers/merge_requests_controller_spec.rb +++ b/spec/controllers/merge_requests_controller_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' describe Projects::MergeRequestsController do - let(:project) { create(:project_with_code) } + let(:project) { create(:project) } let(:user) { create(:user) } - let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project, target_branch: "bcf03b5d~3", source_branch: "bcf03b5d") } + let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project, target_branch: "stable", source_branch: "master") } before do sign_in(user) @@ -61,7 +61,7 @@ describe Projects::MergeRequestsController do it "should really be a git email patch with commit" do get :show, project_id: project.to_param, id: merge_request.iid, format: format - expect(response.body[0..100]).to start_with("From #{merge_request.commits.last.id}") + expect(response.body[0..100]).to start_with("From 6ea87c47f0f8a24ae031c3fff17bc913889ecd00") end it "should contain git diffs" do diff --git a/spec/controllers/profile_keys_controller_spec.rb b/spec/controllers/profile_keys_controller_spec.rb new file mode 100644 index 0000000000..593d3e9eb5 --- /dev/null +++ b/spec/controllers/profile_keys_controller_spec.rb @@ -0,0 +1,59 @@ +require 'spec_helper' + +describe Profiles::KeysController do + let(:user) { create(:user) } + + describe "#get_keys" do + describe "non existant user" do + it "should generally not work" do + get :get_keys, username: 'not-existent' + + expect(response).not_to be_success + end + end + + describe "user with no keys" do + it "should generally work" do + get :get_keys, username: user.username + + expect(response).to be_success + end + + it "should render all keys separated with a new line" do + get :get_keys, username: user.username + + expect(response.body).to eq("") + end + + it "should respond with text/plain content type" do + get :get_keys, username: user.username + expect(response.content_type).to eq("text/plain") + end + end + + describe "user with keys" do + before do + user.keys << create(:key) + user.keys << create(:another_key) + end + + it "should generally work" do + get :get_keys, username: user.username + + expect(response).to be_success + end + + it "should render all keys separated with a new line" do + get :get_keys, username: user.username + + expect(response.body).not_to eq("") + expect(response.body).to eq(user.all_ssh_keys.join("\n")) + end + + it "should respond with text/plain content type" do + get :get_keys, username: user.username + expect(response.content_type).to eq("text/plain") + end + end + end +end diff --git a/spec/controllers/tree_controller_spec.rb b/spec/controllers/tree_controller_spec.rb index bb1232e626..479118a346 100644 --- a/spec/controllers/tree_controller_spec.rb +++ b/spec/controllers/tree_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Projects::TreeController do - let(:project) { create(:project_with_code) } + let(:project) { create(:project) } let(:user) { create(:user) } before do diff --git a/spec/factories.rb b/spec/factories.rb index 624cb0f765..148477d638 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -15,7 +15,7 @@ FactoryGirl.define do email { Faker::Internet.email } name sequence(:username) { |n| "#{Faker::Internet.user_name}#{n}" } - password "123456" + password "12345678" password_confirmation { password } confirmed_at { Time.now } confirmation_token { nil } @@ -27,49 +27,50 @@ FactoryGirl.define do factory :admin, traits: [:admin] end - factory :project do + factory :empty_project, class: 'Project' do sequence(:name) { |n| "project#{n}" } path { name.downcase.gsub(/\s/, '_') } namespace creator - trait :source do - sequence(:name) { |n| "source project#{n}" } - end - trait :target do - sequence(:name) { |n| "target project#{n}" } + trait :public do + visibility_level Gitlab::VisibilityLevel::PUBLIC end - factory :source_project, traits: [:source] - factory :target_project, traits: [:target] + trait :internal do + visibility_level Gitlab::VisibilityLevel::INTERNAL + end + + trait :private do + visibility_level Gitlab::VisibilityLevel::PRIVATE + end end + # Generates a test repository from the repository stored under `spec/seed_project.tar.gz`. + # Once you run `rake gitlab:setup`, you can see what the repository looks like under `tmp/repositories/gitlabhq`. + # In order to modify files in the repository, you must untar the seed, modify and remake the tar. + # Before recompressing, do not forget to `git checkout master`. + # After recompressing, you need to run `RAILS_ENV=test bundle exec rake gitlab:setup` to regenerate the seeds under tmp. + # + # If you want to modify the repository only for an specific type of tests, e.g., markdown tests, + # consider using a feature branch to reduce the chances of collision with other tests. + # Create a new commit, and use the same commit message that you will use for the change in the main repo. + # Changing the commig message and SHA of branch `master` may break tests. + factory :project, parent: :empty_project do + path { 'gitlabhq' } + + after :create do |project| + TestEnv.clear_repo_dir(project.namespace, project.path) + TestEnv.reset_satellite_dir + TestEnv.create_repo(project.namespace, project.path) + end + end factory :redmine_project, parent: :project do issues_tracker { "redmine" } issues_tracker_id { "project_name_in_redmine" } end - factory :project_with_code, parent: :project do - path { 'gitlabhq' } - - trait :source_path do - path { 'source_gitlabhq' } - end - - trait :target_path do - path { 'target_gitlabhq' } - end - - factory :source_project_with_code, traits: [:source, :source_path] - factory :target_project_with_code, traits: [:target, :target_path] - - after :create do |project| - TestEnv.clear_repo_dir(project.namespace, project.path) - TestEnv.create_repo(project.namespace, project.path) - end - end - factory :group do sequence(:name) { |n| "group#{n}" } path { name.downcase.gsub(/\s/, '_') } @@ -108,25 +109,45 @@ FactoryGirl.define do factory :merge_request do title author - source_project factory: :source_project_with_code - target_project factory: :target_project_with_code + source_project factory: :project + target_project { source_project } + + # → git log stable..master --pretty=oneline + # b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828 tree css fixes + # 8716fc78f3c65bbf7bcf7b574febd583bc5d2812 Added loading animation for notes + # cd5c4bac5042c5469dcdf7e7b2f768d3c6fd7088 notes count for wall + # 8470d70da67355c9c009e4401746b1d5410af2e3 notes controller refactored + # 1e689bfba39525ead225eaf611948cfbe8ac34cf fixed notes logic + # f0f14c8eaba69ebddd766498a9d0b0e79becd633 finished scss refactoring + # 3a4b4fb4cde7809f033822a171b9feae19d41fff Moving ui styles to one scss file, Added ui class to body + # 065c200c33f68c2bb781e35a43f9dc8138a893b5 removed unnecessary hr tags & titles + # 1e8b111be85df0db6c8000ef9a710bc0221eae83 Merge branch 'master' of github.com:gitlabhq/gitlabhq + # f403da73f5e62794a0447aca879360494b08f678 Fixed ajax loading image. Fixed wrong wording + # e6ea73c77600d413d370249b8e392734f7d1dbee Merge pull request #468 from bencevans/patch-1 + # 4a3c05b69355deee25767a74d0512ec4b510d4ef Merge pull request #470 from bgondy/patch-1 + # 0347fe2412eb51d3efeccc35210e9268bc765ac5 Update app/views/projects/team.html.haml + # 2b5c61bdece1f7eb2b901ceea7d364065cdf76ac Title for a link fixed + # 460eeb13b7560b40104044973ff933b1a6dbbcaa Increased count of notes loaded when visit wall page + # 21c141afb1c53a9180a99d2cca29ffa613eb7e3a Merge branch 'notes_refactoring' + # 292a41cbe295f16f7148913b31eb0fb91f3251c3 Fixed comments for snippets. Tests fixed + # d41d8ffb02fa74fd4571603548bd7e401ec99e0c Reply button, Comments for Merge Request diff + # b1a36b552be2a7a6bc57fbed6c52dc6ed82111f8 Merge pull request #466 from skroutz/no-rbenv + # db75dae913e8365453ca231f101b067314a7ea71 Merge pull request #465 from skroutz/branches_commit_link + # 75f040fbfe4b5af23ff004ad3207c3976df097a8 Don't enforce rbenv version + # e42fb4fda475370dcb0d8f8f1268bfdc7a0cc437 Fix broken commit link in branches page + # 215a01f63ccdc085f75a48f6f7ab6f2b15b5852c move notes login to one controller + # 81092c01984a481e312de10a28e3f1a6dda182a3 Status codes for errors, New error pages + # 7d279f9302151e3c8f4c5df9c5200a72799409b9 better error handling for not found resource, gitolite error + # 9e6d0710e927aa8ea834b8a9ae9f277be617ac7d Merge pull request #443 from CedricGatay/fix/incorrectLineNumberingInDiff + # 6ea87c47f0f8a24ae031c3fff17bc913889ecd00 Incorrect line numbering in diff + # + # → git log master..stable --pretty=oneline + # empty + source_branch "master" target_branch "stable" - # pick 3 commits "at random" (from bcf03b5d~3 to bcf03b5d) trait :with_diffs do - target_branch "master" # pretend bcf03b5d~3 - source_branch "stable" # pretend bcf03b5d - st_commits do - [ - source_project.repository.commit('bcf03b5d').to_hash, - source_project.repository.commit('bcf03b5d~1').to_hash, - source_project.repository.commit('bcf03b5d~2').to_hash - ] - end - st_diffs do - source_project.repo.diff("bcf03b5d~3", "bcf03b5d") - end end trait :closed do @@ -137,6 +158,11 @@ FactoryGirl.define do state :reopened end + trait :simple do + source_branch "simple_merge_request" + target_branch "master" + end + factory :closed_merge_request, traits: [:closed] factory :reopened_merge_request, traits: [:reopened] factory :merge_request_with_diffs, traits: [:with_diffs] @@ -152,10 +178,9 @@ FactoryGirl.define do factory :note_on_issue, traits: [:on_issue], aliases: [:votable_note] factory :note_on_merge_request, traits: [:on_merge_request] factory :note_on_merge_request_diff, traits: [:on_merge_request, :on_diff] - factory :note_on_merge_request_with_attachment, traits: [:on_merge_request, :with_attachment] trait :on_commit do - project factory: :project_with_code + project factory: :project commit_id "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" noteable_type "Commit" end @@ -165,7 +190,7 @@ FactoryGirl.define do end trait :on_merge_request do - project factory: :project_with_code + project factory: :project noteable_id 1 noteable_type "MergeRequest" end @@ -208,12 +233,31 @@ FactoryGirl.define do end end + factory :another_key do + key do + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmTillFzNTrrGgwaCKaSj+QCz81E6jBc/s9av0+3b1Hwfxgkqjl4nAK/OD2NjgyrONDTDfR8cRN4eAAy6nY8GLkOyYBDyuc5nTMqs5z3yVuTwf3koGm/YQQCmo91psZ2BgDFTor8SVEE5Mm1D1k3JDMhDFxzzrOtRYFPci9lskTJaBjpqWZ4E9rDTD2q/QZntCqbC3wE9uSemRQB5f8kik7vD/AD8VQXuzKladrZKkzkONCPWsXDspUitjM8HkQdOf0PsYn1CMUC1xKYbCxkg5TkEosIwGv6CoEArUrdu/4+10LVslq494mAvEItywzrluCLCnwELfW+h/m8UHoVhZ" + end + end + factory :invalid_key do key do "ssh-rsa this_is_invalid_key==" end end end + + factory :email do + user + email do + Faker::Internet.email('alias') + end + + factory :another_email do + email do + Faker::Internet.email('another.alias') + end + end + end factory :milestone do title diff --git a/spec/factories/broadcast_messages.rb b/spec/factories/broadcast_messages.rb new file mode 100644 index 0000000000..ea0039d39e --- /dev/null +++ b/spec/factories/broadcast_messages.rb @@ -0,0 +1,27 @@ +# == Schema Information +# +# Table name: broadcast_messages +# +# id :integer not null, primary key +# message :text not null +# starts_at :datetime +# ends_at :datetime +# alert_type :integer +# created_at :datetime +# updated_at :datetime +# color :string(255) +# font :string(255) +# + +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :broadcast_message do + message "MyText" + starts_at "2013-11-12 13:43:25" + ends_at "2013-11-12 13:43:25" + alert_type 1 + color "#555555" + font "#BBBBBB" + end +end diff --git a/spec/factories/forked_project_links.rb b/spec/factories/forked_project_links.rb index 2f9b91acf2..906e4106b3 100644 --- a/spec/factories/forked_project_links.rb +++ b/spec/factories/forked_project_links.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # forked_to_project_id :integer not null # forked_from_project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # # Read about factories at https://github.com/thoughtbot/factory_girl diff --git a/spec/factories/users_groups.rb b/spec/factories/users_groups.rb index 34bc0c5146..49c3a367e1 100644 --- a/spec/factories/users_groups.rb +++ b/spec/factories/users_groups.rb @@ -6,8 +6,8 @@ # group_access :integer not null # group_id :integer not null # user_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # notification_level :integer default(3), not null # diff --git a/spec/features/admin/admin_hooks_spec.rb b/spec/features/admin/admin_hooks_spec.rb index 102a1b928f..120448ae33 100644 --- a/spec/features/admin/admin_hooks_spec.rb +++ b/spec/features/admin/admin_hooks_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Admin::Hooks" do +describe "Admin::Hooks", feature: true do before do @project = create(:project) login_as :admin diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb index 2337089124..3b3d027ab7 100644 --- a/spec/features/admin/admin_projects_spec.rb +++ b/spec/features/admin/admin_projects_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Admin::Projects" do +describe "Admin::Projects", feature: true do before do @project = create(:project) login_as :admin diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index 8d69b595ae..1aba40966c 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Admin::Users" do +describe "Admin::Users", feature: true do before { login_as :admin } describe "GET /admin/users" do diff --git a/spec/features/admin/security_spec.rb b/spec/features/admin/security_spec.rb index 6306832628..21b0d8b965 100644 --- a/spec/features/admin/security_spec.rb +++ b/spec/features/admin/security_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Admin::Projects" do +describe "Admin::Projects", feature: true do describe "GET /admin/projects" do subject { admin_projects_path } diff --git a/spec/features/atom/dashboard_issues_spec.rb b/spec/features/atom/dashboard_issues_spec.rb index 6f5d51d16b..9fd2933b2c 100644 --- a/spec/features/atom/dashboard_issues_spec.rb +++ b/spec/features/atom/dashboard_issues_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Dashboard Issues Feed" do +describe "Dashboard Issues Feed", feature: true do describe "GET /issues" do let!(:user) { create(:user) } let!(:project1) { create(:project) } @@ -8,6 +8,11 @@ describe "Dashboard Issues Feed" do let!(:issue1) { create(:issue, author: user, assignee: user, project: project1) } let!(:issue2) { create(:issue, author: user, assignee: user, project: project2) } + before do + project1.team << [user, :master] + project2.team << [user, :master] + end + describe "atom feed" do it "should render atom feed via private token" do visit issues_dashboard_path(:atom, private_token: user.private_token) diff --git a/spec/features/atom/dashboard_spec.rb b/spec/features/atom/dashboard_spec.rb index 6257ad5c89..e5d9f8ab5d 100644 --- a/spec/features/atom/dashboard_spec.rb +++ b/spec/features/atom/dashboard_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Dashboard Feed" do +describe "Dashboard Feed", feature: true do describe "GET /" do let!(:user) { create(:user) } diff --git a/spec/features/atom/issues_spec.rb b/spec/features/atom/issues_spec.rb index c9bbdad380..6ff03ec862 100644 --- a/spec/features/atom/issues_spec.rb +++ b/spec/features/atom/issues_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Issues Feed" do +describe "Issues Feed", feature: true do describe "GET /issues" do let!(:user) { create(:user) } let!(:project) { create(:project) } diff --git a/spec/features/gitlab_flavored_markdown_spec.rb b/spec/features/gitlab_flavored_markdown_spec.rb index 2ea569a620..9f50d1c973 100644 --- a/spec/features/gitlab_flavored_markdown_spec.rb +++ b/spec/features/gitlab_flavored_markdown_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe "GitLab Flavored Markdown" do - let(:project) { create(:project_with_code) } +describe "GitLab Flavored Markdown", feature: true do + let(:project) { create(:project) } let(:issue) { create(:issue, project: project) } let(:merge_request) { create(:merge_request, source_project: project, target_project: project) } let(:fred) do diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index 8cb984946b..e62517ad71 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Issues" do +describe "Issues", feature: true do let(:project) { create(:project) } before do @@ -43,6 +43,31 @@ describe "Issues" do page.should have_content project.name end end + + end + + describe "Editing issue assignee" do + let!(:issue) do + create(:issue, + author: @user, + assignee: @user, + project: project) + end + + it 'allows user to select unasigned', :js => true do + visit edit_project_issue_path(project, issue) + + page.should have_content "Assign to #{@user.name}" + + page.first('#s2id_issue_assignee_id').click + sleep 2 # wait for ajax stuff to complete + page.first('.user-result').click + + click_button "Save changes" + + page.should have_content "Assignee: Select assignee" + issue.reload.assignee.should be_nil + end end describe "Filter issue" do @@ -95,4 +120,185 @@ describe "Issues" do page.should have_content 'gitlab' end end + + describe 'filter issue' do + titles = ['foo','bar','baz'] + titles.each_with_index do |title, index| + let!(title.to_sym) { create(:issue, title: title, project: project, created_at: Time.now - (index * 60)) } + end + let(:newer_due_milestone) { create(:milestone, due_date: '2013-12-11') } + let(:later_due_milestone) { create(:milestone, due_date: '2013-12-12') } + + it 'sorts by newest' do + visit project_issues_path(project, sort: 'newest') + + first_issue.should include("foo") + last_issue.should include("baz") + end + + it 'sorts by oldest' do + visit project_issues_path(project, sort: 'oldest') + + first_issue.should include("baz") + last_issue.should include("foo") + end + + it 'sorts by most recently updated' do + baz.updated_at = Time.now + 100 + baz.save + visit project_issues_path(project, sort: 'recently_updated') + + first_issue.should include("baz") + end + + it 'sorts by least recently updated' do + baz.updated_at = Time.now - 100 + baz.save + visit project_issues_path(project, sort: 'last_updated') + + first_issue.should include("baz") + end + + describe 'sorting by milestone' do + before :each do + foo.milestone = newer_due_milestone + foo.save + bar.milestone = later_due_milestone + bar.save + end + + it 'sorts by recently due milestone' do + visit project_issues_path(project, sort: 'milestone_due_soon') + + first_issue.should include("foo") + end + + it 'sorts by least recently due milestone' do + visit project_issues_path(project, sort: 'milestone_due_later') + + first_issue.should include("bar") + end + end + + describe 'combine filter and sort' do + let(:user2) { create(:user) } + + before :each do + foo.assignee = user2 + foo.save + bar.assignee = user2 + bar.save + end + + it 'sorts with a filter applied' do + visit project_issues_path(project, sort: 'oldest', assignee_id: user2.id) + + first_issue.should include("bar") + last_issue.should include("foo") + page.should_not have_content 'baz' + end + end + end + + describe 'update assignee from issue#show' do + let(:issue) { create(:issue, project: project, author: @user) } + + context 'by autorized user' do + + it 'with dropdown menu' do + visit project_issue_path(project, issue) + + find('.edit-issue.inline-update #issue_assignee_id').set project.team.members.first.id + click_button 'Update Issue' + + page.should have_content "Assignee:" + page.has_select?('issue_assignee_id', :selected => project.team.members.first.name) + end + end + + context 'by unauthorized user' do + + let(:guest) { create(:user) } + + before :each do + project.team << [[guest], :guest] + issue.assignee = @user + issue.save + end + + it 'shows assignee text' do + logout + login_with guest + + visit project_issue_path(project, issue) + page.should have_content issue.assignee.name + end + end + end + + describe 'update milestone from issue#show' do + let!(:issue) { create(:issue, project: project, author: @user) } + let!(:milestone) { create(:milestone, project: project) } + + context 'by authorized user' do + + it 'with dropdown menu' do + visit project_issue_path(project, issue) + + find('.edit-issue.inline-update').select(milestone.title, from: 'issue_milestone_id') + click_button 'Update Issue' + + page.should have_content "Milestone" + page.has_select?('issue_assignee_id', :selected => milestone.title) + end + end + + context 'by unauthorized user' do + let(:guest) { create(:user) } + + before :each do + project.team << [guest, :guest] + issue.milestone = milestone + issue.save + end + + it 'shows milestone text' do + logout + login_with guest + + visit project_issue_path(project, issue) + page.should have_content milestone.title + end + end + + describe 'removing assignee' do + let(:user2) { create(:user) } + + before :each do + issue.assignee = user2 + issue.save + end + + it 'allows user to remove assignee', :js => true do + visit project_issue_path(project, issue) + page.should have_content "Assignee: #{user2.name}" + + page.first('#s2id_issue_assignee_id').click + sleep 2 # wait for ajax stuff to complete + page.first('.user-result').click + + page.should have_content "Assignee: Unassigned" + sleep 2 # wait for ajax stuff to complete + issue.reload.assignee.should be_nil + end + end + end + + def first_issue + all("ul.issues-list li").first.text + end + + def last_issue + all("ul.issues-list li").last.text + end end diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb index d29bed4dea..cfb6deb183 100644 --- a/spec/features/notes_on_merge_requests_spec.rb +++ b/spec/features/notes_on_merge_requests_spec.rb @@ -1,14 +1,12 @@ require 'spec_helper' -describe "On a merge request", js: true do - let!(:project) { create(:project_with_code) } - let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) } - let!(:note) { create(:note_on_merge_request_with_attachment, project: project) } +describe "On a merge request", js: true, feature: true do + let!(:merge_request) { create(:merge_request, :simple) } + let!(:project) { merge_request.source_project } + let!(:note) { create(:note_on_merge_request, :with_attachment, project: project) } before do - login_as :user - project.team << [@user, :master] - + login_as :admin visit project_merge_request_path(project, merge_request) end @@ -108,7 +106,7 @@ describe "On a merge request", js: true do within("#note_#{note.id}") do should have_css(".note-last-update small") - find(".note-last-update small").text.should match(/Edited just now/) + find(".note-last-update small").text.should match(/Edited less than a minute ago/) end end end @@ -134,22 +132,20 @@ describe "On a merge request", js: true do end end -describe "On a merge request diff", js: true, focus: true do - let!(:project) { create(:source_project_with_code) } - let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) } +describe "On a merge request diff", js: true do + let(:merge_request) { create(:merge_request, :with_diffs, :simple) } + let(:project) { merge_request.source_project } before do - login_as :user - project.team << [@user, :master] + login_as :admin visit diffs_project_merge_request_path(project, merge_request) end - subject { page } describe "when adding a note" do before do - find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click + find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7"]').click end describe "the notes holder" do @@ -159,22 +155,14 @@ describe "On a merge request diff", js: true, focus: true do end describe "the note form" do - it 'should be valid' do - within(".js-temp-notes-holder") { find("#note_noteable_type").value.should == "MergeRequest" } - within(".js-temp-notes-holder") { find("#note_noteable_id").value.should == merge_request.id.to_s } - within(".js-temp-notes-holder") { find("#note_commit_id").value.should == "" } - within(".js-temp-notes-holder") { find("#note_line_code").value.should == "4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185" } - should have_css(".js-close-discussion-note-form", text: "Cancel") - end - it "shouldn't add a second form for same row" do - find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click + find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7"]').click - should have_css("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185'] + .js-temp-notes-holder form", count: 1) + should have_css("tr[id='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7'] + .js-temp-notes-holder form", count: 1) end it "should be removed when canceled" do - within(".file form[rel$='4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185']") do + within(".diff-file form[rel$='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7']") do find(".js-close-discussion-note-form").trigger("click") end @@ -184,12 +172,9 @@ describe "On a merge request diff", js: true, focus: true do end describe "with muliple note forms" do - let!(:project) { create(:source_project_with_code) } - let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) } - before do - find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click - find('a[data-line-code="342e16cbbd482ac2047dc679b2749d248cc1428f_18_17"]').click + find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7"]').click + find('a[data-line-code="8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_10_10"]').click end it { should have_css(".js-temp-notes-holder", count: 2) } @@ -197,12 +182,12 @@ describe "On a merge request diff", js: true, focus: true do describe "previewing them separately" do before do # add two separate texts and trigger previews on both - within("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185'] + .js-temp-notes-holder") do - fill_in "note[note]", with: "One comment on line 185" + within("tr[id='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_7_7'] + .js-temp-notes-holder") do + fill_in "note[note]", with: "One comment on line 7" find(".js-note-preview-button").trigger("click") end - within("tr[id='342e16cbbd482ac2047dc679b2749d248cc1428f_18_17'] + .js-temp-notes-holder") do - fill_in "note[note]", with: "Another comment on line 17" + within("tr[id='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_10_10'] + .js-temp-notes-holder") do + fill_in "note[note]", with: "Another comment on line 10" find(".js-note-preview-button").trigger("click") end end @@ -210,14 +195,14 @@ describe "On a merge request diff", js: true, focus: true do describe "posting a note" do before do - within("tr[id='342e16cbbd482ac2047dc679b2749d248cc1428f_18_17'] + .js-temp-notes-holder") do - fill_in "note[note]", with: "Another comment on line 17" + within("tr[id='8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d_10_10'] + .js-temp-notes-holder") do + fill_in "note[note]", with: "Another comment on line 10" click_button("Add Comment") end end it 'should be added as discussion' do - should have_content("Another comment on line 17") + should have_content("Another comment on line 10") should have_css(".notes_holder") should have_css(".notes_holder .note", count: 1) should have_link("Reply") diff --git a/spec/features/profile_spec.rb b/spec/features/profile_spec.rb index b67ce3c67f..e8364bbb96 100644 --- a/spec/features/profile_spec.rb +++ b/spec/features/profile_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Profile account page" do +describe "Profile account page", feature: true do before(:each) { enable_observers } after(:each) {disable_observers} let(:user) { create(:user) } diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index 9d5f9d5a2e..1e24782c39 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Projects" do +describe "Projects", feature: true do before(:each) { enable_observers } after(:each) {disable_observers} before { login_as :user } diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb index 3ca59da493..f12eb12429 100644 --- a/spec/features/search_spec.rb +++ b/spec/features/search_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Search" do +describe "Search", feature: true do before do ActiveRecord::Base.observers.enable(:user_observer) login_as :user diff --git a/spec/features/security/dashboard_access_spec.rb b/spec/features/security/dashboard_access_spec.rb index adec5926c6..1cca82cef6 100644 --- a/spec/features/security/dashboard_access_spec.rb +++ b/spec/features/security/dashboard_access_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Dashboard access" do +describe "Dashboard access", feature: true do describe "GET /dashboard" do subject { dashboard_path } diff --git a/spec/features/security/group_access_spec.rb b/spec/features/security/group/group_access_spec.rb similarity index 96% rename from spec/features/security/group_access_spec.rb rename to spec/features/security/group/group_access_spec.rb index dea957962a..b65e1d2dbf 100644 --- a/spec/features/security/group_access_spec.rb +++ b/spec/features/security/group/group_access_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Group access" do +describe "Group access", feature: true do describe "GET /projects/new" do it { new_group_path.should be_allowed_for :admin } it { new_group_path.should be_allowed_for :user } @@ -14,6 +14,7 @@ describe "Group access" do let(:master) { create(:user) } let(:reporter) { create(:user) } let(:guest) { create(:user) } + let(:nonmember) { create(:user) } before do group.add_user(owner, Gitlab::Access::OWNER) diff --git a/spec/features/security/group/internal_group_access_spec.rb b/spec/features/security/group/internal_group_access_spec.rb new file mode 100644 index 0000000000..da5c6eb4e9 --- /dev/null +++ b/spec/features/security/group/internal_group_access_spec.rb @@ -0,0 +1,82 @@ +require 'spec_helper' + +describe "Group with internal project access", feature: true do + describe "Group" do + let(:group) { create(:group) } + + let(:owner) { create(:owner) } + let(:master) { create(:user) } + let(:reporter) { create(:user) } + let(:guest) { create(:user) } + let(:nonmember) { create(:user) } + + before do + group.add_user(owner, Gitlab::Access::OWNER) + group.add_user(master, Gitlab::Access::MASTER) + group.add_user(reporter, Gitlab::Access::REPORTER) + group.add_user(guest, Gitlab::Access::GUEST) + + create(:project, :internal, group: group) + end + + describe "GET /groups/:path" do + subject { group_path(group) } + + it { should be_allowed_for owner } + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /groups/:path/issues" do + subject { issues_group_path(group) } + + it { should be_allowed_for owner } + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /groups/:path/merge_requests" do + subject { merge_requests_group_path(group) } + + it { should be_allowed_for owner } + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /groups/:path/members" do + subject { members_group_path(group) } + + it { should be_allowed_for owner } + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /groups/:path/edit" do + subject { edit_group_path(group) } + + it { should be_allowed_for owner } + it { should be_denied_for master } + it { should be_denied_for reporter } + it { should be_allowed_for :admin } + it { should be_denied_for guest } + it { should be_denied_for :user } + it { should be_denied_for :visitor } + end + end +end diff --git a/spec/features/security/group/mixed_group_access_spec.rb b/spec/features/security/group/mixed_group_access_spec.rb new file mode 100644 index 0000000000..c9889d9959 --- /dev/null +++ b/spec/features/security/group/mixed_group_access_spec.rb @@ -0,0 +1,83 @@ +require 'spec_helper' + +describe "Group access", feature: true do + describe "Group" do + let(:group) { create(:group) } + + let(:owner) { create(:owner) } + let(:master) { create(:user) } + let(:reporter) { create(:user) } + let(:guest) { create(:user) } + let(:nonmember) { create(:user) } + + before do + group.add_user(owner, Gitlab::Access::OWNER) + group.add_user(master, Gitlab::Access::MASTER) + group.add_user(reporter, Gitlab::Access::REPORTER) + group.add_user(guest, Gitlab::Access::GUEST) + + create(:project, :internal, path: "internal_project", group: group) + create(:project, :public, path: "public_project", group: group) + end + + describe "GET /groups/:path" do + subject { group_path(group) } + + it { should be_allowed_for owner } + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_allowed_for :visitor } + end + + describe "GET /groups/:path/issues" do + subject { issues_group_path(group) } + + it { should be_allowed_for owner } + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_allowed_for :visitor } + end + + describe "GET /groups/:path/merge_requests" do + subject { merge_requests_group_path(group) } + + it { should be_allowed_for owner } + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_allowed_for :visitor } + end + + describe "GET /groups/:path/members" do + subject { members_group_path(group) } + + it { should be_allowed_for owner } + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_allowed_for :visitor } + end + + describe "GET /groups/:path/edit" do + subject { edit_group_path(group) } + + it { should be_allowed_for owner } + it { should be_denied_for master } + it { should be_denied_for reporter } + it { should be_allowed_for :admin } + it { should be_denied_for guest } + it { should be_denied_for :user } + it { should be_denied_for :visitor } + end + end +end diff --git a/spec/features/security/group/public_group_access_spec.rb b/spec/features/security/group/public_group_access_spec.rb new file mode 100644 index 0000000000..2e76ab154f --- /dev/null +++ b/spec/features/security/group/public_group_access_spec.rb @@ -0,0 +1,82 @@ +require 'spec_helper' + +describe "Group with public project access", feature: true do + describe "Group" do + let(:group) { create(:group) } + + let(:owner) { create(:owner) } + let(:master) { create(:user) } + let(:reporter) { create(:user) } + let(:guest) { create(:user) } + let(:nonmember) { create(:user) } + + before do + group.add_user(owner, Gitlab::Access::OWNER) + group.add_user(master, Gitlab::Access::MASTER) + group.add_user(reporter, Gitlab::Access::REPORTER) + group.add_user(guest, Gitlab::Access::GUEST) + + create(:project, :public, group: group) + end + + describe "GET /groups/:path" do + subject { group_path(group) } + + it { should be_allowed_for owner } + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_allowed_for :visitor } + end + + describe "GET /groups/:path/issues" do + subject { issues_group_path(group) } + + it { should be_allowed_for owner } + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_allowed_for :visitor } + end + + describe "GET /groups/:path/merge_requests" do + subject { merge_requests_group_path(group) } + + it { should be_allowed_for owner } + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_allowed_for :visitor } + end + + describe "GET /groups/:path/members" do + subject { members_group_path(group) } + + it { should be_allowed_for owner } + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_allowed_for :visitor } + end + + describe "GET /groups/:path/edit" do + subject { edit_group_path(group) } + + it { should be_allowed_for owner } + it { should be_denied_for master } + it { should be_denied_for reporter } + it { should be_allowed_for :admin } + it { should be_denied_for guest } + it { should be_denied_for :user } + it { should be_denied_for :visitor } + end + end +end diff --git a/spec/features/security/profile_access_spec.rb b/spec/features/security/profile_access_spec.rb index 078c257538..4efc0ffdcd 100644 --- a/spec/features/security/profile_access_spec.rb +++ b/spec/features/security/profile_access_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Users Security" do +describe "Users Security", feature: true do describe "Project" do before do @u1 = create(:user) diff --git a/spec/features/security/project/internal_access_spec.rb b/spec/features/security/project/internal_access_spec.rb new file mode 100644 index 0000000000..f6ab47ed91 --- /dev/null +++ b/spec/features/security/project/internal_access_spec.rb @@ -0,0 +1,246 @@ +require 'spec_helper' + +describe "Internal Project Access", feature: true do + let(:project) { create(:project, :internal) } + + let(:master) { create(:user) } + let(:guest) { create(:user) } + let(:reporter) { create(:user) } + + before do + # full access + project.team << [master, :master] + + # readonly + project.team << [reporter, :reporter] + end + + describe "Project should be internal" do + subject { project } + + its(:internal?) { should be_true } + end + + describe "GET /:project_path" do + subject { project_path(project) } + + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/tree/master" do + subject { project_tree_path(project, project.repository.root_ref) } + + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/commits/master" do + subject { project_commits_path(project, project.repository.root_ref, limit: 1) } + + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/commit/:sha" do + subject { project_commit_path(project, project.repository.commit) } + + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/compare" do + subject { project_compare_index_path(project) } + + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/team" do + subject { project_team_index_path(project) } + + it { should be_allowed_for master } + it { should be_denied_for reporter } + it { should be_allowed_for :admin } + it { should be_denied_for guest } + it { should be_denied_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/wall" do + subject { project_wall_path(project) } + + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/blob" do + before do + commit = project.repository.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)) + end + + it { @blob_path.should be_allowed_for master } + it { @blob_path.should be_allowed_for reporter } + it { @blob_path.should be_allowed_for :admin } + it { @blob_path.should be_allowed_for guest } + it { @blob_path.should be_allowed_for :user } + it { @blob_path.should be_denied_for :visitor } + end + + describe "GET /:project_path/edit" do + subject { edit_project_path(project) } + + it { should be_allowed_for master } + it { should be_denied_for reporter } + it { should be_allowed_for :admin } + it { should be_denied_for guest } + it { should be_denied_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/deploy_keys" do + subject { project_deploy_keys_path(project) } + + it { should be_allowed_for master } + it { should be_denied_for reporter } + it { should be_allowed_for :admin } + it { should be_denied_for guest } + it { should be_denied_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/issues" do + subject { project_issues_path(project) } + + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/snippets" do + subject { project_snippets_path(project) } + + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/snippets/new" do + subject { new_project_snippet_path(project) } + + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_denied_for guest } + it { should be_denied_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/merge_requests" do + subject { project_merge_requests_path(project) } + + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/merge_requests/new" do + subject { new_project_merge_request_path(project) } + + it { should be_allowed_for master } + it { should be_denied_for reporter } + it { should be_allowed_for :admin } + it { should be_denied_for guest } + it { should be_denied_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/branches/recent" do + subject { recent_project_branches_path(project) } + + it { should be_allowed_for master } + it { should be_allowed_for reporter } + it { should be_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/branches" do + subject { project_branches_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_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/tags" do + subject { project_tags_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_allowed_for :admin } + it { should be_allowed_for guest } + it { should be_allowed_for :user } + it { should be_denied_for :visitor } + end + + describe "GET /:project_path/hooks" do + subject { project_hooks_path(project) } + + it { should be_allowed_for master } + it { should be_denied_for reporter } + it { should be_allowed_for :admin } + it { should be_denied_for guest } + it { should be_denied_for :user } + it { should be_denied_for :visitor } + end +end diff --git a/spec/features/security/project/private_access_spec.rb b/spec/features/security/project/private_access_spec.rb index 7f3f8c50f0..8a0fcb8e9f 100644 --- a/spec/features/security/project/private_access_spec.rb +++ b/spec/features/security/project/private_access_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe "Private Project Access" do - let(:project) { create(:project_with_code) } +describe "Private Project Access", feature: true do + let(:project) { create(:project) } let(:master) { create(:user) } let(:guest) { create(:user) } @@ -15,6 +15,12 @@ describe "Private Project Access" do project.team << [reporter, :reporter] end + describe "Project should be private" do + subject { project } + + its(:private?) { should be_true } + end + describe "GET /:project_path" do subject { project_path(project) } diff --git a/spec/features/security/project/public_access_spec.rb b/spec/features/security/project/public_access_spec.rb index 267643fd8e..eb511bfefe 100644 --- a/spec/features/security/project/public_access_spec.rb +++ b/spec/features/security/project/public_access_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe "Public Project Access" do - let(:project) { create(:project_with_code) } +describe "Public Project Access", feature: true do + let(:project) { create(:project) } let(:master) { create(:user) } let(:guest) { create(:user) } @@ -9,7 +9,7 @@ describe "Public Project Access" do before do # public project - project.public = true + project.visibility_level = Gitlab::VisibilityLevel::PUBLIC project.save! # full access diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index ed9e44fb47..7b831c4861 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Users' do +describe 'Users', feature: true do describe "GET /users/sign_up" do before do Gitlab.config.gitlab.stub(:signup_enabled).and_return(true) diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb new file mode 100644 index 0000000000..7489e56f42 --- /dev/null +++ b/spec/finders/issues_finder_spec.rb @@ -0,0 +1,58 @@ +require 'spec_helper' + +describe IssuesFinder do + let(:user) { create :user } + let(:user2) { create :user } + let(:project1) { create(:project) } + let(:project2) { create(:project) } + let(:issue1) { create(:issue, assignee: user, project: project1) } + let(:issue2) { create(:issue, assignee: user, project: project2) } + let(:issue3) { create(:issue, assignee: user2, project: project2) } + + before do + project1.team << [user, :master] + project2.team << [user, :developer] + project2.team << [user2, :developer] + end + + describe :execute do + before :each do + issue1 + issue2 + issue3 + end + + it 'should filter by all' do + params = { scope: "all", state: 'opened' } + issues = IssuesFinder.new.execute(user, params) + issues.size.should == 3 + end + + it 'should filter by assignee' do + params = { scope: "assigned-to-me", state: 'opened' } + issues = IssuesFinder.new.execute(user, params) + issues.size.should == 2 + end + + it 'should filter by project' do + params = { scope: "assigned-to-me", state: 'opened', project_id: project1.id } + issues = IssuesFinder.new.execute(user, params) + issues.size.should == 1 + end + + it 'should be empty for unauthorized user' do + params = { scope: "all", state: 'opened' } + issues = IssuesFinder.new.execute(nil, params) + issues.size.should be_zero + end + + it 'should not include unauthorized issues' do + params = { scope: "all", state: 'opened' } + issues = IssuesFinder.new.execute(user2, params) + issues.size.should == 2 + issues.should_not include(issue1) + issues.should include(issue2) + issues.should include(issue3) + end + end +end diff --git a/spec/finders/merge_requests_finder_spec.rb b/spec/finders/merge_requests_finder_spec.rb new file mode 100644 index 0000000000..94b4d4c4ff --- /dev/null +++ b/spec/finders/merge_requests_finder_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe MergeRequestsFinder do + let(:user) { create :user } + let(:user2) { create :user } + + let(:project1) { create(:project) } + let(:project2) { create(:project, forked_from_project: project1) } + + let!(:merge_request1) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project1) } + let!(:merge_request2) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project1, state: 'closed') } + let!(:merge_request3) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project2) } + + before do + project1.team << [user, :master] + project2.team << [user, :developer] + project2.team << [user2, :developer] + end + + describe "#execute" do + it 'should filter by scope' do + params = { scope: 'authored', state: 'opened' } + merge_requests = MergeRequestsFinder.new.execute(user, params) + merge_requests.size.should == 2 + end + + it 'should filter by project' do + params = { project_id: project1.id, scope: 'authored', state: 'opened' } + merge_requests = MergeRequestsFinder.new.execute(user, params) + merge_requests.size.should == 1 + end + end +end diff --git a/spec/finders/notes_finder_spec.rb b/spec/finders/notes_finder_spec.rb new file mode 100644 index 0000000000..4f8a5f909d --- /dev/null +++ b/spec/finders/notes_finder_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper' + +describe NotesFinder do + let(:user) { create :user } + let(:project) { create :project } + let(:note1) { create :note_on_commit, project: project } + let(:note2) { create :note_on_commit, project: project } + let(:commit) { note1.noteable } + + before do + project.team << [user, :master] + end + + describe :execute do + let(:params) { { target_id: commit.id, target_type: 'commit', last_fetched_at: 1.hour.ago.to_i } } + + before do + note1 + note2 + end + + it 'should find all notes' do + notes = NotesFinder.new.execute(project, user, params) + notes.size.should eq(2) + end + + it 'should raise an exception for an invalid target_type' do + params.merge!(target_type: 'invalid') + expect { NotesFinder.new.execute(project, user, params) }.to raise_error('invalid target_type') + end + + it 'filters out old notes' do + note2.update_attribute(:updated_at, 2.hours.ago) + notes = NotesFinder.new.execute(project, user, params) + notes.should eq([note1]) + end + end +end diff --git a/spec/finders/projects_finder_spec.rb b/spec/finders/projects_finder_spec.rb new file mode 100644 index 0000000000..6e3ae4d615 --- /dev/null +++ b/spec/finders/projects_finder_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper' + +describe ProjectsFinder do + let(:user) { create :user } + let(:group) { create :group } + + let(:project1) { create(:empty_project, :public, group: group) } + let(:project2) { create(:empty_project, :internal, group: group) } + let(:project3) { create(:empty_project, :private, group: group) } + let(:project4) { create(:empty_project, :private, group: group) } + + context 'non authenticated' do + subject { ProjectsFinder.new.execute(nil, group: group) } + + it { should include(project1) } + it { should_not include(project2) } + it { should_not include(project3) } + it { should_not include(project4) } + end + + context 'authenticated' do + subject { ProjectsFinder.new.execute(user, group: group) } + + it { should include(project1) } + it { should include(project2) } + it { should_not include(project3) } + it { should_not include(project4) } + end + + context 'authenticated, project member' do + before { project3.team << [user, :developer] } + + subject { ProjectsFinder.new.execute(user, group: group) } + + it { should include(project1) } + it { should include(project2) } + it { should include(project3) } + it { should_not include(project4) } + end + + context 'authenticated, group member' do + before { group.add_user(user, Gitlab::Access::DEVELOPER) } + + subject { ProjectsFinder.new.execute(user, group: group) } + + it { should include(project1) } + it { should include(project2) } + it { should include(project3) } + it { should include(project4) } + end +end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index d63a2de880..0376e0aadf 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe ApplicationHelper do describe 'current_controller?' do before do - controller.stub!(:controller_name).and_return('foo') + controller.stub(:controller_name).and_return('foo') end it "returns true when controller matches argument" do @@ -22,7 +22,7 @@ describe ApplicationHelper do describe 'current_action?' do before do - stub!(:action_name).and_return('foo') + allow(self).to receive(:action_name).and_return('foo') end it "returns true when action matches argument" do @@ -38,7 +38,24 @@ describe ApplicationHelper do current_action?(:baz, :bar, :foo).should be_true end end - + + describe "group_icon" do + avatar_file_path = File.join(Rails.root, 'public', 'gitlab_logo.png') + + it "should return an url for the avatar" do + group = create(:group) + group.avatar = File.open(avatar_file_path) + group.save! + group_icon(group.path).to_s.should match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png") + end + + it "should give default avatar_icon when no avatar is present" do + group = create(:group) + group.save! + group_icon(group.path).should match("group_avatar.png") + end + end + describe "avatar_icon" do avatar_file_path = File.join(Rails.root, 'public', 'gitlab_logo.png') @@ -46,13 +63,13 @@ describe ApplicationHelper do user = create(:user) user.avatar = File.open(avatar_file_path) user.save! - avatar_icon(user.email).to_s.should == "/uploads/user/avatar/#{ user.id }/gitlab_logo.png" + avatar_icon(user.email).to_s.should match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png") end it "should call gravatar_icon when no avatar is present" do user = create(:user) user.save! - stub!(:gravatar_icon).and_return('gravatar_method_called') + allow(self).to receive(:gravatar_icon).and_return('gravatar_method_called') avatar_icon(user.email).to_s.should == "gravatar_method_called" end end @@ -62,50 +79,88 @@ describe ApplicationHelper do it "should return a generic avatar path when Gravatar is disabled" do Gitlab.config.gravatar.stub(:enabled).and_return(false) - gravatar_icon(user_email).should == 'no_avatar.png' + gravatar_icon(user_email).should == '/assets/no_avatar.png' end it "should return a generic avatar path when email is blank" do - gravatar_icon('').should == 'no_avatar.png' + gravatar_icon('').should == '/assets/no_avatar.png' end it "should return default gravatar url" do - stub!(:request).and_return(double(:ssl? => false)) + allow(self).to receive(:request).and_return(double(:ssl? => false)) gravatar_icon(user_email).should match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118') end it "should use SSL when appropriate" do - stub!(:request).and_return(double(:ssl? => true)) + allow(self).to receive(:request).and_return(double(:ssl? => true)) gravatar_icon(user_email).should match('https://secure.gravatar.com') end it "should return custom gravatar path when gravatar_url is set" do - stub!(:request).and_return(double(:ssl? => false)) + allow(self).to receive(:request).and_return(double(:ssl? => false)) Gitlab.config.gravatar.stub(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}') gravatar_icon(user_email, 20).should == 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118' end it "should accept a custom size" do - stub!(:request).and_return(double(:ssl? => false)) + allow(self).to receive(:request).and_return(double(:ssl? => false)) gravatar_icon(user_email, 64).should match(/\?s=64/) end it "should use default size when size is wrong" do - stub!(:request).and_return(double(:ssl? => false)) + allow(self).to receive(:request).and_return(double(:ssl? => false)) gravatar_icon(user_email, nil).should match(/\?s=40/) end it "should be case insensitive" do - stub!(:request).and_return(double(:ssl? => false)) + allow(self).to receive(:request).and_return(double(:ssl? => false)) gravatar_icon(user_email).should == gravatar_icon(user_email.upcase + " ") end + end + describe "grouped_options_refs" do + # Override Rails' grouped_options_for_select helper since HTML is harder to work with + def grouped_options_for_select(options, *args) + options + end + + let(:options) { grouped_options_refs } + + before do + # Must be an instance variable + @project = create(:project) + end + + it "includes a list of branch names" do + options[0][0].should == 'Branches' + options[0][1].should include('master', 'stable') + end + + it "includes a list of tag names" do + options[1][0].should == 'Tags' + options[1][1].should include('v0.9.4','v1.2.0') + end + + it "includes a specific commit ref if defined" do + # Must be an instance variable + @ref = '2ed06dc41dbb5936af845b87d79e05bbf24c73b8' + + options[2][0].should == 'Commit' + options[2][1].should == [@ref] + end + + it "sorts tags in a natural order" do + # Stub repository.tag_names to make sure we get some valid testing data + expect(@project.repository).to receive(:tag_names).and_return(["v1.0.9", "v1.0.10", "v2.0", "v3.1.4.2", "v1.0.9a"]) + + options[1][1].should == ["v3.1.4.2", "v2.0", "v1.0.10", "v1.0.9a", "v1.0.9"] + end end describe "user_color_scheme_class" do context "with current_user is nil" do it "should return a string" do - stub!(:current_user).and_return(nil) + allow(self).to receive(:current_user).and_return(nil) user_color_scheme_class.should be_kind_of(String) end end @@ -115,7 +170,7 @@ describe ApplicationHelper do context "with color_scheme_id == #{color_scheme_id}" do it "should return a string" do current_user = double(:color_scheme_id => color_scheme_id) - stub!(:current_user).and_return(current_user) + allow(self).to receive(:current_user).and_return(current_user) user_color_scheme_class.should be_kind_of(String) end end diff --git a/spec/helpers/broadcast_messages_helper_spec.rb b/spec/helpers/broadcast_messages_helper_spec.rb new file mode 100644 index 0000000000..1338ce4873 --- /dev/null +++ b/spec/helpers/broadcast_messages_helper_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe BroadcastMessagesHelper do + describe 'broadcast_styling' do + let(:broadcast_message) { double(color: "", font: "") } + + context "default style" do + it "should have no style" do + broadcast_styling(broadcast_message).should match('') + end + end + + context "customiezd style" do + before { broadcast_message.stub(color: "#f2dede", font: "#b94a48") } + + it "should have a customized style" do + broadcast_styling(broadcast_message).should match('background-color:#f2dede;color:#b94a48') + end + end + end +end diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb index a0bbc02642..49b48d26e2 100644 --- a/spec/helpers/gitlab_markdown_helper_spec.rb +++ b/spec/helpers/gitlab_markdown_helper_spec.rb @@ -4,7 +4,7 @@ describe GitlabMarkdownHelper do include ApplicationHelper include IssuesHelper - let!(:project) { create(:project_with_code) } + let!(:project) { create(:project) } let(:user) { create(:user, username: 'gfm') } let(:commit) { project.repository.commit } @@ -16,6 +16,7 @@ describe GitlabMarkdownHelper do before do # Helper expects a @project instance variable @project = project + @repository = project.repository end describe "#gfm" do @@ -180,6 +181,52 @@ describe GitlabMarkdownHelper do include_examples 'referenced object' end + describe "referencing a Jira issue" do + let(:actual) { "Reference to JIRA-#{issue.iid}" } + let(:expected) { "http://jira.example/browse/JIRA-#{issue.iid}" } + let(:reference) { "JIRA-#{issue.iid}" } + + before do + issue_tracker_config = { "jira" => { "title" => "JIRA tracker", "issues_url" => "http://jira.example/browse/:id" } } + Gitlab.config.stub(:issues_tracker).and_return(issue_tracker_config) + @project.stub(:issues_tracker).and_return("jira") + @project.stub(:issues_tracker_id).and_return("JIRA") + end + + it "should link using a valid id" do + gfm(actual).should match(expected) + end + + it "should link with adjacent text" do + # Wrap the reference in parenthesis + gfm(actual.gsub(reference, "(#{reference})")).should match(expected) + + # Append some text to the end of the reference + gfm(actual.gsub(reference, "#{reference}, right?")).should match(expected) + end + + it "should keep whitespace intact" do + actual = "Referenced #{reference} already." + expected = /Referenced [^\s]+<\/a> already/ + gfm(actual).should match(expected) + end + + it "should not link with an invalid id" do + # Modify the reference string so it's still parsed, but is invalid + invalid_reference = actual.gsub(/(\d+)$/, "r45") + gfm(invalid_reference).should == invalid_reference + end + + it "should include a title attribute" do + title = "Issue in JIRA tracker" + gfm(actual).should match(/title="#{title}"/) + end + + it "should include standard gfm classes" do + gfm(actual).should match(/class="\s?gfm gfm-issue\s?"/) + end + end + describe "referencing a merge request" do let(:object) { merge_request } let(:reference) { "!#{merge_request.iid}" } @@ -347,8 +394,21 @@ describe GitlabMarkdownHelper do it "should handle references in headers" do actual = "\n# Working around ##{issue.iid}\n## Apply !#{merge_request.iid}" - markdown(actual).should match(%r{Working around ##{issue.iid}}) - markdown(actual).should match(%r{Apply !#{merge_request.iid}}) + markdown(actual, {no_header_anchors:true}).should match(%r{Working around ##{issue.iid}}) + markdown(actual, {no_header_anchors:true}).should match(%r{Apply !#{merge_request.iid}}) + end + + it "should add ids and links to headers" do + # Test every rule except nested tags. + text = '..Ab_c-d. e..' + id = 'ab_c-d-e' + markdown("# #{text}").should match(%r{

    #{text}

    }) + markdown("# #{text}", {no_header_anchors:true}).should == "

    #{text}

    " + + id = 'link-text' + markdown("# [link text](url) ![img alt](url)").should match( + %r{

    link text ]*>

    } + ) end it "should handle references in lists" do @@ -378,9 +438,10 @@ describe GitlabMarkdownHelper do it "should leave code blocks untouched" do helper.stub(:user_color_scheme_class).and_return(:white) - helper.markdown("\n some code from $#{snippet.id}\n here too\n").should include("
    some code from $#{snippet.id}\nhere too\n
    ") + target_html = "\n
    \n
    \n
    some code from $#{snippet.id}\nhere too\n
    \n
    \n
    \n\n" - helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should include("
    some code from $#{snippet.id}\nhere too\n
    ") + helper.markdown("\n some code from $#{snippet.id}\n here too\n").should == target_html + helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should == target_html end it "should leave inline code untouched" do @@ -392,7 +453,7 @@ describe GitlabMarkdownHelper do end it "should leave ref-like href of 'manual' links untouched" do - markdown("why not [inspect !#{merge_request.iid}](http://example.tld/#!#{merge_request.iid})").should == "

    why not inspect !#{merge_request.iid}

    \n" + markdown("why not [inspect !#{merge_request.iid}](http://example.tld/#!#{merge_request.iid})").should == "

    why not inspect !#{merge_request.iid}

    \n" end it "should leave ref-like src of images untouched" do @@ -425,16 +486,28 @@ describe GitlabMarkdownHelper do markdown(actual).should match(expected) end - it "should handle wiki urls" do - actual = "[Link](test/link)\n" - expected = "

    Link

    \n" + it "should handle relative urls in reference links for a file in master" do + actual = "[GitLab API doc][GitLab readme]\n [GitLab readme]: doc/api/README.md\n" + expected = "

    GitLab API doc

    \n" + markdown(actual).should match(expected) + end + + it "should handle relative urls in reference links for a directory in master" do + actual = "[GitLab API doc directory][GitLab readmes]\n [GitLab readmes]: doc/api/\n" + expected = "

    GitLab API doc directory

    \n" + markdown(actual).should match(expected) + end + + it "should not handle malformed relative urls in reference links for a file in master" do + actual = "[GitLab readme]: doc/api/README.md\n" + expected = "" markdown(actual).should match(expected) end end describe "#render_wiki_content" do before do - @wiki = stub('WikiPage') + @wiki = double('WikiPage') @wiki.stub(:content).and_return('wiki content') end @@ -448,7 +521,7 @@ describe GitlabMarkdownHelper do it "should use the Gollum renderer for all other file types" do @wiki.stub(:format).and_return(:rdoc) - formatted_content_stub = stub('formatted_content') + formatted_content_stub = double('formatted_content') formatted_content_stub.should_receive(:html_safe) @wiki.stub(:formatted_content).and_return(formatted_content_stub) diff --git a/spec/helpers/labels_helper_spec.rb b/spec/helpers/labels_helper_spec.rb new file mode 100644 index 0000000000..f66a5cc9f5 --- /dev/null +++ b/spec/helpers/labels_helper_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +describe LabelsHelper do + describe '#label_css_class' do + it 'returns label-danger when given Bug as param' do + expect(label_css_class('bug')).to eq('label-danger') + end + + it 'returns label-danger when given Bug as param' do + expect(label_css_class('Bug')).to eq('label-danger') + end + end +end diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 328f66237c..dce28525ca 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -2,13 +2,13 @@ require 'spec_helper' describe NotificationsHelper do describe 'notification_icon' do - let(:notification) { stub(disabled?: false, participating?: false, watch?: false) } + let(:notification) { double(disabled?: false, participating?: false, watch?: false) } context "disabled notification" do before { notification.stub(disabled?: true) } it "has a red icon" do - notification_icon(notification).should match('class="icon-circle cred"') + notification_icon(notification).should match('class="icon-volume-off cred"') end end @@ -16,7 +16,7 @@ describe NotificationsHelper do before { notification.stub(participating?: true) } it "has a blue icon" do - notification_icon(notification).should match('class="icon-circle cblue"') + notification_icon(notification).should match('class="icon-volume-down cblue"') end end @@ -24,7 +24,7 @@ describe NotificationsHelper do before { notification.stub(watch?: true) } it "has a green icon" do - notification_icon(notification).should match('class="icon-circle cgreen"') + notification_icon(notification).should match('class="icon-volume-up cgreen"') end end diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index 62f88dd522..114058e309 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -7,5 +7,17 @@ describe ProjectsHelper do "\n" \ "" end + + it "returns the correct issues trackers available with current tracker 'gitlab' selected" do + project_issues_trackers('gitlab').should == + "\n" \ + "" + end + + it "returns the correct issues trackers available with current tracker 'redmine' selected" do + project_issues_trackers('redmine').should == + "\n" \ + "" + end end end diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb index 55b6b6b4da..733f275472 100644 --- a/spec/helpers/search_helper_spec.rb +++ b/spec/helpers/search_helper_spec.rb @@ -8,55 +8,46 @@ describe SearchHelper do describe 'search_autocomplete_source' do context "with no current user" do - before { stub!(:current_user).and_return(nil) } + before do + allow(self).to receive(:current_user).and_return(nil) + end it "it returns nil" do - search_autocomplete_source.should be_nil + search_autocomplete_opts("q").should be_nil end end context "with a user" do let(:user) { create(:user) } - let(:result) { JSON.parse(search_autocomplete_source) } before do - stub!(:current_user).and_return(user) + allow(self).to receive(:current_user).and_return(user) end it "includes Help sections" do - result.select { |h| h['label'] =~ /^help:/ }.length.should == 9 + search_autocomplete_opts("hel").size.should == 9 end it "includes default sections" do - result.count { |h| h['label'] =~ /^(My|Admin)\s/ }.should == 4 + search_autocomplete_opts("adm").size.should == 1 end it "includes the user's groups" do create(:group).add_owner(user) - result.count { |h| h['label'] =~ /^group:/ }.should == 1 + search_autocomplete_opts("gro").size.should == 1 end it "includes the user's projects" do - create(:project, namespace: create(:namespace, owner: user)) - result.count { |h| h['label'] =~ /^project:/ }.should == 1 + project = create(:project, namespace: create(:namespace, owner: user)) + search_autocomplete_opts(project.name).size.should == 1 end context "with a current project" do - before { @project = create(:project_with_code) } + before { @project = create(:project) } it "includes project-specific sections" do - result.count { |h| h['label'] =~ /^#{@project.name_with_namespace} - / }.should == 11 - end - - it "uses @ref in urls if defined" do - @ref = "foo_bar" - result.count { |h| h['url'] == project_tree_path(@project, @ref) }.should == 1 - end - end - - context "with no current project" do - it "does not include project-specific sections" do - result.count { |h| h['label'] =~ /Files$/ }.should == 0 + search_autocomplete_opts("Files").size.should == 1 + search_autocomplete_opts("Commits").size.should == 1 end end end diff --git a/spec/helpers/submodule_helper_spec.rb b/spec/helpers/submodule_helper_spec.rb new file mode 100644 index 0000000000..20378b1b17 --- /dev/null +++ b/spec/helpers/submodule_helper_spec.rb @@ -0,0 +1,118 @@ +require 'spec_helper' + +describe SubmoduleHelper do + describe 'submodule links' do + let(:submodule_item) { double(id: 'hash', path: 'rack') } + let(:config) { Gitlab.config.gitlab } + let(:repo) { double() } + + before do + self.instance_variable_set(:@repository, repo) + end + + context 'submodule on self' do + before do + Gitlab.config.gitlab.stub(protocol: 'http') # set this just to be sure + end + + it 'should detect ssh on standard port' do + Gitlab.config.gitlab.stub(ssh_port: 22) # set this just to be sure + stub_url([ config.user, '@', config.host, ':gitlab-org/gitlab-ce.git' ].join('')) + submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ] + end + + it 'should detect ssh on non-standard port' do + Gitlab.config.gitlab_shell.stub(ssh_port: 2222) + Gitlab.config.gitlab_shell.stub(ssh_path_prefix: Settings.send(:build_gitlab_shell_ssh_path_prefix)) + stub_url([ 'ssh://', config.user, '@', config.host, ':2222/gitlab-org/gitlab-ce.git' ].join('')) + submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ] + end + + it 'should detect http on standard port' do + Gitlab.config.gitlab.stub(port: 80) + Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url)) + stub_url([ 'http://', config.host, '/gitlab-org/gitlab-ce.git' ].join('')) + submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ] + end + + it 'should detect http on non-standard port' do + Gitlab.config.gitlab.stub(port: 3000) + Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url)) + stub_url([ 'http://', config.host, ':3000/gitlab-org/gitlab-ce.git' ].join('')) + submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ] + end + + it 'should work with relative_url_root' do + Gitlab.config.gitlab.stub(port: 80) # set this just to be sure + Gitlab.config.gitlab.stub(relative_url_root: '/gitlab/root') + Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url)) + stub_url([ 'http://', config.host, '/gitlab/root/gitlab-org/gitlab-ce.git' ].join('')) + submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ] + end + end + + context 'submodule on github.com' do + it 'should detect ssh' do + stub_url('git@github.com:gitlab-org/gitlab-ce.git') + submodule_links(submodule_item).should == [ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ] + end + + it 'should detect http' do + stub_url('http://github.com/gitlab-org/gitlab-ce.git') + submodule_links(submodule_item).should == [ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ] + end + + it 'should detect https' do + stub_url('https://github.com/gitlab-org/gitlab-ce.git') + submodule_links(submodule_item).should == [ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ] + end + + it 'should return original with non-standard url' do + stub_url('http://github.com/gitlab-org/gitlab-ce') + submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ] + + stub_url('http://github.com/another/gitlab-org/gitlab-ce.git') + submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ] + end + end + + context 'submodule on gitlab.com' do + it 'should detect ssh' do + stub_url('git@gitlab.com:gitlab-org/gitlab-ce.git') + submodule_links(submodule_item).should == [ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ] + end + + it 'should detect http' do + stub_url('http://gitlab.com/gitlab-org/gitlab-ce.git') + submodule_links(submodule_item).should == [ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ] + end + + it 'should detect https' do + stub_url('https://gitlab.com/gitlab-org/gitlab-ce.git') + submodule_links(submodule_item).should == [ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ] + end + + it 'should return original with non-standard url' do + stub_url('http://gitlab.com/gitlab-org/gitlab-ce') + submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ] + + stub_url('http://gitlab.com/another/gitlab-org/gitlab-ce.git') + submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ] + end + end + + context 'submodule on unsupported' do + it 'should return original' do + stub_url('http://mygitserver.com/gitlab-org/gitlab-ce') + submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ] + + stub_url('http://mygitserver.com/gitlab-org/gitlab-ce.git') + submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ] + end + end + end + + def stub_url(url) + repo.stub(submodule_url_for: url) + end +end diff --git a/spec/helpers/tab_helper_spec.rb b/spec/helpers/tab_helper_spec.rb index ef8e4cf637..fa8a3f554f 100644 --- a/spec/helpers/tab_helper_spec.rb +++ b/spec/helpers/tab_helper_spec.rb @@ -5,8 +5,8 @@ describe TabHelper do describe 'nav_link' do before do - controller.stub!(:controller_name).and_return('foo') - stub!(:action_name).and_return('foo') + controller.stub(:controller_name).and_return('foo') + allow(self).to receive(:action_name).and_return('foo') end it "captures block output" do diff --git a/spec/javascripts/stat_graph_contributors_graph_spec.js b/spec/javascripts/stat_graph_contributors_graph_spec.js index 8d2e2038a5..1090cb7f62 100644 --- a/spec/javascripts/stat_graph_contributors_graph_spec.js +++ b/spec/javascripts/stat_graph_contributors_graph_spec.js @@ -88,19 +88,20 @@ describe("ContributorsGraph", function () { describe("ContributorsMasterGraph", function () { - describe("#process_dates", function () { - it("gets and parses dates", function () { - var graph = new ContributorsMasterGraph() - var data = 'random data here' - spyOn(graph, 'parse_dates') - spyOn(graph, 'get_dates').andReturn("get") - spyOn(ContributorsGraph,'set_dates').andCallThrough() - graph.process_dates(data) - expect(graph.parse_dates).toHaveBeenCalledWith(data) - expect(graph.get_dates).toHaveBeenCalledWith(data) - expect(ContributorsGraph.set_dates).toHaveBeenCalledWith("get") - }) - }) + // TODO: fix or remove + //describe("#process_dates", function () { + //it("gets and parses dates", function () { + //var graph = new ContributorsMasterGraph() + //var data = 'random data here' + //spyOn(graph, 'parse_dates') + //spyOn(graph, 'get_dates').andReturn("get") + //spyOn(ContributorsGraph,'set_dates').andCallThrough() + //graph.process_dates(data) + //expect(graph.parse_dates).toHaveBeenCalledWith(data) + //expect(graph.get_dates).toHaveBeenCalledWith(data) + //expect(ContributorsGraph.set_dates).toHaveBeenCalledWith("get") + //}) + //}) describe("#get_dates", function () { it("plucks the date field from data collection", function () { diff --git a/spec/javascripts/stat_graph_contributors_util_spec.js b/spec/javascripts/stat_graph_contributors_util_spec.js index 2e52479ccb..9c1b588861 100644 --- a/spec/javascripts/stat_graph_contributors_util_spec.js +++ b/spec/javascripts/stat_graph_contributors_util_spec.js @@ -54,16 +54,17 @@ describe("ContributorsStatGraphUtil", function () { }) - describe("#store_commits", function () { - var fake_total = "fake_total" - var fake_by_author = "fake_by_author" + // TODO: fix or remove + //describe("#store_commits", function () { + //var fake_total = "fake_total" + //var fake_by_author = "fake_by_author" - it("calls #add twice with arguments fake_total and fake_by_author respectively", function () { - spyOn(ContributorsStatGraphUtil, 'add') - ContributorsStatGraphUtil.store_commits(fake_total, fake_by_author) - expect(ContributorsStatGraphUtil.add.argsForCall).toEqual([["fake_total", "commits", 1], ["fake_by_author", "commits", 1]]) - }) - }) + //it("calls #add twice with arguments fake_total and fake_by_author respectively", function () { + //spyOn(ContributorsStatGraphUtil, 'add') + //ContributorsStatGraphUtil.store_commits(fake_total, fake_by_author) + //expect(ContributorsStatGraphUtil.add.argsForCall).toEqual([["fake_total", "commits", 1], ["fake_by_author", "commits", 1]]) + //}) + //}) describe("#add", function () { it("adds 1 to current test_field in collection", function () { @@ -79,27 +80,29 @@ describe("ContributorsStatGraphUtil", function () { }) }) - describe("#store_additions", function () { - var fake_entry = {additions: 10} - var fake_total= "fake_total" - var fake_by_author = "fake_by_author" - it("calls #add twice with arguments fake_total and fake_by_author respectively", function () { - spyOn(ContributorsStatGraphUtil, 'add') - ContributorsStatGraphUtil.store_additions(fake_entry, fake_total, fake_by_author) - expect(ContributorsStatGraphUtil.add.argsForCall).toEqual([["fake_total", "additions", 10], ["fake_by_author", "additions", 10]]) - }) - }) + // TODO: fix or remove + //describe("#store_additions", function () { + //var fake_entry = {additions: 10} + //var fake_total= "fake_total" + //var fake_by_author = "fake_by_author" + //it("calls #add twice with arguments fake_total and fake_by_author respectively", function () { + //spyOn(ContributorsStatGraphUtil, 'add') + //ContributorsStatGraphUtil.store_additions(fake_entry, fake_total, fake_by_author) + //expect(ContributorsStatGraphUtil.add.argsForCall).toEqual([["fake_total", "additions", 10], ["fake_by_author", "additions", 10]]) + //}) + //}) - describe("#store_deletions", function () { - var fake_entry = {deletions: 10} - var fake_total= "fake_total" - var fake_by_author = "fake_by_author" - it("calls #add twice with arguments fake_total and fake_by_author respectively", function () { - spyOn(ContributorsStatGraphUtil, 'add') - ContributorsStatGraphUtil.store_deletions(fake_entry, fake_total, fake_by_author) - expect(ContributorsStatGraphUtil.add.argsForCall).toEqual([["fake_total", "deletions", 10], ["fake_by_author", "deletions", 10]]) - }) - }) + // TODO: fix or remove + //describe("#store_deletions", function () { + //var fake_entry = {deletions: 10} + //var fake_total= "fake_total" + //var fake_by_author = "fake_by_author" + //it("calls #add twice with arguments fake_total and fake_by_author respectively", function () { + //spyOn(ContributorsStatGraphUtil, 'add') + //ContributorsStatGraphUtil.store_deletions(fake_entry, fake_total, fake_by_author) + //expect(ContributorsStatGraphUtil.add.argsForCall).toEqual([["fake_total", "deletions", 10], ["fake_by_author", "deletions", 10]]) + //}) + //}) describe("#add_date", function () { it("adds a date field to the collection", function () { diff --git a/spec/javascripts/support/jasmine_helper.rb b/spec/javascripts/support/jasmine_helper.rb index 34b418a9ca..b4919802af 100644 --- a/spec/javascripts/support/jasmine_helper.rb +++ b/spec/javascripts/support/jasmine_helper.rb @@ -1,5 +1,11 @@ -WebMock.allow_net_connect! +#Use this file to set/override Jasmine configuration options +#You can remove it if you don't need it. +#This file is loaded *after* jasmine.yml is interpreted. +# +#Example: using a different boot file. +#Jasmine.configure do |config| +# config.boot_dir = '/absolute/path/to/boot_dir' +# config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] } +#end +# -Jasmine.configure do |config| - config.browser = :phantomjs -end diff --git a/spec/lib/auth_spec.rb b/spec/lib/auth_spec.rb index e05fde9573..073b811c3f 100644 --- a/spec/lib/auth_spec.rb +++ b/spec/lib/auth_spec.rb @@ -8,21 +8,21 @@ describe Gitlab::Auth do @user = create( :user, username: 'john', - password: '888777', - password_confirmation: '888777' + password: '88877711', + password_confirmation: '88877711' ) end it "should find user by valid login/password" do - gl_auth.find('john', '888777').should == @user + gl_auth.find('john', '88877711').should == @user end it "should not find user with invalid password" do - gl_auth.find('john', 'invalid').should_not == @user + gl_auth.find('john', 'invalid11').should_not == @user end it "should not find user with invalid login and password" do - gl_auth.find('jon', 'invalid').should_not == @user + gl_auth.find('jon', 'invalid11').should_not == @user end end end diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index aac72c63ea..7b3818ea5c 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -7,7 +7,7 @@ describe ExtractsPath do before do @project = project - project.stub(repository: stub(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0'])) + project.stub(repository: double(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0'])) project.stub(path_with_namespace: 'gitlab/gitlab-ci') end diff --git a/spec/lib/gitlab/ldap/ldap_access_spec.rb b/spec/lib/gitlab/ldap/ldap_access_spec.rb new file mode 100644 index 0000000000..d8c107502b --- /dev/null +++ b/spec/lib/gitlab/ldap/ldap_access_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe Gitlab::LDAP::Access do + let(:access) { Gitlab::LDAP::Access.new } + let(:user) { create(:user) } + + describe :allowed? do + subject { access.allowed?(user) } + + context 'when the user cannot be found' do + before { Gitlab::LDAP::Person.stub(find_by_dn: nil) } + + it { should be_false } + end + + context 'when the user is found' do + before { Gitlab::LDAP::Person.stub(find_by_dn: :ldap_user) } + + context 'and the Active Directory disabled flag is set' do + before { Gitlab::LDAP::Person.stub(active_directory_disabled?: true) } + + it { should be_false } + end + + context 'and the Active Directory disabled flag is not set' do + before { Gitlab::LDAP::Person.stub(active_directory_disabled?: false) } + + it { should be_true } + end + end + end +end diff --git a/spec/lib/gitlab/ldap/ldap_adapter_spec.rb b/spec/lib/gitlab/ldap/ldap_adapter_spec.rb new file mode 100644 index 0000000000..c3f0733443 --- /dev/null +++ b/spec/lib/gitlab/ldap/ldap_adapter_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe Gitlab::LDAP::Adapter do + let(:adapter) { Gitlab::LDAP::Adapter.new } + + describe :dn_matches_filter? do + let(:ldap) { double(:ldap) } + subject { adapter.dn_matches_filter?(:dn, :filter) } + before { adapter.stub(ldap: ldap) } + + context "when the search is successful" do + context "and the result is non-empty" do + before { ldap.stub(search: [:foo]) } + + it { should be_true } + end + + context "and the result is empty" do + before { ldap.stub(search: []) } + + it { should be_false } + end + end + + context "when the search encounters an error" do + before { ldap.stub(search: nil, get_operation_result: double(code: 1, message: 'some error')) } + + it { should be_false } + end + end +end diff --git a/spec/lib/gitlab/ldap/ldap_user_auth_spec.rb b/spec/lib/gitlab/ldap/ldap_user_auth_spec.rb index b1c583c047..501642dca7 100644 --- a/spec/lib/gitlab/ldap/ldap_user_auth_spec.rb +++ b/spec/lib/gitlab/ldap/ldap_user_auth_spec.rb @@ -6,16 +6,17 @@ describe Gitlab::LDAP do before do Gitlab.config.stub(omniauth: {}) - @info = mock( + @info = double( uid: '12djsak321', name: 'John', - email: 'john@mail.com' + email: 'john@mail.com', + nickname: 'john' ) end describe :find_for_ldap_auth do before do - @auth = mock( + @auth = double( uid: '12djsak321', info: @info, provider: 'ldap' @@ -25,7 +26,7 @@ describe Gitlab::LDAP do it "should update credentials by email if missing uid" do user = double('User') User.stub find_by_extern_uid_and_provider: nil - User.stub find_by_email: user + User.stub(:find_by).with(hash_including(email: anything())) { user } user.should_receive :update_attributes gl_auth.find_or_create(@auth) end @@ -35,8 +36,8 @@ describe Gitlab::LDAP do value = Gitlab.config.ldap.allow_username_or_email_login Gitlab.config.ldap['allow_username_or_email_login'] = true User.stub find_by_extern_uid_and_provider: nil - User.stub find_by_email: nil - User.stub find_by_username: user + User.stub(:find_by).with(hash_including(email: anything())) { nil } + User.stub(:find_by).with(hash_including(username: anything())) { user } user.should_receive :update_attributes gl_auth.find_or_create(@auth) Gitlab.config.ldap['allow_username_or_email_login'] = value @@ -47,8 +48,8 @@ describe Gitlab::LDAP do value = Gitlab.config.ldap.allow_username_or_email_login Gitlab.config.ldap['allow_username_or_email_login'] = false User.stub find_by_extern_uid_and_provider: nil - User.stub find_by_email: nil - User.stub find_by_username: user + User.stub(:find_by).with(hash_including(email: anything())) { nil } + User.stub(:find_by).with(hash_including(username: anything())) { user } user.should_not_receive :update_attributes gl_auth.find_or_create(@auth) Gitlab.config.ldap['allow_username_or_email_login'] = value diff --git a/spec/lib/gitlab/popen_spec.rb b/spec/lib/gitlab/popen_spec.rb index 4791be4161..76d506eb3c 100644 --- a/spec/lib/gitlab/popen_spec.rb +++ b/spec/lib/gitlab/popen_spec.rb @@ -10,7 +10,7 @@ describe 'Gitlab::Popen', no_db: true do context 'zero status' do before do - @output, @status = @klass.new.popen('ls', path) + @output, @status = @klass.new.popen(%W(ls), path) end it { @status.should be_zero } @@ -19,11 +19,27 @@ describe 'Gitlab::Popen', no_db: true do context 'non-zero status' do before do - @output, @status = @klass.new.popen('cat NOTHING', path) + @output, @status = @klass.new.popen(%W(cat NOTHING), path) end it { @status.should == 1 } it { @output.should include('No such file or directory') } end + + context 'unsafe string command' do + it 'raises an error when it gets called with a string argument' do + expect { @klass.new.popen('ls', path) }.to raise_error + end + end + + context 'without a directory argument' do + before do + @output, @status = @klass.new.popen(%W(ls)) + end + + it { @status.should be_zero } + it { @output.should include('spec') } + end + end diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb index 7d805f8c72..99fed27c79 100644 --- a/spec/lib/gitlab/reference_extractor_spec.rb +++ b/spec/lib/gitlab/reference_extractor_spec.rb @@ -11,6 +11,12 @@ describe Gitlab::ReferenceExtractor do subject.issues.should == ["1234"] end + it 'extracts JIRA issue references' do + Gitlab.config.gitlab.stub(:issues_tracker).and_return("jira") + subject.analyze "this one talks about issue JIRA-1234" + subject.issues.should == ["JIRA-1234"] + end + it 'extracts merge request references' do subject.analyze "and here's !43, a merge request" subject.merge_requests.should == ["43"] @@ -43,7 +49,7 @@ describe Gitlab::ReferenceExtractor do end context 'with a project' do - let(:project) { create(:project_with_code) } + let(:project) { create(:project) } it 'accesses valid user objects on the project team' do @u_foo = create(:user, username: 'foo') diff --git a/spec/lib/gitlab/satellite/action_spec.rb b/spec/lib/gitlab/satellite/action_spec.rb index 5e0a825c3c..d65e7c42b7 100644 --- a/spec/lib/gitlab/satellite/action_spec.rb +++ b/spec/lib/gitlab/satellite/action_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'Gitlab::Satellite::Action' do - let(:project) { create(:project_with_code) } + let(:project) { create(:project) } let(:user) { create(:user) } describe '#prepare_satellite!' do diff --git a/spec/lib/gitlab/satellite/merge_action_spec.rb b/spec/lib/gitlab/satellite/merge_action_spec.rb index e40ff73b7f..41d3321b17 100644 --- a/spec/lib/gitlab/satellite/merge_action_spec.rb +++ b/spec/lib/gitlab/satellite/merge_action_spec.rb @@ -2,20 +2,21 @@ require 'spec_helper' describe 'Gitlab::Satellite::MergeAction' do before(:each) do -# TestEnv.init(mailer: false, init_repos: true, repos: true) - @master = ['master', 'b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828'] + @master = ['master', '69b34b7e9ad9f496f0ad10250be37d6265a03bba'] @one_after_stable = ['stable', '6ea87c47f0f8a24ae031c3fff17bc913889ecd00'] #this commit sha is one after stable @wiki_branch = ['wiki', '635d3e09b72232b6e92a38de6cc184147e5bcb41'] #this is the commit sha where the wiki branch goes off from master @conflicting_metior = ['metior', '313d96e42b313a0af5ab50fa233bf43e27118b3f'] #this branch conflicts with the wiki branch - #these commits are quite close together, itended to make string diffs/format patches small + # these commits are quite close together, itended to make string diffs/format patches small @close_commit1 = ['2_3_notes_fix', '8470d70da67355c9c009e4401746b1d5410af2e3'] @close_commit2 = ['scss_refactoring', 'f0f14c8eaba69ebddd766498a9d0b0e79becd633'] end - let(:project) { create(:project_with_code) } + let(:project) { create(:project, namespace: create(:group)) } + let(:fork_project) { create(:project, namespace: create(:group), forked_from_project: project) } let(:merge_request) { create(:merge_request, source_project: project, target_project: project) } - let(:merge_request_fork) { create(:merge_request) } + let(:merge_request_fork) { create(:merge_request, source_project: fork_project, target_project: project) } + describe '#commits_between' do def verify_commits(commits, first_commit_sha, last_commit_sha) commits.each { |commit| commit.class.should == Gitlab::Git::Commit } @@ -145,4 +146,4 @@ describe 'Gitlab::Satellite::MergeAction' do end end end -end \ No newline at end of file +end diff --git a/spec/lib/gitlab/upgrader_spec.rb b/spec/lib/gitlab/upgrader_spec.rb new file mode 100644 index 0000000000..2b254d6b3a --- /dev/null +++ b/spec/lib/gitlab/upgrader_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +describe Gitlab::Upgrader do + let(:upgrader) { Gitlab::Upgrader.new } + let(:current_version) { Gitlab::VERSION } + + describe 'current_version_raw' do + it { upgrader.current_version_raw.should == current_version } + end + + describe 'latest_version?' do + it 'should be true if newest version' do + upgrader.stub(latest_version_raw: current_version) + upgrader.latest_version?.should be_true + end + end + + describe 'latest_version_raw' do + it 'should be latest version for GitLab 5' do + upgrader.stub(current_version_raw: "5.3.0") + upgrader.latest_version_raw.should == "v5.4.2" + end + end +end diff --git a/spec/lib/oauth_spec.rb b/spec/lib/oauth_spec.rb index e21074554b..2f15b5e034 100644 --- a/spec/lib/oauth_spec.rb +++ b/spec/lib/oauth_spec.rb @@ -6,8 +6,9 @@ describe Gitlab::OAuth::User do before do Gitlab.config.stub(omniauth: {}) - @info = mock( + @info = double( uid: '12djsak321', + nickname: 'john', name: 'John', email: 'john@mail.com' ) @@ -15,7 +16,7 @@ describe Gitlab::OAuth::User do describe :create do it "should create user from LDAP" do - @auth = mock(info: @info, provider: 'ldap') + @auth = double(info: @info, provider: 'ldap') user = gl_auth.create(@auth) user.should be_valid @@ -24,7 +25,7 @@ describe Gitlab::OAuth::User do end it "should create user from Omniauth" do - @auth = mock(info: @info, provider: 'twitter') + @auth = double(info: @info, provider: 'twitter') user = gl_auth.create(@auth) user.should be_valid @@ -33,7 +34,7 @@ describe Gitlab::OAuth::User do end it "should apply defaults to user" do - @auth = mock(info: @info, provider: 'ldap') + @auth = double(info: @info, provider: 'ldap') user = gl_auth.create(@auth) user.should be_valid diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 666c6cceff..547268d44f 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -4,8 +4,9 @@ describe Notify do include EmailSpec::Helpers include EmailSpec::Matchers + let(:gitlab_sender) { Gitlab.config.gitlab.email_from } let(:recipient) { create(:user, email: 'recipient@example.com') } - let(:project) { create(:project_with_code) } + let(:project) { create(:project) } shared_examples 'a multiple recipients email' do it 'is sent to the given recipient' do @@ -13,18 +14,28 @@ describe Notify do end end + shared_examples 'an email sent from GitLab' do + it 'is sent from GitLab' do + sender = subject.header[:from].addrs[0] + sender.display_name.should eq('GitLab') + sender.address.should eq(gitlab_sender) + end + end + describe 'for new users, the email' do let(:example_site_path) { root_path } let(:new_user) { create(:user, email: 'newguy@example.com', created_by_id: 1) } subject { Notify.new_user_email(new_user.id, new_user.password) } + it_behaves_like 'an email sent from GitLab' + it 'is sent to the new user' do should deliver_to new_user.email end it 'has the correct subject' do - should have_subject /^gitlab \| Account was created for you$/i + should have_subject /^Account was created for you$/i end it 'contains the new user\'s login name' do @@ -47,12 +58,14 @@ describe Notify do subject { Notify.new_user_email(new_user.id, new_user.password) } + it_behaves_like 'an email sent from GitLab' + it 'is sent to the new user' do should deliver_to new_user.email end it 'has the correct subject' do - should have_subject /^gitlab \| Account was created for you$/i + should have_subject /^Account was created for you$/i end it 'contains the new user\'s login name' do @@ -73,12 +86,14 @@ describe Notify do subject { Notify.new_ssh_key_email(key.id) } + it_behaves_like 'an email sent from GitLab' + it 'is sent to the new user' do should deliver_to key.user.email end it 'has the correct subject' do - should have_subject /^gitlab \| SSH key was added to your account$/i + should have_subject /^SSH key was added to your account$/i end it 'contains the new ssh key title' do @@ -90,19 +105,49 @@ describe Notify do end end + describe 'user added email' do + let(:email) { create(:email) } + + subject { Notify.new_email_email(email.id) } + + it 'is sent to the new user' do + should deliver_to email.user.email + end + + it 'has the correct subject' do + should have_subject /^Email was added to your account$/i + end + + it 'contains the new email address' do + should have_body_text /#{email.email}/ + end + + it 'includes a link to emails page' do + should have_body_text /#{profile_emails_path}/ + end + end + context 'for a project' do describe 'items that are assignable, the email' do + let(:current_user) { create(:user, email: "current@email.com") } let(:assignee) { create(:user, email: 'assignee@example.com') } let(:previous_assignee) { create(:user, name: 'Previous Assignee') } shared_examples 'an assignee email' do + it 'is sent as the author' do + sender = subject.header[:from].addrs[0] + sender.display_name.should eq(current_user.name) + sender.address.should eq(gitlab_sender) + end + it 'is sent to the assignee' do should deliver_to assignee.email end end context 'for issues' do - let(:issue) { create(:issue, assignee: assignee, project: project ) } + let(:issue) { create(:issue, author: current_user, assignee: assignee, project: project) } + let(:issue_with_description) { create(:issue, author: current_user, assignee: assignee, project: project, description: Faker::Lorem.sentence) } describe 'that are new' do subject { Notify.new_issue_email(issue.assignee_id, issue.id) } @@ -110,23 +155,39 @@ describe Notify do it_behaves_like 'an assignee email' it 'has the correct subject' do - should have_subject /#{project.name} \| new issue ##{issue.iid} \| #{issue.title}/ + should have_subject /#{project.name} \| #{issue.title} \(##{issue.iid}\)/ end it 'contains a link to the new issue' do should have_body_text /#{project_issue_path project, issue}/ end + + it 'has the correct message-id set' do + should have_header 'Message-ID', "" + end + end + + describe 'that are new with a description' do + subject { Notify.new_issue_email(issue_with_description.assignee_id, issue_with_description.id) } + + it 'contains the description' do + should have_body_text /#{issue_with_description.description}/ + end end describe 'that have been reassigned' do - before(:each) { issue.stub(:assignee_id_was).and_return(previous_assignee.id) } - - subject { Notify.reassigned_issue_email(recipient.id, issue.id, previous_assignee.id) } + subject { Notify.reassigned_issue_email(recipient.id, issue.id, previous_assignee.id, current_user) } it_behaves_like 'a multiple recipients email' + it 'is sent as the author' do + sender = subject.header[:from].addrs[0] + sender.display_name.should eq(current_user.name) + sender.address.should eq(gitlab_sender) + end + it 'has the correct subject' do - should have_subject /changed issue ##{issue.iid} \| #{issue.title}/ + should have_subject /#{issue.title} \(##{issue.iid}\)/ end it 'contains the name of the previous assignee' do @@ -140,15 +201,24 @@ describe Notify do it 'contains a link to the issue' do should have_body_text /#{project_issue_path project, issue}/ end + + it 'has the correct reference set' do + should have_header 'References', "" + end end describe 'status changed' do - let(:current_user) { create(:user, email: "current@email.com") } let(:status) { 'closed' } subject { Notify.issue_status_changed_email(recipient.id, issue.id, status, current_user) } + it 'is sent as the author' do + sender = subject.header[:from].addrs[0] + sender.display_name.should eq(current_user.name) + sender.address.should eq(gitlab_sender) + end + it 'has the correct subject' do - should have_subject /changed issue ##{issue.iid} \| #{issue.title}/i + should have_subject /#{issue.title} \(##{issue.iid}\)/i end it 'contains the new status' do @@ -162,12 +232,18 @@ describe Notify do it 'contains a link to the issue' do should have_body_text /#{project_issue_path project, issue}/ end + + it 'has the correct reference set' do + should have_header 'References', "" + end end end context 'for merge requests' do - let(:merge_request) { create(:merge_request, assignee: assignee, source_project: project, target_project: project) } + let(:merge_author) { create(:user) } + let(:merge_request) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project) } + let(:merge_request_with_description) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project, description: Faker::Lorem.sentence) } describe 'that are new' do subject { Notify.new_merge_request_email(merge_request.assignee_id, merge_request.id) } @@ -175,7 +251,7 @@ describe Notify do it_behaves_like 'an assignee email' it 'has the correct subject' do - should have_subject /new merge request !#{merge_request.iid}/ + should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/ end it 'contains a link to the new merge request' do @@ -189,17 +265,33 @@ describe Notify do it 'contains the target branch for the merge request' do should have_body_text /#{merge_request.target_branch}/ end + + it 'has the correct message-id set' do + should have_header 'Message-ID', "" + end + end + + describe 'that are new with a description' do + subject { Notify.new_merge_request_email(merge_request_with_description.assignee_id, merge_request_with_description.id) } + + it 'contains the description' do + should have_body_text /#{merge_request_with_description.description}/ + end end describe 'that are reassigned' do - before(:each) { merge_request.stub(:assignee_id_was).and_return(previous_assignee.id) } - - subject { Notify.reassigned_merge_request_email(recipient.id, merge_request.id, previous_assignee.id) } + subject { Notify.reassigned_merge_request_email(recipient.id, merge_request.id, previous_assignee.id, current_user.id) } it_behaves_like 'a multiple recipients email' + it 'is sent as the author' do + sender = subject.header[:from].addrs[0] + sender.display_name.should eq(current_user.name) + sender.address.should eq(gitlab_sender) + end + it 'has the correct subject' do - should have_subject /changed merge request !#{merge_request.iid}/ + should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/ end it 'contains the name of the previous assignee' do @@ -213,7 +305,34 @@ describe Notify do it 'contains a link to the merge request' do should have_body_text /#{project_merge_request_path project, merge_request}/ end + end + describe 'that are merged' do + subject { Notify.merged_merge_request_email(recipient.id, merge_request.id, merge_author.id) } + + it_behaves_like 'a multiple recipients email' + + it 'is sent as the merge author' do + sender = subject.header[:from].addrs[0] + sender.display_name.should eq(merge_author.name) + sender.address.should eq(gitlab_sender) + end + + it 'has the correct subject' do + should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/ + end + + it 'contains the new status' do + should have_body_text /merged/i + end + + it 'contains a link to the merge request' do + should have_body_text /#{project_merge_request_path project, merge_request}/ + end + + it 'has the correct reference set' do + should have_header 'References', "" + end end end end @@ -223,8 +342,10 @@ describe Notify do let(:user) { create(:user) } subject { Notify.project_was_moved_email(project.id, user.id) } + it_behaves_like 'an email sent from GitLab' + it 'has the correct subject' do - should have_subject /project was moved/ + should have_subject /Project was moved/ end it 'contains name of project' do @@ -243,8 +364,11 @@ describe Notify do project: project, user: user) } subject { Notify.project_access_granted_email(users_project.id) } + + it_behaves_like 'an email sent from GitLab' + it 'has the correct subject' do - should have_subject /access to project was granted/ + should have_subject /Access to project was granted/ end it 'contains name of project' do should have_body_text /#{project.name}/ @@ -263,12 +387,14 @@ describe Notify do end shared_examples 'a note email' do - it 'is sent to the given recipient' do - should deliver_to recipient.email + it 'is sent as the author' do + sender = subject.header[:from].addrs[0] + sender.display_name.should eq(note_author.name) + sender.address.should eq(gitlab_sender) end - it 'contains the name of the note\'s author' do - should have_body_text /#{note_author.name}/ + it 'is sent to the given recipient' do + should deliver_to recipient.email end it 'contains the message from the note' do @@ -302,7 +428,7 @@ describe Notify do it_behaves_like 'a note email' it 'has the correct subject' do - should have_subject /note for commit #{commit.short_id}/ + should have_subject /#{commit.title} \(#{commit.short_id}\)/ end it 'contains a link to the commit' do @@ -320,7 +446,7 @@ describe Notify do it_behaves_like 'a note email' it 'has the correct subject' do - should have_subject /note for merge request ##{merge_request.iid}/ + should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/ end it 'contains a link to the merge request note' do @@ -338,7 +464,7 @@ describe Notify do it_behaves_like 'a note email' it 'has the correct subject' do - should have_subject /note for issue ##{issue.iid}/ + should have_subject /#{issue.title} \(##{issue.iid}\)/ end it 'contains a link to the issue note' do @@ -355,8 +481,10 @@ describe Notify do subject { Notify.group_access_granted_email(membership.id) } + it_behaves_like 'an email sent from GitLab' + it 'has the correct subject' do - should have_subject /access to group was granted/ + should have_subject /Access to group was granted/ end it 'contains name of project' do @@ -367,4 +495,102 @@ describe Notify do should have_body_text /#{membership.human_access}/ end end + + describe 'confirmation if email changed' do + let(:example_site_path) { root_path } + let(:user) { create(:user, email: 'old-email@mail.com') } + + before do + user.email = "new-email@mail.com" + user.save + end + + subject { ActionMailer::Base.deliveries.last } + + it_behaves_like 'an email sent from GitLab' + + it 'is sent to the new user' do + should deliver_to 'new-email@mail.com' + end + + it 'has the correct subject' do + should have_subject "Confirmation instructions" + end + + it 'includes a link to the site' do + should have_body_text /#{example_site_path}/ + end + end + + describe 'email on push with multiple commits' do + let(:example_site_path) { root_path } + let(:user) { create(:user) } + let(:compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, 'cd5c4bac', 'b1e6a9db') } + let(:commits) { Commit.decorate(compare.commits) } + let(:diff_path) { project_compare_path(project, from: commits.first, to: commits.last) } + + subject { Notify.repository_push_email(project.id, 'devs@company.name', user.id, 'master', compare) } + + it 'is sent as the author' do + sender = subject.header[:from].addrs[0] + sender.display_name.should eq(user.name) + sender.address.should eq(gitlab_sender) + end + + it 'is sent to recipient' do + should deliver_to 'devs@company.name' + end + + it 'has the correct subject' do + should have_subject /New push to repository/ + end + + it 'includes commits list' do + should have_body_text /tree css fixes/ + end + + it 'includes diffs' do + should have_body_text /Checkout wiki pages for installation information/ + end + + it 'contains a link to the diff' do + should have_body_text /#{diff_path}/ + end + end + + describe 'email on push with a single commit' do + let(:example_site_path) { root_path } + let(:user) { create(:user) } + let(:compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, '8716fc78', 'b1e6a9db') } + let(:commits) { Commit.decorate(compare.commits) } + let(:diff_path) { project_commit_path(project, commits.first) } + + subject { Notify.repository_push_email(project.id, 'devs@company.name', user.id, 'master', compare) } + + it 'is sent as the author' do + sender = subject.header[:from].addrs[0] + sender.display_name.should eq(user.name) + sender.address.should eq(gitlab_sender) + end + + it 'is sent to recipient' do + should deliver_to 'devs@company.name' + end + + it 'has the correct subject' do + should have_subject /New push to repository/ + end + + it 'includes commits list' do + should have_body_text /tree css fixes/ + end + + it 'includes diffs' do + should have_body_text /Checkout wiki pages for installation information/ + end + + it 'contains a link to the diff' do + should have_body_text /#{diff_path}/ + end + end end diff --git a/spec/models/assembla_service_spec.rb b/spec/models/assembla_service_spec.rb new file mode 100644 index 0000000000..acc08fc4d6 --- /dev/null +++ b/spec/models/assembla_service_spec.rb @@ -0,0 +1,53 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# token :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# project_url :string(255) +# subdomain :string(255) +# room :string(255) +# recipients :text +# api_key :string(255) +# + +require 'spec_helper' + +describe AssemblaService, models: true do + describe "Associations" do + it { should belong_to :project } + it { should have_one :service_hook } + end + + describe "Execute" do + let(:user) { create(:user) } + let(:project) { create(:project) } + + before do + @assembla_service = AssemblaService.new + @assembla_service.stub( + project_id: project.id, + project: project, + service_hook: true, + token: 'verySecret', + subdomain: 'project_name' + ) + @sample_data = GitPushService.new.sample_data(project, user) + @api_url = 'https://atlas.assembla.com/spaces/project_name/github_tool?secret_key=verySecret' + WebMock.stub_request(:post, @api_url) + end + + it "should call Assembla API" do + @assembla_service.execute(@sample_data) + WebMock.should have_requested(:post, @api_url).with( + body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/ + ).once + end + end +end diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb new file mode 100644 index 0000000000..0f31c407c9 --- /dev/null +++ b/spec/models/broadcast_message_spec.rb @@ -0,0 +1,39 @@ +# == Schema Information +# +# Table name: broadcast_messages +# +# id :integer not null, primary key +# message :text not null +# starts_at :datetime +# ends_at :datetime +# alert_type :integer +# created_at :datetime +# updated_at :datetime +# color :string(255) +# font :string(255) +# + +require 'spec_helper' + +describe BroadcastMessage do + subject { create(:broadcast_message) } + + it { should be_valid } + + describe :current do + it "should return last message if time match" do + broadcast_message = create(:broadcast_message, starts_at: Time.now.yesterday, ends_at: Time.now.tomorrow) + BroadcastMessage.current.should == broadcast_message + end + + it "should return nil if time not come" do + broadcast_message = create(:broadcast_message, starts_at: Time.now.tomorrow, ends_at: Time.now + 2.days) + BroadcastMessage.current.should be_nil + end + + it "should return nil if time has passed" do + broadcast_message = create(:broadcast_message, starts_at: Time.now - 2.days, ends_at: Time.now.yesterday) + BroadcastMessage.current.should be_nil + end + end +end diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index fa556f94a1..d8ab171d3e 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Commit do - let(:project) { create :project_with_code } + let(:project) { create :project } let(:commit) { project.repository.commit } describe '#title' do diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index 852146ebae..9cbc899067 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -25,16 +25,11 @@ describe Issue, "Issuable" do it { described_class.should respond_to(:assigned) } end - it "has an :author_id_of_changes accessor" do - issue.should respond_to(:author_id_of_changes) - issue.should respond_to(:author_id_of_changes=) - end - describe ".search" do let!(:searchable_issue) { create(:issue, title: "Searchable issue") } it "matches by title" do - described_class.search('able').all.should == [searchable_issue] + described_class.search('able').should == [searchable_issue] end end diff --git a/spec/models/deploy_key_spec.rb b/spec/models/deploy_key_spec.rb index b76ca66041..adbbbac875 100644 --- a/spec/models/deploy_key_spec.rb +++ b/spec/models/deploy_key_spec.rb @@ -4,8 +4,8 @@ # # id :integer not null, primary key # user_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # key :text # title :string(255) # type :string(255) diff --git a/spec/models/deploy_keys_project_spec.rb b/spec/models/deploy_keys_project_spec.rb index aeec171355..3e0e25ee39 100644 --- a/spec/models/deploy_keys_project_spec.rb +++ b/spec/models/deploy_keys_project_spec.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # deploy_key_id :integer not null # project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # require 'spec_helper' diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 85bdf08ae6..f415e750dd 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -8,8 +8,8 @@ # title :string(255) # data :text # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # action :integer # author_id :integer # @@ -67,12 +67,12 @@ describe Event do end describe 'Team events' do - let(:user_project) { stub.as_null_object } + let(:user_project) { double.as_null_object } let(:observer) { UsersProjectObserver.instance } before { Event.should_receive :create - observer.stub(notification: stub.as_null_object) + observer.stub(notification: double.as_null_object) } describe "Joined project team" do diff --git a/spec/models/flowdock_service_spec.rb b/spec/models/flowdock_service_spec.rb index b22193c9e9..25ad133e12 100644 --- a/spec/models/flowdock_service_spec.rb +++ b/spec/models/flowdock_service_spec.rb @@ -7,10 +7,14 @@ # title :string(255) # token :string(255) # project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # active :boolean default(FALSE), not null # project_url :string(255) +# subdomain :string(255) +# room :string(255) +# recipients :text +# api_key :string(255) # require 'spec_helper' @@ -23,7 +27,7 @@ describe FlowdockService do describe "Execute" do let(:user) { create(:user) } - let(:project) { create(:project_with_code) } + let(:project) { create(:project) } before do @flowdock_service = FlowdockService.new diff --git a/spec/models/forked_project_link_spec.rb b/spec/models/forked_project_link_spec.rb index 44b8c6155b..1845c6103f 100644 --- a/spec/models/forked_project_link_spec.rb +++ b/spec/models/forked_project_link_spec.rb @@ -5,8 +5,8 @@ # id :integer not null, primary key # forked_to_project_id :integer not null # forked_from_project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # require 'spec_helper' @@ -58,8 +58,8 @@ describe :forked_from_project do end def fork_project(from_project, user) - context = Projects::ForkContext.new(from_project, user) - shell = mock("gitlab_shell") + context = Projects::ForkService.new(from_project, user) + shell = double("gitlab_shell") shell.stub(fork_repository: true) context.stub(gitlab_shell: shell) context.execute diff --git a/spec/models/gemnasium_service_spec.rb b/spec/models/gemnasium_service_spec.rb new file mode 100644 index 0000000000..efdf0dc891 --- /dev/null +++ b/spec/models/gemnasium_service_spec.rb @@ -0,0 +1,48 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# token :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# project_url :string(255) +# subdomain :string(255) +# room :string(255) +# recipients :text +# api_key :string(255) +# + +require 'spec_helper' + +describe GemnasiumService do + describe "Associations" do + it { should belong_to :project } + it { should have_one :service_hook } + end + + describe "Execute" do + let(:user) { create(:user) } + let(:project) { create(:project) } + + before do + @gemnasium_service = GemnasiumService.new + @gemnasium_service.stub( + project_id: project.id, + project: project, + service_hook: true, + token: 'verySecret', + api_key: 'GemnasiumUserApiKey' + ) + @sample_data = GitPushService.new.sample_data(project, user) + end + it "should call Gemnasium service" do + Gemnasium::GitlabService.should_receive(:execute).with(an_instance_of(Hash)).once + @gemnasium_service.execute(@sample_data) + end + end +end diff --git a/spec/models/gitlab_ci_service_spec.rb b/spec/models/gitlab_ci_service_spec.rb index 56efa9df45..a0708f1423 100644 --- a/spec/models/gitlab_ci_service_spec.rb +++ b/spec/models/gitlab_ci_service_spec.rb @@ -7,12 +7,14 @@ # title :string(255) # token :string(255) # project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # active :boolean default(FALSE), not null # project_url :string(255) # subdomain :string(255) # room :string(255) +# recipients :text +# api_key :string(255) # require 'spec_helper' diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 12b84700eb..8259ed88d8 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -6,10 +6,11 @@ # name :string(255) not null # path :string(255) not null # owner_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # type :string(255) # description :string(255) default(""), not null +# avatar :string(255) # require 'spec_helper' @@ -54,4 +55,19 @@ describe Group do group.users_groups.guests.map(&:user).should_not include(user) end end + + describe :avatar_type do + let(:user) { create(:user) } + before { group.add_user(user, UsersGroup::MASTER) } + + it "should be true if avatar is image" do + group.update_attribute(:avatar, 'uploads/avatar.png') + group.avatar_type.should be_true + end + + it "should be false if avatar is html page" do + group.update_attribute(:avatar, 'uploads/avatar.html') + group.avatar_type.should == ["only images allowed"] + end + end end diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 75155d5dc1..d53c4037c3 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -7,8 +7,8 @@ # assignee_id :integer # author_id :integer # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # position :integer default(0) # branch_name :string(255) # description :text diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 9c872c02a5..474067fe38 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -4,8 +4,8 @@ # # id :integer not null, primary key # user_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # key :text # title :string(255) # type :string(255) @@ -68,4 +68,18 @@ describe Key do build(:invalid_key).should_not be_valid end end + + context 'callbacks' do + it 'should add new key to authorized_file' do + @key = build(:personal_key, id: 7) + GitlabShellWorker.should_receive(:perform_async).with(:add_key, @key.shell_id, @key.key) + @key.save + end + + it 'should remove key from authorized_file' do + @key = create(:personal_key) + GitlabShellWorker.should_receive(:perform_async).with(:remove_key, @key.shell_id, @key.key) + @key.destroy + end + end end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index b17183a281..a10673fda9 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -9,10 +9,8 @@ # author_id :integer # assignee_id :integer # title :string(255) -# created_at :datetime not null -# updated_at :datetime not null -# st_commits :text(2147483647) -# st_diffs :text(2147483647) +# created_at :datetime +# updated_at :datetime # milestone_id :integer # state :string(255) # merge_status :string(255) @@ -73,14 +71,13 @@ describe MergeRequest do describe '#for_fork?' do it 'returns true if the merge request is for a fork' do - subject.source_project = create(:source_project) - subject.target_project = create(:target_project) + subject.source_project = create(:project, namespace: create(:group)) + subject.target_project = create(:project, namespace: create(:group)) subject.for_fork?.should be_true end + it 'returns false if is not for a fork' do - subject.source_project = create(:source_project) - subject.target_project = subject.source_project subject.for_fork?.should be_false end end @@ -107,22 +104,22 @@ describe MergeRequest do describe 'detection of issues to be closed' do let(:issue0) { create :issue, project: subject.project } let(:issue1) { create :issue, project: subject.project } - let(:commit0) { mock('commit0', closes_issues: [issue0]) } - let(:commit1) { mock('commit1', closes_issues: [issue0]) } - let(:commit2) { mock('commit2', closes_issues: [issue1]) } + let(:commit0) { double('commit0', closes_issues: [issue0]) } + let(:commit1) { double('commit1', closes_issues: [issue0]) } + let(:commit2) { double('commit2', closes_issues: [issue1]) } before do - subject.stub(unmerged_commits: [commit0, commit1, commit2]) + subject.stub(commits: [commit0, commit1, commit2]) end it 'accesses the set of issues that will be closed on acceptance' do - subject.project.default_branch = subject.target_branch + subject.project.stub(default_branch: subject.target_branch) subject.closes_issues.should == [issue0, issue1].sort_by(&:id) end it 'only lists issues as to be closed if it targets the default branch' do - subject.project.default_branch = 'master' + subject.project.stub(default_branch: 'master') subject.target_branch = 'something-else' subject.closes_issues.should be_empty diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index b41012a3b8..8309ad3a72 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -7,8 +7,8 @@ # project_id :integer not null # description :text # due_date :date -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # state :string(255) # iid :integer # diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index c38554e2f7..d2bf96979f 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -6,10 +6,11 @@ # name :string(255) not null # path :string(255) not null # owner_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # type :string(255) # description :string(255) default(""), not null +# avatar :string(255) # require 'spec_helper' diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 42c405d8e5..43779e6bbf 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -6,15 +6,15 @@ # note :text # noteable_type :string(255) # author_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # project_id :integer # attachment :string(255) # line_code :string(255) # commit_id :string(255) # noteable_id :integer -# st_diff :text # system :boolean default(FALSE), not null +# st_diff :text # require 'spec_helper' @@ -61,6 +61,11 @@ describe Note do note.should be_upvote end + it "recognizes a thumbsup emoji as a vote" do + note = build(:votable_note, note: ":thumbsup: for this") + note.should be_upvote + end + it "recognizes a -1 note" do note = create(:votable_note, note: "-1 for this") note.should be_downvote @@ -70,6 +75,11 @@ describe Note do note = build(:votable_note, note: ":-1: for this") note.should be_downvote end + + it "recognizes a thumbsdown emoji as a vote" do + note = build(:votable_note, note: ":thumbsdown: for this") + note.should be_downvote + end end let(:project) { create(:project) } @@ -170,11 +180,36 @@ describe Note do end end + describe '#create_assignee_change_note' do + let(:project) { create(:project) } + let(:thing) { create(:issue, project: project) } + let(:author) { create(:user) } + let(:assignee) { create(:user) } + + subject { Note.create_assignee_change_note(thing, project, author, assignee) } + + context 'creates and saves a Note' do + it { should be_a Note } + its(:id) { should_not be_nil } + end + + its(:noteable) { should == thing } + its(:project) { should == thing.project } + its(:author) { should == author } + its(:note) { should =~ /Reassigned to @#{assignee.username}/ } + + context 'assignee is removed' do + let(:assignee) { nil } + + its(:note) { should =~ /Assignee removed/ } + end + end + describe '#create_cross_reference_note' do - let(:project) { create(:project_with_code) } + let(:project) { create(:project) } let(:author) { create(:user) } let(:issue) { create(:issue, project: project) } - let(:mergereq) { create(:merge_request, target_project: project) } + let(:mergereq) { create(:merge_request, :simple, target_project: project, source_project: project) } let(:commit) { project.repository.commit } # Test all of {issue, merge request, commit} in both the referenced and referencing @@ -215,6 +250,16 @@ describe Note do its(:project) { should == project } its(:note) { should == "_mentioned in merge request !#{mergereq.iid}_" } end + + context 'commit from issue' do + subject { Note.create_cross_reference_note(commit, issue, author, project) } + + it { should be_valid } + its(:noteable_type) { should == "Commit" } + its(:noteable_id) { should be_nil } + its(:commit_id) { should == commit.id } + its(:note) { should == "_mentioned in issue ##{issue.iid}_" } + end end describe '#cross_reference_exists?' do @@ -242,6 +287,7 @@ describe Note do let(:issue) { create(:issue, project: project) } let(:other) { create(:issue, project: project) } let(:author) { create(:user) } + let(:assignee) { create(:user) } it 'should recognize user-supplied notes as non-system' do @note = create(:note_on_issue) @@ -257,6 +303,11 @@ describe Note do @note = Note.create_cross_reference_note(issue, other, author, project) @note.should be_system end + + it 'should identify assignee-change notes as system notes' do + @note = Note.create_assignee_change_note(issue, project, author, assignee) + @note.should be_system + end end describe :authorization do diff --git a/spec/models/project_hook_spec.rb b/spec/models/project_hook_spec.rb new file mode 100644 index 0000000000..4e0d50d7f3 --- /dev/null +++ b/spec/models/project_hook_spec.rb @@ -0,0 +1,36 @@ +# == Schema Information +# +# Table name: web_hooks +# +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# type :string(255) default("ProjectHook") +# service_id :integer +# push_events :boolean default(TRUE), not null +# issues_events :boolean default(FALSE), not null +# merge_requests_events :boolean default(FALSE), not null +# tag_push_events :boolean default(FALSE) +# + +require 'spec_helper' + +describe ProjectHook do + describe '.push_hooks' do + it 'should return hooks for push events only' do + hook = create(:project_hook, push_events: true) + hook2 = create(:project_hook, push_events: false) + expect(ProjectHook.push_hooks).to eq([hook]) + end + end + + describe '.tag_push_hooks' do + it 'should return hooks for tag push events only' do + hook = create(:project_hook, tag_push_events: true) + hook2 = create(:project_hook, tag_push_events: false) + expect(ProjectHook.tag_push_hooks).to eq([hook]) + end + end +end diff --git a/spec/models/project_snippet_spec.rb b/spec/models/project_snippet_spec.rb index d3a46ebbb8..4214717938 100644 --- a/spec/models/project_snippet_spec.rb +++ b/spec/models/project_snippet_spec.rb @@ -4,11 +4,11 @@ # # id :integer not null, primary key # title :string(255) -# content :text(2147483647) +# content :text # author_id :integer not null # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # file_name :string(255) # expires_at :datetime # private :boolean default(TRUE), not null diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 88ea692679..b42d7bfe60 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -6,22 +6,22 @@ # name :string(255) # path :string(255) # description :text -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # creator_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 # namespace_id :integer -# public :boolean default(FALSE), not null # issues_tracker :string(255) default("gitlab"), not null # issues_tracker_id :string(255) # snippets_enabled :boolean default(TRUE), not null # last_activity_at :datetime -# imported :boolean default(FALSE), not null # import_url :string(255) +# visibility_level :integer default(0), not null +# archived :boolean default(FALSE), not null +# import_status :string(255) # require 'spec_helper' @@ -47,6 +47,7 @@ describe Project do it { should have_many(:hooks).dependent(:destroy) } it { should have_many(:protected_branches).dependent(:destroy) } it { should have_one(:forked_project_link).dependent(:destroy) } + it { should have_one(:slack_service).dependent(:destroy) } end describe "Mass assignment" do @@ -71,9 +72,9 @@ describe Project do it "should not allow new projects beyond user limits" do project2 = build(:project) - project2.stub(:creator).and_return(double(can_create_project?: false, projects_limit: 0)) + project2.stub(:creator).and_return(double(can_create_project?: false, projects_limit: 0).as_null_object) project2.should_not be_valid - project2.errors[:limit_reached].first.should match(/Your own projects limit is 0/) + project2.errors[:limit_reached].first.should match(/Your project limit is 0/) end end @@ -99,6 +100,11 @@ describe Project do project.web_url.should == "#{Gitlab.config.gitlab.url}/somewhere" end + it "returns the web URL without the protocol for this repo" do + project = Project.new(path: "somewhere") + project.web_url_without_protocol.should == "#{Gitlab.config.gitlab.url.split("://")[1]}/somewhere" + end + describe "last_activity methods" do let(:project) { create(:project) } let(:last_event) { double(created_at: Time.now) } @@ -123,7 +129,7 @@ describe Project do end describe :update_merge_requests do - let(:project) { create(:project_with_code) } + let(:project) { create(:project) } before do @merge_request = create(:merge_request, source_project: project, target_project: project) @@ -131,18 +137,17 @@ describe Project do end it "should close merge request if last commit from source branch was pushed to target branch" do - @merge_request.reloaded_commits - @merge_request.last_commit.id.should == "b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828" - project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828", "refs/heads/stable", @key.user) + @merge_request.reload_code + @merge_request.last_commit.id.should == "69b34b7e9ad9f496f0ad10250be37d6265a03bba" + project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "69b34b7e9ad9f496f0ad10250be37d6265a03bba", "refs/heads/stable", @key.user) @merge_request.reload @merge_request.merged?.should be_true end it "should update merge request commits with new one if pushed to source branch" do - @merge_request.last_commit.should == nil - project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828", "refs/heads/master", @key.user) + project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "69b34b7e9ad9f496f0ad10250be37d6265a03bba", "refs/heads/master", @key.user) @merge_request.reload - @merge_request.last_commit.id.should == "b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828" + @merge_request.last_commit.id.should == "69b34b7e9ad9f496f0ad10250be37d6265a03bba" end end @@ -151,10 +156,10 @@ describe Project do context 'with namespace' do before do @group = create :group, name: 'gitlab' - @project = create(:project, name: 'gitlab-ci', namespace: @group) + @project = create(:project, name: 'gitlabhq', namespace: @group) end - it { Project.find_with_namespace('gitlab/gitlab-ci').should == @project } + it { Project.find_with_namespace('gitlab/gitlabhq').should == @project } it { Project.find_with_namespace('gitlab-ci').should be_nil } end end @@ -163,10 +168,10 @@ describe Project do context 'with namespace' do before do @group = create :group, name: 'gitlab' - @project = create(:project, name: 'gitlab-ci', namespace: @group) + @project = create(:project, name: 'gitlabhq', namespace: @group) end - it { @project.to_param.should == "gitlab/gitlab-ci" } + it { @project.to_param.should == "gitlab/gitlabhq" } end end @@ -232,7 +237,7 @@ describe Project do end describe :open_branches do - let(:project) { create(:project_with_code) } + let(:project) { create(:project) } before do project.protected_branches.create(name: 'master') diff --git a/spec/models/gollum_wiki_spec.rb b/spec/models/project_wiki_spec.rb similarity index 92% rename from spec/models/gollum_wiki_spec.rb rename to spec/models/project_wiki_spec.rb index 9e07d9ee19..32a82470e4 100644 --- a/spec/models/gollum_wiki_spec.rb +++ b/spec/models/project_wiki_spec.rb @@ -1,12 +1,6 @@ require "spec_helper" -describe GollumWiki do - - def create_temp_repo(path) - FileUtils.mkdir_p path - command = "git init --quiet #{path};" - system(command) - end +describe ProjectWiki do def remove_temp_repo(path) FileUtils.rm_rf path @@ -29,7 +23,7 @@ describe GollumWiki do let(:user) { project.owner } let(:gitlab_shell) { Gitlab::Shell.new } - subject { GollumWiki.new(project, user) } + subject { ProjectWiki.new(project, user) } before do create_temp_repo(subject.send(:path_to_repo)) @@ -74,15 +68,15 @@ describe GollumWiki do end it "creates a new wiki repo if one does not yet exist" do - wiki = GollumWiki.new(project, user) + wiki = ProjectWiki.new(project, user) wiki.create_page("index", "test content").should_not == false FileUtils.rm_rf wiki.send(:path_to_repo) end it "raises CouldNotCreateWikiError if it can't create the wiki repository" do - GollumWiki.any_instance.stub(:init_repo).and_return(false) - expect { GollumWiki.new(project, user).wiki }.to raise_exception(GollumWiki::CouldNotCreateWikiError) + ProjectWiki.any_instance.stub(:init_repo).and_return(false) + expect { ProjectWiki.new(project, user).wiki }.to raise_exception(ProjectWiki::CouldNotCreateWikiError) end end diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb index 6e830393e3..35b929c2f3 100644 --- a/spec/models/protected_branch_spec.rb +++ b/spec/models/protected_branch_spec.rb @@ -5,8 +5,8 @@ # 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 +# created_at :datetime +# updated_at :datetime # require 'spec_helper' diff --git a/spec/models/service_hook_spec.rb b/spec/models/service_hook_spec.rb index 0b0262c97f..6ec82438df 100644 --- a/spec/models/service_hook_spec.rb +++ b/spec/models/service_hook_spec.rb @@ -2,13 +2,17 @@ # # 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") -# service_id :integer +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# type :string(255) default("ProjectHook") +# service_id :integer +# push_events :boolean default(TRUE), not null +# issues_events :boolean default(FALSE), not null +# merge_requests_events :boolean default(FALSE), not null +# tag_push_events :boolean default(FALSE) # require "spec_helper" diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index 667c80bcf1..a4bed81c0f 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -7,12 +7,14 @@ # title :string(255) # token :string(255) # project_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # active :boolean default(FALSE), not null # project_url :string(255) # subdomain :string(255) # room :string(255) +# recipients :text +# api_key :string(255) # require 'spec_helper' @@ -44,12 +46,12 @@ describe Service do end describe :can_test do - it { @testable.should == false } + it { @testable.should == true } end end describe "With commits" do - let (:project) { create :project_with_code } + let (:project) { create :project } before do @service.stub( diff --git a/spec/models/slack_message_spec.rb b/spec/models/slack_message_spec.rb new file mode 100644 index 0000000000..1cd5853470 --- /dev/null +++ b/spec/models/slack_message_spec.rb @@ -0,0 +1,65 @@ +require_relative '../../app/models/project_services/slack_message' + +describe SlackMessage do + subject { SlackMessage.new(args) } + + let(:args) { + { + after: 'after', + before: 'before', + project_name: 'project_name', + ref: 'refs/heads/master', + user_name: 'user_name', + project_url: 'url' + } + } + + let(:color) { '#345' } + + context 'push' do + before do + args[:commits] = [ + { message: 'message1', url: 'url1', id: 'abcdefghijkl', author: { name: 'author1' } }, + { message: 'message2', url: 'url2', id: '123456789012', author: { name: 'author2' } }, + ] + end + + it 'returns a message regarding pushes' do + subject.pretext.should == + 'user_name pushed to branch of ' << + ' ()' + subject.attachments.should == [ + { + text: ": message1 - author1\n" << + ": message2 - author2", + color: color, + } + ] + end + end + + context 'new branch' do + before do + args[:before] = '000000' + end + + it 'returns a message regarding a new branch' do + subject.pretext.should == + 'user_name pushed new branch to ' << + '' + subject.attachments.should be_empty + end + end + + context 'removed branch' do + before do + args[:after] = '000000' + end + + it 'returns a message regarding a removed branch' do + subject.pretext.should == + 'user_name removed branch master from ' + subject.attachments.should be_empty + end + end +end diff --git a/spec/models/slack_service_spec.rb b/spec/models/slack_service_spec.rb new file mode 100644 index 0000000000..b00eb30569 --- /dev/null +++ b/spec/models/slack_service_spec.rb @@ -0,0 +1,70 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# token :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# project_url :string(255) +# subdomain :string(255) +# room :string(255) +# recipients :text +# api_key :string(255) +# + +require 'spec_helper' + +describe SlackService do + describe "Associations" do + it { should belong_to :project } + it { should have_one :service_hook } + end + + describe "Validations" do + context "active" do + before do + subject.active = true + end + + it { should validate_presence_of :room } + it { should validate_presence_of :subdomain } + it { should validate_presence_of :token } + end + end + + describe "Execute" do + let(:slack) { SlackService.new } + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:sample_data) { GitPushService.new.sample_data(project, user) } + let(:subdomain) { 'gitlab' } + let(:token) { 'verySecret' } + let(:api_url) { + "https://#{subdomain}.slack.com/services/hooks/incoming-webhook?token=#{token}" + } + + before do + slack.stub( + project: project, + project_id: project.id, + room: '#gitlab', + service_hook: true, + subdomain: subdomain, + token: token + ) + + WebMock.stub_request(:post, api_url) + end + + it "should call Slack API" do + slack.execute(sample_data) + + WebMock.should have_requested(:post, api_url).once + end + end +end diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index 5fa397207c..a77c594aaf 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -4,11 +4,11 @@ # # id :integer not null, primary key # title :string(255) -# content :text(2147483647) +# content :text # author_id :integer not null # project_id :integer -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # file_name :string(255) # expires_at :datetime # private :boolean default(TRUE), not null diff --git a/spec/models/system_hook_spec.rb b/spec/models/system_hook_spec.rb index a9ed6a5fa7..7314439730 100644 --- a/spec/models/system_hook_spec.rb +++ b/spec/models/system_hook_spec.rb @@ -2,13 +2,17 @@ # # 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") -# service_id :integer +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# type :string(255) default("ProjectHook") +# service_id :integer +# push_events :boolean default(TRUE), not null +# issues_events :boolean default(FALSE), not null +# merge_requests_events :boolean default(FALSE), not null +# tag_push_events :boolean default(FALSE) # require "spec_helper" diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index f6c9f82c4e..34a5bcfb4a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -2,40 +2,48 @@ # # Table name: users # -# id :integer not null, primary key -# email :string(255) default(""), not null -# encrypted_password :string(255) 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) -# theme_id :integer default(1), not null -# bio :string(255) -# failed_attempts :integer default(0) -# locked_at :datetime -# extern_uid :string(255) -# provider :string(255) -# username :string(255) -# can_create_group :boolean default(TRUE), not null -# can_create_team :boolean default(TRUE), not null -# state :string(255) -# color_scheme_id :integer default(1), not null -# notification_level :integer default(1), not null -# password_expires_at :datetime -# created_by_id :integer +# id :integer not null, primary key +# email :string(255) default(""), not null +# encrypted_password :string(255) 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 +# updated_at :datetime +# 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) +# theme_id :integer default(1), not null +# bio :string(255) +# failed_attempts :integer default(0) +# locked_at :datetime +# extern_uid :string(255) +# provider :string(255) +# username :string(255) +# can_create_group :boolean default(TRUE), not null +# can_create_team :boolean default(TRUE), not null +# state :string(255) +# color_scheme_id :integer default(1), not null +# notification_level :integer default(1), not null +# password_expires_at :datetime +# created_by_id :integer +# last_credential_check_at :datetime +# avatar :string(255) +# confirmation_token :string(255) +# confirmed_at :datetime +# confirmation_sent_at :datetime +# unconfirmed_email :string(255) +# hide_no_ssh_key :boolean default(FALSE) +# website_url :string(255) default(""), not null # require 'spec_helper' @@ -69,6 +77,27 @@ describe User do it { should_not allow_value(-1).for(:projects_limit) } it { should ensure_length_of(:bio).is_within(0..255) } + + describe 'email' do + it 'accepts info@example.com' do + user = build(:user, email: 'info@example.com') + expect(user).to be_valid + end + it 'accepts info+test@example.com' do + user = build(:user, email: 'info+test@example.com') + expect(user).to be_valid + end + + it 'rejects test@test@example.com' do + user = build(:user, email: 'test@test@example.com') + expect(user).to be_invalid + end + + it 'rejects mailto:test@example.com' do + user = build(:user, email: 'mailto:test@example.com') + expect(user).to be_invalid + end + end end describe "Respond to" do @@ -85,8 +114,8 @@ describe User do end it "should not generate password by default" do - user = create(:user, password: 'abcdefg') - user.password.should == 'abcdefg' + user = create(:user, password: 'abcdefghe') + user.password.should == 'abcdefghe' end it "should generate password when forcing random password" do @@ -135,7 +164,6 @@ describe User do end it { @user.several_namespaces?.should be_true } - it { @user.namespaces.should include(@user.namespace) } it { @user.authorized_groups.should == [@group] } it { @user.owned_groups.should == [@group] } end @@ -162,7 +190,6 @@ describe User do end it { @user.several_namespaces?.should be_false } - it { @user.namespaces.should == [@user.namespace] } end describe 'blocking user' do @@ -266,6 +293,20 @@ describe User do end end + describe 'search' do + let(:user1) { create(:user, username: 'James', email: 'james@testing.com') } + let(:user2) { create(:user, username: 'jameson', email: 'jameson@example.com') } + + it "should be case insensitive" do + User.search(user1.username.upcase).to_a.should == [user1] + User.search(user1.username.downcase).to_a.should == [user1] + User.search(user2.username.upcase).to_a.should == [user2] + User.search(user2.username.downcase).to_a.should == [user2] + User.search(user1.username.downcase).to_a.count.should == 2 + User.search(user2.username.downcase).to_a.count.should == 1 + end + end + describe 'by_username_or_id' do let(:user1) { create(:user, username: 'foo') } @@ -276,4 +317,73 @@ describe User do User.by_username_or_id('bar').should be_nil end end + + describe 'all_ssh_keys' do + it { should have_many(:keys).dependent(:destroy) } + + it "should have all ssh keys" do + user = create :user + key = create :key, key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD33bWLBxu48Sev9Fert1yzEO4WGcWglWF7K/AwblIUFselOt/QdOL9DSjpQGxLagO1s9wl53STIO8qGS4Ms0EJZyIXOEFMjFJ5xmjSy+S37By4sG7SsltQEHMxtbtFOaW5LV2wCrX+rUsRNqLMamZjgjcPO0/EgGCXIGMAYW4O7cwGZdXWYIhQ1Vwy+CsVMDdPkPgBXqK7nR/ey8KMs8ho5fMNgB5hBw/AL9fNGhRw3QTD6Q12Nkhl4VZES2EsZqlpNnJttnPdp847DUsT6yuLRlfiQfz5Cn9ysHFdXObMN5VYIiPFwHeYCZp1X2S4fDZooRE8uOLTfxWHPXwrhqSH", user_id: user.id + + user.all_ssh_keys.should include(key.key) + end + end + + describe :avatar_type do + let(:user) { create(:user) } + + it "should be true if avatar is image" do + user.update_attribute(:avatar, 'uploads/avatar.png') + user.avatar_type.should be_true + end + + it "should be false if avatar is html page" do + user.update_attribute(:avatar, 'uploads/avatar.html') + user.avatar_type.should == ["only images allowed"] + end + end + + describe '#full_website_url' do + let(:user) { create(:user) } + + it 'begins with http if website url omits it' do + user.website_url = 'test.com' + + expect(user.full_website_url).to eq 'http://test.com' + end + + it 'begins with http if website url begins with http' do + user.website_url = 'http://test.com' + + expect(user.full_website_url).to eq 'http://test.com' + end + + it 'begins with https if website url begins with https' do + user.website_url = 'https://test.com' + + expect(user.full_website_url).to eq 'https://test.com' + end + end + + describe '#short_website_url' do + let(:user) { create(:user) } + + it 'does not begin with http if website url omits it' do + user.website_url = 'test.com' + + expect(user.short_website_url).to eq 'test.com' + end + + it 'does not begin with http if website url begins with http' do + user.website_url = 'http://test.com' + + expect(user.short_website_url).to eq 'test.com' + end + + it 'does not begin with https if website url begins with https' do + user.website_url = 'https://test.com' + + expect(user.short_website_url).to eq 'test.com' + end + end end diff --git a/spec/models/users_group_spec.rb b/spec/models/users_group_spec.rb index 9264f2bc03..acecae0714 100644 --- a/spec/models/users_group_spec.rb +++ b/spec/models/users_group_spec.rb @@ -6,8 +6,8 @@ # group_access :integer not null # group_id :integer not null # user_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null +# created_at :datetime +# updated_at :datetime # notification_level :integer default(3), not null # diff --git a/spec/models/users_project_spec.rb b/spec/models/users_project_spec.rb index e289a592b0..aa4b8cb449 100644 --- a/spec/models/users_project_spec.rb +++ b/spec/models/users_project_spec.rb @@ -5,8 +5,8 @@ # 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 +# created_at :datetime +# updated_at :datetime # project_access :integer default(0), not null # notification_level :integer default(3), not null # diff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rb index 2d9301732d..20ee141612 100644 --- a/spec/models/web_hook_spec.rb +++ b/spec/models/web_hook_spec.rb @@ -2,13 +2,17 @@ # # 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") -# service_id :integer +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# type :string(255) default("ProjectHook") +# service_id :integer +# push_events :boolean default(TRUE), not null +# issues_events :boolean default(FALSE), not null +# merge_requests_events :boolean default(FALSE), not null +# tag_push_events :boolean default(FALSE) # require 'spec_helper' diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index 67f2a6da42..005c513af3 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -2,12 +2,6 @@ require "spec_helper" describe WikiPage do - def create_temp_repo(path) - FileUtils.mkdir_p path - command = "git init --quiet #{path};" - system(command) - end - def remove_temp_repo(path) FileUtils.rm_rf path end @@ -28,7 +22,7 @@ describe WikiPage do let(:project) { create(:project) } let(:repository) { project.repository } let(:user) { project.owner } - let(:wiki) { GollumWiki.new(project, user) } + let(:wiki) { ProjectWiki.new(project, user) } subject { WikiPage.new(wiki) } @@ -161,4 +155,20 @@ describe WikiPage do end end + describe "#title" do + before do + create_page("Title", "content") + @page = wiki.find_page("Title") + end + + after do + destroy_page("Title") + end + + it "should be replace a hyphen to a space" do + @page.title = "Import-existing-repositories-into-GitLab" + @page.title.should == "Import existing repositories into GitLab" + end + end + end diff --git a/spec/observers/activity_observer_spec.rb b/spec/observers/activity_observer_spec.rb deleted file mode 100644 index dc14ab86b6..0000000000 --- a/spec/observers/activity_observer_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require 'spec_helper' - -describe ActivityObserver do - let(:project) { create(:project) } - - before { Thread.current[:current_user] = create(:user) } - - def self.it_should_be_valid_event - it { @event.should_not be_nil } - it { @event.project.should == project } - end - - describe "Issue created" do - before do - Issue.observers.enable :activity_observer do - @issue = create(:issue, project: project) - @event = Event.last - end - end - - it_should_be_valid_event - it { @event.action.should == Event::CREATED } - it { @event.target.should == @issue } - end - - describe "Issue commented" do - before do - Note.observers.enable :activity_observer do - @issue = create(:issue, project: project) - @note = create(:note, noteable: @issue, project: project, author: @issue.author) - @event = Event.last - end - end - - it_should_be_valid_event - it { @event.action.should == Event::COMMENTED } - it { @event.target.should == @note } - end - - describe "Ignore system notes" do - let(:author) { create(:user) } - let!(:issue) { create(:issue, project: project) } - let!(:other) { create(:issue) } - - it "should not create events for status change notes" do - expect do - Note.observers.enable :activity_observer do - Note.create_status_change_note(issue, project, author, 'reopened', nil) - end - end.to_not change { Event.count } - end - - it "should not create events for cross-reference notes" do - expect do - Note.observers.enable :activity_observer do - Note.create_cross_reference_note(issue, other, author, issue.project) - end - end.to_not change { Event.count } - end - end -end diff --git a/spec/observers/issue_observer_spec.rb b/spec/observers/issue_observer_spec.rb deleted file mode 100644 index 4155ff3119..0000000000 --- a/spec/observers/issue_observer_spec.rb +++ /dev/null @@ -1,99 +0,0 @@ -require 'spec_helper' - -describe IssueObserver do - let(:some_user) { create :user } - let(:assignee) { create :user } - let(:author) { create :user } - let(:mock_issue) { create(:issue, assignee: assignee, author: author) } - - - before { subject.stub(:current_user).and_return(some_user) } - before { subject.stub(:current_commit).and_return(nil) } - before { subject.stub(notification: mock('NotificationService').as_null_object) } - before { mock_issue.project.stub_chain(:repository, :commit).and_return(nil) } - - subject { IssueObserver.instance } - - describe '#after_create' do - it 'trigger notification to send emails' do - subject.should_receive(:notification) - - subject.after_create(mock_issue) - end - - it 'should create cross-reference notes' do - other_issue = create(:issue) - mock_issue.stub(references: [other_issue]) - - Note.should_receive(:create_cross_reference_note).with(other_issue, mock_issue, - some_user, mock_issue.project) - subject.after_create(mock_issue) - end - end - - context '#after_close' do - context 'a status "closed"' do - before { mock_issue.stub(state: 'closed') } - - it 'note is created if the issue is being closed' do - Note.should_receive(:create_status_change_note).with(mock_issue, mock_issue.project, some_user, 'closed', nil) - - subject.after_close(mock_issue, nil) - end - - it 'trigger notification to send emails' do - subject.notification.should_receive(:close_issue).with(mock_issue, some_user) - subject.after_close(mock_issue, nil) - end - - it 'appends a mention to the closing commit if one is present' do - commit = double('commit', gfm_reference: 'commit 123456') - subject.stub(current_commit: commit) - - Note.should_receive(:create_status_change_note).with(mock_issue, mock_issue.project, some_user, 'closed', commit) - - subject.after_close(mock_issue, nil) - end - end - - context 'a status "reopened"' do - before { mock_issue.stub(state: 'reopened') } - - it 'note is created if the issue is being reopened' do - Note.should_receive(:create_status_change_note).with(mock_issue, mock_issue.project, some_user, 'reopened', nil) - - subject.after_reopen(mock_issue, nil) - end - end - end - - context '#after_update' do - before(:each) do - mock_issue.stub(:is_being_reassigned?).and_return(false) - end - - context 'notification' do - it 'triggered if the issue is being reassigned' do - mock_issue.should_receive(:is_being_reassigned?).and_return(true) - subject.should_receive(:notification) - - subject.after_update(mock_issue) - end - - it 'is not triggered if the issue is not being reassigned' do - mock_issue.should_receive(:is_being_reassigned?).and_return(false) - subject.should_not_receive(:notification) - - subject.after_update(mock_issue) - end - end - - context 'cross-references' do - it 'notices added references' do - mock_issue.should_receive(:notice_added_references) - - subject.after_update(mock_issue) - end - end - end -end diff --git a/spec/observers/key_observer_spec.rb b/spec/observers/key_observer_spec.rb deleted file mode 100644 index b304bf1fcb..0000000000 --- a/spec/observers/key_observer_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe KeyObserver do - before do - @key = create(:personal_key) - - @observer = KeyObserver.instance - end - - context :after_create do - it do - GitlabShellWorker.should_receive(:perform_async).with(:add_key, @key.shell_id, @key.key) - @observer.after_create(@key) - end - end - - context :after_destroy do - it do - GitlabShellWorker.should_receive(:perform_async).with(:remove_key, @key.shell_id, @key.key) - @observer.after_destroy(@key) - end - end -end diff --git a/spec/observers/merge_request_observer_spec.rb b/spec/observers/merge_request_observer_spec.rb deleted file mode 100644 index 3f5250a004..0000000000 --- a/spec/observers/merge_request_observer_spec.rb +++ /dev/null @@ -1,137 +0,0 @@ -require 'spec_helper' - -describe MergeRequestObserver do - let(:some_user) { create :user } - let(:assignee) { create :user } - let(:author) { create :user } - let(:mr_mock) { double(:merge_request, id: 42, assignee: assignee, author: author) } - let(:assigned_mr) { create(:merge_request, assignee: assignee, author: author, target_project: create(:project)) } - let(:unassigned_mr) { create(:merge_request, author: author, target_project: create(:project)) } - let(:closed_assigned_mr) { create(:closed_merge_request, assignee: assignee, author: author, target_project: create(:project)) } - let(:closed_unassigned_mr) { create(:closed_merge_request, author: author, target_project: create(:project)) } - - before { subject.stub(:current_user).and_return(some_user) } - before { subject.stub(notification: mock('NotificationService').as_null_object) } - before { mr_mock.stub(:author_id) } - before { mr_mock.stub(:target_project) } - before { mr_mock.stub(:source_project) } - before { mr_mock.stub(:project) } - before { mr_mock.stub(:create_cross_references!).and_return(true) } - before { Repository.any_instance.stub(commit: nil) } - - before(:each) { enable_observers } - after(:each) { disable_observers } - - subject { MergeRequestObserver.instance } - - describe '#after_create' do - it 'trigger notification service' do - subject.should_receive(:notification) - subject.after_create(mr_mock) - end - - it 'creates cross-reference notes' do - project = create :project - mr_mock.stub(title: "this mr references !#{assigned_mr.id}", project: project) - mr_mock.should_receive(:create_cross_references!).with(project, some_user) - - subject.after_create(mr_mock) - end - end - - context '#after_update' do - before(:each) do - mr_mock.stub(:is_being_reassigned?).and_return(false) - mr_mock.stub(:notice_added_references) - end - - it 'is called when a merge request is changed' do - changed = create(:merge_request, source_project: create(:project)) - subject.should_receive(:after_update) - - MergeRequest.observers.enable :merge_request_observer do - changed.title = 'I changed' - changed.save - end - end - - it 'checks for new references' do - mr_mock.should_receive(:notice_added_references) - - subject.after_update(mr_mock) - end - - context 'a notification' do - it 'is sent if the merge request is being reassigned' do - mr_mock.should_receive(:is_being_reassigned?).and_return(true) - subject.should_receive(:notification) - - subject.after_update(mr_mock) - end - - it 'is not sent if the merge request is not being reassigned' do - mr_mock.should_receive(:is_being_reassigned?).and_return(false) - subject.should_not_receive(:notification) - - subject.after_update(mr_mock) - end - end - end - - context '#after_close' do - context 'a status "closed"' do - it 'note is created if the merge request is being closed' do - Note.should_receive(:create_status_change_note).with(assigned_mr, assigned_mr.target_project, some_user, 'closed', nil) - - assigned_mr.close - end - - it 'notification is delivered only to author if the merge request is being closed' do - Note.should_receive(:create_status_change_note).with(unassigned_mr, unassigned_mr.target_project, some_user, 'closed', nil) - - unassigned_mr.close - end - end - end - - context '#after_reopen' do - context 'a status "reopened"' do - it 'note is created if the merge request is being reopened' do - Note.should_receive(:create_status_change_note).with(closed_assigned_mr, closed_assigned_mr.target_project, some_user, 'reopened', nil) - - closed_assigned_mr.reopen - end - - it 'notification is delivered only to author if the merge request is being reopened' do - Note.should_receive(:create_status_change_note).with(closed_unassigned_mr, closed_unassigned_mr.target_project, some_user, 'reopened', nil) - - closed_unassigned_mr.reopen - end - end - end - - describe "Merge Request created" do - def self.it_should_be_valid_event - it { @event.should_not be_nil } - it { @event.should_not be_nil } - it { @event.project.should == project } - it { @event.project.should == project } - end - - let(:project) { create(:project) } - before do - TestEnv.enable_observers - @merge_request = create(:merge_request, source_project: project, target_project: project) - @event = Event.last - end - - after do - TestEnv.disable_observers - end - - it_should_be_valid_event - it { @event.action.should == Event::CREATED } - it { @event.target.should == @merge_request } - end - -end diff --git a/spec/observers/note_observer_spec.rb b/spec/observers/note_observer_spec.rb index f9b96c255c..f8693355b2 100644 --- a/spec/observers/note_observer_spec.rb +++ b/spec/observers/note_observer_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe NoteObserver do subject { NoteObserver.instance } - before { subject.stub(notification: mock('NotificationService').as_null_object) } + before { subject.stub(notification: double('NotificationService').as_null_object) } let(:team_without_author) { (1..2).map { |n| double :user, id: n } } let(:note) { double(:note).as_null_object } diff --git a/spec/observers/user_observer_spec.rb b/spec/observers/user_observer_spec.rb index b74fceb98b..9aeade535f 100644 --- a/spec/observers/user_observer_spec.rb +++ b/spec/observers/user_observer_spec.rb @@ -4,7 +4,7 @@ describe UserObserver do before(:each) { enable_observers } after(:each) {disable_observers} subject { UserObserver.instance } - before { subject.stub(notification: mock('NotificationService').as_null_object) } + before { subject.stub(notification: double('NotificationService').as_null_object) } it 'calls #after_create when new users are created' do new_user = build(:user) diff --git a/spec/observers/users_group_observer_spec.rb b/spec/observers/users_group_observer_spec.rb index 3bf562edbb..2ab99c33b7 100644 --- a/spec/observers/users_group_observer_spec.rb +++ b/spec/observers/users_group_observer_spec.rb @@ -5,7 +5,7 @@ describe UsersGroupObserver do after(:each) { disable_observers } subject { UsersGroupObserver.instance } - before { subject.stub(notification: mock('NotificationService').as_null_object) } + before { subject.stub(notification: double('NotificationService').as_null_object) } describe "#after_create" do it "should send email to user" do @@ -23,5 +23,10 @@ describe UsersGroupObserver do subject.should_receive(:notification) @membership.update_attribute(:group_access, UsersGroup::MASTER) end + + it "does not send an email when the access level has not changed" do + subject.should_not_receive(:notification) + @membership.update_attribute(:group_access, UsersGroup::OWNER) + end end end diff --git a/spec/observers/users_project_observer_spec.rb b/spec/observers/users_project_observer_spec.rb index e7c624fce5..b024465e8c 100644 --- a/spec/observers/users_project_observer_spec.rb +++ b/spec/observers/users_project_observer_spec.rb @@ -7,27 +7,7 @@ describe UsersProjectObserver do let(:user) { create(:user) } let(:project) { create(:project) } subject { UsersProjectObserver.instance } - before { subject.stub(notification: mock('NotificationService').as_null_object) } - - describe "#after_commit" do - it "should called when UsersProject created" do - subject.should_receive(:after_commit) - create(:users_project) - end - - it "should send email to user" do - subject.should_receive(:notification) - Event.stub(create: true) - - create(:users_project) - end - - it "should create new event" do - Event.should_receive(:create) - - create(:users_project) - end - end + before { subject.stub(notification: double('NotificationService').as_null_object) } describe "#after_update" do before do @@ -35,17 +15,17 @@ describe UsersProjectObserver do end it "should called when UsersProject updated" do - subject.should_receive(:after_commit) + subject.should_receive(:after_update) @users_project.update_attribute(:project_access, UsersProject::MASTER) end it "should send email to user" do subject.should_receive(:notification) - @users_project.update_attribute(:project_access, UsersProject::MASTER) + @users_project.update_attribute(:project_access, UsersProject::OWNER) end it "should not called after UsersProject destroyed" do - subject.should_not_receive(:after_commit) + subject.should_not_receive(:after_update) @users_project.destroy end end @@ -67,28 +47,17 @@ describe UsersProjectObserver do end describe "#after_create" do - context 'wiki_enabled creates repository directory' do - context 'wiki_enabled true creates wiki repository directory' do - before do - @project = create(:project, wiki_enabled: true) - @path = GollumWiki.new(@project, user).send(:path_to_repo) - end + it "should send email to user" do + subject.should_receive(:notification) + Event.stub(create: true) - after do - FileUtils.rm_rf(@path) - end + create(:users_project) + end - it { File.exists?(@path).should be_true } - end + it "should create new event" do + Event.should_receive(:create) - context 'wiki_enabled false does not create wiki repository directory' do - before do - @project = create(:project, wiki_enabled: false) - @path = GollumWiki.new(@project, user).send(:path_to_repo) - end - - it { File.exists?(@path).should be_false } - end + create(:users_project) end end -end \ No newline at end of file +end diff --git a/spec/requests/api/api_helpers_spec.rb b/spec/requests/api/api_helpers_spec.rb index 2fc78a7e39..e2f222c0d3 100644 --- a/spec/requests/api/api_helpers_spec.rb +++ b/spec/requests/api/api_helpers_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API do +describe API, api: true do include API::APIHelpers include ApiHelpers let(:user) { create(:user) } @@ -39,6 +39,17 @@ describe API do end describe ".current_user" do + it "should return nil for an invalid token" do + env[API::APIHelpers::PRIVATE_TOKEN_HEADER] = 'invalid token' + current_user.should be_nil + end + + it "should return nil for a user without access" do + env[API::APIHelpers::PRIVATE_TOKEN_HEADER] = user.private_token + Gitlab::UserAccess.stub(allowed?: false) + current_user.should be_nil + end + it "should leave user as is when sudo not specified" do env[API::APIHelpers::PRIVATE_TOKEN_HEADER] = user.private_token current_user.should == user @@ -158,4 +169,4 @@ describe API do sudo_identifier.should == ' 123' end end -end \ No newline at end of file +end diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb new file mode 100644 index 0000000000..abf6a8646e --- /dev/null +++ b/spec/requests/api/branches_spec.rb @@ -0,0 +1,115 @@ +require 'spec_helper' +require 'mime/types' + +describe API::API, api: true do + include ApiHelpers + before(:each) { enable_observers } + after(:each) {disable_observers} + + let(:user) { create(:user) } + let(:user2) { create(:user) } + let!(:project) { create(:project, creator_id: user.id) } + let!(:master) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } + let!(:guest) { create(:users_project, user: user2, project: project, project_access: UsersProject::GUEST) } + + describe "GET /projects/:id/repository/branches" do + it "should return an array of project branches" do + get api("/projects/#{project.id}/repository/branches", user) + response.status.should == 200 + json_response.should be_an Array + json_response.first['name'].should == project.repo.heads.sort_by(&:name).first.name + end + end + + describe "GET /projects/:id/repository/branches/:branch" do + it "should return the branch information for a single branch" do + get api("/projects/#{project.id}/repository/branches/new_design", user) + response.status.should == 200 + + json_response['name'].should == 'new_design' + json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1' + json_response['protected'].should == false + end + + it "should return a 403 error if guest" do + get api("/projects/#{project.id}/repository/branches", user2) + response.status.should == 403 + end + + it "should return a 404 error if branch is not available" do + get api("/projects/#{project.id}/repository/branches/unknown", user) + response.status.should == 404 + end + end + + describe "PUT /projects/:id/repository/branches/:branch/protect" do + it "should protect a single branch" do + put api("/projects/#{project.id}/repository/branches/new_design/protect", user) + response.status.should == 200 + + json_response['name'].should == 'new_design' + json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1' + json_response['protected'].should == true + end + + it "should return a 404 error if branch not found" do + put api("/projects/#{project.id}/repository/branches/unknown/protect", user) + response.status.should == 404 + end + + it "should return a 403 error if guest" do + put api("/projects/#{project.id}/repository/branches/new_design/protect", user2) + response.status.should == 403 + end + + it "should return success when protect branch again" do + put api("/projects/#{project.id}/repository/branches/new_design/protect", user) + put api("/projects/#{project.id}/repository/branches/new_design/protect", user) + response.status.should == 200 + end + end + + describe "PUT /projects/:id/repository/branches/:branch/unprotect" do + it "should unprotect a single branch" do + put api("/projects/#{project.id}/repository/branches/new_design/unprotect", user) + response.status.should == 200 + + json_response['name'].should == 'new_design' + json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1' + json_response['protected'].should == false + end + + it "should return success when unprotect branch" do + put api("/projects/#{project.id}/repository/branches/unknown/unprotect", user) + response.status.should == 404 + end + + it "should return success when unprotect branch again" do + put api("/projects/#{project.id}/repository/branches/new_design/unprotect", user) + put api("/projects/#{project.id}/repository/branches/new_design/unprotect", user) + response.status.should == 200 + end + end + + + describe "POST /projects/:id/repository/branches" do + it "should create a new branch" do + post api("/projects/#{project.id}/repository/branches", user), + branch_name: 'new_design', + ref: '621491c677087aa243f165eab467bfdfbee00be1' + + response.status.should == 201 + + json_response['name'].should == 'new_design' + json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1' + end + + it "should deny for user without push access" do + post api("/projects/#{project.id}/repository/branches", user2), + branch_name: 'new_design', + ref: '621491c677087aa243f165eab467bfdfbee00be1' + + response.status.should == 403 + end + end +end diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb new file mode 100644 index 0000000000..165276d143 --- /dev/null +++ b/spec/requests/api/commits_spec.rb @@ -0,0 +1,87 @@ +require 'spec_helper' +require 'mime/types' + +describe API::API, api: true do + include ApiHelpers + before(:each) { enable_observers } + after(:each) {disable_observers} + + let(:user) { create(:user) } + let(:user2) { create(:user) } + let!(:project) { create(:project, creator_id: user.id) } + let!(:master) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } + let!(:guest) { create(:users_project, user: user2, project: project, project_access: UsersProject::GUEST) } + + before { project.team << [user, :reporter] } + + describe "GET /projects/:id/repository/commits" do + context "authorized user" do + before { project.team << [user2, :reporter] } + + it "should return project commits" do + get api("/projects/#{project.id}/repository/commits", user) + response.status.should == 200 + + json_response.should be_an Array + json_response.first['id'].should == project.repository.commit.id + end + end + + context "unauthorized user" do + it "should not return project commits" do + get api("/projects/#{project.id}/repository/commits") + response.status.should == 401 + end + end + end + + describe "GET /projects:id/repository/commits/:sha" do + context "authorized user" do + it "should return a commit by sha" do + get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) + response.status.should == 200 + json_response['id'].should == project.repository.commit.id + json_response['title'].should == project.repository.commit.title + end + + it "should return a 404 error if not found" do + get api("/projects/#{project.id}/repository/commits/invalid_sha", user) + response.status.should == 404 + end + end + + context "unauthorized user" do + it "should not return the selected commit" do + get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}") + response.status.should == 401 + end + end + end + + describe "GET /projects:id/repository/commits/:sha/diff" do + context "authorized user" do + before { project.team << [user2, :reporter] } + + it "should return the diff of the selected commit" do + get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff", user) + response.status.should == 200 + + json_response.should be_an Array + json_response.length.should >= 1 + json_response.first.keys.should include "diff" + end + + it "should return a 404 error if invalid commit" do + get api("/projects/#{project.id}/repository/commits/invalid_sha/diff", user) + response.status.should == 404 + end + end + + context "unauthorized user" do + it "should not return the diff of the selected commit" do + get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff") + response.status.should == 401 + end + end + end +end diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb new file mode 100644 index 0000000000..edfe935d98 --- /dev/null +++ b/spec/requests/api/files_spec.rb @@ -0,0 +1,145 @@ +require 'spec_helper' + +describe API::API, api: true do + include ApiHelpers + before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } + after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } + + let(:user) { create(:user) } + let!(:project) { create(:project, namespace: user.namespace ) } + before { project.team << [user, :developer] } + + describe "GET /projects/:id/repository/files" do + it "should return file info" do + params = { + file_path: 'app/models/key.rb', + ref: 'master', + } + + get api("/projects/#{project.id}/repository/files", user), params + response.status.should == 200 + json_response['file_path'].should == 'app/models/key.rb' + json_response['file_name'].should == 'key.rb' + Base64.decode64(json_response['content']).lines.first.should == "class Key < ActiveRecord::Base\n" + end + + it "should return a 400 bad request if no params given" do + get api("/projects/#{project.id}/repository/files", user) + response.status.should == 400 + end + + it "should return a 404 if such file does not exist" do + params = { + file_path: 'app/models/application.rb', + ref: 'master', + } + + get api("/projects/#{project.id}/repository/files", user), params + response.status.should == 404 + end + end + + describe "POST /projects/:id/repository/files" do + let(:valid_params) { + { + file_path: 'newfile.rb', + branch_name: 'master', + content: 'puts 8', + commit_message: 'Added newfile' + } + } + + it "should create a new file in project repo" do + Gitlab::Satellite::NewFileAction.any_instance.stub( + commit!: true, + ) + + post api("/projects/#{project.id}/repository/files", user), valid_params + response.status.should == 201 + json_response['file_path'].should == 'newfile.rb' + end + + it "should return a 400 bad request if no params given" do + post api("/projects/#{project.id}/repository/files", user) + response.status.should == 400 + end + + it "should return a 400 if satellite fails to create file" do + Gitlab::Satellite::NewFileAction.any_instance.stub( + commit!: false, + ) + + post api("/projects/#{project.id}/repository/files", user), valid_params + response.status.should == 400 + end + end + + describe "PUT /projects/:id/repository/files" do + let(:valid_params) { + { + file_path: 'spec/spec_helper.rb', + branch_name: 'master', + content: 'puts 8', + commit_message: 'Changed file' + } + } + + it "should update existing file in project repo" do + Gitlab::Satellite::EditFileAction.any_instance.stub( + commit!: true, + ) + + put api("/projects/#{project.id}/repository/files", user), valid_params + response.status.should == 200 + json_response['file_path'].should == 'spec/spec_helper.rb' + end + + it "should return a 400 bad request if no params given" do + put api("/projects/#{project.id}/repository/files", user) + response.status.should == 400 + end + + it "should return a 400 if satellite fails to create file" do + Gitlab::Satellite::EditFileAction.any_instance.stub( + commit!: false, + ) + + put api("/projects/#{project.id}/repository/files", user), valid_params + response.status.should == 400 + end + end + + describe "DELETE /projects/:id/repository/files" do + let(:valid_params) { + { + file_path: 'spec/spec_helper.rb', + branch_name: 'master', + commit_message: 'Changed file' + } + } + + it "should delete existing file in project repo" do + Gitlab::Satellite::DeleteFileAction.any_instance.stub( + commit!: true, + ) + + delete api("/projects/#{project.id}/repository/files", user), valid_params + response.status.should == 200 + json_response['file_path'].should == 'spec/spec_helper.rb' + end + + it "should return a 400 bad request if no params given" do + delete api("/projects/#{project.id}/repository/files", user) + response.status.should == 400 + end + + it "should return a 400 if satellite fails to create file" do + Gitlab::Satellite::DeleteFileAction.any_instance.stub( + commit!: false, + ) + + delete api("/projects/#{project.id}/repository/files", user), valid_params + response.status.should == 400 + end + end +end diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 25b9a10bd8..6fcab85335 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe API::API, api: true do include ApiHelpers let(:user1) { create(:user) } @@ -147,7 +147,7 @@ describe API::API do describe "POST /groups/:id/projects/:project_id" do let(:project) { create(:project) } before(:each) do - project.stub!(:transfer).and_return(true) + project.stub(:transfer).and_return(true) Project.stub(:find).and_return(project) end diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index e8870f4d5d..8797c3fbbb 100644 --- a/spec/requests/api/internal_spec.rb +++ b/spec/requests/api/internal_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe API::API, api: true do include ApiHelpers before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } @@ -103,6 +103,33 @@ describe API::API do end end + context "archived project" do + let(:personal_project) { create(:project, namespace: user.namespace) } + + before do + project.team << [user, :developer] + project.archive! + end + + context "git pull" do + it do + pull(key, project) + + response.status.should == 200 + response.body.should == 'true' + end + end + + context "git push" do + it do + push(key, project) + + response.status.should == 200 + response.body.should == 'false' + end + end + end + context "deploy key" do let(:key) { create(:deploy_key) } diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index c55025d72b..e62bc84435 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe API::API, api: true do include ApiHelpers before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } @@ -25,6 +25,12 @@ describe API::API do json_response.should be_an Array json_response.first['title'].should == issue.title end + + it "should add pagination headers" do + get api("/issues?per_page=3", user) + response.headers['Link'].should == + '; rel="first", ; rel="last"' + end end end @@ -100,16 +106,4 @@ describe API::API do response.status.should == 405 end end - - describe "PUT /projects/:id/issues/:issue_id to test observer on close" do - before { enable_observers } - after { disable_observers } - - it "should create an activity event when an issue is closed" do - Event.should_receive(:create) - - put api("/projects/#{project.id}/issues/#{issue.id}", user), - state_event: "close" - end - end end diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index f31b4da90c..2fb3684fdf 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -1,12 +1,15 @@ require "spec_helper" -describe API::API do +describe API::API, api: true do include ApiHelpers before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } let(:user) { create(:user) } - let!(:project) {create(:project_with_code, creator_id: user.id, namespace: user.namespace) } - let!(:merge_request) { create(:merge_request, author: user, assignee: user, source_project: project, target_project: project, title: "Test") } + let!(:project) {create(:project, creator_id: user.id, namespace: user.namespace) } + let!(:merge_request) { create(:merge_request, :simple, author: user, assignee: user, source_project: project, target_project: project, title: "Test") } + let!(:merge_request_closed) { create(:merge_request, state: "closed", author: user, assignee: user, source_project: project, target_project: project, title: "Closed test") } + let!(:merge_request_merged) { create(:merge_request, state: "merged", author: user, assignee: user, source_project: project, target_project: project, title: "Merged test") } + let!(:note) { create(:note_on_merge_request, author: user, project: project, noteable: merge_request, note: "a comment on a MR") } before { project.team << [user, :reporters] } @@ -20,12 +23,42 @@ describe API::API do end context "when authenticated" do - it "should return an array of merge_requests" do + it "should return an array of all merge_requests" do get api("/projects/#{project.id}/merge_requests", user) response.status.should == 200 json_response.should be_an Array + json_response.length.should == 3 json_response.first['title'].should == merge_request.title end + it "should return an array of all merge_requests" do + get api("/projects/#{project.id}/merge_requests?state", user) + response.status.should == 200 + json_response.should be_an Array + json_response.length.should == 3 + json_response.first['title'].should == merge_request.title + end + it "should return an array of open merge_requests" do + get api("/projects/#{project.id}/merge_requests?state=opened", user) + response.status.should == 200 + json_response.should be_an Array + json_response.length.should == 1 + json_response.first['title'].should == merge_request.title + end + it "should return an array of closed merge_requests" do + get api("/projects/#{project.id}/merge_requests?state=closed", user) + response.status.should == 200 + json_response.should be_an Array + json_response.length.should == 2 + json_response.first['title'].should == merge_request_closed.title + json_response.second['title'].should == merge_request_merged.title + end + it "should return an array of merged merge_requests" do + get api("/projects/#{project.id}/merge_requests?state=merged", user) + response.status.should == 200 + json_response.should be_an Array + json_response.length.should == 1 + json_response.first['title'].should == merge_request_merged.title + end end end @@ -47,54 +80,51 @@ describe API::API do context 'between branches projects' do it "should return merge_request" do post api("/projects/#{project.id}/merge_requests", user), - title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user + title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user response.status.should == 201 json_response['title'].should == 'Test merge_request' end it "should return 422 when source_branch equals target_branch" do post api("/projects/#{project.id}/merge_requests", user), - title: "Test merge_request", source_branch: "master", target_branch: "master", author: user + title: "Test merge_request", source_branch: "master", target_branch: "master", author: user response.status.should == 422 end it "should return 400 when source_branch is missing" do post api("/projects/#{project.id}/merge_requests", user), - title: "Test merge_request", target_branch: "master", author: user + title: "Test merge_request", target_branch: "master", author: user response.status.should == 400 end it "should return 400 when target_branch is missing" do post api("/projects/#{project.id}/merge_requests", user), - title: "Test merge_request", source_branch: "stable", author: user + title: "Test merge_request", source_branch: "stable", author: user response.status.should == 400 end it "should return 400 when title is missing" do post api("/projects/#{project.id}/merge_requests", user), - target_branch: 'master', source_branch: 'stable' + target_branch: 'master', source_branch: 'stable' response.status.should == 400 end end context 'forked projects' do - let!(:user2) {create(:user)} - let!(:forked_project_link) { build(:forked_project_link) } - let!(:fork_project) { create(:source_project_with_code, forked_project_link: forked_project_link, namespace: user2.namespace, creator_id: user2.id) } - let!(:unrelated_project) { create(:target_project_with_code, namespace: user2.namespace, creator_id: user2.id) } + let!(:user2) { create(:user) } + let!(:fork_project) { create(:project, forked_from_project: project, namespace: user2.namespace, creator_id: user2.id) } + let!(:unrelated_project) { create(:project, namespace: create(:user).namespace, creator_id: user2.id) } before :each do |each| fork_project.team << [user2, :reporters] - forked_project_link.forked_from_project = project - forked_project_link.forked_to_project = fork_project - forked_project_link.save! end it "should return merge_request" do post api("/projects/#{fork_project.id}/merge_requests", user2), - title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user2, target_project_id: project.id + title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user2, target_project_id: project.id, description: 'Test description for Test merge_request' response.status.should == 201 json_response['title'].should == 'Test merge_request' + json_response['description'].should == 'Test description for Test merge_request' end it "should not return 422 when source_branch equals target_branch" do @@ -102,44 +132,44 @@ describe API::API do fork_project.forked?.should be_true fork_project.forked_from_project.should == project post api("/projects/#{fork_project.id}/merge_requests", user2), - title: 'Test merge_request', source_branch: "master", target_branch: "master", author: user2, target_project_id: project.id + title: 'Test merge_request', source_branch: "master", target_branch: "master", author: user2, target_project_id: project.id response.status.should == 201 json_response['title'].should == 'Test merge_request' end it "should return 400 when source_branch is missing" do post api("/projects/#{fork_project.id}/merge_requests", user2), - title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id + title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id response.status.should == 400 end it "should return 400 when target_branch is missing" do post api("/projects/#{fork_project.id}/merge_requests", user2), - title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id + title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id response.status.should == 400 end it "should return 400 when title is missing" do post api("/projects/#{fork_project.id}/merge_requests", user2), - target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: project.id + target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: project.id response.status.should == 400 end - it "should return 400 when target_branch is specified and not a forked project" do + it "should return 404 when target_branch is specified and not a forked project" do post api("/projects/#{project.id}/merge_requests", user), - title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user, target_project_id: fork_project.id - response.status.should == 400 + title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user, target_project_id: fork_project.id + response.status.should == 404 end - it "should return 400 when target_branch is specified and for a different fork" do + it "should return 404 when target_branch is specified and for a different fork" do post api("/projects/#{fork_project.id}/merge_requests", user2), - title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: unrelated_project.id - response.status.should == 400 + title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: unrelated_project.id + response.status.should == 404 end it "should return 201 when target_branch is specified and for the same project" do post api("/projects/#{fork_project.id}/merge_requests", user2), - title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: fork_project.id + title: 'Test merge_request', target_branch: 'master', source_branch: 'stable', author: user2, target_project_id: fork_project.id response.status.should == 201 end end @@ -153,11 +183,33 @@ describe API::API do end end - describe "PUT /projects/:id/merge_request/:merge_request_id to merge MR" do - it "should return merge_request" do - put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), state_event: "merge" + describe "PUT /projects/:id/merge_request/:merge_request_id/merge" do + it "should return merge_request in case of success" do + MergeRequest.any_instance.stub(can_be_merged?: true, automerge!: true) + put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user) response.status.should == 200 - json_response['state'].should == 'merged' + end + + it "should return 405 if branch can't be merged" do + MergeRequest.any_instance.stub(can_be_merged?: false) + put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user) + response.status.should == 405 + json_response['message'].should == 'Branch cannot be merged' + end + + it "should return 405 if merge_request is not open" do + merge_request.close + put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user) + response.status.should == 405 + json_response['message'].should == 'Method Not Allowed' + end + + it "should return 401 if user has no permissions to merge" do + user2 = create(:user) + project.team << [user2, :reporter] + put api("/projects/#{project.id}/merge_request/#{merge_request.id}/merge", user2) + response.status.should == 401 + json_response['message'].should == '401 Unauthorized' end end @@ -168,9 +220,15 @@ describe API::API do json_response['title'].should == 'New title' end + it "should return merge_request" do + put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), description: "New description" + response.status.should == 200 + json_response['description'].should == 'New description' + end + it "should return 422 when source_branch and target_branch are renamed the same" do put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), - source_branch: "master", target_branch: "master" + source_branch: "master", target_branch: "master" response.status.should == 422 end @@ -199,4 +257,19 @@ describe API::API do end end + describe "GET :id/merge_request/:merge_request_id/comments" do + it "should return merge_request comments" do + get api("/projects/#{project.id}/merge_request/#{merge_request.id}/comments", user) + response.status.should == 200 + json_response.should be_an Array + json_response.length.should == 1 + json_response.first['note'].should == "a comment on a MR" + json_response.first['author']['id'].should == user.id + end + + it "should return a 404 error if merge_request_id not found" do + get api("/projects/#{project.id}/merge_request/999/comments", user) + response.status.should == 404 + end + end end diff --git a/spec/requests/api/milestones_spec.rb b/spec/requests/api/milestones_spec.rb index febfc63921..0d2740c5ac 100644 --- a/spec/requests/api/milestones_spec.rb +++ b/spec/requests/api/milestones_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe API::API, api: true do include ApiHelpers before(:each) { enable_observers } after(:each) {disable_observers} diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb new file mode 100644 index 0000000000..2de7d1e23c --- /dev/null +++ b/spec/requests/api/namespaces_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe API::API, api: true do + include ApiHelpers + before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } + after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } + + let(:admin) { create(:admin) } + let!(:group1) { create(:group) } + let!(:group2) { create(:group) } + + describe "GET /namespaces" do + context "when unauthenticated" do + it "should return authentication error" do + get api("/namespaces") + response.status.should == 401 + end + end + + context "when authenticated as admin" do + it "admin: should return an array of all namespaces" do + get api("/namespaces", admin) + response.status.should == 200 + json_response.should be_an Array + + # Admin namespace + 2 group namespaces + json_response.length.should == 3 + end + end + end +end diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb index 6ed96eb97f..81576f7c23 100644 --- a/spec/requests/api/notes_spec.rb +++ b/spec/requests/api/notes_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe API::API, api: true do include ApiHelpers before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb new file mode 100644 index 0000000000..6e281f5a43 --- /dev/null +++ b/spec/requests/api/project_hooks_spec.rb @@ -0,0 +1,132 @@ +require 'spec_helper' + +describe API::API, 'ProjectHooks', api: true do + include ApiHelpers + before(:each) { enable_observers } + after(:each) { disable_observers } + + let(:user) { create(:user) } + let(:user3) { create(:user) } + let!(:project) { create(:project, creator_id: user.id, namespace: user.namespace) } + let!(:hook) { create(:project_hook, project: project, url: "http://example.com") } + + before do + project.team << [user, :master] + project.team << [user3, :developer] + end + + describe "GET /projects/:id/hooks" do + context "authorized user" do + it "should return project hooks" do + get api("/projects/#{project.id}/hooks", user) + response.status.should == 200 + + json_response.should be_an Array + json_response.count.should == 1 + json_response.first['url'].should == "http://example.com" + end + end + + context "unauthorized user" do + it "should not access project hooks" do + get api("/projects/#{project.id}/hooks", user3) + response.status.should == 403 + end + end + end + + describe "GET /projects/:id/hooks/:hook_id" do + context "authorized user" do + it "should return a project hook" do + get api("/projects/#{project.id}/hooks/#{hook.id}", user) + response.status.should == 200 + json_response['url'].should == hook.url + end + + it "should return a 404 error if hook id is not available" do + get api("/projects/#{project.id}/hooks/1234", user) + response.status.should == 404 + end + end + + context "unauthorized user" do + it "should not access an existing hook" do + get api("/projects/#{project.id}/hooks/#{hook.id}", user3) + response.status.should == 403 + end + end + + it "should return a 404 error if hook id is not available" do + get api("/projects/#{project.id}/hooks/1234", user) + response.status.should == 404 + end + end + + describe "POST /projects/:id/hooks" do + it "should add hook to project" do + expect { + post api("/projects/#{project.id}/hooks", user), + url: "http://example.com", issues_events: true + }.to change {project.hooks.count}.by(1) + response.status.should == 201 + end + + it "should return a 400 error if url not given" do + post api("/projects/#{project.id}/hooks", user) + response.status.should == 400 + end + + it "should return a 422 error if url not valid" do + post api("/projects/#{project.id}/hooks", user), "url" => "ftp://example.com" + response.status.should == 422 + end + end + + describe "PUT /projects/:id/hooks/:hook_id" do + it "should update an existing project hook" do + put api("/projects/#{project.id}/hooks/#{hook.id}", user), + url: 'http://example.org', push_events: false + response.status.should == 200 + json_response['url'].should == 'http://example.org' + end + + it "should return 404 error if hook id not found" do + put api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org' + response.status.should == 404 + end + + it "should return 400 error if url is not given" do + put api("/projects/#{project.id}/hooks/#{hook.id}", user) + response.status.should == 400 + end + + it "should return a 422 error if url is not valid" do + put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com' + response.status.should == 422 + end + end + + describe "DELETE /projects/:id/hooks/:hook_id" do + it "should delete hook from project" do + expect { + delete api("/projects/#{project.id}/hooks/#{hook.id}", user) + }.to change {project.hooks.count}.by(-1) + response.status.should == 200 + end + + it "should return success when deleting hook" do + delete api("/projects/#{project.id}/hooks/#{hook.id}", user) + response.status.should == 200 + end + + it "should return success when deleting non existent hook" do + delete api("/projects/#{project.id}/hooks/42", user) + response.status.should == 200 + end + + it "should return a 405 error if hook id not given" do + delete api("/projects/#{project.id}/hooks", user) + response.status.should == 405 + end + end +end diff --git a/spec/requests/api/project_members_spec.rb b/spec/requests/api/project_members_spec.rb new file mode 100644 index 0000000000..ec2d6e8509 --- /dev/null +++ b/spec/requests/api/project_members_spec.rb @@ -0,0 +1,156 @@ +require 'spec_helper' + +describe API::API, api: true do + include ApiHelpers + before(:each) { enable_observers } + after(:each) { disable_observers } + + let(:user) { create(:user) } + let(:user2) { create(:user) } + let(:user3) { create(:user) } + let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) } + let(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } + let(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) } + + describe "GET /projects/:id/members" do + before { users_project } + before { users_project2 } + + it "should return project team members" do + get api("/projects/#{project.id}/members", user) + response.status.should == 200 + json_response.should be_an Array + json_response.count.should == 2 + json_response.map { |u| u['email'] }.should include user.email + end + + it "finds team members with query string" do + get api("/projects/#{project.id}/members", user), query: user.username + response.status.should == 200 + json_response.should be_an Array + json_response.count.should == 1 + json_response.first['email'].should == user.email + end + + it "should return a 404 error if id not found" do + get api("/projects/9999/members", user) + response.status.should == 404 + end + end + + describe "GET /projects/:id/members/:user_id" do + before { users_project } + + it "should return project team member" do + get api("/projects/#{project.id}/members/#{user.id}", user) + response.status.should == 200 + json_response['email'].should == user.email + json_response['access_level'].should == UsersProject::MASTER + end + + it "should return a 404 error if user id not found" do + get api("/projects/#{project.id}/members/1234", user) + response.status.should == 404 + end + end + + describe "POST /projects/:id/members" do + it "should add user to project team" do + expect { + post api("/projects/#{project.id}/members", user), user_id: user2.id, + access_level: UsersProject::DEVELOPER + }.to change { UsersProject.count }.by(1) + + response.status.should == 201 + json_response['email'].should == user2.email + json_response['access_level'].should == UsersProject::DEVELOPER + end + + it "should return a 201 status if user is already project member" do + post api("/projects/#{project.id}/members", user), user_id: user2.id, + access_level: UsersProject::DEVELOPER + expect { + post api("/projects/#{project.id}/members", user), user_id: user2.id, + access_level: UsersProject::DEVELOPER + }.not_to change { UsersProject.count }.by(1) + + response.status.should == 201 + json_response['email'].should == user2.email + json_response['access_level'].should == UsersProject::DEVELOPER + end + + it "should return a 400 error when user id is not given" do + post api("/projects/#{project.id}/members", user), access_level: UsersProject::MASTER + response.status.should == 400 + end + + it "should return a 400 error when access level is not given" do + post api("/projects/#{project.id}/members", user), user_id: user2.id + response.status.should == 400 + end + + it "should return a 422 error when access level is not known" do + post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: 1234 + response.status.should == 422 + end + end + + describe "PUT /projects/:id/members/:user_id" do + before { users_project2 } + + it "should update project team member" do + put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: UsersProject::MASTER + response.status.should == 200 + json_response['email'].should == user3.email + json_response['access_level'].should == UsersProject::MASTER + end + + it "should return a 404 error if user_id is not found" do + put api("/projects/#{project.id}/members/1234", user), access_level: UsersProject::MASTER + response.status.should == 404 + end + + it "should return a 400 error when access level is not given" do + put api("/projects/#{project.id}/members/#{user3.id}", user) + response.status.should == 400 + end + + it "should return a 422 error when access level is not known" do + put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: 123 + response.status.should == 422 + end + end + + describe "DELETE /projects/:id/members/:user_id" do + before { users_project } + before { users_project2 } + + it "should remove user from project team" do + expect { + delete api("/projects/#{project.id}/members/#{user3.id}", user) + }.to change { UsersProject.count }.by(-1) + end + + it "should return 200 if team member is not part of a project" do + delete api("/projects/#{project.id}/members/#{user3.id}", user) + expect { + delete api("/projects/#{project.id}/members/#{user3.id}", user) + }.to_not change { UsersProject.count }.by(1) + end + + it "should return 200 if team member already removed" do + delete api("/projects/#{project.id}/members/#{user3.id}", user) + delete api("/projects/#{project.id}/members/#{user3.id}", user) + response.status.should == 200 + end + + it "should return 200 OK when the user was not member" do + expect { + delete api("/projects/#{project.id}/members/1000000", user) + }.to change { UsersProject.count }.by(0) + response.status.should == 200 + json_response['message'].should == "Access revoked" + json_response['id'].should == 1000000 + end + end +end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index bf4a174941..81e6abbb0d 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe API::API, api: true do include ApiHelpers before(:each) { enable_observers } after(:each) { disable_observers } @@ -9,15 +9,21 @@ describe API::API do let(:user2) { create(:user) } let(:user3) { create(:user) } let(:admin) { create(:admin) } - let!(:project) { create(:project_with_code, creator_id: user.id, namespace: user.namespace) } - let!(:hook) { create(:project_hook, project: project, url: "http://example.com") } - let!(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') } - let!(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } - let!(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) } + let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) } + let(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') } + let(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } + let(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) } + let(:issue_with_labels) { create(:issue, author: user, assignee: user, project: project, :label_list => "label1, label2") } + let(:merge_request_with_labels) do + create(:merge_request, :simple, author: user, assignee: user, + source_project: project, target_project: project, title: 'Test', + label_list: 'label3, label4') + end - before { project.team << [user, :reporter] } describe "GET /projects" do + before { project } + context "when unauthenticated" do it "should return authentication error" do get api("/projects") @@ -36,6 +42,34 @@ describe API::API do end end + describe "GET /projects/all" do + before { project } + + context "when unauthenticated" do + it "should return authentication error" do + get api("/projects/all") + response.status.should == 401 + end + end + + context "when authenticated as regular user" do + it "should return authentication error" do + get api("/projects/all", user) + response.status.should == 403 + end + end + + context "when authenticated as admin" do + it "should return an array of all projects" do + get api("/projects/all", admin) + response.status.should == 200 + json_response.should be_an Array + json_response.first['name'].should == project.name + json_response.first['owner']['email'].should == user.email + end + end + end + describe "POST /projects" do context "maximum number of projects reached" do before do @@ -91,7 +125,6 @@ describe API::API do it "should assign attributes to project" do project = attributes_for(:project, { description: Faker::Lorem.sentence, - default_branch: 'stable', issues_enabled: false, wall_enabled: false, merge_requests_enabled: false, @@ -107,22 +140,50 @@ describe API::API do end it "should set a project as public" do + project = attributes_for(:project, :public) + post api("/projects", user), project + json_response['public'].should be_true + json_response['visibility_level'].should == Gitlab::VisibilityLevel::PUBLIC + end + + it "should set a project as public using :public" do project = attributes_for(:project, { public: true }) post api("/projects", user), project json_response['public'].should be_true + json_response['visibility_level'].should == Gitlab::VisibilityLevel::PUBLIC + end + it "should set a project as internal" do + project = attributes_for(:project, :internal) + post api("/projects", user), project + json_response['public'].should be_false + json_response['visibility_level'].should == Gitlab::VisibilityLevel::INTERNAL + end + + it "should set a project as internal overriding :public" do + project = attributes_for(:project, :internal, { public: true }) + post api("/projects", user), project + json_response['public'].should be_false + json_response['visibility_level'].should == Gitlab::VisibilityLevel::INTERNAL end it "should set a project as private" do + project = attributes_for(:project, :private) + post api("/projects", user), project + json_response['public'].should be_false + json_response['visibility_level'].should == Gitlab::VisibilityLevel::PRIVATE + end + + it "should set a project as private using :public" do project = attributes_for(:project, { public: false }) post api("/projects", user), project json_response['public'].should be_false - + json_response['visibility_level'].should == Gitlab::VisibilityLevel::PRIVATE end - end describe "POST /projects/user/:id" do + before { project } before { admin } it "should create new project without path" do @@ -146,7 +207,6 @@ describe API::API do it "should assign attributes to project" do project = attributes_for(:project, { description: Faker::Lorem.sentence, - default_branch: 'stable', issues_enabled: false, wall_enabled: false, merge_requests_enabled: false, @@ -162,22 +222,52 @@ describe API::API do end it "should set a project as public" do + project = attributes_for(:project, :public) + post api("/projects/user/#{user.id}", admin), project + json_response['public'].should be_true + json_response['visibility_level'].should == Gitlab::VisibilityLevel::PUBLIC + end + + it "should set a project as public using :public" do project = attributes_for(:project, { public: true }) post api("/projects/user/#{user.id}", admin), project json_response['public'].should be_true + json_response['visibility_level'].should == Gitlab::VisibilityLevel::PUBLIC + end + it "should set a project as internal" do + project = attributes_for(:project, :internal) + post api("/projects/user/#{user.id}", admin), project + json_response['public'].should be_false + json_response['visibility_level'].should == Gitlab::VisibilityLevel::INTERNAL + end + + it "should set a project as internal overriding :public" do + project = attributes_for(:project, :internal, { public: true }) + post api("/projects/user/#{user.id}", admin), project + json_response['public'].should be_false + json_response['visibility_level'].should == Gitlab::VisibilityLevel::INTERNAL end it "should set a project as private" do + project = attributes_for(:project, :private) + post api("/projects/user/#{user.id}", admin), project + json_response['public'].should be_false + json_response['visibility_level'].should == Gitlab::VisibilityLevel::PRIVATE + end + + it "should set a project as private using :public" do project = attributes_for(:project, { public: false }) post api("/projects/user/#{user.id}", admin), project json_response['public'].should be_false - + json_response['visibility_level'].should == Gitlab::VisibilityLevel::PRIVATE end - end describe "GET /projects/:id" do + before { project } + before { users_project } + it "should return a project by id" do get api("/projects/#{project.id}", user) response.status.should == 200 @@ -202,9 +292,33 @@ describe API::API do get api("/projects/#{project.id}", other_user) response.status.should == 404 end + + describe 'permissions' do + context 'personal project' do + before { get api("/projects/#{project.id}", user) } + + it { response.status.should == 200 } + it { json_response['permissions']["project_access"]["access_level"].should == Gitlab::Access::MASTER } + it { json_response['permissions']["group_access"].should be_nil } + end + + context 'group project' do + before do + project2 = create(:project, group: create(:group)) + project2.group.add_owner(user) + get api("/projects/#{project2.id}", user) + end + + it { response.status.should == 200 } + it { json_response['permissions']["project_access"].should be_nil } + it { json_response['permissions']["group_access"]["access_level"].should == Gitlab::Access::OWNER } + end + end end describe "GET /projects/:id/events" do + before { users_project } + it "should return a project events" do get api("/projects/#{project.id}/events", user) response.status.should == 200 @@ -227,256 +341,9 @@ describe API::API do end end - describe "GET /projects/:id/members" do - it "should return project team members" do - get api("/projects/#{project.id}/members", user) - response.status.should == 200 - json_response.should be_an Array - json_response.count.should == 2 - json_response.map { |u| u['email'] }.should include user.email - end - - it "finds team members with query string" do - get api("/projects/#{project.id}/members", user), query: user.username - response.status.should == 200 - json_response.should be_an Array - json_response.count.should == 1 - json_response.first['email'].should == user.email - end - - it "should return a 404 error if id not found" do - get api("/projects/9999/members", user) - response.status.should == 404 - end - end - - describe "GET /projects/:id/members/:user_id" do - it "should return project team member" do - get api("/projects/#{project.id}/members/#{user.id}", user) - response.status.should == 200 - json_response['email'].should == user.email - json_response['access_level'].should == UsersProject::MASTER - end - - it "should return a 404 error if user id not found" do - get api("/projects/#{project.id}/members/1234", user) - response.status.should == 404 - end - end - - describe "POST /projects/:id/members" do - it "should add user to project team" do - expect { - post api("/projects/#{project.id}/members", user), user_id: user2.id, - access_level: UsersProject::DEVELOPER - }.to change { UsersProject.count }.by(1) - - response.status.should == 201 - json_response['email'].should == user2.email - json_response['access_level'].should == UsersProject::DEVELOPER - end - - it "should return a 201 status if user is already project member" do - post api("/projects/#{project.id}/members", user), user_id: user2.id, - access_level: UsersProject::DEVELOPER - expect { - post api("/projects/#{project.id}/members", user), user_id: user2.id, - access_level: UsersProject::DEVELOPER - }.not_to change { UsersProject.count }.by(1) - - response.status.should == 201 - json_response['email'].should == user2.email - json_response['access_level'].should == UsersProject::DEVELOPER - end - - it "should return a 400 error when user id is not given" do - post api("/projects/#{project.id}/members", user), access_level: UsersProject::MASTER - response.status.should == 400 - end - - it "should return a 400 error when access level is not given" do - post api("/projects/#{project.id}/members", user), user_id: user2.id - response.status.should == 400 - end - - it "should return a 422 error when access level is not known" do - post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: 1234 - response.status.should == 422 - end - end - - describe "PUT /projects/:id/members/:user_id" do - it "should update project team member" do - put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: UsersProject::MASTER - response.status.should == 200 - json_response['email'].should == user3.email - json_response['access_level'].should == UsersProject::MASTER - end - - it "should return a 404 error if user_id is not found" do - put api("/projects/#{project.id}/members/1234", user), access_level: UsersProject::MASTER - response.status.should == 404 - end - - it "should return a 400 error when access level is not given" do - put api("/projects/#{project.id}/members/#{user3.id}", user) - response.status.should == 400 - end - - it "should return a 422 error when access level is not known" do - put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: 123 - response.status.should == 422 - end - end - - describe "DELETE /projects/:id/members/:user_id" do - it "should remove user from project team" do - expect { - delete api("/projects/#{project.id}/members/#{user3.id}", user) - }.to change { UsersProject.count }.by(-1) - end - - it "should return 200 if team member is not part of a project" do - delete api("/projects/#{project.id}/members/#{user3.id}", user) - expect { - delete api("/projects/#{project.id}/members/#{user3.id}", user) - }.to_not change { UsersProject.count }.by(1) - end - - it "should return 200 if team member already removed" do - delete api("/projects/#{project.id}/members/#{user3.id}", user) - delete api("/projects/#{project.id}/members/#{user3.id}", user) - response.status.should == 200 - end - end - - describe "DELETE /projects/:id/members/:user_id" do - it "should return 200 OK when the user was not member" do - expect { - delete api("/projects/#{project.id}/members/1000000", user) - }.to change { UsersProject.count }.by(0) - response.status.should == 200 - json_response['message'].should == "Access revoked" - json_response['id'].should == 1000000 - end - end - - describe "GET /projects/:id/hooks" do - context "authorized user" do - it "should return project hooks" do - get api("/projects/#{project.id}/hooks", user) - response.status.should == 200 - - json_response.should be_an Array - json_response.count.should == 1 - json_response.first['url'].should == "http://example.com" - end - end - - context "unauthorized user" do - it "should not access project hooks" do - get api("/projects/#{project.id}/hooks", user3) - response.status.should == 403 - end - end - end - - describe "GET /projects/:id/hooks/:hook_id" do - context "authorized user" do - it "should return a project hook" do - get api("/projects/#{project.id}/hooks/#{hook.id}", user) - response.status.should == 200 - json_response['url'].should == hook.url - end - - it "should return a 404 error if hook id is not available" do - get api("/projects/#{project.id}/hooks/1234", user) - response.status.should == 404 - end - end - - context "unauthorized user" do - it "should not access an existing hook" do - get api("/projects/#{project.id}/hooks/#{hook.id}", user3) - response.status.should == 403 - end - end - - it "should return a 404 error if hook id is not available" do - get api("/projects/#{project.id}/hooks/1234", user) - response.status.should == 404 - end - end - - describe "POST /projects/:id/hooks" do - it "should add hook to project" do - expect { - post api("/projects/#{project.id}/hooks", user), - url: "http://example.com" - }.to change {project.hooks.count}.by(1) - response.status.should == 201 - end - - it "should return a 400 error if url not given" do - post api("/projects/#{project.id}/hooks", user) - response.status.should == 400 - end - - it "should return a 422 error if url not valid" do - post api("/projects/#{project.id}/hooks", user), "url" => "ftp://example.com" - response.status.should == 422 - end - end - - describe "PUT /projects/:id/hooks/:hook_id" do - it "should update an existing project hook" do - put api("/projects/#{project.id}/hooks/#{hook.id}", user), - url: 'http://example.org' - response.status.should == 200 - json_response['url'].should == 'http://example.org' - end - - it "should return 404 error if hook id not found" do - put api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org' - response.status.should == 404 - end - - it "should return 400 error if url is not given" do - put api("/projects/#{project.id}/hooks/#{hook.id}", user) - response.status.should == 400 - end - - it "should return a 422 error if url is not valid" do - put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com' - response.status.should == 422 - end - end - - describe "DELETE /projects/:id/hooks/:hook_id" do - it "should delete hook from project" do - expect { - delete api("/projects/#{project.id}/hooks/#{hook.id}", user) - }.to change {project.hooks.count}.by(-1) - response.status.should == 200 - end - - it "should return success when deleting hook" do - delete api("/projects/#{project.id}/hooks/#{hook.id}", user) - response.status.should == 200 - end - - it "should return success when deleting non existent hook" do - delete api("/projects/#{project.id}/hooks/42", user) - response.status.should == 200 - end - - it "should return a 405 error if hook id not given" do - delete api("/projects/#{project.id}/hooks", user) - response.status.should == 405 - end - end - describe "GET /projects/:id/snippets" do + before { snippet } + it "should return an array of project snippets" do get api("/projects/#{project.id}/snippets", user) response.status.should == 200 @@ -543,6 +410,8 @@ describe API::API do end describe "DELETE /projects/:id/snippets/:snippet_id" do + before { snippet } + it "should delete existing project snippet" do expect { delete api("/projects/#{project.id}/snippets/#{snippet.id}", user) @@ -628,10 +497,10 @@ describe API::API do describe :fork_admin do let(:project_fork_target) { create(:project) } - let(:project_fork_source) { create(:project, public: true) } + let(:project_fork_source) { create(:project, :public) } describe "POST /projects/:id/fork/:forked_from_id" do - let(:new_project_fork_source) { create(:project, public: true) } + let(:new_project_fork_source) { create(:project, :public) } it "shouldn't available for non admin users" do post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user) @@ -695,13 +564,15 @@ describe API::API do describe "GET /projects/search/:query" do let!(:query) { 'query'} - let!(:search) { create(:project, name: query, creator_id: user.id, namespace: user.namespace) } - let!(:pre) { create(:project, name: "pre_#{query}", creator_id: user.id, namespace: user.namespace) } - let!(:post) { create(:project, name: "#{query}_post", creator_id: user.id, namespace: user.namespace) } - let!(:pre_post) { create(:project, name: "pre_#{query}_post", creator_id: user.id, namespace: user.namespace) } - let!(:unfound) { create(:project, name: 'unfound', creator_id: user.id, namespace: user.namespace) } - let!(:public) { create(:project, name: "another #{query}",public: true) } - let!(:unfound_public) { create(:project, name: 'unfound public', public: true) } + let!(:search) { create(:empty_project, name: query, creator_id: user.id, namespace: user.namespace) } + let!(:pre) { create(:empty_project, name: "pre_#{query}", creator_id: user.id, namespace: user.namespace) } + let!(:post) { create(:empty_project, name: "#{query}_post", creator_id: user.id, namespace: user.namespace) } + let!(:pre_post) { create(:empty_project, name: "pre_#{query}_post", creator_id: user.id, namespace: user.namespace) } + let!(:unfound) { create(:empty_project, name: 'unfound', creator_id: user.id, namespace: user.namespace) } + let!(:internal) { create(:empty_project, :internal, name: "internal #{query}") } + let!(:unfound_internal) { create(:empty_project, :internal, name: 'unfound internal') } + let!(:public) { create(:empty_project, :public, name: "public #{query}") } + let!(:unfound_public) { create(:empty_project, :public, name: 'unfound public') } context "when unauthenticated" do it "should return authentication error" do @@ -715,7 +586,7 @@ describe API::API do get api("/projects/search/#{query}",user) response.status.should == 200 json_response.should be_an Array - json_response.size.should == 5 + json_response.size.should == 6 json_response.each {|project| project['name'].should =~ /.*query.*/} end end @@ -725,8 +596,8 @@ describe API::API do get api("/projects/search/#{query}", user2) response.status.should == 200 json_response.should be_an Array - json_response.size.should == 1 - json_response.first['name'].should == "another #{query}" + json_response.size.should == 2 + json_response.each {|project| project['name'].should =~ /(internal|public) query/} end end end @@ -768,4 +639,46 @@ describe API::API do end end end + + describe 'GET /projects/:id/labels' do + context 'with an issue' do + before { issue_with_labels } + + it 'should return project labels' do + get api("/projects/#{project.id}/labels", user) + response.status.should == 200 + json_response.should be_an Array + json_response.first['name'].should == issue_with_labels.labels.first.name + json_response.last['name'].should == issue_with_labels.labels.last.name + end + end + + context 'with a merge request' do + before { merge_request_with_labels } + + it 'should return project labels' do + get api("/projects/#{project.id}/labels", user) + response.status.should == 200 + json_response.should be_an Array + json_response.first['name'].should == merge_request_with_labels.labels.first.name + json_response.last['name'].should == merge_request_with_labels.labels.last.name + end + end + + context 'with an issue and a merge request' do + before do + issue_with_labels + merge_request_with_labels + end + + it 'should return project labels from both' do + get api("/projects/#{project.id}/labels", user) + response.status.should == 200 + json_response.should be_an Array + all_labels = issue_with_labels.labels.map(&:name).to_a + .concat(merge_request_with_labels.labels.map(&:name).to_a) + json_response.map { |e| e['name'] }.should =~ all_labels + end + end + end end diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index 9649c4d09c..5a5222ed3c 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -1,98 +1,19 @@ require 'spec_helper' +require 'mime/types' -describe API::API do +describe API::API, api: true do include ApiHelpers before(:each) { enable_observers } after(:each) {disable_observers} let(:user) { create(:user) } let(:user2) { create(:user) } - let!(:project) { create(:project_with_code, creator_id: user.id) } + let!(:project) { create(:project, creator_id: user.id) } let!(:master) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } let!(:guest) { create(:users_project, user: user2, project: project, project_access: UsersProject::GUEST) } before { project.team << [user, :reporter] } - - describe "GET /projects/:id/repository/branches" do - it "should return an array of project branches" do - get api("/projects/#{project.id}/repository/branches", user) - response.status.should == 200 - json_response.should be_an Array - json_response.first['name'].should == project.repo.heads.sort_by(&:name).first.name - end - end - - describe "GET /projects/:id/repository/branches/:branch" do - it "should return the branch information for a single branch" do - get api("/projects/#{project.id}/repository/branches/new_design", user) - response.status.should == 200 - - json_response['name'].should == 'new_design' - json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1' - json_response['protected'].should == false - end - - it "should return a 403 error if guest" do - get api("/projects/#{project.id}/repository/branches", user2) - response.status.should == 403 - end - - it "should return a 404 error if branch is not available" do - get api("/projects/#{project.id}/repository/branches/unknown", user) - response.status.should == 404 - end - end - - describe "PUT /projects/:id/repository/branches/:branch/protect" do - it "should protect a single branch" do - put api("/projects/#{project.id}/repository/branches/new_design/protect", user) - response.status.should == 200 - - json_response['name'].should == 'new_design' - json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1' - json_response['protected'].should == true - end - - it "should return a 404 error if branch not found" do - put api("/projects/#{project.id}/repository/branches/unknown/protect", user) - response.status.should == 404 - end - - it "should return a 403 error if guest" do - put api("/projects/#{project.id}/repository/branches/new_design/protect", user2) - response.status.should == 403 - end - - it "should return success when protect branch again" do - put api("/projects/#{project.id}/repository/branches/new_design/protect", user) - put api("/projects/#{project.id}/repository/branches/new_design/protect", user) - response.status.should == 200 - end - end - - describe "PUT /projects/:id/repository/branches/:branch/unprotect" do - it "should unprotect a single branch" do - put api("/projects/#{project.id}/repository/branches/new_design/unprotect", user) - response.status.should == 200 - - json_response['name'].should == 'new_design' - json_response['commit']['id'].should == '621491c677087aa243f165eab467bfdfbee00be1' - json_response['protected'].should == false - end - - it "should return success when unprotect branch" do - put api("/projects/#{project.id}/repository/branches/unknown/unprotect", user) - response.status.should == 404 - end - - it "should return success when unprotect branch again" do - put api("/projects/#{project.id}/repository/branches/new_design/unprotect", user) - put api("/projects/#{project.id}/repository/branches/new_design/unprotect", user) - response.status.should == 200 - end - end - describe "GET /projects/:id/repository/tags" do it "should return an array of project tags" do get api("/projects/#{project.id}/repository/tags", user) @@ -102,77 +23,6 @@ describe API::API do end end - describe "GET /projects/:id/repository/commits" do - context "authorized user" do - before { project.team << [user2, :reporter] } - - it "should return project commits" do - get api("/projects/#{project.id}/repository/commits", user) - response.status.should == 200 - - json_response.should be_an Array - json_response.first['id'].should == project.repository.commit.id - end - end - - context "unauthorized user" do - it "should not return project commits" do - get api("/projects/#{project.id}/repository/commits") - response.status.should == 401 - end - end - end - - describe "GET /projects:id/repository/commits/:sha" do - context "authorized user" do - it "should return a commit by sha" do - get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) - response.status.should == 200 - json_response['id'].should == project.repository.commit.id - json_response['title'].should == project.repository.commit.title - end - - it "should return a 404 error if not found" do - get api("/projects/#{project.id}/repository/commits/invalid_sha", user) - response.status.should == 404 - end - end - - context "unauthorized user" do - it "should not return the selected commit" do - get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}") - response.status.should == 401 - end - end - end - - describe "GET /projects:id/repository/commits/:sha/diff" do - context "authorized user" do - before { project.team << [user2, :reporter] } - - it "should return the diff of the selected commit" do - get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff", user) - response.status.should == 200 - - json_response.should be_an Array - json_response.length.should >= 1 - json_response.first.keys.should include "diff" - end - - it "should return a 404 error if invalid commit" do - get api("/projects/#{project.id}/repository/commits/invalid_sha/diff", user) - response.status.should == 404 - end - end - - context "unauthorized user" do - it "should not return the diff of the selected commit" do - get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff") - response.status.should == 401 - end - end - end - describe "GET /projects/:id/repository/tree" do context "authorized user" do before { project.team << [user2, :reporter] } @@ -225,11 +75,36 @@ describe API::API do end end - describe "GET /projects/:id/repository/archive/:sha" do + describe "GET /projects/:id/repository/raw_blobs/:sha" do + it "should get the raw file contents" do + get api("/projects/#{project.id}/repository/raw_blobs/d1aff2896d99d7acc4d9780fbb716b113c45ecf7", user) + response.status.should == 200 + end + end + + describe "GET /projects/:id/repository/archive(.:format)?:sha" do it "should get the archive" do get api("/projects/#{project.id}/repository/archive", user) + repo_name = project.repository.name.gsub("\.git", "") response.status.should == 200 - response.content_type.should == 'application/x-gzip' + response.headers['Content-Disposition'].should =~ /filename\=\"#{repo_name}\-[^\.]+\.tar.gz\"/ + response.content_type.should == MIME::Types.type_for('file.tar.gz').first.content_type + end + + it "should get the archive.zip" do + get api("/projects/#{project.id}/repository/archive.zip", user) + repo_name = project.repository.name.gsub("\.git", "") + response.status.should == 200 + response.headers['Content-Disposition'].should =~ /filename\=\"#{repo_name}\-[^\.]+\.zip\"/ + response.content_type.should == MIME::Types.type_for('file.zip').first.content_type + end + + it "should get the archive.tar.bz2" do + get api("/projects/#{project.id}/repository/archive.tar.bz2", user) + repo_name = project.repository.name.gsub("\.git", "") + response.status.should == 200 + response.headers['Content-Disposition'].should =~ /filename\=\"#{repo_name}\-[^\.]+\.tar.bz2\"/ + response.content_type.should == MIME::Types.type_for('file.tar.bz2').first.content_type end it "should return 404 for invalid sha" do diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb index e2fd945bad..684f861599 100644 --- a/spec/requests/api/services_spec.rb +++ b/spec/requests/api/services_spec.rb @@ -1,12 +1,12 @@ require "spec_helper" -describe API::API do +describe API::API, api: true do include ApiHelpers before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } let(:user) { create(:user) } - let(:project) {create(:project_with_code, creator_id: user.id, namespace: user.namespace) } + let(:project) {create(:project, creator_id: user.id, namespace: user.namespace) } describe "POST /projects/:id/services/gitlab-ci" do it "should update gitlab-ci settings" do diff --git a/spec/requests/api/session_spec.rb b/spec/requests/api/session_spec.rb index 0fd90c567e..013f425d6c 100644 --- a/spec/requests/api/session_spec.rb +++ b/spec/requests/api/session_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe API::API, api: true do include ApiHelpers let(:user) { create(:user) } @@ -8,7 +8,7 @@ describe API::API do describe "POST /session" do context "when valid password" do it "should return private token" do - post api("/session"), email: user.email, password: '123456' + post api("/session"), email: user.email, password: '12345678' response.status.should == 201 json_response['email'].should == user.email diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb index b1df3cb788..5784ae8c23 100644 --- a/spec/requests/api/system_hooks_spec.rb +++ b/spec/requests/api/system_hooks_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe API::API, api: true do include ApiHelpers let(:user) { create(:user) } diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 4ef78b8e5d..a6d300b099 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe API::API do +describe API::API, api: true do include ApiHelpers let(:user) { create(:user) } @@ -93,7 +93,7 @@ describe API::API do expect { post api("/users", admin), attr }.to change { User.count }.by(1) - user = User.find_by_username(attr[:username]) + user = User.find_by(username: attr[:username]) user.projects_limit.should == limit user.theme_id.should == Gitlab::Theme::MARS Gitlab.config.gitlab.unstub(:default_projects_limit) @@ -242,6 +242,67 @@ describe API::API do end end + describe 'GET /user/:uid/keys' do + before { admin } + + context 'when unauthenticated' do + it 'should return authentication error' do + get api("/users/#{user.id}/keys") + response.status.should == 401 + end + end + + context 'when authenticated' do + it 'should return 404 for non-existing user' do + get api('/users/999999/keys', admin) + response.status.should == 404 + end + + it 'should return array of ssh keys' do + user.keys << key + user.save + get api("/users/#{user.id}/keys", admin) + response.status.should == 200 + json_response.should be_an Array + json_response.first['title'].should == key.title + end + end + end + + describe 'DELETE /user/:uid/keys/:id' do + before { admin } + + context 'when unauthenticated' do + it 'should return authentication error' do + delete api("/users/#{user.id}/keys/42") + response.status.should == 401 + end + end + + context 'when authenticated' do + it 'should delete existing key' do + user.keys << key + user.save + expect { + delete api("/users/#{user.id}/keys/#{key.id}", admin) + }.to change { user.keys.count }.by(-1) + response.status.should == 200 + end + + it 'should return 404 error if user not found' do + user.keys << key + user.save + delete api("/users/999999/keys/#{key.id}", admin) + response.status.should == 404 + end + + it 'should return 404 error if key not foud' do + delete api("/users/#{user.id}/keys/42", admin) + response.status.should == 404 + end + end + end + describe "DELETE /users/:id" do before { admin } diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 5597f08d18..fa9762625d 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -130,6 +130,14 @@ describe Projects::RepositoriesController, "routing" do get("/gitlab/gitlabhq/repository/archive").should route_to('projects/repositories#archive', project_id: 'gitlab/gitlabhq') end + it "to #archive format:zip" do + get("/gitlab/gitlabhq/repository/archive.zip").should route_to('projects/repositories#archive', project_id: 'gitlab/gitlabhq', format: 'zip') + end + + it "to #archive format:tar.bz2" do + get("/gitlab/gitlabhq/repository/archive.tar.bz2").should route_to('projects/repositories#archive', project_id: 'gitlab/gitlabhq', format: 'tar.bz2') + end + it "to #show" do get("/gitlab/gitlabhq/repository").should route_to('projects/repositories#show', project_id: 'gitlab/gitlabhq') end @@ -205,7 +213,7 @@ describe Projects::RefsController, "routing" do end # diffs_project_merge_request GET /:project_id/merge_requests/:id/diffs(.:format) projects/merge_requests#diffs -# automerge_project_merge_request GET /:project_id/merge_requests/:id/automerge(.:format) projects/merge_requests#automerge +# automerge_project_merge_request POST /:project_id/merge_requests/:id/automerge(.:format) projects/merge_requests#automerge # automerge_check_project_merge_request GET /:project_id/merge_requests/:id/automerge_check(.:format) projects/merge_requests#automerge_check # branch_from_project_merge_requests GET /:project_id/merge_requests/branch_from(.:format) projects/merge_requests#branch_from # branch_to_project_merge_requests GET /:project_id/merge_requests/branch_to(.:format) projects/merge_requests#branch_to @@ -222,7 +230,10 @@ describe Projects::MergeRequestsController, "routing" do end it "to #automerge" do - get("/gitlab/gitlabhq/merge_requests/1/automerge").should route_to('projects/merge_requests#automerge', project_id: 'gitlab/gitlabhq', id: '1') + post('/gitlab/gitlabhq/merge_requests/1/automerge').should route_to( + 'projects/merge_requests#automerge', + project_id: 'gitlab/gitlabhq', id: '1' + ) end it "to #automerge_check" do diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index 1b1d19d26b..a2d2a35140 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -111,13 +111,6 @@ describe HelpController, "routing" do end end -# errors_githost GET /errors/githost(.:format) errors#githost -describe ErrorsController, "routing" do - it "to #githost" do - get("/errors/githost").should route_to('errors#githost') - end -end - # profile_account GET /profile/account(.:format) profile#account # profile_history GET /profile/history(.:format) profile#history # profile_password PUT /profile/password(.:format) profile#password_update @@ -183,6 +176,35 @@ describe Profiles::KeysController, "routing" do it "to #destroy" do delete("/profile/keys/1").should route_to('profiles/keys#destroy', id: '1') end + + # get all the ssh-keys of a user + it "to #get_keys" do + get("/foo.keys").should route_to('profiles/keys#get_keys', username: 'foo') + end +end + +# emails GET /emails(.:format) emails#index +# POST /keys(.:format) emails#create +# DELETE /keys/:id(.:format) keys#destroy +describe Profiles::EmailsController, "routing" do + it "to #index" do + get("/profile/emails").should route_to('profiles/emails#index') + end + + it "to #create" do + post("/profile/emails").should route_to('profiles/emails#create') + end + + it "to #destroy" do + delete("/profile/emails/1").should route_to('profiles/emails#destroy', id: '1') + end +end + +# profile_avatar DELETE /profile/avatar(.:format) profiles/avatars#destroy +describe Profiles::AvatarsController, "routing" do + it "to #destroy" do + delete("/profile/avatar").should route_to('profiles/avatars#destroy') + end end # dashboard GET /dashboard(.:format) dashboard#show @@ -216,3 +238,14 @@ end describe "Authentication", "routing" do # pending end + +describe "Groups", "routing" do + it "to #show" do + get("/groups/1").should route_to('groups#show', id: '1') + end + + it "also display group#show on the short path" do + get("/1").should route_to('groups#show', id: '1') + end +end + diff --git a/spec/seed_project.tar.gz b/spec/seed_project.tar.gz index 7abb51ebdf..8d32a927da 100644 Binary files a/spec/seed_project.tar.gz and b/spec/seed_project.tar.gz differ diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb new file mode 100644 index 0000000000..713aa3e7e7 --- /dev/null +++ b/spec/services/event_create_service_spec.rb @@ -0,0 +1,103 @@ +require 'spec_helper' + +describe EventCreateService do + let(:service) { EventCreateService.new } + + describe 'Issues' do + describe :open_issue do + let(:issue) { create(:issue) } + + it { service.open_issue(issue, issue.author).should be_true } + + it "should create new event" do + expect { service.open_issue(issue, issue.author) }.to change { Event.count } + end + end + + describe :close_issue do + let(:issue) { create(:issue) } + + it { service.close_issue(issue, issue.author).should be_true } + + it "should create new event" do + expect { service.close_issue(issue, issue.author) }.to change { Event.count } + end + end + + describe :reopen_issue do + let(:issue) { create(:issue) } + + it { service.reopen_issue(issue, issue.author).should be_true } + + it "should create new event" do + expect { service.reopen_issue(issue, issue.author) }.to change { Event.count } + end + end + end + + describe 'Merge Requests' do + describe :open_mr do + let(:merge_request) { create(:merge_request) } + + it { service.open_mr(merge_request, merge_request.author).should be_true } + + it "should create new event" do + expect { service.open_mr(merge_request, merge_request.author) }.to change { Event.count } + end + end + + describe :close_mr do + let(:merge_request) { create(:merge_request) } + + it { service.close_mr(merge_request, merge_request.author).should be_true } + + it "should create new event" do + expect { service.close_mr(merge_request, merge_request.author) }.to change { Event.count } + end + end + + describe :merge_mr do + let(:merge_request) { create(:merge_request) } + + it { service.merge_mr(merge_request, merge_request.author).should be_true } + + it "should create new event" do + expect { service.merge_mr(merge_request, merge_request.author) }.to change { Event.count } + end + end + + describe :reopen_mr do + let(:merge_request) { create(:merge_request) } + + it { service.reopen_mr(merge_request, merge_request.author).should be_true } + + it "should create new event" do + expect { service.reopen_mr(merge_request, merge_request.author) }.to change { Event.count } + end + end + end + + describe 'Milestone' do + let(:user) { create :user } + + describe :open_milestone do + let(:milestone) { create(:milestone) } + + it { service.open_milestone(milestone, user).should be_true } + + it "should create new event" do + expect { service.open_milestone(milestone, user) }.to change { Event.count } + end + end + + describe :close_mr do + let(:milestone) { create(:milestone) } + + it { service.close_milestone(milestone, user).should be_true } + + it "should create new event" do + expect { service.close_milestone(milestone, user) }.to change { Event.count } + end + end + end +end diff --git a/spec/contexts/fork_context_spec.rb b/spec/services/fork_service_spec.rb similarity index 92% rename from spec/contexts/fork_context_spec.rb rename to spec/services/fork_service_spec.rb index ed51b0c3f8..b6573095db 100644 --- a/spec/contexts/fork_context_spec.rb +++ b/spec/services/fork_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Projects::ForkContext do +describe Projects::ForkService do describe :fork_by_user do before do @from_namespace = create(:namespace) @@ -47,8 +47,8 @@ describe Projects::ForkContext do end def fork_project(from_project, user, fork_success = true) - context = Projects::ForkContext.new(from_project, user) - shell = mock("gitlab_shell") + context = Projects::ForkService.new(from_project, user) + shell = double("gitlab_shell") shell.stub(fork_repository: fork_success) context.stub(gitlab_shell: shell) context.execute diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index 2870f59195..6b89f213be 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe GitPushService do let (:user) { create :user } - let (:project) { create :project_with_code } + let (:project) { create :project } let (:service) { GitPushService.new } before do @@ -74,38 +74,19 @@ describe GitPushService do end describe "Web Hooks" do - context "with web hooks" do - before do - @project_hook = create(:project_hook) - @project_hook_2 = create(:project_hook) - project.hooks << [@project_hook, @project_hook_2] - - stub_request(:post, @project_hook.url) - stub_request(:post, @project_hook_2.url) - end - - it "executes multiple web hook" do - @project_hook.should_receive(:async_execute).once - @project_hook_2.should_receive(:async_execute).once - - service.execute(project, user, @oldrev, @newrev, @ref) - end - end - context "execute web hooks" do - before do - @project_hook = create(:project_hook) - project.hooks << [@project_hook] - stub_request(:post, @project_hook.url) - end - it "when pushing a branch for the first time" do - @project_hook.should_receive(:async_execute) + project.should_receive(:execute_hooks) service.execute(project, user, @blankrev, 'newrev', 'refs/heads/master') end + it "when pushing new commits to existing branch" do + project.should_receive(:execute_hooks) + service.execute(project, user, 'oldrev', 'newrev', 'refs/heads/master') + end + it "when pushing tags" do - @project_hook.should_not_receive(:async_execute) + project.should_not_receive(:execute_hooks) service.execute(project, user, 'newrev', 'newrev', 'refs/tags/v1.0.0') end end @@ -189,16 +170,10 @@ describe GitPushService do Issue.find(issue.id).should be_closed end - it "passes the closing commit as a thread-local" do - service.execute(project, user, @oldrev, @newrev, @ref) - - Thread.current[:current_commit].should == closing_commit - end - it "doesn't create cross-reference notes for a closing reference" do expect { service.execute(project, user, @oldrev, @newrev, @ref) - }.not_to change { Note.where(project_id: project.id, system: true).count } + }.not_to change { Note.where(project_id: project.id, system: true, commit_id: closing_commit.id).count } end it "doesn't close issues when pushed to non-default branches" do diff --git a/spec/services/git_tag_push_service_spec.rb b/spec/services/git_tag_push_service_spec.rb new file mode 100644 index 0000000000..e65a8204c5 --- /dev/null +++ b/spec/services/git_tag_push_service_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper' + +describe GitTagPushService do + let (:user) { create :user } + let (:project) { create :project } + let (:service) { GitTagPushService.new } + + before do + @ref = 'refs/tags/super-tag' + @oldrev = 'b98a310def241a6fd9c9a9a3e7934c48e498fe81' + @newrev = 'b19a04f53caeebf4fe5ec2327cb83e9253dc91bb' + end + + describe 'Git Tag Push Data' do + before do + service.execute(project, user, @oldrev, @newrev, @ref) + @push_data = service.push_data + end + + subject { @push_data } + + it { should include(ref: @ref) } + it { should include(before: @oldrev) } + it { should include(after: @newrev) } + it { should include(user_id: user.id) } + it { should include(user_name: user.name) } + it { should include(project_id: project.id) } + + context 'With repository data' do + subject { @push_data[:repository] } + + it { should include(name: project.name) } + it { should include(url: project.url_to_repo) } + it { should include(description: project.description) } + it { should include(homepage: project.web_url) } + end + end + + describe "Web Hooks" do + context "execute web hooks" do + it "when pushing tags" do + project.should_receive(:execute_hooks) + service.execute(project, user, 'oldrev', 'newrev', 'refs/tags/v1.0.0') + end + end + end +end diff --git a/spec/contexts/issues/bulk_update_context_spec.rb b/spec/services/issues/bulk_update_context_spec.rb similarity index 85% rename from spec/contexts/issues/bulk_update_context_spec.rb rename to spec/services/issues/bulk_update_context_spec.rb index 058e43ba09..548109a845 100644 --- a/spec/contexts/issues/bulk_update_context_spec.rb +++ b/spec/services/issues/bulk_update_context_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Issues::BulkUpdateContext do +describe Issues::BulkUpdateService do before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } @@ -14,7 +14,7 @@ describe Issues::BulkUpdateContext do name: "GitLab", namespace: @user.namespace } - @project = Projects::CreateContext.new(@user, opts).execute + @project = Projects::CreateService.new(@user, opts).execute end describe :close_issue do @@ -32,7 +32,7 @@ describe Issues::BulkUpdateContext do end it { - result = Issues::BulkUpdateContext.new(@project, @user, @params).execute + result = Issues::BulkUpdateService.new(@project, @user, @params).execute result[:success].should be_true result[:count].should == @issues.count @@ -57,7 +57,7 @@ describe Issues::BulkUpdateContext do end it { - result = Issues::BulkUpdateContext.new(@project, @user, @params).execute + result = Issues::BulkUpdateService.new(@project, @user, @params).execute result[:success].should be_true result[:count].should == @issues.count @@ -80,7 +80,7 @@ describe Issues::BulkUpdateContext do end it { - result = Issues::BulkUpdateContext.new(@project, @user, @params).execute + result = Issues::BulkUpdateService.new(@project, @user, @params).execute result[:success].should be_true result[:count].should == 1 @@ -102,7 +102,7 @@ describe Issues::BulkUpdateContext do end it { - result = Issues::BulkUpdateContext.new(@project, @user, @params).execute + result = Issues::BulkUpdateService.new(@project, @user, @params).execute result[:success].should be_true result[:count].should == 1 diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb new file mode 100644 index 0000000000..d4f2cc1339 --- /dev/null +++ b/spec/services/issues/close_service_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe Issues::CloseService do + let(:project) { create(:empty_project) } + let(:user) { create(:user) } + let(:user2) { create(:user) } + let(:issue) { create(:issue, assignee: user2) } + + before do + project.team << [user, :master] + project.team << [user2, :developer] + end + + describe :execute do + context "valid params" do + before do + @issue = Issues::CloseService.new(project, user, {}).execute(issue) + end + + it { @issue.should be_valid } + it { @issue.should be_closed } + + it 'should send email to user2 about assign of new issue' do + email = ActionMailer::Base.deliveries.last + email.to.first.should == user2.email + email.subject.should include(issue.title) + end + + it 'should create system note about issue reassign' do + note = @issue.notes.last + note.note.should include "Status changed to closed" + end + end + end +end diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb new file mode 100644 index 0000000000..90720be5de --- /dev/null +++ b/spec/services/issues/create_service_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe Issues::CreateService do + let(:project) { create(:empty_project) } + let(:user) { create(:user) } + + describe :execute do + context "valid params" do + before do + project.team << [user, :master] + opts = { + title: 'Awesome issue', + description: 'please fix' + } + + @issue = Issues::CreateService.new(project, user, opts).execute + end + + it { @issue.should be_valid } + it { @issue.title.should == 'Awesome issue' } + end + end +end diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb new file mode 100644 index 0000000000..347560414e --- /dev/null +++ b/spec/services/issues/update_service_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' + +describe Issues::UpdateService do + let(:project) { create(:empty_project) } + let(:user) { create(:user) } + let(:user2) { create(:user) } + let(:issue) { create(:issue) } + + before do + project.team << [user, :master] + project.team << [user2, :developer] + end + + describe :execute do + context "valid params" do + before do + opts = { + title: 'New title', + description: 'Also please fix', + assignee_id: user2.id, + state_event: 'close' + } + + @issue = Issues::UpdateService.new(project, user, opts).execute(issue) + end + + it { @issue.should be_valid } + it { @issue.title.should == 'New title' } + it { @issue.assignee.should == user2 } + it { @issue.should be_closed } + + it 'should send email to user2 about assign of new issue' do + email = ActionMailer::Base.deliveries.last + email.to.first.should == user2.email + email.subject.should include(issue.title) + end + + it 'should create system note about issue reassign' do + note = @issue.notes.last + note.note.should include "Reassigned to \@#{user2.username}" + end + end + end +end diff --git a/spec/services/merge_requests/close_service_spec.rb b/spec/services/merge_requests/close_service_spec.rb new file mode 100644 index 0000000000..a504f916b0 --- /dev/null +++ b/spec/services/merge_requests/close_service_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe MergeRequests::CloseService do + let(:user) { create(:user) } + let(:user2) { create(:user) } + let(:merge_request) { create(:merge_request, assignee: user2) } + let(:project) { merge_request.project } + + before do + project.team << [user, :master] + project.team << [user2, :developer] + end + + describe :execute do + context "valid params" do + before do + @merge_request = MergeRequests::CloseService.new(project, user, {}).execute(merge_request) + end + + it { @merge_request.should be_valid } + it { @merge_request.should be_closed } + + it 'should send email to user2 about assign of new merge_request' do + email = ActionMailer::Base.deliveries.last + email.to.first.should == user2.email + email.subject.should include(merge_request.title) + end + + it 'should create system note about merge_request reassign' do + note = @merge_request.notes.last + note.note.should include "Status changed to closed" + end + end + end +end diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb new file mode 100644 index 0000000000..cebeb0644d --- /dev/null +++ b/spec/services/merge_requests/create_service_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +describe MergeRequests::CreateService do + let(:project) { create(:project) } + let(:user) { create(:user) } + + describe :execute do + context "valid params" do + before do + project.team << [user, :master] + opts = { + title: 'Awesome merge_request', + description: 'please fix', + source_branch: 'stable', + target_branch: 'master' + } + + @merge_request = MergeRequests::CreateService.new(project, user, opts).execute + end + + it { @merge_request.should be_valid } + it { @merge_request.title.should == 'Awesome merge_request' } + end + end +end diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb new file mode 100644 index 0000000000..af5d3a3dc8 --- /dev/null +++ b/spec/services/merge_requests/update_service_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' + +describe MergeRequests::UpdateService do + let(:user) { create(:user) } + let(:user2) { create(:user) } + let(:merge_request) { create(:merge_request, :simple) } + let(:project) { merge_request.project } + + before do + project.team << [user, :master] + project.team << [user2, :developer] + end + + describe :execute do + context "valid params" do + before do + opts = { + title: 'New title', + description: 'Also please fix', + assignee_id: user2.id, + state_event: 'close' + } + + @merge_request = MergeRequests::UpdateService.new(project, user, opts).execute(merge_request) + end + + it { @merge_request.should be_valid } + it { @merge_request.title.should == 'New title' } + it { @merge_request.assignee.should == user2 } + it { @merge_request.should be_closed } + + it 'should send email to user2 about assign of new merge_request' do + email = ActionMailer::Base.deliveries.last + email.to.first.should == user2.email + email.subject.should include(merge_request.title) + end + + it 'should create system note about merge_request reassign' do + note = @merge_request.notes.last + note.note.should include "Reassigned to \@#{user2.username}" + end + end + end +end diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index a112835d4d..57a4240f7a 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -5,7 +5,7 @@ describe NotificationService do describe 'Keys' do describe :new_key do - let(:key) { create(:personal_key) } + let!(:key) { create(:personal_key) } it { notification.new_key(key).should be_true } @@ -16,9 +16,23 @@ describe NotificationService do end end + describe 'Email' do + describe :new_email do + let!(:email) { create(:email) } + + it { notification.new_email(email).should be_true } + + it 'should send email to email owner' do + Notify.should_receive(:new_email_email).with(email.id) + notification.new_email(email) + end + end + end + describe 'Notes' do context 'issue note' do let(:issue) { create(:issue, assignee: create(:user)) } + let(:mentioned_issue) { create(:issue, assignee: issue.assignee) } let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id, note: '@mention referenced') } before do @@ -37,14 +51,48 @@ describe NotificationService do notification.new_note(note) end - def should_email(user_id) - Notify.should_receive(:note_issue_email).with(user_id, note.id) + it 'filters out "mentioned in" notes' do + mentioned_note = Note.create_cross_reference_note(mentioned_issue, issue, issue.author, issue.project) + + Notify.should_not_receive(:note_issue_email) + notification.new_note(mentioned_note) + end + end + + describe 'new note on issue in project that belongs to a group' do + let(:group) { create(:group) } + + before do + note.project.namespace_id = group.id + note.project.group.add_user(@u_watcher, UsersGroup::MASTER) + note.project.save + user_project = note.project.users_projects.find_by_user_id(@u_watcher.id) + user_project.notification_level = Notification::N_PARTICIPATING + user_project.save + user_group = note.project.group.users_groups.find_by_user_id(@u_watcher.id) + user_group.notification_level = Notification::N_GLOBAL + user_group.save end - def should_not_email(user_id) - Notify.should_not_receive(:note_issue_email).with(user_id, note.id) + it do + should_email(note.noteable.author_id) + should_email(note.noteable.assignee_id) + should_email(@u_mentioned.id) + should_not_email(@u_watcher.id) + should_not_email(note.author_id) + should_not_email(@u_participating.id) + should_not_email(@u_disabled.id) + notification.new_note(note) end end + + def should_email(user_id) + Notify.should_receive(:note_issue_email).with(user_id, note.id) + end + + def should_not_email(user_id) + Notify.should_not_receive(:note_issue_email).with(user_id, note.id) + end end context 'commit note' do @@ -124,11 +172,11 @@ describe NotificationService do end def should_email(user_id) - Notify.should_receive(:reassigned_issue_email).with(user_id, issue.id, issue.assignee_id) + Notify.should_receive(:reassigned_issue_email).with(user_id, issue.id, issue.assignee_id, @u_disabled.id) end def should_not_email(user_id) - Notify.should_not_receive(:reassigned_issue_email).with(user_id, issue.id, issue.assignee_id) + Notify.should_not_receive(:reassigned_issue_email).with(user_id, issue.id, issue.assignee_id, @u_disabled.id) end end @@ -188,11 +236,11 @@ describe NotificationService do end def should_email(user_id) - Notify.should_receive(:reassigned_merge_request_email).with(user_id, merge_request.id, merge_request.assignee_id) + Notify.should_receive(:reassigned_merge_request_email).with(user_id, merge_request.id, merge_request.assignee_id, merge_request.author_id) end def should_not_email(user_id) - Notify.should_not_receive(:reassigned_merge_request_email).with(user_id, merge_request.id, merge_request.assignee_id) + Notify.should_not_receive(:reassigned_merge_request_email).with(user_id, merge_request.id, merge_request.assignee_id, merge_request.author_id) end end @@ -220,15 +268,40 @@ describe NotificationService do should_email(@u_watcher.id) should_not_email(@u_participating.id) should_not_email(@u_disabled.id) - notification.merge_mr(merge_request) + notification.merge_mr(merge_request, @u_disabled) end def should_email(user_id) - Notify.should_receive(:merged_merge_request_email).with(user_id, merge_request.id) + Notify.should_receive(:merged_merge_request_email).with(user_id, merge_request.id, @u_disabled.id) end def should_not_email(user_id) - Notify.should_not_receive(:merged_merge_request_email).with(user_id, merge_request.id) + Notify.should_not_receive(:merged_merge_request_email).with(user_id, merge_request.id, @u_disabled.id) + end + end + end + + describe 'Projects' do + let(:project) { create :project } + + before do + build_team(project) + end + + describe :project_was_moved do + it do + should_email(@u_watcher.id) + should_email(@u_participating.id) + should_not_email(@u_disabled.id) + notification.project_was_moved(project) + end + + def should_email(user_id) + Notify.should_receive(:project_was_moved_email).with(project.id, user_id) + end + + def should_not_email(user_id) + Notify.should_not_receive(:project_was_moved_email).with(project.id, user_id) end end end diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb new file mode 100644 index 0000000000..38aae452c3 --- /dev/null +++ b/spec/services/projects/create_service_spec.rb @@ -0,0 +1,163 @@ +require 'spec_helper' + +describe Projects::CreateService do + before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } + after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } + + describe :create_by_user do + before do + @user = create :user + @admin = create :user, admin: true + @opts = { + name: "GitLab", + namespace: @user.namespace + } + end + + context 'user namespace' do + before do + @project = create_project(@user, @opts) + end + + it { @project.should be_valid } + it { @project.owner.should == @user } + it { @project.namespace.should == @user.namespace } + end + + context 'group namespace' do + before do + @group = create :group + @group.add_owner(@user) + + @opts.merge!(namespace_id: @group.id) + @project = create_project(@user, @opts) + end + + it { @project.should be_valid } + it { @project.owner.should == @group } + it { @project.namespace.should == @group } + end + + context 'wiki_enabled creates repository directory' do + context 'wiki_enabled true creates wiki repository directory' do + before do + @project = create_project(@user, @opts) + @path = ProjectWiki.new(@project, @user).send(:path_to_repo) + end + + it { File.exists?(@path).should be_true } + end + + context 'wiki_enabled false does not create wiki repository directory' do + before do + @opts.merge!(wiki_enabled: false) + @project = create_project(@user, @opts) + @path = ProjectWiki.new(@project, @user).send(:path_to_repo) + end + + it { File.exists?(@path).should be_false } + end + end + + context 'respect configured visibility setting' do + before(:each) do + @settings = double("settings") + @settings.stub(:issues) { true } + @settings.stub(:merge_requests) { true } + @settings.stub(:wiki) { true } + @settings.stub(:wall) { true } + @settings.stub(:snippets) { true } + stub_const("Settings", Class.new) + @restrictions = double("restrictions") + @restrictions.stub(:restricted_visibility_levels) { [] } + Settings.stub_chain(:gitlab).and_return(@restrictions) + Settings.stub_chain(:gitlab, :default_projects_features).and_return(@settings) + end + + context 'should be public when setting is public' do + before do + @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC } + @project = create_project(@user, @opts) + end + + it { @project.public?.should be_true } + end + + context 'should be private when setting is private' do + before do + @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE } + @project = create_project(@user, @opts) + end + + it { @project.private?.should be_true } + end + + context 'should be internal when setting is internal' do + before do + @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::INTERNAL } + @project = create_project(@user, @opts) + end + + it { @project.internal?.should be_true } + end + end + + context 'respect configured visibility restrictions setting' do + before(:each) do + @settings = double("settings") + @settings.stub(:issues) { true } + @settings.stub(:merge_requests) { true } + @settings.stub(:wiki) { true } + @settings.stub(:wall) { true } + @settings.stub(:snippets) { true } + @settings.stub(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE } + stub_const("Settings", Class.new) + @restrictions = double("restrictions") + @restrictions.stub(:restricted_visibility_levels) { [ Gitlab::VisibilityLevel::PUBLIC ] } + Settings.stub_chain(:gitlab).and_return(@restrictions) + Settings.stub_chain(:gitlab, :default_projects_features).and_return(@settings) + end + + context 'should be private when option is public' do + before do + @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) + @project = create_project(@user, @opts) + end + + it { @project.private?.should be_true } + end + + context 'should be public when option is public for admin' do + before do + @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) + @project = create_project(@admin, @opts) + end + + it { @project.public?.should be_true } + end + + context 'should be private when option is private' do + before do + @opts.merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) + @project = create_project(@user, @opts) + end + + it { @project.private?.should be_true } + end + + context 'should be internal when option is internal' do + before do + @opts.merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) + @project = create_project(@user, @opts) + end + + it { @project.internal?.should be_true } + end + end + end + + def create_project(user, opts) + Projects::CreateService.new(user, opts).execute + end +end + diff --git a/spec/services/project_transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb similarity index 100% rename from spec/services/project_transfer_service_spec.rb rename to spec/services/projects/transfer_service_spec.rb diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb new file mode 100644 index 0000000000..1854c0d823 --- /dev/null +++ b/spec/services/projects/update_service_spec.rb @@ -0,0 +1,111 @@ +require 'spec_helper' + +describe Projects::UpdateService do + before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } + after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } + + describe :update_by_user do + before do + @user = create :user + @admin = create :user, admin: true + @project = create :project, creator_id: @user.id, namespace: @user.namespace + @opts = { project: {} } + end + + context 'should be private when updated to private' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) + update_project(@project, @user, @opts) + end + + it { @created_private.should be_true } + it { @project.private?.should be_true } + end + + context 'should be internal when updated to internal' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) + update_project(@project, @user, @opts) + end + + it { @created_private.should be_true } + it { @project.internal?.should be_true } + end + + context 'should be public when updated to public' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) + update_project(@project, @user, @opts) + end + + it { @created_private.should be_true } + it { @project.public?.should be_true } + end + + context 'respect configured visibility restrictions setting' do + before(:each) do + @restrictions = double("restrictions") + @restrictions.stub(:restricted_visibility_levels) { [ Gitlab::VisibilityLevel::PUBLIC ] } + Settings.stub_chain(:gitlab).and_return(@restrictions) + end + + context 'should be private when updated to private' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) + update_project(@project, @user, @opts) + end + + it { @created_private.should be_true } + it { @project.private?.should be_true } + end + + context 'should be internal when updated to internal' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::INTERNAL) + update_project(@project, @user, @opts) + end + + it { @created_private.should be_true } + it { @project.internal?.should be_true } + end + + context 'should be private when updated to public' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) + update_project(@project, @user, @opts) + end + + it { @created_private.should be_true } + it { @project.private?.should be_true } + end + + context 'should be public when updated to public by admin' do + before do + @created_private = @project.private? + + @opts[:project].merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC) + update_project(@project, @admin, @opts) + end + + it { @created_private.should be_true } + it { @project.public?.should be_true } + end + end + end + + def update_project(project, user, opts) + Projects::UpdateService.new(project, user, opts).execute + end +end diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb new file mode 100644 index 0000000000..b467282a5d --- /dev/null +++ b/spec/services/search_service_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper' + +describe 'Search::GlobalService' do + let(:user) { create(:user, namespace: found_namespace) } + let(:public_user) { create(:user, namespace: public_namespace) } + let(:internal_user) { create(:user, namespace: internal_namespace) } + + let(:found_namespace) { create(:namespace, name: 'searchable namespace', path:'another_thing') } + let(:unfound_namespace) { create(:namespace, name: 'unfound namespace', path: 'yet_something_else') } + let(:internal_namespace) { create(:namespace, name: 'searchable internal namespace', path: 'something_internal') } + let(:public_namespace) { create(:namespace, name: 'searchable public namespace', path: 'something_public') } + + let!(:found_project) { create(:project, :private, name: 'searchable_project', creator_id: user.id, namespace: found_namespace) } + let!(:unfound_project) { create(:project, :private, name: 'unfound_project', creator_id: user.id, namespace: unfound_namespace) } + let!(:internal_project) { create(:project, :internal, name: 'searchable_internal_project', creator_id: internal_user.id, namespace: internal_namespace) } + let!(:public_project) { create(:project, :public, name: 'searchable_public_project', creator_id: public_user.id, namespace: public_namespace) } + + describe '#execute' do + context 'unauthenticated' do + it 'should return public projects only' do + context = Search::GlobalService.new(nil, search: "searchable") + results = context.execute + results[:projects].should match_array [public_project] + end + end + + context 'authenticated' do + it 'should return public, internal and private projects' do + context = Search::GlobalService.new(user, search: "searchable") + results = context.execute + results[:projects].should match_array [public_project, found_project, internal_project] + end + + it 'should return only public & internal projects' do + context = Search::GlobalService.new(internal_user, search: "searchable") + results = context.execute + results[:projects].should match_array [internal_project, public_project] + end + + it 'namespace name should be searchable' do + context = Search::GlobalService.new(user, search: "searchable namespace") + results = context.execute + results[:projects].should match_array [found_project] + end + end + end +end diff --git a/spec/services/system_hooks_service_spec.rb b/spec/services/system_hooks_service_spec.rb index ebc1ed51d2..3c2eec6cfd 100644 --- a/spec/services/system_hooks_service_spec.rb +++ b/spec/services/system_hooks_service_spec.rb @@ -8,10 +8,10 @@ describe SystemHooksService do context 'event data' do it { event_data(user, :create).should include(:event_name, :name, :created_at, :email, :user_id) } it { event_data(user, :destroy).should include(:event_name, :name, :created_at, :email, :user_id) } - it { event_data(project, :create).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email) } - it { event_data(project, :destroy).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email) } - it { event_data(users_project, :create).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access) } - it { event_data(users_project, :destroy).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access) } + it { event_data(project, :create).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) } + it { event_data(project, :destroy).should include(:event_name, :name, :created_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) } + it { event_data(users_project, :create).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access, :project_visibility) } + it { event_data(users_project, :destroy).should include(:event_name, :created_at, :project_name, :project_path, :project_id, :user_name, :user_email, :project_access, :project_visibility) } end context 'event names' do @@ -24,10 +24,10 @@ describe SystemHooksService do end def event_data(*args) - SystemHooksService.build_event_data(*args) + SystemHooksService.new.send :build_event_data, *args end def event_name(*args) - SystemHooksService.build_event_name(*args) + SystemHooksService.new.send :build_event_name, *args end end diff --git a/spec/services/test_hook_service_spec.rb b/spec/services/test_hook_service_spec.rb new file mode 100644 index 0000000000..76af5bf7b8 --- /dev/null +++ b/spec/services/test_hook_service_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe TestHookService do + let (:user) { create :user } + let (:project) { create :project } + let (:hook) { create :project_hook, project: project } + + describe :execute do + it "should execute successfully" do + stub_request(:post, hook.url).to_return(status: 200) + TestHookService.new.execute(hook, user).should be_true + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dd008ed02a..e6b1f816df 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,63 +1,50 @@ -require 'rubygems' -require 'spork' +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV["RAILS_ENV"] ||= 'test' +require File.expand_path("../../config/environment", __FILE__) -Spork.prefork do - require 'simplecov' unless ENV['CI'] +require 'simplecov' unless ENV['CI'] - if ENV['TRAVIS'] - require 'coveralls' - Coveralls.wear! - end - - # This file is copied to spec/ when you run 'rails generate rspec:install' - ENV["RAILS_ENV"] ||= 'test' - require File.expand_path("../../config/environment", __FILE__) - require 'rspec/rails' - require 'capybara/rails' - require 'capybara/rspec' - require 'webmock/rspec' - require 'email_spec' - require 'sidekiq/testing/inline' - require 'capybara/poltergeist' - - # Loading more in this block will cause your tests to run faster. However, - - # if you change any configuration or code from libraries loaded here, you'll - # need to restart spork for it take effect. - Capybara.javascript_driver = :poltergeist - Capybara.default_wait_time = 10 - - # Requires supporting ruby files with custom matchers and macros, etc, - # in spec/support/ and its subdirectories. - Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} - - WebMock.disable_net_connect!(allow_localhost: true) - - RSpec.configure do |config| - config.mock_with :rspec - - config.include LoginHelpers, type: :feature - config.include LoginHelpers, type: :request - config.include FactoryGirl::Syntax::Methods - config.include Devise::TestHelpers, type: :controller - - config.include TestEnv - - # 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 - # instead of true. - config.use_transactional_fixtures = false - - config.before(:suite) do - TestEnv.init(observers: false, init_repos: true, repos: false) - end - config.before(:each) do - TestEnv.setup_stubs - end - end +if ENV['TRAVIS'] + require 'coveralls' + Coveralls.wear! end -Spork.each_run do - # This code will be run each time you run your specs. +require 'rspec/rails' +require 'capybara/rails' +require 'capybara/rspec' +require 'webmock/rspec' +require 'email_spec' +require 'sidekiq/testing/inline' +require 'capybara/poltergeist' +Capybara.javascript_driver = :poltergeist +Capybara.default_wait_time = 10 + +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + +WebMock.disable_net_connect!(allow_localhost: true) + +RSpec.configure do |config| + config.mock_with :rspec + + config.include LoginHelpers, type: :feature + config.include LoginHelpers, type: :request + config.include FactoryGirl::Syntax::Methods + config.include Devise::TestHelpers, type: :controller + + config.include TestEnv + + # 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 + # instead of true. + config.use_transactional_fixtures = false + + config.before(:suite) do + TestEnv.init(observers: false, init_repos: true, repos: false) + end + config.before(:each) do + TestEnv.setup_stubs + end end diff --git a/spec/support/chosen_helper.rb b/spec/support/chosen_helper.rb deleted file mode 100644 index 42c9342c77..0000000000 --- a/spec/support/chosen_helper.rb +++ /dev/null @@ -1,21 +0,0 @@ -# Chosen programmatic helper -# It allows you to select value from chosen select -# -# Params -# value - real value of selected item -# opts - options containing css selector -# -# Usage: -# -# chosen(2, from: '#user_ids') -# - -module ChosenHelper - def chosen(value, options={}) - raise "Must pass a hash containing 'from'" if not options.is_a?(Hash) or not options.has_key?(:from) - - selector = options[:from] - - page.execute_script("$('#{selector}').val('#{value}').trigger('chosen:updated');") - end -end diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 025534a900..cc0ec2f4e3 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -16,7 +16,7 @@ module LoginHelpers def login_with(user) visit new_user_session_path fill_in "user_login", with: user.email - fill_in "user_password", with: "123456" + fill_in "user_password", with: "12345678" click_button "Sign in" Thread.current[:current_user] = user end diff --git a/spec/support/mentionable_shared_examples.rb b/spec/support/mentionable_shared_examples.rb index a7f189777c..3802e94ecf 100644 --- a/spec/support/mentionable_shared_examples.rb +++ b/spec/support/mentionable_shared_examples.rb @@ -11,8 +11,8 @@ def common_mentionable_setup let(:mentioned_issue) { create :issue, project: mproject } let(:other_issue) { create :issue, project: mproject } - let(:mentioned_mr) { create :merge_request, target_project: mproject, source_branch: 'different' } - let(:mentioned_commit) { mock('commit', sha: '1234567890abcdef').as_null_object } + let(:mentioned_mr) { create :merge_request, source_project: mproject, source_branch: 'different' } + let(:mentioned_commit) { double('commit', sha: '1234567890abcdef').as_null_object } # Override to add known commits to the repository stub. let(:extra_commits) { [] } @@ -30,7 +30,7 @@ def common_mentionable_setup commitmap = { '123456' => mentioned_commit } extra_commits.each { |c| commitmap[c.sha[0..5]] = c } - repo = mock('repository') + repo = double('repository') repo.stub(:commit) { |sha| commitmap[sha] } mproject.stub(repository: repo) diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index 16e10b1a62..b1bb65a836 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -29,7 +29,6 @@ module TestEnv disable_mailer if opts[:mailer] == false setup_stubs - clear_test_repo_dir if opts[:init_repos] == true setup_test_repos(opts) if opts[:repos] == true end @@ -45,6 +44,7 @@ module TestEnv def disable_mailer NotificationService.any_instance.stub(mailer: double.as_null_object) end + def enable_mailer NotificationService.any_instance.unstub(:mailer) end @@ -52,7 +52,7 @@ module TestEnv def setup_stubs() # Use tmp dir for FS manipulations repos_path = testing_path() - GollumWiki.any_instance.stub(:init_repo) do |path| + ProjectWiki.any_instance.stub(:init_repo) do |path| create_temp_repo(File.join(repos_path, "#{path}.git")) end @@ -68,7 +68,12 @@ module TestEnv remove_repository: true, update_repository_head: true, add_key: true, - remove_key: true + remove_key: true, + version: '6.3.0' + ) + + Gitlab::Satellite::MergeAction.any_instance.stub( + merge!: true, ) Gitlab::Satellite::Satellite.any_instance.stub( @@ -85,7 +90,7 @@ module TestEnv size: 12.45 ) - ActivityObserver.any_instance.stub( + BaseObserver.any_instance.stub( current_user: double("current_user", id: 1) ) end @@ -96,13 +101,24 @@ module TestEnv FileUtils.rm_rf File.join(testing_path(), "#{name}.wiki.git") end + def reset_satellite_dir + setup_stubs + [ + %W(git reset --hard --quiet), + %W(git clean -fx --quiet), + %W(git checkout --quiet origin/master) + ].each do |git_cmd| + system(*git_cmd, chdir: seed_satellite_path) + end + end + # Create a repo and it's satellite def create_repo(namespace, name) setup_stubs repo = repo(namespace, name) # Symlink tmp/repositories/gitlabhq to tmp/test-git-base-path/gitlabhq - system("ln -s -f #{seed_repo_path()} #{repo}") + FileUtils.ln_sf(seed_repo_path, repo) create_satellite(repo, namespace, name) end @@ -148,8 +164,7 @@ module TestEnv def clear_test_repo_dir setup_stubs - # Use tmp dir for FS manipulations - repos_path = testing_path() + # Remove tmp/test-git-base-path FileUtils.rm_rf Gitlab.config.gitlab_shell.repos_path @@ -166,12 +181,11 @@ module TestEnv # Symlink tmp/satellite/gitlabhq to tmp/test-git-base-path/satellite/gitlabhq, create the directory if it doesn't exist already satellite_dir = File.dirname(satellite_repo) FileUtils.mkdir_p(satellite_dir) unless File.exists?(satellite_dir) - system("ln -s -f #{seed_satellite_path} #{satellite_repo}") + FileUtils.ln_sf(seed_satellite_path, satellite_repo) end def create_temp_repo(path) FileUtils.mkdir_p path - command = "git init --quiet --bare #{path};" - system(command) + system(*%W(git init --quiet --bare -- #{path})) end end diff --git a/spec/support/valid_commit.rb b/spec/support/valid_commit.rb index 8094b679e9..98bc59b573 100644 --- a/spec/support/valid_commit.rb +++ b/spec/support/valid_commit.rb @@ -2,6 +2,7 @@ module ValidCommit ID = "8470d70da67355c9c009e4401746b1d5410af2e3" MESSAGE = "notes controller refactored" AUTHOR_FULL_NAME = "Dmitriy Zaporozhets" + AUTHOR_EMAIL = "dmitriy.zaporozhets@gmail.com" FILES = [".foreman", ".gitignore", ".rails_footnotes", ".rspec", ".travis.yml", "CHANGELOG", "Gemfile", "Gemfile.lock", "LICENSE", "Procfile", "Procfile.production", "README.md", "Rakefile", "VERSION", "app", "config.ru", "config", "db", "doc", "lib", "log", "public", "resque.sh", "script", "spec", "vendor"] FILES_COUNT = 26 diff --git a/spec/support/valid_commit_with_alt_email.rb b/spec/support/valid_commit_with_alt_email.rb new file mode 100644 index 0000000000..d6e364c41f --- /dev/null +++ b/spec/support/valid_commit_with_alt_email.rb @@ -0,0 +1,6 @@ +module ValidCommitWithAltEmail + ID = "1e689bfba39525ead225eaf611948cfbe8ac34cf" + MESSAGE = "fixed notes logic" + AUTHOR_FULL_NAME = "Dmitriy Zaporozhets" + AUTHOR_EMAIL = "dzaporozhets@sphereconsultinginc.com" +end \ No newline at end of file diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index cba243226d..71a45eb2fa 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -5,6 +5,7 @@ describe 'gitlab:app namespace rake task' do before :all do Rake.application.rake_require "tasks/gitlab/task_helpers" Rake.application.rake_require "tasks/gitlab/backup" + Rake.application.rake_require "tasks/gitlab/shell" # empty task as env is already loaded Rake::Task.define_task :environment end @@ -26,12 +27,15 @@ describe 'gitlab:app namespace rake task' do Dir.stub :chdir File.stub exists?: true Kernel.stub system: true + FileUtils.stub cp_r: true + FileUtils.stub mv: true + Rake::Task["gitlab:shell:setup"].stub invoke: true end - let(:gitlab_version) { %x{git rev-parse HEAD}.gsub(/\n/,"") } + let(:gitlab_version) { Gitlab::VERSION } it 'should fail on mismatch' do - YAML.stub load_file: {gitlab_version: gitlab_version.reverse} + YAML.stub load_file: {gitlab_version: "not #{gitlab_version}" } expect { run_rake_task }.to raise_error SystemExit end @@ -39,7 +43,8 @@ describe 'gitlab:app namespace rake task' do YAML.stub load_file: {gitlab_version: gitlab_version} Rake::Task["gitlab:backup:db:restore"].should_receive :invoke Rake::Task["gitlab:backup:repo:restore"].should_receive :invoke - expect { run_rake_task }.to_not raise_error SystemExit + Rake::Task["gitlab:shell:setup"].should_receive :invoke + expect { run_rake_task }.to_not raise_error end end diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index 46e86dbe00..e6bf79b853 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -9,7 +9,7 @@ describe PostReceive do end context "web hook" do - let(:project) { create(:project_with_code) } + let(:project) { create(:project) } let(:key) { create(:key, user: project.owner) } let(:key_id) { key.shell_id } @@ -19,7 +19,7 @@ describe PostReceive do end it "does not run if the author is not in the project" do - Key.stub(find_by_id: nil) + Key.stub(:find_by).with(hash_including(id: anything())) { nil } project.should_not_receive(:execute_hooks) diff --git a/tmp/pids/.gitkeep b/tmp/pids/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tmp/sockets/.gitkeep b/tmp/sockets/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vendor/assets/images/authbuttons/github_32.png b/vendor/assets/images/authbuttons/github_32.png deleted file mode 100644 index 247e52a5f4..0000000000 Binary files a/vendor/assets/images/authbuttons/github_32.png and /dev/null differ diff --git a/vendor/assets/images/authbuttons/google_32.png b/vendor/assets/images/authbuttons/google_32.png deleted file mode 100644 index 3909e9de93..0000000000 Binary files a/vendor/assets/images/authbuttons/google_32.png and /dev/null differ diff --git a/vendor/assets/images/authbuttons/google_64.png b/vendor/assets/images/authbuttons/google_64.png deleted file mode 100644 index e55f34f1b7..0000000000 Binary files a/vendor/assets/images/authbuttons/google_64.png and /dev/null differ diff --git a/vendor/assets/images/authbuttons/twitter_32.png b/vendor/assets/images/authbuttons/twitter_32.png deleted file mode 100644 index daadcffd31..0000000000 Binary files a/vendor/assets/images/authbuttons/twitter_32.png and /dev/null differ diff --git a/vendor/assets/images/authbuttons/twitter_64.png b/vendor/assets/images/authbuttons/twitter_64.png deleted file mode 100644 index 68b74530c0..0000000000 Binary files a/vendor/assets/images/authbuttons/twitter_64.png and /dev/null differ diff --git a/vendor/assets/images/icon_sprite.png b/vendor/assets/images/icon_sprite.png deleted file mode 100644 index 636c80f221..0000000000 Binary files a/vendor/assets/images/icon_sprite.png and /dev/null differ diff --git a/vendor/assets/images/progress_bar.gif b/vendor/assets/images/progress_bar.gif deleted file mode 100644 index 156fbb5313..0000000000 Binary files a/vendor/assets/images/progress_bar.gif and /dev/null differ diff --git a/vendor/assets/images/ui-icons_222222_256x240.png b/vendor/assets/images/ui-icons_222222_256x240.png deleted file mode 100644 index b273ff111d..0000000000 Binary files a/vendor/assets/images/ui-icons_222222_256x240.png and /dev/null differ diff --git a/vendor/assets/images/ui-icons_454545_256x240.png b/vendor/assets/images/ui-icons_454545_256x240.png deleted file mode 100644 index 59bd45b907..0000000000 Binary files a/vendor/assets/images/ui-icons_454545_256x240.png and /dev/null differ diff --git a/vendor/assets/javascripts/ace-src-noconflict/ace.js b/vendor/assets/javascripts/ace-src-noconflict/ace.js deleted file mode 100644 index 8bd2d9a605..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/ace.js +++ /dev/null @@ -1,15881 +0,0 @@ -/* ***** 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 initial 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 initial 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 emitted - // 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 - // being 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 occurrence 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]; - }); - })(); - diff --git a/vendor/assets/javascripts/ace-src-noconflict/keybinding-emacs.js b/vendor/assets/javascripts/ace-src-noconflict/keybinding-emacs.js deleted file mode 100644 index ba53c7c5ff..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/keybinding-emacs.js +++ /dev/null @@ -1,374 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 88ebc4e7c3..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/keybinding-vim.js +++ /dev/null @@ -1,1679 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 9f8401b753..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-c9search.js +++ /dev/null @@ -1,268 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 4b128fa40b..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-c_cpp.js +++ /dev/null @@ -1,759 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 6aa6fd717c..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-clojure.js +++ /dev/null @@ -1,347 +0,0 @@ -/* ***** 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 deleted file mode 100644 index b1d5e5f2b7..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-coffee.js +++ /dev/null @@ -1,513 +0,0 @@ -/* ***** 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 deleted file mode 100644 index aea4214560..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-coldfusion.js +++ /dev/null @@ -1,1852 +0,0 @@ -/* ***** 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 division 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 deleted file mode 100644 index 7aa8082fa4..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-csharp.js +++ /dev/null @@ -1,619 +0,0 @@ -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 deleted file mode 100644 index 48665f9510..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-css.js +++ /dev/null @@ -1,457 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 75e26cc705..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-diff.js +++ /dev/null @@ -1,244 +0,0 @@ -/* ***** 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 deleted file mode 100644 index c46651b20d..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-glsl.js +++ /dev/null @@ -1,834 +0,0 @@ -/* ***** 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 deleted file mode 100644 index c894682da0..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-golang.js +++ /dev/null @@ -1,674 +0,0 @@ -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 deleted file mode 100644 index 80d153d8fb..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-groovy.js +++ /dev/null @@ -1,1160 +0,0 @@ -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 division 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 deleted file mode 100644 index 78910005af..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-haxe.js +++ /dev/null @@ -1,624 +0,0 @@ -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 deleted file mode 100644 index 5ec11f141c..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-html.js +++ /dev/null @@ -1,1950 +0,0 @@ -/* ***** 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 division 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 deleted file mode 100644 index 32aafd17c9..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-jade.js +++ /dev/null @@ -1,2038 +0,0 @@ -/* ***** 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 division 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 deleted file mode 100644 index c05bf0f9e7..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-java.js +++ /dev/null @@ -1,1120 +0,0 @@ -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 division 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 deleted file mode 100644 index 90cf57eb5f..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-javascript.js +++ /dev/null @@ -1,990 +0,0 @@ -/* ***** 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 division 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 deleted file mode 100644 index 19260b4729..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-json.js +++ /dev/null @@ -1,581 +0,0 @@ -/* ***** 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 deleted file mode 100644 index e4f4bcffed..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-jsp.js +++ /dev/null @@ -1,1664 +0,0 @@ -/* ***** 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 division 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 deleted file mode 100644 index eb706bbdb6..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-latex.js +++ /dev/null @@ -1,95 +0,0 @@ -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 deleted file mode 100644 index 43bf8a9d52..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-less.js +++ /dev/null @@ -1,504 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 3886e739ba..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-liquid.js +++ /dev/null @@ -1,1003 +0,0 @@ -/* ***** 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 division 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 deleted file mode 100644 index 22d35f18a3..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-lua.js +++ /dev/null @@ -1,524 +0,0 @@ -/* ***** 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 deleted file mode 100644 index d8a1b653f3..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-luahtml.js +++ /dev/null @@ -1,2415 +0,0 @@ -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 division 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; - -}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-luapage.js b/vendor/assets/javascripts/ace-src-noconflict/mode-luapage.js deleted file mode 100644 index 9be136de97..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-luapage.js +++ /dev/null @@ -1,2480 +0,0 @@ -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 division 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; - -}); diff --git a/vendor/assets/javascripts/ace-src-noconflict/mode-markdown.js b/vendor/assets/javascripts/ace-src-noconflict/mode-markdown.js deleted file mode 100644 index e1c269eefc..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-markdown.js +++ /dev/null @@ -1,2252 +0,0 @@ -/* ***** 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 division 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 deleted file mode 100644 index e6188c7323..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-ocaml.js +++ /dev/null @@ -1,452 +0,0 @@ -/* ***** 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 deleted file mode 100644 index d53a347ae8..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-perl.js +++ /dev/null @@ -1,419 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 2bc99ff9ca..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-pgsql.js +++ /dev/null @@ -1,963 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 40710ceef2..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-php.js +++ /dev/null @@ -1,2359 +0,0 @@ -/* ***** 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 division 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 deleted file mode 100644 index 6e58237bde..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-powershell.js +++ /dev/null @@ -1,608 +0,0 @@ -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 deleted file mode 100644 index 51e1acf7b7..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-python.js +++ /dev/null @@ -1,383 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 72ad0a4a2c..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-ruby.js +++ /dev/null @@ -1,302 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 3d3c42cd18..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-scad.js +++ /dev/null @@ -1,712 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 87b8e12b8e..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-scala.js +++ /dev/null @@ -1,1151 +0,0 @@ -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 division 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 deleted file mode 100644 index 10a2b33d8f..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-scss.js +++ /dev/null @@ -1,530 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 52fbfae331..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-sh.js +++ /dev/null @@ -1,238 +0,0 @@ -/* ***** 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 deleted file mode 100644 index d7fab1c53e..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-sql.js +++ /dev/null @@ -1,145 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 96b965ba11..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-svg.js +++ /dev/null @@ -1,1602 +0,0 @@ -/* ***** 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 division 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 deleted file mode 100644 index 64473a2479..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-tcl.js +++ /dev/null @@ -1,444 +0,0 @@ -/* ***** 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-textile.js b/vendor/assets/javascripts/ace-src-noconflict/mode-textile.js deleted file mode 100644 index fb70ddc0e2..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-textile.js +++ /dev/null @@ -1,175 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 07a154d6df..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-xml.js +++ /dev/null @@ -1,822 +0,0 @@ -/* ***** 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 deleted file mode 100644 index b42730f900..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-xquery.js +++ /dev/null @@ -1,591 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 87a059fa6b..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/mode-yaml.js +++ /dev/null @@ -1,371 +0,0 @@ -/* ***** 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 deleted file mode 100644 index fb4e15707e..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-ambiance.js +++ /dev/null @@ -1,269 +0,0 @@ -/* ***** 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 deleted file mode 100644 index dbbe865f78..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-chrome.js +++ /dev/null @@ -1,205 +0,0 @@ -/* ***** 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 deleted file mode 100644 index b6d474907d..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-clouds.js +++ /dev/null @@ -1,170 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 57501d91d0..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-clouds_midnight.js +++ /dev/null @@ -1,171 +0,0 @@ -/* ***** 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 deleted file mode 100644 index d0c8d24ece..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-cobalt.js +++ /dev/null @@ -1,182 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 38230ae8cc..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-crimson_editor.js +++ /dev/null @@ -1,197 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 8ac1239a58..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-dawn.js +++ /dev/null @@ -1,183 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 315df6b30a..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-dreamweaver.js +++ /dev/null @@ -1,224 +0,0 @@ -/* ***** 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 deleted file mode 100644 index a26af55ee8..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-eclipse.js +++ /dev/null @@ -1,154 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 7aacdf1a69..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-github.js +++ /dev/null @@ -1,175 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 79c1299018..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-idle_fingers.js +++ /dev/null @@ -1,171 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 12f5d5b38e..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-kr_theme.js +++ /dev/null @@ -1,177 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 2e2926d532..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-merbivore.js +++ /dev/null @@ -1,168 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 9e41cb7cdf..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-merbivore_soft.js +++ /dev/null @@ -1,169 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 7f9c355d1a..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-mono_industrial.js +++ /dev/null @@ -1,180 +0,0 @@ -/* ***** 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 deleted file mode 100644 index e1f832aad9..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-monokai.js +++ /dev/null @@ -1,174 +0,0 @@ -/* ***** 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 deleted file mode 100644 index df29686a6b..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-pastel_on_dark.js +++ /dev/null @@ -1,187 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 7894bdef01..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-solarized_dark.js +++ /dev/null @@ -1,159 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 35f880c26a..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-solarized_light.js +++ /dev/null @@ -1,164 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 97c0b18317..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-textmate.js +++ /dev/null @@ -1,207 +0,0 @@ -/* ***** 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 deleted file mode 100644 index f7e24444cf..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow.js +++ /dev/null @@ -1,182 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 9e65098d9e..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night.js +++ /dev/null @@ -1,182 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 19d8c3b5dd..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_blue.js +++ /dev/null @@ -1,179 +0,0 @@ -/* ***** 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 deleted file mode 100644 index c5009ba779..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_bright.js +++ /dev/null @@ -1,182 +0,0 @@ -/* ***** 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 deleted file mode 100644 index e68e3279d4..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-tomorrow_night_eighties.js +++ /dev/null @@ -1,178 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 925093bbc2..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-twilight.js +++ /dev/null @@ -1,184 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 097810cd38..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-vibrant_ink.js +++ /dev/null @@ -1,164 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 7c040fa281..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/theme-xcode.js +++ /dev/null @@ -1,156 +0,0 @@ -/* ***** 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 deleted file mode 100644 index 3a7bf80fce..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/worker-coffee.js +++ /dev/null @@ -1,7213 +0,0 @@ -"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 deleted file mode 100644 index 19513c7ba9..0000000000 --- a/vendor/assets/javascripts/ace-src-noconflict/worker-css.js +++ /dev/null @@ -1,10940 +0,0 @@ -"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: "