Skip to content

Commit

Permalink
Merge branch 'edge'
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxMD committed Nov 29, 2022
2 parents 95c6530 + ef372e5 commit a891e2d
Show file tree
Hide file tree
Showing 28 changed files with 500 additions and 189 deletions.
6 changes: 5 additions & 1 deletion .dockerignore
@@ -1,7 +1,10 @@
.git
logs
.github
docs
_site
.bundle
vendor
docs/.jekyll-cache
node_modules
coverage
.nyc_output
Expand All @@ -23,3 +26,4 @@ coverage
!tsconfig.json
!package*.json
!docker/config/**
!_config.yml
15 changes: 15 additions & 0 deletions Dockerfile
Expand Up @@ -96,11 +96,26 @@ WORKDIR /app

FROM base as build

# copy NPM dependencies and install
COPY --chown=abc:abc package*.json ./
COPY --chown=abc:abc tsconfig.json .

RUN npm install

# copy bundle/jekyll dependencies and docs folder
COPY --chown=abc:abc Gemfile Gemfile.lock _config.yml ./
COPY --chown=abc:abc docs ./docs/

# sassc (a jekll dependency) is very slow to compile bc there are no alpine binaries
# https://github.com/sass/sassc-ruby/issues/189#issuecomment-629758948
# so for now sync used jekyll version with prebuilt binary available in alpine repo
RUN apk add --no-cache --virtual .build-deps \
ruby-jekyll \
&& bundle install \
&& jekyll build -b /docs \
&& apk del .build-deps \
&& rm -rf docs

COPY --chown=abc:abc . /app

RUN npm run build && rm -rf node_modules
Expand Down
5 changes: 4 additions & 1 deletion Gemfile
@@ -1,6 +1,9 @@
source 'https://rubygems.org'

gem "jekyll", "~> 4.3" # installed by `gem jekyll`
# sassc (a jekll dependency) is very slow to compile bc there are no alpine binaries
# https://github.com/sass/sassc-ruby/issues/189#issuecomment-629758948
# so for now sync used jekyll version with prebuilt binary available in alpine repo
gem "jekyll", "4.2.2" # installed by `gem jekyll`
# gem "webrick" # required when using Ruby >= 3 and Jekyll <= 4.2.2

gem "just-the-docs", "0.4.0.rc3" # currently the latest pre-release
Expand Down
28 changes: 12 additions & 16 deletions Gemfile.lock
Expand Up @@ -14,22 +14,21 @@ GEM
http_parser.rb (0.8.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
jekyll (4.3.0)
jekyll (4.2.2)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
i18n (~> 1.0)
jekyll-sass-converter (>= 2.0, < 4.0)
jekyll-sass-converter (~> 2.0)
jekyll-watch (~> 2.0)
kramdown (~> 2.3, >= 2.3.1)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.0)
liquid (~> 4.0)
mercenary (>= 0.3.6, < 0.5)
mercenary (~> 0.4.0)
pathutil (~> 0.9)
rouge (>= 3.0, < 5.0)
rouge (~> 3.0)
safe_yaml (~> 1.0)
terminal-table (>= 1.8, < 4.0)
webrick (~> 1.7)
terminal-table (~> 2.0)
jekyll-default-layout (0.1.5)
jekyll (>= 3.0, < 5.0)
jekyll-optional-front-matter (0.3.2)
Expand Down Expand Up @@ -67,22 +66,19 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.5)
rouge (4.0.0)
rouge (3.30.0)
safe_yaml (1.0.5)
sassc (2.4.0)
ffi (~> 1.9)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (2.3.0)
webrick (1.7.0)
terminal-table (2.0.0)
unicode-display_width (~> 1.1, >= 1.1.1)
unicode-display_width (1.8.0)

PLATFORMS
arm64-darwin-21
x86_64-darwin-19
x86_64-linux

DEPENDENCIES
jekyll (~> 4.3)
jekyll (= 4.2.2)
jekyll-default-layout
jekyll-optional-front-matter
jekyll-readme-index
Expand All @@ -91,4 +87,4 @@ DEPENDENCIES
just-the-docs (= 0.4.0.rc3)

BUNDLED WITH
2.3.9
2.3.25
3 changes: 3 additions & 0 deletions docker-compose.yml
Expand Up @@ -24,6 +24,9 @@ services:

cache:
image: 'redis:7-alpine'
volumes:
# on linux will need to make sure this directory has correct permissions for container to access
- './data/cache:/data'

database:
image: 'mariadb:10.9.3'
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
@@ -1,6 +1,6 @@
---
title: Overview
permalink: /overview
permalink: /overview.html
nav_order: 2
---

Expand Down
6 changes: 4 additions & 2 deletions docs/operator/installation.md
Expand Up @@ -55,20 +55,22 @@ The included [`docker-compose.yml`](/docker-compose.yml) provides production-rea

#### Setup

The included `docker-compose.yml` file is written for **Docker Compose v2.**

For new installations copy [`config.yaml`](/docker/config/docker-compose/config.yaml) into a folder named `data` in the same folder `docker-compose.yml` will be run from. For users migrating their existing CM instances to docker-compose, copy your existing `config.yaml` into the same `data` folder.

Read through the comments in both `docker-compose.yml` and `config.yaml` and makes changes to any relevant settings (passwords, usernames, etc...). Ensure that any settings used in both files (EX mariaDB passwords) match.

To build and start CM:

```bash
docker-compose up -d
docker compose up -d
```

To include Grafana/Influx dependencies run:

```bash
docker-compose --profile full up -d
docker compose --profile full up -d
```

## Locally
Expand Down
23 changes: 23 additions & 0 deletions docs/subreddit-configuration/actionTemplating.md
Expand Up @@ -57,6 +57,29 @@ All Actions with `content` have access to this data:
| `title` | As comments => the body of the comment. As Submission => title | Test post please ignore |
| `shortTitle` | The same as `title` but truncated to 15 characters | test post pleas... |

#### Common Author

Additionally, `author` has these properties accessible:

| Name | Description | Example |
|----------------|-------------------------------------|----------|
| `age` | (Approximate) Age of account | 3 months |
| `linkKarma` | Amount of link karma | 10 |
| `commentKarma` | Amount of comment karma | 3 |
| `totalKarma` | Combined link+comment karma | 13 |
| `verified` | Does account have a verified email? | true |

NOTE: Accessing these properties may require an additional API call so use sparingly on high-volume comments

##### Example Usage

```
The user {{item.author}} has been a redditor for {{item.author.age}}
```
Produces:

> The user FoxxMD has been a redditor for 3 months
### Submissions

If the **Activity** is a Submission these additional properties are accessible:
Expand Down
68 changes: 68 additions & 0 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -44,6 +44,7 @@
"@nlpjs/lang-fr": "^4.23.4",
"@nlpjs/language": "^4.22.7",
"@nlpjs/nlp": "^4.23.5",
"@npmcli/promise-spawn": "^6.0.1",
"@stdlib/regexp-regexp": "^0.0.6",
"ajv": "^7.2.4",
"ansi-regex": ">=5.0.1",
Expand All @@ -52,6 +53,7 @@
"body-parser": "^1.19.0",
"cache-manager": "^3.4.4",
"cache-manager-redis-store": "^2.0.0",
"command-exists": "^1.2.9",
"commander": "^8.0.0",
"comment-json": "^4.1.1",
"connect-typeorm": "^2.0.0",
Expand Down Expand Up @@ -120,6 +122,7 @@
"@types/cache-manager-redis-store": "^2.0.0",
"@types/chai": "^4.3.0",
"@types/chai-as-promised": "^7.1.5",
"@types/command-exists": "^1.2.0",
"@types/cookie-parser": "^1.4.2",
"@types/express": "^4.17.13",
"@types/express-session": "^1.17.4",
Expand Down
29 changes: 12 additions & 17 deletions src/Action/SubmissionAction/FlairAction.ts
Expand Up @@ -30,30 +30,25 @@ export class FlairAction extends Action {
async process(item: Comment | Submission, ruleResults: RuleResultEntity[], actionResults: ActionResultEntity[], options: runCheckOptions): Promise<ActionProcessResult> {
const dryRun = this.getRuntimeAwareDryrun(options);
let flairParts = [];
if(this.text !== '') {
flairParts.push(`Text: ${this.text}`);
}
if(this.css !== '') {
flairParts.push(`CSS: ${this.css}`);
}
if(this.flair_template_id !== '') {
flairParts.push(`Template: ${this.flair_template_id}`);
}
const renderedText = this.text === '' ? '' : await this.renderContent(this.text, item, ruleResults, actionResults) as string;
flairParts.push(`Text: ${renderedText === '' ? '(None)' : renderedText}`);

const renderedCss = this.css === '' ? '' : await this.renderContent(this.css, item, ruleResults, actionResults) as string;
flairParts.push(`CSS: ${renderedCss === '' ? '(None)' : renderedCss}`);

flairParts.push(`Template: ${this.flair_template_id === '' ? '(None)' : this.flair_template_id}`);

const flairSummary = flairParts.length === 0 ? 'No flair (unflaired)' : flairParts.join(' | ');
this.logger.verbose(flairSummary);
if (item instanceof Submission) {
if(!this.dryRun) {
if (this.flair_template_id) {
// typings are wrong for this function, flair_template_id should be accepted
// assignFlair uses /api/flair (mod endpoint)
// selectFlair uses /api/selectflair (self endpoint for user to choose their own flair for submission)
// @ts-ignore
await item.assignFlair({flair_template_id: this.flair_template_id}).then(() => {});
await item.selectFlair({flair_template_id: this.flair_template_id}).then(() => {});
item.link_flair_template_id = this.flair_template_id;
} else {
await item.assignFlair({text: this.text, cssClass: this.css}).then(() => {});
item.link_flair_css_class = this.css;
item.link_flair_text = this.text;
await item.assignFlair({text: renderedText, cssClass: renderedCss}).then(() => {});
item.link_flair_css_class = renderedCss;
item.link_flair_text = renderedText;
}
await this.resources.resetCacheForItem(item);
}
Expand Down

0 comments on commit a891e2d

Please sign in to comment.