Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added script to refresh an entry's GUID
- Loading branch information
1 parent
dee0ccb
commit 351dcc2
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var Entry = require("../../app/models/entry"); | ||
var get = require("../get/entry"); | ||
var helper = require("../../app/helper"); | ||
var guid = helper.guid; | ||
|
||
get(process.argv[2], function(err, user, blog, entry) { | ||
if (err) throw err; | ||
|
||
console.log('Old GUID:', entry.guid); | ||
|
||
entry.guid = "entry_" + guid(); | ||
|
||
console.log('New GUID:', entry.guid); | ||
|
||
Entry.set(blog.id, entry.path, entry, function(err) { | ||
if (err) throw err; | ||
|
||
console.log("Refreshed GUID of entry:", process.argv[2]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var User = require("../../app/models/user"); | ||
var Entry = require("../../app/models/entry"); | ||
var Blog = require("../../app/models/blog"); | ||
var parseUrl = require("url").parse; | ||
|
||
// Takes a URL and fetches the blog, user and entry | ||
|
||
module.exports = function get(url, callback) { | ||
url = parseUrl(url); | ||
|
||
Blog.get({ domain: url.host }, function(err, blog) { | ||
if (err || !blog) return callback(err || new Error("No blog")); | ||
|
||
User.getById(blog.owner, function(err, user) { | ||
if (err || !user) return callback(err || new Error("No user")); | ||
|
||
Entry.getByUrl(blog.id, url.path, function(entry) { | ||
if (!entry) return callback(new Error("No entry")); | ||
|
||
callback(err, user, blog, entry); | ||
}); | ||
}); | ||
}); | ||
}; |