From 00eb634a53c00bff48d72fda2630b23b5b62c6c9 Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Wed, 30 Nov 2022 22:22:27 -0700 Subject: [PATCH] 1.2.3: Make domain name configurable (#31) * Make domain name configurable * Bump version * Add Flatpak workflow * Remove legacy build CI * Revert Granite version change --- .github/workflows/flatpak.yml | 42 ++++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 13 ++++++++++ .github/workflows/main.yml | 37 ---------------------------- README.md | 43 +++------------------------------ com.cassidyjames.plausible.json | 8 +++--- data/gschema.xml | 5 ++++ data/metainfo.xml | 9 +++++-- meson.build | 2 +- src/App.vala | 3 +-- src/MainWindow.vala | 30 ++++++++++++----------- src/WebContext.vala | 2 +- 11 files changed, 93 insertions(+), 101 deletions(-) create mode 100644 .github/workflows/flatpak.yml create mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/flatpak.yml b/.github/workflows/flatpak.yml new file mode 100644 index 0000000..b9ea753 --- /dev/null +++ b/.github/workflows/flatpak.yml @@ -0,0 +1,42 @@ +name: Flatpak + +on: [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + flatpak: + runs-on: ubuntu-latest + + container: + image: bilelmoussaoui/flatpak-github-actions:gnome-42 + options: --privileged + + strategy: + matrix: + arch: [x86_64, aarch64] + # Don't fail the whole workflow if one architecture fails + fail-fast: false + steps: + - uses: actions/checkout@v2 + + - name: Install deps + run: | + dnf -y install docker + if: ${{ matrix.arch == 'aarch64' }} + + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v1 + with: + platforms: arm64 + if: ${{ matrix.arch == 'aarch64' }} + + - uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4 + with: + bundle: plausible-${{ matrix.arch }}.flatpak + manifest-path: com.cassidyjames.plausible.json + cache-key: "flatpak-builder-${{ github.sha }}" + arch: ${{ matrix.arch }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..e9f0537 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,13 @@ +name: CI + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + container: + image: valalang/lint + steps: + - uses: actions/checkout@v1 + - name: Lint + run: io.elementary.vala-lint -d . diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 8e96720..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: CI - -on: [push, pull_request] - -jobs: - build: - - runs-on: ubuntu-latest - - container: - image: elementary/docker:unstable - - steps: - - uses: actions/checkout@v1 - - name: Install Dependencies - run: | - apt update - apt install -y libgranite-dev libgtk-3-dev libhandy-1-dev libvala-dev libvte-2.91-dev libwebkit2gtk-4.0-dev meson valac - - name: Build - env: - DESTDIR: out - run: | - meson build - ninja -C build - ninja -C build install - - lint: - - runs-on: ubuntu-latest - - container: - image: valalang/lint - - steps: - - uses: actions/checkout@v1 - - name: Lint - run: io.elementary.vala-lint -d . diff --git a/README.md b/README.md index b70ae6f..8763c0f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Plausible -Hybrid native + web app for [Plausible Analytics](https://plausible.io). Designed for elementary OS. +Hybrid native + web app for [Plausible Analytics](https://plausible.io). ![Screenshot](data/screenshots/dashboard-dark.png) Plausible is the simple privacy-friendly alternative to Google Analytics. This app wraps the Plausible web app in a native UI, integrating better with desktop operating systems like elementary OS. Native features include: -- Icon in your Applications Menu, Dock, etc. +- Icon in your App Grid, Applications Menu, Dash, Dock, etc. - Native header bar with buttons for account settings and logging out - Save and restore current view, size, and position when closed and opened - Two-finger swipe to go back/forward between views @@ -16,43 +16,6 @@ Other features: - Zoom in/out with Ctrl+Plus/Minus, and it's remembered the next time you use the app - Slimmed down web app UI (no header or footer with external links) - ## Developing and Building -Development is targeted at [elementary OS](https://elementary.io). If you want to hack on and build the app yourself, you'll need the following dependencies: - -* libgranite-dev (>=5.5) -* libgtk-3-dev -* libhandy-1-dev -* libwebkit2gtk-4.0-dev -* meson -* valac - -You can install them on elementary OS with: - -```shell -sudo apt install elementary-sdk libwebkit2gtk-4.0-dev -``` - -Run `meson build` to configure the build environment and run `ninja` to build: - -```shell -meson build --prefix=/usr -cd build -ninja -``` - -To install, use `ninja install`, then execute with `com.cassidyjames.plausible`: - -```shell -ninja install -com.cassidyjames.plausible -``` - -### Flatpak - -Building is also possible with Flatpak. Ensure you have Flathub added as a user repo, then from the top-level of this repo: - -```shell -flatpak-builder --user --force-clean --install-deps-from=flathub --install build-dir com.cassidyjames.plausible.yml -``` +How to build Plausible is currently undergoing a rework; for now, I recommend using GNOME Builder with default settings to build the Flatpak. diff --git a/com.cassidyjames.plausible.json b/com.cassidyjames.plausible.json index 72d83f9..69cd05d 100644 --- a/com.cassidyjames.plausible.json +++ b/com.cassidyjames.plausible.json @@ -36,8 +36,8 @@ { "type" : "git", "url" : "https://github.com/elementary/stylesheet.git", - "tag" : "7.0.0", - "commit" : "15363725675baf2e8284a48c4d82022624c24969" + "tag" : "7.0.1", + "commit" : "5fbc525f2f3b0e8dd15298401516a9fae96dbe63" } ], "modules" : [ @@ -97,8 +97,8 @@ { "type" : "git", "url" : "https://github.com/elementary/icons.git", - "tag" : "7.0.0", - "commit" : "c52a16f4c5bb7b756db6ae965fe4b3d03b1003f6" + "tag" : "7.1.0", + "commit" : "9b5b27167e4211e76a2ae04223fbc6462e67afbd" } ], "modules" : [ diff --git a/data/gschema.xml b/data/gschema.xml index 2957e1a..ab6d4bb 100644 --- a/data/gschema.xml +++ b/data/gschema.xml @@ -6,6 +6,11 @@ Current URL The last-viewed URL for restoring state + + "plausible.io" + Plausible instance domain + The domain name for the Plausible instance, by default plausible.io + false Window maximized diff --git a/data/metainfo.xml b/data/metainfo.xml index 78520c0..3ae64e3 100644 --- a/data/metainfo.xml +++ b/data/metainfo.xml @@ -1,5 +1,5 @@ - + com.cassidyjames.plausible Plausible @@ -9,7 +9,7 @@

Hybrid native + web app for Plausible Analytics, the lightweight and open-source website analytics tool. This app wraps the Plausible web app in a native UI, integrating better with desktop operating systems. Native features include:

    -
  • Icon in your Applications Menu, Dock, etc.
  • +
  • Icon in your App Grid, Applications Menu, Dash, Dock, etc.
  • Native header bar with buttons for account settings and logging out
  • Save and restore current view, size, and position when closed and opened
  • Two-finger swipe to go back/forward between views
  • @@ -30,6 +30,11 @@ touch + + +

    Under-the-hood update to prepare for custom domains

    +
    +

    Fix background color of loading screen

    diff --git a/meson.build b/meson.build index ed1f505..1978643 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'com.cassidyjames.plausible', 'vala', 'c', - version: '1.2.2' + version: '1.2.3' ) gnome = import('gnome') diff --git a/src/App.vala b/src/App.vala index 74ff22c..4503ad8 100644 --- a/src/App.vala +++ b/src/App.vala @@ -1,5 +1,5 @@ /* -* Copyright © 2020–2021 Cassidy James Blaede (https://cassidyjames.com) +* Copyright © 2020–2022 Cassidy James Blaede (https://cassidyjames.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -20,7 +20,6 @@ */ public class Plausible.App : Gtk.Application { - public string domain = "plausible.io"; public static GLib.Settings settings; public App () { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 6dcf17c..da9be15 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -1,5 +1,5 @@ /* -* Copyright © 2020–2021 Cassidy James Blaede (https://cassidyjames.com) +* Copyright © 2020–2022 Cassidy James Blaede (https://cassidyjames.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public @@ -89,11 +89,12 @@ public class Plausible.MainWindow : Hdy.Window { web_view = new Plausible.WebView (); + string domain = App.settings.get_string ("domain"); string current_url = App.settings.get_string ("current-url"); if (current_url != "") { web_view.load_uri (current_url); } else { - web_view.load_uri ("https://" + App.instance.domain + "/sites"); + web_view.load_uri ("https://" + domain + "/sites"); } var logo = new Gtk.Image.from_resource ("/com/cassidyjames/plausible/logo-dark.png") { @@ -140,17 +141,17 @@ public class Plausible.MainWindow : Hdy.Window { }); sites_button.clicked.connect (() => { - web_view.load_uri ("https://" + App.instance.domain + "/sites"); + web_view.load_uri ("https://" + domain + "/sites"); }); account_button.clicked.connect (() => { - web_view.load_uri ("https://" + App.instance.domain + "/settings"); + web_view.load_uri ("https://" + domain + "/settings"); }); logout_button.clicked.connect (() => { // NOTE: Plausible expects a POST not just loading the URL // https://github.com/plausible/analytics/issues/730 - // web_view.load_uri ("https://" + App.instance.domain + "/logout"); + // web_view.load_uri ("https://" + domain + "/logout"); web_view.get_website_data_manager ().clear.begin ( WebKit.WebsiteDataTypes.COOKIES, @@ -158,7 +159,7 @@ public class Plausible.MainWindow : Hdy.Window { null, () => { debug ("Cleared cookies; going home."); - web_view.load_uri ("https://" + App.instance.domain + "/sites"); + web_view.load_uri ("https://" + domain + "/sites"); } ); }); @@ -245,20 +246,21 @@ public class Plausible.MainWindow : Hdy.Window { private void on_loading () { // Only do anything once we're done loading if (! web_view.is_loading) { + string domain = App.settings.get_string ("domain"); sites_revealer.reveal_child = ( - web_view.uri != "https://" + App.instance.domain + "/login" && - web_view.uri != "https://" + App.instance.domain + "/register" && - web_view.uri != "https://" + App.instance.domain + "/password/request-reset" && - web_view.uri != "https://" + App.instance.domain + "/sites" + web_view.uri != "https://" + domain + "/login" && + web_view.uri != "https://" + domain + "/register" && + web_view.uri != "https://" + domain + "/password/request-reset" && + web_view.uri != "https://" + domain + "/sites" ); account_revealer.reveal_child = ( - web_view.uri != "https://" + App.instance.domain + "/login" && - web_view.uri != "https://" + App.instance.domain + "/register" && - web_view.uri != "https://" + App.instance.domain + "/password/request-reset" + web_view.uri != "https://" + domain + "/login" && + web_view.uri != "https://" + domain + "/register" && + web_view.uri != "https://" + domain + "/password/request-reset" ); - if (web_view.uri == "https://" + App.instance.domain + "/settings") { + if (web_view.uri == "https://" + domain + "/settings") { account_stack.visible_child_name = "logout"; } else { account_stack.visible_child_name = "account"; diff --git a/src/WebContext.vala b/src/WebContext.vala index 13c2a83..541fbf8 100644 --- a/src/WebContext.vala +++ b/src/WebContext.vala @@ -1,5 +1,5 @@ /* -* Copyright © 2019–2021 Cassidy James Blaede (https://cassidyjames.com) +* Copyright © 2019–2022 Cassidy James Blaede (https://cassidyjames.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public