apostrophe
Advanced tools
Comparing version 0.3.13 to 0.3.14
@@ -55,15 +55,19 @@ var oembed = require('oembed'); | ||
type: 'button', | ||
label: 'b' | ||
label: 'b', | ||
icon: 'bold' | ||
}, | ||
italic: { | ||
type: 'button', | ||
label: 'i' | ||
label: 'i', | ||
icon: 'italic' | ||
}, | ||
createLink: { | ||
type: 'button', | ||
label: 'Link' | ||
label: 'Link', | ||
icon: 'link' | ||
}, | ||
insertUnorderedList: { | ||
type: 'button', | ||
label: 'List' | ||
label: 'List', | ||
icon: 'ul' | ||
} | ||
@@ -107,5 +111,5 @@ }; | ||
function setupAreas(callback) { | ||
db.collection('aposAreas', options, function(err, collection) { | ||
db.collection('aposAreas', function(err, collection) { | ||
self.areas = areas = collection; | ||
collection.ensureIndex({ slug: 1 }, { unique: true }, function(err) { | ||
collection.ensureIndex({ slug: 1 }, { safe: true, unique: true }, function(err) { | ||
return callback(err); | ||
@@ -117,7 +121,7 @@ }); | ||
function setupPages(callback) { | ||
db.collection('aposPages', options, function(err, collection) { | ||
db.collection('aposPages', function(err, collection) { | ||
self.pages = pages = collection; | ||
async.series([indexSlug], callback); | ||
function indexSlug(callback) { | ||
self.pages.ensureIndex({ slug: 1 }, { unique: true }, callback); | ||
self.pages.ensureIndex({ slug: 1 }, { safe: true, unique: true }, callback); | ||
} | ||
@@ -129,3 +133,3 @@ // ... more index functions | ||
function setupFiles(callback) { | ||
db.collection('aposFiles', options, function(err, collection) { | ||
db.collection('aposFiles', function(err, collection) { | ||
self.files = files = collection; | ||
@@ -195,3 +199,2 @@ return callback(err); | ||
aposLocals.aposSingleton = function(options) { | ||
console.log('aposSingleton'); | ||
if (!self.itemTypes[options.type]) { | ||
@@ -206,9 +209,4 @@ console.log("Unknown item type: " + options.type); | ||
}); | ||
if (!item) { | ||
item = { type: options.type }; | ||
} | ||
options.itemType = self.itemTypes[item.type]; | ||
options.itemType = self.itemTypes[options.type]; | ||
options.item = item; | ||
console.log('Rendering!'); | ||
console.log(options); | ||
return partial('singleton.html', options); | ||
@@ -218,3 +216,2 @@ } | ||
aposLocals.aposAreaIsEmpty = function(options) { | ||
console.log('WOOOO'); | ||
if (!options.area) { | ||
@@ -374,3 +371,3 @@ return true; | ||
info._id = id; | ||
info.name = slugify(file.name); | ||
info.name = self.slugify(file.name); | ||
info.createdAt = new Date(); | ||
@@ -476,2 +473,3 @@ | ||
if (err) { | ||
console.log('forbid'); | ||
return forbid(res); | ||
@@ -523,4 +521,2 @@ } | ||
console.log('PREVIEW: ', item); | ||
var itemType = self.itemTypes[item.type]; | ||
@@ -534,3 +530,2 @@ if (!itemType) { | ||
itemType.sanitize(item); | ||
console.log('AFTER SANITIZE:', item); | ||
} | ||
@@ -779,4 +774,2 @@ | ||
if (page) { | ||
console.log('LOADED PAGE:'); | ||
console.log(page); | ||
// For convenience guarantee there is a page.areas property | ||
@@ -886,22 +879,2 @@ if (!page.areas) { | ||
function slugify(s) { | ||
// Note: you'll need to use xregexp instead if you need non-Latin character | ||
// support in slugs | ||
// Everything not a letter or number becomes a dash | ||
s = s.replace(/[^A-Za-z0-9]/g, '-'); | ||
// Consecutive dashes become one dash | ||
s = s.replace(/\-+/g, '-'); | ||
// Leading dashes go away | ||
s = s.replace(/^\-/, ''); | ||
// Trailing dashes go away | ||
s = s.replace(/\-$/, ''); | ||
// If the string is empty, supply something so that routes still match | ||
if (!s.length) | ||
{ | ||
s = 'none'; | ||
} | ||
return s.toLowerCase(); | ||
} | ||
// String.replace does NOT do this | ||
@@ -955,2 +928,3 @@ // Regexps can but they can't be trusted with UTF8 ): | ||
label: 'Image', | ||
icon: 'image', | ||
render: function(data) { | ||
@@ -964,2 +938,3 @@ return partial('image.html', data); | ||
label: 'Video', | ||
icon: 'video', | ||
render: function(data) { | ||
@@ -975,2 +950,3 @@ return partial('video.html', data); | ||
wrapper: 'span', | ||
icon: 'quote-left', | ||
// Without this it's bothersome for editor.js to grab the text | ||
@@ -998,25 +974,33 @@ // without accidentally grabbing the buttons. -Tom | ||
self.slugify = function(text, options) { | ||
// Note: you'll need to use xregexp instead if you need non-Latin character | ||
// support in slugs. KEEP IN SYNC WITH SERVER SIDE IMPLEMENTATION in apostrophe.js | ||
self.slugify = function(s, options) { | ||
// By default everything not a letter or number becomes a dash. | ||
// You can add additional allowed characters via options.allow | ||
if (!options) { | ||
options = {}; | ||
} | ||
_.defaults(options, { | ||
disallow: /[^\w\d]+/g, | ||
substitute: '-' | ||
}); | ||
slug = text.toLowerCase().replace(options.disallow, options.substitute); | ||
// Lop off leading and trailing - | ||
if (slug.length) | ||
if (!options.allow) { | ||
options.allow = ''; | ||
} | ||
var r = "[^A-Za-z0-9" + RegExp.quote(options.allow) + "]"; | ||
var regex = new RegExp(r, 'g'); | ||
s = s.replace(regex, '-'); | ||
// Consecutive dashes become one dash | ||
s = s.replace(/\-+/g, '-'); | ||
// Leading dashes go away | ||
s = s.replace(/^\-/, ''); | ||
// Trailing dashes go away | ||
s = s.replace(/\-$/, ''); | ||
// If the string is empty, supply something so that routes still match | ||
if (!s.length) | ||
{ | ||
if (slug.substr(0, 1) === options.substitute) | ||
{ | ||
slug = slug.substr(1); | ||
} | ||
if (slug.substr(slug.length - 1, 1) === options.substitute) | ||
{ | ||
slug = slug.substr(0, slug.length - 1); | ||
} | ||
s = 'none'; | ||
} | ||
return slug; | ||
}; | ||
return s.toLowerCase(); | ||
} | ||
@@ -1045,4 +1029,14 @@ // For convenience when configuring uploadfs | ||
} | ||
] | ||
]; | ||
// Is this MongoDB error related to the uniqueness of the specified field? | ||
// Great for retrying on duplicates. Used heavily by the pages module and | ||
// no doubt will be by other things | ||
self.isUniqueError = function(err, field) { | ||
if (!err) { | ||
return false; | ||
} | ||
return (((err.code === 11000) || (err.code === 11001)) && (err.err.indexOf(field) !== -1)); | ||
} | ||
} | ||
{ | ||
"name": "apostrophe", | ||
"version": "0.3.13", | ||
"version": "0.3.14", | ||
"description": "Apostrophe is a user-friendly content management system. This core module of Apostrophe provides rich content editing and essential facilities to integrate Apostrophe into your Express project. Apostrophe also includes simple facilities for storing your rich content areas in MongoDB and fetching them back again. Additional functionality is available in modules like apostrophe-twitter and apostrophe-rss and forthcoming modules that address page trees, blog posts, events and the like.", | ||
@@ -5,0 +5,0 @@ "main": "apostrophe.js", |
@@ -597,2 +597,4 @@ if (!window.apos) { | ||
self.data.type = self.type; | ||
if (self.data.id) { | ||
@@ -1582,1 +1584,37 @@ self.exists = true; | ||
// Note: you'll need to use xregexp instead if you need non-Latin character | ||
// support in slugs. KEEP IN SYNC WITH SERVER SIDE IMPLEMENTATION in apostrophe.js | ||
apos.slugify = function(s, options) { | ||
// By default everything not a letter or number becomes a dash. | ||
// You can add additional allowed characters via options.allow | ||
if (!options) { | ||
options = {}; | ||
} | ||
if (!options.allow) { | ||
options.allow = ''; | ||
} | ||
var r = "[^A-Za-z0-9" + apos.regExpQuote(options.allow) + "]"; | ||
var regex = new RegExp(r, 'g'); | ||
s = s.replace(regex, '-'); | ||
// Consecutive dashes become one dash | ||
s = s.replace(/\-+/g, '-'); | ||
// Leading dashes go away | ||
s = s.replace(/^\-/, ''); | ||
// Trailing dashes go away | ||
s = s.replace(/\-$/, ''); | ||
// If the string is empty, supply something so that routes still match | ||
if (!s.length) | ||
{ | ||
s = 'none'; | ||
} | ||
return s.toLowerCase(); | ||
} | ||
// Borrowed from the regexp-quote module for node | ||
apos.regExpQuote = function (string) { | ||
return string.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&") | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2974706
141
14891
18