Skip to content

Commit

Permalink
Merge pull request #67 from tgxn/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tgxn authored Oct 24, 2023
2 parents 2733ec1 + c35d86b commit f70b183
Show file tree
Hide file tree
Showing 17 changed files with 367 additions and 148 deletions.
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ RUN npm run build

# copy files to run container
FROM nginx:stable-alpine

# copy distribution from build step
COPY --from=build /app/dist /usr/share/nginx/html

# expose and start nginx
# install entrypoint script to /usr/local/bin/
RUN mkdir -p /usr/local/bin/
COPY ./scripts/docker-startup.sh /usr/local/bin/docker-startup.sh
RUN chmod 700 /usr/local/bin/docker-startup.sh

# expose and set entrypoint
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
ENTRYPOINT ["sh", "/usr/local/bin/docker-startup.sh"]
48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
- Filter by local instance actions
- Quick Switch Accounts on different Lemmy instances

## User Types

There are 3 types of users in Lemmy Modder: user, mod and `admin`

This is determined based on the amount of moderated communities you manage.



## Hosting Options

Expand All @@ -49,9 +56,32 @@ services:
restart: unless-stopped
ports:
- 9696:80
environment:
LOCK_DOMAIN: modder.example.com # optionally locks the domain that can be used with this instance
```
2. Bring up the new container `docker-compose up -d lemmy-modder`
2. Setup your reverse proxy to proxy requests for `modder.example.com` to the new container on port `80`.
3. Setup your reverse proxy to proxy requests for `modder.example.com` to the new container on port `80`.

If you use Traefik, the labels will be something like this:
```yaml
networks:
- traefik-net
labels:
- "traefik.enable=true"
- "traefik.docker.network=traefik-net"
- "traefik.http.services.lemmy_mod.loadbalancer.server.port=80"
# internet https
- "traefik.http.routers.lemmy_mod_https_net.rule=Host(`modder.example.com`)"
- "traefik.http.routers.lemmy_mod_https_net.entrypoints=https"
- "traefik.http.routers.lemmy_mod_https_net.tls.certResolver=SSL_RESOLVER"

# internet http redirect
- "traefik.http.routers.lemmy_mod_http_redirect_net.rule=Host(`modder.example.com`)"
- "traefik.http.routers.lemmy_mod_http_redirect_net.entrypoints=http"
- "traefik.http.routers.lemmy_mod_http_redirect_net.middlewares=redirect_https@file"
```
_There are no more steps, as there is no users or databases._
Expand Down Expand Up @@ -79,9 +109,23 @@ npm start
```
5. Open http://localhost:9696 in your browser
### Testing Docker Image
1. Build the docker image
```
docker build -t lemmy-modder:local .
```
2. Run the docker image _(with lock example)_
```
docker run --rm --env LOCK_DOMAIN="lemmy.tgxn.net" -p 9696:80 lemmy-modder:local
```
# Credits
Lemmy Devs https://github.com/LemmyNet
Lemmy Devs https://github.com/LemmyNet
Logo made by Andy Cuccaro (@andycuccaro) under the CC-BY-SA 4.0 license.
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<meta name="description" content="Moderation Tooling for Lemmy " />
<meta name="keywords" content="Lemmy, Social Data, Reddit" />
<meta name="author" content="https://github.com/tgxn/lemmy-modder" />

<script src="/runtime-config.js"></script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lemmy-modder-frontend",
"version": "1.2.1",
"version": "1.2.2",
"description": "Lemmy Moderation App",
"author": "tgxn",
"license": "MIT",
Expand Down
21 changes: 21 additions & 0 deletions scripts/docker-startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# load runtime configuration
LOCK_DOMAIN=${LOCK_DOMAIN:-""}

# store runtime configuration
RUNTIME_CONFIG_FILE=/usr/share/nginx/html/runtime-config.js
if [ -f $RUNTIME_CONFIG_FILE ]; then
rm $RUNTIME_CONFIG_FILE
fi

echo "$(cat <<EOM
// runtime-config.js
window['RuntimeConfig'] = {
DomainLock: "${LOCK_DOMAIN}"
};
EOM
)" > $RUNTIME_CONFIG_FILE

# Start Nginx (default entrypoint)
exec nginx -g "daemon off;"
2 changes: 2 additions & 0 deletions src/components/Actions/PostButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useSelector } from "react-redux";

import { useQueryClient } from "@tanstack/react-query";

import Typography from "@mui/joy/Typography";

import DoneAllIcon from "@mui/icons-material/DoneAll";

import { useLemmyHttpAction } from "../../hooks/useLemmyHttp.js";
Expand Down
2 changes: 2 additions & 0 deletions src/components/Actions/RegistrationButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { toast } from "sonner";
import { useSelector } from "react-redux";
import { useQueryClient } from "@tanstack/react-query";

import Typography from "@mui/joy/Typography";

import ThumbUpIcon from "@mui/icons-material/ThumbUp";
import ThumbDownIcon from "@mui/icons-material/ThumbDown";

Expand Down
24 changes: 12 additions & 12 deletions src/components/Activity/ModLogAccordians.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,33 @@ export default function ModLogAccordians({ modLogData }) {
if (modLogItem.type === "removed_posts") {
return <RemovedPostRow item={modLogItem} />;
}
if (modLogItem.type === "removed_comments") {
return <RemovedCommentRow item={modLogItem} />;
}
if (modLogItem.type === "banned_from_community") {
return <BannedFromCommunityRow item={modLogItem} />;
}
if (modLogItem.type === "locked_posts") {
return <LockedPostRow item={modLogItem} />;
}
if (modLogItem.type === "banned") {
return <BannedRow item={modLogItem} />;
}
if (modLogItem.type === "added_to_community") {
return <AddedToCommunityRow item={modLogItem} />;
}
if (modLogItem.type === "featured_posts") {
return <FeaturedPostRow item={modLogItem} />;
}
if (modLogItem.type === "removed_comments") {
return <RemovedCommentRow item={modLogItem} />;
}
if (modLogItem.type === "removed_communities") {
return <RemovedCommunityRow item={modLogItem} />;
}
if (modLogItem.type === "banned_from_community") {
return <BannedFromCommunityRow item={modLogItem} />;
}
if (modLogItem.type === "added_to_community") {
return <AddedToCommunityRow item={modLogItem} />;
}
if (modLogItem.type === "transferred_to_community") {
return <TransferredToCommunityRow item={modLogItem} />;
}
if (modLogItem.type === "added") {
return <AddedRow item={modLogItem} />;
}
if (modLogItem.type === "banned") {
return <BannedRow item={modLogItem} />;
}

return (
<Accordion>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Filters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function FilterCommunity() {
}}
>
<Option key="all" value="all">
All Communities
Show Everything
</Option>
{modCommms.map((community) => {
const { name, title } = community.community;
Expand Down
Loading

0 comments on commit f70b183

Please sign in to comment.