Skip to content

Commit

Permalink
Merge pull request #20 from PaulWaldo/feature/serverstring
Browse files Browse the repository at this point in the history
Adds display of connected server
  • Loading branch information
PaulWaldo authored Oct 14, 2023
2 parents 6d6a051 + d00c37d commit 2df6c01
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 374 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,38 +79,3 @@ jobs:
# - os: ios
# args: -app-id calc.sha${{ github.sha }}
# host: macos-latest

# - name: Cache build artifacts
# uses: actions/cache@v3
# with:
# path: |
# ~/go/pkg/mod
# ~/.cache/go-build
# ~/.cache/fyne-cross
# key: ${{ runner.os }}-build-cache-${{ hashFiles('**/go.sum') }}

# - name: Install Fyne-cross
# # working-directory: fyne-cross
# run: go install github.com/fyne-io/fyne-cross@latest

# # attempt to use "go install" but fallback to "go get"
# # - name: Install Fyne
# # run: |
# # go install fyne.io/fyne/v2/cmd/fyne@latest ||
# # go get fyne.io/fyne/v2/cmd/fyne@latest

# # - name: Install Podman
# # if: ${{ runner.os == 'macos' }}
# # run: |
# # brew install podman
# # podman machine init
# # podman machine start

# - name: Build
# # working-directory: calculator
# run: |
# fyne-cross \
# ${{ matrix.target.os }} \
# ${{ matrix.target.args }} \
# -name mastotool${{ matrix.target.ext }} \
# -app-id com.github.PaulWaldo.mastotool
17 changes: 9 additions & 8 deletions .github/workflows/verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,22 @@ jobs:
run: test -z $(find . -name '*.go' -type f | xargs goimports -e -d | tee /dev/stderr)
- name: "Run staticcheck"
run: staticcheck ./...
# Unable to do race detection now, see https://github.com/fyne-io/fyne/issues/2509
- name: "Unit Tests"
run: go test -v -race -cover ./...
run: go test -v -cover ./...

golangci:
strategy:
matrix:
go: ["1.21"]
os: [macos-latest, windows-latest, linux]
name: lint
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install required packages
run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev xorg-dev

- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
go-version: "1.21.x"

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand Down
184 changes: 184 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# !! Requires Pre-Commit
# !! https://pre-commit.com
# !! Config File: $GIT_REPO_ROOT/.pre-commit-config.yaml
# !! Already have a config file present?
# !! Copy/Paste everything below `repos:` into your existing file
# !! Don't already have a config file?
# !! Copy this whole file into your repo root (as '.pre-commit-config.yaml')
# !! Delete this header section
# !! Consider adding some built-in pre-commmit hooks to your project
# !! (They're quite useful!)
# !! ALL Hooks enabled by default - Comment out hooks you are not using
repos:
# ==========================================================================
# Golang Pre-Commit Hooks | https://github.com/tekwizely/pre-commit-golang
#
# Visit the project home page to learn more about the available Hooks,
# including useful arguments you might want to pass into them.
#
# File-Based Hooks:
# Run against matching staged files individually.
#
# Module-Based Hooks:
# Run against module root folders containing matching staged files.
#
# Package-Based Hooks:
# Run against folders containing one or more staged files.
#
# Repo-Based Hooks:
# Run against the entire repo.
# The hooks only run once (if any matching files are staged),
# and are NOT provided the list of staged files,
#
# My-Cmd-* Hooks
# Allow you to invoke custom tools in various contexts.
# Can be useful if your favorite tool(s) are not built-in (yet)
#
# Hook Suffixes
# Hooks have suffixes in their name that indicate their targets:
#
# +-----------+--------------+
# | Suffix | Target |
# |-----------+--------------+
# | <none> | Files |
# | -mod | Module |
# | -pkg | Package |
# | -repo | Repo Root |
# | -repo-mod | All Modules |
# | -repo-pkg | All Packages |
# +-----------+--------------+
#
# ! Multiple Hook Invocations
# ! Due to OS command-line-length limits, Pre-Commit can invoke a hook
# ! multiple times if a large number of files are staged.
# ! For file and repo-based hooks, this isn't an issue, but for module
# ! and package-based hooks, there is a potential for the hook to run
# ! against the same module or package multiple times, duplicating any
# ! errors or warnings.
#
# Useful Hook Parameters:
# - id: hook-id
# args: [arg1, arg2, ..., '--'] # Pass options ('--' is optional)
# always_run: true # Run even if no matching files staged
# alias: hook-alias # Create an alias
#
# Passing Options To Hooks:
# If your options contain a reference to an existing file, then you will
# need to use a trailing '--' argument to separate the hook options from
# the modified-file list that Pre-Commit passes into the hook.
# NOTE: For repo-based hooks, '--' is not needed.
#
# Passing Environment Variables to Hooks:
# You can pass environment variables to hooks using args with the
# following format:
#
# --hook:env:NAME=VALUE
#
# Always Run:
# By default, hooks ONLY run when matching file types are staged.
# When configured to "always_run", a hook is executed as if EVERY matching
# file were staged.
#
# Aliases:
# Consider adding aliases to longer-named hooks for easier CLI usage.
# ==========================================================================
- repo: https://github.com/tekwizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
#
# Go Build
#
# - id: go-build-mod
# - id: go-build-pkg
# - id: go-build-repo-mod
# - id: go-build-repo-pkg
#
# Go Mod Tidy
#
- id: go-mod-tidy
# - id: go-mod-tidy-repo
#
# Go Test
#
- id: go-test-mod
# - id: go-test-pkg
# - id: go-test-repo-mod
# - id: go-test-repo-pkg
#
# Go Vet
#
# - id: go-vet
# - id: go-vet-mod
# - id: go-vet-pkg
# - id: go-vet-repo-mod
# - id: go-vet-repo-pkg
#
# Revive
#
# - id: go-revive
# - id: go-revive-mod
# - id: go-revive-repo-mod
#
# GoSec
#
# - id: go-sec-mod
# - id: go-sec-pkg
# - id: go-sec-repo-mod
# - id: go-sec-repo-pkg
#
# StaticCheck
#
- id: go-staticcheck-mod
# - id: go-staticcheck-pkg
# - id: go-staticcheck-repo-mod
# - id: go-staticcheck-repo-pkg
#
# StructSlop
#
# - id: go-structslop-mod
# - id: go-structslop-pkg
# - id: go-structslop-repo-mod
# - id: go-structslop-repo-pkg
#
# Formatters
#
# - id: go-fmt
# - id: go-fmt-repo
# - id: go-fumpt # replaces go-fmt
# - id: go-fumpt-repo # replaces go-fmt-repo
- id: go-imports # replaces go-fmt
# - id: go-imports-repo # replaces go-fmt-repo
# - id: go-returns # replaces go-imports & go-fmt
# - id: go-returns-repo # replaces go-imports-repo & go-fmt-repo
#
# Style Checkers
#
# - id: go-lint
# - id: go-critic
#
# GolangCI-Lint
# - Fast Multi-Linter
# - Can be configured to replace MOST other hooks
# - Supports repo config file for configuration
# - https://github.com/golangci/golangci-lint
#
# - id: golangci-lint
# - id: golangci-lint-mod
# - id: golangci-lint-pkg
- id: golangci-lint-repo-mod
# - id: golangci-lint-repo-pkg
#
# Invoking Custom Go Tools
# - Configured *entirely* through the `args` attribute, ie:
# args: [ go, test, ./... ]
# - Use arg `--hook:error-on-output` to indicate that any output from the tool
# should be treated as an error.
# - Use the `name` attribute to provide better messaging when the hook runs
# - Use the `alias` attribute to be able to invoke your hook via `pre-commit run`
#
# - id: my-cmd
# - id: my-cmd-mod
# - id: my-cmd-pkg
# - id: my-cmd-repo
# - id: my-cmd-repo-mod
# - id: my-cmd-repo-pkg
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@ package:
fyne package -icon assets/Icon.png -name Mastotool

mobilesim:
go run -tags mobile main.go
go run -tags mobile main.go

showcov:
go test ./... -coverprofile=coverage.out -covermode=count
go tool cover -html=coverage.out
rm coverage.out

