├── .gitignore ├── LICENSE ├── README.md ├── admin ├── .gitignore ├── LICENSE ├── __tests__ │ └── preprocessor.js ├── dist │ ├── font │ │ ├── rango.eot │ │ ├── rango.svg │ │ ├── rango.ttf │ │ └── rango.woff │ └── index.html ├── gulpfile.js ├── lib │ ├── actions.js │ ├── api.js │ ├── components │ │ ├── app.jsx │ │ ├── browser.jsx │ │ ├── browserRow.jsx │ │ ├── browserSidebar.jsx │ │ ├── browserTable.jsx │ │ ├── editor.jsx │ │ ├── editorContent.jsx │ │ ├── editorImages.jsx │ │ ├── editorMetadata.jsx │ │ ├── header.jsx │ │ ├── imageItem.jsx │ │ ├── inputCheckbox.jsx │ │ ├── inputDropdown.jsx │ │ ├── inputText.jsx │ │ ├── inputTextarea.jsx │ │ └── sortableItem.jsx │ ├── main.jsx │ └── stores │ │ ├── app.js │ │ ├── browser.js │ │ ├── config.js │ │ └── editor.js ├── package.json └── style │ ├── app │ ├── _body.scss │ ├── _browser.scss │ ├── _editor.scss │ └── _header.scss │ ├── main.scss │ ├── modules │ ├── _buttons.scss │ ├── _extends.scss │ ├── _form.scss │ ├── _functions.scss │ ├── _icon_font.scss │ ├── _mixins.scss │ ├── _sortable.scss │ └── _type.scss │ └── vendor │ ├── _normalize.scss │ ├── codemirror │ ├── _base16-light.scss │ ├── _index.scss │ └── _solarized.scss │ └── jeet │ ├── _functions.scss │ ├── _grid.scss │ ├── _settings.scss │ └── index.scss ├── config.toml ├── docs ├── screenshot_1.jpg └── screenshot_2.jpg ├── errors.go ├── handlers.go ├── handlers_test.go ├── logger.go ├── main.go ├── rangolib ├── asset.go ├── config.go ├── config_test.go ├── dir.go ├── dir_test.go ├── file.go ├── hugo.go ├── page.go ├── page_test.go └── treecopier.go ├── router.go ├── routes.go └── utils.go /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | /rango 6 | 7 | # Folders 8 | _obj 9 | _test 10 | node_modules 11 | 12 | /admin/dist/*.css 13 | /admin/dist/*.js 14 | 15 | # Architecture specific extensions/prefixes 16 | *.[568vq] 17 | [568vq].out 18 | 19 | *.cgo1.go 20 | *.cgo2.c 21 | _cgo_defun.c 22 | _cgo_gotypes.go 23 | _cgo_export.* 24 | 25 | _testmain.go 26 | 27 | *.exe 28 | *.test 29 | 30 | # Hugo folders 31 | /content/**/*.md 32 | /static 33 | /public 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 George Czabania 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | rango 2 | ===== 3 | 4 | A web frontend for [hugo](https://gohugo.io). 5 | 6 | It's designed to make it easy to manage a small site, even for people with 7 | little computer experience. 8 | 9 | ![File Browser](./docs/screenshot_1.jpg) 10 | 11 | ![Text Editor](./docs/screenshot_2.jpg) 12 | 13 | ## Installation 14 | 15 | ``` 16 | $ go get -u -v github.com/stayradiated/rango 17 | $ cd $GOPATH/src/github.com/stayradiated/rango 18 | $ cd admin 19 | $ npm install 20 | $ gulp 21 | $ cd .. 22 | $ go build 23 | $ ./rango 24 | ``` 25 | 26 | ## Using with Apache 27 | 28 | Based on [this 29 | tutorial](http://www.jeffreybolle.com/blog/run-google-go-web-apps-behind-apache). 30 | 31 | 1. Create a folder named `admin` or `rango` or whatever. 32 | 2. Create a `.htaccess` inside that folder with the following content: 33 | 3. Enable apache modules: `proxy`, `proxy_http`, `rewrite` 34 | 35 | ``` 36 | RewriteEngine on 37 | RewriteRule ^(.*)$ http://localhost:8080/$1 [P,L] 38 | ``` 39 | -------------------------------------------------------------------------------- /admin/.gitignore: -------------------------------------------------------------------------------- 1 | dist/js/*.js 2 | dist/css/*.css 3 | node_modules 4 | .svn 5 | -------------------------------------------------------------------------------- /admin/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 George Czabania 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /admin/__tests__/preprocessor.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var ReactTools = require('react-tools'); 4 | 5 | module.exports = { 6 | process: function (src) { 7 | return ReactTools.transform(src); 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /admin/dist/font/rango.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayradiated/rango/71c995cba6cef7f0cb387f530474dd796302f4d6/admin/dist/font/rango.eot -------------------------------------------------------------------------------- /admin/dist/font/rango.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copyright (C) 2015 by original authors @ fontello.com 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /admin/dist/font/rango.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayradiated/rango/71c995cba6cef7f0cb387f530474dd796302f4d6/admin/dist/font/rango.ttf -------------------------------------------------------------------------------- /admin/dist/font/rango.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayradiated/rango/71c995cba6cef7f0cb387f530474dd796302f4d6/admin/dist/font/rango.woff -------------------------------------------------------------------------------- /admin/dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Rango 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /admin/gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var gulp = require('gulp'); 4 | var source = require('vinyl-source-stream'); 5 | var browserSync = require('browser-sync'); 6 | var sass = require('gulp-sass'); 7 | var autoprefixer = require('gulp-autoprefixer'); 8 | var reactify = require('reactify'); 9 | var browserify = require('browserify'); 10 | var watchify = require('watchify'); 11 | var uglify = require('gulp-uglify'); 12 | 13 | gulp.task('default', ['lib', 'style'], function () { 14 | gulp.watch('./style/**/*.scss', ['style']); 15 | }); 16 | 17 | gulp.task('server', ['default'], function () { 18 | return browserSync({ 19 | notify: false, 20 | ghostMode: false, 21 | server: { 22 | baseDir: './dist/', 23 | } 24 | }); 25 | }); 26 | 27 | gulp.task('proxy', ['default'], function () { 28 | return browserSync({ 29 | notify: false, 30 | open: false, 31 | ghostMode: false, 32 | proxy: 'localhost:8080', 33 | }); 34 | }); 35 | 36 | gulp.task('lib', function () { 37 | var bundler = watchify(browserify({ 38 | cache: {}, 39 | packageCache: {}, 40 | fullPaths: true, 41 | extensions: '.jsx' 42 | })); 43 | 44 | bundler.add('./lib/main.jsx'); 45 | bundler.transform(reactify); 46 | 47 | bundler.on('update', rebundle); 48 | 49 | function rebundle () { 50 | console.log('rebundling'); 51 | return bundler.bundle() 52 | .on('error', function (err) { 53 | console.log(err.message); 54 | }) 55 | .pipe(source('main.js')) 56 | .pipe(gulp.dest('./dist')) 57 | .pipe(browserSync.reload({stream: true})); 58 | } 59 | 60 | return rebundle(); 61 | }); 62 | 63 | gulp.task('style', function () { 64 | return gulp.src('./style/main.scss') 65 | .pipe(sass({errLogToConsole: true, outputStyle: 'compressed'})) 66 | .pipe(autoprefixer()) 67 | .pipe(gulp.dest('./dist')) 68 | .pipe(browserSync.reload({stream: true})); 69 | }); 70 | 71 | gulp.task('minify', function () { 72 | return gulp.src('./dist/*.js') 73 | .pipe(uglify()) 74 | .pipe(gulp.dest('./dist')); 75 | }); 76 | -------------------------------------------------------------------------------- /admin/lib/actions.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _ = require('lodash'); 4 | 5 | _.extend(exports, { 6 | open: { 7 | directory: dispatch('OPEN_DIRECTORY'), 8 | parent: dispatch('OPEN_PARENT_DIRECTORY'), 9 | page: dispatch('OPEN_PAGE'), 10 | path: dispatch('OPEN_PATH'), 11 | }, 12 | create: { 13 | page: dispatch('CREATE_PAGE'), 14 | directory: dispatch('CREATE_DIRECTORY'), 15 | }, 16 | update: { 17 | page: dispatch('UPDATE_PAGE'), 18 | content: dispatch('UPDATE_CONTENT'), 19 | metadata: dispatch('UPDATE_METADATA'), 20 | directory: dispatch('UPDATE_DIRECTORY'), 21 | }, 22 | select: { 23 | file: dispatch('SELECT_FILE'), 24 | none: dispatch('DESELECT_ALL'), 25 | }, 26 | remove: { 27 | selected: dispatch('REMOVE_SELECTED_FILES'), 28 | }, 29 | save: { 30 | page: dispatch('SAVE_PAGE'), 31 | }, 32 | publish: { 33 | site: dispatch('PUBLISH_SITE'), 34 | }, 35 | upload: { 36 | file: dispatch('UPLOAD_FILE'), 37 | }, 38 | }); 39 | 40 | function dispatch (event) { 41 | return function (args) { 42 | this.dispatch(event, args); 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /admin/lib/api.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var _ = require('lodash'); 4 | var jQuery = require('jquery'); 5 | var Path = require('path'); 6 | 7 | var BASE_URL = 'api/' 8 | var DIR = 'dir'; 9 | var PAGE = 'page'; 10 | var CONFIG = 'config'; 11 | 12 | _.extend(exports, { 13 | 14 | // Directories 15 | 16 | readDir: function (path) { 17 | return get(DIR, path).then(function (res) { 18 | return res.data; 19 | }); 20 | }, 21 | 22 | createDir: function (path, dirname) { 23 | return post(DIR, path, { 24 | dir: { 25 | name: dirname, 26 | }, 27 | }).then(function (res) { 28 | return res.dir; 29 | }); 30 | }, 31 | 32 | updateDir: function (path, props) { 33 | return put(DIR, path, { 34 | dir: props, 35 | }).then(function (res) { 36 | return res.dir; 37 | }); 38 | }, 39 | 40 | deleteDir: function (path) { 41 | return del(DIR, path); 42 | }, 43 | 44 | 45 | // Pages 46 | 47 | readPage: function (path) { 48 | return get(PAGE, path).then(function (res) { 49 | return res.page; 50 | }); 51 | }, 52 | 53 | createPage: function (dirPath, page) { 54 | return post(PAGE, dirPath, { 55 | page: { 56 | meta: JSON.stringify(page.metadata), 57 | content: page.content, 58 | }, 59 | }).then(function (res) { 60 | return res.page; 61 | }); 62 | }, 63 | 64 | updatePage: function (path, page) { 65 | return put(PAGE, path, { 66 | page: { 67 | meta: JSON.stringify(page.metadata), 68 | content: page.content, 69 | }, 70 | }).then(function (res) { 71 | return res.page; 72 | }); 73 | }, 74 | 75 | deletePage: function (path) { 76 | return del(PAGE, path); 77 | }, 78 | 79 | 80 | // Config 81 | 82 | readConfig: function () { 83 | return get(CONFIG, ''); 84 | }, 85 | 86 | updateConfig: function (config) { 87 | return put(CONFIG, '', { config: config }); 88 | }, 89 | 90 | 91 | // Site 92 | 93 | publishSite: function () { 94 | return post('site', 'publish').then(function (res) { 95 | return res.output; 96 | }); 97 | }, 98 | 99 | 100 | // Assets 101 | 102 | createAsset: function (path, file) { 103 | var formData = new FormData(); 104 | formData.append('file', file); 105 | return postForm('asset', path, formData); 106 | }, 107 | 108 | copy: function (src, dst) { 109 | return post('copy', src, { destination: dst }); 110 | }, 111 | 112 | move: function (src, dst) { 113 | return post('copy', src, { destination: dst }).then(function () { 114 | return del(src); 115 | }); 116 | }, 117 | 118 | }); 119 | 120 | function get (method, path) { 121 | return jQuery.ajax({ 122 | type: 'get', 123 | url: Path.join(BASE_URL, method, path), 124 | dataType: 'json', 125 | }); 126 | } 127 | 128 | function post (method, path, params) { 129 | return jQuery.ajax({ 130 | type: 'post', 131 | url: Path.join(BASE_URL, method, path), 132 | dataType: 'json', 133 | data: params, 134 | }); 135 | } 136 | 137 | function postForm (method, path, formData) { 138 | return jQuery.ajax({ 139 | type: 'post', 140 | url: Path.join(BASE_URL, method, path), 141 | data: formData, 142 | cache: false, 143 | contentType: false, 144 | processData: false 145 | }); 146 | } 147 | 148 | function put (method, path, params) { 149 | return jQuery.ajax({ 150 | type: 'put', 151 | url: Path.join(BASE_URL, method, path), 152 | dataType: 'json', 153 | data: params, 154 | }); 155 | } 156 | 157 | function del (method, path) { 158 | return jQuery.ajax({ 159 | type: 'delete', 160 | url: Path.join(BASE_URL, method, path), 161 | dataType: 'json', 162 | }); 163 | } 164 | -------------------------------------------------------------------------------- /admin/lib/components/app.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var Fluxxor = require('fluxxor'); 5 | var FluxMixin = Fluxxor.FluxMixin(React); 6 | var StoreWatchMixin = Fluxxor.StoreWatchMixin; 7 | 8 | var Header = require('./header'); 9 | var Browser = require('./browser'); 10 | var Editor = require('./editor'); 11 | 12 | var App = React.createClass({ 13 | mixins: [ 14 | FluxMixin, 15 | StoreWatchMixin('App', 'Browser', 'Editor'), 16 | ], 17 | 18 | getStateFromFlux: function () { 19 | var flux = this.getFlux(); 20 | return { 21 | app: flux.store('App').state, 22 | editor: flux.store('Editor').state, 23 | browser: flux.store('Browser').state, 24 | }; 25 | }, 26 | 27 | render: function () { 28 | var view = null; 29 | 30 | switch (this.state.app.get('route')) { 31 | case 'BROWSER': 32 | view = 33 | break; 34 | case 'EDITOR': 35 | view = 36 | break; 37 | } 38 | 39 | return ( 40 |
41 |
46 | {view} 47 |
48 | ); 49 | }, 50 | 51 | }); 52 | 53 | module.exports = App; 54 | -------------------------------------------------------------------------------- /admin/lib/components/browser.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var PureRenderMixin = require('react/addons').addons.PureRenderMixin; 5 | 6 | var BrowserSidebar = require('./browserSidebar'); 7 | var BrowserTable = require('./browserTable'); 8 | 9 | var Browser = React.createClass({ 10 | mixins: [PureRenderMixin], 11 | 12 | propTypes: { 13 | browser: React.PropTypes.object.isRequired, 14 | }, 15 | 16 | render: function () { 17 | return ( 18 |
19 | 20 | 21 |
22 | ); 23 | }, 24 | 25 | }); 26 | 27 | module.exports = Browser; 28 | -------------------------------------------------------------------------------- /admin/lib/components/browserRow.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var moment = require('moment'); 5 | var classSet = require('react/addons').addons.classSet; 6 | var PureRenderMixin = require('react/addons').addons.PureRenderMixin; 7 | var Fluxxor = require('fluxxor'); 8 | var FluxMixin = Fluxxor.FluxMixin(React); 9 | 10 | var actions = require('../actions'); 11 | 12 | var BrowserRow = React.createClass({ 13 | mixins: [ 14 | FluxMixin, 15 | PureRenderMixin, 16 | ], 17 | 18 | propTypes: { 19 | item: React.PropTypes.object.isRequired, 20 | selected: React.PropTypes.bool.isRequired, 21 | }, 22 | 23 | render: function () { 24 | var item = this.props.item; 25 | var lastModified = moment(item.get('modTime') * 1000).format('LT ll'); 26 | var isDir = item.get('isDir'); 27 | 28 | var icon = isDir ? ( 29 | 30 | ) : ( 31 | 32 | ); 33 | 34 | var classes = classSet({ 35 | selected: this.props.selected, 36 | }); 37 | 38 | return ( 39 | 44 | {icon} 45 | {item.get('name')} 46 | {lastModified} 47 | 48 | 49 | 50 | ); 51 | }, 52 | 53 | onClick: function (e) { 54 | e.stopPropagation(); 55 | this.getFlux().actions.select.file(this.props.item); 56 | }, 57 | 58 | onDoubleClick: function () { 59 | var actions = this.getFlux().actions; 60 | 61 | if (this.props.item.get('isDir')) { 62 | actions.open.path(this.props.item.get('path')); 63 | } else { 64 | actions.open.page(this.props.item.get('path')); 65 | } 66 | }, 67 | 68 | }); 69 | 70 | module.exports = BrowserRow; 71 | -------------------------------------------------------------------------------- /admin/lib/components/browserSidebar.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var Fluxxor = require('fluxxor'); 5 | var FluxMixin = Fluxxor.FluxMixin(React); 6 | var PureRenderMixin = require('react/addons').addons.PureRenderMixin; 7 | 8 | var BrowserSidebar = React.createClass({ 9 | mixins: [ 10 | FluxMixin, 11 | PureRenderMixin, 12 | ], 13 | 14 | propTypes: { 15 | browser: React.PropTypes.object.isRequired, 16 | }, 17 | 18 | render: function () { 19 | var selected = this.props.browser.get('selected').size; 20 | 21 | return ( 22 |
23 |
    24 |
  • Create Folder
  • 25 |
  • Create Page
  • 26 |
    27 | { 28 | selected === 1 ? ( 29 |
  • Rename Selected Folder
  • 30 | ) : null 31 | } 32 | { 33 | selected >= 1 ? ( 34 |
  • Delete Selected Items
  • 35 | ) : null 36 | } 37 |
38 |
39 | ); 40 | }, 41 | 42 | createDirectory: function () { 43 | this.getFlux().actions.create.directory(); 44 | }, 45 | 46 | renameDirectory: function () { 47 | this.getFlux().actions.update.directory(); 48 | }, 49 | 50 | createPage: function () { 51 | this.getFlux().actions.create.page(); 52 | }, 53 | 54 | removeSelected: function () { 55 | this.getFlux().actions.remove.selected(); 56 | }, 57 | 58 | /* 59 | openParent: function () { 60 | this.getFlux().actions.open.parent(); 61 | }, 62 | */ 63 | 64 | }); 65 | 66 | module.exports = BrowserSidebar; 67 | -------------------------------------------------------------------------------- /admin/lib/components/browserTable.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var Fluxxor = require('fluxxor'); 5 | var FluxMixin = Fluxxor.FluxMixin(React); 6 | var PureRenderMixin = require('react/addons').addons.PureRenderMixin; 7 | 8 | var BrowserRow = require('./browserRow'); 9 | 10 | var BrowserTable = React.createClass({ 11 | mixins: [ 12 | FluxMixin, 13 | PureRenderMixin, 14 | ], 15 | 16 | propTypes: { 17 | browser: React.PropTypes.object.isRequired, 18 | }, 19 | 20 | render: function () { 21 | var contents = this.props.browser.get('contents'); 22 | var selected = this.props.browser.get('selected'); 23 | 24 | var rows = contents.toArray().map(function (item) { 25 | return ( 26 | 31 | ); 32 | }); 33 | 34 | return ( 35 |
36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | {rows} 48 | 49 |
NameLast ModifiedContentsDraft
50 |
51 | ); 52 | }, 53 | 54 | onClick: function () { 55 | this.getFlux().actions.select.none(); 56 | }, 57 | 58 | }); 59 | 60 | module.exports = BrowserTable; 61 | -------------------------------------------------------------------------------- /admin/lib/components/editor.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var PureRenderMixin = require('react/addons').addons.PureRenderMixin; 5 | 6 | var EditorMetadata = require('./editorMetadata'); 7 | var EditorContent = require('./editorContent'); 8 | var EditorImages = require('./editorImages'); 9 | 10 | var Editor = React.createClass({ 11 | mixins: [ 12 | PureRenderMixin, 13 | ], 14 | 15 | propTypes: { 16 | editor: React.PropTypes.object.isRequired, 17 | }, 18 | 19 | render: function () { 20 | return ( 21 |
22 | 23 | {/* 25 |
26 | ); 27 | }, 28 | 29 | }); 30 | 31 | module.exports = Editor; 32 | -------------------------------------------------------------------------------- /admin/lib/components/editorContent.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var Fluxxor = require('fluxxor'); 5 | var FluxMixin = Fluxxor.FluxMixin(React); 6 | var PureRenderMixin = require('react/addons').addons.PureRenderMixin; 7 | var CodeMirror = require('react-code-mirror'); 8 | var Marked = require('marked'); 9 | 10 | // load markdown syntax for codemirror 11 | require('codemirror/mode/markdown/markdown'); 12 | 13 | var EditorContent = React.createClass({ 14 | mixins: [ 15 | FluxMixin, 16 | PureRenderMixin 17 | ], 18 | 19 | propTypes: { 20 | content: React.PropTypes.string.isRequired, 21 | }, 22 | 23 | render: function () { 24 | // var markdown = Marked(this.props.content); 25 | 26 | //
30 | 31 | return ( 32 |
33 | 42 |
43 | ); 44 | }, 45 | 46 | onChange: function (e) { 47 | var value = e.target.value; 48 | this.getFlux().actions.update.content(value); 49 | }, 50 | 51 | }); 52 | 53 | module.exports = EditorContent; 54 | -------------------------------------------------------------------------------- /admin/lib/components/editorImages.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * TODO: Split this file up into multiple components. 5 | */ 6 | 7 | var React = require('react'); 8 | var PureRenderMixin = require('react/addons').addons.PureRenderMixin; 9 | var Sortable = require('react-anything-sortable'); 10 | var Immutable = require('immutable'); 11 | var Fluxxor = require('fluxxor'); 12 | var FluxMixin = Fluxxor.FluxMixin(React); 13 | var Dropzone = require('react-dropzone'); 14 | 15 | var ImageItem = require('./imageItem'); 16 | var SortableItem = require('./sortableItem'); 17 | 18 | var EditorImages = React.createClass({ 19 | 20 | mixins: [ 21 | FluxMixin, 22 | PureRenderMixin, 23 | ], 24 | 25 | propTypes: { 26 | // images: React.PropTypes.arrayOf(React.PropTypes.string).isRequired, 27 | metadata: React.PropTypes.object.isRequired, 28 | }, 29 | 30 | render: function () { 31 | var meta = this.props.metadata; 32 | var key = 'images'; 33 | 34 | var imageArr = meta.get('images'); 35 | var images = []; 36 | var key = ''; 37 | 38 | if (imageArr != null) { 39 | // concat image paths to make parent key 40 | key = imageArr.toArray().join('+'); 41 | 42 | images = imageArr.map(function (path, index) { 43 | return ( 44 | 45 | 50 | 51 | ); 52 | }, this).toArray(); 53 | } 54 | 55 | return ( 56 |
57 | 58 | 59 |
Add Images
60 |
61 | 62 |
63 | 64 | {images} 65 | 66 |
67 |
68 | ); 69 | }, 70 | 71 | handleSort: function (imageArray) { 72 | var imageList = Immutable.fromJS(imageArray); 73 | var meta = this.props.metadata.set('images', imageList); 74 | this.getFlux().actions.update.metadata(meta); 75 | }, 76 | 77 | handleRemove: function (path) { 78 | var meta = this.props.metadata; 79 | 80 | if (meta.has('images')) { 81 | meta = meta.update('images', function (images) { 82 | var index = images.indexOf(path); 83 | if (index >= 0) { 84 | images = images.delete(index); 85 | } 86 | return images; 87 | }); 88 | 89 | this.getFlux().actions.update.metadata(meta); 90 | } 91 | }, 92 | 93 | handleDrop: function (files) { 94 | for (var i = 0, len = files.length; i < len; i++) { 95 | var file = files[i]; 96 | this.getFlux().actions.upload.file(file); 97 | } 98 | }, 99 | 100 | }); 101 | 102 | module.exports = EditorImages; 103 | -------------------------------------------------------------------------------- /admin/lib/components/editorMetadata.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var PureRenderMixin = require('react/addons').addons.PureRenderMixin; 5 | var Fluxxor = require('fluxxor'); 6 | var FluxMixin = Fluxxor.FluxMixin(React); 7 | 8 | var InputText = require('./inputText'); 9 | var InputTextarea = require('./inputTextarea'); 10 | var InputCheckbox = require('./inputCheckbox'); 11 | var InputDropdown = require('./inputDropdown'); 12 | 13 | var EditorMetadata = React.createClass({ 14 | mixins: [ 15 | FluxMixin, 16 | PureRenderMixin, 17 | ], 18 | 19 | propTypes: { 20 | metadata: React.PropTypes.object.isRequired, 21 | }, 22 | 23 | render: function () { 24 | var meta = this.props.metadata; 25 | 26 | var data = { 27 | title: { 28 | type: InputText, 29 | value: meta.get('title', ''), 30 | }, 31 | part: { 32 | type: InputText, 33 | value: meta.get('part', ''), 34 | }, 35 | description: { 36 | type: InputText, 37 | value: meta.get('description', ''), 38 | }, 39 | date: { 40 | type: InputText, 41 | value: meta.get('date', ''), 42 | }, 43 | type: { 44 | type: InputDropdown, 45 | value: meta.get('type', ''), 46 | }, 47 | }; 48 | 49 | // for (var key in meta) { 50 | // data[key] = meta[key]; 51 | // } 52 | 53 | var inputs = []; 54 | for (var key in data) { 55 | inputs.push( 56 | React.createElement(data[key].type, { 57 | key: key, 58 | label: key, 59 | value: data[key].value, 60 | onChange: this.onChange.bind(this, key), 61 | }) 62 | ); 63 | } 64 | 65 | return ( 66 |
67 |

Details

68 | {inputs} 69 | 70 |
71 | ); 72 | }, 73 | 74 | onChange: function (key, e) { 75 | var value = e.target.value; 76 | var meta = this.props.metadata.set(key, value); 77 | this.getFlux().actions.update.metadata(meta); 78 | }, 79 | 80 | }); 81 | 82 | module.exports = EditorMetadata; 83 | -------------------------------------------------------------------------------- /admin/lib/components/header.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var PureRenderMixin = require('react/addons').addons.PureRenderMixin; 5 | var Fluxxor = require('fluxxor'); 6 | var FluxMixin = Fluxxor.FluxMixin(React); 7 | 8 | var Header = React.createClass({ 9 | mixins: [ 10 | FluxMixin, 11 | PureRenderMixin, 12 | ], 13 | 14 | propTypes: { 15 | app: React.PropTypes.object.isRequired, 16 | editor: React.PropTypes.object.isRequired, 17 | browser: React.PropTypes.object.isRequired, 18 | }, 19 | 20 | render: function () { 21 | return ( 22 |
23 | 35 |
36 | 43 | 46 |
47 |
48 | ); 49 | }, 50 | 51 | onClickSaveBtn: function () { 52 | this.getFlux().actions.save.page(); 53 | }, 54 | 55 | onClickPublishBtn: function () { 56 | this.getFlux().actions.publish.site(); 57 | }, 58 | 59 | onPathClick: function (index) { 60 | var path = '/'; 61 | if (index >= 0) { 62 | path = this.props.browser.get('path').slice(0, index + 1).join('/'); 63 | } 64 | this.getFlux().actions.open.path(path); 65 | }, 66 | 67 | }); 68 | 69 | module.exports = Header; 70 | -------------------------------------------------------------------------------- /admin/lib/components/imageItem.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | 5 | var ImageItem = React.createClass({ 6 | 7 | propTypes: { 8 | path: React.PropTypes.string.isRequired, 9 | onRemove: React.PropTypes.func, 10 | }, 11 | 12 | render: function () { 13 | var path = this.props.path; 14 | 15 | return ( 16 | //
17 |
18 | 19 | 23 |
24 | ); 25 | }, 26 | 27 | handleMouseDown: function (event) { 28 | // stop sortable from firing 29 | event.stopPropagation(); 30 | }, 31 | 32 | }); 33 | 34 | module.exports = ImageItem; 35 | -------------------------------------------------------------------------------- /admin/lib/components/inputCheckbox.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var PureRenderMixin = require('react/addons').addons.PureRenderMixin; 5 | 6 | var InputCheckbox = React.createClass({ 7 | mixins: [ 8 | PureRenderMixin, 9 | ], 10 | 11 | propTypes: { 12 | label: React.PropTypes.string.isRequired, 13 | }, 14 | 15 | render: function () { 16 | return ( 17 |
18 | 19 | 20 |
21 | ); 22 | }, 23 | 24 | }); 25 | 26 | module.exports = InputCheckbox; 27 | -------------------------------------------------------------------------------- /admin/lib/components/inputDropdown.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var PureRenderMixin = require('react/addons').addons.PureRenderMixin; 5 | 6 | var InputDropdown = React.createClass({ 7 | mixins: [ 8 | PureRenderMixin, 9 | ], 10 | 11 | propTypes: { 12 | label: React.PropTypes.string.isRequired, 13 | value: React.PropTypes.string.isRequired, 14 | onChange: React.PropTypes.func, 15 | }, 16 | 17 | render: function () { 18 | return ( 19 |
20 | 21 | 30 |
31 | ); 32 | }, 33 | 34 | }); 35 | 36 | module.exports = InputDropdown; 37 | -------------------------------------------------------------------------------- /admin/lib/components/inputText.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var PureRenderMixin = require('react/addons').addons.PureRenderMixin; 5 | 6 | var InputText = React.createClass({ 7 | mixins: [ 8 | PureRenderMixin, 9 | ], 10 | 11 | propTypes: { 12 | label: React.PropTypes.string.isRequired, 13 | value: React.PropTypes.string.isRequired, 14 | onChange: React.PropTypes.func, 15 | }, 16 | 17 | render: function () { 18 | return ( 19 |
20 | 21 | 27 |
28 | ); 29 | }, 30 | 31 | }); 32 | 33 | module.exports = InputText; 34 | -------------------------------------------------------------------------------- /admin/lib/components/inputTextarea.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var React = require('react'); 4 | var PureRenderMixin = require('react/addons').addons.PureRenderMixin; 5 | 6 | var InputTextarea = React.createClass({ 7 | mixins: [ 8 | PureRenderMixin, 9 | ], 10 | 11 | propTypes: { 12 | label: React.PropTypes.string.isRequired, 13 | value: React.PropTypes.string.isRequired, 14 | }, 15 | 16 | getInitialState: function (props) { 17 | return { 18 | value: (props || this.props).value, 19 | }; 20 | }, 21 | 22 | componentWillReceiveProps: function (nextProps) { 23 | this.setState(this.getInitialState(nextProps)); 24 | }, 25 | 26 | render: function () { 27 | return ( 28 |
29 | 30 |