Compare commits
60 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9ddba17d46 | |||
| b04426a330 | |||
| 925254983e | |||
| 4c6fb83793 | |||
| 7c456009be | |||
| db916039db | |||
| 06c625c686 | |||
| f2203710cb | |||
| 3c1617c4f9 | |||
| 2388a5846d | |||
| b102534136 | |||
| 072e32da30 | |||
| 5ea3e73727 | |||
| f340bd50c7 | |||
| 3de6b46465 | |||
| 3c6d5de314 | |||
| 2a4b98dce4 | |||
| d253fee523 | |||
| 07731d0b73 | |||
| 15cbd17003 | |||
| 5d3b3485fa | |||
| 8a2788bf6a | |||
| ecbd64efb1 | |||
| 9245320712 | |||
| 7cf3a4b37c | |||
| 3ddd6d0254 | |||
| 7edd0220b6 | |||
| b26e785277 | |||
| b2829908f1 | |||
| 60bb5b72f6 | |||
| 9e0bbf81ed | |||
| 28576c1fa3 | |||
| d99b42582d | |||
| 92a386277b | |||
| 297d9fcf40 | |||
| ef70cb93e6 | |||
| efb76a3c17 | |||
| 197f0d7ecd | |||
| 3be842c653 | |||
| dabe904642 | |||
| 180e34b07c | |||
| 847d6f7fac | |||
| 6a3f210dfc | |||
| 73aa301d4a | |||
| b3d367b174 | |||
| edaccd1a31 | |||
| e1bd2eab75 | |||
| ac7a05b09a | |||
| 71e0a35e06 | |||
| c217e5e9b3 | |||
| 8ba0c17db5 | |||
| 4e43c676b4 | |||
| b834d1c282 | |||
| 506fe9955d | |||
| 02c528cae4 | |||
| 2a58835f92 | |||
| 5f8d6b8e0e | |||
| 3663bffe5c | |||
| 72464fb428 | |||
| 23049b638c |
@@ -10,7 +10,7 @@ executors:
|
||||
type: boolean
|
||||
default: false
|
||||
docker:
|
||||
- image: plumeorg/plume-buildenv:v0.0.8
|
||||
- image: plumeorg/plume-buildenv:v0.0.9
|
||||
- image: <<#parameters.postgres>>circleci/postgres:9.6-alpine<</parameters.postgres>><<^parameters.postgres>>alpine:latest<</parameters.postgres>>
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
@@ -226,6 +226,7 @@ jobs:
|
||||
steps:
|
||||
- restore_env:
|
||||
cache: none
|
||||
- run: cargo build
|
||||
- run: crowdin upload -b master
|
||||
|
||||
workflows:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
localhost:443 {
|
||||
proxy / localhost:7878 {
|
||||
proxy / integration:7878 {
|
||||
transparent
|
||||
}
|
||||
tls self_signed
|
||||
|
||||
@@ -8,7 +8,7 @@ RUN apt update &&\
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
#install and configure rust
|
||||
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2019-03-23 -y &&\
|
||||
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2020-01-15 -y &&\
|
||||
rustup component add rustfmt clippy &&\
|
||||
rustup component add rust-std --target wasm32-unknown-unknown
|
||||
|
||||
|
||||
+233
@@ -0,0 +1,233 @@
|
||||
// This is the CI config for Plume.
|
||||
// It uses a Drone CI instance, on https://ci.joinplu.me
|
||||
|
||||
// First of all, we define a few useful constants
|
||||
|
||||
// This Docker image contains everything we need to build Plume.
|
||||
// Its Dockerfile can be found at https://git.joinplu.me/plume/buildenv
|
||||
local plumeEnv = "plumeorg/plume-buildenv:v0.2.0";
|
||||
|
||||
// Common cache config
|
||||
local cacheConfig(name, extra) = {
|
||||
name: name,
|
||||
image: "meltwater/drone-cache:dev",
|
||||
pull: true,
|
||||
environment: {
|
||||
AWS_ACCESS_KEY_ID: { from_secret: 'minio_key' },
|
||||
AWS_SECRET_ACCESS_KEY: { from_secret: 'minio_secret' },
|
||||
},
|
||||
settings: extra + {
|
||||
cache_key: 'v0-{{ checksum "Cargo.lock" }}-{{ .Commit.Branch }}',
|
||||
archive_format: "gzip",
|
||||
mount: [ "~/.cargo/", "./target" ],
|
||||
bucket: 'cache',
|
||||
path_style: true,
|
||||
endpoints: "127.0.0.1:9000",
|
||||
region: 'us-east-1',
|
||||
debug: true,
|
||||
},
|
||||
volumes: [ { name: "cache", path: "/tmp/cache" } ]
|
||||
};
|
||||
|
||||
|
||||
// A pipeline step that restores the cache.
|
||||
// The cache contains all the cargo build files.
|
||||
// Thus, we don't have to download and compile all of our dependencies for each
|
||||
// commit.
|
||||
// This cache is only "deleted" when the contents of Cargo.lock changes.
|
||||
//
|
||||
// We use this plugin for caching: https://github.com/meltwater/drone-cache/
|
||||
//
|
||||
// Potential TODO: use one cache per pipeline, as we used to do when we were
|
||||
// using CircleCI.
|
||||
local restoreCache = cacheConfig("restore-cache", { restore: true });
|
||||
// And a step that saves the cache.
|
||||
local saveCache = cacheConfig("save-cache", { rebuild: true });
|
||||
|
||||
// This step starts a PostgreSQL database if the db parameter is "postgres",
|
||||
// otherwise it does nothing.
|
||||
local startDb(db) = if db == "postgres" then {
|
||||
name: "start-db",
|
||||
image: "postgres:12.3-alpine",
|
||||
detach: true,
|
||||
environment: {
|
||||
POSTGRES_USER: "plume",
|
||||
POSTGRES_DB: "plume",
|
||||
POSTGRES_PASSWORD: "password",
|
||||
}
|
||||
} else {};
|
||||
|
||||
// A utility function to generate a new pipeline
|
||||
local basePipeline(name, steps) = {
|
||||
kind: "pipeline",
|
||||
name: name,
|
||||
type: "docker",
|
||||
environment: {
|
||||
RUST_TEST_THREADS: '1',
|
||||
},
|
||||
steps: steps
|
||||
};
|
||||
|
||||
// And this function creates a pipeline with caching
|
||||
local cachedPipeline(name, commands) = basePipeline(
|
||||
name,
|
||||
[
|
||||
restoreCache,
|
||||
{
|
||||
name: name,
|
||||
image: plumeEnv,
|
||||
commands: commands,
|
||||
},
|
||||
saveCache
|
||||
]
|
||||
);
|
||||
|
||||
// This function creates a step to upload artifacts to Minio
|
||||
local upload(name, source) = {
|
||||
name: name,
|
||||
image: 'plugins/s3',
|
||||
settings: {
|
||||
bucket: 'artifacts',
|
||||
source: source,
|
||||
target: '/${DRONE_BUILD_NUMBER}',
|
||||
path_style: true,
|
||||
endpoint: 'http://127.0.0.1:9000',
|
||||
access_key: { from_secret: 'minio_key' },
|
||||
secret_key: { from_secret: 'minio_secret' },
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
// Here starts the actual list of pipelines!
|
||||
|
||||
// PIPELINE 1: a pipeline that runs cargo fmt, and that fails if the style of
|
||||
// the code is not standard.
|
||||
local CargoFmt() = cachedPipeline(
|
||||
"cargo-fmt",
|
||||
[ "cargo fmt --all -- --check" ]
|
||||
);
|
||||
|
||||
// PIPELINE 2: runs clippy, a tool that helps
|
||||
// you writing idiomatic Rust.
|
||||
|
||||
// Helper function:
|
||||
local cmd(db, pkg, features=true) = if features then
|
||||
"cargo clippy --no-default-features --features " + db + " --release -p "
|
||||
+ pkg + " -- -D warnings"
|
||||
else
|
||||
"cargo clippy --no-default-features --release -p "
|
||||
+ pkg + " -- -D warnings";
|
||||
|
||||
// The actual pipeline:
|
||||
local Clippy(db) = cachedPipeline(
|
||||
"clippy-" + db,
|
||||
[
|
||||
cmd(db, "plume"),
|
||||
cmd(db, "plume-cli"),
|
||||
cmd(db, "plume-front", false)
|
||||
]
|
||||
);
|
||||
|
||||
// PIPELINE 3: runs unit tests
|
||||
local Unit(db) = cachedPipeline(
|
||||
"unit-" + db,
|
||||
[
|
||||
"cargo test --all --exclude plume-front --exclude plume-macro"
|
||||
+ " --no-run --no-default-features --features=" + db
|
||||
]
|
||||
);
|
||||
|
||||
// PIPELINE 4: runs integration tests
|
||||
// It installs a local instance an run integration test with Python scripts
|
||||
// that use Selenium (located in scripts/browser_test).
|
||||
local Integration(db) = basePipeline(
|
||||
"integration-" + db,
|
||||
[
|
||||
restoreCache,
|
||||
startDb(db),
|
||||
{
|
||||
name: 'selenium',
|
||||
image: 'elgalu/selenium:latest',
|
||||
detach: true,
|
||||
},
|
||||
{
|
||||
name: "integration",
|
||||
image: plumeEnv,
|
||||
environment: {
|
||||
BROWSER: "firefox",
|
||||
DATABASE_URL: if db == "postgres" then "postgres://plume:password@start-db/plume" else "plume.db",
|
||||
},
|
||||
commands: [
|
||||
// Install the front-end
|
||||
"cargo web deploy -p plume-front",
|
||||
// Install the server
|
||||
'cargo install --debug --no-default-features --features="'
|
||||
+ db + '",test --force --path .',
|
||||
// Install plm
|
||||
'cargo install --debug --no-default-features --features="'
|
||||
+ db + '" --force --path plume-cli',
|
||||
// Run the tests
|
||||
"./script/run_browser_test.sh"
|
||||
],
|
||||
},
|
||||
saveCache,
|
||||
]
|
||||
);
|
||||
|
||||
// PIPELINE 5: make a release build and save artifacts
|
||||
//
|
||||
// It should also deploy the SQlite build to a test instance
|
||||
// located at https://pr-XXX.joinplu.me (but this system is not very
|
||||
// stable, and often breaks).
|
||||
local Release(db) = basePipeline(
|
||||
"release-" + db,
|
||||
[
|
||||
restoreCache,
|
||||
{
|
||||
name: 'release-' + db,
|
||||
image: plumeEnv,
|
||||
commands: [
|
||||
"cargo web deploy -p plume-front --release",
|
||||
"cargo build --release --no-default-features --features=" + db + " -p plume",
|
||||
"cargo build --release --no-default-features --features=" + db + " -p plume-cli",
|
||||
"./script/generate_artifact.sh",
|
||||
] + if db == "sqlite" then
|
||||
[ "./script/upload_test_environment.sh" ] else
|
||||
[]
|
||||
},
|
||||
upload('artifacts-' + db, '*.tar.gz'),
|
||||
saveCache,
|
||||
]
|
||||
|
||||
);
|
||||
|
||||
// PIPELINE 6: upload the new PO templates (.pot) to Crowdin
|
||||
//
|
||||
// TODO: run only on master
|
||||
local PushTranslations() = basePipeline(
|
||||
"push-translations",
|
||||
[
|
||||
{
|
||||
name: "push-translations",
|
||||
image: plumeEnv,
|
||||
commands: [
|
||||
"cargo build",
|
||||
"crowdin upload -b master"
|
||||
]
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
// And finally, the list of all our pipelines:
|
||||
[
|
||||
CargoFmt(),
|
||||
Clippy("postgres"),
|
||||
Clippy("sqlite"),
|
||||
Unit("postgres"),
|
||||
Unit("sqlite"),
|
||||
Integration("postgres"),
|
||||
Integration("sqlite"),
|
||||
Release("postgres"),
|
||||
Release("sqlite"),
|
||||
PushTranslations()
|
||||
]
|
||||
Generated
+1827
-1406
File diff suppressed because it is too large
Load Diff
+6
-5
@@ -3,6 +3,7 @@ authors = ["Plume contributors"]
|
||||
name = "plume"
|
||||
version = "0.4.0"
|
||||
repository = "https://github.com/Plume-org/Plume"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
activitypub = "0.1.3"
|
||||
@@ -19,11 +20,10 @@ heck = "0.3.0"
|
||||
lettre = "0.9.2"
|
||||
lettre_email = "0.9.2"
|
||||
num_cpus = "1.10"
|
||||
rocket = "0.4.0"
|
||||
rocket_contrib = { version = "0.4.0", features = ["json"] }
|
||||
rocket = "0.4.2"
|
||||
rocket_contrib = { version = "0.4.2", features = ["json"] }
|
||||
rocket_i18n = { git = "https://github.com/Plume-org/rocket_i18n", rev = "e922afa7c366038b3433278c03b1456b346074f2" }
|
||||
rpassword = "4.0"
|
||||
runtime-fmt = "0.3.0"
|
||||
scheduled-thread-pool = "0.2.2"
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
@@ -66,10 +66,10 @@ path = "plume-models"
|
||||
|
||||
[dependencies.rocket_csrf]
|
||||
git = "https://github.com/fdb-hiroshima/rocket_csrf"
|
||||
rev = "4a72ea2ec716cb0b26188fb00bccf2ef7d1e031c"
|
||||
rev = "29910f2829e7e590a540da3804336577b48c7b31"
|
||||
|
||||
[build-dependencies]
|
||||
ructe = "0.6.2"
|
||||
ructe = "0.9.0"
|
||||
rsass = "0.9"
|
||||
|
||||
[features]
|
||||
@@ -78,6 +78,7 @@ postgres = ["plume-models/postgres", "diesel/postgres"]
|
||||
sqlite = ["plume-models/sqlite", "diesel/sqlite"]
|
||||
debug-mailer = []
|
||||
test = []
|
||||
search-lindera = ["plume-models/search-lindera"]
|
||||
|
||||
[workspace]
|
||||
members = ["plume-api", "plume-cli", "plume-models", "plume-common", "plume-front", "plume-macro"]
|
||||
|
||||
+2
-1
@@ -10,7 +10,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gcc \
|
||||
make \
|
||||
openssl \
|
||||
libssl-dev
|
||||
libssl-dev \
|
||||
clang
|
||||
|
||||
WORKDIR /scratch
|
||||
COPY script/wasm-deps.sh .
|
||||
|
||||
@@ -190,7 +190,28 @@ p.error {
|
||||
|
||||
background: $gray;
|
||||
|
||||
text-overflow: ellipsis;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
footer.authors {
|
||||
div {
|
||||
float: left;
|
||||
margin-right: 0.25em;
|
||||
}
|
||||
|
||||
.likes { color: $red; }
|
||||
.reshares { color: $primary; }
|
||||
|
||||
span.likes, span.resahres {
|
||||
font-family: "Route159",serif;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
svg.feather {
|
||||
width: 0.85em;
|
||||
height: 0.85em;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
> * {
|
||||
margin: 20px;
|
||||
@@ -469,93 +490,6 @@ figure {
|
||||
|
||||
/// Small screens
|
||||
@media screen and (max-width: 600px) {
|
||||
@keyframes menuOpening {
|
||||
from {
|
||||
transform: scaleX(0);
|
||||
transform-origin: left;
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: scaleX(1);
|
||||
transform-origin: left;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
body > header {
|
||||
flex-direction: column;
|
||||
|
||||
nav#menu {
|
||||
display: inline-flex;
|
||||
z-index: 21;
|
||||
}
|
||||
|
||||
#content {
|
||||
display: none;
|
||||
appearance: none;
|
||||
text-align: center;
|
||||
z-index: 20;
|
||||
}
|
||||
}
|
||||
|
||||
body > header:focus-within #content, #content.show {
|
||||
position: fixed;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
animation: 0.2s menuOpening;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
transform: skewX(-10deg);
|
||||
top: 0;
|
||||
left: -20%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
z-index: -10;
|
||||
|
||||
background: $primary;
|
||||
}
|
||||
|
||||
> nav {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
|
||||
a {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin: 0;
|
||||
padding: 1rem 1.5rem;
|
||||
color: $background;
|
||||
font-size: 1.4em;
|
||||
font-weight: 300;
|
||||
|
||||
&.title { font-size: 1.8em; }
|
||||
|
||||
> *:first-child { width: 3rem; }
|
||||
> img:first-child { height: 3rem; }
|
||||
> *:last-child { margin-left: 1rem; }
|
||||
> nav hr {
|
||||
display: block;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
border: solid $background 0.1rem;
|
||||
}
|
||||
.mobile-label { display: initial; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
main .article-meta {
|
||||
> *, .comments {
|
||||
margin: 0 5%;
|
||||
|
||||
@@ -101,6 +101,96 @@ body > header {
|
||||
}
|
||||
}
|
||||
|
||||
/// Small screens
|
||||
@media screen and (max-width: 600px) {
|
||||
@keyframes menuOpening {
|
||||
from {
|
||||
transform: scaleX(0);
|
||||
transform-origin: left;
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: scaleX(1);
|
||||
transform-origin: left;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
body > header {
|
||||
flex-direction: column;
|
||||
|
||||
nav#menu {
|
||||
display: inline-flex;
|
||||
z-index: 21;
|
||||
}
|
||||
|
||||
#content {
|
||||
display: none;
|
||||
appearance: none;
|
||||
text-align: center;
|
||||
z-index: 20;
|
||||
}
|
||||
}
|
||||
|
||||
body > header:focus-within #content, #content.show {
|
||||
position: fixed;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
animation: 0.2s menuOpening;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
transform: skewX(-10deg);
|
||||
top: 0;
|
||||
left: -20%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
z-index: -10;
|
||||
|
||||
background: $primary;
|
||||
}
|
||||
|
||||
> nav {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
|
||||
a {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin: 0;
|
||||
padding: 1rem 1.5rem;
|
||||
color: $background;
|
||||
font-size: 1.4em;
|
||||
font-weight: 300;
|
||||
|
||||
&.title { font-size: 1.8em; }
|
||||
|
||||
> *:first-child { width: 3rem; }
|
||||
> img:first-child { height: 3rem; }
|
||||
> *:last-child { margin-left: 1rem; }
|
||||
> nav hr {
|
||||
display: block;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
border: solid $background 0.1rem;
|
||||
}
|
||||
.mobile-label { display: initial; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Only enable label animations on large screens */
|
||||
@media screen and (min-width: 600px) {
|
||||
header nav a {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/* Color Scheme */
|
||||
$gray: #F3F3F3;
|
||||
$gray: #f3f3f3;
|
||||
$black: #242424;
|
||||
$white: #F8F8F8;
|
||||
$purple: #7765E3;
|
||||
$white: #f8f8f8;
|
||||
$purple: #7765e3;
|
||||
$lightpurple: #c2bbee;
|
||||
$red: #E92F2F;
|
||||
$red: #e92f2f;
|
||||
$yellow: #ffe347;
|
||||
$green: #23f0c7;
|
||||
|
||||
@@ -24,14 +24,14 @@ $margin: 0 $horizontal-margin;
|
||||
|
||||
/* Fonts */
|
||||
|
||||
$route159: "Route159", serif;
|
||||
$playfair: "Playfair Display", serif;
|
||||
$lora: "Lora", serif;
|
||||
$route159: "Shabnam", "Route159", serif;
|
||||
$playfair: "Vazir", "Playfair Display", serif;
|
||||
$lora: "Vazir", "Lora", serif;
|
||||
|
||||
//Code Highlighting
|
||||
$code-keyword-color: #45244a;
|
||||
$code-source-color: #4c588c;
|
||||
$code-constant-color: scale-color(magenta,$lightness:-5%);
|
||||
$code-operator-color: scale-color($code-source-color,$lightness:-5%);
|
||||
$code-constant-color: scale-color(magenta, $lightness: -5%);
|
||||
$code-operator-color: scale-color($code-source-color, $lightness: -5%);
|
||||
$code-string-color: #8a571c;
|
||||
$code-comment-color: #1c4c8a;
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
/* color palette: https://coolors.co/23f0c7-ef767a-7765e3-6457a6-ffe347 */
|
||||
|
||||
@import url('./feather.css');
|
||||
@import url('./fonts/Route159/Route159.css');
|
||||
@import url('./fonts/Lora/Lora.css');
|
||||
@import url('./fonts/Playfair_Display/PlayfairDisplay.css');
|
||||
@import url("./feather.css");
|
||||
@import url("./fonts/Route159/Route159.css");
|
||||
@import url("./fonts/Lora/Lora.css");
|
||||
@import url("./fonts/Playfair_Display/PlayfairDisplay.css");
|
||||
@import url("./fonts/Vazir_WOL/Vazir_WOL.css");
|
||||
@import url("./fonts/Shabnam_WOL/Shabnam_WOL.css");
|
||||
|
||||
@import 'dark_variables';
|
||||
@import 'global';
|
||||
@import 'header';
|
||||
@import 'article';
|
||||
@import 'forms';
|
||||
@import "dark_variables";
|
||||
@import "global";
|
||||
@import "header";
|
||||
@import "article";
|
||||
@import "forms";
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
Copyright (c) 2015, Saber Rastikerdar (saber.rastikerdar@gmail.com),
|
||||
Glyphs and data from Roboto font are licensed under the Apache License, Version 2.0.
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,49 @@
|
||||
@font-face {
|
||||
font-family: Shabnam;
|
||||
src: url("Shabnam-WOL.eot");
|
||||
src: url("Shabnam-WOL.eot?#iefix") format("embedded-opentype"),
|
||||
url("Shabnam-WOL.woff2") format("woff2"),
|
||||
url("Shabnam-WOL.woff") format("woff"),
|
||||
url("Shabnam-WOL.ttf") format("truetype");
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Shabnam;
|
||||
src: url("Shabnam-Bold-WOL.eot");
|
||||
src: url("Shabnam-Bold-WOL.eot?#iefix") format("embedded-opentype"),
|
||||
url("Shabnam-Bold-WOL.woff2") format("woff2"),
|
||||
url("Shabnam-Bold-WOL.woff") format("woff"),
|
||||
url("Shabnam-Bold-WOL.ttf") format("truetype");
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Shabnam;
|
||||
src: url("Shabnam-Thin-WOL.eot");
|
||||
src: url("Shabnam-Thin-WOL.eot?#iefix") format("embedded-opentype"),
|
||||
url("Shabnam-Thin-WOL.woff2") format("woff2"),
|
||||
url("Shabnam-Thin-WOL.woff") format("woff"),
|
||||
url("Shabnam-Thin-WOL.ttf") format("truetype");
|
||||
font-weight: 100;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Shabnam;
|
||||
src: url("Shabnam-Light-WOL.eot");
|
||||
src: url("Shabnam-Light-WOL.eot?#iefix") format("embedded-opentype"),
|
||||
url("Shabnam-Light-WOL.woff2") format("woff2"),
|
||||
url("Shabnam-Light-WOL.woff") format("woff"),
|
||||
url("Shabnam-Light-WOL.ttf") format("truetype");
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Shabnam;
|
||||
src: url("Shabnam-Medium-WOL.eot");
|
||||
src: url("Shabnam-Medium-WOL.eot?#iefix") format("embedded-opentype"),
|
||||
url("Shabnam-Medium-WOL.woff2") format("woff2"),
|
||||
url("Shabnam-Medium-WOL.woff") format("woff"),
|
||||
url("Shabnam-Medium-WOL.ttf") format("truetype");
|
||||
font-weight: 500;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
Changes by Saber Rastikerdar (saber.rastikerdar@gmail.com) are in public domain.
|
||||
Glyphs and data from Roboto font are licensed under the Apache License, Version 2.0.
|
||||
|
||||
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
|
||||
|
||||
Bitstream Vera Fonts Copyright
|
||||
------------------------------
|
||||
|
||||
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
|
||||
a trademark of Bitstream, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of the fonts accompanying this license ("Fonts") and associated
|
||||
documentation files (the "Font Software"), to reproduce and distribute the
|
||||
Font Software, including without limitation the rights to use, copy, merge,
|
||||
publish, distribute, and/or sell copies of the Font Software, and to permit
|
||||
persons to whom the Font Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright and trademark notices and this permission notice shall
|
||||
be included in all copies of one or more of the Font Software typefaces.
|
||||
|
||||
The Font Software may be modified, altered, or added to, and in particular
|
||||
the designs of glyphs or characters in the Fonts may be modified and
|
||||
additional glyphs or characters may be added to the Fonts, only if the fonts
|
||||
are renamed to names not containing either the words "Bitstream" or the word
|
||||
"Vera".
|
||||
|
||||
This License becomes null and void to the extent applicable to Fonts or Font
|
||||
Software that has been modified and is distributed under the "Bitstream
|
||||
Vera" names.
|
||||
|
||||
The Font Software may be sold as part of a larger software package but no
|
||||
copy of one or more of the Font Software typefaces may be sold by itself.
|
||||
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
|
||||
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
|
||||
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
|
||||
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
|
||||
FONT SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the names of Gnome, the Gnome
|
||||
Foundation, and Bitstream Inc., shall not be used in advertising or
|
||||
otherwise to promote the sale, use or other dealings in this Font Software
|
||||
without prior written authorization from the Gnome Foundation or Bitstream
|
||||
Inc., respectively. For further information, contact: fonts at gnome dot
|
||||
org.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,65 @@
|
||||
@font-face {
|
||||
font-family: Vazir;
|
||||
src: url('Vazir-WOL.eot');
|
||||
src: url('Vazir-WOL.eot?#iefix') format('embedded-opentype'),
|
||||
url('Vazir-WOL.woff2') format('woff2'),
|
||||
url('Vazir-WOL.woff') format('woff'),
|
||||
url('Vazir-WOL.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Vazir;
|
||||
src: url('Vazir-Bold-WOL.eot');
|
||||
src: url('Vazir-Bold-WOL.eot?#iefix') format('embedded-opentype'),
|
||||
url('Vazir-Bold-WOL.woff2') format('woff2'),
|
||||
url('Vazir-Bold-WOL.woff') format('woff'),
|
||||
url('Vazir-Bold-WOL.ttf') format('truetype');
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Vazir;
|
||||
src: url('Vazir-Black-WOL.eot');
|
||||
src: url('Vazir-Black-WOL.eot?#iefix') format('embedded-opentype'),
|
||||
url('Vazir-Black-WOL.woff2') format('woff2'),
|
||||
url('Vazir-Black-WOL.woff') format('woff'),
|
||||
url('Vazir-Black-WOL.ttf') format('truetype');
|
||||
font-weight: 900;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Vazir;
|
||||
src: url('Vazir-Medium-WOL.eot');
|
||||
src: url('Vazir-Medium-WOL.eot?#iefix') format('embedded-opentype'),
|
||||
url('Vazir-Medium-WOL.woff2') format('woff2'),
|
||||
url('Vazir-Medium-WOL.woff') format('woff'),
|
||||
url('Vazir-Medium-WOL.ttf') format('truetype');
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Vazir;
|
||||
src: url('Vazir-Light-WOL.eot');
|
||||
src: url('Vazir-Light-WOL.eot?#iefix') format('embedded-opentype'),
|
||||
url('Vazir-Light-WOL.woff2') format('woff2'),
|
||||
url('Vazir-Light-WOL.woff') format('woff'),
|
||||
url('Vazir-Light-WOL.ttf') format('truetype');
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Vazir;
|
||||
src: url('Vazir-Thin-WOL.eot');
|
||||
src: url('Vazir-Thin-WOL.eot?#iefix') format('embedded-opentype'),
|
||||
url('Vazir-Thin-WOL.woff2') format('woff2'),
|
||||
url('Vazir-Thin-WOL.woff') format('woff'),
|
||||
url('Vazir-Thin-WOL.ttf') format('truetype');
|
||||
font-weight: 100;
|
||||
font-style: normal;
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
/* color palette: https://coolors.co/23f0c7-ef767a-7765e3-6457a6-ffe347 */
|
||||
|
||||
@import url('./feather.css');
|
||||
@import url('./fonts/Route159/Route159.css');
|
||||
@import url('./fonts/Lora/Lora.css');
|
||||
@import url('./fonts/Playfair_Display/PlayfairDisplay.css');
|
||||
@import url("./feather.css");
|
||||
@import url("./fonts/Route159/Route159.css");
|
||||
@import url("./fonts/Lora/Lora.css");
|
||||
@import url("./fonts/Playfair_Display/PlayfairDisplay.css");
|
||||
@import url("./fonts/Vazir_WOL/Vazir_WOL.css");
|
||||
@import url("./fonts/Shabnam_WOL/Shabnam_WOL.css");
|
||||
|
||||
@import 'variables';
|
||||
@import 'global';
|
||||
@import 'header';
|
||||
@import 'article';
|
||||
@import 'forms';
|
||||
@import "variables";
|
||||
@import "global";
|
||||
@import "header";
|
||||
@import "article";
|
||||
@import "forms";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
extern crate rsass;
|
||||
extern crate ructe;
|
||||
use rsass;
|
||||
|
||||
use ructe::Ructe;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::{env, ffi::OsStr, fs::*, io::Write, path::*};
|
||||
use std::{ffi::OsStr, fs::*, io::Write, path::*};
|
||||
|
||||
fn compute_static_hash() -> String {
|
||||
//"find static/ -type f ! -path 'static/media/*' | sort | xargs stat -c'%n %Y' | openssl dgst -r"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
name = "plume-api"
|
||||
version = "0.4.0"
|
||||
authors = ["Plume contributors"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = "1.0"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
extern crate serde;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
name = "plume-cli"
|
||||
version = "0.4.0"
|
||||
authors = ["Plume contributors"]
|
||||
edition = "2018"
|
||||
|
||||
[[bin]]
|
||||
name = "plm"
|
||||
@@ -22,3 +23,4 @@ path = "../plume-models"
|
||||
[features]
|
||||
postgres = ["plume-models/postgres", "diesel/postgres"]
|
||||
sqlite = ["plume-models/sqlite", "diesel/sqlite"]
|
||||
search-lindera = ["plume-models/search-lindera"]
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
extern crate clap;
|
||||
extern crate diesel;
|
||||
extern crate dotenv;
|
||||
extern crate plume_models;
|
||||
extern crate rpassword;
|
||||
use dotenv;
|
||||
|
||||
use clap::App;
|
||||
use diesel::Connection;
|
||||
|
||||
@@ -82,7 +82,7 @@ fn init<'a>(args: &ArgMatches<'a>, conn: &Connection) {
|
||||
}
|
||||
};
|
||||
if can_do || force {
|
||||
let searcher = Searcher::create(&path).unwrap();
|
||||
let searcher = Searcher::create(&path, &CONFIG.search_tokenizers).unwrap();
|
||||
refill(args, conn, Some(searcher));
|
||||
} else {
|
||||
eprintln!(
|
||||
@@ -98,7 +98,8 @@ fn refill<'a>(args: &ArgMatches<'a>, conn: &Connection, searcher: Option<Searche
|
||||
Some(path) => Path::new(path).join("search_index"),
|
||||
None => Path::new(&CONFIG.search_index).to_path_buf(),
|
||||
};
|
||||
let searcher = searcher.unwrap_or_else(|| Searcher::open(&path).unwrap());
|
||||
let searcher =
|
||||
searcher.unwrap_or_else(|| Searcher::open(&path, &CONFIG.search_tokenizers).unwrap());
|
||||
|
||||
searcher.fill(conn).expect("Couldn't import post");
|
||||
println!("Commiting result");
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
name = "plume-common"
|
||||
version = "0.4.0"
|
||||
authors = ["Plume contributors"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
activitypub = "0.1.1"
|
||||
@@ -21,6 +22,7 @@ serde_json = "1.0"
|
||||
shrinkwraprs = "0.2.1"
|
||||
syntect = "3.3"
|
||||
tokio = "0.1.22"
|
||||
regex-syntax = { version = "0.6.17", default-features = false, features = ["unicode-perl"] }
|
||||
|
||||
[dependencies.chrono]
|
||||
features = ["serde"]
|
||||
|
||||
@@ -64,7 +64,7 @@ impl<T> ActivityStream<T> {
|
||||
}
|
||||
|
||||
impl<'r, O: Object> Responder<'r> for ActivityStream<O> {
|
||||
fn respond_to(self, request: &Request) -> Result<Response<'r>, Status> {
|
||||
fn respond_to(self, request: &Request<'_>) -> Result<Response<'r>, Status> {
|
||||
let mut json = serde_json::to_value(&self.0).map_err(|_| Status::InternalServerError)?;
|
||||
json["@context"] = context();
|
||||
serde_json::to_string(&json).respond_to(request).map(|r| {
|
||||
|
||||
@@ -5,8 +5,8 @@ use reqwest::header::{HeaderMap, HeaderValue, ACCEPT, CONTENT_TYPE, DATE, USER_A
|
||||
use std::ops::Deref;
|
||||
use std::time::SystemTime;
|
||||
|
||||
use activity_pub::sign::Signer;
|
||||
use activity_pub::{ap_accept_header, AP_CONTENT_TYPE};
|
||||
use crate::activity_pub::sign::Signer;
|
||||
use crate::activity_pub::{ap_accept_header, AP_CONTENT_TYPE};
|
||||
|
||||
const PLUME_USER_AGENT: &str = concat!("Plume/", env!("CARGO_PKG_VERSION"));
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ impl SignatureValidity {
|
||||
|
||||
pub fn verify_http_headers<S: Signer + ::std::fmt::Debug>(
|
||||
sender: &S,
|
||||
all_headers: &HeaderMap,
|
||||
all_headers: &HeaderMap<'_>,
|
||||
data: &request::Digest,
|
||||
) -> SignatureValidity {
|
||||
let sig_header = all_headers.get_one("Signature");
|
||||
|
||||
+4
-15
@@ -1,27 +1,16 @@
|
||||
#![feature(custom_attribute, associated_type_defaults)]
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
extern crate activitypub;
|
||||
#[macro_use]
|
||||
extern crate activitystreams_derive;
|
||||
extern crate activitystreams_traits;
|
||||
extern crate array_tool;
|
||||
extern crate base64;
|
||||
extern crate chrono;
|
||||
extern crate heck;
|
||||
extern crate hex;
|
||||
extern crate openssl;
|
||||
extern crate pulldown_cmark;
|
||||
extern crate reqwest;
|
||||
extern crate rocket;
|
||||
extern crate serde;
|
||||
use activitystreams_traits;
|
||||
|
||||
use serde;
|
||||
#[macro_use]
|
||||
extern crate shrinkwraprs;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
#[macro_use]
|
||||
extern crate serde_json;
|
||||
extern crate syntect;
|
||||
extern crate tokio;
|
||||
|
||||
pub mod activity_pub;
|
||||
pub mod utils;
|
||||
|
||||
+33
-14
@@ -1,6 +1,7 @@
|
||||
use heck::CamelCase;
|
||||
use openssl::rand::rand_bytes;
|
||||
use pulldown_cmark::{html, Event, Options, Parser, Tag};
|
||||
use regex_syntax::is_word_character;
|
||||
use rocket::{
|
||||
http::uri::Uri,
|
||||
response::{Flash, Redirect},
|
||||
@@ -48,7 +49,7 @@ enum State {
|
||||
Ready,
|
||||
}
|
||||
|
||||
fn to_inline(tag: Tag) -> Tag {
|
||||
fn to_inline(tag: Tag<'_>) -> Tag<'_> {
|
||||
match tag {
|
||||
Tag::Header(_) | Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell => {
|
||||
Tag::Paragraph
|
||||
@@ -146,7 +147,7 @@ fn inline_tags<'a>(
|
||||
}
|
||||
}
|
||||
|
||||
pub type MediaProcessor<'a> = Box<'a + Fn(i32) -> Option<(String, Option<String>)>>;
|
||||
pub type MediaProcessor<'a> = Box<dyn 'a + Fn(i32) -> Option<(String, Option<String>)>>;
|
||||
|
||||
fn process_image<'a, 'b>(
|
||||
evt: Event<'a>,
|
||||
@@ -157,9 +158,7 @@ fn process_image<'a, 'b>(
|
||||
match evt {
|
||||
Event::Start(Tag::Image(id, title)) => {
|
||||
if let Some((url, cw)) = id.parse::<i32>().ok().and_then(processor.as_ref()) {
|
||||
if inline || cw.is_none() {
|
||||
Event::Start(Tag::Image(Cow::Owned(url), title))
|
||||
} else {
|
||||
if let (Some(cw), false) = (cw, inline) {
|
||||
// there is a cw, and where are not inline
|
||||
Event::Html(Cow::Owned(format!(
|
||||
r#"<label for="postcontent-cw-{id}">
|
||||
@@ -170,9 +169,11 @@ fn process_image<'a, 'b>(
|
||||
</span>
|
||||
<img src="{url}" alt=""#,
|
||||
id = random_hex(),
|
||||
cw = cw.unwrap(),
|
||||
cw = cw,
|
||||
url = url
|
||||
)))
|
||||
} else {
|
||||
Event::Start(Tag::Image(Cow::Owned(url), title))
|
||||
}
|
||||
} else {
|
||||
Event::Start(Tag::Image(id, title))
|
||||
@@ -200,6 +201,12 @@ fn process_image<'a, 'b>(
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
struct DocumentContext {
|
||||
in_code: bool,
|
||||
in_link: bool,
|
||||
}
|
||||
|
||||
/// Returns (HTML, mentions, hashtags)
|
||||
pub fn md_to_html<'a>(
|
||||
md: &str,
|
||||
@@ -214,7 +221,7 @@ pub fn md_to_html<'a>(
|
||||
};
|
||||
let parser = Parser::new_ext(md, Options::all());
|
||||
|
||||
let (parser, mentions, hashtags): (Vec<Event>, Vec<String>, Vec<String>) = parser
|
||||
let (parser, mentions, hashtags): (Vec<Event<'_>>, Vec<String>, Vec<String>) = parser
|
||||
// Flatten text because pulldown_cmark break #hashtag in two individual text elements
|
||||
.scan(None, flatten_text)
|
||||
.flatten()
|
||||
@@ -223,13 +230,21 @@ pub fn md_to_html<'a>(
|
||||
.map(|evt| process_image(evt, inline, &media_processor))
|
||||
// Ignore headings, images, and tables if inline = true
|
||||
.scan((vec![], inline), inline_tags)
|
||||
.scan(false, |in_code, evt| match evt {
|
||||
.scan(&mut DocumentContext::default(), |ctx, evt| match evt {
|
||||
Event::Start(Tag::CodeBlock(_)) | Event::Start(Tag::Code) => {
|
||||
*in_code = true;
|
||||
ctx.in_code = true;
|
||||
Some((vec![evt], vec![], vec![]))
|
||||
}
|
||||
Event::End(Tag::CodeBlock(_)) | Event::End(Tag::Code) => {
|
||||
*in_code = false;
|
||||
ctx.in_code = false;
|
||||
Some((vec![evt], vec![], vec![]))
|
||||
}
|
||||
Event::Start(Tag::Link(_, _)) => {
|
||||
ctx.in_link = true;
|
||||
Some((vec![evt], vec![], vec![]))
|
||||
}
|
||||
Event::End(Tag::Link(_, _)) => {
|
||||
ctx.in_link = false;
|
||||
Some((vec![evt], vec![], vec![]))
|
||||
}
|
||||
Event::Text(txt) => {
|
||||
@@ -247,7 +262,7 @@ pub fn md_to_html<'a>(
|
||||
text_acc.push(c)
|
||||
}
|
||||
let mention = text_acc;
|
||||
let short_mention = mention.splitn(1, '@').nth(0).unwrap_or("");
|
||||
let short_mention = mention.splitn(1, '@').next().unwrap_or("");
|
||||
let link = Tag::Link(
|
||||
format!("{}@/{}/", base_url, &mention).into(),
|
||||
short_mention.to_owned().into(),
|
||||
@@ -269,7 +284,7 @@ pub fn md_to_html<'a>(
|
||||
}
|
||||
}
|
||||
State::Hashtag => {
|
||||
let char_matches = c.is_alphanumeric() || "-_".contains(c);
|
||||
let char_matches = c == '-' || is_word_character(c);
|
||||
if char_matches && (n < (txt.chars().count() - 1)) {
|
||||
text_acc.push(c);
|
||||
(events, State::Hashtag, text_acc, n + 1, mentions, hashtags)
|
||||
@@ -300,7 +315,7 @@ pub fn md_to_html<'a>(
|
||||
}
|
||||
}
|
||||
State::Ready => {
|
||||
if !*in_code && c == '@' {
|
||||
if !ctx.in_code && !ctx.in_link && c == '@' {
|
||||
events.push(Event::Text(text_acc.into()));
|
||||
(
|
||||
events,
|
||||
@@ -310,7 +325,7 @@ pub fn md_to_html<'a>(
|
||||
mentions,
|
||||
hashtags,
|
||||
)
|
||||
} else if !*in_code && c == '#' {
|
||||
} else if !ctx.in_code && !ctx.in_link && c == '#' {
|
||||
events.push(Event::Text(text_acc.into()));
|
||||
(
|
||||
events,
|
||||
@@ -399,6 +414,7 @@ mod tests {
|
||||
("not_a@mention", vec![]),
|
||||
("`@helo`", vec![]),
|
||||
("```\n@hello\n```", vec![]),
|
||||
("[@atmark in link](https://example.org/)", vec![]),
|
||||
];
|
||||
|
||||
for (md, mentions) in tests {
|
||||
@@ -424,6 +440,9 @@ mod tests {
|
||||
("with some punctuation #test!", vec!["test"]),
|
||||
(" #spaces ", vec!["spaces"]),
|
||||
("not_a#hashtag", vec![]),
|
||||
("#نرمافزار_آزاد", vec!["نرمافزار_آزاد"]),
|
||||
("[#hash in link](https://example.org/)", vec![]),
|
||||
("#zwsp\u{200b}inhash", vec!["zwsp"]),
|
||||
];
|
||||
|
||||
for (md, mentions) in tests {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
name = "plume-front"
|
||||
version = "0.4.0"
|
||||
authors = ["Plume contributors"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
stdweb = "=0.4.18"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::CATALOG;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json;
|
||||
use std::sync::Mutex;
|
||||
@@ -5,7 +6,6 @@ use stdweb::{
|
||||
unstable::{TryFrom, TryInto},
|
||||
web::{event::*, html_element::*, *},
|
||||
};
|
||||
use CATALOG;
|
||||
|
||||
macro_rules! mv {
|
||||
( $( $var:ident ),* => $exp:expr ) => {
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
#![recursion_limit = "128"]
|
||||
#![feature(decl_macro, proc_macro_hygiene, try_trait)]
|
||||
|
||||
extern crate gettext;
|
||||
#[macro_use]
|
||||
extern crate gettext_macros;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
#[macro_use]
|
||||
extern crate stdweb;
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
use stdweb::web::{event::*, *};
|
||||
|
||||
init_i18n!(
|
||||
@@ -22,6 +19,7 @@ init_i18n!(
|
||||
en,
|
||||
eo,
|
||||
es,
|
||||
fa,
|
||||
fr,
|
||||
gl,
|
||||
hi,
|
||||
|
||||
+11
-14
@@ -1,8 +1,7 @@
|
||||
#![recursion_limit = "128"]
|
||||
extern crate proc_macro;
|
||||
|
||||
#[macro_use]
|
||||
extern crate quote;
|
||||
extern crate syn;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
@@ -103,19 +102,17 @@ fn file_to_migration(file: &str) -> TokenStream2 {
|
||||
acc.push_str(line);
|
||||
acc.push('\n');
|
||||
}
|
||||
} else if line.starts_with("--#!") {
|
||||
acc.push_str(&line[4..]);
|
||||
acc.push('\n');
|
||||
} else if line.starts_with("--") {
|
||||
continue;
|
||||
} else {
|
||||
if line.starts_with("--#!") {
|
||||
acc.push_str(&line[4..]);
|
||||
acc.push('\n');
|
||||
} else if line.starts_with("--") {
|
||||
continue;
|
||||
} else {
|
||||
let func: TokenStream2 = trampoline(TokenStream::from_str(&acc).unwrap().into());
|
||||
actions.push(quote!(Action::Function(&#func)));
|
||||
sql = true;
|
||||
acc = line.to_string();
|
||||
acc.push('\n');
|
||||
}
|
||||
let func: TokenStream2 = trampoline(TokenStream::from_str(&acc).unwrap().into());
|
||||
actions.push(quote!(Action::Function(&#func)));
|
||||
sql = true;
|
||||
acc = line.to_string();
|
||||
acc.push('\n');
|
||||
}
|
||||
}
|
||||
if !acc.trim().is_empty() {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
name = "plume-models"
|
||||
version = "0.4.0"
|
||||
authors = ["Plume contributors"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
activitypub = "0.1.1"
|
||||
@@ -11,7 +12,7 @@ bcrypt = "0.5"
|
||||
guid-create = "0.1"
|
||||
heck = "0.3.0"
|
||||
itertools = "0.8.0"
|
||||
lazy_static = "*"
|
||||
lazy_static = "1.0"
|
||||
migrations_internals= "1.4.0"
|
||||
openssl = "0.10.22"
|
||||
rocket = "0.4.0"
|
||||
@@ -21,7 +22,7 @@ scheduled-thread-pool = "0.2.2"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
tantivy = "0.10.1"
|
||||
tantivy = "0.12.0"
|
||||
url = "2.1"
|
||||
walkdir = "2.2"
|
||||
webfinger = "0.4.1"
|
||||
@@ -29,6 +30,7 @@ whatlang = "0.7.1"
|
||||
shrinkwraprs = "0.2.1"
|
||||
diesel-derive-newtype = "0.1.2"
|
||||
glob = "0.3.0"
|
||||
lindera-tantivy = { version = "0.1.2", optional = true }
|
||||
|
||||
[dependencies.chrono]
|
||||
features = ["serde"]
|
||||
@@ -53,3 +55,4 @@ diesel_migrations = "1.3.0"
|
||||
[features]
|
||||
postgres = ["diesel/postgres", "plume-macro/postgres" ]
|
||||
sqlite = ["diesel/sqlite", "plume-macro/sqlite" ]
|
||||
search-lindera = ["lindera-tantivy"]
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use crate::users::User;
|
||||
use rocket::{
|
||||
http::Status,
|
||||
request::{self, FromRequest, Request},
|
||||
Outcome,
|
||||
};
|
||||
|
||||
use users::User;
|
||||
|
||||
/// Wrapper around User to use as a request guard on pages reserved to admins.
|
||||
pub struct Admin(pub User);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::{db_conn::DbConn, schema::api_tokens, Error, Result};
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
use rocket::{
|
||||
@@ -6,10 +7,6 @@ use rocket::{
|
||||
Outcome,
|
||||
};
|
||||
|
||||
use db_conn::DbConn;
|
||||
use schema::api_tokens;
|
||||
use {Error, Result};
|
||||
|
||||
#[derive(Clone, Queryable)]
|
||||
pub struct ApiToken {
|
||||
pub id: i32,
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
use crate::{schema::apps, Error, Result};
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
|
||||
use schema::apps;
|
||||
use {Error, Result};
|
||||
|
||||
#[derive(Clone, Queryable, Serialize)]
|
||||
pub struct App {
|
||||
pub id: i32,
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
use crate::{schema::email_blocklist, Connection, Error, Result};
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, TextExpressionMethods};
|
||||
use glob::Pattern;
|
||||
|
||||
use schema::email_blocklist;
|
||||
use {Connection, Error, Result};
|
||||
|
||||
#[derive(Clone, Queryable, Identifiable)]
|
||||
#[table_name = "email_blocklist"]
|
||||
pub struct BlocklistedEmail {
|
||||
@@ -89,10 +87,9 @@ impl BlocklistedEmail {
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::{instance::tests as instance_tests, tests::rockets, Connection as Conn};
|
||||
use diesel::Connection;
|
||||
use instance::tests as instance_tests;
|
||||
use tests::rockets;
|
||||
use Connection as Conn;
|
||||
|
||||
pub(crate) fn fill_database(conn: &Conn) -> Vec<BlocklistedEmail> {
|
||||
instance_tests::fill_database(conn);
|
||||
let domainblock =
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
use crate::{schema::blog_authors, Error, Result};
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
|
||||
use schema::blog_authors;
|
||||
use {Error, Result};
|
||||
|
||||
#[derive(Clone, Queryable, Identifiable)]
|
||||
pub struct BlogAuthor {
|
||||
pub id: i32,
|
||||
|
||||
+25
-25
@@ -1,3 +1,7 @@
|
||||
use crate::{
|
||||
ap_url, instance::*, medias::Media, posts::Post, safe_string::SafeString, schema::blogs,
|
||||
search::Searcher, users::User, Connection, Error, PlumeRocket, Result, ITEMS_PER_PAGE,
|
||||
};
|
||||
use activitypub::{
|
||||
actor::Group,
|
||||
collection::{OrderedCollection, OrderedCollectionPage},
|
||||
@@ -12,22 +16,13 @@ use openssl::{
|
||||
rsa::Rsa,
|
||||
sign::{Signer, Verifier},
|
||||
};
|
||||
use serde_json;
|
||||
use url::Url;
|
||||
use webfinger::*;
|
||||
|
||||
use instance::*;
|
||||
use medias::Media;
|
||||
use plume_common::activity_pub::{
|
||||
inbox::{AsActor, FromId},
|
||||
sign, ActivityStream, ApSignature, Id, IntoId, PublicKey, Source,
|
||||
};
|
||||
use posts::Post;
|
||||
use safe_string::SafeString;
|
||||
use schema::blogs;
|
||||
use search::Searcher;
|
||||
use users::User;
|
||||
use {ap_url, Connection, Error, PlumeRocket, Result, ITEMS_PER_PAGE};
|
||||
use serde_json;
|
||||
use url::Url;
|
||||
use webfinger::*;
|
||||
|
||||
pub type CustomGroup = CustomObject<ApSignature, Group>;
|
||||
|
||||
@@ -106,8 +101,8 @@ impl Blog {
|
||||
}
|
||||
|
||||
pub fn list_authors(&self, conn: &Connection) -> Result<Vec<User>> {
|
||||
use schema::blog_authors;
|
||||
use schema::users;
|
||||
use crate::schema::blog_authors;
|
||||
use crate::schema::users;
|
||||
let authors_ids = blog_authors::table
|
||||
.filter(blog_authors::blog_id.eq(self.id))
|
||||
.select(blog_authors::author_id);
|
||||
@@ -118,7 +113,7 @@ impl Blog {
|
||||
}
|
||||
|
||||
pub fn count_authors(&self, conn: &Connection) -> Result<i64> {
|
||||
use schema::blog_authors;
|
||||
use crate::schema::blog_authors;
|
||||
blog_authors::table
|
||||
.filter(blog_authors::blog_id.eq(self.id))
|
||||
.count()
|
||||
@@ -127,7 +122,7 @@ impl Blog {
|
||||
}
|
||||
|
||||
pub fn find_for_author(conn: &Connection, author: &User) -> Result<Vec<Blog>> {
|
||||
use schema::blog_authors;
|
||||
use crate::schema::blog_authors;
|
||||
let author_ids = blog_authors::table
|
||||
.filter(blog_authors::author_id.eq(author.id))
|
||||
.select(blog_authors::blog_id);
|
||||
@@ -501,14 +496,17 @@ impl NewBlog {
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use blog_authors::*;
|
||||
use crate::{
|
||||
blog_authors::*,
|
||||
config::CONFIG,
|
||||
instance::tests as instance_tests,
|
||||
medias::NewMedia,
|
||||
search::tests::get_searcher,
|
||||
tests::{db, rockets},
|
||||
users::tests as usersTests,
|
||||
Connection as Conn,
|
||||
};
|
||||
use diesel::Connection;
|
||||
use instance::tests as instance_tests;
|
||||
use medias::NewMedia;
|
||||
use search::tests::get_searcher;
|
||||
use tests::{db, rockets};
|
||||
use users::tests as usersTests;
|
||||
use Connection as Conn;
|
||||
|
||||
pub(crate) fn fill_database(conn: &Conn) -> (Vec<User>, Vec<Blog>) {
|
||||
instance_tests::fill_database(conn);
|
||||
@@ -770,7 +768,9 @@ pub(crate) mod tests {
|
||||
conn.test_transaction::<_, (), _>(|| {
|
||||
let (_, blogs) = fill_database(conn);
|
||||
|
||||
blogs[0].delete(conn, &get_searcher()).unwrap();
|
||||
blogs[0]
|
||||
.delete(conn, &get_searcher(&CONFIG.search_tokenizers))
|
||||
.unwrap();
|
||||
assert!(Blog::get(conn, blogs[0].id).is_err());
|
||||
Ok(())
|
||||
})
|
||||
@@ -780,7 +780,7 @@ pub(crate) mod tests {
|
||||
fn delete_via_user() {
|
||||
let conn = &db();
|
||||
conn.test_transaction::<_, (), _>(|| {
|
||||
let searcher = get_searcher();
|
||||
let searcher = get_searcher(&CONFIG.search_tokenizers);
|
||||
let (user, _) = fill_database(conn);
|
||||
|
||||
let b1 = Blog::insert(
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
use crate::{comments::Comment, schema::comment_seers, users::User, Connection, Error, Result};
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
|
||||
use comments::Comment;
|
||||
use schema::comment_seers;
|
||||
use users::User;
|
||||
use {Connection, Error, Result};
|
||||
|
||||
#[derive(Queryable, Clone)]
|
||||
pub struct CommentSeers {
|
||||
pub id: i32,
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
use crate::{
|
||||
comment_seers::{CommentSeers, NewCommentSeers},
|
||||
instance::Instance,
|
||||
medias::Media,
|
||||
mentions::Mention,
|
||||
notifications::*,
|
||||
posts::Post,
|
||||
safe_string::SafeString,
|
||||
schema::comments,
|
||||
users::User,
|
||||
Connection, Error, PlumeRocket, Result,
|
||||
};
|
||||
use activitypub::{
|
||||
activity::{Create, Delete},
|
||||
link,
|
||||
@@ -5,25 +17,15 @@ use activitypub::{
|
||||
};
|
||||
use chrono::{self, NaiveDateTime};
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
|
||||
use serde_json;
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use comment_seers::{CommentSeers, NewCommentSeers};
|
||||
use instance::Instance;
|
||||
use medias::Media;
|
||||
use mentions::Mention;
|
||||
use notifications::*;
|
||||
use plume_common::activity_pub::{
|
||||
inbox::{AsActor, AsObject, FromId},
|
||||
Id, IntoId, PUBLIC_VISIBILITY,
|
||||
use plume_common::{
|
||||
activity_pub::{
|
||||
inbox::{AsActor, AsObject, FromId},
|
||||
Id, IntoId, PUBLIC_VISIBILITY,
|
||||
},
|
||||
utils,
|
||||
};
|
||||
use plume_common::utils;
|
||||
use posts::Post;
|
||||
use safe_string::SafeString;
|
||||
use schema::comments;
|
||||
use users::User;
|
||||
use {Connection, Error, PlumeRocket, Result};
|
||||
use serde_json;
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[derive(Queryable, Identifiable, Clone, AsChangeset)]
|
||||
pub struct Comment {
|
||||
@@ -77,7 +79,7 @@ impl Comment {
|
||||
}
|
||||
|
||||
pub fn count_local(conn: &Connection) -> Result<i64> {
|
||||
use schema::users;
|
||||
use crate::schema::users;
|
||||
let local_authors = users::table
|
||||
.filter(users::instance_id.eq(Instance::get_local()?.id))
|
||||
.select(users::id);
|
||||
@@ -127,9 +129,8 @@ impl Comment {
|
||||
)?))?;
|
||||
note.object_props
|
||||
.set_published_string(chrono::Utc::now().to_rfc3339())?;
|
||||
note.object_props
|
||||
.set_attributed_to_link(author.clone().into_id())?;
|
||||
note.object_props.set_to_link_vec(to.clone())?;
|
||||
note.object_props.set_attributed_to_link(author.into_id())?;
|
||||
note.object_props.set_to_link_vec(to)?;
|
||||
note.object_props.set_tag_link_vec(
|
||||
mentions
|
||||
.into_iter()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::search::TokenizerKind as SearchTokenizer;
|
||||
use rocket::config::Limits;
|
||||
use rocket::Config as RocketConfig;
|
||||
use std::env::{self, var};
|
||||
@@ -11,7 +12,10 @@ pub struct Config {
|
||||
pub base_url: String,
|
||||
pub database_url: String,
|
||||
pub db_name: &'static str,
|
||||
pub db_max_size: Option<u32>,
|
||||
pub db_min_idle: Option<u32>,
|
||||
pub search_index: String,
|
||||
pub search_tokenizers: SearchTokenizerConfig,
|
||||
pub rocket: Result<RocketConfig, RocketError>,
|
||||
pub logo: LogoConfig,
|
||||
pub default_theme: String,
|
||||
@@ -186,6 +190,56 @@ impl Default for LogoConfig {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SearchTokenizerConfig {
|
||||
pub tag_tokenizer: SearchTokenizer,
|
||||
pub content_tokenizer: SearchTokenizer,
|
||||
pub property_tokenizer: SearchTokenizer,
|
||||
}
|
||||
|
||||
impl SearchTokenizerConfig {
|
||||
pub fn init() -> Self {
|
||||
use SearchTokenizer::*;
|
||||
|
||||
match var("SEARCH_LANG").ok().as_deref() {
|
||||
Some("ja") => {
|
||||
#[cfg(not(feature = "search-lindera"))]
|
||||
panic!("You need build Plume with search-lindera feature, or execute it with SEARCH_TAG_TOKENIZER=ngram and SEARCH_CONTENT_TOKENIZER=ngram to enable Japanese search feature");
|
||||
#[cfg(feature = "search-lindera")]
|
||||
Self {
|
||||
tag_tokenizer: Self::determine_tokenizer("SEARCH_TAG_TOKENIZER", Lindera),
|
||||
content_tokenizer: Self::determine_tokenizer(
|
||||
"SEARCH_CONTENT_TOKENIZER",
|
||||
Lindera,
|
||||
),
|
||||
property_tokenizer: Ngram,
|
||||
}
|
||||
}
|
||||
_ => Self {
|
||||
tag_tokenizer: Self::determine_tokenizer("SEARCH_TAG_TOKENIZER", Whitespace),
|
||||
content_tokenizer: Self::determine_tokenizer("SEARCH_CONTENT_TOKENIZER", Simple),
|
||||
property_tokenizer: Ngram,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn determine_tokenizer(var_name: &str, default: SearchTokenizer) -> SearchTokenizer {
|
||||
use SearchTokenizer::*;
|
||||
|
||||
match var(var_name).ok().as_deref() {
|
||||
Some("simple") => Simple,
|
||||
Some("ngram") => Ngram,
|
||||
Some("whitespace") => Whitespace,
|
||||
Some("lindera") => {
|
||||
#[cfg(not(feature = "search-lindera"))]
|
||||
panic!("You need build Plume with search-lindera feature to use Lindera tokenizer");
|
||||
#[cfg(feature = "search-lindera")]
|
||||
Lindera
|
||||
}
|
||||
_ => default,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
pub static ref CONFIG: Config = Config {
|
||||
base_url: var("BASE_URL").unwrap_or_else(|_| format!(
|
||||
@@ -193,12 +247,21 @@ lazy_static! {
|
||||
var("ROCKET_PORT").unwrap_or_else(|_| "7878".to_owned())
|
||||
)),
|
||||
db_name: DB_NAME,
|
||||
db_max_size: var("DB_MAX_SIZE").map_or(None, |s| Some(
|
||||
s.parse::<u32>()
|
||||
.expect("Couldn't parse DB_MAX_SIZE into u32")
|
||||
)),
|
||||
db_min_idle: var("DB_MIN_IDLE").map_or(None, |s| Some(
|
||||
s.parse::<u32>()
|
||||
.expect("Couldn't parse DB_MIN_IDLE into u32")
|
||||
)),
|
||||
#[cfg(feature = "postgres")]
|
||||
database_url: var("DATABASE_URL")
|
||||
.unwrap_or_else(|_| format!("postgres://plume:plume@localhost/{}", DB_NAME)),
|
||||
#[cfg(feature = "sqlite")]
|
||||
database_url: var("DATABASE_URL").unwrap_or_else(|_| format!("{}.sqlite", DB_NAME)),
|
||||
search_index: var("SEARCH_INDEX").unwrap_or_else(|_| "search_index".to_owned()),
|
||||
search_tokenizers: SearchTokenizerConfig::init(),
|
||||
rocket: get_rocket_config(),
|
||||
logo: LogoConfig::default(),
|
||||
default_theme: var("DEFAULT_THEME").unwrap_or_else(|_| "default-light".to_owned()),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::Connection;
|
||||
use diesel::r2d2::{
|
||||
ConnectionManager, CustomizeConnection, Error as ConnError, Pool, PooledConnection,
|
||||
};
|
||||
@@ -10,8 +11,6 @@ use rocket::{
|
||||
};
|
||||
use std::ops::Deref;
|
||||
|
||||
use Connection;
|
||||
|
||||
pub type DbPool = Pool<ConnectionManager<Connection>>;
|
||||
|
||||
// From rocket documentation
|
||||
@@ -26,7 +25,7 @@ impl<'a, 'r> FromRequest<'a, 'r> for DbConn {
|
||||
type Error = ();
|
||||
|
||||
fn from_request(request: &'a Request<'r>) -> request::Outcome<Self, Self::Error> {
|
||||
let pool = request.guard::<State<DbPool>>()?;
|
||||
let pool = request.guard::<State<'_, DbPool>>()?;
|
||||
match pool.get() {
|
||||
Ok(conn) => Outcome::Success(DbConn(conn)),
|
||||
Err(_) => Outcome::Failure((Status::ServiceUnavailable, ())),
|
||||
@@ -73,5 +72,4 @@ pub(crate) mod tests {
|
||||
Ok(conn.begin_test_transaction().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
use crate::{
|
||||
ap_url, notifications::*, schema::follows, users::User, Connection, Error, PlumeRocket, Result,
|
||||
CONFIG,
|
||||
};
|
||||
use activitypub::activity::{Accept, Follow as FollowAct, Undo};
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
|
||||
|
||||
use notifications::*;
|
||||
use plume_common::activity_pub::{
|
||||
broadcast,
|
||||
inbox::{AsActor, AsObject, FromId},
|
||||
sign::Signer,
|
||||
Id, IntoId, PUBLIC_VISIBILITY,
|
||||
};
|
||||
use schema::follows;
|
||||
use users::User;
|
||||
use {ap_url, Connection, Error, PlumeRocket, Result, CONFIG};
|
||||
|
||||
#[derive(Clone, Queryable, Identifiable, Associations, AsChangeset)]
|
||||
#[belongs_to(User, foreign_key = "following_id")]
|
||||
@@ -56,8 +55,7 @@ impl Follow {
|
||||
let target = User::get(conn, self.following_id)?;
|
||||
|
||||
let mut act = FollowAct::default();
|
||||
act.follow_props
|
||||
.set_actor_link::<Id>(user.clone().into_id())?;
|
||||
act.follow_props.set_actor_link::<Id>(user.into_id())?;
|
||||
act.follow_props
|
||||
.set_object_link::<Id>(target.clone().into_id())?;
|
||||
act.object_props.set_id_string(self.ap_url.clone())?;
|
||||
@@ -202,9 +200,8 @@ impl IntoId for Follow {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{tests::db, users::tests as user_tests};
|
||||
use diesel::Connection;
|
||||
use tests::db;
|
||||
use users::tests as user_tests;
|
||||
|
||||
#[test]
|
||||
fn test_id() {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
use crate::{
|
||||
ap_url,
|
||||
medias::Media,
|
||||
safe_string::SafeString,
|
||||
schema::{instances, users},
|
||||
users::{Role, User},
|
||||
Connection, Error, Result,
|
||||
};
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
use std::sync::RwLock;
|
||||
|
||||
use ap_url;
|
||||
use medias::Media;
|
||||
use plume_common::utils::md_to_html;
|
||||
use safe_string::SafeString;
|
||||
use schema::{instances, users};
|
||||
use users::{Role, User};
|
||||
use {Connection, Error, Result};
|
||||
use std::sync::RwLock;
|
||||
|
||||
#[derive(Clone, Identifiable, Queryable)]
|
||||
pub struct Instance {
|
||||
@@ -242,9 +243,8 @@ impl Instance {
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::{tests::db, Connection as Conn};
|
||||
use diesel::Connection;
|
||||
use tests::db;
|
||||
use Connection as Conn;
|
||||
|
||||
pub(crate) fn fill_database(conn: &Conn) -> Vec<(NewInstance, Instance)> {
|
||||
let res = vec![
|
||||
|
||||
+6
-30
@@ -1,43 +1,21 @@
|
||||
#![feature(try_trait)]
|
||||
#![feature(never_type)]
|
||||
#![feature(custom_attribute)]
|
||||
#![feature(proc_macro_hygiene)]
|
||||
|
||||
extern crate activitypub;
|
||||
extern crate ammonia;
|
||||
extern crate askama_escape;
|
||||
extern crate bcrypt;
|
||||
extern crate chrono;
|
||||
#[macro_use]
|
||||
extern crate diesel;
|
||||
extern crate guid_create;
|
||||
extern crate heck;
|
||||
extern crate itertools;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
extern crate migrations_internals;
|
||||
extern crate openssl;
|
||||
extern crate plume_api;
|
||||
extern crate plume_common;
|
||||
#[macro_use]
|
||||
extern crate plume_macro;
|
||||
extern crate reqwest;
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
extern crate rocket_i18n;
|
||||
extern crate scheduled_thread_pool;
|
||||
extern crate serde;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
#[macro_use]
|
||||
extern crate serde_json;
|
||||
#[macro_use]
|
||||
extern crate tantivy;
|
||||
extern crate glob;
|
||||
extern crate url;
|
||||
extern crate walkdir;
|
||||
extern crate webfinger;
|
||||
extern crate whatlang;
|
||||
|
||||
use plume_common::activity_pub::inbox::InboxError;
|
||||
|
||||
@@ -250,12 +228,13 @@ macro_rules! get {
|
||||
/// Model::insert(connection, NewModelType::new());
|
||||
/// ```
|
||||
macro_rules! insert {
|
||||
($table:ident, $from:ident) => {
|
||||
($table:ident, $from:ty) => {
|
||||
insert!($table, $from, |x, _conn| Ok(x));
|
||||
};
|
||||
($table:ident, $from:ident, |$val:ident, $conn:ident | $( $after:tt )+) => {
|
||||
($table:ident, $from:ty, |$val:ident, $conn:ident | $( $after:tt )+) => {
|
||||
last!($table);
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn insert(conn: &crate::Connection, new: $from) -> Result<Self> {
|
||||
diesel::insert_into($table::table)
|
||||
.values(new)
|
||||
@@ -282,6 +261,7 @@ macro_rules! insert {
|
||||
/// ```
|
||||
macro_rules! last {
|
||||
($table:ident) => {
|
||||
#[allow(dead_code)]
|
||||
pub fn last(conn: &crate::Connection) -> Result<Self> {
|
||||
$table::table
|
||||
.order_by($table::id.desc())
|
||||
@@ -301,16 +281,12 @@ pub fn ap_url(url: &str) -> String {
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
mod tests {
|
||||
use db_conn;
|
||||
use crate::{db_conn, migrations::IMPORTED_MIGRATIONS, search, Connection as Conn, CONFIG};
|
||||
use diesel::r2d2::ConnectionManager;
|
||||
use migrations::IMPORTED_MIGRATIONS;
|
||||
use plume_common::utils::random_hex;
|
||||
use scheduled_thread_pool::ScheduledThreadPool;
|
||||
use search;
|
||||
use std::env::temp_dir;
|
||||
use std::sync::Arc;
|
||||
use Connection as Conn;
|
||||
use CONFIG;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! part_eq {
|
||||
@@ -344,7 +320,7 @@ mod tests {
|
||||
pub fn rockets() -> super::PlumeRocket {
|
||||
super::PlumeRocket {
|
||||
conn: db_conn::DbConn((*DB_POOL).get().unwrap()),
|
||||
searcher: Arc::new(search::tests::get_searcher()),
|
||||
searcher: Arc::new(search::tests::get_searcher(&CONFIG.search_tokenizers)),
|
||||
worker: Arc::new(ScheduledThreadPool::new(2)),
|
||||
user: None,
|
||||
}
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
use crate::{
|
||||
notifications::*, posts::Post, schema::likes, timeline::*, users::User, Connection, Error,
|
||||
PlumeRocket, Result,
|
||||
};
|
||||
use activitypub::activity;
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
|
||||
use notifications::*;
|
||||
use plume_common::activity_pub::{
|
||||
inbox::{AsActor, AsObject, FromId},
|
||||
Id, IntoId, PUBLIC_VISIBILITY,
|
||||
};
|
||||
use posts::Post;
|
||||
use schema::likes;
|
||||
use timeline::*;
|
||||
use users::User;
|
||||
use {Connection, Error, PlumeRocket, Result};
|
||||
|
||||
#[derive(Clone, Queryable, Identifiable)]
|
||||
pub struct Like {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use crate::{
|
||||
blogs::Blog,
|
||||
schema::{blogs, list_elems, lists, users},
|
||||
users::User,
|
||||
Connection, Error, Result,
|
||||
};
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
|
||||
use blogs::Blog;
|
||||
use schema::{blogs, list_elems, lists, users};
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use users::User;
|
||||
use {Connection, Error, Result};
|
||||
|
||||
/// Represent what a list is supposed to store. Represented in database as an integer
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
@@ -164,7 +165,7 @@ impl List {
|
||||
last!(lists);
|
||||
get!(lists);
|
||||
|
||||
fn insert(conn: &Connection, val: NewList) -> Result<Self> {
|
||||
fn insert(conn: &Connection, val: NewList<'_>) -> Result<Self> {
|
||||
diesel::insert_into(lists::table)
|
||||
.values(val)
|
||||
.execute(conn)?;
|
||||
@@ -309,7 +310,7 @@ mod private {
|
||||
};
|
||||
|
||||
impl ListElem {
|
||||
insert!(list_elems, NewListElem);
|
||||
insert!(list_elems, NewListElem<'_>);
|
||||
|
||||
pub fn user_in_list(conn: &Connection, list: &List, user: i32) -> Result<bool> {
|
||||
dsl::select(dsl::exists(
|
||||
@@ -359,9 +360,8 @@ mod private {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use blogs::tests as blog_tests;
|
||||
use crate::{blogs::tests as blog_tests, tests::db};
|
||||
use diesel::Connection;
|
||||
use tests::db;
|
||||
|
||||
#[test]
|
||||
fn list_type() {
|
||||
@@ -551,5 +551,4 @@ mod tests {
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+14
-15
@@ -1,20 +1,17 @@
|
||||
use crate::{
|
||||
ap_url, instance::Instance, safe_string::SafeString, schema::medias, users::User, Connection,
|
||||
Error, PlumeRocket, Result,
|
||||
};
|
||||
use activitypub::object::Image;
|
||||
use askama_escape::escape;
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
use guid_create::GUID;
|
||||
use reqwest;
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use plume_common::{
|
||||
activity_pub::{inbox::FromId, Id},
|
||||
utils::MediaProcessor,
|
||||
};
|
||||
|
||||
use instance::Instance;
|
||||
use safe_string::SafeString;
|
||||
use schema::medias;
|
||||
use users::User;
|
||||
use {ap_url, Connection, Error, PlumeRocket, Result};
|
||||
use reqwest;
|
||||
use std::{fs, path::Path};
|
||||
|
||||
#[derive(Clone, Identifiable, Queryable)]
|
||||
pub struct Media {
|
||||
@@ -117,15 +114,19 @@ impl Media {
|
||||
Ok(match self.category() {
|
||||
MediaCategory::Image => SafeString::trusted(&format!(
|
||||
r#"<img src="{}" alt="{}" title="{}">"#,
|
||||
url, escape(&self.alt_text), escape(&self.alt_text)
|
||||
url,
|
||||
escape(&self.alt_text),
|
||||
escape(&self.alt_text)
|
||||
)),
|
||||
MediaCategory::Audio => SafeString::trusted(&format!(
|
||||
r#"<div class="media-preview audio"></div><audio src="{}" title="{}" controls></audio>"#,
|
||||
url, escape(&self.alt_text)
|
||||
url,
|
||||
escape(&self.alt_text)
|
||||
)),
|
||||
MediaCategory::Video => SafeString::trusted(&format!(
|
||||
r#"<video src="{}" title="{}" controls></video>"#,
|
||||
url, escape(&self.alt_text)
|
||||
url,
|
||||
escape(&self.alt_text)
|
||||
)),
|
||||
MediaCategory::Unknown => SafeString::trusted(&format!(
|
||||
r#"<a href="{}" class="media-preview unknown"></a>"#,
|
||||
@@ -259,13 +260,11 @@ impl Media {
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::{tests::db, users::tests as usersTests, Connection as Conn};
|
||||
use diesel::Connection;
|
||||
use std::env::{current_dir, set_current_dir};
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use tests::db;
|
||||
use users::tests as usersTests;
|
||||
use Connection as Conn;
|
||||
|
||||
pub(crate) fn fill_database(conn: &Conn) -> (Vec<User>, Vec<Media>) {
|
||||
let mut wd = current_dir().unwrap().to_path_buf();
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
use crate::{
|
||||
comments::Comment, notifications::*, posts::Post, schema::mentions, users::User, Connection,
|
||||
Error, PlumeRocket, Result,
|
||||
};
|
||||
use activitypub::link;
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
|
||||
use comments::Comment;
|
||||
use notifications::*;
|
||||
use plume_common::activity_pub::inbox::AsActor;
|
||||
use posts::Post;
|
||||
use schema::mentions;
|
||||
use users::User;
|
||||
use PlumeRocket;
|
||||
use {Connection, Error, Result};
|
||||
|
||||
#[derive(Clone, Queryable, Identifiable)]
|
||||
pub struct Mention {
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
use Connection;
|
||||
use Error;
|
||||
use Result;
|
||||
|
||||
use crate::{Connection, Error, Result};
|
||||
use diesel::connection::{Connection as Conn, SimpleConnection};
|
||||
use migrations_internals::{setup_database, MigrationConnection};
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
#[allow(dead_code)] //variants might not be constructed if not required by current migrations
|
||||
enum Action {
|
||||
Sql(&'static str),
|
||||
Function(&'static Fn(&Connection, &Path) -> Result<()>),
|
||||
Function(&'static dyn Fn(&Connection, &Path) -> Result<()>),
|
||||
}
|
||||
|
||||
impl Action {
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
use crate::{
|
||||
comments::Comment,
|
||||
follows::Follow,
|
||||
likes::Like,
|
||||
mentions::Mention,
|
||||
posts::Post,
|
||||
reshares::Reshare,
|
||||
schema::{follows, notifications},
|
||||
users::User,
|
||||
Connection, Error, Result,
|
||||
};
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, ExpressionMethods, JoinOnDsl, QueryDsl, RunQueryDsl};
|
||||
|
||||
use comments::Comment;
|
||||
use follows::Follow;
|
||||
use likes::Like;
|
||||
use mentions::Mention;
|
||||
use posts::Post;
|
||||
use reshares::Reshare;
|
||||
use schema::{follows, notifications};
|
||||
use users::User;
|
||||
use {Connection, Error, Result};
|
||||
|
||||
pub mod notification_kind {
|
||||
pub const COMMENT: &str = "COMMENT";
|
||||
pub const FOLLOW: &str = "FOLLOW";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use crate::{schema::password_reset_requests, Connection, Error, Result};
|
||||
use chrono::{offset::Utc, Duration, NaiveDateTime};
|
||||
use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
use schema::password_reset_requests;
|
||||
use {Connection, Error, Result};
|
||||
|
||||
#[derive(Clone, Identifiable, Queryable)]
|
||||
pub struct PasswordResetRequest {
|
||||
@@ -75,9 +74,8 @@ impl PasswordResetRequest {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{tests::db, users::tests as user_tests};
|
||||
use diesel::Connection;
|
||||
use tests::db;
|
||||
use users::tests as user_tests;
|
||||
|
||||
#[test]
|
||||
fn test_insert_and_find_password_reset_request() {
|
||||
|
||||
@@ -2,9 +2,7 @@ pub use self::module::PlumeRocket;
|
||||
|
||||
#[cfg(not(test))]
|
||||
mod module {
|
||||
use crate::db_conn::DbConn;
|
||||
use crate::search;
|
||||
use crate::users;
|
||||
use crate::{db_conn::DbConn, search, users};
|
||||
use rocket::{
|
||||
request::{self, FlashMessage, FromRequest, Request},
|
||||
Outcome, State,
|
||||
@@ -29,9 +27,9 @@ mod module {
|
||||
let conn = request.guard::<DbConn>()?;
|
||||
let intl = request.guard::<rocket_i18n::I18n>()?;
|
||||
let user = request.guard::<users::User>().succeeded();
|
||||
let worker = request.guard::<State<Arc<ScheduledThreadPool>>>()?;
|
||||
let searcher = request.guard::<State<Arc<search::Searcher>>>()?;
|
||||
let flash_msg = request.guard::<FlashMessage>().succeeded();
|
||||
let worker = request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>()?;
|
||||
let searcher = request.guard::<'_, State<'_, Arc<search::Searcher>>>()?;
|
||||
let flash_msg = request.guard::<FlashMessage<'_, '_>>().succeeded();
|
||||
Outcome::Success(PlumeRocket {
|
||||
conn,
|
||||
intl,
|
||||
@@ -46,9 +44,7 @@ mod module {
|
||||
|
||||
#[cfg(test)]
|
||||
mod module {
|
||||
use crate::db_conn::DbConn;
|
||||
use crate::search;
|
||||
use crate::users;
|
||||
use crate::{db_conn::DbConn, search, users};
|
||||
use rocket::{
|
||||
request::{self, FromRequest, Request},
|
||||
Outcome, State,
|
||||
@@ -70,8 +66,8 @@ mod module {
|
||||
fn from_request(request: &'a Request<'r>) -> request::Outcome<PlumeRocket, ()> {
|
||||
let conn = request.guard::<DbConn>()?;
|
||||
let user = request.guard::<users::User>().succeeded();
|
||||
let worker = request.guard::<State<Arc<ScheduledThreadPool>>>()?;
|
||||
let searcher = request.guard::<State<Arc<search::Searcher>>>()?;
|
||||
let worker = request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>()?;
|
||||
let searcher = request.guard::<'_, State<'_, Arc<search::Searcher>>>()?;
|
||||
Outcome::Success(PlumeRocket {
|
||||
conn,
|
||||
user,
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
use crate::{posts::Post, schema::post_authors, users::User, Error, Result};
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
|
||||
use posts::Post;
|
||||
use schema::post_authors;
|
||||
use users::User;
|
||||
use {Error, Result};
|
||||
|
||||
#[derive(Clone, Queryable, Identifiable, Associations)]
|
||||
#[belongs_to(Post)]
|
||||
#[belongs_to(User, foreign_key = "author_id")]
|
||||
|
||||
+22
-30
@@ -1,3 +1,8 @@
|
||||
use crate::{
|
||||
ap_url, blogs::Blog, instance::Instance, medias::Media, mentions::Mention, post_authors::*,
|
||||
safe_string::SafeString, schema::posts, search::Searcher, tags::*, timeline::*, users::User,
|
||||
Connection, Error, PlumeRocket, Result, CONFIG,
|
||||
};
|
||||
use activitypub::{
|
||||
activity::{Create, Delete, Update},
|
||||
link,
|
||||
@@ -7,13 +12,6 @@ use activitypub::{
|
||||
use chrono::{NaiveDateTime, TimeZone, Utc};
|
||||
use diesel::{self, BelongingToDsl, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
|
||||
use heck::{CamelCase, KebabCase};
|
||||
use serde_json;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use blogs::Blog;
|
||||
use instance::Instance;
|
||||
use medias::Media;
|
||||
use mentions::Mention;
|
||||
use plume_common::{
|
||||
activity_pub::{
|
||||
inbox::{AsObject, FromId},
|
||||
@@ -21,14 +19,8 @@ use plume_common::{
|
||||
},
|
||||
utils::md_to_html,
|
||||
};
|
||||
use post_authors::*;
|
||||
use safe_string::SafeString;
|
||||
use schema::posts;
|
||||
use search::Searcher;
|
||||
use tags::*;
|
||||
use timeline::*;
|
||||
use users::User;
|
||||
use {ap_url, Connection, Error, PlumeRocket, Result, CONFIG};
|
||||
use serde_json;
|
||||
use std::collections::HashSet;
|
||||
|
||||
pub type LicensedArticle = CustomObject<Licensed, Article>;
|
||||
|
||||
@@ -111,7 +103,7 @@ impl Post {
|
||||
tag: String,
|
||||
(min, max): (i32, i32),
|
||||
) -> Result<Vec<Post>> {
|
||||
use schema::tags;
|
||||
use crate::schema::tags;
|
||||
|
||||
let ids = tags::table.filter(tags::tag.eq(tag)).select(tags::post_id);
|
||||
posts::table
|
||||
@@ -125,7 +117,7 @@ impl Post {
|
||||
}
|
||||
|
||||
pub fn count_for_tag(conn: &Connection, tag: String) -> Result<i64> {
|
||||
use schema::tags;
|
||||
use crate::schema::tags;
|
||||
let ids = tags::table.filter(tags::tag.eq(tag)).select(tags::post_id);
|
||||
posts::table
|
||||
.filter(posts::id.eq_any(ids))
|
||||
@@ -139,8 +131,8 @@ impl Post {
|
||||
}
|
||||
|
||||
pub fn count_local(conn: &Connection) -> Result<i64> {
|
||||
use schema::post_authors;
|
||||
use schema::users;
|
||||
use crate::schema::post_authors;
|
||||
use crate::schema::users;
|
||||
let local_authors = users::table
|
||||
.filter(users::instance_id.eq(Instance::get_local()?.id))
|
||||
.select(users::id);
|
||||
@@ -188,7 +180,7 @@ impl Post {
|
||||
author: &User,
|
||||
limit: i64,
|
||||
) -> Result<Vec<Post>> {
|
||||
use schema::post_authors;
|
||||
use crate::schema::post_authors;
|
||||
|
||||
let posts = PostAuthor::belonging_to(author).select(post_authors::post_id);
|
||||
posts::table
|
||||
@@ -239,7 +231,7 @@ impl Post {
|
||||
}
|
||||
|
||||
pub fn drafts_by_author(conn: &Connection, author: &User) -> Result<Vec<Post>> {
|
||||
use schema::post_authors;
|
||||
use crate::schema::post_authors;
|
||||
|
||||
let posts = PostAuthor::belonging_to(author).select(post_authors::post_id);
|
||||
posts::table
|
||||
@@ -251,8 +243,8 @@ impl Post {
|
||||
}
|
||||
|
||||
pub fn get_authors(&self, conn: &Connection) -> Result<Vec<User>> {
|
||||
use schema::post_authors;
|
||||
use schema::users;
|
||||
use crate::schema::post_authors;
|
||||
use crate::schema::users;
|
||||
let author_list = PostAuthor::belonging_to(self).select(post_authors::author_id);
|
||||
users::table
|
||||
.filter(users::id.eq_any(author_list))
|
||||
@@ -261,7 +253,7 @@ impl Post {
|
||||
}
|
||||
|
||||
pub fn is_author(&self, conn: &Connection, author_id: i32) -> Result<bool> {
|
||||
use schema::post_authors;
|
||||
use crate::schema::post_authors;
|
||||
Ok(PostAuthor::belonging_to(self)
|
||||
.filter(post_authors::author_id.eq(author_id))
|
||||
.count()
|
||||
@@ -270,7 +262,7 @@ impl Post {
|
||||
}
|
||||
|
||||
pub fn get_blog(&self, conn: &Connection) -> Result<Blog> {
|
||||
use schema::blogs;
|
||||
use crate::schema::blogs;
|
||||
blogs::table
|
||||
.filter(blogs::id.eq(self.blog_id))
|
||||
.first(conn)
|
||||
@@ -278,7 +270,7 @@ impl Post {
|
||||
}
|
||||
|
||||
pub fn count_likes(&self, conn: &Connection) -> Result<i64> {
|
||||
use schema::likes;
|
||||
use crate::schema::likes;
|
||||
likes::table
|
||||
.filter(likes::post_id.eq(self.id))
|
||||
.count()
|
||||
@@ -287,7 +279,7 @@ impl Post {
|
||||
}
|
||||
|
||||
pub fn count_reshares(&self, conn: &Connection) -> Result<i64> {
|
||||
use schema::reshares;
|
||||
use crate::schema::reshares;
|
||||
reshares::table
|
||||
.filter(reshares::post_id.eq(self.id))
|
||||
.count()
|
||||
@@ -632,7 +624,7 @@ impl FromId<PlumeRocket> for Post {
|
||||
.into_iter()
|
||||
.map(|s| s.to_camel_case())
|
||||
.collect::<HashSet<_>>();
|
||||
if let Some(serde_json::Value::Array(tags)) = article.object_props.tag.clone() {
|
||||
if let Some(serde_json::Value::Array(tags)) = article.object_props.tag {
|
||||
for tag in tags {
|
||||
serde_json::from_value::<link::Mention>(tag.clone())
|
||||
.map(|m| Mention::from_activity(conn, &m, post.id, true, true))
|
||||
@@ -725,7 +717,7 @@ impl FromId<PlumeRocket> for PostUpdate {
|
||||
.ok()
|
||||
.map(|x| x.content),
|
||||
license: updated.custom_props.license_string().ok(),
|
||||
tags: updated.object.object_props.tag.clone(),
|
||||
tags: updated.object.object_props.tag,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -806,7 +798,7 @@ impl AsObject<User, Update, &PlumeRocket> for PostUpdate {
|
||||
|
||||
impl IntoId for Post {
|
||||
fn into_id(self) -> Id {
|
||||
Id::new(self.ap_url.clone())
|
||||
Id::new(self.ap_url)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user