Skip to content

Commit

Permalink
TEST
Browse files Browse the repository at this point in the history
  • Loading branch information
TaYaKi71751 committed Dec 11, 2023
1 parent b4a33c8 commit 00d098e
Show file tree
Hide file tree
Showing 17 changed files with 413 additions and 164 deletions.
170 changes: 85 additions & 85 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,53 @@ on:
merge_group:

jobs:
ios-build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
ref: dev
- uses: subosito/flutter-action@v2
with:
# flutter-version: '2.5.2'
channel: 'stable'
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Preprocess
run: |
# cd lib/server
# wget -q ${{ secrets.SECRET_SALT }}
# wget -q ${{ secrets.SECRET_WSALT }}
# cd ../..
cat << EOF > lib/server/salt.dart
String getValid(foo) {return foo;}
EOF
cat << EOF > lib/server/wsalt.dart
String getValid(foo) {return foo;}
EOF
python3 preprocess-ios.py
- name: Podfile
run: |
cd ios
rm Podfile.lock
flutter clean
flutter pub get
pod install
pod update
cd ..
- name: Build
run: |
flutter build ios --release --no-codesign
mkdir -p Payload
mv ./build/ios/iphoneos/Runner.app Payload
zip -r -y Payload.zip Payload/Runner.app
mv Payload.zip Payload.ipa
- name: Upload IPA
uses: actions/upload-artifact@v2
with:
name: ipa-build
path: Payload.ipa
# ios-build:
# runs-on: macos-latest
# steps:
# - uses: actions/checkout@v2
# with:
# ref: dev
# - uses: subosito/flutter-action@v2
# with:
# # flutter-version: '2.5.2'
# channel: 'stable'
# - uses: actions/setup-python@v2
# with:
# python-version: '3.8'
# - name: Preprocess
# run: |
# # cd lib/server
# # wget -q ${{ secrets.SECRET_SALT }}
# # wget -q ${{ secrets.SECRET_WSALT }}
# # cd ../..
# cat << EOF > lib/server/salt.dart
# String getValid(foo) {return foo;}
# EOF
# cat << EOF > lib/server/wsalt.dart
# String getValid(foo) {return foo;}
# EOF
# python3 preprocess-ios.py
# - name: Podfile
# run: |
# cd ios
# rm Podfile.lock
# flutter clean
# flutter pub get
# pod install
# pod update
# cd ..
# - name: Build
# run: |
# flutter build ios --release --no-codesign
# mkdir -p Payload
# mv ./build/ios/iphoneos/Runner.app Payload
# zip -r -y Payload.zip Payload/Runner.app
# mv Payload.zip Payload.ipa
# - name: Upload IPA
# uses: actions/upload-artifact@v2
# with:
# name: ipa-build
# path: Payload.ipa

# https://github.com/AppImageCrafters/appimage-builder-flutter-example/blob/main/.github/workflows/appimage.yml
linux-build:
Expand Down Expand Up @@ -103,41 +103,41 @@ jobs:
# files: './*.AppImage*'
# repo_token: ${{ secrets.GITHUB_TOKEN }}

