Work on default theme
- Add caching for SQLite
This commit is contained in:
parent
a4bdac7b55
commit
cfc9472a2e
|
@ -26,6 +26,7 @@
|
||||||
<PackageReference Include="Giraffe" Version="6.0.0" />
|
<PackageReference Include="Giraffe" Version="6.0.0" />
|
||||||
<PackageReference Include="Giraffe.Htmx" Version="1.7.0" />
|
<PackageReference Include="Giraffe.Htmx" Version="1.7.0" />
|
||||||
<PackageReference Include="Giraffe.ViewEngine.Htmx" Version="1.7.0" />
|
<PackageReference Include="Giraffe.ViewEngine.Htmx" Version="1.7.0" />
|
||||||
|
<PackageReference Include="NeoSmart.Caching.Sqlite" Version="6.0.1" />
|
||||||
<PackageReference Include="RethinkDB.DistributedCache" Version="1.0.0-rc1" />
|
<PackageReference Include="RethinkDB.DistributedCache" Version="1.0.0-rc1" />
|
||||||
<PackageReference Update="FSharp.Core" Version="6.0.5" />
|
<PackageReference Update="FSharp.Core" Version="6.0.5" />
|
||||||
<PackageReference Include="System.ServiceModel.Syndication" Version="6.0.0" />
|
<PackageReference Include="System.ServiceModel.Syndication" Version="6.0.0" />
|
||||||
|
|
|
@ -58,6 +58,7 @@ open Giraffe.EndpointRouting
|
||||||
open Microsoft.AspNetCore.Authentication.Cookies
|
open Microsoft.AspNetCore.Authentication.Cookies
|
||||||
open Microsoft.AspNetCore.Builder
|
open Microsoft.AspNetCore.Builder
|
||||||
open Microsoft.AspNetCore.HttpOverrides
|
open Microsoft.AspNetCore.HttpOverrides
|
||||||
|
open NeoSmart.Caching.Sqlite
|
||||||
open RethinkDB.DistributedCache
|
open RethinkDB.DistributedCache
|
||||||
|
|
||||||
[<EntryPoint>]
|
[<EntryPoint>]
|
||||||
|
@ -97,17 +98,16 @@ let rec main args =
|
||||||
|> ignore
|
|> ignore
|
||||||
| :? SQLiteData ->
|
| :? SQLiteData ->
|
||||||
// ADO.NET connections are designed to work as per-request instantiation
|
// ADO.NET connections are designed to work as per-request instantiation
|
||||||
|
let cfg = sp.GetRequiredService<IConfiguration> ()
|
||||||
builder.Services.AddScoped<SqliteConnection> (fun sp ->
|
builder.Services.AddScoped<SqliteConnection> (fun sp ->
|
||||||
let cfg = sp.GetRequiredService<IConfiguration> ()
|
|
||||||
let conn = new SqliteConnection (cfg.GetConnectionString "SQLite")
|
let conn = new SqliteConnection (cfg.GetConnectionString "SQLite")
|
||||||
SQLiteData.setUpConnection conn |> Async.AwaitTask |> Async.RunSynchronously
|
SQLiteData.setUpConnection conn |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
conn)
|
conn)
|
||||||
|> ignore
|
|> ignore
|
||||||
builder.Services.AddScoped<IData, SQLiteData> () |> ignore
|
builder.Services.AddScoped<IData, SQLiteData> () |> ignore
|
||||||
let log = sp.GetRequiredService<ILoggerFactory> ()
|
// Use SQLite for caching as well
|
||||||
let logger = log.CreateLogger "MyWebLog.StartUp"
|
let cachePath = defaultArg (Option.ofObj (cfg.GetConnectionString "SQLiteCachePath")) "./session.db"
|
||||||
logger.LogWarning "Session caching is not yet implemented via SQLite; using memory cache for sessions"
|
builder.Services.AddSqliteCache (fun o -> o.CachePath <- cachePath) |> ignore
|
||||||
builder.Services.AddDistributedMemoryCache () |> ignore
|
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
| None ->
|
| None ->
|
||||||
invalidOp "There is no data configuration present; please add a RethinkDB section or LiteDB connection string"
|
invalidOp "There is no data configuration present; please add a RethinkDB section or LiteDB connection string"
|
||||||
|
|
|
@ -3,56 +3,50 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<section class="container" aria-label="The posts for the page">
|
<section class="container" aria-label="The posts for the page">
|
||||||
{% for post in model.posts %}
|
{% for post in model.posts %}
|
||||||
<div class="row">
|
<article>
|
||||||
<div class="col">
|
<h1>
|
||||||
<article>
|
<a href="{{ post | relative_link }}" title="Permanent link to "{{ post.title | escape }}"">
|
||||||
<h1>
|
{{ post.title }}
|
||||||
<a href="{{ post | relative_link }}" title="Permanent link to "{{ post.title | escape }}"">
|
</a>
|
||||||
{{ post.title }}
|
</h1>
|
||||||
</a>
|
<p>
|
||||||
</h1>
|
Published on {{ post.published_on | date: "MMMM d, yyyy" }}
|
||||||
|
at {{ post.published_on | date: "h:mmtt" | downcase }}
|
||||||
|
by {{ model.authors | value: post.author_id }}
|
||||||
|
</p>
|
||||||
|
{{ post.text }}
|
||||||
|
{%- assign category_count = post.category_ids | size -%}
|
||||||
|
{%- assign tag_count = post.tags | size -%}
|
||||||
|
{% if category_count > 0 or tag_count > 0 %}
|
||||||
|
<footer>
|
||||||
<p>
|
<p>
|
||||||
Published on {{ post.published_on | date: "MMMM d, yyyy" }}
|
{%- if category_count > 0 -%}
|
||||||
at {{ post.published_on | date: "h:mmtt" | downcase }}
|
Categorized under:
|
||||||
by {{ model.authors | value: post.author_id }}
|
{% for cat in post.category_ids -%}
|
||||||
|
{%- assign this_cat = categories | where: "id", cat | first -%}
|
||||||
|
{{ this_cat.name }}{% unless forloop.last %}, {% endunless %}
|
||||||
|
{%- assign cat_names = this_cat.name | concat: cat_names -%}
|
||||||
|
{%- endfor -%}
|
||||||
|
{%- assign cat_names = "" -%}
|
||||||
|
<br>
|
||||||
|
{% endif -%}
|
||||||
|
{%- if tag_count > 0 %}
|
||||||
|
Tagged: {{ post.tags | join: ", " }}
|
||||||
|
{% endif -%}
|
||||||
</p>
|
</p>
|
||||||
{{ post.text }}
|
</footer>
|
||||||
{%- assign category_count = post.category_ids | size -%}
|
|
||||||
{%- assign tag_count = post.tags | size -%}
|
|
||||||
{% if category_count > 0 or tag_count > 0 %}
|
|
||||||
<footer>
|
|
||||||
<p>
|
|
||||||
{%- if category_count > 0 -%}
|
|
||||||
Categorized under: {{ cat_names | reverse | join: ", " }}
|
|
||||||
{%- for cat in post.category_ids -%}
|
|
||||||
{%- assign this_cat = categories | where: "id", cat | first -%}
|
|
||||||
{{ this_cat.name }},
|
|
||||||
{%- assign cat_names = this_cat.name | concat: cat_names -%}
|
|
||||||
{%- endfor -%}
|
|
||||||
{%- assign cat_names = "" -%}
|
|
||||||
<br>
|
|
||||||
{% endif -%}
|
|
||||||
{%- if tag_count > 0 %}
|
|
||||||
Tagged: {{ post.tags | join: ", " }}
|
|
||||||
{% endif -%}
|
|
||||||
</p>
|
|
||||||
</footer>
|
|
||||||
{% endif %}
|
|
||||||
<hr>
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
<nav aria-label="pagination">
|
|
||||||
<ul class="pager">
|
|
||||||
{% if model.newer_link -%}
|
|
||||||
<li class="previous item"><a href="{{ model.newer_link.value }}">« Newer Posts</a></li>
|
|
||||||
{%- else -%}
|
|
||||||
<li></li>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if model.older_link -%}
|
<hr>
|
||||||
<li class="next item"><a href="{{ model.older_link.value }}">Older Posts »</a></li>
|
</article>
|
||||||
{%- endif -%}
|
{% endfor %}
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</section>
|
</section>
|
||||||
|
<nav aria-label="pagination">
|
||||||
|
<ul class="pagination justify-content-evenly mt-2">
|
||||||
|
{% if model.newer_link -%}
|
||||||
|
<li class="page-item"><a class="page-link" href="{{ model.newer_link.value }}">« Newer Posts</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% if model.older_link -%}
|
||||||
|
<li class="page-item"><a class="page-link" href="{{ model.older_link.value }}">Older Posts »</a></li>
|
||||||
|
{%- endif -%}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
|
@ -21,13 +21,12 @@
|
||||||
{% if web_log.subtitle -%}
|
{% if web_log.subtitle -%}
|
||||||
<span class="navbar-text">{{ web_log.subtitle.value | escape }}</span>
|
<span class="navbar-text">{{ web_log.subtitle.value | escape }}</span>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{% if page_list -%}
|
<ul class="navbar-nav">
|
||||||
<ul class="navbar-nav">
|
{% unless web_log.default_page == "posts" %}{{ "page/1" | nav_link: "Posts" }}{% endunless %}
|
||||||
{% for pg in page_list -%}
|
{% if page_list -%}
|
||||||
{{ pg.permalink | nav_link: pg.title }}
|
{% for pg in page_list %}{{ pg.permalink | nav_link: pg.title }}{% endfor %}
|
||||||
{%- endfor %}
|
{%- endif %}
|
||||||
</ul>
|
</ul>
|
||||||
{%- endif %}
|
|
||||||
{% user_links %}
|
{% user_links %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -53,7 +52,7 @@
|
||||||
<footer>
|
<footer>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="container-fluid text-end">
|
<div class="container-fluid text-end">
|
||||||
<img src="{{ "themes/admin/logo-dark.png" | relative_link }}" alt="myWebLog">
|
<img src="{{ "themes/admin/logo-dark.png" | relative_link }}" alt="myWebLog" width="120" height="34">
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<h2 class="py-3">{{ page.title }}</h2>
|
<h2 class="py-3">{{ page.title }}</h2>
|
||||||
<article>
|
<article class="container">
|
||||||
{{ page.text }}
|
{{ page.text }}
|
||||||
</article>
|
</article>
|
||||||
|
|
|
@ -1,77 +1,62 @@
|
||||||
{%- assign post = model.posts | first -%}
|
{%- assign post = model.posts | first -%}
|
||||||
<div class="content single">
|
<h1>{{ post.title }}</h1>
|
||||||
<article class="item">
|
<h4 class="item-meta text-muted">
|
||||||
<h1 class="item-heading">{{ post.title }}</h1>
|
{% if post.published_on -%}
|
||||||
<h4 class="post-meta">
|
Published {{ post.published_on | date: "dddd, MMMM d, yyyy" }}
|
||||||
{% if post.published_on -%}
|
at {{ post.published_on | date: "h:mm tt" | downcase }}
|
||||||
<span title="Published On">
|
{%- else -%}
|
||||||
<i class="fa fa-calendar"></i> {{ post.published_on | date: "dddd, MMMM d, yyyy" }}
|
**DRAFT**
|
||||||
</span>
|
{% endif %}
|
||||||
<span title="Published At">
|
by {{ model.authors | value: post.author_id }}
|
||||||
<i class="fa fa-clock-o"></i> {{ post.published_on | date: "h:mm tt" | downcase }}
|
{% if logged_on %} • <a hx-boost="false" href="{{ post | edit_post_link }}">Edit Post</a> {% endif %}
|
||||||
</span>
|
</h4>
|
||||||
{%- else -%}
|
<div>
|
||||||
<span>**DRAFT**</span>
|
<article class="container mt-3">
|
||||||
{% endif %}
|
|
||||||
<span title="Author"><i class="fa fa-user"></i> {{ model.authors | value: post.author_id }}</span>
|
|
||||||
{% if logged_on %}
|
|
||||||
<span>
|
|
||||||
<a hx-boost="false" href="{{ post | edit_post_link }}">
|
|
||||||
<i class="fa fa-pencil-square-o"></i> Edit Post
|
|
||||||
</a>
|
|
||||||
</span>
|
|
||||||
{% endif %}
|
|
||||||
</h4>
|
|
||||||
<div>{{ post.text }}</div>
|
<div>{{ post.text }}</div>
|
||||||
{%- assign cat_count = post.category_ids | size -%}
|
{%- assign cat_count = post.category_ids | size -%}
|
||||||
{% if cat_count > 0 -%}
|
{% if cat_count > 0 -%}
|
||||||
<h4>
|
<h4 class="item-meta text-muted">
|
||||||
Categorized
|
Categorized under
|
||||||
{% for cat_id in post.category_ids -%}
|
{% for cat_id in post.category_ids -%}
|
||||||
{% assign cat = categories | where: "id", cat_id | first %}
|
{% assign cat = categories | where: "id", cat_id | first %}
|
||||||
<span class="no-wrap">
|
<span class="text-nowrap">
|
||||||
<i class="fa fa-folder-open-o" title="Category"></i>
|
|
||||||
<a href="{{ cat | category_link }}" title="Categorized under “{{ cat.name | escape }}”">
|
<a href="{{ cat | category_link }}" title="Categorized under “{{ cat.name | escape }}”">
|
||||||
{{ cat.name }}
|
{{ cat.name }}
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
|
{% unless forloop.last %} • {% endunless %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
</h4>
|
</h4>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- assign tag_count = post.tags | size -%}
|
{%- assign tag_count = post.tags | size -%}
|
||||||
{% if tag_count > 0 -%}
|
{% if tag_count > 0 -%}
|
||||||
<h4>
|
<h4 class="item-meta text-muted">
|
||||||
Tagged
|
Tagged
|
||||||
{% for tag in post.tags %}
|
{% for tag in post.tags %}
|
||||||
<span class="no-wrap">
|
<span class="text-nowrap">
|
||||||
<a href="{{ tag | tag_link }}" title="Posts tagged “{{ tag | escape }}”" rel="tag">
|
<a href="{{ tag | tag_link }}" title="Posts tagged “{{ tag | escape }}”" rel="tag">{{ tag }}</a>
|
||||||
<i class="fa fa-tag"></i> {{ tag }}
|
|
||||||
</a>
|
|
||||||
</span>
|
</span>
|
||||||
|
{% unless forloop.last %} • {% endunless %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
</h4>
|
</h4>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
</article>
|
</article>
|
||||||
<div>
|
<div>
|
||||||
<nav aria-label="pagination">
|
<nav aria-label="pagination">
|
||||||
<ul class="pager">
|
<ul class="pagination justify-content-evenly mt-5">
|
||||||
{% if model.newer_link -%}
|
{% if model.newer_link -%}
|
||||||
<li class="previous item">
|
<li class="page-item">
|
||||||
<h4 class="item-heading">
|
<a class="page-link" href="{{ model.newer_link.value | relative_link }}">{{ model.newer_name.value }}</a>
|
||||||
<a href="{{ model.newer_link.value | relative_link }}">«</a> Previous Post
|
<span class="text-muted">« Previous Post</span>
|
||||||
</h4>
|
|
||||||
<a href="{{ model.newer_link.value | relative_link }}">{{ model.newer_name.value }}</a>
|
|
||||||
</li>
|
</li>
|
||||||
{%- else -%}
|
|
||||||
<li></li>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if model.older_link -%}
|
{% if model.older_link -%}
|
||||||
<li class="next item">
|
<li class="page-item text-end">
|
||||||
<h4 class="item-heading">Next Post <a href="{{ model.older_link.value | relative_link }}">»</a></h4>
|
<a class="page-link" href="{{ model.older_link.value | relative_link }}">{{ model.older_name.value }}</a>
|
||||||
<a href="{{ model.older_link.value | relative_link }}">{{ model.older_name.value }}</a>
|
<span class="text-muted">Next Post »</span>
|
||||||
</li>
|
</li>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,22 @@
|
||||||
.messages {
|
.messages {
|
||||||
max-width: 60rem;
|
max-width: 60rem;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
}
|
||||||
|
blockquote {
|
||||||
|
border-left: solid 4px lightgray;
|
||||||
|
padding-left: 1rem;
|
||||||
|
}
|
||||||
|
.item-meta {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
font-weight: normal;;
|
||||||
|
}
|
||||||
|
.item-meta::before {
|
||||||
|
content: "»";
|
||||||
|
vertical-align: text-top;
|
||||||
|
}
|
||||||
|
a:link, a:visited {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user