summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2019-04-06 15:49:51 -0700
committerDessalines <tyhou13@gmx.com>2019-04-06 15:49:51 -0700
commitb8c259f9e791b295aa7c3c83033bd1d8377f3407 (patch)
tree03b3b89b2945bc84fafde91b4b8c155c3493d3f6 /docs
parentb6190d08d9c7487a428eb9502dc745e7bbb222ea (diff)
Adding expanding navbar, some docs
Diffstat (limited to 'docs')
-rw-r--r--docs/API.md378
-rw-r--r--docs/goals.md37
-rw-r--r--docs/ranking.md28
3 files changed, 443 insertions, 0 deletions
diff --git a/docs/API.md b/docs/API.md
new file mode 100644
index 00000000..78cc81ab
--- /dev/null
+++ b/docs/API.md
@@ -0,0 +1,378 @@
+# API
+
+- Start with the [reddit API](https://www.reddit.com/dev/api), and find [Activitypub vocab](https://www.w3.org/TR/activitystreams-vocabulary/) to match it.
+
+<!-- toc -->
+
+- [Actors](#actors)
+ * [User / Person](#user--person)
+ * [Community / Group](#community--group)
+- [Objects](#objects)
+ * [Post / Page](#post--page)
+ * [Post Listings / Ordered CollectionPage](#post-listings--ordered-collectionpage)
+ * [Comment / Note](#comment--note)
+ * [Comment Listings / Ordered CollectionPage](#comment-listings--ordered-collectionpage)
+ * [Deleted thing / Tombstone](#deleted-thing--tombstone)
+- [Actions](#actions)
+ * [Comments](#comments)
+ + [Create](#create)
+ + [Delete](#delete)
+ + [Update](#update)
+ + [Read](#read)
+ + [Like](#like)
+ + [Dislike](#dislike)
+ * [Posts](#posts)
+ + [Create](#create-1)
+ + [Delete](#delete-1)
+ + [Update](#update-1)
+ + [Read](#read-1)
+ * [Communities](#communities)
+ + [Create](#create-2)
+ + [Delete](#delete-2)
+ + [Update](#update-2)
+ + [Join](#join)
+ + [Leave](#leave)
+ * [Moderator](#moderator)
+ + [Ban user from community / Block](#ban-user-from-community--block)
+ + [Delete Comment](#delete-comment)
+ + [Invite a moderator](#invite-a-moderator)
+ + [Accept Invitation](#accept-invitation)
+ + [Reject Invitation](#reject-invitation)
+
+<!-- tocstop -->
+
+## Actors
+
+### [User / Person](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-person)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Person",
+ "id": "https://instance_url/api/v1/user/sally_smith",
+ "inbox": "https://instance_url/api/v1/user/sally_smith/inbox",
+ "outbox": "https://instance_url/api/v1/user/sally_smith/outbox",
+ "liked": "https://instance_url/api/v1/user/sally_smith/liked",
+ // TODO disliked?
+ "following": "https://instance_url/api/v1/user/sally_smith/following",
+ "name": "sally_smith",
+ "preferredUsername": "Sally",
+ "icon"?: {
+ "type": "Image",
+ "name": "User icon",
+ "url": "https://instance_url/api/v1/user/sally_smith/icon.png",
+ "width": 32,
+ "height": 32
+ },
+ "published": "2014-12-31T23:00:00-08:00",
+ "summary"?: "This is sally's profile."
+}
+```
+
+### [Community / Group](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-group)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Group",
+ "id": "https://instance_url/api/v1/community/today_i_learned",
+ "name": "today_i_learned"
+ "attributedTo": [ // The moderators
+ "http://joe.example.org",
+ ],
+ "followers": "https://instance_url/api/v1/community/today_i_learned/followers",
+ "published": "2014-12-31T23:00:00-08:00",
+ "summary"?: "The group's tagline",
+ "attachment: [{}] // TBD, these would be where strong types for custom styles, and images would work.
+}
+```
+
+## Objects
+
+### [Post / Page](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-page)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Page",
+ "id": "https://instance_url/api/v1/post/1",
+ "name": "The title of a post, maybe a link to imgur",
+ "url": "https://news.blah.com"
+ "attributedTo": "http://joe.example.org", // The poster
+ "published": "2014-12-31T23:00:00-08:00",
+}
+```
+
+### [Post Listings / Ordered CollectionPage](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollectionpage)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "OrderedCollectionPage",
+ "id": "https://instance_url/api/v1/posts?type={all, best, front}&sort={}&page=1,
+ "partOf": "http://example.org/foo",
+ "orderedItems": [Posts]
+}
+```
+
+### [Comment / Note](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-note)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Note",
+ "id": "https://instance_url/api/v1/comment/1",
+ "mediaType": "text/markdown",
+ "content": "Looks like it is going to rain today. Bring an umbrella *if necessary*!"
+ "attributedTo": john_id,
+ "inReplyTo": "comment or post id",
+ "published": "2014-12-31T23:00:00-08:00",
+ "updated"?: "2014-12-12T12:12:12Z"
+ "replies" // TODO, not sure if these objects should embed all replies in them or not.
+ "to": [sally_id, group_id]
+}
+```
+### [Comment Listings / Ordered CollectionPage](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollectionpage)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "OrderedCollectionPage",
+ "id": "https://instance_url/api/v1/comments?type={all,user,community,post,parent_comment}&id=1&page=1,
+ "partOf": "http://example.org/foo",
+ "orderedItems": [Comments]
+}
+```
+### [Deleted thing / Tombstone](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tombstone)
+```
+{
+ "type": "Tombstone",
+ "formerType": "Note / Post",
+ "id": note / post_id,
+ "deleted": "2016-03-17T00:00:00Z"
+}
+```
+## Actions
+- These are all posts to a user's outbox.
+- The server then creates a post to the necessary inbox of the recipient, or the followers.
+- Whenever a user accesses the site, they do a get from their inbox.
+
+### Comments
+#### [Create](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-create)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Create",
+ "actor": id,
+ "object": comment_id, or post_id
+}
+```
+#### [Delete](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-delete)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Delete",
+ "actor": id,
+ "object": comment_id, or post_id
+}
+```
+#### [Update](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-update)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Create",
+ "actor": id,
+ "object": comment_id, or post_id
+ "content": "New comment",
+ "updated": "New Date"
+}
+```
+#### [Read](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-read)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Read",
+ "actor": user_id
+ "object": comment_id
+}
+```
+
+#### [Like](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-like)
+- TODO: Should likes be notifications? IE, have a to?
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Like",
+ "actor": user_id
+ "object": comment_id
+ // TODO different types of reactions, or no?
+}
+```
+#### [Dislike](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-dislike)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Dislike",
+ "actor": user_id
+ "object": comment_id
+ // TODO different types of reactions, or no?
+}
+```
+
+### Posts
+#### [Create](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-create)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Create",
+ "actor": id,
+ "to": community_id/followers
+ "object": post_id
+}
+```
+#### [Delete](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-delete)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Delete",
+ "actor": id,
+ "object": comment_id, or post_id
+}
+```
+
+#### [Update](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-update)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Create",
+ "actor": id,
+ "object": comment_id, or post_id
+ TODO fields.
+}
+```
+#### [Read](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-read)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Read",
+ "actor": user_id
+ "object": post_id
+}
+```
+
+### Communities
+#### [Create](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-create)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Create",
+ "actor": id,
+ "object": community_id
+}
+```
+#### [Delete](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-delete)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Delete",
+ "actor": id,
+ "object": community_id
+}
+```
+
+#### [Update](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-update)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Create",
+ "actor": id,
+ "object": community_id
+ TODO fields.
+}
+```
+
+#### [Follow / Subscribe](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-follow)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Follow",
+ "actor": id
+ "object": community_id
+}
+```
+
+#### [Ignore/ Unsubscribe](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-ignore)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Follow",
+ "actor": id
+ "object": community_id
+}
+```
+#### [Join / Become a Mod](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-join)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Join",
+ "actor": user_id,
+ "object": community_id
+}
+```
+
+#### [Leave](https://www.w3.org/TR/activitystreams-vocabulary#dfn-leave)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Leave",
+ "actor": user_id,
+ "object": community_id
+}
+```
+
+### Moderator
+#### [Ban user from community / Block](https://www.w3.org/TR/activitystreams-vocabulary#dfn-block)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Remove",
+ "actor": mod_id,
+ "object": user_id,
+ "origin": group_id
+}
+```
+
+#### [Delete Comment](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-delete)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Delete",
+ "actor": id,
+ "object": community_id
+}
+```
+
+#### [Invite a moderator](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-invite)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Invite",
+ "id": "https://instance_url/api/v1/invite/1",
+ "actor": sally_id,
+ "object": group_id,
+ "target": john_id
+}
+```
+#### [Accept Invitation](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-accept)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Accept",
+ "actor": john_id,
+ "object": invite_id
+}
+```
+#### [Reject Invitation](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-reject)
+```
+{
+ "@context": "https://www.w3.org/ns/activitystreams",
+ "type": "Reject",
+ "actor": john_id,
+ "object": invite_id
+}
+```
+
diff --git a/docs/goals.md b/docs/goals.md
new file mode 100644
index 00000000..e569b1f7
--- /dev/null
+++ b/docs/goals.md
@@ -0,0 +1,37 @@
+# Goals
+- Come up with a name / codename.
+- Must have communities.
+- Must have threaded comments.
+- Must be federated: liking and following communities across instances.
+- Be live-updating: have a right pane for new comments, and a main pain for the full threaded view.
+ - Use websockets for post / gets to your own instance.
+
+# Questions
+- How does voting work? Should we go back to the old way of showing up and downvote counts? Or just a score?
+- Decide on tech to be used
+ - Backend: Actix, Diesel.
+ - Frontend: inferno, typescript and bootstrap for now.
+- Should it allow bots?
+- Should the comments / votes be static, or feel like a chat, like [flowchat?](https://flow-chat.com).
+ - Two pane model - Right pane is live comments, left pane is live tree view.
+ - On mobile, allow you to switch between them. Default?
+
+# Resources / Potential Libraries
+- Use the [activitypub crate.](https://docs.rs/activitypub/0.1.4/activitypub/)
+- https://docs.rs/activitypub/0.1.4/activitypub/
+- [Activitypub vocab.](https://www.w3.org/TR/activitystreams-vocabulary/)
+- [Activitypub main](https://www.w3.org/TR/activitypub/)
+- [Diesel to Postgres data types](https://kotiri.com/2018/01/31/postgresql-diesel-rust-types.html)
+- [helpful diesel examples](http://siciarz.net/24-days-rust-diesel/)
+- [Mastodan public key server example](https://blog.joinmastodon.org/2018/06/how-to-implement-a-basic-activitypub-server/)
+- [Recursive query for adjacency list for nested comments](https://stackoverflow.com/questions/192220/what-is-the-most-efficient-elegant-way-to-parse-a-flat-table-into-a-tree/192462#192462)
+- https://github.com/sparksuite/simplemde-markdown-editor
+- [Markdown-it](https://github.com/markdown-it/markdown-it)
+- [Sticky Sidebar](https://stackoverflow.com/questions/38382043/how-to-use-css-position-sticky-to-keep-a-sidebar-visible-with-bootstrap-4/49111934)
+- [RXJS websocket](https://stackoverflow.com/questions/44060315/reconnecting-a-websocket-in-angular-and-rxjs/44067972#44067972)
+- [Rust JWT](https://github.com/Keats/jsonwebtoken)
+- [Hierarchical tree building javascript](https://stackoverflow.com/a/40732240/1655478)
+- [Hot sorting discussion](https://meta.stackexchange.com/questions/11602/what-formula-should-be-used-to-determine-hot-questions) [2](https://medium.com/hacking-and-gonzo/how-reddit-ranking-algorithms-work-ef111e33d0d9)
+- [Classification types.](https://www.reddit.com/r/ModeratorDuck/wiki/subreddit_classification)
+- [Temp Icon](https://www.flaticon.com/free-icon/mouse_194242)
+
diff --git a/docs/ranking.md b/docs/ranking.md
new file mode 100644
index 00000000..f55a1284
--- /dev/null
+++ b/docs/ranking.md
@@ -0,0 +1,28 @@
+# Trending / Hot / Best Sorting algorithm
+## Goals
+- During the day, new posts and comments should be near the top, so they can be voted on.
+- After a day or so, the time factor should go away.
+- Use a log scale, since votes tend to snowball, and so the first 10 votes are just as important as the next hundred.
+
+## Reddit Sorting
+[Reddit's comment sorting algorithm](https://medium.com/hacking-and-gonzo/how-reddit-ranking-algorithms-work-ef111e33d0d9), the wilson confidence sort, is inadequate, because it completely ignores time. What ends up happening, especially in smaller subreddits, is that the early comments end up getting upvoted, and newer comments stay at the bottom, never to be seen.
+
+## Hacker News Sorting
+The [Hacker New's ranking algorithm](https://medium.com/hacking-and-gonzo/how-hacker-news-ranking-algorithm-works-1d9b0cf2c08d) is great, but it doesn't use a log scale for the scores.
+
+## My Algorithm
+```
+Rank = ScaleFactor * sign(Score) * log(1 + abs(Score)) / (Time + 2)^Gravity
+
+Score = Upvotes - Downvotes
+Time = time since submission (in hours)
+Gravity = Decay gravity, 1.8 is default
+```
+
+- Add 1 to the score, so that the standard new comment score of +1 will be affected by time decay. Otherwise all new comments would stay at zero, near the bottom.
+- The sign and abs of the score are necessary for dealing with the log of negative scores.
+- A scale factor of 10k gets the rank in integer form.
+
+A plot of rank over 24 hours, of scores of 1, 5, 10, 100, 1000, with a scale factor of 10k.
+
+![](https://i.imgur.com/w8oBLlL.png)