Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/bc/web/static_src/po…
Browse files Browse the repository at this point in the history
…stcss-8.4.31
  • Loading branch information
mlissner authored Mar 31, 2024
2 parents 2f817ac + d652272 commit 40e480c
Show file tree
Hide file tree
Showing 48 changed files with 1,837 additions and 418 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
!pyproject.toml
!docker
!manage.py
!scripts

# But no matter what, ignore these things.
bc/assets/static
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/bulid-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand All @@ -26,12 +26,12 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set shortcode
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
id: cp311
with:
python-version: "3.11"
Expand All @@ -31,7 +31,7 @@ jobs:

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-cache-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock')}}-v20210414
Expand Down Expand Up @@ -66,9 +66,9 @@ jobs:
lint-isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.9"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sentry-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
createSentryRelease:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Create a Sentry.io release
uses: getsentry/action-release@v1.4.1
uses: getsentry/action-release@v1.7.0
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: freelawproject
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
DB_PASSWORD: postgres
DB_NAME: bots
DB_HOST: localhost
REDIS_HOST: redis://localhost
services:
postgres:
image: postgres
Expand All @@ -24,11 +25,21 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports:
- 6379:6379
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.11
id: cp311
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'

Expand All @@ -44,7 +55,7 @@ jobs:

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-cache-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock')}}-v20210414
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ It costs a lot to build and maintain this system and we need your support.
[slack]: https://github.com/freelawproject/bigcases2/issues/10
[teams]: https://github.com/freelawproject/bigcases2/issues/41
[flp]: https://free.law/
[flpd]: https://free.law/donate/
[flpd]: https://donate.free.law/forms/supportflp
[bcb1]: https://github.com/bdheath/Big-Cases
[c]: https://free.law/contact/
[litte]: https://github.com/freelawproject/bigcases2/issues/8
4 changes: 3 additions & 1 deletion bc/assets/templates/includes/follow-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
<div class="h-6 w-6">
{% if service_name == 'Twitter' %}
{% include 'includes/inlines/twitter.svg' %}
{% else %}
{% elif service_name == 'Mastodon' %}
{% include 'includes/inlines/mastodon.svg' %}
{% elif service_name == 'Bluesky' %}
{% include 'includes/inlines/bluesky.svg' %}
{% endif %}
</div>
<div class="ml-3">
Expand Down
10 changes: 8 additions & 2 deletions bc/assets/templates/includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <H5>Other work</H5>
<div class="pb-3">
<H5>About FLP</H5>
{% include "./footer-link.html" with href="https://free.law/about/" text="Our Mission" %}
{% include "./footer-link.html" with href="https://free.law/donate/" text="Donate Now" %}
{% include "./footer-link.html" with href="https://donate.free.law/forms/supportflp" text="Donate Now" %}
{% include "./footer-link.html" with href="https://free.law/blog/" text="Follow the FLP Blog" %}
{% include "./footer-link.html" with href="https://free.law/contact/" text="Contact Us" %}
</div>
Expand All @@ -76,6 +76,12 @@ <H5>About FLP</H5>
<p> Follow us: </p>
</div>
<!-- Social media icons were downloaded from www.svgrepo.com -->
<a href="https://bsky.app/profile/free.law" class="rounded-full bg-gray-500 p-3" aria-label="Bluesky Link">
<div class="h-5 w-5 text-white">
{% include './inlines/bluesky.svg' %}
</div>
</a>

<a rel="me" href="https://law.builders/@flp" class="rounded-full bg-gray-500 p-3" aria-label="Mastodon Link">
<div class="h-5 w-5 text-white">
{% include './inlines/mastodon.svg' %}
Expand All @@ -88,7 +94,7 @@ <H5>About FLP</H5>
</div>
</a>

