From dcf4cdf873da90944cdf67a77a4ce833ef1f8443 Mon Sep 17 00:00:00 2001 From: Michele Azzolari Date: Tue, 9 Oct 2018 12:14:41 +0200 Subject: [PATCH 1/7] Fix issue #5 --- template/fork.html | 2 +- template/material.html | 2 +- template/original.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/template/fork.html b/template/fork.html index 9177ae4..786dcef 100644 --- a/template/fork.html +++ b/template/fork.html @@ -41,7 +41,7 @@
-

rep_URL

+

rep_SURL

diff --git a/template/material.html b/template/material.html index cce0e0a..24dca0c 100644 --- a/template/material.html +++ b/template/material.html @@ -48,7 +48,7 @@

rep_SNAME

-

We're working hard to get rep_URL online! Hang tight :)

+

We're working hard to get rep_SURL online! Hang tight :)

- rep_DEVNAME

diff --git a/template/original.html b/template/original.html index 3285c2f..3eb0f85 100644 --- a/template/original.html +++ b/template/original.html @@ -39,7 +39,7 @@
-

rep_URL is being worked on by rep_DEVNAME!

+

rep_SURL is being worked on by rep_DEVNAME!

\ No newline at end of file From 8f4781a85b1c907fd161fb25f978f06e71b93aad Mon Sep 17 00:00:00 2001 From: Michele Azzolari Date: Tue, 9 Oct 2018 12:19:10 +0200 Subject: [PATCH 2/7] Fix issues #4 #7 --- assets/app.js | 70 ++++++++++++++++++++++++++++++++++++--------------- index.html | 8 +++--- 2 files changed, 54 insertions(+), 24 deletions(-) diff --git a/assets/app.js b/assets/app.js index 5e90e89..44c1fd3 100644 --- a/assets/app.js +++ b/assets/app.js @@ -1,29 +1,59 @@ console.log("app.js loaded"); +const placeHolders = []; + var getTemplateHtml = template => { - document.getElementById('iframe').src = "about:blank"; - fetch('template/'+template+'.html') - .then(function(response) { - return response.text() - }) - .then(function(html) { - document.getElementById('iframe').contentWindow.document.write(html); - console.log(document.getElementById('iframe').contentWindow.document) - }); -} + document.getElementById('iframe').src = "about:blank"; + fetch('template/'+template+'.html') + .then(function(response) { + return response.text() + }) + .then(function(html) { + html = parseContent(html); + document.getElementById('iframe').contentWindow.document.write(html); + console.log(document.getElementById('iframe').contentWindow.document) + }); +}; var valueChange = value => { - var iframehtml = document.getElementById('iframe').contentWindow.document.getElementById(value); - val = document.getElementById(value).value; - iframehtml.innerHTML = val -} + var iframehtml = document.getElementById('iframe').contentWindow.document.getElementById(value); + var val = document.getElementById(value).value; + iframehtml.innerHTML = val +}; var downloadPage = () => { - var pageContents = new XMLSerializer().serializeToString(document.getElementById('iframe').contentWindow.document) - pageContents = pageContents.replace("rep_DEVNAME", document.getElementById("devname").value) - pageContents = pageContents.replace("rep_SNAME", document.getElementById("sitename").value) - pageContents = pageContents.replace("rep_SURL", document.getElementById("url").value) + var pageContents = new XMLSerializer().serializeToString(document.getElementById('iframe').contentWindow.document); + pageContents = parseContent(pageContents); + download(pageContents, "index.html", "text/html") +}; + +var parseContent = pageContents => { + placeHolders.forEach(ph => { + const val = document.getElementById(ph.id).value; + if(val) { + const re = new RegExp(ph.text, 'g'); + pageContents = pageContents.replace(re, val); + } + }); + return pageContents +}; + +var loadPlaceholder = () => { + const inputs = document.querySelectorAll('#inputs [type=text]'); + inputs.forEach(input => { + const ph = {} + const attrs = input.attributes; + for(let i = attrs.length - 1; i >= 0; i--) { + if(attrs[i].name === 'id') { + ph['id'] = attrs[i].value; + } else if( attrs[i].name === 'data-placeholder') { + ph['text'] = attrs[i].value; + } + } + placeHolders.push(ph); + }); +}; + +loadPlaceholder(); - download(pageContents, "index.html", "text/html") -} getTemplateHtml("original"); \ No newline at end of file diff --git a/index.html b/index.html index 750cdc0..2e090ca 100644 --- a/index.html +++ b/index.html @@ -16,7 +16,7 @@

I'm not done my website!

-

Theme

+

Template

@@ -30,11 +30,11 @@

Values

