summaryrefslogtreecommitdiffstats
path: root/adenosine-pds
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2022-11-07 02:56:46 -0800
committerBryan Newbold <bnewbold@robocracy.org>2022-11-07 02:56:46 -0800
commit2f414df00e378728701e4061cdb3bebad5df798a (patch)
tree01a262f07dbfb3ba999ebb803dc33063262c6f9f /adenosine-pds
parent73bb6f114d3fe9233af4f9ab91c8fc2b09b3c6c0 (diff)
downloadadenosine-2f414df00e378728701e4061cdb3bebad5df798a.tar.gz
adenosine-2f414df00e378728701e4061cdb3bebad5df798a.zip
pds: initial pass at crude web interface
Diffstat (limited to 'adenosine-pds')
-rw-r--r--adenosine-pds/Cargo.toml1
-rw-r--r--adenosine-pds/src/lib.rs180
-rw-r--r--adenosine-pds/src/repo.rs1
-rw-r--r--adenosine-pds/src/web.rs66
-rw-r--r--adenosine-pds/templates/about.html6
-rw-r--r--adenosine-pds/templates/adenosine.css626
-rw-r--r--adenosine-pds/templates/at_collection.html12
-rw-r--r--adenosine-pds/templates/at_record.html8
-rw-r--r--adenosine-pds/templates/at_repo.html18
-rw-r--r--adenosine-pds/templates/base.html32
-rw-r--r--adenosine-pds/templates/favicon.pngbin0 -> 2301 bytes
-rw-r--r--adenosine-pds/templates/home.html7
-rw-r--r--adenosine-pds/templates/logo_128.pngbin0 -> 16651 bytes
-rw-r--r--adenosine-pds/templates/post.html5
-rw-r--r--adenosine-pds/templates/profile.html7
-rw-r--r--adenosine-pds/templates/robots.txt1
16 files changed, 966 insertions, 4 deletions
diff --git a/adenosine-pds/Cargo.toml b/adenosine-pds/Cargo.toml
index 64765a4..7075e65 100644
--- a/adenosine-pds/Cargo.toml
+++ b/adenosine-pds/Cargo.toml
@@ -43,6 +43,7 @@ ucan = "0.7.0-alpha.1"
bs58 = "*"
async-trait = "*"
dotenv = "*"
+askama = "0.11"
# for vendored iroh-car
thiserror = "1.0"
diff --git a/adenosine-pds/src/lib.rs b/adenosine-pds/src/lib.rs
index a11b862..ee281e1 100644
--- a/adenosine-pds/src/lib.rs
+++ b/adenosine-pds/src/lib.rs
@@ -10,6 +10,7 @@ use std::fmt;
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::Mutex;
+use askama::Template;
mod car;
mod crypto;
@@ -28,6 +29,7 @@ pub use db::AtpDatabase;
pub use models::*;
pub use repo::{Mutation, RepoCommit, RepoStore};
pub use ucan_p256::P256KeyMaterial;
+use web::*;
struct AtpService {
pub repo: RepoStore,
@@ -74,6 +76,25 @@ fn xrpc_wrap<S: serde::Serialize>(resp: Result<S>) -> Response {
}
}
+/// Helper to take a Askama render Result and transform it to a rouille response, including more
+/// friendly HTML 404s, etc.
+fn web_wrap(resp: Result<String>) -> Response {
+ match resp {
+ Ok(val) => Response::html(val),
+ Err(e) => {
+ let msg = e.to_string();
+ let code = match e.downcast_ref::<XrpcError>() {
+ Some(XrpcError::BadRequest(_)) => 400,
+ Some(XrpcError::NotFound(_)) => 404,
+ Some(XrpcError::Forbidden(_)) => 403,
+ None => 500,
+ };
+ warn!("HTTP {}: {}", code, msg);
+ Response::html(format!("<html><body><h1>{}</h1><p>{}</body></html>", code, msg))
+ }
+ }
+}
+
pub fn run_server(
port: u16,
blockstore_db_path: &PathBuf,
@@ -100,13 +121,44 @@ pub fn run_server(
);
};
- // TODO: robots.txt
// TODO: some static files? https://github.com/tomaka/rouille/blob/master/examples/static-files.rs
rouille::start_server(format!("localhost:{}", port), move |request| {
rouille::log_custom(request, log_ok, log_err, || {
router!(request,
(GET) ["/"] => {
- Response::text("Not much to see here yet!")
+ let view = GenericHomeView { domain: "domain.todo".to_string() };
+ Response::html(view.render().unwrap())
+ },
+ (GET) ["/about"] => {
+ let view = AboutView { domain: "domain.todo".to_string() };
+ Response::html(view.render().unwrap())
+ },
+ (GET) ["/robots.txt"] => {
+ Response::text(include_str!("../templates/robots.txt"))
+ },
+ (GET) ["/u/{did}", did: Did] => {
+ web_wrap(profile_handler(&srv, &did, request))
+ },
+ (GET) ["/u/{did}/{collection}/{tid}", did: Did, collection: Nsid, tid: Tid] => {
+ web_wrap(post_handler(&srv, &did, &collection, &tid, request))
+ },
+ (GET) ["/at/{did}", did: Did] => {
+ web_wrap(repo_handler(&srv, &did, request))
+ },
+ (GET) ["/at/{did}/{collection}", did: Did, collection: Nsid] => {
+ web_wrap(collection_handler(&srv, &did, &collection, request))
+ },
+ (GET) ["/at/{did}/{collection}/{tid}", did: Did, collection: Nsid, tid: Tid] => {
+ web_wrap(record_handler(&srv, &did, &collection, &tid, request))
+ },
+ (GET) ["/static/adenosine.css"] => {
+ Response::from_data("text/css", include_str!("../templates/adenosine.css"))
+ },
+ (GET) ["/static/favicon.png"] => {
+ Response::from_data("image/png", include_bytes!("../templates/favicon.png").to_vec())
+ },
+ (GET) ["/static/logo_128.png"] => {
+ Response::from_data("image/png", include_bytes!("../templates/logo_128.png").to_vec())
},
(POST) ["/xrpc/{endpoint}", endpoint: String] => {
xrpc_wrap(xrpc_post_handler(&srv, &endpoint, request))
@@ -114,7 +166,7 @@ pub fn run_server(
(GET) ["/xrpc/{endpoint}", endpoint: String] => {
xrpc_wrap(xrpc_get_handler(&srv, &endpoint, request))
},
- _ => rouille::Response::empty_404()
+ _ => Response::text("404: Not Found")
)
})
});
@@ -205,7 +257,7 @@ fn xrpc_get_handler(
"com.atproto.server.getAccountsConfig" => {
Ok(json!({"availableUserDomains": ["test"], "inviteCodeRequired": false}))
}
- "com.atproto.repoGetRecord" => {
+ "com.atproto.repo.getRecord" => {
let did = Did::from_str(&xrpc_required_param(request, "user")?)?;
let collection = Nsid::from_str(&xrpc_required_param(request, "collection")?)?;
let rkey = Tid::from_str(&xrpc_required_param(request, "rkey")?)?;
@@ -456,3 +508,123 @@ fn xrpc_post_handler(
)))),
}
}
+
+fn profile_handler(srv: &Mutex<AtpService>, did: &str, _request: &Request) -> Result<String> {
+ let did = Did::from_str(did)?;
+ let mut _srv = srv.lock().expect("service mutex");
+
+ // TODO: get profile (bsky helper)
+ // TODO: get feed (bsky helper)
+
+ Ok(ProfileView {
+ domain: "domain.todo".to_string(),
+ did: did,
+ profile: json!({}),
+ feed: vec![],
+ }.render()?)
+}
+
+fn post_handler(srv: &Mutex<AtpService>, did: &str, collection: &str, tid: &str, _request: &Request) -> Result<String> {
+ let did = Did::from_str(did)?;
+ let collection = Nsid::from_str(collection)?;
+ let rkey = Tid::from_str(tid)?;
+ let mut srv = srv.lock().expect("service mutex");
+
+ let post = match srv.repo.get_atp_record(&did, &collection, &rkey) {
+ // TODO: format as JSON, not text debug
+ Ok(Some(ipld)) => ipld_into_json_value(ipld),
+ Ok(None) => Err(anyhow!(XrpcError::NotFound(format!(
+ "could not find record: /{}/{}", collection, rkey
+ ))))?,
+ Err(e) => Err(e)?,
+ };
+
+ Ok(PostView {
+ domain: "domain.todo".to_string(),
+ did: did,
+ collection: collection,
+ tid: rkey,
+ post_text: post["text"].as_str().unwrap().to_string(), // TODO: unwrap
+ post_created_at: "some-time".to_string(),
+ }.render()?)
+}
+
+fn repo_handler(srv: &Mutex<AtpService>, did: &str, _request: &Request) -> Result<String> {
+ let did = Did::from_str(did)?;
+
+ let mut srv = srv.lock().expect("service mutex");
+ let did_doc = srv.atp_db.get_did_doc(&did)?;
+ let commit_cid = &srv.repo.lookup_commit(&did)?.unwrap();
+ let commit = srv.repo.get_commit(commit_cid)?;
+ let collections: Vec<String> = srv.repo.collections(&did)?;
+ let desc = RepoDescribe {
+ name: did.to_string(), // TODO
+ did: did.to_string(),
+ didDoc: did_doc,
+ collections: collections,
+ nameIsCorrect: true,
+ };
+
+ Ok(RepoView {
+ domain: "domain.todo".to_string(),
+ did: did,
+ commit: commit,
+ describe: desc,
+ }.render()?)
+}
+
+fn collection_handler(srv: &Mutex<AtpService>, did: &str, collection: &str, _request: &Request) -> Result<String> {
+ let did = Did::from_str(did)?;
+ let collection = Nsid::from_str(collection)?;
+
+ let mut record_list: Vec<Value> = vec![];
+ let mut srv = srv.lock().expect("service mutex");
+ let commit_cid = &srv.repo.lookup_commit(&did)?.unwrap();
+ let last_commit = srv.repo.get_commit(commit_cid)?;
+ let full_map = srv.repo.mst_to_map(&last_commit.mst_cid)?;
+ let prefix = format!("/{}/", collection);
+ for (mst_key, cid) in full_map.iter() {
+ debug!("{}", mst_key);
+ if mst_key.starts_with(&prefix) {
+ let record = srv.repo.get_ipld(cid)?;
+ record_list.push(json!({
+ "uri": format!("at://{}{}", did, mst_key),
+ "tid": mst_key.split('/').nth(2).unwrap(),
+ "cid": cid,
+ "value": ipld_into_json_value(record),
+ }));
+ }
+ }
+
+ Ok(CollectionView {
+ domain: "domain.todo".to_string(),
+ did: did,
+ collection: collection,
+ records: record_list,
+ }.render()?)
+}
+
+fn record_handler(srv: &Mutex<AtpService>, did: &str, collection: &str, tid: &str, _request: &Request) -> Result<String> {
+
+ let did = Did::from_str(did)?;
+ let collection = Nsid::from_str(collection)?;
+ let rkey = Tid::from_str(tid)?;
+
+ let mut srv = srv.lock().expect("service mutex");
+ let key = format!("/{}/{}", collection, rkey);
+ let record = match srv.repo.get_atp_record(&did, &collection, &rkey) {
+ Ok(Some(ipld)) => ipld_into_json_value(ipld),
+ Ok(None) => Err(anyhow!(XrpcError::NotFound(format!(
+ "could not find record: {}",
+ key
+ ))))?,
+ Err(e) => Err(e)?,
+ };
+ Ok(RecordView {
+ domain: "domain.todo".to_string(),
+ did,
+ collection,
+ tid: rkey,
+ record,
+ }.render()?)
+}
diff --git a/adenosine-pds/src/repo.rs b/adenosine-pds/src/repo.rs
index 1bfc581..7b6f7e6 100644
--- a/adenosine-pds/src/repo.rs
+++ b/adenosine-pds/src/repo.rs
@@ -14,6 +14,7 @@ use std::collections::HashSet;
use std::path::PathBuf;
use std::str::FromStr;
+#[derive(Debug)]
pub struct RepoCommit {
pub sig: Box<[u8]>,
pub commit_cid: Cid,
diff --git a/adenosine-pds/src/web.rs b/adenosine-pds/src/web.rs
new file mode 100644
index 0000000..81e62be
--- /dev/null
+++ b/adenosine-pds/src/web.rs
@@ -0,0 +1,66 @@
+
+use adenosine_cli::identifiers::{Did, Nsid, Tid};
+use serde_json;
+use askama::Template;
+use crate::repo::RepoCommit;
+use crate::models::*;
+
+#[derive(Template)]
+#[template(path = "home.html")]
+pub struct GenericHomeView {
+ pub domain: String,
+}
+
+#[derive(Template)]
+#[template(path = "about.html")]
+pub struct AboutView {
+ pub domain: String,
+}
+
+#[derive(Template)]
+#[template(path = "profile.html")]
+pub struct ProfileView {
+ pub domain: String,
+ pub did: Did,
+ pub profile: serde_json::Value,
+ pub feed: Vec<serde_json::Value>,
+}
+
+#[derive(Template)]
+#[template(path = "post.html")]
+pub struct PostView {
+ pub domain: String,
+ pub did: Did,
+ pub collection: Nsid,
+ pub tid: Tid,
+ pub post_text: String,
+ pub post_created_at: String,
+}
+
+#[derive(Template)]
+#[template(path = "at_repo.html")]
+pub struct RepoView {
+ pub domain: String,
+ pub did: Did,
+ pub commit: RepoCommit,
+ pub describe: RepoDescribe,
+}
+
+#[derive(Template)]
+#[template(path = "at_collection.html")]
+pub struct CollectionView {
+ pub domain: String,
+ pub did: Did,
+ pub collection: Nsid,
+ pub records: Vec<serde_json::Value>,
+}
+
+#[derive(Template)]
+#[template(path = "at_record.html")]
+pub struct RecordView {
+ pub domain: String,
+ pub did: Did,
+ pub collection: Nsid,
+ pub tid: Tid,
+ pub record: serde_json::Value,
+}
diff --git a/adenosine-pds/templates/about.html b/adenosine-pds/templates/about.html
new file mode 100644
index 0000000..6c30c6b
--- /dev/null
+++ b/adenosine-pds/templates/about.html
@@ -0,0 +1,6 @@
+{% extends "base.html" %}
+
+{% block content %}
+This about page is the kind of place one would put policies, license details, etc.
+
+{% endblock %}
diff --git a/adenosine-pds/templates/adenosine.css b/adenosine-pds/templates/adenosine.css
new file mode 100644
index 0000000..0686f9e
--- /dev/null
+++ b/adenosine-pds/templates/adenosine.css
@@ -0,0 +1,626 @@
+/* This is simple.css, commit a73f11a: https://simplecss.org/
+ * adenosine styles are at the very bottom */
+/* Global variables. */
+:root {
+ /* Set sans-serif & mono fonts */
+ --sans-font: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir,
+ "Nimbus Sans L", Roboto, "Noto Sans", "Segoe UI", Arial, Helvetica,
+ "Helvetica Neue", sans-serif;
+ --mono-font: Consolas, Menlo, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
+
+ /* Default (light) theme */
+ --bg: #fff;
+ --accent-bg: #f5f7ff;
+ --text: #212121;
+ --text-light: #585858;
+ --border: #898EA4;
+ --accent: #0d47a1;
+ --code: #d81b60;
+ --preformatted: #444;
+ --marked: #ffdd33;
+ --disabled: #efefef;
+}
+
+/* Dark theme */
+@media (prefers-color-scheme: dark) {
+ :root {
+ color-scheme: dark;
+ --bg: #212121;
+ --accent-bg: #2b2b2b;
+ --text: #dcdcdc;
+ --text-light: #ababab;
+ --accent: #ffb300;
+ --code: #f06292;
+ --preformatted: #ccc;
+ --disabled: #111;
+ }
+ /* Add a bit of transparency so light media isn't so glaring in dark mode */
+ img,
+ video {
+ opacity: 0.8;
+ }
+}
+
+/* Reset box-sizing */
+*, *::before, *::after {
+ box-sizing: border-box;
+}
+
+/* Reset default appearance */
+textarea,
+select,
+input,
+progress {
+ appearance: none;
+ -webkit-appearance: none;
+ -moz-appearance: none;
+}
+
+html {
+ /* Set the font globally */
+ font-family: var(--sans-font);
+ scroll-behavior: smooth;
+}
+
+/* Make the body a nice central block */
+body {
+ color: var(--text);
+ background-color: var(--bg);
+ font-size: 1.15rem;
+ line-height: 1.5;
+ display: grid;
+ grid-template-columns: 1fr min(45rem, 90%) 1fr;
+ margin: 0;
+}
+body > * {
+ grid-column: 2;
+}
+
+/* Make the header bg full width, but the content inline with body */
+body > header {
+ background-color: var(--accent-bg);
+ border-bottom: 1px solid var(--border);
+ text-align: center;
+ padding: 0 0.5rem 2rem 0.5rem;
+ grid-column: 1 / -1;
+}
+
+body > header h1 {
+ max-width: 1200px;
+ margin: 1rem auto;
+}
+
+body > header p {
+ max-width: 40rem;
+ margin: 1rem auto;
+}
+
+/* Add a little padding to ensure spacing is correct between content and header > nav */
+main {
+ padding-top: 1.5rem;
+}
+
+body > footer {
+ margin-top: 4rem;
+ padding: 2rem 1rem 1.5rem 1rem;
+ color: var(--text-light);
+ font-size: 0.9rem;
+ text-align: center;
+ border-top: 1px solid var(--border);
+}
+
+/* Format headers */
+h1 {
+ font-size: 3rem;
+}
+
+h2 {
+ font-size: 2.6rem;
+ margin-top: 3rem;
+}
+
+h3 {
+ font-size: 2rem;
+ margin-top: 3rem;
+}
+
+h4 {
+ font-size: 1.44rem;
+}
+
+h5 {
+ font-size: 1.15rem;
+}
+
+h6 {
+ font-size: 0.96rem;
+}
+
+/* Prevent long strings from overflowing container */
+p, h1, h2, h3, h4, h5, h6 {
+ overflow-wrap: break-word;
+}
+
+/* Fix line height when title wraps */
+h1,
+h2,
+h3 {
+ line-height: 1.1;
+}
+
+/* Reduce header size on mobile */
+@media only screen and (max-width: 720px) {
+ h1 {
+ font-size: 2.5rem;
+ }
+
+ h2 {
+ font-size: 2.1rem;
+ }
+
+ h3 {
+ font-size: 1.75rem;
+ }
+
+ h4 {
+ font-size: 1.25rem;
+ }
+}
+
+/* Format links & buttons */
+a,
+a:visited {
+ color: var(--accent);
+}
+
+a:hover {
+ text-decoration: none;
+}
+
+button,
+[role="button"],
+input[type="submit"],
+input[type="reset"],
+input[type="button"],
+label[type="button"] {
+ border: none;
+ border-radius: 5px;
+ background-color: var(--accent);
+ font-size: 1rem;
+ color: var(--bg);
+ padding: 0.7rem 0.9rem;
+ margin: 0.5rem 0;
+}
+
+button[disabled],
+[role="button"][aria-disabled="true"],
+input[type="submit"][disabled],
+input[type="reset"][disabled],
+input[type="button"][disabled],
+input[type="checkbox"][disabled],
+input[type="radio"][disabled],
+select[disabled] {
+ opacity: 0.5;
+ cursor: not-allowed;
+}
+
+input:disabled,
+textarea:disabled,
+select:disabled {
+ cursor: not-allowed;
+ background-color: var(--disabled);
+}
+
+input[type="range"] {
+ padding: 0;
+}
+
+/* Set the cursor to '?' on an abbreviation and style the abbreviation to show that there is more information underneath */
+abbr[title] {
+ cursor: help;
+ text-decoration-line: underline;
+ text-decoration-style: dotted;
+}
+
+button:focus,
+button:enabled:hover,
+[role="button"]:focus,
+[role="button"]:not([aria-disabled="true"]):hover,
+input[type="submit"]:focus,
+input[type="submit"]:enabled:hover,
+input[type="reset"]:focus,
+input[type="reset"]:enabled:hover,
+input[type="button"]:focus,
+input[type="button"]:enabled:hover,
+label[type="button"]:focus,
+label[type="button"]:hover {
+ filter: brightness(1.4);
+ cursor: pointer;
+}
+
+/* Format navigation */
+header > nav {
+ font-size: 1rem;
+ line-height: 2;
+ padding: 1rem 0 0 0;
+}
+
+/* Use flexbox to allow items to wrap, as needed */
+header > nav ul,
+header > nav ol {
+ align-content: space-around;
+ align-items: center;
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ justify-content: center;
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+}
+
+/* List items are inline elements, make them behave more like blocks */
+header > nav ul li,
+header > nav ol li {
+ display: inline-block;
+}
+
+header > nav a,
+header > nav a:visited {
+ margin: 0 0.5rem 1rem 0.5rem;
+ border: 1px solid var(--border);
+ border-radius: 5px;
+ color: var(--text);
+ display: inline-block;
+ padding: 0.1rem 1rem;
+ text-decoration: none;
+}
+
+header > nav a:hover {
+ border-color: var(--accent);
+ color: var(--accent);
+ cursor: pointer;
+}
+
+/* Reduce nav side on mobile */
+@media only screen and (max-width: 720px) {
+ header > nav a {
+ border: none;
+ padding: 0;
+ text-decoration: underline;
+ line-height: 1;
+ }
+}
+
+/* Consolidate box styling */
+aside, details, pre, progress {
+ background-color: var(--accent-bg);
+ border: 1px solid var(--border);
+ border-radius: 5px;
+ margin-bottom: 1rem;
+}
+
+aside {
+ font-size: 1rem;
+ width: 30%;
+ padding: 0 15px;
+ margin-left: 15px;
+ float: right;
+}
+
+/* Make aside full-width on mobile */
+@media only screen and (max-width: 720px) {
+ aside {
+ width: 100%;
+ float: none;
+ margin-left: 0;
+ }
+}
+
+article, fieldset {
+ border: 1px solid var(--border);
+ padding: 1rem;
+ border-radius: 5px;
+ margin-bottom: 1rem;
+}
+
+article h2:first-child,
+section h2:first-child {
+ margin-top: 1rem;
+}
+
+section {
+ border-top: 1px solid var(--border);
+ border-bottom: 1px solid var(--border);
+ padding: 2rem 1rem;
+ margin: 3rem 0;
+}
+
+/* Don't double separators when chaining sections */
+section + section,
+section:first-child {
+ border-top: 0;
+ padding-top: 0;
+}
+
+section:last-child {
+ border-bottom: 0;
+ padding-bottom: 0;
+}
+
+details {
+ padding: 0.7rem 1rem;
+}
+
+summary {
+ cursor: pointer;
+ font-weight: bold;
+ padding: 0.7rem 1rem;
+ margin: -0.7rem -1rem;
+ word-break: break-all;
+}
+
+details[open] > summary + * {
+ margin-top: 0;
+}
+
+details[open] > summary {
+ margin-bottom: 0.5rem;
+}
+
+details[open] > :last-child {
+ margin-bottom: 0;
+}
+
+/* Format tables */
+table {
+ border-collapse: collapse;
+ display: block;
+ margin: 1.5rem 0;
+ overflow: auto;
+ width: 100%;
+}
+
+td,
+th {
+ border: 1px solid var(--border);
+ text-align: left;
+ padding: 0.5rem;
+}
+
+th {
+ background-color: var(--accent-bg);
+ font-weight: bold;
+}
+
+tr:nth-child(even) {
+ /* Set every other cell slightly darker. Improves readability. */
+ background-color: var(--accent-bg);
+}
+
+table caption {
+ font-weight: bold;
+ margin-bottom: 0.5rem;
+}
+
+/* Format forms */
+textarea,
+select,
+input {
+ font-size: inherit;
+ font-family: inherit;
+ padding: 0.5rem;
+ margin-bottom: 0.5rem;
+ color: var(--text);
+ background-color: var(--bg);
+ border: 1px solid var(--border);
+ border-radius: 5px;
+ box-shadow: none;
+ max-width: 100%;
+ display: inline-block;
+}
+label {
+ display: block;
+}
+textarea:not([cols]) {
+ width: 100%;
+}
+
+/* Add arrow to drop-down */
+select:not([multiple]) {
+ background-image: linear-gradient(45deg, transparent 49%, var(--text) 51%),
+ linear-gradient(135deg, var(--text) 51%, transparent 49%);
+ background-position: calc(100% - 15px), calc(100% - 10px);
+ background-size: 5px 5px, 5px 5px;
+ background-repeat: no-repeat;
+ padding-right: 25px;
+}
+
+/* checkbox and radio button style */
+input[type="checkbox"],
+input[type="radio"] {
+ vertical-align: middle;
+ position: relative;
+ width: min-content;
+}
+
+input[type="checkbox"] + label,
+input[type="radio"] + label {
+ display: inline-block;
+}
+
+input[type="radio"] {
+ border-radius: 100%;
+}
+
+input[type="checkbox"]:checked,
+input[type="radio"]:checked {
+ background-color: var(--accent);
+}
+
+input[type="checkbox"]:checked::after {
+ /* Creates a rectangle with colored right and bottom borders which is rotated to look like a check mark */
+ content: " ";
+ width: 0.18em;
+ height: 0.32em;
+ border-radius: 0;
+ position: absolute;
+ top: 0.05em;
+ left: 0.17em;
+ background-color: transparent;
+ border-right: solid var(--bg) 0.08em;
+ border-bottom: solid var(--bg) 0.08em;
+ font-size: 1.8em;
+ transform: rotate(45deg);
+}
+input[type="radio"]:checked::after {
+ /* creates a colored circle for the checked radio button */
+ content: " ";
+ width: 0.25em;
+ height: 0.25em;
+ border-radius: 100%;
+ position: absolute;
+ top: 0.125em;
+ background-color: var(--bg);
+ left: 0.125em;
+ font-size: 32px;
+}
+
+/* Makes input fields wider on smaller screens */
+@media only screen and (max-width: 720px) {
+ textarea,
+ select,
+ input {
+ width: 100%;
+ }
+}
+
+/* Set a height for color input */
+input[type="color"] {
+ height: 2.5rem;
+ padding: 0.2rem;
+}
+
+/* do not show border around file selector button */
+input[type="file"] {
+ border: 0;
+}
+
+/* Misc body elements */
+hr {
+ border: none;
+ height: 1px;
+ background: var(--border);
+ margin: 1rem auto;
+}
+
+mark {
+ padding: 2px 5px;
+ border-radius: 4px;
+ background-color: var(--marked);
+}
+
+img,
+video {
+ max-width: 100%;
+ height: auto;
+ border-radius: 5px;
+}
+
+figure {
+ margin: 0;
+ text-align: center;
+}
+
+figcaption {
+ font-size: 0.9rem;
+ color: var(--text-light);
+ margin-bottom: 1rem;
+}
+
+blockquote {
+ margin: 2rem 0 2rem 2rem;
+ padding: 0.4rem 0.8rem;
+ border-left: 0.35rem solid var(--accent);
+ color: var(--text-light);
+ font-style: italic;
+}
+
+cite {
+ font-size: 0.9rem;
+ color: var(--text-light);
+ font-style: normal;
+}
+
+dt {
+ color: var(--text-light);
+}
+
+/* Use mono font for code elements */
+code,
+pre,
+pre span,
+kbd,
+samp {
+ font-family: var(--mono-font);
+ color: var(--code);
+}
+
+kbd {
+ color: var(--preformatted);
+ border: 1px solid var(--preformatted);
+ border-bottom: 3px solid var(--preformatted);
+ border-radius: 5px;
+ padding: 0.1rem 0.4rem;
+}
+
+pre {
+ padding: 1rem 1.4rem;
+ max-width: 100%;
+ overflow: auto;
+ color: var(--preformatted);
+}
+
+/* Fix embedded code within pre */
+pre code {
+ color: var(--preformatted);
+ background: none;
+ margin: 0;
+ padding: 0;
+}
+
+/* Progress bars */
+/* Declarations are repeated because you */
+/* cannot combine vendor-specific selectors */
+progress {
+ width: 100%;
+}
+
+progress:indeterminate {
+ background-color: var(--accent-bg);
+}
+
+progress::-webkit-progress-bar {
+ border-radius: 5px;
+ background-color: var(--accent-bg);
+}
+
+progress::-webkit-progress-value {
+ border-radius: 5px;
+ background-color: var(--accent);
+}
+
+progress::-moz-progress-bar {
+ border-radius: 5px;
+ background-color: var(--accent);
+ transition-property: width;
+ transition-duration: 0.3s;
+}
+
+progress:indeterminate::-moz-progress-bar {
+ background-color: var(--accent-bg);
+}
+
+/********** adenosine tweaks **********/
+body { font-family: var(--mono-font); }
+a { text-decoration: none; }
diff --git a/adenosine-pds/templates/at_collection.html b/adenosine-pds/templates/at_collection.html
new file mode 100644
index 0000000..b4b7036
--- /dev/null
+++ b/adenosine-pds/templates/at_collection.html
@@ -0,0 +1,12 @@
+{% extends "base.html" %}
+
+{% block main %}
+<p><b>at://{{ did }}/{{ collection }}/</b>
+
+<p><b>records:</b>
+<ul>
+{% for record in records %}
+ <li><a href="/at/{{did}}/{{collection}}/{{record["tid"].as_str().unwrap() }}">{{ record["tid"].as_str().unwrap() }}</a>
+{% endfor %}
+</ul>
+{% endblock %}
diff --git a/adenosine-pds/templates/at_record.html b/adenosine-pds/templates/at_record.html
new file mode 100644
index 0000000..10ed838
--- /dev/null
+++ b/adenosine-pds/templates/at_record.html
@@ -0,0 +1,8 @@
+{% extends "base.html" %}
+
+{% block main %}
+<p><b>at://{{ did }}/{{ collection }}/{{ tid }}</b>
+
+<p><b>record json:</b>
+<pre><code>{{ record }}</code></pre>
+{% endblock %}
diff --git a/adenosine-pds/templates/at_repo.html b/adenosine-pds/templates/at_repo.html
new file mode 100644
index 0000000..dcf4d87
--- /dev/null
+++ b/adenosine-pds/templates/at_repo.html
@@ -0,0 +1,18 @@
+{% extends "base.html" %}
+
+{% block main %}
+<p><b>at://{{ did }}/</b>
+
+<p><b>collections:</b>
+<ul>
+{% for collection in describe.collections %}
+ <li><a href="/at/{{ did }}/{{ collection }}">{{collection}}/</a>
+{% endfor %}
+</ul>
+
+<p>repo commit:
+<pre><code>{{ "{:?}"|format(commit) }}</code></pre>
+
+<p>repo describe
+<pre><code>{{ "{:?}"|format(describe) }}</code></pre>
+{% endblock %}
diff --git a/adenosine-pds/templates/base.html b/adenosine-pds/templates/base.html
new file mode 100644
index 0000000..0ae2061
--- /dev/null
+++ b/adenosine-pds/templates/base.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <link rel="stylesheet" href="/static/adenosine.css" type="text/css">
+ <link rel="icon" href="/static/favicon.png" />
+ <title>{% block title -%}adenosine{%- endblock %}</title>
+ {% block head %}{% endblock %}
+ </head>
+ <body>
+ <nav>
+ <a href="/">
+ <h3>
+ <img src="/static/logo_128.png" width="64" height="64">{{ domain }}
+ </h3>
+ </a>
+ </nav>
+ <hr>
+ <main>
+ {% block main %}{% endblock %}
+ </main>
+ <hr>
+ <footer>
+ <nav>
+ <a href="/">home</a> -
+ <a href="/about">about</a> -
+ <a href="https://gitlab.com/bnewbold/adenosine">source code</a>
+ </nav>
+ </footer>
+ </body>
+</html>
diff --git a/adenosine-pds/templates/favicon.png b/adenosine-pds/templates/favicon.png
new file mode 100644
index 0000000..5be4e16
--- /dev/null
+++ b/adenosine-pds/templates/favicon.png
Binary files differ
diff --git a/adenosine-pds/templates/home.html b/adenosine-pds/templates/home.html
new file mode 100644
index 0000000..3854d4a
--- /dev/null
+++ b/adenosine-pds/templates/home.html
@@ -0,0 +1,7 @@
+{% extends "base.html" %}
+
+{% block content %}
+This is the homepage, which maybe would describe what adenosine is, and what
+this instance is specifically.
+
+{% endblock %}
diff --git a/adenosine-pds/templates/logo_128.png b/adenosine-pds/templates/logo_128.png
new file mode 100644
index 0000000..39ea824
--- /dev/null
+++ b/adenosine-pds/templates/logo_128.png
Binary files differ
diff --git a/adenosine-pds/templates/post.html b/adenosine-pds/templates/post.html
new file mode 100644
index 0000000..d7e6c85
--- /dev/null
+++ b/adenosine-pds/templates/post.html
@@ -0,0 +1,5 @@
+{% extends "base.html" %}
+
+{% block post %}
+Post page (TODO)
+{% endblock %}
diff --git a/adenosine-pds/templates/profile.html b/adenosine-pds/templates/profile.html
new file mode 100644
index 0000000..7c17951
--- /dev/null
+++ b/adenosine-pds/templates/profile.html
@@ -0,0 +1,7 @@
+{% extends "base.html" %}
+
+{% block main %}
+<p><b>at://{{ did }}/</b>
+
+<p>Profile page (TODO)
+{% endblock %}
diff --git a/adenosine-pds/templates/robots.txt b/adenosine-pds/templates/robots.txt
new file mode 100644
index 0000000..2cba06f
--- /dev/null
+++ b/adenosine-pds/templates/robots.txt
@@ -0,0 +1 @@
+// this is the default adenosine PDS robots.txt file