mirror of
https://github.com/wassname/talk.git
synced 2026-08-16 11:29:31 +08:00
Merge branch 'master' into fix-my-profile-title-link
This commit is contained in:
+52
-23
@@ -23,23 +23,33 @@ util.onshutdown([() => mongoose.disconnect()]);
|
||||
/**
|
||||
* Lists all the assets registered in the database.
|
||||
*/
|
||||
async function listAssets() {
|
||||
async function listAssets(opts) {
|
||||
try {
|
||||
let assets = await AssetModel.find({}).sort({ created_at: 1 });
|
||||
|
||||
let table = new Table({
|
||||
head: ['ID', 'Title', 'URL'],
|
||||
});
|
||||
switch (opts.format) {
|
||||
case 'json': {
|
||||
console.log(JSON.stringify(assets, null, 2));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
let table = new Table({
|
||||
head: ['ID', 'Title', 'URL'],
|
||||
});
|
||||
|
||||
assets.forEach(asset => {
|
||||
table.push([
|
||||
asset.id,
|
||||
asset.title ? asset.title : '',
|
||||
asset.url ? asset.url : '',
|
||||
]);
|
||||
});
|
||||
assets.forEach(asset => {
|
||||
table.push([
|
||||
asset.id,
|
||||
asset.title ? asset.title : '',
|
||||
asset.url ? asset.url : '',
|
||||
]);
|
||||
});
|
||||
|
||||
console.log(table.toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(table.toString());
|
||||
util.shutdown();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@@ -49,12 +59,13 @@ async function listAssets() {
|
||||
|
||||
async function refreshAssets(ageString) {
|
||||
try {
|
||||
const now = new Date().getTime();
|
||||
const ageMs = parseDuration(ageString);
|
||||
const age = new Date(now - ageMs);
|
||||
const query = AssetModel.find({}, { id: 1 });
|
||||
if (ageString) {
|
||||
// An age was specified, so filter only those assets.
|
||||
const ageMs = parseDuration(ageString);
|
||||
const age = new Date(Date.now() - ageMs);
|
||||
|
||||
let assets = await AssetModel.find(
|
||||
{
|
||||
query.merge({
|
||||
$or: [
|
||||
{
|
||||
scraped: {
|
||||
@@ -65,16 +76,28 @@ async function refreshAssets(ageString) {
|
||||
scraped: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
{ id: 1 }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Create a graph context.
|
||||
const ctx = Context.forSystem();
|
||||
|
||||
// Load the assets.
|
||||
const cursor = query.cursor();
|
||||
|
||||
// Queue all the assets for scraping.
|
||||
await Promise.all(assets.map(({ id }) => scraper.create(ctx, id)));
|
||||
console.log('Assets were queued to be scraped');
|
||||
const promises = [];
|
||||
|
||||
let asset = await cursor.next();
|
||||
while (asset) {
|
||||
promises.push(scraper.create(ctx, asset.id));
|
||||
asset = await cursor.next();
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
console.log(`${promises.length} Assets were queued to be scraped.`);
|
||||
|
||||
util.shutdown();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@@ -202,11 +225,17 @@ async function rewrite(search, replace, options) {
|
||||
|
||||
program
|
||||
.command('list')
|
||||
.option(
|
||||
'--format <type>',
|
||||
'Specify the output format [table]',
|
||||
/^(table|json)$/i,
|
||||
'table'
|
||||
)
|
||||
.description('list all the assets in the database')
|
||||
.action(listAssets);
|
||||
|
||||
program
|
||||
.command('refresh <age>')
|
||||
.command('refresh [age]')
|
||||
.description('queues the assets that exceed the age requested')
|
||||
.action(refreshAssets);
|
||||
|
||||
|
||||
+1
-1
@@ -328,7 +328,7 @@ program
|
||||
.action(searchUsers);
|
||||
|
||||
program
|
||||
.command('set-role <userID> <role>')
|
||||
.command('set-role <userID>')
|
||||
.description('sets the role on a user')
|
||||
.action(setUserRole);
|
||||
|
||||
|
||||
+1
-1
@@ -274,7 +274,7 @@ en:
|
||||
comment: comment
|
||||
comment_is_ignored: "This comment is hidden because you ignored this user."
|
||||
comment_is_rejected: "You have rejected this comment."
|
||||
comment_is_deleted: "This comment was deleted."
|
||||
comment_is_deleted: "This commenter has deleted their account."
|
||||
comment_is_hidden: "This comment is not available."
|
||||
comments: comments
|
||||
configure_stream: "Configure"
|
||||
|
||||
@@ -114,11 +114,11 @@ class Profile extends React.Component {
|
||||
|
||||
isSaveEnabled = () => {
|
||||
const { formData } = this.state;
|
||||
const { emailAddress, username } = this.props;
|
||||
const { root: { me: { username, email } } } = this.props;
|
||||
const formHasErrors = !!Object.keys(this.state.errors).length;
|
||||
const validUsername =
|
||||
formData.newUsername && formData.newUsername !== username;
|
||||
const validEmail = formData.newEmail && formData.newEmail !== emailAddress;
|
||||
const validEmail = formData.newEmail && formData.newEmail !== email;
|
||||
|
||||
return !formHasErrors && (validUsername || validEmail);
|
||||
};
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
@custom-media --small-viewport (min-width: 425px);
|
||||
|
||||
.dialog {
|
||||
width: calc(100% - 50px);
|
||||
border: none;
|
||||
box-shadow: 0 9px 46px 8px rgba(0, 0, 0, 0.14), 0 11px 15px -7px rgba(0, 0, 0, 0.12), 0 24px 38px 3px rgba(0, 0, 0, 0.2);
|
||||
width: 380px;
|
||||
|
||||
top: 10px;
|
||||
font-family: Helvetica, 'Helvetica Neue', Verdana, sans-serif;
|
||||
font-size: 14px;
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
|
||||
@media (--small-viewport) {
|
||||
width: 380px;
|
||||
}
|
||||
}
|
||||
|
||||
.close {
|
||||
|
||||
Reference in New Issue
Block a user