import 'moment/locale/fa';
import 'moment/locale/pt-br';
import 'moment/locale/ja';
+import 'moment/locale/ka';
import {
UserOperation,
import Toastify from 'toastify-js';
import tippy from 'tippy.js';
-export const repoUrl = 'https://github.com/dessalines/lemmy';
+export const repoUrl = 'https://github.com/LemmyNet/lemmy';
export const helpGuideUrl = '/docs/about_guide.html';
export const markdownHelpUrl = `${helpGuideUrl}#markdown-guide`;
export const sortingHelpUrl = `${helpGuideUrl}#sorting`;
export const fetchLimit: number = 20;
export const mentionDropdownFetchLimit = 10;
+export const languages = [
+ { code: 'ca', name: 'Català' },
+ { code: 'en', name: 'English' },
+ { code: 'eo', name: 'Esperanto' },
+ { code: 'es', name: 'Español' },
+ { code: 'de', name: 'Deutsch' },
+ { code: 'ka', name: 'ქართული ენა' },
+ { code: 'fa', name: 'فارسی' },
+ { code: 'ja', name: '日本語' },
+ { code: 'pt_BR', name: 'Português Brasileiro' },
+ { code: 'zh', name: '中文' },
+ { code: 'fi', name: 'Suomi' },
+ { code: 'fr', name: 'Français' },
+ { code: 'sv', name: 'Svenska' },
+ { code: 'ru', name: 'Русский' },
+ { code: 'nl', name: 'Nederlands' },
+ { code: 'it', name: 'Italiano' },
+];
+
+export const themes = [
+ 'litera',
+ 'materia',
+ 'minty',
+ 'solar',
+ 'united',
+ 'cyborg',
+ 'darkly',
+ 'journal',
+ 'sketchy',
+ 'vaporwave',
+ 'vaporwave-dark',
+ 'i386',
+];
+
export function randomStr() {
return Math.random()
.toString(36)
}
export function validEmail(email: string) {
- let re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+ let re = /^(([^\s"(),.:;<>@[\\\]]+(\.[^\s"(),.:;<>@[\\\]]+)*)|(".+"))@((\[(?:\d{1,3}\.){3}\d{1,3}])|(([\dA-Za-z\-]+\.)+[A-Za-z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
};
}
-export const languages = [
- { code: 'ca', name: 'Català' },
- { code: 'en', name: 'English' },
- { code: 'eo', name: 'Esperanto' },
- { code: 'es', name: 'Español' },
- { code: 'de', name: 'Deutsch' },
- { code: 'fa', name: 'فارسی' },
- { code: 'ja', name: '日本語' },
- { code: 'pt_BR', name: 'Português Brasileiro' },
- { code: 'zh', name: '中文' },
- { code: 'fi', name: 'Suomi' },
- { code: 'fr', name: 'Français' },
- { code: 'sv', name: 'Svenska' },
- { code: 'ru', name: 'Русский' },
- { code: 'nl', name: 'Nederlands' },
- { code: 'it', name: 'Italiano' },
-];
-
export function getLanguage(): string {
let user = UserService.Instance.user;
let lang = user && user.lang ? user.lang : 'browser';
lang = 'pt-br';
} else if (lang.startsWith('ja')) {
lang = 'ja';
+ } else if (lang.startsWith('ka')) {
+ lang = 'ka';
} else {
lang = 'en';
}
return lang;
}
-export const themes = [
- 'litera',
- 'materia',
- 'minty',
- 'solar',
- 'united',
- 'cyborg',
- 'darkly',
- 'journal',
- 'sketchy',
- 'vaporwave',
- 'vaporwave-dark',
- 'i386',
-];
-
export function setTheme(theme: string = 'darkly') {
// unload all the other themes
for (var i = 0; i < themes.length; i++) {
}).showToast();
}
+export function messageToastify(
+ creator: string,
+ avatar: string,
+ body: string,
+ link: string,
+ router: any
+) {
+ let backgroundColor = `var(--light)`;
+
+ let toast = Toastify({
+ text: `${body}<br />${creator}`,
+ avatar: avatar,
+ backgroundColor: backgroundColor,
+ close: true,
+ gravity: 'top',
+ position: 'right',
+ duration: 0,
+ onClick: () => {
+ if (toast) {
+ toast.hideToast();
+ router.history.push(link);
+ }
+ },
+ }).showToast();
+}
+
export function setupTribute(): Tribute {
return new Tribute({
collection: [
function randomHsl() {
return `hsla(${Math.random() * 360}, 100%, 50%, 1)`;
}
+
+export function previewLines(text: string, lines: number = 3): string {
+ // Use lines * 2 because markdown requires 2 lines
+ return text
+ .split('\n')
+ .slice(0, lines * 2)
+ .join('\n');
+}