Newer
Older
import { AnalysisAnalyzer, IndicesIndexSettings } from '@elastic/elasticsearch/lib/api/types';

Marlène SIMONDANT
committed
import { ConfigurationService } from '../configuration/configuration.service';
import { Page } from '../pages/schemas/page.schema';
import { Post } from '../posts/schemas/post.schema';
import { UserRole } from '../users/enum/user-role.enum';
import { User } from '../users/schemas/user.schema';

Marlène SIMONDANT
committed
export function rewriteGhostImgUrl(configService: ConfigurationService, itemData: Page | Post): Page | Post {
// Handle image display. Rewrite image URL to fit ghost infra issue.
if (!configService.isLocalConf()) {
if (itemData.feature_image) {
itemData.feature_image = `https://${configService.config.host}/blog/content${
itemData.feature_image.split('/content')[1]
}`;
}

Marlène SIMONDANT
committed
itemData.html = itemData.html.replace(regex, `https://${configService.config.host}/blog`);
}
return itemData;
}
export function hasAdminRole(user: User): boolean {
return user.role === UserRole.admin;
}
const analyzer: Record<string, AnalysisAnalyzer> = {
homemade_french: {
type: 'custom',
tokenizer: 'standard',
filter: ['lowercase', 'asciifolding', 'french_elision', 'french_stop', 'french_stemmer'],
},
homemade_french_stopless: {
type: 'custom',
tokenizer: 'standard',
filter: ['lowercase', 'asciifolding', 'french_elision', 'french_stemmer'],
},
};
export const es_settings_homemade_french: IndicesIndexSettings = {
analysis: {
filter: {
french_elision: {
type: 'elision',
articles_case: true,
articles: ['l', 'm', 't', 'qu', 'n', 's', 'j', 'd', 'c', 'jusqu', 'quoiqu', 'lorsqu', 'puisqu'],
},
french_stop: {
type: 'stop',
stopwords: '_french_',
},
french_stemmer: {
type: 'stemmer',
language: 'minimal_french',
},
},