Compare commits

..

9 Commits

Author SHA1 Message Date
4cb07692b1 Update styles 2023-01-31 18:22:05 +01:00
c5853fc2aa Add configurable prevention of user registration
Should be done appropriately soon.
2023-01-31 18:16:28 +01:00
54b609185d Fix issue in a botchy way 2023-01-31 18:12:39 +01:00
119ef28746 Add top image 2023-01-31 18:10:18 +01:00
4d75b598ff Update design of public pages 2023-01-31 18:08:10 +01:00
6cafe09331 Update default route 2023-01-31 18:03:58 +01:00
98426773b7 Add layout for public pages 2023-01-31 18:02:10 +01:00
60eaca943a Cleanup superfluous code 2023-01-30 22:05:38 +01:00
1578d9932a Add tz timezone database 2023-01-27 14:15:01 +01:00
22 changed files with 121 additions and 74 deletions

View File

@ -1,5 +1,6 @@
.article {
@apply pr-8
/* @apply pr-8 */
max-width: 25rem;
}
.article .tunit {
@ -27,7 +28,7 @@
}
.article h4 {
@apply font-semibold text-lg leading-8 text-zinc-800;
@apply my-2 font-semibold text-lg leading-8 text-zinc-800;
}
.article p, .article div {

View File

@ -131,3 +131,5 @@ config :floki, :html_parser, Floki.HTMLParser.FastHtml
config :nanoid,
size: 12,
alphabet: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
config :elixir, :time_zone_database, Tz.TimeZoneDatabase

View File

@ -9,13 +9,18 @@ defmodule Outlook.Hyphenation do
]
)
response_raw = HTTPoison.request!(
case HTTPoison.request(
:post,
System.get_env("HYPH_URL"),
form,
get_multipart_headers()
)
response_raw.body
) do
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
body
_ ->
# this is poor but for now better than loss of all work
html
end
end
defp get_multipart_form fields do

View File

@ -89,6 +89,7 @@ defmodule OutlookWeb do
import OutlookWeb.HtmlTreeComponent
import OutlookWeb.HtmlDocComponent
import OutlookWeb.TunitEditorComponent
import OutlookWeb.PublicComponents
import OutlookWeb.Gettext
# Shortcut for generating JS commands

View File

