From 94d9685815cf03b4f6b16e297ee2af7e721dc76d Mon Sep 17 00:00:00 2001 From: piyoppi Date: Sat, 9 Mar 2024 20:26:39 +0900 Subject: [PATCH 1/2] Fix README, Sample Code and add license --- CHANGELOG.md | 3 +++ LICENSE | 9 +++++++++ README.md | 29 ++++++++++++++++++++++------- samples/README.md | 10 ++++++++-- samples/sample-code.html | 27 +++++++++++++++++++++++++++ samples/sample-code.js | 12 ++++++------ src/main.rs | 5 +++++ 7 files changed, 80 insertions(+), 15 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 samples/sample-code.html diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0e8bcb1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# 0.1.0 + +Initial Release diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..73f06d6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright 2024 piyoppi + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index be4e171..5969734 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ## Usage ``` -chiritori --filename=./sample-code.html +chiritori --filename=./samples/sample-code.html ``` This command will remove the parts of the following source code bounded by the "time-limited" element. @@ -16,7 +16,10 @@ This command will remove the parts of the following source code bounded by the "

Hello World

-

Campaign until 2024/02/15 12:00

+

Campaign until 2024/02/15 12:00

+ + +

Campaign until 9999/12/31

@@ -27,22 +30,34 @@ This command will remove the parts of the following source code bounded by the "

Hello World

+ +

Campaign until 9999/12/31

+ ``` +For more options, run the following commands. + +``` +chiritori --help +``` + The delimiter for representing an element can be changed via command line arguments. This allows any programming language to be used. ``` chiritori \ - --filename=./sample-code.js \ - --time-limited-delimiter-start="// --" \ - --time-limited-delimiter-end="-- //" + --filename=./samples/sample-code.js \ + --delimiter-start="// --" \ + --delimiter-end="-- //" \ + --time-limited-tag-name="time-limited-code" ``` +### Supported character code + Only UTF-8 character encoding is supported. If you want to enter other character codes, you need to convert it. ``` -iconv -f euc-jp -t utf-8 ./sample-code.php | chiritori -``` \ No newline at end of file +iconv -f euc-jp -t utf-8 ./sample-code.php | chiritori | iconv -f utf-8 -t euc-jp +``` diff --git a/samples/README.md b/samples/README.md index 891bc3f..6e9e370 100644 --- a/samples/README.md +++ b/samples/README.md @@ -2,14 +2,20 @@ Run Chiritori with the sample code in this directory to experience how it works. +## HTML + +``` +chiritori --filename=./samples/sample-code.html +``` + ## JavaScript ``` -chiritori --filename=sample-code.js --time-limited-delimiter-start="// --" --time-limited-delimiter-end="-- //" +chiritori --filename=./samples/sample-code.js --delimiter-start="// --" --delimiter-end="-- //" --time-limited-tag-name="time-limited-code" ``` ## PHP (EUC-JP encoding) ``` iconv -f euc-jp -t utf-8 sample-code.eucjp.php | chiritori --time-limited-delimiter-start="# <" --time-limited-delimiter-end="> #" -``` \ No newline at end of file +``` diff --git a/samples/sample-code.html b/samples/sample-code.html new file mode 100644 index 0000000..826c8d9 --- /dev/null +++ b/samples/sample-code.html @@ -0,0 +1,27 @@ + + + + Sample Code + + + +

Hello World

+

This is a sample page with some code.

+ +

This content is only available until the end of the year.

+

After that, it will be removed from the page.

+ + + Campaign! + + 40% off! Only until the 2001/12/31! + + + + + Campaign! + + until the 2001/12/31! + + + diff --git a/samples/sample-code.js b/samples/sample-code.js index 61b7d81..af99923 100644 --- a/samples/sample-code.js +++ b/samples/sample-code.js @@ -2,16 +2,16 @@ function main() { console.log('Hello, World! 1'); - // -- time-limited code to="2020-12-31 23:59:59" -- // + // -- time-limited-code to="2020-12-31 23:59:59" -- // console.log('🧹This code will be removed after 2020-12-31T23:59:59.999Z'); - // -- /time-limited -- // + // -- /time-limited-code -- // - // -- time-limited code to="2099-12-31 23:59:59" -- // + // -- time-limited-code to="2099-12-31 23:59:59" -- // console.log('📌This code will be removed after 2099-12-31T23:59:59.999Z'); - // -- /time-limited -- // + // -- /time-limited-code -- // - // -- time-limited code to="2020-12-31 23:59:59" -- // + // -- time-limited-code to="2020-12-31 23:59:59" -- // console.log('🧹This code will be removed after 2020-12-31T23:59:59.999Z'); - // -- /time-limited -- // + // -- /time-limited-code -- // console.log('Hello, World! 2'); } diff --git a/src/main.rs b/src/main.rs index 266411a..1877bf0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,18 +20,23 @@ struct Args { #[arg(short, long)] output: Option, + /// The tag name for time-limited content #[arg(long, default_value = "time-limited")] time_limited_tag_name: String, + /// The time offset for time-limited content #[arg(long, default_value = "+00:00")] time_limited_time_offset: String, + /// The current time for time-limited content #[arg(long, default_value = "")] time_limited_current: String, + /// The delimiter start #[arg(long, default_value = "")] delimiter_end: String, } From 34f29987375dbc7bee056c866f472710c9d38e6c Mon Sep 17 00:00:00 2001 From: piyoppi Date: Sat, 9 Mar 2024 20:27:23 +0900 Subject: [PATCH 2/2] Fix release workflow --- .../{release-nightly.yml => release.yml} | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) rename .github/workflows/{release-nightly.yml => release.yml} (77%) diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release.yml similarity index 77% rename from .github/workflows/release-nightly.yml rename to .github/workflows/release.yml index 80e9bd0..72e2e57 100644 --- a/.github/workflows/release-nightly.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,11 @@ -name: Release-Nightly +name: Attach Release Asset on: push: branches: - main - + tags: + - 'v*.*.*' jobs: build: name: Build and Release @@ -46,7 +47,7 @@ jobs: with: name: macos-latest-binary - - name: Create Release + - name: Create Release (nightly) uses: softprops/action-gh-release@v1 with: tag_name: nightly @@ -55,3 +56,12 @@ jobs: files: | ubuntu-latest.tar.gz macos-latest.tar.gz + + - name: Create Release(Release) + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/v') + with: + tag_name: ${{ github.ref }} + files: | + ubuntu-latest.tar.gz + macos-latest.tar.gz