Skip to content

Commit

Permalink
1.2.3: Make domain name configurable (#31)
Browse files Browse the repository at this point in the history
* Make domain name configurable

* Bump version

* Add Flatpak workflow

* Remove legacy build CI

* Revert Granite version change
  • Loading branch information
cassidyjames authored Dec 1, 2022
1 parent de37b25 commit 00eb634
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 101 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
@@ -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 }}
13 changes: 13 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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 .
37 changes: 0 additions & 37 deletions .github/workflows/main.yml

This file was deleted.

43 changes: 3 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
8 changes: 4 additions & 4 deletions com.cassidyjames.plausible.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" : [
Expand Down Expand Up @@ -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" : [
Expand Down
5 changes: 5 additions & 0 deletions data/gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<summary>Current URL</summary>
<description>The last-viewed URL for restoring state</description>
</key>
<key name="domain" type="s">
<default>"plausible.io"</default>
<summary>Plausible instance domain</summary>
<description>The domain name for the Plausible instance, by default plausible.io</description>
</key>
<key name="window-maximized" type="b">
<default>false</default>
<summary>Window maximized</summary>
Expand Down
9 changes: 7 additions & 2 deletions data/metainfo.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2021 Cassidy James Blaede <[email protected]> -->
<!-- Copyright 2021–2022 Cassidy James Blaede <[email protected]> -->
<component type="desktop">
<id>com.cassidyjames.plausible</id>
<name>Plausible</name>
Expand All @@ -9,7 +9,7 @@
<description>
<p>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:</p>
<ul>
<li>Icon in your Applications Menu, Dock, etc.</li>
<li>Icon in your App Grid, Applications Menu, Dash, Dock, etc.</li>
<li>Native header bar with buttons for account settings and logging out</li>
<li>Save and restore current view, size, and position when closed and opened</li>
<li>Two-finger swipe to go back/forward between views</li>
Expand All @@ -30,6 +30,11 @@
<control>touch</control>
</recommends>
<releases>
<release version="1.2.3" date="2022-11-30">
<description>
<p>Under-the-hood update to prepare for custom domains</p>
</description>
</release>
<release version="1.2.2" date="2021-03-24">
<description>
<p>Fix background color of loading screen</p>
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
'com.cassidyjames.plausible',
'vala', 'c',
version: '1.2.2'
version: '1.2.3'
)

gnome = import('gnome')
Expand Down
3 changes: 1 addition & 2 deletions src/App.vala
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,7 +20,6 @@
*/

public class Plausible.App : Gtk.Application {
public string domain = "plausible.io";
public static GLib.Settings settings;

public App () {
Expand Down
30 changes: 16 additions & 14 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -140,25 +141,25 @@ 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,
0,
null,
() => {
debug ("Cleared cookies; going home.");
web_view.load_uri ("https://" + App.instance.domain + "/sites");
web_view.load_uri ("https://" + domain + "/sites");
}
);
});
Expand Down Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/WebContext.vala
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 00eb634

Please sign in to comment.