├── .gitignore ├── LICENSE ├── README.adoc ├── client ├── .bowerrc ├── .editorconfig ├── .ember-cli ├── .gitignore ├── .jshintrc ├── .travis.yml ├── .watchmanconfig ├── README.md ├── app │ ├── app.js │ ├── application │ │ ├── _styles.scss │ │ ├── controller.js │ │ ├── route.js │ │ └── template.hbs │ ├── auth-success │ │ ├── route.js │ │ └── template.hbs │ ├── components │ │ ├── .gitkeep │ │ ├── ace-editor │ │ │ ├── _styles.scss │ │ │ └── component.js │ │ ├── content-modal │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── doc-title-editor │ │ │ ├── _styles.scss │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── font-modal │ │ │ ├── _styles.scss │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── header-status │ │ │ ├── _styles.scss │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── loading-banner │ │ │ ├── _styles.scss │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── pane-layout │ │ │ ├── _styles.scss │ │ │ ├── component.js │ │ │ └── template.hbs │ │ └── theme-modal │ │ │ ├── _styles.scss │ │ │ ├── component.js │ │ │ └── template.hbs │ ├── edit │ │ ├── _styles.scss │ │ ├── controller.js │ │ ├── route.js │ │ └── template.hbs │ ├── helpers │ │ └── .gitkeep │ ├── index.html │ ├── index │ │ ├── controller.js │ │ └── route.js │ ├── loading │ │ └── template.hbs │ ├── locales │ │ └── en │ │ │ └── translations.js │ ├── models │ │ ├── .gitkeep │ │ └── doc.js │ ├── router.js │ ├── services │ │ ├── settings.js │ │ └── storage-providers.js │ ├── styles │ │ ├── _asciidoctor.scss │ │ ├── _bootstrap-vars.scss │ │ └── app.scss │ └── utils │ │ ├── compiler.js │ │ ├── dropbox-storage-provider.js │ │ ├── google-drive-storage-provider.js │ │ ├── modal-mixin.js │ │ ├── scroll-state.js │ │ ├── storage-provider.js │ │ ├── storage-spec.js │ │ └── storage-type.js ├── bower.json ├── config │ └── environment.js ├── ember-cli-build.js ├── package.json ├── public │ ├── assets │ │ ├── about-en.adoc │ │ ├── faq-en.adoc │ │ ├── logo.png │ │ ├── save-white.png │ │ └── scratch.txt │ ├── crossdomain.xml │ ├── favicon.png │ ├── robots.txt │ └── sitemap.xml ├── testem.js ├── testem.json ├── tests │ ├── .jshintrc │ ├── acceptance │ │ ├── application-test.js │ │ └── index-test.js │ ├── helpers │ │ ├── destroy-app.js │ │ ├── module-for-acceptance.js │ │ ├── resolver.js │ │ └── start-app.js │ ├── index.html │ ├── integration │ │ └── .gitkeep │ ├── test-helper.js │ └── unit │ │ └── .gitkeep ├── vendor │ └── .gitkeep └── workers │ └── asciidoctor-js-compile-worker.js ├── misc ├── favicon.png ├── favicon.xcf ├── logo.png └── logo.xcf └── production ├── Dockerfile ├── build.sh ├── nginx-server.conf └── run.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | *.pyc 3 | .sass-cache 4 | *.dart.js* 5 | *.precompiled.js 6 | /build/ 7 | /client/build 8 | /client/packages 9 | /client/pubspec.lock 10 | /client/web/packages 11 | /server/config.py 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | AsciiDocLIVE 2 | ------------ 3 | 4 | AsciiDocLIVE (https://asciidoclive.com[asciidoclive.com]) is a full-featured 5 | online http://www.methods.co.nz/asciidoc/[AsciiDoc] editor. 6 | 7 | Main features: 8 | 9 | - Instant live preview (based on 10 | https://github.com/asciidoctor/asciidoctor.js[asciidoctor.js]); 11 | - Sync with Dropbox and Google Drive; 12 | - Customizable editor (based on https://ace.c9.io/[ACE]), with themes and Vim / 13 | Emacs keybindings; 14 | - Runs in any modern browser; no installation required. 15 | 16 | Try it out at https://asciidoclive.com[asciidoclive.com]! 17 | 18 | 19 | Demo 20 | ~~~~ 21 | 22 | Click for demo: 23 | 24 | https://youtu.be/th_H1gixMEE[image:http://img.youtube.com/vi/th_H1gixMEE/0.jpg["AsciiDocLIVE Demo"]] 25 | 26 | 27 | Running Locally 28 | ~~~~~~~~~~~~~~~ 29 | 30 | AsciiDocLIVE uses the http://ember-cli.com/[Ember CLI] build system. To build: 31 | 32 | [source,bash] 33 | ---- 34 | git clone git@github.com:jichu4n/asciidoclive.git 35 | cd asciidoclive/client 36 | npm install 37 | bower install 38 | 39 | npm install -g ember-cli 40 | # To run local development server on port 8001: 41 | ember serve 42 | ---- 43 | 44 | For Dropbox integration, https://www.dropbox.com/developers/apps/create[create an app] 45 | on Dropbox and copy the generated App Key into the `DROPBOX_APP_KEY` field in 46 | https://github.com/jichu4n/asciidoclive/blob/master/client/config/environment.js[`/client/config/environment.js`], 47 | and set `ENABLE_DROPBOX` to `true`. 48 | 49 | For Google Drive integration, 50 | https://developers.google.com/identity/sign-in/web/devconsole-project[create a new project] 51 | in the Google Developers Console and 52 | https://support.google.com/cloud/answer/6158862?hl=en&ref_topic=6262490[create a Browser API Key and OAuth Client ID]. 53 | Then populate the following fields in 54 | https://github.com/jichu4n/asciidoclive/blob/master/client/config/environment.js[`/client/config/environment.js`] 55 | accordingly: 56 | 57 | * `ENABLE_GOOGLE_DRIVE`: `true` 58 | * `GOOGLE_CLIENT_ID`: The OAuth Client ID (e.g., `12345678-abcdefg.apps.googleusercontent.com`); 59 | * `GOOGLE_APP_ID`: The leading digits of the OAuth Client ID preceding the hyphen (e.g., `12345678`); 60 | * `GOOGLE_API_KEY`: The Browser API Key (e.g., `AbCdEfGh_1IjK`) 61 | 62 | 63 | Deployment 64 | ~~~~~~~~~~ 65 | 66 | To build for production: 67 | 68 | [source,bash] 69 | ---- 70 | cd asciidoclive/client 71 | ember build --environment=production 72 | ---- 73 | 74 | The 75 | https://github.com/jichu4n/asciidoclive/tree/master/production[`/production/`] 76 | directory contains an example Dockerized NGINX server setup for the app. You 77 | can use it as a template to build a Docker container for deployment. 78 | 79 | 80 | License 81 | ~~~~~~~ 82 | 83 | The source code is distributed under the Apache License 2.0. 84 | 85 | 86 | -------------------------------------------------------------------------------- /client/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components", 3 | "analytics": false 4 | } 5 | -------------------------------------------------------------------------------- /client/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.js] 17 | indent_style = space 18 | indent_size = 2 19 | 20 | [*.hbs] 21 | insert_final_newline = false 22 | indent_style = space 23 | indent_size = 2 24 | 25 | [*.css] 26 | indent_style = space 27 | indent_size = 2 28 | 29 | [*.html] 30 | indent_style = space 31 | indent_size = 2 32 | 33 | [*.{diff,md}] 34 | trim_trailing_whitespace = false 35 | -------------------------------------------------------------------------------- /client/.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | "usePods": true, 3 | "disableAnalytics": true, 4 | "watcher": "polling", 5 | "port": 8001, 6 | "liveReloadPort": 8002 7 | } 8 | -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | 7 | # dependencies 8 | /node_modules 9 | /bower_components 10 | 11 | # misc 12 | /.sass-cache 13 | /connect.lock 14 | /coverage/* 15 | /libpeerconnection.log 16 | npm-debug.log 17 | testem.log 18 | -------------------------------------------------------------------------------- /client/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "-Promise" 6 | ], 7 | "browser": true, 8 | "boss": true, 9 | "curly": true, 10 | "debug": false, 11 | "devel": true, 12 | "eqeqeq": true, 13 | "evil": true, 14 | "forin": false, 15 | "immed": false, 16 | "laxbreak": false, 17 | "newcap": true, 18 | "noarg": true, 19 | "noempty": false, 20 | "nonew": false, 21 | "nomen": false, 22 | "onevar": false, 23 | "plusplus": false, 24 | "regexp": false, 25 | "undef": true, 26 | "sub": true, 27 | "strict": false, 28 | "white": false, 29 | "eqnull": true, 30 | "esnext": true, 31 | "unused": true 32 | } 33 | -------------------------------------------------------------------------------- /client/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: node_js 3 | node_js: 4 | - "0.12" 5 | 6 | sudo: false 7 | 8 | cache: 9 | directories: 10 | - node_modules 11 | 12 | before_install: 13 | - export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH 14 | - "npm config set spin false" 15 | - "npm install -g npm@^2" 16 | 17 | install: 18 | - npm install -g bower 19 | - npm install 20 | - bower install 21 | 22 | script: 23 | - npm test 24 | -------------------------------------------------------------------------------- /client/.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /client/README.md: -------------------------------------------------------------------------------- 1 | # Amoya 2 | 3 | This README outlines the details of collaborating on this Ember application. 4 | A short introduction of this app could easily go here. 5 | 6 | ## Prerequisites 7 | 8 | You will need the following things properly installed on your computer. 9 | 10 | * [Git](http://git-scm.com/) 11 | * [Node.js](http://nodejs.org/) (with NPM) 12 | * [Bower](http://bower.io/) 13 | * [Ember CLI](http://www.ember-cli.com/) 14 | * [PhantomJS](http://phantomjs.org/) 15 | 16 | ## Installation 17 | 18 | * `git clone ` this repository 19 | * change into the new directory 20 | * `npm install` 21 | * `bower install` 22 | 23 | ## Running / Development 24 | 25 | * `ember server` 26 | * Visit your app at [http://localhost:4200](http://localhost:4200). 27 | 28 | ### Code Generators 29 | 30 | Make use of the many generators for code, try `ember help generate` for more details 31 | 32 | ### Running Tests 33 | 34 | * `ember test` 35 | * `ember test --server` 36 | 37 | ### Building 38 | 39 | * `ember build` (development) 40 | * `ember build --environment production` (production) 41 | 42 | ### Deploying 43 | 44 | Specify what it takes to deploy your app. 45 | 46 | ## Further Reading / Useful Links 47 | 48 | * [ember.js](http://emberjs.com/) 49 | * [ember-cli](http://www.ember-cli.com/) 50 | * Development Browser Extensions 51 | * [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi) 52 | * [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/) 53 | 54 | -------------------------------------------------------------------------------- /client/app/app.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | import Resolver from 'ember-resolver'; 7 | import loadInitializers from 'ember-load-initializers'; 8 | import config from './config/environment'; 9 | 10 | let App; 11 | 12 | Ember.MODEL_FACTORY_INJECTIONS = true; 13 | 14 | App = Ember.Application.extend({ 15 | modulePrefix: config.modulePrefix, 16 | podModulePrefix: config.podModulePrefix, 17 | Resolver 18 | }); 19 | 20 | loadInitializers(App, config.modulePrefix); 21 | 22 | export default App; 23 | -------------------------------------------------------------------------------- /client/app/application/_styles.scss: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | html, 6 | body { 7 | height: 100%; 8 | } 9 | 10 | .navbar { 11 | border: none; 12 | } 13 | 14 | $navbar-brand-img-height: 14px; 15 | .navbar-brand > img { 16 | height: $navbar-brand-img-height; 17 | margin-top: ( 18 | ($navbar-height - $navbar-brand-img-height) / 2 - 19 | $navbar-padding-vertical); 20 | } 21 | 22 | .navbar-toggle { 23 | color: #fff; 24 | } 25 | 26 | .navbar #header-menu { 27 | 28 | .save-icon { 29 | width: 1em; 30 | height: auto; 31 | vertical-align: -35%; 32 | 33 | @media (min-width: $grid-float-breakpoint) { 34 | margin-left: 0.2em; 35 | } 36 | @media (max-width: $grid-float-breakpoint) { 37 | margin-right: 0.3em; 38 | } 39 | } 40 | 41 | li.dropdown > a { 42 | text-transform: uppercase; 43 | letter-spacing: 1px; 44 | 45 | @media (min-width: $grid-float-breakpoint) { 46 | span.icon-label { 47 | display: none; 48 | } 49 | } 50 | } 51 | li.dropdown-header { 52 | text-transform: uppercase; 53 | letter-spacing: 1.25px; 54 | 55 | @media (max-width: $grid-float-breakpoint) { 56 | color: #fff; 57 | opacity: 0.85; 58 | } 59 | } 60 | 61 | ul.dropdown-menu .fa { 62 | @media (min-width: $grid-float-breakpoint) { 63 | color: $gray; 64 | } 65 | 66 | &.fa-toggle-on { 67 | color: $brand-success; 68 | } 69 | &.fa-toggle-off { 70 | @media (min-width: $grid-float-breakpoint) { 71 | color: $gray; 72 | } 73 | } 74 | } 75 | 76 | ul.dropdown-menu .open-local { 77 | position: relative; 78 | padding: 0; 79 | 80 | & > label { 81 | font-weight: normal; 82 | margin: 0; 83 | padding: 3px 20px; // Same as regular li > a padding 84 | width: 100%; 85 | cursor: pointer; 86 | } 87 | & > input[type="file"] { 88 | position: absolute; 89 | opacity: 0; 90 | z-index: -1; 91 | } 92 | } 93 | } 94 | 95 | #loading-banner { 96 | padding-top: ($navbar-height * 3); 97 | text-align: center; 98 | } 99 | -------------------------------------------------------------------------------- /client/app/application/controller.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | import ENV from '../config/environment'; 7 | 8 | export default Ember.Controller.extend({ 9 | // Injected by route. 10 | headerActionHandler: null, 11 | headerSaveStorageSpec: null, 12 | headerSaveTitle: null, 13 | 14 | storageProviders: Ember.inject.service(), 15 | settings: Ember.inject.service(), 16 | 17 | sendToHeaderActionHandler(action, args) { 18 | var handler = this.get('headerActionHandler'); 19 | if (Ember.isNone(handler)) { 20 | console.warning('No navbar action handler registered!'); 21 | return; 22 | } 23 | handler.send.apply(handler, [action].concat( 24 | Array.prototype.slice.call(args))); 25 | }, 26 | 27 | headerSaveStorageTypeIcon: Ember.computed( 28 | 'headerSaveStorageSpec.storageType', function() { 29 | var storageType = this.get('headerSaveStorageSpec.storageType'); 30 | if (Ember.isNone(storageType)) { 31 | return null; 32 | } 33 | return this.get('storageProviders').getStorageProvider(storageType) 34 | .get('storageTypeIcon'); 35 | }), 36 | 37 | headerSaveStorageTypeTranslation: Ember.computed( 38 | 'headerSaveStorageSpec.storageType', function() { 39 | var storageType = this.get('headerSaveStorageSpec.storageType'); 40 | if (Ember.isNone(storageType)) { 41 | return null; 42 | } 43 | return 'storageTypePrefix.' + storageType; 44 | }), 45 | 46 | recentFiles: Ember.computed( 47 | 'settings.recentFiles.[]', 48 | 'headerSaveStorageSpec.storageType', 49 | 'headerSaveStorageSpec.storagePath', 50 | function() { 51 | var storageProviders = this.get('storageProviders'); 52 | var headerSaveStorageType = this.get('headerSaveStorageSpec.storageType'); 53 | var headerSaveStoragePath = this.get('headerSaveStorageSpec.storagePath'); 54 | return this.get('settings.recentFiles') 55 | .reject(function(recentFile) { 56 | return recentFile.storage_type === headerSaveStorageType && 57 | recentFile.storage_path === headerSaveStoragePath; 58 | }, this) 59 | .map(function(recentFile) { 60 | var storageType = recentFile.storage_type; 61 | return { 62 | storage_type: storageType, 63 | storage_path: recentFile.storage_path, 64 | title: recentFile.title, 65 | 66 | storageTypeIcon: 67 | storageProviders.getStorageProvider(storageType) 68 | .get('storageTypeIcon'), 69 | storageTypeTranslation: 'storageTypePrefix.' + storageType 70 | }; 71 | }, this); 72 | }), 73 | 74 | isFaqModalVisible: false, 75 | isAboutModalVisible: false, 76 | isEditorThemeModalVisible: false, 77 | isHighlightjsThemeModalVisible: false, 78 | isFontModalVisible: false, 79 | isEditorModeModalVisible: false, 80 | 81 | bindLocalFileSelected: Ember.on('init', function() { 82 | Ember.run.scheduleOnce('afterRender', this, function() { 83 | Ember.$('#open-local-file-input').change(function() { 84 | this.sendToHeaderActionHandler('openLocal', arguments); 85 | }.bind(this)); 86 | }); 87 | }), 88 | 89 | ENV: ENV, 90 | 91 | actions: { 92 | open() { 93 | this.sendToHeaderActionHandler('open', arguments); 94 | }, 95 | openRecent() { 96 | this.sendToHeaderActionHandler('openRecent', arguments); 97 | }, 98 | openScratch() { 99 | this.sendToHeaderActionHandler('openScratch', arguments); 100 | }, 101 | save() { 102 | this.sendToHeaderActionHandler('save', arguments); 103 | }, 104 | saveAs() { 105 | this.sendToHeaderActionHandler('saveAs', arguments); 106 | }, 107 | toggleSetting(key) { 108 | this.get('settings').set(key, !this.get('settings.' + key)); 109 | }, 110 | showFaqModal() { 111 | this.set('isFaqModalVisible', true); 112 | }, 113 | showAboutModal() { 114 | this.set('isAboutModalVisible', true); 115 | }, 116 | showEditorThemeModal() { 117 | this.set('isEditorThemeModalVisible', true); 118 | }, 119 | showHighlightjsThemeModal() { 120 | this.set('isHighlightjsThemeModalVisible', true); 121 | }, 122 | showFontModal() { 123 | this.set('isFontModalVisible', true); 124 | }, 125 | showEditorModeModal() { 126 | this.set('isEditorModeModalVisible', true); 127 | }, 128 | saveLocal() { 129 | this.sendToHeaderActionHandler('saveLocal', arguments); 130 | }, 131 | downloadHtml() { 132 | this.sendToHeaderActionHandler('downloadHtml', arguments); 133 | } 134 | } 135 | }); 136 | -------------------------------------------------------------------------------- /client/app/application/route.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | import StorageType from '../utils/storage-type'; 7 | 8 | export default Ember.Route.extend({ 9 | // Force initialization of storageProviders service at page load. The 10 | // StorageProviders service will load 3rd party client libraries when 11 | // initialized. However, since Ember initializes services lazily, this will 12 | // not happen until the first time we try to open / save / etc, which is too 13 | // late. 14 | storageProviders: Ember.inject.service(), 15 | afterModel() { 16 | this.get('storageProviders'); 17 | }, 18 | 19 | actions: { 20 | setHeaderActionHandler(controller) { 21 | this.get('controller').set('headerActionHandler', controller); 22 | }, 23 | setHeaderSaveStorageSpec(storageSpec) { 24 | if (storageSpec.get('storageType') === StorageType.NONE) { 25 | storageSpec = null; 26 | } 27 | this.get('controller').set('headerSaveStorageSpec', storageSpec); 28 | }, 29 | setHeaderSaveTitle(title) { 30 | this.get('controller').set('headerSaveTitle', title); 31 | } 32 | } 33 | }); 34 | -------------------------------------------------------------------------------- /client/app/application/template.hbs: -------------------------------------------------------------------------------- 1 | 229 | {{outlet}} 230 | {{content-modal contentKey="faq" 231 | titleTranslation="modal.faq.title" 232 | isVisible=isFaqModalVisible}} 233 | {{content-modal contentKey="about" 234 | titleTranslation="modal.about.title" 235 | isVisible=isAboutModalVisible}} 236 | {{theme-modal themes=settings.EDITOR_THEMES 237 | themeName=settings.editorThemeName 238 | titleTranslation="modal.editorTheme.title" 239 | isVisible=isEditorThemeModalVisible}} 240 | {{theme-modal themes=settings.HIGHLIGHTJS_THEMES 241 | themeName=settings.highlightjsThemeName 242 | titleTranslation="modal.highlightjsTheme.title" 243 | isVisible=isHighlightjsThemeModalVisible}} 244 | {{theme-modal themes=settings.EDITOR_MODES 245 | themeName=settings.editorModeName 246 | titleTranslation="modal.editorMode.title" 247 | isVisible=isEditorModeModalVisible}} 248 | {{font-modal isVisible=isFontModalVisible}} 249 | 250 | -------------------------------------------------------------------------------- /client/app/auth-success/route.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | /* global Cookies */ 6 | 7 | import Ember from 'ember'; 8 | 9 | export default Ember.Route.extend({ 10 | redirect() { 11 | var redirect = this.getRedirect(); 12 | if (Ember.isNone(redirect)) { 13 | console.error('No redirect info found'); 14 | } else { 15 | console.info('Redirect: %o', redirect); 16 | this.transitionTo.apply(this, [redirect.route].concat(redirect.args)); 17 | } 18 | }, 19 | getRedirect() { 20 | // 1. Try cookies. 21 | var redirect = Cookies.getJSON('redirect'); 22 | if (!Ember.isNone(redirect)) { 23 | return redirect; 24 | } 25 | 26 | // 2. Try state hash parameter. 27 | var hashParams = {}; 28 | window.location.hash.substr(1).split('&').forEach(function(segment) { 29 | var pair = segment.split('='); 30 | hashParams[pair[0]] = decodeURIComponent(pair[1]); 31 | }); 32 | if (!Ember.isNone(hashParams.state)) { 33 | redirect = JSON.parse(hashParams.state); 34 | return redirect; 35 | } 36 | } 37 | }); 38 | -------------------------------------------------------------------------------- /client/app/auth-success/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} 2 | -------------------------------------------------------------------------------- /client/app/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jichu4n/asciidoclive/1d7bdf89755f74f639a9df2ecee0eb792a3e1371/client/app/components/.gitkeep -------------------------------------------------------------------------------- /client/app/components/ace-editor/_styles.scss: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | .ember-view.ace-editor { 6 | position: relative; 7 | font-size: $font-size-base; 8 | } 9 | -------------------------------------------------------------------------------- /client/app/components/ace-editor/component.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | /* global ace */ 6 | 7 | import Ember from 'ember'; 8 | import ScrollState from '../../utils/scroll-state'; 9 | 10 | export default Ember.Component.extend({ 11 | // To be injected. 12 | doc: null, 13 | width: null, 14 | height: null, 15 | classNames: ['ace-editor'], 16 | scrollState: null, 17 | 18 | settings: Ember.inject.service(), 19 | 20 | editor: null, 21 | session: null, 22 | debounceState: { 23 | debounceMs: 100, 24 | lastUpdateTs: new Date(), 25 | nextUpdate: null, 26 | }, 27 | 28 | didInsertElement() { 29 | Ember.run.scheduleOnce('afterRender', this, function() { 30 | this.$().css('width', this.get('width') + 'px'); 31 | 32 | this.set('editor', ace.edit(this.$()[0])); 33 | this.set('session', this.get('editor').getSession()); 34 | window.aceEditor = this.get('editor'); 35 | window.aceEditorSession = this.get('session'); 36 | this.get('session').setValue(this.get('doc.body').toString() || ''); 37 | this.get('session').on('change', this.debouncedUpdate.bind(this)); 38 | this.get('session').setMode('ace/mode/asciidoc'); 39 | this.get('session').setUseWrapMode(true); 40 | this.get('editor').setShowPrintMargin(false); 41 | this.get('session').on('change', this.onScroll.bind(this)); 42 | this.get('session').on('changeScrollTop', this.onScroll.bind(this)); 43 | this.onScroll(); 44 | this.onThemeChanged(); 45 | this.onEditorFontChanged(); 46 | this.onEditorFontSizeChanged(); 47 | this.onEditorModeChanged(); 48 | }); 49 | }, 50 | updateSize: Ember.observer('width', 'height', function() { 51 | Ember.run.once(this, function() { 52 | this.$().css('width', this.get('width') + 'px'); 53 | this.$().css('height', this.get('height') + 'px'); 54 | if (Ember.isNone(this.get('editor'))) { 55 | return; 56 | } 57 | this.get('editor').resize(); 58 | this.onScroll(); 59 | }); 60 | }), 61 | onDocBodyChange: Ember.observer('doc.body', function() { 62 | if (Ember.isNone(this.get('editor'))) { 63 | return; 64 | } 65 | var body = (this.get('doc.body').toString() || '').toString(); 66 | if (body !== this.get('session').getValue()) { 67 | this.get('session').setValue(body); 68 | } 69 | }), 70 | debouncedUpdate() { 71 | var debounceState = this.get('debounceState'); 72 | if (!Ember.isNone(debounceState.nextUpdate)) { 73 | return; 74 | } 75 | var now = new Date(); 76 | var timeSinceLastUpdate = now - debounceState.lastUpdateTs; 77 | if (timeSinceLastUpdate > debounceState.debounceMs) { 78 | debounceState.nextUpdate = Ember.run.next(this, this.update); 79 | } else { 80 | debounceState.nextUpdate = Ember.run.later( 81 | this, this.update, debounceState.debounceMs - timeSinceLastUpdate); 82 | } 83 | }, 84 | update() { 85 | var debounceState = this.get('debounceState'); 86 | debounceState.lastUpdateTs = new Date(); 87 | debounceState.nextUpdate = null; 88 | var docBody = this.get('doc.body'); 89 | var newDocBody = this.get('session').getValue(); 90 | if (docBody !== newDocBody) { 91 | this.get('doc').set('body', newDocBody); 92 | } 93 | }, 94 | onScroll() { 95 | var scrollState = this.get('scrollState'); 96 | if (Ember.isNone(scrollState)) { 97 | this.set('scrollState', scrollState = ScrollState.create()); 98 | } 99 | scrollState.set('viewportHeight', this.get('height')); 100 | scrollState.set( 101 | 'contentHeight', 102 | this.get('session').getScreenLength() * 103 | this.get('editor').renderer.lineHeight); 104 | scrollState.set('scrollTop', this.get('session').getScrollTop() || 0); 105 | }, 106 | onScrollTopChanged: Ember.observer('scrollState.scrollTop', function() { 107 | this.get('session').setScrollTop(this.get('scrollState.scrollTop')); 108 | }), 109 | 110 | onThemeChanged: Ember.observer('settings.editorTheme', function() { 111 | if (Ember.isNone(this.get('editor'))) { 112 | return; 113 | } 114 | var theme = this.get('settings.editorTheme'); 115 | this.get('editor').setTheme( 116 | Ember.isNone(theme) ? 117 | undefined : 118 | ('ace/theme/' + theme)); 119 | }), 120 | 121 | onEditorFontChanged: Ember.observer( 122 | 'settings.editorFont', function() { 123 | if (Ember.isNone(this.get('editor'))) { 124 | return; 125 | } 126 | this.get('editor').setOptions({ 127 | fontFamily: this.get('settings.editorFont') 128 | }); 129 | }), 130 | 131 | onEditorFontSizeChanged: Ember.observer( 132 | 'settings.editorFontSize', function() { 133 | if (Ember.isNone(this.get('editor'))) { 134 | return; 135 | } 136 | this.get('editor').setFontSize(this.get('settings.editorFontSize')); 137 | }), 138 | 139 | onEditorModeChanged: Ember.observer( 140 | 'settings.editorMode', function() { 141 | if (Ember.isNone(this.get('editor'))) { 142 | return; 143 | } 144 | this.get('editor').setKeyboardHandler(this.get('settings.editorMode')); 145 | }) 146 | }); 147 | -------------------------------------------------------------------------------- /client/app/components/content-modal/component.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | import ModalMixin from '../../utils/modal-mixin'; 7 | 8 | export default Ember.Component.extend(ModalMixin, { 9 | // To be injected. 10 | contentKey: '', 11 | titleTranslation: null, 12 | 13 | i18n: Ember.inject.service(), 14 | 15 | content: '', 16 | fetchContent: Ember.on('didInsertElement', Ember.observer( 17 | 'i18n.locale', 'contentKey', function() { 18 | if (Ember.isEmpty(this.get('contentKey'))) { 19 | return; 20 | } 21 | this.set('content', ''); 22 | Ember.$.get( 23 | '/assets/' + this.get('contentKey') + '-' + 24 | this.get('i18n.locale') + '.html') 25 | .then(function(fileContent) { 26 | this.set('content', fileContent); 27 | }.bind(this)); 28 | })), 29 | }); 30 | -------------------------------------------------------------------------------- /client/app/components/content-modal/template.hbs: -------------------------------------------------------------------------------- 1 | 25 | -------------------------------------------------------------------------------- /client/app/components/doc-title-editor/_styles.scss: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | .ember-view.doc-title-editor { 6 | display: flex; 7 | flex-direction: row; 8 | padding: 0 15px; 9 | border-bottom: 1px solid $gray-lighter; 10 | 11 | .doc-title-icon, 12 | input.doc-title { 13 | height: ($doc-title-editor-height - 1px); 14 | line-height: ($doc-title-editor-height - 1px); 15 | } 16 | 17 | .doc-title-icon { 18 | color: $input-color-placeholder; 19 | } 20 | 21 | input.doc-title { 22 | flex-grow: 1; 23 | padding: 0 15px; 24 | border: none; 25 | font-family: $font-family-monospace; 26 | font-weight: bold; 27 | font-size: $font-size-h4; 28 | 29 | &:focus { 30 | outline: none; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /client/app/components/doc-title-editor/component.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | 7 | export default Ember.Component.extend({ 8 | // TO be injected. 9 | doc: null, 10 | classNames: ['doc-title-editor'] 11 | }); 12 | -------------------------------------------------------------------------------- /client/app/components/doc-title-editor/template.hbs: -------------------------------------------------------------------------------- 1 | {{fa-icon "file-text-o" size="lg" classNames="doc-title-icon"}} 2 | {{input value=doc.title classNames="doc-title"}} 3 | -------------------------------------------------------------------------------- /client/app/components/font-modal/_styles.scss: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | .ember-view.font-size-modal { 6 | #editor-font, 7 | #preview-font, 8 | .slider-container > .slider { 9 | width: 100%; 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /client/app/components/font-modal/component.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | import ModalMixin from '../../utils/modal-mixin'; 7 | 8 | export default Ember.Component.extend(ModalMixin, { 9 | classNames: ['font-size-modal'], 10 | 11 | settings: Ember.inject.service(), 12 | 13 | editorFontSize: Ember.computed('settings.editorFontSize', { 14 | get() { 15 | return this.get('settings.editorFontSize'); 16 | }, 17 | set(key, value) { 18 | value = parseInt(value); 19 | this.set('settings.editorFontSize', value); 20 | return value; 21 | } 22 | }), 23 | previewFontSize: Ember.computed('settings.previewFontSize', { 24 | get() { 25 | return this.get('settings.previewFontSize'); 26 | }, 27 | set(key, value) { 28 | value = parseInt(value); 29 | this.set('settings.previewFontSize', value); 30 | return value; 31 | } 32 | }), 33 | 34 | setupSlider: Ember.on('didInsertElement', function() { 35 | Ember.run.scheduleOnce('afterRender', this, function() { 36 | this.$('#editor-font-size-slider').bootstrapSlider({ 37 | min: this.get('settings.minFontSize'), 38 | max: this.get('settings.maxFontSize'), 39 | value: this.get('editorFontSize') 40 | }); 41 | this.$('#preview-font-size-slider').bootstrapSlider({ 42 | min: this.get('settings.minFontSize'), 43 | max: this.get('settings.maxFontSize'), 44 | value: this.get('previewFontSize') 45 | }); 46 | }); 47 | }) 48 | }); 49 | -------------------------------------------------------------------------------- /client/app/components/font-modal/template.hbs: -------------------------------------------------------------------------------- 1 | 58 | -------------------------------------------------------------------------------- /client/app/components/header-status/_styles.scss: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | .header-status { 6 | position: fixed; 7 | top: 0; 8 | right: 244px; 9 | line-height: $navbar-height; 10 | z-index: ($zindex-navbar-fixed + 1); 11 | color: #fff; 12 | opacity: 0.9; 13 | transition: opacity 0.4s; 14 | 15 | @media (max-width: $grid-float-breakpoint) { 16 | right: 60px; 17 | line-height: $navbar-height-collapsed; 18 | } 19 | 20 | &.hidden { 21 | display: block !important; 22 | opacity: 0.0; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /client/app/components/header-status/component.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | 7 | export default Ember.Component.extend({ 8 | // To be injected. 9 | show: false, 10 | durationMs: null, 11 | 12 | classNames: ['header-status'], 13 | classNameBindings: ['show::hidden'], 14 | 15 | autoHide: Ember.observer('show', function() { 16 | if (this.get('show') && !Ember.isNone(this.get('durationMs'))) { 17 | Ember.run.later( 18 | this, this.set, 'show', false, this.get('durationMs')); 19 | } 20 | }) 21 | }); 22 | -------------------------------------------------------------------------------- /client/app/components/header-status/template.hbs: -------------------------------------------------------------------------------- 1 | {{yield}} 2 | -------------------------------------------------------------------------------- /client/app/components/loading-banner/_styles.scss: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | .loading-banner { 6 | color: $gray; 7 | } 8 | -------------------------------------------------------------------------------- /client/app/components/loading-banner/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | classNames: ['loading-banner'] 5 | }); 6 | -------------------------------------------------------------------------------- /client/app/components/loading-banner/template.hbs: -------------------------------------------------------------------------------- 1 | {{fa-icon "spinner" spin=true size="2x"}} 2 | -------------------------------------------------------------------------------- /client/app/components/pane-layout/_styles.scss: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | .ember-view.pane-layout { 6 | display: flex; 7 | flex-direction: row; 8 | overflow: hidden; 9 | 10 | .editor-pane{ 11 | flex: 0 0 auto; 12 | width: 50%; 13 | } 14 | .resize-handle { 15 | flex: 0 0 auto; 16 | width: 7px; 17 | background: $gray-lighter; 18 | cursor: col-resize; 19 | } 20 | 21 | .preview-pane, 22 | .html-preview-pane { 23 | flex: 1 1 auto; 24 | width: 50%; 25 | padding: 10px; 26 | } 27 | 28 | .preview-pane { 29 | overflow-y: auto; 30 | word-break: break-word; 31 | 32 | @import 'app/styles/asciidoctor'; 33 | } 34 | 35 | .html-preview-pane { 36 | border: none; 37 | border-radius: 0; 38 | overflow-x: auto; 39 | overflow-y: auto; 40 | margin: 0; 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /client/app/components/pane-layout/component.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | /* global hljs */ 6 | 7 | import Ember from 'ember'; 8 | import ResizeAware from 'ember-resize/mixins/resize-aware'; 9 | import ScrollState from '../../utils/scroll-state'; 10 | 11 | export default Ember.Component.extend(ResizeAware, { 12 | // To be injected. 13 | doc: null, 14 | 15 | classNames: ['pane-layout'], 16 | minPaneWidth: 200, 17 | 18 | editorPaneWidth: null, 19 | editorScrollState: null, 20 | previewScrollState: ScrollState.create(), 21 | isSyncedScroll: false, 22 | editorLastScrollRatio: 0, 23 | previewLastScrollRatio: 0, 24 | 25 | i18n: Ember.inject.service(), 26 | settings: Ember.inject.service(), 27 | 28 | getContainer() { 29 | return this.$(); 30 | }, 31 | getEditorPane() { 32 | return this.$('.editor-pane'); 33 | }, 34 | getPreviewPane() { 35 | if (this.get('settings.showHtml')) { 36 | return this.$('.html-preview-pane'); 37 | } else { 38 | return this.$('.preview-pane'); 39 | } 40 | }, 41 | getResizeHandle() { 42 | return this.$('.resize-handle'); 43 | }, 44 | getMaxPaneWidth() { 45 | return this.getContainer().width() - 46 | this.get('minPaneWidth') - 47 | this.getResizeHandle().width(); 48 | }, 49 | updateEditorPaneSize() { 50 | var editorPane = this.getEditorPane(); 51 | this.set('editorPaneWidth', editorPane.width()); 52 | this.set('editorPaneHeight', editorPane.height()); 53 | }, 54 | 55 | initialized: false, 56 | setupUi: Ember.on('didInsertElement', function() { 57 | Ember.run(this, function() { 58 | Ember.run.scheduleOnce('afterRender', this, function() { 59 | this.getEditorPane().resizable({ 60 | handles: { 61 | e: this.getResizeHandle() 62 | }, 63 | minWidth: this.get('minPaneWidth'), 64 | maxWidth: this.getMaxPaneWidth(), 65 | resize: this.updateEditorPaneSize.bind(this) 66 | }); 67 | this.updateEditorPaneSize(); 68 | this.getPreviewPane().scroll(function() { 69 | Ember.run.once(this, this.updatePreviewScrollState); 70 | }.bind(this)); 71 | this.updatePreviewScrollState(); 72 | this.onPreviewFontChanged(); 73 | this.onPreviewFontSizeChanged(); 74 | this.initialized = true; 75 | }); 76 | }); 77 | }), 78 | debouncedDidResize() { 79 | if (!this.get('initialized')) { 80 | return; 81 | } 82 | var maxPaneWidth = this.getMaxPaneWidth(); 83 | var editorPane = this.getEditorPane(); 84 | editorPane.resizable('option', 'maxWidth', maxPaneWidth); 85 | if (editorPane.width() > maxPaneWidth) { 86 | editorPane.width(maxPaneWidth); 87 | } 88 | this.updateEditorPaneSize(); 89 | this.updatePreviewScrollState(); 90 | }, 91 | 92 | onEditorScroll: Ember.observer('editorScrollState.scrollTop', function() { 93 | if (this.get('settings.syncScroll') && !this.get('isSyncedScroll')) { 94 | this.set('isSyncedScroll', true); 95 | var editorScrollRatioDelta = this.get('editorScrollState.scrollRatio') - 96 | this.get('editorLastScrollRatio'); 97 | this.get('previewScrollState').set( 98 | 'scrollRatio', 99 | this.get('previewScrollState.scrollRatio') + editorScrollRatioDelta); 100 | this.getPreviewPane().scrollTop(this.get('previewScrollState.scrollTop')); 101 | this.set('isSyncedScroll', false); 102 | } 103 | this.set( 104 | 'editorLastScrollRatio', this.get('editorScrollState.scrollRatio')); 105 | }), 106 | onPreviewChanged: Ember.on('didRender', function() { 107 | var scrollState = this.get('previewScrollState'); 108 | var shouldScrollToBottom = 109 | scrollState.get('isAtBottom') && !scrollState.get('isAtTop'); 110 | this.set('isSyncedScroll', true); 111 | if (!this.get('settings.showHtml')) { 112 | this.getPreviewPane().find('pre code').each(function(i, block) { 113 | hljs.highlightBlock(block); 114 | }); 115 | } 116 | this.updatePreviewScrollState(); 117 | if (shouldScrollToBottom) { 118 | scrollState.set('scrollTop', scrollState.get('maxScrollTop')); 119 | this.getPreviewPane().scrollTop(scrollState.get('scrollTop')); 120 | } 121 | this.set('isSyncedScroll', false); 122 | }), 123 | updatePreviewScrollState() { 124 | var scrollState = this.get('previewScrollState'); 125 | var previewPane = this.getPreviewPane(); 126 | scrollState.set('viewportHeight', previewPane.innerHeight()); 127 | scrollState.set('contentHeight', previewPane.prop('scrollHeight')); 128 | scrollState.set('scrollTop', previewPane.scrollTop() || 0); 129 | }, 130 | onPreviewScroll: Ember.observer('previewScrollState.scrollTop', function() { 131 | if (this.get('settings.syncScroll') && !this.get('isSyncedScroll')) { 132 | this.set('isSyncedScroll', true); 133 | var previewScrollRatioDelta = this.get('previewScrollState.scrollRatio') - 134 | this.get('previewLastScrollRatio'); 135 | this.get('editorScrollState').set( 136 | 'scrollRatio', 137 | this.get('editorScrollState.scrollRatio') + previewScrollRatioDelta); 138 | this.set('isSyncedScroll', false); 139 | } 140 | this.set( 141 | 'previewLastScrollRatio', this.get('previewScrollState.scrollRatio')); 142 | }), 143 | 144 | onPreviewFontChanged: Ember.observer( 145 | 'settings.previewFont', function() { 146 | this.getPreviewPane() 147 | .css('font-family', this.get('settings.previewFont')); 148 | }), 149 | 150 | onPreviewFontSizeChanged: Ember.observer( 151 | 'settings.previewFontSize', function() { 152 | var fontSizePercentage = 153 | this.get('settings.previewFontSize') / 154 | this.get('settings.previewFontSizeBase') * 100; 155 | this.getPreviewPane().css('font-size', fontSizePercentage + '%'); 156 | }) 157 | }); 158 | -------------------------------------------------------------------------------- /client/app/components/pane-layout/template.hbs: -------------------------------------------------------------------------------- 1 | 3 | 4 |
5 | {{ace-editor doc=doc width=editorPaneWidth height=editorPaneHeight 6 | scrollState=editorScrollState}} 7 |
8 |
9 | {{#if settings.showHtml}} 10 |
{{{doc.compiledBody}}}
11 | {{else}} 12 |
{{{doc.compiledBody}}}
13 | {{/if}} 14 | -------------------------------------------------------------------------------- /client/app/components/theme-modal/_styles.scss: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | .ember-view.theme-modal { 6 | .theme-list { 7 | max-height: 20em; 8 | overflow-y: auto; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /client/app/components/theme-modal/component.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | import ModalMixin from '../../utils/modal-mixin'; 7 | 8 | export default Ember.Component.extend(ModalMixin, { 9 | // To be injected. 10 | themes: [], 11 | themeName: null, 12 | titleTranslation: null, 13 | 14 | classNames: ['theme-modal'], 15 | 16 | displayedThemes: Ember.computed('themes', 'themeName', function() { 17 | var themeName = this.get('themeName'); 18 | return this.get('themes').map(function(theme) { 19 | return { 20 | name: theme.name, 21 | value: theme.value, 22 | isSelected: theme.name === themeName 23 | }; 24 | }); 25 | }), 26 | 27 | actions: { 28 | setTheme(themeName) { 29 | this.set('themeName', themeName); 30 | console.log('Set theme to: %s', this.get('themeName')); 31 | } 32 | } 33 | }); 34 | -------------------------------------------------------------------------------- /client/app/components/theme-modal/template.hbs: -------------------------------------------------------------------------------- 1 | 33 | -------------------------------------------------------------------------------- /client/app/edit/_styles.scss: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | $doc-title-editor-height: 50px; 6 | 7 | #doc-title-editor { 8 | position: absolute; 9 | top: $navbar-height; 10 | height: $doc-title-editor-height; 11 | left: 0; 12 | right: 0; 13 | } 14 | 15 | #edit-layout { 16 | position: absolute; 17 | top: ($navbar-height + $doc-title-editor-height); 18 | bottom: 0; 19 | left: 0; 20 | right: 0; 21 | 22 | @media (max-width: $grid-float-breakpoint) { 23 | top: $navbar-height-collapsed; 24 | } 25 | } 26 | 27 | /* For tests. */ 28 | #ember-testing #edit-layout { 29 | height: 300px; 30 | } 31 | -------------------------------------------------------------------------------- /client/app/edit/controller.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | import StorageType from '../utils/storage-type'; 7 | 8 | export default Ember.Controller.extend({ 9 | i18n: Ember.inject.service(), 10 | storageProviders: Ember.inject.service(), 11 | settings: Ember.inject.service(), 12 | 13 | isFirstTitleChange: true, 14 | 15 | autoSaveDelayMs: 5 * 1000, 16 | 17 | showSavingStatus: false, 18 | showSavedStatus: false, 19 | showSaveErrorStatus: false, 20 | reopenStorageType: null, 21 | reopenStorageTypeTranslation: null, 22 | 23 | actions: { 24 | open(storageType, markClean) { 25 | console.log('Opening from %o', storageType); 26 | this.get('storageProviders').open(storageType) 27 | .then(function(storageSpec) { 28 | if (markClean) { 29 | this.get('model').markClean(); 30 | } 31 | this.transitionToRoute( 32 | 'edit', 33 | storageSpec.get('storageType'), 34 | storageSpec.get('storagePath')); 35 | }.bind(this), function(error) { 36 | console.error('Open error: %o', error); 37 | }); 38 | }, 39 | openRecent(recentFile) { 40 | console.log('Opening recent file: %o', recentFile); 41 | this.transitionToRoute( 42 | 'edit', 43 | recentFile.storage_type, 44 | recentFile.storage_path); 45 | }, 46 | openScratch() { 47 | this.transitionToRoute( 48 | 'edit', StorageType.NONE, this.get('settings.scratchId') + 1); 49 | }, 50 | save() { 51 | this.set('showSavedStatus', false); 52 | this.set('showSaveErrorStatus', false); 53 | this.set('showSavingStatus', true); 54 | var prevStorageSpec = this.get('model.storageSpec'); 55 | var docJsonBeforeSave = this.get('model.json'); 56 | this.get('storageProviders').save(this.get('model')) 57 | .then(function(storageSpec) { 58 | this.set('showSavingStatus', false); 59 | this.set('showSavedStatus', true); 60 | if (JSON.stringify(this.get('model.json')) === 61 | JSON.stringify(docJsonBeforeSave)) { 62 | this.get('model').markClean(); 63 | } 64 | this.get('settings').set( 65 | 'recentFiles', 66 | this.get('settings.recentFiles') 67 | .reject(function(recentFile) { 68 | return recentFile.storage_type === 69 | prevStorageSpec.get('storageType') && 70 | recentFile.storage_path === 71 | prevStorageSpec.get('storagePath'); 72 | })); 73 | this.get('target').send('updateRecentFiles', this.get('model')); 74 | if (prevStorageSpec.get('storageType') !== 75 | storageSpec.get('storageType') || 76 | prevStorageSpec.get('storagePath') !== 77 | storageSpec.get('storagePath')) { 78 | this.transitionToRoute( 79 | 'edit', 80 | storageSpec.get('storageType'), 81 | storageSpec.get('storagePath')); 82 | } 83 | }.bind(this), function(error) { 84 | console.error('Save error: %o', error); 85 | this.set('showSavingStatus', false); 86 | this.set('showSaveErrorStatus', true); 87 | }.bind(this)); 88 | }, 89 | saveAs(storageType) { 90 | this.set('showSavedStatus', false); 91 | this.set('showSaveErrorStatus', false); 92 | this.set('showSavingStatus', true); 93 | this.get('storageProviders').saveAs(this.get('model'), storageType) 94 | .then(function(storageSpec) { 95 | this.set('showSavingStatus', false); 96 | this.set('showSavedStatus', true); 97 | if (Ember.isNone(storageSpec)) { 98 | this.set('reopenStorageType', storageType); 99 | this.set( 100 | 'reopenStorageTypeTranslation', 101 | this.get('i18n').t('storageType.' + storageType)); 102 | Ember.$('#reopen-dialog').modal('show'); 103 | } else { 104 | this.transitionToRoute( 105 | 'edit', 106 | storageSpec.get('storageType'), 107 | storageSpec.get('storagePath')); 108 | } 109 | }.bind(this), function(error) { 110 | console.error('Save error: %o', error); 111 | this.set('showSavingStatus', false); 112 | this.set('showSaveErrorStatus', true); 113 | }.bind(this)); 114 | }, 115 | reopen(storageType) { 116 | Ember.$('#reopen-dialog').modal('hide'); 117 | this.send('open', storageType.toString(), true); 118 | }, 119 | saveLocal() { 120 | var fileName = this.get('model.fileName'); 121 | var blob = new Blob([this.get('model.body')], { type: 'text/plain' }); 122 | this.downloadBlob(fileName, blob); 123 | }, 124 | downloadHtml() { 125 | var fileName = this.get('model.compiledBodyFileName'); 126 | var compiledBodyForDownload = this.get('model.compiledBodyForDownload'); 127 | var blob = new Blob([compiledBodyForDownload], { type: 'text/html' }); 128 | this.downloadBlob(fileName, blob); 129 | }, 130 | openLocal(ev) { 131 | var fileInput = ev.target; 132 | var file = fileInput.files[0]; 133 | console.info('Opening local file: %o', file); 134 | var reader = new FileReader(); 135 | reader.onload = function(ev) { 136 | this.get('settings').set( 137 | 'localFile', 138 | { 139 | 'name': file.name, 140 | 'content': ev.target.result 141 | }); 142 | Ember.$(fileInput).wrap('
').closest('form').get(0).reset(); 143 | Ember.$(fileInput).unwrap(); 144 | this.send('openScratch'); 145 | }.bind(this); 146 | reader.readAsText(file); 147 | } 148 | }, 149 | 150 | downloadBlob(fileName, blob) { 151 | if (navigator.msSaveOrOpenBlob) { 152 | navigator.msSaveBlob(blob, fileName); 153 | } else { 154 | var e = document.createElement('a'); 155 | e.href = URL.createObjectURL(blob); 156 | e.download = fileName; 157 | document.body.appendChild(e); 158 | e.click(); 159 | document.body.removeChild(e); 160 | } 161 | }, 162 | 163 | onTitleChanged: Ember.observer('model.title', function() { 164 | this.get('target').send('collectTitleTokens', []); 165 | this.get('target').send('setHeaderSaveTitle', this.get('model.title')); 166 | }), 167 | onHasDirtyAttributesChanged: Ember.observer( 168 | 'model.hasDirtyAttributes', function() { 169 | this.get('target').send('collectTitleTokens', []); 170 | }), 171 | 172 | autoSave() { 173 | if (!this.get('settings.autoSave') || 174 | this.get('model.storageSpec.storageType') === StorageType.NONE || 175 | !this.get('model.hasDirtyAttributes')) { 176 | return; 177 | } 178 | if (this.get('showSavingStatus')) { 179 | Ember.run.debounce(this, this.autoSave, this.get('autoSaveDelayMs')); 180 | return; 181 | } 182 | console.info('Starting autosave'); 183 | this.send('save'); 184 | }, 185 | onModelChanged: Ember.observer('model.title', 'model.body', function() { 186 | Ember.run.debounce(this, this.autoSave, this.get('autoSaveDelayMs')); 187 | }) 188 | }); 189 | -------------------------------------------------------------------------------- /client/app/edit/route.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | /* global Cookies */ 6 | 7 | import Ember from 'ember'; 8 | import StorageSpec from '../utils/storage-spec'; 9 | import StorageType from '../utils/storage-type'; 10 | 11 | export default Ember.Route.extend({ 12 | i18n: Ember.inject.service(), 13 | storageProviders: Ember.inject.service(), 14 | settings: Ember.inject.service(), 15 | 16 | model(params) { 17 | if (params.storage_type === StorageType.NONE) { 18 | this.get('settings').set('scratchId', parseInt(params.storage_path)); 19 | var docTitle; 20 | var docContentPromise; 21 | var shouldMarkAsClean; 22 | if (!Ember.isNone(this.get('settings.localFile.name')) && 23 | !Ember.isNone(this.get('settings.localFile.content'))) { 24 | docTitle = this.get('settings.localFile.name'); 25 | console.info('Loading local file "%s"', docTitle); 26 | docContentPromise = Ember.RSVP.Promise.resolve( 27 | this.get('settings.localFile.content')); 28 | this.get('settings').set('localFile', null); 29 | shouldMarkAsClean = false; 30 | } else { 31 | console.info('Loading scratch content'); 32 | docTitle = this.get('i18n').t('defaultTitle'); 33 | docContentPromise = Ember.$.get('/assets/scratch.txt'); 34 | shouldMarkAsClean = true; 35 | } 36 | return docContentPromise.then(function(docContent) { 37 | var doc = this.get('store').createRecord('doc', { 38 | title: docTitle, 39 | body: docContent, 40 | storageSpec: StorageSpec.create({ 41 | storageType: StorageType.NONE, 42 | storagePath: '' 43 | }) 44 | }); 45 | if (shouldMarkAsClean) { 46 | doc.markClean(); 47 | } 48 | return doc; 49 | }.bind(this)); 50 | } else { 51 | Cookies.set('redirect', { 52 | route: this.get('routeName'), 53 | args: [params.storage_type, params.storage_path] 54 | }); 55 | return this.get('storageProviders').load(StorageSpec.create({ 56 | storageType: params.storage_type, 57 | storagePath: decodeURIComponent(params.storage_path) 58 | })); 59 | } 60 | }, 61 | 62 | isConfirmCloseBound: false, 63 | afterModel(model) { 64 | Ember.run(this, function() { 65 | Cookies.remove('redirect'); 66 | 67 | if (!this.get('isConfirmCloseBound')) { 68 | Ember.$(window).bind('beforeunload', this.confirmClose.bind(this)); 69 | this.set('isConfirmCloseBound', true); 70 | } 71 | 72 | // Sending actions is not possible inside afterModel :-/ 73 | Ember.run.next(this, function() { 74 | this.send('setHeaderSaveStorageSpec', model.get('storageSpec')); 75 | this.send('setHeaderSaveTitle', model.get('title')); 76 | this.send('updateRecentFiles', model); 77 | }); 78 | }); 79 | }, 80 | 81 | serialize(model) { 82 | return { 83 | storage_type: model.get('storageSpec.storageType'), 84 | storage_path: model.get('storageSpec.storagePath') 85 | }; 86 | }, 87 | 88 | titleToken(model) { 89 | if (model.get('storageSpec.storageType') === StorageType.NONE && 90 | !model.get('hasDirtyAttributes')) { 91 | return ''; 92 | } 93 | var title = ''; 94 | if (model.get('hasDirtyAttributes')) { 95 | title += '*'; 96 | } 97 | title += model.get('title'); 98 | return title; 99 | }, 100 | title(tokens) { 101 | if (Ember.isEmpty(tokens[0])) { 102 | return this.get('i18n').t('title'); 103 | } 104 | return tokens[0] + this.get('i18n').t('titleSuffix'); 105 | }, 106 | 107 | actions: { 108 | willTransition(transition) { 109 | var message = this.confirmClose(); 110 | if (Ember.isNone(message) || window.confirm(message)) { 111 | this.get('controller.model').markClean(); 112 | return true; 113 | } 114 | transition.abort(); 115 | }, 116 | didTransition() { 117 | this.send('setHeaderActionHandler', this.get('controller')); 118 | }, 119 | updateRecentFiles(model) { 120 | if (model.get('storageSpec.storageType') === StorageType.NONE) { 121 | return; 122 | } 123 | var recentFile = this.serialize(model); 124 | recentFile.title = model.get('title'); 125 | var recentFiles = this.get('settings.recentFiles') 126 | .reject(function(existingRecentFile) { 127 | return existingRecentFile.storage_type === recentFile.storage_type && 128 | existingRecentFile.storage_path === recentFile.storage_path; 129 | }); 130 | console.info('Adding to recent files: %o', recentFile); 131 | recentFiles.unshift(recentFile); 132 | while (recentFiles.length > this.get('settings.maxRecentFiles')) { 133 | recentFiles.pop(); 134 | } 135 | this.get('settings').set('recentFiles', recentFiles); 136 | } 137 | }, 138 | 139 | confirmClose() { 140 | var model = this.get('controller.model'); 141 | if (model.get('hasDirtyAttributes')) { 142 | return this.get('i18n').t('confirmClose', { 143 | title: model.get('title') 144 | }); 145 | } 146 | } 147 | }); 148 | -------------------------------------------------------------------------------- /client/app/edit/template.hbs: -------------------------------------------------------------------------------- 1 | {{doc-title-editor doc=model id="doc-title-editor"}} 2 | {{pane-layout doc=model id="edit-layout"}} 3 | 4 | {{#header-status show=showSavingStatus}} 5 | {{fa-icon "spinner" spin=true}} 6 | {{t "header.saving"}} 7 | {{/header-status}} 8 | {{#header-status show=showSavedStatus durationMs=5000}} 9 | {{fa-icon "check"}} 10 | {{t "header.saved"}} 11 | {{/header-status}} 12 | {{#header-status show=showSaveErrorStatus durationMs=10000}} 13 | {{fa-icon "exclamation-circle"}} 14 | {{t "header.saveError"}} 15 | {{/header-status}} 16 | 17 | 42 | 43 | -------------------------------------------------------------------------------- /client/app/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jichu4n/asciidoclive/1d7bdf89755f74f639a9df2ecee0eb792a3e1371/client/app/helpers/.gitkeep -------------------------------------------------------------------------------- /client/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | AsciiDocLIVE 11 | 12 | {{content-for 'head'}} 13 | 14 | 15 | 16 | 17 | 18 | 31 | 32 | 33 | 34 | {{content-for 'head-footer'}} 35 | 36 | 37 | 38 | {{content-for 'body'}} 39 | 40 | 41 | 42 | 43 | 44 | 45 | {{content-for 'body-footer'}} 46 | 47 | 48 | -------------------------------------------------------------------------------- /client/app/index/controller.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | /* global $ */ 6 | 7 | import Ember from 'ember'; 8 | 9 | export default Ember.Controller.extend({ 10 | resize: Ember.inject.service(), 11 | 12 | resizeMainLayout() { 13 | $('#main-layout').css('top', $('.navbar').outerHeight() + 'px'); 14 | }, 15 | init() { 16 | Ember.run(function() { 17 | this.get('resize').on('didResize', this.resizeMainLayout.bind(this)); 18 | Ember.run.next(this, this.resizeMainLayout); 19 | }); 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /client/app/index/route.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | import StorageType from '../utils/storage-type'; 7 | 8 | export default Ember.Route.extend({ 9 | settings: Ember.inject.service(), 10 | 11 | beforeModel() { 12 | this.transitionTo( 13 | 'edit', StorageType.NONE, this.get('settings.scratchId') + 1); 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /client/app/loading/template.hbs: -------------------------------------------------------------------------------- 1 | {{loading-banner id="loading-banner"}} 2 | -------------------------------------------------------------------------------- /client/app/locales/en/translations.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | export default { 6 | title: 'AsciiDocLIVE', 7 | titleSuffix: ' - AsciiDocLIVE', 8 | header: { 9 | open: 'Open', 10 | openRecentHeader: 'Open recent', 11 | openScratch: 'New Document', 12 | openHeader: 'Open from', 13 | save: 'Save', 14 | saveHeader: 'Save', 15 | saveAsHeader: 'Save as new file', 16 | local: 'Local File', 17 | exportHeader: 'Export As', 18 | exportHtml: 'HTML', 19 | settings: 'Settings', 20 | saving: 'Saving...', 21 | saved: 'Saved', 22 | saveError: 'Could not save document', 23 | help: 'Help', 24 | cheatsheet: 'AsciiDoc Cheatsheet', 25 | faq: 'FAQ', 26 | about: 'About', 27 | feedback: 'Submit Feedback' 28 | }, 29 | defaultTitle: 'Untitled Document', 30 | defaultBody: '', 31 | storageTypePrefix: { 32 | dropbox: '[Dropbox] ', 33 | 'google-drive': '[Google Drive] ' 34 | }, 35 | storageType: { 36 | dropbox: 'Dropbox', 37 | 'google-drive': 'Google Drive' 38 | }, 39 | edit: { 40 | reopen: { 41 | title: 'Open from {{storageType}}', 42 | prompt: 'Would you like to open the newly saved file from ' + 43 | '{{storageType}}?', 44 | ok: 'Open from {{storageType}}', 45 | cancel: 'Cancel' 46 | } 47 | }, 48 | settings: { 49 | syncScroll: 'Sync Scrolling', 50 | autoSave: 'Auto Save', 51 | showHtml: 'Show Output HTML', 52 | editorTheme: 'Editor Theme...', 53 | previewCodeListingTheme: 'Preview Code Listing Theme...', 54 | previewTheme: 'Preview Theme...', 55 | font: 'Fonts & Sizes...', 56 | editorMode: 'Key Bindings...' 57 | }, 58 | confirmClose: 'The document "{{title}}" has not been saved. ' + 59 | 'If you leave this page, all your changes will be lost. ', 60 | modal: { 61 | close: 'Close', 62 | faq: { 63 | title: 'Frequently Asked Questions' 64 | }, 65 | about: { 66 | title: 'About' 67 | }, 68 | editorTheme: { 69 | title: 'Editor Theme' 70 | }, 71 | highlightjsTheme: { 72 | title: 'Preview Code Listing Theme' 73 | }, 74 | font: { 75 | title: 'Fonts & Sizes', 76 | editorFont: 'Editor Font', 77 | editorFontPlaceholder: 'Leave blank to use default', 78 | editorFontSize: 'Editor Font Size', 79 | previewFont: 'Preview Font', 80 | previewFontPlaceholder: 'Leave blank to use default', 81 | previewFontSize: 'Preview Font Size' 82 | }, 83 | editorMode: { 84 | title: 'Editor Key Bindings' 85 | } 86 | } 87 | }; 88 | -------------------------------------------------------------------------------- /client/app/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jichu4n/asciidoclive/1d7bdf89755f74f639a9df2ecee0eb792a3e1371/client/app/models/.gitkeep -------------------------------------------------------------------------------- /client/app/models/doc.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | import DS from 'ember-data'; 7 | import Compiler from '../utils/compiler'; 8 | import StorageSpec from '../utils/storage-spec'; 9 | 10 | export default DS.Model.extend({ 11 | title: DS.attr('string'), 12 | body: DS.attr('string'), 13 | storageSpec: StorageSpec.create(), 14 | 15 | compiledBody: '', 16 | 17 | settings: Ember.inject.service(), 18 | 19 | compiler: null, 20 | init() { 21 | Ember.run(this, function() { 22 | this._super.apply(this, arguments); 23 | console.info('Creating compiler'); 24 | this.set('compiler', Compiler.create({ 25 | doc: this, 26 | settings: this.get('settings') 27 | })); 28 | }); 29 | }, 30 | onBodyOrShowHtmlChanged: Ember.on( 31 | 'init', 32 | Ember.observer('body', 'settings.showHtml', function() { 33 | this.get('compiler').compile(); 34 | })), 35 | fileName: Ember.computed('title', function() { 36 | var title = this.get('title').toString() || ''; 37 | return title.indexOf('.') > -1 ? 38 | title : 39 | title + '.adoc'; 40 | }), 41 | compiledBodyFileName: Ember.computed('title', function() { 42 | var title = this.get('title').toString() || ''; 43 | return title.indexOf('.') > -1 ? 44 | title.substr(0, title.lastIndexOf('.')) + '.html' : 45 | title + '.html'; 46 | }), 47 | markClean() { 48 | // See http://stackoverflow.com/a/32275254. This will likely break with 49 | // newer Ember Data versions. 50 | var internalModel = this.get('_internalModel'); 51 | internalModel.send('willCommit'); 52 | internalModel._attributes = {}; 53 | internalModel.send('didCommit'); 54 | }, 55 | json: Ember.computed('title', 'body', function() { 56 | return { 57 | title: this.get('title'), 58 | body: this.get('body') 59 | }; 60 | }), 61 | compiledBodyForDownload: Ember.computed('body', function() { 62 | return this.get('compiler').compileForDownload(); 63 | }) 64 | }); 65 | -------------------------------------------------------------------------------- /client/app/router.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | import config from './config/environment'; 7 | import googlePageview from './mixins/google-pageview'; 8 | 9 | const Router = Ember.Router.extend(googlePageview, { 10 | location: config.locationType 11 | }); 12 | 13 | Router.map(function() { 14 | this.route('edit', { 15 | path: '/edit/:storage_type/*storage_path' 16 | }); 17 | this.route('authSuccess', { 18 | path: '/auth_success' 19 | }); 20 | 21 | // For testing base application. 22 | this.route('test', { 23 | path: '/_test' 24 | }); 25 | }); 26 | 27 | export default Router; 28 | -------------------------------------------------------------------------------- /client/app/services/settings.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | import { localStorageProxy } from 'ember-local-storage-proxy'; 7 | 8 | export default Ember.Service.extend({ 9 | syncScroll: Ember.computed(localStorageProxy('v1/syncScroll', false)), 10 | editorThemeName: Ember.computed(localStorageProxy( 11 | 'v1/editorThemeName', 'Default')), 12 | highlightjsThemeName: Ember.computed(localStorageProxy( 13 | 'v1/highlightjsThemeName', 'Default')), 14 | editorFont: Ember.computed(localStorageProxy('v1/editorFont', '')), 15 | editorFontSize: Ember.computed(localStorageProxy('v1/editorFontSize', 14)), 16 | previewFont: Ember.computed(localStorageProxy('v1/previewFont', '')), 17 | previewFontSize: Ember.computed(localStorageProxy('v1/previewFontSize', 14)), 18 | editorModeName: Ember.computed(localStorageProxy( 19 | 'v1/editorModeName', 'Default')), 20 | recentFiles: Ember.computed(localStorageProxy('v1/recentFiles', [])), 21 | autoSave: Ember.computed(localStorageProxy('v1/autoSave', false)), 22 | showHtml: Ember.computed(localStorageProxy('v1/showHtml', false)), 23 | 24 | EDITOR_THEMES: [ 25 | { name: 'Default', value: undefined }, 26 | { name: 'Ambiance', value: 'ambiance' }, 27 | { name: 'Chaos', value: 'chaos' }, 28 | { name: 'Chrome', value: 'chrome' }, 29 | { name: 'Clouds', value: 'clouds' }, 30 | { name: 'Clouds Midnight', value: 'clouds_midnight' }, 31 | { name: 'Cobalt', value: 'cobalt' }, 32 | { name: 'Crimson Editor', value: 'crimson_editor' }, 33 | { name: 'Dawn', value: 'dawn' }, 34 | { name: 'Dreamweaver', value: 'dreamweaver' }, 35 | { name: 'Eclipse', value: 'eclipse' }, 36 | { name: 'GitHub', value: 'github' }, 37 | { name: 'Idle Fingers', value: 'idle_fingers' }, 38 | { name: 'Iplastic', value: 'iplastic' }, 39 | { name: 'Katzenmilch', value: 'katzenmilch' }, 40 | { name: 'KR Theme', value: 'kr_theme' }, 41 | { name: 'Kuroir', value: 'kuroir' }, 42 | { name: 'Merbivore', value: 'merbivore' }, 43 | { name: 'Merbivore Soft', value: 'merbivore_soft' }, 44 | { name: 'Mono Industrial', value: 'mono_industrial' }, 45 | { name: 'Monokai', value: 'monokai' }, 46 | { name: 'Pastel on Dark', value: 'pastel_on_dark' }, 47 | { name: 'Solarized Dark', value: 'solarized_dark' }, 48 | { name: 'Solarized Light', value: 'solarized_light' }, 49 | { name: 'SQLServer', value: 'sqlserver' }, 50 | { name: 'Terminal', value: 'terminal' }, 51 | { name: 'Textmate', value: 'textmate' }, 52 | { name: 'Tomorrow', value: 'tomorrow' }, 53 | { name: 'Tomorrow Night', value: 'tomorrow_night' }, 54 | { name: 'Tomorrow Night Blue', value: 'tomorrow_night_blue' }, 55 | { name: 'Tomorrow Night Bright', value: 'tomorrow_night_bright' }, 56 | { name: 'Tomorrow Night Eighties', value: 'tomorrow_night_eighties' }, 57 | { name: 'Twilight', value: 'twilight' }, 58 | { name: 'Vibrant Ink', value: 'vibrant_ink' }, 59 | { name: 'Xcode', value: 'xcode' } 60 | ], 61 | editorTheme: Ember.computed('editorThemeName', function() { 62 | return this.get('EDITOR_THEMES') 63 | .findBy('name', this.get('editorThemeName')).value; 64 | }), 65 | 66 | HIGHLIGHTJS_THEMES: [ 67 | { name: 'Default', value: 'default' }, 68 | { name: 'Agate', value: 'agate' }, 69 | { name: 'Android Studio', value: 'androidstudio' }, 70 | { name: 'Arduino Light', value: 'arduino-light' }, 71 | { name: 'Arta', value: 'arta' }, 72 | { name: 'Ascetic', value: 'ascetic' }, 73 | { name: 'Atelier Cave Dark', value: 'atelier-cave-dark' }, 74 | { name: 'Atelier Cave Light', value: 'atelier-cave-light' }, 75 | { name: 'Atelier Dune Dark', value: 'atelier-dune-dark' }, 76 | { name: 'Atelier Dune Light', value: 'atelier-dune-light' }, 77 | { name: 'Atelier Estuary Dark', value: 'atelier-estuary-dark' }, 78 | { name: 'Atelier Estuary Light', value: 'atelier-estuary-light' }, 79 | { name: 'Atelier Forest Dark', value: 'atelier-forest-dark' }, 80 | { name: 'Atelier Forest Light', value: 'atelier-forest-light' }, 81 | { name: 'Atelier Heath Dark', value: 'atelier-heath-dark' }, 82 | { name: 'Atelier Heath Light', value: 'atelier-heath-light' }, 83 | { name: 'Atelier Lakeside Dark', value: 'atelier-lakeside-dark' }, 84 | { name: 'Atelier Lakeside Light', value: 'atelier-lakeside-light' }, 85 | { name: 'Atelier Plateau Dark', value: 'atelier-plateau-dark' }, 86 | { name: 'Atelier Plateau Light', value: 'atelier-plateau-light' }, 87 | { name: 'Atelier Savanna Dark', value: 'atelier-savanna-dark' }, 88 | { name: 'Atelier Savanna Light', value: 'atelier-savanna-light' }, 89 | { name: 'Atelier Seaside Dark', value: 'atelier-seaside-dark' }, 90 | { name: 'Atelier Seaside Light', value: 'atelier-seaside-light' }, 91 | { name: 'Atelier Sulphurpool Dark', value: 'atelier-sulphurpool-dark' }, 92 | { name: 'Atelier Sulphurpool Light', value: 'atelier-sulphurpool-light' }, 93 | { name: 'Brown Paper', value: 'brown-paper' }, 94 | { name: 'Codepen Embed', value: 'codepen-embed' }, 95 | { name: 'Color Brewer', value: 'color-brewer' }, 96 | { name: 'Dark', value: 'dark' }, 97 | { name: 'Darkula', value: 'darkula' }, 98 | { name: 'Docco', value: 'docco' }, 99 | { name: 'Dracula', value: 'dracula' }, 100 | { name: 'Far', value: 'far' }, 101 | { name: 'Foundation', value: 'foundation' }, 102 | { name: 'Github', value: 'github' }, 103 | { name: 'Github Gist', value: 'github-gist' }, 104 | { name: 'Googlecode', value: 'googlecode' }, 105 | { name: 'Grayscale', value: 'grayscale' }, 106 | { name: 'Gruvbox Dark', value: 'gruvbox-dark' }, 107 | { name: 'Gruvbox Light', value: 'gruvbox-light' }, 108 | { name: 'Hopscotch', value: 'hopscotch' }, 109 | { name: 'Hybrid', value: 'hybrid' }, 110 | { name: 'IDEA', value: 'idea' }, 111 | { name: 'IR Black', value: 'ir-black' }, 112 | { name: 'Magula', value: 'magula' }, 113 | { name: 'Mono Blue', value: 'mono-blue' }, 114 | { name: 'Monokai', value: 'monokai' }, 115 | { name: 'Monokai Sublime', value: 'monokai-sublime' }, 116 | { name: 'Obsidian', value: 'obsidian' }, 117 | { name: 'Paraiso Dark', value: 'paraiso-dark' }, 118 | { name: 'Paraiso Light', value: 'paraiso-light' }, 119 | { name: 'Pojoaque', value: 'pojoaque' }, 120 | { name: 'RailsCasts', value: 'railscasts' }, 121 | { name: 'Rainbow', value: 'rainbow' }, 122 | { name: 'School Book', value: 'school-book' }, 123 | { name: 'Solarized Dark', value: 'solarized-dark' }, 124 | { name: 'Solarized Light', value: 'solarized-light' }, 125 | { name: 'Sunburst', value: 'sunburst' }, 126 | { name: 'Tomorrow', value: 'tomorrow' }, 127 | { name: 'Tomorrow Night Blue', value: 'tomorrow-night-blue' }, 128 | { name: 'Tomorrow Night Bright', value: 'tomorrow-night-bright' }, 129 | { name: 'Tomorrow Night', value: 'tomorrow-night' }, 130 | { name: 'Tomorrow Night Eighties', value: 'tomorrow-night-eighties' }, 131 | { name: 'VS', value: 'vs' }, 132 | { name: 'Xcode', value: 'xcode' }, 133 | { name: 'Zenburn', value: 'zenburn' }, 134 | ], 135 | highlightjsTheme: Ember.computed('highlightjsThemeName', function() { 136 | return this.get('HIGHLIGHTJS_THEMES') 137 | .findBy('name', this.get('highlightjsThemeName')).value; 138 | }), 139 | 140 | EDITOR_MODES: [ 141 | { name: 'Default', value: '' }, 142 | { name: 'Vim', value: 'ace/keyboard/vim' }, 143 | { name: 'Emacs', value: 'ace/keyboard/emacs' } 144 | ], 145 | editorMode: Ember.computed('editorModeName', function() { 146 | return this.get('EDITOR_MODES') 147 | .findBy('name', this.get('editorModeName')).value; 148 | }), 149 | 150 | minFontSize: 8, 151 | maxFontSize: 24, 152 | previewFontSizeBase: 14, 153 | 154 | maxRecentFiles: 5, 155 | 156 | scratchId: 0, 157 | localFile: null 158 | }); 159 | -------------------------------------------------------------------------------- /client/app/services/storage-providers.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | import Ember from 'ember'; 6 | import DS from 'ember-data'; 7 | import ENV from '../config/environment'; 8 | import DropboxStorageProvider from '../utils/dropbox-storage-provider'; 9 | import GoogleDriveStorageProvider from '../utils/google-drive-storage-provider'; 10 | 11 | export default Ember.Service.extend({ 12 | store: Ember.inject.service(), 13 | 14 | storageProviders: {}, 15 | 16 | init() { 17 | this._super.apply(this, arguments); 18 | Ember.run(this, function() { 19 | var storageProviders = []; 20 | if (ENV.APP.ENABLE_DROPBOX) { 21 | storageProviders.push( 22 | DropboxStorageProvider.create({ store: this.get('store') })); 23 | } else { 24 | console.info('Dropbox integration is disabled'); 25 | } 26 | if (ENV.APP.ENABLE_GOOGLE_DRIVE) { 27 | storageProviders.push( 28 | GoogleDriveStorageProvider.create({ store: this.get('store') })); 29 | } else { 30 | console.info('Google Drive integration is disabled'); 31 | } 32 | storageProviders.forEach(function(storageProvider) { 33 | console.info( 34 | 'Registering storage provider "%s"', 35 | storageProvider.get('storageType')); 36 | this.get('storageProviders')[storageProvider.get('storageType')] = 37 | storageProvider; 38 | }, this); 39 | }); 40 | }, 41 | 42 | getStorageProvider(storageTypeOrStorageSpec) { 43 | var storageType = (typeof storageTypeOrStorageSpec === 'string') ? 44 | storageTypeOrStorageSpec : 45 | storageTypeOrStorageSpec.get('storageType'); 46 | var storageProvider = this.get('storageProviders')[storageType] || null; 47 | if (storageProvider === null) { 48 | console.error('Could not find storage provider "%s"', storageType); 49 | } 50 | return storageProvider; 51 | }, 52 | 53 | open(storageType) { 54 | console.info('Opening from storage type: %o', storageType); 55 | var storageProvider = this.getStorageProvider(storageType); 56 | if (Ember.isNone(storageProvider)) { 57 | return Ember.RSVP.reject(); 58 | } 59 | return storageProvider.open(); 60 | }, 61 | 62 | load(storageSpec) { 63 | console.info('Loading from spec: %o', storageSpec); 64 | var storageProvider = this.getStorageProvider(storageSpec); 65 | if (Ember.isNone(storageProvider)) { 66 | return DS.PromiseObject.create({ 67 | promise: Ember.RSVP.reject() 68 | }); 69 | } 70 | return storageProvider.load(storageSpec.get('storagePath')); 71 | }, 72 | 73 | save(doc) { 74 | console.info('Saving doc: %o', doc); 75 | var storageProvider = this.getStorageProvider(doc.get('storageSpec')); 76 | if (Ember.isNone(storageProvider)) { 77 | return Ember.RSVP.reject(); 78 | } 79 | return storageProvider.save(doc); 80 | }, 81 | 82 | saveAs(doc, storageType) { 83 | console.info('Saving doc to storage type "%s": %o', storageType, doc); 84 | var storageProvider = this.getStorageProvider(storageType); 85 | if (Ember.isNone(storageProvider)) { 86 | return Ember.RSVP.reject(); 87 | } 88 | return storageProvider.saveAs(doc); 89 | }, 90 | 91 | rename(doc) { 92 | console.info('Renaming doc: %o', doc); 93 | var storageProvider = this.getStorageProvider(doc.get('storageSpec')); 94 | if (Ember.isNone(storageProvider)) { 95 | return Ember.RSVP.resolve(); 96 | } 97 | return storageProvider.rename(doc); 98 | } 99 | }); 100 | -------------------------------------------------------------------------------- /client/app/styles/_asciidoctor.scss: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | // Scalable typography. 6 | h1, .h1 { font-size: #{$font-size-h1 / $font-size-base}em; } 7 | h2, .h2 { font-size: #{$font-size-h2 / $font-size-base}em; } 8 | h3, .h3 { font-size: #{$font-size-h3 / $font-size-base}em; } 9 | h4, .h4 { font-size: #{$font-size-h4 / $font-size-base}em; } 10 | h5, .h5 { font-size: #{$font-size-h5 / $font-size-base}em; } 11 | h6, .h6 { font-size: #{$font-size-h6 / $font-size-base}em; } 12 | pre { font-size: #{($font-size-base - 1) / $font-size-base}em; } 13 | 14 | // Selected styles copied from asciidoctor.css. 15 | 16 | // Table styles. 17 | table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede} 18 | table thead,table tfoot{background:#f7f8f7;font-weight:bold} 19 | table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left} 20 | table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)} 21 | table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7} 22 | table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6} 23 | table.tableblock{max-width:100%;border-collapse:separate} 24 | table.tableblock td>.paragraph:last-child p>p:last-child,table.tableblock th>p:last-child,table.tableblock td>p:last-child{margin-bottom:0} 25 | table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede} 26 | table.grid-all th.tableblock,table.grid-all td.tableblock{border-width:0 1px 1px 0} 27 | table.grid-all tfoot>tr>th.tableblock,table.grid-all tfoot>tr>td.tableblock{border-width:1px 1px 0 0} 28 | table.grid-cols th.tableblock,table.grid-cols td.tableblock{border-width:0 1px 0 0} 29 | table.grid-all *>tr>.tableblock:last-child,table.grid-cols *>tr>.tableblock:last-child{border-right-width:0} 30 | table.grid-rows th.tableblock,table.grid-rows td.tableblock{border-width:0 0 1px 0} 31 | table.grid-all tbody>tr:last-child>th.tableblock,table.grid-all tbody>tr:last-child>td.tableblock,table.grid-all thead:last-child>tr>th.tableblock,table.grid-rows tbody>tr:last-child>th.tableblock,table.grid-rows tbody>tr:last-child>td.tableblock,table.grid-rows thead:last-child>tr>th.tableblock{border-bottom-width:0} 32 | table.grid-rows tfoot>tr>th.tableblock,table.grid-rows tfoot>tr>td.tableblock{border-width:1px 0 0 0} 33 | table.frame-all{border-width:1px} 34 | table.frame-sides{border-width:0 1px} 35 | table.frame-topbot{border-width:1px 0} 36 | th.halign-left,td.halign-left{text-align:left} 37 | th.halign-right,td.halign-right{text-align:right} 38 | th.halign-center,td.halign-center{text-align:center} 39 | th.valign-top,td.valign-top{vertical-align:top} 40 | th.valign-bottom,td.valign-bottom{vertical-align:bottom} 41 | th.valign-middle,td.valign-middle{vertical-align:middle} 42 | table thead th,table tfoot th{font-weight:bold} 43 | tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7} 44 | tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold} 45 | p.tableblock>code:only-child{background:none;padding:0} 46 | p.tableblock{font-size:1em} 47 | td>div.verse{white-space:pre} 48 | .hdlist>table,.colist>table{border:0;background:none} 49 | .hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none} 50 | td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em} 51 | td.hdlist1{font-weight:bold;padding-bottom:1.25em} 52 | 53 | // Quotes. 54 | blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd} 55 | blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)} 56 | blockquote cite:before{content:"\2014 \0020"} 57 | blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)} 58 | blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)} 59 | .quoteblock{margin:0 1em 1.25em 1.5em;display:table} 60 | .quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em} 61 | .quoteblock blockquote,.quoteblock blockquote p{color:rgba(0,0,0,.85);font-size:inherit;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify} 62 | .quoteblock blockquote{margin:0;padding:0;border:0} 63 | .quoteblock blockquote:before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:rgba(0,0,0,.6);text-shadow:0 1px 2px rgba(0,0,0,.1)} 64 | .quoteblock blockquote>.paragraph:last-child p{margin-bottom:0} 65 | .quoteblock .attribution{margin-top:.5em;margin-right:.5ex;text-align:right} 66 | .quoteblock .quoteblock{margin-left:0;margin-right:0;padding:.5em 0;border-left:3px solid rgba(0,0,0,.6)} 67 | .quoteblock .quoteblock blockquote{padding:0 0 0 .75em} 68 | .quoteblock .quoteblock blockquote:before{display:none} 69 | .quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic} 70 | .quoteblock .attribution br,.verseblock .attribution br{display:none} 71 | .quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)} 72 | .quoteblock.abstract{margin:0 0 1.25em 0;display:block} 73 | .quoteblock.abstract blockquote,.quoteblock.abstract blockquote p{text-align:left;word-spacing:0} 74 | .quoteblock.abstract blockquote:before,.quoteblock.abstract blockquote p:first-of-type:before{display:none} 75 | 76 | // Lists. 77 | ul.unstyled,ol.unnumbered,ul.checklist,ul.none{list-style-type:none} 78 | ul.unstyled,ol.unnumbered,ul.checklist{margin-left:.625em} 79 | ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1em;font-size:.85em} 80 | ul.checklist li>p:first-child>input[type="checkbox"]:first-child{width:1em;position:relative;top:1px} 81 | ul.inline{margin:0 auto .625em auto;margin-left:-1.375em;margin-right:0;padding:0;list-style:none;overflow:hidden} 82 | ul.inline>li{list-style:none;float:left;margin-left:1.375em;display:block} 83 | ul.inline>li>*{display:block} 84 | .unstyled dl dt{font-weight:400;font-style:normal} 85 | ol.arabic{list-style-type:decimal} 86 | ol.decimal{list-style-type:decimal-leading-zero} 87 | ol.loweralpha{list-style-type:lower-alpha} 88 | ol.upperalpha{list-style-type:upper-alpha} 89 | ol.lowerroman{list-style-type:lower-roman} 90 | ol.upperroman{list-style-type:upper-roman} 91 | ol.lowergreek{list-style-type:lower-greek} 92 | -------------------------------------------------------------------------------- /client/app/styles/_bootstrap-vars.scss: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | $navbar-border-radius: 0; 6 | $navbar-inverse-bg: #444; 7 | $navbar-inverse-toggle-border-color: transparent; 8 | $navbar-inverse-toggle-hover-bg: transparent; 9 | $navbar-inverse-link-disabled-color: #fff; 10 | $navbar-inverse-border: transparent; 11 | $navbar-inverse-color: #fdfdfd; 12 | $navbar-inverse-link-color: #fdfdfd; 13 | 14 | $navbar-height-collapsed: 54px; 15 | 16 | $icon-font-path: '../fonts/'; 17 | -------------------------------------------------------------------------------- /client/app/styles/app.scss: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | @import 'app/styles/bootstrap-vars'; 6 | @import 'bower_components/bootstrap-sass/assets/stylesheets/bootstrap'; 7 | 8 | @import "bower_components/font-awesome/scss/font-awesome"; 9 | 10 | @import 'app/application/styles'; 11 | @import 'app/edit/styles'; 12 | 13 | @import 'app/components/doc-title-editor/styles'; 14 | @import 'app/components/pane-layout/styles'; 15 | @import 'app/components/ace-editor/styles'; 16 | @import 'app/components/loading-banner/styles'; 17 | @import 'app/components/header-status/styles'; 18 | @import 'app/components/theme-modal/styles'; 19 | @import 'app/components/font-modal/styles'; 20 | 21 | -------------------------------------------------------------------------------- /client/app/utils/compiler.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | /* global asciidoctorJsCompile */ 6 | 7 | import Ember from 'ember'; 8 | import ENV from '../config/environment'; 9 | 10 | export default Ember.Object.extend({ 11 | // To be injected. 12 | doc: null, 13 | settings: null, 14 | 15 | compileWorker: null, 16 | compileCount: 0, 17 | runningCompileRequest: null, 18 | pendingCompileRequest: null, 19 | 20 | beautifyOptions: { 21 | 'indent_size': 2, 22 | 'wrap_line_length': 80 23 | }, 24 | 25 | init() { 26 | Ember.run(this, function() { 27 | if (ENV.APP.ENABLE_WEB_WORKER && window.Worker) { 28 | this.set('compileWorker', new Worker( 29 | '/assets/workers/asciidoctor-js-compile-worker.js')); 30 | this.get('compileWorker').addEventListener( 31 | 'message', this.onCompileDone.bind(this)); 32 | } else { 33 | console.log( 34 | 'Web Workers are unsupported or disabled, ' + 35 | 'will compile in main thread.'); 36 | } 37 | }); 38 | }, 39 | useWebWorker: Ember.computed('compileWorker', function() { 40 | return !Ember.isNone(this.get('compileWorker')); 41 | }), 42 | 43 | compile: function() { 44 | if (Ember.isNone(this.get('doc')) || Ember.isNone(this.get('doc.body'))) { 45 | return; 46 | } 47 | this.set('compileCount', this.get('compileCount') + 1); 48 | var body = this.get('doc.body').toString() || ''; 49 | var request = { 50 | body: body, 51 | inline: true, 52 | compileCount: this.get('compileCount'), 53 | beautify: this.get('settings.showHtml'), 54 | beautifyOptions: this.get('beautifyOptions'), 55 | highlight: this.get('settings.showHtml'), 56 | serverUrl: ENV.APP.SERVER_URL, 57 | startTs: new Date() 58 | }; 59 | if (this.get('useWebWorker')) { 60 | if (Ember.isNone(this.get('runningCompileRequest'))) { 61 | console.info('[%d] Compiling immediately', this.get('compileCount')); 62 | this.set('runningCompileRequest', request); 63 | this.get('compileWorker').postMessage(request); 64 | } else { 65 | if (!Ember.isNone(this.get('pendingCompileRequest'))) { 66 | console.info( 67 | '[%d] Discarding previously scheduled compiled run', 68 | this.get('pendingCompileRequest.compileCount')); 69 | } 70 | console.info('[%d] Scheduling compile run', this.get('compileCount')); 71 | this.set('pendingCompileRequest', request); 72 | } 73 | } else { 74 | Ember.run.next(this, this.compileInMainThread, request); 75 | } 76 | }, 77 | compileInMainThread(request) { 78 | var response = asciidoctorJsCompile({ data: request }); 79 | this.onCompileDone({ data: response }); 80 | }, 81 | onCompileDone(ev) { 82 | var endTs = new Date(); 83 | console.info( 84 | '[%d] [%d] Compiled in %dms', 85 | ev.data.compileCount, 86 | endTs.valueOf(), 87 | endTs - (new Date(ev.data.startTs))); 88 | if (this.get('useWebWorker')) { 89 | var pendingRequest = this.get('pendingCompileRequest'); 90 | if (Ember.isNone(pendingRequest)) { 91 | this.set('runningCompileRequest', null); 92 | } else { 93 | console.info( 94 | '[%d] Running previously scheduled compile', 95 | pendingRequest.compileCount); 96 | this.set('runningCompileRequest', pendingRequest); 97 | this.set('pendingCompileRequest', null); 98 | this.get('compileWorker').postMessage(pendingRequest); 99 | } 100 | } 101 | Ember.run(this, function() { 102 | this.get('doc').set('compiledBody', ev.data.compiledBody); 103 | }); 104 | }, 105 | 106 | compileForDownload: function() { 107 | if (Ember.isNone(this.get('doc')) || Ember.isNone(this.get('doc.body'))) { 108 | return ''; 109 | } 110 | var body = this.get('doc.body').toString() || ''; 111 | var request = { 112 | body: body, 113 | inline: false, 114 | beautify: true, 115 | beautifyOptions: this.get('beautifyOptions'), 116 | highlight: false, 117 | serverUrl: ENV.APP.SERVER_URL 118 | }; 119 | return asciidoctorJsCompile({ data: request }).compiledBody; 120 | } 121 | }); 122 | -------------------------------------------------------------------------------- /client/app/utils/dropbox-storage-provider.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | /* global Dropbox, Base64 */ 6 | 7 | import Ember from 'ember'; 8 | import DS from 'ember-data'; 9 | import ENV from '../config/environment'; 10 | import StorageProvider from '../utils/storage-provider'; 11 | import StorageSpec from '../utils/storage-spec'; 12 | import StorageType from '../utils/storage-type'; 13 | 14 | export default StorageProvider.extend({ 15 | storageType: StorageType.DROPBOX, 16 | storageTypeIcon: 'dropbox', 17 | 18 | client: null, 19 | ready: null, 20 | 21 | init() { 22 | this.set( 23 | 'ready', 24 | (new Ember.RSVP.Promise(function(resolve) { 25 | this.checkDropinsLoaded(resolve); 26 | }.bind(this))).then(function() { 27 | console.info('Dropbox dropins loaded'); 28 | })); 29 | Ember.$(' 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | {{content-for 'body-footer'}} 33 | {{content-for 'test-body-footer'}} 34 | 35 | 36 | -------------------------------------------------------------------------------- /client/tests/integration/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jichu4n/asciidoclive/1d7bdf89755f74f639a9df2ecee0eb792a3e1371/client/tests/integration/.gitkeep -------------------------------------------------------------------------------- /client/tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import resolver from './helpers/resolver'; 2 | import { 3 | setResolver 4 | } from 'ember-qunit'; 5 | 6 | setResolver(resolver); 7 | -------------------------------------------------------------------------------- /client/tests/unit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jichu4n/asciidoclive/1d7bdf89755f74f639a9df2ecee0eb792a3e1371/client/tests/unit/.gitkeep -------------------------------------------------------------------------------- /client/vendor/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jichu4n/asciidoclive/1d7bdf89755f74f639a9df2ecee0eb792a3e1371/client/vendor/.gitkeep -------------------------------------------------------------------------------- /client/workers/asciidoctor-js-compile-worker.js: -------------------------------------------------------------------------------- 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 | * Copyright 2016 Chuan Ji * 3 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 4 | 5 | /* global self, Opal, html_beautify, hljs, global */ 6 | 7 | var isInWebWorker = typeof document === 'undefined'; 8 | 9 | function asciidoctorJsCompile(ev) { 10 | var body = ev.data.body; 11 | ev.data.body = null; 12 | var response = JSON.parse(JSON.stringify(ev.data)); 13 | 14 | var compiledBody; 15 | if (response.inline) { 16 | compiledBody = Opal.Asciidoctor.$convert(body, Opal.hash2( 17 | ['attributes'], 18 | { 19 | 'attributes': ['showtitle'] 20 | })); 21 | } else { 22 | var cssPath = 23 | response.serverUrl + '/assets/asciidoctor.js/css/asciidoctor.css'; 24 | compiledBody = Opal.Asciidoctor.$convert(body, Opal.hash2( 25 | ['header_footer', 'attributes'], 26 | { 27 | 'header_footer': true, 28 | 'attributes': ['nofooter', 'linkcss', 'stylesheet=' + cssPath] 29 | })); 30 | } 31 | if (response.beautify) { 32 | compiledBody = html_beautify(compiledBody, response.beautifyOptions); 33 | } 34 | if (response.highlight) { 35 | compiledBody = hljs.highlight( 36 | 'html', 37 | compiledBody, 38 | true /* allow malformed input */).value; 39 | } 40 | response.compiledBody = compiledBody; 41 | if (isInWebWorker) { 42 | self.postMessage(response); 43 | } 44 | return response; 45 | } 46 | 47 | if (isInWebWorker) { 48 | if (typeof console !== 'undefined') { 49 | console.info('Starting Asciidoctor compile worker'); 50 | } 51 | // For js-beautify. 52 | global = {}; 53 | self.importScripts( 54 | '/assets/asciidoctor.js/asciidoctor-all.min.js', 55 | '/assets/js-beautify/beautify-html.js', 56 | '/assets/highlightjs/highlight.pack.min.js'); 57 | self.addEventListener('message', asciidoctorJsCompile); 58 | html_beautify = global.html_beautify; 59 | } 60 | -------------------------------------------------------------------------------- /misc/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jichu4n/asciidoclive/1d7bdf89755f74f639a9df2ecee0eb792a3e1371/misc/favicon.png -------------------------------------------------------------------------------- /misc/favicon.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jichu4n/asciidoclive/1d7bdf89755f74f639a9df2ecee0eb792a3e1371/misc/favicon.xcf -------------------------------------------------------------------------------- /misc/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jichu4n/asciidoclive/1d7bdf89755f74f639a9df2ecee0eb792a3e1371/misc/logo.png -------------------------------------------------------------------------------- /misc/logo.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jichu4n/asciidoclive/1d7bdf89755f74f639a9df2ecee0eb792a3e1371/misc/logo.xcf -------------------------------------------------------------------------------- /production/Dockerfile: -------------------------------------------------------------------------------- 1 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 2 | # Copyright 2016 Chuan Ji # 3 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 4 | 5 | # Dockerfile for NGINX server hosting amoya. Build with build.sh. 6 | 7 | FROM nginx 8 | 9 | COPY nginx-server.conf /etc/nginx/conf.d/default.conf 10 | COPY dist /usr/share/nginx/html 11 | 12 | -------------------------------------------------------------------------------- /production/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 3 | # Copyright 2016 Chuan Ji # 4 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 5 | 6 | # Build NGINX server Docker image. 7 | 8 | docker_tag="r.chu4n.com/amoya" 9 | 10 | root_dir=$(realpath $(dirname $0)/..) 11 | client_dir=$root_dir/client 12 | production_dir=$root_dir/production 13 | 14 | set -ex 15 | 16 | cd $client_dir 17 | time ember build --environment=production 18 | 19 | cd $production_dir 20 | rm -rf dist 21 | cp -a $client_dir/dist ./ 22 | docker build -t $docker_tag . 23 | rm -rf dist 24 | docker push $docker_tag 25 | 26 | -------------------------------------------------------------------------------- /production/nginx-server.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | server_name _; 4 | return 301 $scheme://asciidoclive.com$request_uri; 5 | } 6 | 7 | server { 8 | listen 80; 9 | server_name asciidoclive.com; 10 | 11 | root /usr/share/nginx/html; 12 | index index.html; 13 | 14 | location / { 15 | try_files $uri $uri/ /index.html; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /production/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 3 | # Copyright 2016 Chuan Ji # 4 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 5 | 6 | 7 | docker_tag="r.chu4n.com/amoya" 8 | 9 | set -ex 10 | 11 | docker pull $docker_tag 12 | docker rm -f amoya || true 13 | docker run \ 14 | -d \ 15 | --restart=always \ 16 | -p 127.0.0.1:9002:80 \ 17 | --name amoya \ 18 | $docker_tag 19 | --------------------------------------------------------------------------------