Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring app structure #98

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,13 @@
[![VueJs 2.6](https://img.shields.io/badge/VueJs-2.6-green.svg)](http://vuejs.org)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d645b6be9b6a42a8b6189cc32ea8f546)](https://www.codacy.com/app/ttimot24/HorizontCMS?utm_source=github.com&utm_medium=referral&utm_content=ttimot24/HorizontCMS&utm_campaign=Badge_Grade)

**HorizontCMS** is an open-source, responsive Content Management System (CMS) built on the powerful combination of Laravel 9, Vue.js 2.6, and Bootstrap 5.2. With its sleek design and robust features, HorizontCMS empowers developers like you to create stunning websites and blogs for the next generation.
**HorizontCMS** is an open-source, responsive Content Management System (CMS) built on the powerful combination of Laravel 10, Vue.js 2.6, and Bootstrap 5.2. With its sleek design and robust features, HorizontCMS empowers developers like you to create stunning websites and blogs for the next generation.

This lightweight CMS platform is not just about functionality—it's about empowerment. Whether you're a seasoned developer or a novice user, HorizontCMS provides intuitive tools and a seamless interface to extend and build your online presence with ease. With just one click, you can unlock endless possibilities and unleash your creativity.


### Latest version: [v1.2.0](https://github.com/ttimot24/HorizontCMS/releases/tag/v1.2.0)

### Try out

Frontend: [http://horizontcms.herokuapp.com/](https://horizontcms.herokuapp.com/)

Backend: [http://horizontcms.herokuapp.com/admin](https://horizontcms.herokuapp.com/admin)

> Username & password: admin/admin

### Installation
#### Browser
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function handle()

$this->info("3. Generating .env file...");

$dotenv = new \App\Libs\DotEnvGenerator();
$dotenv = new \App\Services\DotEnvGenerator();
$dotenv->addEnvVar('DB_HOST', '127.0.0.1');
$dotenv->addEnvVar('DB_CONNECTION', $database['driver']);
$dotenv->addEnvVar('DB_USERNAME', $database['username']);
Expand Down
11 changes: 9 additions & 2 deletions app/Controllers/BlogpostCategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@ class BlogpostCategoryController extends Controller
*
* @return \Illuminate\Http\Response
*/
public function index()
public function index(Request $request)
{

$all_categories = BlogpostCategory::all();

if ($request->wantsJson()) {
return response()->json($all_categories);
}

return view('blogposts.category.index', [
'all_category' => BlogpostCategory::all(),
'all_category' => $all_categories,
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Controllers/InstallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function step4()
{

if (!Session::has('error')) {
$dotenv = new \App\Libs\DotEnvGenerator();
$dotenv = new \App\Services\DotEnvGenerator(); //TODO Inject
$dotenv->addEnvVar('DB_HOST', Session::get('step2.server'));
$dotenv->addEnvVar('DB_CONNECTION', Session::get('step2.db_driver'));
$dotenv->addEnvVar('DB_USERNAME', Session::get('step2.username'));
Expand Down
4 changes: 2 additions & 2 deletions app/Controllers/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function create(Request $request)

return view('pages.form', [
'all_page' => Page::all(),
'page_templates' => (new \App\Libs\Theme($request->settings['theme']))->templates(),
'page_templates' => (new \App\Services\Theme($request->settings['theme']))->templates(),
]);
}

Expand Down Expand Up @@ -112,7 +112,7 @@ public function edit(Request $request, Page $page)
return view('pages.form', [
'page' => $page,
'all_page' => Page::all(),
'page_templates' => (new \App\Libs\Theme($request->settings['theme']))->templates(),
'page_templates' => (new \App\Services\Theme($request->settings['theme']))->templates(),
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Controllers/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use App\Libs\SearchEngine;
use App\Services\SearchEngine;

class SearchController extends Controller
{
Expand Down
15 changes: 8 additions & 7 deletions app/Controllers/ThemeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

use App\Services\Theme;
use App\Model\Settings;

class ThemeController extends Controller
Expand All @@ -19,9 +20,9 @@ class ThemeController extends Controller
public function index(Request $request)
{
return view("theme.index", [
'active_theme' => new \App\Libs\Theme($request->settings['theme']),
'active_theme' => new Theme($request->settings['theme']),
'all_themes' => collect(array_slice(scandir("themes"), 2))->map(function ($theme) {
return new \App\Libs\Theme($theme);
return new Theme($theme);
})
]);
}
Expand All @@ -48,15 +49,15 @@ public function config($slug)
$websiteController = new \App\Controllers\WebsiteController(request());
$websiteController->before();

$theme_engine = new \App\Libs\ThemeEngine(request());
$theme_engine->setTheme(new \App\Libs\Theme(request()->settings['theme']));
$theme_engine = new \App\Services\ThemeEngine(request());
$theme_engine->setTheme(new Theme(request()->settings['theme']));

$theme_engine->boot();

\Website::initalize($theme_engine);

return view("theme.config", [
'active_theme' => new \App\Libs\Theme(request()->settings['theme']),
'active_theme' => new Theme(request()->settings['theme']),
'website_content' => $websiteController->index(request()->input('page')),
]);
}
Expand All @@ -73,7 +74,7 @@ public function options($theme)
$theme_css->save();
}

$theme = new \App\Libs\Theme($theme == null ? request()->settings['theme'] : $theme);
$theme = new Theme($theme == null ? request()->settings['theme'] : $theme);

$translations = [];

Expand All @@ -90,7 +91,7 @@ public function updateTranslations($theme)
if (request()->isMethod('POST')) {

try {
$theme = new \App\Libs\Theme($theme == null ? request()->settings['theme'] : $theme);
$theme = new Theme($theme == null ? request()->settings['theme'] : $theme);

$translations = [];

Expand Down
10 changes: 5 additions & 5 deletions app/Controllers/WebsiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class WebsiteController extends Controller
private $request;

private $engines = [
'hcms' => \App\Libs\ThemeEngine::class,
'blade' => \App\Libs\BladeThemeEngine::class,
//'twig' => \App\Libs\TwigThemeEngine::class,
'hcms' => \App\Services\ThemeEngine::class,
'blade' => \App\Services\BladeThemeEngine::class,
//'twig' => \App\Services\TwigThemeEngine::class,
];

private $theme;

public function __construct(Request $request, \App\Libs\Theme $theme){
public function __construct(Request $request, \App\Services\Theme $theme){
$this->request = $request;
$this->theme = $theme;
}
Expand Down Expand Up @@ -140,7 +140,7 @@ public function search()
}


$search_engine = new \App\Libs\SearchEngine();
$search_engine = new \App\Services\SearchEngine();

$search_engine->registerModel(\App\Model\Blogpost::class);
$search_engine->registerModel(\App\Model\Page::class);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/WebsiteMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class WebsiteMiddleware

private $widgets;

public function __construct(\App\Libs\ShortCode $shortcode_engine){
public function __construct(\App\Services\ShortCode $shortcode_engine){
$this->widgets = $shortcode_engine;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Libs;
namespace App\Interfaces;

interface PluginInterface {

Expand Down
80 changes: 0 additions & 80 deletions app/Libs/BladeThemeEngine.php

This file was deleted.

52 changes: 0 additions & 52 deletions app/Libs/Controller.php

This file was deleted.

61 changes: 0 additions & 61 deletions app/Libs/ViewResolver.php

This file was deleted.

2 changes: 1 addition & 1 deletion app/Model/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function getRegister($register, $default = null)

$instance = new $plugin_namespace();

if ($instance instanceof \App\Libs\PluginInterface) {
if ($instance instanceof \App\Interfaces\PluginInterface) {
return $instance->$register();
}
}
Expand Down
Loading
Loading