Skip to content

Commit

Permalink
Merge pull request #54 from corenting/feat/better-flairs
Browse files Browse the repository at this point in the history
feat: update flair display logic
  • Loading branch information
corenting committed Jun 14, 2023
2 parents 17709f1 + 75ef4ff commit 50bd05b
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 100 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

![Build](https://img.shields.io/github/actions/workflow/status/corenting/eddrit/ci.yml?branch=master) ![License](https://img.shields.io/github/license/corenting/eddrit) ![Codecov](https://img.shields.io/codecov/c/github/corenting/eddrit)

An alternative frontend for Reddit, written with Python + [Starlette](https://www.starlette.io/). Inspired by [Nitter](https://github.com/zedeus/nitter), an alternative frontend for Twitter
An alternative frontend for Reddit, written with Python + [Starlette](https://www.starlette.io/). Inspired by [Nitter](https://github.com/zedeus/nitter), an alternative frontend for Twitter.

- Lightweight
- No ads
- Compact design (closer to [old.reddit.com](https://old.reddit.com) than to the redesign)
- Mobile support (responsive design)
- Use the old `.json` APIs, no need to register for an OAuth2 identifier
- Mobile support
- Use the old `.json` APIs, no need to register for an OAuth2 identifier for self-hosting

Official instance: [eddrit.com](https://eddrit.com)

## Screenshots

Expand All @@ -20,12 +22,15 @@ An alternative frontend for Reddit, written with Python + [Starlette](https://ww

### Docker

A Docker image is available on [Docker Hub](https://hub.docker.com/r/corentingarcia/eddrit).
A Docker image is available on [Docker Hub](https://hub.docker.com/r/corentingarcia/eddrit) and on [ghcr.io](https://github.com/corenting/eddrit/pkgs/container/eddrit).

There are multiple tags:
- `latest` for the latest stable tagged release
- `master` for the latest commit on the master branch
- `dev` for the latest commit on the master branch
- Version tags (like `0.1.1`, `0.1.2`) for specific versions

The image supports linux/amd64 or linux/arm64 architectures.

### Without Docker

You can run the app with gunicorn directly :
Expand Down
2 changes: 1 addition & 1 deletion eddrit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from loguru import logger
from eddrit import config

__version__ = "0.5.5"
__version__ = "0.5.6"

logger.remove()
logger.add(sys.stderr, level=config.LOG_LEVEL)
12 changes: 4 additions & 8 deletions eddrit/reddit/content_parser/flair.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
def get_post_flair(api_post_data: Dict[Hashable, Any]) -> Optional[models.Flair]:
flair_components = []

# Background color
# Colors
text_color = (
"black" if api_post_data["link_flair_text_color"] == "dark" else "white"
)
bg_color = api_post_data["link_flair_background_color"]
if not bg_color or bg_color == "#ffffff":
bg_color = "#6495ED"

# Text color
text_color = api_post_data["link_flair_text_color"]
if not text_color:
text_color = "#ffffff"

if api_post_data.get("is_original_content", False):
flair_components.append(
Expand Down
144 changes: 72 additions & 72 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "eddrit"
version = "0.5.5"
version = "0.5.6"
description = "Alternative Reddit frontend"
authors = ["corenting <corenting@gmail.com>"]
license = "MIT"
Expand All @@ -16,7 +16,7 @@ Jinja2 = "^3.1.2"
loguru = "^0.7.0"
lxml = "^4.9.2"
python-multipart = "^0.0.6"
starlette = "^0.27.0"
starlette = "^0.28.0"
timeago = "^1.0.16"
tldextract = "^3.4.1"
uvicorn = {version = "^0.22.0", extras = ["standard"]}
Expand Down
8 changes: 2 additions & 6 deletions static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,8 @@ html[data-theme='dark'] .dark-inverted {
width: fit-content;
}

.post-flair-spoiler {
background-color: darkred;
}

.post-flair-text {
mix-blend-mode: difference;
.post-flair-warning {
background-color: red;
}

.post-flair-icon {
Expand Down
4 changes: 2 additions & 2 deletions templates/macros/common.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% macro render_flair(flair) %}
{% if flair %}
<span class="post-flair" style="background-color: {{ flair.background_color }};">
<span class="post-flair" style="color: {{ flair.text_color }}; background-color: {{ flair.background_color }};">
{% for item in flair.components %}
{% if item.type.value == 'text' %}
<span class="post-flair-text">
<span>
{{ item.content | safe }}
</span>
{% elif item.type.value == 'emoji' %}
Expand Down
6 changes: 2 additions & 4 deletions templates/macros/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

{% macro render_warning_flair(is_enabled, text) %}
{% if is_enabled %}
<span class="post-flair post-flair-spoiler">
<span>
{{ text }}
</span>
<span class="post-flair post-flair-warning">
{{ text }}
</span>
{% endif %}
{% endmacro %}
Expand Down

0 comments on commit 50bd05b

Please sign in to comment.