Editable landing page.

This commit is contained in:
codevictory
2021-05-26 21:47:50 +03:00
parent 8befa3058c
commit f1e44e87d9
20 changed files with 484 additions and 68 deletions

104
lib/runosaari/pages.ex Normal file
View File

@@ -0,0 +1,104 @@
defmodule Runosaari.Pages do
@moduledoc """
The Pages context.
"""
import Ecto.Query, warn: false
alias Runosaari.Repo
alias Runosaari.Pages.Index
@doc """
Returns the list of index_paragraphs.
## Examples
iex> list_index_paragraphs()
[%Index{}, ...]
"""
def list_index_paragraphs do
Repo.all(Index)
end
@doc """
Gets a single index.
Raises `Ecto.NoResultsError` if the Index does not exist.
## Examples
iex> get_index!(123)
%Index{}
iex> get_index!(456)
** (Ecto.NoResultsError)
"""
def get_index!(id), do: Repo.get!(Index, id)
@doc """
Creates a index.
## Examples
iex> create_index(%{field: value})
{:ok, %Index{}}
iex> create_index(%{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def create_index(attrs \\ %{}) do
%Index{}
|> Index.changeset(attrs)
|> Repo.insert()
end
@doc """
Updates a index.
## Examples
iex> update_index(index, %{field: new_value})
{:ok, %Index{}}
iex> update_index(index, %{field: bad_value})
{:error, %Ecto.Changeset{}}
"""
def update_index(%Index{} = index, attrs) do
index
|> Index.changeset(attrs)
|> Repo.update()
end
@doc """
Deletes a index.
## Examples
iex> delete_index(index)
{:ok, %Index{}}
iex> delete_index(index)
{:error, %Ecto.Changeset{}}
"""
def delete_index(%Index{} = index) do
Repo.delete(index)
end
@doc """
Returns an `%Ecto.Changeset{}` for tracking index changes.
## Examples
iex> change_index(index)
%Ecto.Changeset{data: %Index{}}
"""
def change_index(%Index{} = index, attrs \\ %{}) do
Index.changeset(index, attrs)
end
end

View File

@@ -0,0 +1,18 @@
defmodule Runosaari.Pages.Index do
use Ecto.Schema
import Ecto.Changeset
schema "index_paragraphs" do
field :content, :string
field :seqnum, :integer, default: 999
timestamps()
end
@doc false
def changeset(index, attrs) do
index
|> cast(attrs, [:content, :seqnum])
|> validate_required([:content, :seqnum])
end
end

View File

@@ -0,0 +1,67 @@
defmodule RunosaariWeb.IndexController do
use RunosaariWeb, :controller
alias Runosaari.Pages
alias Runosaari.Pages.Index
def index(conn, _params) do
index_paragraphs = Pages.list_index_paragraphs()
render(conn, "index.html", index_paragraphs: index_paragraphs)
end
def admin(conn, _params) do
index_paragraphs = Pages.list_index_paragraphs()
render(conn, "admin.html", index_paragraphs: index_paragraphs)
end
def new(conn, _params) do
changeset = Pages.change_index(%Index{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"index" => index_params}) do
case Pages.create_index(index_params) do
{:ok, index} ->
conn
|> put_flash(:info, "Index created successfully.")
|> redirect(to: Routes.admin_index_path(conn, :show, index))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
def show(conn, %{"id" => id}) do
index = Pages.get_index!(id)
render(conn, "show.html", index: index)
end
def edit(conn, %{"id" => id}) do
index = Pages.get_index!(id)
changeset = Pages.change_index(index)
render(conn, "edit.html", index: index, changeset: changeset)
end
def update(conn, %{"id" => id, "index" => index_params}) do
index = Pages.get_index!(id)
case Pages.update_index(index, index_params) do
{:ok, index} ->
conn
|> put_flash(:info, "Index updated successfully.")
|> redirect(to: Routes.admin_index_path(conn, :show, index))
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "edit.html", index: index, changeset: changeset)
end
end
def delete(conn, %{"id" => id}) do
index = Pages.get_index!(id)
{:ok, _index} = Pages.delete_index(index)
conn
|> put_flash(:info, "Index deleted successfully.")
|> redirect(to: Routes.index_path(conn, :index))
end
end

View File

@@ -1,10 +1,6 @@
defmodule RunosaariWeb.PageController do
use RunosaariWeb, :controller
def index(conn, _params) do
render(conn, "index.html")
end
def info(conn, _params) do
render(conn, "info.html")
end

View File

@@ -16,7 +16,7 @@ defmodule RunosaariWeb.Router do
scope "/", RunosaariWeb do
pipe_through :browser
get "/", PageController, :index
resources "/", IndexController, only: [:index]
get "/info", PageController, :info
get "/covid19", PageController, :covid19
get "/privacy", PageController, :privacy
@@ -29,6 +29,8 @@ defmodule RunosaariWeb.Router do
scope "/admin", RunosaariWeb, as: :admin do
pipe_through :browser
get "/index", IndexController, :admin
resources "/index", IndexController, except: [:index]
get "/performers", PerformerController, :admin
get "/performances", PerformanceController, :admin
resources "/performers", PerformerController, except: [:index]

View File

@@ -0,0 +1,30 @@
<section class="main">
<h1>HALLINTA - Etusivu</h1>
<table>
<thead>
<tr>
<th>Sisältö</th>
<th>Prioriteetti</th>
<th></th>
</tr>
</thead>
<tbody>
<%= for index <- @index_paragraphs do %>
<tr>
<td><%= index.content %></td>
<td><%= index.seqnum %></td>
<td class="actions">
<span><%= link "Lisätietoja", to: Routes.admin_index_path(@conn, :show, index) %></span>
<span><%= link "Muokkaa", to: Routes.admin_index_path(@conn, :edit, index) %></span>
<span><%= link "Poista", to: Routes.admin_index_path(@conn, :delete, index), method: :delete, data: [confirm: "Are you sure?"] %></span>
</td>
</tr>
<% end %>
</tbody>
</table>
<span><%= link "Uusi Kappale", to: Routes.admin_index_path(@conn, :new) %></span>
</section>

View File

@@ -0,0 +1,5 @@
<h1>Muokkaa kappaletta</h1>
<%= render "form.html", Map.put(assigns, :action, Routes.admin_index_path(@conn, :update, @index)) %>
<span><%= link "Takaisin", to: Routes.index_path(@conn, :index) %></span>

View File

@@ -0,0 +1,19 @@
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Jokin kentistä on tyhjä</p>
</div>
<% end %>
<%= label f, :content, "Sisältö" %>
<%= textarea f, :content %>
<%= error_tag f, :content %>
<%= label f, :seqnum, "Prioriteetti (1 on korkein)" %>
<%= number_input f, :seqnum %>
<%= error_tag f, :seqnum %>
<div>
<%= submit "Tallenna" %>
</div>
<% end %>

View File

@@ -0,0 +1,28 @@
<section class="logo" id="logo-start">
<picture>
<source
srcset="<%= Routes.static_path(@conn, "/images/runosaari-logo_small.jpg") %>"
media="(max-width: 600px)"
alt="Runosaari logo"
/>
<source srcset="<%= Routes.static_path(@conn, "/images/runosaari-logo.jpg") %>" alt="Runosaari logo" />
<img src="<%= Routes.static_path(@conn, "/images/runosaari-logo.jpg") %>" alt="Runosaari logo" />
</picture>
<div id="logo-credits"><div>@Sanna Hukkanen</div></div>
</section>
<section class="main">
<h1 id="main-title">Runosaari 2021</h1>
<h2>
<span class="time-and-place"
>~ 22.-24.7. Livonsaari & Velkuanmaa ~</span
><br />
Eksymisretki omaan luontoosi, metsänpeiton suojaan!
</h2>
<%= for index <- @index_paragraphs do %>
<p><%= index.content %></p>
<% end %>
<p>
<i>[Ohjelmaa päivitetään muuttuvan tilanteen mukaan]</i>
</p>
</section>

View File

@@ -0,0 +1,7 @@
<section class="main">
<h1>Luo kappale</h1>
<%= render "form.html", Map.put(assigns, :action, Routes.admin_index_path(@conn, :create)) %>
<span><%= link "Takaisin", to: Routes.index_path(@conn, :index) %></span>
</section>

View File

@@ -0,0 +1,20 @@
<section class="main">
<h1>Kappaleen tiedot</h1>
<ul>
<li>
<strong>Sisältö:</strong>
<%= @index.content %>
</li>
<li>
<strong>Prioriteetti:</strong>
<%= @index.seqnum %>
</li>
</ul>
<span><%= link "Muokkaa", to: Routes.admin_index_path(@conn, :edit, @index) %></span>
<span><%= link "Takaisin", to: Routes.index_path(@conn, :index) %></span>
</section>

View File

@@ -15,7 +15,7 @@
<body>
<header >
<nav class="main-nav-bar" role="navigation">
<%= link "Etusivu", to: Routes.page_path(@conn, :index) %>
<%= link "Etusivu", to: Routes.index_path(@conn, :index) %>
<%= link "Ohjelma", to: Routes.performance_path(@conn, :index) %>
<%= link "Esiintyjät", to: Routes.performer_path(@conn, :index) %>
<%= link "Info", to: Routes.page_path(@conn, :info) %>
@@ -26,7 +26,7 @@
<a href="/#logo-container">Runosaari 2021</a>
</h1>
<nav class="mobile-main-nav-bar" id="nav-bar">
<%= link "Etusivu", to: "#{Routes.page_path(@conn, :index)}#logo-start" %>
<%= link "Etusivu", to: "#{Routes.index_path(@conn, :index)}#logo-start" %>
<%= link "Ohjelma", to: "#{Routes.performance_path(@conn, :index)}#calendar-start" %>
<%= link "Esiintyjät", to: "#{Routes.performer_path(@conn, :index)}#performers-start" %>
<%= link "Info", to: "#{Routes.page_path(@conn, :info)}#contact-start" %>

View File

@@ -1,50 +0,0 @@
<section class="logo" id="logo-start">
<picture>
<source
srcset="<%= Routes.static_path(@conn, "/images/runosaari-logo_small.jpg") %>"
media="(max-width: 600px)"
alt="Runosaari logo"
/>
<source srcset="<%= Routes.static_path(@conn, "/images/runosaari-logo.jpg") %>" alt="Runosaari logo" />
<img src="<%= Routes.static_path(@conn, "/images/runosaari-logo.jpg") %>" alt="Runosaari logo" />
</picture>
<div id="logo-credits"><div>@Sanna Hukkanen</div></div>
</section>
<section class="main">
<h1 id="main-title">Runosaari 2021</h1>
<h2>
<span class="time-and-place"
>~ 22.-24.7. Livonsaari & Velkuanmaa ~</span
><br />
Eksymisretki omaan luontoosi, metsänpeiton suojaan!
</h2>
<p>
Lumi ja jää vähenee, vedenpinta nousee ja pandemian aallot viistävät
meidänkin rantojamme. Peurojen kurittaman monimuotoisuuden keskelle
nousee RUNOSAARI täynnä ihmetystä ja kysymyksiä: onko tulevaisuudella
tulevaisuutta? Kuinka luontoon lomittuminen voi olla mahdollista? Jos
eksymme metsänpeittoon, voimmeko löytää jonnekin?
</p>
<p>
Järjestämme Livonsaaressa ja Velkuanmaassa uuden poikkitaiteellisen
runofestivaalin 22.-24.7.2021. Ohjelmassa runous yhdistyy elävään
musiikkiin ja erilaisiin taiteellisiin työpajoihin. Tapahtuma
järjestetään joustavasti vallitsevien koronarajoitusten mukaan,
ulkotiloja sekä erillisiä sisätiloja hyödyntäen. Livonsaaren
perinteinen Seurantalo piknik-nurmikkoineen ja lähimetsineen tarjoaa
puitteet lavaesiintyjille, työpajoille ja elävälle musiikille.
Velkuanmaan saaren pastoraali-idylli kahden lossin takana viettelee
saaristoluonnon syvyyksiin runolaulu-työpajan, kukkaseppelkruunujen ja
karjalaisen löylyriitin myötä.
</p>
<p>
Runosaari-festivaaliin osallistuu toistakymmentä maamme eturivin
runoilijaa, muusikoita, työpajan vetäjiä ja muita esiintyjiä to 22.7.
la 24.7.2021.
</p>
<p>
<i>[Ohjelmaa päivitetään muuttuvan tilanteen mukaan]</i>
</p>
</section>

View File

@@ -14,7 +14,7 @@
<%= error_tag form, :desc %>
<%= label form, :seqnum, "Prioriteetti (1 on korkein)" %>
<%= textarea form, :seqnum %>
<%= number_input form, :seqnum %>
<%= error_tag form, :seqnum %>
<%= label form, :photo, "Esiintyjän kuva" %>

View File

@@ -1,12 +1,11 @@
<section class="main">
<h1 id="performers-start">Esiintyjät</h1>
<%= if length(@performers) == 0 do %>
<i>Lisätietoja tulossa myöhemmin!</i>
<% end %>
<%= for performer <- @performers do %>
<h2><%= performer.name %></h2>
<p><%= performer.desc %></p>
<% end %>
<h1 id="performers-start">Esiintyjät</h1>
<%= if length(@performers) == 0 do %>
<i>Lisätietoja tulossa myöhemmin!</i>
<% end %>
<%= for performer <- @performers do %>
<h2><%= performer.name %></h2>
<p><%= performer.desc %></p>
<% end %>
</section>

View File

@@ -1,5 +1,5 @@
<section class="main">
<h1>Ilmoittaudu</h1>
<h1>Luo esiintyjä</h1>
<%= render "form.html", Map.put(assigns, :action, Routes.admin_performer_path(@conn, :create)) %>
</section>

View File

@@ -0,0 +1,3 @@
defmodule RunosaariWeb.IndexView do
use RunosaariWeb, :view
end