From e0359a54c1187a9b0f45add08fe0dc998455d2ae Mon Sep 17 00:00:00 2001 From: Waleed Ashraf Date: Sat, 31 Mar 2018 22:55:57 +0500 Subject: [PATCH 1/7] moved to css foldder and added code for characters --- css/styles.css | 149 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 css/styles.css diff --git a/css/styles.css b/css/styles.css new file mode 100644 index 0000000..cf3ab05 --- /dev/null +++ b/css/styles.css @@ -0,0 +1,149 @@ +* { box-sizing: border-box; } + +body { + margin-top: 50px; +} + +.sr-only { + color: transparent !important; + font-size: 0 !important; +} + +table { + text-align: center; + display: block; + overflow-x: scroll; + overflow-y: hidden; + position: static; + margin-left: 140px; +} + +tr { + position: static; + height: 32px; +} + +tr:not(:first-of-type):before { + content: ""; + width: calc(100vw - 160px); + background-color: #e7f4fa; + position: absolute; + border-radius: 4px; + height: 30px; + transform: translateY(1px); +} + +td { + background-color: transparent; + position: relative; + color: transparent; + font-size: 0; + line-height: 24px; +} + +th { + padding: 0 8px; + white-space: pre; +} + +td:first-of-type, th:first-of-type { + background-color: white; + color: black; + font-size: 18px; + text-align: left; + font-weight: bold; + white-space: pre; + position: absolute; + left: 0; + width: 150px; + text-overflow: ellipsis; + z-index: 999; + overflow: hidden; +} + +td:first-of-type a, th:first-of-type a{ + color: black; + text-decoration: underline; + padding: 0 8px; +} + +td.present:after { + content: "\2714"; + color: white; + position: absolute; + z-index: 1; + font-size: 12px; + left: calc(50% + 1px); + top: 50%; + transform: translate(-50%, -50%); +} + +td.present:before { + content: ""; + width: 18px; + height: 18px; + border-radius: 50%; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + background-color: green; +} + +td.absent:after { + content: "\00B7"; + color: white; + position: absolute; + z-index: 1; + font-size: 64px; + line-height: 24px; + left: calc(50% + 1px); + top: 50%; + transform: translate(-50%, -50%); +} + +nav { + height: 49px; + box-shadow: inset 0 -1px 0px 0px #999; + overflow: hidden; + position: fixed; + top: 0; + padding-top: 4px; + width: 100%; + left: 4px; + z-index: 9999; + background: white; +} +nav ul { + margin: 0; + padding: 0; +} + +nav ul li { + list-style: none; + display: inline; + padding: 0; + border-radius: 2px 2px 0 0; + border: 1px solid #999; + margin-right: -1px; + float: left; + height: 45px; +} + +nav ul li:hover { + background-color: #e7f4fa; +} + +nav ul li a { + color: black; + line-height: 45px; + text-decoration: none; + display: block; + padding: 0 16px; +} + +nav ul li.active { + background-color: white; + border-bottom-width: 0px; + box-shadow: inset 0 1px 0px 0px #999 +} \ No newline at end of file From b2fbaedd19cb9d24d17839e0dd8d2e354aaf210f Mon Sep 17 00:00:00 2001 From: Waleed Ashraf Date: Sat, 31 Mar 2018 22:56:07 +0500 Subject: [PATCH 2/7] ejs package added --- package-lock.json | 5 +++++ package.json | 1 + 2 files changed, 6 insertions(+) diff --git a/package-lock.json b/package-lock.json index 97e2f5e..d5c75fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -223,6 +223,11 @@ "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=" }, + "ejs": { + "version": "2.5.8", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.5.8.tgz", + "integrity": "sha512-QIDZL54fyV8MDcAsO91BMH1ft2qGGaHIJsJIA/+t+7uvXol1dm413fPcUgUb4k8F/9457rx4/KFE4XfDifrQxQ==" + }, "end-of-stream": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", diff --git a/package.json b/package.json index 047dc4c..56a3deb 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "dependencies": { "bluebird": "^3.5.1", "download-git-repo": "^1.0.2", + "ejs": "^2.5.8", "rimraf": "^2.6.2" } } From 67b9f4bb1ad15b8a36943d4fc5a8c5d81decc0c4 Mon Sep 17 00:00:00 2001 From: Waleed Ashraf Date: Sat, 31 Mar 2018 22:56:15 +0500 Subject: [PATCH 3/7] moved to folder --- styles.css | 149 ----------------------------------------------------- 1 file changed, 149 deletions(-) delete mode 100644 styles.css diff --git a/styles.css b/styles.css deleted file mode 100644 index 6381ff9..0000000 --- a/styles.css +++ /dev/null @@ -1,149 +0,0 @@ -* { box-sizing: border-box; } - -body { - margin-top: 50px; -} - -.sr-only { - color: transparent !important; - font-size: 0 !important; -} - -table { - text-align: center; - display: block; - overflow-x: scroll; - overflow-y: hidden; - position: static; - margin-left: 140px; -} - -tr { - position: static; - height: 32px; -} - -tr:not(:first-of-type):before { - content: ""; - width: calc(100vw - 160px); - background-color: #e7f4fa; - position: absolute; - border-radius: 4px; - height: 30px; - transform: translateY(1px); -} - -td { - background-color: transparent; - position: relative; - color: transparent; - font-size: 0; - line-height: 24px; -} - -th { - padding: 0 8px; - white-space: pre; -} - -td:first-of-type, th:first-of-type { - background-color: white; - color: black; - font-size: 18px; - text-align: left; - font-weight: bold; - white-space: pre; - position: absolute; - left: 0; - width: 150px; - text-overflow: ellipsis; - z-index: 999; - overflow: hidden; -} - -td:first-of-type a, th:first-of-type a{ - color: black; - text-decoration: underline; - padding: 0 8px; -} - -td.present:after { - content: "✔"; - color: white; - position: absolute; - z-index: 1; - font-size: 12px; - left: calc(50% + 1px); - top: 50%; - transform: translate(-50%, -50%); -} - -td.present:before { - content: ""; - width: 18px; - height: 18px; - border-radius: 50%; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - background-color: green; -} - -td.absent:after { - content: "·"; - color: white; - position: absolute; - z-index: 1; - font-size: 64px; - line-height: 24px; - left: calc(50% + 1px); - top: 50%; - transform: translate(-50%, -50%); -} - -nav { - height: 49px; - box-shadow: inset 0 -1px 0px 0px #999; - overflow: hidden; - position: fixed; - top: 0; - padding-top: 4px; - width: 100%; - left: 4px; - z-index: 9999; - background: white; -} -nav ul { - margin: 0; - padding: 0; -} - -nav ul li { - list-style: none; - display: inline; - padding: 0; - border-radius: 2px 2px 0 0; - border: 1px solid #999; - margin-right: -1px; - float: left; - height: 45px; -} - -nav ul li:hover { - background-color: #e7f4fa; -} - -nav ul li a { - color: black; - line-height: 45px; - text-decoration: none; - display: block; - padding: 0 16px; -} - -nav ul li.active { - background-color: white; - border-bottom-width: 0px; - box-shadow: inset 0 1px 0px 0px #999 -} \ No newline at end of file From 55ade6cb3d4be9f7459474cb5a8082149bca1bf9 Mon Sep 17 00:00:00 2001 From: Waleed Ashraf Date: Sat, 31 Mar 2018 22:56:40 +0500 Subject: [PATCH 4/7] added header.ejs including styles --- templates/header.ejs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 templates/header.ejs diff --git a/templates/header.ejs b/templates/header.ejs new file mode 100644 index 0000000..f3d5929 --- /dev/null +++ b/templates/header.ejs @@ -0,0 +1,2 @@ +Node.js Meeting Participation + From 504bbd3be342257afc8791d01cba17691759ad0c Mon Sep 17 00:00:00 2001 From: Waleed Ashraf Date: Sat, 31 Mar 2018 22:56:57 +0500 Subject: [PATCH 5/7] added page.ejs --- templates/page.ejs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 templates/page.ejs diff --git a/templates/page.ejs b/templates/page.ejs new file mode 100644 index 0000000..8e4a2b6 --- /dev/null +++ b/templates/page.ejs @@ -0,0 +1,18 @@ + + + + <%- include header %> + + + + <%- include table %> + + \ No newline at end of file From e491326e6d3452efdcde793d00e55e4e989856ee Mon Sep 17 00:00:00 2001 From: Waleed Ashraf Date: Sat, 31 Mar 2018 22:57:10 +0500 Subject: [PATCH 6/7] added table.ejs --- templates/table.ejs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 templates/table.ejs diff --git a/templates/table.ejs b/templates/table.ejs new file mode 100644 index 0000000..2e81ced --- /dev/null +++ b/templates/table.ejs @@ -0,0 +1,26 @@ + + + + + <% + let members = Object.keys(content.members).sort(); + let allDates = [...content.dates.entries()].sort().reverse(); + %> + + <% for (let [date] of allDates) { %> + + <% } %> + + <% for (let user of members) { %> + + <% let href = "https://www.github.com/" + user.replace('@', ''); %> + + <% for (let [date] of allDates) { + let isPresent = content.members[user].has(date) ? 'present' : 'absent'; + %> + + <% } %> + + <% } %> + +
Username<%=new Date(date).toDateString()%>
<%=user%><%=isPresent%>
\ No newline at end of file From 39bdef4c80dd26a0c41624ca84ff1ae3bffae6d8 Mon Sep 17 00:00:00 2001 From: Waleed Ashraf Date: Sat, 31 Mar 2018 22:57:42 +0500 Subject: [PATCH 7/7] added ejs / removed format function / updated write function --- build.js | 73 +++++++++++++------------------------------------------- 1 file changed, 17 insertions(+), 56 deletions(-) diff --git a/build.js b/build.js index 52bac4e..8d3488f 100644 --- a/build.js +++ b/build.js @@ -5,6 +5,7 @@ const path = require('path'); const fs = P.promisifyAll(require('fs')); const rimraf = P.promisify(require('rimraf')); const ghdownload = P.promisify(require('download-git-repo')); +const ejs = require('ejs'); const REPOS = require('./repositories.json').sort(); const REPO_DEST = path.join(__dirname, 'repo'); @@ -70,64 +71,26 @@ async function parse(REPO){ return { members: MEMBERS, dates: ALL_DATES }; } -// Format the parsed data from all markdown files into an HTML table. -async function format(data) { - let TABLE = ``; - let members = Object.keys(data.members).sort(); - let allDates = [...data.dates.entries()].sort().reverse(); - - // Table headers. - TABLE += `\n ` - TABLE += `\n `; - for (let [date] of allDates) { - TABLE += `\n ` - } - TABLE += `\n ` - - // Member rows. - for (let user of members) { - TABLE += `\n `; - TABLE += `\n `; - for (let [date] of allDates) { - let isPresent = data.members[user].has(date); - TABLE += `\n `; - } - TABLE += `\n `; - } - TABLE += `
Username${(new Date(date)).toDateString()}
${user}${isPresent ? 'Present' : 'Absent'}
`; - - return TABLE; -} - // Write the final HTML document to disk. -async function write(repos, repo, table) { - - let html = ` - - - - Node.js Meeting Participation - - - - - ${table} - - -`; - +async function write(repos, repo, content) { + + let options = { + 'client': true, + 'root': './' + }; + let data = { + 'repos': repos, + 'repo' : repo, + 'content': content + }; + let html = await ejs.renderFile('templates/page.ejs', data, options); let desc = repo.split('/'); try { await fs.mkdirAsync(SITE_DEST); await fs.mkdirAsync(path.join(SITE_DEST, desc[0])); - } catch (e) { } - + } catch (e) { + console.log('error', e); + } await fs.writeFileAsync(path.join(SITE_DEST, desc[0], `${desc[1]}.html`), html); } @@ -142,10 +105,8 @@ async function run(){ await fetch(repo); // Parse the member participant data for each meeting let data = await parse(repo); - // Generate an HTML table using the data - let table = await format(data); // Write a new HTML document for this page - await write(REPOS.slice(), repo, table); + await write(REPOS.slice(), repo, data); } }