Remove static paths

This commit is contained in:
Liam 2024-04-27 23:01:16 -04:00
parent c64606ae02
commit 2f7f1b3802
9 changed files with 22 additions and 29 deletions

View file

@ -17,7 +17,7 @@ defmodule PhilomenaWeb do
and import those modules here. and import those modules here.
""" """
def static_paths, do: ~w(assets images favicon.ico favicon.svg robots.txt) def static_paths, do: ~w(assets favicon.ico favicon.svg robots.txt)
def controller do def controller do
quote do quote do

View file

@ -8,8 +8,8 @@ html lang="en"
title title
=> @status => @status
| - Philomena | - Philomena
link rel="stylesheet" href=stylesheet_path(@conn, nil) link rel="stylesheet" href=stylesheet_path(nil)
link rel="stylesheet" href=dark_stylesheet_path(@conn) media="(prefers-color-scheme: dark)" link rel="stylesheet" href=dark_stylesheet_path() media="(prefers-color-scheme: dark)"
link rel="icon" href="/favicon.ico" type="image/x-icon" link rel="icon" href="/favicon.ico" type="image/x-icon"
link rel="icon" href="/favicon.svg" type="image/svg+xml" link rel="icon" href="/favicon.svg" type="image/svg+xml"

View file

@ -6,7 +6,7 @@
strong strong
= link("This image is blocked by your current filter - click here to display it anyway", to: "#", data: [click_unfilter: @image.id]) = link("This image is blocked by your current filter - click here to display it anyway", to: "#", data: [click_unfilter: @image.id])
p p
= img_tag(Routes.static_path(PhilomenaWeb.Endpoint, "/images/tagblocked.svg"), width: 250, height: 250, data: [click_unfilter: @image.id]) = img_tag(static_path(@conn, "/images/tagblocked.svg"), width: 250, height: 250, data: [click_unfilter: @image.id])
span.filter-explanation span.filter-explanation
=< link("your current filter", to: Routes.filter_path(@conn, :show, @conn.assigns.current_filter), class: "filter-link") =< link("your current filter", to: Routes.filter_path(@conn, :show, @conn.assigns.current_filter), class: "filter-link")
' . ' .

View file

@ -10,11 +10,11 @@ html lang="en"
' - Derpibooru ' - Derpibooru
- else - else
' Derpibooru ' Derpibooru
link rel="stylesheet" href=stylesheet_path(@conn, @current_user) link rel="stylesheet" href=stylesheet_path(@current_user)
= if is_nil(@current_user) do = if is_nil(@current_user) do
link rel="stylesheet" href=dark_stylesheet_path(@conn) media="(prefers-color-scheme: dark)" link rel="stylesheet" href=dark_stylesheet_path() media="(prefers-color-scheme: dark)"
link rel="icon" href="/favicon.ico" type="image/x-icon" link rel="icon" href=~p"/favicon.ico" type="image/x-icon"
link rel="icon" href="/favicon.svg" type="image/svg+xml" link rel="icon" href=~p"/favicon.svg" type="image/svg+xml"
meta name="generator" content="philomena" meta name="generator" content="philomena"
meta name="theme-color" content="#618fc3" meta name="theme-color" content="#618fc3"
meta name="format-detection" content="telephone=no" meta name="format-detection" content="telephone=no"
@ -24,7 +24,7 @@ html lang="en"
script type="module" src="http://localhost:5173/@vite/client" script type="module" src="http://localhost:5173/@vite/client"
script type="module" src="http://localhost:5173/js/app.js" script type="module" src="http://localhost:5173/js/app.js"
- else - else
script type="text/javascript" src=Routes.static_path(@conn, "/js/app.js") async="async" script type="text/javascript" src=~p"/js/app.js" async="async"
= render PhilomenaWeb.LayoutView, "_opengraph.html", assigns = render PhilomenaWeb.LayoutView, "_opengraph.html", assigns
body data-theme=theme_name(@current_user) data-vite-reload=to_string(vite_reload?()) body data-theme=theme_name(@current_user) data-vite-reload=to_string(vite_reload?())
= render PhilomenaWeb.LayoutView, "_burger.html", assigns = render PhilomenaWeb.LayoutView, "_burger.html", assigns

