Skip to content

Commit

Permalink
Add linux
Browse files Browse the repository at this point in the history
  • Loading branch information
TaYaKi71751 committed Dec 10, 2023
1 parent 97fbe6a commit c8beaca
Show file tree
Hide file tree
Showing 49 changed files with 1,332 additions and 157 deletions.
77 changes: 69 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ jobs:
python-version: '3.8'
- name: Preprocess
run: |
cd lib/server
wget -q ${{ secrets.SECRET_SALT }}
wget -q ${{ secrets.SECRET_WSALT }}
cd ../..
# cd lib/server
# wget -q ${{ secrets.SECRET_SALT }}
# wget -q ${{ secrets.SECRET_WSALT }}
# cd ../..
cat >> lib/server/salt.dart << EOF
String getValid(foo) {return foo;}
EOF
cat >> lib/server/wsalt.dart << EOF
String getValid(foo) {return foo;}
EOF
python3 preprocess-ios.py
- name: Podfile
run: |
Expand All @@ -48,6 +54,55 @@ jobs:
name: ipa-build
path: Payload.ipa

# https://github.com/AppImageCrafters/appimage-builder-flutter-example/blob/main/.github/workflows/appimage.yml
linux-build:
runs-on: Ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
# with:
# flutter-version: '1.22.4'
- run: flutter channel beta
- run: flutter upgrade
- run: flutter config --enable-linux-desktop
- name: "Install dependencies"
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build build-essential pkg-config curl file git unzip xz-utils zip libgtk-3-dev
- name: Build flutter app
run: |
# cd lib/server
# wget -q ${{ secrets.SECRET_SALT }}
# wget -q ${{ secrets.SECRET_WSALT }}
# cd ../..
python3 preprocess-linux.py
cat << EOF > lib/server/salt.dart
String getValid(foo) {return foo;}
EOF
cat << EOF > lib/server/wsalt.dart
String getValid(foo) {return foo;}
EOF
flutter build linux
- name: Build AppImage unsing appimage-builder
uses: docker://appimagecrafters/appimage-builder:0.8.5
with:
entrypoint: appimage-builder
args: --recipe ./AppImageBuilder.yml --skip-test
- name: Save build Artifact
uses: actions/upload-artifact@v2
with:
name: AppImage
path: './*.AppImage*'
- name: Release AppImage
uses: marvinpinto/action-automatic-releases@latest
with:
title: Continuous build
automatic_release_tag: 'continuous'
prerelease: true
draft: false
files: './*.AppImage*'
repo_token: ${{ secrets.GITHUB_TOKEN }}

android-build:
runs-on: ubuntu-latest
steps:
Expand All @@ -66,10 +121,16 @@ jobs:
python-version: '3.8'
- name: Preprocess
run: |
cd lib/server
wget -q ${{ secrets.SECRET_SALT }}
wget -q ${{ secrets.SECRET_WSALT }}
cd ../..
# 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: |
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ migrate_working_dir/
.pub-cache/
.pub/
/build/
/AppDir/
*.AppImage
*.appimage