- + - + - +
From ad314162ca88232cbb02422270d9b9ee9d56e1d8 Mon Sep 17 00:00:00 2001 From: Michele Azzolari Date: Wed, 10 Oct 2018 09:16:20 +0200 Subject: [PATCH 3/7] Add a gitignore file, right now all IntelliJ files are excluded --- .gitignore | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72f4d98 --- /dev/null +++ b/.gitignore @@ -0,0 +1,66 @@ +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser From f263331209e072fb4692b266add37fde1324b923 Mon Sep 17 00:00:00 2001 From: Michele Azzolari Date: Wed, 10 Oct 2018 09:39:29 +0200 Subject: [PATCH 4/7] Proposal for #11: having templates' buttons dynamically loaded --- assets/app.js | 46 +++++++++++++++++++++++++++++++++++----------- index.html | 3 --- templates.json | 17 +++++++++++++++++ 3 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 templates.json diff --git a/assets/app.js b/assets/app.js index 44c1fd3..5a6cd2d 100644 --- a/assets/app.js +++ b/assets/app.js @@ -2,7 +2,32 @@ console.log("app.js loaded"); const placeHolders = []; -var getTemplateHtml = template => { +const getTemplates = () => { + fetch('templates.json') + .then(function(response) { + return response.json() + }) + .then(function(templates) { + populateTemplates(templates); + getTemplateHtml(templates[0].id); + }); +}; + +const populateTemplates = templates => { + const templatesContainer = document.getElementById('themebtns'); + templates.forEach(template => { + const button = document.createElement('button'); + button.setAttribute("class", "themebtn"); + button.setAttribute('id', template.id); + button.addEventListener("click", () => { + getTemplateHtml(template.id); + }); + button.textContent = template.name + ' (by ' + template.author + ')'; + templatesContainer.appendChild(button); + }); +}; + +const getTemplateHtml = template => { document.getElementById('iframe').src = "about:blank"; fetch('template/'+template+'.html') .then(function(response) { @@ -11,23 +36,22 @@ var getTemplateHtml = template => { .then(function(html) { html = parseContent(html); document.getElementById('iframe').contentWindow.document.write(html); - console.log(document.getElementById('iframe').contentWindow.document) }); }; -var valueChange = value => { - var iframehtml = document.getElementById('iframe').contentWindow.document.getElementById(value); - var val = document.getElementById(value).value; +const valueChange = value => { + const iframehtml = document.getElementById('iframe').contentWindow.document.getElementById(value); + const val = document.getElementById(value).value; iframehtml.innerHTML = val }; -var downloadPage = () => { - var pageContents = new XMLSerializer().serializeToString(document.getElementById('iframe').contentWindow.document); +const downloadPage = () => { + let pageContents = new XMLSerializer().serializeToString(document.getElementById('iframe').contentWindow.document); pageContents = parseContent(pageContents); download(pageContents, "index.html", "text/html") }; -var parseContent = pageContents => { +const parseContent = pageContents => { placeHolders.forEach(ph => { const val = document.getElementById(ph.id).value; if(val) { @@ -38,7 +62,7 @@ var parseContent = pageContents => { return pageContents }; -var loadPlaceholder = () => { +const loadPlaceholder = () => { const inputs = document.querySelectorAll('#inputs [type=text]'); inputs.forEach(input => { const ph = {} @@ -54,6 +78,6 @@ var loadPlaceholder = () => { }); }; -loadPlaceholder(); +getTemplates(); -getTemplateHtml("original"); \ No newline at end of file +loadPlaceholder(); diff --git a/index.html b/index.html index 2e090ca..342e5b8 100644 --- a/index.html +++ b/index.html @@ -17,9 +17,6 @@

I'm not done my website!

Template

- - -
+ + + + rep_SNAME + + + + + + + +
+
+
+
+ rep_SNAME is being worked on by rep_DEVNAME! +
+
+
+
+
+ + + \ No newline at end of file From 9fd845f53a7c998761155822d32c0cc0daafdbe2 Mon Sep 17 00:00:00 2001 From: hemanth kumar <43946715+hemanth-hk@users.noreply.github.com> Date: Wed, 10 Oct 2018 18:55:06 +0530 Subject: [PATCH 7/7] added css a little bit of css is added to made it user interactive and background is made a little bit darker --- template/fork.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/template/fork.html b/template/fork.html index 786dcef..4da1de6 100644 --- a/template/fork.html +++ b/template/fork.html @@ -12,12 +12,12 @@ font-family: sans-serif; padding: 0; margin: 0; - background-color: #E9E9E9; + background-color: #a09f9f; } .container { width: 40%; - margin: 0 auto; + margin: auto; } header { @@ -34,6 +34,9 @@ font-weight: 400; text-align: center; box-shadow:2px 2px 5px #888; + hover{ + boeder : 6px 6px 6px 6px; + } } @@ -50,4 +53,4 @@

rep_SNAME is being worked on by rep_DEVNAME!!

- \ No newline at end of file +