Merge branch 'master' into use-attohttpc

This commit is contained in:
Dessalines 2020-06-11 09:53:18 -04:00
commit 74c5380975
12 changed files with 99 additions and 42 deletions

2
ansible/VERSION vendored
View file

@ -1 +1 @@
v0.6.71 v0.6.73

View file

@ -12,7 +12,7 @@ services:
restart: always restart: always
lemmy: lemmy:
image: dessalines/lemmy:v0.6.71 image: dessalines/lemmy:v0.6.73
ports: ports:
- "127.0.0.1:8536:8536" - "127.0.0.1:8536:8536"
restart: always restart: always

View file

@ -1,31 +1,61 @@
#### Requirements ### Ubuntu
- [Rust](https://www.rust-lang.org/)
- [Yarn](https://yarnpkg.com/en/)
- [Postgres](https://www.postgresql.org/)
#### Set up Postgres DB #### Build requirements:
```
sudo apt install git cargo libssl-dev pkg-config libpq-dev yarn curl gnupg2 git
# install yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
```
```bash #### Get the source code
```
git clone https://github.com/LemmyNet/lemmy.git
# or alternatively from gitea
# git clone https://yerbamate.dev/LemmyNet/lemmy.git
```
All the following commands need to be run either in `lemmy/server` or `lemmy/ui`, as indicated
by the `cd` command.
#### Build the backend (Rust)
```
cd server cd server
./db-init.sh cargo build
# for development, use `cargo check` instead)
``` ```
Or run the commands manually: #### Build the frontend (Typescript)
```
cd ui
yarn
yarn build
```
```bash #### Setup postgresql
psql -c "create user lemmy with password 'password' superuser;" -U postgres ```
psql -c 'create database lemmy with owner lemmy;' -U postgres sudo apt install postgresql
sudo systemctl start postgresql
# initialize postgres database
sudo -u postgres psql -c "create user lemmy with password 'password' superuser;" -U postgres
sudo -u postgres psql -c 'create database lemmy with owner lemmy;' -U postgres
export LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy export LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy
# or execute server/db-init.sh
``` ```
#### Running #### Run a local development instance
```bash
git clone https://github.com/LemmyNet/lemmy
cd lemmy
./install.sh
# For live coding, where both the front and back end, automagically reload on any save, do:
# cd ui && yarn start
# cd server && cargo watch -x run
``` ```
# run each of these in a seperate terminal
cd server && cargo run
ui & yarn start
```
Then open [localhost:4444](http://localhost:4444) in your browser. It will auto-refresh if you edit
any frontend files. For backend coding, you will have to rerun `cargo run`. You can use
`cargo check` as a faster way to find compilation errors.
Note that this setup doesn't include image uploads or link previews (provided by pict-rs and
iframely respectively). If you want to test those, you should use the
[Docker development](contributing_docker_development.md).

View file

@ -1 +1 @@
pub const VERSION: &str = "v0.6.71"; pub const VERSION: &str = "v0.6.73";

View file

@ -111,6 +111,7 @@ export class Login extends Component<any, State> {
required required
/> />
<button <button
type="button"
disabled={!validEmail(this.state.loginForm.username_or_email)} disabled={!validEmail(this.state.loginForm.username_or_email)}
onClick={linkEvent(this, this.handlePasswordReset)} onClick={linkEvent(this, this.handlePasswordReset)}
className="btn p-0 btn-link d-inline-block float-right text-muted small font-weight-bold" className="btn p-0 btn-link d-inline-block float-right text-muted small font-weight-bold"

View file

@ -922,7 +922,7 @@ export class User extends Component<any, UserState> {
handleUserSettingsThemeChange(i: User, event: any) { handleUserSettingsThemeChange(i: User, event: any) {
i.state.userSettingsForm.theme = event.target.value; i.state.userSettingsForm.theme = event.target.value;
setTheme(event.target.value); setTheme(event.target.value, true);
i.setState(i.state); i.setState(i.state);
} }

3
ui/src/index.html vendored
View file

@ -15,7 +15,8 @@
<link rel="stylesheet" type="text/css" href="/static/assets/css/toastify.css" /> <link rel="stylesheet" type="text/css" href="/static/assets/css/toastify.css" />
<link rel="stylesheet" type="text/css" href="/static/assets/css/selectr.min.css" /> <link rel="stylesheet" type="text/css" href="/static/assets/css/selectr.min.css" />
<link rel="stylesheet" type="text/css" href="/static/assets/css/tippy.css" /> <link rel="stylesheet" type="text/css" href="/static/assets/css/tippy.css" />
<link rel="stylesheet" type="text/css" href="/static/assets/css/themes/darkly.min.css" id="darkly" /> <link rel="stylesheet" type="text/css" href="/static/assets/css/themes/united.min.css" id="default-light" media="(prefers-color-scheme: light)" />
<link rel="stylesheet" type="text/css" href="/static/assets/css/themes/darkly.min.css" id="default-dark" media="(prefers-color-scheme: no-preference), (prefers-color-scheme: dark)" />
<link rel="stylesheet" type="text/css" href="/static/assets/css/main.css" /> <link rel="stylesheet" type="text/css" href="/static/assets/css/main.css" />
<!-- Scripts --> <!-- Scripts -->

View file

@ -41,9 +41,7 @@ export class UserService {
private setUser(jwt: string) { private setUser(jwt: string) {
this.user = jwt_decode(jwt); this.user = jwt_decode(jwt);
if (this.user.theme != 'darkly') { setTheme(this.user.theme, true);
setTheme(this.user.theme);
}
this.sub.next({ user: this.user }); this.sub.next({ user: this.user });
console.log(this.user); console.log(this.user);
} }

22
ui/src/utils.ts vendored
View file

@ -404,7 +404,7 @@ export function getMomentLanguage(): string {
return lang; return lang;
} }
export function setTheme(theme: string = 'darkly') { export function setTheme(theme: string = 'darkly', loggedIn: boolean = false) {
// unload all the other themes // unload all the other themes
for (var i = 0; i < themes.length; i++) { for (var i = 0; i < themes.length; i++) {
let styleSheet = document.getElementById(themes[i]); let styleSheet = document.getElementById(themes[i]);
@ -413,10 +413,19 @@ export function setTheme(theme: string = 'darkly') {
} }
} }
// Load the theme dynamically // if the user is not logged in, we load the default themes and let the browser decide
let cssLoc = `/static/assets/css/themes/${theme}.min.css`; if(!loggedIn) {
loadCss(theme, cssLoc); document.getElementById("default-light").removeAttribute('disabled')
document.getElementById(theme).removeAttribute('disabled'); document.getElementById("default-dark").removeAttribute('disabled')
} else {
document.getElementById("default-light").setAttribute('disabled', 'disabled');
document.getElementById("default-dark").setAttribute('disabled', 'disabled');
// Load the theme dynamically
let cssLoc = `/static/assets/css/themes/${theme}.min.css`;
loadCss(theme, cssLoc);
document.getElementById(theme).removeAttribute('disabled');
}
} }
export function loadCss(id: string, loc: string) { export function loadCss(id: string, loc: string) {
@ -501,7 +510,7 @@ export function messageToastify(
text: `${body}<br />${creator}`, text: `${body}<br />${creator}`,
avatar: avatar, avatar: avatar,
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
className: 'text-body', className: 'text-dark',
close: true, close: true,
gravity: 'top', gravity: 'top',
position: 'right', position: 'right',
@ -887,7 +896,6 @@ function canUseWebP() {
return false; return false;
// var elem = document.createElement('canvas'); // var elem = document.createElement('canvas');
// if (!!(elem.getContext && elem.getContext('2d'))) { // if (!!(elem.getContext && elem.getContext('2d'))) {
// var testString = !(window.mozInnerScreenX == null) ? 'png' : 'webp'; // var testString = !(window.mozInnerScreenX == null) ? 'png' : 'webp';
// // was able or not to get WebP representation // // was able or not to get WebP representation

2
ui/src/version.ts vendored
View file

@ -1 +1 @@
export const version: string = 'v0.6.71'; export const version: string = 'v0.6.73';

View file

@ -28,7 +28,7 @@
"community_reqs": "en minuscule, sans espace et avec tiret du bas.", "community_reqs": "en minuscule, sans espace et avec tiret du bas.",
"create_private_message": "Créer un message privé", "create_private_message": "Créer un message privé",
"send_secure_message": "Envoyer le message sécurisé", "send_secure_message": "Envoyer le message sécurisé",
"send_message": "Enovyer le message", "send_message": "Envoyer le message",
"message": "Message", "message": "Message",
"edit": "éditer", "edit": "éditer",
"reply": "répondre", "reply": "répondre",
@ -58,14 +58,14 @@
"remove_as_admin": "Supprimer comme admin", "remove_as_admin": "Supprimer comme admin",
"appoint_as_admin": "Nommer comme admin", "appoint_as_admin": "Nommer comme admin",
"remove": "retirer", "remove": "retirer",
"removed": "retiré", "removed": "retiré par le modérateur",
"locked": "bloqué", "locked": "bloqué",
"stickied": "épinglé", "stickied": "épinglé",
"reason": "Raison", "reason": "Raison",
"mark_as_read": "marquer comme lu", "mark_as_read": "marquer comme lu",
"mark_as_unread": "marquer comme non-lu", "mark_as_unread": "marquer comme non-lu",
"delete": "supprimer", "delete": "supprimer",
"deleted": "supprimé", "deleted": "supprimé par le créateur",
"delete_account": "Supprimer le compte", "delete_account": "Supprimer le compte",
"delete_account_confirm": "Avertissement : cette action supprimera toutes vos données de façons permanente ! Saisissez votre mot de passe pour confirmer.", "delete_account_confirm": "Avertissement : cette action supprimera toutes vos données de façons permanente ! Saisissez votre mot de passe pour confirmer.",
"restore": "restaurer", "restore": "restaurer",
@ -171,7 +171,7 @@
"theme": "Thème", "theme": "Thème",
"sponsors": "Sponsors", "sponsors": "Sponsors",
"sponsors_of_lemmy": "Sponsors de Lemmy", "sponsors_of_lemmy": "Sponsors de Lemmy",
"sponsor_message": "Lemmy est un logiciel libre et <1>open-source</1>, cest à dire, il fonctionne sans publicité et sans monétisation aucune. Vos dons soutiennent directement le développement du projet à temps plein. Merci à toutes ces personnes :", "sponsor_message": "Lemmy est un logiciel libre et <1>open-source</1>, sans jamais aucune publicité, ni monétisation ou capital-risque. Vos dons soutiennent directement le développement du projet à temps plein. Merci à toutes ces personnes :",
"support_on_patreon": "Soutenir sur Patreon", "support_on_patreon": "Soutenir sur Patreon",
"support_on_liberapay": "Soutenir sur Liberapay", "support_on_liberapay": "Soutenir sur Liberapay",
"donate_to_lemmy": "Faire un don à Lemmy", "donate_to_lemmy": "Faire un don à Lemmy",
@ -251,5 +251,7 @@
"number_of_downvotes_plural": "{{count}} votes contre", "number_of_downvotes_plural": "{{count}} votes contre",
"downvote": "Voter contre", "downvote": "Voter contre",
"emoji_picker": "Sélecteur démojis", "emoji_picker": "Sélecteur démojis",
"silver_sponsors": "Les sponsors argent sont ceux et celles qui ont fait une donation de 40$ à Lemmy." "silver_sponsors": "Les sponsors argent sont ceux et celles qui ont fait une donation de 40$ à Lemmy.",
"select_a_community": "Sélectionner une communauté",
"invalid_username": "Nom d'utilisateur invalide."
} }

View file

@ -1 +1,18 @@
{} {
"post": "Elküld",
"remove_post": "Bejegyzés eltávolítása",
"no_posts": "Nincs bejegyzés.",
"create_post": "Új bejegyzés létrehozása",
"create_a_post": "Új bejegyzés létrehozása",
"number_of_posts": "{{count}} bejegyzés",
"number_of_posts_plural": "{{count}} bejegyzés",
"posts": "Bejegyzések",
"related_posts": "Ezek a bejegyzések kapcsolódhatnak",
"cross_posts": "Ez a hivatkozás itt is be lett küldve:",
"cross_post": "keresztbejegyzés",
"comments": "Hozzászólások",
"remove_comment": "Hozzászólások eltávolítása",
"cross_posted_to": "beküldve ide is: ",
"number_of_comments": "{{count}} hozzászólás",
"number_of_comments_plural": "{{count}} hozzászólás"
}