Skip to content

Commit 101ec35

Browse files
Merge pull request #2 from uasoft-indonesia/layout-postfree
Layout postfree
2 parents 334bd23 + 5d2bf5b commit 101ec35

File tree

122 files changed

+11399
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+11399
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
vendor
2+
node_modules
3+
.DS_Store
4+
composer.lock

.gitlab-ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
image: node:15.12-alpine3.13
2+
3+
stages:
4+
- test
5+
- deploy
6+
7+
test:
8+
stage: test
9+
script:
10+
- cd website
11+
- yarn install
12+
- yarn build
13+
rules:
14+
- if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH
15+
16+
pages:
17+
stage: deploy
18+
script:
19+
- cd website
20+
- yarn install
21+
- yarn build
22+
- mv ./build ../public
23+
artifacts:
24+
paths:
25+
- public
26+
rules:
27+
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
28+

composer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"version": "0.1.0",
3+
"name": "badaso/postfree-theme",
4+
"description": "Official free theme for post module system on badaso",
5+
"keywords": [
6+
"laravel",
7+
"admin",
8+
"panel",
9+
"dashboard",
10+
"pwa",
11+
"generator",
12+
"blog",
13+
"badaso",
14+
"news"
15+
],
16+
"license": "proprietary",
17+
"homepage": "https://badaso.uatech.co.id/",
18+
"support": {
19+
"issues": "https://github.com/uasoft-indonesia/badaso-postfree-theme/issues",
20+
"discussion": "https://github.com/uasoft-indonesia/badaso-postfree-theme/discussions",
21+
"source": "https://github.com/uasoft-indonesia/badaso-postfree-theme"
22+
},
23+
"type": "library",
24+
"require": {
25+
"badaso/content-module": "^2.1.1",
26+
"badaso/core": "^2.9",
27+
"badaso/post-module": "^2.3.0"
28+
},
29+
"authors": [
30+
{
31+
"name": "UASOFT",
32+
"email": "hello@uatech.co.id"
33+
}
34+
],
35+
"minimum-stability": "alpha",
36+
"autoload": {
37+
"psr-4": {
38+
"Uasoft\\Badaso\\Theme\\PostfreeTheme\\": "src/"
39+
}
40+
},
41+
"extra": {
42+
"laravel": {
43+
"providers": [
44+
"Uasoft\\Badaso\\Theme\\PostfreeTheme\\Providers\\PostfreeThemeServiceProvider"
45+
]
46+
}
47+
}
48+
}

src/.DS_Store

