diff --git a/app/Http/Controllers/SubscriptionController.php b/app/Http/Controllers/ApiController.php
similarity index 53%
rename from app/Http/Controllers/SubscriptionController.php
rename to app/Http/Controllers/ApiController.php
index 8c91f7c..28f3fd1 100644
--- a/app/Http/Controllers/SubscriptionController.php
+++ b/app/Http/Controllers/ApiController.php
@@ -1,11 +1,45 @@
validate($request, [
+ 'name' => 'required',
+ 'email' => 'required|email',
+ 'message' => 'required'
+ ]);
+
+ $contact = new Contact;
+ $contact->name = $request['name'];
+ $contact->email = $request['email'];
+ $contact->message = $request['message'];
+ $contact->save();
+
+ // Send the email if the MAIL_SENDTO variable is set
+ if (env('MAIL_SENDTO') != null) {
+ Mail::send('email.contact', [ 'contact' => $contact ], function($mail) use ($contact) {
+ $mail->from(env('MAIL_SENDFROM'), env('APP_NAME'))
+ ->to(env('MAIL_SENDTO'))
+ ->subject('Contact form submission');
+ });
+ }
+
+ return 'success';
+ }
public function postSubscriptionSubmit(Request $request)
{
diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php
deleted file mode 100644
index be99deb..0000000
--- a/app/Http/Controllers/ContactController.php
+++ /dev/null
@@ -1,35 +0,0 @@
-validate($request, [
- 'name' => 'required',
- 'email' => 'required|email',
- 'message' => 'required'
- ]);
-
- $contact = new Contact;
- $contact->name = $request['name'];
- $contact->email = $request['email'];
- $contact->message = $request['message'];
- $contact->save();
-
- // Send the email if the MAIL_SENDTO variable is set
- if (env('MAIL_SENDTO') != null) {
- Mail::send('email.contact', [ 'contact' => $contact ], function($mail) use ($contact) {
- $mail->from(env('MAIL_SENDFROM'), env('APP_NAME'))
- ->to(env('MAIL_SENDTO'))
- ->subject('Contact form submission');
- });
- }
-
- return 'success';
- }
-
-}
diff --git a/app/Models/Blog.php b/app/Models/Blog.php
index 34831fa..ebb6cd8 100644
--- a/app/Models/Blog.php
+++ b/app/Models/Blog.php
@@ -2,7 +2,9 @@
namespace App\Models;
+use Parsedown;
use Illuminate\Database\Eloquent\Model;
+use App\User;
class Blog extends DashboardModel
{
@@ -22,4 +24,38 @@ class Blog extends DashboardModel
[ 'name' => 'tags', 'type' => 'text' ],
[ 'name' => 'header-image', 'title' => 'Header Image', 'type' => 'image', 'delete' => true ]
];
+
+ public static function getBlogEntries()
+ {
+ $blog_entries = [];
+
+ foreach (self::orderBy(self::$dashboard_sort_column, self::$dashboard_sort_direction)->get() as $blog_entry) {
+ // Add the name of the user that created the post
+ $blog_entry['username'] = User::find($blog_entry->user_id)->name;
+
+ // Add a string with the date and time the post was made
+ $blog_entry['date'] = date('M j, Y @ g:iA', strtotime($blog_entry->created_at));
+
+ // Convert the markdown in the body to html
+ $blog_entry['body'] = Parsedown::instance()->setBreaksEnabled(true)->setMarkupEscaped(true)->parse($blog_entry['body']);
+
+ // Replace the tags string with an array
+ $tags = [];
+
+ foreach (explode(';', $blog_entry['tags']) as $tag) {
+ array_push($tags, $tag);
+ }
+
+ $blog_entry['tags'] = $tags;
+
+ // Add the header image if one exists
+ $header_image_path = '/uploads/blog/img/' . $blog_entry->id . '-header-image.jpg';
+ $blog_entry['headerimage'] = file_exists(base_path() . '/public' . $header_image_path) ? $header_image_path : '';
+
+ // Add the processed blog entry to the array
+ array_push($blog_entries, $blog_entry);
+ }
+
+ return $blog_entries;
+ }
}
diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js
index ecde5c3..f8a7e42 100644
--- a/resources/assets/js/app.js
+++ b/resources/assets/js/app.js
@@ -17,6 +17,7 @@ Vue.http.headers.common["X-CSRF-TOKEN"] = env.csrfToken;
// Import page components
import HomePage from "pages/home.vue";
+import BlogPage from "pages/blog.vue";
import ContactPage from "pages/contact.vue";
import Error404Page from "pages/error404.vue";
@@ -36,6 +37,7 @@ const router = new VueRouter({
routes: [
{ path: "/", component: HomePage },
+ { path: "/blog", component: BlogPage },
{ path: "/contact", component: ContactPage },
{ path: "/*", component: Error404Page }
],
diff --git a/resources/assets/sass/_var.scss b/resources/assets/sass/_var.scss
index a162c52..2dd51fa 100644
--- a/resources/assets/sass/_var.scss
+++ b/resources/assets/sass/_var.scss
@@ -28,7 +28,7 @@ $c-accent: #fa7921; // accent
$c-error: #fa2036; // error
// Values
-$nav-link-count: 2;
+$nav-link-count: 3;
// Sizes
$nav-height-desktop: 60px;
diff --git a/resources/assets/sass/pages/_blog.scss b/resources/assets/sass/pages/_blog.scss
new file mode 100644
index 0000000..1d4ba89
--- /dev/null
+++ b/resources/assets/sass/pages/_blog.scss
@@ -0,0 +1,81 @@
+.blog-page-component {
+ padding: $grid-gutter-width 0px;
+
+ h1 {
+ margin-bottom: $grid-gutter-width;
+ }
+
+ .blog-entry {
+ border: 1px solid lighten($c-base, 75%);
+ border-radius: 5px;
+
+ @include media-breakpoint-up(md) {
+ display: flex;
+ }
+
+
+ &:not(:last-child) {
+ margin-bottom: $grid-gutter-width;
+ }
+
+ &-header-image {
+ background-position: center center;
+ background-size: cover;
+ background-repeat: no-repeat;
+
+ @include media-breakpoint-down(sm) {
+ @include aspect-ratio(3, 1);
+ width: 100%;
+ }
+
+ @include media-breakpoint-up(md) {
+ width: 35%;
+ flex-shrink: 0;
+ }
+ }
+
+ &-content {
+ padding: 25px;
+
+ @include media-breakpoint-up(md) {
+ display: flex;
+ flex-direction: row;
+ flex-grow: 1;
+ flex-wrap: wrap;
+ }
+
+ > * {
+ width: 100%;
+ }
+
+ &-title {
+ @include font-sans-semibold;
+ margin-bottom: $grid-gutter-width;
+ font-size: 25px;
+ text-align: center;
+ text-transform: uppercase;
+ }
+
+ &-info {
+ color: lighten($c-text, 30%);
+ }
+
+ &-body {
+ margin: ($grid-gutter-width / 2) 0px;
+ }
+
+ &-taglist {
+ width: 100%;
+
+ &-item {
+ margin-right: 5px;
+ display: inline-block;
+ padding: 3px 8px;
+ border-radius: 3px;
+ background-color: $c-accent;
+ color: $c-text-light;
+ }
+ }
+ }
+ }
+}
diff --git a/resources/components/pages/blog.vue b/resources/components/pages/blog.vue
new file mode 100644
index 0000000..1304ecb
--- /dev/null
+++ b/resources/components/pages/blog.vue
@@ -0,0 +1,66 @@
+
+ Blog
+
+ {{ entry.title }}
+
+
+ {!! $entry['body'] !!} +
+ +