<a href="https://free.law/newsletter/" class="rounded-full bg-gray-500 p-3" aria-label="Newsletter Link">
<a href="https://donate.free.law/np/clients/freelawproject/subscribe.jsp?subscription=9" class="rounded-full bg-gray-500 p-3" aria-label="Newsletter Link">
<div class="w-5 h-5 stroke-white">
{% include './inlines/newspaper.svg' %}
</div>
Expand Down
32 changes: 24 additions & 8 deletions bc/assets/templates/includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@
</div>
</div>
<div class="grid grid-cols-1 gap-2">
<a href="https://free.law/donate/" aria-label="Donate" class="w-full flex items-center justify-center px-4 py-2 border border-transparent rounded-md shadow-sm font-medium text-sm no-underline text-bcb-black bg-saffron-400 hover:bg-saffron-500">
<a href="https://donate.free.law/forms/supportflp" aria-label="Donate" class="w-full flex items-center justify-center px-4 py-2 border border-transparent rounded-md shadow-sm font-medium text-sm no-underline text-bcb-black bg-saffron-400 hover:bg-saffron-500">
&nbsp;Donate
</a>
<a rel="me" href="https://law.builders/@bigcases" aria-label="Mastodon" class="w-full flex items-center justify-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium border-gray-500">
<a href="https://bsky.app/profile/bigcases.bots.law" aria-label="Bluesky" class="w-full flex items-center justify-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium border-gray-500">
<div class="h-6 w-6 text-gray-400 pr-1">
{% include './inlines/bluesky.svg' %}
</div>
Follow on Bluesky
</a>
<a rel="me" href="https://law.builders/@bigcases" aria-label="Mastodon" class="w-full flex p-3 items-center justify-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium border-gray-500">
<div class="h-6 w-6 text-gray-400">
{% include './inlines/mastodon.svg' %}
</div>
Expand Down Expand Up @@ -74,7 +80,7 @@
</div>
</button>
<div class="absolute top-16 -translate-x-8 xl:-translate-x-32 z-50">
<div id="dropdown" class="z-10 bg-white hidden divide-y divide-gray-100 rounded-lg shadow-lg ring-1 ring-black ring-opacity-5 overflow-hidden max-w-xs md:w-screen lg:max-w-md">
<div id="dropdown" class="z-10 bg-white hidden divide-y divide-gray-100 rounded-lg shadow-lg ring-1 ring-black ring-opacity-5 overflow-hidden sm:max-w-sm md:w-screen lg:max-w-md">
<div class="relative grid px-5 py-6 gap-4 text-sm text-gray-700 dark:text-gray-400 md:gap-8 sm:p-8" aria-labelledby="dropdownNavbarButton">
<a href="{% url 'big_cases_about' %}" class="flex items-start -m-3 p-3 hover:bg-gray-100" aria-label="About Me">
<div class="h-6 w-6 relative flex-shrink-0">
Expand All @@ -97,23 +103,33 @@
</a>
</div>
<div class="px-5 py-1 bg-gray-50 flex md:py-2 md:px-8">
<div class="w-1/2">
<div class="w-1/3">
<a href="https://bsky.app/profile/bigcases.bots.law" aria-label="Bluesky" class="flex p-3 items-center justify-center rounded-md hover:bg-gray-100">
<div class="h-5 w-5 text-gray-400">
{% include './inlines/bluesky.svg' %}
</div>
<div class="ml-3">
<p class="text-xs lg:text-sm xl:text-base text-center font-medium">Bluesky</p>
</div>
</a>
</div>
<div class="w-1/3">
<a rel="me" href="https://law.builders/@bigcases" aria-label="Mastodon" class="flex p-3 items-center justify-center rounded-md hover:bg-gray-100">
<div class="h-6 w-6 text-gray-400">
{% include './inlines/mastodon.svg' %}
</div>
<div class="ml-3">
<p class="text-sm xl:text-base text-center font-medium">Mastodon</p>
<p class="text-xs lg:text-sm xl:text-base text-center font-medium">Mastodon</p>
</div>
</a>
</div>
<div class="w-1/2">
<div class="w-1/3">
<a href="https://twitter.com/big_cases" aria-label="Twitter" class="flex p-3 items-center justify-center rounded-md hover:bg-gray-100">
<div class="h-6 w-6 text-gray-400">
{% include './inlines/twitter.svg' %}
</div>
<div class="ml-3">
<p class="text-sm xl:text-base text-center font-medium">Twitter</p>
<p class="text-xs lg:text-sm xl:text-base text-center font-medium">Twitter</p>
</div>
</a>
</div>
Expand All @@ -138,7 +154,7 @@

