Implemented sync/publish location links
This commit is contained in:
parent
b225379703
commit
8127bfb5d0
@ -1,6 +1,3 @@
|
||||
var request = require('request');
|
||||
var async = require('async');
|
||||
|
||||
var validate = function(newDoc) {
|
||||
Object.keys(newDoc).forEach(function(key) {
|
||||
if(key[0] !== '_' && [
|
||||
@ -88,14 +85,6 @@ var byTagAndUpdate = function(doc) {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
if(process.argv.length < 3) {
|
||||
console.error('Missing URL parameter');
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
var url = process.argv[2];
|
||||
|
||||
var ddocs = [
|
||||
{
|
||||
path: '/_design/validate',
|
||||
@ -125,31 +114,66 @@ var ddocs = [
|
||||
}
|
||||
];
|
||||
|
||||
async.each(ddocs, function(ddoc, cb) {
|
||||
if(process.argv.length < 3) {
|
||||
console.error('Missing URL parameter');
|
||||
process.exit(-1);
|
||||
}
|
||||
|
||||
request.get(url + ddoc.path, function(err, res) {
|
||||
if(res && res.body) {
|
||||
ddoc.body._rev = JSON.parse(res.body)._rev;
|
||||
}
|
||||
request.put({
|
||||
url: url + ddoc.path,
|
||||
json: true,
|
||||
body: ddoc.body
|
||||
}, function(err, res) {
|
||||
if(err) {
|
||||
return cb(res);
|
||||
}
|
||||
if(res.statusCode >= 300) {
|
||||
return cb(res.body);
|
||||
}
|
||||
cb();
|
||||
});
|
||||
});
|
||||
var url = require('url').parse(process.argv[2]);
|
||||
var request = require(url.protocol === 'https:' ? 'https' : 'http').request;
|
||||
|
||||
}, function(err) {
|
||||
if(err) {
|
||||
console.error(err);
|
||||
} else {
|
||||
console.log('All design documents updated successfully');
|
||||
function onError(err, body) {
|
||||
console.error(err);
|
||||
body && console.error(body);
|
||||
process.exit(1);
|
||||
}
|
||||
function uploadDdoc() {
|
||||
if(ddocs.length === 0) {
|
||||
return console.log('All design documents updated successfully.');
|
||||
}
|
||||
});
|
||||
var ddoc = ddocs.shift();
|
||||
var options = {
|
||||
hostname: url.hostname,
|
||||
port: url.port,
|
||||
path: url.path + ddoc.path,
|
||||
auth: url.auth,
|
||||
method: 'GET'
|
||||
};
|
||||
request(options, function(res) {
|
||||
var body = '';
|
||||
res
|
||||
.on('data', function(chunk) {
|
||||
body += chunk;
|
||||
})
|
||||
.on('end', function() {
|
||||
res.statusCode >= 300 && onError('Status code: ' + res.statusCode, body);
|
||||
ddoc.body._rev = JSON.parse(body)._rev;
|
||||
var options = {
|
||||
hostname: url.hostname,
|
||||
port: url.port,
|
||||
path: url.path + ddoc.path,
|
||||
auth: url.auth,
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-type': 'application/json'
|
||||
}
|
||||
};
|
||||
request(options, function(res) {
|
||||
var body = '';
|
||||
res
|
||||
.on('data', function(chunk) {
|
||||
body += chunk;
|
||||
})
|
||||
.on('end', function() {
|
||||
res.statusCode >= 300 && onError('Status code: ' + res.statusCode, body);
|
||||
uploadDdoc();
|
||||
});
|
||||
})
|
||||
.on('error', onError)
|
||||
.end(JSON.stringify(ddoc.body));
|
||||
});
|
||||
})
|
||||
.on('error', onError)
|
||||
.end();
|
||||
}
|
||||
uploadDdoc();
|
42
doc/couchdb-setup.md
Normal file
42
doc/couchdb-setup.md
Normal file
@ -0,0 +1,42 @@
|
||||
### Pre-requisites
|
||||
|
||||
- CouchDB 1.5 or later, because of the use of `POST /{db}/_changes`,
|
||||
- Node.js, to load the design documents in the database.
|
||||
|
||||
> **Note:**
|
||||
>
|
||||
> - In order to work with https://stackedit.io, your database has to be accessible through HTTPS. You can use a free hosting service like [Couchappy](https://www.couchappy.com/) or [configure your own instance to use SSL](http://docs.couchdb.org/en/latest/config/http.html#ssl).
|
||||
>
|
||||
> - StackEdit doesn't deal with user access rights, but you can still set permissions for your database and configure StackEdit to connect to it using URL like this: `https://username:password@instance.couchappy.com/documents`.
|
||||
>
|
||||
> - It's up to you to trigger the database compaction, or to keep the full history of your documents.
|
||||
|
||||
|
||||
### Enable CORS
|
||||
|
||||
Add the following key/value pairs to your CouchDB configuration:
|
||||
|
||||
```
|
||||
[httpd]
|
||||
enable_cors = true
|
||||
|
||||
[cors]
|
||||
origins = http://localhost, https://stackedit.io
|
||||
```
|
||||
|
||||
|
||||
### Create the database
|
||||
|
||||
```bash
|
||||
curl -X PUT https://instance.couchappy.com/documents
|
||||
```
|
||||
|
||||
### Insert the design documents
|
||||
|
||||
```bash
|
||||
curl https://raw.githubusercontent.com/benweet/stackedit/master/couchdb/setup.js | node /dev/stdin https://instance.couchappy.com/documents
|
||||
```
|
||||
|
||||
### Update StackEdit settings
|
||||
|
||||
To configure StackEdit to use your CouchDB instance, change the in URL in `Menu` > `Settings` > `Advanced` > `CouchDB URL` to `https://instance.couchappy.com/documents`.
|
@ -33,8 +33,7 @@
|
||||
"gulp-util": "^3.0.1",
|
||||
"knox": "^0.9.1",
|
||||
"mime": "^1.2.11",
|
||||
"event-stream": "^3.1.7",
|
||||
"async": "^0.9.0"
|
||||
"event-stream": "^3.1.7"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
@ -1,40 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="1600" height="400" viewBox="0, 0, 1600, 400">
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="1680" height="420" viewBox="0, 0, 1680, 420">
|
||||
<defs>
|
||||
<linearGradient id="Gradient_1" gradientUnits="userSpaceOnUse" x1="800" y1="-0" x2="800" y2="400">
|
||||
<linearGradient id="Gradient_1" gradientUnits="userSpaceOnUse" x1="897.423" y1="-0" x2="897.423" y2="420">
|
||||
<stop offset="0" stop-color="#5F5F5F"/>
|
||||
<stop offset="1" stop-color="#343434"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="Layer_3">
|
||||
<g>
|
||||
<path d="M80,0 L1520,0 C1564.183,0 1600,35.817 1600,80 L1600,320 C1600,364.183 1564.183,400 1520,400 L80,400 C35.817,400 0,364.183 0,320 L0,80 C0,35.817 35.817,0 80,0 z" fill="url(#Gradient_1)"/>
|
||||
<path d="M80,0 L1520,0 C1564.183,0 1600,35.817 1600,80 L1600,320 C1600,364.183 1564.183,400 1520,400 L80,400 C35.817,400 0,364.183 0,320 L0,80 C0,35.817 35.817,0 80,0 z" fill-opacity="0" stroke="#3492DB" stroke-width="1" stroke-opacity="0.33"/>
|
||||
</g>
|
||||
<path d="M193.104,-0 L1601.742,-0 C1644.963,-0 1680,37.608 1680,84 L1680,336 C1680,382.392 1644.963,420 1601.742,420 L193.104,420 C149.884,420 114.846,382.392 114.846,336 L114.846,84 C114.846,37.608 149.884,-0 193.104,-0 z" fill="url(#Gradient_1)"/>
|
||||
</g>
|
||||
<g id="Layer_1" opacity="0.95">
|
||||
<text transform="matrix(1, 0, 0, 1, 566.047, -181.461)"/>
|
||||
<path d="M139.64,288.048 L140.034,75.73 L467.206,101.901 L407.327,309.461 L269.714,322.458" fill="#E34F26"/>
|
||||
<path d="M273.069,304.953 L383.845,294.888 L435.048,117.102 L301.568,106.424" fill="#EF652A"/>
|
||||
<path d="M255.208,120.058 L282.568,235.467 L342.065,127.006 L409.124,132.37 L388.052,279.161 L369.844,277.705 C362.759,277.138 357.194,275.139 353.148,271.707 C349.283,268.163 348.566,266.516 347.991,261.227 L362.879,157.514 L301.189,272.258 L254.567,268.528 L226.207,146.581 L209.222,264.901 L167.071,261.529 L185.889,130.441 C186.5,126.185 189.254,122.746 194.153,120.125 C199.051,117.503 204.714,116.306 211.141,116.533 z" fill="#FFFFFF" fill-opacity="0.95"/>
|
||||
<path d="M342.065,127.006 L409.124,132.37 L388.052,279.161 L369.844,277.705 C362.759,277.138 357.194,275.139 353.148,271.707 C349.283,268.163 348.566,266.516 347.991,261.227 L362.879,157.514 L301.189,272.258 L278.028,270.405 L283.212,234.294 z" fill="#FFFFFF"/>
|
||||
<text transform="matrix(1, 0, 0, 1, 514.064, -238.176)"/>
|
||||
<path d="M6.993,318.601 L7.46,66.367 L396.141,97.459 L325.004,344.039 L161.52,359.48" fill="#E34F26"/>
|
||||
<path d="M165.506,338.684 L297.108,326.727 L357.937,115.517 L199.362,102.832" fill="#EF652A"/>
|
||||
<path d="M144.287,119.029 L176.791,256.135 L247.473,127.283 L327.139,133.655 L302.106,308.044 L280.474,306.313 C272.058,305.64 265.446,303.265 260.64,299.187 C256.048,294.977 255.197,293.021 254.514,286.738 L272.201,163.527 L198.912,299.842 L143.525,295.411 L109.834,150.538 L89.656,291.102 L39.58,287.097 L61.936,131.364 C62.662,126.308 65.934,122.222 71.753,119.108 C77.572,115.993 84.3,114.571 91.935,114.841 z" fill="#FFFFFF" fill-opacity="0.95"/>
|
||||
<path d="M247.473,127.283 L327.139,133.655 L302.106,308.044 L280.474,306.313 C272.058,305.64 265.446,303.265 260.64,299.187 C256.048,294.977 255.197,293.021 254.514,286.738 L272.2,163.527 L198.912,299.842 L171.397,297.641 L177.556,254.741 z" fill="#FFFFFF"/>
|
||||
</g>
|
||||
<g id="Layer_2">
|
||||
<path d="M440.537,261.869 Q428.624,253.233 423.519,238.598 Q418.414,223.964 418.414,208.13 Q418.414,195.175 422.668,182.22 Q426.923,169.265 435.999,160.628 Q450.747,146.234 474.005,143.595 Q497.262,140.956 515.982,146.714 Q537.537,153.911 547.748,171.664 Q557.391,187.498 557.391,208.61 Q557.391,223.964 553.42,235 Q549.45,246.036 543.21,253.713 Q529.596,269.547 508.607,273.385 Q489.888,277.703 470.885,274.105 Q451.882,270.506 440.537,261.869 z M467.765,177.422 Q455.853,188.458 456.987,210.289 Q458.122,232.121 466.63,240.758 Q470.034,244.596 478.543,247.235 Q487.052,249.874 495.844,247.715 Q504.637,245.556 511.444,236.919 Q518.251,228.282 518.818,209.09 Q518.818,191.816 512.294,183.18 Q505.771,174.543 497.262,172.144 Q488.753,169.745 480.245,171.904 Q471.736,174.063 467.765,177.422 z" fill="#FFFFFF"/>
|
||||
<path d="M700.075,273.385 L680.221,273.385 Q671.712,273.385 666.323,268.827 Q660.934,264.269 660.934,257.071 L660.934,191.816 Q660.934,180.301 652.709,175.023 Q644.484,169.745 634.273,169.745 Q624.063,169.745 616.121,175.023 Q608.179,180.301 608.179,191.816 L608.179,273.385 L568.472,273.385 L568.472,198.534 Q568.472,165.906 588.609,154.87 Q608.747,143.835 633.139,142.875 Q658.098,142.875 679.086,153.911 Q700.075,164.947 700.075,198.534 z" fill="#FFFFFF"/>
|
||||
<path d="M819.97,234.04 L848.333,234.04 Q842.093,254.192 824.508,264.748 Q806.923,275.784 780.262,275.784 Q747.928,275.784 729.776,258.031 Q711.624,240.758 711.624,208.61 Q711.624,177.902 729.209,160.628 Q747.361,142.875 779.695,142.875 Q813.73,142.875 832.449,160.148 Q850.602,177.902 850.602,209.57 Q850.602,211.489 850.602,212.928 Q850.602,214.368 850.602,214.847 Q850.602,217.247 850.034,218.206 L751.899,218.206 Q752.466,233.081 760.408,240.278 Q767.782,247.955 782.531,247.955 Q792.174,247.955 798.981,244.596 Q800.683,244.116 802.101,242.917 Q803.519,241.717 805.221,240.278 Q805.788,238.838 809.476,236.439 Q813.163,234.04 819.97,234.04 z M751.899,196.614 L809.759,196.614 Q808.625,183.659 801.818,177.422 Q794.443,170.704 780.829,170.704 Q768.35,170.704 760.408,177.422 Q752.466,184.139 751.899,196.614 z" fill="#FFFFFF"/>
|
||||
<path d="M926.682,273.385 Q907.963,274.345 886.123,272.905 Q864.284,271.466 864.284,249.394 L864.284,108.328 L884.705,108.328 Q892.079,108.328 897.752,113.126 Q903.424,117.925 903.424,124.642 L903.424,146.234 L926.682,146.234 L926.682,152.951 Q926.682,160.148 921.009,164.707 Q915.337,169.265 907.395,169.265 L903.424,169.265 L903.424,240.278 Q903.424,248.435 914.77,248.435 L926.682,248.435 z" fill="#FFFFFF"/>
|
||||
<path d="M943.17,145.754 L963.591,145.754 Q971.533,145.754 977.205,150.552 Q982.878,155.35 982.878,162.068 L982.878,273.385 L943.17,273.385 z M943.17,108.328 L963.591,108.328 Q971.533,108.328 977.205,113.126 Q982.878,117.925 982.878,124.642 L982.878,134.718 L943.17,134.718 z" fill="#FFFFFF"/>
|
||||
<path d="M997.165,273.385 L997.165,247.955 L1078.283,172.144 L1020.99,172.144 Q1013.048,172.144 1007.376,167.586 Q1001.703,163.027 1001.703,156.31 L1001.703,145.754 L1125.365,145.754 L1125.365,173.103 L1045.382,245.556 L1128.201,245.556 L1128.201,273.385 z" fill="#FFFFFF"/>
|
||||
<path d="M1245.192,234.04 L1273.555,234.04 Q1267.315,254.192 1249.73,264.748 Q1232.145,275.784 1205.484,275.784 Q1173.151,275.784 1154.998,258.031 Q1136.846,240.758 1136.846,208.61 Q1136.846,177.902 1154.431,160.628 Q1172.583,142.875 1204.917,142.875 Q1238.952,142.875 1257.672,160.148 Q1275.824,177.902 1275.824,209.569 Q1275.824,211.489 1275.824,212.928 Q1275.824,214.368 1275.824,214.847 Q1275.824,217.247 1275.256,218.206 L1177.121,218.206 Q1177.689,233.08 1185.63,240.278 Q1193.005,247.955 1207.753,247.955 Q1217.396,247.955 1224.203,244.596 Q1225.905,244.116 1227.323,242.917 Q1228.742,241.717 1230.443,240.278 Q1231.011,238.838 1234.698,236.439 Q1238.385,234.04 1245.192,234.04 z M1177.121,196.614 L1234.981,196.614 Q1233.847,183.659 1227.04,177.422 Q1219.665,170.704 1206.051,170.704 Q1193.572,170.704 1185.63,177.422 Q1177.689,184.139 1177.121,196.614 z" fill="#FFFFFF"/>
|
||||
<path d="M369.458,287.501 Q355.306,277.241 349.241,259.855 Q343.176,242.469 343.176,223.659 Q343.176,208.268 348.23,192.877 Q353.284,177.487 364.066,167.226 Q381.588,150.126 409.218,146.991 Q436.848,143.855 459.086,150.696 Q484.694,159.246 496.825,180.337 Q508.281,199.148 508.281,224.229 Q508.281,242.469 503.564,255.58 Q498.846,268.69 491.433,277.811 Q475.26,296.621 450.325,301.181 Q428.087,306.312 405.511,302.037 Q382.936,297.761 369.458,287.501 z M401.805,187.177 Q387.653,200.288 389.001,226.224 Q390.348,252.16 400.457,262.42 Q404.5,266.98 414.609,270.115 Q424.717,273.25 435.163,270.685 Q445.608,268.12 453.695,257.86 Q461.782,247.599 462.456,224.799 Q462.456,204.278 454.706,194.017 Q446.956,183.757 436.848,180.907 Q426.739,178.057 416.631,180.622 Q406.522,183.187 401.805,187.177 z" fill="#FFFFFF"/>
|
||||
<path d="M677.789,301.181 L654.202,301.181 Q644.094,301.181 637.692,295.766 Q631.29,290.351 631.29,281.801 L631.29,204.278 Q631.29,190.597 621.518,184.327 Q611.747,178.057 599.617,178.057 Q587.486,178.057 578.052,184.327 Q568.617,190.597 568.617,204.278 L568.617,301.181 L521.444,301.181 L521.444,212.258 Q521.444,173.497 545.368,160.386 Q569.291,147.276 598.269,146.136 Q627.92,146.136 652.855,159.246 Q677.789,172.357 677.789,212.258 z" fill="#FFFFFF"/>
|
||||
<path d="M820.224,254.44 L853.919,254.44 Q846.506,278.381 825.615,290.921 Q804.725,304.032 773.051,304.032 Q734.639,304.032 713.074,282.941 Q691.509,262.42 691.509,224.229 Q691.509,187.747 712.4,167.226 Q733.965,146.136 772.377,146.136 Q812.811,146.136 835.05,166.656 Q856.615,187.747 856.615,225.369 Q856.615,227.649 856.615,229.359 Q856.615,231.069 856.615,231.639 Q856.615,234.489 855.941,235.629 L739.356,235.629 Q740.03,253.3 749.465,261.85 Q758.225,270.97 775.747,270.97 Q787.203,270.97 795.29,266.98 Q797.312,266.41 798.996,264.985 Q800.681,263.56 802.703,261.85 Q803.377,260.14 807.757,257.29 Q812.137,254.44 820.224,254.44 z M739.356,209.978 L808.094,209.978 Q806.746,194.587 798.659,187.177 Q789.899,179.197 773.725,179.197 Q758.899,179.197 749.465,187.177 Q740.03,195.157 739.356,209.978 z" fill="#FFFFFF"/>
|
||||
<path d="M946.998,301.181 Q924.759,302.322 898.814,300.611 Q872.869,298.901 872.869,272.68 L872.869,105.094 L897.13,105.094 Q905.89,105.094 912.629,110.794 Q919.368,116.494 919.368,124.475 L919.368,150.126 L946.998,150.126 L946.998,158.106 Q946.998,166.656 940.259,172.072 Q933.52,177.487 924.086,177.487 L919.368,177.487 L919.368,261.85 Q919.368,271.54 932.846,271.54 L946.998,271.54 z" fill="#FFFFFF"/>
|
||||
<path d="M966.586,149.556 L990.846,149.556 Q1000.281,149.556 1007.02,155.256 Q1013.759,160.956 1013.759,168.936 L1013.759,301.181 L966.586,301.181 z M966.586,105.094 L990.846,105.094 Q1000.281,105.094 1007.02,110.794 Q1013.759,116.494 1013.759,124.475 L1013.759,136.445 L966.586,136.445 z" fill="#FFFFFF"/>
|
||||
<path d="M1030.732,301.181 L1030.732,270.97 L1127.1,180.907 L1059.036,180.907 Q1049.601,180.907 1042.862,175.492 Q1036.123,170.076 1036.123,162.096 L1036.123,149.556 L1183.033,149.556 L1183.033,182.047 L1088.014,268.12 L1186.403,268.12 L1186.403,301.181 z" fill="#FFFFFF"/>
|
||||
<path d="M1325.388,254.44 L1359.083,254.44 Q1351.67,278.381 1330.779,290.921 Q1309.888,304.032 1278.215,304.032 Q1239.803,304.032 1218.238,282.941 Q1196.673,262.42 1196.673,224.229 Q1196.673,187.747 1217.564,167.226 Q1239.129,146.135 1277.541,146.135 Q1317.975,146.135 1340.214,166.656 Q1361.779,187.747 1361.779,225.369 Q1361.779,227.649 1361.779,229.359 Q1361.779,231.069 1361.779,231.639 Q1361.779,234.489 1361.105,235.629 L1244.52,235.629 Q1245.194,253.3 1254.629,261.85 Q1263.389,270.97 1280.911,270.97 Q1292.367,270.97 1300.454,266.98 Q1302.475,266.41 1304.16,264.985 Q1305.845,263.56 1307.867,261.85 Q1308.541,260.14 1312.921,257.29 Q1317.301,254.44 1325.388,254.44 z M1244.52,209.978 L1313.258,209.978 Q1311.91,194.587 1303.823,187.177 Q1295.063,179.197 1278.889,179.197 Q1264.063,179.197 1254.629,187.177 Q1245.194,195.157 1244.52,209.978 z" fill="#FFFFFF"/>
|
||||
<g>
|
||||
<path d="M1364.929,271.719 L1389.389,271.719 Q1390.787,280.054 1397.426,283.388 Q1404.415,287.278 1416.645,287.278 Q1427.478,287.278 1433.068,284.222 Q1438.659,281.166 1438.659,275.331 Q1438.659,266.439 1407.21,260.882 L1406.511,260.604 Q1406.511,260.604 1403.716,260.049 Q1385.895,256.992 1379.954,253.658 Q1372.966,250.602 1370.17,244.767 Q1366.676,239.765 1366.676,231.985 Q1366.676,218.371 1378.557,210.591 Q1390.438,203.089 1413.151,203.089 Q1434.466,203.089 1445.998,210.868 Q1457.878,219.482 1458.577,233.375 L1444.6,233.375 Q1436.563,233.375 1433.068,227.54 Q1431.321,224.761 1428.176,222.816 Q1421.887,219.204 1411.054,219.204 Q1400.571,219.204 1396.028,222.261 Q1390.787,225.317 1390.787,230.874 Q1390.787,238.376 1411.054,241.988 Q1416.995,243.377 1419.79,243.655 Q1426.08,245.322 1430.797,246.295 Q1435.515,247.267 1438.31,247.823 Q1443.202,249.49 1448.094,251.157 Q1455.083,254.492 1458.927,259.771 Q1462.771,265.606 1462.771,272.552 Q1462.771,287.556 1450.191,295.892 Q1437.611,303.672 1414.548,303.672 Q1390.787,303.672 1378.906,295.614 Q1365.977,287.556 1364.929,271.719 z" fill="#FFFFFF"/>
|
||||
<path d="M1364.929,271.719 L1389.389,271.719 Q1390.787,280.054 1397.426,283.388 Q1404.415,287.278 1416.645,287.278 Q1427.478,287.278 1433.068,284.222 Q1438.659,281.166 1438.659,275.331 Q1438.659,266.439 1407.21,260.882 L1406.511,260.604 Q1406.511,260.604 1403.716,260.049 Q1385.895,256.992 1379.954,253.658 Q1372.966,250.602 1370.17,244.767 Q1366.676,239.765 1366.676,231.985 Q1366.676,218.371 1378.557,210.591 Q1390.438,203.089 1413.151,203.089 Q1434.466,203.089 1445.998,210.868 Q1457.878,219.482 1458.577,233.375 L1444.6,233.375 Q1436.563,233.375 1433.068,227.54 Q1431.321,224.761 1428.176,222.816 Q1421.887,219.204 1411.054,219.204 Q1400.571,219.204 1396.028,222.261 Q1390.787,225.317 1390.787,230.874 Q1390.787,238.376 1411.054,241.988 Q1416.995,243.377 1419.79,243.655 Q1426.08,245.322 1430.797,246.295 Q1435.515,247.267 1438.31,247.823 Q1443.202,249.49 1448.094,251.157 Q1455.083,254.492 1458.927,259.771 Q1462.771,265.606 1462.771,272.552 Q1462.771,287.556 1450.191,295.892 Q1437.611,303.672 1414.548,303.672 Q1390.787,303.672 1378.906,295.614 Q1365.977,287.556 1364.929,271.719 z" fill-opacity="0" stroke="#FFFFFF" stroke-width="5"/>
|
||||
<path d="M1467.635,299.202 L1496.694,299.202 Q1498.355,309.104 1506.242,313.065 Q1514.545,317.687 1529.074,317.687 Q1541.943,317.687 1548.585,314.056 Q1555.228,310.425 1555.228,303.493 Q1555.228,292.93 1517.866,286.328 L1517.036,285.998 Q1517.036,285.998 1513.715,285.338 Q1492.543,281.707 1485.486,277.746 Q1477.183,274.115 1473.862,267.183 Q1469.711,261.241 1469.711,251.999 Q1469.711,235.824 1483.825,226.582 Q1497.94,217.669 1524.923,217.669 Q1550.246,217.669 1563.945,226.912 Q1578.06,237.145 1578.89,253.649 L1562.285,253.649 Q1552.737,253.649 1548.585,246.717 Q1546.51,243.416 1542.774,241.106 Q1535.301,236.815 1522.432,236.815 Q1509.979,236.815 1504.582,240.446 Q1498.355,244.077 1498.355,250.678 Q1498.355,259.591 1522.432,263.882 Q1529.49,265.532 1532.811,265.863 Q1540.283,267.843 1545.887,268.998 Q1551.491,270.154 1554.812,270.814 Q1560.624,272.794 1566.436,274.775 Q1574.739,278.736 1579.305,285.008 Q1583.871,291.94 1583.871,300.192 Q1583.871,318.017 1568.927,327.92 Q1553.982,337.162 1526.584,337.162 Q1498.355,337.162 1484.241,327.589 Q1468.881,318.017 1467.635,299.202 z" fill="#FFFFFF"/>
|
||||
<path d="M1467.635,299.202 L1496.694,299.202 Q1498.355,309.104 1506.242,313.065 Q1514.545,317.687 1529.074,317.687 Q1541.943,317.687 1548.585,314.056 Q1555.228,310.425 1555.228,303.493 Q1555.228,292.93 1517.866,286.328 L1517.036,285.998 Q1517.036,285.998 1513.715,285.338 Q1492.543,281.707 1485.486,277.746 Q1477.183,274.115 1473.862,267.183 Q1469.711,261.241 1469.711,251.999 Q1469.711,235.824 1483.825,226.582 Q1497.94,217.669 1524.923,217.669 Q1550.246,217.669 1563.945,226.912 Q1578.06,237.145 1578.89,253.649 L1562.285,253.649 Q1552.737,253.649 1548.585,246.717 Q1546.51,243.416 1542.774,241.106 Q1535.301,236.815 1522.432,236.815 Q1509.979,236.815 1504.582,240.446 Q1498.355,244.077 1498.355,250.678 Q1498.355,259.591 1522.432,263.882 Q1529.49,265.532 1532.811,265.863 Q1540.283,267.843 1545.887,268.998 Q1551.491,270.154 1554.812,270.814 Q1560.624,272.794 1566.436,274.775 Q1574.739,278.736 1579.305,285.008 Q1583.871,291.94 1583.871,300.192 Q1583.871,318.017 1568.927,327.92 Q1553.982,337.162 1526.584,337.162 Q1498.355,337.162 1484.241,327.589 Q1468.881,318.017 1467.635,299.202 z" fill-opacity="0" stroke="#FFFFFF" stroke-width="5.94"/>
|
||||
</g>
|
||||
<g>
|
||||
<path d="M1352.699,205.867 L1352.699,273.386 C1352.699,279.499 1352.35,283.944 1351.651,286.723 C1350.486,289.872 1348.972,292.372 1347.108,294.225 C1343.847,297.374 1339.537,299.782 1334.179,301.449 C1328.122,302.931 1321.6,303.672 1314.611,303.672 C1307.156,303.672 1301.099,302.931 1296.44,301.449 C1291.548,300.523 1287.239,298.485 1283.511,295.336 C1280.483,292.743 1278.503,290.15 1277.571,287.556 C1276.406,284.222 1275.824,279.406 1275.824,273.108 L1275.824,271.913 L1299.935,271.913 L1299.935,277.276 C1299.935,280.61 1301.099,283.203 1303.429,285.056 C1305.759,286.723 1309.369,287.556 1314.261,287.556 C1319.154,287.556 1322.764,286.537 1325.094,284.5 C1326.958,282.648 1327.889,278.665 1327.889,272.552 L1327.889,215.87 C1327.889,213.091 1329.171,210.73 1331.733,208.785 C1334.296,206.84 1337.324,205.867 1340.819,205.867 z" fill="#FFFFFF"/>
|
||||
<path d="M1352.699,205.867 L1352.699,273.386 C1352.699,279.499 1352.35,283.944 1351.651,286.723 C1350.486,289.872 1348.972,292.372 1347.108,294.225 C1343.847,297.374 1339.537,299.782 1334.179,301.449 C1328.122,302.931 1321.6,303.672 1314.611,303.672 C1307.156,303.672 1301.099,302.931 1296.44,301.449 C1291.548,300.523 1287.239,298.485 1283.511,295.336 C1280.483,292.743 1278.503,290.15 1277.571,287.556 C1276.406,284.222 1275.824,279.406 1275.824,273.108 L1275.824,271.913 L1299.935,271.913 L1299.935,277.276 C1299.935,280.61 1301.099,283.203 1303.429,285.056 C1305.759,286.723 1309.369,287.556 1314.261,287.556 C1319.154,287.556 1322.764,286.537 1325.094,284.5 C1326.958,282.648 1327.889,278.665 1327.889,272.552 L1327.889,215.87 C1327.889,213.091 1329.171,210.73 1331.733,208.785 C1334.296,206.84 1337.324,205.867 1340.819,205.867 z" fill-opacity="0" stroke="#FFFFFF" stroke-width="5"/>
|
||||
<path d="M1453.107,220.97 L1453.107,301.182 C1453.107,308.444 1452.692,313.726 1451.861,317.027 C1450.478,320.768 1448.679,323.738 1446.465,325.939 C1442.59,329.68 1437.47,332.541 1431.105,334.521 C1423.91,336.282 1416.16,337.162 1407.858,337.162 C1399.002,337.162 1391.806,336.282 1386.271,334.521 C1380.459,333.421 1375.339,331 1370.911,327.259 C1367.314,324.179 1364.961,321.098 1363.854,318.017 C1362.47,314.056 1361.779,308.334 1361.779,300.852 L1361.779,299.432 L1390.422,299.432 L1390.422,305.803 C1390.422,309.765 1391.806,312.845 1394.574,315.046 C1397.341,317.027 1401.631,318.017 1407.443,318.017 C1413.255,318.017 1417.544,316.807 1420.312,314.386 C1422.526,312.185 1423.633,307.454 1423.633,300.192 L1423.633,232.853 C1423.633,229.553 1425.155,226.747 1428.199,224.436 C1431.243,222.126 1434.841,220.97 1438.993,220.97 z" fill="#FFFFFF"/>
|
||||
<path d="M1453.107,220.97 L1453.107,301.182 C1453.107,308.444 1452.692,313.726 1451.861,317.027 C1450.478,320.768 1448.679,323.738 1446.465,325.939 C1442.59,329.68 1437.47,332.541 1431.105,334.521 C1423.91,336.282 1416.16,337.162 1407.858,337.162 C1399.002,337.162 1391.806,336.282 1386.271,334.521 C1380.459,333.421 1375.339,331 1370.911,327.259 C1367.314,324.179 1364.961,321.098 1363.854,318.017 C1362.47,314.056 1361.779,308.334 1361.779,300.852 L1361.779,299.432 L1390.422,299.432 L1390.422,305.803 C1390.422,309.765 1391.806,312.845 1394.574,315.046 C1397.341,317.027 1401.631,318.017 1407.443,318.017 C1413.255,318.017 1417.544,316.807 1420.312,314.386 C1422.526,312.185 1423.633,307.454 1423.633,300.192 L1423.633,232.853 C1423.633,229.553 1425.155,226.747 1428.199,224.436 C1431.243,222.126 1434.841,220.97 1438.993,220.97 z" fill-opacity="0" stroke="#FFFFFF" stroke-width="5.94"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.7 KiB |
@ -1,145 +1,187 @@
|
||||
define([
|
||||
"underscore",
|
||||
"utils",
|
||||
"storage",
|
||||
"underscore",
|
||||
"utils",
|
||||
"storage",
|
||||
], function(_, utils, storage) {
|
||||
|
||||
function FileDescriptor(fileIndex, title, syncLocations, publishLocations) {
|
||||
this.fileIndex = fileIndex;
|
||||
this._title = title || storage[fileIndex + ".title"];
|
||||
this._editorScrollTop = parseInt(storage[fileIndex + ".editorScrollTop"]) || 0;
|
||||
this._editorStart = parseInt(storage[fileIndex + ".editorEnd"]) || 0;
|
||||
this._editorEnd = parseInt(storage[fileIndex + ".editorEnd"]) || 0;
|
||||
this._previewScrollTop = parseInt(storage[fileIndex + ".previewScrollTop"]) || 0;
|
||||
this._selectTime = parseInt(storage[fileIndex + ".selectTime"]) || 0;
|
||||
this._discussionList = JSON.parse(storage[fileIndex + ".discussionList"] || '{}');
|
||||
this.syncLocations = syncLocations || {};
|
||||
this.publishLocations = publishLocations || {};
|
||||
Object.defineProperty(this, 'title', {
|
||||
get: function() {
|
||||
return this._title;
|
||||
},
|
||||
set: function(title) {
|
||||
this._title = title;
|
||||
storage[this.fileIndex + ".title"] = title;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'content', {
|
||||
get: function() {
|
||||
return storage[this.fileIndex + ".content"];
|
||||
},
|
||||
set: function(content) {
|
||||
storage[this.fileIndex + ".content"] = content;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'editorScrollTop', {
|
||||
get: function() {
|
||||
return this._editorScrollTop;
|
||||
},
|
||||
set: function(editorScrollTop) {
|
||||
this._editorScrollTop = editorScrollTop;
|
||||
storage[this.fileIndex + ".editorScrollTop"] = editorScrollTop;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'editorStart', {
|
||||
get: function() {
|
||||
return this._editorStart;
|
||||
},
|
||||
set: function(editorStart) {
|
||||
this._editorStart = editorStart;
|
||||
storage[this.fileIndex + ".editorStart"] = editorStart;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'editorEnd', {
|
||||
get: function() {
|
||||
return this._editorEnd;
|
||||
},
|
||||
set: function(editorEnd) {
|
||||
this._editorEnd = editorEnd;
|
||||
storage[this.fileIndex + ".editorEnd"] = editorEnd;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'previewScrollTop', {
|
||||
get: function() {
|
||||
return this._previewScrollTop;
|
||||
},
|
||||
set: function(previewScrollTop) {
|
||||
this._previewScrollTop = previewScrollTop;
|
||||
storage[this.fileIndex + ".previewScrollTop"] = previewScrollTop;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'selectTime', {
|
||||
get: function() {
|
||||
return this._selectTime;
|
||||
},
|
||||
set: function(selectTime) {
|
||||
this._selectTime = selectTime;
|
||||
storage[this.fileIndex + ".selectTime"] = selectTime;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'discussionList', {
|
||||
get: function() {
|
||||
return this._discussionList;
|
||||
},
|
||||
set: function(discussionList) {
|
||||
this._discussionList = discussionList;
|
||||
storage[this.fileIndex + ".discussionList"] = JSON.stringify(discussionList);
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'discussionListJSON', {
|
||||
get: function() {
|
||||
return storage[this.fileIndex + ".discussionList"] || '{}';
|
||||
},
|
||||
set: function(discussionList) {
|
||||
this._discussionList = JSON.parse(discussionList);
|
||||
storage[this.fileIndex + ".discussionList"] = discussionList;
|
||||
}
|
||||
});
|
||||
}
|
||||
function FileDescriptor(fileIndex, title, syncLocations, publishLocations) {
|
||||
this.fileIndex = fileIndex;
|
||||
this._title = title || storage[fileIndex + ".title"];
|
||||
this._editorScrollTop = parseInt(storage[fileIndex + ".editorScrollTop"]) || 0;
|
||||
this._editorStart = parseInt(storage[fileIndex + ".editorEnd"]) || 0;
|
||||
this._editorEnd = parseInt(storage[fileIndex + ".editorEnd"]) || 0;
|
||||
this._previewScrollTop = parseInt(storage[fileIndex + ".previewScrollTop"]) || 0;
|
||||
this._selectTime = parseInt(storage[fileIndex + ".selectTime"]) || 0;
|
||||
this._discussionList = JSON.parse(storage[fileIndex + ".discussionList"] || '{}');
|
||||
this.syncLocations = syncLocations || {};
|
||||
this.publishLocations = publishLocations || {};
|
||||
Object.defineProperty(this, 'title', {
|
||||
get: function() {
|
||||
return this._title;
|
||||
},
|
||||
set: function(title) {
|
||||
this._title = title;
|
||||
storage[this.fileIndex + ".title"] = title;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'content', {
|
||||
get: function() {
|
||||
return storage[this.fileIndex + ".content"];
|
||||
},
|
||||
set: function(content) {
|
||||
storage[this.fileIndex + ".content"] = content;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'editorScrollTop', {
|
||||
get: function() {
|
||||
return this._editorScrollTop;
|
||||
},
|
||||
set: function(editorScrollTop) {
|
||||
this._editorScrollTop = editorScrollTop;
|
||||
storage[this.fileIndex + ".editorScrollTop"] = editorScrollTop;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'editorStart', {
|
||||
get: function() {
|
||||
return this._editorStart;
|
||||
},
|
||||
set: function(editorStart) {
|
||||
this._editorStart = editorStart;
|
||||
storage[this.fileIndex + ".editorStart"] = editorStart;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'editorEnd', {
|
||||
get: function() {
|
||||
return this._editorEnd;
|
||||
},
|
||||
set: function(editorEnd) {
|
||||
this._editorEnd = editorEnd;
|
||||
storage[this.fileIndex + ".editorEnd"] = editorEnd;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'previewScrollTop', {
|
||||
get: function() {
|
||||
return this._previewScrollTop;
|
||||
},
|
||||
set: function(previewScrollTop) {
|
||||
this._previewScrollTop = previewScrollTop;
|
||||
storage[this.fileIndex + ".previewScrollTop"] = previewScrollTop;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'selectTime', {
|
||||
get: function() {
|
||||
return this._selectTime;
|
||||
},
|
||||
set: function(selectTime) {
|
||||
this._selectTime = selectTime;
|
||||
storage[this.fileIndex + ".selectTime"] = selectTime;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'discussionList', {
|
||||
get: function() {
|
||||
return this._discussionList;
|
||||
},
|
||||
set: function(discussionList) {
|
||||
this._discussionList = discussionList;
|
||||
storage[this.fileIndex + ".discussionList"] = JSON.stringify(discussionList);
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, 'discussionListJSON', {
|
||||
get: function() {
|
||||
return storage[this.fileIndex + ".discussionList"] || '{}';
|
||||
},
|
||||
set: function(discussionList) {
|
||||
this._discussionList = JSON.parse(discussionList);
|
||||
storage[this.fileIndex + ".discussionList"] = discussionList;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
FileDescriptor.prototype.addSyncLocation = function(syncAttributes) {
|
||||
utils.storeAttributes(syncAttributes);
|
||||
utils.appendIndexToArray(this.fileIndex + ".sync", syncAttributes.syncIndex);
|
||||
this.syncLocations[syncAttributes.syncIndex] = syncAttributes;
|
||||
};
|
||||
FileDescriptor.prototype.addSyncLocation = function(syncAttributes) {
|
||||
utils.storeAttributes(syncAttributes);
|
||||
utils.appendIndexToArray(this.fileIndex + ".sync", syncAttributes.syncIndex);
|
||||
this.syncLocations[syncAttributes.syncIndex] = syncAttributes;
|
||||
};
|
||||
|
||||
FileDescriptor.prototype.removeSyncLocation = function(syncAttributes) {
|
||||
utils.removeIndexFromArray(this.fileIndex + ".sync", syncAttributes.syncIndex);
|
||||
delete this.syncLocations[syncAttributes.syncIndex];
|
||||
};
|
||||
FileDescriptor.prototype.removeSyncLocation = function(syncAttributes) {
|
||||
utils.removeIndexFromArray(this.fileIndex + ".sync", syncAttributes.syncIndex);
|
||||
delete this.syncLocations[syncAttributes.syncIndex];
|
||||
};
|
||||
|
||||
FileDescriptor.prototype.addPublishLocation = function(publishAttributes) {
|
||||
utils.storeAttributes(publishAttributes);
|
||||
utils.appendIndexToArray(this.fileIndex + ".publish", publishAttributes.publishIndex);
|
||||
this.publishLocations[publishAttributes.publishIndex] = publishAttributes;
|
||||
};
|
||||
FileDescriptor.prototype.addPublishLocation = function(publishAttributes) {
|
||||
utils.storeAttributes(publishAttributes);
|
||||
utils.appendIndexToArray(this.fileIndex + ".publish", publishAttributes.publishIndex);
|
||||
this.publishLocations[publishAttributes.publishIndex] = publishAttributes;
|
||||
};
|
||||
|
||||
FileDescriptor.prototype.removePublishLocation = function(publishAttributes) {
|
||||
utils.removeIndexFromArray(this.fileIndex + ".publish", publishAttributes.publishIndex);
|
||||
delete this.publishLocations[publishAttributes.publishIndex];
|
||||
};
|
||||
FileDescriptor.prototype.removePublishLocation = function(publishAttributes) {
|
||||
utils.removeIndexFromArray(this.fileIndex + ".publish", publishAttributes.publishIndex);
|
||||
delete this.publishLocations[publishAttributes.publishIndex];
|
||||
};
|
||||
|
||||
FileDescriptor.prototype.composeTitle = function() {
|
||||
var result = [];
|
||||
_.chain(this.syncLocations).sortBy(function(attributes) {
|
||||
return attributes.provider.providerId;
|
||||
}).each(function(attributes) {
|
||||
result.push('<i class="icon-provider-' + attributes.provider.providerId + '"></i>');
|
||||
});
|
||||
if(_.size(this.syncLocations) !== 0) {
|
||||
result.push('<i class="icon-refresh title-icon-category"></i>');
|
||||
}
|
||||
_.chain(this.publishLocations).sortBy(function(attributes) {
|
||||
return attributes.provider.providerId;
|
||||
}).each(function(attributes) {
|
||||
result.push('<i class="icon-provider-' + attributes.provider.providerId + '"></i>');
|
||||
});
|
||||
if(_.size(this.publishLocations) !== 0) {
|
||||
result.push('<i class="icon-upload title-icon-category"></i>');
|
||||
}
|
||||
result.push(_.escape(this.title));
|
||||
return result.join('');
|
||||
};
|
||||
function addIcon(result, attributes) {
|
||||
result.push('<i class="icon-provider-' + attributes.provider.providerId + '"></i>');
|
||||
}
|
||||
|
||||
return FileDescriptor;
|
||||
function addSyncIconWithLink(result, attributes) {
|
||||
if(attributes.provider.getSyncLocationLink) {
|
||||
var syncLocationLink = attributes.provider.getSyncLocationLink(attributes);
|
||||
result.push([
|
||||
'<a href="',
|
||||
syncLocationLink,
|
||||
'" target="_blank" title="Open in ',
|
||||
attributes.provider.providerName,
|
||||
'"><i class="icon-provider-',
|
||||
attributes.provider.providerId,
|
||||
'"></i><i class="icon-link-ext-alt"></i></a>'
|
||||
].join(''));
|
||||
}
|
||||
else {
|
||||
addIcon(result, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
function addPublishIconWithLink(result, attributes) {
|
||||
if(attributes.provider.getPublishLocationLink) {
|
||||
var publishLocationLink = attributes.provider.getPublishLocationLink(attributes);
|
||||
result.push([
|
||||
'<a href="',
|
||||
publishLocationLink,
|
||||
'" target="_blank" title="Open in ',
|
||||
attributes.provider.providerName,
|
||||
'"><i class="icon-provider-',
|
||||
attributes.provider.providerId,
|
||||
'"></i><i class="icon-link-ext-alt"></i></a>'
|
||||
].join(''));
|
||||
}
|
||||
else {
|
||||
addIcon(result, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
FileDescriptor.prototype.composeTitle = function(createLinks) {
|
||||
var result = [];
|
||||
var addSyncIcon = createLinks ? addSyncIconWithLink : addIcon;
|
||||
var addPublishIcon = createLinks ? addPublishIconWithLink : addIcon;
|
||||
_.chain(this.syncLocations).sortBy(function(attributes) {
|
||||
return attributes.provider.providerId;
|
||||
}).each(function(attributes) {
|
||||
addSyncIcon(result, attributes);
|
||||
});
|
||||
if(_.size(this.syncLocations) !== 0) {
|
||||
result.push('<i class="icon-refresh title-icon-category"></i>');
|
||||
}
|
||||
_.chain(this.publishLocations).sortBy(function(attributes) {
|
||||
return attributes.provider.providerId;
|
||||
}).each(function(attributes) {
|
||||
addPublishIcon(result, attributes);
|
||||
});
|
||||
if(_.size(this.publishLocations) !== 0) {
|
||||
result.push('<i class="icon-upload title-icon-category"></i>');
|
||||
}
|
||||
result.push(_.escape(this.title));
|
||||
return result.join('');
|
||||
};
|
||||
|
||||
return FileDescriptor;
|
||||
});
|
||||
|
@ -145,6 +145,8 @@ define([
|
||||
utils.setInputValue("#textarea-settings-pdf-template", settings.pdfTemplate);
|
||||
// PDF options
|
||||
utils.setInputValue("#textarea-settings-pdf-options", settings.pdfOptions);
|
||||
// CouchDB URL
|
||||
utils.setInputValue("#input-settings-couchdb-url", settings.couchdbUrl);
|
||||
|
||||
// Load extension settings
|
||||
eventMgr.onLoadSettings();
|
||||
@ -190,6 +192,8 @@ define([
|
||||
newSettings.pdfTemplate = utils.getInputTextValue("#textarea-settings-pdf-template", event);
|
||||
// PDF options
|
||||
newSettings.pdfOptions = utils.getInputJSONValue("#textarea-settings-pdf-options", event);
|
||||
// CouchDB URL
|
||||
newSettings.couchdbUrl = utils.getInputValue("#input-settings-couchdb-url", event);
|
||||
|
||||
// Save extension settings
|
||||
newSettings.extensionSettings = {};
|
||||
|
@ -172,6 +172,7 @@ define([
|
||||
addEventHook("onFileMgrCreated");
|
||||
addEventHook("onSynchronizerCreated");
|
||||
addEventHook("onPublisherCreated");
|
||||
addEventHook("onSharingCreated");
|
||||
addEventHook("onEventMgrCreated");
|
||||
|
||||
// Operations on files
|
||||
|
@ -1,61 +1,62 @@
|
||||
define([
|
||||
"jquery",
|
||||
"underscore",
|
||||
"classes/Extension",
|
||||
"text!html/dialogManagePublicationLocation.html",
|
||||
"jquery",
|
||||
"underscore",
|
||||
"classes/Extension",
|
||||
"text!html/dialogManagePublicationLocation.html",
|
||||
], function($, _, Extension, dialogManagePublicationLocationHTML) {
|
||||
|
||||
var dialogManagePublication = new Extension("dialogManagePublication", 'Dialog "Manage publication"', false, true);
|
||||
var dialogManagePublication = new Extension("dialogManagePublication", 'Dialog "Manage publication"', false, true);
|
||||
|
||||
var eventMgr;
|
||||
dialogManagePublication.onEventMgrCreated = function(eventMgrParameter) {
|
||||
eventMgr = eventMgrParameter;
|
||||
};
|
||||
var eventMgr;
|
||||
dialogManagePublication.onEventMgrCreated = function(eventMgrParameter) {
|
||||
eventMgr = eventMgrParameter;
|
||||
};
|
||||
|
||||
var fileDesc;
|
||||
var publishListElt;
|
||||
var $showAlreadyPublishedElt;
|
||||
var refreshDialog = function(fileDescParameter) {
|
||||
if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) {
|
||||
return;
|
||||
}
|
||||
var fileDesc;
|
||||
var publishListElt;
|
||||
var $showAlreadyPublishedElt;
|
||||
var refreshDialog = function(fileDescParameter) {
|
||||
if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) {
|
||||
return;
|
||||
}
|
||||
|
||||
$showAlreadyPublishedElt.toggleClass("hide", _.size(fileDesc.publishLocations) === 0);
|
||||
$showAlreadyPublishedElt.toggleClass("hide", _.size(fileDesc.publishLocations) === 0);
|
||||
|
||||
var publishListHtml = _.reduce(fileDesc.publishLocations, function(result, publishAttributes) {
|
||||
var formattedAttributes = _.omit(publishAttributes, "provider", "publishIndex", "sharingLink");
|
||||
formattedAttributes.password && (formattedAttributes.password = "********");
|
||||
formattedAttributes = JSON.stringify(formattedAttributes).replace(/{|}|"/g, "").replace(/,/g, ", ");
|
||||
return result + _.template(dialogManagePublicationLocationHTML, {
|
||||
publishAttributes: publishAttributes,
|
||||
publishDesc: formattedAttributes
|
||||
});
|
||||
}, '');
|
||||
var publishListHtml = _.reduce(fileDesc.publishLocations, function(result, publishAttributes) {
|
||||
var formattedAttributes = _.omit(publishAttributes, "provider", "publishIndex");
|
||||
formattedAttributes.password && (formattedAttributes.password = "********");
|
||||
formattedAttributes = JSON.stringify(formattedAttributes).replace(/{|}|"/g, "").replace(/,/g, ", ");
|
||||
return result + _.template(dialogManagePublicationLocationHTML, {
|
||||
publishAttributes: publishAttributes,
|
||||
publishDesc: formattedAttributes,
|
||||
publishLocationLink: publishAttributes.provider.getPublishLocationLink && publishAttributes.provider.getPublishLocationLink(publishAttributes)
|
||||
});
|
||||
}, '');
|
||||
|
||||
publishListElt.innerHTML = publishListHtml;
|
||||
};
|
||||
publishListElt.innerHTML = publishListHtml;
|
||||
};
|
||||
|
||||
dialogManagePublication.onFileSelected = function(fileDescParameter) {
|
||||
fileDesc = fileDescParameter;
|
||||
refreshDialog(fileDescParameter);
|
||||
};
|
||||
dialogManagePublication.onFileSelected = function(fileDescParameter) {
|
||||
fileDesc = fileDescParameter;
|
||||
refreshDialog(fileDescParameter);
|
||||
};
|
||||
|
||||
dialogManagePublication.onNewPublishSuccess = refreshDialog;
|
||||
dialogManagePublication.onPublishRemoved = refreshDialog;
|
||||
dialogManagePublication.onNewPublishSuccess = refreshDialog;
|
||||
dialogManagePublication.onPublishRemoved = refreshDialog;
|
||||
|
||||
dialogManagePublication.onReady = function() {
|
||||
var modalElt = document.querySelector(".modal-manage-publish");
|
||||
publishListElt = modalElt.querySelector(".publish-list");
|
||||
dialogManagePublication.onReady = function() {
|
||||
var modalElt = document.querySelector(".modal-manage-publish");
|
||||
publishListElt = modalElt.querySelector(".publish-list");
|
||||
|
||||
$showAlreadyPublishedElt = $(document.querySelectorAll(".show-already-published"));
|
||||
$showAlreadyPublishedElt = $(document.querySelectorAll(".show-already-published"));
|
||||
|
||||
$(publishListElt).on('click', '.remove-button', function() {
|
||||
var $removeButtonElt = $(this);
|
||||
var publishAttributes = fileDesc.publishLocations[$removeButtonElt.data('publishIndex')];
|
||||
fileDesc.removePublishLocation(publishAttributes);
|
||||
eventMgr.onPublishRemoved(fileDesc, publishAttributes);
|
||||
});
|
||||
};
|
||||
$(publishListElt).on('click', '.remove-button', function() {
|
||||
var $removeButtonElt = $(this);
|
||||
var publishAttributes = fileDesc.publishLocations[$removeButtonElt.data('publishIndex')];
|
||||
fileDesc.removePublishLocation(publishAttributes);
|
||||
eventMgr.onPublishRemoved(fileDesc, publishAttributes);
|
||||
});
|
||||
};
|
||||
|
||||
return dialogManagePublication;
|
||||
return dialogManagePublication;
|
||||
});
|
||||
|
@ -1,63 +1,70 @@
|
||||
define([
|
||||
"jquery",
|
||||
"underscore",
|
||||
"classes/Extension",
|
||||
"text!html/dialogManageSharingLocation.html"
|
||||
], function($, _, Extension, dialogManageSharingLocationHTML) {
|
||||
"jquery",
|
||||
"underscore",
|
||||
"constants",
|
||||
"classes/Extension",
|
||||
"text!html/dialogManageSharingLocation.html"
|
||||
], function($, _, constants, Extension, dialogManageSharingLocationHTML) {
|
||||
|
||||
var dialogManageSharing = new Extension("dialogManageSharing", 'Button "Share"', false, true);
|
||||
var dialogManageSharing = new Extension("dialogManageSharing", 'Button "Share"', false, true);
|
||||
|
||||
var eventMgr;
|
||||
dialogManageSharing.onEventMgrCreated = function(eventMgrParam) {
|
||||
eventMgr = eventMgrParam;
|
||||
};
|
||||
var eventMgr;
|
||||
dialogManageSharing.onEventMgrCreated = function(eventMgrParam) {
|
||||
eventMgr = eventMgrParam;
|
||||
};
|
||||
var sharing;
|
||||
dialogManageSharing.onSharingCreated = function(sharingParam) {
|
||||
sharing = sharingParam;
|
||||
};
|
||||
|
||||
var fileDesc;
|
||||
var shareListElt;
|
||||
var $msgShareListElt;
|
||||
var $msgNoShareElt;
|
||||
var refreshDocumentSharing = function(fileDescParameter) {
|
||||
if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) {
|
||||
return;
|
||||
}
|
||||
var fileDesc;
|
||||
var shareListElt;
|
||||
var $msgShareListElt;
|
||||
var $msgNoShareElt;
|
||||
var refreshDocumentSharing = function(fileDescParameter) {
|
||||
if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) {
|
||||
return;
|
||||
}
|
||||
|
||||
var linkListHtml = _.reduce(fileDesc.publishLocations, function(result, attributes) {
|
||||
if(attributes.sharingLink) {
|
||||
result += _.template(dialogManageSharingLocationHTML, {
|
||||
link: attributes.sharingLink,
|
||||
title: fileDesc.title
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}, '');
|
||||
shareListElt.innerHTML = linkListHtml;
|
||||
var linkListHtml = _.reduce(fileDesc.publishLocations, function(result, attributes) {
|
||||
var params = sharing.getViewerParams(attributes);
|
||||
if(params) {
|
||||
var link = constants.MAIN_URL + 'viewer?' + $.param(params);
|
||||
result += _.template(dialogManageSharingLocationHTML, {
|
||||
link: link,
|
||||
title: fileDesc.title
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}, '');
|
||||
shareListElt.innerHTML = linkListHtml;
|
||||
|
||||
$msgShareListElt.toggleClass('hide', linkListHtml.length === 0);
|
||||
$msgNoShareElt.toggleClass('hide', linkListHtml.length !== 0);
|
||||
};
|
||||
$msgShareListElt.toggleClass('hide', linkListHtml.length === 0);
|
||||
$msgNoShareElt.toggleClass('hide', linkListHtml.length !== 0);
|
||||
};
|
||||
|
||||
dialogManageSharing.onFileSelected = function(fileDescParameter) {
|
||||
fileDesc = fileDescParameter;
|
||||
refreshDocumentSharing(fileDescParameter);
|
||||
};
|
||||
dialogManageSharing.onFileSelected = function(fileDescParameter) {
|
||||
fileDesc = fileDescParameter;
|
||||
refreshDocumentSharing(fileDescParameter);
|
||||
};
|
||||
|
||||
dialogManageSharing.onNewPublishSuccess = function(fileDescParameter, publishAttributes) {
|
||||
refreshDocumentSharing(fileDescParameter);
|
||||
if(publishAttributes.sharingLink) {
|
||||
$('.modal').modal('hide');
|
||||
$('.modal-manage-sharing').modal('show');
|
||||
}
|
||||
};
|
||||
dialogManageSharing.onNewPublishSuccess = function(fileDescParameter, publishAttributes) {
|
||||
refreshDocumentSharing(fileDescParameter);
|
||||
if(sharing.getViewerParams(publishAttributes)) {
|
||||
$('.modal').modal('hide');
|
||||
$('.modal-manage-sharing').modal('show');
|
||||
}
|
||||
};
|
||||
|
||||
dialogManageSharing.onPublishRemoved = refreshDocumentSharing;
|
||||
dialogManageSharing.onPublishRemoved = refreshDocumentSharing;
|
||||
|
||||
dialogManageSharing.onReady = function() {
|
||||
var modalElt = document.querySelector('.modal-manage-sharing');
|
||||
shareListElt = modalElt.querySelector('.share-list');
|
||||
$msgShareListElt = $(modalElt.querySelectorAll('.msg-share-list'));
|
||||
$msgNoShareElt = $(modalElt.querySelectorAll('.msg-no-share'));
|
||||
};
|
||||
dialogManageSharing.onReady = function() {
|
||||
var modalElt = document.querySelector('.modal-manage-sharing');
|
||||
shareListElt = modalElt.querySelector('.share-list');
|
||||
$msgShareListElt = $(modalElt.querySelectorAll('.msg-share-list'));
|
||||
$msgNoShareElt = $(modalElt.querySelectorAll('.msg-no-share'));
|
||||
};
|
||||
|
||||
return dialogManageSharing;
|
||||
return dialogManageSharing;
|
||||
|
||||
});
|
@ -1,64 +1,65 @@
|
||||
define([
|
||||
"jquery",
|
||||
"underscore",
|
||||
"classes/Extension",
|
||||
"text!html/dialogManageSynchronizationLocation.html",
|
||||
"jquery",
|
||||
"underscore",
|
||||
"classes/Extension",
|
||||
"text!html/dialogManageSynchronizationLocation.html",
|
||||
], function($, _, Extension, dialogManageSynchronizationLocationHTML) {
|
||||
|
||||
var dialogManageSynchronization = new Extension("dialogManageSynchronization", 'Dialog "Manage synchronization"', false, true);
|
||||
var dialogManageSynchronization = new Extension("dialogManageSynchronization", 'Dialog "Manage synchronization"', false, true);
|
||||
|
||||
var eventMgr;
|
||||
dialogManageSynchronization.onEventMgrCreated = function(eventMgrParameter) {
|
||||
eventMgr = eventMgrParameter;
|
||||
};
|
||||
var eventMgr;
|
||||
dialogManageSynchronization.onEventMgrCreated = function(eventMgrParameter) {
|
||||
eventMgr = eventMgrParameter;
|
||||
};
|
||||
|
||||
var synchronizer;
|
||||
dialogManageSynchronization.onSynchronizerCreated = function(synchronizerParameter) {
|
||||
synchronizer = synchronizerParameter;
|
||||
};
|
||||
var synchronizer;
|
||||
dialogManageSynchronization.onSynchronizerCreated = function(synchronizerParameter) {
|
||||
synchronizer = synchronizerParameter;
|
||||
};
|
||||
|
||||
var fileDesc;
|
||||
var syncListElt;
|
||||
var $showAlreadySynchronizedElt;
|
||||
var refreshDialog = function(fileDescParameter) {
|
||||
if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) {
|
||||
return;
|
||||
}
|
||||
var fileDesc;
|
||||
var syncListElt;
|
||||
var $showAlreadySynchronizedElt;
|
||||
var refreshDialog = function(fileDescParameter) {
|
||||
if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) {
|
||||
return;
|
||||
}
|
||||
|
||||
$showAlreadySynchronizedElt.toggleClass("hide", _.size(fileDesc.syncLocations) === 0);
|
||||
$showAlreadySynchronizedElt.toggleClass("hide", _.size(fileDesc.syncLocations) === 0);
|
||||
|
||||
var syncListHtml = _.reduce(fileDesc.syncLocations, function(result, syncAttributes) {
|
||||
return result + _.template(dialogManageSynchronizationLocationHTML, {
|
||||
syncAttributes: syncAttributes,
|
||||
syncDesc: syncAttributes.id || syncAttributes.path
|
||||
});
|
||||
}, '');
|
||||
var syncListHtml = _.reduce(fileDesc.syncLocations, function(result, syncAttributes) {
|
||||
return result + _.template(dialogManageSynchronizationLocationHTML, {
|
||||
syncAttributes: syncAttributes,
|
||||
syncDesc: syncAttributes.id || syncAttributes.path,
|
||||
syncLocationLink: syncAttributes.provider.getSyncLocationLink && syncAttributes.provider.getSyncLocationLink(syncAttributes)
|
||||
});
|
||||
}, '');
|
||||
|
||||
syncListElt.innerHTML = syncListHtml;
|
||||
};
|
||||
syncListElt.innerHTML = syncListHtml;
|
||||
};
|
||||
|
||||
dialogManageSynchronization.onFileSelected = function(fileDescParameter) {
|
||||
fileDesc = fileDescParameter;
|
||||
refreshDialog(fileDescParameter);
|
||||
};
|
||||
dialogManageSynchronization.onFileSelected = function(fileDescParameter) {
|
||||
fileDesc = fileDescParameter;
|
||||
refreshDialog(fileDescParameter);
|
||||
};
|
||||
|
||||
dialogManageSynchronization.onSyncExportSuccess = refreshDialog;
|
||||
dialogManageSynchronization.onSyncRemoved = refreshDialog;
|
||||
dialogManageSynchronization.onSyncExportSuccess = refreshDialog;
|
||||
dialogManageSynchronization.onSyncRemoved = refreshDialog;
|
||||
|
||||
dialogManageSynchronization.onReady = function() {
|
||||
var modalElt = document.querySelector(".modal-manage-sync");
|
||||
syncListElt = modalElt.querySelector(".sync-list");
|
||||
dialogManageSynchronization.onReady = function() {
|
||||
var modalElt = document.querySelector(".modal-manage-sync");
|
||||
syncListElt = modalElt.querySelector(".sync-list");
|
||||
|
||||
$showAlreadySynchronizedElt = $(document.querySelectorAll(".show-already-synchronized"));
|
||||
$showAlreadySynchronizedElt = $(document.querySelectorAll(".show-already-synchronized"));
|
||||
|
||||
$(syncListElt).on('click', '.remove-button', function() {
|
||||
var $removeButtonElt = $(this);
|
||||
var syncAttributes = fileDesc.syncLocations[$removeButtonElt.data('syncIndex')];
|
||||
fileDesc.removeSyncLocation(syncAttributes);
|
||||
eventMgr.onSyncRemoved(fileDesc, syncAttributes);
|
||||
});
|
||||
};
|
||||
$(syncListElt).on('click', '.remove-button', function() {
|
||||
var $removeButtonElt = $(this);
|
||||
var syncAttributes = fileDesc.syncLocations[$removeButtonElt.data('syncIndex')];
|
||||
fileDesc.removeSyncLocation(syncAttributes);
|
||||
eventMgr.onSyncRemoved(fileDesc, syncAttributes);
|
||||
});
|
||||
};
|
||||
|
||||
return dialogManageSynchronization;
|
||||
return dialogManageSynchronization;
|
||||
|
||||
});
|
||||
|
@ -14,7 +14,7 @@ define([
|
||||
}
|
||||
|
||||
var title = fileDesc.title;
|
||||
$fileTitleNavbar.html(fileDesc.composeTitle());
|
||||
$fileTitleNavbar.html(fileDesc.composeTitle(true));
|
||||
$(".file-title").text(title);
|
||||
$(".input-file-title").val(title);
|
||||
}, 50);
|
||||
|
@ -1,7 +1,6 @@
|
||||
define([
|
||||
"jquery",
|
||||
"underscore",
|
||||
"constants",
|
||||
"core",
|
||||
"utils",
|
||||
"storage",
|
||||
@ -9,7 +8,7 @@ define([
|
||||
"settings",
|
||||
"eventMgr",
|
||||
"classes/AsyncTask"
|
||||
], function($, _, constants, core, utils, storage, logger, settings, eventMgr, AsyncTask) {
|
||||
], function($, _, core, utils, storage, logger, settings, eventMgr, AsyncTask) {
|
||||
|
||||
var couchdbHelper = {};
|
||||
|
||||
@ -26,7 +25,7 @@ define([
|
||||
if(tags) {
|
||||
// Has to be an array
|
||||
if(!_.isArray(tags)) {
|
||||
tags = _.chain(('' + tags).split(/\s+/))
|
||||
tags = _.chain(('' + tags).split(/,/))
|
||||
.compact()
|
||||
.unique()
|
||||
.value();
|
||||
@ -43,7 +42,7 @@ define([
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: constants.COUCHDB_URL,
|
||||
url: settings.couchdbUrl,
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
data: JSON.stringify({
|
||||
@ -82,7 +81,7 @@ define([
|
||||
task.onRun(function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: constants.COUCHDB_URL + '/_changes?' + $.param({
|
||||
url: settings.couchdbUrl + '/_changes?' + $.param({
|
||||
filter: '_doc_ids',
|
||||
since: newChangeId,
|
||||
include_docs: true,
|
||||
@ -130,7 +129,7 @@ define([
|
||||
return task.chain(recursiveDownloadContent);
|
||||
}
|
||||
$.ajax({
|
||||
url: constants.COUCHDB_URL + '/' + encodeURIComponent(document._id),
|
||||
url: settings.couchdbUrl + '/' + encodeURIComponent(document._id),
|
||||
headers: {
|
||||
Accept: 'application/json'
|
||||
},
|
||||
@ -172,7 +171,7 @@ define([
|
||||
tag
|
||||
]) : undefined;
|
||||
$.ajax({
|
||||
url: constants.COUCHDB_URL + ddoc,
|
||||
url: settings.couchdbUrl + ddoc,
|
||||
data: {
|
||||
start_key: startKey,
|
||||
end_key: endKey,
|
||||
@ -203,7 +202,7 @@ define([
|
||||
task.onRun(function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: constants.COUCHDB_URL + '/_bulk_docs',
|
||||
url: settings.couchdbUrl + '/_bulk_docs',
|
||||
data: JSON.stringify({
|
||||
docs: docs.map(function(doc) {
|
||||
return {
|
||||
|
@ -8,7 +8,7 @@ define([
|
||||
"logger",
|
||||
"settings",
|
||||
"eventMgr",
|
||||
"classes/AsyncTask",
|
||||
"classes/AsyncTask"
|
||||
], function($, constants, core, utils, storage, logger, settings, eventMgr, AsyncTask) {
|
||||
|
||||
var connected;
|
||||
@ -162,7 +162,7 @@ define([
|
||||
}
|
||||
});
|
||||
task.onSuccess(function() {
|
||||
callback();
|
||||
callback(undefined, username);
|
||||
});
|
||||
task.onError(function(error) {
|
||||
callback(error);
|
||||
|
@ -108,12 +108,17 @@ define([
|
||||
]
|
||||
};
|
||||
|
||||
function authenticate(task, permission, accountId) {
|
||||
googleHelper.getAuthorizationMgr = function(accountId) {
|
||||
var authorizationMgr = authorizationMgrMap[accountId];
|
||||
if(!authorizationMgr) {
|
||||
authorizationMgr = new AuthorizationMgr(accountId);
|
||||
authorizationMgrMap[accountId] = authorizationMgr;
|
||||
}
|
||||
return authorizationMgr;
|
||||
};
|
||||
|
||||
function authenticate(task, permission, accountId) {
|
||||
var authorizationMgr = googleHelper.getAuthorizationMgr(accountId);
|
||||
task.onRun(function() {
|
||||
var currentToken = gapi.auth.getToken();
|
||||
var newToken;
|
||||
@ -185,6 +190,7 @@ define([
|
||||
}
|
||||
else {
|
||||
// Success but we need to check the user id
|
||||
authorizationMgr.authuser = authuser;
|
||||
immediate === true && authuser++;
|
||||
task.chain(getTokenInfo);
|
||||
}
|
||||
|
@ -1,182 +1,183 @@
|
||||
define([
|
||||
"jquery",
|
||||
"constants",
|
||||
"core",
|
||||
"utils",
|
||||
"storage",
|
||||
"logger",
|
||||
"eventMgr",
|
||||
"classes/AsyncTask"
|
||||
"jquery",
|
||||
"constants",
|
||||
"core",
|
||||
"utils",
|
||||
"storage",
|
||||
"logger",
|
||||
"eventMgr",
|
||||
"classes/AsyncTask"
|
||||
], function($, constants, core, utils, storage, logger, eventMgr, AsyncTask) {
|
||||
|
||||
var token;
|
||||
var token;
|
||||
|
||||
var wordpressHelper = {};
|
||||
var wordpressHelper = {};
|
||||
|
||||
// Listen to offline status changes
|
||||
var isOffline = false;
|
||||
eventMgr.addListener("onOfflineChanged", function(isOfflineParam) {
|
||||
isOffline = isOfflineParam;
|
||||
});
|
||||
// Listen to offline status changes
|
||||
var isOffline = false;
|
||||
eventMgr.addListener("onOfflineChanged", function(isOfflineParam) {
|
||||
isOffline = isOfflineParam;
|
||||
});
|
||||
|
||||
// Only used to check the offline status
|
||||
function connect(task) {
|
||||
task.onRun(function() {
|
||||
if(isOffline === true) {
|
||||
task.error(new Error("Operation not available in offline mode.|stopPublish"));
|
||||
return;
|
||||
}
|
||||
task.chain();
|
||||
});
|
||||
}
|
||||
// Only used to check the offline status
|
||||
function connect(task) {
|
||||
task.onRun(function() {
|
||||
if(isOffline === true) {
|
||||
return task.error(new Error("Operation not available in offline mode.|stopPublish"));
|
||||
}
|
||||
task.chain();
|
||||
});
|
||||
}
|
||||
|
||||
// Try to authenticate with OAuth
|
||||
function authenticate(task) {
|
||||
var authWindow;
|
||||
var intervalId;
|
||||
task.onRun(function() {
|
||||
token = storage.wordpressToken;
|
||||
if(token !== undefined) {
|
||||
task.chain();
|
||||
return;
|
||||
}
|
||||
var errorMsg = "Failed to retrieve a token from Wordpress.";
|
||||
// We add time for user to enter his credentials
|
||||
task.timeout = constants.ASYNC_TASK_LONG_TIMEOUT;
|
||||
var code;
|
||||
function oauthRedirect() {
|
||||
utils.redirectConfirm('You are being redirected to <strong>WordPress</strong> authorization page.', function() {
|
||||
task.chain(getCode);
|
||||
}, function() {
|
||||
task.error(new Error('Operation canceled.'));
|
||||
});
|
||||
}
|
||||
function getCode() {
|
||||
storage.removeItem("wordpressCode");
|
||||
authWindow = utils.popupWindow('html/wordpress-oauth-client.html?client_id=' + constants.WORDPRESS_CLIENT_ID, 'stackedit-wordpress-oauth', 960, 600);
|
||||
authWindow.focus();
|
||||
intervalId = setInterval(function() {
|
||||
if(authWindow.closed === true) {
|
||||
clearInterval(intervalId);
|
||||
authWindow = undefined;
|
||||
intervalId = undefined;
|
||||
code = storage.wordpressCode;
|
||||
if(code === undefined) {
|
||||
task.error(new Error(errorMsg));
|
||||
return;
|
||||
}
|
||||
storage.removeItem("wordpressCode");
|
||||
task.chain(getToken);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
function getToken() {
|
||||
$.getJSON(constants.WORDPRESS_PROXY_URL + "authenticate/" + code, function(data) {
|
||||
if(data.token !== undefined) {
|
||||
token = data.token;
|
||||
storage.wordpressToken = token;
|
||||
task.chain();
|
||||
}
|
||||
else {
|
||||
task.error(new Error(errorMsg));
|
||||
}
|
||||
});
|
||||
}
|
||||
task.chain(oauthRedirect);
|
||||
});
|
||||
task.onError(function() {
|
||||
if(intervalId !== undefined) {
|
||||
clearInterval(intervalId);
|
||||
}
|
||||
if(authWindow !== undefined) {
|
||||
authWindow.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
// Try to authenticate with OAuth
|
||||
function authenticate(task) {
|
||||
var authWindow;
|
||||
var intervalId;
|
||||
task.onRun(function() {
|
||||
token = storage.wordpressToken;
|
||||
if(token !== undefined) {
|
||||
return task.chain();
|
||||
}
|
||||
var errorMsg = "Failed to retrieve a token from Wordpress.";
|
||||
// We add time for user to enter his credentials
|
||||
task.timeout = constants.ASYNC_TASK_LONG_TIMEOUT;
|
||||
var code;
|
||||
|
||||
wordpressHelper.upload = function(site, postId, tags, status, date, title, content, callback) {
|
||||
var task = new AsyncTask();
|
||||
connect(task);
|
||||
authenticate(task);
|
||||
task.onRun(function() {
|
||||
var url = constants.WORDPRESS_PROXY_URL + "post";
|
||||
var data = {
|
||||
token: token,
|
||||
site: site,
|
||||
postId: postId,
|
||||
tags: tags,
|
||||
status: status,
|
||||
date: date,
|
||||
title: title,
|
||||
content: content
|
||||
};
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: data,
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
timeout: constants.AJAX_TIMEOUT
|
||||
}).done(function(response) {
|
||||
if(response.body.ID) {
|
||||
postId = response.body.ID;
|
||||
task.chain();
|
||||
return;
|
||||
}
|
||||
var error = {
|
||||
code: response.code,
|
||||
message: response.body.error
|
||||
};
|
||||
// Handle error
|
||||
if(error.code === 404) {
|
||||
if(error.message == "unknown_blog") {
|
||||
error = 'Site "' + site + '" not found on WordPress.|removePublish';
|
||||
}
|
||||
else if(error.message == "unknown_post") {
|
||||
error = 'Post ' + postId + ' not found on WordPress.|removePublish';
|
||||
}
|
||||
}
|
||||
handleError(error, task);
|
||||
}).fail(function(jqXHR) {
|
||||
var error = {
|
||||
code: jqXHR.status,
|
||||
message: jqXHR.statusText
|
||||
};
|
||||
handleError(error, task);
|
||||
});
|
||||
});
|
||||
task.onSuccess(function() {
|
||||
callback(undefined, postId);
|
||||
});
|
||||
task.onError(function(error) {
|
||||
callback(error);
|
||||
});
|
||||
task.enqueue();
|
||||
};
|
||||
function oauthRedirect() {
|
||||
utils.redirectConfirm('You are being redirected to <strong>WordPress</strong> authorization page.', function() {
|
||||
task.chain(getCode);
|
||||
}, function() {
|
||||
task.error(new Error('Operation canceled.'));
|
||||
});
|
||||
}
|
||||
|
||||
function handleError(error, task) {
|
||||
var errorMsg;
|
||||
if(error) {
|
||||
logger.error(error);
|
||||
// Try to analyze the error
|
||||
if(typeof error === "string") {
|
||||
errorMsg = error;
|
||||
}
|
||||
else {
|
||||
errorMsg = "Could not publish on WordPress.";
|
||||
if((error.code === 400 && error.message == "invalid_token") || error.code === 401 || error.code === 403) {
|
||||
storage.removeItem("wordpressToken");
|
||||
errorMsg = "Access to WordPress account is not authorized.";
|
||||
task.retry(new Error(errorMsg), 1);
|
||||
return;
|
||||
}
|
||||
else if(error.code <= 0) {
|
||||
core.setOffline();
|
||||
errorMsg = "|stopPublish";
|
||||
}
|
||||
}
|
||||
}
|
||||
task.error(new Error(errorMsg));
|
||||
}
|
||||
function getCode() {
|
||||
storage.removeItem("wordpressCode");
|
||||
authWindow = utils.popupWindow('html/wordpress-oauth-client.html?client_id=' + constants.WORDPRESS_CLIENT_ID, 'stackedit-wordpress-oauth', 960, 600);
|
||||
authWindow.focus();
|
||||
intervalId = setInterval(function() {
|
||||
if(authWindow.closed === true) {
|
||||
clearInterval(intervalId);
|
||||
authWindow = undefined;
|
||||
intervalId = undefined;
|
||||
code = storage.wordpressCode;
|
||||
if(code === undefined) {
|
||||
return task.error(new Error(errorMsg));
|
||||
}
|
||||
storage.removeItem("wordpressCode");
|
||||
task.chain(getToken);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
return wordpressHelper;
|
||||
function getToken() {
|
||||
$.getJSON(constants.WORDPRESS_PROXY_URL + "authenticate/" + code, function(data) {
|
||||
if(data.token !== undefined) {
|
||||
token = data.token;
|
||||
storage.wordpressToken = token;
|
||||
task.chain();
|
||||
}
|
||||
else {
|
||||
task.error(new Error(errorMsg));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
task.chain(oauthRedirect);
|
||||
});
|
||||
task.onError(function() {
|
||||
if(intervalId !== undefined) {
|
||||
clearInterval(intervalId);
|
||||
}
|
||||
if(authWindow !== undefined) {
|
||||
authWindow.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
wordpressHelper.upload = function(site, postId, tags, status, date, title, content, callback) {
|
||||
var task = new AsyncTask();
|
||||
connect(task);
|
||||
authenticate(task);
|
||||
var siteId;
|
||||
task.onRun(function() {
|
||||
var url = constants.WORDPRESS_PROXY_URL + "post";
|
||||
var data = {
|
||||
token: token,
|
||||
site: site,
|
||||
postId: postId,
|
||||
tags: tags,
|
||||
status: status,
|
||||
date: date,
|
||||
title: title,
|
||||
content: content
|
||||
};
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: data,
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
timeout: constants.AJAX_TIMEOUT
|
||||
}).done(function(response) {
|
||||
if(response.body.ID) {
|
||||
postId = response.body.ID;
|
||||
siteId = response.body.site_ID;
|
||||
return task.chain();
|
||||
}
|
||||
var error = {
|
||||
code: response.code,
|
||||
message: response.body.error
|
||||
};
|
||||
// Handle error
|
||||
if(error.code === 404) {
|
||||
if(error.message == "unknown_blog") {
|
||||
error = 'Site "' + site + '" not found on WordPress.|removePublish';
|
||||
}
|
||||
else if(error.message == "unknown_post") {
|
||||
error = 'Post ' + postId + ' not found on WordPress.|removePublish';
|
||||
}
|
||||
}
|
||||
handleError(error, task);
|
||||
}).fail(function(jqXHR) {
|
||||
var error = {
|
||||
code: jqXHR.status,
|
||||
message: jqXHR.statusText
|
||||
};
|
||||
handleError(error, task);
|
||||
});
|
||||
});
|
||||
task.onSuccess(function() {
|
||||
callback(undefined, siteId, postId);
|
||||
});
|
||||
task.onError(function(error) {
|
||||
callback(error);
|
||||
});
|
||||
task.enqueue();
|
||||
};
|
||||
|
||||
function handleError(error, task) {
|
||||
var errorMsg;
|
||||
if(error) {
|
||||
logger.error(error);
|
||||
// Try to analyze the error
|
||||
if(typeof error === "string") {
|
||||
errorMsg = error;
|
||||
}
|
||||
else {
|
||||
errorMsg = "Could not publish on WordPress.";
|
||||
if((error.code === 400 && error.message == "invalid_token") || error.code === 401 || error.code === 403) {
|
||||
storage.removeItem("wordpressToken");
|
||||
errorMsg = "Access to WordPress account is not authorized.";
|
||||
return task.retry(new Error(errorMsg), 1);
|
||||
}
|
||||
else if(error.code <= 0) {
|
||||
core.setOffline();
|
||||
errorMsg = "|stopPublish";
|
||||
}
|
||||
}
|
||||
}
|
||||
task.error(new Error(errorMsg));
|
||||
}
|
||||
|
||||
return wordpressHelper;
|
||||
});
|
||||
|
@ -89,7 +89,7 @@
|
||||
<a href="#" data-toggle="collapse" data-target=".collapse-synchronize"
|
||||
class="list-group-item">
|
||||
<div><i class="icon-refresh"></i> Synchronize</div>
|
||||
<small>Open/Save in the Cloud</small>
|
||||
<small>Open, save, collaborate in the Cloud</small>
|
||||
</a>
|
||||
<div class="sub-menu collapse collapse-synchronize clearfix">
|
||||
<ul class="nav alert alert-danger show-already-synchronized">
|
||||
@ -135,7 +135,7 @@
|
||||
Update publication</a></li>
|
||||
<li><a href="#" data-toggle="modal" data-target=".modal-manage-publish"
|
||||
class="action-reset-input"><i class="icon-upload"></i>
|
||||
Manage publishing</a></li>
|
||||
Manage publication</a></li>
|
||||
</ul>
|
||||
<ul class="nav publish-on-provider-list">
|
||||
</ul>
|
||||
@ -572,6 +572,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="msg-default-couchdb hide alert alert-danger"><i class="icon-attention"></i> <b>Careful:</b>
|
||||
You're using the public CouchDB instance.
|
||||
<b>Anybody can open, edit and delete your files there!</b> To setup your own CouchDB instance <a
|
||||
target="blank" href="https://github.com/benweet/stackedit/blob/master/doc/couchdb-setup.md">click
|
||||
here</a>.
|
||||
</p>
|
||||
|
||||
<div class="form-horizontal byid-mode">
|
||||
<div class="form-group">
|
||||
<label for="input-sync-import-couchdb-documentid" class="col-sm-3 control-label">Document
|
||||
@ -638,6 +645,13 @@
|
||||
<h2 class="modal-title">Save on CouchDB</h2>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="msg-default-couchdb hide alert alert-danger"><i class="icon-attention"></i> <b>Careful:</b>
|
||||
You're using the public CouchDB instance.
|
||||
<b>Anybody can open, edit and delete your files there!</b> To setup your own CouchDB instance <a
|
||||
target="blank" href="https://github.com/benweet/stackedit/blob/master/doc/couchdb-setup.md">click
|
||||
here</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This will save "<span class="file-title"></span>" to CouchDB and keep it synchronized.
|
||||
</p>
|
||||
@ -645,6 +659,7 @@
|
||||
<b>Tip:</b> You can use a
|
||||
<a href="http://jekyllrb.com/docs/frontmatter/"
|
||||
target="_blank">YAML front matter</a> to specify tags for your document.
|
||||
Alternatively, you can place comma separated tags in squared brackets at the beginning of the document title.
|
||||
</blockquote>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
@ -1247,10 +1262,25 @@
|
||||
class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label"
|
||||
for="input-settings-couchdb-url">CouchDB URL</label>
|
||||
<div class="col-sm-7">
|
||||
<input type="text" id="input-settings-couchdb-url"
|
||||
class="form-control">
|
||||
<span class="help-block pull-right"><a
|
||||
target="blank"
|
||||
href="https://github.com/benweet/stackedit/blob/master/doc/couchdb-setup.md">Setup
|
||||
your own CouchDB...</a></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="tabpane-settings-extensions">
|
||||
<div class="panel-group accordion-extensions"></div>
|
||||
<span class="help-block pull-right"><a target="_blank"
|
||||
href="https://github.com/benweet/stackedit/blob/master/doc/developer-guide.md#developer-guide">Create
|
||||
your own extension...</a></span>
|
||||
</div>
|
||||
<div class="tab-pane" id="tabpane-settings-utils">
|
||||
<div class="tab-pane-button-container">
|
||||
|
@ -36,6 +36,7 @@
|
||||
Pete Eigel (contributor)<br />
|
||||
wiibaa (contributor)<br />
|
||||
<a target="_blank" href="http://www.hugwebdesign.com/">Daniel Hug</a> (contributor)<br />
|
||||
<a target="_blank" href="https://github.com/kmb32123">Kevin Brey</a> (themer)<br />
|
||||
</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
@ -44,6 +45,9 @@
|
||||
<a href="#" class="sponsorship-button"><img height="30" data-stackedit-src="button.svg" /></a>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>
|
||||
A special thanks to <a target="blank" href="http://www.couchappy.com/">Couchappy</a> for hosting StackEdit's public CouchDB instance.
|
||||
</p>
|
||||
<p>
|
||||
StackEdit <%= version %> – <a target="_blank" href="privacy_policy.html">Privacy Policy</a><br /> Copyright 2013-2014 <a
|
||||
target="_blank" href="https://twitter.com/benweet">Benoit
|
||||
|
@ -19,15 +19,13 @@
|
||||
for="input-sync-export-<%= providerId %>-parentid">Folder ID
|
||||
(optional)</label>
|
||||
<div class="col-lg-8">
|
||||
<div class="input-group">
|
||||
<input type="text" id="input-sync-export-<%= providerId %>-parentid"
|
||||
placeholder="FolderID" class="form-control">
|
||||
<div class="input-group-btn">
|
||||
<a class="btn btn-link action-export-<%= providerId %>-choose-folder"
|
||||
title="Choose folder" data-dismiss="modal"><i
|
||||
class="icon-folder-open"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<input type="text" id="input-sync-export-<%= providerId %>-parentid"
|
||||
placeholder="FolderID" class="form-control">
|
||||
<div class="text-right">
|
||||
<a class="btn btn-link btn-sm action-export-<%= providerId %>-choose-folder"
|
||||
title="Choose folder" data-dismiss="modal"><i
|
||||
class="icon-folder-open"></i> Open folder</a>
|
||||
</div>
|
||||
<span class="help-block"> If no folder ID is supplied, the
|
||||
file will be created in your root folder. </span>
|
||||
</div>
|
||||
|
@ -1,11 +1,16 @@
|
||||
<div class="input-group">
|
||||
<div class="entry">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" title="<%= publishAttributes.provider.providerName %>">
|
||||
<i class="icon-provider-<%= publishAttributes.provider.providerId %>"></i>
|
||||
</span> <input class="form-control" type="text"
|
||||
value="<%= publishDesc %>" disabled />
|
||||
<div class="input-group-btn">
|
||||
<a class="btn btn-link remove-button" title="Remove this location"
|
||||
data-publish-index="<%= publishAttributes.publishIndex %>"><i
|
||||
class="icon-trash"></i></a>
|
||||
</div>
|
||||
value="<%= publishDesc %>" disabled/>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<a class="btn btn-link btn-sm open-location<%- publishLocationLink ? '' : ' hide' %>"
|
||||
target="_blank" href="<%- publishLocationLink %>">
|
||||
<i class="icon-link-ext-alt"></i> Open in <%= publishAttributes.provider.providerName %>
|
||||
</a>
|
||||
<a class="btn btn-link btn-sm remove-button"
|
||||
data-publish-index="<%= publishAttributes.publishIndex %>"><i class="icon-trash"></i> Remove location</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,12 +1,16 @@
|
||||
<div class="input-group">
|
||||
<div class="entry">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"
|
||||
title="<%= syncAttributes.provider.providerName %>">
|
||||
<i
|
||||
class="icon-provider-<%= syncAttributes.provider.providerId %>"></i>
|
||||
</span> <input class="form-control" type="text"
|
||||
value="<%= syncDesc %>" disabled />
|
||||
<div class="input-group-btn">
|
||||
<a class="btn btn-link remove-button" title="Remove this location"
|
||||
data-sync-index="<%= syncAttributes.syncIndex %>"><i class="icon-trash"></i></a>
|
||||
</div>
|
||||
title="<%= syncAttributes.provider.providerName %>">
|
||||
<i class="icon-provider-<%= syncAttributes.provider.providerId %>"></i>
|
||||
</span> <input class="form-control" type="text" value="<%= syncDesc %>" disabled/>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<a class="btn btn-link btn-sm open-location<%- syncLocationLink ? '' : ' hide' %>"
|
||||
target="_blank" href="<%- syncLocationLink %>">
|
||||
<i class="icon-link-ext-alt"></i> Open in <%= syncAttributes.provider.providerName %>
|
||||
</a>
|
||||
<a class="btn btn-link btn-sm remove-button"
|
||||
data-sync-index="<%= syncAttributes.syncIndex %>"><i class="icon-trash"></i> Remove location</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<p>Helps to find and replace text in the current document.</p>
|
||||
<p>Helps find and replace text in the current document.</p>
|
||||
<div class="form-horizontal">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-5 control-label"
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 22 KiB |
@ -197,7 +197,7 @@ if(window.baseDir.indexOf('-min') !== -1) {
|
||||
themeModule = "css!themes/" + window.theme;
|
||||
}
|
||||
|
||||
// RequireJS entry point. By requiring synchronizer, publisher and
|
||||
// RequireJS entry point. By requiring synchronizer, publisher, sharing and
|
||||
// media-importer, we are actually loading all the modules
|
||||
require([
|
||||
"jquery",
|
||||
@ -206,6 +206,7 @@ require([
|
||||
"eventMgr",
|
||||
"synchronizer",
|
||||
"publisher",
|
||||
"sharing",
|
||||
"mediaImporter",
|
||||
"css",
|
||||
"rangy-cssclassapplier",
|
||||
|
@ -11,7 +11,16 @@ define([
|
||||
"blogger-url"
|
||||
];
|
||||
|
||||
bloggerPageProvider.publish = function(publishAttributes, frontMatter, title, content, callback) {
|
||||
bloggerPageProvider.getPublishLocationLink = function(attributes) {
|
||||
return [
|
||||
'https://www.blogger.com/blogger.g?blogID=',
|
||||
attributes.blogId,
|
||||
'#editor/target=page;pageID=',
|
||||
attributes.pageId
|
||||
].join('');
|
||||
};
|
||||
|
||||
bloggerPageProvider.publish = function(publishAttributes, frontMatter, title, content, callback) {
|
||||
var isDraft = frontMatter && frontMatter.published === false;
|
||||
var publishDate = frontMatter && frontMatter.date;
|
||||
googleHelper.uploadBloggerPage(publishAttributes.blogUrl, publishAttributes.blogId, publishAttributes.pageId, isDraft, publishDate, title, content, function(error, blogId, pageId) {
|
||||
|
@ -11,7 +11,16 @@ define([
|
||||
"blogger-url"
|
||||
];
|
||||
|
||||
bloggerProvider.publish = function(publishAttributes, frontMatter, title, content, callback) {
|
||||
bloggerProvider.getPublishLocationLink = function(attributes) {
|
||||
return [
|
||||
'https://www.blogger.com/blogger.g?blogID=',
|
||||
attributes.blogId,
|
||||
'#editor/target=post;postID=',
|
||||
attributes.postId
|
||||
].join('');
|
||||
};
|
||||
|
||||
bloggerProvider.publish = function(publishAttributes, frontMatter, title, content, callback) {
|
||||
var labelList = publishAttributes.labelList || [];
|
||||
if(frontMatter) {
|
||||
frontMatter.tags !== undefined && (labelList = frontMatter.tags);
|
||||
|
@ -23,6 +23,15 @@ define([
|
||||
PROVIDER_COUCHDB + "-tag"
|
||||
];
|
||||
|
||||
couchdbProvider.getSyncLocationLink = function(attributes) {
|
||||
return [
|
||||
settings.couchdbUrl,
|
||||
'/',
|
||||
attributes.id,
|
||||
'/content'
|
||||
].join('');
|
||||
};
|
||||
|
||||
function createSyncIndex(id) {
|
||||
return "sync." + PROVIDER_COUCHDB + "." + id;
|
||||
}
|
||||
@ -97,9 +106,18 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
function getTags(frontMatter, title) {
|
||||
var tags = frontMatter && frontMatter.tags;
|
||||
var match = title.match(/^\s*\[(.*?)\]/);
|
||||
if(match) {
|
||||
tags = match[1];
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
couchdbProvider.exportFile = function(event, title, content, discussionListJSON, frontMatter, callback) {
|
||||
var data = couchdbProvider.serializeContent(content, discussionListJSON);
|
||||
var tags = frontMatter && frontMatter.tags;
|
||||
var tags = getTags(frontMatter, title);
|
||||
couchdbHelper.uploadDocument(undefined, title, data, tags, undefined, function(error, result) {
|
||||
if(error) {
|
||||
return callback(error);
|
||||
@ -119,7 +137,7 @@ define([
|
||||
}
|
||||
|
||||
var data = couchdbProvider.serializeContent(content, discussionList);
|
||||
var tags = frontMatter && frontMatter.tags;
|
||||
var tags = getTags(frontMatter, title);
|
||||
couchdbHelper.uploadDocument(syncAttributes.id, title, data, tags, syncAttributes.rev, function(error, result) {
|
||||
if(error) {
|
||||
return callback(error, true);
|
||||
@ -211,10 +229,13 @@ define([
|
||||
};
|
||||
|
||||
eventMgr.addListener("onReady", function() {
|
||||
if(constants.COUCHDB_URL == settings.couchdbUrl) {
|
||||
$('.msg-default-couchdb').removeClass('hide');
|
||||
}
|
||||
var documentEltTmpl = [
|
||||
'<a href="#" class="list-group-item document clearfix" data-document-id="<%= document._id %>">',
|
||||
'<div class="date pull-right"><%= date %></div></div>',
|
||||
'<div class="name"><i class="icon-provider-couchdb"></i> ',
|
||||
'<div class="name"><i class="icon-file"></i> ',
|
||||
'<%= document.title %></div>',
|
||||
'</a>'
|
||||
].join('');
|
||||
@ -334,7 +355,7 @@ define([
|
||||
.value();
|
||||
storage[PROVIDER_COUCHDB + '.tagList'] = JSON.stringify(tagList);
|
||||
updateTagList();
|
||||
$selectTagElt.val(tag);
|
||||
$selectTagElt.val(tag).change();
|
||||
}, "Tag");
|
||||
})
|
||||
.on('click', '.action-remove-tag', function() {
|
||||
@ -344,9 +365,9 @@ define([
|
||||
tagList = _.without(tagList, tag);
|
||||
storage[PROVIDER_COUCHDB + '.tagList'] = JSON.stringify(tagList);
|
||||
updateTagList();
|
||||
$selectTagElt.val('');
|
||||
$selectTagElt.val('').change();
|
||||
}
|
||||
}, "Tag");
|
||||
});
|
||||
})
|
||||
.on('click', '.action-delete-items', function() {
|
||||
if($selectedElts.length) {
|
||||
|
@ -14,7 +14,18 @@ define([
|
||||
var dropboxProvider = new Provider(PROVIDER_DROPBOX, "Dropbox");
|
||||
dropboxProvider.defaultPublishFormat = "template";
|
||||
|
||||
function checkPath(path) {
|
||||
dropboxProvider.getSyncLocationLink = dropboxProvider.getPublishLocationLink = function(attributes) {
|
||||
var pathComponents = attributes.path.split('/').map(encodeURIComponent);
|
||||
var filename = pathComponents.pop();
|
||||
return [
|
||||
'https://www.dropbox.com/home',
|
||||
pathComponents.join('/'),
|
||||
'?select=',
|
||||
filename
|
||||
].join('');
|
||||
};
|
||||
|
||||
function checkPath(path) {
|
||||
if(path === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -24,6 +24,16 @@ define([
|
||||
providerId + "-parentid"
|
||||
];
|
||||
|
||||
gdriveProvider.getSyncLocationLink = gdriveProvider.getPublishLocationLink = function(attributes) {
|
||||
var authuser = googleHelper.getAuthorizationMgr(accountId).authuser;
|
||||
return [
|
||||
'https://docs.google.com/file/d/',
|
||||
attributes.id,
|
||||
'/edit',
|
||||
authuser ? '?authuser=' + authuser : ''
|
||||
].join('');
|
||||
};
|
||||
|
||||
function createSyncIndex(id) {
|
||||
return "sync." + providerId + "." + id;
|
||||
}
|
||||
|
@ -13,6 +13,13 @@ define([
|
||||
"filename"
|
||||
];
|
||||
|
||||
gistProvider.getPublishLocationLink = function(attributes) {
|
||||
return [
|
||||
'https://gist.github.com/',
|
||||
attributes.gistId
|
||||
].join('');
|
||||
};
|
||||
|
||||
gistProvider.publish = function(publishAttributes, frontMatter, title, content, callback) {
|
||||
githubHelper.uploadGist(publishAttributes.gistId, publishAttributes.filename, publishAttributes.isPublic, title, content, function(error, gistId) {
|
||||
if(error) {
|
||||
|
@ -1,36 +1,50 @@
|
||||
define([
|
||||
"utils",
|
||||
"classes/Provider",
|
||||
"settings",
|
||||
"helpers/githubHelper"
|
||||
"utils",
|
||||
"classes/Provider",
|
||||
"settings",
|
||||
"helpers/githubHelper"
|
||||
], function(utils, Provider, settings, githubHelper) {
|
||||
|
||||
var githubProvider = new Provider("github", "GitHub");
|
||||
githubProvider.publishPreferencesInputIds = [
|
||||
"github-repo",
|
||||
"github-branch"
|
||||
];
|
||||
var githubProvider = new Provider("github", "GitHub");
|
||||
githubProvider.publishPreferencesInputIds = [
|
||||
"github-repo",
|
||||
"github-branch"
|
||||
];
|
||||
|
||||
githubProvider.publish = function(publishAttributes, frontMatter, title, content, callback) {
|
||||
var commitMsg = settings.commitMsg;
|
||||
githubHelper.upload(publishAttributes.repository, publishAttributes.username, publishAttributes.branch, publishAttributes.path, content, commitMsg, callback);
|
||||
};
|
||||
githubProvider.getPublishLocationLink = function(attributes) {
|
||||
var result = [
|
||||
'https://github.com',
|
||||
attributes.username,
|
||||
attributes.repository,
|
||||
'blob',
|
||||
attributes.branch
|
||||
];
|
||||
return result.concat(attributes.path.split('/').map(encodeURIComponent)).join('/');
|
||||
};
|
||||
|
||||
githubProvider.newPublishAttributes = function(event) {
|
||||
var publishAttributes = {};
|
||||
publishAttributes.repository = utils.getInputTextValue("#input-publish-github-repo", event);
|
||||
publishAttributes.branch = utils.getInputTextValue("#input-publish-github-branch", event);
|
||||
publishAttributes.path = utils.getInputTextValue("#input-publish-file-path", event);
|
||||
if(event.isPropagationStopped()) {
|
||||
return undefined;
|
||||
}
|
||||
githubProvider.publish = function(publishAttributes, frontMatter, title, content, callback) {
|
||||
var commitMsg = settings.commitMsg;
|
||||
githubHelper.upload(publishAttributes.repository, publishAttributes.username, publishAttributes.branch, publishAttributes.path, content, commitMsg, function(err, username) {
|
||||
publishAttributes.username = username;
|
||||
callback(err);
|
||||
});
|
||||
};
|
||||
|
||||
githubProvider.newPublishAttributes = function(event) {
|
||||
var publishAttributes = {};
|
||||
publishAttributes.repository = utils.getInputTextValue("#input-publish-github-repo", event);
|
||||
publishAttributes.branch = utils.getInputTextValue("#input-publish-github-branch", event);
|
||||
publishAttributes.path = utils.getInputTextValue("#input-publish-file-path", event);
|
||||
if(event.isPropagationStopped()) {
|
||||
return undefined;
|
||||
}
|
||||
var parsedRepository = publishAttributes.repository.match(/[\/:]?([^\/:]+)\/([^\/]+?)(?:\.git)?$/);
|
||||
if(parsedRepository) {
|
||||
publishAttributes.repository = parsedRepository[2];
|
||||
publishAttributes.username = parsedRepository[1];
|
||||
}
|
||||
return publishAttributes;
|
||||
};
|
||||
return publishAttributes;
|
||||
};
|
||||
|
||||
return githubProvider;
|
||||
return githubProvider;
|
||||
});
|
@ -11,7 +11,16 @@ define([
|
||||
"tumblr-hostname"
|
||||
];
|
||||
|
||||
tumblrProvider.publish = function(publishAttributes, frontMatter, title, content, callback) {
|
||||
tumblrProvider.getPublishLocationLink = function(attributes) {
|
||||
return [
|
||||
'http://',
|
||||
attributes.blogHostname,
|
||||
'/post/',
|
||||
attributes.postId
|
||||
].join('');
|
||||
};
|
||||
|
||||
tumblrProvider.publish = function(publishAttributes, frontMatter, title, content, callback) {
|
||||
var labelList = publishAttributes.tags || [];
|
||||
if(frontMatter) {
|
||||
frontMatter.tags !== undefined && (labelList = frontMatter.tags);
|
||||
|
@ -11,7 +11,15 @@ define([
|
||||
"wordpress-site"
|
||||
];
|
||||
|
||||
wordpressProvider.publish = function(publishAttributes, frontMatter, title, content, callback) {
|
||||
wordpressProvider.getPublishLocationLink = function(attributes) {
|
||||
return attributes.siteId && [
|
||||
'https://wordpress.com/post',
|
||||
attributes.siteId,
|
||||
attributes.postId
|
||||
].join('/');
|
||||
};
|
||||
|
||||
wordpressProvider.publish = function(publishAttributes, frontMatter, title, content, callback) {
|
||||
var labelList = publishAttributes.tags || [];
|
||||
if(frontMatter) {
|
||||
frontMatter.tags !== undefined && (labelList = frontMatter.tags);
|
||||
@ -19,11 +27,11 @@ define([
|
||||
var status = (frontMatter && frontMatter.published === false) ? 'draft' : 'publish';
|
||||
var date = frontMatter && frontMatter.date;
|
||||
_.isString(labelList) && (labelList = _.compact(labelList.split(/[\s,]/)));
|
||||
wordpressHelper.upload(publishAttributes.site, publishAttributes.postId, labelList.join(','), status, date, title, content, function(error, postId) {
|
||||
wordpressHelper.upload(publishAttributes.site, publishAttributes.postId, labelList.join(','), status, date, title, content, function(error, siteId, postId) {
|
||||
if(error) {
|
||||
callback(error);
|
||||
return;
|
||||
return callback(error);
|
||||
}
|
||||
publishAttributes.siteId = siteId;
|
||||
publishAttributes.postId = postId;
|
||||
callback();
|
||||
});
|
||||
|
@ -56,6 +56,7 @@ define([
|
||||
' "pageSize": "A4"',
|
||||
'}'
|
||||
].join('\n'),
|
||||
couchdbUrl: constants.COUCHDB_URL,
|
||||
extensionSettings: {}
|
||||
};
|
||||
|
||||
|
@ -28,10 +28,7 @@ define([
|
||||
});
|
||||
|
||||
sharing.getEditorParams = function(attributes) {
|
||||
var provider = providerMap[attributes.provider.providerId];
|
||||
if(provider === undefined) {
|
||||
return;
|
||||
}
|
||||
var provider = attributes.provider;
|
||||
var params = {
|
||||
provider: provider.providerId
|
||||
};
|
||||
@ -45,10 +42,9 @@ define([
|
||||
};
|
||||
|
||||
sharing.getViewerParams = function(attributes) {
|
||||
var provider = providerMap[attributes.provider.providerId];
|
||||
if(provider === undefined ||
|
||||
// Or document is not published in markdown format
|
||||
attributes.format != "markdown") {
|
||||
var provider = attributes.provider;
|
||||
// If document is not published in markdown format
|
||||
if(attributes.format != "markdown") {
|
||||
return;
|
||||
}
|
||||
var params = {
|
||||
@ -98,5 +94,6 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
eventMgr.onSharingCreated(sharing);
|
||||
return sharing;
|
||||
});
|
||||
|
@ -199,7 +199,7 @@ h5 { font-size: @title-base-size; }
|
||||
h6 { font-size: @title-base-size * 0.85; }
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
margin: 1.3em 0;
|
||||
margin: 1.8em 0;
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
@ -416,7 +416,7 @@ kbd {
|
||||
width: 18px;
|
||||
height: 16px;
|
||||
margin-top: -2px;
|
||||
margin-left: 1px;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.icon-provider-stackedit {
|
||||
|
@ -93,10 +93,10 @@
|
||||
@list-group-bg: @secondary-bg-light;
|
||||
@list-group-border: @transparent;
|
||||
@list-group-active-color: darken(@primary-desaturated, 25%);
|
||||
@list-group-active-bg: @primary-bg;
|
||||
@list-group-active-bg: @secondary-bg-dark;
|
||||
@list-group-active-border: fade(@secondary, 5%);
|
||||
@list-group-hover-bg: @btn-default-hover-bg;
|
||||
@list-group-hover-border-color: fade(@secondary, 10%);
|
||||
@list-group-hover-border-color: @btn-default-hover-border;
|
||||
@input-color: @secondary-color-darkest;
|
||||
@input-color-placeholder: @disabled-color;
|
||||
@gray-lighter: @body-bg;
|
||||
@ -300,13 +300,14 @@ a {
|
||||
@btn-default-bg: @transparent;
|
||||
@btn-default-border: @transparent;
|
||||
@btn-default-hover-bg: fade(@secondary-desaturated, 4%);
|
||||
@btn-default-hover-border: fade(@secondary, 10%);
|
||||
.btn-default, .alertify-button-cancel {
|
||||
&:hover,
|
||||
&:focus,
|
||||
&:active,
|
||||
.open &.dropdown-toggle {
|
||||
color: darken(@secondary, 30%);
|
||||
border-color: fade(@secondary, 10%);
|
||||
border-color: @btn-default-hover-border;
|
||||
background-color: @btn-default-hover-bg !important; // important to override .nav > li > a:hover
|
||||
}
|
||||
}
|
||||
@ -315,13 +316,14 @@ a {
|
||||
@btn-primary-bg: @primary-bg;
|
||||
@btn-primary-border: fade(@secondary, 5%);
|
||||
@btn-primary-hover-bg: mix(@primary-desaturated, @btn-primary-bg, 7.5%);
|
||||
@btn-primary-hover-border: fade(@secondary, 10%);
|
||||
.btn-primary, .alertify-button-ok {
|
||||
&:hover,
|
||||
&:focus,
|
||||
&:active,
|
||||
.open &.dropdown-toggle {
|
||||
color: darken(@secondary, 30%);
|
||||
border-color: fade(@secondary, 10%);
|
||||
border-color: @btn-primary-hover-border;
|
||||
background-color: @btn-primary-hover-bg !important; // important to override .nav > li > a:hover
|
||||
}
|
||||
}
|
||||
@ -330,13 +332,14 @@ a {
|
||||
@btn-success-color: darken(@primary-desaturated, 20%);
|
||||
@btn-success-bg: @transparent;
|
||||
@btn-success-border: @transparent;
|
||||
@btn-success-hover-color: darken(@primary, 30%);
|
||||
@btn-success-hover-bg: fade(@primary-desaturated, 5%);
|
||||
.btn-success {
|
||||
&:hover,
|
||||
&:focus,
|
||||
&:active,
|
||||
.open &.dropdown-toggle {
|
||||
color: darken(@primary, 30%) !important;
|
||||
color: @btn-success-hover-color !important;
|
||||
border-color: @primary-border-color;
|
||||
background-color: @btn-success-hover-bg !important; // important to override .nav > li > a:hover
|
||||
}
|
||||
@ -522,6 +525,27 @@ a {
|
||||
font-weight: 200;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
a {
|
||||
i {
|
||||
.transition(~"all ease-in-out .15s");
|
||||
}
|
||||
.icon-link-ext-alt {
|
||||
color: transparent;
|
||||
position: relative;
|
||||
font-size: 12px;
|
||||
top: -12px;
|
||||
right: 6px;
|
||||
width: 0;
|
||||
}
|
||||
&:hover {
|
||||
[class^="icon-provider-"], [class*=" icon-provider-"] {
|
||||
.opacity(0.5);
|
||||
}
|
||||
.icon-link-ext-alt {
|
||||
color: @btn-success-hover-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.input-file-title-container {
|
||||
@ -547,7 +571,7 @@ a {
|
||||
height: 6px;
|
||||
border-radius: 1px;
|
||||
margin: 0 2px;
|
||||
opacity: 0.25;
|
||||
.opacity(0.25);
|
||||
background-color: fade(@btn-success-color, 75%);
|
||||
}
|
||||
}
|
||||
@ -807,7 +831,12 @@ a {
|
||||
padding: 9px 20px 9px 15px;
|
||||
}
|
||||
.name i {
|
||||
margin-right: 8px;
|
||||
&.icon-file, &.icon-folder {
|
||||
margin-right: 8px;
|
||||
font-size: 20px;
|
||||
line-height: 15px;
|
||||
margin-top: -2px;
|
||||
}
|
||||
}
|
||||
.date {
|
||||
font-weight: normal;
|
||||
@ -959,7 +988,7 @@ a {
|
||||
& > li > a {
|
||||
&:hover, &:focus {
|
||||
color: darken(@secondary, 30%);
|
||||
border-color: fade(@secondary, 10%);
|
||||
border-color: @btn-default-hover-border;
|
||||
background-color: @btn-default-hover-bg;
|
||||
border-bottom-color: @transparent;
|
||||
}
|
||||
@ -987,7 +1016,7 @@ a {
|
||||
.modal-manage-publish .publish-list,
|
||||
.modal-manage-sharing .share-list {
|
||||
margin-bottom: 20px;
|
||||
.input-group {
|
||||
.entry {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
@ -1381,7 +1410,7 @@ div.dropdown-menu, {
|
||||
a:focus {
|
||||
color: @link-hover-color;
|
||||
}
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
h1, h2, h3 {
|
||||
margin: 1em 0;
|
||||
}
|
||||
}
|
||||
@ -1567,7 +1596,7 @@ div.jGrowl {
|
||||
div.jGrowl-notification, div.jGrowl-closer {
|
||||
background-color: @jgrowl-bg-color;
|
||||
width: @jgrowl-width;
|
||||
margin: 10px 0;
|
||||
margin: 6px 0;
|
||||
padding: 10px 12px;
|
||||
-ms-filter: none;
|
||||
filter: none;
|
||||
|
@ -45,7 +45,6 @@
|
||||
@btn-success-color: @A1;
|
||||
@btn-success-bg: @transparent;
|
||||
@btn-success-border: @transparent;
|
||||
@btn-success-hover-color: @transparent;
|
||||
@btn-success-hover-bg: @blue;
|
||||
|
||||
/* Buttons over preview */
|
||||
|
@ -16,14 +16,9 @@
|
||||
|
||||
// Navbar buttons
|
||||
@btn-success-color: #ddd;
|
||||
@btn-success-hover-color: #fff;
|
||||
@btn-success-hover-bg: darken(@navbar-default-bg, 10%);
|
||||
.btn-success {
|
||||
&:hover,
|
||||
&:focus,
|
||||
&:active,
|
||||
.open &.dropdown-toggle {
|
||||
color: #fff !important;
|
||||
}
|
||||
.buttons-dropdown .dropdown-menu & {
|
||||
color: darken(@primary-desaturated, 20%) !important;
|
||||
&:hover,
|
||||
@ -53,8 +48,9 @@
|
||||
|
||||
@btn-default-color: @text-color;
|
||||
@btn-default-bg: #fff;
|
||||
@btn-default-border: @input-border;
|
||||
@btn-default-border: fade(@input-border, 75%);
|
||||
@btn-default-hover-bg: fade(#000, 2%);
|
||||
@btn-default-hover-border: fade(@secondary, 5%);
|
||||
|
||||
@secondary-bg: #fcfcfc;
|
||||
@secondary-bg-light: #f6f6f6;
|
||||
|
@ -20,6 +20,7 @@
|
||||
@btn-success-color: #ddd;
|
||||
@btn-success-bg: @transparent;
|
||||
@btn-success-border: @transparent;
|
||||
@btn-success-hover-color: #fff;
|
||||
@btn-success-hover-bg: lighten(@navbar-default-bg, 10%);
|
||||
@panel-button-bg-color: #eee;
|
||||
|
||||
@ -30,7 +31,6 @@
|
||||
&:focus,
|
||||
&:active,
|
||||
.open &.dropdown-toggle {
|
||||
color: #fff;
|
||||
border-color: lighten(@navbar-default-bg, 10%);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user