Skip to content

Commit

Permalink
Daily commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fakoua committed Aug 4, 2020
1 parent 3aa0d67 commit 1863852
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 8 deletions.
5 changes: 3 additions & 2 deletions mod.ts
Expand Up @@ -61,7 +61,6 @@ router

// static
app.use(async (context, next: any) => {
console.log("------------------------------------------------------------------------")
if (context.request.url.pathname.startsWith("/themes")) {
await send(context, context.request.url.pathname, {
root: `${Deno.cwd()}/src/cms/`,
Expand Down Expand Up @@ -121,12 +120,14 @@ router
const pageId = ctx.request.url.searchParams.get("pageId") ?? ""
const page = await AdminPages.getPage(ctx.request.url)
let html = await AdminPages.getTheme()
let glob = AdminPages.getGlob()
page.pageId = pageId
if (page.head === undefined) {
ctx.response.body = page.content
} else {
const model = {
page: page
page: page,
glob: glob,
}
html = handle.render(html, model)
html = handle.render(html, model) // for the body page.
Expand Down
8 changes: 5 additions & 3 deletions src/core/admin/layout.html
@@ -1,11 +1,9 @@
<!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, maximum-scale=1.0" />
<title>Force - {{page.head.pageTitle}}</title>

<!-- CSS -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="/admin/content/css/admin-materialize.min.css" type="text/css" rel="stylesheet"
Expand Down Expand Up @@ -161,6 +159,11 @@
}); // end of document ready
})(jQuery); // end of jQuery name space

let glob = {
os: '{{glob.os}}',
pathSep: '{{glob.pathSep}}'
}

function hideLoader() {
$('#content-container').css('filter', 'blur(0px)')
$('.preloader-background').delay(200).fadeOut(600);
Expand All @@ -177,5 +180,4 @@
</script>
{{page.sections.script}}
</body>

</html>
5 changes: 2 additions & 3 deletions src/core/admin/pages/pages/index.html
Expand Up @@ -178,7 +178,6 @@
window.menuItems = res.data
})
.catch((err) => {

})
.then(() => {
hideLoader()
Expand All @@ -196,8 +195,8 @@

function renameMenu(fullPath, nameView, order) {
const ord = order < 10 ? `0${order}` : `${order}`
let regEx = new RegExp('\\\\(\\d\\d)\\.(' + nameView + ')', 'gi')
let res = fullPath.replace(regEx, `\\${ord}.$2`)
let regEx = new RegExp(glob.pathSep + '(\\d\\d)\\.(' + nameView + ')', 'gi')
let res = fullPath.replace(regEx, `${glob.pathSep}${ord}.$2`)
return res
}
</script>
Expand Down
8 changes: 8 additions & 0 deletions src/core/bll/admin/Pages.ts
Expand Up @@ -2,13 +2,21 @@ import { join } from "https://deno.land/std/path/mod.ts"
import { exists} from "https://deno.land/std/fs/mod.ts"
import { PageModel } from "../../models/page/PageModel.ts"
import { SectionModel } from "../../models/page/SectionModel.ts"
import { GlobModel } from "../../models/GlobModel.ts"

export async function getTheme(): Promise<string> {
const themePath = join(Deno.cwd(), "src/core/admin/layout.html")
const result = await Deno.readTextFile(themePath)
return result
}

export function getGlob(): GlobModel {
return {
os: Deno.build.os,
pathSep: Deno.build.os == "windows" ? "\\\\" : "/",
}
}

export async function getPage(url: URL | string): Promise<PageModel> {
let filePath: string

Expand Down
4 changes: 4 additions & 0 deletions src/core/models/GlobModel.ts
@@ -0,0 +1,4 @@
export interface GlobModel {
os: string,
pathSep: string
}

0 comments on commit 1863852

Please sign in to comment.