Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
258 changes: 129 additions & 129 deletions .github/workflows/instances.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: instances
name: instances

on:
push:
branches:
Expand All @@ -12,28 +12,28 @@ permissions:

jobs:
instances:
name: Instances
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Query Instances
run: |
# Query the list of Lemmy instances
curl -H 'Content-Type: application/json' -X POST \
-d '{"query": "query {nodes(softwarename: \"lemmy\") {domain active_users_monthly}}"}' https://api.fediverse.observer 2> /dev/null | \
jq -r '.data.nodes | .[] | select(.active_users_monthly > 50) | .domain' | sort | uniq -i > lemmy-instances.txt
# Query the list of PieFed instances
curl -H 'Content-Type: application/json' -X POST \
-d '{"query": "query {nodes(softwarename: \"piefed\") {domain active_users_monthly}}"}' https://api.fediverse.observer 2> /dev/null | \
jq -r '.data.nodes | .[] | select(.active_users_monthly > 50) | .domain' | sort | uniq -i > piefed-instances.txt
# Combine both lemmy and piefed instances into a single sorted list for Android/Safari
cat lemmy-instances.txt piefed-instances.txt | sort | uniq -i > instances.txt
# Convert to a dart file with a map of domain -> platform
name: Instances
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Query Instances
run: |
# Query the list of Lemmy instances
curl -H 'Content-Type: application/json' -X POST \
-d '{"query": "query {nodes(softwarename: \"lemmy\") {domain active_users_monthly}}"}' https://api.fediverse.observer 2> /dev/null | \
jq -r '.data.nodes | .[] | select(.active_users_monthly > 50) | .domain' | sort | uniq -i > lemmy-instances.txt

# Query the list of PieFed instances
curl -H 'Content-Type: application/json' -X POST \
-d '{"query": "query {nodes(softwarename: \"piefed\") {domain active_users_monthly}}"}' https://api.fediverse.observer 2> /dev/null | \
jq -r '.data.nodes | .[] | select(.active_users_monthly > 50) | .domain' | sort | uniq -i > piefed-instances.txt

# Combine both lemmy and piefed instances into a single sorted list for Android/Safari
cat lemmy-instances.txt piefed-instances.txt | sort | uniq -i > instances.txt

# Convert to a dart file with a map of domain -> platform
cat << EOF > lib/src/features/instance/data/constants/known_instances.dart
import 'package:thunder/src/foundation/primitives/primitives.dart';

Expand All @@ -42,109 +42,109 @@ jobs:
$(awk '{ print " \047"$0"\047: ThreadiversePlatform.piefed," }' piefed-instances.txt)
};
EOF
# Put the instances in the Android manifest file
manifestInstances="$(awk '{ print " <data android:host=\""$0"\" />" }' instances.txt)"
inSection=false
while IFS= read -r line; do
if [[ $line == *"#AUTO_GEN_INSTANCE_LIST_DO_NOT_TOUCH#"* ]]; then
inSection=true
fi
if [[ $line == *"#INSTANCE_LIST_END#"* ]]; then
echo "$manifestInstances" >> android/app/src/main/AndroidManifest-new.xml
inSection=false
fi
if [[ $line == *"android:host"* ]]; then
if [ "$inSection" = true ]; then
continue
fi
fi
echo "$line" >> android/app/src/main/AndroidManifest-new.xml
done < android/app/src/main/AndroidManifest.xml
mv android/app/src/main/AndroidManifest-new.xml android/app/src/main/AndroidManifest.xml
# ---------- Safari Extension ----------
totalLines=$(wc -l < instances.txt)
currentLine=0
safariManifestInstances=""
safariContentInstances=""
# Generate the Safari extension domains used in manifest.json and content.js
# It ignores the last comma in the list to generate proper json
while IFS= read -r instance; do
currentLine=$((currentLine + 1))
if [ "$currentLine" -eq 1 ]; then
# First line
safariManifestInstances=" \"*://$instance/*\""
safariContentInstances=" \"$instance\""
elif [ "$currentLine" -eq "$totalLines" ]; then
# Last line
safariManifestInstances="$safariManifestInstances,\n \"*://$instance/*\"\n"
safariContentInstances="$safariContentInstances,\n \"$instance\"\n"
else
safariManifestInstances="$safariManifestInstances,\n \"*://$instance/*\""
safariContentInstances="$safariContentInstances,\n \"$instance\""
fi
done < instances.txt
# Generates the new manifest.json with the updated instances
inSection=false
while IFS= read -r line; do
if [[ $line == *"matches\": ["* ]]; then
inSection=true
fi
if [[ $line == " ]" ]]; then
printf "$safariManifestInstances" >> "ios/Open In Thunder/Resources/manifest-new.json"
inSection=false
fi
if [[ $line == *"*://"* ]]; then
if [ "$inSection" = true ]; then
continue
fi
fi
echo "$line" >> "ios/Open In Thunder/Resources/manifest-new.json"
done < "ios/Open In Thunder/Resources/manifest.json"
mv "ios/Open In Thunder/Resources/manifest-new.json" "ios/Open In Thunder/Resources/manifest.json"
# Generates the new content.js with the updated instances
inSection=false
while IFS= read -r line; do
if [[ $line == *"let instances = ["* ]]; then
inSection=true
fi
if [[ $line == "];" ]]; then
printf "$safariContentInstances" >> "ios/Open In Thunder/Resources/content-new.js"
inSection=false
fi
if [[ $line == *" \""* ]]; then
if [ "$inSection" = true ]; then
continue
fi
fi
echo "$line" >> "ios/Open In Thunder/Resources/content-new.js"
done < "ios/Open In Thunder/Resources/content.js"
mv "ios/Open In Thunder/Resources/content-new.js" "ios/Open In Thunder/Resources/content.js"
# Clean up temporary txt files
rm lemmy-instances.txt piefed-instances.txt instances.txt
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6.0.1
with:
commit-message: Update instances
title: Update instances

