Add basic live editing for admin

This commit is contained in:
Timothy Warren 2016-02-25 20:54:23 -05:00
parent e57d02f5af
commit 2b4cd0c3a6
10 changed files with 1109 additions and 616 deletions

View File

@ -3,7 +3,10 @@
module.exports = { module.exports = {
'/': { '/': {
get: (req, res) => { get: (req, res) => {
res.render('admin-edit', {
title: 'Edit page',
theme: 'github-gist',
});
}, },
}, },

View File

@ -0,0 +1,76 @@
<header class="w930">
<div class="heading">
<a href="/admin"><span class="title">Blog Admin</span></a>
</div>
</header>
<main class="w930 admin">
<section>
<section class="grid grid-no-wrap grid-fit">
<div class="cell cell-1of2 edit-left">
<textarea name="post_content" id="post_content">
# Article Title
Feb 18, 2016
---
Headers
# Level 1
## Level 2
### Level 3
#### Level 4
##### Level 5
###### Level 6
---
Here are some random code examples:
HTML is always fun to look at, right?
```HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Some Random Title</title>
</head>
<body></body>
</html>
```
Javascript has several ways of making a self-executing function.
```javascript
// ES5 IIFE
(function() {
var x = 'foo';
}());
// ES5 Alternate IIFE
(function() {
var y = 'bar';
})();
// ES6 IIFE
(() => {
let x = 'foo';
const y = 'bar';
})();
```
</textarea>
</div>
<div class="cell cell-1of2 edit-right" id="preview">
</div>
</section>
</section>
<footer>
<p>&copy; Timothy J. Warren</p>
</footer>
</main>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js"></script>
<script src="/assets/js/lib/autosize.min.js"></script>
<script src="/assets/js/lib/markdown-it.min.js"></script>
<script src="/assets/js/admin.js"></script>

View File

@ -130,8 +130,5 @@ section {
</main> </main>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js"></script>
<script> <script>
hljs.configure({
tabReplace: ' '
});
hljs.initHighlightingOnLoad(); hljs.initHighlightingOnLoad();
</script> </script>

View File

@ -19,7 +19,8 @@
"highlight.js": "^9.1.0", "highlight.js": "^9.1.0",
"knex": "^0.10.0", "knex": "^0.10.0",
"lodash": "^4.5.0", "lodash": "^4.5.0",
"marked": "^0.3.5", "markdown-it": "^6.0.0",
"moment": "^2.11.2",
"morgan": "~1.6.1", "morgan": "~1.6.1",
"nodemon": "^1.9.0", "nodemon": "^1.9.0",
"scrypt": "^6.0.1", "scrypt": "^6.0.1",

View File

@ -1,6 +1,6 @@
:root { :root {
background: whitesmoke; background: whitesmoke;
font-family: 'Slabo 27px', serif; font-family: 'PT Serif', serif;
box-sizing: border-box; box-sizing: border-box;
cursor: default; cursor: default;
line-height: 1.4; line-height: 1.4;
@ -12,9 +12,297 @@
text-size-adjust: 100%; text-size-adjust: 100%;
} }
/* * {
*! Flexbox grid -moz-tab-size: 4;
*/ -o-tab-size: 4;
tab-size: 4;
}
/*! Basic element styles*/
html {
font-size: 62.5%;
}
body {
font-size: 1.6em;
padding: 0;
color: #444;
font-style: normal;
font-weight: 400;
}
a {
color: #1271db;
-webkit-transition: .25s ease;
transition: .25s ease;
}
a,
a:focus,
a:hover {
text-decoration: none;
}
blockquote,
pre {
margin: 1.6rem 0;
}
blockquote,
figcaption {
font-family: serif;
}
article,
aside,
dl,
hr,
section {
margin-bottom: 1.6rem;
}
footer,
hr {
border-top: .1rem solid rgba(0, 0, 0, .2);
}
footer,
img,
section {
max-width: 100%;
}
img,
select[multiple] {
height: auto;
}
hr {
width: 100%;
}
pre,
textarea {
overflow: auto;
}
legend,
ol,
textarea,
ul {
margin-bottom: .8rem;
}
::after,
::before,
td,
th {
vertical-align: inherit;
}
footer,
nav ul,
td,
th {
text-align: center;
}
[hidden],
audio:not([controls]),
template {
display: none;
}
small {
font-size: 75%;
color: #777;
}
big {
font-size: 125%;
}
[unselectable] {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
[unselectable],
button,
input[type=submit] {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
::after,
::before {
text-decoration: inherit;
}
code,
kbd,
pre,
samp {
font-family: 'Anonymous Pro', Menlo, Monaco, Consolas, 'Courier New', monospace;
}
pre {
/*box-shadow:rgba(0,0,0,0.1) 0 0 5px;*/
padding: 0.25em;
}
code,
pre {
font-family: 'Anonymous Pro', Menlo, Monaco, Consolas, 'Courier New', monospace;
word-break: break-all;
word-wrap: break-word;
overflow-x: auto;
}
::-moz-selection {
background-color: #b3d4fc;
text-shadow: none;
}
::selection {
background-color: #b3d4fc;
text-shadow: none;
}
button::-moz-focus-inner {
border: 0;
}
p {
margin: 0 0 1.6rem;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'PT Serif', serif;
margin: 0.5em 0;
}
h1 {
font-size: 1.75em;
margin-top: 0;
font-style: normal;
}
dd {
margin-left: 4rem;
}
ol,
ul {
padding-left: 2rem;
}
blockquote {
border-left: .2rem solid #1271db;
font-style: italic;
padding-left: 1.6rem;
}
article,
aside,
details,
footer,
header,
main,
section,
summary {
display: block;
height: auto;
margin: 0 auto;
width: 100%;
}
main {
margin: 0 auto;
max-width: 76.8em;
padding: 0 1.6rem 1.6rem;
}
footer {
padding: 1rem 0;
}
nav ul {
list-style: none;
margin: 0.5em auto;
}
nav a,
td,
th {
padding: .8rem 1.6rem;
}
nav ul li {
display: inline;
}
nav a {
border-bottom: .2rem solid transparent;
color: #444;
-webkit-transition: .25s ease;
transition: .25s ease;
}
nav a:hover {
border-color: rgba(0, 0, 0, .2);
}
nav a:active {
border-color: rgba(0, 0, 0, .56);
}
table {
border-collapse: collapse;
border-spacing: 0;
margin-bottom: 1.6rem;
}
caption {
padding: .8rem 0;
}
thead th {
background: #efefef;
color: #444;
}
tr {
background: #fff;
margin-bottom: .8rem;
}
td,
th {
border: .1rem solid #ccc;
}
tfoot tr {
background: 0 0;
}
tfoot td {
color: #efefef;
font-size: .8em;
font-style: italic;
padding: 1.6rem .4rem;
}
/*! Flexbox grid */
section { section {
-webkit-box-flex: 0; -webkit-box-flex: 0;
@ -39,6 +327,12 @@ section {
padding: 0; padding: 0;
} }
.grid-no-wrap {
-webkit-flex-wrap: nowrap !important;
-ms-flex-wrap: nowrap !important;
flex-wrap: nowrap !important;
}
.grid-top { .grid-top {
-webkit-box-align: start; -webkit-box-align: start;
-webkit-align-items: flex-start; -webkit-align-items: flex-start;
@ -187,370 +481,7 @@ section {
padding: 2em 0 0 2em; padding: 2em 0 0 2em;
} }
/* /*! Misc layout styles*/
*! Basic element styles
*/
h1,
h2,
h3 {
font-weight: 500;
}
body,
h5 {
font-size: 1.6rem;
}
h4,
h5,
h6 {
font-weight: 600;
}
a,
a:focus,
a:hover {
text-decoration: none;
}
blockquote,
pre {
margin: 1.6rem 0;
}
blockquote,
figcaption {
font-family: serif;
}
article,
aside,
dl,
hr,
section {
margin-bottom: 1.6rem;
}
footer,
hr {
border-top: .1rem solid rgba(0, 0, 0, .2);
}
footer,
img,
section {
max-width: 100%;
}
img,
select[multiple] {
height: auto;
}
hr {
width: 100%;
}
audio,
canvas,
iframe,
img,
input[type=radio],
input[type=checkbox],
svg,
textarea,
video {
vertical-align: middle;
}
pre,
textarea {
overflow: auto;
}
legend,
ol,
textarea,
ul {
margin-bottom: .8rem;
}
body {
padding: 0;
}
::after,
::before,
td,
th {
vertical-align: inherit;
}
footer,
nav ul,
td,
th {
text-align: center;
}
[hidden],
audio:not([controls]),
template {
display: none;
}
small {
font-size: 75%;
color: #777;
}
big {
font-size: 125%;
}
[unselectable] {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
[unselectable],
button,
input[type=submit] {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
::after,
::before {
text-decoration: inherit;
}
a {
color: #1271db;
-webkit-transition: .25s ease;
transition: .25s ease;
}
code,
kbd,
pre,
samp {
font-family: 'Anonymous Pro', Menlo, Monaco, Consolas, 'Courier New', monospace;
}
pre {
box-shadow: rgba(0,0,0,0.1) 0 0 5px;
}
code,
pre {
color: #444;
background: #efefef;
font-family: 'Anonymous Pro', Menlo, Monaco, Consolas, 'Courier New', monospace;
font-size: 1.4rem;
word-break: break-all;
word-wrap: break-word;
overflow-x: auto;
}
::-moz-selection {
background-color: #b3d4fc;
text-shadow: none;
}
::selection {
background-color: #b3d4fc;
text-shadow: none;
}
button::-moz-focus-inner {
border: 0;
}
hr,
legend,
main,
pre,
textarea {
display: block;
}
body {
color: #444;
font-style: normal;
font-weight: 400;
}
p {
margin: 0 0 1.6rem;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'PT Serif', serif;
margin-start: 0;
margin-end: 0;
margin-before: 0.67em;
margin-after: 0.67em;
/*margin: 2rem 0 1.6rem*/
}
h3,
h4,
h5,
h6 {
font-style: normal;
margin: 1.6rem 0 .4rem;
}
h1 {
border-bottom: .1rem solid rgba(0, 0, 0, .2);
font-size: 3.6rem;
font-style: normal;
}
h2 {
font-size: 3rem;
font-style: normal;
}
h3 {
font-size: 2.4rem;
}
h4 {
font-size: 1.8rem;
}
h6 {
color: #777;
font-size: 1.4rem;
}
pre {
padding: 0;
}
dd {
margin-left: 4rem;
}
ol,
ul {
padding-left: 2rem;
}
blockquote {
border-left: .2rem solid #1271db;
font-style: italic;
padding-left: 1.6rem;
}
html {
font-size: 62.5%;
}
article,
aside,
details,
footer,
header,
main,
section,
summary {
display: block;
height: auto;
margin: 0 auto;
width: 100%;
}
main {
margin: 0 auto;
max-width: 76.8rem;
padding: 0 1.6rem 1.6rem;
}
footer {
padding: 1rem 0;
}
nav ul {
list-style: none;
margin: 0.5em auto;
}
nav a,
td,
th {
padding: .8rem 1.6rem;
}
nav ul li {
display: inline;
}
nav a {
border-bottom: .2rem solid transparent;
color: #444;
-webkit-transition: .25s ease;
transition: .25s ease;
}
nav a:hover {
border-color: rgba(0, 0, 0, .2);
}
nav a:active {
border-color: rgba(0, 0, 0, .56);
}
table {
border-collapse: collapse;
border-spacing: 0;
margin-bottom: 1.6rem;
}
caption {
padding: .8rem 0;
}
thead th {
background: #efefef;
color: #444;
}
tr {
background: #fff;
margin-bottom: .8rem;
}
td,
th {
border: .1rem solid #ccc;
}
tfoot tr {
background: 0 0;
}
tfoot td {
color: #efefef;
font-size: .8rem;
font-style: italic;
padding: 1.6rem .4rem;
}
/*
*! Misc layout styles
*/
.no-top-margin { .no-top-margin {
margin-top: 0 !important; margin-top: 0 !important;
@ -560,6 +491,14 @@ tfoot td {
padding-top: 0 !important; padding-top: 0 !important;
} }
.margin5 {
margin: 0.5em;
}
.padding5 {
padding: 0.5em;
}
.pagebody { .pagebody {
background: #fff; background: #fff;
min-height: 100%; min-height: 100%;
@ -643,6 +582,27 @@ tfoot td {
padding-bottom: 6px; padding-bottom: 6px;
} }
/*! Admin Styles*/
.admin textarea {
font-family: 'Anonymous Pro', Menlo, Monaco, Consolas, 'Courier New', monospace;
font-size: 1em;
box-sizing: border-box;
width: 100%;
min-height: 15em;
border: none;
padding: 0;
overflow: hidden;
resize: none;
}
.admin .edit-left,
.admin .edit-right {
background: #fff;
padding: 0.5em;
box-shadow: rgba(0,0,0,0.1) 0 0 5px;
}
@media (min-width:12em) { @media (min-width:12em) {
.small-Grid--gutters { .small-Grid--gutters {
margin: -1em 0 1em -1em; margin: -1em 0 1em -1em;

View File

@ -1,7 +1,7 @@
:root { :root {
--code-fonts: 'Anonymous Pro', Menlo, Monaco, Consolas, 'Courier New', monospace; --code-fonts: 'Anonymous Pro', Menlo, Monaco, Consolas, 'Courier New', monospace;
--body-font: 'Slabo 27px', serif;
--header-fonts: 'PT Serif', serif; --header-fonts: 'PT Serif', serif;
--body-font: 'PT Serif', serif;
background:whitesmoke; background:whitesmoke;
font-family: var(--body-font); font-family: var(--body-font);
box-sizing: border-box; box-sizing: border-box;
@ -13,9 +13,198 @@
text-size-adjust: 100% text-size-adjust: 100%
} }
/* * {
*! Flexbox grid tab-size:4;
*/ }
/*! Basic element styles*/
html {
font-size: 62.5%
}
body {
font-size: 1.6em;
padding: 0;
color: #444;
font-style: normal;
font-weight: 400;
}
a {
color: #1271db;
transition: .25s ease
}
a, a:focus, a:hover {
text-decoration: none
}
blockquote, pre {
margin: 1.6rem 0
}
blockquote, figcaption {
font-family: serif
}
article, aside, dl, hr, section {
margin-bottom: 1.6rem
}
footer, hr {
border-top: .1rem solid rgba(0, 0, 0, .2)
}
footer, img, section {
max-width: 100%
}
img, select[multiple] {
height: auto
}
hr {
width: 100%
}
pre, textarea {
overflow: auto
}
legend, ol, textarea, ul {
margin-bottom: .8rem
}
::after, ::before, td, th {
vertical-align: inherit
}
footer, nav ul, td, th {
text-align: center
}
[hidden], audio:not([controls]), template {
display: none
}
small {
font-size: 75%;
color: #777
}
big {
font-size: 125%
}
[unselectable] {
user-select: none
}
[unselectable], button, input[type=submit] {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none
}
::after, ::before {
text-decoration: inherit
}
code, kbd, pre, samp {
font-family: var(--code-fonts);
}
pre {
/*box-shadow:rgba(0,0,0,0.1) 0 0 5px;*/
padding:0.25em;
}
code, pre {
font-family: var(--code-fonts);
word-break: break-all;
word-wrap: break-word;
overflow-x: auto;
}
::-moz-selection {
background-color: #b3d4fc;
text-shadow: none
}
::selection {
background-color: #b3d4fc;
text-shadow: none
}
button::-moz-focus-inner {
border: 0
}
p {
margin: 0 0 1.6rem
}
h1, h2, h3, h4, h5, h6 {
font-family: var(--header-fonts);
margin:0.5em 0;
}
h1 {
font-size: 1.75em;
margin-top:0;
font-style: normal
}
dd {
margin-left: 4rem
}
ol, ul {
padding-left: 2rem
}
blockquote {
border-left: .2rem solid #1271db;
font-style: italic;
padding-left: 1.6rem
}
article, aside, details, footer, header, main, section, summary {
display: block;
height: auto;
margin: 0 auto;
width: 100%
}
main {
margin: 0 auto;
max-width: 76.8em;
padding: 0 1.6rem 1.6rem
}
footer {
padding: 1rem 0
}
nav ul {
list-style: none;
margin: 0.5em auto;
}
nav a, td, th {
padding: .8rem 1.6rem
}
nav ul li {
display: inline
}
nav a {
border-bottom: .2rem solid transparent;
color: #444;
transition: .25s ease
}
nav a:hover {
border-color: rgba(0, 0, 0, .2)
}
nav a:active {
border-color: rgba(0, 0, 0, .56)
}
table {
border-collapse: collapse;
border-spacing: 0;
margin-bottom: 1.6rem
}
caption {
padding: .8rem 0
}
thead th {
background: #efefef;
color: #444
}
tr {
background: #fff;
margin-bottom: .8rem
}
td, th {
border: .1rem solid #ccc
}
tfoot tr {
background: 0 0
}
tfoot td {
color: #efefef;
font-size: .8em;
font-style: italic;
padding: 1.6rem .4rem
}
/*! Flexbox grid */
section { section {
flex: 0; flex: 0;
} }
@ -31,6 +220,10 @@ section {
padding:0; padding:0;
} }
.grid-no-wrap {
flex-wrap: nowrap !important;
}
.grid-top {align-items:flex-start} .grid-top {align-items:flex-start}
.grid-bottom {align-items:flex-end} .grid-bottom {align-items:flex-end}
.grid-center {align-items:center} .grid-center {align-items:center}
@ -88,245 +281,11 @@ section {
padding: 2em 0 0 2em; padding: 2em 0 0 2em;
} }
/* /*! Misc layout styles*/
*! Basic element styles
*/
h1, h2, h3 {
font-weight: 500
}
body, h5 {
font-size: 1.6rem
}
h4, h5, h6 {
font-weight: 600
}
a, a:focus, a:hover {
text-decoration: none
}
blockquote, pre {
margin: 1.6rem 0
}
blockquote, figcaption {
font-family: serif
}
article, aside, dl, hr, section {
margin-bottom: 1.6rem
}
footer, hr {
border-top: .1rem solid rgba(0, 0, 0, .2)
}
footer, img, section {
max-width: 100%
}
img, select[multiple] {
height: auto
}
hr {
width: 100%
}
audio, canvas, iframe, img, input[type=radio], input[type=checkbox], svg, textarea, video {
vertical-align: middle
}
pre, textarea {
overflow: auto
}
legend, ol, textarea, ul {
margin-bottom: .8rem
}
body {
padding: 0
}
::after, ::before, td, th {
vertical-align: inherit
}
footer, nav ul, td, th {
text-align: center
}
[hidden], audio:not([controls]), template {
display: none
}
small {
font-size: 75%;
color: #777
}
big {
font-size: 125%
}
[unselectable] {
user-select: none
}
[unselectable], button, input[type=submit] {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none
}
::after, ::before {
text-decoration: inherit
}
a {
color: #1271db;
-webkit-transition: .25s ease;
transition: .25s ease
}
code, kbd, pre, samp {
font-family: var(--code-fonts);
}
pre {
box-shadow:rgba(0,0,0,0.1) 0 0 5px;
}
code, pre {
color: #444;
background: #efefef;
font-family: var(--code-fonts);
font-size: 1.4rem;
word-break: break-all;
word-wrap: break-word;
overflow-x: auto;
}
::-moz-selection {
background-color: #b3d4fc;
text-shadow: none
}
::selection {
background-color: #b3d4fc;
text-shadow: none
}
button::-moz-focus-inner {
border: 0
}
hr, legend, main, pre, textarea {
display: block
}
body {
color: #444;
font-style: normal;
font-weight: 400
}
p {
margin: 0 0 1.6rem
}
h1, h2, h3, h4, h5, h6 {
font-family: var(--header-fonts);
margin-start:0;
margin-end:0;
margin-before:0.67em;
margin-after:0.67em;
/*margin: 2rem 0 1.6rem*/
}
h3, h4, h5, h6 {
font-style: normal;
margin: 1.6rem 0 .4rem
}
h1 {
border-bottom: .1rem solid rgba(0, 0, 0, .2);
font-size: 3.6rem;
font-style: normal
}
h2 {
font-size: 3rem;
font-style: normal
}
h3 {
font-size: 2.4rem
}
h4 {
font-size: 1.8rem
}
h6 {
color: #777;
font-size: 1.4rem
}
pre {
padding: 0
}
dd {
margin-left: 4rem
}
ol, ul {
padding-left: 2rem
}
blockquote {
border-left: .2rem solid #1271db;
font-style: italic;
padding-left: 1.6rem
}
html {
font-size: 62.5%
}
article, aside, details, footer, header, main, section, summary {
display: block;
height: auto;
margin: 0 auto;
width: 100%
}
main {
margin: 0 auto;
max-width: 76.8rem;
padding: 0 1.6rem 1.6rem
}
footer {
padding: 1rem 0
}
nav ul {
list-style: none;
margin: 0.5em auto;
}
nav a, td, th {
padding: .8rem 1.6rem
}
nav ul li {
display: inline
}
nav a {
border-bottom: .2rem solid transparent;
color: #444;
transition: .25s ease
}
nav a:hover {
border-color: rgba(0, 0, 0, .2)
}
nav a:active {
border-color: rgba(0, 0, 0, .56)
}
table {
border-collapse: collapse;
border-spacing: 0;
margin-bottom: 1.6rem
}
caption {
padding: .8rem 0
}
thead th {
background: #efefef;
color: #444
}
tr {
background: #fff;
margin-bottom: .8rem
}
td, th {
border: .1rem solid #ccc
}
tfoot tr {
background: 0 0
}
tfoot td {
color: #efefef;
font-size: .8rem;
font-style: italic;
padding: 1.6rem .4rem
}
/*
*! Misc layout styles
*/
.no-top-margin{margin-top:0 !important} .no-top-margin{margin-top:0 !important}
.no-top-padding{padding-top:0 !important} .no-top-padding{padding-top:0 !important}
.margin5 {margin:0.5em}
.padding5 {padding:0.5em}
.pagebody { .pagebody {
background:#fff; background:#fff;
@ -410,6 +369,25 @@ tfoot td {
padding-bottom:6px; padding-bottom:6px;
} }
/*! Admin Styles*/
.admin textarea {
font-family: var(--code-fonts);
font-size:1em;
box-sizing:border-box;
width:100%;
min-height:15em;
border:none;
padding:0;
overflow:hidden;
resize:none;
}
.admin .edit-left, .admin .edit-right {
background:#fff;
padding:0.5em;
box-shadow: rgba(0,0,0,0.1) 0 0 5px;
}
@media (min-width:12em) { @media (min-width:12em) {
.small-Grid--gutters { .small-Grid--gutters {
margin: -1em 0 1em -1em; margin: -1em 0 1em -1em;
@ -473,8 +451,6 @@ tfoot td {
} }
} }
@media screen { @media screen {
[hidden~=screen] { [hidden~=screen] {
display: inherit display: inherit

424
public/assets/css/normalize.css vendored Normal file
View File

@ -0,0 +1,424 @@
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
/**
* 1. Set default font family to sans-serif.
* 2. Prevent iOS and IE text size adjust after device orientation change,
* without disabling user zoom.
*/
html {
font-family: sans-serif; /* 1 */
-ms-text-size-adjust: 100%; /* 2 */
-webkit-text-size-adjust: 100%; /* 2 */
}
/**
* Remove default margin.
*/
body {
margin: 0;
}
/* HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined for any HTML5 element in IE 8/9.
* Correct `block` display not defined for `details` or `summary` in IE 10/11
* and Firefox.
* Correct `block` display not defined for `main` in IE 11.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
main,
menu,
nav,
section,
summary {
display: block;
}
/**
* 1. Correct `inline-block` display not defined in IE 8/9.
* 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
*/
audio,
canvas,
progress,
video {
display: inline-block; /* 1 */
vertical-align: baseline; /* 2 */
}
/**
* Prevent displaying `audio` without controls in Mobile Safari 4/5/6/7.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/**
* Address `[hidden]` styling not present in IE 8/9/10.
* Hide the `template` element in IE 8/9/10/11, Safari, and Firefox < 22.
*/
[hidden],
template {
display: none;
}
/* Links
========================================================================== */
/**
* Remove the gray background color from active links in IE 10.
*/
a {
background-color: transparent;
}
/**
* Improve readability of focused elements when they are also in an
* active/hover state.
*/
a:active,
a:hover {
outline: 0;
}
/* Text-level semantics
========================================================================== */
/**
* Address inconsistent styling of `abbr[title]`.
* 1. Correct styling in Firefox 39 and Opera 12.
* 2. Correct missing styling in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none; /* 1 */
text-decoration: underline; /* 2 */
text-decoration: underline dotted; /* 2 */
}
/**
* Address inconsistent styling of b and strong.
* 1. Correct duplicate application of `bolder` in Safari 6.0.2.
* 2. Correct style set to `bold` in Edge 12+, Safari 6.2+, and Chrome 18+.
*/
b,
strong {
font-weight: inherit; /* 1 */
}
b,
strong {
font-weight: bolder; /* 2 */
}
/**
* Address styling not present in Safari and Chrome.
*/
dfn {
font-style: italic;
}
/**
* Address variable `h1` font-size and margin within `section` and `article`
* contexts in Firefox 4+, Safari, and Chrome.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
/**
* Address styling not present in IE 8/9.
*/
mark {
background-color: #ff0;
color: #000;
}
/**
* Address inconsistent and variable font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` affecting `line-height` in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
/* Embedded content
========================================================================== */
/**
* Remove border when inside `a` element in IE 8/9/10.
*/
img {
border: 0;
}
/**
* Correct overflow not hidden in IE 9/10/11.
*/
svg:not(:root) {
overflow: hidden;
}
/* Grouping content
========================================================================== */
/**
* Address margin not present in IE 8/9 and Safari.
*/
figure {
margin: 1em 40px;
}
/**
* Address inconsistent styling of `hr`.
* 1. Correct `box-sizing` set to `border-box` in Firefox.
* 2. Correct `overflow` set to `hidden` in IE 8/9/10/11 and Edge 12.
*/
hr {
box-sizing: content-box; /* 1 */
height: 0; /* 1 */
overflow: visible; /* 2 */
}
/**
* Contain overflow in all browsers.
*/
pre {
overflow: auto;
}
/**
* 1. Correct inheritance and scaling of font-size for preformatted text.
* 2. Address odd `em`-unit font size rendering in all browsers.
*/
code,
kbd,
pre,
samp {
font-family: monospace, monospace; /* 1 */
font-size: 1em; /* 2 */
}
/* Forms
========================================================================== */
/**
* Known limitation: by default, Chrome and Safari on OS X allow very limited
* styling of `select`, unless a `border` property is set.
*/
/**
* 1. Correct font properties not being inherited.
* 2. Address margins set differently in Firefox 4+, Safari, and Chrome.
*/
button,
input,
optgroup,
select,
textarea {
font: inherit; /* 1 */
margin: 0; /* 2 */
}
/**
* Address `overflow` set to `hidden` in IE 8/9/10/11.
*/
button {
overflow: visible;
}
/**
* Address inconsistent `text-transform` inheritance for `button` and `select`.
* All other form control elements do not inherit `text-transform` values.
* Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
* Correct `select` style inheritance in Firefox.
*/
button,
select {
text-transform: none;
}
/**
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
* and `video` controls.
* 2. Correct inability to style clickable `input` types in iOS.
* 3. Improve usability and consistency of cursor style between image-type
* `input` and others.
*/
button,
html input[type="button"], /* 1 */
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button; /* 2 */
cursor: pointer; /* 3 */
}
/**
* Re-set default cursor for disabled elements.
*/
button[disabled],
html input[disabled] {
cursor: default;
}
/**
* Remove inner padding and border in Firefox 4+.
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/**
* Restore focus style in Firefox 4+ (unset by a rule above)
*/
button:-moz-focusring,
input:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Address Firefox 4+ setting `line-height` on `input` using `!important` in
* the UA stylesheet.
*/
input {
line-height: normal;
}
/**
* It's recommended that you don't attempt to style these elements.
* Firefox's implementation doesn't respect box-sizing, padding, or width.
*
* 1. Address box sizing set to `content-box` in IE 8/9/10.
* 2. Remove excess padding in IE 8/9/10.
*/
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box; /* 1 */
padding: 0; /* 2 */
}
/**
* Fix the cursor style for Chrome's increment/decrement buttons. For certain
* `font-size` values of the `input`, it causes the cursor style of the
* decrement button to change from `default` to `text`.
*/
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* Address `appearance` set to `searchfield` in Safari and Chrome.
*/
input[type="search"] {
-webkit-appearance: textfield;
}
/**
* Remove inner padding and search cancel button in Safari and Chrome on OS X.
* Safari (but not Chrome) clips the cancel button when the search input has
* padding (and `textfield` appearance).
*/
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* Define consistent border, margin, and padding.
*/
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em;
}
/**
* 1. Correct `color` not being inherited in IE 8/9/10/11.
* 2. Remove padding so people aren't caught out if they zero out fieldsets.
*/
legend {
border: 0; /* 1 */
padding: 0; /* 2 */
}
/**
* Remove default vertical scrollbar in IE 8/9/10/11.
*/
textarea {
overflow: auto;
}
/**
* Restore font weight (unset by a rule above).
* NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
*/
optgroup {
font-weight: bold;
}

View File

@ -0,0 +1,45 @@
(function() {
'use strict';
autosize(document.getElementsByTagName('textarea'));
var md = markdownit({
html: true,
xhtmlOut: true,
highlight: function (str, lang) {
hljs.configure({
tabReplace: ' '
});
if (lang && hljs.getLanguage(lang)) {
try {
return hljs.highlight(lang, str).value;
} catch (__) {}
}
return ''; // use external default escaping
}
});
function liveUpdate(e) {
}
document.getElementById('post_content').addEventListener('input', function(e) {
document.getElementById('preview').innerHTML = md.render(this.value);
});
document.getElementById('post_content').addEventListener('keydown', function (e) {
// Allow use of tab key for indentation
if (e.keycode == 9 || e.which == 9) {
e.preventDefault();
//e.stopPropagation();
var s = this.selectionStart;
this.value = this.value.substring(0,this.selectionStart) + "\t" + this.value.substring(this.selectionEnd);
this.selectionEnd = s+1;
}
document.getElementById('preview').innerHTML = md.render(this.value);
});
document.getElementById('preview').innerHTML = md.render(document.getElementById('post_content').value);
})();

6
public/assets/js/lib/autosize.min.js vendored Normal file
View File

@ -0,0 +1,6 @@
/*!
Autosize 3.0.15
license: MIT
http://www.jacklmoore.com/autosize
*/
!function(e,t){if("function"==typeof define&&define.amd)define(["exports","module"],t);else if("undefined"!=typeof exports&&"undefined"!=typeof module)t(exports,module);else{var n={exports:{}};t(n.exports,n),e.autosize=n.exports}}(this,function(e,t){"use strict";function n(e){function t(){var t=window.getComputedStyle(e,null);p=t.overflowY,"vertical"===t.resize?e.style.resize="none":"both"===t.resize&&(e.style.resize="horizontal"),c="content-box"===t.boxSizing?-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),isNaN(c)&&(c=0),i()}function n(t){var n=e.style.width;e.style.width="0px",e.offsetWidth,e.style.width=n,p=t,f&&(e.style.overflowY=t),o()}function o(){var t=window.pageYOffset,n=document.body.scrollTop,o=e.style.height;e.style.height="auto";var i=e.scrollHeight+c;return 0===e.scrollHeight?void(e.style.height=o):(e.style.height=i+"px",v=e.clientWidth,document.documentElement.scrollTop=t,void(document.body.scrollTop=n))}function i(){var t=e.style.height;o();var i=window.getComputedStyle(e,null);if(i.height!==e.style.height?"visible"!==p&&n("visible"):"hidden"!==p&&n("hidden"),t!==e.style.height){var r=d("autosize:resized");e.dispatchEvent(r)}}var s=void 0===arguments[1]?{}:arguments[1],a=s.setOverflowX,l=void 0===a?!0:a,u=s.setOverflowY,f=void 0===u?!0:u;if(e&&e.nodeName&&"TEXTAREA"===e.nodeName&&!r.has(e)){var c=null,p=null,v=e.clientWidth,h=function(){e.clientWidth!==v&&i()},y=function(t){window.removeEventListener("resize",h,!1),e.removeEventListener("input",i,!1),e.removeEventListener("keyup",i,!1),e.removeEventListener("autosize:destroy",y,!1),e.removeEventListener("autosize:update",i,!1),r["delete"](e),Object.keys(t).forEach(function(n){e.style[n]=t[n]})}.bind(e,{height:e.style.height,resize:e.style.resize,overflowY:e.style.overflowY,overflowX:e.style.overflowX,wordWrap:e.style.wordWrap});e.addEventListener("autosize:destroy",y,!1),"onpropertychange"in e&&"oninput"in e&&e.addEventListener("keyup",i,!1),window.addEventListener("resize",h,!1),e.addEventListener("input",i,!1),e.addEventListener("autosize:update",i,!1),r.add(e),l&&(e.style.overflowX="hidden",e.style.wordWrap="break-word"),t()}}function o(e){if(e&&e.nodeName&&"TEXTAREA"===e.nodeName){var t=d("autosize:destroy");e.dispatchEvent(t)}}function i(e){if(e&&e.nodeName&&"TEXTAREA"===e.nodeName){var t=d("autosize:update");e.dispatchEvent(t)}}var r="function"==typeof Set?new Set:function(){var e=[];return{has:function(t){return Boolean(e.indexOf(t)>-1)},add:function(t){e.push(t)},"delete":function(t){e.splice(e.indexOf(t),1)}}}(),d=function(e){return new Event(e)};try{new Event("test")}catch(s){d=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!1),t}}var a=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?(a=function(e){return e},a.destroy=function(e){return e},a.update=function(e){return e}):(a=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],function(e){return n(e,t)}),e},a.destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],o),e},a.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],i),e}),t.exports=a});

File diff suppressed because one or more lines are too long