codeforcroatia / codeforcroatia.org

[Deprecated] Extended project of Laddr for Code for Croatia website
https://codeforcroatia.org
1 stars 2 forks source link

Make Laddr comments configurable and add optional comments integration with Discourse #46

Open schlos opened 3 years ago

schlos commented 3 years ago

We're getting a lot of spam, so we need better mechanism to stop spammers.

Level 1 - Captcha

Level 2 - Make Comments configurable (enable/disable per instance)

Level 3 - Make comments with Discourse comments (configurable)

schlos commented 3 years ago

OPTION 1) Discourse embedding comments via JS: https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963

OPTION 2) CfP proof-of-concept by Chris: https://codeforphilly.org/discourse/topic/872 & embedded discourse comments look like: http://codeforphilly.org/discourse/topic/246

so in this example you put a discourse topic id into the laddr URL and it loads the content over the api and renders it as a page, and then embeds the comments for that topic:

{extends designs/site.tpl}
{block title}{$fancy_title|escape} — {$dwoo.parent}{/block}
{block content}
    <h2>{$fancy_title|escape}</h2>
    {$post_stream.posts[0].cooked}
    <hr>
    {$url = "http://forum.codeforphilly.org/t/$slug/$id"}
    Edit or discuss this page at <a href="{$url|escape}">{$url|escape}</a>
    <hr>
    <div id="discourse-comments"></div>
    <script type="text/javascript">
        var DiscourseEmbed = {
            discourseUrl: '//forum.codeforphilly.org/',
            topicId: {$id|json_encode}
        };
        (function() {
            var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
            d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
        })();
    </script>
{/block}
schlos commented 3 years ago

Option 1) https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963

Replace discourseEmbedUrl: 'http://example.com/blog/entry-123.html' with: "http://{Site::getConfig(primary_hostname)}{$Post->getURL()}" (http OR https??)