Skip to content

Commit aea5061

Browse files
committed
Add frame-based navigation
1 parent 8a43f1e commit aea5061

9 files changed

Lines changed: 96 additions & 5 deletions

File tree

data/index.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ interests:
1414
url: https://ar.al/2020/08/07/what-is-the-small-web/
1515
---
1616

17-
Welcome to the [Muhokama](https://github.com/muhokama/) webring. A collection of
18-
**personal spaces** maintained by people _who share certain ideas or approaches
19-
to the Internet_. You can also retrieve **the list of RSS/Atom feeds** associated
20-
with the webring using the [following OPML file](/opml/ring.opml).
17+
Welcome to the [Muhokama](https://github.com/muhokama/) webring. A
18+
collection of **personal spaces** maintained by people _who share
19+
certain ideas or approaches to the Internet_. You can also retrieve
20+
**the list of RSS/Atom feeds** associated with the webring using the
21+
[following OPML file](/opml/ring.opml) or browse the various sites in
22+
[the reader](/u/xvw/frame.html) (making it easy to switch from one
23+
site to another).

lib/action/chain.ml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,27 @@ let index (module R : Sigs.RESOLVER) current_member pred succ =
2929
(module Model.Member_page)
3030
(R.Source.template "layout.html"))
3131

32+
let frame (module R : Sigs.RESOLVER) curr pred succ =
33+
let target = R.Target.frame ~id:(Model.Member.id curr) in
34+
Yocaml.Action.Static.write_file_with_metadata target
35+
(let open Yocaml.Task in
36+
R.track_common_dependencies
37+
>>> Yocaml.Pipeline.track_file R.Source.members
38+
>>> Model.Frame.init ~current:curr ~predecessor:pred ~successor:succ
39+
>>> empty_body ()
40+
>>> Yocaml_jingoo.Pipeline.as_template
41+
(module Model.Frame)
42+
(R.Source.template "frame.html"))
43+
3244
let run (module R : Sigs.RESOLVER) chain =
3345
let member = member (module R) in
3446
let index = index (module R) in
47+
let frame = frame (module R) in
3548
Yocaml.Action.batch_list (Model.Chain.to_list chain)
3649
(fun (curr, (pred, succ)) cache ->
3750
let open Yocaml.Eff in
3851
cache
3952
|> member `Pred curr pred
4053
>>= member `Succ curr succ
54+
>>= frame curr pred succ
4155
>>= index curr pred succ)

lib/model/frame.ml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
type t = { current : Member.t; predecessor : Member.t; successor : Member.t }
2+
3+
let init ~current ~predecessor ~successor =
4+
Yocaml.Task.const { current; predecessor; successor }
5+
6+
let normalize { current; predecessor; successor } =
7+
let open Yocaml.Data in
8+
[
9+
("current", record @@ Member.normalize current);
10+
("predecessor", record @@ Member.normalize predecessor);
11+
("successor", record @@ Member.normalize successor);
12+
]

lib/model/frame.mli

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(** Describe a zipper element of the chain. *)
2+
3+
type t
4+
5+
val init :
6+
current:Member.t ->
7+
predecessor:Member.t ->
8+
successor:Member.t ->
9+
(unit, t) Yocaml.Task.t
10+
11+
val normalize : t -> (string * Yocaml.Data.t) list

lib/resolver.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module Make (R : Sigs.RESOLVABLE) = struct
3434
let index = Path.(R.target / "index.html")
3535
let images = Path.(R.target / "images")
3636
let avatars = Path.(images / "avatars")
37+
let frame ~id = Path.(members / id / "frame.html")
3738
let member ~id = Path.(members / id / "index.html")
3839
let blog = Path.(R.target / "blog.html")
3940

lib/sigs.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ module type RESOLVER = sig
7676
val images : Yocaml.Path.t
7777
val members : Yocaml.Path.t
7878
val member_redirection : id:string -> [ `Pred | `Succ ] -> Yocaml.Path.t
79+
val frame : id:string -> Yocaml.Path.t
7980
val member : id:string -> Yocaml.Path.t
8081
val avatars : Yocaml.Path.t
8182
val blog : Yocaml.Path.t

static/css/style.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ body {
1111
display: flex;
1212
flex-direction: column;
1313
background-color: var(--main-dark-color);
14+
min-height: 100dvh;
1415
}
1516

1617
a {
@@ -325,3 +326,29 @@ footer nav {
325326
flex-direction: column;
326327
}
327328
}
329+
330+
div.frame {
331+
display: flex;
332+
flex-direction: column;
333+
flex: 1;
334+
335+
& aside {
336+
font-family: "Inter";
337+
padding: 1.5rem;
338+
339+
& nav {
340+
margin-top: 0.2rem;
341+
342+
& a {
343+
display: inline-block;
344+
margin-right: 1rem;
345+
font-weight: 700;
346+
}
347+
}
348+
}
349+
350+
& > iframe {
351+
flex: 1;
352+
background-color: #fff;
353+
}
354+
}

static/templates/frame.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="x-ua-compatible" content="ie=edge" />
6+
<title>ring.muhokama.fun - {{ current.main_link.title}}</title>
7+
<link rel="stylesheet" href="/css/style.css" />
8+
</head>
9+
<body>
10+
<div class="frame">
11+
<aside class="toolbox">
12+
Browsing <a href="/">ring.muhokama.fun</a>
13+
<nav>
14+
<a href="/u/{{ predecessor.id }}/frame.html">← {{ predecessor.main_link.title}}</a>
15+
<a href="/u/{{ current.id }}/frame.html">{{ current.main_link.title}}</a>
16+
<a href="/u/{{ successor.id }}/frame.html">{{ successor.main_link.title}} →</a>
17+
</nav>
18+
</aside>
19+
<iframe frameborder="0" src="{{ current.main_link.url.url }}"></iframe>
20+
</div>
21+
</body>
22+
</html>

static/templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h2><a href="/u/{{ m.id }}">{{ m.display_name }}</a></h2>
1818
</div>
1919

2020
<nav>
21-
<a href="{{ m.main_link.url.url }}" title="{{ m.main_link.title }}"
21+
<a href="/u/{{ m.id }}/frame.html" title="{{ m.main_link.title }}"
2222
>www</a
2323
>
2424
{%- if m.has_main_feed -%}

0 commit comments

Comments
 (0)