Skip to content

Commit

Permalink
Add data url
Browse files Browse the repository at this point in the history
  • Loading branch information
nntrn committed Oct 1, 2024
1 parent 807274f commit 60ba5ec
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion _includes/breadcrumb.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{%- assign crumbs = page.url | split: '/' -%}
{%- for crumb in crumbs -%}
{%- if forloop.last -%}
<span>&#47;{{crumb}}</strong>
<span>&#47;{{crumb|replace:".html",""}}</strong>
{% elsif forloop.first %}
<a href="{{ '/' | relative_url}}">home</a>
{%- else -%}
Expand Down
1 change: 1 addition & 0 deletions _includes/docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ a:hover{color:#222}
.mark q{background:var(--bs-highlight-bg)}
.muted{color:#656d76}
.gray{color:#aaa}
.accent{color:rgba(var(--bs-primary-rgb),.5)}
.sans-serif{font-family:var(--bs-font-sans-serif)}
.serif{font-family:var(--bs-font-serif)}
.pre{white-space:pre}
Expand Down
2 changes: 2 additions & 0 deletions _layouts/book.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ <h3 class="h5">{{page.author}}</h3>
<span>{{annotations.size}} annotation{% if annotations.size > 1 %}s{%- endif -%}</span>
<span class="accent">&bull;</span>
<span><span title="Created">{{pagecreated}}</span>{%- if pagemodified != pagecreated -%}&nbsp;&ndash;&nbsp;<span title="Modified">{{pagemodified}}</span>{%- endif %}</span>
<span class="accent">&bull;</span>
<a class="muted" href="{{site.baseurl}}/api/{{page.assetid}}.json">data</a>
</div>
<hr>
<section class="d-flex gap-sm-3 gap-lg-5">
Expand Down
4 changes: 2 additions & 2 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
</head>
<body data-layout="{{site.font_family}}">
<div class="container">
<header class="my-2 d-flex flex-column gap-2">
<div class="d-flex justify-content-between align-items-baseline">
<header class="mt-2 d-flex flex-column gap-2 mb-3">
<div class="d-flex justify-content-between align-items-baseline flex-wrap">
<h1 class="h1 site-title"><a href="{{ '/' | relative_url }}">{{site.title}}</a></h1>
<div class="d-flex gap-2 smaller">
{%- for link in site.links %}
Expand Down
8 changes: 4 additions & 4 deletions _layouts/genre.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<h2>{{page.tag|replace: "-"," "}}</h2>
<ul style="width:90%" class="d-flex flex-column gap-3">
{%- for book in booklist %}
<li class="small">
<li class="small text-mute">
<h3 class="h6"><a href="{{book.slug}}">{{book.title}}</a> by {{book.author|split: ","|first}}</h3>
<span class="text-muted">last read on <time>{{book.modified|date: '%b %e %Y'}}</time></span>
<span class="red">&nbsp;/&nbsp;</span>
<span>{{book.count}} annotation{% if book.count > 1 %}s{%- endif -%}</span>
<span>last read on <time>{{book.modified|date: '%b %e %Y'}}</time></span>
<span>&nbsp;/&nbsp;</span>
<span class="accent">{{book.count}} annotation{% if book.count > 1 %}s{%- endif -%}</span>
</li>
{%- endfor %}
</ul>
Expand Down
9 changes: 5 additions & 4 deletions scripts/books.jq
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,25 @@ def identify_subsection:

def getnum($str): $str
| gsub("(?<w>[^0-9])(?<n>[0-9]+)";.w + " " + .n)
| [match("(\\b[0-9]+)";"g").string|tonumber]|last|tostring;
| [match("(\\b[0-9]+)";"g").string|tonumber]|first|tostring;

def format_chapter:
([.]|flatten|unique) as $input
| ($input | join(" ")
| gsub("x?[0-9]{8,}"; .n; "x")) as $str
| gsub("x?[0-9 ]{8,}"; ""; "x")) as $str
| $str |
if test("[cC][chapter]{1,}") or test("^[cC].*([0-9]+)") then "Chapter " + getnum($str)
if test("[cC][chapter]{1,}";"i") then "Chapter " + getnum($input|map(select("^[cChapter]{2,}"))|first)
elif test("toc_marker") then getnum($str)
else
$str
| gsub("(epub|EPUB|[[:punct:]]?xhtml|html|ji[0-9]+|sup[0-9]+|nav_|div[0-9]+)"; "")
| gsub("^[^a-zA-Z0-9]+";"")
# | if ($input[0]| test("^[cC][chapter]{1,}")) then "Chapter " + getnum($str)
end
;

def format_location:
[match("\\[([^\\]]+)\\]+";"g").captures[].string] as $raw
| ($raw|join(" ")|identify_subsection) as $sec
| (if $sec then $sec else ($raw|format_chapter) end)
| (if $sec then $sec else ($raw|first|format_chapter) end)
;

0 comments on commit 60ba5ec

Please sign in to comment.