<div class="hidden md:flex items-center">
<div class="w-28 text-sm font-medium mr-1">
{% include './action-button.html' with link="https://free.law/donate/" text="Donate" size='sm' color='saffron' %}
{% include './action-button.html' with link="https://donate.free.law/forms/supportflp" text="Donate" size='sm' color='saffron' %}
</div>
{% if user.is_authenticated %}
<div class="w-28 text-sm font-medium sm:text-md">
Expand Down
1 change: 1 addition & 0 deletions bc/assets/templates/includes/inlines/bluesky.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.2.7 on 2023-12-03 16:15

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("channel", "0007_group_border_color"),
]

operations = [
migrations.AlterField(
model_name="channel",
name="service",
field=models.PositiveSmallIntegerField(
choices=[(1, "Twitter"), (2, "Mastodon"), (3, "Bluesky")],
help_text="Type of the service",
),
),
migrations.AlterField(
model_name="post",
name="object_id",
field=models.CharField(
help_text="The object's id returned by Twitter/Mastodon/etc's API"
),
),
]
32 changes: 20 additions & 12 deletions bc/channel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from bc.users.models import User

from .utils.connectors.base import BaseAPIConnector
from .utils.connectors.bluesky import BlueskyConnector
from .utils.connectors.masto import (
MastodonConnector,
get_server_url,
Expand Down Expand Up @@ -64,9 +65,11 @@ class Channel(AbstractDateTimeModel):

TWITTER = 1
MASTODON = 2
BLUESKY = 3
CHANNELS = (
(TWITTER, "Twitter"),
(MASTODON, "Mastodon"),
(BLUESKY, "Bluesky"),
)
service = models.PositiveSmallIntegerField(
help_text="Type of the service",
Expand Down Expand Up @@ -115,23 +118,28 @@ def get_api_wrapper(self) -> BaseAPIConnector:
return MastodonConnector(
self.access_token, get_server_url(self.account)
)
case self.BLUESKY:
return BlueskyConnector(self.account_id, self.access_token)
case _:
raise NotImplementedError(
f"No wrapper implemented for service: '{self.service}'."
)

def self_url(self):
if self.service == self.TWITTER:
return f"https://twitter.com/{self.account}"
elif self.service == self.MASTODON:
result = masto_regex.search(self.account)
assert len(result.groups()) == 2
account_part, instance_part = result.groups()
return f"https://{instance_part}/@{account_part}"
else:
raise NotImplementedError(
f"Channel.self_url() not yet implemented for service {self.service}"
)
match self.service:
case self.TWITTER:
return f"https://twitter.com/{self.account}"
case self.MASTODON:
result = masto_regex.search(self.account)
assert len(result.groups()) == 2
account_part, instance_part = result.groups()
return f"https://{instance_part}/@{account_part}"
case self.BLUESKY:
return f"https://bsky.app/profile/{self.account_id}"
case _:
raise NotImplementedError(
f"Channel.self_url() not yet implemented for service {self.service}"
)

def __str__(self) -> str:
if self.account:
Expand All @@ -148,7 +156,7 @@ class Post(AbstractDateTimeModel):
channel = models.ForeignKey(
"Channel", related_name="posts", on_delete=models.CASCADE
)
object_id = models.PositiveBigIntegerField(
object_id = models.CharField(
help_text="The object's id returned by Twitter/Mastodon/etc's API",
)
text = models.TextField(
Expand Down
6 changes: 4 additions & 2 deletions bc/channel/utils/connectors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from bc.core.utils.images import TextImage

from .bluesky_api.types import ImageBlob

ApiWrapper = Union[Mastodon, TwitterAPI]


Expand All @@ -25,7 +27,7 @@ def get_api_object(self, version: str | None = None) -> ApiWrapper:
"""
...

def upload_media(self, media: bytes, alt_text: str) -> int:
def upload_media(self, media: bytes, alt_text: str) -> int | ImageBlob:
"""
creates a media attachment to be used with a new status.
Expand All @@ -47,7 +49,7 @@ def add_status(
message: str,
text_image: TextImage | None = None,
thumbnails: list[bytes] | None = None,
) -> int:
) -> int | str:
"""
Creates a new status using the API wrapper object and returns the integer
representation of the identifier for the new status.
Expand Down
Loading

0 comments on commit 40e480c

Please sign in to comment.