android-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: dev
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
# flutter-version: '2.5.2'
channel: 'stable'
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Preprocess
run: |
# cd lib/server
# wget -q ${{ secrets.SECRET_SALT }}
# wget -q ${{ secrets.SECRET_WSALT }}
# cd ../..
cat << EOF > lib/server/salt.dart
String getValid(foo) {return foo;}
EOF
cat << EOF > lib/server/wsalt.dart
String getValid(foo) {return foo;}
EOF
python3 preprocess-android.py
- name: Build
run: |
flutter clean
flutter build apk --release
- name: Upload APK
uses: actions/upload-artifact@v2
with:
name: apk-build
path: ./build/app/outputs/apk/release/app-release.apk
# android-build:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# with:
# ref: dev
# - uses: actions/setup-java@v1
# with:
# java-version: '12.x'
# - uses: subosito/flutter-action@v1
# with:
# # flutter-version: '2.5.2'
# channel: 'stable'
# - uses: actions/setup-python@v2
# with:
# python-version: '3.8'
# - name: Preprocess
# run: |
# # cd lib/server
# # wget -q ${{ secrets.SECRET_SALT }}
# # wget -q ${{ secrets.SECRET_WSALT }}
# # cd ../..
# cat << EOF > lib/server/salt.dart
# String getValid(foo) {return foo;}
# EOF
# cat << EOF > lib/server/wsalt.dart
# String getValid(foo) {return foo;}
# EOF
# python3 preprocess-android.py
# - name: Build
# run: |
# flutter clean
# flutter build apk --release
# - name: Upload APK
# uses: actions/upload-artifact@v2
# with:
# name: apk-build
# path: ./build/app/outputs/apk/release/app-release.apk
9 changes: 5 additions & 4 deletions AppImageBuilder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: 1
script:
- rm -rf AppDir || true
- cp -r build/linux/x64/release/bundle AppDir
- cp -r build/linux/x64/release AppDir
- mkdir -p AppDir/usr/share/icons/hicolor/64x64/apps/
- cp assets/images/logo.png AppDir/usr/share/icons/hicolor/64x64/apps/
AppDir:
Expand All @@ -12,7 +12,7 @@ AppDir:
name: Violet
icon: logo
version: latest
exec: violet
exec: ./bundle/violet
exec_args: $@
apt:
arch: amd64
Expand All @@ -37,8 +37,9 @@ AppDir:
- ubuntu-mono
files:
include:
- lib/*.so
- data
- ./*
- bundle/lib/*.so
- bundle/data
exclude:
- usr/share/man
- usr/share/doc/*/README.*
Expand Down
16 changes: 14 additions & 2 deletions lib/checker/checker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,20 @@ class VioletChecker {
//
// 0. get database path
//
var dir = await getApplicationDocumentsDirectory();
var dbPath = '${dir.path}/user.db';
var dir;
if(Platform.isAndroid || Platform.isIOS){
var d = await getApplicationDocumentsDirectory();
dir = d.path;
} else if(Platform.isLinux){
var home = '';
Platform.environment.forEach((key, value) {
if(key == 'HOME'){
home = value;
}
});
dir = '${home}/.violet';
}
var dbPath = '${dir}/user.db';

//
// 1. check file exists
Expand Down
47 changes: 41 additions & 6 deletions lib/component/hitomi/hitomi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:tuple/tuple.dart';
import 'package:violet/algorithm/distance.dart';
import 'package:violet/component/hitomi/displayed_tag.dart';
import 'package:violet/component/hitomi/tag_translate.dart';
import 'package:violet/log/log.dart';
import 'package:violet/script/script_manager.dart';
import 'package:violet/settings/settings.dart';
import 'package:violet/variables.dart';
Expand All @@ -18,6 +19,7 @@ class HitomiManager {
// [Image List], [Big Thumbnail List (Perhaps only two are valid.)], [Small Thubmnail List]
static Future<Tuple3<List<String>, List<String>, List<String>>> getImageList(
String id) async {
Logger.info('[runHitomiGetImageList] id = ${id}');
final result = await ScriptManager.runHitomiGetImageList(int.parse(id));
if (result != null) return result;
return const Tuple3<List<String>, List<String>, List<String>>(
Expand All @@ -27,8 +29,18 @@ class HitomiManager {
static int? getArticleCount(String classification, String name) {
if (tagmap == null) {
final subdir = Platform.isAndroid ? '/data' : '';
final path =
File('${Variables.applicationDocumentsDirectory}$subdir/index.json');
late final path;
if(Platform.isAndroid || Platform.isIOS){
path = File('${Variables.applicationDocumentsDirectory}$subdir/index.json');
} else if(Platform.isLinux){
var home = '';
Platform.environment.forEach((key, value) {
if(key == 'HOME'){
home = value;
}
});
path = File('${home}/.violet$subdir/index.json');
}
final text = path.readAsStringSync();
tagmap = jsonDecode(text);
}
Expand All @@ -38,8 +50,18 @@ class HitomiManager {

static void reloadIndex() {
final subdir = Platform.isAndroid ? '/data' : '';
final path =
File('${Variables.applicationDocumentsDirectory}$subdir/index.json');
late final path;
if(Platform.isAndroid || Platform.isIOS){
path = File('${Variables.applicationDocumentsDirectory}$subdir/index.json');
} else if(Platform.isLinux){
var home = '';
Platform.environment.forEach((key, value) {
if(key == 'HOME'){
home = value;
}
});
path = File('${home}/.violet$subdir/index.json');
}
final text = path.readAsStringSync();
tagmap = jsonDecode(text);
}
Expand Down Expand Up @@ -81,8 +103,21 @@ class HitomiManager {
tagmap = jsonDecode(await file.readAsString());
} else {
final subdir = Platform.isAndroid ? '/data' : '';
final directory = await getApplicationDocumentsDirectory();
final path = File('${directory.path}$subdir/index.json');
late final directory;
late final path;
if(Platform.isAndroid || Platform.isIOS){
directory = await getApplicationDocumentsDirectory();
path = File('${directory.path}$subdir/index.json');
} else if(Platform.isLinux){
var home = '';
Platform.environment.forEach((key, value) {
if(key == 'HOME'){
home = value;
}
});
directory = '${home}/.violet';
path = File('${directory}$subdir/index.json');
}
final text = path.readAsStringSync();
tagmap = jsonDecode(text);
}
Expand Down
34 changes: 23 additions & 11 deletions lib/component/hitomi/indexs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,44 @@ class HitomiIndexs {
static late Map<String, dynamic> relatedTag;

static Future<void> init() async {
final directory = await getApplicationDocumentsDirectory();
late final directory;
if(Platform.isAndroid || Platform.isIOS){
var d = await getApplicationDocumentsDirectory();
directory = d.path;
} else if(Platform.isLinux){
var home = '';
Platform.environment.forEach((key, value) {
if(key == 'HOME'){
home = value;
}
});
directory = '${home}/.violet';
}
final subdir = Platform.isAndroid ? '/data' : '';

// No data on first run.
final path2 = File('${directory.path}$subdir/tag-artist.json');
final path2 = File('${directory}$subdir/tag-artist.json');
if (!await path2.exists()) return;
tagArtist = jsonDecode(await path2.readAsString());
final path3 = File('${directory.path}$subdir/tag-group.json');
final path3 = File('${directory}$subdir/tag-group.json');
tagGroup = jsonDecode(await path3.readAsString());
final path4 = File('${directory.path}$subdir/tag-index.json');
final path4 = File('${directory}$subdir/tag-index.json');
tagIndex = jsonDecode(await path4.readAsString());
final path5 = File('${directory.path}$subdir/tag-uploader.json');
final path5 = File('${directory}$subdir/tag-uploader.json');
tagUploader = jsonDecode(await path5.readAsString());
try {
final path6 = File('${directory.path}$subdir/tag-series.json');
final path6 = File('${directory}$subdir/tag-series.json');
tagSeries = jsonDecode(await path6.readAsString());
final path7 = File('${directory.path}$subdir/tag-character.json');
final path7 = File('${directory}$subdir/tag-character.json');
tagCharacter = jsonDecode(await path7.readAsString());
final path8 = File('${directory.path}$subdir/character-series.json');
final path8 = File('${directory}$subdir/character-series.json');
characterSeries = jsonDecode(await path8.readAsString());
final path9 = File('${directory.path}$subdir/series-character.json');
final path9 = File('${directory}$subdir/series-character.json');
seriesCharacter = jsonDecode(await path9.readAsString());

final path10 = File('${directory.path}$subdir/character-character.json');
final path10 = File('${directory}$subdir/character-character.json');
characterCharacter = jsonDecode(await path10.readAsString());
final path11 = File('${directory.path}$subdir/series-series.json');
final path11 = File('${directory}$subdir/series-series.json');
seriesSeries = jsonDecode(await path11.readAsString());
} catch (e, st) {
Logger.error('[Hitomi-Indexs] E: $e\n'
Expand Down
17 changes: 15 additions & 2 deletions lib/component/hitomi/series_finder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,21 @@ import 'package:violet/database/query.dart';
class SeriesFinder {
static Future<void> doFind1() async {
final subdir = Platform.isAndroid ? '/data' : '';
final directory = await getApplicationDocumentsDirectory();
final path = File('${directory.path}$subdir/index.json');
late final directory;
late final path;
if(Platform.isAndroid || Platform.isIOS){
directory = await getApplicationDocumentsDirectory();
path = File('${directory.path}$subdir/index.json');
} else if(Platform.isLinux){
var home = '';
Platform.environment.forEach((key, value) {
if(key == 'HOME'){
home = value;
}
});
directory = '${home}/.violet';
path = '${directory}$subdir/index.json';
}
final text = path.readAsStringSync();
final tagmap = jsonDecode(text);
final artists = tagmap['artist'] as Map<String, dynamic>;
Expand Down
Loading

0 comments on commit 00d098e

Please sign in to comment.