Support for template
This commit is contained in:
parent
d00b734017
commit
b7b63b843c
@ -1 +1 @@
|
||||
CACHE MANIFEST
# v35
CACHE:
index.html
css/bootstrap.css
css/jgrowl.css
css/main.css
js/main-min.js
js/require.js
NETWORK:
*
|
||||
CACHE MANIFEST
# v36
CACHE:
index.html
css/bootstrap.css
css/jgrowl.css
css/main.css
js/main-min.js
js/require.js
NETWORK:
*
|
||||
|
@ -329,6 +329,9 @@ hr {
|
||||
}
|
||||
|
||||
#modal-settings textarea {
|
||||
max-width: 206px;
|
||||
height: 150px;
|
||||
height: 180px;
|
||||
}
|
||||
|
||||
.tooltip-inner {
|
||||
text-align: left;
|
||||
}
|
||||
|
@ -488,10 +488,10 @@
|
||||
<a target="_blank" href="http://requirejs.org/">RequireJS</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a target="_blank" href="http://underscorejs.org/">Underscore.js</a>
|
||||
<a target="_blank" href="http://layout.jquery-dev.net/">UI Layout</a>
|
||||
</dd>
|
||||
<dd>
|
||||
<a target="_blank" href="http://layout.jquery-dev.net/">UI Layout</a>
|
||||
<a target="_blank" href="http://underscorejs.org/">Underscore.js</a>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>Copyright 2013 <a target="_blank"
|
||||
|
@ -389,15 +389,15 @@ define(["jquery", "google-helper", "dropbox-helper", "github-helper", "synchroni
|
||||
|
||||
// Create a new publication on GitHub
|
||||
function newPublishGithub(event) {
|
||||
var publishObject = {};
|
||||
publishObject.repository = core.getInputValue($("#input-publish-github-reponame"), event);
|
||||
publishObject.branch = core.getInputValue($("#input-publish-github-branch"), event);
|
||||
publishObject.path = core.getInputValue($("#input-publish-github-path"), event);
|
||||
publishObject.provider = newPublishProvider;
|
||||
var publishAttributes = {};
|
||||
publishAttributes.repository = core.getInputValue($("#input-publish-github-reponame"), event);
|
||||
publishAttributes.branch = core.getInputValue($("#input-publish-github-branch"), event);
|
||||
publishAttributes.path = core.getInputValue($("#input-publish-github-path"), event);
|
||||
publishAttributes.provider = newPublishProvider;
|
||||
if(event.isPropagationStopped()) {
|
||||
return;
|
||||
}
|
||||
publisher.newLocation(publishObject);
|
||||
publisher.newLocation(publishAttributes);
|
||||
}
|
||||
|
||||
// Create a new publication on Blogger
|
||||
|
@ -9,10 +9,10 @@ define(["jquery", "github-helper"], function($, githubHelper) {
|
||||
providerName: "GitHub"
|
||||
};
|
||||
|
||||
publishGithub.publish = function(publishObject, title, content, callback) {
|
||||
publishGithub.publish = function(publishAttributes, title, content, callback) {
|
||||
var commitMsg = core.settings.commitMsg;
|
||||
githubHelper.upload(publishObject.repository, publishObject.branch,
|
||||
publishObject.path, content, commitMsg, callback);
|
||||
githubHelper.upload(publishAttributes.repository, publishAttributes.branch,
|
||||
publishAttributes.path, content, commitMsg, callback);
|
||||
};
|
||||
|
||||
publishGithub.init = function(coreModule) {
|
||||
|
10
js/main-min.js
vendored
10
js/main-min.js
vendored
File diff suppressed because one or more lines are too long
@ -41,28 +41,34 @@ define(["jquery", "github-provider", "underscore"], function($) {
|
||||
};
|
||||
|
||||
// Apply template to the current document
|
||||
publisher.applyTemplate = function() {
|
||||
publisher.applyTemplate = function(publishAttributes) {
|
||||
var fileIndex = fileManager.getCurrentFileIndex();
|
||||
try {
|
||||
return _.template(core.settings.template, {
|
||||
documentTitle: localStorage[fileIndex + ".title"],
|
||||
documentMarkdown: $("#wmd-input").val(),
|
||||
documentHTML: $("#wmd-preview").html()
|
||||
documentHTML: $("#wmd-preview").html(),
|
||||
publishAttributes: publishAttributes
|
||||
});
|
||||
} catch(e) {
|
||||
core.showError(e);
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
// Used to get content to publish
|
||||
function getPublishContent(publishObject) {
|
||||
if(publishObject.format === undefined) {
|
||||
publishObject.format = $("input:radio[name=radio-publish-format]:checked").prop("value");
|
||||
function getPublishContent(publishAttributes) {
|
||||
if(publishAttributes.format === undefined) {
|
||||
publishAttributes.format = $("input:radio[name=radio-publish-format]:checked").prop("value");
|
||||
}
|
||||
if(publishObject.format == "markdown") {
|
||||
if(publishAttributes.format == "markdown") {
|
||||
return $("#wmd-input").val();
|
||||
}
|
||||
else if(publishObject.format == "html") {
|
||||
else if(publishAttributes.format == "html") {
|
||||
return $("#wmd-preview").html();
|
||||
}
|
||||
else {
|
||||
return publisher.applyTemplate();
|
||||
return publisher.applyTemplate(publishAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,12 +85,12 @@ define(["jquery", "github-provider", "underscore"], function($) {
|
||||
|
||||
// Dequeue a synchronized location
|
||||
var publishIndex = publishIndexList.pop();
|
||||
var publishObject = JSON.parse(localStorage[publishIndex]);
|
||||
var content = getPublishContent(publishObject);
|
||||
var publishAttributes = JSON.parse(localStorage[publishIndex]);
|
||||
var content = getPublishContent(publishAttributes);
|
||||
|
||||
// Call the provider
|
||||
var provider = providerMap[publishObject.provider];
|
||||
provider.publish(publishObject, publishTitle, content, function(error) {
|
||||
var provider = providerMap[publishAttributes.provider];
|
||||
provider.publish(publishAttributes, publishTitle, content, function(error) {
|
||||
publishLocation(callback, errorFlag);
|
||||
});
|
||||
}
|
||||
@ -105,30 +111,30 @@ define(["jquery", "github-provider", "underscore"], function($) {
|
||||
publishRunning = false;
|
||||
publisher.updatePublishButton();
|
||||
if(errorFlag === undefined) {
|
||||
core.showMessage('"' + title + '" successfully published.');
|
||||
core.showMessage('"' + publishTitle + '" successfully published.');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Generate a publishIndex associated to a fileIndex and store a publishObject
|
||||
function createPublishIndex(fileIndex, publishObject) {
|
||||
// Generate a publishIndex associated to a fileIndex and store publishAttributes
|
||||
function createPublishIndex(fileIndex, publishAttributes) {
|
||||
var publishIndex = undefined;
|
||||
do {
|
||||
publishIndex = "publish." + core.randomString();
|
||||
} while(_.has(localStorage, publishIndex));
|
||||
localStorage[publishIndex] = JSON.stringify(publishObject);
|
||||
localStorage[publishIndex] = JSON.stringify(publishAttributes);
|
||||
localStorage[fileIndex + ".publish"] += publishIndex + ";";
|
||||
}
|
||||
|
||||
// Add a new publish location to a local document
|
||||
publisher.newLocation = function(publishObject) {
|
||||
publisher.newLocation = function(publishAttributes) {
|
||||
var fileIndex = fileManager.getCurrentFileIndex();
|
||||
var title = localStorage[fileIndex + ".title"];
|
||||
var content = getPublishContent(publishObject);
|
||||
var provider = providerMap[publishObject.provider];
|
||||
provider.publish(publishObject, title, content, function(error) {
|
||||
var content = getPublishContent(publishAttributes);
|
||||
var provider = providerMap[publishAttributes.provider];
|
||||
provider.publish(publishAttributes, title, content, function(error) {
|
||||
if(error === undefined) {
|
||||
createPublishIndex(fileIndex, publishObject);
|
||||
createPublishIndex(fileIndex, publishAttributes);
|
||||
publisher.notifyPublish();
|
||||
core.showMessage('"' + title
|
||||
+ '" will now be published on GitHub.');
|
||||
@ -155,10 +161,10 @@ define(["jquery", "github-provider", "underscore"], function($) {
|
||||
}
|
||||
_.each(publishIndexList, function(publishIndex) {
|
||||
var serializedObject = localStorage[publishIndex];
|
||||
var publishObject = JSON.parse(serializedObject);
|
||||
var publishDesc = JSON.stringify(_.omit(publishObject, 'provider')).replace(/{|}|"/g, "");
|
||||
var publishAttributes = JSON.parse(serializedObject);
|
||||
var publishDesc = JSON.stringify(_.omit(publishAttributes, 'provider')).replace(/{|}|"/g, "");
|
||||
lineElement = $(_.template(lineTemplate, {
|
||||
provider: providerMap[publishObject.provider],
|
||||
provider: providerMap[publishAttributes.provider],
|
||||
publishDesc: publishDesc
|
||||
}));
|
||||
lineElement.append($(removeButtonTemplate).click(function() {
|
||||
@ -184,9 +190,30 @@ define(["jquery", "github-provider", "underscore"], function($) {
|
||||
});
|
||||
|
||||
$(".tooltip-template").tooltip({
|
||||
title: ['Variables:\n',
|
||||
'documentTitle: the document title'
|
||||
html: true,
|
||||
container: '#modal-settings',
|
||||
placement: 'right',
|
||||
trigger: 'manual',
|
||||
title: ['Available variables:<br>',
|
||||
'<ul><li><b>documentTitle</b>: document title</li>',
|
||||
'<li><b>documentMarkdown</b>: document in Markdown format</li>',
|
||||
'<li><b>documentHTML</b>: document in HTML format</li>',
|
||||
'<li><b>publishAttributes</b>: attributes of the publish location (undefined when using "Save")</li></ul>',
|
||||
'Examples:<br>',
|
||||
_.escape('<title><%= documentTitle %></title>'),
|
||||
'<br>',
|
||||
_.escape('<div><%- documentHTML %></div>'),
|
||||
'<br>',
|
||||
_.escape('<% if(publishAttributes.provider == "github") print(documentMarkdown); %>'),
|
||||
'<br><br><a target="_blank" href="http://underscorejs.org/#template">More info</a>',
|
||||
].join("")
|
||||
}).click(function(e) {
|
||||
$(this).tooltip('show');
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$(document).click(function(e) {
|
||||
$(".tooltip-template").tooltip('hide');
|
||||
});
|
||||
};
|
||||
|
||||
|
58
test.html
58
test.html
@ -1,58 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>README.md</title>
|
||||
</head>
|
||||
<body><h1>StackEdit</h1>
|
||||
|
||||
<p>StackEdit is a free, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.</p>
|
||||
|
||||
<h3>StackEdit can:</h3>
|
||||
|
||||
<ul>
|
||||
<li>Manage multiple Markdown documents locally</li>
|
||||
<li>Export your documents in Markdown or HTML format</li>
|
||||
<li>Synchronize your Markdown documents in the Cloud</li>
|
||||
<li>Edit existing Markdown documents from Google Drive and Dropbox</li>
|
||||
<li>Publish your document on GitHub in one click</li>
|
||||
</ul>
|
||||
|
||||
<h3>Features:</h3>
|
||||
|
||||
<ul>
|
||||
<li>Real-time HTML preview</li>
|
||||
<li>WYSIWYG control buttons</li>
|
||||
<li>Configurable layout</li>
|
||||
<li>Offline editing</li>
|
||||
<li>Online synchronization using Google Drive and Dropbox</li>
|
||||
<li>Publish on GitHub</li>
|
||||
</ul>
|
||||
|
||||
<blockquote>
|
||||
<p><strong>NOTE:</strong> This page has been written with <a href="http://benweet.github.io/stackedit/" title="StackEdit">StackEdit</a>.</p>
|
||||
</blockquote>StackEdit
|
||||
=========
|
||||
|
||||
StackEdit is a free, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.
|
||||
|
||||
### StackEdit can:
|
||||
|
||||
- Manage multiple Markdown documents locally
|
||||
- Export your documents in Markdown or HTML format
|
||||
- Synchronize your Markdown documents in the Cloud
|
||||
- Edit existing Markdown documents from Google Drive and Dropbox
|
||||
- Publish your document on GitHub in one click
|
||||
|
||||
### Features:
|
||||
|
||||
- Real-time HTML preview
|
||||
- WYSIWYG control buttons
|
||||
- Configurable layout
|
||||
- Offline editing
|
||||
- Online synchronization using Google Drive and Dropbox
|
||||
- Publish on GitHub
|
||||
|
||||
> **NOTE:** This page has been written with [StackEdit][1].
|
||||
|
||||
[1]: http://benweet.github.io/stackedit/ "StackEdit"</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user