diff --git a/isso/js/app/config.js b/isso/js/app/config.js index 043cdb4..08bdbde 100644 --- a/isso/js/app/config.js +++ b/isso/js/app/config.js @@ -8,6 +8,8 @@ define(function() { "max-comments-top": "inf", "max-comments-nested": 5, "reveal-on-click": 5, + "auth": false, + "signin": "", "avatar": true, "avatar-bg": "#f0f0f0", "avatar-fg": ["#9abf88", "#5698c4", "#e279a3", "#9163b6", diff --git a/isso/js/app/i18n/en.js b/isso/js/app/i18n/en.js index ec4b4d0..6650414 100644 --- a/isso/js/app/i18n/en.js +++ b/isso/js/app/i18n/en.js @@ -3,7 +3,10 @@ define({ "postbox-author": "Name (optional)", "postbox-email": "E-mail (optional)", "postbox-website": "Website (optional)", - "postbox-submit": "Submit", + "postbox-submit": "submit", + "postbox-auth-required": "Authentication required to comment.", + "postbox-auth-sign-in": "Sign-in", + "postbox-auth-commenting-as": "Commenting as", "num-comments": "One Comment\n{{ n }} Comments", "no-comments": "No Comments Yet", diff --git a/isso/js/app/isso.js b/isso/js/app/isso.js index 4312d45..d6ef149 100644 --- a/isso/js/app/isso.js +++ b/isso/js/app/isso.js @@ -24,7 +24,11 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n", // submit form, initialize optional fields with `null` and reset form. // If replied to a comment, remove form completely. - $("[type=submit]", el).on("click", function() { + submit = $("[type=submit]", el) + if (submit === null) { + return el; + } + submit.on("click", function() { if (! el.validate()) { return; } diff --git a/isso/js/app/text/postbox.jade b/isso/js/app/text/postbox.jade index a2428de..f0ad123 100644 --- a/isso/js/app/text/postbox.jade +++ b/isso/js/app/text/postbox.jade @@ -1,14 +1,25 @@ -div(class='isso-postbox') +mixin form(style) div(class='form-wrapper') div(class='textarea-wrapper') div(class='textarea placeholder' contenteditable='true') = i18n('postbox-text') section(class='auth-section') - p(class='input-wrapper') + p(class='input-wrapper' style=style) input(type='text' name='author' placeholder=i18n('postbox-author')) - p(class='input-wrapper') + p(class='input-wrapper' style=style) input(type='email' name='email' placeholder=i18n('postbox-email')) - p(class='input-wrapper') + p(class='input-wrapper' style=style) input(type='text' name='website' placeholder=i18n('postbox-website')) p(class='post-action') input(type='submit' value=i18n('postbox-submit')) + +div(class='isso-postbox') + if conf.auth + if cookie.valid + p=i18n('postbox-auth-commenting-as') + ' ' + cookie.username + +form('visibility: hidden;') + else + p=i18n('postbox-auth-required') + a(href='#{conf.signin}') #{i18n('postbox-auth-sign-in')} + else + +form('') diff --git a/isso/js/embed.js b/isso/js/embed.js index 680880b..8134315 100644 --- a/isso/js/embed.js +++ b/isso/js/embed.js @@ -11,6 +11,7 @@ require(["app/lib/ready", "app/config", "app/i18n", "app/api", "app/isso", "app/ jade.set("i18n", i18n.translate); jade.set("pluralize", i18n.pluralize); jade.set("svg", svg); + jade.set("cookie", {'valid': true, 'username': 'Nicolas'}) domready(function() {