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 diff --git a/.gitignore b/.gitignore index 75edf4d..f22e62a 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ node_modules/ package-lock.json /.lsp/ /.clj-kondo/ + +*.pyc \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..82517d1 --- /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/build-report.html + +package-frontend: + <<: *cljs + stage: package + script: + - pyb package_frontend + artifacts: + paths: + - target/ + +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 {}}}} diff --git a/src/main/dda/masto_embed/account_mode.cljs b/src/main/dda/masto_embed/account_mode.cljs index e12135e..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 [:account :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"} @@ -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 %))) + (filter #(= nil (:in_reply_to_account_id %))) (take 4) (masto->html) (render-html) 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)))) 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"}