Skip to content

Commit

Permalink
Merge pull request #1 from MarcinOrlowski/dev
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
MarcinOrlowski authored Oct 6, 2024
2 parents a5f025f + 94ca024 commit d8e17b6
Show file tree
Hide file tree
Showing 15 changed files with 298 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ MANIFEST
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# *.spec

# Installer logs
pip-log.txt
Expand Down
3 changes: 2 additions & 1 deletion .markdownlint.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ MD033: false # MOR
# allowed_elements: []

# MD034/no-bare-urls - Bare URL used
MD034: true
MD034: false # MOR
#MD034: true

# MD035/hr-style - Horizontal rule style
MD035:
Expand Down
7 changes: 6 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@

---

* 1.1.0 (2024-10-06)
* Now allows only single instance per each profile to be run.
* Added `--minimized` option to start app minimized.
* Added `-t` as short form for `--no-tray` switch.

* 1.0.0 (2024-01-28)
* Initial release
* Initial release.
46 changes: 27 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

Run any website as standalone desktop application

[master](https://github.com/MarcinOrlowski/website-as-app/tree/master) branch:
[![Code lint](https://github.com/MarcinOrlowski/website-as-app/actions/workflows/linter.yml/badge.svg?branch=master)](https://github.com/MarcinOrlowski/website-as-app/actions/workflows/linter.yml)
[![MD Lint](https://github.com/MarcinOrlowski/website-as-app/actions/workflows/markdown.yml/badge.svg?branch=master)](https://github.com/MarcinOrlowski/website-as-app/actions/workflows/markdown.yml)
---

Small Python script opening any web page in dedicated window, using embedded QT WebEngine. There are
Expand All @@ -21,22 +18,23 @@ window manager or task switcher etc.
## Installation

Use `pip` to install the script system-wide:
I recommend you use [pipx](https://pipx.pypa.io/) to install this tool in isolated environment:

```bash
$ pip install website-as-app
$ pipx install website-as-app
```

If you want to use virtual environment (which is recommended):
You can also use plain `pip`:

```bash
$ python -m venv venv
$ source venv/bin/activate
$ pip install website-as-app
```
```

But that might be a problem on some distributions no longer allowing such installations, therefore
use of `pipx` is strongly recommended as the all-in-one solution.

Once app is running, please use `--help` to see all available options, as i.e. custom icon,
window title etc.
Once installed `webapp` executable (and its alias `runasapp`) should be available in your system.
Please use `--help` to see all available options, as i.e. custom icons, window title etc.

## Usage

Expand All @@ -46,7 +44,7 @@ When app is installed system-wide, you can run it from anywhere:
$ webapp "https://github.com"
```

If you are using virtual environment, there's handy Bash script in [extras/](extras/) directory
If you are using virtual environment, there's handy Bash script in `extras/` directory
which takes care of initializing virtual environment and running the app using that environment.
You simply use `extras/webapp.sh` script instead of `webapp` directly:

Expand All @@ -68,12 +66,15 @@ positional arguments:
url The URL to open
options:
--profile PROFILE Profile name (for cookies isolation etc). Default: "default"
--name NAME, -n NAME Application name (shown as window title)
--geometry GEOMETRY Initial window geometry (in format "WIDTHxHEIGHT+X+Y")
--icon ICON, -i ICON Full path to image file to be used as app icon
--zoom ZOOM, -z ZOOM Initial WebBrowserView zoom factor. Default: 1.0
--no-tray Disables system tray support (closing window terminates app)
--profile PROFILE, -p PROFILE Profile name (for cookies isolation etc). Default: "default"
--name NAME, -n NAME Application name (shown as window title)
--icon ICON, -i ICON Full path to PNG image file to be used as app icon
--geometry GEOMETRY, -g GEOMETRY Initial window ("WIDTHxHEIGHT+X+Y"). Default: "450x600+0+0"
--zoom ZOOM, -z ZOOM WebView scale. Default: 1.0 (no scale change).
--no-tray, -t Disables docking app in system tray (closing window quits app)
--minimized, -m Starts app minimized to system tray.
--allow-multiple, -a Allows multiple instances of the app to run on the same profile
--debug, -d Makes app print more debug messages during execution
```
The most important option is `--profile` which allows you to isolate cookies and app settings
Expand All @@ -82,6 +83,13 @@ settings. This is useful if you want to run multiple instances of the same app,
different accounts. By default `default` profile is used and it's recommended to use different
profile per each app instance.

By default only one instance per profile is allowed to run (attempt to run second instance
will bring the first one to the front). If you want to allow multiple instances of the app
to run on the same profile, use `--allow-multiple` switch.

NOTE: `--zoom` accepts fractional values, so you can use i.e. `--zoom 1.25` to scale content up by
25% or `--zoom 0.75` to scale down to 75% of the original size.

## Current limitations

* Due to security based limitations of embedded `QWebBrowerView` you will not be able
Expand All @@ -90,7 +98,7 @@ profile per each app instance.
select given portion of the site and copy using function from context menu as any buttons
on the page that is using JS to write to the host's clipboard will not currently work.

## License ##
## License

* Written and copyrighted &copy;2023-2024 by Marcin Orlowski <mail (#) marcinorlowski (.) com>
* ResponseBuilder is open-sourced software licensed under
Expand Down
46 changes: 38 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
#!/bin/bash

ACTVATED=0
if [[ -n "{$VIRTUAL_ENV}" ]]; then
source venv/bin/activate
ACTIVATED=1
##################################################################################
#
# Website As App
# Run any website as standalone desktop application
#
# @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
# @copyright 2023-2024 Marcin Orlowski
# @license https://www.opensource.org/licenses/mit-license.php MIT
# @link https://github.com/MarcinOrlowski/website-as-app
#
##################################################################################

# Function to extract version components from const.py
extract_version() {
local const_file="websiteapp/const.py"
local major=$(sed -n 's/.*MAJOR *= *\([0-9]\+\).*/\1/p' "$const_file")
local minor=$(sed -n 's/.*MINOR *= *\([0-9]\+\).*/\1/p' "$const_file")
local patch=$(sed -n 's/.*PATCH *= *\([0-9]\+\).*/\1/p' "$const_file")
echo "${major}.${minor}.${patch}"
}

# Extract version
VERSION=$(extract_version)
echo "Current version: ${VERSION}"

# Check if version was successfully extracted
if [ -z "$VERSION" ]; then
echo "Error: Failed to extract version from const source file."
exit 1
fi

ACTIVATED=0
if [[ -n "${VIRTUAL_ENV}" ]]; then
source venv/bin/activate
ACTIVATED=1
fi

python3 -m build &&
pip uninstall --yes dist/website_as_app-1.0.0-py3-none-any.whl &&
pip install dist/website_as_app-1.0.0-py3-none-any.whl
pip uninstall --yes "dist/website_as_app-${VERSION}-py3-none-any.whl" &&
pip install "dist/website_as_app-${VERSION}-py3-none-any.whl"

if [[ ${ACTIVATED} -eq 1 ]]; then
deactivate
deactivate
fi

2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ application. This is useful if you, as me, would like to have a website run as s
independently of your main browser which can be beneficial as it gives you separate entry in
window manager or task switcher etc.

> **IMPORTANT:** This tool is **NOT** turning websites into OFFLINE apps! It's about separating
> **IMPORTANT:** This tool is **NOT** turning websites into OFFLINE apps! It's about separating
> each of your key websites i.e. from each other, or gazzilions of your browser's tabs. But you
> still MUST be connected to the Internet for the apps (websites) to work as previously.
Expand Down
40 changes: 21 additions & 19 deletions docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Dev corner

[&laquo; Back to main menu](README.md)

1. [Profiles](#profiles)
2. [Building the package](#building-the-package)

Expand All @@ -21,65 +22,66 @@ directory:

Windows

```
%USERPROFILE%\AppData\Local\MarcinOrlowski\WebsiteAsApp\<APP_PROFILE_NAME>\
```
```ascii
%USERPROFILE%\AppData\Local\MarcinOrlowski\WebsiteAsApp\<APP_PROFILE_NAME>\
```

Linux

```
~/.local/share/MarcinOrlowski/WebsiteAsApp/<APP_PROFILE_NAME>/
```
```ascii
~/.local/share/MarcinOrlowski/WebsiteAsApp/<APP_PROFILE_NAME>/
```

MacOS

```
??? (PLEASE ASSIST)
```
```ascii
??? (PLEASE ASSIST)
```

---

## Building the package

1. Checkout the source code:
Checkout the source code:

```bash
$ cd <DIR>
$ git clone ....
$ cd website-as-app
```

2. Setup its runtime environment (NOTE: if you are using different shell than `bash` (i.e. `fish`),
please use correct `activate` script from `venv/bin/` directory):
Setup its runtime environment (NOTE: if you are using different shell than `bash` (i.e. `fish`),
please use correct `activate` script from `venv/bin/` directory):

```bash
$ python -m venv venv
$ source venv/bin/activate # User right one for your shell
```

3. Install all the dependencies:
Install all the dependencies:

```bash
(venv) $ pip install -r requirements-dev.txt
```

4. Build the package:
Build the package:

```bash
(venv) $ python -m build
```

5. Install package locally for testing.
We intentionally ignore `install --upgrade` while planting new build, as we need to ensure no
cached bytecode from previous version remains (which could be the case as we do not increment the
version each build).
Install package locally for testing.

We intentionally ignore `install --upgrade` while planting new build, as we need to ensure no
cached bytecode from previous version remains (which could be the case as we do not increment the
version each build).

```bash
(venv) $ pip uninstall --yes dist/website_as_app-1.0.0-py3-none-any.whl
(venv) $ pip install dist/website_as_app-1.0.0-py3-none-any.whl
```

6. Test the app
Test the app

```bash
(venv) $ webapp -h
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ twine
wheel
build
wemake-python-styleguide
pyinstaller
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
PySide6>=6.6.1
PyQtWebEngine>=5.15.6
fasteners>=0.19
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# python -m build
# # Reinstall the app (do not do "install --upgrade" as cached bytecode can not be updated)
# pip uninstall --yes dist/website_as_app-1.0.0-py3-none-any.whl
# # intentionally no --upgrade for install to endforce conflict if not uninstalled fully first.
# # intentionally no --upgrade for install to enforce conflict if not uninstalled fully first.
# pip install dist/website_as_app-1.0.0-py3-none-any.whl
# twine upload dist/*
#
Expand Down
79 changes: 79 additions & 0 deletions webapp.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# -*- mode: python ; coding: utf-8 -*-

##################################################################################
#
# Website As App
# Run any website as standalone desktop application
#
# @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
# @copyright 2023-2024 Marcin Orlowski
# @license https://www.opensource.org/licenses/mit-license.php MIT
# @link https://github.com/MarcinOrlowski/website-as-app
#
#####
#
# python -m venv venv
# source venv/bin/activate
# pip install -r requirements-dev.txt
#
# On Windows:
# pyinstaller webapp.spec
#
# On Ubuntu:
# apt install -y wine32:i386 libgd3:i386
# # install python under wine:
# wget https://www.python.org/ftp/python/3.12.4/python-3.12.4.exe
# wine python-3.12.4.exe
#
#


block_cipher = None

a = Analysis(
['websiteapp/webapp.py'],
pathex=[],
binaries=[],
datas=[
('websiteapp/icons/default.png', 'websiteapp/icons'),
('websiteapp/icons/logo.png', 'websiteapp/icons'),
],
hiddenimports=['websiteapp.const', 'PySide6', 'PyQtWebEngine'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,

win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='webapp',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
)

coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='webapp',
)
Empty file modified websiteapp/about.py
100755 → 100644
Empty file.
Loading

0 comments on commit d8e17b6

Please sign in to comment.