Compare commits

...

386 Commits

Author SHA1 Message Date
Kitaiti Makoto 3cb6f86ea2 Install remove-dup-image into Docker image 2021-03-29 00:34:30 +09:00
Kitaiti Makoto e0f91f7481 Add remove-dup-images command 2021-03-28 20:54:53 +09:00
Kitaiti Makoto 58324945cc Add migration to add index to medias.file_path for SQLite3 2021-03-28 17:34:41 +09:00
KitaitiMakoto 16953ea907 Merge pull request 'Upsert posts and media when fetching remote posts' (#912) from upsert into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/912
2021-03-27 19:27:59 +00:00
Kitaiti Makoto d3c2dc8286 Add changelog on upsert 2021-03-28 04:27:06 +09:00
Kitaiti Makoto ebb0b45299 Create blog_authors only when needed 2021-03-28 04:26:17 +09:00
Kitaiti Makoto 702aa11ecf Don't drop path components of image URI 2021-03-28 04:26:17 +09:00
Kitaiti Makoto 33221d386e Upsert Post in from_activity() 2021-03-28 04:26:17 +09:00
Kitaiti Makoto 589c159eb9 Call Post::publish_updated() only for local posts 2021-03-28 04:26:17 +09:00
Kitaiti Makoto ea1f4d48d5 Upsert Media in from_activity() 2021-03-28 04:26:17 +09:00
Kitaiti Makoto 462c5a1d42 Define Media::find_by_file_path() 2021-03-28 04:26:17 +09:00
Kitaiti Makoto f90d7ddee3 Add SQL to add/drop index to/from medias.file_path 2021-03-28 04:26:17 +09:00
Kitaiti Makoto 175055cf9d Add migration to add index to medias.file_path
% diesel migration generate medias_index_file_path
2021-03-28 04:26:17 +09:00
KitaitiMakoto fe92d95f6c Merge pull request 'Make actors subscribe to channel once' (#913) from remote-fetch-once into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/913
2021-03-27 19:25:22 +00:00
Kitaiti Makoto 8e50d95a7a Fix code according to clippy 2021-03-28 03:46:37 +09:00
Kitaiti Makoto 9ed36b2aa3 Add changelog on actor subscription fix 2021-03-28 03:12:20 +09:00
Kitaiti Makoto 722165a734 Upgrade lexical-core crate 2021-03-28 01:39:41 +09:00
Kitaiti Makoto 74f99e2588 Upgrade Rust version 2021-03-28 01:39:26 +09:00
Kitaiti Makoto 77c08845b5 [BUG FIX]Make SearchActor subscribe to channel once 2021-03-27 23:55:26 +09:00
Kitaiti Makoto 2bfc26faf2 [BUG FIX]Make RemoveFetchActor subscribe to channel once 2021-03-27 23:54:09 +09:00
KitaitiMakoto c26f2623a8 Merge pull request 'Fix #905 Prevent remote image duplication' (#907) from dup-remote-image into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/907
2021-02-18 06:10:27 +00:00
Kitaiti Makoto 451c3b5c88 Add TODO comments 2021-02-18 11:35:39 +09:00
Kitaiti Makoto af5674074d Revert "Save remote post only when it doesn't exist on local"
This reverts commit 37cbf537bb.
2021-02-18 11:34:20 +09:00
Kitaiti Makoto 28380021a7 Determine file path of mirror of remote image using the URI 2021-02-18 01:23:57 +09:00
Kitaiti Makoto 37cbf537bb Save remote post only when it doesn't exist on local 2021-02-16 23:48:09 +09:00
KitaitiMakoto 9345a1b7a9 Merge pull request 'Make images in post card links' (#900) from image-link into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/900
2021-02-15 01:42:21 +00:00
Kitaiti Makoto d18f1d6d1d Indicate images in post card clickable 2021-02-15 10:17:41 +09:00
Kitaiti Makoto 621258481d Make images in post card link 2021-02-15 10:17:22 +09:00
KitaitiMakoto ce285bac17 Merge pull request 'Make links in menu work on iOS' (#899) from menu into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/899
2021-02-14 15:02:03 +00:00
KitaitiMakoto a7e45bee11 Merge pull request 'Make it possible to open menu on iOS mobile devices' (#897) from menu into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/897
2021-02-14 14:56:55 +00:00
KitaitiMakoto 73e075e216 Merge pull request 'Fix #890 Fix interact URI used from remote account to remote account' (#898) from remote-follow-from-remote into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/898
2021-02-14 14:40:25 +00:00
Kitaiti Makoto b7c7b6da9f Percent encode remote interact URI 2021-02-14 22:59:01 +09:00
Kitaiti Makoto 703328601c [BUG FIX] Don't append host part twice to remote interact URI 2021-02-14 22:15:32 +09:00
Kitaiti Makoto b2e7664339 Extract User::acct_authority() method 2021-02-14 22:14:44 +09:00
Kitaiti Makoto ed22c6b103 Make links in menu work on iOS 2021-02-13 23:40:18 +09:00
Kitaiti Makoto 94ccbd6190 Move Rust flag for plume-front to .cargo/config.toml from env var 2021-02-13 22:53:20 +09:00
Kitaiti Makoto 77edc4849f Add current pull request to changelog 2021-02-13 22:23:03 +09:00
Kitaiti Makoto 07da97f434 Revert "Remove unused diesel_cli from Docker env image"
This reverts commit 056d68804a.
2021-02-13 19:36:57 +09:00
Kitaiti Makoto 89dd6be7dd Fix design 2021-02-12 19:28:45 +09:00
Kitaiti Makoto 60c1a4264e Fix indentation 2021-02-12 19:21:36 +09:00
Kitaiti Makoto c4c177c530 Remove unnecessary CSS properties 2021-02-12 19:21:02 +09:00
Kitaiti Makoto 4a5bffbd57 Update base Docker image for buildenv 2021-02-12 19:10:54 +09:00
Kitaiti Makoto 49b2296015 Revert "Install rustfmt and cargo-clippy explicitly in dev env"
This reverts commit 347bc653d8.
2021-02-12 19:08:33 +09:00
Kitaiti Makoto 0ef4a06565 Revert "Install zip package in Docker dev image"
This reverts commit b55c2ff2f0.
2021-02-12 19:07:26 +09:00
Kitaiti Makoto 16b1337d67 Add WAI-ARIA attributes to menu 2021-02-12 18:54:42 +09:00
Kitaiti Makoto 6599179174 Use document() function 2021-02-12 18:48:33 +09:00
Kitaiti Makoto f2411f4607 Use a element instead of nav to capture touchend event 2021-02-12 18:26:05 +09:00
Kitaiti Makoto 2c3d429b8e Suppress Clippy 2021-02-12 18:20:48 +09:00
Kitaiti Makoto 7562cf1e75 Open menu even when focus-within code doesn't work 2021-02-12 18:18:45 +09:00
Kitaiti Makoto de1c3f3245 Move document() from plume_front::editor to plume_front 2021-02-12 18:12:38 +09:00
Kitaiti Makoto 5d38c3ad70 Fix file name 2021-02-12 18:11:49 +09:00
Kitaiti Makoto b55c2ff2f0 Install zip package in Docker dev image 2021-02-12 14:38:15 +09:00
Kitaiti Makoto 056d68804a Remove unused diesel_cli from Docker env image 2021-02-12 14:35:06 +09:00
Kitaiti Makoto 347bc653d8 Install rustfmt and cargo-clippy explicitly in dev env 2021-02-12 14:34:32 +09:00
Kitaiti Makoto 6fcece3bc0 Follow file name change 2021-02-12 13:31:22 +09:00
Kitaiti Makoto e119c5bde9 Update Docker image for testing 2021-02-12 13:10:32 +09:00
Kitaiti Makoto 1bc2749e1b Return when required element is not present 2021-02-12 05:00:42 +09:00
Kitaiti Makoto 58bb07d11d Remove unused stdweb crate from dependencies 2021-02-12 05:00:42 +09:00
Kitaiti Makoto affe24b9c6 Replace cargo-web with wasm-pack on build environment 2021-02-12 05:00:34 +09:00
Kitaiti Makoto 0bcf063b05 Remove old plume_front::main 2021-02-12 03:20:33 +09:00
Kitaiti Makoto 24ecb15119 Remplement plume_front::editor using web-sys 2021-02-12 03:19:46 +09:00
Kitaiti Makoto 208c515d70 Remove prefix 'web_sys' 2021-02-11 01:24:41 +09:00
Kitaiti Makoto d0ada7fc53 Reimplement search() in web-sys 2021-02-11 01:19:42 +09:00
Kitaiti Makoto d86bd898cb Prepare JavaScript on build process 2021-02-11 01:19:32 +09:00
Kitaiti Makoto db581a955b Reimplement menu() in web-sys 2021-02-10 23:51:09 +09:00
Kitaiti Makoto 0b8b1bf25f Load new JavaScript file 2021-02-10 23:50:41 +09:00
Kitaiti Makoto faab5f6b3b Make plume-front's type cdylib 2021-02-10 21:53:59 +09:00
Kitaiti Makoto 6387a1334b Add wasm-bindgen to plume-front's dependencies 2021-02-10 21:51:57 +09:00
KitaitiMakoto 10be055381 Merge pull request 'Fix #892 Build client for every inbox in broadcast()' (#895) from broadcast-timeout into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/895
2021-02-09 13:56:16 +00:00
Kitaiti Makoto 24c9c7b5a1 Build client for every inbox in broadcast() 2021-02-09 18:15:14 +09:00
KitaitiMakoto ac48744aca Merge pull request 'Fix #872 Include (request-target) and Host header to HTTP Signature' (#884) from httpsig into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/884
2021-02-06 19:19:36 +00:00
KitaitiMakoto f2d2ecb247 Merge pull request 'Raise jobs on CI' (#893) from ci-jobs into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/893
2021-02-06 19:18:21 +00:00
Kitaiti Makoto 1d46bf8d50 Reduce start jobs on CI 2021-02-07 03:28:07 +09:00
Kitaiti Makoto 4353f2a92d raise jobs on CI 2021-02-07 03:13:38 +09:00
Kitaiti Makoto 1b9aeae53c Add test for signagure() 2021-02-05 10:34:33 +09:00
Kitaiti Makoto 540b9af873 Add changelog about (request-target) 2021-02-04 22:14:25 +09:00
Kitaiti Makoto d08d2c6958 Care the case of invalid header value 2021-02-04 17:10:05 +09:00
Kitaiti Makoto 348259a14b Care about error case 2021-02-04 15:31:57 +09:00
KitaitiMakoto e68ca1151d Merge pull request 'Close #888 Extract DbConn from PlumeRocket' (#889) from extract-dbconn into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/889
2021-01-31 17:32:46 +00:00
Kitaiti Makoto 3c15f5a82f Merge branch 'main' into extract-dbconn 2021-02-01 02:31:45 +09:00
Kitaiti Makoto 5ba823990a Don't panic in loop 2021-02-01 01:36:36 +09:00
Kitaiti Makoto c82c38fe52 Comment on database connections 2021-02-01 01:16:52 +09:00
Kitaiti Makoto e7ab80d5c8 Move worker tasks in routes::user::details to RemoteFetchActor 2021-02-01 00:51:37 +09:00
Kitaiti Makoto 61b68c3a42 Initialize RemoteFetchActor 2021-02-01 00:50:48 +09:00
Kitaiti Makoto 6401cb6fb7 Define User::remote_user_found() and publish_remote_user_found() 2021-02-01 00:48:22 +09:00
Kitaiti Makoto 9d37408535 Define RemoteFetchActor 2021-01-31 22:56:17 +09:00
Kitaiti Makoto ded64e1cf0 Add USER_CHAN 2021-01-31 22:55:52 +09:00
Kitaiti Makoto 3b766fc427 Define UserEvent 2021-01-31 22:55:28 +09:00
Kitaiti Makoto ad285898f6 Replace PlumeRocket.conn with DbConn 2021-01-31 21:58:44 +09:00
Kitaiti Makoto 78be49d57d Make tests follow API changes 2021-01-31 21:58:44 +09:00
Kitaiti Makoto 25e52788c5 Replace PlumeRocket with DbConn where possible 2021-01-31 21:58:09 +09:00
Kitaiti Makoto 5d25a64f13 Remove DbConn from PlumeRocket 2021-01-31 21:58:09 +09:00
Kitaiti Makoto 0dc89fbf23 Set default log level to warn 2021-01-31 21:58:03 +09:00
KitaitiMakoto 94ed0eec2a Merge pull request 'Set default log level to warn' (#886) from loglevel-warn into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/886
2021-01-25 07:40:09 +00:00
Kitaiti Makoto d70e585b64 Set default log level to warn 2021-01-25 16:39:25 +09:00
KitaitiMakoto 8f55e50c6e Merge pull request 'Add default log level in .env.sample' (#885) from loglevel into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/885
2021-01-25 01:43:19 +00:00
Kitaiti Makoto c113c99e1d Add default log level in .env.sample 2021-01-25 09:41:40 +09:00
Kitaiti Makoto 191239584b Define RequestTarget 2021-01-25 02:16:53 +09:00
Kitaiti Makoto bd1caaf5da Include (request-target) and Host header to HTTP Signature 2021-01-25 02:16:53 +09:00
KitaitiMakoto 76f7b5e7ac Merge pull request 'Add shortcut links to edit page' (#883) from shortcut-links into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/883
2021-01-24 17:16:11 +00:00
Kitaiti Makoto afe449b951 Set ROCKET_SECRET_KEY on CI 2021-01-25 01:25:37 +09:00
Kitaiti Makoto 29f0712ea1 Init search index on CI 2021-01-25 00:46:26 +09:00
Kitaiti Makoto d091c24f79 Specify cpu count to build plume-cli 2021-01-25 00:27:45 +09:00
Kitaiti Makoto f9e7d2bb23 Remove all instances before testing 2021-01-25 00:06:40 +09:00
Kitaiti Makoto dbf36ddf05 Cache fetched instance 2021-01-25 00:06:40 +09:00
Kitaiti Makoto 8b00853e88 Make instance for search actor remote 2021-01-25 00:06:35 +09:00
Kitaiti Makoto 84a3d53075 Use uri! macro to generate URI strings 2021-01-24 23:30:24 +09:00
Kitaiti Makoto 7967dd91c2 Remove needless option; duplicated to env var 2021-01-24 23:30:24 +09:00
Kitaiti Makoto b5eb2628f9 Don't remove records after testing 2021-01-24 23:30:20 +09:00
Kitaiti Makoto 4ef6561cc6 Extract login() from test function 2021-01-24 21:38:51 +09:00
Kitaiti Makoto 7f54f418a8 Suppress clippy 2021-01-24 19:49:49 +09:00
Kitaiti Makoto 8f90ea18bf Add tests for edit link presence 2021-01-24 19:37:49 +09:00
Kitaiti Makoto e12528aae4 Extract launch_rocket() from main() as public within crate scope 2021-01-24 19:28:05 +09:00
Kitaiti Makoto 042a1fd2b0 Use Post::get_blog_fqn() in post_card template 2021-01-20 10:39:11 +09:00
Kitaiti Makoto be99fe5f99 Implement Post::get_blog_fqn() 2021-01-20 10:38:32 +09:00
Kitaiti Makoto 4a212e5f9e Use soft tabs instead of hard tabs in SCSS files 2021-01-17 23:14:46 +09:00
Kitaiti Makoto c253bdee54 Show edit link in post cards 2021-01-17 23:14:46 +09:00
KitaitiMakoto 46fc030df4 Merge pull request 'Search Actor' (#870) from search-actor into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/870
2021-01-17 14:13:54 +00:00
Kitaiti Makoto 02277b1ace Specify features on running migration on CI 2021-01-16 17:38:35 +09:00
Kitaiti Makoto ac507d1d42 Fix CI command 2021-01-16 16:50:57 +09:00
Kitaiti Makoto 5148349098 Add changlog about actor and searcher 2021-01-16 16:44:39 +09:00
Kitaiti Makoto e817941cc5 Update pot 2021-01-16 16:44:20 +09:00
Kitaiti Makoto 06962514fe Run database migration on CI 2021-01-16 16:39:12 +09:00
Kitaiti Makoto c3c8f6804b Remove transaction from test search::tests::search for CI 2021-01-16 16:39:12 +09:00
Kitaiti Makoto 6dd730030d Wrap Post in PostEvent with Arc
See https://github.com/riker-rs/riker/issues/153
2021-01-16 16:39:12 +09:00
Kitaiti Makoto 6c1dd6608d Add test for search actor 2021-01-16 16:39:12 +09:00
Kitaiti Makoto 42fb0cf825 Use pattern match instead of unwrap() 2021-01-16 16:39:12 +09:00
Kitaiti Makoto 2483303138 SearchActor waits for transaction commit 2021-01-16 16:39:12 +09:00
Kitaiti Makoto 47e67d9b64 Add methods to clear data of instances and users table for testing 2021-01-16 16:39:12 +09:00
Kitaiti Makoto 1d042e1bb2 Add methods to clear data of instances and users table for testing 2021-01-16 16:39:12 +09:00
Kitaiti Makoto 31418b1079 Fix search::tests::search to use searcher directly instead of actor 2021-01-16 16:39:12 +09:00
Kitaiti Makoto 68d79bfa9c Publish PostUpdated only when the post is published 2021-01-16 16:39:12 +09:00
Kitaiti Makoto a46b718937 Ignore search::tests::search 2021-01-16 16:39:12 +09:00
Kitaiti Makoto 5570494a37 Update pot 2021-01-16 16:39:12 +09:00
Kitaiti Makoto a0cd9dd6bd Fix tests to follow API changes 2021-01-16 16:39:12 +09:00
Kitaiti Makoto cd5895d560 Update pot 2021-01-16 16:39:11 +09:00
Kitaiti Makoto fc8ee1c3bc Remove searcher from arguments of Post::delete() and dependented methods 2021-01-16 16:38:18 +09:00
Kitaiti Makoto 2a8cc5f3ba Send event to channel when post deleted 2021-01-16 16:36:14 +09:00
Kitaiti Makoto 82524c9dca Update pot 2021-01-16 16:35:27 +09:00
Kitaiti Makoto 864379fb81 Remove searcher from arguments of Post::update() 2021-01-16 16:34:36 +09:00
Kitaiti Makoto aae2073146 Send event to channel when post updated 2021-01-16 16:33:29 +09:00
Kitaiti Makoto 69963689f9 Update pot 2021-01-16 16:33:29 +09:00
Kitaiti Makoto 6ad3359609 Remove searcher from arguments of Post::insert() 2021-01-16 16:25:36 +09:00
Kitaiti Makoto 6a2ba2260d Send event to channel when post published 2021-01-16 16:25:36 +09:00
Kitaiti Makoto ccbf2124cb Run cargo fmt 2021-01-16 16:22:39 +09:00
Kitaiti Makoto a733ece26e Suppress clippy 2021-01-16 16:22:39 +09:00
Kitaiti Makoto 16624fd742 Run cargo fmt 2021-01-16 16:22:39 +09:00
Kitaiti Makoto e18be6ec95 Initialize SearchActor at start 2021-01-16 16:22:39 +09:00
Kitaiti Makoto 1bfed0294f Define SearchActor::init() 2021-01-16 16:22:39 +09:00
Kitaiti Makoto d4d32bcc11 Define ACTOR_SYS and POST_CHAN 2021-01-16 16:22:39 +09:00
Kitaiti Makoto 0a148721de Define SearchActor 2021-01-16 16:22:39 +09:00
Kitaiti Makoto cfe097edf4 Define PostEvent 2021-01-16 16:22:39 +09:00
Kitaiti Makoto 578768d7df Remove unnecessary attribute to suppress clippy 2021-01-16 16:22:39 +09:00
Kitaiti Makoto 996dc309f7 Make Searcher::open_or_create() accept path and tokenizers 2021-01-16 16:22:38 +09:00
Kitaiti Makoto 09d9164a1c Extract Searcher::open_or_recreate() from main() 2021-01-16 16:22:38 +09:00
Kitaiti Makoto 43f32d30cb Add once_cell to dependdencies 2021-01-16 16:22:38 +09:00
Kitaiti Makoto b1d7b3969d Add Riker to dependencies 2021-01-16 16:20:49 +09:00
KitaitiMakoto 89fa208bec Update CHANGELOG (#881)
Update CHANGELOG

Co-authored-by: Kitaiti Makoto <KitaitiMakoto@gmail.com>
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/881
2021-01-16 05:49:12 +00:00
KitaitiMakoto a11205324b Merge pull request 'Upgrade Tantivy to 0.13.3' (#878) from upgrade-tantivy into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/878
2021-01-16 05:40:14 +00:00
Kitaiti Makoto 7d17b12000 Upgrade lindera-tantivy to 0.7.1 2021-01-16 13:34:15 +09:00
Kitaiti Makoto 885dcf91fe Remove redundant imports 2021-01-16 12:53:05 +09:00
Kitaiti Makoto 192c0f8efd Remove unused lifetime 2021-01-16 12:21:49 +09:00
Kitaiti Makoto 35e71b0f8a Replace string range access with strip_prefix() 2021-01-16 12:20:21 +09:00
Kitaiti Makoto 1a24ba44b2 Remove redundant imports 2021-01-16 12:12:13 +09:00
Kitaiti Makoto 7c00d4a88a Remove no-landing-pads option from CI environment 2021-01-16 12:03:56 +09:00
Kitaiti Makoto 476310a217 Update plume.pot 2021-01-16 01:15:48 +09:00
Kitaiti Makoto 26ffde726f Run cargo fmt 2021-01-16 01:13:45 +09:00
Kitaiti Makoto 3fd89e6b48 Remove unnecessary wraps 2021-01-16 01:05:42 +09:00
Kitaiti Makoto be939cf169 Suppress clippy 2021-01-16 00:59:07 +09:00
Kitaiti Makoto 4a15bef34f Impl From<ListType> for i32 instead of Into<i32> for ListType 2021-01-16 00:49:34 +09:00
Kitaiti Makoto 6eee4b0b65 Define custom errors 2021-01-16 00:43:41 +09:00
Kitaiti Makoto f720dcbe9a Remove underscore prefix from route methods to suppress clippy 2021-01-15 23:58:48 +09:00
Kitaiti Makoto 33fceddc08 Use is_empty() instead of comparing with "" 2021-01-15 23:25:07 +09:00
Kitaiti Makoto dfe83aafc5 Replace as_ref().map() with as_deref() 2021-01-15 23:21:33 +09:00
Kitaiti Makoto 0775c8f3f9 Fix redundant method chains 2021-01-15 23:19:47 +09:00
Kitaiti Makoto 4cdc1a3655 Use char instead of one length &str 2021-01-15 23:01:37 +09:00
Kitaiti Makoto bbd415c392 Use strip_prefix() instead of range access 2021-01-15 23:00:15 +09:00
Kitaiti Makoto a236f33269 Remove unused macro_use 2021-01-15 22:38:40 +09:00
Kitaiti Makoto 9b593c76e4 Remove unused doc comments 2021-01-15 22:36:59 +09:00
Kitaiti Makoto 012c8d2026 Remove redundant imports 2021-01-15 22:35:19 +09:00
Kitaiti Makoto cb05571339 Upgrade tantivy to 0.13.3 2021-01-15 10:19:54 +09:00
Kitaiti Makoto 64e4550dea Update rust-toolchain to nightly-2021-01-15 2021-01-15 10:19:12 +09:00
KitaitiMakoto ec8c17482d Merge pull request 'proxy support' (#829) from dr-bonez/Plume:feature/proxy into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/829
Reviewed-by: KitaitiMakoto <kitaitimakoto@noreply@joinplu.me>
2021-01-13 14:20:36 +00:00
Aiden McClelland f167aad0fb fix doc tests 2021-01-11 13:29:01 -07:00
Aiden McClelland 24aac22b89 proxy support 2021-01-11 13:27:52 -07:00
KitaitiMakoto 615a5fe346 Merge pull request 'Update CHANGELOG' (#877) from changelog into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/877
2021-01-11 18:15:58 +00:00
Kitaiti Makoto a6699a7319 Add about translation languages to CHANGELOG 2021-01-12 03:12:59 +09:00
Kitaiti Makoto 0f408bc738 Update CHANGELOG 2021-01-12 03:11:29 +09:00
KitaitiMakoto 44a7953c20 Merge pull request 'GitHub 838: Fix menu animation not opening on iOS' (#876) from ios_nav_menu_animation_fixed-4 into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/876
2021-01-11 17:53:30 +00:00
Marek Ľach 21069ea18e Fix code formatting 2021-01-11 18:04:21 +01:00
Marek Ľach 1e1fd49c8c Update _header.scss 2021-01-11 17:48:39 +01:00
Marek Ľach 84621d1d27 Update _header.scss 2021-01-11 01:40:17 +01:00
Marek Ľach ba4476bf5a Update _header.scss 2021-01-11 01:34:09 +01:00
KITAITI Makoto f87bc455b7 Merge branch 'main' into ios_nav_menu_animation_fixed-4 2021-01-11 09:26:37 +09:00
KitaitiMakoto 76ec0d2b13 Merge pull request 'Initialize tracing subscriber' (#875) from init-tracing into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/875
2021-01-11 00:24:54 +00:00
Kitaiti Makoto 4d547082e0 Update pot 2021-01-11 09:15:45 +09:00
Kitaiti Makoto b9b9af6c44 Initialize tracing subscriber 2021-01-11 09:15:34 +09:00
Kitaiti Makoto 4a4534d6f3 Run cargo fmt 2021-01-11 09:05:31 +09:00
Kitaiti Makoto 894c4fee2c Add tracing-subscriber to dependencies 2021-01-11 09:05:28 +09:00
Kitaiti Makoto 27a33c833d Run cargo fmt 2021-01-11 08:38:41 +09:00
Marek Ľach b52d8e4e26 Fix menu animation not working on mobile iOS (also Midori) 2021-01-10 21:23:11 +01:00
Marek Ľach b059fb48fc Update _header.scss
The menu does not open on iOS Safari because of how it can't handle translateZ, and needs an -webkit specific prefix for the @keyframes property for the animation to work. This PR fixes the issue.
2021-01-10 18:32:21 +01:00
KitaitiMakoto f33b057961 Merge pull request 'Add SQlite journal files to .gitignore' (#874) from ignore-journal into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/874
2021-01-10 09:08:36 +00:00
Kitaiti Makoto 663ca4f530 Add SQlite journal files to .gitignore 2021-01-10 18:05:17 +09:00
KitaitiMakoto 5892c0b088 Merge pull request 'Remove SQLite journal files' (#873) from sqlite-journal into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/873
2021-01-10 06:31:14 +00:00
Kitaiti Makoto 044a24eac8 Remove SQLite journal files 2021-01-10 10:27:53 +09:00
Kitaiti Makoto b93ebedaf3 Revert "Initialize Rocket early to initialize logger early"
This reverts commit 30093d3a9f.
2021-01-09 18:41:47 +09:00
KitaitiMakoto 8539bdaf72 Merge pull request 'Fix #623 tracing crate' (#868) from logging into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/868

I read tracing's documentation and thought that is what I need. I decided use it instead of log crate. Thank you for info, igalic.
2021-01-06 13:38:48 +00:00
Kitaiti Makoto c1abd3d6f9 Use eprintln! instead of println! for console message 2021-01-06 21:40:14 +09:00
Kitaiti Makoto becb40544c Replace println!()s with logging macros 2021-01-06 21:40:14 +09:00
Kitaiti Makoto ee96d2b754 Fix a typo 2021-01-06 21:40:14 +09:00
Kitaiti Makoto 30093d3a9f Initialize Rocket early to initialize logger early 2021-01-06 21:40:14 +09:00
Kitaiti Makoto 29f2239e3f Extract dotenv initialization from init_pool because it affects not only database 2021-01-06 21:40:14 +09:00
Kitaiti Makoto 7f1b33a567 Add tracing crate to dependences 2021-01-06 21:40:07 +09:00
KitaitiMakoto d0dd23a1af Merge pull request 'Percent encode URI for remote_interact' (#866) from encode-remote-interact into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/866
2021-01-02 21:28:27 +00:00
Kitaiti Makoto f8774223d4 Update pot file 2021-01-03 05:51:38 +09:00
Kitaiti Makoto bca870f1f8 Percent encode URI for remote_interact 2021-01-03 05:49:45 +09:00
KitaitiMakoto 64d38c88e8 Merge pull request 'Add scripts to make prebuilt binaries' (#864) from prebuild-script into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/864
2021-01-02 16:46:02 +00:00
Kitaiti Makoto 3ac94b3e43 Add script to prebuild in Docker container 2021-01-02 23:51:09 +09:00
Kitaiti Makoto 254eef6a2a Add prebuild script 2021-01-02 23:48:30 +09:00
KitaitiMakoto f1255f477f Merge pull request 'Add translated languages to plume-front' (#863) from add-langs-front into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/863
2021-01-02 14:36:22 +00:00
Kitaiti Makoto 6c7b95c1b9 Add translated languages to plume-front 2021-01-02 23:29:46 +09:00
KitaitiMakoto e7d17caf9d Merge pull request 'Update crates' (#858) from update-crates into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/858
2021-01-02 14:23:45 +00:00
KitaitiMakoto 71dd80f125 Merge pull request 'Add translated languages' (#862) from add-langs into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/862
2021-01-02 14:21:25 +00:00
KitaitiMakoto ed4761e841 Merge pull request 'fix-test' (#861) from fix-test into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/861
2021-01-02 14:20:49 +00:00
Kitaiti Makoto fe05f9a58e cargo fmt 2021-01-02 22:54:46 +09:00
Kitaiti Makoto 51e5a401a5 Update Welsh translation 2021-01-02 22:45:04 +09:00
Kitaiti Makoto f1990b782d Fix tests 2021-01-02 22:15:26 +09:00
KitaitiMakoto 4e3ed0f4c1 Merge pull request 'add dir to allowed attributes' (#860) from dir-safestring into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/860
Reviewed-by: Mina Galić <me+git@igalic.co>
Reviewed-by: KitaitiMakoto <kitaitimakoto@noreply@joinplu.me>
2021-01-02 10:46:32 +00:00
Trinity Pointard fdb58215c0 add dir to allowed attributes 2021-01-02 00:26:56 +01:00
Kitaiti Makoto 47c8711933 Run cargo fmt 2021-01-02 07:10:10 +09:00
Kitaiti Makoto 20a099c16f Replace Syntect's deprecated APIs with new APIs 2021-01-02 06:47:55 +09:00
Kitaiti Makoto 3824e4ba25 Upgrade shrinkwraprs 2021-01-02 06:04:59 +09:00
Kitaiti Makoto b163fc8423 Remove unused serde_qs crate 2021-01-02 04:32:41 +09:00
Kitaiti Makoto b50f723a4d Upgrade Ructe 2021-01-02 04:24:06 +09:00
Kitaiti Makoto b778933c64 Upgrade rpassword 2021-01-02 04:04:17 +09:00
Kitaiti Makoto 12b97ce713 Remove unused colored crate 2021-01-02 03:16:22 +09:00
Kitaiti Makoto 4025a45d52 Upgrade whatlang 2020-12-30 22:36:47 +09:00
Kitaiti Makoto 8a6d832513 Upgrade rocket 2020-12-30 22:35:24 +09:00
Kitaiti Makoto 0b0b3a158f Upgrade diesel 2020-12-30 22:31:02 +09:00
Kitaiti Makoto 6b745ca8f0 Upgrade dotenv 2020-12-30 22:28:34 +09:00
Kitaiti Makoto 1f0cb7e05c Uninstall syntect 2020-12-30 21:27:15 +09:00
Kitaiti Makoto c59821945d Remove dependency to syntect from root package 2020-12-30 21:26:41 +09:00
Kitaiti Makoto 1a723b78b7 Install syntect 2020-12-30 21:23:52 +09:00
Kitaiti Makoto e7ff7e3263 Upgrade syntect to 0.4.5 2020-12-30 21:23:41 +09:00
KitaitiMakoto 3a6c1aeeef Merge pull request 'Bump version to development version' (#856) from dev-version into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/856
2020-12-29 14:30:43 +00:00
Kitaiti Makoto 567e011a66 Update dependencies 2020-12-29 22:52:11 +09:00
Kitaiti Makoto eaf63e0b17 start next development iteration 2020-12-29 18:01:18 +09:00
Kitaiti Makoto 63b31a9154 Fix changelog about security fix scope 2020-12-29 17:58:24 +09:00
KitaitiMakoto 5885cb5b09 Merge pull request 'Release 0.6.0' (#855) from release0.6.0 into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/855
2020-12-29 07:31:59 +00:00
Kitaiti Makoto f5ca464b16 Fix Matrix room ID in README 2020-12-29 16:29:43 +09:00
Kitaiti Makoto 1c40d5d3bc Add release date to CHANGELOG 2020-12-29 16:27:29 +09:00
Kitaiti Makoto 7e1abc527f Re-version to v0.6.0 2020-12-29 16:27:20 +09:00
KitaitiMakoto 39b2ef72fd Merge pull request 'Update CHANGELOG' (#854) from changelog into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/854
2020-12-28 13:19:41 +00:00
Kitaiti Makoto 17b081a21f Mark 0.6.0 unreleased 2020-12-28 22:18:46 +09:00
Kitaiti Makoto c482b1b552 Run cargo fmt 2020-12-28 22:15:45 +09:00
Kitaiti Makoto 8b16b9aaa4 Add changelog about support for RTL languages 2020-12-28 22:15:14 +09:00
KitaitiMakoto 11acc4172c Merge pull request 'add support for right to left languages in post content' (#853) from bidi-md into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/853
Reviewed-by: KitaitiMakoto <kitaitimakoto@noreply@joinplu.me>
2020-12-28 12:22:24 +00:00
Trinity Pointard 6187c62cb3 add bidi via forked pulldown-cmark 2020-12-27 21:02:37 +01:00
Trinity Pointard d6b5b9a721 upgrade to pulldown v0.8 2020-12-27 20:38:23 +01:00
KitaitiMakoto 80675f85f3 Merge pull request 'resynth1943/patch-1' (#852) from resynth1943/patch-1 into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/852
2020-12-27 16:44:10 +00:00
Resynth 07a6be424f Update alias 2020-12-26 12:48:39 +00:00
KitaitiMakoto 8cc56d8d81 Merge pull request 'Validate proofing for all activities' (#851) from prevent-spoof into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/851
2020-12-24 06:23:49 +00:00
Resynth f8cabcc904 Change riot.im link to matrix.to 2020-12-23 20:59:22 +00:00
Kitaiti Makoto d6a946f5b9 Validate spoofing for all activities 2020-12-22 16:31:12 +09:00
Kitaiti Makoto 2a5a2ec4d2 (cargo-release) start next development iteration {{next_version}} 2020-12-19 11:24:59 +00:00
Kitaiti Makoto 106e9417d3 (cargo-release) version {{version}} 2020-12-19 11:24:59 +00:00
Kitaiti Makoto 2660efec16 Define tag-name for cargo-release 2020-12-19 11:24:59 +00:00
Kitaiti Makoto 1eaa5a6e31 Add pre-release-hook to release.toml of subcrates to prevent running
one of root crate
2020-12-19 11:24:59 +00:00
Kitaiti Makoto b2c26f03e8 Pull master branch from Crowdin 2020-12-19 11:24:59 +00:00
Kitaiti Makoto a75cdaa870 Move security fix to next release in CHANGELOG 2020-12-19 11:24:59 +00:00
Kitaiti Makoto 2047355d46 Validate attributedTo in the case it is an object 2020-12-19 11:24:59 +00:00
Kitaiti Makoto 17bbcd1a4b Add changelog about security fix 2020-12-19 11:24:59 +00:00
Kitaiti Makoto 5c8170a97d Validate spoofing of Create activity 2020-12-19 11:24:59 +00:00
Kitaiti Makoto beaeaf743a Add test for preventing spoofing 2020-12-19 11:24:59 +00:00
Kitaiti Makoto fe641620a6 Update translations 2020-12-19 11:24:59 +00:00
Kitaiti Makoto 3e1a6e61ad Add *.pot 2020-12-19 11:24:59 +00:00
Kitaiti Makoto 45b46838ae Merge branch 'main' of git.joinplu.me:Plume/Plume into main 2020-12-19 07:26:11 +09:00
Kitaiti Makoto 46cdde8687 (cargo-release) start next development iteration {{next_version}} 2020-12-19 07:22:24 +09:00
Kitaiti Makoto 6b0dfb729c (cargo-release) version {{version}} 2020-12-19 07:22:19 +09:00
Kitaiti Makoto 75a4d1abf1 Define tag-name for cargo-release 2020-12-19 07:03:40 +09:00
Kitaiti Makoto 984c0cda6b Add pre-release-hook to release.toml of subcrates to prevent running
one of root crate
2020-12-19 06:57:09 +09:00
Kitaiti Makoto 902612a470 Pull master branch from Crowdin 2020-12-19 06:21:59 +09:00
Kitaiti Makoto e311d4d423 Move security fix to next release in CHANGELOG 2020-12-19 06:04:23 +09:00
Kitaiti Makoto aa33c8e7d3 Merge branch 'validate-attributed-to' into main 2020-12-19 06:01:45 +09:00
Kitaiti Makoto 60e6d49319 Update translations 2020-12-19 05:59:58 +09:00
Kitaiti Makoto 6dbd9b76fb Add *.pot 2020-12-19 05:56:36 +09:00
KitaitiMakoto e3877d3022 Fill changelogs for the next release (#842)
Clarify purpose of adding Vazir font

Fill changelogs for the next release

Co-authored-by: Kitaiti Makoto <KitaitiMakoto@gmail.com>
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/842
2020-12-18 14:30:51 +00:00
KitaitiMakoto 4c11df65dc Merge pull request 'Pull request template' (#848) from pr-template into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/848
2020-12-13 10:03:21 +00:00
Kitaiti Makoto f8cfb8cacf Move GitHub pull request template 2020-12-13 19:01:55 +09:00
Kitaiti Makoto 9a7e10b560 Merge branch 'main' of git.joinplu.me:Plume/Plume into main 2020-12-13 19:01:16 +09:00
KitaitiMakoto e131330175 Add guide to GitHub pull request (#847)
Add guide to pull request

Co-authored-by: Kitaiti Makoto <KitaitiMakoto@gmail.com>
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/847
2020-12-13 09:57:48 +00:00
KITAITI Makoto b9066cb7d0 Update issue templates
Guide to use Gitea issues.
2020-12-13 18:50:50 +09:00
KitaitiMakoto 4c4d9fafd5 Merge pull request 'Fix CI environment' (#843) from fix-ci-env into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/843
2020-12-10 16:31:16 +00:00
Kitaiti Makoto bbdf2a8293 Merge branch 'main' into validate-attributed-to 2020-12-11 01:14:22 +09:00
KitaitiMakoto 0d3e1a233f Merge pull request 'Update Cargo.lock' (#844) from cargo-lock into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/844
2020-12-10 16:13:37 +00:00
Kitaiti Makoto 712bc2afbe Update Cargo.lock 2020-12-11 01:12:15 +09:00
Kitaiti Makoto 2eadb80435 Validate attributedTo in the case it is an object 2020-12-11 00:35:20 +09:00
Kitaiti Makoto de05b9e176 Add changelog about security fix 2020-12-09 23:45:56 +09:00
Kitaiti Makoto 5bf1e81f0b Merge branch 'main' into validate-attributed-to 2020-12-09 23:43:29 +09:00
Kitaiti Makoto 55abbff9b8 Use Caddy v2 on build env 2020-12-08 21:51:09 +09:00
Kitaiti Makoto 5f89401a7c Update Rust on buildenv image 2020-12-08 20:06:21 +09:00
KitaitiMakoto 7bd3c1b01e Merge pull request 'Fix #763 Update Dockerfile.dev' (#841) from update-dockerfile-dev into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/841
2020-12-07 02:06:00 +00:00
KitaitiMakoto 961806247c Merge branch 'main' into update-dockerfile-dev 2020-12-07 02:05:34 +00:00
Kitaiti Makoto ac7ffae121 Update plumeorg/plume-buildenv used on CI 2020-12-07 07:50:33 +09:00
Kitaiti Makoto 5321f3cf18 Add clang dependency in Dockerfile.dev 2020-12-07 07:47:11 +09:00
KitaitiMakoto 5099a00c6b Merge pull request 'better-caching' (#840) from better-caching into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/840
2020-12-06 17:32:33 +00:00
KitaitiMakoto d44c034f6a Merge branch 'main' into better-caching 2020-12-06 17:31:53 +00:00
KitaitiMakoto 963e742dcf Merge pull request 'Run cargo fmt' (#839) from fmt into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/839
2020-12-06 17:05:39 +00:00
Kitaiti Makoto 50462204e8 Run cargo fmt 2020-12-07 02:04:37 +09:00
KitaitiMakoto 174ed738bd Merge pull request 'Update Docker image for testing' (#838) from update-build-image into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/838
2020-12-06 17:02:22 +00:00
Kitaiti Makoto f8d098f353 Update Docker image for testing 2020-12-07 01:58:41 +09:00
KitaitiMakoto f5b18dffaf cargo release helper (again) (#835)
remove tag-prefix deletion

as discussed here: https://github.com/igalic/Plume/pull/1

Update all versions numbers

Update Crowdin config to v3 + Pull translations with cargo release

Follow a more standard CHANGELOG format

add release.toml configuration file for cargo-release

and also add overrides in all other crates, since we only have one
CHANGELOG.md: https://github.com/sunng87/cargo-release/issues/205
we might wanna have that looked at or fixed

ignore .vscode/

add / backfill Changelog.md

Co-authored-by: Mina Galić <me+git@igalic.co>
Co-authored-by: Ana Gelez <ana@gelez.xyz>
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/835
2020-12-06 15:52:27 +00:00
KitaitiMakoto 002d1f1720 Merge pull request 'Update distro of Docker image for testing' (#834) from test-buster into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/834
2020-12-06 13:28:54 +00:00
Kitaiti Makoto 23a5634035 Update distro of Docker image for testing 2020-12-06 22:26:30 +09:00
Kitaiti Makoto 5cd8ae9106 Validate spoofing of Create activity 2020-12-03 19:20:10 +09:00
Kitaiti Makoto 350697f89a Run cargo fmt 2020-12-03 19:20:10 +09:00
Kitaiti Makoto 569979374f Add test for preventing spoofing 2020-12-03 19:20:10 +09:00
KitaitiMakoto 3c666080a9 Merge pull request 'Keep tags as-is' (#832) from KitaitiMakoto/Plume:keep-tag into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/832
Reviewed-by: kiwii <kiwii@noreply@joinplu.me>
2020-11-22 16:21:42 +00:00
Kitaiti Makoto 4e6d7b70cf Keep tags as-is 2020-11-22 22:24:43 +09:00
kiwii a59f167771 Merge pull request 'PR #818 from Github' (#831) from gh-pr-818 into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/831
2020-11-22 11:45:47 +00:00
Ana Gelez f28ab19dc0 Merge branch 'serra-allgood/#754-display-error-for-duplicated-blocklist-email' of https://github.com/serra-allgood/Plume into gh-pr-818 2020-11-22 12:43:46 +01:00
KitaitiMakoto 6dd4080d65 Merge pull request 'Remove link to unimplemented page(timeline edit)' (#827) from KitaitiMakoto/Plume:feed-edit-button into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/827
Reviewed-by: Mina Galić <me+git@igalic.co>
2020-11-15 17:10:55 +00:00
Kitaiti Makoto eac76e6806 Merge remote-tracking branch 'upstream/main' into feed-edit-button 2020-11-12 00:05:42 +09:00
trinity-1686a 0cd26dfbf4 fix test following ldap udpate
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/828
Reviewed-by: Mina Galić <me+git@igalic.co>
2020-10-08 19:18:04 +00:00
Trinity Pointard 3de009713d try fixing clippy and fmt 2020-10-08 20:24:03 +02:00
Trinity Pointard 69bcb01715 fix test following ldap udpate 2020-10-08 19:59:54 +02:00
trinity-1686a 9ec2d93f50 implement login via LDAP
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/826
Reviewed-by: Mina Galić <me+git@igalic.co>
2020-10-08 16:11:35 +00:00
Trinity Pointard 4da9b24cb1 cargo fmt 2020-10-07 23:40:27 +02:00
Trinity Pointard f40634aa97 address comments 2020-10-07 23:39:38 +02:00
Kitaiti Makoto 83282e0736 Remove link to unimplemented page 2020-10-06 19:47:35 +09:00
Serra Allgood 43fde90387 Fix displaying not found page when submitting a duplicated blocklist email
Signed-off-by: Serra Allgood <serra@allgood.dev>
2020-10-05 20:17:30 -07:00
Trinity Pointard ccba8163c9 fix compilation issue with cli 2020-10-04 23:53:14 +02:00
Trinity Pointard 8975b0f9e9 cargo fmt 2020-10-04 12:18:54 +02:00
Trinity Pointard d626f3366d add support for ldap 2020-10-04 12:18:22 +02:00
Trinity Pointard b24f195e10 refactor login
first step toward ldap
should have no functionnal change
2020-10-03 13:21:31 +02:00
Mina Galić 003dcf861a Merge pull request 'CSS Fix: My title is displayed at the wrong position on Webkit browsers' (#825) from quentin/Plume:pr/flex into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/825
Reviewed-by: Mina Galić <me+git@igalic.co>
2020-09-29 07:15:06 +00:00
Quentin Dufour 5d8efa77a3 Fix title 2020-09-25 11:19:24 +02:00
kiwii fb6d49cc6e Merge pull request 'GPU acceleration for the mobile menu' (#818) from gpu-acceleration into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/818
Reviewed-by: kiwii <kiwii@noreply@joinplu.me>
2020-08-27 10:29:34 +00:00
Mina Galić 48776939f4 Merge branch 'main' into gpu-acceleration 2020-08-19 19:53:39 +00:00
Marek Ľach 104b6c1d0c GPU acceleration for the mobile menu
Reimplements #810, but for all browsers.
2020-08-19 21:34:07 +02:00
Mina Galić 3881927550 Merge pull request 'mobile-margins' (#817) from mobile-margins into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/817
Reviewed-by: Mina Galić <me+git@igalic.co>
2020-08-19 11:35:04 +00:00
Ana Gelez 0bec13edc0 Improve responsiveness 2020-08-11 20:13:27 +02:00
Ana Gelez 191d6da486 Move header-related style to _header.scss
It seems to fix the overflowing menu items on small screens too
2020-08-11 20:13:27 +02:00
kiwii 9aaff1a484 Merge pull request 'Use result of local storage insert operation to suppress Clippy' (#810) from KitaitiMakoto/Plume:suppress-clippy into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/810
Reviewed-by: kiwii <kiwii@noreply@joinplu.me>
2020-07-25 17:28:26 +00:00
Kitaiti Makoto 36fd55a7e4 Use result of local storage insert operation to suppress Clippy 2020-07-25 20:13:41 +09:00
kiwii fc474bf8d1 Merge pull request '[BUG FIX]Make it possible to switch to rich text editor' (#808) from KitaitiMakoto/Plume:richtexteditor into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/808
Reviewed-by: kiwii <kiwii@noreply@joinplu.me>
2020-07-23 18:25:53 +00:00
Kitaiti Makoto a050deb557 [BUG FIX]Make it possible to switch to rich text editor 2020-07-23 23:36:09 +09:00
kiwii 6de9a1f1c8 Merge pull request 'Recreate search index if its format is outdated' (#802) from KitaitiMakoto/Plume:invalid-index into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/802
Reviewed-by: Mina Galić <me+git@igalic.co>
2020-07-19 12:04:43 +00:00
Kitaiti Makoto 5e30bede40 Don't care about needless return value of closures 2020-07-19 08:24:17 +09:00
Kitaiti Makoto 5cca66b346 Add action user can take to error message 2020-07-19 07:16:34 +09:00
Kitaiti Makoto 484659fde2 Run cargo fmt 2020-07-18 22:52:39 +09:00
Kitaiti Makoto 5fc827c1c9 Re-initialize search index when recreating is failed 2020-07-18 21:00:58 +09:00
Kitaiti Makoto 50753b3a65 Recreate search index if its format is outdated 2020-07-18 09:40:58 +09:00
Kitaiti Makoto c5d03d300b Cause IndexInvalidDataError when search index is invalid 2020-07-18 09:40:47 +09:00
kiwii 010eac6c4a Merge pull request 'upgrade rocket* to the latest stable' (#800) from igalic/Plume:update/rocket into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/800
Reviewed-by: kiwii <kiwii@noreply@joinplu.me>
2020-07-17 13:39:12 +00:00
Mina Galić a107d35492 upgrade rocket* to the latest stable
before we embark on upgrading to async, and all the refactoring that
this will bring on us (see #797 & #799), we should keep our `main`
branch as stable and current as possible.
Let's start by upgrading rocket and its dependencies.
2020-07-17 09:38:55 +02:00
Kitaiti Makoto f9beb2383b Update lindera-tantivy to v0.1.3 2020-07-05 17:59:51 +02:00
Chosto 7e78cffcaa Bump Docker base images to buster flavor (#797) 2020-07-02 12:46:56 +02:00
Ana Gelez 719fec0828 Add a comment 2020-06-25 22:26:44 +02:00
Ana Gelez 90fdade566 Better caching
Based on @trinity-1686a's patch: https://github.com/Plume-org/Plume/issues/786#issuecomment-647170325
2020-06-25 22:20:31 +02:00
TheMasix 28576c1fa3 Add Vazir Font (#787)
* Add Vazir Font

* Add Vazir Font License

* fix prettier problem

* Shabnam added
2020-06-24 15:48:04 +02:00
Gelez d99b42582d Add Persian to the list of languages (#782) 2020-06-17 18:33:58 +02:00
KITAITI Makoto 92a386277b Switchable tokenizer (#776)
* [REFACTORING]Rename whitespace_tokenizer to tag_tokenizer for
registration

Name representing its purpose is preferred.

* Add lindera-tantivy to plume-model's dependencies

* Install lindera-tantivy

* Add SearchTokenizerConfig struct

* Add search tokenizers to config option

* Use CONFIG for tokenizers

* Use enum to hold tokenizer config instead of initializing on config phase

* Use guard instead of duplicate default values

* Use as_deref() instead of guard

* Move SearchTokenizer from plume-models to plume-models::search::tokenizer

* Rename SearchTokenizer to TokenizerKind

* Define SearchTokenierConfig::determine_tokenizer()

* Use determine_tokenizer in SearchTokenizerConfig::init()

* Pass tokenizer config to Searcher methods

* Add LowerCase filter to Lindera tokenizer

* Add test for Lindera tokenizer

* Define SEARCH_LANG env to specify tokenizers set

* Run cargo fmt

* Make Lindera tokenizer optional

* Fix typos
2020-06-17 16:57:28 +02:00
Gelez 297d9fcf40 Don't show boosts and likes for "all" and "local" in timelines (#781)
Fixes #711
2020-06-15 19:50:28 +02:00
KITAITI Makoto ef70cb93e6 Upgrade Tantivy to v0.12.0 (#771)
* Upgrade Tantivy to 0.12.0

* Follow Tantivy Tokenizer's new type definition

* Wrap tokenizers with TextAnalyzer to use filter methods

* Replace async IndexWriter::garbage_collect_files with sync functions

* Update Cargo.toml
2020-05-20 13:31:45 +02:00
Daniel Watkins efb76a3c17 remove dependency on runtime-fmt (#773)
Per the issue, "runtime-fmt uses perma-unstable rust APIs and is
therefore susceptible to breakage".

This replaces the two calls to rt_format! with .replace() and drops the
dependency.

Fixes #769
2020-05-18 20:18:07 +02:00
KITAITI Makoto 197f0d7ecd Add test for hash including ZWSP (#772)
* Add test for hash including ZWSP

* Run cargo fmt
2020-05-17 13:53:31 +02:00
KITAITI Makoto 3be842c653 Make database connections configurable by environment variables (#768)
* Make env DB_MAX_SIZE and DB_MIN_IDLE recognizable

* Make database max size and minimum idle configurable

* Restore file permission

* Fail fast
2020-05-06 19:27:59 +02:00
KITAITI Makoto dabe904642 Escape expressions in @Html (#767) 2020-05-05 23:48:29 +02:00
KITAITI Makoto 180e34b07c Fix Atom feed datetime format (#766) 2020-05-04 23:46:59 +02:00
KITAITI Makoto 847d6f7fac Fix Atom feed (#764)
* Percent-encode URI segments in ap_url

* Fix invalid Atoms

* Remove redundant clone according to cargo clippy

* Revert "Percent-encode URI segments in ap_url"

This reverts commit 8253aa79bd.
ActivityPub(JSON-LD) accepts URI.
See https://github.com/Plume-org/Plume/pull/764#issuecomment-623105734

* Use absolute IRI for IDs in Atom

* Reuse formatted string

* Use parent element's creation date for Atom updated if there's no post

* Remove uncecessary UTC conversion

* Extract routes::build_atom_feed function
2020-05-04 15:28:52 +02:00
KITAITI Makoto 6a3f210dfc Keep atmarks and hashes in link (#765)
* [REFACTORING]Use DocumentContext during parsing Markdown

* Add test case for hash in link

* Make DocumentContext derive Debug

* Add in_link field in DocumentContext

* Don't make hash words tags in link

* Add test for atmark in link

* Don't make atmark words in link mentions
2020-05-03 14:50:32 +02:00
KITAITI Makoto 73aa301d4a Fix user subscription URI so that plume::routes:interact accept it (#762) 2020-05-02 12:07:45 +02:00
KITAITI Makoto b3d367b174 Use plural form for 0 in French (#760)
See https://github.com/Plume-org/Plume/issues/745
2020-04-30 15:35:12 +02:00
KITAITI Makoto edaccd1a31 Fixes #757 Allow Unicode hashtags (#758)
* Add test for Persian language hashtags

See https://github.com/Plume-org/Plume/issues/757

* Add regex-syntax with unicode-perl feature to dependencies

* Install regex-syntax

* Allow hashtag to use Unicode word characters

* Run cargo fmt
2020-04-29 15:13:31 +02:00
Floréal Toumikian e1bd2eab75 Updated: Cargo.lock (#753) 2020-04-19 09:34:05 +02:00
KITAITI Makoto ac7a05b09a Make blocklist deletion possible (#750) 2020-04-18 11:46:10 +02:00
KITAITI Makoto 71e0a35e06 Use LenientForm instead Form for CSRF protected pages (#751) 2020-04-18 11:45:28 +02:00
KITAITI Makoto c217e5e9b3 Move stylesheets for header from _global.sccss to _header.scss (#749) 2020-04-14 23:32:27 +02:00
KITAITI Makoto 8ba0c17db5 Build app and po files before upload pos to Crowdin (#748) 2020-04-14 20:51:53 +02:00
Floréal Toumikian 4e43c676b4 Fixed: #713: Disply likes and boosts on post cards (#744)
This is a basic and simple way to display them. No interaction possible.

Alos, this patch is not optimised. as everytime a partial post_card is
called, `Post::count_likes()` and `Post::count_reshares()` are called
which means quite a few more quesies are sent to database unless diesel
uses some cache mechanisem.

A way to enhance this this would be to keep a count of likes and reshares
are kept in Post model / table.
2020-04-12 21:29:48 +02:00
KITAITI Makoto b834d1c282 Fix #701 Preferable default theme (#746)
* Make it possible to update users.preferred_theme to NULL

* Make preferred them null when 'Default theme' is selected

* Run cargo fmt
2020-04-12 17:36:00 +02:00
Kenneth Steimel 506fe9955d Fixed #734 , passowrds are now hidden on the remote_interact pages (#741)
* Fixed #734 , passowrds are now hidden on the remote_interact pages

* Update templates/remote_interact_base.rs.html

Co-Authored-By: Floréal Toumikian <floreal+github@nimukaito.net>

Co-authored-by: Floréal Toumikian <floreal+github@nimukaito.net>
2020-04-09 20:55:22 +02:00
KemoNine 02c528cae4 Bump llvm -> 9.0.0 (fixes arm builds) (#737) 2020-01-29 21:37:54 +01:00
Christopher James Halse Rogers 2a58835f92 Snapcraft updates (#731)
* snap: Update rust compiler

* snap: Fix the build.

We now need libclang

* snap: Fix the non-x86 builds.

The goddamned environment variable is SNAPCRAFT_ARCH_TRIPLE*T*

* snap: Mark as stable.

The snap works fine; we don't need to warn people away
2020-01-22 14:10:49 +02:00
250 changed files with 36449 additions and 25091 deletions
+10
View File
@@ -0,0 +1,10 @@
[target.wasm32-unknown-unknown]
# required for clippy
rustflags = [
"--cfg", "web_sys_unstable_apis",
]
[target.x86_64-unknown-linux-gnu]
rustflags = [
"--cfg", "web_sys_unstable_apis",
]
+14 -9
View File
@@ -10,7 +10,7 @@ executors:
type: boolean
default: false
docker:
- image: plumeorg/plume-buildenv:v0.0.9
- image: plumeorg/plume-buildenv:v0.4.0
- image: <<#parameters.postgres>>circleci/postgres:9.6-alpine<</parameters.postgres>><<^parameters.postgres>>alpine:latest<</parameters.postgres>>
environment:
POSTGRES_USER: postgres
@@ -21,6 +21,7 @@ executors:
RUST_TEST_THREADS: 1
FEATURES: <<#parameters.postgres>>postgres<</ parameters.postgres>><<^parameters.postgres>>sqlite<</parameters.postgres>>
DATABASE_URL: <<#parameters.postgres>>postgres://postgres@localhost/plume<</parameters.postgres>><<^parameters.postgres>>plume.sqlite<</parameters.postgres>>
ROCKET_SECRET_KEY: VN5xV1DN7XdpATadOCYcuGeR/dV0hHfgx9mx9TarLdM=
commands:
@@ -71,7 +72,7 @@ commands:
type: string
steps:
- run: |
export RUSTFLAGS="-Zprofile -Zfewer-names -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Zno-landing-pads -Clink-arg=-Xlinker -Clink-arg=--no-keep-memory -Clink-arg=-Xlinker -Clink-arg=--reduce-memory-overheads"
export RUSTFLAGS="-Zprofile -Zfewer-names -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Clink-arg=-Xlinker -Clink-arg=--no-keep-memory -Clink-arg=-Xlinker -Clink-arg=--reduce-memory-overheads"
export CARGO_INCREMENTAL=0
<< parameters.cmd >>
@@ -99,7 +100,7 @@ commands:
steps:
- run: |
cmd="cargo build <<#parameters.release>>--release<</parameters.release>> --no-default-features --features="${FEATURES}" -p <<parameters.package>> -j"
for i in 36 4 2 1 1; do
for i in 16 4 2 1 1; do
$cmd $i && exit 0
done
exit 1
@@ -143,11 +144,14 @@ jobs:
cache: <<#parameters.postgres>>postgres<</ parameters.postgres>><<^parameters.postgres>>sqlite<</parameters.postgres>>
- run_with_coverage:
cmd: |
cargo build -p plume-cli --no-default-features --features=${FEATURES} -j 4
./target/debug/plm migration run
./target/debug/plm search init
cmd="cargo test --all --exclude plume-front --exclude plume-macro --no-run --no-default-features --features=${FEATURES} -j"
for i in 36 4 2 1 1; do
for i in 16 4 2 1 1; do
$cmd $i && break
done
cargo test --all --exclude plume-front --exclude plume-macro --no-default-features --features="${FEATURES}" -j1 -- --test-threads=1
cargo test --all --exclude plume-front --exclude plume-macro --no-default-features --features="${FEATURES}" -j1
- upload_coverage:
type: unit
- cache:
@@ -164,18 +168,18 @@ jobs:
steps:
- restore_env:
cache: <<#parameters.postgres>>postgres<</ parameters.postgres>><<^parameters.postgres>>sqlite<</parameters.postgres>>
- run: cargo web deploy -p plume-front
- run: wasm-pack build --target web --release plume-front
- run_with_coverage:
cmd: |
cmd="cargo install --debug --no-default-features --features="${FEATURES}",test --force --path . -j"
for i in 36 4 2 1 1; do
for i in 16 4 2 1 1; do
$cmd $i && exit 0
done
exit 1
- run_with_coverage:
cmd: |
cmd="cargo install --debug --no-default-features --features="${FEATURES}" --force --path plume-cli -j"
for i in 36 4 2 1 1; do
for i in 16 4 2 1 1; do
$cmd $i && exit 0
done
exit 1
@@ -199,7 +203,7 @@ jobs:
steps:
- restore_env:
cache: release-<<#parameters.postgres>>postgres<</ parameters.postgres>><<^parameters.postgres>>sqlite<</parameters.postgres>>
- run: cargo web deploy -p plume-front --release
- run: wasm-pack build --target web --release plume-front
- build:
package: plume
release: true
@@ -226,6 +230,7 @@ jobs:
steps:
- restore_env:
cache: none
- run: cargo build
- run: crowdin upload -b master
workflows:
+2 -5
View File
@@ -1,6 +1,3 @@
localhost:443 {
proxy / localhost:7878 {
transparent
}
tls self_signed
localhost {
reverse_proxy localhost:7878
}
+8 -6
View File
@@ -1,19 +1,22 @@
FROM debian:stretch-20190326
FROM debian:buster-20210208
ENV PATH="/root/.cargo/bin:${PATH}"
#install native/circleci/build dependancies
RUN apt update &&\
apt install -y --no-install-recommends git ssh tar gzip ca-certificates default-jre&&\
apt install -y --no-install-recommends binutils-dev build-essential cmake curl gcc gettext git libcurl4-openssl-dev libdw-dev libelf-dev libiberty-dev libpq-dev libsqlite3-dev libssl-dev make openssl pkg-config postgresql postgresql-contrib python zlib1g-dev python3-pip zip unzip libclang-dev&&\
echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" \
| tee -a /etc/apt/sources.list.d/caddy-fury.list &&\
apt update &&\
apt install -y --no-install-recommends binutils-dev build-essential cmake curl gcc gettext git libcurl4-openssl-dev libdw-dev libelf-dev libiberty-dev libpq-dev libsqlite3-dev libssl-dev make openssl pkg-config postgresql postgresql-contrib python zlib1g-dev python3-pip zip unzip libclang-dev clang caddy&&\
rm -rf /var/lib/apt/lists/*
#install and configure rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2020-01-15 -y &&\
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2021-01-15 -y &&\
rustup component add rustfmt clippy &&\
rustup component add rust-std --target wasm32-unknown-unknown
#compile some deps
RUN cargo install cargo-web &&\
RUN cargo install wasm-pack &&\
cargo install grcov &&\
strip /root/.cargo/bin/* &&\
rm -fr ~/.cargo/registry
@@ -24,8 +27,7 @@ COPY cargo_config /root/.cargo/config
#install selenium for front end tests
RUN pip3 install selenium
#install and configure caddy
RUN curl https://getcaddy.com | bash -s personal
#configure caddy
COPY Caddyfile /Caddyfile
#install crowdin
+12
View File
@@ -15,6 +15,9 @@ DATABASE_URL=postgres://plume:plume@localhost/plume
# The domain of your instance
BASE_URL=plu.me
# Log level for each crate
RUST_LOG=warn,html5ever=warn,hyper=warn,tantivy=warn
# The secret key for private cookies and CSRF protection
# You can generate one with `openssl rand -base64 32`
ROCKET_SECRET_KEY=
@@ -45,3 +48,12 @@ ROCKET_ADDRESS=127.0.0.1
#PLUME_LOGO_192=icons/trwnh/paragraphs/plumeParagraphs192.png
#PLUME_LOGO_256=icons/trwnh/paragraphs/plumeParagraphs256.png
#PLUME_LOGO_512=icons/trwnh/paragraphs/plumeParagraphs512.png
## LDAP CONFIG ##
# the object that will be bound is "${USER_NAME_ATTR}=${username},${BASE_DN}"
#LDAP_ADDR=ldap://127.0.0.1:1389
#LDAP_BASE_DN="ou=users,dc=your-org,dc=eu"
#LDAP_USER_NAME_ATTR=cn
#LDAP_USER_MAIL_ATTR=mail
#LDAP_TLS=false
+10
View File
@@ -7,6 +7,16 @@ assignees: ''
---
<!--
We would appreciated if you report a bug at our Gitea instance's issue page:
https://git.joinplu.me/Plume/Plume/issues
You can login to the Gitea with your GitHub account.
We welcome to receive bug reports here, GitHub, too.
-->
<!-- Describe your bug, explaining how to reproduce it, and what was expected -->
@@ -7,6 +7,15 @@ assignees: ''
---
<!--
We would appreciated if you request a feature at our Gitea instance's issue page:
https://git.joinplu.me/Plume/Plume/issues
You can login to the Gitea with your GitHub account.
We welcome to receive feature requests here, GitHub, too.
-->
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+7
View File
@@ -0,0 +1,7 @@
<!--
We would appreciated if you report a bug at our Gitea instance's pull request page:
https://git.joinplu.me/Plume/Plume/pulls
You can login to the Gitea with your GitHub account.
We welcome to receive pull requests here, GitHub, too.
-->
+2
View File
@@ -18,3 +18,5 @@ tags.*
search_index
.buildconfig
__pycache__
.vscode/
*-journal
+214
View File
@@ -0,0 +1,214 @@
# Changelog
<!-- next-header -->
## [Unreleased] - ReleaseDate
### Added
- Allow `dir` attributes for LtoR text in RtoL document (#860)
- More translation languages (#862)
- Proxy support (#829)
- Riker a actor system library (#870)
- (request-target) and Host header in HTTP Signature (#872)
### Changed
- Upgrade some dependent crates (#858)
- Use tracing crate (#868)
- Update Rust version to nightly-2021-01-15 (#878)
- Upgrade Tantivy to 0.13.3 and lindera-tantivy to 0.7.1 (#878)
- Run searcher on actor system (#870)
### Fixed
- Percent-encode URI for remote_interact (#866, #857)
- Menu animation not opening on iOS (#876, #897)
- Make actors subscribe to channel once (#913)
- Upsert posts and media instead of trying to insert and fail (#912)
## [[0.6.0]] - 2020-12-29
### Added
- Vazir font for better support of languages written in Arabic script (#787)
- Login via LDAP (#826)
- cargo-release (#835)
- Care about weak ETag header for better caching (#840)
- Support for right to left languages in post content (#853)
### Changed
- Bump Docker base images to Buster flavor (#797)
- Upgrade Rocket to 0.4.5 (#800)
- Keep tags as-is (#832)
- Update Docker image for testing (#838)
- Update Dockerfile.dev (#841)
### Fixed
- Recreate search index if its format is outdated (#802)
- Make it possible to switch to rich text editor (#808)
- Fix margins for the mobile devices (#817)
- GPU acceleration for the mobile menu (#818)
- Natural title position for RtoL languages (#825)
- Remove link to unimplemented page (#827)
- Fix displaying not found page when submitting a duplicated blocklist email (#831)
### Security
- Validate spoofing of activity
## [0.5.0] - 2020-06-21
### Added
- Email blocklisting (#718)
- Syntax highlighting (#691)
- Persian localization (#782)
- Switchable tokenizer - enables Japanese full-text search (#776)
- Make database connections configurable by environment variables (#768)
### Changed
- Display likes and boost on post cards (#744)
- Rust 2018 (#726)
- Bump to LLVM to 9.0.0 to fix ARM builds (#737)
- Remove dependency on runtime-fmt (#773)
- Drop the -alpha suffix in release names, it is implied that Plume is not stable yet because of the 0 major version (Plume 1.0.0 will be the first stable release).
### Fixed
- Fix parsing of mentions inside a Markdown code block (be430c6)
- Fix RSS issues (#720)
- Fix Atom feed (#764)
- Fix default theme (#746)
- Fix shown password on remote interact pages (#741)
- Allow unicode hashtags (#757)
- Fix French grammar for for 0 (#760)
- Don't show boosts and likes for "all" and "local" in timelines (#781)
- Fix liking and boosting posts on remote instances (#762)
## [0.4.0] - 2019-12-23
### Added
- Add support for generic timeline (#525)
- Federate user deletion (#551)
- import migrations and don't require diesel_cli for admins (#555)
- Cache local instance (#572)
- Initial RTL support #575 (#577)
- Confirm deletion of blog (#602)
- Make a distinction between moderators and admins (#619)
- Theming (#624)
- Add clap to plume in order to print help and version (#631)
- Add Snapcraft metadata and install/maintenance hooks (#666)
- Add environmental variable to control path of media (#683)
- Add autosaving to the editor (#688)
- CI: Upload artifacts to pull request deploy environment (#539)
- CI: Upload artifact of wasm binary (#571)
### Changed
- Update follow_remote.rs.html grammar (#548)
- Add some feedback when performing some actions (#552)
- Theme update (#553)
- Remove the new index lock tantivy uses (#556)
- Reduce reqwest timeout to 5s (#557)
- Improve notification management (#561)
- Fix occurrences of 'have been' to 'has been' (#578) + Direct follow-up to #578 (#603)
- Store password reset requests in database (#610)
- Use futures and tokio to send activities (#620)
- Don't ignore dotenv errors (#630)
- Replace the input! macro with an Input builder (#646)
- Update default license (#659)
- Paginate the outbox responses. Fixes #669 (#681)
- Use the "classic" editor by default (#697)
- Fix issue #705 (#708)
- Make comments in styleshhets a bit clearer (#545)
- Rewrite circleci config (#558)
- Use openssl instead of sha256sum for build.rs (#568)
- Update dependencies (#574)
- Refactor code to use Shrinkwraprs and diesel-derive-newtype (#598)
- Add enum containing all successful route returns (#614)
- Update dependencies which depended on nix -- fixes arm32 builds (#615)
- Update some documents (#616)
- Update dependencies (#643)
- Make the comment syntax consistent across all CSS (#487)
### Fixed
- Remove r (#535)
- Fix certain improper rendering of forms (#560)
- make hashtags work in profile summary (#562)
- Fix some federation issue (#573)
- Prevent comment form submit button distortion on iOS (#592)
- Update textarea overflow to scroll (#609)
- Fix arm builds (#612)
- Fix theme caching (#647)
- Fix issue #642, frontend not in English if the user language does not exist (#648)
- Don't index drafts (#656)
- Fill entirely user on creation (#657)
- Delete notification on user deletion (#658)
- Order media so that latest added are top (#660)
- Fix logo URL (#664)
- Snap: Ensure cargo-web doesn't erroneously adopt our workspace. (#667)
- Snap: Another fix for building (#668)
- Snap: Fix build for non-Tier-1 Rust platforms (#672)
- Don't split sentences for translations (#677)
- Escape href quotation marks (#678)
- Re-add empty strings in translation (#682)
- Make the search index creation during migration respect SEARCH_INDEX (#689)
- Fix the navigation menu not opening on touch (#690)
- Make search items optional (#693)
- Various snap fixes (#698)
- Fix #637 : Markdown footnotes (#700)
- Fix lettre (#706)
- CI: Fix Crowdin upload (#576)
### Removed
- Remove the Canapi dependency (#540)
- Remove use of Rust in migrations (#704)
## [0.3.0] - 2019-04-19
### Added
- Cover for articles (#299, #387)
- Password reset (#448)
- New editor (#293, #458, #482, #483, #486, #530)
- Search (#324, #375, #445)
- Edit blogs (#460, #494, #497)
- Hashtags in articles (#283, #295)
- API endpoints (#245, #285, #307)
- A bunch of new translations! (#479, #501, #506, #510, #512, #514)
### Changed
- Federation improvements (#216, #217, #357, #364, #399, #443, #446, #455, #502, #519)
- Improved build process (#281, #374, #392, #402, #489, #498, #503, #511, #513, #515, #528)
### Fixes
- UI usability fixes (#370, #386, #401, #417, #418, #444, #452, #480, #516, #518, #522, #532)
## [0.2.0] - 2018-09-12
### Added
- Article publishing, or save as a draft
- Like, or boost an article
- Basic Markdown editor
- Federated commenting system
- User account creation
- Limited federation on other platforms and subscribing to users
- Ability to create multiple blogs
<!-- next-url -->
[Unreleased]: https://github.com/Plume-org/Plume/compare/0.6.0...HEAD
[[0.6.0]]: https://github.com/Plume-org/Plume/compare/0.5.0...0.6.0
[0.5.0]: https://github.com/Plume-org/Plume/compare/0.4.0-alpha-4...0.5.0
[0.4.0]: https://github.com/Plume-org/Plume/compare/0.3.0-alpha-2...0.4.0-alpha-4
[0.3.0]: https://github.com/Plume-org/Plume/compare/0.2.0-alpha-1...0.3.0-alpha-2
[0.2.0]: https://github.com/Plume-org/Plume/releases/tag/0.2.0-alpha-1
Generated
+3092 -2133
View File
File diff suppressed because it is too large Load Diff
+10 -10
View File
@@ -1,7 +1,7 @@
[package]
authors = ["Plume contributors"]
name = "plume"
version = "0.4.0"
version = "0.6.1-dev"
repository = "https://github.com/Plume-org/Plume"
edition = "2018"
@@ -10,8 +10,7 @@ activitypub = "0.1.3"
askama_escape = "0.1"
atom_syndication = "0.6"
clap = "2.33"
colored = "1.8"
dotenv = "0.14"
dotenv = "0.15.0"
gettext = { git = "https://github.com/Plume-org/gettext/", rev = "294c54d74c699fbc66502b480a37cc66c1daa7f3" }
gettext-macros = { git = "https://github.com/Plume-org/gettext-macros/", rev = "a7c605f7edd6bfbfbfe7778026bfefd88d82db10" }
gettext-utils = { git = "https://github.com/Plume-org/gettext-macros/", rev = "a7c605f7edd6bfbfbfe7778026bfefd88d82db10" }
@@ -20,20 +19,20 @@ heck = "0.3.0"
lettre = "0.9.2"
lettre_email = "0.9.2"
num_cpus = "1.10"
rocket = "0.4.2"
rocket_contrib = { version = "0.4.2", features = ["json"] }
rocket = "0.4.6"
rocket_contrib = { version = "0.4.5", 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"
serde_qs = "0.5"
shrinkwraprs = "0.2.1"
syntect = "3.3"
validator = "0.8"
validator_derive = "0.8"
webfinger = "0.4.1"
tracing = "0.1.22"
tracing-subscriber = "0.2.15"
riker = "0.4.2"
[[bin]]
name = "plume"
@@ -49,7 +48,7 @@ version = "3.1.2"
[dependencies.diesel]
features = ["r2d2", "chrono"]
version = "*"
version = "1.4.5"
[dependencies.multipart]
default-features = false
@@ -70,7 +69,7 @@ git = "https://github.com/fdb-hiroshima/rocket_csrf"
rev = "29910f2829e7e590a540da3804336577b48c7b31"
[build-dependencies]
ructe = "0.9.0"
ructe = "0.13.0"
rsass = "0.9"
[features]
@@ -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"]
+4 -3
View File
@@ -1,4 +1,4 @@
FROM rust:1-stretch as builder
FROM rust:1-buster as builder
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
@@ -19,7 +19,7 @@ RUN chmod a+x ./wasm-deps.sh && sleep 1 && ./wasm-deps.sh
WORKDIR /app
COPY Cargo.toml Cargo.lock rust-toolchain ./
RUN cargo install cargo-web
RUN cargo install wasm-pack
COPY . .
@@ -28,7 +28,7 @@ RUN cargo install --path ./ --force --no-default-features --features postgres
RUN cargo install --path plume-cli --force --no-default-features --features postgres
RUN cargo clean
FROM debian:stretch-slim
FROM debian:buster-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
@@ -40,6 +40,7 @@ WORKDIR /app
COPY --from=builder /app /app
COPY --from=builder /usr/local/cargo/bin/plm /bin/
COPY --from=builder /usr/local/cargo/bin/plume /bin/
COPY --from=builder /usr/local/cargo/bin/remove-dup-images /bin/
CMD ["plume"]
+4 -3
View File
@@ -1,4 +1,4 @@
FROM rust:1-stretch
FROM rust:1-buster
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
@@ -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 .
@@ -19,7 +20,7 @@ RUN chmod a+x ./wasm-deps.sh && sleep 1 && ./wasm-deps.sh
WORKDIR /app
COPY Cargo.toml Cargo.lock rust-toolchain ./
RUN cargo install diesel_cli --no-default-features --features postgres --version '=1.3.0'
RUN cargo install cargo-web
RUN cargo install wasm-pack
COPY . .
+1 -1
View File
@@ -34,7 +34,7 @@ rules and thematics, but they can all communicate with each other.
## Get involved
If you want to have regular news about the project, the best place is probably [our blog](https://fediverse.blog/~/PlumeDev), or our Matrix room: [`#plume:disroot.org`](https://riot.im/app/#/room/#plume:disroot.org).
If you want to have regular news about the project, the best place is probably [our blog](https://fediverse.blog/~/PlumeDev), or our Matrix room: [`#plume-blog:matrix.org`](https://matrix.to/#/#plume-blog:matrix.org).
If you want to contribute more, a good first step is to read [our contribution guides](https://docs.joinplu.me/contribute). We accept all kind of contribution:
+1 -1
View File
@@ -1,3 +1,3 @@
* {
font-family: monospace;
font-family: monospace;
}
+116 -89
View File
@@ -40,7 +40,7 @@ main header.article {
display: flex;
flex-direction: column;
justify-content: end;
justify-content: flex-end;
h1, .article-info {
text-align: center;
@@ -64,37 +64,37 @@ main header.article {
}
main .article-info {
margin: 0 auto 3em;
font-size: 0.95em;
font-weight: 400;
margin: 0 auto 3em;
font-size: 0.95em;
font-weight: 400;
.author, .author a {
font-weight: 600;
}
.author, .author a {
font-weight: 600;
}
}
/* The article itself */
main article {
max-width: $article-width;
margin: 2.5em auto;
font-family: $lora;
font-size: 1.2em;
line-height: 1.7;
margin: 2.5em auto;
font-family: $lora;
font-size: 1.2em;
line-height: 1.7;
a:hover {
text-decoration: underline;
}
a:hover {
text-decoration: underline;
}
img {
display: block;
margin: 3em auto;
max-width: 100%;
img {
display: block;
margin: 3em auto;
max-width: 100%;
}
pre {
padding: 1em;
background: $gray;
overflow: auto;
padding: 1em;
background: $gray;
overflow: auto;
}
blockquote {
@@ -126,7 +126,7 @@ main .article-meta {
> p {
margin: 2em $horizontal-margin;
font-size: 0.9em;
font-size: 0.9em;
}
/* Article Tags */
@@ -157,15 +157,15 @@ main .article-meta {
/* Likes & Boosts */
.actions {
display: flex;
flex-direction: row;
justify-content: space-around;
flex-direction: row;
justify-content: space-around;
}
.likes, .reshares {
display: flex;
flex-direction: column;
align-items: center;
padding: 0.5em 0;
flex-direction: column;
align-items: center;
padding: 0.5em 0;
p {
font-size: 1.5em;
@@ -175,34 +175,34 @@ main .article-meta {
.action {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 0;
padding: 0;
background: none;
color: $text-color;
border: none;
font-size: 1.1em;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 0;
padding: 0;
background: none;
color: $text-color;
border: none;
font-size: 1.1em;
cursor: pointer;
svg.feather {
transition: background 0.1s ease-in;
display: flex;
align-items: center;
justify-content: center;
svg.feather {
transition: background 0.1s ease-in;
display: flex;
align-items: center;
justify-content: center;
margin: 0.5em 0;
width: 2.5em;
height: 2.5em;
margin: 0.5em 0;
width: 2.5em;
height: 2.5em;
border-radius: 50%;
border-radius: 50%;
}
&.reshared, &.liked {
svg.feather {
color: $background;
font-weight: 900;
color: $background;
font-weight: 900;
}
}
}
@@ -213,14 +213,14 @@ main .article-meta {
.action svg.feather {
padding: 0.7em;
box-sizing: border-box;
color: $red;
fill: none;
border: solid $red thin;
box-sizing: border-box;
color: $red;
fill: none;
border: solid $red thin;
}
.action:hover svg.feather {
background: transparentize($red, 0.85);
background: transparentize($red, 0.85);
}
.action.liked svg.feather {
@@ -238,22 +238,22 @@ main .article-meta {
.action svg.feather {
padding: 0.7em;
box-sizing: border-box;
color: $primary;
border: solid $primary thin;
font-weight: 600;
box-sizing: border-box;
color: $primary;
border: solid $primary thin;
font-weight: 600;
}
.action:hover svg.feather {
background: transparentize($primary, 0.85);
background: transparentize($primary, 0.85);
}
.action.reshared svg.feather {
background: $primary;
}
.action.reshared:hover svg.feather {
background: transparentize($primary, 0.75)
color: $primary;
background: transparentize($primary, 0.75)
color: $primary;
}
}
@@ -262,9 +262,9 @@ main .article-meta {
margin: 0 $horizontal-margin;
h2 {
color: $primary;
font-size: 1.5em;
font-weight: 600;
color: $primary;
font-size: 1.5em;
font-weight: 600;
}
summary {
@@ -279,16 +279,16 @@ main .article-meta {
// Respond & delete comment buttons
a.button, form.inline, form.inline input {
padding: 0;
background: none;
color: $text-color;
margin-right: 2em;
font-family: $route159;
padding: 0;
background: none;
color: $text-color;
margin-right: 2em;
font-family: $route159;
font-weight: normal;
&::before {
color: $primary;
padding-right: 0.5em;
&::before {
color: $primary;
padding-right: 0.5em;
}
&:hover { color: $primary; }
@@ -296,8 +296,8 @@ main .article-meta {
.comment {
margin: 1em 0;
font-size: 1em;
border: none;
font-size: 1em;
border: none;
.content {
background: $gray;
@@ -328,36 +328,36 @@ main .article-meta {
color: transparentize($text-color, 0.6);
}
.author {
display: flex;
flex-direction: row;
align-items: center;
align-content: center;
.author {
display: flex;
flex-direction: row;
align-items: center;
align-content: center;
* {
transition: all 0.1s ease-in;
}
* {
transition: all 0.1s ease-in;
}
.display-name {
color: $text-color;
.display-name {
color: $text-color;
}
&:hover {
.display-name { color: $primary; }
small { opacity: 1; }
}
}
}
& > .comment {
padding-left: 2em;
}
.text {
padding: 1.25em 0;
font-family: $lora;
font-size: 1.1em;
line-height: 1.4;
text-align: left;
.text {
padding: 1.25em 0;
font-family: $lora;
font-size: 1.1em;
line-height: 1.4;
text-align: left;
}
}
}
@@ -490,3 +490,30 @@ input:checked ~ .cw-container > .cw-text {
display: inline;
}
}
// Small screens
@media screen and (max-width: 600px) {
#plume-editor header {
flex-direction: column-reverse;
button {
flex: 0 0 0;
}
}
.popup {
top: 10vh;
bottom: 10vh;
left: 1vw;
right: 1vw;
}
main article {
margin: 2.5em .5em;
max-width: none;
}
main .article-meta > *, main .article-meta .comments, main .article-meta > .banner > * {
margin: 0 5%;
}
}
+48 -48
View File
@@ -1,27 +1,27 @@
label {
display: block;
margin: 2em auto .5em;
font-size: 1.2em;
display: block;
margin: 2em auto .5em;
font-size: 1.2em;
}
input, textarea, select {
transition: all 0.1s ease-in;
display: block;
width: 100%;
margin: auto;
padding: 1em;
box-sizing: border-box;
transition: all 0.1s ease-in;
display: block;
width: 100%;
margin: auto;
padding: 1em;
box-sizing: border-box;
-webkit-appearance: textarea;
background: $form-input-background;
color: $text-color;
border: solid $form-input-border thin;
background: $form-input-background;
color: $text-color;
border: solid $form-input-border thin;
font-size: 1.2em;
font-weight: 400;
font-size: 1.2em;
font-weight: 400;
&:focus {
border-color: $primary;
}
&:focus {
border-color: $primary;
}
}
form input[type="submit"] {
margin: 2em auto;
@@ -29,18 +29,18 @@ form input[type="submit"] {
}
textarea {
resize: vertical;
resize: vertical;
overflow-y: scroll;
font-family: $lora;
font-size: 1.1em;
line-height: 1.5;
font-family: $lora;
font-size: 1.1em;
line-height: 1.5;
}
input[type="checkbox"] {
display: inline;
margin: initial;
min-width: initial;
width: initial;
display: inline;
margin: initial;
min-width: initial;
width: initial;
-webkit-appearance: checkbox;
}
@@ -71,31 +71,31 @@ form.inline {
}
.button, .button:visited, input[type="submit"], input[type="submit"].button {
transition: all 0.1s ease-in;
display: inline-block;
transition: all 0.1s ease-in;
display: inline-block;
-webkit-appearance: none;
margin: 0.5em auto;
padding: 0.75em 1em;
margin: 0.5em auto;
padding: 0.75em 1em;
background: $primary;
color: $primary-text-color;
background: $primary;
color: $primary-text-color;
font-weight: bold;
border: none;
cursor: pointer;
cursor: pointer;
&:hover {
background: transparentize($primary, 0.1);
}
&:hover {
background: transparentize($primary, 0.1);
}
&.destructive {
background: $red;
&.destructive {
background: $red;
&:hover {
background: transparentize($red, 0.1);
}
}
}
&.secondary {
background: $gray;
@@ -115,20 +115,20 @@ input[type="submit"] {
form.new-post {
max-width: 60em;
.title {
margin: 0 auto;
padding: 0.75em 0;
margin: 0 auto;
padding: 0.75em 0;
background: none;
border: none;
background: none;
border: none;
font-family: $playfair;
font-size: 2em;
text-align: left;
font-family: $playfair;
font-size: 2em;
text-align: left;
}
textarea {
min-height: 20em;
overflow-y: scroll;
resize: none;
min-height: 20em;
overflow-y: scroll;
resize: none;
-webkit-appearance: textarea;
}
}
+129 -173
View File
@@ -6,43 +6,43 @@ html {
}
html, body {
margin: 0;
padding: 0;
background: $background;
color: $text-color;
font-family: $route159;
margin: 0;
padding: 0;
background: $background;
color: $text-color;
font-family: $route159;
::selection {
background: transparentize($primary, 0.7);
}
::-moz-selection {
::-moz-selection {
background: transparentize($primary, 0.7);
}
}
}
a, a:visited {
color: $primary;
text-decoration: none;
color: $primary;
text-decoration: none;
}
a::selection {
color: $background;
color: $background;
}
a::-moz-selection {
color: $background;
color: $background;
}
small {
margin-left: 1em;
color: transparentize($text-color, 0.6);
font-size: 0.75em;
word-wrap: break-word;
word-break: break-all;
margin-left: 1em;
color: transparentize($text-color, 0.6);
font-size: 0.75em;
word-wrap: break-word;
word-break: break-all;
}
.center {
text-align: center;
font-weight: bold;
opacity: 0.6;
padding: 5em;
text-align: center;
font-weight: bold;
opacity: 0.6;
padding: 5em;
}
.right {
@@ -53,28 +53,28 @@ small {
}
.spaced {
margin: 4rem 0;
margin: 4rem 0;
}
.banner {
background: $gray;
padding-top: 2em;
padding-bottom: 1em;
margin: 3em 0px;
background: $gray;
padding-top: 2em;
padding-bottom: 1em;
margin: 3em 0px;
}
.hidden {
display: none;
appearance: none;
display: none;
appearance: none;
}
/* Main */
body > main > *, .h-feed > * {
margin: 1em $horizontal-margin;
margin: 1em $horizontal-margin;
}
body > main > .h-entry, .h-feed {
margin: 0;
margin: 0;
}
body > main {
@@ -98,18 +98,18 @@ main {
margin-top: 1em;
&.article {
margin: 1em auto 0.5em;
font-family: $playfair;
font-size: 2.5em;
font-weight: normal;
margin: 1em auto 0.5em;
font-family: $playfair;
font-size: 2.5em;
font-weight: normal;
}
}
h2 {
font-size: 1.75em;
font-weight: 300;
font-size: 1.75em;
font-weight: 300;
&.article {
&.article {
font-size: 1.25em;
margin-bottom: 0.5em;
}
@@ -139,15 +139,15 @@ main {
/* Errors */
p.error {
color: $red;
font-weight: bold;
color: $red;
font-weight: bold;
}
/* User page */
.user h1 {
display: flex;
flex-direction: row;
align-items: center;
display: flex;
flex-direction: row;
align-items: center;
margin: 0px;
}
@@ -156,14 +156,14 @@ p.error {
}
.badge {
margin-right: 1em;
padding: 0.35em 1em;
margin-right: 1em;
padding: 0.35em 1em;
background: $background;
color: $primary;
border: 1px solid $primary;
background: $background;
color: $primary;
border: 1px solid $primary;
font-size: 1rem;
font-size: 1rem;
}
.user-summary {
@@ -172,58 +172,97 @@ p.error {
/* Cards */
.cards {
display: flex;
flex-direction: row;
flex-wrap: wrap;
padding: 0 5%;
display: flex;
flex-direction: row;
flex-wrap: wrap;
padding: 0 5%;
margin: 1rem 0 5rem;
}
.card {
flex: 1;
display: flex;
flex-direction: column;
flex: 1;
display: flex;
flex-direction: column;
min-width: 20em;
min-height: 20em;
margin: 1em;
box-sizing: border-box;
position: relative;
background: $gray;
min-width: 20em;
min-height: 20em;
margin: 1em;
box-sizing: border-box;
text-overflow: ellipsis;
background: $gray;
> * {
margin: 20px;
}
text-overflow: ellipsis;
.cover {
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;
}
.cover {
min-height: 10em;
background-position: center;
background-size: cover;
margin: 0px;
&:hover {
opacity: 0.9;
}
}
h3 {
margin: 0.75em 20px;
font-family: $playfair;
font-size: 1.75em;
font-weight: normal;
a {
transition: color 0.1s ease-in;
color: $text-color;
flex-grow: 1;
margin: 0;
font-family: $playfair;
font-size: 1.75em;
font-weight: normal;
line-height: 1.75;
a {
display: block;
transition: color 0.1s ease-in;
color: $text-color;
&:hover { color: $primary; }
}
&:hover { color: $primary; }
}
}
.controls {
float: right;
.button {
margin-top: 0;
margin-bottom: 0;
}
}
main {
flex: 1;
flex: 1;
font-family: $lora;
font-size: 1em;
line-height: 1.25;
text-align: left;
overflow: hidden;
font-family: $lora;
font-size: 1em;
line-height: 1.25;
text-align: left;
overflow: hidden;
}
}
@@ -265,15 +304,15 @@ p.error {
/* Stats */
.stats {
display: flex;
justify-content: space-around;
margin: 2em;
display: flex;
justify-content: space-around;
margin: 2em;
> div {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
> div {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
p {
@@ -469,91 +508,8 @@ 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; }
}
}
body > main > *, .h-feed > * {
margin: 1em;
}
main .article-meta {
@@ -601,7 +557,7 @@ figure {
margin: 0;
& > * {
max-width: 100%;
max-width: 100% !important;
}
}
+262 -58
View File
@@ -3,8 +3,8 @@ body > header {
#content {
display: flex;
align-content: center;
justify-content: space-between;
align-content: center;
justify-content: space-between;
}
nav#menu {
@@ -19,44 +19,44 @@ body > header {
a {
transform: skewX(15deg);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 1.4em;
height: 1.4em;
margin: 0;
padding: 0;
color: $gray;
font-size: 1.33em;
}
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 1.4em;
height: 1.4em;
margin: 0;
padding: 0;
color: $gray;
font-size: 1.33em;
}
}
nav {
display: flex;
flex-direction: row;
align-items: center;
flex-direction: row;
align-items: center;
hr {
height: 100%;
width: 0.2em;
background: $primary;
border: none;
transform: skewX(-15deg);
hr {
height: 100%;
width: 0.2em;
background: $primary;
border: none;
transform: skewX(-15deg);
}
a {
display: flex;
align-items: center;
position: relative;
align-self: stretch;
margin: 0;
padding: 0 2em;
font-size: 1em;
display: flex;
align-items: center;
position: relative;
align-self: stretch;
margin: 0;
padding: 0 2em;
font-size: 1em;
i { font-size: 1.2em; }
i { font-size: 1.2em; }
&.title {
margin: 0;
&.title {
margin: 0;
text-align: center;
padding: 0.5em 1em;
font-size: 1.75em;
@@ -70,7 +70,7 @@ body > header {
margin: 0;
padding-left: 0.5em;
}
}
}
}
}
}
@@ -101,33 +101,237 @@ 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;
}
}
@-webkit-keyframes menuOpening {
from {
-webkit-transform: scaleX(0);
transform-origin: left;
opacity: 0;
}
to {
-webkit-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, .show + #content {
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 {
i {
transition: all 0.2s ease;
margin: 0;
}
.mobile-label {
transition: all 0.2s ease;
display: block;
position: absolute;
left: 50%;
transform: translate(-50%, 0);
opacity: 0;
font-size: 0.9em;
white-space: nowrap;
}
img + .mobile-label { display: none; }
&:hover {
i { margin-bottom: 0.75em; }
.mobile-label {
opacity: 1;
transform: translate(-50%, 80%);
}
header nav a {
i {
transition: all 0.2s ease;
margin: 0;
}
}
.mobile-label {
transition: all 0.2s ease;
display: block;
position: absolute;
left: 50%;
transform: translateZ(0);
opacity: 0;
font-size: 0.9em;
white-space: nowrap;
}
img + .mobile-label { display: none; }
&:hover {
i { margin-bottom: 0.75em; }
.mobile-label {
opacity: 1;
transform: translate(-50%, 80%);
}
}
}
}
// 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;
}
}
@-webkit-keyframes menuOpening {
from {
-webkit-transform: scaleX(0);
transform-origin: left;
opacity: 0;
}
to {
-webkit-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, .show + #content {
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; }
}
}
}
}
+9 -9
View File
@@ -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;
+11 -9
View File
@@ -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.
@@ -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.
@@ -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;
}
+11 -9
View File
@@ -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";
+7 -15
View File
@@ -1,5 +1,3 @@
use rsass;
use ructe::Ructe;
use std::process::{Command, Stdio};
use std::{ffi::OsStr, fs::*, io::Write, path::*};
@@ -50,19 +48,13 @@ fn main() {
create_dir_all(&Path::new("static").join("media")).expect("Couldn't init media directory");
let cache_id = &compute_static_hash()[..8];
println!("cargo:rerun-if-changed=target/deploy/plume-front.wasm");
copy("target/deploy/plume-front.wasm", "static/plume-front.wasm")
.and_then(|_| read_to_string("target/deploy/plume-front.js"))
.and_then(|js| {
write(
"static/plume-front.js",
js.replace(
"\"plume-front.wasm\"",
&format!("\"/static/cached/{}/plume-front.wasm\"", cache_id),
),
)
})
.ok();
println!("cargo:rerun-if-changed=plume-front/pkg/plume_front_bg.wasm");
copy(
"plume-front/pkg/plume_front_bg.wasm",
"static/plume_front_bg.wasm",
)
.and_then(|_| copy("plume-front/pkg/plume_front.js", "static/plume_front.js"))
.ok();
println!("cargo:rustc-env=CACHE_ID={}", cache_id)
}
+2 -2
View File
@@ -1,5 +1,5 @@
"project_identifier": "plume"
"api_key_env": CROWDIN_API_KEY
"project_id": 352097
"api_token_env": "CROWDIN_API_KEY"
preserve_hierarchy: true
files:
- source: /po/plume/plume.pot
@@ -0,0 +1 @@
DROP INDEX medias_index_file_path;
@@ -0,0 +1 @@
CREATE INDEX medias_index_file_path ON medias (file_path);
@@ -0,0 +1 @@
DROP INDEX medias_index_file_path;
@@ -0,0 +1 @@
CREATE INDEX medias_index_file_path ON medias (file_path);
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "plume-api"
version = "0.4.0"
version = "0.6.1-dev"
authors = ["Plume contributors"]
edition = "2018"
+2
View File
@@ -0,0 +1,2 @@
pre-release-hook = ["cargo", "fmt"]
pre-release-replacements = []
+8 -3
View File
@@ -1,6 +1,6 @@
[package]
name = "plume-cli"
version = "0.4.0"
version = "0.6.1-dev"
authors = ["Plume contributors"]
edition = "2018"
@@ -8,14 +8,18 @@ edition = "2018"
name = "plm"
path = "src/main.rs"
[[bin]]
name = "remove-dup-images"
path = "src/remove-dup-images.rs"
[dependencies]
clap = "2.33"
dotenv = "0.14"
rpassword = "4.0"
rpassword = "5.0.0"
[dependencies.diesel]
features = ["r2d2", "chrono"]
version = "*"
version = "1.4.5"
[dependencies.plume-models]
path = "../plume-models"
@@ -23,3 +27,4 @@ path = "../plume-models"
[features]
postgres = ["plume-models/postgres", "diesel/postgres"]
sqlite = ["plume-models/sqlite", "diesel/sqlite"]
search-lindera = ["plume-models/search-lindera"]
+2
View File
@@ -0,0 +1,2 @@
pre-release-hook = ["cargo", "fmt"]
pre-release-replacements = []
-2
View File
@@ -1,5 +1,3 @@
use dotenv;
use clap::App;
use diesel::Connection;
use plume_models::{instance::Instance, Connection as Conn, CONFIG};
+149
View File
@@ -0,0 +1,149 @@
use diesel::{
BoolExpressionMethods, Connection, ExpressionMethods, JoinOnDsl, NullableExpressionMethods,
QueryDsl, RunQueryDsl,
};
use plume_models::{
blogs::Blog, instance::Instance, medias::Media, posts::Post, Connection as Conn, CONFIG,
};
use std::collections::hash_map::{DefaultHasher, HashMap};
use std::fs::File;
use std::hash::Hasher;
use std::io::{BufReader, Read};
use std::path::Path;
fn main() {
match dotenv::dotenv() {
Ok(path) => eprintln!("Configuration read from {}", path.display()),
Err(ref e) if e.not_found() => eprintln!("no .env was found"),
e => e.map(|_| ()).unwrap(),
}
let conn = Conn::establish(CONFIG.database_url.as_str()).expect("extablish connection");
Instance::cache_local(&conn);
let covers = get_remote_post_covers(&conn);
let remote_media_hashes = calculate_remote_media_hashes(covers);
eprintln!("remote medias: {:?}", remote_media_hashes);
let orphan_medias = get_orphan_medias(&conn);
eprintln!("{:?} orphan media(s)", orphan_medias.len());
for media in orphan_medias {
match calculate_file_hash(&Path::new(&media.file_path)) {
Some(hash) => {
match remote_media_hashes.get(&hash) {
Some(file_path) => {
eprintln!(
"File already referred. Removes only medias record. {}",
&file_path
);
// Remove medias record
diesel::delete(&media)
.execute(&conn)
.expect("Delete medias record");
}
None => {
eprintln!("Removes {}", &media.file_path);
// Remove file and medias record
media.delete(&conn).expect("Delete media record and file");
}
}
}
None => {
eprintln!(
"File doesn't exist. Removes medias record. medias.id: {}, path: {}",
&media.id, &media.file_path
);
diesel::delete(&media)
.execute(&conn)
.expect("Delete medias record");
}
}
}
}
fn get_remote_post_covers(conn: &Conn) -> Vec<Media> {
use plume_models::schema::blogs;
use plume_models::schema::posts;
let remote_instances = Instance::get_remotes(&conn).expect("get remote instances");
let remote_instance_ids = remote_instances.iter().map(|instance| instance.id);
let remote_blogs = blogs::table
.filter(blogs::instance_id.eq_any(remote_instance_ids))
.load::<Blog>(conn)
.expect("remote blogs");
let remote_blog_ids = remote_blogs.iter().map(|blog| blog.id);
let remote_posts = posts::table
.filter(posts::blog_id.eq_any(remote_blog_ids))
.load::<Post>(conn)
.expect("remote posts");
remote_posts
.iter()
.filter_map(|post| post.cover_id)
.map(|cover_id| Media::get(conn, cover_id).expect("Media"))
.collect()
}
fn calculate_remote_media_hashes(medias: Vec<Media>) -> HashMap<u64, String> {
let mut media_hashes = HashMap::new();
for media in medias.iter() {
if let Some(hash) = calculate_file_hash(Path::new(&media.file_path)) {
let _ = media_hashes.insert(hash, media.file_path.clone());
}
}
media_hashes
}
fn calculate_file_hash(path: &Path) -> Option<u64> {
if !path.exists() {
return None;
}
let file = File::open(path).expect("open file");
let mut reader = BufReader::new(file);
let mut hasher = DefaultHasher::new();
let mut buffer = [0; 2048];
while let Ok(n) = reader.read(&mut buffer) {
hasher.write(&buffer);
if n == 0 {
break;
}
}
Some(hasher.finish())
}
fn get_orphan_medias(conn: &Conn) -> Vec<Media> {
use plume_models::schema::{self, medias};
use plume_models::schema::{blogs::dsl::blogs, posts::dsl::posts, users::dsl::users};
let query = medias::table
.select((
medias::id,
medias::file_path,
medias::alt_text,
medias::is_remote,
medias::remote_url,
medias::sensitive,
medias::content_warning,
medias::owner_id,
))
.left_outer_join(users.on(schema::users::avatar_id.eq(medias::id.nullable())))
.left_outer_join(
blogs.on(schema::blogs::icon_id
.eq(medias::id.nullable())
.or(schema::blogs::banner_id.eq(medias::id.nullable()))),
)
.left_outer_join(posts.on(schema::posts::cover_id.eq(medias::id.nullable())))
.filter(
schema::users::avatar_id.is_null().and(
schema::blogs::icon_id.is_null().and(
schema::blogs::banner_id.is_null().and(
schema::posts::cover_id
.is_null()
.and(medias::is_remote.eq(false)),
),
),
),
);
eprintln!(
"query for orphan medias: {}",
diesel::debug_query::<_, _>(&query)
);
query.load::<Media>(conn).expect("Load orphan medias")
}
+4 -3
View File
@@ -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,14 +98,15 @@ 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");
searcher.commit();
}
fn unlock<'a>(args: &ArgMatches<'a>) {
fn unlock(args: &ArgMatches) {
let path = match args.value_of("path") {
None => Path::new(&CONFIG.search_index),
Some(x) => Path::new(x),
+1 -2
View File
@@ -1,7 +1,6 @@
use clap::{App, Arg, ArgMatches, SubCommand};
use plume_models::{instance::Instance, users::*, Connection};
use rpassword;
use std::io::{self, Write};
pub fn command<'a, 'b>() -> App<'a, 'b> {
@@ -132,7 +131,7 @@ fn new<'a>(args: &ArgMatches<'a>, conn: &Connection) {
role,
&bio,
email,
User::hash_pass(&password).expect("Couldn't hash password"),
Some(User::hash_pass(&password).expect("Couldn't hash password")),
)
.expect("Couldn't save new user");
}
+9 -6
View File
@@ -1,6 +1,6 @@
[package]
name = "plume-common"
version = "0.4.0"
version = "0.6.1-dev"
authors = ["Plume contributors"]
edition = "2018"
@@ -14,14 +14,16 @@ heck = "0.3.0"
hex = "0.3"
hyper = "0.12.33"
openssl = "0.10.22"
rocket = "0.4.0"
reqwest = "0.9"
rocket = "0.4.6"
reqwest = { version = "0.9", features = ["socks"] }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
shrinkwraprs = "0.2.1"
syntect = "3.3"
shrinkwraprs = "0.3.0"
syntect = "4.5.0"
tokio = "0.1.22"
regex-syntax = { version = "0.6.17", default-features = false, features = ["unicode-perl"] }
tracing = "0.1.22"
[dependencies.chrono]
features = ["serde"]
@@ -29,4 +31,5 @@ version = "0.4"
[dependencies.pulldown-cmark]
default-features = false
version = "0.2.0"
git = "https://git.joinplu.me/Plume/pulldown-cmark"
branch = "bidi-plume"
+2
View File
@@ -0,0 +1,2 @@
pre-release-hook = ["cargo", "fmt"]
pre-release-replacements = []
+75 -39
View File
@@ -71,8 +71,8 @@ use std::fmt::Debug;
/// # let conn = ();
/// #
/// let result: Result<(), ()> = Inbox::handle(&conn, activity_json)
/// .with::<User, Announce, Message>()
/// .with::<User, Create, Message>()
/// .with::<User, Announce, Message>(None)
/// .with::<User, Create, Message>(None)
/// .done();
/// ```
pub enum Inbox<'a, C, E, R>
@@ -144,7 +144,7 @@ where
}
/// Registers an handler on this Inbox.
pub fn with<A, V, M>(self) -> Inbox<'a, C, E, R>
pub fn with<A, V, M>(self, proxy: Option<&reqwest::Proxy>) -> Inbox<'a, C, E, R>
where
A: AsActor<&'a C> + FromId<C, Error = E>,
V: activitypub::Activity,
@@ -164,11 +164,17 @@ where
Some(x) => x,
None => return Inbox::NotHandled(ctx, act, InboxError::InvalidActor(None)),
};
if Self::is_spoofed_activity(&actor_id, &act) {
return Inbox::NotHandled(ctx, act, InboxError::InvalidObject(None));
}
// Transform this actor to a model (see FromId for details about the from_id function)
let actor = match A::from_id(
ctx,
&actor_id,
serde_json::from_value(act["actor"].clone()).ok(),
proxy,
) {
Ok(a) => a,
// If the actor was not found, go to the next handler
@@ -189,6 +195,7 @@ where
ctx,
&obj_id,
serde_json::from_value(act["object"].clone()).ok(),
proxy,
) {
Ok(o) => o,
Err((json, e)) => {
@@ -222,6 +229,26 @@ where
Inbox::Failed(err) => Err(err),
}
}
fn is_spoofed_activity(actor_id: &str, act: &serde_json::Value) -> bool {
use serde_json::Value::{Array, Object, String};
let attributed_to = act["object"].get("attributedTo");
if attributed_to.is_none() {
return false;
}
let attributed_to = attributed_to.unwrap();
match attributed_to {
Array(v) => v.iter().all(|i| match i {
String(s) => s != actor_id,
Object(obj) => obj.get("id").map_or(true, |s| s != actor_id),
_ => false,
}),
String(s) => s != actor_id,
Object(obj) => obj.get("id").map_or(true, |s| s != actor_id),
_ => false,
}
}
}
/// Get the ActivityPub ID of a JSON value.
@@ -267,43 +294,52 @@ pub trait FromId<C>: Sized {
ctx: &C,
id: &str,
object: Option<Self::Object>,
proxy: Option<&reqwest::Proxy>,
) -> Result<Self, (Option<serde_json::Value>, Self::Error)> {
match Self::from_db(ctx, id) {
Ok(x) => Ok(x),
_ => match object {
Some(o) => Self::from_activity(ctx, o).map_err(|e| (None, e)),
None => Self::from_activity(ctx, Self::deref(id)?).map_err(|e| (None, e)),
None => Self::from_activity(ctx, Self::deref(id, proxy.cloned())?)
.map_err(|e| (None, e)),
},
}
}
/// Dereferences an ID
fn deref(id: &str) -> Result<Self::Object, (Option<serde_json::Value>, Self::Error)> {
reqwest::ClientBuilder::new()
.connect_timeout(Some(std::time::Duration::from_secs(5)))
.build()
.map_err(|_| (None, InboxError::DerefError.into()))?
.get(id)
.header(
ACCEPT,
HeaderValue::from_str(
&super::ap_accept_header()
.into_iter()
.collect::<Vec<_>>()
.join(", "),
)
.map_err(|_| (None, InboxError::DerefError.into()))?,
fn deref(
id: &str,
proxy: Option<reqwest::Proxy>,
) -> Result<Self::Object, (Option<serde_json::Value>, Self::Error)> {
if let Some(proxy) = proxy {
reqwest::ClientBuilder::new().proxy(proxy)
} else {
reqwest::ClientBuilder::new()
}
.connect_timeout(Some(std::time::Duration::from_secs(5)))
.build()
.map_err(|_| (None, InboxError::DerefError.into()))?
.get(id)
.header(
ACCEPT,
HeaderValue::from_str(
&super::ap_accept_header()
.into_iter()
.collect::<Vec<_>>()
.join(", "),
)
.send()
.map_err(|_| (None, InboxError::DerefError))
.and_then(|mut r| {
let json: serde_json::Value = r
.json()
.map_err(|_| (None, InboxError::InvalidObject(None)))?;
serde_json::from_value(json.clone())
.map_err(|_| (Some(json), InboxError::InvalidObject(None)))
})
.map_err(|(json, e)| (json, e.into()))
.map_err(|_| (None, InboxError::DerefError.into()))?,
)
.send()
.map_err(|_| (None, InboxError::DerefError))
.and_then(|mut r| {
let json: serde_json::Value = r
.json()
.map_err(|_| (None, InboxError::InvalidObject(None)))?;
serde_json::from_value(json.clone())
.map_err(|_| (Some(json), InboxError::InvalidObject(None)))
})
.map_err(|(json, e)| (json, e.into()))
}
/// Builds a `Self` from its ActivityPub representation
@@ -525,7 +561,7 @@ mod tests {
fn test_inbox_basic() {
let act = serde_json::to_value(build_create()).unwrap();
let res: Result<(), ()> = Inbox::handle(&(), act)
.with::<MyActor, Create, MyObject>()
.with::<MyActor, Create, MyObject>(None)
.done();
assert!(res.is_ok());
}
@@ -534,10 +570,10 @@ mod tests {
fn test_inbox_multi_handlers() {
let act = serde_json::to_value(build_create()).unwrap();
let res: Result<(), ()> = Inbox::handle(&(), act)
.with::<MyActor, Announce, MyObject>()
.with::<MyActor, Delete, MyObject>()
.with::<MyActor, Create, MyObject>()
.with::<MyActor, Like, MyObject>()
.with::<MyActor, Announce, MyObject>(None)
.with::<MyActor, Delete, MyObject>(None)
.with::<MyActor, Create, MyObject>(None)
.with::<MyActor, Like, MyObject>(None)
.done();
assert!(res.is_ok());
}
@@ -547,8 +583,8 @@ mod tests {
let act = serde_json::to_value(build_create()).unwrap();
// Create is not handled by this inbox
let res: Result<(), ()> = Inbox::handle(&(), act)
.with::<MyActor, Announce, MyObject>()
.with::<MyActor, Like, MyObject>()
.with::<MyActor, Announce, MyObject>(None)
.with::<MyActor, Like, MyObject>(None)
.done();
assert!(res.is_err());
}
@@ -596,13 +632,13 @@ mod tests {
let act = serde_json::to_value(build_create()).unwrap();
let res: Result<(), ()> = Inbox::handle(&(), act.clone())
.with::<FailingActor, Create, MyObject>()
.with::<FailingActor, Create, MyObject>(None)
.done();
assert!(res.is_err());
let res: Result<(), ()> = Inbox::handle(&(), act.clone())
.with::<FailingActor, Create, MyObject>()
.with::<MyActor, Create, MyObject>()
.with::<FailingActor, Create, MyObject>(None)
.with::<MyActor, Create, MyObject>(None)
.done();
assert!(res.is_ok());
}
+46 -23
View File
@@ -1,14 +1,14 @@
use activitypub::{Activity, Link, Object};
use array_tool::vec::Uniq;
use reqwest::r#async::ClientBuilder;
use reqwest::{header::HeaderValue, r#async::ClientBuilder, Url};
use rocket::{
http::Status,
request::{FromRequest, Request},
response::{Responder, Response},
Outcome,
};
use serde_json;
use tokio::prelude::*;
use tracing::{debug, warn};
use self::sign::Signable;
@@ -108,7 +108,7 @@ impl<'a, 'r> FromRequest<'a, 'r> for ApRequest {
.unwrap_or(Outcome::Forward(()))
}
}
pub fn broadcast<S, A, T, C>(sender: &S, act: A, to: Vec<T>)
pub fn broadcast<S, A, T, C>(sender: &S, act: A, to: Vec<T>, proxy: Option<reqwest::Proxy>)
where
S: sign::Signer,
A: Activity,
@@ -132,31 +132,54 @@ where
let mut rt = tokio::runtime::current_thread::Runtime::new()
.expect("Error while initializing tokio runtime for federation");
let client = ClientBuilder::new()
.connect_timeout(std::time::Duration::from_secs(5))
.build()
.expect("Can't build client");
for inbox in boxes {
let body = signed.to_string();
let mut headers = request::headers();
let url = Url::parse(&inbox);
if url.is_err() {
warn!("Inbox is invalid URL: {:?}", &inbox);
continue;
}
let url = url.unwrap();
if !url.has_host() {
warn!("Inbox doesn't have host: {:?}", &inbox);
continue;
};
let host_header_value = HeaderValue::from_str(&url.host_str().expect("Unreachable"));
if host_header_value.is_err() {
warn!("Header value is invalid: {:?}", url.host_str());
continue;
}
headers.insert("Host", host_header_value.unwrap());
headers.insert("Digest", request::Digest::digest(&body));
rt.spawn(
client
.post(&inbox)
.headers(headers.clone())
.header(
"Signature",
request::signature(sender, &headers)
.expect("activity_pub::broadcast: request signature error"),
)
.body(body)
.send()
.and_then(|r| r.into_body().concat2())
.map(move |response| {
println!("Successfully sent activity to inbox ({})", inbox);
println!("Response: \"{:?}\"\n", response)
})
.map_err(|e| println!("Error while sending to inbox ({:?})", e)),
if let Some(proxy) = proxy.clone() {
ClientBuilder::new().proxy(proxy)
} else {
ClientBuilder::new()
}
.connect_timeout(std::time::Duration::from_secs(5))
.build()
.expect("Can't build client")
.post(&inbox)
.headers(headers.clone())
.header(
"Signature",
request::signature(sender, &headers, ("post", url.path(), url.query()))
.expect("activity_pub::broadcast: request signature error"),
)
.body(body)
.send()
.and_then(move |r| {
if r.status().is_success() {
debug!("Successfully sent activity to inbox ({})", &inbox);
} else {
warn!("Error while sending to inbox ({:?})", &r)
}
r.into_body().concat2()
})
.map(move |response| debug!("Response: \"{:?}\"\n", response))
.map_err(|e| warn!("Error while sending to inbox ({:?})", e)),
);
}
rt.run().unwrap();
+101 -20
View File
@@ -1,15 +1,18 @@
use base64;
use chrono::{offset::Utc, DateTime};
use openssl::hash::{Hasher, MessageDigest};
use reqwest::header::{HeaderMap, HeaderValue, ACCEPT, CONTENT_TYPE, DATE, USER_AGENT};
use std::ops::Deref;
use std::time::SystemTime;
use tracing::warn;
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"));
#[derive(Debug)]
pub struct Error();
pub struct Digest(String);
impl Digest {
@@ -62,16 +65,16 @@ impl Digest {
base64::decode(&self.0[pos..]).expect("Digest::value: invalid encoding error")
}
pub fn from_header(dig: &str) -> Result<Self, ()> {
pub fn from_header(dig: &str) -> Result<Self, Error> {
if let Some(pos) = dig.find('=') {
let pos = pos + 1;
if base64::decode(&dig[pos..]).is_ok() {
Ok(Digest(dig.to_owned()))
} else {
Err(())
Err(Error())
}
} else {
Err(())
Err(Error())
}
}
@@ -110,27 +113,47 @@ pub fn headers() -> HeaderMap {
headers
}
pub fn signature<S: Signer>(signer: &S, headers: &HeaderMap) -> Result<HeaderValue, ()> {
let signed_string = headers
type Method<'a> = &'a str;
type Path<'a> = &'a str;
type Query<'a> = &'a str;
type RequestTarget<'a> = (Method<'a>, Path<'a>, Option<Query<'a>>);
pub fn signature<S: Signer>(
signer: &S,
headers: &HeaderMap,
request_target: RequestTarget,
) -> Result<HeaderValue, Error> {
let (method, path, query) = request_target;
let origin_form = if let Some(query) = query {
format!("{}?{}", path, query)
} else {
path.to_string()
};
let mut headers_vec = Vec::with_capacity(headers.len());
for (h, v) in headers.iter() {
let v = v.to_str();
if v.is_err() {
warn!("invalid header error: {:?}", v.unwrap_err());
return Err(Error());
}
headers_vec.push((h.as_str().to_lowercase(), v.expect("Unreachable")));
}
let request_target = format!("{} {}", method.to_lowercase(), origin_form);
headers_vec.push(("(request-target)".to_string(), &request_target));
let signed_string = headers_vec
.iter()
.map(|(h, v)| {
format!(
"{}: {}",
h.as_str().to_lowercase(),
v.to_str()
.expect("request::signature: invalid header error")
)
})
.map(|(h, v)| format!("{}: {}", h, v))
.collect::<Vec<String>>()
.join("\n");
let signed_headers = headers
let signed_headers = headers_vec
.iter()
.map(|(h, _)| h.as_str())
.map(|(h, _)| h.as_ref())
.collect::<Vec<&str>>()
.join(" ")
.to_lowercase();
.join(" ");
let data = signer.sign(&signed_string).map_err(|_| ())?;
let data = signer.sign(&signed_string).map_err(|_| Error())?;
let sign = base64::encode(&data);
HeaderValue::from_str(&format!(
@@ -138,5 +161,63 @@ pub fn signature<S: Signer>(signer: &S, headers: &HeaderMap) -> Result<HeaderVal
key_id = signer.get_key_id(),
signed_headers = signed_headers,
signature = sign
)).map_err(|_| ())
)).map_err(|_| Error())
}
#[cfg(test)]
mod tests {
use super::{signature, Error};
use crate::activity_pub::sign::{gen_keypair, Signer};
use openssl::{hash::MessageDigest, pkey::PKey, rsa::Rsa};
use reqwest::header::HeaderMap;
struct MySigner {
public_key: String,
private_key: String,
}
impl MySigner {
fn new() -> Self {
let (pub_key, priv_key) = gen_keypair();
Self {
public_key: String::from_utf8(pub_key).unwrap(),
private_key: String::from_utf8(priv_key).unwrap(),
}
}
}
impl Signer for MySigner {
type Error = Error;
fn get_key_id(&self) -> String {
"mysigner".into()
}
fn sign(&self, to_sign: &str) -> Result<Vec<u8>, Self::Error> {
let key = PKey::from_rsa(Rsa::private_key_from_pem(self.private_key.as_ref()).unwrap())
.unwrap();
let mut signer = openssl::sign::Signer::new(MessageDigest::sha256(), &key).unwrap();
signer.update(to_sign.as_bytes()).unwrap();
signer.sign_to_vec().map_err(|_| Error())
}
fn verify(&self, data: &str, signature: &[u8]) -> Result<bool, Self::Error> {
let key = PKey::from_rsa(Rsa::public_key_from_pem(self.public_key.as_ref()).unwrap())
.unwrap();
let mut verifier = openssl::sign::Verifier::new(MessageDigest::sha256(), &key).unwrap();
verifier.update(data.as_bytes()).unwrap();
verifier.verify(&signature).map_err(|_| Error())
}
}
#[test]
fn test_signature_request_target() {
let signer = MySigner::new();
let headers = HeaderMap::new();
let result = signature(&signer, &headers, ("post", "/inbox", None)).unwrap();
let fields: Vec<&str> = result.to_str().unwrap().split(",").collect();
assert_eq!(r#"headers="(request-target)""#, fields[2]);
let sign = &fields[3][11..(fields[3].len() - 1)];
assert!(signer.verify("post /inbox", sign.as_bytes()).is_ok());
}
}
+6 -6
View File
@@ -1,10 +1,7 @@
use super::request;
use base64;
use chrono::{naive::NaiveDateTime, DateTime, Duration, Utc};
use hex;
use openssl::{pkey::PKey, rsa::Rsa, sha::sha256};
use rocket::http::HeaderMap;
use serde_json;
/// Returns (public key, private key)
pub fn gen_keypair() -> (Vec<u8>, Vec<u8>) {
@@ -20,6 +17,9 @@ pub fn gen_keypair() -> (Vec<u8>, Vec<u8>) {
)
}
#[derive(Debug)]
pub struct Error();
pub trait Signer {
type Error;
@@ -32,7 +32,7 @@ pub trait Signer {
}
pub trait Signable {
fn sign<T>(&mut self, creator: &T) -> Result<&mut Self, ()>
fn sign<T>(&mut self, creator: &T) -> Result<&mut Self, Error>
where
T: Signer;
fn verify<T>(self, creator: &T) -> bool
@@ -46,7 +46,7 @@ pub trait Signable {
}
impl Signable for serde_json::Value {
fn sign<T: Signer>(&mut self, creator: &T) -> Result<&mut serde_json::Value, ()> {
fn sign<T: Signer>(&mut self, creator: &T) -> Result<&mut serde_json::Value, Error> {
let creation_date = Utc::now().to_rfc3339();
let mut options = json!({
"type": "RsaSignature2017",
@@ -64,7 +64,7 @@ impl Signable for serde_json::Value {
let document_hash = Self::hash(&self.to_string());
let to_be_signed = options_hash + &document_hash;
let signature = base64::encode(&creator.sign(&to_be_signed).map_err(|_| ())?);
let signature = base64::encode(&creator.sign(&to_be_signed).map_err(|_| Error())?);
options["signatureValue"] = serde_json::Value::String(signature);
self["signature"] = options;
Regular → Executable
-3
View File
@@ -2,9 +2,6 @@
#[macro_use]
extern crate activitystreams_derive;
use activitystreams_traits;
use serde;
#[macro_use]
extern crate shrinkwraprs;
#[macro_use]
+83 -44
View File
@@ -1,13 +1,13 @@
use heck::CamelCase;
use openssl::rand::rand_bytes;
use pulldown_cmark::{html, Event, Options, Parser, Tag};
use pulldown_cmark::{html, CodeBlockKind, CowStr, Event, LinkType, Options, Parser, Tag};
use regex_syntax::is_word_character;
use rocket::{
http::uri::Uri,
response::{Flash, Redirect},
};
use std::borrow::Cow;
use std::collections::HashSet;
use syntect::html::ClassedHTMLGenerator;
use syntect::html::{ClassStyle, ClassedHTMLGenerator};
use syntect::parsing::SyntaxSet;
/// Generates an hexadecimal representation of 32 bytes of random data
@@ -50,46 +50,61 @@ enum State {
fn to_inline(tag: Tag<'_>) -> Tag<'_> {
match tag {
Tag::Header(_) | Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell => {
Tag::Heading(_) | Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell => {
Tag::Paragraph
}
Tag::Image(url, title) => Tag::Link(url, title),
Tag::Image(typ, url, title) => Tag::Link(typ, url, title),
t => t,
}
}
struct HighlighterContext {
content: Vec<String>,
}
#[allow(clippy::unnecessary_wraps)]
fn highlight_code<'a>(
context: &mut Option<HighlighterContext>,
evt: Event<'a>,
) -> Option<Vec<Event<'a>>> {
match evt {
Event::Start(Tag::CodeBlock(lang)) => {
if lang.is_empty() {
Some(vec![Event::Start(Tag::CodeBlock(lang))])
} else {
*context = Some(HighlighterContext { content: vec![] });
Some(vec![Event::Start(Tag::CodeBlock(lang))])
Event::Start(Tag::CodeBlock(kind)) => {
match &kind {
CodeBlockKind::Fenced(lang) if !lang.is_empty() => {
*context = Some(HighlighterContext { content: vec![] });
}
_ => {}
}
Some(vec![Event::Start(Tag::CodeBlock(kind))])
}
Event::End(Tag::CodeBlock(x)) => {
Event::End(Tag::CodeBlock(kind)) => {
let mut result = vec![];
if let Some(ctx) = context.take() {
let lang = if let CodeBlockKind::Fenced(lang) = &kind {
if lang.is_empty() {
unreachable!();
} else {
lang
}
} else {
unreachable!();
};
let syntax_set = SyntaxSet::load_defaults_newlines();
let syntax = syntax_set.find_syntax_by_token(&x).unwrap_or_else(|| {
let syntax = syntax_set.find_syntax_by_token(&lang).unwrap_or_else(|| {
syntax_set
.find_syntax_by_name(&x)
.find_syntax_by_name(&lang)
.unwrap_or_else(|| syntax_set.find_syntax_plain_text())
});
let mut html = ClassedHTMLGenerator::new(&syntax, &syntax_set);
let mut html = ClassedHTMLGenerator::new_with_class_style(
&syntax,
&syntax_set,
ClassStyle::Spaced,
);
for line in ctx.content {
html.parse_html_for_line(&line);
html.parse_html_for_line_which_includes_newline(&line);
}
let q = html.finalize();
result.push(Event::Html(q.into()));
}
result.push(Event::End(Tag::CodeBlock(x)));
result.push(Event::End(Tag::CodeBlock(kind)));
*context = None;
Some(result)
}
@@ -105,6 +120,7 @@ fn highlight_code<'a>(
_ => Some(vec![evt]),
}
}
#[allow(clippy::unnecessary_wraps)]
fn flatten_text<'a>(state: &mut Option<String>, evt: Event<'a>) -> Option<Vec<Event<'a>>> {
let (s, res) = match evt {
Event::Text(txt) => match state.take() {
@@ -112,10 +128,10 @@ fn flatten_text<'a>(state: &mut Option<String>, evt: Event<'a>) -> Option<Vec<Ev
prev_txt.push_str(&txt);
(Some(prev_txt), vec![])
}
None => (Some(txt.into_owned()), vec![]),
None => (Some(txt.into_string()), vec![]),
},
e => match state.take() {
Some(prev) => (None, vec![Event::Text(Cow::Owned(prev)), e]),
Some(prev) => (None, vec![Event::Text(CowStr::Boxed(prev.into())), e]),
None => (None, vec![e]),
},
};
@@ -123,6 +139,7 @@ fn flatten_text<'a>(state: &mut Option<String>, evt: Event<'a>) -> Option<Vec<Ev
Some(res)
}
#[allow(clippy::unnecessary_wraps)]
fn inline_tags<'a>(
(state, inline): &mut (Vec<Tag<'a>>, bool),
evt: Event<'a>,
@@ -155,42 +172,45 @@ fn process_image<'a, 'b>(
) -> Event<'a> {
if let Some(ref processor) = *processor {
match evt {
Event::Start(Tag::Image(id, title)) => {
Event::Start(Tag::Image(typ, id, title)) => {
if let Some((url, cw)) = id.parse::<i32>().ok().and_then(processor.as_ref()) {
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}">
Event::Html(CowStr::Boxed(
format!(
r#"<label for="postcontent-cw-{id}">
<input type="checkbox" id="postcontent-cw-{id}" checked="checked" class="cw-checkbox">
<span class="cw-container">
<span class="cw-text">
{cw}
</span>
<img src="{url}" alt=""#,
id = random_hex(),
cw = cw,
url = url
)))
id = random_hex(),
cw = cw,
url = url
)
.into(),
))
} else {
Event::Start(Tag::Image(Cow::Owned(url), title))
Event::Start(Tag::Image(typ, CowStr::Boxed(url.into()), title))
}
} else {
Event::Start(Tag::Image(id, title))
Event::Start(Tag::Image(typ, id, title))
}
}
Event::End(Tag::Image(id, title)) => {
Event::End(Tag::Image(typ, id, title)) => {
if let Some((url, cw)) = id.parse::<i32>().ok().and_then(processor.as_ref()) {
if inline || cw.is_none() {
Event::End(Tag::Image(Cow::Owned(url), title))
Event::End(Tag::Image(typ, CowStr::Boxed(url.into()), title))
} else {
Event::Html(Cow::Borrowed(
Event::Html(CowStr::Borrowed(
r#""/>
</span>
</label>"#,
))
}
} else {
Event::End(Tag::Image(id, title))
Event::End(Tag::Image(typ, id, title))
}
}
e => e,
@@ -200,6 +220,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,
@@ -223,13 +249,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 {
Event::Start(Tag::CodeBlock(_)) | Event::Start(Tag::Code) => {
*in_code = true;
.scan(&mut DocumentContext::default(), |ctx, evt| match evt {
Event::Start(Tag::CodeBlock(_)) => {
ctx.in_code = true;
Some((vec![evt], vec![], vec![]))
}
Event::End(Tag::CodeBlock(_)) | Event::End(Tag::Code) => {
*in_code = false;
Event::End(Tag::CodeBlock(_)) => {
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) => {
@@ -249,6 +283,7 @@ pub fn md_to_html<'a>(
let mention = text_acc;
let short_mention = mention.splitn(1, '@').next().unwrap_or("");
let link = Tag::Link(
LinkType::Inline,
format!("{}@/{}/", base_url, &mention).into(),
short_mention.to_owned().into(),
);
@@ -269,7 +304,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)
@@ -279,8 +314,8 @@ pub fn md_to_html<'a>(
}
let hashtag = text_acc;
let link = Tag::Link(
format!("{}tag/{}", base_url, &hashtag.to_camel_case())
.into(),
LinkType::Inline,
format!("{}tag/{}", base_url, &hashtag).into(),
hashtag.to_owned().into(),
);
@@ -300,7 +335,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 +345,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 +434,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 +460,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 {
@@ -441,11 +480,11 @@ mod tests {
fn test_inline() {
assert_eq!(
md_to_html("# Hello", None, false, None).0,
String::from("<h1>Hello</h1>\n")
String::from("<h1 dir=\"auto\">Hello</h1>\n")
);
assert_eq!(
md_to_html("# Hello", None, true, None).0,
String::from("<p>Hello</p>\n")
String::from("<p dir=\"auto\">Hello</p>\n")
);
}
}
+40 -3
View File
@@ -1,15 +1,52 @@
[package]
name = "plume-front"
version = "0.4.0"
version = "0.6.1-dev"
authors = ["Plume contributors"]
edition = "2018"
[lib]
crate-type = ["cdylib"]
[dependencies]
stdweb = "=0.4.18"
stdweb-internal-runtime = "=0.1.4"
gettext = { git = "https://github.com/Plume-org/gettext/", rev = "294c54d74c699fbc66502b480a37cc66c1daa7f3" }
gettext-macros = { git = "https://github.com/Plume-org/gettext-macros/", rev = "a7c605f7edd6bfbfbfe7778026bfefd88d82db10" }
gettext-utils = { git = "https://github.com/Plume-org/gettext-macros/", rev = "a7c605f7edd6bfbfbfe7778026bfefd88d82db10" }
lazy_static = "1.3"
serde = "1.0"
serde_json = "1.0"
wasm-bindgen = "0.2.70"
js-sys = "0.3.47"
serde_derive = "1.0.123"
console_error_panic_hook = "0.1.6"
[dependencies.web-sys]
version = "0.3.47"
features = [
'console',
'ClipboardEvent',
'CssStyleDeclaration',
'DataTransfer',
'Document',
'DomStringMap',
'DomTokenList',
'Element',
'EventTarget',
'FocusEvent',
'History',
'HtmlAnchorElement',
'HtmlDocument',
'HtmlFormElement',
'HtmlInputElement',
'HtmlSelectElement',
'HtmlTextAreaElement',
'KeyboardEvent',
'Storage',
'Location',
'MouseEvent',
'Navigator',
'Node',
'NodeList',
'Text',
'TouchEvent',
'Window'
]
+2
View File
@@ -0,0 +1,2 @@
pre-release-hook = ["cargo", "fmt"]
pre-release-replacements = []
+430 -264
View File
@@ -1,10 +1,12 @@
use crate::CATALOG;
use serde::{Deserialize, Serialize};
use serde_json;
use std::sync::Mutex;
use stdweb::{
unstable::{TryFrom, TryInto},
web::{event::*, html_element::*, *},
use crate::{document, CATALOG};
use js_sys::{encode_uri_component, Date, RegExp};
use serde_derive::{Deserialize, Serialize};
use std::{convert::TryInto, sync::Mutex};
use wasm_bindgen::{prelude::*, JsCast, JsValue};
use web_sys::{
console, window, ClipboardEvent, Element, Event, FocusEvent, HtmlAnchorElement, HtmlDocument,
HtmlElement, HtmlFormElement, HtmlInputElement, HtmlSelectElement, HtmlTextAreaElement,
KeyboardEvent, MouseEvent, Node,
};
macro_rules! mv {
@@ -18,30 +20,29 @@ macro_rules! mv {
fn get_elt_value(id: &'static str) -> String {
let elt = document().get_element_by_id(id).unwrap();
let inp: Result<InputElement, _> = elt.clone().try_into();
let textarea: Result<TextAreaElement, _> = elt.clone().try_into();
let select: Result<SelectElement, _> = elt.try_into();
inp.map(|i| i.raw_value()).unwrap_or_else(|_| {
let inp: Option<&HtmlInputElement> = elt.dyn_ref();
let textarea: Option<&HtmlTextAreaElement> = elt.dyn_ref();
let select: Option<&HtmlSelectElement> = elt.dyn_ref();
inp.map(|i| i.value()).unwrap_or_else(|| {
textarea
.map(|t| t.value())
.unwrap_or_else(|_| select.unwrap().raw_value())
.unwrap_or_else(|| select.unwrap().value())
})
}
fn set_value<S: AsRef<str>>(id: &'static str, val: S) {
let elt = document().get_element_by_id(id).unwrap();
let inp: Result<InputElement, _> = elt.clone().try_into();
let textarea: Result<TextAreaElement, _> = elt.clone().try_into();
let select: Result<SelectElement, _> = elt.try_into();
inp.map(|i| i.set_raw_value(val.as_ref()))
.unwrap_or_else(|_| {
textarea
.map(|t| t.set_value(val.as_ref()))
.unwrap_or_else(|_| select.unwrap().set_raw_value(val.as_ref()))
})
let inp: Option<&HtmlInputElement> = elt.dyn_ref();
let textarea: Option<&HtmlTextAreaElement> = elt.dyn_ref();
let select: Option<&HtmlSelectElement> = elt.dyn_ref();
inp.map(|i| i.set_value(val.as_ref())).unwrap_or_else(|| {
textarea
.map(|t| t.set_value(val.as_ref()))
.unwrap_or_else(|| select.unwrap().set_value(val.as_ref()))
})
}
fn no_return(evt: KeyDownEvent) {
fn no_return(evt: KeyboardEvent) {
if evt.key() == "Enter" {
evt.prevent_default();
}
@@ -51,7 +52,6 @@ fn no_return(evt: KeyDownEvent) {
pub enum EditorError {
NoneError,
DOMError,
TypeError,
}
impl From<std::option::NoneError> for EditorError {
@@ -59,22 +59,7 @@ impl From<std::option::NoneError> for EditorError {
EditorError::NoneError
}
}
impl From<stdweb::web::error::InvalidCharacterError> for EditorError {
fn from(_: stdweb::web::error::InvalidCharacterError) -> Self {
EditorError::DOMError
}
}
impl From<stdweb::private::TODO> for EditorError {
fn from(_: stdweb::private::TODO) -> Self {
EditorError::DOMError
}
}
impl From<stdweb::private::ConversionError> for EditorError {
fn from(_: stdweb::private::ConversionError) -> Self {
EditorError::TypeError
}
}
const AUTOSAVE_DEBOUNCE_TIME: u32 = 5000;
const AUTOSAVE_DEBOUNCE_TIME: i32 = 5000;
#[derive(Serialize, Deserialize)]
struct AutosaveInformation {
contents: String,
@@ -85,10 +70,16 @@ struct AutosaveInformation {
tags: String,
title: String,
}
js_serializable!(AutosaveInformation);
fn is_basic_editor() -> bool {
if let Some(basic_editor) = window().local_storage().get("basic-editor") {
basic_editor == "true"
if let Some(basic_editor) = window()
.unwrap()
.local_storage()
.unwrap()
.unwrap()
.get("basic-editor")
.unwrap()
{
&basic_editor == "true"
} else {
false
}
@@ -97,65 +88,58 @@ fn get_title() -> String {
if is_basic_editor() {
get_elt_value("title")
} else {
let title_field = HtmlElement::try_from(
document()
.query_selector("#plume-editor > h1")
.ok()
.unwrap()
.unwrap(),
)
.ok()
.unwrap();
title_field.inner_text()
document()
.query_selector("#plume-editor > h1")
.unwrap()
.unwrap()
.dyn_ref::<HtmlElement>()
.unwrap()
.inner_text()
}
}
fn get_autosave_id() -> String {
format!(
"editor_contents={}",
window().location().unwrap().pathname().unwrap()
window().unwrap().location().pathname().unwrap()
)
}
fn get_editor_contents() -> String {
if is_basic_editor() {
get_elt_value("editor-content")
} else {
let editor =
HtmlElement::try_from(document().query_selector("article").ok().unwrap().unwrap())
.ok()
.unwrap();
editor.child_nodes().iter().fold(String::new(), |md, ch| {
let editor = document().query_selector("article").unwrap().unwrap();
let child_nodes = editor.child_nodes();
let mut md = String::new();
for i in 0..child_nodes.length() {
let ch = child_nodes.get(i).unwrap();
let to_append = match ch.node_type() {
NodeType::Element => {
if js! { return @{&ch}.tagName; } == "DIV" {
(js! { return @{&ch}.innerHTML; })
.try_into()
.unwrap_or_default()
Node::ELEMENT_NODE => {
let elt = ch.dyn_ref::<Element>().unwrap();
if elt.tag_name() == "DIV" {
elt.inner_html()
} else {
(js! { return @{&ch}.outerHTML; })
.try_into()
.unwrap_or_default()
elt.outer_html()
}
}
NodeType::Text => ch.node_value().unwrap_or_default(),
Node::TEXT_NODE => ch.node_value().unwrap_or_default(),
_ => unreachable!(),
};
format!("{}\n\n{}", md, to_append)
})
md = format!("{}\n\n{}", md, to_append);
}
md
}
}
fn get_subtitle() -> String {
if is_basic_editor() {
get_elt_value("subtitle")
} else {
let subtitle_element = HtmlElement::try_from(
document()
.query_selector("#plume-editor > h2")
.unwrap()
.unwrap(),
)
.ok()
.unwrap();
subtitle_element.inner_text()
document()
.query_selector("#plume-editor > h2")
.unwrap()
.unwrap()
.dyn_ref::<HtmlElement>()
.unwrap()
.inner_text()
}
}
fn autosave() {
@@ -170,27 +154,31 @@ fn autosave() {
};
let id = get_autosave_id();
match window()
.unwrap()
.local_storage()
.insert(&id, &serde_json::to_string(&info).unwrap())
.unwrap()
.unwrap()
.set(&id, &serde_json::to_string(&info).unwrap())
{
Ok(_) => {}
_ => console!(log, "Autosave failed D:"),
_ => console::log_1(&"Autosave failed D:".into()),
}
}
//This is only necessary until we go to stdweb 4.20 at least
fn confirm(message: &str) -> bool {
let result: bool = js! {return confirm(@{message});} == true;
result
}
fn load_autosave() {
if let Some(autosave_str) = window().local_storage().get(&get_autosave_id()) {
if let Ok(Some(autosave_str)) = window()
.unwrap()
.local_storage()
.unwrap()
.unwrap()
.get(&get_autosave_id())
{
let autosave_info: AutosaveInformation = serde_json::from_str(&autosave_str).ok().unwrap();
let message = i18n!(
CATALOG,
"Do you want to load the local autosave last edited at {}?";
Date::from_time(autosave_info.last_saved).to_date_string()
Date::new(&JsValue::from_f64(autosave_info.last_saved)).to_date_string().as_string().unwrap()
);
if confirm(&message) {
if let Ok(true) = window().unwrap().confirm_with_message(&message) {
set_value("editor-content", &autosave_info.contents);
set_value("title", &autosave_info.title);
set_value("subtitle", &autosave_info.subtitle);
@@ -203,18 +191,33 @@ fn load_autosave() {
}
}
fn clear_autosave() {
window().local_storage().remove(&get_autosave_id());
console!(log, &format!("Saved to {}", &get_autosave_id()));
window()
.unwrap()
.local_storage()
.unwrap()
.unwrap()
.remove_item(&get_autosave_id())
.unwrap();
console::log_1(&&format!("Saved to {}", &get_autosave_id()).into());
}
type TimeoutHandle = i32;
lazy_static! {
static ref AUTOSAVE_TIMEOUT: Mutex<Option<TimeoutHandle>> = Mutex::new(None);
}
fn autosave_debounce() {
let window = window().unwrap();
let timeout = &mut AUTOSAVE_TIMEOUT.lock().unwrap();
if let Some(timeout) = timeout.take() {
timeout.clear();
window.clear_timeout_with_handle(timeout);
}
**timeout = Some(window().set_clearable_timeout(autosave, AUTOSAVE_DEBOUNCE_TIME));
let callback = Closure::once(autosave);
**timeout = window
.set_timeout_with_callback_and_timeout_and_arguments_0(
callback.as_ref().unchecked_ref(),
AUTOSAVE_DEBOUNCE_TIME,
)
.ok();
callback.forget();
}
fn init_widget(
parent: &Element,
@@ -223,19 +226,33 @@ fn init_widget(
content: String,
disable_return: bool,
) -> Result<HtmlElement, EditorError> {
let widget = placeholder(make_editable(tag).try_into()?, &placeholder_text);
let widget = placeholder(
make_editable(tag).dyn_into::<HtmlElement>().unwrap(),
&placeholder_text,
);
if !content.is_empty() {
widget.dataset().insert("edited", "true")?;
widget
.dataset()
.set("edited", "true")
.map_err(|_| EditorError::DOMError)?;
}
widget.append_child(&document().create_text_node(&content));
widget
.append_child(&document().create_text_node(&content))
.map_err(|_| EditorError::DOMError)?;
if disable_return {
widget.add_event_listener(no_return);
let callback = Closure::wrap(Box::new(no_return) as Box<dyn FnMut(KeyboardEvent)>);
widget
.add_event_listener_with_callback("keydown", callback.as_ref().unchecked_ref())
.map_err(|_| EditorError::DOMError)?;
callback.forget();
}
parent.append_child(&widget);
parent
.append_child(&widget)
.map_err(|_| EditorError::DOMError)?;
// We need to do that to make sure the placeholder is correctly rendered
widget.focus();
widget.blur();
widget.focus().map_err(|_| EditorError::DOMError)?;
widget.blur().map_err(|_| EditorError::DOMError)?;
filter_paste(&widget);
@@ -244,42 +261,88 @@ fn init_widget(
fn filter_paste(elt: &HtmlElement) {
// Only insert text when pasting something
js! {
@{&elt}.addEventListener("paste", function (evt) {
evt.preventDefault();
document.execCommand("insertText", false, evt.clipboardData.getData("text"));
});
};
let insert_text = Closure::wrap(Box::new(|evt: ClipboardEvent| {
evt.prevent_default();
if let Some(data) = evt.clipboard_data() {
if let Ok(data) = data.get_data("text") {
document()
.dyn_ref::<HtmlDocument>()
.unwrap()
.exec_command_with_show_ui_and_value("insertText", false, &data)
.unwrap();
}
}
}) as Box<dyn FnMut(ClipboardEvent)>);
elt.add_event_listener_with_callback("paste", insert_text.as_ref().unchecked_ref())
.unwrap();
insert_text.forget();
}
pub fn init() -> Result<(), EditorError> {
if let Some(ed) = document().get_element_by_id("plume-fallback-editor") {
load_autosave();
ed.add_event_listener(|_: SubmitEvent| clear_autosave());
let callback = Closure::wrap(Box::new(|_| clear_autosave()) as Box<dyn FnMut(Event)>);
ed.add_event_listener_with_callback("submit", callback.as_ref().unchecked_ref())
.map_err(|_| EditorError::DOMError)?;
callback.forget();
}
// Check if the user wants to use the basic editor
if window()
.unwrap()
.local_storage()
.unwrap()
.unwrap()
.get("basic-editor")
.map(|x| x == "true")
.map(|x| x.is_some() && x.unwrap() == "true")
.unwrap_or(true)
{
if let Some(editor) = document().get_element_by_id("plume-fallback-editor") {
if let Ok(Some(title_label)) = document().query_selector("label[for=title]") {
let editor_button = document().create_element("a")?;
js! { @{&editor_button}.href = "#"; }
editor_button.add_event_listener(|_: ClickEvent| {
window().local_storage().remove("basic-editor");
window().history().go(0).ok(); // refresh
});
editor_button.append_child(
&document().create_text_node(&i18n!(CATALOG, "Open the rich text editor")),
let editor_button = document()
.create_element("a")
.map_err(|_| EditorError::DOMError)?;
editor_button
.dyn_ref::<HtmlAnchorElement>()
.unwrap()
.set_href("#");
let disable_basic_editor = Closure::wrap(Box::new(|_| {
let window = window().unwrap();
if window
.local_storage()
.unwrap()
.unwrap()
.set("basic-editor", "false")
.is_err()
{
console::log_1(&"Failed to write into local storage".into());
}
window.history().unwrap().go_with_delta(0).ok(); // refresh
})
as Box<dyn FnMut(MouseEvent)>);
editor_button
.add_event_listener_with_callback(
"click",
disable_basic_editor.as_ref().unchecked_ref(),
)
.map_err(|_| EditorError::DOMError)?;
disable_basic_editor.forget();
editor_button
.append_child(
&document().create_text_node(&i18n!(CATALOG, "Open the rich text editor")),
)
.map_err(|_| EditorError::DOMError)?;
editor
.insert_before(&editor_button, Some(&title_label))
.ok();
let callback = Closure::wrap(
Box::new(|_| autosave_debounce()) as Box<dyn FnMut(KeyboardEvent)>
);
editor.insert_before(&editor_button, &title_label).ok();
document()
.get_element_by_id("editor-content")
.unwrap()
.add_event_listener(|_: KeyDownEvent| autosave_debounce());
.add_event_listener_with_callback("keydown", callback.as_ref().unchecked_ref())
.map_err(|_| EditorError::DOMError)?;
callback.forget();
}
}
@@ -292,14 +355,30 @@ pub fn init() -> Result<(), EditorError> {
fn init_editor() -> Result<(), EditorError> {
if let Some(ed) = document().get_element_by_id("plume-editor") {
// Show the editor
js! { @{&ed}.style.display = "block"; };
ed.dyn_ref::<HtmlElement>()
.unwrap()
.style()
.set_property("display", "block")
.map_err(|_| EditorError::DOMError)?;
// And hide the HTML-only fallback
let old_ed = document().get_element_by_id("plume-fallback-editor")?;
let old_ed = document().get_element_by_id("plume-fallback-editor");
if old_ed.is_none() {
return Ok(());
}
let old_ed = old_ed.unwrap();
let old_title = document().get_element_by_id("plume-editor-title")?;
js! {
@{&old_ed}.style.display = "none";
@{&old_title}.style.display = "none";
};
old_ed
.dyn_ref::<HtmlElement>()
.unwrap()
.style()
.set_property("display", "none")
.map_err(|_| EditorError::DOMError)?;
old_title
.dyn_ref::<HtmlElement>()
.unwrap()
.style()
.set_property("display", "none")
.map_err(|_| EditorError::DOMError)?;
// Get content from the old editor (when editing an article for instance)
let title_val = get_elt_value("title");
@@ -321,35 +400,44 @@ fn init_editor() -> Result<(), EditorError> {
content_val.clone(),
false,
)?;
js! { @{&content}.innerHTML = @{content_val}; };
content.set_inner_html(&content_val);
// character counter
content.add_event_listener(mv!(content => move |_: KeyDownEvent| {
window().set_timeout(mv!(content => move || {
let character_counter = Closure::wrap(Box::new(mv!(content => move |_| {
let update_char_count = Closure::wrap(Box::new(mv!(content => move || {
if let Some(e) = document().get_element_by_id("char-count") {
let count = chars_left("#plume-fallback-editor", &content).unwrap_or_default();
let text = i18n!(CATALOG, "Around {} characters left"; count);
HtmlElement::try_from(e).map(|e| {
js!{@{e}.innerText = @{text}};
}).ok();
e.dyn_ref::<HtmlElement>().map(|e| {
e.set_inner_text(&text);
}).unwrap();
};
}), 0);
})) as Box<dyn FnMut()>);
window().unwrap().set_timeout_with_callback_and_timeout_and_arguments(update_char_count.as_ref().unchecked_ref(), 0, &js_sys::Array::new()).unwrap();
update_char_count.forget();
autosave_debounce();
}));
})) as Box<dyn FnMut(KeyboardEvent)>);
content
.add_event_listener_with_callback("keydown", character_counter.as_ref().unchecked_ref())
.map_err(|_| EditorError::DOMError)?;
character_counter.forget();
document().get_element_by_id("publish")?.add_event_listener(
mv!(title, subtitle, content, old_ed => move |_: ClickEvent| {
let popup = document().get_element_by_id("publish-popup").or_else(||
init_popup(&title, &subtitle, &content, &old_ed).ok()
).unwrap();
let bg = document().get_element_by_id("popup-bg").or_else(||
init_popup_bg().ok()
).unwrap();
let show_popup = Closure::wrap(Box::new(mv!(title, subtitle, content, old_ed => move |_| {
let popup = document().get_element_by_id("publish-popup").or_else(||
init_popup(&title, &subtitle, &content, &old_ed).ok()
).unwrap();
let bg = document().get_element_by_id("popup-bg").or_else(||
init_popup_bg().ok()
).unwrap();
popup.class_list().add("show").unwrap();
bg.class_list().add("show").unwrap();
}),
);
popup.class_list().add_1("show").unwrap();
bg.class_list().add_1("show").unwrap();
})) as Box<dyn FnMut(MouseEvent)>);
document()
.get_element_by_id("publish")?
.add_event_listener_with_callback("click", show_popup.as_ref().unchecked_ref())
.map_err(|_| EditorError::DOMError)?;
show_popup.forget();
show_errors();
setup_close_button();
@@ -359,32 +447,47 @@ fn init_editor() -> Result<(), EditorError> {
fn setup_close_button() {
if let Some(button) = document().get_element_by_id("close-editor") {
button.add_event_listener(|_: ClickEvent| {
let close_editor = Closure::wrap(Box::new(|_| {
window()
.unwrap()
.local_storage()
.insert("basic-editor", "true")
.unwrap()
.unwrap()
.set("basic-editor", "true")
.unwrap();
window().history().go(0).unwrap(); // Refresh the page
});
window()
.unwrap()
.history()
.unwrap()
.go_with_delta(0)
.unwrap(); // Refresh the page
}) as Box<dyn FnMut(MouseEvent)>);
button
.add_event_listener_with_callback("click", close_editor.as_ref().unchecked_ref())
.unwrap();
close_editor.forget();
}
}
fn show_errors() {
if let Ok(Some(header)) = document().query_selector("header") {
let list = document().create_element("header").unwrap();
list.class_list().add("messages").unwrap();
for error in document().query_selector_all("p.error").unwrap() {
let document = document();
if let Ok(Some(header)) = document.query_selector("header") {
let list = document.create_element("header").unwrap();
list.class_list().add_1("messages").unwrap();
let errors = document.query_selector_all("p.error").unwrap();
for i in 0..errors.length() {
let error = errors.get(i).unwrap();
error
.parent_element()
.unwrap()
.remove_child(&error)
.unwrap();
list.append_child(&error);
let _ = list.append_child(&error);
}
header
.parent_element()
.unwrap()
.insert_before(&list, &header.next_sibling().unwrap())
.insert_before(&list, header.next_sibling().as_ref())
.unwrap();
}
}
@@ -395,9 +498,17 @@ fn init_popup(
content: &HtmlElement,
old_ed: &Element,
) -> Result<Element, EditorError> {
let popup = document().create_element("div")?;
popup.class_list().add("popup")?;
popup.set_attribute("id", "publish-popup")?;
let document = document();
let popup = document
.create_element("div")
.map_err(|_| EditorError::DOMError)?;
popup
.class_list()
.add_1("popup")
.map_err(|_| EditorError::DOMError)?;
popup
.set_attribute("id", "publish-popup")
.map_err(|_| EditorError::DOMError)?;
let tags = get_elt_value("tags")
.split(',')
@@ -405,112 +516,157 @@ fn init_popup(
.map(str::to_string)
.collect::<Vec<_>>();
let license = get_elt_value("license");
make_input(&i18n!(CATALOG, "Tags"), "popup-tags", &popup).set_raw_value(&tags.join(", "));
make_input(&i18n!(CATALOG, "License"), "popup-license", &popup).set_raw_value(&license);
make_input(&i18n!(CATALOG, "Tags"), "popup-tags", &popup).set_value(&tags.join(", "));
make_input(&i18n!(CATALOG, "License"), "popup-license", &popup).set_value(&license);
let cover_label = document().create_element("label")?;
cover_label.append_child(&document().create_text_node(&i18n!(CATALOG, "Cover")));
cover_label.set_attribute("for", "cover")?;
let cover = document().get_element_by_id("cover")?;
let cover_label = document
.create_element("label")
.map_err(|_| EditorError::DOMError)?;
cover_label
.append_child(&document.create_text_node(&i18n!(CATALOG, "Cover")))
.map_err(|_| EditorError::DOMError)?;
cover_label
.set_attribute("for", "cover")
.map_err(|_| EditorError::DOMError)?;
let cover = document.get_element_by_id("cover")?;
cover.parent_element()?.remove_child(&cover).ok();
popup.append_child(&cover_label);
popup.append_child(&cover);
popup
.append_child(&cover_label)
.map_err(|_| EditorError::DOMError)?;
popup
.append_child(&cover)
.map_err(|_| EditorError::DOMError)?;
if let Some(draft_checkbox) = document().get_element_by_id("draft") {
let draft_label = document().create_element("label")?;
draft_label.set_attribute("for", "popup-draft")?;
if let Some(draft_checkbox) = document.get_element_by_id("draft") {
let draft_checkbox = draft_checkbox.dyn_ref::<HtmlInputElement>().unwrap();
let draft_label = document
.create_element("label")
.map_err(|_| EditorError::DOMError)?;
draft_label
.set_attribute("for", "popup-draft")
.map_err(|_| EditorError::DOMError)?;
let draft = document().create_element("input").unwrap();
js! {
@{&draft}.id = "popup-draft";
@{&draft}.name = "popup-draft";
@{&draft}.type = "checkbox";
@{&draft}.checked = @{&draft_checkbox}.checked;
};
let draft = document.create_element("input").unwrap();
draft.set_id("popup-draft");
let draft = draft.dyn_ref::<HtmlInputElement>().unwrap();
draft.set_name("popup-draft");
draft.set_type("checkbox");
draft.set_checked(draft_checkbox.checked());
draft_label.append_child(&draft);
draft_label.append_child(&document().create_text_node(&i18n!(CATALOG, "This is a draft")));
popup.append_child(&draft_label);
draft_label
.append_child(&draft)
.map_err(|_| EditorError::DOMError)?;
draft_label
.append_child(&document.create_text_node(&i18n!(CATALOG, "This is a draft")))
.map_err(|_| EditorError::DOMError)?;
popup
.append_child(&draft_label)
.map_err(|_| EditorError::DOMError)?;
}
let button = document().create_element("input")?;
js! {
@{&button}.type = "submit";
@{&button}.value = @{i18n!(CATALOG, "Publish")};
};
button.append_child(&document().create_text_node(&i18n!(CATALOG, "Publish")));
button.add_event_listener(
mv!(title, subtitle, content, old_ed => move |_: ClickEvent| {
title.focus(); // Remove the placeholder before publishing
set_value("title", title.inner_text());
subtitle.focus();
set_value("subtitle", subtitle.inner_text());
content.focus();
set_value("editor-content", content.child_nodes().iter().fold(String::new(), |md, ch| {
let to_append = match ch.node_type() {
NodeType::Element => {
if js!{ return @{&ch}.tagName; } == "DIV" {
(js!{ return @{&ch}.innerHTML; }).try_into().unwrap_or_default()
} else {
(js!{ return @{&ch}.outerHTML; }).try_into().unwrap_or_default()
}
},
NodeType::Text => ch.node_value().unwrap_or_default(),
_ => unreachable!(),
};
format!("{}\n\n{}", md, to_append)
}));
set_value("tags", get_elt_value("popup-tags"));
if let Some(draft) = document().get_element_by_id("popup-draft") {
js!{
document.getElementById("draft").checked = @{draft}.checked;
};
}
let cover = document().get_element_by_id("cover").unwrap();
cover.parent_element().unwrap().remove_child(&cover).ok();
old_ed.append_child(&cover);
set_value("license", get_elt_value("popup-license"));
clear_autosave();
js! {
@{&old_ed}.submit();
let button = document
.create_element("input")
.map_err(|_| EditorError::DOMError)?;
button
.append_child(&document.create_text_node(&i18n!(CATALOG, "Publish")))
.map_err(|_| EditorError::DOMError)?;
let button = button.dyn_ref::<HtmlInputElement>().unwrap();
button.set_type("submit");
button.set_value(&i18n!(CATALOG, "Publish"));
let callback = Closure::wrap(Box::new(mv!(title, subtitle, content, old_ed => move |_| {
let document = self::document();
title.focus().unwrap(); // Remove the placeholder before publishing
set_value("title", title.inner_text());
subtitle.focus().unwrap();
set_value("subtitle", subtitle.inner_text());
content.focus().unwrap();
let mut md = String::new();
let child_nodes = content.child_nodes();
for i in 0..child_nodes.length() {
let ch = child_nodes.get(i).unwrap();
let to_append = match ch.node_type() {
Node::ELEMENT_NODE => {
let ch = ch.dyn_ref::<Element>().unwrap();
if ch.tag_name() == "DIV" {
ch.inner_html()
} else {
ch.outer_html()
}
},
Node::TEXT_NODE => ch.node_value().unwrap_or_default(),
_ => unreachable!(),
};
}),
);
popup.append_child(&button);
md = format!("{}\n\n{}", md, to_append);
}
set_value("editor-content", md);
set_value("tags", get_elt_value("popup-tags"));
if let Some(draft) = document.get_element_by_id("popup-draft") {
if let Some(draft_checkbox) = document.get_element_by_id("draft") {
let draft_checkbox = draft_checkbox.dyn_ref::<HtmlInputElement>().unwrap();
let draft = draft.dyn_ref::<HtmlInputElement>().unwrap();
draft_checkbox.set_checked(draft.checked());
}
}
let cover = document.get_element_by_id("cover").unwrap();
cover.parent_element().unwrap().remove_child(&cover).ok();
old_ed.append_child(&cover).unwrap();
set_value("license", get_elt_value("popup-license"));
clear_autosave();
let old_ed = old_ed.dyn_ref::<HtmlFormElement>().unwrap();
old_ed.submit().unwrap();
})) as Box<dyn FnMut(MouseEvent)>);
button
.add_event_listener_with_callback("click", callback.as_ref().unchecked_ref())
.map_err(|_| EditorError::DOMError)?;
callback.forget();
popup
.append_child(&button)
.map_err(|_| EditorError::DOMError)?;
document().body()?.append_child(&popup);
document
.body()?
.append_child(&popup)
.map_err(|_| EditorError::DOMError)?;
Ok(popup)
}
fn init_popup_bg() -> Result<Element, EditorError> {
let bg = document().create_element("div")?;
bg.class_list().add("popup-bg")?;
bg.set_attribute("id", "popup-bg")?;
let bg = document()
.create_element("div")
.map_err(|_| EditorError::DOMError)?;
bg.class_list()
.add_1("popup-bg")
.map_err(|_| EditorError::DOMError)?;
bg.set_attribute("id", "popup-bg")
.map_err(|_| EditorError::DOMError)?;
document().body()?.append_child(&bg);
bg.add_event_listener(|_: ClickEvent| close_popup());
document()
.body()?
.append_child(&bg)
.map_err(|_| EditorError::DOMError)?;
let callback = Closure::wrap(Box::new(|_| close_popup()) as Box<dyn FnMut(MouseEvent)>);
bg.add_event_listener_with_callback("click", callback.as_ref().unchecked_ref())
.unwrap();
callback.forget();
Ok(bg)
}
fn chars_left(selector: &str, content: &HtmlElement) -> Option<i32> {
match document().query_selector(selector) {
Ok(Some(form)) => HtmlElement::try_from(form).ok().and_then(|form| {
Ok(Some(form)) => form.dyn_ref::<HtmlElement>().and_then(|form| {
if let Some(len) = form
.get_attribute("content-size")
.and_then(|s| s.parse::<i32>().ok())
{
(js! {
let x = encodeURIComponent(@{content}.innerHTML)
.replace(/%20/g, "+")
.replace(/%0A/g, "%0D%0A")
.replace(new RegExp("[!'*()]", "g"), "XXX") // replace exceptions of encodeURIComponent with placeholder
.length + 2;
console.log(x);
return x;
})
.try_into()
.map(|c: i32| len - c)
.ok()
(encode_uri_component(&content.inner_html())
.replace("%20", "+")
.replace("%0A", "%0D0A")
.replace_by_pattern(&RegExp::new("[!'*()]", "g"), "XXX")
.length()
+ 2_u32)
.try_into()
.map(|c: i32| len - c)
.ok()
} else {
None
}
@@ -520,26 +676,26 @@ fn chars_left(selector: &str, content: &HtmlElement) -> Option<i32> {
}
fn close_popup() {
let hide = |x: Element| x.class_list().remove("show");
let hide = |x: Element| x.class_list().remove_1("show");
document().get_element_by_id("publish-popup").map(hide);
document().get_element_by_id("popup-bg").map(hide);
}
fn make_input(label_text: &str, name: &'static str, form: &Element) -> InputElement {
let label = document().create_element("label").unwrap();
label.append_child(&document().create_text_node(label_text));
fn make_input(label_text: &str, name: &'static str, form: &Element) -> HtmlInputElement {
let document = document();
let label = document.create_element("label").unwrap();
label
.append_child(&document.create_text_node(label_text))
.unwrap();
label.set_attribute("for", name).unwrap();
let inp: InputElement = document()
.create_element("input")
.unwrap()
.try_into()
.unwrap();
let inp = document.create_element("input").unwrap();
let inp = inp.dyn_into::<HtmlInputElement>().unwrap();
inp.set_attribute("name", name).unwrap();
inp.set_attribute("id", name).unwrap();
form.append_child(&label);
form.append_child(&inp);
form.append_child(&label).unwrap();
form.append_child(&inp).unwrap();
inp
}
@@ -553,36 +709,46 @@ fn make_editable(tag: &'static str) -> Element {
}
fn placeholder(elt: HtmlElement, text: &str) -> HtmlElement {
elt.dataset().insert("placeholder", text).unwrap();
elt.dataset().insert("edited", "false").unwrap();
elt.dataset().set("placeholder", text).unwrap();
elt.dataset().set("edited", "false").unwrap();
elt.add_event_listener(mv!(elt => move |_: FocusEvent| {
let callback = Closure::wrap(Box::new(mv!(elt => move |_: FocusEvent| {
if elt.dataset().get("edited").unwrap().as_str() != "true" {
clear_children(&elt);
}
}));
elt.add_event_listener(mv!(elt => move |_: BlurEvent| {
})) as Box<dyn FnMut(FocusEvent)>);
elt.add_event_listener_with_callback("focus", callback.as_ref().unchecked_ref())
.unwrap();
callback.forget();
let callback = Closure::wrap(Box::new(mv!(elt => move |_: Event| {
if elt.dataset().get("edited").unwrap().as_str() != "true" {
clear_children(&elt);
let ph = document().create_element("span").expect("Couldn't create placeholder");
ph.class_list().add("placeholder").expect("Couldn't add class");
ph.append_child(&document().create_text_node(&elt.dataset().get("placeholder").unwrap_or_default()));
elt.append_child(&ph);
ph.class_list().add_1("placeholder").expect("Couldn't add class");
ph.append_child(&document().create_text_node(&elt.dataset().get("placeholder").unwrap_or_default())).unwrap();
elt.append_child(&ph).unwrap();
}
}));
elt.add_event_listener(mv!(elt => move |_: KeyUpEvent| {
elt.dataset().insert("edited", if elt.inner_text().trim_matches('\n').is_empty() {
})) as Box<dyn FnMut(Event)>);
elt.add_event_listener_with_callback("blur", callback.as_ref().unchecked_ref())
.unwrap();
callback.forget();
let callback = Closure::wrap(Box::new(mv!(elt => move |_: KeyboardEvent| {
elt.dataset().set("edited", if elt.inner_text().trim_matches('\n').is_empty() {
"false"
} else {
"true"
}).expect("Couldn't update edition state");
}));
})) as Box<dyn FnMut(KeyboardEvent)>);
elt.add_event_listener_with_callback("keyup", callback.as_ref().unchecked_ref())
.unwrap();
callback.forget();
elt
}
fn clear_children(elt: &HtmlElement) {
for child in elt.child_nodes() {
elt.remove_child(&child).unwrap();
let child_nodes = elt.child_nodes();
for _ in 0..child_nodes.length() {
elt.remove_child(&child_nodes.get(0).unwrap()).unwrap();
}
}
+174
View File
@@ -0,0 +1,174 @@
#![recursion_limit = "128"]
#![feature(decl_macro, proc_macro_hygiene, try_trait)]
#[macro_use]
extern crate gettext_macros;
#[macro_use]
extern crate lazy_static;
use wasm_bindgen::{prelude::*, JsCast};
use web_sys::{console, window, Document, Element, Event, HtmlInputElement, TouchEvent};
init_i18n!(
"plume-front",
af,
ar,
bg,
ca,
cs,
cy,
da,
de,
el,
en,
eo,
es,
fa,
fi,
fr,
gl,
he,
hi,
hr,
hu,
it,
ja,
ko,
nb,
nl,
no,
pl,
pt,
ro,
ru,
sat,
si,
sk,
sl,
sr,
sv,
tr,
uk,
vi,
zh
);
mod editor;
compile_i18n!();
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = window().unwrap().navigator().language().unwrap();
let lang = lang.splitn(2, '-').next().unwrap_or("en");
let english_position = catalogs
.iter()
.position(|(language_code, _)| *language_code == "en")
.unwrap();
catalogs
.iter()
.find(|(l, _)| l == &lang)
.unwrap_or(&catalogs[english_position])
.clone()
.1
};
}
#[wasm_bindgen(start)]
pub fn main() -> Result<(), JsValue> {
extern crate console_error_panic_hook;
use std::panic;
panic::set_hook(Box::new(console_error_panic_hook::hook));
menu();
search();
editor::init()
.map_err(|e| console::error_1(&&format!("Editor error: {:?}", e).into()))
.ok();
Ok(())
}
/// Toggle menu on mobile devices
///
/// It should normally be working fine even without this code
/// But :focus-within is not yet supported by Webkit/Blink
fn menu() {
let document = document();
if let Ok(Some(button)) = document.query_selector("#menu a") {
if let Some(menu) = document.get_element_by_id("content") {
let show_menu = Closure::wrap(Box::new(|_: TouchEvent| {
self::document()
.get_element_by_id("menu")
.map(|menu| {
menu.set_attribute("aria-expanded", "true")
.map(|_| menu.class_list().add_1("show"))
})
.unwrap()
.unwrap()
.unwrap();
}) as Box<dyn FnMut(TouchEvent)>);
button
.add_event_listener_with_callback("touchend", show_menu.as_ref().unchecked_ref())
.unwrap();
show_menu.forget();
let close_menu = Closure::wrap(Box::new(|evt: TouchEvent| {
if evt
.target()
.unwrap()
.dyn_ref::<Element>()
.unwrap()
.closest("a")
.unwrap()
.is_some()
{
return;
}
self::document()
.get_element_by_id("menu")
.map(|menu| {
menu.set_attribute("aria-expanded", "false")
.map(|_| menu.class_list().remove_1("show"))
})
.unwrap()
.unwrap()
.unwrap()
}) as Box<dyn FnMut(TouchEvent)>);
menu.add_event_listener_with_callback("touchend", close_menu.as_ref().unchecked_ref())
.unwrap();
close_menu.forget();
}
}
}
/// Clear the URL of the search page before submitting request
fn search() {
if let Some(form) = document().get_element_by_id("form") {
let normalize_query = Closure::wrap(Box::new(|_: Event| {
document()
.query_selector_all("#form input")
.map(|inputs| {
for i in 0..inputs.length() {
let input = inputs.get(i).unwrap();
let input = input.dyn_ref::<HtmlInputElement>().unwrap();
if input.name().is_empty() {
input.set_name(&input.dyn_ref::<Element>().unwrap().id());
}
if !input.name().is_empty() && input.value().is_empty() {
input.set_name("");
}
}
})
.unwrap();
}) as Box<dyn FnMut(Event)>);
form.add_event_listener_with_callback("submit", normalize_query.as_ref().unchecked_ref())
.unwrap();
normalize_query.forget();
}
}
fn document() -> Document {
window().unwrap().document().unwrap()
}
-111
View File
@@ -1,111 +0,0 @@
#![recursion_limit = "128"]
#![feature(decl_macro, proc_macro_hygiene, try_trait)]
#[macro_use]
extern crate gettext_macros;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate stdweb;
use stdweb::web::{event::*, *};
init_i18n!(
"plume-front",
ar,
bg,
ca,
cs,
de,
en,
eo,
es,
fr,
gl,
hi,
hr,
it,
ja,
nb,
pl,
pt,
ro,
ru,
sr,
sk,
sv
);
mod editor;
compile_i18n!();
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js! { return navigator.language }.into_string().unwrap();
let lang = lang.splitn(2, '-').next().unwrap_or("en");
let english_position = catalogs
.iter()
.position(|(language_code, _)| *language_code == "en")
.unwrap();
catalogs
.iter()
.find(|(l, _)| l == &lang)
.unwrap_or(&catalogs[english_position])
.clone()
.1
};
}
fn main() {
menu();
search();
editor::init()
.map_err(|e| console!(error, format!("Editor error: {:?}", e)))
.ok();
}
/// Toggle menu on mobile devices
///
/// It should normally be working fine even without this code
/// But :focus-within is not yet supported by Webkit/Blink
fn menu() {
if let Some(button) = document().get_element_by_id("menu") {
if let Some(menu) = document().get_element_by_id("content") {
button.add_event_listener(|_: TouchEnd| {
document()
.get_element_by_id("menu")
.map(|menu| menu.class_list().add("show"));
});
menu.add_event_listener(|_: TouchEnd| {
document()
.get_element_by_id("menu")
.map(|menu| menu.class_list().remove("show"));
});
}
}
}
/// Clear the URL of the search page before submitting request
fn search() {
if let Some(form) = document().get_element_by_id("form") {
form.add_event_listener(|_: SubmitEvent| {
document()
.query_selector_all("#form input")
.map(|inputs| {
for input in inputs {
js! {
if (@{&input}.name === "") {
@{&input}.name = @{&input}.id
}
if (@{&input}.name && !@{&input}.value) {
@{&input}.name = "";
}
}
}
})
.ok();
});
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "plume-macro"
version = "0.4.0"
version = "0.6.1-dev"
authors = ["Trinity Pointard <trinity.pointard@insa-rennes.fr>"]
edition = "2018"
description = "Plume procedural macros"
+2
View File
@@ -0,0 +1,2 @@
pre-release-hook = ["cargo", "fmt"]
pre-release-replacements = []

Some files were not shown because too many files have changed in this diff Show More