-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add events Signed-off-by: Oliver Tale-Yazdi <oliver@tasty.limo> * typo Signed-off-by: Oliver Tale-Yazdi <oliver@tasty.limo> * Events Signed-off-by: Oliver Tale-Yazdi <oliver@tasty.limo> * build Signed-off-by: Oliver Tale-Yazdi <oliver@tasty.limo> * fix merge Signed-off-by: Oliver Tale-Yazdi <oliver@tasty.limo> --------- Signed-off-by: Oliver Tale-Yazdi <oliver@tasty.limo>
- Loading branch information
Showing
13 changed files
with
303 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
defmodule PhoenixApp.Events.Event do | ||
use Ecto.Schema | ||
import Ecto.Changeset | ||
|
||
schema "events" do | ||
field :name, :string | ||
field :short, :string | ||
field :long, :string | ||
field :links, {:array, :string} | ||
field :learn_more_id, :integer, default: 0 | ||
field :contact, {:array, :string} | ||
field :when_from, :date | ||
field :when_to, :date | ||
field :when_est, :string | ||
field :where, :string | ||
field :where_link, :string | ||
field :duration, :string | ||
field :historic, :boolean, default: false | ||
|
||
timestamps() | ||
end | ||
|
||
@all [:homepage, :name, :contact, :where] | ||
|
||
@doc false | ||
def changeset(team, attrs) do | ||
team | ||
|> cast(attrs, @all ++ [:when_to, :when_from, :when_est, :where_link, :duration, :long, :short, :links, :historic, :learn_more_id]) | ||
|> validate_required(@all) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<main class="min-h-screen bg-gray-900"> | ||
<section class="w-full bg-gray-800 py-12 px-4"> | ||
<div class="max-w-7xl mx-auto"> | ||
<div class="flex flex-col md:flex-row gap-8 items-center justify-between"> | ||
<div class="space-y-4"> | ||
<h1 class="text-4xl font-bold text-white"><%= @event.name %></h1> | ||
<%= if @event.short do %> | ||
<p class="text-xl text-gray-300"><%= @event.short %></p> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<%= if @event.historic do %> | ||
<div class="w-full bg-amber-900/50 py-3 px-4"> | ||
<div class="max-w-7xl mx-auto"> | ||
<div class="flex items-center justify-center gap-2 text-amber-200"> | ||
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"> | ||
<path fillRule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clipRule="evenodd" /> | ||
</svg> | ||
<p>This event already happened and is shown for archival purposes only.</p> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<section class="w-full py-16"> | ||
<div class="max-w-7xl mx-auto px-4"> | ||
<div class="grid grid-cols-1 md:grid-cols-3 gap-8"> | ||
<%# Main Content %> | ||
<div class="md:col-span-2 space-y-8"> | ||
<div class="bg-gray-800 rounded-lg p-6 space-y-6"> | ||
<div> | ||
<h2 class="text-2xl font-semibold text-white mb-4">About This Event</h2> | ||
<div class="prose prose-invert max-w-none"> | ||
<%= raw(fmt_desc(@event)) %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<%# Contact Information %> | ||
<%= if @event.contact && length(@event.contact) > 0 do %> | ||
<div class="bg-gray-800 rounded-lg p-6"> | ||
<h3 class="text-xl font-semibold text-white mb-4">Contact Information</h3> | ||
<div class="space-y-2"> | ||
<%= for contact <- @event.contact do %> | ||
<p class="text-gray-300"><%= contact %></p> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<%= if @event.links && length(@event.links) > 0 do %> | ||
<div class="bg-gray-800 rounded-lg p-6"> | ||
<h3 class="text-xl font-semibold text-white mb-4">Related Links</h3> | ||
<div class="space-y-2"> | ||
<%= for {link, index} <- Enum.with_index(@event.links) do %> | ||
<div class="flex items-center gap-2"> | ||
<span class="text-gray-400 min-w-[1.5rem]"><%= index + 1 %>:</span> | ||
<%= link link, | ||
to: link, | ||
class: "text-blue-400 hover:text-blue-300", | ||
target: "_blank" %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
<%# Sidebar %> | ||
<div class="space-y-6"> | ||
<div class="bg-gray-800 rounded-lg p-6 space-y-4"> | ||
<%# Date Information %> | ||
<div class="flex items-center space-x-3"> | ||
<svg class="w-6 h-6 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"> | ||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" /> | ||
</svg> | ||
<div> | ||
<p class="text-gray-400">Date</p> | ||
<%= if @event.when_from do %> | ||
<p class="text-white"> | ||
<%= Calendar.strftime(@event.when_from, "%B %d, %Y") %> | ||
<%= if @event.when_to && @event.when_to != @event.when_from do %> | ||
- <%= Calendar.strftime(@event.when_to, "%B %d, %Y") %> | ||
<% end %> | ||
<%= fmt_duration(@event) %> | ||
</p> | ||
<% end %> | ||
<%= if @event.when_est do %> | ||
<p class="text-gray-300 text-sm mt-1"> | ||
<%= @event.when_est %> <%= fmt_duration(@event) %> | ||
</p> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
<%# Location %> | ||
<div class="flex items-center space-x-3"> | ||
<svg class="w-6 h-6 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"> | ||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" /> | ||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z" /> | ||
</svg> | ||
<div> | ||
<p class="text-gray-400">Location</p> | ||
<%= if @event.where_link do %> | ||
<%= link to: @event.where_link, class: "text-white hover:text-blue-300" do %> | ||
<%= @event.where %> | ||
<span class="ml-1">↗</span> | ||
<% end %> | ||
<% else %> | ||
<p class="text-white"><%= @event.where %></p> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<%# Call to Action %> | ||
<%= if @event.links && length(@event.links) > 0 do %> | ||
<div class="bg-gray-800 rounded-lg p-6 text-center"> | ||
<%= link "Learn More", | ||
to: Enum.at(@event.links, @event.learn_more_id), | ||
class: "w-full px-6 py-3 bg-blue-500 hover:bg-blue-600 text-white font-semibold rounded-lg transition-colors duration-200" %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
</main> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,57 @@ | ||
defmodule PhoenixAppWeb.EventView do | ||
use PhoenixAppWeb, :view | ||
|
||
alias PhoenixApp.Events.Event | ||
|
||
def fmt_when(%Event{when_from: from, when_to: to} = event) when not is_nil(from) and not is_nil(to) do | ||
""" | ||
#{event.when_from} - #{event.when_to} | ||
""" | ||
end | ||
|
||
def fmt_when(%Event{when_est: est} = event) when not is_nil(est) do | ||
""" | ||
#{event.when_est} | ||
""" | ||
end | ||
|
||
def fmt_when(%Event{} = event) do | ||
raise ArgumentError, "Event has no date: #{inspect(event)}" | ||
end | ||
|
||
def fmt_duration(%Event{duration: duration} = event) when not is_nil(duration) do | ||
""" | ||
(#{event.duration}) | ||
""" | ||
end | ||
|
||
def fmt_duration(%Event{}) do | ||
"" | ||
end | ||
|
||
# Format MD links to HTML links by looking up the links from a list. | ||
# For example: | ||
# >Make sure to join the [1](Matrix chat) for updates. | ||
# becomes: | ||
# >Make sure to join the <a href="Enum.at(event.links, 1)">Matrix chat</a> for updates. | ||
def fmt_desc(%Event{long: desc, links: links} = _event) when not is_nil(desc) and is_list(links) do | ||
matches = Regex.scan(~r/\[([0-9]+)\]\(([^)]+)\)/, desc) | ||
Enum.reduce(matches, desc, fn [full_match, idx_str, name], acc -> | ||
case Integer.parse(idx_str) do | ||
{idx, _} -> | ||
link = Enum.at(links, idx) | ||
if link do | ||
String.replace(acc, full_match, | ||
"<a href=\"#{link}\" class=\"text-blue-400 hover:text-blue-300\">#{name}</a><sup>#{idx + 1}</sup>") | ||
else | ||
acc | ||
end | ||
_ -> acc | ||
end | ||
end) | ||
|> String.replace(~r/\n/, "<br>") | ||
end | ||
|
||
def fmt_desc(%Event{long: desc}) when not is_nil(desc), do: desc | ||
def fmt_desc(_), do: "" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.