Commit graph

84 commits

Author SHA1 Message Date
Vincent Ambo
02a466a28b style(templates): Minor fixes to search & index layouts 2018-04-15 00:41:17 +02:00
Vincent Ambo
ba33efd772 refactor(handlers): Receive search terms via query parameters
There are several reasons for this, but one important one is that
people expect to be able to share search links.
2018-04-14 23:28:34 +02:00
Vincent Ambo
e0b1bc2627 fix(render): Escape post bodies
... derp.

Well, the CSP prevented script executions already.
2018-04-14 22:33:35 +02:00
Vincent Ambo
8057b8849e feat(templates): Add 'sticky' badge to sticky threads 2018-04-14 22:33:35 +02:00
Vincent Ambo
06f7f23bab fix(migrations): Change weighting of title vs. body
After thinking for a little while I actually think the body of a post
may be more relevant when searching for posts than the thread title.

Right now this is just a hunch and we'll have to find out how it
actually ends up working in real life.
2018-04-14 22:21:55 +02:00
Vincent Ambo
4132869277 feat: Implement search result view & enable search
Implements a very simple and currently kinda broken-looking search
result view.
2018-04-14 22:21:55 +02:00
Vincent Ambo
dae97fdaf5 chore(db): Arbitrarily limit search result size
... until pagination is in place.
2018-04-14 22:21:55 +02:00
Vincent Ambo
39d1cd64bc feat(main/db): Schedule regular search view refresh
Schedules refreshes of the database view used for search at one-minute
intervals.
2018-04-14 22:21:55 +02:00
Vincent Ambo
3e5b1098c6 refactor(schema): Unify integer type usage across tables 2018-04-14 22:21:55 +02:00
Vincent Ambo
ea68bac427 refactor(handlers): Improve error handling in post creation 2018-04-14 22:21:55 +02:00
Vincent Ambo
31b0a550f2 feat(db): Implement handling of 'SearchPosts' message
Adds support for executing full-text search across a forum instance by
sending the `SearchPosts` message with a search query to the DB actor.

The struct used for results is mapped manually to the expected query
result as the query is embedded via raw SQL.
2018-04-14 22:21:55 +02:00
Vincent Ambo
2d8db52010 feat(migrations): Add materialized view & index for full text search
Adds a materialized view to be used for full-text searches that
indexes the tsvector documents for each post.
2018-04-14 22:21:55 +02:00
Vincent Ambo
529da884da fix(templates): Fluidly scale all images 2018-04-14 18:12:24 +02:00
Vincent Ambo
324778c7e0 fix(templates): Set CSPs on templates 2018-04-14 17:59:52 +02:00
Vincent Ambo
b684320a73 docs(todo): Stickies are done! 2018-04-14 17:56:36 +02:00
Vincent Ambo
c6995fcab3 feat(templates): Highlight stickied threads in index 2018-04-14 17:55:57 +02:00
Vincent Ambo
d1c45159b9 feat(db): Add support for stickies in database
Adds a 'sticky' column to threads and rewrites the thread index to
take sticky markings into account when ordering threads.

Stickies are not yet highlighted in any way in the forum overview.
2018-04-14 17:47:31 +02:00
Vincent Ambo
c136d34e79 docs(todo): Add note about stickies 2018-04-14 17:16:10 +02:00
Vincent Ambo
f10bd20276 feat(db): Add view for ordering thread index by most recent post
This implements the classic thread ordering expected by most forum
users (i.e. the thread with the most recent post is at the top).
2018-04-14 17:15:27 +02:00
Vincent Ambo
cf64826e4e feat(build): Configure Travis builds for Rust 2018-04-14 16:43:59 +02:00
Vincent Ambo
a326e1ea2e feat: License project under GPLv3 2018-04-14 16:40:56 +02:00
Vincent Ambo
d1acf4cfd7 docs(CODE_OF_CONDUCT): Add a reasonable code of conduct 2018-04-14 16:38:48 +02:00
Vincent Ambo
b0825f3850 docs(README): Add a very simple README file 2018-04-14 16:38:05 +02:00
Vincent Ambo
8c30ef92f6 refactor(db): Store thread body in the posts table
This is a simplification over the previous approach. The OP of a
thread is just a normal post like any other in this model, which
allows some code simplifications (and future query convenience).
2018-04-14 16:33:45 +02:00
Vincent Ambo
a90d1cc1a4 feat(migrations): Drop 'body' column from threads
As a data model simplification, the text of a thread's top post should
simply also go into the posts table.
2018-04-14 16:33:15 +02:00
Vincent Ambo
bf02c70f74 feat(handlers/main): Add 'anonymous' mode for forum
Adds a `REQUIRE_LOGIN` environment variable which, if set to anything
other than true, will let users post anonymously on the forums.
2018-04-12 01:28:37 +02:00
Vincent Ambo
e7a54a5aff feat(handler): Perform basic input validation on new thread view 2018-04-12 01:07:25 +02:00
Vincent Ambo
f46f6f3c42 chore(cargo): Remove unused dependency 2018-04-12 00:32:06 +02:00
Vincent Ambo
0ec214423e fix(handlers): Fix chained error handling in actors
This took me some time to figure out so it's useful to document in the
commit message.