# Web related
lib/generated_plugin_registrant.dart
Expand Down Expand Up @@ -62,4 +65,4 @@ emulator.bat
img/*
test/db
test/*.7z
test/rawdata-korean
test/rawdata-korean
16 changes: 8 additions & 8 deletions .metadata
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
# This file should be version controlled and should not be manually edited.

version:
revision: 18a827f3933c19f51862dde3fa472197683249d6
channel: stable
revision: "7f20e5d18ce4cb80c621533090a7c5113f5bdc52"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 18a827f3933c19f51862dde3fa472197683249d6
base_revision: 18a827f3933c19f51862dde3fa472197683249d6
- platform: windows
create_revision: 18a827f3933c19f51862dde3fa472197683249d6
base_revision: 18a827f3933c19f51862dde3fa472197683249d6
create_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52
base_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52
- platform: linux
create_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52
base_revision: 7f20e5d18ce4cb80c621533090a7c5113f5bdc52

# User provided section

Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"files.associations": {
"ostream": "cpp"
}
},
"java.compile.nullAnalysis.mode": "disabled"
}
76 changes: 76 additions & 0 deletions AppImageBuilder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# appimage-builder recipe see https://appimage-builder.readthedocs.io for details
version: 1
script:
- rm -rf AppDir || true
- cp -r build/linux/x64/release/bundle AppDir
- mkdir -p AppDir/usr/share/icons/hicolor/64x64/apps/
- cp assets/images/logo.png AppDir/usr/share/icons/hicolor/64x64/apps/
AppDir:
path: ./AppDir
app_info:
id: xyz.project.violet
name: Violet
icon: logo
version: latest
exec: violet
exec_args: $@
apt:
arch: amd64
allow_unauthenticated: true
sources:
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal main restricted
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal universe
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal multiverse
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
- sourceline: deb http://security.ubuntu.com/ubuntu focal-security main restricted
- sourceline: deb http://security.ubuntu.com/ubuntu focal-security universe
- sourceline: deb http://security.ubuntu.com/ubuntu focal-security multiverse
include:
- libgtk-3-0
exclude:
- humanity-icon-theme
- hicolor-icon-theme
- adwaita-icon-theme
- ubuntu-mono
files:
include:
- lib/*.so
- data
exclude:
- usr/share/man
- usr/share/doc/*/README.*
- usr/share/doc/*/changelog.*
- usr/share/doc/*/NEWS.*
- usr/share/doc/*/TODO.*
runtime:
env:
GIO_MODULE_DIR: $APPDIR/usr/lib/x86_64-linux-gnu/gio/modules/
test:
fedora:
image: appimagecrafters/tests-env:fedora-30
command: ./violet
use_host_x: true
debian:
image: appimagecrafters/tests-env:debian-stable
command: ./violet
use_host_x: true
arch:
image: appimagecrafters/tests-env:archlinux-latest
command: ./violet
use_host_x: true
centos:
image: appimagecrafters/tests-env:centos-7
command: ./violet
use_host_x: true
ubuntu:
image: appimagecrafters/tests-env:ubuntu-xenial
command: ./violet
use_host_x: true
AppImage:
arch: x86_64
update-information: guess
sign-key: None

Binary file added assets/db/null.db
Binary file not shown.
9 changes: 9 additions & 0 deletions lib/checker/checker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ class VioletChecker {
var dbPath = Platform.isAndroid
? '${(await getApplicationDocumentsDirectory()).path}/data/data.db'
: '${await getDatabasesPath()}/data.db';
if(Platform.isLinux){
var home = '';
Platform.environment.forEach((key, value) {
if(key == 'HOME'){
home = value;
}
});
dbPath = '${home}/.violet/data.db'
}

//
// 1. check file exists
Expand Down
13 changes: 7 additions & 6 deletions lib/component/eh/eh_headers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
import 'package:http/http.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:violet/network/wrapper.dart' as http;
import 'package:violet/settings/settings.dart';

class EHSession {
static EHSession? tryLogin(String id, String pass) {
return null;
}

static Future<String> requestString(String url) async {
final prefs = await SharedPreferences.getInstance();
var cookie = prefs.getString('eh_cookies');
final prefs = await MultiPreferences.getInstance();
var cookie = await prefs.getString('eh_cookies');
return (await http.get(url, headers: {'Cookie': cookie ?? ''})).body;
}

static Future<String?> requestRedirect(String url) async {
final prefs = await SharedPreferences.getInstance();
var cookie = prefs.getString('eh_cookies');
final prefs = await MultiPreferences.getInstance();
var cookie = await prefs.getString('eh_cookies');
Request req = Request('Get', Uri.parse(url))..followRedirects = false;
req.headers['Cookie'] = cookie ?? '';
Client baseClient = Client();
Expand All @@ -27,8 +28,8 @@ class EHSession {
}

static Future<String> postComment(String url, String content) async {
final prefs = await SharedPreferences.getInstance();
var cookie = prefs.getString('eh_cookies');
final prefs = await MultiPreferences.getInstance();
var cookie = await prefs.getString('eh_cookies');
return (await http.post(url,
headers: {'Cookie': cookie ?? ''},
body: 'commenttext_new=${Uri.encodeFull(content)}'))
Expand Down
4 changes: 2 additions & 2 deletions lib/component/eh/eh_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class EHentaiImageProvider extends VioletImageProvider {

@override
Future<Map<String, String>> getHeader(int page) async {
final prefs = await SharedPreferences.getInstance();
var cookie = prefs.getString('eh_cookies');
final prefs = await MultiPreferences.getInstance();
var cookie = await prefs.getString('eh_cookies');
return {'Cookie': cookie ?? ''};
}

Expand Down
2 changes: 1 addition & 1 deletion lib/component/hentai.dart
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class HentaiManager {
'https://e${exh ? 'x' : '-'}hentai.org/?page=$page&f_cats=993&f_search=$search&advsearch=1&f_sname=on&f_stags=on&f_sh=on&f_spf=&f_spt=';

final cookie =
(await SharedPreferences.getInstance()).getString('eh_cookies') ?? '';
(await (await MultiPreferences.getInstance()).getString('eh_cookies')) ?? '';
final html =
(await http.get(url, headers: {'Cookie': '$cookie;sl=dm_2'})).body;

Expand Down
22 changes: 19 additions & 3 deletions lib/database/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,19 @@ class DataBaseManager {
if (Platform.environment.containsKey('FLUTTER_TEST')) {
dbPath = join(Directory.current.path, 'test/db/data.db');
} else {
dbPath = Platform.isAndroid
? '${(await getApplicationDocumentsDirectory()).path}/data/data.db'
: '${await getDatabasesPath()}/data.db';
if(Platform.isAndroid || Platform.isIOS){
dbPath = Platform.isAndroid
? '${(await getApplicationDocumentsDirectory()).path}/data/data.db'
: '${await getDatabasesPath()}/data.db';
} else if(Platform.isLinux){
var home = '';
Platform.environment.forEach((key, value) {
if(key == 'HOME'){
home = value;
}
});
dbPath = '${home}/.violet/data.db';
}
}
_instance = create(dbPath);
await _instance!.open();
Expand Down Expand Up @@ -63,25 +73,29 @@ class DataBaseManager {
List<Map<String, dynamic>> result = [];
await checkOpen();
result = await db!.rawQuery(str);
await db!.close();
return result;
}

Future<void> execute(String str) async {
await checkOpen();
await db!.execute(str);
await db!.close();
}

Future<int> insert(String name, Map<String, dynamic> wh) async {
int result = -1;
await checkOpen();
result = await db!.insert(name, wh);
await db!.close();
return result;
}

Future<void> update(String name, Map<String, dynamic> wh, String where,
List<dynamic> args) async {
await checkOpen();
await db!.update(name, wh, where: where, whereArgs: args);
await db!.close();
}

Future<void> swap(String name, String key, String what, int key1, int key2,
Expand All @@ -91,11 +105,13 @@ class DataBaseManager {
await txn.rawUpdate('UPDATE $name SET $what=? WHERE $key=?', [s2, key1]);
await txn.rawUpdate('UPDATE $name SET $what=? WHERE $key=?', [s1, key2]);
});
await db!.close();
}

Future<void> delete(String name, String where, List<dynamic> args) async {
await checkOpen();
await db!.delete(name, where: where, whereArgs: args);
await db!.close();
}

Future<bool> test() async {
Expand Down
Loading

0 comments on commit c8beaca

Please sign in to comment.