locomotive_cms 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +45 -0
- data/README.textile +23 -0
- data/app/controllers/admin/accounts_controller.rb +24 -0
- data/app/controllers/admin/asset_collections_controller.rb +66 -0
- data/app/controllers/admin/assets_controller.rb +48 -0
- data/app/controllers/admin/base_controller.rb +55 -0
- data/app/controllers/admin/content_types_controller.rb +52 -0
- data/app/controllers/admin/contents_controller.rb +72 -0
- data/app/controllers/admin/current_sites_controller.rb +33 -0
- data/app/controllers/admin/layouts_controller.rb +56 -0
- data/app/controllers/admin/memberships_controller.rb +39 -0
- data/app/controllers/admin/my_accounts_controller.rb +21 -0
- data/app/controllers/admin/page_parts_controller.rb +12 -0
- data/app/controllers/admin/pages_controller.rb +70 -0
- data/app/controllers/admin/passwords_controller.rb +11 -0
- data/app/controllers/admin/rendering_controller.rb +15 -0
- data/app/controllers/admin/sessions_controller.rb +17 -0
- data/app/controllers/admin/sites_controller.rb +48 -0
- data/app/controllers/admin/snippets_controller.rb +56 -0
- data/app/controllers/admin/theme_assets_controller.rb +79 -0
- data/app/controllers/application_controller.rb +3 -0
- data/app/controllers/home_controller.rb +7 -0
- data/app/helpers/admin/accounts_helper.rb +8 -0
- data/app/helpers/admin/assets_helper.rb +15 -0
- data/app/helpers/admin/base_helper.rb +54 -0
- data/app/helpers/admin/custom_fields_helper.rb +24 -0
- data/app/helpers/admin/login_helper.rb +17 -0
- data/app/helpers/admin/pages_helper.rb +23 -0
- data/app/helpers/admin/sites_helper.rb +24 -0
- data/app/models/account.rb +46 -0
- data/app/models/asset.rb +38 -0
- data/app/models/asset_collection.rb +60 -0
- data/app/models/content_instance.rb +29 -0
- data/app/models/content_type.rb +63 -0
- data/app/models/extensions/asset/vignette.rb +40 -0
- data/app/models/extensions/page/parts.rb +54 -0
- data/app/models/extensions/page/render.rb +19 -0
- data/app/models/extensions/page/tree.rb +97 -0
- data/app/models/layout.rb +49 -0
- data/app/models/liquid_template.rb +32 -0
- data/app/models/membership.rb +36 -0
- data/app/models/page.rb +87 -0
- data/app/models/page_part.rb +38 -0
- data/app/models/site.rb +93 -0
- data/app/models/snippet.rb +3 -0
- data/app/models/theme_asset.rb +101 -0
- data/app/uploaders/asset_uploader.rb +68 -0
- data/app/uploaders/theme_asset_uploader.rb +42 -0
- data/app/views/admin/accounts/new.html.haml +22 -0
- data/app/views/admin/asset_collections/_asset.html.haml +7 -0
- data/app/views/admin/asset_collections/edit.html.haml +30 -0
- data/app/views/admin/asset_collections/index.html.haml +8 -0
- data/app/views/admin/asset_collections/new.html.haml +17 -0
- data/app/views/admin/assets/_form.html.haml +18 -0
- data/app/views/admin/assets/edit.html.haml +15 -0
- data/app/views/admin/assets/new.html.haml +12 -0
- data/app/views/admin/content_types/_form.html.haml +13 -0
- data/app/views/admin/content_types/edit.html.haml +16 -0
- data/app/views/admin/content_types/new.html.haml +15 -0
- data/app/views/admin/contents/_form.html.haml +10 -0
- data/app/views/admin/contents/edit.html.haml +16 -0
- data/app/views/admin/contents/index.html.haml +35 -0
- data/app/views/admin/contents/new.html.haml +15 -0
- data/app/views/admin/current_sites/_form.html.haml +45 -0
- data/app/views/admin/current_sites/edit.html.haml +15 -0
- data/app/views/admin/layouts/_form.html.haml +10 -0
- data/app/views/admin/layouts/_layout.html.haml +7 -0
- data/app/views/admin/layouts/edit.html.haml +18 -0
- data/app/views/admin/layouts/index.html.haml +15 -0
- data/app/views/admin/layouts/new.html.haml +15 -0
- data/app/views/admin/memberships/new.html.haml +15 -0
- data/app/views/admin/my_accounts/edit.html.haml +42 -0
- data/app/views/admin/pages/_form.html.haml +37 -0
- data/app/views/admin/pages/_page.html.haml +16 -0
- data/app/views/admin/pages/edit.html.haml +15 -0
- data/app/views/admin/pages/index.html.haml +18 -0
- data/app/views/admin/pages/new.html.haml +12 -0
- data/app/views/admin/passwords/edit.html.haml +18 -0
- data/app/views/admin/passwords/new.html.haml +17 -0
- data/app/views/admin/sessions/new.html.haml +15 -0
- data/app/views/admin/shared/_custom_fields.html.haml +47 -0
- data/app/views/admin/shared/_footer.html.haml +5 -0
- data/app/views/admin/shared/_form_actions.html.haml +15 -0
- data/app/views/admin/shared/_head.html.haml +18 -0
- data/app/views/admin/shared/_header.html.haml +8 -0
- data/app/views/admin/shared/_menu.html.haml +5 -0
- data/app/views/admin/shared/menu/_assets.html.haml +7 -0
- data/app/views/admin/shared/menu/_contents.html.haml +27 -0
- data/app/views/admin/shared/menu/_settings.html.haml +6 -0
- data/app/views/admin/sites/_form.html.haml +35 -0
- data/app/views/admin/sites/new.html.haml +12 -0
- data/app/views/admin/snippets/_form.html.haml +11 -0
- data/app/views/admin/snippets/_snippet.html.haml +7 -0
- data/app/views/admin/snippets/edit.html.haml +15 -0
- data/app/views/admin/snippets/index.html.haml +15 -0
- data/app/views/admin/snippets/new.html.haml +12 -0
- data/app/views/admin/theme_assets/_asset.html.haml +12 -0
- data/app/views/admin/theme_assets/_form.html.haml +39 -0
- data/app/views/admin/theme_assets/edit.html.haml +15 -0
- data/app/views/admin/theme_assets/images.html.haml +15 -0
- data/app/views/admin/theme_assets/index.html.haml +27 -0
- data/app/views/admin/theme_assets/new.html.haml +12 -0
- data/app/views/devise/confirmations/new.html.haml +12 -0
- data/app/views/devise/mailer/confirmation_instructions.html.haml +8 -0
- data/app/views/devise/mailer/reset_password_instructions.html.haml +12 -0
- data/app/views/devise/mailer/unlock_instructions.html.haml +10 -0
- data/app/views/devise/registrations/edit.html.haml +35 -0
- data/app/views/devise/registrations/new.html.haml +20 -0
- data/app/views/devise/sessions/new.html.haml +22 -0
- data/app/views/devise/shared/_links.haml +20 -0
- data/app/views/devise/unlocks/new.html.haml +12 -0
- data/app/views/home/show.html.haml +4 -0
- data/app/views/layouts/admin/application.html.haml +26 -0
- data/app/views/layouts/admin/login.html.haml +17 -0
- data/app/views/layouts/application.html.haml +7 -0
- data/config/application.rb +48 -0
- data/config/boot.rb +17 -0
- data/config/cucumber.yml +8 -0
- data/config/database.yml +20 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +35 -0
- data/config/environments/production.rb +33 -0
- data/config/environments/test.rb +33 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/carrierwave.rb +57 -0
- data/config/initializers/devise.rb +119 -0
- data/config/initializers/formtastic.rb +5 -0
- data/config/initializers/inflections.rb +10 -0
- data/config/initializers/locomotive.rb +7 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/initializers/mongoid.rb +61 -0
- data/config/initializers/rspec_generator.rb +8 -0
- data/config/locales/admin_ui_en.yml +211 -0
- data/config/locales/admin_ui_fr.yml +21 -0
- data/config/locales/carrierwave_en.yml +4 -0
- data/config/locales/carrierwave_fr.yml +4 -0
- data/config/locales/default_en.yml +29 -0
- data/config/locales/default_fr.yml +30 -0
- data/config/locales/devise.en.yml +36 -0
- data/config/routes.rb +57 -0
- data/lib/core_ext.rb +32 -0
- data/lib/generators/locomotive_generator.rb +14 -0
- data/lib/locomotive.rb +35 -0
- data/lib/locomotive/configuration.rb +67 -0
- data/lib/locomotive/devise/sessions_controller.rb +2 -0
- data/lib/locomotive/engine.rb +21 -0
- data/lib/locomotive/liquid.rb +5 -0
- data/lib/locomotive/liquid/db_file_system.rb +18 -0
- data/lib/locomotive/liquid/drops/asset_collections.rb +19 -0
- data/lib/locomotive/liquid/drops/base.rb +50 -0
- data/lib/locomotive/liquid/drops/content.rb +19 -0
- data/lib/locomotive/liquid/drops/contents.rb +63 -0
- data/lib/locomotive/liquid/drops/javascripts.rb +18 -0
- data/lib/locomotive/liquid/drops/stylesheets.rb +19 -0
- data/lib/locomotive/liquid/filters/date.rb +30 -0
- data/lib/locomotive/liquid/filters/html.rb +114 -0
- data/lib/locomotive/liquid/filters/misc.rb +30 -0
- data/lib/locomotive/liquid/liquify_template.rb +57 -0
- data/lib/locomotive/liquid/tags/blueprint.rb +21 -0
- data/lib/locomotive/liquid/tags/jquery.rb +17 -0
- data/lib/locomotive/liquid/tags/paginate.rb +100 -0
- data/lib/locomotive/liquid/tags/snippet.rb +42 -0
- data/lib/locomotive/liquid/tags/with_scope.rb +39 -0
- data/lib/locomotive/mongoid.rb +2 -0
- data/lib/locomotive/mongoid/document.rb +20 -0
- data/lib/locomotive/mongoid/model_extensions.rb +1 -0
- data/lib/locomotive/patches.rb +2 -0
- data/lib/locomotive/regexps.rb +13 -0
- data/lib/locomotive/render.rb +59 -0
- data/lib/locomotive/routing/default_constraint.rb +45 -0
- data/lib/locomotive/routing/site_dispatcher.rb +48 -0
- data/lib/misc_form_builder.rb +35 -0
- data/lib/tasks/cucumber.rake +53 -0
- data/lib/tasks/rspec.rake +69 -0
- data/public/images/admin/background/body.png +0 -0
- data/public/images/admin/background/footer.png +0 -0
- data/public/images/admin/background/light.png +0 -0
- data/public/images/admin/buttons/action-left.png +0 -0
- data/public/images/admin/buttons/action-right.png +0 -0
- data/public/images/admin/buttons/add-left.png +0 -0
- data/public/images/admin/buttons/add-right.png +0 -0
- data/public/images/admin/buttons/dark-gray-left.png +0 -0
- data/public/images/admin/buttons/dark-gray-right.png +0 -0
- data/public/images/admin/buttons/emboss-left.png +0 -0
- data/public/images/admin/buttons/emboss-right.png +0 -0
- data/public/images/admin/buttons/gray-left.png +0 -0
- data/public/images/admin/buttons/gray-right.png +0 -0
- data/public/images/admin/buttons/light-gray-left.png +0 -0
- data/public/images/admin/buttons/light-gray-right.png +0 -0
- data/public/images/admin/buttons/search.png +0 -0
- data/public/images/admin/buttons/transparent-left.png +0 -0
- data/public/images/admin/buttons/transparent-right.png +0 -0
- data/public/images/admin/form/big_item.png +0 -0
- data/public/images/admin/form/error-arrow.png +0 -0
- data/public/images/admin/form/field.png +0 -0
- data/public/images/admin/form/folded-arrow-off.png +0 -0
- data/public/images/admin/form/folded-arrow-on.png +0 -0
- data/public/images/admin/form/folded.png +0 -0
- data/public/images/admin/form/footer.png +0 -0
- data/public/images/admin/form/growl-error.png +0 -0
- data/public/images/admin/form/growl-notice.png +0 -0
- data/public/images/admin/form/header-first-on.png +0 -0
- data/public/images/admin/form/header-left-on.png +0 -0
- data/public/images/admin/form/header-on.png +0 -0
- data/public/images/admin/form/header-right-on.png +0 -0
- data/public/images/admin/form/header.png +0 -0
- data/public/images/admin/form/icons/drag.png +0 -0
- data/public/images/admin/form/icons/spinner.gif +0 -0
- data/public/images/admin/form/icons/trash.png +0 -0
- data/public/images/admin/form/item.png +0 -0
- data/public/images/admin/form/pen.png +0 -0
- data/public/images/admin/icons/filetype/medium/AC3.png +0 -0
- data/public/images/admin/icons/filetype/medium/ACE.png +0 -0
- data/public/images/admin/icons/filetype/medium/ADE.png +0 -0
- data/public/images/admin/icons/filetype/medium/ADP.png +0 -0
- data/public/images/admin/icons/filetype/medium/AI.png +0 -0
- data/public/images/admin/icons/filetype/medium/AIFF.png +0 -0
- data/public/images/admin/icons/filetype/medium/AU.png +0 -0
- data/public/images/admin/icons/filetype/medium/AVI.png +0 -0
- data/public/images/admin/icons/filetype/medium/BAT.png +0 -0
- data/public/images/admin/icons/filetype/medium/BIN.png +0 -0
- data/public/images/admin/icons/filetype/medium/BMP.png +0 -0
- data/public/images/admin/icons/filetype/medium/BUP.png +0 -0
- data/public/images/admin/icons/filetype/medium/CAB.png +0 -0
- data/public/images/admin/icons/filetype/medium/CAT.png +0 -0
- data/public/images/admin/icons/filetype/medium/CHM.png +0 -0
- data/public/images/admin/icons/filetype/medium/CSS.png +0 -0
- data/public/images/admin/icons/filetype/medium/CUE.png +0 -0
- data/public/images/admin/icons/filetype/medium/DAT.png +0 -0
- data/public/images/admin/icons/filetype/medium/DCR.png +0 -0
- data/public/images/admin/icons/filetype/medium/DER.png +0 -0
- data/public/images/admin/icons/filetype/medium/DIC.png +0 -0
- data/public/images/admin/icons/filetype/medium/DIVX.png +0 -0
- data/public/images/admin/icons/filetype/medium/DIZ.png +0 -0
- data/public/images/admin/icons/filetype/medium/DLL.png +0 -0
- data/public/images/admin/icons/filetype/medium/DOC.png +0 -0
- data/public/images/admin/icons/filetype/medium/DOCX.png +0 -0
- data/public/images/admin/icons/filetype/medium/DOS.png +0 -0
- data/public/images/admin/icons/filetype/medium/DVD.png +0 -0
- data/public/images/admin/icons/filetype/medium/DWG.png +0 -0
- data/public/images/admin/icons/filetype/medium/DWT.png +0 -0
- data/public/images/admin/icons/filetype/medium/EMF.png +0 -0
- data/public/images/admin/icons/filetype/medium/EXC.png +0 -0
- data/public/images/admin/icons/filetype/medium/FON.png +0 -0
- data/public/images/admin/icons/filetype/medium/GIF.png +0 -0
- data/public/images/admin/icons/filetype/medium/HLP.png +0 -0
- data/public/images/admin/icons/filetype/medium/HTML.png +0 -0
- data/public/images/admin/icons/filetype/medium/IFO.png +0 -0
- data/public/images/admin/icons/filetype/medium/INF.png +0 -0
- data/public/images/admin/icons/filetype/medium/INI.png +0 -0
- data/public/images/admin/icons/filetype/medium/INS.png +0 -0
- data/public/images/admin/icons/filetype/medium/IP.png +0 -0
- data/public/images/admin/icons/filetype/medium/ISO.png +0 -0
- data/public/images/admin/icons/filetype/medium/ISP.png +0 -0
- data/public/images/admin/icons/filetype/medium/JAVA.png +0 -0
- data/public/images/admin/icons/filetype/medium/JFIF.png +0 -0
- data/public/images/admin/icons/filetype/medium/JPEG.png +0 -0
- data/public/images/admin/icons/filetype/medium/JPG.png +0 -0
- data/public/images/admin/icons/filetype/medium/LOG.png +0 -0
- data/public/images/admin/icons/filetype/medium/M4A.png +0 -0
- data/public/images/admin/icons/filetype/medium/MID.png +0 -0
- data/public/images/admin/icons/filetype/medium/MMF.png +0 -0
- data/public/images/admin/icons/filetype/medium/MMM.png +0 -0
- data/public/images/admin/icons/filetype/medium/MOV.png +0 -0
- data/public/images/admin/icons/filetype/medium/MOVIE.png +0 -0
- data/public/images/admin/icons/filetype/medium/MP2.png +0 -0
- data/public/images/admin/icons/filetype/medium/MP2V.png +0 -0
- data/public/images/admin/icons/filetype/medium/MP3.png +0 -0
- data/public/images/admin/icons/filetype/medium/MP4.png +0 -0
- data/public/images/admin/icons/filetype/medium/MPE.png +0 -0
- data/public/images/admin/icons/filetype/medium/MPEG.png +0 -0
- data/public/images/admin/icons/filetype/medium/MPG.png +0 -0
- data/public/images/admin/icons/filetype/medium/MPV2.png +0 -0
- data/public/images/admin/icons/filetype/medium/NFO.png +0 -0
- data/public/images/admin/icons/filetype/medium/PDD.png +0 -0
- data/public/images/admin/icons/filetype/medium/PDF.png +0 -0
- data/public/images/admin/icons/filetype/medium/PHP.png +0 -0
- data/public/images/admin/icons/filetype/medium/PNG.png +0 -0
- data/public/images/admin/icons/filetype/medium/PPT.png +0 -0
- data/public/images/admin/icons/filetype/medium/PPTX.png +0 -0
- data/public/images/admin/icons/filetype/medium/PSD.png +0 -0
- data/public/images/admin/icons/filetype/medium/RAR.png +0 -0
- data/public/images/admin/icons/filetype/medium/REG.png +0 -0
- data/public/images/admin/icons/filetype/medium/RTF.png +0 -0
- data/public/images/admin/icons/filetype/medium/SCP.png +0 -0
- data/public/images/admin/icons/filetype/medium/THEME.png +0 -0
- data/public/images/admin/icons/filetype/medium/TIF.png +0 -0
- data/public/images/admin/icons/filetype/medium/TIFF.png +0 -0
- data/public/images/admin/icons/filetype/medium/TLB.png +0 -0
- data/public/images/admin/icons/filetype/medium/TTF.png +0 -0
- data/public/images/admin/icons/filetype/medium/TXT.png +0 -0
- data/public/images/admin/icons/filetype/medium/Thumbs.db +0 -0
- data/public/images/admin/icons/filetype/medium/UIS.png +0 -0
- data/public/images/admin/icons/filetype/medium/URL.png +0 -0
- data/public/images/admin/icons/filetype/medium/VBS.png +0 -0
- data/public/images/admin/icons/filetype/medium/VCR.png +0 -0
- data/public/images/admin/icons/filetype/medium/VOB.png +0 -0
- data/public/images/admin/icons/filetype/medium/WAV.png +0 -0
- data/public/images/admin/icons/filetype/medium/WBA.png +0 -0
- data/public/images/admin/icons/filetype/medium/WMA.png +0 -0
- data/public/images/admin/icons/filetype/medium/WMV.png +0 -0
- data/public/images/admin/icons/filetype/medium/WPL.png +0 -0
- data/public/images/admin/icons/filetype/medium/WRI.png +0 -0
- data/public/images/admin/icons/filetype/medium/WTX.png +0 -0
- data/public/images/admin/icons/filetype/medium/XLS.png +0 -0
- data/public/images/admin/icons/filetype/medium/XLSX.png +0 -0
- data/public/images/admin/icons/filetype/medium/XML.png +0 -0
- data/public/images/admin/icons/filetype/medium/XSL.png +0 -0
- data/public/images/admin/icons/filetype/medium/ZAP.png +0 -0
- data/public/images/admin/icons/filetype/medium/ZIP.png +0 -0
- data/public/images/admin/icons/filetype/medium/unknown.png +0 -0
- data/public/images/admin/icons/filetype/thumb/AC3.png +0 -0
- data/public/images/admin/icons/filetype/thumb/ACE.png +0 -0
- data/public/images/admin/icons/filetype/thumb/ADE.png +0 -0
- data/public/images/admin/icons/filetype/thumb/ADP.png +0 -0
- data/public/images/admin/icons/filetype/thumb/AI.png +0 -0
- data/public/images/admin/icons/filetype/thumb/AIFF.png +0 -0
- data/public/images/admin/icons/filetype/thumb/AU.png +0 -0
- data/public/images/admin/icons/filetype/thumb/AVI.png +0 -0
- data/public/images/admin/icons/filetype/thumb/BAT.png +0 -0
- data/public/images/admin/icons/filetype/thumb/BIN.png +0 -0
- data/public/images/admin/icons/filetype/thumb/BMP.png +0 -0
- data/public/images/admin/icons/filetype/thumb/BUP.png +0 -0
- data/public/images/admin/icons/filetype/thumb/CAB.png +0 -0
- data/public/images/admin/icons/filetype/thumb/CAT.png +0 -0
- data/public/images/admin/icons/filetype/thumb/CHM.png +0 -0
- data/public/images/admin/icons/filetype/thumb/CSS.png +0 -0
- data/public/images/admin/icons/filetype/thumb/CUE.png +0 -0
- data/public/images/admin/icons/filetype/thumb/DAT.png +0 -0
- data/public/images/admin/icons/filetype/thumb/DCR.png +0 -0
- data/public/images/admin/icons/filetype/thumb/DER.png +0 -0
- data/public/images/admin/icons/filetype/thumb/DIC.png +0 -0
- data/public/images/admin/icons/filetype/thumb/DIVX.png +0 -0
- data/public/images/admin/icons/filetype/thumb/DIZ.png +0 -0
- data/public/images/admin/icons/filetype/thumb/DLL.png +0 -0
- data/public/images/admin/icons/filetype/thumb/DOC.png +0 -0
- data/public/images/admin/icons/filetype/thumb/DOCX.png +0 -0
- data/public/images/admin/icons/filetype/thumb/DOS.png +0 -0
- data/public/images/admin/icons/filetype/thumb/DVD.png +0 -0
- data/public/images/admin/icons/filetype/thumb/DWG.png +0 -0
- data/public/images/admin/icons/filetype/thumb/DWT.png +0 -0
- data/public/images/admin/icons/filetype/thumb/EMF.png +0 -0
- data/public/images/admin/icons/filetype/thumb/EXC.png +0 -0
- data/public/images/admin/icons/filetype/thumb/FON.png +0 -0
- data/public/images/admin/icons/filetype/thumb/GIF.png +0 -0
- data/public/images/admin/icons/filetype/thumb/HLP.png +0 -0
- data/public/images/admin/icons/filetype/thumb/HTML.png +0 -0
- data/public/images/admin/icons/filetype/thumb/IFO.png +0 -0
- data/public/images/admin/icons/filetype/thumb/INF.png +0 -0
- data/public/images/admin/icons/filetype/thumb/INI.png +0 -0
- data/public/images/admin/icons/filetype/thumb/INS.png +0 -0
- data/public/images/admin/icons/filetype/thumb/IP.png +0 -0
- data/public/images/admin/icons/filetype/thumb/ISO.png +0 -0
- data/public/images/admin/icons/filetype/thumb/ISP.png +0 -0
- data/public/images/admin/icons/filetype/thumb/JAVA.png +0 -0
- data/public/images/admin/icons/filetype/thumb/JFIF.png +0 -0
- data/public/images/admin/icons/filetype/thumb/JPEG.png +0 -0
- data/public/images/admin/icons/filetype/thumb/JPG.png +0 -0
- data/public/images/admin/icons/filetype/thumb/LOG.png +0 -0
- data/public/images/admin/icons/filetype/thumb/M4A.png +0 -0
- data/public/images/admin/icons/filetype/thumb/MID.png +0 -0
- data/public/images/admin/icons/filetype/thumb/MMF.png +0 -0
- data/public/images/admin/icons/filetype/thumb/MMM.png +0 -0
- data/public/images/admin/icons/filetype/thumb/MOV.png +0 -0
- data/public/images/admin/icons/filetype/thumb/MOVIE.png +0 -0
- data/public/images/admin/icons/filetype/thumb/MP2.png +0 -0
- data/public/images/admin/icons/filetype/thumb/MP2V.png +0 -0
- data/public/images/admin/icons/filetype/thumb/MP3.png +0 -0
- data/public/images/admin/icons/filetype/thumb/MP4.png +0 -0
- data/public/images/admin/icons/filetype/thumb/MPE.png +0 -0
- data/public/images/admin/icons/filetype/thumb/MPEG.png +0 -0
- data/public/images/admin/icons/filetype/thumb/MPG.png +0 -0
- data/public/images/admin/icons/filetype/thumb/MPV2.png +0 -0
- data/public/images/admin/icons/filetype/thumb/NFO.png +0 -0
- data/public/images/admin/icons/filetype/thumb/PDD.png +0 -0
- data/public/images/admin/icons/filetype/thumb/PDF.png +0 -0
- data/public/images/admin/icons/filetype/thumb/PHP.png +0 -0
- data/public/images/admin/icons/filetype/thumb/PNG.png +0 -0
- data/public/images/admin/icons/filetype/thumb/PPT.png +0 -0
- data/public/images/admin/icons/filetype/thumb/PPTX.png +0 -0
- data/public/images/admin/icons/filetype/thumb/PSD.png +0 -0
- data/public/images/admin/icons/filetype/thumb/RAR.png +0 -0
- data/public/images/admin/icons/filetype/thumb/REG.png +0 -0
- data/public/images/admin/icons/filetype/thumb/RTF.png +0 -0
- data/public/images/admin/icons/filetype/thumb/SCP.png +0 -0
- data/public/images/admin/icons/filetype/thumb/THEME.png +0 -0
- data/public/images/admin/icons/filetype/thumb/TIF.png +0 -0
- data/public/images/admin/icons/filetype/thumb/TIFF.png +0 -0
- data/public/images/admin/icons/filetype/thumb/TLB.png +0 -0
- data/public/images/admin/icons/filetype/thumb/TTF.png +0 -0
- data/public/images/admin/icons/filetype/thumb/TXT.png +0 -0
- data/public/images/admin/icons/filetype/thumb/UIS.png +0 -0
- data/public/images/admin/icons/filetype/thumb/URL.png +0 -0
- data/public/images/admin/icons/filetype/thumb/VBS.png +0 -0
- data/public/images/admin/icons/filetype/thumb/VCR.png +0 -0
- data/public/images/admin/icons/filetype/thumb/VOB.png +0 -0
- data/public/images/admin/icons/filetype/thumb/WAV.png +0 -0
- data/public/images/admin/icons/filetype/thumb/WBA.png +0 -0
- data/public/images/admin/icons/filetype/thumb/WMA.png +0 -0
- data/public/images/admin/icons/filetype/thumb/WMV.png +0 -0
- data/public/images/admin/icons/filetype/thumb/WPL.png +0 -0
- data/public/images/admin/icons/filetype/thumb/WRI.png +0 -0
- data/public/images/admin/icons/filetype/thumb/WTX.png +0 -0
- data/public/images/admin/icons/filetype/thumb/XLS.png +0 -0
- data/public/images/admin/icons/filetype/thumb/XLSX.png +0 -0
- data/public/images/admin/icons/filetype/thumb/XML.png +0 -0
- data/public/images/admin/icons/filetype/thumb/XSL.png +0 -0
- data/public/images/admin/icons/filetype/thumb/ZAP.png +0 -0
- data/public/images/admin/icons/filetype/thumb/ZIP.png +0 -0
- data/public/images/admin/icons/filetype/thumb/unknown.png +0 -0
- data/public/images/admin/icons/flags/en.png +0 -0
- data/public/images/admin/icons/flags/fr.png +0 -0
- data/public/images/admin/list/empty.png +0 -0
- data/public/images/admin/list/icons/cross.png +0 -0
- data/public/images/admin/list/icons/drag.png +0 -0
- data/public/images/admin/list/icons/node_closed.png +0 -0
- data/public/images/admin/list/icons/node_open.png +0 -0
- data/public/images/admin/list/icons/trash.png +0 -0
- data/public/images/admin/list/item-left.png +0 -0
- data/public/images/admin/list/item-right.png +0 -0
- data/public/images/admin/list/item.png +0 -0
- data/public/images/admin/list/none.png +0 -0
- data/public/images/admin/list/thumb.png +0 -0
- data/public/images/admin/login/bottom_panel_bg.png +0 -0
- data/public/images/admin/login/buttons/left_bg.png +0 -0
- data/public/images/admin/login/buttons/right_bg.png +0 -0
- data/public/images/admin/login/content_panel_bg.png +0 -0
- data/public/images/admin/login/input_bg.png +0 -0
- data/public/images/admin/login/light_bg.png +0 -0
- data/public/images/admin/login/top_panel_bg.png +0 -0
- data/public/images/admin/login/wrapper_bg.png +0 -0
- data/public/images/admin/menu/arrow.png +0 -0
- data/public/images/admin/menu/blue-bg.png +0 -0
- data/public/images/admin/menu/blue-border.png +0 -0
- data/public/images/admin/menu/gray-bg.png +0 -0
- data/public/images/admin/menu/gray-border.png +0 -0
- data/public/images/admin/menu/green-bg.png +0 -0
- data/public/images/admin/menu/green-border.png +0 -0
- data/public/images/admin/menu/icons/add.png +0 -0
- data/public/images/admin/menu/icons/bullet.png +0 -0
- data/public/images/admin/menu/icons/folder.png +0 -0
- data/public/images/admin/menu/icons/settings.png +0 -0
- data/public/images/admin/menu/left.png +0 -0
- data/public/images/admin/menu/popup-body.png +0 -0
- data/public/images/admin/menu/popup-footer.png +0 -0
- data/public/images/admin/menu/popup-header.png +0 -0
- data/public/images/admin/menu/right.png +0 -0
- data/public/images/admin/menu/shadow.png +0 -0
- data/public/images/admin/menu/top-left.png +0 -0
- data/public/images/admin/menu/top.png +0 -0
- data/public/images/admin/nocoffee.gif +0 -0
- data/public/images/admin/plugins/fancybox/blank.gif +0 -0
- data/public/images/admin/plugins/fancybox/fancy_close.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_loading.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_nav_left.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_nav_right.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_shadow_e.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_shadow_n.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_shadow_ne.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_shadow_nw.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_shadow_s.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_shadow_se.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_shadow_sw.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_shadow_w.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_title_left.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_title_main.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_title_over.png +0 -0
- data/public/images/admin/plugins/fancybox/fancy_title_right.png +0 -0
- data/public/images/admin/plugins/fancybox/fancybox-x.png +0 -0
- data/public/images/admin/plugins/fancybox/fancybox-y.png +0 -0
- data/public/images/admin/plugins/fancybox/fancybox.png +0 -0
- data/public/images/admin/plugins/toggle_handle-bg.png +0 -0
- data/public/images/admin/plugins/toggle_handle_left-bg.png +0 -0
- data/public/images/admin/plugins/toggle_handle_right-bg.png +0 -0
- data/public/images/admin/plugins/toggle_shadow-bg.png +0 -0
- data/public/images/admin/rails.png +0 -0
- data/public/javascripts/admin/application.js +105 -0
- data/public/javascripts/admin/asset_collections.js +50 -0
- data/public/javascripts/admin/content_types.js +16 -0
- data/public/javascripts/admin/contents.js +17 -0
- data/public/javascripts/admin/custom_fields.js +113 -0
- data/public/javascripts/admin/jquery.js +154 -0
- data/public/javascripts/admin/jquery.ui.js +404 -0
- data/public/javascripts/admin/page_parts.js +83 -0
- data/public/javascripts/admin/pages.js +67 -0
- data/public/javascripts/admin/plugins/codemirror/codemirror.js +469 -0
- data/public/javascripts/admin/plugins/codemirror/editor.js +1465 -0
- data/public/javascripts/admin/plugins/codemirror/highlight.js +68 -0
- data/public/javascripts/admin/plugins/codemirror/mirrorframe.js +81 -0
- data/public/javascripts/admin/plugins/codemirror/parsecss.js +155 -0
- data/public/javascripts/admin/plugins/codemirror/parsedummy.js +32 -0
- data/public/javascripts/admin/plugins/codemirror/parsehtmlmixed.js +74 -0
- data/public/javascripts/admin/plugins/codemirror/parsejavascript.js +352 -0
- data/public/javascripts/admin/plugins/codemirror/parseliquid.js +409 -0
- data/public/javascripts/admin/plugins/codemirror/parsesparql.js +162 -0
- data/public/javascripts/admin/plugins/codemirror/parsexml.js +286 -0
- data/public/javascripts/admin/plugins/codemirror/select.js +619 -0
- data/public/javascripts/admin/plugins/codemirror/stringstream.js +140 -0
- data/public/javascripts/admin/plugins/codemirror/tokenize.js +57 -0
- data/public/javascripts/admin/plugins/codemirror/tokenizejavascript.js +174 -0
- data/public/javascripts/admin/plugins/codemirror/undo.js +410 -0
- data/public/javascripts/admin/plugins/codemirror/util.js +130 -0
- data/public/javascripts/admin/plugins/cookie.js +96 -0
- data/public/javascripts/admin/plugins/fancybox.js +1077 -0
- data/public/javascripts/admin/plugins/growl.js +143 -0
- data/public/javascripts/admin/plugins/json2.js +478 -0
- data/public/javascripts/admin/plugins/plupload/gears_init.js +86 -0
- data/public/javascripts/admin/plugins/plupload/jquery.plupload.queue.min.js +1 -0
- data/public/javascripts/admin/plugins/plupload/plupload.browserplus.min.js +1 -0
- data/public/javascripts/admin/plugins/plupload/plupload.flash.min.js +1 -0
- data/public/javascripts/admin/plugins/plupload/plupload.flash.swf +0 -0
- data/public/javascripts/admin/plugins/plupload/plupload.full.js +1 -0
- data/public/javascripts/admin/plugins/plupload/plupload.gears.min.js +1 -0
- data/public/javascripts/admin/plugins/plupload/plupload.html4.min.js +1 -0
- data/public/javascripts/admin/plugins/plupload/plupload.html5.min.js +1 -0
- data/public/javascripts/admin/plugins/plupload/plupload.js +1 -0
- data/public/javascripts/admin/plugins/plupload/plupload.silverlight.min.js +1 -0
- data/public/javascripts/admin/plugins/plupload/plupload.silverlight.xap +0 -0
- data/public/javascripts/admin/plugins/scrollTo.js +11 -0
- data/public/javascripts/admin/plugins/toggle.js +109 -0
- data/public/javascripts/admin/plugins/wslide.js +125 -0
- data/public/javascripts/admin/rails.js +127 -0
- data/public/javascripts/admin/site.js +36 -0
- data/public/javascripts/admin/snippets.js +16 -0
- data/public/javascripts/admin/theme_assets.js +103 -0
- data/public/stylesheets/admin/application.css +257 -0
- data/public/stylesheets/admin/blueprint/ie.css +26 -0
- data/public/stylesheets/admin/blueprint/plugins/buttons/icons/cross.png +0 -0
- data/public/stylesheets/admin/blueprint/plugins/buttons/icons/key.png +0 -0
- data/public/stylesheets/admin/blueprint/plugins/buttons/icons/tick.png +0 -0
- data/public/stylesheets/admin/blueprint/plugins/buttons/readme.txt +32 -0
- data/public/stylesheets/admin/blueprint/plugins/buttons/screen.css +97 -0
- data/public/stylesheets/admin/blueprint/plugins/fancy-type/readme.txt +14 -0
- data/public/stylesheets/admin/blueprint/plugins/fancy-type/screen.css +71 -0
- data/public/stylesheets/admin/blueprint/plugins/link-icons/icons/doc.png +0 -0
- data/public/stylesheets/admin/blueprint/plugins/link-icons/icons/email.png +0 -0
- data/public/stylesheets/admin/blueprint/plugins/link-icons/icons/external.png +0 -0
- data/public/stylesheets/admin/blueprint/plugins/link-icons/icons/feed.png +0 -0
- data/public/stylesheets/admin/blueprint/plugins/link-icons/icons/im.png +0 -0
- data/public/stylesheets/admin/blueprint/plugins/link-icons/icons/pdf.png +0 -0
- data/public/stylesheets/admin/blueprint/plugins/link-icons/icons/visited.png +0 -0
- data/public/stylesheets/admin/blueprint/plugins/link-icons/icons/xls.png +0 -0
- data/public/stylesheets/admin/blueprint/plugins/link-icons/readme.txt +18 -0
- data/public/stylesheets/admin/blueprint/plugins/link-icons/screen.css +40 -0
- data/public/stylesheets/admin/blueprint/plugins/rtl/readme.txt +10 -0
- data/public/stylesheets/admin/blueprint/plugins/rtl/screen.css +109 -0
- data/public/stylesheets/admin/blueprint/print.css +30 -0
- data/public/stylesheets/admin/blueprint/screen.css +253 -0
- data/public/stylesheets/admin/blueprint/src/forms.css +49 -0
- data/public/stylesheets/admin/blueprint/src/grid.css +213 -0
- data/public/stylesheets/admin/blueprint/src/grid.png +0 -0
- data/public/stylesheets/admin/blueprint/src/ie.css +59 -0
- data/public/stylesheets/admin/blueprint/src/print.css +85 -0
- data/public/stylesheets/admin/blueprint/src/reset.css +38 -0
- data/public/stylesheets/admin/blueprint/src/typography.css +105 -0
- data/public/stylesheets/admin/box.css +14 -0
- data/public/stylesheets/admin/buttons.css +67 -0
- data/public/stylesheets/admin/formtastic.css +137 -0
- data/public/stylesheets/admin/formtastic_changes.css +461 -0
- data/public/stylesheets/admin/layout.css +175 -0
- data/public/stylesheets/admin/login.css +141 -0
- data/public/stylesheets/admin/menu.css +241 -0
- data/public/stylesheets/admin/page_parts.css +60 -0
- data/public/stylesheets/admin/plugins/codemirror/csscolors.css +51 -0
- data/public/stylesheets/admin/plugins/codemirror/docs.css +50 -0
- data/public/stylesheets/admin/plugins/codemirror/javascriptcolors.css +56 -0
- data/public/stylesheets/admin/plugins/codemirror/jscolors.css +59 -0
- data/public/stylesheets/admin/plugins/codemirror/liquidcolors.css +35 -0
- data/public/stylesheets/admin/plugins/codemirror/people.jpg +0 -0
- data/public/stylesheets/admin/plugins/codemirror/sparqlcolors.css +43 -0
- data/public/stylesheets/admin/plugins/codemirror/xmlcolors.css +55 -0
- data/public/stylesheets/admin/plugins/fancybox.css +363 -0
- data/public/stylesheets/admin/plugins/toggle.css +42 -0
- data/spec/factories.rb +77 -0
- data/spec/lib/locomotive/liquid/filters/html_spec.rb +82 -0
- data/spec/lib/locomotive/liquid/filters/misc_spec.rb +36 -0
- data/spec/lib/locomotive/liquid/tags/paginate_spec.rb +99 -0
- data/spec/lib/locomotive/liquid/tags/snippet_spec.rb +20 -0
- data/spec/lib/locomotive/liquid/tags/with_scope_spec.rb +20 -0
- data/spec/lib/locomotive/render_spec.rb +85 -0
- data/spec/models/account_spec.rb +65 -0
- data/spec/models/asset_collections_spec.rb +174 -0
- data/spec/models/content_instance_spec.rb +33 -0
- data/spec/models/content_type_spec.rb +49 -0
- data/spec/models/layout_spec.rb +64 -0
- data/spec/models/liquid_template_spec.rb +19 -0
- data/spec/models/membership_spec.rb +55 -0
- data/spec/models/page_spec.rb +329 -0
- data/spec/models/site_spec.rb +143 -0
- data/spec/models/snippet_spec.rb +9 -0
- data/spec/models/theme_asset_spec.rb +89 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/be_valid.rb +31 -0
- data/spec/support/carrierwave.rb +32 -0
- data/spec/support/locomotive.rb +41 -0
- data/vendor/plugins/custom_fields/MIT-LICENSE +20 -0
- data/vendor/plugins/custom_fields/README +13 -0
- data/vendor/plugins/custom_fields/Rakefile +23 -0
- data/vendor/plugins/custom_fields/init.rb +2 -0
- data/vendor/plugins/custom_fields/install.rb +1 -0
- data/vendor/plugins/custom_fields/lib/custom_fields.rb +14 -0
- data/vendor/plugins/custom_fields/lib/custom_fields/custom_field.rb +84 -0
- data/vendor/plugins/custom_fields/lib/custom_fields/custom_fields_for.rb +49 -0
- data/vendor/plugins/custom_fields/lib/custom_fields/extensions/mongoid/associations/embeds_many.rb +24 -0
- data/vendor/plugins/custom_fields/lib/custom_fields/extensions/mongoid/document.rb +35 -0
- data/vendor/plugins/custom_fields/uninstall.rb +1 -0
- metadata +848 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
// Minimal framing needed to use CodeMirror-style parsers to highlight
|
2
|
+
// code. Load this along with tokenize.js, stringstream.js, and your
|
3
|
+
// parser. Then call highlightText, passing a string as the first
|
4
|
+
// argument, and as the second argument either a callback function
|
5
|
+
// that will be called with an array of SPAN nodes for every line in
|
6
|
+
// the code, or a DOM node to which to append these spans, and
|
7
|
+
// optionally (not needed if you only loaded one parser) a parser
|
8
|
+
// object.
|
9
|
+
|
10
|
+
// Stuff from util.js that the parsers are using.
|
11
|
+
var StopIteration = {toString: function() {return "StopIteration"}};
|
12
|
+
|
13
|
+
var Editor = {};
|
14
|
+
var indentUnit = 2;
|
15
|
+
|
16
|
+
(function(){
|
17
|
+
function normaliseString(string) {
|
18
|
+
var tab = "";
|
19
|
+
for (var i = 0; i < indentUnit; i++) tab += " ";
|
20
|
+
|
21
|
+
string = string.replace(/\t/g, tab).replace(/\u00a0/g, " ").replace(/\r\n?/g, "\n");
|
22
|
+
var pos = 0, parts = [], lines = string.split("\n");
|
23
|
+
for (var line = 0; line < lines.length; line++) {
|
24
|
+
if (line != 0) parts.push("\n");
|
25
|
+
parts.push(lines[line]);
|
26
|
+
}
|
27
|
+
|
28
|
+
return {
|
29
|
+
next: function() {
|
30
|
+
if (pos < parts.length) return parts[pos++];
|
31
|
+
else throw StopIteration;
|
32
|
+
}
|
33
|
+
};
|
34
|
+
}
|
35
|
+
|
36
|
+
window.highlightText = function(string, callback, parser) {
|
37
|
+
parser = (parser || Editor.Parser).make(stringStream(normaliseString(string)));
|
38
|
+
var line = [];
|
39
|
+
if (callback.nodeType == 1) {
|
40
|
+
var node = callback;
|
41
|
+
callback = function(line) {
|
42
|
+
for (var i = 0; i < line.length; i++)
|
43
|
+
node.appendChild(line[i]);
|
44
|
+
node.appendChild(document.createElement("BR"));
|
45
|
+
};
|
46
|
+
}
|
47
|
+
|
48
|
+
try {
|
49
|
+
while (true) {
|
50
|
+
var token = parser.next();
|
51
|
+
if (token.value == "\n") {
|
52
|
+
callback(line);
|
53
|
+
line = [];
|
54
|
+
}
|
55
|
+
else {
|
56
|
+
var span = document.createElement("SPAN");
|
57
|
+
span.className = token.style;
|
58
|
+
span.appendChild(document.createTextNode(token.value));
|
59
|
+
line.push(span);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
catch (e) {
|
64
|
+
if (e != StopIteration) throw e;
|
65
|
+
}
|
66
|
+
if (line.length) callback(line);
|
67
|
+
}
|
68
|
+
})();
|
@@ -0,0 +1,81 @@
|
|
1
|
+
/* Demonstration of embedding CodeMirror in a bigger application. The
|
2
|
+
* interface defined here is a mess of prompts and confirms, and
|
3
|
+
* should probably not be used in a real project.
|
4
|
+
*/
|
5
|
+
|
6
|
+
function MirrorFrame(place, options) {
|
7
|
+
this.home = document.createElement("DIV");
|
8
|
+
if (place.appendChild)
|
9
|
+
place.appendChild(this.home);
|
10
|
+
else
|
11
|
+
place(this.home);
|
12
|
+
|
13
|
+
var self = this;
|
14
|
+
function makeButton(name, action) {
|
15
|
+
var button = document.createElement("INPUT");
|
16
|
+
button.type = "button";
|
17
|
+
button.value = name;
|
18
|
+
self.home.appendChild(button);
|
19
|
+
button.onclick = function(){self[action].call(self);};
|
20
|
+
}
|
21
|
+
|
22
|
+
makeButton("Search", "search");
|
23
|
+
makeButton("Replace", "replace");
|
24
|
+
makeButton("Current line", "line");
|
25
|
+
makeButton("Jump to line", "jump");
|
26
|
+
makeButton("Insert constructor", "macro");
|
27
|
+
makeButton("Indent all", "reindent");
|
28
|
+
|
29
|
+
this.mirror = new CodeMirror(this.home, options);
|
30
|
+
}
|
31
|
+
|
32
|
+
MirrorFrame.prototype = {
|
33
|
+
search: function() {
|
34
|
+
var text = prompt("Enter search term:", "");
|
35
|
+
if (!text) return;
|
36
|
+
|
37
|
+
var first = true;
|
38
|
+
do {
|
39
|
+
var cursor = this.mirror.getSearchCursor(text, first, true);
|
40
|
+
first = false;
|
41
|
+
while (cursor.findNext()) {
|
42
|
+
cursor.select();
|
43
|
+
if (!confirm("Search again?"))
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
} while (confirm("End of document reached. Start over?"));
|
47
|
+
},
|
48
|
+
|
49
|
+
replace: function() {
|
50
|
+
// This is a replace-all, but it is possible to implement a
|
51
|
+
// prompting replace.
|
52
|
+
var from = prompt("Enter search string:", ""), to;
|
53
|
+
if (from) to = prompt("What should it be replaced with?", "");
|
54
|
+
if (to == null) return;
|
55
|
+
|
56
|
+
var cursor = this.mirror.getSearchCursor(from, false);
|
57
|
+
while (cursor.findNext())
|
58
|
+
cursor.replace(to);
|
59
|
+
},
|
60
|
+
|
61
|
+
jump: function() {
|
62
|
+
var line = prompt("Jump to line:", "");
|
63
|
+
if (line && !isNaN(Number(line)))
|
64
|
+
this.mirror.jumpToLine(Number(line));
|
65
|
+
},
|
66
|
+
|
67
|
+
line: function() {
|
68
|
+
alert("The cursor is currently at line " + this.mirror.currentLine());
|
69
|
+
this.mirror.focus();
|
70
|
+
},
|
71
|
+
|
72
|
+
macro: function() {
|
73
|
+
var name = prompt("Name your constructor:", "");
|
74
|
+
if (name)
|
75
|
+
this.mirror.replaceSelection("function " + name + "() {\n \n}\n\n" + name + ".prototype = {\n \n};\n");
|
76
|
+
},
|
77
|
+
|
78
|
+
reindent: function() {
|
79
|
+
this.mirror.reindent();
|
80
|
+
}
|
81
|
+
};
|
@@ -0,0 +1,155 @@
|
|
1
|
+
/* Simple parser for CSS */
|
2
|
+
|
3
|
+
var CSSParser = Editor.Parser = (function() {
|
4
|
+
var tokenizeCSS = (function() {
|
5
|
+
function normal(source, setState) {
|
6
|
+
var ch = source.next();
|
7
|
+
if (ch == "@") {
|
8
|
+
source.nextWhileMatches(/\w/);
|
9
|
+
return "css-at";
|
10
|
+
}
|
11
|
+
else if (ch == "/" && source.equals("*")) {
|
12
|
+
setState(inCComment);
|
13
|
+
return null;
|
14
|
+
}
|
15
|
+
else if (ch == "<" && source.equals("!")) {
|
16
|
+
setState(inSGMLComment);
|
17
|
+
return null;
|
18
|
+
}
|
19
|
+
else if (ch == "=") {
|
20
|
+
return "css-compare";
|
21
|
+
}
|
22
|
+
else if (source.equals("=") && (ch == "~" || ch == "|")) {
|
23
|
+
source.next();
|
24
|
+
return "css-compare";
|
25
|
+
}
|
26
|
+
else if (ch == "\"" || ch == "'") {
|
27
|
+
setState(inString(ch));
|
28
|
+
return null;
|
29
|
+
}
|
30
|
+
else if (ch == "#") {
|
31
|
+
source.nextWhileMatches(/\w/);
|
32
|
+
return "css-hash";
|
33
|
+
}
|
34
|
+
else if (ch == "!") {
|
35
|
+
source.nextWhileMatches(/[ \t]/);
|
36
|
+
source.nextWhileMatches(/\w/);
|
37
|
+
return "css-important";
|
38
|
+
}
|
39
|
+
else if (/\d/.test(ch)) {
|
40
|
+
source.nextWhileMatches(/[\w.%]/);
|
41
|
+
return "css-unit";
|
42
|
+
}
|
43
|
+
else if (/[,.+>*\/]/.test(ch)) {
|
44
|
+
return "css-select-op";
|
45
|
+
}
|
46
|
+
else if (/[;{}:\[\]]/.test(ch)) {
|
47
|
+
return "css-punctuation";
|
48
|
+
}
|
49
|
+
else {
|
50
|
+
source.nextWhileMatches(/[\w\\\-_]/);
|
51
|
+
return "css-identifier";
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
function inCComment(source, setState) {
|
56
|
+
var maybeEnd = false;
|
57
|
+
while (!source.endOfLine()) {
|
58
|
+
var ch = source.next();
|
59
|
+
if (maybeEnd && ch == "/") {
|
60
|
+
setState(normal);
|
61
|
+
break;
|
62
|
+
}
|
63
|
+
maybeEnd = (ch == "*");
|
64
|
+
}
|
65
|
+
return "css-comment";
|
66
|
+
}
|
67
|
+
|
68
|
+
function inSGMLComment(source, setState) {
|
69
|
+
var dashes = 0;
|
70
|
+
while (!source.endOfLine()) {
|
71
|
+
var ch = source.next();
|
72
|
+
if (dashes >= 2 && ch == ">") {
|
73
|
+
setState(normal);
|
74
|
+
break;
|
75
|
+
}
|
76
|
+
dashes = (ch == "-") ? dashes + 1 : 0;
|
77
|
+
}
|
78
|
+
return "css-comment";
|
79
|
+
}
|
80
|
+
|
81
|
+
function inString(quote) {
|
82
|
+
return function(source, setState) {
|
83
|
+
var escaped = false;
|
84
|
+
while (!source.endOfLine()) {
|
85
|
+
var ch = source.next();
|
86
|
+
if (ch == quote && !escaped)
|
87
|
+
break;
|
88
|
+
escaped = !escaped && ch == "\\";
|
89
|
+
}
|
90
|
+
if (!escaped)
|
91
|
+
setState(normal);
|
92
|
+
return "css-string";
|
93
|
+
};
|
94
|
+
}
|
95
|
+
|
96
|
+
return function(source, startState) {
|
97
|
+
return tokenizer(source, startState || normal);
|
98
|
+
};
|
99
|
+
})();
|
100
|
+
|
101
|
+
function indentCSS(inBraces, inRule, base) {
|
102
|
+
return function(nextChars) {
|
103
|
+
if (!inBraces || /^\}/.test(nextChars)) return base;
|
104
|
+
else if (inRule) return base + indentUnit * 2;
|
105
|
+
else return base + indentUnit;
|
106
|
+
};
|
107
|
+
}
|
108
|
+
|
109
|
+
// This is a very simplistic parser -- since CSS does not really
|
110
|
+
// nest, it works acceptably well, but some nicer colouroing could
|
111
|
+
// be provided with a more complicated parser.
|
112
|
+
function parseCSS(source, basecolumn) {
|
113
|
+
basecolumn = basecolumn || 0;
|
114
|
+
var tokens = tokenizeCSS(source);
|
115
|
+
var inBraces = false, inRule = false;
|
116
|
+
|
117
|
+
var iter = {
|
118
|
+
next: function() {
|
119
|
+
var token = tokens.next(), style = token.style, content = token.content;
|
120
|
+
|
121
|
+
if (style == "css-identifier" && inRule)
|
122
|
+
token.style = "css-value";
|
123
|
+
if (style == "css-hash")
|
124
|
+
token.style = inRule ? "css-colorcode" : "css-identifier";
|
125
|
+
|
126
|
+
if (content == "\n")
|
127
|
+
token.indentation = indentCSS(inBraces, inRule, basecolumn);
|
128
|
+
|
129
|
+
if (content == "{")
|
130
|
+
inBraces = true;
|
131
|
+
else if (content == "}")
|
132
|
+
inBraces = inRule = false;
|
133
|
+
else if (inBraces && content == ";")
|
134
|
+
inRule = false;
|
135
|
+
else if (inBraces && style != "css-comment" && style != "whitespace")
|
136
|
+
inRule = true;
|
137
|
+
|
138
|
+
return token;
|
139
|
+
},
|
140
|
+
|
141
|
+
copy: function() {
|
142
|
+
var _inBraces = inBraces, _inRule = inRule, _tokenState = tokens.state;
|
143
|
+
return function(source) {
|
144
|
+
tokens = tokenizeCSS(source, _tokenState);
|
145
|
+
inBraces = _inBraces;
|
146
|
+
inRule = _inRule;
|
147
|
+
return iter;
|
148
|
+
};
|
149
|
+
}
|
150
|
+
};
|
151
|
+
return iter;
|
152
|
+
}
|
153
|
+
|
154
|
+
return {make: parseCSS, electricChars: "}"};
|
155
|
+
})();
|
@@ -0,0 +1,32 @@
|
|
1
|
+
var DummyParser = Editor.Parser = (function() {
|
2
|
+
function tokenizeDummy(source) {
|
3
|
+
while (!source.endOfLine()) source.next();
|
4
|
+
return "text";
|
5
|
+
}
|
6
|
+
function parseDummy(source) {
|
7
|
+
function indentTo(n) {return function() {return n;}}
|
8
|
+
source = tokenizer(source, tokenizeDummy);
|
9
|
+
var space = 0;
|
10
|
+
|
11
|
+
var iter = {
|
12
|
+
next: function() {
|
13
|
+
var tok = source.next();
|
14
|
+
if (tok.type == "whitespace") {
|
15
|
+
if (tok.value == "\n") tok.indentation = indentTo(space);
|
16
|
+
else space = tok.value.length;
|
17
|
+
}
|
18
|
+
return tok;
|
19
|
+
},
|
20
|
+
copy: function() {
|
21
|
+
var _space = space;
|
22
|
+
return function(_source) {
|
23
|
+
space = _space;
|
24
|
+
source = tokenizer(_source, tokenizeDummy);
|
25
|
+
return iter;
|
26
|
+
};
|
27
|
+
}
|
28
|
+
};
|
29
|
+
return iter;
|
30
|
+
}
|
31
|
+
return {make: parseDummy};
|
32
|
+
})();
|
@@ -0,0 +1,74 @@
|
|
1
|
+
var HTMLMixedParser = Editor.Parser = (function() {
|
2
|
+
if (!(CSSParser && JSParser && XMLParser))
|
3
|
+
throw new Error("CSS, JS, and XML parsers must be loaded for HTML mixed mode to work.");
|
4
|
+
XMLParser.configure({useHTMLKludges: true});
|
5
|
+
|
6
|
+
function parseMixed(stream) {
|
7
|
+
var htmlParser = XMLParser.make(stream), localParser = null, inTag = false;
|
8
|
+
var iter = {next: top, copy: copy};
|
9
|
+
|
10
|
+
function top() {
|
11
|
+
var token = htmlParser.next();
|
12
|
+
if (token.content == "<")
|
13
|
+
inTag = true;
|
14
|
+
else if (token.style == "xml-tagname" && inTag === true)
|
15
|
+
inTag = token.content.toLowerCase();
|
16
|
+
else if (token.content == ">") {
|
17
|
+
if (inTag == "script")
|
18
|
+
iter.next = local(JSParser, "</script");
|
19
|
+
else if (inTag == "style")
|
20
|
+
iter.next = local(CSSParser, "</style");
|
21
|
+
inTag = false;
|
22
|
+
}
|
23
|
+
return token;
|
24
|
+
}
|
25
|
+
function local(parser, tag) {
|
26
|
+
var baseIndent = htmlParser.indentation();
|
27
|
+
localParser = parser.make(stream, baseIndent + indentUnit);
|
28
|
+
return function() {
|
29
|
+
if (stream.lookAhead(tag, false, false, true)) {
|
30
|
+
localParser = null;
|
31
|
+
iter.next = top;
|
32
|
+
return top();
|
33
|
+
}
|
34
|
+
|
35
|
+
var token = localParser.next();
|
36
|
+
var lt = token.value.lastIndexOf("<"), sz = Math.min(token.value.length - lt, tag.length);
|
37
|
+
if (lt != -1 && token.value.slice(lt, lt + sz).toLowerCase() == tag.slice(0, sz) &&
|
38
|
+
stream.lookAhead(tag.slice(sz), false, false, true)) {
|
39
|
+
stream.push(token.value.slice(lt));
|
40
|
+
token.value = token.value.slice(0, lt);
|
41
|
+
}
|
42
|
+
|
43
|
+
if (token.indentation) {
|
44
|
+
var oldIndent = token.indentation;
|
45
|
+
token.indentation = function(chars) {
|
46
|
+
if (chars == "</")
|
47
|
+
return baseIndent;
|
48
|
+
else
|
49
|
+
return oldIndent(chars);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
return token;
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
57
|
+
function copy() {
|
58
|
+
var _html = htmlParser.copy(), _local = localParser && localParser.copy(),
|
59
|
+
_next = iter.next, _inTag = inTag;
|
60
|
+
return function(_stream) {
|
61
|
+
stream = _stream;
|
62
|
+
htmlParser = _html(_stream);
|
63
|
+
localParser = _local && _local(_stream);
|
64
|
+
iter.next = _next;
|
65
|
+
inTag = _inTag;
|
66
|
+
return iter;
|
67
|
+
};
|
68
|
+
}
|
69
|
+
return iter;
|
70
|
+
}
|
71
|
+
|
72
|
+
return {make: parseMixed, electricChars: "{}/:"};
|
73
|
+
|
74
|
+
})();
|
@@ -0,0 +1,352 @@
|
|
1
|
+
/* Parse function for JavaScript. Makes use of the tokenizer from
|
2
|
+
* tokenizejavascript.js. Note that your parsers do not have to be
|
3
|
+
* this complicated -- if you don't want to recognize local variables,
|
4
|
+
* in many languages it is enough to just look for braces, semicolons,
|
5
|
+
* parentheses, etc, and know when you are inside a string or comment.
|
6
|
+
*
|
7
|
+
* See manual.html for more info about the parser interface.
|
8
|
+
*/
|
9
|
+
|
10
|
+
var JSParser = Editor.Parser = (function() {
|
11
|
+
// Token types that can be considered to be atoms.
|
12
|
+
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true};
|
13
|
+
// Setting that can be used to have JSON data indent properly.
|
14
|
+
var json = false;
|
15
|
+
// Constructor for the lexical context objects.
|
16
|
+
function JSLexical(indented, column, type, align, prev, info) {
|
17
|
+
// indentation at start of this line
|
18
|
+
this.indented = indented;
|
19
|
+
// column at which this scope was opened
|
20
|
+
this.column = column;
|
21
|
+
// type of scope ('vardef', 'stat' (statement), 'form' (special form), '[', '{', or '(')
|
22
|
+
this.type = type;
|
23
|
+
// '[', '{', or '(' blocks that have any text after their opening
|
24
|
+
// character are said to be 'aligned' -- any lines below are
|
25
|
+
// indented all the way to the opening character.
|
26
|
+
if (align != null)
|
27
|
+
this.align = align;
|
28
|
+
// Parent scope, if any.
|
29
|
+
this.prev = prev;
|
30
|
+
this.info = info;
|
31
|
+
}
|
32
|
+
|
33
|
+
// My favourite JavaScript indentation rules.
|
34
|
+
function indentJS(lexical) {
|
35
|
+
return function(firstChars) {
|
36
|
+
var firstChar = firstChars && firstChars.charAt(0), type = lexical.type;
|
37
|
+
var closing = firstChar == type;
|
38
|
+
if (type == "vardef")
|
39
|
+
return lexical.indented + 4;
|
40
|
+
else if (type == "form" && firstChar == "{")
|
41
|
+
return lexical.indented;
|
42
|
+
else if (type == "stat" || type == "form")
|
43
|
+
return lexical.indented + indentUnit;
|
44
|
+
else if (lexical.info == "switch" && !closing)
|
45
|
+
return lexical.indented + (/^(?:case|default)\b/.test(firstChars) ? indentUnit : 2 * indentUnit);
|
46
|
+
else if (lexical.align)
|
47
|
+
return lexical.column - (closing ? 1 : 0);
|
48
|
+
else
|
49
|
+
return lexical.indented + (closing ? 0 : indentUnit);
|
50
|
+
};
|
51
|
+
}
|
52
|
+
|
53
|
+
// The parser-iterator-producing function itself.
|
54
|
+
function parseJS(input, basecolumn) {
|
55
|
+
// Wrap the input in a token stream
|
56
|
+
var tokens = tokenizeJavaScript(input);
|
57
|
+
// The parser state. cc is a stack of actions that have to be
|
58
|
+
// performed to finish the current statement. For example we might
|
59
|
+
// know that we still need to find a closing parenthesis and a
|
60
|
+
// semicolon. Actions at the end of the stack go first. It is
|
61
|
+
// initialized with an infinitely looping action that consumes
|
62
|
+
// whole statements.
|
63
|
+
var cc = [json ? singleExpr : statements];
|
64
|
+
// Context contains information about the current local scope, the
|
65
|
+
// variables defined in that, and the scopes above it.
|
66
|
+
var context = null;
|
67
|
+
// The lexical scope, used mostly for indentation.
|
68
|
+
var lexical = new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false);
|
69
|
+
// Current column, and the indentation at the start of the current
|
70
|
+
// line. Used to create lexical scope objects.
|
71
|
+
var column = 0;
|
72
|
+
var indented = 0;
|
73
|
+
// Variables which are used by the mark, cont, and pass functions
|
74
|
+
// below to communicate with the driver loop in the 'next'
|
75
|
+
// function.
|
76
|
+
var consume, marked;
|
77
|
+
|
78
|
+
// The iterator object.
|
79
|
+
var parser = {next: next, copy: copy};
|
80
|
+
|
81
|
+
function next(){
|
82
|
+
// Start by performing any 'lexical' actions (adjusting the
|
83
|
+
// lexical variable), or the operations below will be working
|
84
|
+
// with the wrong lexical state.
|
85
|
+
while(cc[cc.length - 1].lex)
|
86
|
+
cc.pop()();
|
87
|
+
|
88
|
+
// Fetch a token.
|
89
|
+
var token = tokens.next();
|
90
|
+
|
91
|
+
// Adjust column and indented.
|
92
|
+
if (token.type == "whitespace" && column == 0)
|
93
|
+
indented = token.value.length;
|
94
|
+
column += token.value.length;
|
95
|
+
if (token.content == "\n"){
|
96
|
+
indented = column = 0;
|
97
|
+
// If the lexical scope's align property is still undefined at
|
98
|
+
// the end of the line, it is an un-aligned scope.
|
99
|
+
if (!("align" in lexical))
|
100
|
+
lexical.align = false;
|
101
|
+
// Newline tokens get an indentation function associated with
|
102
|
+
// them.
|
103
|
+
token.indentation = indentJS(lexical);
|
104
|
+
}
|
105
|
+
// No more processing for meaningless tokens.
|
106
|
+
if (token.type == "whitespace" || token.type == "comment")
|
107
|
+
return token;
|
108
|
+
// When a meaningful token is found and the lexical scope's
|
109
|
+
// align is undefined, it is an aligned scope.
|
110
|
+
if (!("align" in lexical))
|
111
|
+
lexical.align = true;
|
112
|
+
|
113
|
+
// Execute actions until one 'consumes' the token and we can
|
114
|
+
// return it.
|
115
|
+
while(true) {
|
116
|
+
consume = marked = false;
|
117
|
+
// Take and execute the topmost action.
|
118
|
+
cc.pop()(token.type, token.content);
|
119
|
+
if (consume){
|
120
|
+
// Marked is used to change the style of the current token.
|
121
|
+
if (marked)
|
122
|
+
token.style = marked;
|
123
|
+
// Here we differentiate between local and global variables.
|
124
|
+
else if (token.type == "variable" && inScope(token.content))
|
125
|
+
token.style = "js-localvariable";
|
126
|
+
return token;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
// This makes a copy of the parser state. It stores all the
|
132
|
+
// stateful variables in a closure, and returns a function that
|
133
|
+
// will restore them when called with a new input stream. Note
|
134
|
+
// that the cc array has to be copied, because it is contantly
|
135
|
+
// being modified. Lexical objects are not mutated, and context
|
136
|
+
// objects are not mutated in a harmful way, so they can be shared
|
137
|
+
// between runs of the parser.
|
138
|
+
function copy(){
|
139
|
+
var _context = context, _lexical = lexical, _cc = cc.concat([]), _tokenState = tokens.state;
|
140
|
+
|
141
|
+
return function copyParser(input){
|
142
|
+
context = _context;
|
143
|
+
lexical = _lexical;
|
144
|
+
cc = _cc.concat([]); // copies the array
|
145
|
+
column = indented = 0;
|
146
|
+
tokens = tokenizeJavaScript(input, _tokenState);
|
147
|
+
return parser;
|
148
|
+
};
|
149
|
+
}
|
150
|
+
|
151
|
+
// Helper function for pushing a number of actions onto the cc
|
152
|
+
// stack in reverse order.
|
153
|
+
function push(fs){
|
154
|
+
for (var i = fs.length - 1; i >= 0; i--)
|
155
|
+
cc.push(fs[i]);
|
156
|
+
}
|
157
|
+
// cont and pass are used by the action functions to add other
|
158
|
+
// actions to the stack. cont will cause the current token to be
|
159
|
+
// consumed, pass will leave it for the next action.
|
160
|
+
function cont(){
|
161
|
+
push(arguments);
|
162
|
+
consume = true;
|
163
|
+
}
|
164
|
+
function pass(){
|
165
|
+
push(arguments);
|
166
|
+
consume = false;
|
167
|
+
}
|
168
|
+
// Used to change the style of the current token.
|
169
|
+
function mark(style){
|
170
|
+
marked = style;
|
171
|
+
}
|
172
|
+
|
173
|
+
// Push a new scope. Will automatically link the current scope.
|
174
|
+
function pushcontext(){
|
175
|
+
context = {prev: context, vars: {"this": true, "arguments": true}};
|
176
|
+
}
|
177
|
+
// Pop off the current scope.
|
178
|
+
function popcontext(){
|
179
|
+
context = context.prev;
|
180
|
+
}
|
181
|
+
// Register a variable in the current scope.
|
182
|
+
function register(varname){
|
183
|
+
if (context){
|
184
|
+
mark("js-variabledef");
|
185
|
+
context.vars[varname] = true;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
// Check whether a variable is defined in the current scope.
|
189
|
+
function inScope(varname){
|
190
|
+
var cursor = context;
|
191
|
+
while (cursor) {
|
192
|
+
if (cursor.vars[varname])
|
193
|
+
return true;
|
194
|
+
cursor = cursor.prev;
|
195
|
+
}
|
196
|
+
return false;
|
197
|
+
}
|
198
|
+
|
199
|
+
// Push a new lexical context of the given type.
|
200
|
+
function pushlex(type, info) {
|
201
|
+
var result = function(){
|
202
|
+
lexical = new JSLexical(indented, column, type, null, lexical, info)
|
203
|
+
};
|
204
|
+
result.lex = true;
|
205
|
+
return result;
|
206
|
+
}
|
207
|
+
// Pop off the current lexical context.
|
208
|
+
function poplex(){
|
209
|
+
lexical = lexical.prev;
|
210
|
+
}
|
211
|
+
poplex.lex = true;
|
212
|
+
// The 'lex' flag on these actions is used by the 'next' function
|
213
|
+
// to know they can (and have to) be ran before moving on to the
|
214
|
+
// next token.
|
215
|
+
|
216
|
+
// Creates an action that discards tokens until it finds one of
|
217
|
+
// the given type.
|
218
|
+
function expect(wanted){
|
219
|
+
return function expecting(type){
|
220
|
+
if (type == wanted) cont();
|
221
|
+
else cont(arguments.callee);
|
222
|
+
};
|
223
|
+
}
|
224
|
+
|
225
|
+
// Looks for a statement, and then calls itself.
|
226
|
+
function statements(type){
|
227
|
+
return pass(statement, statements);
|
228
|
+
}
|
229
|
+
function singleExpr(type){
|
230
|
+
return pass(expression, statements);
|
231
|
+
}
|
232
|
+
// Dispatches various types of statements based on the type of the
|
233
|
+
// current token.
|
234
|
+
function statement(type){
|
235
|
+
if (type == "var") cont(pushlex("vardef"), vardef1, expect(";"), poplex);
|
236
|
+
else if (type == "keyword a") cont(pushlex("form"), expression, statement, poplex);
|
237
|
+
else if (type == "keyword b") cont(pushlex("form"), statement, poplex);
|
238
|
+
else if (type == "{") cont(pushlex("}"), block, poplex);
|
239
|
+
else if (type == "function") cont(functiondef);
|
240
|
+
else if (type == "for") cont(pushlex("form"), expect("("), pushlex(")"), forspec1, expect(")"), poplex, statement, poplex);
|
241
|
+
else if (type == "variable") cont(pushlex("stat"), maybelabel);
|
242
|
+
else if (type == "switch") cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"), block, poplex, poplex);
|
243
|
+
else if (type == "case") cont(expression, expect(":"));
|
244
|
+
else if (type == "default") cont(expect(":"));
|
245
|
+
else if (type == "catch") cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"), statement, poplex, popcontext);
|
246
|
+
else pass(pushlex("stat"), expression, expect(";"), poplex);
|
247
|
+
}
|
248
|
+
// Dispatch expression types.
|
249
|
+
function expression(type){
|
250
|
+
if (atomicTypes.hasOwnProperty(type)) cont(maybeoperator);
|
251
|
+
else if (type == "function") cont(functiondef);
|
252
|
+
else if (type == "keyword c") cont(expression);
|
253
|
+
else if (type == "(") cont(pushlex(")"), expression, expect(")"), poplex, maybeoperator);
|
254
|
+
else if (type == "operator") cont(expression);
|
255
|
+
else if (type == "[") cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);
|
256
|
+
else if (type == "{") cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
|
257
|
+
}
|
258
|
+
// Called for places where operators, function calls, or
|
259
|
+
// subscripts are valid. Will skip on to the next action if none
|
260
|
+
// is found.
|
261
|
+
function maybeoperator(type){
|
262
|
+
if (type == "operator") cont(expression);
|
263
|
+
else if (type == "(") cont(pushlex(")"), expression, commasep(expression, ")"), poplex, maybeoperator);
|
264
|
+
else if (type == ".") cont(property, maybeoperator);
|
265
|
+
else if (type == "[") cont(pushlex("]"), expression, expect("]"), poplex, maybeoperator);
|
266
|
+
}
|
267
|
+
// When a statement starts with a variable name, it might be a
|
268
|
+
// label. If no colon follows, it's a regular statement.
|
269
|
+
function maybelabel(type){
|
270
|
+
if (type == ":") cont(poplex, statement);
|
271
|
+
else pass(maybeoperator, expect(";"), poplex);
|
272
|
+
}
|
273
|
+
// Property names need to have their style adjusted -- the
|
274
|
+
// tokenizer thinks they are variables.
|
275
|
+
function property(type){
|
276
|
+
if (type == "variable") {mark("js-property"); cont();}
|
277
|
+
}
|
278
|
+
// This parses a property and its value in an object literal.
|
279
|
+
function objprop(type){
|
280
|
+
if (type == "variable") mark("js-property");
|
281
|
+
if (atomicTypes.hasOwnProperty(type)) cont(expect(":"), expression);
|
282
|
+
}
|
283
|
+
// Parses a comma-separated list of the things that are recognized
|
284
|
+
// by the 'what' argument.
|
285
|
+
function commasep(what, end){
|
286
|
+
function proceed(type) {
|
287
|
+
if (type == ",") cont(what, proceed);
|
288
|
+
else if (type == end) cont();
|
289
|
+
else cont(expect(end));
|
290
|
+
}
|
291
|
+
return function commaSeparated(type) {
|
292
|
+
if (type == end) cont();
|
293
|
+
else pass(what, proceed);
|
294
|
+
};
|
295
|
+
}
|
296
|
+
// Look for statements until a closing brace is found.
|
297
|
+
function block(type){
|
298
|
+
if (type == "}") cont();
|
299
|
+
else pass(statement, block);
|
300
|
+
}
|
301
|
+
// Variable definitions are split into two actions -- 1 looks for
|
302
|
+
// a name or the end of the definition, 2 looks for an '=' sign or
|
303
|
+
// a comma.
|
304
|
+
function vardef1(type, value){
|
305
|
+
if (type == "variable"){register(value); cont(vardef2);}
|
306
|
+
else cont();
|
307
|
+
}
|
308
|
+
function vardef2(type, value){
|
309
|
+
if (value == "=") cont(expression, vardef2);
|
310
|
+
else if (type == ",") cont(vardef1);
|
311
|
+
}
|
312
|
+
// For loops.
|
313
|
+
function forspec1(type){
|
314
|
+
if (type == "var") cont(vardef1, forspec2);
|
315
|
+
else if (type == ";") pass(forspec2);
|
316
|
+
else if (type == "variable") cont(formaybein);
|
317
|
+
else pass(forspec2);
|
318
|
+
}
|
319
|
+
function formaybein(type, value){
|
320
|
+
if (value == "in") cont(expression);
|
321
|
+
else cont(maybeoperator, forspec2);
|
322
|
+
}
|
323
|
+
function forspec2(type, value){
|
324
|
+
if (type == ";") cont(forspec3);
|
325
|
+
else if (value == "in") cont(expression);
|
326
|
+
else cont(expression, expect(";"), forspec3);
|
327
|
+
}
|
328
|
+
function forspec3(type) {
|
329
|
+
if (type == ")") pass();
|
330
|
+
else cont(expression);
|
331
|
+
}
|
332
|
+
// A function definition creates a new context, and the variables
|
333
|
+
// in its argument list have to be added to this context.
|
334
|
+
function functiondef(type, value){
|
335
|
+
if (type == "variable"){register(value); cont(functiondef);}
|
336
|
+
else if (type == "(") cont(pushcontext, commasep(funarg, ")"), statement, popcontext);
|
337
|
+
}
|
338
|
+
function funarg(type, value){
|
339
|
+
if (type == "variable"){register(value); cont();}
|
340
|
+
}
|
341
|
+
|
342
|
+
return parser;
|
343
|
+
}
|
344
|
+
|
345
|
+
return {
|
346
|
+
make: parseJS,
|
347
|
+
electricChars: "{}:",
|
348
|
+
configure: function(obj) {
|
349
|
+
if (obj.json != null) json = obj.json;
|
350
|
+
}
|
351
|
+
};
|
352
|
+
})();
|