Skip to content

Commit

Permalink
Added default index page, default startPage, removed iframe (#250)
Browse files Browse the repository at this point in the history
* Removed iframe, added default index page, made startPage optional parameter

* Renamed class for landing content

* Added paddings for message in index page, removed iframe link from index

* Renamed landing to greeting

* rm extra margins, upd svg

Co-authored-by: Peter Savchenko <[email protected]>
  • Loading branch information
slaveeks and neSpecc authored Sep 12, 2022
1 parent ba40b4f commit e1fd9a7
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 39 deletions.
1 change: 0 additions & 1 deletion .codexdocsrc.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"Guides",
{"title": "CodeX", "uri": "https://codex.so"}
],
"landingFrameSrc": "https://codex.so/editor?frame=1",
"startPage": "",
"misprintsChatId": "12344564",
"yandexMetrikaId": "",
Expand Down
17 changes: 16 additions & 1 deletion src/backend/routes/home.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import express, { Request, Response } from 'express';
import verifyToken from './middlewares/token.js';
import PagesOrder from '../controllers/pagesOrder.js';
import Pages from '../controllers/pages.js';


const router = express.Router();

/* GET home page. */
router.get('/', verifyToken, async (req: Request, res: Response) => {
const config = req.app.locals.config;

// Check if config consists startPage
if (config.startPage) {
return res.redirect(config.startPage);
} else {
const pageOrder = await PagesOrder.getRootPageOrder();

// Check if page order consists
if (pageOrder.order.length > 0) {
// Get the first parent page
const page = await Pages.get(pageOrder.order[0]);

res.redirect(page.uri!);
} else {
res.render('pages/index', { isAuthorized: res.locals.isAuthorized });
}
}
res.render('pages/index', { isAuthorized: res.locals.isAuthorized });
});

export default router;
13 changes: 7 additions & 6 deletions src/backend/views/pages/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<head>
<title>{{ config.title }}</title>
<link rel="stylesheet" href="/dist/main.css" />
<link rel="preload" href="{{ config.landingFrameSrc }}" as="document">
<link rel="icon" type="{{ favicon.type }}" href="{{ favicon.destination }}">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta property="og:title" content="{{ config.title }}" />
Expand All @@ -12,13 +11,15 @@
</head>
<script>
</script>
<body class="landing-body">
<body class="greeting-body">
{% include "components/header.twig" %}
<div class="landing-loader" id="frame-loader">
{{ svg('loader') }}
<div class="greeting-content">
{{ svg('frog') }}
<p class="greeting-content__message">
It’s time to create the first page!
</p>
{% include 'components/button.twig' with {label: 'Add page', icon: 'plus', size: 'small', url: '/page/new'} %}
</div>
<iframe class="landing-frame" src="{{ config.landingFrameSrc }}" seamless frameborder="0" onload="this.style.opacity = 1; setTimeout(document.getElementById('frame-loader').remove(), 500)"></iframe>

{% if config.yandexMetrikaId is not empty %}
<script type="text/javascript" >
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
Expand Down
25 changes: 25 additions & 0 deletions src/frontend/styles/components/greeting.pcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.greeting-body {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
}

.greeting-content {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: auto;

& > svg {
width: 62px;
height: 71px;
}

&__message {
margin: 0;
padding: 26px 0 26px 0;
font-weight: 500;
}
}
30 changes: 0 additions & 30 deletions src/frontend/styles/components/landing.pcss

This file was deleted.

2 changes: 1 addition & 1 deletion src/frontend/styles/main.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@import './components/header.pcss';
@import './components/writing.pcss';
@import './components/page.pcss';
@import './components/landing.pcss';
@import './components/greeting.pcss';
@import './components/auth.pcss';
@import './components/error.pcss';
@import './components/button.pcss';
Expand Down
1 change: 1 addition & 0 deletions src/frontend/svg/frog.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e1fd9a7

Please sign in to comment.