Comparing version 1.0.8 to 1.0.9
11
index.js
@@ -81,3 +81,12 @@ module.exports = function init(options) { | ||
//Master Pages | ||
site.masterPages = []; | ||
site.addMasterPage = function (page) { | ||
site.masterPages.push({ | ||
name: page.name, | ||
header: page.header, | ||
footer: page.footer | ||
}) | ||
} | ||
site.reset = function () { | ||
@@ -84,0 +93,0 @@ |
@@ -17,5 +17,5 @@ module.exports = function init(req, res, site) { | ||
function getContent(name){ | ||
if(name.endsWith('.html')){ | ||
return site.readFileSync(site.dir + '/html/' + name) | ||
function getContent(name) { | ||
if (name.endsWith('.html')) { | ||
return site.readFileSync(site.dir + '/html/' + name) | ||
} | ||
@@ -39,12 +39,14 @@ return 'Content Of : ' + name | ||
let matches = $.html().match(/##.*?##/g) | ||
for (var i = 0; i < matches.length; i++) { | ||
let v = matches[i] | ||
if (matches) { | ||
for (var i = 0; i < matches.length; i++) { | ||
let v = matches[i] | ||
if (v.startsWith('##var.')) { | ||
v = v.replace('##var.', '').replace('##', '') | ||
if (v.startsWith('##var.')) { | ||
v = v.replace('##var.', '').replace('##', '') | ||
txt = txt.replace(matches[i], renderVar(v)) | ||
txt = txt.replace(matches[i], renderVar(v)) | ||
} | ||
} | ||
} | ||
} | ||
return txt | ||
@@ -51,0 +53,0 @@ } |
@@ -78,2 +78,10 @@ module.exports = function init(site) { | ||
route.content = data.toString('utf8') | ||
if (route.masterPage) { | ||
for (var i = 0; i < site.masterPages.length; i++) { | ||
if (route.masterPage == site.masterPages[i].name) { | ||
route.content = site.readFileSync(site.masterPages[i].header) + route.content + site.readFileSync(site.masterPages[i].footer) | ||
break; | ||
} | ||
} | ||
} | ||
res.setHeader('x-content', 'Route Read File') | ||
@@ -93,3 +101,3 @@ res.code = 200 | ||
if (!err) { | ||
res.setHeader('x-content', 'Route Read Files') | ||
res.setHeader('x-content', 'Route Read Files') | ||
route.content = data.toString('utf8') | ||
@@ -100,3 +108,3 @@ res.code = 200 | ||
} else { | ||
res.setHeader('x-error', 'Route Error Read Files') | ||
res.setHeader('x-error', 'Route Error Read Files') | ||
res.code = 404 | ||
@@ -127,2 +135,3 @@ route.empty = true; | ||
parser: r.parser || 'static', | ||
masterPage : r.masterPage || null, | ||
cache: typeof r.cache == 'undefined' ? true : r.cache, | ||
@@ -129,0 +138,0 @@ callback: r.callback || defaultCallback |
{ | ||
"name": "isite", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Fast & Easy Full Web Site Management", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# Features | ||
- Auto Routes [simple & Advanced] | ||
- Handle Response Headers & codes | ||
- Auto Configer Request Cookies & Query Strings | ||
- Handle Request & Response Headers [Cookies - Query Strings] | ||
- Auto Detect & Configer User Session | ||
- Easy Creating Master Pages | ||
- Compain Multi Files Contents in One Route | ||
- Auto Caching Files in Memory | ||
- Fast Read Files Content [Site Folder Structure] | ||
- Custom Html Attributes [imports] | ||
- MD5 Hash Function | ||
@@ -125,4 +128,25 @@ | ||
``` | ||
## Imports | ||
## MasterPages | ||
add Custom Master Page And Using it .. | ||
```js | ||
site.addMasterPage({ | ||
name: 'masterPage1', | ||
header: site.dir + '/html/header.html', | ||
footer: site.dir + '/html/footer.html' | ||
}) | ||
site.get({ | ||
name: '/ContactUs', | ||
masterPage : 'masterPage1', | ||
path: site.dir + '/html/contact.html', | ||
parser: 'html' | ||
}); | ||
``` | ||
## Server Tags & Attributes | ||
Add Custom Html Content | ||
@@ -133,4 +157,15 @@ | ||
``` | ||
Page "welcome.html" Must Be In HTML Site Dir ['/site_dir/html/welcome.html'] | ||
Page "welcome.html" Must Be In HTML Site Dir ['/site_files/html/welcome.html'] | ||
- Dynamic Varibles Sets | ||
```js | ||
site.addVar('siteName', 'First Site With Isite Library '); | ||
site.addVar('siteBrand', 'XSite'); | ||
``` | ||
```html | ||
<title>##var.siteName##</title> | ||
<h2>##var.siteBrand##</h2> | ||
``` | ||
## More | ||
@@ -137,0 +172,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24457
540
173