Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ jobs:
- name: Install Tailwind CSS
run: |
curl --fail --location --silent --show-error \
https://github.com/tailwindlabs/tailwindcss/releases/download/v4.2.2/tailwindcss-linux-x64 \
https://github.com/tailwindlabs/tailwindcss/releases/download/v4.3.3/tailwindcss-linux-x64 \
--output /tmp/tailwindcss
echo '4ab84f2b496c402d3ec4fd25e0e5559fe1184d886dadae8fb4438344ec044c22 /tmp/tailwindcss' | sha256sum --check
echo 'dc61b3ac6b8c9ca874c0cc4c57b2409791a64c5540404ca5f5367360babc313a /tmp/tailwindcss' | sha256sum --check
sudo install /tmp/tailwindcss /usr/local/bin/tailwindcss
- name: Run local E2E
working-directory: ./e2e
Expand Down
2 changes: 1 addition & 1 deletion THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This repository includes browser assets from the following projects.

## Datastar 1.0.0-RC.6
## Datastar 1.0.2

Source: https://github.com/starfederation/datastar

Expand Down
6 changes: 3 additions & 3 deletions app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ WORKDIR /app
# install tailwindcss v4 CLI (match builder platform)
RUN ARCH=$(uname -m | sed 's/aarch64/arm64/' | sed 's/x86_64/x64/') \
&& case "$ARCH" in \
arm64) SHA256=ad627e77b496cccada4a6e26eafff698ef0829081e575a4baf3af8524bb00747 ;; \
x64) SHA256=4ab84f2b496c402d3ec4fd25e0e5559fe1184d886dadae8fb4438344ec044c22 ;; \
arm64) SHA256=55fd0b241214eff3de1e8ee4f22796662f2d2e7a49bcfca7477cfd0bac398195 ;; \
x64) SHA256=dc61b3ac6b8c9ca874c0cc4c57b2409791a64c5540404ca5f5367360babc313a ;; \
*) echo "Unsupported architecture: $ARCH" >&2; exit 1 ;; \
esac \
&& curl -fsSLo /usr/local/bin/tailwindcss "https://github.com/tailwindlabs/tailwindcss/releases/download/v4.2.2/tailwindcss-linux-${ARCH}" \
&& curl -fsSLo /usr/local/bin/tailwindcss "https://github.com/tailwindlabs/tailwindcss/releases/download/v4.3.3/tailwindcss-linux-${ARCH}" \
&& echo "$SHA256 /usr/local/bin/tailwindcss" | sha256sum --check \
&& chmod +x /usr/local/bin/tailwindcss

Expand Down
267 changes: 134 additions & 133 deletions app/paket.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions app/src/App/src/Articles/View.fs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ let articlesPage (state:ArticlesPageState) =
_action "/articles"
_class "border-b border-gray-300/60 py-4 dark:border-gray-700/60"
match filters.tag with
| Some tag -> input { _type "hidden"; _name "tag"; _value (SafeOutput.attribute tag) }
| Some tag -> input { _type "hidden"; _name "tag"; _value tag }
| None -> ()
match filters.publishedYear with
| Some year -> input { _type "hidden"; _name "year"; _value (string year) }
Expand All @@ -135,7 +135,7 @@ let articlesPage (state:ArticlesPageState) =
_role "searchbox"
_name "search"
_ariaLabel "Search articles"
_value (filters.search |> Option.defaultValue "" |> SafeOutput.attribute)
_value (filters.search |> Option.defaultValue "")
_placeholder "Search articles"
_class searchInputClass
}
Expand Down Expand Up @@ -285,7 +285,7 @@ module Block =
| _ -> Other

let rec toHtml (block:Domain.Notion.Block) : HtmlElement =
let cleanId = block.id.Replace("-", "") |> SafeOutput.attribute
let cleanId = block.id.Replace("-", "")

match block.blockType with
| Domain.Notion.BlockType.Heading1 richText ->
Expand Down Expand Up @@ -325,7 +325,7 @@ module Block =
| "JSON" -> "json"
| "TOML" -> "toml"
| other -> other
let languageClass = $"language-{language}" |> SafeOutput.attribute
let languageClass = $"language-{language}"
pre {
_class languageClass
code {
Expand Down
20 changes: 6 additions & 14 deletions app/src/App/src/Common/View.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ open Domain.Article
open System
open System.Collections.Generic
open System.IO
open System.Net
open System.Text.Json
open type Html
open type Datastar
Expand Down Expand Up @@ -36,9 +35,6 @@ module SafeOutput =
let private linkSchemes = Set.ofList [ Uri.UriSchemeHttp; Uri.UriSchemeHttps; Uri.UriSchemeMailto ]
let private imageSchemes = Set.ofList [ Uri.UriSchemeHttp; Uri.UriSchemeHttps ]

let attribute (value:string) =
WebUtility.HtmlEncode value

let private tryAbsoluteUrl (allowedSchemes:Set<string>) (value:string) =
match Uri.TryCreate(value, UriKind.Absolute) with
| true, uri when allowedSchemes.Contains(uri.Scheme.ToLowerInvariant()) ->
Expand All @@ -47,18 +43,14 @@ module SafeOutput =

let tryLinkAttribute (value:string) =
if value.StartsWith("#", StringComparison.Ordinal) then
value |> attribute |> Some
Some value
elif value.StartsWith("/", StringComparison.Ordinal) && not (value.StartsWith("//", StringComparison.Ordinal)) then
value |> attribute |> Some
Some value
else
value
|> tryAbsoluteUrl linkSchemes
|> Option.map attribute
tryAbsoluteUrl linkSchemes value

let tryImageAttribute (value:string) =
value
|> tryAbsoluteUrl imageSchemes
|> Option.map attribute
tryAbsoluteUrl imageSchemes value

let tryBackgroundImageStyle (value:string) =
value
Expand All @@ -72,7 +64,7 @@ module SafeOutput =
.Replace("(", "%28", StringComparison.Ordinal)
.Replace(")", "%29", StringComparison.Ordinal)

$"background-image: url('{cssUrl}')" |> attribute)
$"background-image: url('{cssUrl}')")

module SiteUrl =
let article (permalink:string) =
Expand Down Expand Up @@ -377,7 +369,7 @@ type Document =
}
link { _href (Asset.fingerprinted "/css/compiled.css"); _rel "stylesheet" }
link { _href (Asset.fingerprinted "/css/prism.css"); _rel "stylesheet" }
script { _type "module"; _src (Asset.fingerprinted "/scripts/datastar.1.0.0-RC.6.js") }
script { _type "module"; _src (Asset.fingerprinted "/scripts/datastar.1.0.2.js") }
}
body {
_dataSignals $"{{selectedNav: '{selectedNav}'}}"
Expand Down
5 changes: 3 additions & 2 deletions app/src/App/src/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ let configureServices (serviceCollection: IServiceCollection) (tracerProvider: T
.AddSerilog()
.AddSingleton(tracerProvider)
.AddHostedService(fun _ -> Article.SyncBackgroundService(services.article))
.AddDatastar()
.AddGiraffe()
|> ignore

serviceCollection.AddDatastar() |> ignore
serviceCollection.AddGiraffe() |> ignore

let private addSecurityHeaders (ctx:HttpContext) =
ctx.Response.Headers["Content-Security-Policy"] <- "base-uri 'self'; frame-ancestors 'none'; object-src 'none'"
ctx.Response.Headers["Permissions-Policy"] <- "camera=(), geolocation=(), microphone=()"
Expand Down
Loading
Loading