testdocs:
gotestdox ./...
13 changes: 3 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fredbi/uri v1.0.0 h1:s4QwUAZ8fz+mbTsukND+4V5f+mJ/wjaTokwstGUAemg=
github.com/fredbi/uri v1.0.0/go.mod h1:1xC40RnIOGCaQzswaOvrzvG/3M3F0hyDVb3aO/1iGy0=
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
github.com/fredbi/uri v1.1.0 h1:OqLpTXtyRg9ABReqvDGdJPqZUxs8cyBDOMXBbskCaB8=
github.com/fredbi/uri v1.1.0/go.mod h1:aYTUoAXBOq7BLfVJ8GnKmfcuURosB1xyHDIfWeC/iW4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
Expand All @@ -98,8 +97,6 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b h1:GgabKamyOY
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-text/render v0.0.0-20230619120952-35bccb6164b8 h1:VkKnvzbvHqgEfm351rfr8Uclu5fnwq8HP2ximUzJsBM=
github.com/go-text/render v0.0.0-20230619120952-35bccb6164b8/go.mod h1:h29xCucjNsDcYb7+0rJokxVwYAq+9kQ19WiFuBKkYtc=
github.com/go-text/typesetting v0.0.0-20230803102845-24e03d8b5372 h1:FQivqchis6bE2/9uF70M2gmmLpe82esEm2QadL0TEJo=
github.com/go-text/typesetting v0.0.0-20230803102845-24e03d8b5372/go.mod h1:evDBbvNR/KaVFZ2ZlDSOWWXIUKq0wCOEtzLxRM8SG3k=
github.com/go-text/typesetting v0.0.0-20230905121921-abdbcca6e0eb h1:4GpJirtA8yY24aqbU3uppiXGYiVpWfLIrqc2NNKKk9s=
github.com/go-text/typesetting v0.0.0-20230905121921-abdbcca6e0eb/go.mod h1:evDBbvNR/KaVFZ2ZlDSOWWXIUKq0wCOEtzLxRM8SG3k=
github.com/go-text/typesetting-utils v0.0.0-20230616150549-2a7df14b6a22 h1:LBQTFxP2MfsyEDqSKmUBZaDuDHN1vpqDyOZjcqS7MYI=
Expand Down Expand Up @@ -165,6 +162,7 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
Expand Down Expand Up @@ -239,6 +237,7 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA=
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -269,15 +268,13 @@ github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c/go.mod h1:cNQ3dwVJtS
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef h1:Ch6Q+AZUxDBCVqdkI8FSpFyZDtCVBc2VmejdNrm5rRQ=
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef/go.mod h1:nXTWP6+gD5+LUJ8krVhhoeHjvHTutPxMYl5SvkcnJNE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
Expand Down Expand Up @@ -327,8 +324,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
Expand All @@ -350,8 +345,6 @@ golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPI
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee/go.mod h1:pe2sM7Uk+2Su1y7u/6Z8KJ24D7lepUjFZbhFOrmDfuQ=
golang.org/x/mobile v0.0.0-20230901161150-52620a4a7557 h1:mLrcd+qwh23kzD7ej1VxCa+A23UNr+BCjSj2tNX8/NM=
golang.org/x/mobile v0.0.0-20230901161150-52620a4a7557/go.mod h1:f0gjFM6UTH7y1WEZBm/kquBYsogL+NQtllKFy4Rdulc=
golang.org/x/mobile v0.0.0-20230922142353-e2f452493d57 h1:Q6NT8ckDYNcwmi/bmxe+XbiDMXqMRW1xFBtJ+bIpie4=
golang.org/x/mobile v0.0.0-20230922142353-e2f452493d57/go.mod h1:wEyOn6VvNW7tcf+bW/wBz1sehi2s2BZ4TimyR7qZen4=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
Expand Down
4 changes: 1 addition & 3 deletions internal/app/ui/authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ func (ma *myApp) authenticate() {
form := dialog.NewCustomConfirm("URL of your Mastodon server", "Authenticate", "Abort", formContents, func(confirmed bool) {
if confirmed {
val, _ := ma.prefs.MastodonServer.Get()
// fmt.Printf("Server is %s\n", val)
app, err := mastodon.RegisterApp(context.Background(), app.NewAuthenticationConfig(val))
// fmt.Printf("Got token %+v\n", app)
if err != nil {
dialog.NewError(err, ma.window).Show()
return
Expand Down Expand Up @@ -66,7 +64,7 @@ func (ma *myApp) getAuthCode() {
{
Text: "Authorization Code",
Widget: accessTokenEntry,
HintText: "XXXXXXXXXXXXXXX",
HintText: "XXX-XXX-XXX",
}},
func(confirmed bool) {
if confirmed {
Expand Down
19 changes: 18 additions & 1 deletion internal/app/ui/followedtags.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"strings"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
Expand Down Expand Up @@ -72,7 +74,22 @@ func (ma *myApp) MakeFollowedTagsUI() fyne.CanvasObject {
ma.refreshButton = widget.NewButtonWithIcon("Refresh", theme.ViewRefreshIcon(), func() {
ma.refreshFollowedTags()
})
bottom := container.NewBorder(nil, nil, nil, ma.refreshButton, ma.unfollowButton)
bottomButtons := container.NewBorder(nil, nil, nil, ma.refreshButton, ma.unfollowButton)

// Created muted text that shows the connected server
ma.serverText = canvas.NewText("", theme.PlaceHolderColor())
ma.serverText.TextSize = theme.CaptionTextSize()
ss := func() {
s, _ := ma.prefs.MastodonServer.Get()
ma.serverText.Text = s
ma.serverText.Refresh()
}
if ma.prefs.MastodonServer != nil {
ma.prefs.MastodonServer.AddListener(binding.NewDataListener(ss))
}

bottom := container.NewVBox(ma.serverText, bottomButtons)
// bottom := container.NewBorder(nil, nil, nil, ma.refreshButton, ma.unfollowButton)
return container.NewBorder(nil, bottom, nil, nil, ma.listChoices)
}

Expand Down
Loading

0 comments on commit 2df6c01

Please sign in to comment.