From ce1cf5500f80fc31627cf2f33421ab59efeedcbe Mon Sep 17 00:00:00 2001 From: Isaac Freeman Date: Sun, 29 Oct 2023 15:43:45 +1300 Subject: [PATCH] Initial commit --- .editorconfig | 10 +++ .github/workflows/release-version.yml | 50 ++++++++++++++ .gitignore | 15 +++++ README.md | 95 +++++++++++++++++++++++++++ manifest.json | 7 ++ package.json | 7 ++ theme.css | 34 ++++++++++ version-bump.mjs | 26 ++++++++ versions.json | 3 + 9 files changed, 247 insertions(+) create mode 100644 .editorconfig create mode 100644 .github/workflows/release-version.yml create mode 100644 .gitignore create mode 100644 README.md create mode 100644 manifest.json create mode 100644 package.json create mode 100644 theme.css create mode 100644 version-bump.mjs create mode 100644 versions.json diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5fd185c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +# top-most EditorConfig file +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = tab +indent_size = 4 +tab_width = 4 \ No newline at end of file diff --git a/.github/workflows/release-version.yml b/.github/workflows/release-version.yml new file mode 100644 index 0000000..c1da420 --- /dev/null +++ b/.github/workflows/release-version.yml @@ -0,0 +1,50 @@ +name: Publish new theme version + +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - "*" # Push events to matching any tag format, i.e. 1.0, 20.15.10 + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Bundle + id: bundle + run: | + ls + echo "::set-output name=tag_name::$(git tag --sort version:refname | tail -n 1)" + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{ github.ref }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: false + prerelease: false + - name: Upload manifest.json + id: upload-manifest + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./manifest.json + asset_name: manifest.json + asset_content_type: application/json + - name: Upload theme.css + id: upload-css + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./theme.css + asset_name: theme.css + asset_content_type: text/css diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..32aa38e --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +# vscode +.vscode + +# Intellij +*.iml +.idea + +# npm +node_modules + +# Exclude sourcemaps +*.map + +# Exclude macOS Finder (System Explorer) View States +.DS_Store diff --git a/README.md b/README.md new file mode 100644 index 0000000..dc70192 --- /dev/null +++ b/README.md @@ -0,0 +1,95 @@ +This is a sample theme for Obsidian ([https://obsidian.md](https://obsidian.md/)). + +## First Time publishing a theme? + +### Quick start + +Pasted image 20220822135601 + +First, choose **Use this template**. That will create a copy of this repository (repo) under your Github profile. Then, you will want to _clone_ your new repository to your computer. + +Once you have the repo locally on your computer, there are a couple of placeholder fields you will need to fill in. + +1. Inside the `manifest.json` file, change the "name" field to whatever you want the name of your theme to be. For example: + + ```json + { + "name": "Moonstone", + "version": "0.0.0", + "minAppVersion": "1.0.0" + } + ``` + +2. Also inside the manifest.json file, you can include your name under next to the "author" field. + +After you have those fields configured, all that's left to do is add your styles! All of your CSS needs to be inside the file `theme.css` which is located at root of your repository. + +## Adding your theme to the Theme Gallery + +### Add a screenshot thumbnail + +Inside the repository, include a screenshot thumbnail of your theme. You can name the file anything, for example `screenshot.png`. This image will be used for the small preview in the theme list. + +Your screenshot file should be `16:9` aspect ratio. +The recommended size is 512x288. + +### Submit your theme for review + +To have your theme included in the Theme Gallery, you will need to submit a Pull Request to [`obsidianmd/obsidian-releases`](https://github.com/obsidianmd/obsidian-releases#community-theme). + +## Releasing Versions _(Optional)_ + +If your theme is getting more and more complex, you might want to start thinking about how your theme will stay compatible with different versions of Obsidian. Introduced in v0.16 of Obsidian, themes support [Github Releases](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository). This means that you can specify which versions of your theme are compatible with which versions of Obsidian. + +### Steps for releasing the initial version of your theme (1.0.0) + +1. From your theme's repository, click on "Releases". + +Pasted image 20220822145001 + +2. On the Releases page, there should be a button to **Draft a new Release**. Press it. + +Pasted image 20220822145048 + +3. Fill out the Release information form. + - **Choose a Tag**: Type in the name of the version number here. At the bottom of the dropdown should be a button to create a new tag with your latest theme changes. Choose this option. + Pasted image 20220822145648 + - **Release Title**: This can be the version number. + - **Description** _Optional_: Anything that changed + - **Files:** The most important part of this form is uploading the files. You can do this by dragging 'n dropping the `manifest.json` file and the `theme.css` file your for theme inside the file upload field. + +Pasted image 20220822145356 + +4. Click "Publish Release." +5. Make sure that `versions.json` is set up correctly. This file is a map. + ```json + { + "1.0.0": "0.16.0" + } + ``` + + This means that version 1.0.0 of your theme is compatible with version 0.16.0 of Obsidian. For the initial release of your theme, you shouldn't need to make any changes to this file. + +### Steps for releasing new versions + +Releasing a new version of your theme is the same as releasing the initial version. + +1. From your theme's repository, click on "Releases." +2. On the Releases page, there should be a button to **Draft a new Release**. Press it. +3. Fill out the Release information form. + - **Choose a Tag**: Type in the name of the version number here. At the bottom of the dropdown should be a button to create a new tag with your latest theme changes. Choose this option. + Pasted image 20220822145812 + - **Release Title**: This can be the version number. + - **Description** _Optional_: Anything that changed + - **Files:** The most important part of this form is uploading the files. You can do this by dragging 'n dropping the `manifest.json` file and the `theme.css` file your for theme inside the file upload field. + +4. Click "Publish Release." +5. Update the `versions.json` file in your repository. For the initial release of your theme, you probably didn't need to make any changes to the `versions.json` file. When you release subsequent versions of your theme; however, it's best practice to include the new version as entry in the versions.json file. So this might look like: + ```json + { + "1.0.0": "0.16.0", + "1.0.1": "0.16.0" + } + ``` + + What's important to note here is: the new version is included as the "key" and the "value" is the minimum version of Obsidian that your theme compatible with. So if the new version of your theme is only compatible with an Insider version of Obsidian, it's important to set this value accordingly. This will prevent users on older versions of Obsidian from updating to the newer version of your theme. diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..a3ebe75 --- /dev/null +++ b/manifest.json @@ -0,0 +1,7 @@ +{ + "name": "Sample Theme", + "version": "1.0.0", + "minAppVersion": "1.0.0", + "author": "Obsidian", + "authorUrl": "https://obsidian.md" +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..3adfc39 --- /dev/null +++ b/package.json @@ -0,0 +1,7 @@ +{ + "name": "sample-obsidian-theme", + "version": "1.0.0", + "scripts": { + "version": "node version-bump.mjs && git add manifest.json versions.json" + } +} diff --git a/theme.css b/theme.css new file mode 100644 index 0000000..2307fc8 --- /dev/null +++ b/theme.css @@ -0,0 +1,34 @@ +body { + --radius-s: 0px; + --radius-m: 0px; + --radius-l: 0px; + --input-radius: 0px; + --tab-radius-active: 0px; + --checkbox-radius: 0px; + --toggle-radius: 0px; + --toggle-thumb-radius: 0px; + --slider-thumb-radius: 0px; +} + +.workspace-tab-header.is-active::before, .workspace-tab-header.is-active::after { + display: none; +} + +svg * { + stroke-linecap: square; + stroke-linejoin: miter; + rx: 0; + ry: 0; +} + +.menu { + padding: var(--size-2-1); +} + +.menu-item { + padding: var(--size-4-1) var(--size-4-2); +} + +.menu-separator { + margin: var(--size-2-1) calc(var(--size-2-1) * -1); +} diff --git a/version-bump.mjs b/version-bump.mjs new file mode 100644 index 0000000..9d0e052 --- /dev/null +++ b/version-bump.mjs @@ -0,0 +1,26 @@ +/** + * This script makes it slightly easier to release new versions of your + * theme. If you are not using Github Releases with your theme, or + * you are not interested in automating the process, you can safely ignore + * this script. + * + * Usage: `$ npm run version` + * + * This script will automatically add a new entry to the versions.json file for + * the current version of your theme. + */ + +import { readFileSync, writeFileSync } from "fs"; + +const targetVersion = process.env.npm_package_version; + +// read minAppVersion from manifest.json and bump version to target version +let manifest = JSON.parse(readFileSync("manifest.json", "utf8")); +const { minAppVersion } = manifest; +manifest.version = targetVersion; +writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t")); + +// update versions.json with target version and minAppVersion from manifest.json +let versions = JSON.parse(readFileSync("versions.json", "utf8")); +versions[targetVersion] = minAppVersion; +writeFileSync("versions.json", JSON.stringify(versions, null, "\t")); diff --git a/versions.json b/versions.json new file mode 100644 index 0000000..6ac7b35 --- /dev/null +++ b/versions.json @@ -0,0 +1,3 @@ +{ + "1.0.0": "1.0.0" +} \ No newline at end of file