Fixed Tumblr post format when publishing using template

This commit is contained in:
benweet 2013-10-27 20:27:39 +00:00
parent 293aac30ed
commit 627087891e
5 changed files with 23 additions and 8 deletions

View File

@ -41,7 +41,7 @@ define([
var htmlCode = _.template(buttonHtmlCode.config.template, { var htmlCode = _.template(buttonHtmlCode.config.template, {
documentTitle: selectedFileDesc.title, documentTitle: selectedFileDesc.title,
documentMarkdown: selectedFileDesc.content, documentMarkdown: selectedFileDesc.content,
trimmedDocumentMarkdown: selectedFileDesc.content.substring(selectedFileDesc.frontMatter ? selectedFileDesc.frontMatter._frontMatter.length : 0), strippedDocumentMarkdown: selectedFileDesc.content.substring(selectedFileDesc.frontMatter ? selectedFileDesc.frontMatter._frontMatter.length : 0),
documentHTML: html, documentHTML: html,
frontMatter: selectedFileDesc.frontMatter, frontMatter: selectedFileDesc.frontMatter,
publishAttributes: undefined, publishAttributes: undefined,

View File

@ -6,7 +6,7 @@ Available variables:
<li> <li>
<b>documentMarkdown</b>: document in Markdown format</li> <b>documentMarkdown</b>: document in Markdown format</li>
<li> <li>
<b>trimmedDocumentMarkdown</b>: document without front matter</li> <b>strippedDocumentMarkdown</b>: document without front matter</li>
<li> <li>
<b>documentHTML</b>: document in HTML format</li> <b>documentHTML</b>: document in HTML format</li>
<li> <li>

View File

@ -1,9 +1,10 @@
define([ define([
"underscore", "underscore",
"settings",
"utils", "utils",
"classes/Provider", "classes/Provider",
"helpers/tumblrHelper" "helpers/tumblrHelper"
], function(_, utils, Provider, tumblrHelper) { ], function(_, settings, utils, Provider, tumblrHelper) {
var tumblrProvider = new Provider("tumblr", "Tumblr"); var tumblrProvider = new Provider("tumblr", "Tumblr");
tumblrProvider.publishPreferencesInputIds = [ tumblrProvider.publishPreferencesInputIds = [
@ -16,7 +17,22 @@ define([
frontMatter.tags !== undefined && (labelList = frontMatter.tags); frontMatter.tags !== undefined && (labelList = frontMatter.tags);
} }
_.isString(labelList) && (labelList = _.compact(labelList.split(/[\s,]/))); _.isString(labelList) && (labelList = _.compact(labelList.split(/[\s,]/)));
tumblrHelper.upload(publishAttributes.blogHostname, publishAttributes.postId, labelList.join(','), publishAttributes.format == "markdown" ? "markdown" : "html", title, content, function(error, postId) {
// Deduce format from publishAttributes/template
var format = (function() {
if(publishAttributes.format == 'html') {
return 'html';
}
if(publishAttributes.format == 'template') {
var template = publishAttributes.customTmpl || settings.template;
if(template.indexOf("documentHTML") !== -1) {
return 'html';
}
}
return 'markdown';
})();
tumblrHelper.upload(publishAttributes.blogHostname, publishAttributes.postId, labelList.join(','), format, title, content, function(error, postId) {
if(error) { if(error) {
callback(error); callback(error);
return; return;

View File

@ -62,7 +62,7 @@ define([
return _.template(template, { return _.template(template, {
documentTitle: fileDesc.title, documentTitle: fileDesc.title,
documentMarkdown: fileDesc.content, documentMarkdown: fileDesc.content,
trimmedDocumentMarkdown: fileDesc.content.substring(fileDesc.frontMatter ? fileDesc.frontMatter._frontMatter.length : 0), strippedDocumentMarkdown: fileDesc.content.substring(fileDesc.frontMatter ? fileDesc.frontMatter._frontMatter.length : 0),
documentHTML: html, documentHTML: html,
frontMatter: fileDesc.frontMatter, frontMatter: fileDesc.frontMatter,
publishAttributes: publishAttributes publishAttributes: publishAttributes

View File

@ -1215,15 +1215,14 @@ div.dropdown-menu textarea {
.title-icon-category { .title-icon-category {
display: inline-block; display: inline-block;
opacity: 0.1; opacity: 0.1;
margin-top: -4px; margin-top: -2px;
margin-left: -2px; margin-left: -2px;
margin-right: 2px; margin-right: 2px;
font-size: 14px; font-size: 14px;
vertical-align: top; vertical-align: top;
.file-title-navbar & { .file-title-navbar & {
font-size: 16px; font-size: 16px;
margin-top: -2px; margin-left: -3px;
margin-left: -4px;
} }
} }