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 15eebaa
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 116 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
45 changes: 39 additions & 6 deletions lib/component/hitomi/hitomi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,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 +48,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 +101,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
1 change: 1 addition & 0 deletions lib/log/log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Logger {

if (!Platform.environment.containsKey('FLUTTER_TEST')) {
await lock.synchronized(() async {
await init();
await logFile.writeAsString('[${DateTime.now().toUtc()}] $msg\n',
mode: FileMode.append);
});
Expand Down
36 changes: 24 additions & 12 deletions lib/pages/database_download/database_download_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -662,30 +662,42 @@ class DataBaseDownloadPageState extends State<DataBaseDownloadPage> {
'class': classes,
};

final directory = await getApplicationDocumentsDirectory();
final path1 = File('${directory.path}/index.json');
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 path1 = File('${directory}/index.json');
path1.writeAsString(jsonEncode(index));

final path2 = File('${directory.path}/tag-artist.json');
final path2 = File('${directory}/tag-artist.json');
path2.writeAsString(jsonEncode(tagArtist));
final path3 = File('${directory.path}/tag-group.json');
final path3 = File('${directory}/tag-group.json');
path3.writeAsString(jsonEncode(tagGroup));
final path4 = File('${directory.path}/tag-index.json');
final path4 = File('${directory}/tag-index.json');
path4.writeAsString(jsonEncode(tagIndex));
final path5 = File('${directory.path}/tag-uploader.json');
final path5 = File('${directory}/tag-uploader.json');
path5.writeAsString(jsonEncode(tagUploader));
final path6 = File('${directory.path}/tag-series.json');
final path6 = File('${directory}/tag-series.json');
path6.writeAsString(jsonEncode(tagSeries));
final path7 = File('${directory.path}/tag-character.json');
final path7 = File('${directory}/tag-character.json');
path7.writeAsString(jsonEncode(tagCharacter));

final path8 = File('${directory.path}/character-series.json');
final path8 = File('${directory}/character-series.json');
path8.writeAsString(jsonEncode(characterSeries));
final path9 = File('${directory.path}/series-character.json');
final path9 = File('${directory}/series-character.json');
path9.writeAsString(jsonEncode(seriesCharacter));
final path10 = File('${directory.path}/character-character.json');
final path10 = File('${directory}/character-character.json');
path10.writeAsString(jsonEncode(characterCharacter));
final path11 = File('${directory.path}/series-series.json');
final path11 = File('${directory}/series-series.json');
path11.writeAsString(jsonEncode(seriesSeries));

setState(() {
Expand Down
3 changes: 3 additions & 0 deletions lib/script/script_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ class ScriptManager {
if (_scriptCache == null) return null;

try {
if(_runtime == null){
_initRuntime();
}
var downloadUrl =
_runtime.evaluate("create_download_url('$id')").stringResult;
var headers = await runHitomiGetHeaderContent(id.toString());
Expand Down

0 comments on commit 15eebaa

Please sign in to comment.