omnia: start

This commit is contained in:
E. S. 2025-05-17 23:56:30 +03:00
parent b7e422c701
commit c2ee3e24bc
26 changed files with 242 additions and 5 deletions

View File

@ -26,6 +26,10 @@
"app\\ic\\": [
"src/lib/ic",
"src/handlers/ic"
],
"app\\omnia\\": [
"src/lib/omnia",
"src/handlers/omnia"
]
}
}

View File

@ -8,6 +8,8 @@ subdomains:
dev: foreignone
ic: ic
icdev: ic
omnia: omnia
omniadev: omnia
mysql:
host: "127.0.0.1"

View File

@ -22,7 +22,7 @@ while [ $# -gt 0 ]; do
done
[ -z "$OUTPUT_ROOT_DIR" ] && die "you must specify output directory"
for project in ic foreignone; do
for project in ic foreignone omnia; do
"$SCRIPT_DIR"/util/build_css.sh -i "$APP_DIR/public/$project/scss" -o "$OUTPUT_ROOT_DIR/public/$project/dist-css" || die "build_css failed"
"$SCRIPT_DIR"/util/build_js.sh -i "$APP_DIR/public/common/js" -o "$OUTPUT_ROOT_DIR/public/$project/dist-js" || die "build_js failed"
$PHP "$SCRIPT_DIR"/util/gen_runtime_config.php \

View File

@ -28,7 +28,7 @@ $hashes = [
'assets' => []
];
foreach (['ic', 'foreignone'] as $project) {
foreach (['ic', 'foreignone', 'omnia'] as $project) {
foreach (['js', 'css'] as $type) {
$dist_dir = $app_root.'/public/'.$project.'/dist-'.$type;
$entries = glob_recursive($dist_dir.'/*.'.$type);

View File

@ -77,6 +77,7 @@
vertical-align: top;
color: $dark-grey; // color of separators
padding-top: 15px;
white-space: nowrap;
}
a.head-item {
border: 1px $head-items-border solid;

View File

@ -11,6 +11,9 @@ textarea {
.head, .head-inner, .head-logo-wrap, .head-items, .head-logo {
display: block;
}
.head-items {
white-space: normal;
}
.head {
overflow: hidden;
border-bottom: 1px $border-color solid;

BIN
public/omnia/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
public/omnia/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -0,0 +1,3 @@
@import "../../common/scss/app/common";
@import "../../common/scss/app/head";
@import "../../common/scss/app/foot";

View File

@ -0,0 +1,2 @@
@import '../../common/scss/colors/dark';
@import './common';

View File

@ -0,0 +1,2 @@
@import '../../common/scss/colors/light';
@import './common';

View File

@ -0,0 +1,2 @@
common
admin

View File

@ -45,6 +45,7 @@ abstract class RequestHandler
$router = router::getInstance();
$route = $router->find($uri);
if ($route === null)
throw new NotFound('Route not found');

View File

@ -0,0 +1,25 @@
<?php
namespace app\omnia;
use engine\http\RequestHandler;
use engine\skin\BaseSkin;
abstract class BaseHandler
extends RequestHandler
{
public readonly BaseSkin $skin;
public function __construct() {
$this->skin = new OmniaSkin();
$this->skin->strings->load('omnia');
$this->skin->addStatic(
'css/common.css',
'js/common.js'
);
$this->skin->setGlobal([
'is_admin' => isAdmin(),
'is_dev' => isDev()
]);
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace app\omnia;
use engine\http\errors\Forbidden;
class MainHandler
extends BaseHandler
{
public function beforeDispatch(string $http_method, string $action) {
if (!isAdmin())
throw new Forbidden();
}
public function GET_index() {
$this->skin->meta->title = lang('meta_index_title');
$this->skin->meta->description = lang('meta_index_description');
$this->skin->meta->url = 'https://'.$_SERVER['HTTP_HOST'].'/';
$this->skin->options->isIndex = true;
return $this->skin->renderPage('index.twig');
}
}

View File

@ -96,6 +96,7 @@ class ForeignOneSkin
'admin_email' => $config['admin_email'],
'script_html' => $this->getFooterScriptTags(),
'theme' => ThemesUtil::getUserTheme(),
'omnia_url' => 'https://omnia'.(isDev() ? 'dev' : '').'.'.$config['domain'],
];
return $this->doRender('footer.twig', $footer_vars);
}

View File

@ -0,0 +1,78 @@
<?php
namespace app\omnia;
use app\ThemesUtil;
use engine\http\Response;
use Twig\Loader\FilesystemLoader;
use Twig\Loader\LoaderInterface;
class OmniaSkin
extends \engine\skin\FeaturedSkin
{
public OmniaSkinOptions $options;
public string $title {
get {
$title = isset($this->title) && $this->title ? $this->title : lang('site_title');
if (!$this->options->isIndex)
$title = $title.' - Omnia';
return $title;
}
set(string $title) {
$this->title = $title;
}
}
public function __construct() {
parent::__construct();
$this->options = new OmniaSkinOptions();
}
protected function getTwigLoader(): LoaderInterface {
$twig_loader = new FilesystemLoader(APP_ROOT.'/src/skins/omnia', APP_ROOT);
return $twig_loader;
}
protected function getCacheDir(): string {
global $config;
return $config['skin_cache_'.(isDev() ? 'dev' : 'prod').'_dir'].'/omnia';
}
protected function renderHeader(): string {
global $config;
$vars = [
'title' => $this->title,
'meta_html' => $this->meta->getHtml(),
'static_html' => $this->getHeaderStaticTags(),
'svg_html' => $this->getSVGTags(),
'render_options' => $this->options->getOptions(),
'home_url' => 'https://'.(isDev() ? 'dev.' : '').$config['domain'],
'app_config' => [
'domain' => $config['domain'],
'devMode' => isDev(),
'cookieHost' => $config['cookie_host'],
],
'theme' => ThemesUtil::getUserTheme(),
];
return $this->doRender('header.twig', $vars);
}
protected function renderBody(string $template, array $vars): string {
return $this->doRender($template, $this->vars + $vars);
}
protected function renderFooter(): string {
global $config;
$footer_vars = [
'exec_time' => getExecutionTime(),
'render_options' => $this->options->getOptions(),
'admin_email' => $config['admin_email'] ?? '',
'script_html' => $this->getFooterScriptTags(),
'theme' => ThemesUtil::getUserTheme(),
];
return $this->doRender('footer.twig', $footer_vars);
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace app\omnia;
class OmniaSkinOptions
extends \engine\skin\Options
{
public bool $isIndex = false;
}

View File

@ -62,5 +62,13 @@ return [
'tbc/(\d+|appendix)/' => 'tzo_part part=$(1)',
],
];
})(),
'omnia' => (function() {
return [
'Main' => [
'/' => 'index',
],
];
})()
];

View File

@ -30,7 +30,7 @@ body {
width: 220px;
height: 220px;
display: block;
background: url("/img/eagle.jpg") no-repeat center center;
background: url("https://4in1.ws/img/eagle.jpg") no-repeat center center;
background-size: cover;
border-radius: 50%;
text-decoration: none;

View File

@ -8,7 +8,8 @@
<div class="footer-left">
Theme: <a id="switch-theme" href="javascript:void(0)" onclick="return ThemeSwitcher.next(event)">{{ theme }}</a>
{% if is_admin %}
<span class="footer-separator">|</span> <a href="/admin/">Admin panel</a>
<span class="footer-separator">|</span> <a href="/admin/">Admin</a>
<span class="footer-separator">|</span> <a href="{{ omnia_url }}">Omnia</a>
{% endif %}
</div>
</div>

View File

@ -36,7 +36,13 @@
wiki
</a><a class="head-item {% if render_options.head_section == 'about' %} is-selected{% endif %}" href="/info/">
about
</a><a class="head-item is-ic" href="{{ ic_url }}">
</a><!--
{%- if is_admin -%}
<a class="head-item" href="{{ omnia_url }}">
omnia
</a>
{%- endif -%}
--><a class="head-item is-ic" href="{{ ic_url }}">
invisible college {{ svgInPlace('college_20') }}
</a>
</div>

View File

@ -0,0 +1,21 @@
</div>
<div class="footer">
<div class="footer-right">
Email: <a href="mailto:{{ admin_email }}">{{ admin_email }}</a>
</div>
<div class="footer-left">
Theme: <a id="switch-theme" href="javascript:void(0)" onclick="return ThemeSwitcher.next(event)">{{ theme }}</a>
</div>
</div>
</div>
{{ script_html|raw }}
</body>
</html>
{% if is_admin %}
<!-- {{ exec_time }} s -->
{% endif %}

View File

@ -0,0 +1,34 @@
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="icon" href="/favicon.png?v=2" type="image/png">
<link rel="icon" href="/favicon.ico?v=2" type="image/x-icon">
<title>{{ title }}</title>
<script type="text/javascript">window.appConfig = {{ app_config|json_encode|raw }};</script>
{{ meta_html|raw }}
{{ static_html|raw }}
</head>
<body>
{{ svg_html|raw }}
<div class="page-content base-width">
<div class="head no-subtitle">
<div class="head-inner">
<div class="head-logo-wrap">
<div class="head-logo">
<a href="/">
<div class="head-logo-title">Omnia</div>
</a>
</div>
</div>
<div class="head-items">
<a class="head-item is-ic" href="{{ home_url }}">
foreign one {{ svgInPlace('riverbank_eagle_20') }}
</a>
</div>
</div>
</div>
<div class="page-content-inner">

View File

@ -0,0 +1,6 @@
<div class="page is-index">
<div class="blog-post-text">
<h1>Welcome to Omnia</h1>
<p>Hello, world.</p>
</div>
</div>

4
src/strings/omnia.yaml Normal file
View File

@ -0,0 +1,4 @@
# common
site_title: Omnia
meta_index_title: "Omnia"
meta_index_description: "Omnia domain"