@ -8,17 +8,13 @@ defmodule OutlookWeb.HtmlDocComponent do
alias Phoenix.LiveView.JS
attr :tree, :list, required: true
attr :tunit_tag, :atom, default: :span
def render_doc(%{tunit_tag: _} = assigns) do
def render_doc(assigns) do
~H"""
<.dnode :for={node <- @tree} node={node} tunit_tag={@tunit_tag} />
"""
end
def render_doc(assigns) do
assigns
|> Map.put(:tunit_tag, "span")
|> render_doc()
end
def dnode(%{node: %{status: _}} = assigns) do
~H"""

View File

@ -0,0 +1,13 @@
<header class="">
<a href="/">
<img class="w-full" src="/images/elbefoto-lg.jpg"
src-set="elbefoto-xxl.jpg 4496w, /images/elbefoto-lg.jpg 2248w, /images/elbefoto-md.jpg 1199w, /images/elbefoto-sm.jpg 991w, /images/elbefoto-xs.jpg 767w">
</a>
</header>
<main class="px-4 py-20 sm:px-6 lg:px-8">
<div class="mx-auto max-w-4xl">
<.flash kind={:info} title="Success!" flash={@flash} />
<.flash kind={:error} title="Error!" flash={@flash} />
<%= @inner_content %>
</div>
</main>

View File

@ -24,9 +24,6 @@
<.link href={~p"/users/log_out"} method="delete">Log out</.link>
</li>
<% else %>
<li>
<.link href={~p"/users/register"}>Register</.link>
</li>
<li>
<.link href={~p"/users/log_in"}>Log in</.link>
</li>

View File

@ -0,0 +1,38 @@
defmodule OutlookWeb.PublicComponents do
@moduledoc """
Provides components for showing and listing artikel and autoren.
"""
use Phoenix.Component
import Phoenix.HTML
alias Phoenix.LiveView.JS
attr :autor, :any, required: true
def autor(assigns) do
~H"""
<a href={"/autoren/#{@autor.id}"}>
<div class="p-4 my-2 border rounded-lg border-slate-400 text-slate-800">
<div class="font-bold"><%= @autor.name %></div>
<div class=""><%= @autor.description %></div>
</div>
</a>
"""
end
attr :artikel, :any, required: true
attr :show_author, :boolean, default: true
def artikel(assigns) do
~H"""
<.link navigate={"/artikel/#{@artikel.id}"}>
<div class="my-2 px-2 rounded border-2 border-solid border-gray-300">
<h4 class="font-bold py-2"><%= @artikel.title %></h4>
<div :if={@show_author}><small><%= @artikel.article.author.name %></small></div>
<div><small><%= @artikel.date |> Calendar.strftime("%d.%m.%Y") %></small></div>
<div><%= @artikel.teaser |> raw %></div>
</div>
</.link>
"""
end
end

View File

@ -1,19 +1,2 @@
<.header>
Listing Artikel
<:actions>
</:actions>
</.header>
<.table id="artikel" rows={@artikel} row_click={&JS.navigate(~p"/artikel/#{&1}")}>
<:col :let={artikel} label="Title"><%= artikel.title %></:col>
<:col :let={artikel} label="Teaser"><%= artikel.teaser %></:col>
<%!-- <:col :let={artikel} label="Translator"><%= artikel.translator %></:col> --%>
<:col :let={artikel} label="Unauthorized"><%= artikel.unauthorized %></:col>
<:col :let={artikel} label="Public content"><%= artikel.public_content %></:col>
<:col :let={artikel} label="Date"><%= Calendar.strftime(artikel.date, "%d.%m.%Y") %></:col>
<:action :let={artikel}>
<div class="sr-only">
<.link navigate={~p"/artikel/#{artikel}"}>Show</.link>
</div>
</:action>
</.table>
<.artikel :for={artikel <- @artikel} artikel={artikel} />

View File

@ -1,19 +1,17 @@
<.header>
<%= @artikel.title %>
<:subtitle><%= @artikel.article.author.name %></:subtitle>
<:actions>
<header class="mb-20">
<h1 class="text-lg font-semibold leading-8 text-zinc-800"><%= @artikel.title %></h1>
<p class="my-2"><.link href={"/autoren/#{@artikel.article.author.id}"}><%= @artikel.article.author.name %></.link>
&nbsp;&nbsp;&nbsp; — &nbsp;&nbsp;&nbsp;<%= Calendar.strftime(@artikel.article.date, "%d.%m.%Y") %></p>
<div>Original
<.link href={@artikel.article.url} >
<%= @artikel.article.title %>
</.link> <%= Calendar.strftime(@artikel.article.date, "%d.%m.%Y") %>
</:actions>
</.header>
</.link><br>
</div>
<div class="my-2">
Übersetzung <%= Calendar.strftime(@artikel.date, "%d.%m.%Y") %>
</div>
</header>
<.list>
<:item title="Title"><%= @artikel.title %></:item>
<%!-- <:item title="Translator"><%= @artikel.translator %></:item> --%>
<:item title="Unauthorized"><%= @artikel.unauthorized %></:item>
<:item title="Date"><%= Calendar.strftime(@artikel.date, "%d.%m.%Y") %></:item>
</.list>
<div class="article"><%= @artikel.public_content |> raw %></div>
<div class="article w-full"><%= @artikel.public_content |> raw %></div>
<.back navigate={~p"/autoren/#{@artikel.article.author}"}>Back to Autor</.back>

View File

@ -1,20 +1,5 @@
<.header>
Listing Autoren
<:actions>
<.link href={~p"/autoren/new"}>
<.button>New Autor</.button>
</.link>
</:actions>
Autoren
</.header>
<.table id="autoren" rows={@autoren} row_click={&JS.navigate(~p"/autoren/#{&1}")}>
<:col :let={autor} label="Name"><%= autor.name %></:col>
<:col :let={autor} label="Description"><%= autor.description %></:col>
<:col :let={autor} label="Homepage name"><%= autor.homepage_name %></:col>
<:col :let={autor} label="Homepage url"><%= autor.homepage_url %></:col>
<:action :let={autor}>
<div class="sr-only">
<.link navigate={~p"/autoren/#{autor}"}>Show</.link>
</div>
</:action>
</.table>
<.autor :for={autor <- @autoren} autor={autor} />

View File

@ -7,10 +7,7 @@
<%= for article <- @autor.articles do %>
<div :for={translation <- article.translations} class="my-2 px-2 rounded border-2 border-solid border-gray-300">
<.link navigate={~p"/artikel/#{translation}"}><h4 class="font-bold py-2"><%= translation.title %></h4></.link>
<div><%= translation.teaser %></div>
</div>
<.artikel :for={translation <- article.translations} artikel={translation} show_author={false} />
<% end %>
<.back navigate={~p"/autoren"}>Back to autoren</.back>

View File

@ -7,11 +7,13 @@ defmodule OutlookWeb.UserLoginLive do
<.header class="text-center">
Sign in to account
<:subtitle>
<%= unless System.get_env("DISABLE_REGISTRATION") do %>
Don't have an account?
<.link navigate={~p"/users/register"} class="font-semibold text-brand hover:underline">
Sign up
</.link>
for an account now.
<% end %>
</:subtitle>
</.header>

View File

@ -0,0 +1,20 @@
defmodule Outlook.PreventRegistration do
import Plug.Conn
import Phoenix.Controller
def prevent_registration(conn, _) do
if System.get_env("DISABLE_REGISTRATION") && is_registration_path(conn) do
conn
|> put_flash(:error, "User Registration is disabled.")
|> redirect(to: "/users/log_in")
|> halt()
else
conn
end
end
defp is_registration_path(conn) do
"/users/register" == current_path(conn, %{})
end
end

View File

@ -3,6 +3,8 @@ defmodule OutlookWeb.Router do
import OutlookWeb.UserAuth
import Outlook.PreventRegistration
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
@ -15,6 +17,11 @@ defmodule OutlookWeb.Router do
pipeline :public_root_layout do
plug :put_root_layout, "proot.html"
plug :put_layout, {OutlookWeb.Layouts, :public}
end
pipeline :check_registration do
plug :prevent_registration
end
pipeline :api do
@ -22,9 +29,12 @@ defmodule OutlookWeb.Router do
end
scope "/", OutlookWeb do
pipe_through :browser
pipe_through [:browser, :public_root_layout]
get "/", PageController, :home
get "/", ArtikelController, :index
resources "/autoren", AutorController, only: [:index, :show]
resources "/artikel", ArtikelController, only: [:index, :show]
end
# Other scopes may use custom stacks.
@ -52,7 +62,7 @@ defmodule OutlookWeb.Router do
## Authentication routes
scope "/", OutlookWeb do
pipe_through [:browser, :redirect_if_user_is_authenticated]
pipe_through [:browser, :redirect_if_user_is_authenticated, :check_registration]
live_session :redirect_if_user_is_authenticated,
on_mount: [{OutlookWeb.UserAuth, :redirect_if_user_is_authenticated}] do
@ -105,7 +115,7 @@ defmodule OutlookWeb.Router do
end
scope "/", OutlookWeb do
pipe_through [:browser, :public_root_layout]
pipe_through :browser
delete "/users/log_out", UserSessionController, :delete
@ -114,8 +124,5 @@ defmodule OutlookWeb.Router do
live "/users/confirm/:token", UserConfirmationLive, :edit
live "/users/confirm", UserConfirmationInstructionsLive, :new
end
resources "/autoren", AutorController, only: [:index, :show]
resources "/artikel", ArtikelController, only: [:index, :show]
end
end

View File

@ -56,6 +56,7 @@ defmodule Outlook.MixProject do
{:fast_html, "~> 2.0"},
{:httpoison, "~> 1.8"},
{:nanoid, "~> 2.0.5"},
{:tz, "~> 0.24.0"},
]
end

View File

@ -54,6 +54,7 @@
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
"telemetry_metrics": {:hex, :telemetry_metrics, "0.6.1", "315d9163a1d4660aedc3fee73f33f1d355dcc76c5c3ab3d59e76e3edf80eef1f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7be9e0871c41732c233be71e4be11b96e56177bf15dde64a8ac9ce72ac9834c6"},
"telemetry_poller": {:hex, :telemetry_poller, "1.0.0", "db91bb424e07f2bb6e73926fcafbfcbcb295f0193e0a00e825e589a0a47e8453", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b3a24eafd66c3f42da30fc3ca7dda1e9d546c12250a2d60d7b81d264fbec4f6e"},
"tz": {:hex, :tz, "0.24.0", "a9073f152c5a9d0abeafde57150cd61d9f11faa7fa3710a20e8487ce05c76cee", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:mint, "~> 1.4", [hex: :mint, repo: "hexpm", optional: true]}], "hexpm", "5c08671bb10a56e09371106b08f5c9192449bb22e94a51de063c8c1317317027"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
"websock": {:hex, :websock, "0.4.3", "184ac396bdcd3dfceb5b74c17d221af659dd559a95b1b92041ecb51c9b728093", [:mix], [], "hexpm", "5e4dd85f305f43fd3d3e25d70bec4a45228dfed60f0f3b072d8eddff335539cf"},
"websock_adapter": {:hex, :websock_adapter, "0.4.5", "30038a3715067f51a9580562c05a3a8d501126030336ffc6edb53bf57d6d2d26", [:mix], [{:bandit, "~> 0.6", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.4", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "1d9812dc7e703c205049426fd4fe0852a247a825f91b099e53dc96f68bafe4c8"},

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 KiB