When chaining messages from actors, the result type of a message (i.e.
the actual `<M as Message>::Result`) is sometimes itself a
`Result<T, E>`.

In many cases this leads to a situation where the return type of a
message sending process is something like (simplified):

    Future<Item=Result<Foo, ConverseError>, Error=actix::MailboxError>

Due to the implementation of
`From<actix::MailboxError> for ConverseError` it is possible to use
`.from_err()` on these futures to convert the future's `Error` to
`ConverseError`.

The type `Result` apparently implements `IntoFuture`, which means that
due to some trait magic that's been applied somewhere in the futures
API a call to `flatten()` can "lift" the contained error if the error
types match and give us a "simple"

    Future<Item=Foo, Error=ConverseError>

From that point on chaining becomes easy.
2018-04-12 00:04:37 +02:00
Vincent Ambo
a9917d54a8 chore(handlers): Remove unused code 2018-04-11 23:34:49 +02:00
Vincent Ambo
b862e3dc79 chore(cargo): Use stable release of actix-web
The git version previously tracked by Converse has been released.
2018-04-11 21:21:21 +02:00
Vincent Ambo
918c2726b4 fix(templates/handlers): Fix post anchors
- ensure users are correctly linked to a post actor after replying
- ensure timestamps are clickable to get post IDs
2018-04-11 16:35:40 +02:00
Vincent Ambo
b781a1fe57 chore: Clean up unused imports 2018-04-11 16:35:26 +02:00
Vincent Ambo
138f4f608d feat(render): Use a more human-readable format for dates 2018-04-11 16:16:37 +02:00
Vincent Ambo
2bbcc8432e fix(render): Escape thread titles in index 2018-04-11 13:52:37 +02:00
Vincent Ambo
87237f5c28 feat(render): Implement Markdown thread rendering & Gravatar
Implements a new thread rendering pipeline which all posts and the
main thread body are first converted to a `RenderablePost` structure.

During the conversion to this structure, the post body is rendered as
Markdown and the author's email address is converted into the format
required by Gravatar.
2018-04-11 13:25:12 +02:00
Vincent Ambo
405e6340f8 chore(cargo): Add md5 crate dependency
Required for Gravatar.
2018-04-11 13:24:32 +02:00
Vincent Ambo
18ba3eba3c fix(main): Correctly set up rendering actor 2018-04-11 12:19:10 +02:00
Vincent Ambo
1cce37446b refactor(handlers): Use rendering actor for page renders
This currently breaks error handling in page render flows. To fix it
properly, the database actor should return failable futures instead of
`Result<T>` wrapped in a future.
2018-04-11 12:18:33 +02:00
Vincent Ambo
fe7e5e48b5 feat(render): Add rendering actor
Adds a separate actor that handles page rendering, templating engine
state and other related topics.
2018-04-11 12:17:33 +02:00
Vincent Ambo
4eb0a57177 fix(main): Update cookie session setup for new actix-web 2018-04-10 09:53:58 +02:00
Vincent Ambo
f599f661ba chore(cargo): Dependency bump & pin versions 2018-04-10 09:53:38 +02:00
Vincent Ambo
97d77ffd07 fix(templates): Fix author name & avatar display 2018-04-09 23:48:31 +02:00
Vincent Ambo
c5833c02e2 fix(db): Order index threads in descending post time
Technically the last post date should matter more here, but we'll get
there.
2018-04-09 23:41:21 +02:00
Vincent Ambo
103a59485f feat(handlers/templates): Add "New Thread" handler and template 2018-04-09 23:37:41 +02:00
Vincent Ambo
fb7df7a346 feat(templates): Slightly less barebones index & thread templates 2018-04-09 23:37:21 +02:00
Vincent Ambo
7c73949066 feat(handlers): Extract & add author to thread and post information 2018-04-09 09:20:27 +02:00
Vincent Ambo
64453ec683 feat(main): Initialise RequireLogin middleware on launch 2018-04-09 09:11:25 +02:00
Vincent Ambo
ef5e8ec8bd feat(handlers): Add RequireLogin middleware
Adds a middleware that automatically redirects users to the login page
if they don't have an active session (i.e. 'author' set).
2018-04-09 09:11:23 +02:00
Vincent Ambo
d91dec28f8 fix(main): Generate random session key 2018-04-09 09:10:36 +02:00