pull/144/head
Henrique Dias 2016-06-28 10:01:00 +01:00
parent 2c22f06b03
commit 062f10ffd7
10 changed files with 1011 additions and 1005 deletions

62
assets/.jsbeautifyrc Normal file
View File

@ -0,0 +1,62 @@
{
// The plugin looks for a .jsbeautifyrc file in the same directory as the
// source file you're prettifying (or any directory above if it doesn't exist,
// or in your home folder if everything else fails) and uses those options
// along the default ones.
// Details: https://github.com/victorporof/Sublime-HTMLPrettify#using-your-own-jsbeautifyrc-options
// Documentation: https://github.com/einars/js-beautify/
"html": {
"allowed_file_extensions": ["htm", "html", "xhtml", "shtml", "xml", "svg"],
"brace_style": "collapse", // [collapse|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line, or attempt to keep them where they are
"end_with_newline": false, // End output with newline
"indent_char": " ", // Indentation character
"indent_handlebars": false, // e.g. {{#foo}}, {{/foo}}
"indent_inner_html": false, // Indent <head> and <body> sections
"indent_scripts": "keep", // [keep|separate|normal]
"indent_size": 4, // Indentation size
"max_preserve_newlines": 0, // Maximum number of line breaks to be preserved in one chunk (0 disables)
"preserve_newlines": true, // Whether existing line breaks before elements should be preserved (only works before elements, not inside tags or for text)
"unformatted": ["a", "span", "img", "code", "pre", "sub", "sup", "em", "strong", "b", "i", "u", "strike", "big", "small", "pre", "h1", "h2", "h3", "h4", "h5", "h6"], // List of tags that should not be reformatted
"wrap_line_length": 0 // Lines should wrap at next opportunity after this number of characters (0 disables)
},
"css": {
"allowed_file_extensions": ["css", "scss", "sass", "less"],
"end_with_newline": false, // End output with newline
"indent_char": " ", // Indentation character
"indent_size": 4, // Indentation size
"newline_between_rules": true, // Add a new line after every css rule
"selector_separator": " ",
"selector_separator_newline": true // Separate selectors with newline or not (e.g. "a,\nbr" or "a, br")
},
"js": {
"allowed_file_extensions": ["js", "json", "jshintrc", "jsbeautifyrc"],
// Set brace_style
// collapse: (old default) Put braces on the same line as control statements
// collapse-preserve-inline: (new default) Same as collapse but better support for ES6 destructuring and other features. https://github.com/victorporof/Sublime-HTMLPrettify/issues/231
// expand: Put braces on own line (Allman / ANSI style)
// end-expand: Put end braces on own line
// none: Keep them where they are
"brace_style": "collapse-preserve-inline",
"break_chained_methods": false, // Break chained method calls across subsequent lines
"e4x": false, // Pass E4X xml literals through untouched
"end_with_newline": false, // End output with newline
"indent_char": " ", // Indentation character
"indent_level": 0, // Initial indentation level
"indent_size": 4, // Indentation size
"indent_with_tabs": false, // Indent with tabs, overrides `indent_size` and `indent_char`
"jslint_happy": false, // If true, then jslint-stricter mode is enforced
"keep_array_indentation": false, // Preserve array indentation
"keep_function_indentation": false, // Preserve function indentation
"max_preserve_newlines": 0, // Maximum number of line breaks to be preserved in one chunk (0 disables)
"preserve_newlines": true, // Whether existing line breaks should be preserved
"space_after_anon_function": false, // Should the space before an anonymous function's parens be added, "function()" vs "function ()"
"space_before_conditional": true, // Should the space before conditional statement be added, "if(true)" vs "if (true)"
"space_in_empty_paren": false, // Add padding spaces within empty paren, "f()" vs "f( )"
"space_in_paren": false, // Add padding spaces within paren, ie. f( a, b )
"unescape_strings": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65"
"wrap_line_length": 0 // Lines should wrap at next opportunity after this number of characters (0 disables)
}
}

View File

