Compare commits
38 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 |
@@ -1,5 +1,5 @@
|
||||
localhost:443 {
|
||||
proxy / localhost:7878 {
|
||||
proxy / integration:7878 {
|
||||
transparent
|
||||
}
|
||||
tls self_signed
|
||||
|
||||
+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
+649
-245
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -24,7 +24,6 @@ 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.4.0"
|
||||
scheduled-thread-pool = "0.2.2"
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
@@ -79,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"]
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -23,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"]
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -442,6 +442,7 @@ mod tests {
|
||||
("not_a#hashtag", vec![]),
|
||||
("#نرمافزار_آزاد", vec!["نرمافزار_آزاد"]),
|
||||
("[#hash in link](https://example.org/)", vec![]),
|
||||
("#zwsp\u{200b}inhash", vec!["zwsp"]),
|
||||
];
|
||||
|
||||
for (md, mentions) in tests {
|
||||
|
||||
@@ -19,6 +19,7 @@ init_i18n!(
|
||||
en,
|
||||
eo,
|
||||
es,
|
||||
fa,
|
||||
fr,
|
||||
gl,
|
||||
hi,
|
||||
|
||||
@@ -22,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"
|
||||
@@ -30,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"]
|
||||
@@ -54,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"]
|
||||
|
||||
@@ -498,6 +498,7 @@ pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
blog_authors::*,
|
||||
config::CONFIG,
|
||||
instance::tests as instance_tests,
|
||||
medias::NewMedia,
|
||||
search::tests::get_searcher,
|
||||
@@ -767,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(())
|
||||
})
|
||||
@@ -777,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,3 +1,4 @@
|
||||
use crate::search::TokenizerKind as SearchTokenizer;
|
||||
use rocket::config::Limits;
|
||||
use rocket::Config as RocketConfig;
|
||||
use std::env::{self, var};
|
||||
@@ -14,6 +15,7 @@ pub struct Config {
|
||||
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,
|
||||
@@ -188,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!(
|
||||
@@ -209,6 +261,7 @@ lazy_static! {
|
||||
#[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()),
|
||||
|
||||
@@ -320,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,
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ mod searcher;
|
||||
mod tokenizer;
|
||||
pub use self::query::PlumeQuery as Query;
|
||||
pub use self::searcher::*;
|
||||
pub use self::tokenizer::TokenizerKind;
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use super::{Query, Searcher};
|
||||
use super::{Query, Searcher, TokenizerKind};
|
||||
use diesel::Connection;
|
||||
use plume_common::utils::random_hex;
|
||||
use std::env::temp_dir;
|
||||
@@ -14,18 +15,20 @@ pub(crate) mod tests {
|
||||
|
||||
use crate::{
|
||||
blogs::tests::fill_database,
|
||||
config::SearchTokenizerConfig,
|
||||
post_authors::*,
|
||||
posts::{NewPost, Post},
|
||||
safe_string::SafeString,
|
||||
tests::db,
|
||||
CONFIG,
|
||||
};
|
||||
|
||||
pub(crate) fn get_searcher() -> Searcher {
|
||||
pub(crate) fn get_searcher(tokenizers: &SearchTokenizerConfig) -> Searcher {
|
||||
let dir = temp_dir().join(&format!("plume-test-{}", random_hex()));
|
||||
if dir.exists() {
|
||||
Searcher::open(&dir)
|
||||
Searcher::open(&dir, tokenizers)
|
||||
} else {
|
||||
Searcher::create(&dir)
|
||||
Searcher::create(&dir, tokenizers)
|
||||
}
|
||||
.unwrap()
|
||||
}
|
||||
@@ -100,27 +103,27 @@ pub(crate) mod tests {
|
||||
fn open() {
|
||||
let dir = temp_dir().join(format!("plume-test-{}", random_hex()));
|
||||
{
|
||||
Searcher::create(&dir).unwrap();
|
||||
Searcher::create(&dir, &CONFIG.search_tokenizers).unwrap();
|
||||
}
|
||||
Searcher::open(&dir).unwrap();
|
||||
Searcher::open(&dir, &CONFIG.search_tokenizers).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create() {
|
||||
let dir = temp_dir().join(format!("plume-test-{}", random_hex()));
|
||||
|
||||
assert!(Searcher::open(&dir).is_err());
|
||||
assert!(Searcher::open(&dir, &CONFIG.search_tokenizers).is_err());
|
||||
{
|
||||
Searcher::create(&dir).unwrap();
|
||||
Searcher::create(&dir, &CONFIG.search_tokenizers).unwrap();
|
||||
}
|
||||
Searcher::open(&dir).unwrap(); //verify it's well created
|
||||
Searcher::open(&dir, &CONFIG.search_tokenizers).unwrap(); //verify it's well created
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn search() {
|
||||
let conn = &db();
|
||||
conn.test_transaction::<_, (), _>(|| {
|
||||
let searcher = get_searcher();
|
||||
let searcher = get_searcher(&CONFIG.search_tokenizers);
|
||||
let blog = &fill_database(conn).1[0];
|
||||
let author = &blog.list_authors(conn).unwrap()[0];
|
||||
|
||||
@@ -180,10 +183,69 @@ pub(crate) mod tests {
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(feature = "search-lindera")]
|
||||
#[test]
|
||||
fn search_japanese() {
|
||||
let conn = &db();
|
||||
conn.test_transaction::<_, (), _>(|| {
|
||||
let tokenizers = SearchTokenizerConfig {
|
||||
tag_tokenizer: TokenizerKind::Lindera,
|
||||
content_tokenizer: TokenizerKind::Lindera,
|
||||
property_tokenizer: TokenizerKind::Ngram,
|
||||
};
|
||||
let searcher = get_searcher(&tokenizers);
|
||||
let blog = &fill_database(conn).1[0];
|
||||
|
||||
let title = random_hex()[..8].to_owned();
|
||||
|
||||
let post = Post::insert(
|
||||
conn,
|
||||
NewPost {
|
||||
blog_id: blog.id,
|
||||
slug: title.clone(),
|
||||
title: title.clone(),
|
||||
content: SafeString::new("ブログエンジンPlumeです。"),
|
||||
published: true,
|
||||
license: "CC-BY-SA".to_owned(),
|
||||
ap_url: "".to_owned(),
|
||||
creation_date: None,
|
||||
subtitle: "".to_owned(),
|
||||
source: "".to_owned(),
|
||||
cover_id: None,
|
||||
},
|
||||
&searcher,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
searcher.commit();
|
||||
|
||||
assert_eq!(
|
||||
searcher.search_document(conn, Query::from_str("ブログエンジン").unwrap(), (0, 1))
|
||||
[0]
|
||||
.id,
|
||||
post.id
|
||||
);
|
||||
assert_eq!(
|
||||
searcher.search_document(conn, Query::from_str("Plume").unwrap(), (0, 1))[0].id,
|
||||
post.id
|
||||
);
|
||||
assert_eq!(
|
||||
searcher.search_document(conn, Query::from_str("です").unwrap(), (0, 1))[0].id,
|
||||
post.id
|
||||
);
|
||||
assert_eq!(
|
||||
searcher.search_document(conn, Query::from_str("。").unwrap(), (0, 1))[0].id,
|
||||
post.id
|
||||
);
|
||||
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn drop_writer() {
|
||||
let searcher = get_searcher();
|
||||
let searcher = get_searcher(&CONFIG.search_tokenizers);
|
||||
searcher.drop_writer();
|
||||
get_searcher();
|
||||
get_searcher(&CONFIG.search_tokenizers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
use crate::{
|
||||
instance::Instance,
|
||||
posts::Post,
|
||||
schema::posts,
|
||||
search::{query::PlumeQuery, tokenizer},
|
||||
tags::Tag,
|
||||
Connection, Result,
|
||||
config::SearchTokenizerConfig, instance::Instance, posts::Post, schema::posts,
|
||||
search::query::PlumeQuery, tags::Tag, Connection, Result,
|
||||
};
|
||||
use chrono::Datelike;
|
||||
use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
use itertools::Itertools;
|
||||
use std::{cmp, fs::create_dir_all, path::Path, sync::Mutex};
|
||||
use tantivy::{
|
||||
collector::TopDocs, directory::MmapDirectory, schema::*, tokenizer::*, Index, IndexReader,
|
||||
IndexWriter, ReloadPolicy, Term,
|
||||
collector::TopDocs, directory::MmapDirectory, schema::*, Index, IndexReader, IndexWriter,
|
||||
ReloadPolicy, Term,
|
||||
};
|
||||
use whatlang::{detect as detect_lang, Lang};
|
||||
|
||||
@@ -34,7 +30,7 @@ impl Searcher {
|
||||
pub fn schema() -> Schema {
|
||||
let tag_indexing = TextOptions::default().set_indexing_options(
|
||||
TextFieldIndexing::default()
|
||||
.set_tokenizer("whitespace_tokenizer")
|
||||
.set_tokenizer("tag_tokenizer")
|
||||
.set_index_option(IndexRecordOption::Basic),
|
||||
);
|
||||
|
||||
@@ -70,15 +66,7 @@ impl Searcher {
|
||||
schema_builder.build()
|
||||
}
|
||||
|
||||
pub fn create(path: &dyn AsRef<Path>) -> Result<Self> {
|
||||
let whitespace_tokenizer = tokenizer::WhitespaceTokenizer.filter(LowerCaser);
|
||||
|
||||
let content_tokenizer = SimpleTokenizer
|
||||
.filter(RemoveLongFilter::limit(40))
|
||||
.filter(LowerCaser);
|
||||
|
||||
let property_tokenizer = NgramTokenizer::new(2, 8, false).filter(LowerCaser);
|
||||
|
||||
pub fn create(path: &dyn AsRef<Path>, tokenizers: &SearchTokenizerConfig) -> Result<Self> {
|
||||
let schema = Self::schema();
|
||||
|
||||
create_dir_all(path).map_err(|_| SearcherError::IndexCreationError)?;
|
||||
@@ -90,9 +78,9 @@ impl Searcher {
|
||||
|
||||
{
|
||||
let tokenizer_manager = index.tokenizers();
|
||||
tokenizer_manager.register("whitespace_tokenizer", whitespace_tokenizer);
|
||||
tokenizer_manager.register("content_tokenizer", content_tokenizer);
|
||||
tokenizer_manager.register("property_tokenizer", property_tokenizer);
|
||||
tokenizer_manager.register("tag_tokenizer", tokenizers.tag_tokenizer);
|
||||
tokenizer_manager.register("content_tokenizer", tokenizers.content_tokenizer);
|
||||
tokenizer_manager.register("property_tokenizer", tokenizers.property_tokenizer);
|
||||
} //to please the borrow checker
|
||||
Ok(Self {
|
||||
writer: Mutex::new(Some(
|
||||
@@ -109,31 +97,38 @@ impl Searcher {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn open(path: &dyn AsRef<Path>) -> Result<Self> {
|
||||
let whitespace_tokenizer = tokenizer::WhitespaceTokenizer.filter(LowerCaser);
|
||||
|
||||
let content_tokenizer = SimpleTokenizer
|
||||
.filter(RemoveLongFilter::limit(40))
|
||||
.filter(LowerCaser);
|
||||
|
||||
let property_tokenizer = NgramTokenizer::new(2, 8, false).filter(LowerCaser);
|
||||
|
||||
let index =
|
||||
pub fn open(path: &dyn AsRef<Path>, tokenizers: &SearchTokenizerConfig) -> Result<Self> {
|
||||
let mut index =
|
||||
Index::open(MmapDirectory::open(path).map_err(|_| SearcherError::IndexOpeningError)?)
|
||||
.map_err(|_| SearcherError::IndexOpeningError)?;
|
||||
|
||||
{
|
||||
let tokenizer_manager = index.tokenizers();
|
||||
tokenizer_manager.register("whitespace_tokenizer", whitespace_tokenizer);
|
||||
tokenizer_manager.register("content_tokenizer", content_tokenizer);
|
||||
tokenizer_manager.register("property_tokenizer", property_tokenizer);
|
||||
tokenizer_manager.register("tag_tokenizer", tokenizers.tag_tokenizer);
|
||||
tokenizer_manager.register("content_tokenizer", tokenizers.content_tokenizer);
|
||||
tokenizer_manager.register("property_tokenizer", tokenizers.property_tokenizer);
|
||||
} //to please the borrow checker
|
||||
let mut writer = index
|
||||
let writer = index
|
||||
.writer(50_000_000)
|
||||
.map_err(|_| SearcherError::WriteLockAcquisitionError)?;
|
||||
writer
|
||||
.garbage_collect_files()
|
||||
|
||||
// Since Tantivy v0.12.0, IndexWriter::garbage_collect_files() returns Future.
|
||||
// To avoid conflict with Plume async project, we don't introduce async now.
|
||||
// After async is introduced to Plume, we can use garbage_collect_files() again.
|
||||
// Algorithm stolen from Tantivy's SegmentUpdater::list_files()
|
||||
use std::collections::HashSet;
|
||||
use std::path::PathBuf;
|
||||
let mut files: HashSet<PathBuf> = index
|
||||
.list_all_segment_metas()
|
||||
.into_iter()
|
||||
.flat_map(|segment_meta| segment_meta.list_files())
|
||||
.collect();
|
||||
files.insert(Path::new("meta.json").to_path_buf());
|
||||
index
|
||||
.directory_mut()
|
||||
.garbage_collect(|| files)
|
||||
.map_err(|_| SearcherError::IndexEditionError)?;
|
||||
|
||||
Ok(Self {
|
||||
writer: Mutex::new(Some(writer)),
|
||||
reader: index
|
||||
|
||||
@@ -1,5 +1,34 @@
|
||||
#[cfg(feature = "search-lindera")]
|
||||
use lindera_tantivy::tokenizer::LinderaTokenizer;
|
||||
use std::str::CharIndices;
|
||||
use tantivy::tokenizer::{Token, TokenStream, Tokenizer};
|
||||
use tantivy::tokenizer::*;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum TokenizerKind {
|
||||
Simple,
|
||||
Ngram,
|
||||
Whitespace,
|
||||
#[cfg(feature = "search-lindera")]
|
||||
Lindera,
|
||||
}
|
||||
|
||||
impl From<TokenizerKind> for TextAnalyzer {
|
||||
fn from(tokenizer: TokenizerKind) -> TextAnalyzer {
|
||||
use TokenizerKind::*;
|
||||
|
||||
match tokenizer {
|
||||
Simple => TextAnalyzer::from(SimpleTokenizer)
|
||||
.filter(RemoveLongFilter::limit(40))
|
||||
.filter(LowerCaser),
|
||||
Ngram => TextAnalyzer::from(NgramTokenizer::new(2, 8, false)).filter(LowerCaser),
|
||||
Whitespace => TextAnalyzer::from(WhitespaceTokenizer).filter(LowerCaser),
|
||||
#[cfg(feature = "search-lindera")]
|
||||
Lindera => {
|
||||
TextAnalyzer::from(LinderaTokenizer::new("decompose", "")).filter(LowerCaser)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Tokenize the text by splitting on whitespaces. Pretty much a copy of Tantivy's SimpleTokenizer,
|
||||
/// but not splitting on punctuation
|
||||
@@ -12,15 +41,13 @@ pub struct WhitespaceTokenStream<'a> {
|
||||
token: Token,
|
||||
}
|
||||
|
||||
impl<'a> Tokenizer<'a> for WhitespaceTokenizer {
|
||||
type TokenStreamImpl = WhitespaceTokenStream<'a>;
|
||||
|
||||
fn token_stream(&self, text: &'a str) -> Self::TokenStreamImpl {
|
||||
WhitespaceTokenStream {
|
||||
impl Tokenizer for WhitespaceTokenizer {
|
||||
fn token_stream<'a>(&self, text: &'a str) -> BoxTokenStream<'a> {
|
||||
BoxTokenStream::from(WhitespaceTokenStream {
|
||||
text,
|
||||
chars: text.char_indices(),
|
||||
token: Token::default(),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
impl<'a> WhitespaceTokenStream<'a> {
|
||||
|
||||
@@ -406,8 +406,8 @@ impl Bool {
|
||||
}
|
||||
}
|
||||
Bool::HasCover => Ok(post.cover_id.is_some()),
|
||||
Bool::Local => Ok(post.get_blog(&rocket.conn)?.is_local()),
|
||||
Bool::All => Ok(true),
|
||||
Bool::Local => Ok(post.get_blog(&rocket.conn)?.is_local() && kind == Kind::Original),
|
||||
Bool::All => Ok(kind == Kind::Original),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1026,6 +1026,7 @@ impl NewUser {
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
config::CONFIG,
|
||||
instance::{tests as instance_tests, Instance},
|
||||
search::tests::get_searcher,
|
||||
tests::{db, rockets},
|
||||
@@ -1122,7 +1123,9 @@ pub(crate) mod tests {
|
||||
let inserted = fill_database(conn);
|
||||
|
||||
assert!(User::get(conn, inserted[0].id).is_ok());
|
||||
inserted[0].delete(conn, &get_searcher()).unwrap();
|
||||
inserted[0]
|
||||
.delete(conn, &get_searcher(&CONFIG.search_tokenizers))
|
||||
.unwrap();
|
||||
assert!(User::get(conn, inserted[0].id).is_err());
|
||||
Ok(())
|
||||
});
|
||||
|
||||
@@ -13,10 +13,12 @@ class Browser(unittest.TestCase):
|
||||
raise Exception("No browser was requested")
|
||||
capabilities['acceptSslCerts'] = True
|
||||
self.driver = webdriver.Remote(
|
||||
command_executor='http://localhost:24444/wd/hub',
|
||||
# The "selenium" address is set up by Drone CI and "points" to the container running selenium
|
||||
command_executor='http://selenium:24444/wd/hub',
|
||||
desired_capabilities=capabilities)
|
||||
def tearDown(self):
|
||||
self.driver.close()
|
||||
|
||||
def get(self, url):
|
||||
# Like "selenium", integration is mapped to the container that runs the plume instance
|
||||
return self.driver.get("https://localhost" + url)
|
||||
|
||||
@@ -12,7 +12,7 @@ plm users new -n admin -N 'Admin' -e 'email@exemple.com' -p 'password'
|
||||
plume &
|
||||
caddy -conf /Caddyfile &
|
||||
|
||||
until curl http://localhost:7878/test/health -f; do sleep 1; done 2>/dev/null >/dev/null
|
||||
until curl http://localhost:7878/test/health -f; do sleep 1; done #2>/dev/null >/dev/null
|
||||
|
||||
cd $(dirname $0)/browser_test/
|
||||
python3 -m unittest *.py
|
||||
|
||||
+3
-4
@@ -6,8 +6,6 @@ extern crate gettext_macros;
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
#[macro_use]
|
||||
extern crate runtime_fmt;
|
||||
#[macro_use]
|
||||
extern crate serde_json;
|
||||
#[macro_use]
|
||||
extern crate validator_derive;
|
||||
@@ -28,7 +26,8 @@ use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
|
||||
init_i18n!(
|
||||
"plume", ar, bg, ca, cs, de, en, eo, es, fr, gl, hi, hr, it, ja, nb, pl, pt, ro, ru, sr, sk, sv
|
||||
"plume", ar, bg, ca, cs, de, en, eo, es, fa, fr, gl, hi, hr, it, ja, nb, pl, pt, ro, ru, sr,
|
||||
sk, sv
|
||||
);
|
||||
|
||||
mod api;
|
||||
@@ -100,7 +99,7 @@ Then try to restart Plume.
|
||||
let workpool = ScheduledThreadPool::with_name("worker {}", num_cpus::get());
|
||||
// we want a fast exit here, so
|
||||
#[allow(clippy::match_wild_err_arm)]
|
||||
let searcher = match UnmanagedSearcher::open(&CONFIG.search_index) {
|
||||
let searcher = match UnmanagedSearcher::open(&CONFIG.search_index, &CONFIG.search_tokenizers) {
|
||||
Err(Error::Search(e)) => match e {
|
||||
SearcherError::WriteLockAcquisitionError => panic!(
|
||||
r#"
|
||||
|
||||
+1
-1
@@ -643,7 +643,7 @@ pub fn remote_interact_post(
|
||||
.and_then(|blog| Post::find_by_slug(&rockets.conn, &slug, blog.id))?;
|
||||
if let Some(uri) = User::fetch_remote_interact_uri(&remote.remote)
|
||||
.ok()
|
||||
.and_then(|uri| rt_format!(uri, uri = target.ap_url).ok())
|
||||
.map(|uri| uri.replace("{uri}", &target.ap_url))
|
||||
{
|
||||
Ok(Redirect::to(uri).into())
|
||||
} else {
|
||||
|
||||
+5
-6
@@ -201,15 +201,14 @@ pub fn follow_not_connected(
|
||||
if let Some(uri) = User::fetch_remote_interact_uri(&remote_form)
|
||||
.ok()
|
||||
.and_then(|uri| {
|
||||
rt_format!(
|
||||
uri,
|
||||
uri = format!(
|
||||
Some(uri.replace(
|
||||
"{uri}",
|
||||
&format!(
|
||||
"{}@{}",
|
||||
target.fqn,
|
||||
target.get_instance(&rockets.conn).ok()?.public_domain
|
||||
)
|
||||
)
|
||||
.ok()
|
||||
),
|
||||
))
|
||||
})
|
||||
{
|
||||
Ok(Redirect::to(uri).into())
|
||||
|
||||
Reference in New Issue
Block a user