Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SSI build script #597

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules

.DS_Store
out/
33 changes: 33 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const ssi = require('ssi');
const glob = require('glob');
const fs = require('fs')
const path = require('path');
const mkdirp = require('mkdirp');

const srcDir = './'; // shtml base dir
const outDir = 'out/'; // build output dir
const matcher = '/**/*.shtml'; // shtml file matcher

const parser = new ssi(srcDir, outDir, matcher);

// find all shtml file in srcDir
glob(srcDir + matcher, (err, match) => {
if (err) throw err;

// exclude node_module and inc dir
match.filter(i => !i.match('node_modules') && !i.match('/inc/')).forEach(file => {
console.log('Reading:', file);

// skip if parse failed
try {
const out = file.replace(srcDir, outDir).replace('.shtml', '.html');
const dir = path.dirname(out);

if (!fs.existsSync(dir)) mkdirp.sync(dir);

fs.writeFileSync(out, parser.parse(file, fs.readFileSync(file, {encoding: "utf8"})));
} catch (error) {
console.error(`Error '${file}' build failed:`, error);
}
});
});
3 changes: 1 addition & 2 deletions dl/fx/index.shtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
<H1>下載 Mozilla Firefox</H1>
<div class='dlall'>
<div><h3> 最新版本 </h3>
<!--#if expr="" --><!-- point to .shtml while test locally --><!--#endif -->
<!--#include virtual="/inc/dlff.html" -->
<!--#include virtual="/inc/dlff.shtml" -->
<br/>

<div style='width: 30%;'>
Expand Down
2 changes: 1 addition & 1 deletion events/sfx/workshop.shtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<body>
<!--#set var="page_title" value="Firefox 研討會" -->
<!--#include virtual="/events/sfx/top_block.html" -->
<!--#include virtual="/events/sfx/top_block.shtml" -->


<div id="main-content">
Expand Down
3 changes: 1 addition & 2 deletions firefox/extension_top_15/1nd.shtml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ function hidden_descript(obj) {

<div class="download">
<h3>下載 Firefox 中文版</h3>
<!--#if expr="" --><!-- point to .shtml while test locally --><!--#endif -->
<!--#include virtual="/inc/dlff.html" -->
<!--#include virtual="/inc/dlff.shtml" -->
</div><ul>
<li><a class="ancilliaryLink" href="/firefox/">Firefox 中文版介紹</a></li>
<li><a class="ancilliaryLink" href="http://forum.moztw.org/viewforum.php?f=11">Mozilla Taiwan 擴充套件討論區</a></li>
Expand Down
3 changes: 1 addition & 2 deletions firefox/extension_top_15/2nd.shtml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ function hidden_descript(obj) {

<div class="download">
<h3>下載 Firefox 中文版</h3>
<!--#if expr="" --><!-- point to .shtml while test locally --><!--#endif -->
<!--#include virtual="/inc/dlff.html" -->
<!--#include virtual="/inc/dlff.shtml" -->
</div><ul>
<li><a class="ancilliaryLink" href="/firefox/">Firefox 中文版介紹</a></li>
<li><a class="ancilliaryLink" href="http://forum.moztw.org/viewforum.php?f=11">MozTW 擴充套件討論區</a></li>
Expand Down
3 changes: 1 addition & 2 deletions firefox/extension_top_15/index.shtml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ function hidden_descript(obj) {

<div class="download">
<h3>下載 Firefox 中文版</h3>
<!--#if expr="" --><!-- point to .shtml while test locally --><!--#endif -->
<!--#include virtual="/inc/dlff.html" -->
<!--#include virtual="/inc/dlff.shtml" -->
</div><ul>
<li><a class="ancilliaryLink" href="/firefox/">Firefox 中文版介紹</a></li>
<li><a class="ancilliaryLink" href="http://forum.moztw.org/viewforum.php?f=11">MozTW 擴充套件討論區</a></li>
Expand Down
3 changes: 1 addition & 2 deletions firefox/releases/1.0pr/index.shtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
<div id="product-side">
<div class="download">
<h3>馬上下載</h3>
<!--#if expr="" --><!-- point to .shtml while test locally --><!--#endif -->
<!--#include virtual="/inc/dlff.html" -->
<!--#include virtual="/inc/dlff.shtml" -->
</div><ul>
<li><a class="ancilliaryLink" href="/docs/ff/system-requirements">系統需求</a></li>
<li><a class="ancilliaryLink" href="/firefox/0.10.html">版本資訊</a></li>
Expand Down
5 changes: 1 addition & 4 deletions index.shtml
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,7 @@
<div class="download dl-box">
<h3><a href="https://mozilla.org/firefox/" title="全新 Firefox Quantum,更快、更多好事。" onclick="ga('send', 'event', 'Outgoing', 'mozilla.org/firefox', 'home_dl_title');"><strong class="downloadText">Firefox 正體中文版</strong></a></h3>
<div style="margin-top: 5px;">
<!--#if expr="" -->
<!-- point to .shtml while test locally -->
<!--#endif -->
<!--#include virtual="/inc/dlff.html" -->
<!--#include virtual="/inc/dlff.shtml" -->
</div>
</div>
<div class="download dl-mobile" onclick="">
Expand Down
3 changes: 1 addition & 2 deletions narrow.shtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
<div class="download">
<h3><a href="/firefox/"><strong class="downloadText">下載 Firefox</strong></a></h3>
<div style='background: url(/images/product-download-firefox.png) no-repeat;margin-top: 5px;'>
<!--#if expr="" --><!-- point to .shtml while test locally --><!--#endif -->
<!--#include virtual="/inc/dlff.html" -->
<!--#include virtual="/inc/dlff.shtml" -->
</div>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "Mozilla Taiwan community web site",
"main": "index.html",
"scripts": {
"start": "browser-sync start --config bs-config.js"
"start": "browser-sync start --config bs-config.js",
"build": "node build.js"
},
"repository": {
"type": "git",
Expand All @@ -26,6 +27,7 @@
"grunt-update-submodules": "~0.4.1",
"gulp": "^3.9.0",
"load-grunt-tasks": "^3.4.0",
"mkdirp": "^0.5.1",
"ssi": "^0.3.0"
}
}
2 changes: 1 addition & 1 deletion thunderbird/inc/tb_tail-sandstone.shtml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
</div>
</section>

<!--#include virtual="/sandstone/footer.html" -->
<!--#include virtual="/sandstone/footer.shtml" -->
Loading