6 KB
Binary file not shown.
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
<?php
2+
3+
namespace Uasoft\Badaso\Theme\PostfreeTheme\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Support\Facades\Artisan;
7+
use Illuminate\Support\Str;
8+
9+
class PostfreeThemeSetup extends Command
10+
{
11+
protected $file;
12+
/**
13+
* The console command name.
14+
*
15+
* @var string
16+
*/
17+
protected $name = 'badaso-postfree-theme:setup';
18+
19+
/**
20+
* The console command description.
21+
*
22+
* @var string
23+
*/
24+
protected $description = 'Setup Badaso Postfree Theme';
25+
26+
/**
27+
* Create a new command instance.
28+
*
29+
* @return void
30+
*/
31+
public function __construct()
32+
{
33+
$this->file = app('files');
34+
parent::__construct();
35+
}
36+
37+
/**
38+
* Execute the console command.
39+
*
40+
* @return mixed
41+
*/
42+
public function handle()
43+
{
44+
$this->updatePackageJson();
45+
$this->publishConfig();
46+
$this->addingBadasoEnv();
47+
$this->updateWebpackMix();
48+
49+
}
50+
51+
protected function publishConfig()
52+
{
53+
Artisan::call('vendor:publish', ['--tag' => 'BadasoPostfreeTheme']);
54+
55+
$this->info('Badaso postfree theme provider published');
56+
}
57+
58+
protected function checkExist($file, $search)
59+
{
60+
return $this->file->exists($file) && !Str::contains($this->file->get($file), $search);
61+
}
62+
63+
protected function updateWebpackMix()
64+
{
65+
$mix_file = base_path('webpack.mix.js');
66+
$search = 'Badaso Postfree Theme';
67+
68+
if ($this->checkExist($mix_file, $search)) {
69+
$data =
70+
<<<'EOT'
71+
72+
// Badaso Postfree Theme
73+
mix.js("vendor/badaso/postfree-theme/src/resources/js/app.js", "public/js/postfree-theme.js")
74+
.css("vendor/badaso/postfree-theme/src/resources/js/assets/css/style.css","public/css/postfree-theme.css",{},[
75+
require("tailwindcss")('./tailwind-postfree.config.js'),
76+
require("autoprefixer"),
77+
]
78+
)
79+
EOT;
80+
81+
$this->file->append($mix_file, $data);
82+
}
83+
84+
$this->info('webpack.mix.js updated');
85+
}
86+
87+
protected function envListUpload()
88+
{
89+
return [
90+
'POSTFREE_THEME_PREFIX' => 'postfree',
91+
];
92+
}
93+
94+
protected function addingBadasoEnv()
95+
{
96+
try {
97+
$env_path = base_path('.env');
98+
99+
$env_file = file_get_contents($env_path);
100+
$arr_env_file = explode("\n", $env_file);
101+
102+
$env_will_adding = $this->envListUpload();
103+
104+
$new_env_adding = [];
105+
foreach ($env_will_adding as $key_add_env => $val_add_env) {
106+
$status_adding = true;
107+
foreach ($arr_env_file as $key_env_file => $val_env_file) {
108+
$val_env_file = trim($val_env_file);
109+
if (substr($val_env_file, 0, 1) != '#' && $val_env_file != '' && strstr($val_env_file, $key_add_env)) {
110+
$status_adding = false;
111+
break;
112+
}
113+
}
114+
if ($status_adding) {
115+
$new_env_adding[] = "{$key_add_env}={$val_add_env}";
116+
}
117+
}
118+
119+
foreach ($new_env_adding as $index_env_add => $val_env_add) {
120+
$arr_env_file[] = $val_env_add;
121+
}
122+
123+
$env_file = join("\n", $arr_env_file);
124+
file_put_contents($env_path, $env_file);
125+
126+
$this->info('Adding badaso env');
127+
} catch (\Exception $e) {
128+
$this->error('Failed adding badaso env '.$e->getMessage());
129+
}
130+
}
131+
132+
protected function updatePackageJson()
133+
{
134+
$package_json = file_get_contents(base_path('package.json'));
135+
$decoded_json = json_decode($package_json, true);
136+
137+
$decoded_json['dependencies']['daisyui'] = '^4.6.0';
138+
$decoded_json['dependencies']['alpinejs'] = '^3.13.5';
139+
$decoded_json['dependencies']['tailwindcss'] = '^3.4.1';
140+
$decoded_json['dependencies']['@tailwindcss/aspect-ratio'] = '^0.4.2';
141+
$encoded_json = json_encode($decoded_json, JSON_PRETTY_PRINT);
142+
file_put_contents(base_path('package.json'), $encoded_json);
143+
144+
$this->info('package.json updated');
145+
}
146+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
return [
4+
'postfree_theme_prefix' => env('POSTFREE_THEME_PREFIX'),
5+
6+
/**
7+
* Overriding controllers.
8+
*/
9+
'controllers' => [],
10+
];

src/Controllers/.DS_Store

6 KB
Binary file not shown.

src/Controllers/Controller.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Uasoft\Badaso\Theme\PostfreeTheme\Controllers;
4+
5+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
6+
use Illuminate\Foundation\Bus\DispatchesJobs;
7+
use Illuminate\Foundation\Validation\ValidatesRequests;
8+
use Illuminate\Routing\Controller as BaseController;
9+
10+
class Controller extends BaseController
11+
{
12+
use AuthorizesRequests;
13+
use DispatchesJobs;
14+
use ValidatesRequests;
15+
}

src/Controllers/HomeController.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Uasoft\Badaso\Theme\PostfreeTheme\Controllers;
4+
5+
use Exception;
6+
use Illuminate\Http\Request;
7+
use Uasoft\Badaso\Module\Post\Models\Post;
8+
use Uasoft\Badaso\Module\Post\Models\Category;
9+
use Uasoft\Badaso\Theme\PostfreeTheme\Helpers\Configurations;
10+
11+
class HomeController extends Controller
12+
{
13+
public function index(){
14+
$category = Category::where('slug', 'postfree')->first();
15+
16+
$data_json = Post::where('category_id', $category['id'])->get();
17+
$title = $data_json[0]->title;
18+
$content = $data_json[0]->content;
19+
$slug = $data_json[0]->slug;
20+
21+
$config = Configurations::index();
22+
$sitetitle = $config->siteTitle;
23+
24+
return view('postfree-theme::pages.landing-page', [
25+
'title' => $title,
26+
'content' => $content,
27+
'sitetitle' => $sitetitle,
28+
'slug' => $slug,
29+
]);
30+
}
31+
32+
33+
}

0 commit comments

Comments
 (0)