Skip to content

Instantly share code, notes, and snippets.

@communiteq
communiteq / question2answer.rb
Last active October 2, 2019 20:50
question2answer import - import comments / remove dependency on other database / import best answer
require 'mysql2'
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
require 'htmlentities'
begin
require 'php_serialize' # https://github.com/jqr/php-serialize
rescue LoadError
puts
puts 'php_serialize not found.'
puts 'Add to Gemfile, like this: '
puts
@communiteq
communiteq / extra-items-in-category-menu.dcstyle.json
Created February 8, 2017 18:59
Discourse site customization: Extra items in 'Category' menu
{"site_customization":{"id":6,"name":"Extra items in Category menu","key":"a82e17bf-7dc9-4409-b951-1453dd118c0e","enabled":true,"created_at":"2016-12-23T17:37:47.056Z","updated_at":"2016-12-23T18:00:45.824Z","stylesheet":"","header":"","footer":"","top":"","mobile_stylesheet":"","mobile_header":"","mobile_footer":"","mobile_top":"","head_tag":"","body_tag":"\u003cscript\u003e\n\n Discourse.ExternalNavItem = Discourse.NavItem.extend({\n href : function() {\n return this.get('href');\n }.property('href')\n });\n\n I18n.translations.en.js.filters.item1 = { title: \"Item 1\", help: \"Tooltip 1\" };\n I18n.translations.en.js.filters.item2 = { title: \"Item 2\", help: \"Tooltip 2\" }\n\n Discourse.NavItem.reopenClass({\n buildList : function(category, args) {\n var list = this._super(category, args);\n if(!category) {\n list.push(Discourse.ExternalNavItem.create({href: '/link1', name: 'item1'}));\n list.push(Discourse.ExternalNavItem.create({href: '/link2', name: 'item2'})
@communiteq
communiteq / change-home-logo.dcstyle.json
Created February 8, 2017 18:58
Discourse site customization: change URL behind home logo
{"site_customization":{"id":3,"name":"Change home logo","key":"a3b4338c-b5a9-4e19-959a-d4b1de267175","enabled":false,"created_at":"2016-09-29T20:55:52.874Z","updated_at":"2016-12-23T17:56:47.611Z","stylesheet":"","header":"","footer":"","top":"","mobile_stylesheet":"","mobile_header":"","mobile_footer":"","mobile_top":"","head_tag":"\u003cscript type=\"text/discourse-plugin\" version=\"0.2\"\u003e\n api.changeWidgetSetting('post-avatar', 'size', '140');\n api.changeWidgetSetting('home-logo', 'href', 'https://www.google.com/');\n\u003c/script\u003e","body_tag":"","embedded_css":""}}
@communiteq
communiteq / showlatest.js
Created December 24, 2016 15:37
Example latest.json display
<script>
jQuery(document).ready(function($) {
var site = 'https://your.discourse.forum';
var size = 50;
var data = $.getJSON(site + '/latest.json', function(data) {
var userArr = {};
for(var i=0; i<data.users.length; i++) {
userArr[data.users[i].id] = data.users[i].avatar_template.replace('{size}',size);
}
@communiteq
communiteq / extra-menu-items-in-top-bar.dcstyle.json
Created December 23, 2016 18:03
Discourse site customization : Extra menu items in top bar
{"site_customization":{"id":7,"name":"Extra menu items in top bar","key":"74197bb7-683d-424f-87af-1feedd585275","enabled":true,"created_at":"2016-12-23T17:43:43.847Z","updated_at":"2016-12-23T17:58:19.457Z","stylesheet":"/* add extra items in the top bar (left to the search icon)\n author: Richard at DiscourseHosting.com\n*/\n\ndiv#toprow-links {\n display: inline;\n float: left;\n font-size: 1.2em;\n margin-right: 20px;\n margin-top: 10px;\n}\ndiv#toprow-links a {\n color: #666;\n margin-right: 20px;\n}","header":"\u003c!-- add extra items in the top bar (left to the search icon)\n author: Richard at DiscourseHosting.com --\u003e\n\n\u003cscript type=\"text/discourse-plugin\" version=\"0.2\"\u003e\napi.decorateWidget('header-icons:before', helper =\u003e {\n const showExtraInfo = helper.attrs.minimized;\n if(!showExtraInfo) {\n return helper.h('div#toprow-links', [\n helper.h('a#test1', {\n href:'https://www.google.com/', \n