Skip to content

Commit

Permalink
migrating over comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gunr2171 committed Sep 5, 2024
1 parent 7f5223a commit 3f949fc
Show file tree
Hide file tree
Showing 7 changed files with 577 additions and 2 deletions.
23 changes: 23 additions & 0 deletions comments/meta.stackoverflow.com.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
// === questions ===
{
type: 'question',
title: 'Burnination request',
body: 'Thanks for posting this request and allowing the community to weigh in! Please note that burninating a tag is the process of carefully moderating a specific piece of Stack Overflow (please think twice before doing tag-only mass edits, as they can be counter-productive); once the community reaches a consensus, burnination can proceed. For more info, see [What is the process for burninating tags?](/q/324070).'
},
{
type: 'question',
title: 'Burnination request Low Quality',
body: 'Please note that burninating a tag is the process of carefully moderating a specific piece of Stack Overflow. Before burnination can proceed your question needs a bit more info on how the tag meets the burnination criteria. For more info, see [What is the process for burninating tags?](/q/324070).'
},
{
type: 'question',
title: 'Meta to Main',
body: 'You are on [Meta](//stackoverflow.com/help/whats-meta). This question will not be answered here and you may want to go over the [Checklist](/q/260648) and [ask] before you repost on main. Please consider deleting this question.'
},
{
type: 'question',
title: 'Voting on meta is different',
body: '[Voting on meta is different](//stackoverflow.com/help/whats-meta). Votes are often used to express (dis)agreement with the general premise of the Meta question. These votes *won\'t affect* your main site reputation.'
}
]
23 changes: 23 additions & 0 deletions comments/musicfans.stackexchange.com.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
// === questions ===
{
type: 'question',
title: 'ID - No tour, no details',
body: 'Hi and welcome. Identification questions need more details to be answerable. Please take the [tour] that will give you the scope of identification questions. [Here](//musicfans.meta.stackexchange.com/q/350) is a list of relevant details that you should specify.'
},
{
type: 'question',
title: 'ID - Tour, no details',
body: 'Identification questions need more details to be answerable. [Here](//musicfans.meta.stackexchange.com/q/350) is a list of relevant details that you should specify.'
},
{
type: 'question',
title: 'ID - No tour, no music (only video description)',
body: 'Hi and welcome. Please add more details about the music itself. Please take the [tour] that will give you the scope of identification questions. [Here](//musicfans.meta.stackexchange.com/q/350) is a list of relevant details that you should specify.'
},
{
type: 'question',
title: 'ID - Tour, no music (only video description)',
body: 'Please add more details about the music itself. [Here](//musicfans.meta.stackexchange.com/q/350) is a list of relevant details that you should specify.'
}
]
455 changes: 455 additions & 0 deletions comments/stackoverflow.com.json5

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions generate-comment-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import path from 'path';
import fs from 'fs';
import JSON5 from 'json5';

const typeToLetter = (type) => {
switch (type) {
case "question": return "Q";
case "answer": return "A";
case "close reason": return "C";
case "custom edit rejection": return "CRC";
case "edit summary question": return "EQ";
default: throw new Error(`'${type}' is not a valid type`);
}
}

const convertJson5FileToJsonp = (json5FilePath) => {
const fileNameWithoutExt = path.parse(json5FilePath).name;

const json5FileContent = fs.readFileSync(json5FilePath, { encoding: "utf-8" });
const data = JSON5.parse(json5FileContent);
const formattedEntries = data.map(entry => {
return {
name: `[${typeToLetter(entry.type)}] ${entry.title}`,
description: entry.body
};
});

const jsonp = "callback(\n" + JSON.stringify(formattedEntries, null, 2) + ")";
const outputFilePath = path.join('.', 'dist', 'comments', `${fileNameWithoutExt}.jsonp`);
if (!fs.existsSync(path.dirname(outputFilePath))) {
fs.mkdirSync(path.dirname(outputFilePath), { recursive: true });
}
fs.writeFileSync(outputFilePath, jsonp, { encoding: "utf-8" });
};

const commentsDirPath = path.join(import.meta.dirname, 'comments');

for (const partialFilePath of fs.readdirSync(commentsDirPath, { recursive: true }))
{
const filePath = `./comments/${partialFilePath}`;
if (path.parse(filePath).ext === '.json5')
{
console.log(filePath);
convertJson5FileToJsonp(filePath);
}
}
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"description": "socvr.org website (for GitHub pages)",
"main": "index.js",
"scripts": {
"build": "concurrently \"npm:build-css\" \"npm:build-images\" \"npm:build-ejs\"",
"build": "concurrently \"npm:build-css\" \"npm:build-images\" \"npm:build-ejs\" \"npm:build-comments\"",
"build-ejs": "ejsc ./pages/**/*.ejs -o ./dist",
"watch-ejs": "ejsc ./pages/**/*.ejs -o ./dist --watch",
"build-css": "ncp ./css ./dist",
"build-images": "ncp ./images ./dist"
"build-images": "ncp ./images ./dist",
"build-comments": "node generate-comment-files.js"
},
"repository": {
"type": "git",
Expand All @@ -20,10 +21,12 @@
"url": "https://github.com/SO-Close-Vote-Reviewers/socvr.org/issues"
},
"homepage": "https://github.com/SO-Close-Vote-Reviewers/socvr.org#readme",
"type": "module",
"dependencies": {
"@wcj/ejs-cli": "^1.6.0",
"concurrently": "^8.2.2",
"ejs": "^3.1.10",
"json5": "^2.2.3",
"marked": "^14.1.0",
"ncp": "^2.0.0"
}
Expand Down
13 changes: 13 additions & 0 deletions pages/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ There are a bunch of [useful userscripts for Stack Overflow out there](https://s
- [How to install a userscript?](https://greasyfork.org/en/help/installing-user-scripts)
- With [Tampermonkey](https://www.tampermonkey.net/), [Violentmonkey](https://violentmonkey.github.io/), or [Greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/) installed, from a GitHub userscript page you can [click the "Raw" button](/images/75kID.gif "GIF showing what happens in Tampermonkey when you click the 'Raw' button"). (Greasemonkey is recommended against, due to general userscript compatibility issues.)</dd>

### Auto Comments

Do you use [AutoReviewComments - Pro-forma comments for SE](https://stackapps.com/questions/2116)? SOCVR has a collection of canned comments we often use during moderation. You can use them as a remote in script.

1. Copy the URL for the site you want
* [stackoverflow.com](/comments/stackoverflow.com.jsonp)
* [meta.stackoverflow.com](/comments/meta.stackoverflow.com.jsonp)
* [musicfans.stackoverflow.com](/comments/musicfans.stackexchange.com.jsonp)
2. Open the Auto Comments dialog and click "remote" at the bottom.
3. Paste in the url, check "auto-get", and click save.

Please be aware that this will overwrite all local entries with the server's, and will overwrite it every time the dialog opens. If you have custom comments you want to keep, commit them to this website's repository or don't use this feature.

### <a id="our-scripts" href="#our-scripts" class="hover-visible"></a>Our own scripts

##### See [our GitHub userscript repository](https://github.com/SO-Close-Vote-Reviewers/UserScripts) with the full list of our scripts!
Expand Down

0 comments on commit 3f949fc

Please sign in to comment.