Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aeafc4c54a
|
||
|
|
514385a38f
|
||
|
|
87d9c75dc1
|
@@ -57,7 +57,7 @@ jobs:
|
||||
run: git clone --depth 1 --branch latest https://github.com/discourse/discourse.git core
|
||||
|
||||
- name: Install plugin
|
||||
run: cp -r plugin core/plugins/hledger
|
||||
run: cp -r plugin core/plugins/discourse-hledger
|
||||
|
||||
- name: Container envs
|
||||
id: container-envs
|
||||
@@ -91,7 +91,7 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: core/tmp/app-cache
|
||||
key: ${{ runner.os }}-app-v1-${{ hashFiles('core/db/**/*', 'core/plugins/hledger/db/**/*', 'plugin/.gitea/workflows/ci.yml') }}
|
||||
key: ${{ runner.os }}-app-v1-${{ hashFiles('core/db/**/*', 'core/plugins/discourse-hledger/db/**/*', 'plugin/.gitea/workflows/ci.yml') }}
|
||||
|
||||
- name: Install hledger
|
||||
run: |
|
||||
@@ -140,10 +140,10 @@ jobs:
|
||||
|
||||
- name: Plugin RSpec
|
||||
working-directory: core
|
||||
run: bin/rspec plugins/hledger/spec/lib plugins/hledger/spec/requests
|
||||
run: bin/rspec plugins/discourse-hledger/spec/lib plugins/discourse-hledger/spec/requests
|
||||
|
||||
- name: Plugin QUnit
|
||||
working-directory: core
|
||||
env:
|
||||
DISCOURSE_DISABLE_BROWSER_SANDBOX: "1"
|
||||
run: bin/rake plugin:qunit['hledger']
|
||||
run: bin/rake plugin:qunit['discourse-hledger']
|
||||
+18
-1
@@ -1,5 +1,22 @@
|
||||
# Changelog
|
||||
|
||||
## 1.2.0 — 2026-09-27
|
||||
|
||||
Fixes the plugin's identity so Discourse associates its site settings and admin
|
||||
UI correctly. The plugin's metadata name was `hledger` while the repository (and
|
||||
therefore the usual install directory) is named `discourse-hledger`. When those
|
||||
differ, Discourse loads the plugin but does not attach its settings to it, so
|
||||
the plugin appeared in the admin Plugins list without a Settings button and
|
||||
without an entry in the admin sidebar.
|
||||
|
||||
### Installation
|
||||
|
||||
The plugin is named `discourse-hledger` throughout now. Clone and install it
|
||||
into `plugins/discourse-hledger`; the directory name must match the plugin's
|
||||
`# name:`. The settings category is now `discourse_hledger`; the individual
|
||||
setting names are unchanged (`hledger_*`), so existing configuration carries
|
||||
over.
|
||||
|
||||
## 1.1.0 — 2026-09-27
|
||||
|
||||
Hardening and operational improvements on top of the first release. The report
|
||||
@@ -109,4 +126,4 @@ per minute per IP, and results are cached per post revision.
|
||||
### Requirements
|
||||
|
||||
- The `hledger` executable on the server.
|
||||
- Discourse 2.7.0 or newer.
|
||||
- Discourse 2.7.0 or newer.
|
||||
|
||||
@@ -16,6 +16,14 @@ by the `hledger` command line tool:
|
||||
balances; contributed capital, not legal ownership)
|
||||
- 🧾 Journal (a detailed transaction log: date, description and postings)
|
||||
|
||||
## Screenshots
|
||||
|
||||
Rendered from the [example journal](docs/example.journal):
|
||||
|
||||
| Accounts | P&L | Journal |
|
||||
| - | - | - |
|
||||
| [](docs/screenshots/accounts.png) | [](docs/screenshots/pnl.png) | [](docs/screenshots/journal.png) |
|
||||
|
||||
## Installation
|
||||
|
||||
The plugin requires the `hledger` executable on the server.
|
||||
@@ -63,7 +71,7 @@ Inside the Discourse dev container, install the plugin's system dependencies
|
||||
(hledger, Chromium and the Playwright browser used by the test suite) with:
|
||||
|
||||
```sh
|
||||
docker exec -u root discourse_dev bash /src/plugins/hledger/bin/setup-dev
|
||||
docker exec -u root discourse_dev bash /src/plugins/discourse-hledger/bin/setup-dev
|
||||
```
|
||||
|
||||
## How to use
|
||||
@@ -124,11 +132,11 @@ in-process resource limits.
|
||||
|
||||
```sh
|
||||
# Ruby specs (run `bin/setup-dev` first for the integration specs)
|
||||
bin/rspec plugins/hledger/spec/lib plugins/hledger/spec/requests
|
||||
bin/rspec plugins/hledger/spec/system
|
||||
bin/rspec plugins/discourse-hledger/spec/lib plugins/discourse-hledger/spec/requests
|
||||
bin/rspec plugins/discourse-hledger/spec/system
|
||||
|
||||
# Frontend tests
|
||||
DISCOURSE_DISABLE_BROWSER_SANDBOX=1 bin/qunit plugins/hledger/test/javascripts
|
||||
DISCOURSE_DISABLE_BROWSER_SANDBOX=1 bin/qunit plugins/discourse-hledger/test/javascripts
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
+2
-2
@@ -2,11 +2,11 @@
|
||||
# Install the system dependencies needed to develop and test the hledger plugin.
|
||||
#
|
||||
# Run inside the dev container as root, for example:
|
||||
# docker exec -u root discourse_dev bash /src/plugins/hledger/bin/setup-dev
|
||||
# docker exec -u root discourse_dev bash /src/plugins/discourse-hledger/bin/setup-dev
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "Run as root inside the dev container, eg: docker exec -u root discourse_dev bash /src/plugins/hledger/bin/setup-dev" >&2
|
||||
echo "Run as root inside the dev container, eg: docker exec -u root discourse_dev bash /src/plugins/discourse-hledger/bin/setup-dev" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ en:
|
||||
admin:
|
||||
site_settings:
|
||||
categories:
|
||||
hledger: "Hledger"
|
||||
discourse_hledger: "Hledger"
|
||||
js:
|
||||
hledger:
|
||||
reports:
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
hledger:
|
||||
discourse_hledger:
|
||||
hledger_enabled:
|
||||
default: false
|
||||
client: true
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
; Example journal for the Discourse hledger plugin.
|
||||
; A community collective with member contributions, dues, donations and costs.
|
||||
|
||||
2024-01-01 Opening balances
|
||||
assets:bank:checking 2500.00 USD
|
||||
assets:bank:savings 5000.00 USD
|
||||
equity:members:@alice -4500.00 USD
|
||||
equity:members:@bob -3000.00 USD
|
||||
|
||||
2024-01-15 Membership dues, Q1
|
||||
assets:bank:checking 300.00 USD
|
||||
revenues:dues
|
||||
|
||||
2024-01-20 Interest-free member loan, @carol
|
||||
assets:bank:checking 500.00 USD
|
||||
liabilities:loans:@carol
|
||||
|
||||
2024-02-03 Donation from @carol
|
||||
assets:bank:checking 150.00 USD
|
||||
revenues:donations
|
||||
|
||||
2024-02-20 Server hosting, February
|
||||
expenses:hosting 40.00 USD
|
||||
assets:bank:checking
|
||||
|
||||
2024-03-05 Podcast microphone
|
||||
expenses:equipment 120.00 USD
|
||||
assets:bank:checking
|
||||
|
||||
2024-03-22 Travel reimbursement, @alice
|
||||
expenses:travel 180.00 USD
|
||||
assets:bank:checking
|
||||
|
||||
2024-04-02 Transfer to savings
|
||||
assets:bank:savings 1000.00 USD
|
||||
assets:bank:checking
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 63 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 122 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
@@ -1,9 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# name: hledger
|
||||
# name: discourse-hledger
|
||||
# about: Render hledger journals in topics
|
||||
# meta_topic_id: TODO
|
||||
# version: 1.1.0
|
||||
# version: 1.2.0
|
||||
# authors: Râu Cao
|
||||
# url: https://gitea.kosmos.org/raucao/discourse-hledger
|
||||
# required_version: 2.7.0
|
||||
@@ -17,7 +17,7 @@ register_svg_icon "receipt"
|
||||
enabled_site_setting :hledger_enabled
|
||||
|
||||
module ::Hledger
|
||||
PLUGIN_NAME = "hledger"
|
||||
PLUGIN_NAME = "discourse-hledger"
|
||||
end
|
||||
|
||||
require_relative "lib/hledger/engine"
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
RSpec.describe "Hledger integration" do
|
||||
before { skip "hledger is not installed" if !Hledger::Runner.new.available? }
|
||||
|
||||
let(:journal) { File.read(Rails.root.join("plugins/hledger/spec/fixtures/journal.txt")) }
|
||||
let(:journal) do
|
||||
File.read(Rails.root.join("plugins/discourse-hledger/spec/fixtures/journal.txt"))
|
||||
end
|
||||
let(:builder) { Hledger::ReportBuilder.new }
|
||||
|
||||
it "builds every supported report" do
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FakeHledgerRunner
|
||||
FIXTURES = Rails.root.join("plugins/hledger/spec/fixtures")
|
||||
FIXTURES = Rails.root.join("plugins/discourse-hledger/spec/fixtures")
|
||||
FILES = {
|
||||
"accounts" => "accounts.json",
|
||||
"balance_sheet" => "balance_sheet.json",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class StubHledgerRunner
|
||||
FIXTURES = Rails.root.join("plugins/hledger/spec/fixtures")
|
||||
FIXTURES = Rails.root.join("plugins/discourse-hledger/spec/fixtures")
|
||||
|
||||
attr_reader :version
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Captures the screenshots used in the README and announcements. Run through the
|
||||
# theme screenshot matrix, for example:
|
||||
#
|
||||
# TAKE_SCREENSHOTS=1 LOAD_PLUGINS=1 SCREENSHOTS_THEMES=foundation \
|
||||
# SCREENSHOTS_MODES=light SCREENSHOTS_DEVICES=desktop \
|
||||
# SCREENSHOTS_SUBSET=hledger \
|
||||
# bin/rspec spec/system/theme_screenshots_spec.rb
|
||||
#
|
||||
# Without TAKE_SCREENSHOTS the spec is skipped, so it does not run in the normal
|
||||
# system suite.
|
||||
RSpec.describe "Hledger dashboard screenshots" do
|
||||
include ThemeScreenshotMarker
|
||||
|
||||
let(:journal) { File.read(Rails.root.join("plugins/discourse-hledger/docs/example.journal")) }
|
||||
|
||||
fab!(:alice) { Fabricate(:user, username: "alice", name: "Alice") }
|
||||
fab!(:bob) { Fabricate(:user, username: "bob", name: "Bob") }
|
||||
fab!(:carol) { Fabricate(:user, username: "carol", name: "Carol") }
|
||||
|
||||
before do
|
||||
skip "Set TAKE_SCREENSHOTS=1 to run this spec" if ENV["TAKE_SCREENSHOTS"] != "1"
|
||||
|
||||
SiteSetting.title = "Hledger demo"
|
||||
SiteSetting.logo = ""
|
||||
SiteSetting.logo_small = ""
|
||||
SiteSetting.hledger_enabled = true
|
||||
end
|
||||
|
||||
it "captures every report" do
|
||||
post = Fabricate(:post, user: alice, raw: "```hledger\n#{journal}\n```")
|
||||
post.topic.update!(title: "Collective finances 2024")
|
||||
post.rebake!
|
||||
|
||||
visit(post.topic.relative_url)
|
||||
expect(page).to have_css(".hledger-dashboard__table", text: "Assets")
|
||||
capture("accounts")
|
||||
|
||||
open_report(2)
|
||||
expect(page).to have_css(".hledger-dashboard__section-title", text: "Assets")
|
||||
capture("balance-sheet")
|
||||
|
||||
open_report(3)
|
||||
expect(page).to have_css(".hledger-dashboard__section-title", text: "Revenues")
|
||||
capture("pnl")
|
||||
|
||||
open_report(4)
|
||||
expect(page).to have_css(".hledger-dashboard__note")
|
||||
capture("equity")
|
||||
|
||||
open_report(5)
|
||||
expect(page).to have_css(".hledger-dashboard__transaction")
|
||||
capture("journal")
|
||||
end
|
||||
|
||||
def open_report(index)
|
||||
find(".hledger-dashboard__toolbar .btn:nth-of-type(#{index})").click
|
||||
end
|
||||
|
||||
def capture(label)
|
||||
screenshot_marker(label: "hledger-#{label}", only: :desktop)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user