summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/css/style.css14
-rw-r--r--public/favicon.icobin0 -> 4286 bytes
-rw-r--r--public/js/nav_highlight.js9
-rw-r--r--public/js/splides.js6
-rw-r--r--src/Controller/Card.php61
-rw-r--r--src/DB.php2
-rw-r--r--src/Model/Card.php33
-rw-r--r--src/Model/Vote.php8
-rw-r--r--src/Model/VoteCard.php5
-rw-r--r--src/Router.php6
-rw-r--r--templates/artwork/artwork_template.twig54
-rw-r--r--templates/artwork/artwork_view.twig10
-rw-r--r--templates/base.twig30
-rw-r--r--templates/card/card.twig13
-rw-r--r--templates/card/card_add.twig43
-rw-r--r--templates/card/card_display.twig48
-rw-r--r--templates/card/card_edit.twig30
-rw-r--r--templates/card/card_list.twig43
-rw-r--r--templates/card/card_meta_template.twig21
-rw-r--r--templates/card/card_template.twig103
-rw-r--r--templates/card/card_view.twig11
-rw-r--r--templates/dashboard.twig58
-rw-r--r--templates/root.twig11
23 files changed, 411 insertions, 208 deletions
diff --git a/public/css/style.css b/public/css/style.css
index bdb53f8..c07c25a 100644
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -15,6 +15,12 @@
header {
padding: 0 0.5rem 0rem 0.5rem;
}
+
+.active {
+ color: var(--accent) !important;
+ border-color: var(--accent) !important;
+}
+
main {
padding-top: 1rem;
}
@@ -43,6 +49,10 @@ input:disabled {
cursor: default;
}
+button:disabled {
+ cursor: default;
+}
+
.content {
background: var(--accent-bg);
border: 1px solid var(--border);
@@ -53,8 +63,8 @@ input:disabled {
padding: 15px;
}
-.content-header {
- margin-top: 50px;
+section {
+ margin-top: 50px !important;
}
.row:after {
diff --git a/public/favicon.ico b/public/favicon.ico
new file mode 100644
index 0000000..a54ce55
--- /dev/null
+++ b/public/favicon.ico
Binary files differ
diff --git a/public/js/nav_highlight.js b/public/js/nav_highlight.js
new file mode 100644
index 0000000..b8ebb09
--- /dev/null
+++ b/public/js/nav_highlight.js
@@ -0,0 +1,9 @@
+document.addEventListener( 'DOMContentLoaded', function() {
+ var url = window.location.href;
+ var navs = document.getElementsByTagName("nav")[0].getElementsByTagName("a");
+ for (var i = 0; i < navs.length; i++) {
+ if (url.startsWith(navs[i].href)) {
+ navs[i].classList.add('active');
+ }
+ }
+});
diff --git a/public/js/splides.js b/public/js/splides.js
new file mode 100644
index 0000000..0a4faae
--- /dev/null
+++ b/public/js/splides.js
@@ -0,0 +1,6 @@
+document.addEventListener( 'DOMContentLoaded', function() {
+ var splides = document.getElementsByClassName("splide");
+ for (var i = 0; i < splides.length; i++) {
+ new Splide(splides[i]).mount();
+ }
+}); \ No newline at end of file
diff --git a/src/Controller/Card.php b/src/Controller/Card.php
index e7fa793..3d8d8e0 100644
--- a/src/Controller/Card.php
+++ b/src/Controller/Card.php
@@ -28,14 +28,13 @@ class Card
public static function getAll(): array
{
- // TODO: is that correct? yes - how to call this getAll?
return DB::$entityManager->getRepository(CardModel::class)->findAll();
}
public static function listCards(): string
{
// get all cards
- $cards = DB::$entityManager->getRepository(CardModel::class)->findAll();
+ $cards = self::getAll();
return Template::render('card/card_list.twig', [
'cards' => $cards
@@ -47,25 +46,40 @@ class Card
// TODO: how to access all available meta?
return Template::render('card/card_add.twig', [
'fields' => [
- 'name' => 'meta[name]',
- 'converted mana cost' => 'meta[cmc]',
- 'is uno reverse' => 'meta[is_uno_reverse]',
+ 'name' => 'name',
+ 'converted mana cost' => 'cmc',
+ 'is uno reverse' => 'is_uno_reverse',
],
]);
}
- public static function displayCard(Request $request): string
+ public static function viewCard(Request $request): string
{
$route = $request->attributes->get('route');
$cardId = $route['id'];
$card = DB::$entityManager->getRepository(CardModel::class)->find($cardId);
- return Template::render('card/card_display.twig', [
+ return Template::render('card/card_view.twig', [
'card' => $card
]);
}
+ public static function viewArtwork(Request $request): string
+ {
+ $route = $request->attributes->get('route');
+ $cardId = $route['id'];
+ $artworkId = $route['artworkId'];
+
+ $card = DB::$entityManager->getRepository(CardModel::class)->find($cardId);
+ $artwork = DB::$entityManager->getRepository(Artwork::class)->find($artworkId);
+
+ return Template::render('artwork/artwork_view.twig', [
+ 'card' => $card,
+ 'artwork' => $artwork
+ ]);
+ }
+
public static function editCard(Request $request)
{
$route = $request->attributes->get('route');
@@ -127,10 +141,41 @@ class Card
{
$route = $request->attributes->get('route');
$cardId = $route['id'];
+ $card = DB::$entityManager->getRepository(CardModel::class)->find($cardId);
- // TODO: like add but edit
+ foreach ($request->get('meta') as $key => $value) {
+ $meta = $card->getMeta($key);
+ if ($meta == null) {
+ $meta = new CardMeta($key, $value);
+ $card->addMeta($meta);
+ } else {
+ $meta->value = strval($value);
+ }
+
+ DB::save($meta);
+ }
+
+ DB::save($card);
$response = new RedirectResponse('/card/' . $cardId);
return $response;
}
+
+ public static function vote(Request $request)
+ {
+ var_dump('VOTE');
+ $route = $request->attributes->get('route');
+ $cardId = $route['id'];
+ $card = DB::$entityManager->getRepository(CardModel::class)->find($cardId);
+
+ $vote = new VoteCard();
+ $vote->value = intval($request->get('value'));
+ $card->addVote($vote);
+ DB::save($vote);
+ DB::save($card);
+
+ // TODO: redirect to last visited
+ $response = new RedirectResponse('/card');
+ return $response;
+ }
}
diff --git a/src/DB.php b/src/DB.php
index c04d189..1effbf0 100644
--- a/src/DB.php
+++ b/src/DB.php
@@ -42,7 +42,7 @@ class DB
if (! empty($criteria) && ! is_null($exists)) {
foreach (get_object_vars($entity) as $key => $value) {
- $exists->$key = $value;
+ $exists->$key = $value;
}
} else {
$exists = $entity;
diff --git a/src/Model/Card.php b/src/Model/Card.php
index 59d2639..934fc2d 100644
--- a/src/Model/Card.php
+++ b/src/Model/Card.php
@@ -99,28 +99,35 @@ class Card
*
* @return string
*/
- public function getMeta(string $key): ?string
+ public function getMetaValue(string $key): ?string
+ {
+ return $this->getMeta($key)->value ?? null;
+ }
+
+ /**
+ * @param string $key
+ *
+ * @return CardMeta
+ */
+ public function getMeta(string $key): ?CardMeta
{
// if meta is already hydrated
if ($this->meta->isInitialized()) {
$meta = $this->meta->unwrap()
#->findFirst(fn (CardMeta $item) => $item->key === $key);
->filter(fn ($item) => $item->key === $key)->first();
- return $meta->value ?? null;
+ return $meta ?? null;
}
// get directly from db otherwise
$result = DB::$entityManager
- ->createQuery(
- 'SELECT cm.value
- FROM Elements\Model\CardMeta cm
- WHERE cm.key = :key AND cm.card = :card'
- )
- ->setParameter('key', $key)
- ->setParameter('card', $this)
- ->getOneOrNullResult();
+ ->getRepository(CardMeta::class)
+ ->findOneBy([
+ 'key' => $key,
+ 'card' => $this
+ ]);
- return $result['value'] ?? null;
+ return $result ?? null;
}
/**
@@ -128,7 +135,7 @@ class Card
*/
public function getAllMeta()
{
- // TODO: do we need this?
+ // TODO: change!
// if meta is already hydrated
if ($this->meta->isInitialized()) {
return $this->meta;
@@ -152,7 +159,7 @@ class Card
*/
public function getAllArtworks()
{
- // TODO: do we need this?
+ // TODO: change!
// if artworks are already hydrated
if ($this->artworks->isInitialized()) {
return $this->artworks;
diff --git a/src/Model/Vote.php b/src/Model/Vote.php
index c5415aa..273a7d8 100644
--- a/src/Model/Vote.php
+++ b/src/Model/Vote.php
@@ -26,5 +26,13 @@ class Vote
* @Column(type="integer")
*/
public int $value;
+
+ /**
+ * Vote constructor.
+ */
+ public function __contruct(int $value)
+ {
+ $this->value = $value;
+ }
}
diff --git a/src/Model/VoteCard.php b/src/Model/VoteCard.php
index e9b3e60..292789f 100644
--- a/src/Model/VoteCard.php
+++ b/src/Model/VoteCard.php
@@ -22,5 +22,10 @@ class VoteCard extends Vote
* @ManyToOne(targetEntity="Card", inversedBy="votes", cascade={"persist"})
*/
public Card $card;
+
+ public function __contruct(int $value)
+ {
+ $this->card = $card;
+ }
}
diff --git a/src/Router.php b/src/Router.php
index aad6122..46e3f4f 100644
--- a/src/Router.php
+++ b/src/Router.php
@@ -31,12 +31,14 @@ class Router
$this->addRoute('GET', '/dashboard', [Home::class, 'dashboard']);
// card
- $this->addRoute('GET', '/card/list', [Card::class, 'listCards']);
+ $this->addRoute('GET', '/card', [Card::class, 'listCards']);
$this->addRoute('GET', '/card/add', [Card::class, 'addCard']);
- $this->addRoute('GET', '/card/{id}', [Card::class, 'displayCard']);
+ $this->addRoute('GET', '/card/{id}', [Card::class, 'viewCard']);
$this->addRoute('GET', '/card/{id}/edit', [Card::class, 'editCard']);
+ $this->addRoute('GET', '/card/{id}/artwork/{artworkId}', [Card::class, 'viewArtwork']);
$this->addRoute('POST', '/card/add', [Card::class, 'add']);
$this->addRoute('POST', '/card/{id}/edit', [Card::class, 'edit']);
+ $this->addRoute('POST', '/card/{id}/vote', [Card::class, 'vote']);
$context = new RequestContext();
$context->fromRequest($request);
diff --git a/templates/artwork/artwork_template.twig b/templates/artwork/artwork_template.twig
new file mode 100644
index 0000000..fe55f6a
--- /dev/null
+++ b/templates/artwork/artwork_template.twig
@@ -0,0 +1,54 @@
+{% if artworkSettings.isPreview == true %}
+ <div class="content">
+ {% if artworkSettings.artworkHeader != "" %}
+ <h4>{{ artworkSettings.artworkHeader }}</h4>
+ {% endif %}
+
+ <div class="row">
+ <div class="column column-5">
+ {% if artworkSettings.isVotable == true %}
+ <!--TODO: vote artworks-->
+ <button class="vote"><i class="fa fa-thumbs-o-up" aria-hidden="true"></i></button>
+ {{ artwork.getVotesTotal() }}
+ <button class="vote"><i class="fa fa-thumbs-o-down" aria-hidden="true"></i></button>
+ {% endif %}
+ </div>
+ <div class="column column-95">
+ <div>
+ <img class="image" src='{{ artwork.path }}'>
+ </div>
+ <div>
+ <button onclick="location.href='/card/{{ card.id }}/artwork/{{ artwork.id }}'">View Artwork</button>
+ </div>
+ </div>
+ </div>
+ </div>
+{% else %}
+ <section id="artwork" class="content">
+ <h3>Artwork</h3>
+ </section>
+
+ <div class="content">
+ <!-- TODO: what is there to edit? or just remove? and add new? -->
+ <button onclick="location.href='/card/{{ card.id }}'">Goto Card</button>
+ <button>Remove Artwork</button>
+ </div>
+
+ <div class="content">
+ <div class="row">
+ <div class="column column-5">
+ {% if artworkSettings.isVotable == true %}
+ <!--TODO: vote artworks-->
+ <button class="vote"><i class="fa fa-thumbs-o-up" aria-hidden="true"></i></button>
+ {{ artwork.getVotesTotal() }}
+ <button class="vote"><i class="fa fa-thumbs-o-down" aria-hidden="true"></i></button>
+ {% endif %}
+ </div>
+ <div class="column column-95">
+ <div>
+ <img class="image" src='{{ artwork.path }}'>
+ </div>
+ </div>
+ </div>
+ </div>
+{% endif %}
diff --git a/templates/artwork/artwork_view.twig b/templates/artwork/artwork_view.twig
new file mode 100644
index 0000000..3eb1c65
--- /dev/null
+++ b/templates/artwork/artwork_view.twig
@@ -0,0 +1,10 @@
+{% extends 'card/card.twig' %}
+
+{% block pagecontent %}
+ {% set artworkSettings = {
+ "artworkHeader": "",
+ "isPreview": false,
+ "isVotable": true
+ } %}
+ {{ include('artwork/artwork_template.twig') }}
+{% endblock %} \ No newline at end of file
diff --git a/templates/base.twig b/templates/base.twig
index 758b6f8..825c09c 100644
--- a/templates/base.twig
+++ b/templates/base.twig
@@ -4,21 +4,37 @@
{{ parent() }}
<!-- SimpleCSS -->
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
+ <!-- Fork Awesome Icons -->
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fork-awesome@1.2.0/css/fork-awesome.min.css" integrity="sha256-XoaMnoYC5TH6/+ihMEnospgm0J1PM/nioxbOUdnM8HY=" crossorigin="anonymous">
+ <!-- Splide -->
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@splidejs/splide@latest/dist/css/splide.min.css">
+ <!-- override -->
<link rel="stylesheet" href="/css/style.css"/>
+{% endblock %}
- <!-- Fork Awesome Icons -->
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fork-awesome@1.2.0/css/fork-awesome.min.css" integrity="sha256-XoaMnoYC5TH6/+ihMEnospgm0J1PM/nioxbOUdnM8HY=" crossorigin="anonymous">
+{% block js %}
+ {{ parent() }}
+ <!-- Splide -->
+ <script src="https://cdn.jsdelivr.net/npm/@splidejs/splide@latest/dist/js/splide.min.js"></script>
+ <script src="/js/splides.js"></script>
+
+ <!-- nav -->
+ <script src="/js/nav_highlight.js"></script>
{% endblock %}
{% block body %}
<header>
<nav>
<a href="/dashboard">Dashboard</a>
- <a href="/card/list">Cards</a>
- <a href="/events/list">Events</a>
- <a href="/news/list">News</a>
- <a href="https://gitlab.com/DRogueRonin/elements">Gitlab</a>
+ <a href="/card">Cards</a>
+ <!--
+ <a href="/events">Events</a>
+ -->
+ <!--
+ <a href="/news">News</a>
+ -->
+ <a href="https://gitlab.com/DRogueRonin/elements" target="_blank">Gitlab</a>
</nav>
<h1>Elements</h1>
<p>{% block subtitle %}{% endblock %}</p>
@@ -27,6 +43,6 @@
{% block main %}{% endblock %}
</main>
<footer>
- visit <a href="https://gitlab.com/DRogueRonin/elements">Gitlab</a>
+ visit <a href="https://gitlab.com/DRogueRonin/elements" target="_blank">Gitlab</a>
</footer>
{% endblock %}
diff --git a/templates/card/card.twig b/templates/card/card.twig
index fcf6bd0..211f6e3 100644
--- a/templates/card/card.twig
+++ b/templates/card/card.twig
@@ -4,13 +4,14 @@
Cards
{% endblock %}
{% block main %}
- <div class="content content-header">
- <button onclick="location.href='/card/list'">Overview</button>
+ <section class="content">
+ <button onclick="location.href='/card'">Overview</button>
+ <!--
+ TODO
+ <button onclick="location.href='/card/{{ cardOfTheDay.id }}'">Card Of The Day</button>
+ -->
<button onclick="location.href='/card/add'">New Card</button>
- </div>
- <div class="content content-header">
- <h3>{% block pagetitle %}{% endblock %}</h3>
- </div>
+ </section>
<div style="align-content: center;">
{% block pagecontent %}{% endblock %}
diff --git a/templates/card/card_add.twig b/templates/card/card_add.twig
index db91fc4..0a90aea 100644
--- a/templates/card/card_add.twig
+++ b/templates/card/card_add.twig
@@ -1,47 +1,24 @@
{% extends 'card/card.twig' %}
{% block pagetitle %}
- Edit Card
+ Add Card
{% endblock %}
{% block pagecontent %}
<div class="content">
- <form action="/card/{{ card.id }}/edit" method="post" enctype="multipart/form-data">
- {% for meta in card.meta %}
+ <form action="/card/add" method="post" enctype="multipart/form-data">
+ {% for key, field in fields %}
<p>
- <label>{{ meta.key }}</label><br>
- <input type="text" name="{{ meta.key }}" value="{{ meta.value }}">
+ <label>{{ key }}</label><br>
+ <input type="text" name="meta[{{ field }}]">
</p>
{% endfor %}
- <input type="submit" value="Save">
+ <!-- TODO: add artworks when adding a card? -->
+ <h4>Artworks</h4>
+ <input type="file" name="images[]" multiple>
+
+ <input type="submit" value="Add">
</form>
</div>
{% endblock %}
-{% block pagetitle %}
- Add Card
-{% endblock %}
-{% block pagecontent %}
- <form action="/card/add" method="post" enctype="multipart/form-data">
- {% for key, field in fields %}
- <p>
- <label>{{ key }}</label><br>
- <input type="text" name="{{ field }}">
- </p>
- {% endfor %}
-
- <!--
- {% for meta in card.meta %}
- <p>
- <label>{{ meta.key }}</label><br>
- <input type="text" name="{{ meta.key }}" value="{{ meta.value }}" disabled>
- </p>
- {% endfor %}
- -->
-
- <h4>Artworks</h4>
- <input type="file" name="images[]" multiple>
-
- <input type="submit" value="Add">
- </form>
-{% endblock %}
diff --git a/templates/card/card_display.twig b/templates/card/card_display.twig
deleted file mode 100644
index 7b2ed3e..0000000
--- a/templates/card/card_display.twig
+++ /dev/null
@@ -1,48 +0,0 @@
-{% extends 'card/card.twig' %}
-
-{% block pagetitle %}
- Show Card
-{% endblock %}
-{% block pagecontent %}
- <div class="content">
- <button onclick="location.href='/card/{{ card.id }}/edit'">Edit</button>
- </div>
-
- <div class="content">
- <div class="row">
- <div class="column column-5">
- <button class="vote"><i class="fa fa-thumbs-o-up" aria-hidden="true"></i></button>
- {{ card.getVotesTotal() }}
- <button class="vote"><i class="fa fa-thumbs-o-down" aria-hidden="true"></i></button>
- </div>
- <div class="column column-95">
- {% for meta in card.meta %}
- <p>
- <label>{{ meta.key }}</label><br>
- <input type="text" name="{{ meta.key }}" value="{{ meta.value }}" disabled>
- </p>
- {% endfor %}
- </div>
- </div>
- </div>
-
- <div class="content content-header">
- <h3>Artworks</h3>
- </div>
-
- {% for artwork in card.artworks %}
- <div class="content">
- <div class="row">
- <div class="column column-5">
- <button class="vote"><i class="fa fa-thumbs-o-up" aria-hidden="true"></i></button>
- {{ artwork.getVotesTotal() }}
- <button class="vote"><i class="fa fa-thumbs-o-down" aria-hidden="true"></i></button>
- </div>
- <div class="column column-95">
- <img class="image" src='{{ artwork.path }}'>
- <button onclick="location.href='/artwork/{{ artwork.id }}'">Show</button>
- </div>
- </div>
- </div>
- {% endfor %}
-{% endblock %}
diff --git a/templates/card/card_edit.twig b/templates/card/card_edit.twig
index b066437..4d13efa 100644
--- a/templates/card/card_edit.twig
+++ b/templates/card/card_edit.twig
@@ -1,36 +1,24 @@
{% extends 'card/card.twig' %}
-{% block pagetitle %}
- Edit Card
-{% endblock %}
{% block pagecontent %}
+ <section class="content">
+ <h3>Edit Card</h3>
+ </section>
+
+ <div class="content">
+ <button onclick="location.href='/card/{{ card.id }}'">Goto Card</button>
+ </div>
+
<div class="content">
<form action="/card/{{ card.id }}/edit" method="post" enctype="multipart/form-data">
{% for meta in card.meta %}
<p>
<label>{{ meta.key }}</label><br>
- <input type="text" name="{{ meta.key }}" value="{{ meta.value }}">
+ <input type="text" name="meta[{{ meta.key }}]" value="{{ meta.value }}">
</p>
{% endfor %}
<input type="submit" value="Save">
</form>
</div>
-
- <div class="content content-header">
- <h3>Edit Artworks</h3>
- </div>
-
- <div class="content">
- <button>Add Artwork</button>
- </div>
-
- {% for artwork in card.artworks %}
- <div class="content">
- <img class="image" src='{{ artwork.path }}'>
- <button onclick="location.href='/artwork/{{ artwork.id }}/edit'">Edit</button>
- <button>Remove</button>
- </div>
- {% endfor %}
-
{% endblock %} \ No newline at end of file
diff --git a/templates/card/card_list.twig b/templates/card/card_list.twig
index b6d8bbe..a233df9 100644
--- a/templates/card/card_list.twig
+++ b/templates/card/card_list.twig
@@ -1,38 +1,17 @@
{% extends 'card/card.twig' %}
-{% block pagetitle %}
-List
-{% endblock %}
{% block pagecontent %}
+ <section class="content">
+ <h3>Cards</h3>
+ </section>
+
{% for card in cards %}
- <div class="content">
- <div class="row">
- <div class="column column-5">
- <button class="vote"><i class="fa fa-thumbs-o-up" aria-hidden="true"></i></button>
- {{ card.getVotesTotal() }}
- <button class="vote"><i class="fa fa-thumbs-o-down" aria-hidden="true"></i></button>
- </div>
- <div class="column column-95">
- <table>
- <thead>
- <tr>
- {% for meta in card.getAllMeta() %}
- <th>{{ meta.key }}</th>
- {% endfor %}
- </tr>
- </thead>
- <tbody>
- <tr>
- {% for meta in card.getAllMeta() %}
- <td>{{ meta.value }}</td>
- {% endfor %}
- </tr>
- </tbody>
- </table>
- <button onclick="location.href='/card/{{ card.id }}'">Card</button>
- <button onclick="location.href='/card/{{ card.id }}/artworks'">Artworks</button>
- </div>
- </div>
- </div>
+ {% set cardSettings = {
+ "cardHeader": "",
+ "isPreview": true,
+ "isVotable": true,
+ "showArtworks": true
+ } %}
+ {{ include('card/card_template.twig') }}
{% endfor %}
{% endblock %}
diff --git a/templates/card/card_meta_template.twig b/templates/card/card_meta_template.twig
new file mode 100644
index 0000000..d57cdd8
--- /dev/null
+++ b/templates/card/card_meta_template.twig
@@ -0,0 +1,21 @@
+<div class="row">
+ <div class="column column-5">
+ <form action="/card/{{ card.id }}/vote" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="value" value="1">
+ <button type="submit" class="vote"><i class="fa fa-thumbs-o-up" aria-hidden="true"></i></button>
+ </form>
+ {{ card.getVotesTotal() }}
+ <form action="/card/{{ card.id }}/vote" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="value" value="-1">
+ <button type="submit" class="vote"><i class="fa fa-thumbs-o-down" aria-hidden="true"></i></button>
+ </form>
+ </div>
+ <div class="column column-95">
+ {% for meta in card.meta %}
+ <p>
+ <label>{{ meta.key }}</label><br>
+ <input type="text" name="{{ meta.key }}" value="{{ meta.value }}" disabled>
+ </p>
+ {% endfor %}
+ </div>
+</div> \ No newline at end of file
diff --git a/templates/card/card_template.twig b/templates/card/card_template.twig
new file mode 100644
index 0000000..411ec2f
--- /dev/null
+++ b/templates/card/card_template.twig
@@ -0,0 +1,103 @@
+{% if cardSettings.isPreview == true %}
+ <div class="content">
+ {% if cardSettings.cardHeader != "" %}
+ <h4>{{ cardSettings.cardHeader }}</h4>
+ {% endif %}
+
+ <div class="row">
+ <div class="column column-5">
+ {% if cardSettings.isVotable == true %}
+ <form action="/card/{{ card.id }}/vote" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="value" value="1">
+ <button type="submit" class="vote"><i class="fa fa-thumbs-o-up" aria-hidden="true"></i></button>
+ </form>
+ {{ card.getVotesTotal() }}
+ <form action="/card/{{ card.id }}/vote" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="value" value="-1">
+ <button type="submit" class="vote"><i class="fa fa-thumbs-o-down" aria-hidden="true"></i></button>
+ </form>
+ {% endif %}
+ </div>
+ <div class="column column-95">
+ {% for meta in card.meta %}
+ <p>
+ <label>{{ meta.key }}</label><br>
+ <input type="text" name="{{ meta.key }}" value="{{ meta.value }}" disabled>
+ </p>
+ {% endfor %}
+
+ {% if cardSettings.showArtworks == true %}
+ {% if card.artworks|length > 0 %}
+ <div class="splide">
+ <div class="splide__track">
+ <ul class="splide__list">
+ {% for artwork in card.artworks %}
+ <li class="splide__slide">
+ <img class="image" src='{{ artwork.path }}'>
+ </li>
+ {% endfor %}
+ </ul>
+ </div>
+ </div>
+ {% endif %}
+ {% endif %}
+
+ <button onclick="location.href='/card/{{ card.id }}'">View Card</button>
+ </div>
+ </div>
+ </div>
+{% else %}
+ <section id="card" class="content">
+ <h3>Card</h3>
+ </section>
+
+ <div class="content">
+ <button onclick="location.href='/card/{{ card.id }}/edit'">Edit Card</button>
+ </div>
+
+ <div class="content">
+ <div class="row">
+ <div class="column column-5">
+ {% if cardSettings.isVotable == true %}
+ <form action="/card/{{ card.id }}/vote" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="value" value="1">
+ <button type="submit" class="vote"><i class="fa fa-thumbs-o-up" aria-hidden="true"></i></button>
+ </form>
+ {{ card.getVotesTotal() }}
+ <form action="/card/{{ card.id }}/vote" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="value" value="-1">
+ <button type="submit" class="vote"><i class="fa fa-thumbs-o-down" aria-hidden="true"></i></button>
+ </form>
+ {% endif %}
+ </div>
+ <div class="column column-95">
+ {% for meta in card.meta %}
+ <p>
+ <label>{{ meta.key }}</label><br>
+ <input type="text" name="{{ meta.key }}" value="{{ meta.value }}" disabled>
+ </p>
+ {% endfor %}
+ </div>
+ </div>
+ </div>
+
+ {% if cardSettings.showArtworks == true %}
+ <section id="artworks" class="content">
+ <h3>Artworks</h3>
+ </section>
+
+ <div class="content">
+ <!-- TODO -->
+ <button>Add Artwork</button>
+ </div>
+
+ {% for artwork in card.artworks %}
+ {% set artworkSettings = {
+ "artworkHeader": "",
+ "isPreview": true,
+ "isVotable": true
+ } %}
+ {{ include('artwork/artwork_template.twig') }}
+ {% endfor %}
+ {% endif %}
+{% endif %}
diff --git a/templates/card/card_view.twig b/templates/card/card_view.twig
new file mode 100644
index 0000000..3b84b26
--- /dev/null
+++ b/templates/card/card_view.twig
@@ -0,0 +1,11 @@
+{% extends 'card/card.twig' %}
+
+{% block pagecontent %}
+ {% set cardSettings = {
+ "cardHeader": "",
+ "isPreview": false,
+ "isVotable": true,
+ "showArtworks": true
+ } %}
+ {{ include('card/card_template.twig') }}
+{% endblock %}
diff --git a/templates/dashboard.twig b/templates/dashboard.twig
index 97534bf..0e10193 100644
--- a/templates/dashboard.twig
+++ b/templates/dashboard.twig
@@ -4,39 +4,41 @@
Dashboard
{% endblock %}
{% block main %}
- <div class="content content-header">
+ <section class="content">
<h3>Hello World</h3>
- </div>
- <div class="content content-header">
+ </section>
+
+ <section class="content">
<h3>Cards</h3>
- </div>
- <div class="content">
- <h4>Card of the day</h4>
- <div class="row">
- <div class="column column-5">
- <button class="vote"><i class="fa fa-thumbs-o-up" aria-hidden="true"></i></button>
- {{ cardOfTheDay.getVotesTotal() }}
- <button class="vote"><i class="fa fa-thumbs-o-down" aria-hidden="true"></i></button>
- </div>
- <div class="column column-95">
- {% for meta in cardOfTheDay.meta %}
- <p>
- <label>{{ meta.key }}</label><br>
- <input type="text" name="{{ meta.key }}" value="{{ meta.value }}" disabled>
- </p>
- {% endfor %}
- </div>
- <button onclick="location.href='/card/{{ cardOfTheDay.id }}'">Card</button>
- <button onclick="location.href='/card/{{ cardOfTheDay.id }}/artworks'">Artworks</button>
- </div>
- </div>
+ </section>
+
+ {% set card = cardOfTheDay %}
+ {% set cardSettings = {
+ "cardHeader": "Card Of The Day",
+ "isPreview": true,
+ "isVotable": true,
+ "showArtworks": true
+ } %}
+ {{ include('card/card_template.twig') }}
+
+ <!--
+ TODO
<div class="content">
<h4>Updates to my cards</h4>
</div>
- <div class="content content-header">
+ -->
+
+ <!--
+ TODO
+ <section class="content">
<h3>Events</h3>
- </div>
- <div class="content content-header">
+ </section>
+ -->
+
+ <!--
+ TODO
+ <section class="content">
<h3>News</h3>
- </div>
+ </section>
+ -->
{% endblock %}
diff --git a/templates/root.twig b/templates/root.twig
index 9c3534e..8be64dd 100644
--- a/templates/root.twig
+++ b/templates/root.twig
@@ -1,14 +1,11 @@
-<html>
+<html> <link rel="/favicon.ico" href="#">
+
<head>
<title>Elements</title>
-
{% block css %}{% endblock %}
</head>
<body>
-{% block body %}{% endblock %}
-<script>
-
-</script>
-{% block js %}{% endblock %}
+ {% block body %}{% endblock %}
+ {% block js %}{% endblock %}
</body>
</html> \ No newline at end of file