mirror of
https://github.com/wassname/talk.git
synced 2026-07-30 12:40:41 +08:00
Merge branch 'master' into edit-link-trans
This commit is contained in:
@@ -18,7 +18,7 @@ You’ve installed Talk on your server, and you’re preparing to launch it on y
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
For advanced configuration and usage of Talk, check out our [Configuration](https://docs.coralproject.net/talk/advanced-configuration/) and [Integration](https://docs.coralproject.net/talk/integrating/authentication/) how-tos. This covers topics in whih you will need dev support to fully customize and integrate Talk, such as SSO/authentication, creating and managing assets and articles, styling Talk with custom CSS, and setting up Notifications and SMTP support.
|
||||
For advanced configuration and usage of Talk, check out our [Configuration](https://docs.coralproject.net/talk/advanced-configuration/) and [Integration](https://docs.coralproject.net/talk/integrating/authentication/) how-tos. This covers topics in which you will need dev support to fully customize and integrate Talk, such as SSO/authentication, creating and managing assets and articles, styling Talk with custom CSS, and setting up Notifications and SMTP support.
|
||||
|
||||
## Versions & Upgrading
|
||||
|
||||
|
||||
@@ -219,6 +219,28 @@ async function rewrite(search, replace, options) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* debugAssetURL will scrape the given URL and print it's scraped values.
|
||||
*/
|
||||
async function debugAssetURL(url) {
|
||||
try {
|
||||
const meta = await scraper.scrape(url);
|
||||
|
||||
const table = new Table({ head: ['Property', 'Value'] });
|
||||
|
||||
for (const [property, value] of Object.entries(meta)) {
|
||||
table.push([property, value]);
|
||||
}
|
||||
|
||||
console.log(table.toString());
|
||||
|
||||
util.shutdown(0);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
util.shutdown(1);
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Setting up the program command line arguments.
|
||||
//==============================================================================
|
||||
@@ -234,6 +256,13 @@ program
|
||||
.description('list all the assets in the database')
|
||||
.action(listAssets);
|
||||
|
||||
program
|
||||
.command('debug [url]')
|
||||
.description(
|
||||
'prints the scraped metadata that would be added to the given asset'
|
||||
)
|
||||
.action(debugAssetURL);
|
||||
|
||||
program
|
||||
.command('refresh [age]')
|
||||
.description('queues the assets that exceed the age requested')
|
||||
|
||||
@@ -155,9 +155,19 @@ class StreamSettings extends React.Component {
|
||||
<ConfigureCard
|
||||
checked={settings.infoBoxEnable}
|
||||
onCheckbox={this.updateInfoBoxEnable}
|
||||
title={t('configure.include_comment_stream')}
|
||||
title={t('configure.code_of_conduct_summary')}
|
||||
>
|
||||
<p>{t('configure.include_comment_stream_desc')}</p>
|
||||
<p>
|
||||
{t('configure.code_of_conduct_summary_desc')}
|
||||
|
||||
<a
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
href="https://guides.coralproject.net/create-a-code-of-conduct/"
|
||||
>
|
||||
Code of Conduct Guide.
|
||||
</a>
|
||||
</p>
|
||||
<div
|
||||
className={cn(
|
||||
styles.configSettingInfoBox,
|
||||
@@ -238,12 +248,14 @@ class StreamSettings extends React.Component {
|
||||
onChange={this.updateClosedTimeout}
|
||||
value={getTimeoutAmount(settings.closedTimeout)}
|
||||
label={t('configure.closed_comments_label')}
|
||||
disabled={!settings.autoCloseStream}
|
||||
/>
|
||||
<div className={styles.configTimeoutSelect}>
|
||||
<SelectField
|
||||
label="comments closed time window"
|
||||
value={getTimeoutMeasure(settings.closedTimeout)}
|
||||
onChange={this.updateClosedTimeoutMeasure}
|
||||
readOnly={!settings.autoCloseStream}
|
||||
>
|
||||
<Option value={'hours'}>{t('configure.hours')}</Option>
|
||||
<Option value={'days'}>{t('configure.days')}</Option>
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import * as actions from '../constants/auth';
|
||||
import jwtDecode from 'jwt-decode';
|
||||
|
||||
function cleanAuthData(localStorage) {
|
||||
localStorage.removeItem('token');
|
||||
localStorage.removeItem('exp');
|
||||
}
|
||||
import { setStorageAuthToken, clearStorageAuthToken } from '../services/auth';
|
||||
|
||||
export const checkLogin = () => (
|
||||
dispatch,
|
||||
@@ -15,7 +10,7 @@ export const checkLogin = () => (
|
||||
rest('/auth')
|
||||
.then(result => {
|
||||
if (!result.user) {
|
||||
cleanAuthData(localStorage);
|
||||
clearStorageAuthToken(localStorage);
|
||||
dispatch(checkLoginSuccess(null));
|
||||
client.resetWebsocket();
|
||||
return;
|
||||
@@ -32,7 +27,7 @@ export const checkLogin = () => (
|
||||
.catch(error => {
|
||||
if (error.status && error.status === 401 && localStorage) {
|
||||
// Unauthorized.
|
||||
cleanAuthData(localStorage);
|
||||
clearStorageAuthToken(localStorage);
|
||||
client.resetWebsocket();
|
||||
} else {
|
||||
console.error(error);
|
||||
@@ -58,8 +53,7 @@ export const setAuthToken = token => (
|
||||
_,
|
||||
{ localStorage, client }
|
||||
) => {
|
||||
localStorage.setItem('exp', jwtDecode(token).exp);
|
||||
localStorage.setItem('token', token);
|
||||
setStorageAuthToken(localStorage, token);
|
||||
|
||||
// Dispatch the set auth token action. For some browsers and situations, we
|
||||
// may not be able to persist the auth token any other way. Keep it in redux!
|
||||
@@ -76,9 +70,7 @@ export const handleSuccessfulLogin = (user, token) => (
|
||||
_,
|
||||
{ client, localStorage, postMessage }
|
||||
) => {
|
||||
const { exp } = jwtDecode(token);
|
||||
localStorage.setItem('exp', exp);
|
||||
localStorage.setItem('token', token);
|
||||
setStorageAuthToken(localStorage, token);
|
||||
|
||||
// Send the message via the messages service to the window.opener if it
|
||||
// exists.
|
||||
@@ -117,7 +109,7 @@ export const logout = () => async (
|
||||
}
|
||||
|
||||
// Clear the auth data persisted to localStorage.
|
||||
cleanAuthData(localStorage);
|
||||
clearStorageAuthToken(localStorage);
|
||||
|
||||
// Reset the websocket.
|
||||
client.resetWebsocket();
|
||||
|
||||
@@ -44,6 +44,5 @@
|
||||
|
||||
.disabledBody {
|
||||
color: #ccc;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import jwtDecode from 'jwt-decode';
|
||||
|
||||
export const setStorageAuthToken = (storage, token) => {
|
||||
storage.setItem('exp', jwtDecode(token).exp);
|
||||
storage.setItem('token', token);
|
||||
};
|
||||
|
||||
export const clearStorageAuthToken = storage => {
|
||||
storage.removeItem('token');
|
||||
storage.removeItem('exp');
|
||||
};
|
||||
+25
-1
@@ -22,6 +22,7 @@ import {
|
||||
} from 'coral-framework/services/storage';
|
||||
import { createHistory } from 'coral-framework/services/history';
|
||||
import { createIntrospection } from 'coral-framework/services/introspection';
|
||||
import { setStorageAuthToken } from 'coral-framework/services/auth';
|
||||
import introspectionData from 'coral-framework/graphql/introspection.json';
|
||||
import coreReducers from '../reducers';
|
||||
import { checkLogin as checkLoginAction } from '../actions/auth';
|
||||
@@ -46,7 +47,30 @@ const getAuthToken = (store, storage) => {
|
||||
// capable of storing the token in localStorage, then we would have
|
||||
// persisted it to the redux state.
|
||||
return state.config.auth_token || state.auth.token;
|
||||
} else if (!bowser.safari && !bowser.ios && storage) {
|
||||
} else if (location.hash && location.hash.startsWith('#access_token=')) {
|
||||
// Check to see if the access token is living in the URL as a hash.
|
||||
const token = location.hash.substring(14);
|
||||
|
||||
history.replaceState(
|
||||
{},
|
||||
document.title,
|
||||
window.location.pathname + window.location.search
|
||||
);
|
||||
|
||||
// Once we clear the hash above, this login method will not persist across
|
||||
// refreshes. We will need to persist the token to storage if it's
|
||||
// available.
|
||||
if (storage) {
|
||||
setStorageAuthToken(storage, token);
|
||||
}
|
||||
|
||||
return token;
|
||||
} else if (
|
||||
!bowser.safari &&
|
||||
!bowser.ios &&
|
||||
storage &&
|
||||
storage.getItem('token')
|
||||
) {
|
||||
// Use local storage auth tokens where there's a stable api.
|
||||
return storage.getItem('token');
|
||||
}
|
||||
|
||||
@@ -104,6 +104,8 @@ sidebar:
|
||||
url: /integrating/authentication/
|
||||
- title: Asset Management
|
||||
url: /integrating/asset-management/
|
||||
- title: Asset Scraping
|
||||
url: /integrating/asset-scraping/
|
||||
- title: Configuring the Comment Stream
|
||||
url: /integrating/configuring-comment-stream/
|
||||
- title: Configuring the Admin
|
||||
|
||||
@@ -7,7 +7,7 @@ Trust is a set of components within Talk that incorporate basic automated modera
|
||||
|
||||
## User Karma Score
|
||||
|
||||
Using Trust’s calculations, Talk will automatically hold back, move to the Reported queue, and tag with a 'History' marker, any comments by users who have an Unreliable karma score. (This is for sites who practice post-moderation. If you set pre-moderation of all comments sitewide, this feature has limited use.)
|
||||
Using Trust’s calculations, Talk will automatically hold back, move to the Reported queue, and tag with a 'Karma' marker, any comments by users who have an Unreliable karma score. (This is for sites who practice post-moderation. If you set pre-moderation of all comments sitewide, this feature has limited use.)
|
||||
|
||||
All users start out with a Neutral karma score (`0`). If they have a comment approved by a moderator, their score increases by `1`; if they have a comment rejected by a moderator, it decreases by `1`. When a commenter's score is labeled as Unreliable, their comments must be approved from the Reported queue before they are posted. Commenters are shown a message stating that a moderator will review their comment shortly.
|
||||
|
||||
@@ -27,29 +27,3 @@ We strongly recommend not telling your community how this system works, or where
|
||||
|
||||
If you see that a high proportion of first-time commenters on your site are abusive, you might want to change the threshhold to `0`, at least temporarily. You can configure your own Trust thresholds by using [TRUST_THRESHOLDS](/talk/advanced-configuration/#trust-thresholds) in your site configuration.
|
||||
|
||||
|
||||
## Reliable and Unreliable Flaggers
|
||||
|
||||
Trust also calculates how reliable users are in terms of the comments they
|
||||
report. This information is displayed to moderators in the User History drawer,
|
||||
which is accessed by clicking on a user’s name in the Admin. Currently, no other action is taken based on this score.
|
||||
|
||||
If a user's reports mostly match what moderators reject, their Report status
|
||||
will display to moderators as Reliable in the user information drawer. If a
|
||||
user's reports mostly differ from what moderators reject, their Report status
|
||||
will show as Unreliable.
|
||||
|
||||
If Talk doesn't have enough reports to make a call, or the reports even out, their
|
||||
status is Neutral.
|
||||
|
||||
Here are the default thresholds:
|
||||
|
||||
```text
|
||||
-1 and lower: Unreliable
|
||||
0 to +1: Neutral
|
||||
+2 and higher: Reliable
|
||||
```
|
||||
You can configure your own Trust thresholds by using [TRUST_THRESHOLDS](/talk/advanced-configuration/#trust-thresholds) in your
|
||||
configuration.
|
||||
|
||||
Note: Report Karma doesn't include reports of "I don't agree with this comment".
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
title: Asset Scraping
|
||||
permalink: /integrating/asset-scraping/
|
||||
---
|
||||
|
||||
By default, Assets in Talk have their metadata scraped when they are loaded.
|
||||
This provides the easiest way for newsrooms to integrate their CMS's into Talk
|
||||
in a simple way. We use the following
|
||||
[meta tags](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta) on
|
||||
the target pages that allow us to extract some properties.
|
||||
|
||||
| Asset Property | Selector |
|
||||
|--------------------|----------|
|
||||
| `title` | See [`metascraper-title`](https://github.com/microlinkhq/metascraper/blob/dc664c37ea1b238b1e3e9d5342edfacc9027892c/packages/metascraper-title/index.js) |
|
||||
| `description` | See [`metascraper-description`](https://github.com/microlinkhq/metascraper/blob/dc664c37ea1b238b1e3e9d5342edfacc9027892c/packages/metascraper-description/index.js) |
|
||||
| `image` | See [`metascraper-image`](https://github.com/microlinkhq/metascraper/blob/dc664c37ea1b238b1e3e9d5342edfacc9027892c/packages/metascraper-image/index.js) |
|
||||
| `author` | See [`metascraper-author`](https://github.com/microlinkhq/metascraper/blob/dc664c37ea1b238b1e3e9d5342edfacc9027892c/packages/metascraper-author/index.js) |
|
||||
| `publication_date` | See [`metascraper-date`](https://github.com/microlinkhq/metascraper/blob/dc664c37ea1b238b1e3e9d5342edfacc9027892c/packages/metascraper-date/index.js) |
|
||||
| `modified_date` | `meta[property="article:modified"]` |
|
||||
| `section` | `meta[property="article:section"]` |
|
||||
|
||||
You can use the `./bin/cli assets debug <url>` to print the scraped metadata
|
||||
from that URL. For example:
|
||||
|
||||
```bash
|
||||
$ ./bin/cli assets debug https://www.washingtonpost.com/technology/2018/10/30/apple-event-october-ipad-pro-macbook-air/
|
||||
┌──────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ Property │ Value │
|
||||
├──────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ title │ Apple redesigns the iPad Pro, breathes new life in the MacBook Air │
|
||||
├──────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ description │ Apple is unveiling new iPads and MacBooks at an event in New York starting at 10 a.m. Fowler is there and will report in with the news and hands-on analysis throughout the day. │
|
||||
├──────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ image │ https://www.washingtonpost.com/resizer/JAwNQE2alL2JjiWrbXeJ46wZHqA=/1484x0/arc-anglerfish-washpost-prod-washpost.s3.amazonaws.com/public/G5TWBFW4LAI6RC5MX7QB7TODUY.jpg │
|
||||
├──────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ author │ Geoffrey A. Fowler │
|
||||
├──────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ publication_date │ 2018-10-30T10:40:00.000Z │
|
||||
├──────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ modified_date │ │
|
||||
├──────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ section │ │
|
||||
└──────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
+3
-62
@@ -3,59 +3,7 @@ const scraper = require('../../services/scraper');
|
||||
const Assets = require('../../services/assets');
|
||||
const { createLogger } = require('../../services/logging');
|
||||
const logger = createLogger('jobs:scraper');
|
||||
const fetch = require('node-fetch');
|
||||
const { merge } = require('lodash');
|
||||
const { version } = require('../../package.json');
|
||||
const { SCRAPER_HEADERS, SCRAPER_PROXY_URL } = require('../../config');
|
||||
const ProxyAgent = require('proxy-agent');
|
||||
|
||||
// Load the scraper with the rules.
|
||||
const metascraper = require('metascraper').load([
|
||||
require('metascraper-title')(),
|
||||
require('metascraper-description')(),
|
||||
require('metascraper-image')(),
|
||||
require('metascraper-author')(),
|
||||
require('metascraper-date')(),
|
||||
require('./rules/modified')(),
|
||||
require('./rules/section')(),
|
||||
]);
|
||||
|
||||
let customHeaders = {};
|
||||
try {
|
||||
customHeaders = JSON.parse(SCRAPER_HEADERS);
|
||||
} catch (err) {
|
||||
console.error('Cannot parse TALK_SCRAPER_HEADERS');
|
||||
throw err;
|
||||
}
|
||||
|
||||
// Parse the headers to be added to the scraper.
|
||||
const headers = merge(
|
||||
{
|
||||
'User-Agent': `Coral-Talk/${version}`,
|
||||
},
|
||||
customHeaders
|
||||
);
|
||||
|
||||
// Add proxy configuration if exists.
|
||||
const agent = SCRAPER_PROXY_URL ? new ProxyAgent(SCRAPER_PROXY_URL) : null;
|
||||
|
||||
/**
|
||||
* Scrapes the given asset for metadata.
|
||||
*/
|
||||
async function scrape({ url }) {
|
||||
const res = await fetch(url, {
|
||||
headers,
|
||||
agent,
|
||||
});
|
||||
const html = await res.text();
|
||||
|
||||
// Get the metadata from the scraped html.
|
||||
const metadata = await metascraper({
|
||||
html,
|
||||
url,
|
||||
});
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an Asset based on scraped asset metadata.
|
||||
@@ -64,16 +12,9 @@ function update(id, meta) {
|
||||
return Asset.update(
|
||||
{ id },
|
||||
{
|
||||
$set: {
|
||||
title: meta.title || '',
|
||||
description: meta.description || '',
|
||||
image: meta.image ? meta.image : '',
|
||||
author: meta.author || '',
|
||||
publication_date: meta.date || '',
|
||||
modified_date: meta.modified || '',
|
||||
section: meta.section || '',
|
||||
$set: merge(meta, {
|
||||
scraped: new Date(),
|
||||
},
|
||||
}),
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -95,7 +36,7 @@ module.exports = () => {
|
||||
}
|
||||
|
||||
// Scrape the metadata from the asset.
|
||||
const meta = await scrape(asset);
|
||||
const meta = await scraper.scrape(asset.url);
|
||||
|
||||
log.info('Finished scraping');
|
||||
|
||||
|
||||
+2
-2
@@ -130,8 +130,8 @@ ar:
|
||||
enable_questionbox: 'اطرح سؤال على القراء'
|
||||
enable_questionbox_description: 'هذا السؤال سيظهر في الجزء العلوي من جدول التعليقات هذا. اسأل القراء عن مسألة معينة في المقال او اطرح أسئلة نقاشية.. الخ.'
|
||||
hours: ساعات
|
||||
include_comment_stream: 'ادراج وصف جدول التعليقات للقراء'
|
||||
include_comment_stream_desc: 'اكتب رسالة ليتم إضافتها إلى الجزء العلوي من جدول التعليقات. ضع موضوعا، اشمل القواعد الإرشادية للمجموعة .. الخ'
|
||||
code_of_conduct_summary: 'ادراج وصف جدول التعليقات للقراء'
|
||||
code_of_conduct_summary_desc: 'اكتب رسالة ليتم إضافتها إلى الجزء العلوي من جدول التعليقات. ضع موضوعا، اشمل القواعد الإرشادية للمجموعة .. الخ'
|
||||
include_question_here: 'اكتب سؤالك هنا:'
|
||||
include_text: 'ادرج النص هنا.'
|
||||
moderate: اشرف
|
||||
|
||||
+2
-2
@@ -123,8 +123,8 @@ da:
|
||||
enable_questionbox: 'Stil et spørgsmål til læserne'
|
||||
enable_questionbox_description: 'Dette spørgsmål vises øverst i denne kommentarstrøm. Stil et spørgsmål til læserne om et bestemt problem i artiklen eller stil spørgsmål til diskussion mv.'
|
||||
hours: Timer
|
||||
include_comment_stream: 'Inkluder kommentarstrømmens beskrivelse for læsere'
|
||||
include_comment_stream_desc: 'Skriv en besked, der skal tilføjes øverst i din kommentarstrøm. Indsæt et emne der omfatter fællesskabsretningslinjer mv.'
|
||||
code_of_conduct_summary: 'Inkluder kommentarstrømmens beskrivelse for læsere'
|
||||
code_of_conduct_summary_desc: 'Skriv en besked, der skal tilføjes øverst i din kommentarstrøm. Indsæt et emne der omfatter fællesskabsretningslinjer mv.'
|
||||
include_question_here: 'Stil dit spørgsmål her:'
|
||||
include_text: 'Medtag din tekst her.'
|
||||
moderate: Moderat
|
||||
|
||||
+2
-2
@@ -132,8 +132,8 @@ de:
|
||||
enable_questionbox: 'Stellen Sie den Lesern eine Frage'
|
||||
enable_questionbox_description: 'Diese Frage erscheint am Anfang des Kommentarbereichs. Regen Sie eine Diskussion an.'
|
||||
hours: Stunden
|
||||
include_comment_stream: 'Einleitung zum Kommentarbereich'
|
||||
include_comment_stream_desc: 'Verfassen Sie eine Einleitung, die über jedem Kommentarbereich erscheint. Nützlich z.B. für Community-Richtlinien.'
|
||||
code_of_conduct_summary: 'Einleitung zum Kommentarbereich'
|
||||
code_of_conduct_summary_desc: 'Verfassen Sie eine Einleitung, die über jedem Kommentarbereich erscheint. Nützlich z.B. für Community-Richtlinien.'
|
||||
include_question_here: 'Stellen Sie Ihre Frage hier:'
|
||||
include_text: 'Fügen Sie Ihren Text hier ein.'
|
||||
moderate: Moderieren
|
||||
|
||||
+3
-3
@@ -137,8 +137,8 @@ en:
|
||||
enable_questionbox: 'Ask Readers a Question'
|
||||
enable_questionbox_description: 'This question will appear at the top of this comment stream. Ask readers about a certain issue in the article or pose discussion questions etc.'
|
||||
hours: Hours
|
||||
include_comment_stream: 'Include Comment Stream Description for Readers'
|
||||
include_comment_stream_desc: 'Write a message to be added to the top of your comment stream. Pose a topic include community guidelines etc.'
|
||||
code_of_conduct_summary: 'Summary of your Code of Conduct'
|
||||
code_of_conduct_summary_desc: 'This message will appear above every comments stream on your site. Click here to learn more about writing a good code.'
|
||||
include_question_here: 'Write your question here:'
|
||||
include_text: 'Include your text here.'
|
||||
moderate: Moderate
|
||||
@@ -259,7 +259,7 @@ en:
|
||||
organization_contact_email: 'Organization email is not valid.'
|
||||
organization_name: 'Organization name must only contain letters or numbers.'
|
||||
password: 'Password must be at least 8 characters'
|
||||
PAGE_NOT_AVAILABLE_ROLE: 'This page is for team use only. Please contact an administrator if you want to join this team.'
|
||||
PAGE_NOT_AVAILABLE_ROLE: 'This page is for team use only. Please contact an administrator if you want to join this team.'
|
||||
PASSWORD_INCORRECT: 'Your current password was entered incorrectly'
|
||||
PASSWORD_LENGTH: 'Password is too short'
|
||||
PASSWORD_REQUIRED: 'Must input a password'
|
||||
|
||||
+29
-29
@@ -4,19 +4,19 @@ es:
|
||||
view_options: 'Ver opciones'
|
||||
already_flagged_username: 'Usted ya reportó a este usuario.'
|
||||
bandialog:
|
||||
are_you_sure: '¿Estás segura que quieres suspender a {0}?'
|
||||
ban_user: '¿Quieres suspender el Usuario?'
|
||||
are_you_sure: '¿Estás seguro que quieres suspender a {0}?'
|
||||
ban_user: '¿Quieres suspender al Usuario?'
|
||||
banned_user: 'Usuario Suspendido'
|
||||
cancel: Cancelar
|
||||
email_message_ban: "Estimado/a {0},\n\nUsted o alguien con acceso a su cuenta a violado los lineamientos de nuestra comunidad. Como consecuencia de esto, su cuenta fue bloqueada. No podrá realizar ni reportar más comentarios. Si usted piensa que esto ha sido un error, por favor contáctese con nosotros."
|
||||
email_message_ban: "Estimado/a {0},\n\nUsted o alguien con acceso a su cuenta ha violado los lineamientos de nuestra comunidad. Como consecuencia de esto, su cuenta fue bloqueada. No podrá realizar ni reportar más comentarios. Si usted piensa que esto ha sido un error, por favor contáctese con nosotros."
|
||||
note: 'Nota: {0}'
|
||||
note_ban_user: 'Suspender a este usuario no le va a permitir (al usuario) borrar ni editar ni comentar.'
|
||||
note_reject_comment: 'Suspender a este usuario también va a colocar este comentario en la cola de Rechazados.'
|
||||
notify_ban_description: 'Esto notificará al usuario por email que fueron suspendidos de la comunidad'
|
||||
notify_ban_description: 'Esto notificará al usuario por correo electrónico que fueron suspendidos de la comunidad'
|
||||
notify_ban_headline: 'Notificar al usuario de la suspensión'
|
||||
send: Enviar
|
||||
write_a_message: 'Escribe un mensaje'
|
||||
yes_ban_user: 'Si, Suspender al usuario'
|
||||
yes_ban_user: 'Si, suspender al usuario'
|
||||
bio_offensive: 'Esta biografia es ofensiva'
|
||||
cancel: Cancelar
|
||||
characters_remaining: 'caracteres restantes'
|
||||
@@ -30,9 +30,9 @@ es:
|
||||
view_context: 'Ver contexto'
|
||||
comment_box:
|
||||
cancel: Cancelar
|
||||
characters_remaining: 'carácteres restantes'
|
||||
characters_remaining: 'caracteres restantes'
|
||||
comment: 'Publicar un comentario'
|
||||
comment_post_banned_word: 'Tu comentario contiene una o más palabras que no están permitidas en nuestro espacio, por lo que no será publicado. Si crees que es un error, por favor contacta a nuestro equipo de moderación.'
|
||||
comment_post_banned_word: 'Tu comentario contiene una o más palabras que no están permitidas en nuestro espacio, por lo que no será publicado. Si crees que es un error, por favor contactate a nuestro equipo de moderación.'
|
||||
comment_post_notif: 'Tu comentario ha sido publicado.'
|
||||
comment_post_notif_premod: 'Gracias por el comentario. Nuestro equipo de moderación va a revisarlo muy pronto.'
|
||||
name: Nombre
|
||||
@@ -40,7 +40,7 @@ es:
|
||||
reply: Responder
|
||||
comment_offensive: 'Este comentario es ofensivo'
|
||||
comment_plural: Comentarios
|
||||
comment_post_banned_word: 'Tu comentario contiene una o más palabras que no están permitidas en nuestro espacio, por lo que no será publicado. Si crees que es un error, por favor contacta a nuestro equipo de moderación.'
|
||||
comment_post_banned_word: 'Tu comentario contiene una o más palabras que no están permitidas en nuestro espacio, por lo que no será publicado. Si crees que es un error, por favor contactate con nuestro equipo de moderación.'
|
||||
comment_post_notif: 'Tu comentario ha sido publicado.'
|
||||
comment_post_notif_premod: 'Gracias por el comentario. Nuestro equipo de moderación va a revisarlo muy pronto.'
|
||||
comment_singular: Comentario
|
||||
@@ -57,40 +57,40 @@ es:
|
||||
account_creation_date: 'Fecha de creación de la cuenta'
|
||||
active: Activa
|
||||
admin: Administrator
|
||||
ads_marketing: 'Esto parece ser un ad/marketing'
|
||||
ads_marketing: 'Esto parece ser un publicidad/acción de comercialización'
|
||||
all: 'Todos'
|
||||
are_you_sure: '¿Estás segura que quieres suspender a {0}?'
|
||||
are_you_sure: '¿Estás seguro que quieres suspender a {0}?'
|
||||
ban_user: '¿Quieres suspender al Usuario?'
|
||||
banned: Suspendido
|
||||
banned_user: 'Usuario Suspendido'
|
||||
banned_user: 'Usuario suspendido'
|
||||
cancel: Cancelar
|
||||
commenter: Comentarista
|
||||
dont_like_username: 'No me gusta este nombre de usuario'
|
||||
filter_users: 'Filter users'
|
||||
filter_users: 'Filtrarr usuarios'
|
||||
filter_role: Rol
|
||||
flaggedaccounts: 'Nombres de Usuario Reportados'
|
||||
flaggedaccounts: 'Nombres de usuario reportados'
|
||||
flags: Reportes
|
||||
impersonating: Impersonando
|
||||
loading: 'Cargando resultados'
|
||||
moderator: Moderator
|
||||
newsroom_role: 'Rol en la redacción'
|
||||
no_flagged_accounts: 'No hay ningún nombre de usario reportado en este momento.'
|
||||
no_flagged_accounts: 'No hay ningún nombre de usuario reportado en este momento.'
|
||||
no_results: 'No se encontraron usuarios con ese nombre o correo.'
|
||||
offensive: Ofensivo
|
||||
other: Otro
|
||||
people: Gente
|
||||
role: 'Seleccionar rol...'
|
||||
select_status: 'Seleccionar estado...'
|
||||
spam_ads: Spam/Publicidad
|
||||
spam_ads: Correo basura/Publicidad
|
||||
staff: Personal
|
||||
status: Estado
|
||||
suspended: Suspendido
|
||||
username_and_email: 'Usuario y Correo'
|
||||
yes_ban_user: 'Si, Suspendan el usuario'
|
||||
yes_ban_user: 'Sí, suspendan el usuario'
|
||||
configure:
|
||||
access_message: 'Usted debe ser un administrador para acceder a esta página. Encuentre a otro admin y actualice los permisos de su cuenta!'
|
||||
access_message: 'Usted debe ser un administrador para acceder a esta página. Encuentre a otro administrador y actualice los permisos de su cuenta!'
|
||||
apply: Aplicar
|
||||
banned_word_text: 'Comentarios que contengan estas palabras o frases, en mayusculas o minúsculas, serán automáticamente eliminados del hilo de comentario. Escribir una palabra y apretar Enter o Tabulador para agregarla. O pueden pegar una lista de palabras separadas por coma.'
|
||||
banned_word_text: 'Comentarios que contengan estas palabras o frases, en mayúsculas o minúsculas, serán automáticamente eliminados del hilo de comentarios. Escribir una palabra y apretar Enter o Tabulador para agregarla. O pueden pegar una lista de palabras separadas por coma.'
|
||||
banned_words_title: 'Lista de palabras prohibidas'
|
||||
close: Cerrar
|
||||
close_after: 'Cerrar comentarios luego de'
|
||||
@@ -98,14 +98,14 @@ es:
|
||||
close_stream_configuration: 'Este hilo de comentario está en este momento cerrado. Al abrirlo, nuevos comentarios serán publicados y mostrados.'
|
||||
closed_comments_desc: 'Escribe un mensaje que será mostrado cuando los comentarios estén cerrados y no se acepten más comentarios.'
|
||||
closed_comments_label: 'Escribe un mensaje...'
|
||||
closed_stream_settings: 'Mensaje que se muestra cuando no se aceptan más comentarios en el articulo'
|
||||
closed_stream_settings: 'Mensaje que se muestra cuando no se aceptan más comentarios en el artículo'
|
||||
comment_count_error: 'Por favor escribir un número válido'
|
||||
comment_count_header: 'Limitar el largo del comentario'
|
||||
comment_count_text_post: carácteres
|
||||
comment_count_text_post: caracteres
|
||||
comment_count_text_pre: 'Los comentarios serán limitados a'
|
||||
comment_settings: Configuración
|
||||
comment_stream: 'Hilo de Comentarios'
|
||||
comment_stream_will_close: 'El hilo de comentarios se cerrara'
|
||||
comment_stream_will_close: 'El hilo de comentarios se cerrará'
|
||||
community: Comunidad
|
||||
configure: Configurar
|
||||
copy_and_paste: 'Copiar y pegar el código de más abajo en tu CMS para colocar la caja de comentarios en tus artículos'
|
||||
@@ -122,16 +122,16 @@ es:
|
||||
embed_comment_stream: 'Colocar Hilo de Comentarios'
|
||||
enable_pre_moderation: 'Permitir pre-moderación'
|
||||
enable_pre_moderation_text: 'Los moderadores deben aprobar todo comentario antes que sea publicado.'
|
||||
enable_premod: 'Activar Pre Moderación'
|
||||
enable_premod: 'Activar Pre-Moderación'
|
||||
enable_premod_description: 'Los y las moderadoras deben aprobar cualquier comentario antes de su publicación'
|
||||
enable_premod_links: 'Pre-Moderar Comentarios que contienen Enlaces'
|
||||
enable_premod_links: 'Pre-Moderar comentarios que contienen Enlaces'
|
||||
enable_premod_links_description: 'Los y las moderadoras deben aprobar cualquier comentario que contengan enlaces antes de su publicación.'
|
||||
enable_premod_links_text: 'Los moderadores deben aprobar todo comentario que contenga un enlace antes de que sea publicado.'
|
||||
enable_questionbox: 'Hacer una pregunta a los y las lectoras.'
|
||||
enable_questionbox_description: 'Esta pregunta aparecerá en la parte de arriba del hilo de comentarios.'
|
||||
hours: Horas
|
||||
include_comment_stream: 'Incluir Descripción de Hilo de Comentarios para Lectores'
|
||||
include_comment_stream_desc: 'Escribir un mensaje para ser incluido al principio del hilo de comentarios. Un tema planteado podría ser la guía de comunidad, etc.'
|
||||
code_of_conduct_summary: 'Incluir Descripción de Hilo de Comentarios para Lectores'
|
||||
code_of_conduct_summary_desc: 'Escribir un mensaje para ser incluido al principio del hilo de comentarios. Un tema planteado podría ser la guía de comunidad, etc.'
|
||||
include_question_here: 'Escribir la pregunta aquí.'
|
||||
include_text: 'Agregar tu texto aquí.'
|
||||
moderate: Moderar
|
||||
@@ -140,7 +140,7 @@ es:
|
||||
open_stream: 'Abrir Hilo de Comentarios'
|
||||
open_stream_configuration: 'Este hilo de comentarios está abierto. Al cerrarlo no se podrán publicar nuevos comentarios pero todos los comentarios anteriores aún serán mostrados.'
|
||||
organization_contact_email: 'Email de la Organización'
|
||||
organization_info_copy: 'Nosotros usamos esta información en las notificaciones de email generadas por Talk. Esto conecta los mensajes de tu organización, y provee una forma para que los usuarios se comuniquen si tienen un inconveniente con su cuenta.'
|
||||
organization_info_copy: 'Nosotros usamos esta información en las notificaciones de correo electrónico generadas por Talk. Esto conecta los mensajes de tu organización, y provee una forma para que los usuarios se comuniquen si tienen un inconveniente con su cuenta.'
|
||||
organization_info_copy_2: 'Recomendamos crear un email genérico (ej: community@yournewsroom.com) for this purpose. Esto significa que puede permanecer consistente con el tiempo y no expone un nombre que los usuarios puedan atacar si su cuenta fue bloqueada.'
|
||||
organization_information: 'Información de la Organización'
|
||||
organization_name: 'Nombre de la Organización'
|
||||
@@ -316,14 +316,14 @@ es:
|
||||
save: Guardar
|
||||
create:
|
||||
confirm_password: 'Confirmar Contraseña'
|
||||
email: 'Dirección de correo'
|
||||
organization_contact_email: 'Organización: Email de contacto'
|
||||
email: 'Dirección de correo electrónico'
|
||||
organization_contact_email: 'Organización: correo electrónico de contacto'
|
||||
password: Contraseña
|
||||
save: Guardar
|
||||
username: 'Nombre de Usuario'
|
||||
final:
|
||||
close: 'Cerrar este instalador'
|
||||
description: '¡Gracias por instalar Talk! Enviamos un correo para verificar su dirección de correo. Mientras esta terminando de configurar su cuenta, ya puede comenzar a involucrarse con sus lectores.'
|
||||
description: '¡Gracias por instalar Talk! Enviamos un correo para verificar su dirección de correo electrónico. Mientras esta terminando de configurar su cuenta, ya puede comenzar a involucrarse con sus lectores.'
|
||||
launch: 'Iniciar Talk'
|
||||
initial:
|
||||
description: 'Vamos a crear su comunidad Talk en unos pocos pasos.'
|
||||
|
||||
+2
-2
@@ -123,8 +123,8 @@ fi_FI:
|
||||
enable_questionbox: 'Kysy lukijoilta'
|
||||
enable_questionbox_description: 'Tämä kysymys tulee näkymään kommenttiosion ylälaidassa. Kysy artikkelin aiheesta tai ohjaa keskustelua kysymyksen avulla.'
|
||||
hours: Tuntia
|
||||
include_comment_stream: 'Sisällytä kommentoinnin kuvaus lukijoille'
|
||||
include_comment_stream_desc: 'Kirjoita kommenttiosion yläreunassa näkyvä viesti. Aseta keskustelun aihe, sisällytä sääntöjä tms.'
|
||||
code_of_conduct_summary: 'Sisällytä kommentoinnin kuvaus lukijoille'
|
||||
code_of_conduct_summary_desc: 'Kirjoita kommenttiosion yläreunassa näkyvä viesti. Aseta keskustelun aihe, sisällytä sääntöjä tms.'
|
||||
include_question_here: 'Kirjoita kysymyksesi tähän:'
|
||||
include_text: 'Lisää teksti tähän.'
|
||||
moderate: Moderoi
|
||||
|
||||
+2
-2
@@ -127,8 +127,8 @@ fr:
|
||||
enable_questionbox: 'Posez une question aux lecteurs.'
|
||||
enable_questionbox_description: 'Cette question apparaîtra en haut de ce fil de commentaires. Demandez aux lecteurs de s''exprimer sur un sujet évoqué dans l''article ou posez les termes de la discussion, etc.'
|
||||
hours: Heures
|
||||
include_comment_stream: 'Inclure la description du fil de commentaires pour les lecteurs'
|
||||
include_comment_stream_desc: 'Écrivez un message à ajouter au haut de votre flux de commentaires. Publiez un sujet de discussion, avec des suggestion sur la tenue des débats, etc.'
|
||||
code_of_conduct_summary: 'Inclure la description du fil de commentaires pour les lecteurs'
|
||||
code_of_conduct_summary_desc: 'Écrivez un message à ajouter au haut de votre flux de commentaires. Publiez un sujet de discussion, avec des suggestion sur la tenue des débats, etc.'
|
||||
include_question_here: 'Écrivez votre question ici.'
|
||||
include_text: 'Entrez votre texte ici.'
|
||||
moderate: Modérer
|
||||
|
||||
+2
-2
@@ -123,8 +123,8 @@ nl_NL:
|
||||
enable_questionbox: 'Stel een vraag aan de lezers'
|
||||
enable_questionbox_description: 'Deze vraag zal bovenaan de conversatie verschijnen. Vraag lezers naar een probleem in het artikel, poneer discussie vragen, enzovoort.'
|
||||
hours: Uren
|
||||
include_comment_stream: 'Neem conversatie beschrijving op voor lezers.'
|
||||
include_comment_stream_desc: 'Schrijf een bericht voor boven je conversatie. Poneer een stelling, wijs op de community richtlijnen, etc.'
|
||||
code_of_conduct_summary: 'Neem conversatie beschrijving op voor lezers.'
|
||||
code_of_conduct_summary_desc: 'Schrijf een bericht voor boven je conversatie. Poneer een stelling, wijs op de community richtlijnen, etc.'
|
||||
include_question_here: 'Schrijf je vraag hier:'
|
||||
include_text: 'Schrijf hier je tekst.'
|
||||
moderate: Modereer
|
||||
|
||||
+4
-4
@@ -130,8 +130,8 @@ pt_BR:
|
||||
enable_questionbox: 'Faça uma pergunta aos leitores'
|
||||
enable_questionbox_description: 'Esta pergunta aparecerá no topo da lista de comentários. Pergunte aos leitores sobre um determinado problema no artigo, abra o assunto para discussão, etc.'
|
||||
hours: Horas
|
||||
include_comment_stream: 'Incluir descrição da lista comentários para leitores'
|
||||
include_comment_stream_desc: 'Escreva uma mensagem para adicionar ao topo do seu hilo de comentários. Posicionar um tópico, incluem diretrizes comunitárias, etc.'
|
||||
code_of_conduct_summary: 'Incluir descrição da lista comentários para leitores'
|
||||
code_of_conduct_summary_desc: 'Escreva uma mensagem para adicionar ao topo do seu hilo de comentários. Posicionar um tópico, incluem diretrizes comunitárias, etc.'
|
||||
include_question_here: 'Escreva sua pergunta aqui:'
|
||||
include_text: 'Inclua seu texto aqui:'
|
||||
moderate: Moderar
|
||||
@@ -209,7 +209,7 @@ pt_BR:
|
||||
to_confirm: 'Para confirmar a conta, visite este link: '
|
||||
password_change:
|
||||
body: "A sua senha foi alterada.\n\nSe você não solicitou essa alteracão, por favor nos contate em {0}"
|
||||
subject: '{0} password change'
|
||||
subject: '{0} password change'
|
||||
password_reset:
|
||||
if_you_did: 'Se você solicitou isso, '
|
||||
please_click: 'clique aqui para redefinir sua senha.'
|
||||
@@ -223,7 +223,7 @@ pt_BR:
|
||||
copied: 'Copiado'
|
||||
error:
|
||||
ALREADY_EXISTS: 'O recurso já existe'
|
||||
AUTHENTICATION: ‘Ocorreu um erro durante a autenticação da sua conta’
|
||||
AUTHENTICATION: ‘Ocorreu um erro durante a autenticação da sua conta’
|
||||
CANNOT_IGNORE_STAFF: 'Não é possível ignorar membros Staff.'
|
||||
COMMENT_PARENT_NOT_VISIBLE: 'O comentário que você está respondendo foi removido ou não existe.'
|
||||
COMMENT_TOO_SHORT: 'Seu comentário precisar ter mais de um caracter. Revise seu comentário e envie novamente'
|
||||
|
||||
+2
-2
@@ -114,8 +114,8 @@ zh_CN:
|
||||
enable_questionbox: 向读者提问
|
||||
enable_questionbox_description: 该问题将在评论流顶部出现。可以就文章中特定内容发问,也可以设置一个讨论问题,等等。
|
||||
hours: 小时
|
||||
include_comment_stream: 开启评论流描述
|
||||
include_comment_stream_desc: 填写将在评论流顶部出现的描述。可以写评论主题、社群指引方针,等等。
|
||||
code_of_conduct_summary: 开启评论流描述
|
||||
code_of_conduct_summary_desc: 填写将在评论流顶部出现的描述。可以写评论主题、社群指引方针,等等。
|
||||
include_question_here: 此处输入问题:
|
||||
include_text: 此处输入文本。
|
||||
moderate: 审查
|
||||
|
||||
+2
-2
@@ -113,8 +113,8 @@ zh_TW:
|
||||
enable_questionbox: 向讀者提問
|
||||
enable_questionbox_description: 該問題將會在評論流置頂。您可以詢問其他讀者有關文章中的具體時間或是提出討論等
|
||||
hours: 小時
|
||||
include_comment_stream: 包含讀者的評論流描述
|
||||
include_comment_stream_desc: 留言將在您的評論流中置頂。發布一個社區規則等
|
||||
code_of_conduct_summary: 包含讀者的評論流描述
|
||||
code_of_conduct_summary_desc: 留言將在您的評論流中置頂。發布一個社區規則等
|
||||
include_question_here: 請在此處輸入問題:
|
||||
include_text: 在此插入您的文本
|
||||
moderate: 審核
|
||||
|
||||
@@ -10,7 +10,8 @@ const debug = require('debug')('talk:plugin:toxic-comments');
|
||||
|
||||
/**
|
||||
* Get scores from the perspective api
|
||||
* @param {string} text text to be anaylized
|
||||
*
|
||||
* @param {string} text text to be analyzed
|
||||
* @return {object} object containing toxicity scores
|
||||
*/
|
||||
async function getScores(text) {
|
||||
@@ -43,13 +44,13 @@ async function getScores(text) {
|
||||
|
||||
// If we get an error, just say it's not a toxic comment.
|
||||
if (data.error) {
|
||||
debug('Recieved Error when submitting: %o', data.error);
|
||||
debug('Received Error when submitting: %o', data.error);
|
||||
return {
|
||||
TOXICITY: {
|
||||
summaryScore: 0.0,
|
||||
summaryScore: null,
|
||||
},
|
||||
SEVERE_TOXICITY: {
|
||||
summaryScore: 0.0,
|
||||
summaryScore: null,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -66,6 +67,7 @@ async function getScores(text) {
|
||||
|
||||
/**
|
||||
* Get toxicity probability
|
||||
*
|
||||
* @param {object} scores scores as returned by `getScores`
|
||||
* @return {number} toxicity probability from 0 - 1.0
|
||||
*/
|
||||
@@ -74,7 +76,9 @@ function getProbability(scores) {
|
||||
}
|
||||
|
||||
/**
|
||||
* isToxic determines if given probabilty or scores meets the toxicity threshold.
|
||||
* isToxic determines if given probability or scores meets the toxicity
|
||||
* threshold.
|
||||
*
|
||||
* @param {object|number} scoresOrProbability scores or probability
|
||||
* @return {boolean}
|
||||
*/
|
||||
@@ -89,6 +93,7 @@ function isToxic(scoresOrProbability) {
|
||||
/**
|
||||
* maskKeyInError is a decorator that calls fn and masks the
|
||||
* API_KEY in errors before throwing.
|
||||
*
|
||||
* @param {function} fn Function that returns a Promise
|
||||
* @return {function} decorated function
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,7 @@ module.exports = (
|
||||
},
|
||||
}
|
||||
) => {
|
||||
if (premodLinksEnable && linkify.test(comment.body)) {
|
||||
if (premodLinksEnable && linkify.test(comment.body.replace(/\xAD/g, ''))) {
|
||||
// Add the flag related to Trust to the comment.
|
||||
return {
|
||||
status: 'SYSTEM_WITHHELD',
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
const kue = require('./kue');
|
||||
|
||||
/**
|
||||
* Exposes a service object to allow operations to execute against the scraper.
|
||||
* @type {Object}
|
||||
*/
|
||||
const scraper = {
|
||||
/**
|
||||
* Create the new Task kue singleton.
|
||||
*/
|
||||
task: new kue.Task({
|
||||
name: 'scraper',
|
||||
}),
|
||||
|
||||
/**
|
||||
* Creates a new scraper job and scrapes the url when it gets processed.
|
||||
*/
|
||||
async create(ctx, id) {
|
||||
ctx.log.info({ assetID: id }, 'Creating job');
|
||||
|
||||
const job = await scraper.task.create({
|
||||
title: `Scrape for asset ${id}`,
|
||||
id: ctx.id,
|
||||
asset_id: id,
|
||||
});
|
||||
|
||||
ctx.log.info({ jobID: job.id, assetID: id }, 'Created job');
|
||||
|
||||
return job;
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = scraper;
|
||||
@@ -0,0 +1,96 @@
|
||||
const fetch = require('node-fetch');
|
||||
const ProxyAgent = require('proxy-agent');
|
||||
const { merge } = require('lodash');
|
||||
|
||||
const { SCRAPER_HEADERS, SCRAPER_PROXY_URL } = require('../../config');
|
||||
const kue = require('../kue');
|
||||
const { version } = require('../../package.json');
|
||||
|
||||
// Load the scraper with the rules.
|
||||
const metascraper = require('metascraper').load([
|
||||
require('metascraper-title')(),
|
||||
require('metascraper-description')(),
|
||||
require('metascraper-image')(),
|
||||
require('metascraper-author')(),
|
||||
require('metascraper-date')(),
|
||||
require('./rules/modified')(),
|
||||
require('./rules/section')(),
|
||||
]);
|
||||
|
||||
let customHeaders = {};
|
||||
try {
|
||||
customHeaders = JSON.parse(SCRAPER_HEADERS);
|
||||
} catch (err) {
|
||||
console.error('Cannot parse TALK_SCRAPER_HEADERS');
|
||||
throw err;
|
||||
}
|
||||
|
||||
// Parse the headers to be added to the scraper.
|
||||
const headers = merge(
|
||||
{
|
||||
'User-Agent': `Coral-Talk/${version}`,
|
||||
},
|
||||
customHeaders
|
||||
);
|
||||
|
||||
// Add proxy configuration if exists.
|
||||
const agent = SCRAPER_PROXY_URL ? new ProxyAgent(SCRAPER_PROXY_URL) : null;
|
||||
|
||||
/**
|
||||
* Exposes a service object to allow operations to execute against the scraper.
|
||||
* @type {Object}
|
||||
*/
|
||||
const scraper = {
|
||||
/**
|
||||
* Create the new Task kue singleton.
|
||||
*/
|
||||
task: new kue.Task({
|
||||
name: 'scraper',
|
||||
}),
|
||||
|
||||
/**
|
||||
* Creates a new scraper job and scrapes the url when it gets processed.
|
||||
*/
|
||||
async create(ctx, id) {
|
||||
ctx.log.info({ assetID: id }, 'Creating job');
|
||||
|
||||
const job = await scraper.task.create({
|
||||
title: `Scrape for asset ${id}`,
|
||||
id: ctx.id,
|
||||
asset_id: id,
|
||||
});
|
||||
|
||||
ctx.log.info({ jobID: job.id, assetID: id }, 'Created job');
|
||||
|
||||
return job;
|
||||
},
|
||||
|
||||
/**
|
||||
* Scrapes the given asset for metadata.
|
||||
*/
|
||||
async scrape(url) {
|
||||
const res = await fetch(url, {
|
||||
headers,
|
||||
agent,
|
||||
});
|
||||
const html = await res.text();
|
||||
|
||||
// Get the metadata from the scraped html.
|
||||
const meta = await metascraper({
|
||||
html,
|
||||
url,
|
||||
});
|
||||
|
||||
return {
|
||||
title: meta.title || '',
|
||||
description: meta.description || '',
|
||||
image: meta.image ? meta.image : '',
|
||||
author: meta.author || '',
|
||||
publication_date: meta.date || '',
|
||||
modified_date: meta.modified || '',
|
||||
section: meta.section || '',
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = scraper;
|
||||
@@ -8,7 +8,7 @@
|
||||
<h1>{{ t('password_reset.set_new_password') }}</h1>
|
||||
<p>{{ t('password_reset.change_password_help') }}</p>
|
||||
<div class="error-console"><span></span></div>
|
||||
<form id="reset-password-form">
|
||||
<form id="reset-password-form" method="post">
|
||||
<label for="password">
|
||||
{{ t('password_reset.new_password') }}
|
||||
<input type="password" name="password" placeholder="{{ t('password_reset.new_password') }}" />
|
||||
|
||||
Reference in New Issue
Block a user