@ -5,101 +5,161 @@ html {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%
}
body {
margin: 0
}
article, aside, details, figcaption, figure, footer, header, main, menu, nav, section, summary {
article,
aside,
details,
figcaption,
figure,
footer,
header,
main,
menu,
nav,
section,
summary {
display: block
}
audio, canvas, progress, video {
audio,
canvas,
progress,
video {
display: inline-block
}
audio:not([controls]) {
display: none;
height: 0
}
progress {
vertical-align: baseline
}
template, [hidden] {
template,
[hidden] {
display: none
}
a {
background-color: transparent;
-webkit-text-decoration-skip: objects
}
a:active, a:hover {
a:active,
a:hover {
outline-width: 0
}
abbr[title] {
border-bottom: none;
text-decoration: underline;
text-decoration: underline dotted
}
b, strong {
b,
strong {
font-weight: inherit
}
b, strong {
b,
strong {
font-weight: bolder
}
dfn {
font-style: italic
}
h1 {
font-size: 2em;
margin: 0.67em 0
}
mark {
background-color: #ff0;
color: #000
}
small {
font-size: 80%
}
sub, sup {
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline
}
sub {
bottom: -0.25em
}
sup {
top: -0.5em
}
img {
border-style: none
border-style: none;
max-width: 100%;
}
svg:not(:root) {
overflow: hidden
}
code, kbd, pre, samp {
code,
kbd,
pre,
samp {
font-family: monospace, monospace;
font-size: 1em
}
figure {
margin: 1em 40px
}
hr {
box-sizing: content-box;
height: 0;
overflow: visible
}
button, input, select, textarea {
button,
input,
select,
textarea {
font: inherit;
margin: 0
}
optgroup {
font-weight: bold
}
button, input {
button,
input {
overflow: visible
}
button, select {
button,
select {
text-transform: none
}
button, .button, html [type="button"], [type="reset"], [type="submit"] {
button,
.button,
html [type="button"],
[type="reset"],
[type="submit"] {
/* -webkit-appearance: button; */
text-decoration: none;
color: #fff !important;
@ -121,13 +181,25 @@ button, .button, html [type="button"], [type="reset"], [type="submit"] {
vertical-align: middle;
-webkit-tap-highlight-color: transparent;
}
button::-moz-focus-inner,.button::-moz-focus-inner, . [type="button"]::-moz-focus-inner, [type="reset"]::-moz-focus-inner, [type="submit"]::-moz-focus-inner {
button::-moz-focus-inner,
.button::-moz-focus-inner,
. [type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0
}
button:-moz-focusring, .button:-moz-focusring,, [type="button"]:-moz-focusring, [type="reset"]:-moz-focusring, [type="submit"]:-moz-focusring {
button:-moz-focusring,
.button:-moz-focusring,
,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText
}
fieldset {
border: none;
margin: 0;
@ -136,6 +208,7 @@ fieldset {
page-break-inside: avoid;
break-inside: avoid;
}
legend {
box-sizing: border-box;
color: inherit;
@ -144,32 +217,43 @@ legend {
padding: 0;
white-space: normal
}
textarea {
overflow: auto
}
[type="checkbox"], [type="radio"] {
[type="checkbox"],
[type="radio"] {
box-sizing: border-box;
padding: 0
}
[type="number"]::-webkit-inner-spin-button, [type="number"]::-webkit-outer-spin-button {
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto
}
[type="search"] {
-webkit-appearance: textfield;
outline-offset: -2px
}
[type="search"]::-webkit-search-cancel-button, [type="search"]::-webkit-search-decoration {
[type="search"]::-webkit-search-cancel-button,
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none
}
::-webkit-input-placeholder {
color: inherit;
opacity: 0.54
}
::-webkit-file-upload-button {
-webkit-appearance: button;
font: inherit
}
/* TANANANA */
body {
@ -178,23 +262,33 @@ body {
background-color: #fcfcfc;
text-rendering: optimizespeed;
}
a {
text-decoration: none;
color: #006ed3;
}
a:hover, h1 a:hover {
a:hover,
h1 a:hover {
color: #319cff;
}
#summary, header {
#summary,
header {
padding-right: 7%;
padding-left: 7%;
}
td:first-child, th:first-child {
td:first-child,
th:first-child {
padding-left: 1em;
}
td:last-child, th:last-child {
td:last-child,
th:last-child {
padding-right: 1em;
}
h1 {
font-size: 1.5em;
font-weight: normal;
@ -202,60 +296,79 @@ h1 {
white-space: nowrap;
text-overflow: ellipsis;
}
h1 a {
color: inherit;
}
h1 a:hover {
text-decoration: underline;
}
main {
display: block;
}
.meta-item {
margin-right: 1em;
}
table {
width: 100%;
border-collapse: collapse;
}
tr {
cursor: pointer;
-webkit-transition: 0.1s ease all;
transition: 0.1s ease all;
border-bottom: 1px dashed #dadada;
}
tr.selected {
background-color: #ccc;
}
td, th {
td,
th {
padding: 1em 0;
text-align: left;
}
th {
font-size: 16px;
padding-top: 15px;
padding-bottom: 15px;
white-space: nowrap;
}
th a {
color: black;
}
th svg {
vertical-align: middle;
}
td {
font-size: 14px;
}
td:first-child {
width: 50%;
}
td:last-child, th:last-child {
td:last-child,
th:last-child {
text-align: right;
}
td:first-child svg {
position: absolute;
}
td .goup, td .name {
td .goup,
td .name {
margin-left: 1.1em;
vertical-align: middle;
white-space: pre-wrap;
@ -263,26 +376,32 @@ td .goup, td .name {
color: #424242;
overflow-wrap: break-word;
}
footer {
font-size: 0.6em;
margin: 1em 0;
text-align: center;
color: grey;
}
footer a, footer a:hover {
footer a,
footer a:hover {
color: inherit;
}
.container {
width: 95%;
max-width: 960px;
margin: 0 auto;
}
pre {
padding: 1em;
border: 1px solid #e6e6e6;
border-radius: 0.5em;
background-color: #f5f5f5;
}
@media (max-width: 600px) {
.hideable {
display: none;
@ -290,18 +409,21 @@ pre {
td:first-child {
width: auto;
}
td:nth-child(2), th:nth-child(2) {
td:nth-child(2),
th:nth-child(2) {
padding-right: 5%;
text-align: right;
}
}
/* MY STYLES */
* {
box-sizing: border-box;
}
/* MATERIAL ICONS */
.material-icons {
@ -328,6 +450,7 @@ pre {
font-feature-settings: 'liga';
}
/* HEADER */
header {
@ -335,29 +458,37 @@ header {
padding: 1.7em 0;
background-color: #2196f3;
}
header h1 {
font-size: 2em;
margin: 0;
}
header a, header a:hover {
header a,
header a:hover {
color: inherit;
}
header p {
font-size: 1.5em;
}
header p i {
font-size: 1em !important;
color: rgba(255, 255, 255, .31);
}
header #logout {
background-color: rgba(0, 0, 0, 0.1);
border-radius: 0;
margin: -0.5em -0.5em -0.5em 0;
padding: .5em;
}
header p i {
vertical-align: middle;
}
header form {
display: inline-block;
height: 100%;
@ -367,38 +498,48 @@ header form {
border-radius: 0.3em;
background-color: #1e88e5;
}
header form i, header form input {
header form i,
header form input {
vertical-align: middle;
}
header form i {
margin-right: 0.3em;
color: rgba(255, 255, 255, .5);
}
header form input {
min-width: 20em;
border: 0;
outline: 0;
background-color: transparent;
}
header form::-webkit-input-placeholder {
/* WebKit, Blink, Edge */
color: rgba(255, 255, 255, .5);
}
header form:-moz-placeholder {
opacity: 1;
/* Mozilla Firefox 4 to 18 */
color: rgba(255, 255, 255, .5);
}
header form::-moz-placeholder {
opacity: 1;
/* Mozilla Firefox 19+ */
color: rgba(255, 255, 255, .5);
}
header form:-ms-input-placeholder {
/* Internet Explorer 10-11 */
color: rgba(255, 255, 255, .5);
}
#toolbar, header {
#toolbar,
header {
position: fixed;
top: 0;
left: 0;
@ -409,20 +550,29 @@ header form:-ms-input-placeholder {
padding: 0.5em;
color: #fff;
}
#toolbar div, header div {
#toolbar div,
header div {
vertical-align: middle;
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
}
#toolbar p, header p {
#toolbar p,
header p {
display: inline-block;
margin: 0;
vertical-align: middle;
}
#toolbar p a, #toolbar p a:hover, header p a, header p a:hover {
#toolbar p a,
#toolbar p a:hover,
header p a,
header p a:hover {
color: inherit;
}
#toolbar {
z-index: 1000;
top: -4em;
@ -432,13 +582,17 @@ header form:-ms-input-placeholder {
color: #fff;
background-color: #6f6f6f;
}
#toolbar.enabled {
top: 0;
opacity: 1;
}
#toolbar div:nth-child(2), header div:nth-child(2) {
#toolbar div:nth-child(2),
header div:nth-child(2) {
text-align: right;
}
.action {
display: inline-block;
margin: 0 0.2em;
@ -448,30 +602,36 @@ header form:-ms-input-placeholder {
border: 0;
border-radius: 50%;
}
.action.disabled {
opacity: 0.2;
cursor: not-allowed;
}
.action i {
padding: 0.5em;
-webkit-transition: 0.2s ease-in-out all;
transition: 0.2s ease-in-out all;
border-radius: 50%;
}
.action:hover i {
background-color: rgba(0, 0, 0, .1);
}
.floating {
position: fixed;
bottom: 1em;
right: 1em;
}
.floating .action {
background-color: #68EFAD;
color: #306e50;
box-shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .12);
}
/* LISTING */
#listing {
@ -485,12 +645,14 @@ header form:-ms-input-placeholder {
-ms-flex-pack: justify;
justify-content: space-between;
}
#listing.list {
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
}
#listing .item {
margin: 0 0.5em 1em;
padding: 0.5em;
@ -506,6 +668,7 @@ header form:-ms-input-placeholder {
flex-grow: 1;
position: relative;
}
#listing .item .checkbox {
position: absolute;
top: 0;
@ -515,44 +678,55 @@ header form:-ms-input-placeholder {
border: 0;
-webkit-appearance: initial;
}
.item:hover {
box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .24) !important;
}
.item.selected {
border-color: #6f6f6f !important;
}
.item div {
display: inline-block;
vertical-align: middle;
}
.item p {
font-size: 0.9em;
margin: 0;
color: #4e4e4e;
}
.item span {
font-weight: bold;
}
.item i {
font-size: 4em;
margin-right: 0.1em;
}
.item a, .item a:hover {
.item a,
.item a:hover {
color: #6f6f6f;
}
/* ANIMATIONS */
i.spin {
-webkit-animation: 1s spin linear infinite;
animation: 1s spin linear infinite;
}
@-webkit-keyframes spin {
100% {
-webkit-transform: rotate(-360deg);
transform: rotate(-360deg);
}
}
@keyframes spin {
100% {
-webkit-transform: rotate(-360deg);
@ -560,6 +734,7 @@ i.spin {
}
}
/* EDITOR */
#editor .frontmatter {
@ -571,7 +746,9 @@ i.spin {
column-gap: 1em;
margin-bottom: 1em;
}
#editor .group, #editor #editor-source {
#editor .group,
#editor #editor-source {
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
display: block;
border-radius: .2em;
@ -585,31 +762,41 @@ i.spin {
width: 100%;
break-inside: avoid-column;
}
#editor .block {
border-bottom: 1px solid #eee;
margin-bottom: .5em;
padding-bottom: .5em;
}
#editor .block:last-child {
border: 0;
margin: 0;
padding: 0;
}
#editor .block label {
display: block;
color: #212121;
font-weight: 500;
}
#editor h3 {
margin: 0 0 .5em;
display: inline-block;
vertical-align: middle;
width: calc(100% - 2.5em);
}
#editor .block input, #editor .block .actions {
#editor .block input,
#editor .block .actions {
display: inline-block;
}
#editor .block input, #editor .block textarea, #editor fieldset input, #editor fieldset textarea {
#editor .block input,
#editor .block textarea,
#editor fieldset input,
#editor fieldset textarea {
border: 0;
background-color: transparent;
overflow: hidden;
@ -617,51 +804,67 @@ i.spin {
resize: none;
width: calc(100% - 1.5em);
}
#editor .action {
border: 0;
background-color: transparent;
font-size: .8em;
margin: 0;
}
#editor .delete, #editor .add {
#editor .delete,
#editor .add {
color: #ddd;
}
#editor i {
padding: 0;
}
#editor .add:hover i {
color: #8BC34A;
}
#editor .delete:hover i {
color: #E53935;
}
#editor .add:hover i, #editor .delete:hover i {
#editor .add:hover i,
#editor .delete:hover i {
background-color: transparent;
}
#editor fieldset> .action {
opacity: 0;
}
#editor fieldset:hover> .action {
opacity: 1;
}
#editor textarea[name="content"] {
display: none;
}
#editor fieldset fieldset {
margin-left: 1em;
}
#editor #submit span {
vertical-align: middle;
transition: 0.2s ease-in-out all;
}
#editor #submit span i {
vertical-align: sub;
font-size: 1.3rem;
margin-right: .2em;
}
#editor .group.temp {
background-color: #f5f5f5;
}
#editor .group.temp label {
font-weight: lighter;
font-size: .8em;
@ -669,6 +872,13 @@ i.spin {
color: #7d7d7d;
}
#editor .group.temp input {
color: #212121;
#editor .group.temp input {
color: #212121;
}
@media screen and (max-width: 1024px) {
header p a:first-of-type,
header p i:first-of-type {
display: none;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,349 +0,0 @@
/**
* Copyright (c) 2010 Maxim Vasiliev
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author Maxim Vasiliev
* Date: 09.09.2010
* Time: 19:02:33
*/
(function (root, factory)
{
if (typeof exports !== 'undefined' && typeof module !== 'undefined' && module.exports) {
// NodeJS
module.exports = factory();
}
else if (typeof define === 'function' && define.amd)
{
// AMD. Register as an anonymous module.
define(factory);
}
else
{
// Browser globals
root.form2js = factory();
}
}(this, function ()
{
"use strict";
/**
* Returns form values represented as Javascript object
* "name" attribute defines structure of resulting object
*
* @param rootNode {Element|String} root form element (or it's id) or array of root elements
* @param delimiter {String} structure parts delimiter defaults to '.'
* @param skipEmpty {Boolean} should skip empty text values, defaults to true
* @param nodeCallback {Function} custom function to get node value
* @param useIdIfEmptyName {Boolean} if true value of id attribute of field will be used if name of field is empty
*/
function form2js(rootNode, delimiter, skipEmpty, nodeCallback, useIdIfEmptyName, getDisabled)
{
getDisabled = getDisabled ? true : false;
if (typeof skipEmpty == 'undefined' || skipEmpty == null) skipEmpty = true;
if (typeof delimiter == 'undefined' || delimiter == null) delimiter = '.';
if (arguments.length < 5) useIdIfEmptyName = false;
rootNode = typeof rootNode == 'string' ? document.getElementById(rootNode) : rootNode;
var formValues = [],
currNode,
i = 0;
/* If rootNode is array - combine values */
if (rootNode.constructor == Array || (typeof NodeList != "undefined" && rootNode.constructor == NodeList))
{
while(currNode = rootNode[i++])
{
formValues = formValues.concat(getFormValues(currNode, nodeCallback, useIdIfEmptyName, getDisabled));
}
}
else
{
formValues = getFormValues(rootNode, nodeCallback, useIdIfEmptyName, getDisabled);
}
return processNameValues(formValues, skipEmpty, delimiter);
}
/**
* Processes collection of { name: 'name', value: 'value' } objects.
* @param nameValues
* @param skipEmpty if true skips elements with value == '' or value == null
* @param delimiter
*/
function processNameValues(nameValues, skipEmpty, delimiter)
{
var result = {},
arrays = {},
i, j, k, l,
value,
nameParts,
currResult,
arrNameFull,
arrName,
arrIdx,
namePart,
name,
_nameParts;
for (i = 0; i < nameValues.length; i++)
{
value = nameValues[i].value;
if (skipEmpty && (value === '' || value === null)) continue;
name = nameValues[i].name;
_nameParts = name.split(delimiter);
nameParts = [];
currResult = result;
arrNameFull = '';
for(j = 0; j < _nameParts.length; j++)
{
namePart = _nameParts[j].split('][');
if (namePart.length > 1)
{
for(k = 0; k < namePart.length; k++)
{
if (k == 0)
{
namePart[k] = namePart[k] + ']';
}
else if (k == namePart.length - 1)
{
namePart[k] = '[' + namePart[k];
}
else
{
namePart[k] = '[' + namePart[k] + ']';
}
arrIdx = namePart[k].match(/([a-z_]+)?\[([a-z_][a-z0-9_]+?)\]/i);
if (arrIdx)
{
for(l = 1; l < arrIdx.length; l++)
{
if (arrIdx[l]) nameParts.push(arrIdx[l]);
}
}
else{
nameParts.push(namePart[k]);
}
}
}
else
nameParts = nameParts.concat(namePart);
}
for (j = 0; j < nameParts.length; j++)
{
namePart = nameParts[j];
if (namePart.indexOf('[]') > -1 && j == nameParts.length - 1)
{
arrName = namePart.substr(0, namePart.indexOf('['));
arrNameFull += arrName;
if (!currResult[arrName]) currResult[arrName] = [];
currResult[arrName].push(value);
}
else if (namePart.indexOf('[') > -1)
{
arrName = namePart.substr(0, namePart.indexOf('['));
arrIdx = namePart.replace(/(^([a-z_]+)?\[)|(\]$)/gi, '');
/* Unique array name */
arrNameFull += '_' + arrName + '_' + arrIdx;
/*
* Because arrIdx in field name can be not zero-based and step can be
* other than 1, we can't use them in target array directly.
* Instead we're making a hash where key is arrIdx and value is a reference to
* added array element
*/
if (!arrays[arrNameFull]) arrays[arrNameFull] = {};
if (arrName != '' && !currResult[arrName]) currResult[arrName] = [];
if (j == nameParts.length - 1)
{
if (arrName == '')
{
currResult.push(value);
arrays[arrNameFull][arrIdx] = currResult[currResult.length - 1];
}
else
{
currResult[arrName].push(value);
arrays[arrNameFull][arrIdx] = currResult[arrName][currResult[arrName].length - 1];
}
}
else
{
if (!arrays[arrNameFull][arrIdx])
{
if ((/^[0-9a-z_]+\[?/i).test(nameParts[j+1])) currResult[arrName].push({});
else currResult[arrName].push([]);
arrays[arrNameFull][arrIdx] = currResult[arrName][currResult[arrName].length - 1];
}
}
currResult = arrays[arrNameFull][arrIdx];
}
else
{
arrNameFull += namePart;
if (j < nameParts.length - 1) /* Not the last part of name - means object */
{
if (!currResult[namePart]) currResult[namePart] = {};
currResult = currResult[namePart];
}
else
{
currResult[namePart] = value;
}
}
}
}
return result;
}
function getFormValues(rootNode, nodeCallback, useIdIfEmptyName, getDisabled)
{
var result = extractNodeValues(rootNode, nodeCallback, useIdIfEmptyName, getDisabled);
return result.length > 0 ? result : getSubFormValues(rootNode, nodeCallback, useIdIfEmptyName, getDisabled);
}
function getSubFormValues(rootNode, nodeCallback, useIdIfEmptyName, getDisabled)
{
var result = [],
currentNode = rootNode.firstChild;
while (currentNode)
{
result = result.concat(extractNodeValues(currentNode, nodeCallback, useIdIfEmptyName, getDisabled));
currentNode = currentNode.nextSibling;
}
return result;
}
function extractNodeValues(node, nodeCallback, useIdIfEmptyName, getDisabled) {
if (node.disabled && !getDisabled) return [];
var callbackResult, fieldValue, result, fieldName = getFieldName(node, useIdIfEmptyName);
callbackResult = nodeCallback && nodeCallback(node);
if (callbackResult && callbackResult.name) {
result = [callbackResult];
}
else if (fieldName != '' && node.nodeName.match(/INPUT|TEXTAREA/i)) {
fieldValue = getFieldValue(node, getDisabled);
if (null === fieldValue) {
result = [];
} else {
result = [ { name: fieldName, value: fieldValue} ];
}
}
else if (fieldName != '' && node.nodeName.match(/SELECT/i)) {
fieldValue = getFieldValue(node, getDisabled);
result = [ { name: fieldName.replace(/\[\]$/, ''), value: fieldValue } ];
}
else {
result = getSubFormValues(node, nodeCallback, useIdIfEmptyName, getDisabled);
}
return result;
}
function getFieldName(node, useIdIfEmptyName)
{
if (node.name && node.name != '') return node.name;
else if (useIdIfEmptyName && node.id && node.id != '') return node.id;
else return '';
}
function getFieldValue(fieldNode, getDisabled)
{
if (fieldNode.disabled && !getDisabled) return null;
switch (fieldNode.nodeName) {
case 'INPUT':
case 'TEXTAREA':
switch (fieldNode.type.toLowerCase()) {
case 'radio':
if (fieldNode.checked && fieldNode.value === "false") return false;
case 'checkbox':
if (fieldNode.checked && fieldNode.value === "true") return true;
if (!fieldNode.checked && fieldNode.value === "true") return false;
if (fieldNode.checked) return fieldNode.value;
break;
case 'button':
case 'reset':
case 'submit':
case 'image':
return '';
break;
default:
return fieldNode.value;
break;
}
break;
case 'SELECT':
return getSelectedOptionValue(fieldNode);
break;
default:
break;
}
return null;
}
function getSelectedOptionValue(selectNode)
{
var multiple = selectNode.multiple,
result = [],
options,
i, l;
if (!multiple) return selectNode.value;
for (options = selectNode.getElementsByTagName("option"), i = 0, l = options.length; i < l; i++)
{
if (options[i].selected) result.push(options[i].value);
}
return result;
}
return form2js;
}));

View File

@ -0,0 +1,2 @@
/* https://github.com/maxatwork/form2js */
(function(a,b){if(typeof exports!=="undefined"&&typeof module!=="undefined"&&module.exports){module.exports=b()}else{if(typeof define==="function"&&define.amd){define(b)}else{a.form2js=b()}}}(this,function(){function e(m,k,j,q,l,r){r=r?true:false;if(typeof j=="undefined"||j==null){j=true}if(typeof k=="undefined"||k==null){k="."}if(arguments.length<5){l=false}m=typeof m=="string"?document.getElementById(m):m;var p=[],o,n=0;if(m.constructor==Array||(typeof NodeList!="undefined"&&m.constructor==NodeList)){while(o=m[n++]){p=p.concat(d(o,q,l,r))}}else{p=d(m,q,l,r)}return b(p,j,k)}function b(s,A,C){var p={},q={},y,x,w,v,u,r,n,t,o,m,z,D,B;for(y=0;y<s.length;y++){u=s[y].value;if(A&&(u===""||u===null)){continue}D=s[y].name;B=D.split(C);r=[];n=p;t="";for(x=0;x<B.length;x++){z=B[x].split("][");if(z.length>1){for(w=0;w<z.length;w++){if(w==0){z[w]=z[w]+"]"}else{if(w==z.length-1){z[w]="["+z[w]}else{z[w]="["+z[w]+"]"}}m=z[w].match(/([a-z_]+)?\[([a-z_][a-z0-9_]+?)\]/i);if(m){for(v=1;v<m.length;v++){if(m[v]){r.push(m[v])}}}else{r.push(z[w])}}}else{r=r.concat(z)}}for(x=0;x<r.length;x++){z=r[x];if(z.indexOf("[]")>-1&&x==r.length-1){o=z.substr(0,z.indexOf("["));t+=o;if(!n[o]){n[o]=[]}n[o].push(u)}else{if(z.indexOf("[")>-1){o=z.substr(0,z.indexOf("["));m=z.replace(/(^([a-z_]+)?\[)|(\]$)/gi,"");t+="_"+o+"_"+m;if(!q[t]){q[t]={}}if(o!=""&&!n[o]){n[o]=[]}if(x==r.length-1){if(o==""){n.push(u);q[t][m]=n[n.length-1]}else{n[o].push(u);q[t][m]=n[o][n[o].length-1]}}else{if(!q[t][m]){if((/^[0-9a-z_]+\[?/i).test(r[x+1])){n[o].push({})}else{n[o].push([])}q[t][m]=n[o][n[o].length-1]}}n=q[t][m]}else{t+=z;if(x<r.length-1){if(!n[z]){n[z]={}}n=n[z]}else{n[z]=u}}}}}return p}function d(l,k,m,j){var i=a(l,k,m,j);return i.length>0?i:g(l,k,m,j)}function g(l,k,n,j){var i=[],m=l.firstChild;while(m){i=i.concat(a(m,k,n,j));m=m.nextSibling}return i}function a(m,k,o,j){if(m.disabled&&!j){return[]}var l,n,i,p=f(m,o);l=k&&k(m);if(l&&l.name){i=[l]}else{if(p!=""&&m.nodeName.match(/INPUT|TEXTAREA/i)){n=c(m,j);if(null===n){i=[]}else{i=[{name:p,value:n}]}}else{if(p!=""&&m.nodeName.match(/SELECT/i)){n=c(m,j);i=[{name:p.replace(/\[\]$/,""),value:n}]}else{i=g(m,k,o,j)}}}return i}function f(i,j){if(i.name&&i.name!=""){return i.name}else{if(j&&i.id&&i.id!=""){return i.id}else{return""}}}function c(j,i){if(j.disabled&&!i){return null}switch(j.nodeName){case"INPUT":case"TEXTAREA":switch(j.type.toLowerCase()){case"radio":if(j.checked&&j.value==="false"){return false}case"checkbox":if(j.checked&&j.value==="true"){return true}if(!j.checked&&j.value==="true"){return false}if(j.checked){return j.value}break;case"button":case"reset":case"submit":case"image":return"";break;default:return j.value;break}break;case"SELECT":return h(j);break;default:break}return null}function h(o){var k=o.multiple,j=[],n,p,m;if(!k){return o.value}for(n=o.getElementsByTagName("option"),p=0,m=n.length;p<m;p++){if(n[p].selected){j.push(n[p].value)}}return j}return e}));

View File

@ -1,96 +1,114 @@
<!DOCTYPE html>
<html>
<head>
<title>{{.Name}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Roboto:400,500' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="{{ .Config.BaseURL }}/_filemanagerinternal/css/styles.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.3/ace.js"></script>
<script src="{{ .Config.BaseURL }}/_filemanagerinternal/js/form-to-json.js"></script>
<script src="{{ .Config.BaseURL }}/_filemanagerinternal/js/application.js"></script>
{{ if ne .Config.StyleSheet "" }}<style>{{.Config.StyleSheet}}</style>{{ end }}
</head>
<body>
<header>
<div>
{{ $lnk := .PreviousLink }}
{{ if ne $lnk ""}}<a href="{{ $lnk }}">{{ end }}
<div class="action{{ if eq $lnk ""}} disabled{{ end }}" id="prev">
<i class="material-icons">subdirectory_arrow_left</i>
</div>
{{ if ne $lnk ""}}</a>{{ end }}
<head>
<title>{{.Name}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Roboto:400,500' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="{{ .Config.BaseURL }}/_filemanagerinternal/css/styles.css">
<p>
<a href="{{ if eq .Config.BaseURL "" }}/{{ else }}{{ .Config.BaseURL }}{{ end }}">
{{ if .Config.HugoEnabled }}Hugo{{ else }}File Manager{{ end }}
</a>
{{ if ne .Name "/"}}<i class="material-icons">chevron_right</i>{{ .Name }}
</p>
{{ end }}
{{ if ne .Config.StyleSheet "" }}
<style>
{{.Config.StyleSheet}}
</style>
{{ end }}
</head>
<body>
<header>
<div>
{{ $lnk := .PreviousLink }}
{{ if ne $lnk ""}}
<a href="{{ $lnk }}">
{{ end }}
<div class="action{{ if eq $lnk " "}} disabled{{ end }}" id="prev">
<i class="material-icons">subdirectory_arrow_left</i>
</div>
{{ if ne $lnk ""}}
</a>
{{ end }}
<p>
<a href="{{ if eq .Config.BaseURL " " }}/{{ else }}{{ .Config.BaseURL }}{{ end }}">
{{ if .Config.HugoEnabled }}Hugo{{ else }}File Manager{{ end }}
</a>
{{ if ne .Name "/"}}
<i class="material-icons">chevron_right</i>{{ .Name }}
</p>
{{ end }}
</div>
<div>
{{ if .IsDir}}
<!--
<form>
<i class="material-icons">search</i>
<input type="text" placeholder="Search or command">
</form>
-->
<div class="action" id="view">
<i class="material-icons">view_headline</i>
</div>
<div class="action" id="upload">
<i class="material-icons">file_upload</i>
</div>
{{ else }}
{{ template "actions" . }}
{{ end }}
{{ if .Config.HugoEnabled }}
<a href="{{ .Config.BaseURL }}/settings">
<div class="action">
<i class="material-icons">settings</i>
</div>
</a>
{{ end }}
<div class="action" id="logout">
<i class="material-icons">exit_to_app</i>
</div>
</div>
</header>
{{ if .IsDir }}
<div id="toolbar">
<div>
{{ if .IsDir}}
<!-- <form>
<i class="material-icons">search</i>
<input type="text" placeholder="Search or command">
</form> -->
<div class="action" id="view">
<i class="material-icons">view_headline</i>
</div>
<div class="action" id="upload">
<i class="material-icons">file_upload</i>
</div>
{{ else }}
{{ template "actions" . }}
{{ end }}
{{ if .Config.HugoEnabled }}
<a href="{{ .Config.BaseURL }}/settings">
<div class="action">
<i class="material-icons">settings</i>
</div>
</a>
{{ end }}
<div class="action" id="logout">
<i class="material-icons">exit_to_app</i>
</div>
</div>
</header>
{{ if .IsDir }}
<div id="toolbar">
<div>
<div class="action" id="back">
<i class="material-icons">arrow_back</i>
</div>
<p><span id="selected-number">0</span> selected.</p>
<div class="action" id="back">
<i class="material-icons">arrow_back</i>
</div>
<p>
<span id="selected-number">0</span>
selected.</p>
</div>
<div>
{{ template "actions" . }}
{{ template "actions" . }}
</div>
</div>
{{ end }}
</div>
{{ end }}
<main>
{{ template "content" .Data }}
</main>
<main>
{{ template "content" .Data }}
</main>
{{ if .IsDir }}
<div class="floating">
{{ if .IsDir }}
<div class="floating">
<div class="action" id="newfolder">
<i class="material-icons">add</i>
<i class="material-icons">add</i>
</div>
</div>
{{ end }}
</div>
{{ end }}
<footer>
Served with <a rel="noopener noreferrer" href="https://caddyserver.com">Caddy</a> and
<a rel="noopener noreferrer" href="https://github.com/hacdias/caddy-filemanager">File Manager</a>.
{{ if .Config.HugoEnabled }}With a flavour of
<a rel="noopener noreferrer" href="https://github.com/hacdias/caddy-filemanager">Hugo</a>.{{ end }}
</footer>
</body>
<footer>
Served with
<a rel="noopener noreferrer" href="https://caddyserver.com">Caddy</a>
and
<a rel="noopener noreferrer" href="https://github.com/hacdias/caddy-filemanager">File Manager</a>.
{{ if .Config.HugoEnabled }}With a flavour of
<a rel="noopener noreferrer" href="https://github.com/hacdias/caddy-filemanager">Hugo</a>.{{ end }}
</footer>
<!-- SCRIPTS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.3/ace.js"></script>
<script src="{{ .Config.BaseURL }}/_filemanagerinternal/js/form2js.js"></script>
<script src="{{ .Config.BaseURL }}/_filemanagerinternal/js/application.js"></script>
</body>
</html>

View File

@ -1,26 +1,32 @@
{{ define "content" }}
<div id="editor" class="container" data-kind="{{ .Class }}">
<form method="POST" action="./">
{{ if or (eq .Class "frontmatter-only") (eq .Class "complete") }}
<div class="frontmatter" data-type="parent">
{{ template "blocks" .FrontMatter }}
<div class="button add">Add field</div>
</div>
{{ end }}
<div id="editor" class="container" data-kind="{{ .Class }}">
<form method="POST" action="./">
{{ if or (eq .Class "frontmatter-only") (eq .Class "complete") }}
<div class="frontmatter" data-type="parent">
{{ template "blocks" .FrontMatter }}
<div class="button add">Add field</div>
</div>
{{ end }}
{{ if or (eq .Class "content-only") (eq .Class "complete") }}
{{ if or (eq .Class "content-only") (eq .Class "complete") }}
{{ if (eq .Class "complete")}}<h3>Body</h3>{{ end }}
<div class="content">
<div id="editor-source" data-mode="{{ .Mode }}"></div>
<textarea name="content">{{ .Content }}</textarea>
</div>
{{ end }}
{{ if (eq .Class "complete")}}
<h3>Body</h3>
{{ end }}
<div class="content">
<div id="editor-source" data-mode="{{ .Mode }}"></div>
<textarea name="content">{{ .Content }}</textarea>
</div>
{{ end }}
<div>
<button id="submit" type="submit" data-type="{{ .Class }}"><span><i class="material-icons">save</i></span> <span>save</span>
</button>
</div>
</form>
</div>
<div>
<button id="submit" type="submit" data-type="{{ .Class }}">
<span>
<i class="material-icons">save</i>
</span>
<span>save</span>
</button>
</div>
</form>
</div>
{{ end }}

View File

@ -1,55 +1,60 @@
{{ define "blocks" }}
{{ if .Fields }}<div class="group">{{ end }}
{{ range $key, $value := .Fields }}
{{ if eq $value.Parent.Type "array" }}
<div id="{{ $value.Name }}-{{ $key }}" data-type="array-item">
{{ template "value" $value }}
<div class="action delete" data-delete="{{ $value.Name }}-{{ $key }}">
<i class="material-icons">close</i>
</div>
</div>
{{ else }}
<div class="block" id="block-{{ $value.Name }}" data-content="{{ $value.Name }}">
<label for="{{ $value.Name }}">{{ SplitCapitalize $value.Title }}</label>
{{ template "value" $value }}
<div class="action delete" data-delete="block-{{ $value.Name }}">
<i class="material-icons">close</i>
</div>
</div>
{{ end }}
{{ end }}
{{ if .Fields }}</div>{{ end }}
{{ if .Fields }}
<div class="group">
{{ end }}
{{ range $key, $value := .Fields }}
{{ if eq $value.Parent.Type "array" }}
<div id="{{ $value.Name }}-{{ $key }}" data-type="array-item">
{{ template "value" $value }}
<div class="action delete" data-delete="{{ $value.Name }}-{{ $key }}">
<i class="material-icons">close</i>
</div>
</div>
{{ else }}
<div class="block" id="block-{{ $value.Name }}" data-content="{{ $value.Name }}">
<label for="{{ $value.Name }}">{{ SplitCapitalize $value.Title }}</label>
{{ template "value" $value }}
<div class="action delete" data-delete="block-{{ $value.Name }}">
<i class="material-icons">close</i>
</div>
</div>
{{ end }}
{{ end }}
{{ if .Fields }}
</div>
{{ end }}
{{ range $key, $value := .Arrays }}
{{ template "fielset" $value }}
{{ end }}
{{ range $key, $value := .Arrays }}
{{ template "fielset" $value }}
{{ end }}
{{ range $key, $value := .Objects }}
{{ template "fielset" $value }}
{{ end }}
{{ range $key, $value := .Objects }}
{{ template "fielset" $value }}
{{ end }}
{{ end }}
{{ define "value" }}
{{ if eq .HTMLType "textarea" }}
<textarea class="scroll" name="{{ .Name }}" id="{{.Name }}" data-parent-type="{{ .Parent.Type }}">{{ .Content.Other }}</textarea>
{{ else if eq .HTMLType "datetime" }}
<input name="{{ .Name }}" id="{{ .Name }}" value="{{ .Content.Other.Format "2006-01-02T15:04" }}" type="datetime-local" data-parent-type="{{ .Parent.Type }}"></input>
{{ else }}
<input name="{{ .Name }}" id="{{ .Name }}" value="{{ .Content.Other }}" type="{{ .HTMLType }}" data-parent-type="{{ .Parent.Type }}"></input>
{{ if eq .HTMLType "textarea" }}
<textarea class="scroll" name="{{ .Name }}" id="{{.Name }}" data-parent-type="{{ .Parent.Type }}">{{ .Content.Other }}</textarea>
{{ else if eq .HTMLType "datetime" }}
<input name="{{ .Name }}" id="{{ .Name }}" value="{{ .Content.Other.Format " 2006-01-02T15:04" }}" type="datetime-local" data-parent-type="{{ .Parent.Type }}"></input>
{{ else }}
<input name="{{ .Name }}" id="{{ .Name }}" value="{{ .Content.Other }}" type="{{ .HTMLType }}" data-parent-type="{{ .Parent.Type }}"></input>
{{ end }}
{{ end }}
{{ end }}
{{ define "fielset" }}
<fieldset id="{{ .Name }}" data-type="{{ .Type }}">
{{ if not (eq .Title "") }}<h3>{{ SplitCapitalize .Title }}</h3>{{ end }}
<fieldset id="{{ .Name }}" data-type="{{ .Type }}">
{{ if not (eq .Title "") }}
<h3>{{ SplitCapitalize .Title }}</h3>
{{ end }}
<div class="action add">
<i class="material-icons">add</i>
<i class="material-icons">add</i>
</div>
<div class="action delete" data-delete="{{ .Name }}">
<i class="material-icons">close</i>
<i class="material-icons">close</i>
</div>
{{ template "blocks" .Content }}
</fieldset>
{{ template "blocks" .Content }}
</fieldset>
{{ end }}

View File

@ -25,11 +25,10 @@
</p>
</a>
</div>
<span class="checkbox">
<span class="checkbox"></div>
{{- end}}
</div>
{{- end}}
</div>
</div>
<input style="display:none" type="file" id="upload-input" onchange="handleFiles(this.files)" value="Upload" multiple>
{{ end }}
<input style="display:none" type="file" id="upload-input" onchange="handleFiles(this.files)" value="Upload" multiple>
{{ end }}

View File

@ -1,8 +1,9 @@
// Code generated by go-bindata.
// sources:
// assets/.jsbeautifyrc
// assets/public/css/styles.css
// assets/public/js/application.js
// assets/public/js/form-to-json.js
// assets/public/js/form2js.js
// assets/templates/actions.tmpl
// assets/templates/base.tmpl
// assets/templates/editor.tmpl
@ -35,6 +36,24 @@ type asset struct {
info os.FileInfo
}
// Jsbeautifyrc reads file data from disk. It returns an error on failure.
func Jsbeautifyrc() (*asset, error) {
path := "D:\\Code\\Go\\src\\github.com\\hacdias\\caddy-filemanager\\assets\\.jsbeautifyrc"
name := ".jsbeautifyrc"
bytes, err := bindataRead(path, name)
if err != nil {
return nil, err
}
fi, err := os.Stat(path)
if err != nil {
err = fmt.Errorf("Error reading asset info %s at %s: %v", name, path, err)
}
a := &asset{bytes: bytes, info: fi}
return a, err
}
// publicCssStylesCss reads file data from disk. It returns an error on failure.
func publicCssStylesCss() (*asset, error) {
path := "D:\\Code\\Go\\src\\github.com\\hacdias\\caddy-filemanager\\assets\\public\\css\\styles.css"
@ -71,10 +90,10 @@ func publicJsApplicationJs() (*asset, error) {
return a, err
}
// publicJsFormToJsonJs reads file data from disk. It returns an error on failure.
func publicJsFormToJsonJs() (*asset, error) {
path := "D:\\Code\\Go\\src\\github.com\\hacdias\\caddy-filemanager\\assets\\public\\js\\form-to-json.js"
name := "public/js/form-to-json.js"
// publicJsForm2jsJs reads file data from disk. It returns an error on failure.
func publicJsForm2jsJs() (*asset, error) {
path := "D:\\Code\\Go\\src\\github.com\\hacdias\\caddy-filemanager\\assets\\public\\js\\form2js.js"
name := "public/js/form2js.js"
bytes, err := bindataRead(path, name)
if err != nil {
return nil, err
@ -249,9 +268,10 @@ func AssetNames() []string {
// _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string]func() (*asset, error){
".jsbeautifyrc": Jsbeautifyrc,
"public/css/styles.css": publicCssStylesCss,
"public/js/application.js": publicJsApplicationJs,
"public/js/form-to-json.js": publicJsFormToJsonJs,
"public/js/form2js.js": publicJsForm2jsJs,
"templates/actions.tmpl": templatesActionsTmpl,
"templates/base.tmpl": templatesBaseTmpl,
"templates/editor.tmpl": templatesEditorTmpl,
@ -300,13 +320,14 @@ type bintree struct {
Children map[string]*bintree
}
var _bintree = &bintree{nil, map[string]*bintree{
".jsbeautifyrc": &bintree{Jsbeautifyrc, map[string]*bintree{}},
"public": &bintree{nil, map[string]*bintree{
"css": &bintree{nil, map[string]*bintree{
"styles.css": &bintree{publicCssStylesCss, map[string]*bintree{}},
}},
"js": &bintree{nil, map[string]*bintree{
"application.js": &bintree{publicJsApplicationJs, map[string]*bintree{}},
"form-to-json.js": &bintree{publicJsFormToJsonJs, map[string]*bintree{}},
"form2js.js": &bintree{publicJsForm2jsJs, map[string]*bintree{}},
}},
}},
"templates": &bintree{nil, map[string]*bintree{