View file

@ -6,8 +6,8 @@ html lang="en"
= viewport_meta_tag(@conn) = viewport_meta_tag(@conn)
title Two Factor Authentication - Derpibooru title Two Factor Authentication - Derpibooru
link rel="stylesheet" href=stylesheet_path(@conn, nil) link rel="stylesheet" href=stylesheet_path(nil)
link rel="stylesheet" href=dark_stylesheet_path(@conn) media="(prefers-color-scheme: dark)" link rel="stylesheet" href=dark_stylesheet_path() media="(prefers-color-scheme: dark)"
link rel="icon" href="/favicon.ico" type="image/x-icon" link rel="icon" href="/favicon.ico" type="image/x-icon"
link rel="icon" href="/favicon.svg" type="image/svg+xml" link rel="icon" href="/favicon.svg" type="image/svg+xml"

View file

@ -79,7 +79,7 @@ h1 Content Settings
' For 1080p monitors, try 24. ' For 1080p monitors, try 24.
.field .field
=> label f, :theme => label f, :theme
=> select f, :theme, theme_options(@conn), class: "input" => select f, :theme, theme_options(), class: "input"
= error_tag f, :theme = error_tag f, :theme
.fieldlabel: i Preview themes by selecting one from the dropdown. Saving sets the currently selected theme. .fieldlabel: i Preview themes by selecting one from the dropdown. Saving sets the currently selected theme.
.field .field

View file

@ -3,8 +3,8 @@ defmodule PhilomenaWeb.ErrorView do
import PhilomenaWeb.LayoutView, import PhilomenaWeb.LayoutView,
only: [ only: [
stylesheet_path: 2, stylesheet_path: 1,
dark_stylesheet_path: 1, dark_stylesheet_path: 0,
viewport_meta_tag: 1 viewport_meta_tag: 1
] ]

View file

@ -69,17 +69,10 @@ defmodule PhilomenaWeb.LayoutView do
Config.get(:footer) Config.get(:footer)
end end
def stylesheet_path(conn, %{theme: "dark"}), def stylesheet_path(%{theme: "dark"}), do: ~p"/css/dark.css"
do: Routes.static_path(conn, "/css/dark.css") def stylesheet_path(%{theme: "red"}), do: ~p"/css/red.css"
def stylesheet_path(_user), do: ~p"/css/default.css"
def stylesheet_path(conn, %{theme: "red"}), def dark_stylesheet_path, do: ~p"/css/dark.css"
do: Routes.static_path(conn, "/css/red.css")
def stylesheet_path(conn, _user),
do: Routes.static_path(conn, "/css/default.css")
def dark_stylesheet_path(conn),
do: Routes.static_path(conn, "/css/dark.css")
def theme_name(%{theme: theme}), do: theme def theme_name(%{theme: theme}), do: theme
def theme_name(_user), do: "default" def theme_name(_user), do: "default"

View file

@ -1,15 +1,15 @@
defmodule PhilomenaWeb.SettingView do defmodule PhilomenaWeb.SettingView do
use PhilomenaWeb, :view use PhilomenaWeb, :view
def theme_options(conn) do def theme_options do
[ [
[ [
key: "Default", key: "Default",
value: "default", value: "default",
data: [theme_path: Routes.static_path(conn, "/css/default.css")] data: [theme_path: ~p"/css/default.css"]
], ],
[key: "Dark", value: "dark", data: [theme_path: Routes.static_path(conn, "/css/dark.css")]], [key: "Dark", value: "dark", data: [theme_path: ~p"/css/dark.css"]],
[key: "Red", value: "red", data: [theme_path: Routes.static_path(conn, "/css/red.css")]] [key: "Red", value: "red", data: [theme_path: ~p"/css/red.css"]]
] ]
end end