diff --git a/config.template.yaml b/config.template.yaml index a4a883a6..30aa9429 100644 --- a/config.template.yaml +++ b/config.template.yaml @@ -96,3 +96,9 @@ reserved-names: - '^(.*?[-_])?admin(istrator)?([-_].*)?$' - '^(.*?[-_])?owner([-_].*)?$' pagetitles: [] + +# Provide a contact list for the /contact page +contacts: + - name: 'calzoneman' + title: 'Developer' + email: 'cyzon@cytu.be' diff --git a/lib/config.js b/lib/config.js index 0255bfeb..d244b187 100644 --- a/lib/config.js +++ b/lib/config.js @@ -68,7 +68,14 @@ var defaults = { usernames: ["^(.*?[-_])?admin(istrator)?([-_].*)?$", "^(.*?[-_])?owner([-_].*)?$"], channels: ["^(.*?[-_])?admin(istrator)?([-_].*)?$", "^(.*?[-_])?owner([-_].*)?$"], pagetitles: [] - } + }, + "contacts": [ + { + name: "calzoneman", + title: "Developer", + email: "cyzon@cytu.be" + } + ] }; /** diff --git a/lib/server.js b/lib/server.js index 8d27e901..9ad72f77 100644 --- a/lib/server.js +++ b/lib/server.js @@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -const VERSION = "3.0.0-alpha"; +const VERSION = "3.0.0-RC1"; var singleton = null; var Config = require("./config"); diff --git a/lib/web/webserver.js b/lib/web/webserver.js index b2752336..2507d5b3 100644 --- a/lib/web/webserver.js +++ b/lib/web/webserver.js @@ -177,9 +177,6 @@ function handleSocketConfig(req, res) { "IO_URL=WEB_URL=SSL_URL;}" : "")); } -/** - * Handles a request for the user agreement - */ function handleUserAgreement(req, res) { logRequest(req); sendJade(res, "tos", { @@ -187,6 +184,36 @@ function handleUserAgreement(req, res) { }); } +function handleContactPage(req, res) { + logRequest(req); + + // Make a copy to prevent messing with the original + var contacts = Config.get("contacts").map(function (c) { + return { + name: c.name, + email: c.email, + title: c.title + }; + }); + + // Rudimentary hiding of email addresses to prevent spambots + contacts.forEach(function (c) { + c.emkey = $util.randomSalt(16) + var email = new Array(c.email.length); + for (var i = 0; i < c.email.length; i++) { + email[i] = String.fromCharCode( + c.email.charCodeAt(i) ^ c.emkey.charCodeAt(i % c.emkey.length) + ); + } + c.email = escape(email.join("")); + c.emkey = escape(c.emkey); + }); + + sendJade(res, "contact", { + contacts: contacts + }); +} + module.exports = { /** * Initializes webserver callbacks @@ -210,6 +237,7 @@ module.exports = { app.get("/", handleIndex); app.get("/sioconfig", handleSocketConfig); app.get("/useragreement", handleUserAgreement); + app.get("/contact", handleContactPage); require("./auth").init(app); require("./account").init(app); require("./acp").init(app); diff --git a/package.json b/package.json index 8f0997e3..12ca78d2 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "3.0.0-alpha", + "version": "3.0.0-RC1", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/templates/contact.jade b/templates/contact.jade new file mode 100644 index 00000000..b3204271 --- /dev/null +++ b/templates/contact.jade @@ -0,0 +1,47 @@ +mixin email(e, k) + button.btn.btn-xs.btn-default(onclick="showEmail(this, '#{e}', '#{k}')") Show Email + +doctype html +html(lang="en") + head + include head + mixin head() + body + #wrap + nav.navbar.navbar-inverse.navbar-fixed-top(role="navigation") + include nav + mixin navheader() + #nav-collapsible.collapse.navbar-collapse + ul.nav.navbar-nav + mixin navdefaultlinks("/contact") + mixin navloginlogout("/contact") + section#mainpage + .container + .col-md-8.col-md-offset-2 + h1 Contact + h3 Email + each contact in contacts + strong= contact.name + p.text-muted= contact.title + mixin email(contact.email, contact.emkey) + br + hr + h3 IRC + p. + The developer and other knowledgeable people are usually available on IRC for quick questions or comments. Official support can be provided for cytu.be and synchtube.6irc.net at irc.6irc.net#cytube. These people can also address general questions about the software, but cannot provide technical support for third-party websites using this code. + include footer + mixin footer() + script(type="text/javascript"). + function showEmail(btn, email, key) { + email = unescape(email); + key = unescape(key); + var dest = new Array(email.length); + for (var i = 0; i < email.length; i++) { + dest[i] = String.fromCharCode(email.charCodeAt(i) ^ key.charCodeAt(i % key.length)); + } + email = dest.join(""); + $("").attr("href", "mailto:" + email) + .text(email) + .insertBefore(btn); + $(btn).remove(); + } diff --git a/templates/footer.jade b/templates/footer.jade index 9fe33d1f..157d27e2 100644 --- a/templates/footer.jade +++ b/templates/footer.jade @@ -2,7 +2,7 @@ mixin footer footer#footer .container p.text-muted.credit. - Copyright © 2013 Calvin Montgomery · Fork me on GitHub · User Agreement + Copyright © 2013 Calvin Montgomery · GitHub · User Agreement · Contact script(src="/js/jquery.js") // Must be included before jQuery-UI since jQuery-UI overrides jQuery.fn.button // I should really abandon this crap one day