# Put the instances in the Android manifest file
manifestInstances="$(awk '{ print " <data android:host=\""$0"\" />" }' instances.txt)"
inSection=false
while IFS= read -r line; do
if [[ $line == *"#AUTO_GEN_INSTANCE_LIST_DO_NOT_TOUCH#"* ]]; then
inSection=true
fi

if [[ $line == *"#INSTANCE_LIST_END#"* ]]; then
echo "$manifestInstances" >> android/app/src/main/AndroidManifest-new.xml
inSection=false
fi

if [[ $line == *"android:host"* ]]; then
if [ "$inSection" = true ]; then
continue
fi
fi

echo "$line" >> android/app/src/main/AndroidManifest-new.xml
done < android/app/src/main/AndroidManifest.xml
mv android/app/src/main/AndroidManifest-new.xml android/app/src/main/AndroidManifest.xml

# ---------- Safari Extension ----------
totalLines=$(wc -l < instances.txt)
currentLine=0

safariManifestInstances=""
safariContentInstances=""

# Generate the Safari extension domains used in manifest.json and content.js
# It ignores the last comma in the list to generate proper json
while IFS= read -r instance; do
currentLine=$((currentLine + 1))

if [ "$currentLine" -eq 1 ]; then
# First line
safariManifestInstances=" \"*://$instance/*\""
safariContentInstances=" \"$instance\""
elif [ "$currentLine" -eq "$totalLines" ]; then
# Last line
safariManifestInstances="$safariManifestInstances,\n \"*://$instance/*\"\n"
safariContentInstances="$safariContentInstances,\n \"$instance\"\n"
else
safariManifestInstances="$safariManifestInstances,\n \"*://$instance/*\""
safariContentInstances="$safariContentInstances,\n \"$instance\""
fi
done < instances.txt

# Generates the new manifest.json with the updated instances
inSection=false
while IFS= read -r line; do
if [[ $line == *"matches\": ["* ]]; then
inSection=true
fi

if [[ $line == " ]" ]]; then
printf "$safariManifestInstances" >> "ios/Open In Thunder/Resources/manifest-new.json"
inSection=false
fi

if [[ $line == *"*://"* ]]; then
if [ "$inSection" = true ]; then
continue
fi
fi

echo "$line" >> "ios/Open In Thunder/Resources/manifest-new.json"
done < "ios/Open In Thunder/Resources/manifest.json"
mv "ios/Open In Thunder/Resources/manifest-new.json" "ios/Open In Thunder/Resources/manifest.json"

# Generates the new content.js with the updated instances
inSection=false
while IFS= read -r line; do
if [[ $line == *"let instances = ["* ]]; then
inSection=true
fi

if [[ $line == "];" ]]; then
printf "$safariContentInstances" >> "ios/Open In Thunder/Resources/content-new.js"
inSection=false
fi

if [[ $line == *" \""* ]]; then
if [ "$inSection" = true ]; then
continue
fi
fi

echo "$line" >> "ios/Open In Thunder/Resources/content-new.js"
done < "ios/Open In Thunder/Resources/content.js"
mv "ios/Open In Thunder/Resources/content-new.js" "ios/Open In Thunder/Resources/content.js"

# Clean up temporary txt files
rm lemmy-instances.txt piefed-instances.txt instances.txt

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6.0.1
with:
commit-message: Update instances
title: Update instances
body: This PR is updating `known_instances.dart`, `AndroidManifest.xml`, `manifest.json` and `content.js` with the latest list of Lemmy and PieFed instances retrieved from fediverse.observer.
branch: update-instances
delete-branch: true
author: GitHub <noreply@github.com>
branch: update-instances
delete-branch: true
author: GitHub <noreply@github.com>
3 changes: 3 additions & 0 deletions android/app/src/development/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:usesCleartextTraffic="true" />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="user"/>
<certificates src="system"/>
</trust-anchors>
</base-config>
</network-security-config>
16 changes: 8 additions & 8 deletions fonts/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## How to Add Icons to Thunder Font
1. Go to https://www.fluttericon.com/, press the settings wrench, and import `config.json` from this directory.
2. Select any icons from that website or upload external ones.
3. Press Download in the top-right.
4. Extract the resulting zip file and...
* Update `Thunder.ttf` and `config.json` in this directory.
* Place `thunder_icons.dart` in `lib/thunder/`.
## How to Add Icons to Thunder Font

1. Go to https://www.fluttericon.com/, press the settings wrench, and import `config.json` from this directory.
2. Select any icons from that website or upload external ones.
3. Press Download in the top-right.
4. Extract the resulting zip file and...
* Update `Thunder.ttf` and `config.json` in this directory.
* Place `thunder_icon.dart` in `lib/packages/ui/src/icons/`.
16 changes: 16 additions & 0 deletions lib/packages/ui/src/icons/thunder_icon.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// ignore_for_file: constant_identifier_names

import 'package:flutter/widgets.dart';

/// Custom icon font constants for Thunder.
class ThunderIcon {
ThunderIcon._();

static const _kFontFam = 'Thunder';
static const String? _kFontPkg = null;

static const IconData microphone_variant = IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData shield = IconData(0xe803, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData shield_crown = IconData(0xe804, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData robot = IconData(0xf544, fontFamily: _kFontFam, fontPackage: _kFontPkg);
}
34 changes: 0 additions & 34 deletions lib/packages/ui/src/icons/thunder_icons.dart

This file was deleted.

Loading
Loading