-
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.
- Loading branch information
Ismael G Marin C
committed
Feb 13, 2020
1 parent
9ea4d36
commit 88fcf25
Showing
12 changed files
with
364 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use strict"; | ||
|
||
const Podcast = use("App/Models/Podcast"); | ||
|
||
class HomeController { | ||
async index({ view }) { | ||
const podcasts = await Podcast.query() | ||
.orderBy("id", "desc") | ||
.with("category") | ||
.fetch(); | ||
|
||
return view.render("home", { podcasts: podcasts.toJSON() }); | ||
} | ||
} | ||
|
||
module.exports = HomeController; |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use strict"; | ||
|
||
const { LogicalException } = require("@adonisjs/generic-exceptions"); | ||
|
||
class UnauthorizedException extends LogicalException { | ||
/** | ||
* Handle this exception by itself | ||
*/ | ||
async handle(error, { response, session }) { | ||
session.flash({ | ||
notification: { | ||
type: "danger", | ||
message: error.message | ||
} | ||
}); | ||
|
||
await session.commit(); | ||
|
||
return response.route("myPodcast"); | ||
} | ||
} | ||
|
||
module.exports = UnauthorizedException; |
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,44 @@ | ||
@layout('layouts.app') | ||
|
||
@section('content') | ||
@set('title', 'Your all round dev podcast') | ||
|
||
<section class="section"> | ||
<div class="container"> | ||
<h2 class="subtitle is-3">Latest podcasts</h2> | ||
|
||
<div class="columns is-multiline"> | ||
@each(podcast in podcasts) | ||
<div class="column is-one-quarter"> | ||
<div class="card"> | ||
<div class="card-image"> | ||
<figure class="image is-3by2"> | ||
<a href="{{ route('podcasts.show', { slug: podcast.slug }) }}"> | ||
<img src="{{ assetsUrl(podcast.logo) }}" alt="Podcast logo"> | ||
</a> | ||
</figure> | ||
</div> | ||
<div class="card-content"> | ||
<div class="content"> | ||
<a href="{{ route('podcasts.show', { slug: podcast.slug }) }}"> | ||
{{ podcast.title }} | ||
</a> | ||
|
||
<div> | ||
<a href="{{ route('categories.show', { slug: podcast.category.slug }) }}"> | ||
<span class="tag"> | ||
{{ podcast.category.name }} | ||
</span> | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
@else | ||
<p>No podcast to display.</p> | ||
@endeach | ||
</div> | ||
</div> | ||
</section> | ||
@endsection |
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,113 @@ | ||
@layout('layouts.app') | ||
|
||
@section('content') | ||
@set('title', 'Edit podcast') | ||
|
||
<section class="section"> | ||
<div class="container"> | ||
<div class="columns"> | ||
<div class="column is-three-fifths is-offset-one-fifth"> | ||
<h2 class="title has-text-centered">Edit podcast</h2> | ||
|
||
@include('layouts.partials._notification') | ||
|
||
<form action="{{ '/podcasts/' + podcast.id + '?_method=PUT' }}" method="post" enctype="multipart/form-data"> | ||
{{ csrfField() }} | ||
|
||
<div class="field is-horizontal"> | ||
<div class="field-label"> | ||
<label class="label">Title</label> | ||
</div> | ||
<div class="field-body"> | ||
<div class="field"> | ||
<div class="control"> | ||
<input | ||
type="text" | ||
class="input" | ||
name="title" | ||
value="{{ old('title', podcast.title) }}" | ||
placeholder="Podcast title"> | ||
</div> | ||
|
||
{{ elIf('<p class="help is-danger">$self</p>', getErrorFor('title'), hasErrorFor('title')) }} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="field is-horizontal"> | ||
<div class="field-label"> | ||
<label class="label">Category</label> | ||
</div> | ||
<div class="field-body"> | ||
<div class="field"> | ||
<div class="control"> | ||
<div class="select is-fullwidth"> | ||
<select name="category_id"> | ||
<option value="">Choose a category</option> | ||
@each((name, id) in categories) | ||
<option value="{{ id }}" {{ podcast.category_id == id ? 'selected': '' }}>{{ name }}</option> | ||
@endeach | ||
</select> | ||
</div> | ||
</div> | ||
|
||
{{ elIf('<p class="help is-danger">$self</p>', getErrorFor('category'), hasErrorFor('category')) }} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="field is-horizontal"> | ||
<div class="field-label"> | ||
<label class="label">Logo</label> | ||
</div> | ||
<div class="field-body"> | ||
<div class="field"> | ||
<div class="control"> | ||
<input | ||
type="file" | ||
class="input" | ||
name="logo"> | ||
</div> | ||
|
||
{{ elIf('<p class="help is-danger">$self</p>', getErrorFor('logo'), hasErrorFor('logo')) }} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="field is-horizontal"> | ||
<div class="field-label"> | ||
<label class="label">Description</label> | ||
</div> | ||
<div class="field-body"> | ||
<div class="field"> | ||
<div class="control"> | ||
<textarea | ||
class="textarea" | ||
name="description" | ||
rows="10" | ||
placeholder="Give your podcast a description">{{ old('description', podcast.description) }}</textarea> | ||
</div> | ||
|
||
{{ elIf('<p class="help is-danger">$self</p>', getErrorFor('description'), hasErrorFor('description')) }} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="field is-horizontal"> | ||
<div class="field-label"></div> | ||
<div class="field-body"> | ||
<div class="field"> | ||
<div class="control"> | ||
<button class="button is-primary"> | ||
Update podcast | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
@endsection |
Oops, something went wrong.