From 9f75c9ed0dd7f3d5d93654ff9a2c910419757f12 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 10 May 2024 11:21:18 +0200 Subject: [PATCH 01/11] Filter boosts from account status --- src/main/dda/masto_embed/account_mode.cljs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/dda/masto_embed/account_mode.cljs b/src/main/dda/masto_embed/account_mode.cljs index e12135e..8938618 100644 --- a/src/main/dda/masto_embed/account_mode.cljs +++ b/src/main/dda/masto_embed/account_mode.cljs @@ -57,11 +57,12 @@ (edn (filter #(= account-name (:acct %))) - (infra/debug) (map :id) first))) out)) +; (infra/debug) + (defn account-mode [host-url account-name] (go (let [account-id (edn)] (->> statuus + (filter #(= nil (:reblog %))) (take 4) (masto->html) (render-html) From 4114318ded796e7d790a39e2ccf378891b582a68 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 10 May 2024 11:25:17 +0200 Subject: [PATCH 02/11] Filter replies from account_mode --- src/main/dda/masto_embed/account_mode.cljs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/dda/masto_embed/account_mode.cljs b/src/main/dda/masto_embed/account_mode.cljs index 8938618..8474720 100644 --- a/src/main/dda/masto_embed/account_mode.cljs +++ b/src/main/dda/masto_embed/account_mode.cljs @@ -71,6 +71,7 @@ api/mastojs->edn)] (->> statuus (filter #(= nil (:reblog %))) + (filter #(= nil (:in_reply_to_account_id %))) (take 4) (masto->html) (render-html) From 1821e2bf087007f968dbec9e949144371f08037b Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 10 May 2024 11:31:06 +0200 Subject: [PATCH 03/11] Link to status instead of account --- src/main/dda/masto_embed/account_mode.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/dda/masto_embed/account_mode.cljs b/src/main/dda/masto_embed/account_mode.cljs index 8474720..144c74b 100644 --- a/src/main/dda/masto_embed/account_mode.cljs +++ b/src/main/dda/masto_embed/account_mode.cljs @@ -41,7 +41,7 @@ [:li {:class "list-group-item, card"} [:div {:class "card-body"} [:h2 {:class "card-title"} - [:a {:href (get-in status [:account :url])} + [:a {:href (get-in status [:card :url])} (t/unparse (t/formatters :date) date) " " (t/unparse (t/formatters :hour-minute-second) date)]] [:p {:class "card-text"} From 0e7a16f59b1e8351f710326993c21c9da53792a9 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 10 May 2024 11:39:42 +0200 Subject: [PATCH 04/11] Remove github workflow --- .github/FUNDING.yml | 3 - .github/workflows/stable.yml | 117 --------------------------------- .github/workflows/unstable.yml | 41 ------------ 3 files changed, 161 deletions(-) delete mode 100644 .github/FUNDING.yml delete mode 100644 .github/workflows/stable.yml delete mode 100644 .github/workflows/unstable.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index c5d6415..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -# These are supported funding model platforms - -github: jerger diff --git a/.github/workflows/stable.yml b/.github/workflows/stable.yml deleted file mode 100644 index 63563c0..0000000 --- a/.github/workflows/stable.yml +++ /dev/null @@ -1,117 +0,0 @@ -name: stable -on: - push: - tags: - - '[0-9]+.[0-9]+.[0-9]+' - -jobs: - stable: - name: stable - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [14.x] - - steps: - - uses: actions/checkout@v2 - - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - registry-url: 'https://registry.npmjs.org' - - - name: test em - run: | - npm install - npm install -g --save-dev shadow-cljs - shadow-cljs compile test - - - name: build em - run: | - shadow-cljs release frontend - sha256sum public/js/main.js > target/dda-masto-embed.js.sha256 - sha512sum public/js/main.js > target/dda-masto-embed.js.sha512 - shadow-cljs run shadow.cljs.build-report frontend target/build-report.html - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false - - - name: Upload masto-embed.js - id: upload-masto-embed-js - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: public/js/main.js - asset_name: dda-masto-embed.js - asset_content_type: application/javascript - - - name: Upload masto-embed.js.sha256 - id: upload-masto-embed-js-sha256 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: target/dda-masto-embed.js.sha256 - asset_name: dda-masto-embed.js.sha256 - asset_content_type: text/plain - - - name: Upload masto-embed.js.sha512 - id: upload-masto-embed-js-sha512 - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: target/dda-masto-embed.js.sha512 - asset_name: dda-masto-embed.js.sha512 - asset_content_type: text/plain - - - name: Upload build report - id: build-report - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: target/build-report.html - asset_name: build-report.html - asset_content_type: text/html - - - name: upload to npm - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: | - mkdir -p target/npm-build/ - cp public/js/main.js target/npm-build/dda-masto-embed.js - cp target/dda-masto-embed.js.sha256 target/npm-build/ - cp target/dda-masto-embed.js.sha512 target/npm-build/ - cp package.json target/npm-build/ - cp README.md target/npm-build/ - cp -r doc target/npm-build/ - cp LICENSE target/npm-build/ - npm publish target/npm-build --access public diff --git a/.github/workflows/unstable.yml b/.github/workflows/unstable.yml deleted file mode 100644 index 404de48..0000000 --- a/.github/workflows/unstable.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: unstable -on: - push: - tags: - - '![0-9]+.[0-9]+.[0-9]+' - -jobs: - unstable: - name: unstable - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [14.x] - - steps: - - uses: actions/checkout@v2 - - - name: Cache node modules - uses: actions/cache@v2 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - registry-url: 'https://registry.npmjs.org' - - - name: test em - run: | - npm install - npm install -g --save-dev shadow-cljs - shadow-cljs compile test From 0b0b387ec8aa907660dd2c9be53cc73d66c6779f Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 10 May 2024 12:09:37 +0200 Subject: [PATCH 05/11] Ignore compiled python build files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5cf60e1..4b0399e 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ node_modules/ /public/js /out package-lock.json +*.pyc \ No newline at end of file From eb13c31062e84a1e12ae3d72d875a4a4a8bb3682 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 10 May 2024 12:10:19 +0200 Subject: [PATCH 06/11] Get status url instead of card --- src/main/dda/masto_embed/account_mode.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/dda/masto_embed/account_mode.cljs b/src/main/dda/masto_embed/account_mode.cljs index 144c74b..016b0cd 100644 --- a/src/main/dda/masto_embed/account_mode.cljs +++ b/src/main/dda/masto_embed/account_mode.cljs @@ -41,7 +41,7 @@ [:li {:class "list-group-item, card"} [:div {:class "card-body"} [:h2 {:class "card-title"} - [:a {:href (get-in status [:card :url])} + [:a {:href (get-in status [:url])} (t/unparse (t/formatters :date) date) " " (t/unparse (t/formatters :hour-minute-second) date)]] [:p {:class "card-text"} From 38291503a36af0c09cc62f97bfd1067fbe5d7126 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 10 May 2024 12:10:30 +0200 Subject: [PATCH 07/11] Fix reply mode test --- src/test/dda/masto_embed/reply_mode_test.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/dda/masto_embed/reply_mode_test.cljs b/src/test/dda/masto_embed/reply_mode_test.cljs index d30511b..530e48d 100644 --- a/src/test/dda/masto_embed/reply_mode_test.cljs +++ b/src/test/dda/masto_embed/reply_mode_test.cljs @@ -115,7 +115,7 @@ [:div {:class "card-body row"} [:div {:class "col-sm"} [:h2 {:class "card-title"} - [:a {:href "https://social.meissa-gmbh.de/@jerger/107937257700481042"} "2022-03-11" " " "09:44:07"]] + [:a {:href "https://social.meissa-gmbh.de/@jerger/107937257700481042"} "11.03.2022" " "]] [:div {:class "card-text"} "

@team Hier mein erstes Bild :-)

"]] [:div {:class "col-sm"} [:div {:class "media"} From efea7a59bfc0c68d750983037a36011611066821 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 10 May 2024 12:10:43 +0200 Subject: [PATCH 08/11] Fix account mode test --- src/test/dda/masto_embed/account_mode_test.cljs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/dda/masto_embed/account_mode_test.cljs b/src/test/dda/masto_embed/account_mode_test.cljs index a91f192..5d170eb 100644 --- a/src/test/dda/masto_embed/account_mode_test.cljs +++ b/src/test/dda/masto_embed/account_mode_test.cljs @@ -157,7 +157,7 @@ (is (= [:ul {:class "list-group"} '([:li {:class "list-group-item, card"} [:div {:class "card-body"} - [:h2 {:class "card-title"} [:a {:href "https://social.meissa-gmbh.de/@team"} "2020-05-17" " " "10:12:10"]] + [:h2 {:class "card-title"} [:a {:href "https://social.meissa-gmbh.de/users/team/statuses/104183256213204298/activity"} "2020-05-17" " " "10:12:10"]] [:p {:class "card-text"} "

We've a new asciicast ...

" nil]]])] (sut/masto->html statuses)))) @@ -192,4 +192,4 @@ [:img {:class "card-img-top", :src "https://cf.mastohost.com/v1/AUTH_91eb37814936490c95da7b85993cc2ff/socialmeissagmbhde/cache/preview_cards/images/000/017/635/original/5634071238f1f91f.png"}] [:h3 {:class "card-title"} "DomainDrivenArchitecture/cryogen-core"] [:p {:class "card-body"} "Cryogen's core. Contribute to DomainDrivenArchitecture/cryogen-core development by creating an account on GitHub."]] - (sut/mastocard->html link-card-with-image)))) \ No newline at end of file + (sut/mastocard->html link-card-with-image)))) From 7c5bc8f412284edcb608a8d27ef37f42540411d0 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 10 May 2024 12:10:59 +0200 Subject: [PATCH 09/11] Update build to gitlab and ddadevops --- .gitlab_ci.yml | 55 ++++++++++++++++++++ build.py | 133 ++++++++++++++++++++++++++++++++++++++++++++++++ shadow-cljs.edn | 4 +- 3 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 .gitlab_ci.yml create mode 100644 build.py diff --git a/.gitlab_ci.yml b/.gitlab_ci.yml new file mode 100644 index 0000000..822f9fc --- /dev/null +++ b/.gitlab_ci.yml @@ -0,0 +1,55 @@ +stages: + - build_and_test + - package + - upload + +.cljs-job: &cljs + image: "domaindrivenarchitecture/ddadevops-clj-cljs:4.11.3" + cache: + key: ${CI_COMMIT_REF_SLUG} + paths: + - node_modules/ + - .shadow-cljs/ + - .m2 + before_script: + - export RELEASE_ARTIFACT_TOKEN=$MEISSA_REPO_BUERO_RW + - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc + - npm install + +.tag_only: &tag_only + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + when: never + - if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/' + +test-cljs: + <<: *cljs + stage: build_and_test + script: + - pyb test_cljs + +report-frontend: + <<: *cljs + stage: package + script: + - pyb report_frontend + artifacts: + paths: + - target/frontend-build/build-report.html + +package-frontend: + <<: *cljs + stage: package + script: + - pyb package_frontend + artifacts: + paths: + - target/frontend-build + +release-to-forgejo: + <<: *cljs + <<: *tag_only + stage: upload + script: + - pyb publish_artifacts + diff --git a/build.py b/build.py new file mode 100644 index 0000000..7fa9f02 --- /dev/null +++ b/build.py @@ -0,0 +1,133 @@ +from os import environ +from subprocess import run +from pybuilder.core import init, task +from ddadevops import * + +default_task = "dev" +base_name = "dda-masto-embed" +name = 'dda-masto-embed' +MODULE = 'not-used' +PROJECT_ROOT_PATH = '.' + +version = "0.2.5" + +@init +def initialize(project): + project.build_depends_on("ddadevops>=4.7.0") + + input = { + "name": name, + "module": MODULE, + "stage": "notused", + "project_root_path": PROJECT_ROOT_PATH, + "build_types": [], + "mixin_types": ["RELEASE"], + "release_primary_build_file": "package.json", + "release_secondary_build_files": [ + "build.py" + ], + "release_artifact_server_url": "https://repo.prod.meissa.de", + "release_organisation": "meissa", + "release_repository_name": name, + "release_artifacts": [ + f"target/{name}.js", + ], + "release_main_branch": "master", + } + + build = ReleaseMixin(project, input) + build.initialize_build_dir() + + +@task +def test(project): + test_cljs(project) + + +@task +def test_cljs(project): + run("shadow-cljs compile test", shell=True, check=True) + run("node target/node-tests.js", shell=True, check=True) + + +@task +def report_frontend(project): + run("mkdir -p target/frontend-build", shell=True, check=True) + run( + "shadow-cljs run shadow.cljs.build-report frontend target/build-report.html", + shell=True, + check=True, + ) + + +@task +def package_frontend(project): + run("mkdir -p target/", shell=True, check=True) + run("shadow-cljs release frontend", shell=True, check=True) + run( + f"cp public/js/main.js target/{name}.js", + shell=True, + check=True, + ) + run( + f"sha256sum target/{name}.js > target/{name}.js.sha256", + shell=True, + check=True, + ) + run( + f"sha512sum target/{name}.js > target/{name}.js.sha512", + shell=True, + check=True, + ) + + +@task +def patch(project): + linttest(project, "PATCH") + release(project) + + +@task +def minor(project): + linttest(project, "MINOR") + release(project) + + +@task +def major(project): + linttest(project, "MAJOR") + release(project) + + +@task +def dev(project): + linttest(project, "NONE") + + +@task +def prepare(project): + build = get_devops_build(project) + build.prepare_release() + + +@task +def tag(project): + build = get_devops_build(project) + build.tag_bump_and_push_release() + + +@task +def publish_artifacts(project): + build = get_devops_build(project) + build.publish_artifacts() + + +def release(project): + prepare(project) + tag(project) + + +def linttest(project, release_type): + build = get_devops_build(project) + build.update_release_type(release_type) + test_cljs(project) diff --git a/shadow-cljs.edn b/shadow-cljs.edn index 757b154..539e868 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -14,9 +14,9 @@ :output-to "target/node-tests.js" :autorun true} :lib {:target :node-library - :output-to "target/lib.js" + :output-to "target/dda-masto-embed.js" :exports {:init dda.masto-embed.app/init} - :release {:compiler-options {:optimizations :simple}}} + :release {:compiler-options {:optimizations :advanced}}} :frontend {:target :browser :modules {:main {:init-fn dda.masto-embed.app/init}} :release {}}}} From d35335c2342c6a68045a66fb0cc10485bafa4137 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 10 May 2024 12:12:08 +0200 Subject: [PATCH 10/11] Fix ci file name --- .gitlab_ci.yml => .gitlab-ci.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .gitlab_ci.yml => .gitlab-ci.yml (100%) diff --git a/.gitlab_ci.yml b/.gitlab-ci.yml similarity index 100% rename from .gitlab_ci.yml rename to .gitlab-ci.yml From d926031406bc108c667691cbc67491dfe82515a6 Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 10 May 2024 12:23:07 +0200 Subject: [PATCH 11/11] Fix ci paths --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 822f9fc..82517d1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,7 +35,7 @@ report-frontend: - pyb report_frontend artifacts: paths: - - target/frontend-build/build-report.html + - target/build-report.html package-frontend: <<: *cljs @@ -44,7 +44,7 @@ package-frontend: - pyb package_frontend artifacts: paths: - - target/frontend-build + - target/ release-to-forgejo: <<: *cljs