-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:danielmiessler/fabric
- Loading branch information
Showing
17 changed files
with
274 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Update Version File and Create Tag | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # Monitor the main branch | ||
|
||
permissions: | ||
contents: write # Ensure the workflow has write permissions | ||
|
||
jobs: | ||
update-version: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Fetch all history to include tags | ||
|
||
- name: Set up Git | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
- name: Get the latest tag | ||
id: get_latest_tag | ||
run: | | ||
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | ||
echo "Latest tag is: $latest_tag" | ||
echo "tag=$latest_tag" >> $GITHUB_ENV # Save the latest tag to environment file | ||
- name: Increment patch version | ||
id: increment_version | ||
run: | | ||
latest_tag=${{ env.tag }} | ||
major=$(echo "$latest_tag" | cut -d. -f1 | sed 's/v//') | ||
minor=$(echo "$latest_tag" | cut -d. -f2) | ||
patch=$(echo "$latest_tag" | cut -d. -f3) | ||
new_patch=$((patch + 1)) | ||
new_tag="v${major}.${minor}.${new_patch}" | ||
echo "New tag is: $new_tag" | ||
echo "new_tag=$new_tag" >> $GITHUB_ENV # Save the new tag to environment file | ||
- name: Update version.go file | ||
run: | | ||
echo "package main" > version.go | ||
echo "" >> version.go | ||
echo "var version = \"${{ env.new_tag }}\"" >> version.go | ||
- name: Commit changes | ||
run: | | ||
git add version.go | ||
git commit -m "Update version to ${{ env.new_tag }} and commit $commit_hash" | ||
- name: Push changes | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use GITHUB_TOKEN to authenticate the push | ||
run: | | ||
git push origin main # Push changes to the main branch | ||
- name: Create a new tag | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git tag ${{ env.new_tag }} | ||
git push origin ${{ env.new_tag }} # Push the new tag |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ __pycache__/ | |
|
||
# Distribution / packaging | ||
.Python | ||
.idea | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package converter | ||
|
||
import ( | ||
"bytes" | ||
"github.com/go-shiori/go-readability" | ||
) | ||
|
||
// HtmlReadability Convert HTML input into a clean, readable view | ||
// args: | ||
// | ||
// html (string): full data of web page | ||
// | ||
// return: | ||
// | ||
// viewContent (string): html main content | ||
// err (error): parser error | ||
func HtmlReadability(html string) (ret string, err error) { | ||
buf := bytes.NewBufferString(html) | ||
var article readability.Article | ||
if article, err = readability.FromReader(buf, nil); err != nil { | ||
return | ||
} | ||
ret = article.TextContent | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package converter | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestHtmlReadability(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
html string | ||
expected string | ||
}{ | ||
{ | ||
name: "Empty HTML", | ||
html: "", | ||
expected: "", | ||
}, | ||
{ | ||
name: "HTML with text", | ||
html: "<p>Hello World</p>", | ||
expected: "Hello World", | ||
}, | ||
{ | ||
name: "HTML with nested tags", | ||
html: "<div><p>Hello</p><p>World</p></div>", | ||
expected: "HelloWorld", | ||
}, | ||
{ | ||
name: "HTML missing tags", | ||
html: "<div><p>Hello</p><p>World</div>", | ||
expected: "HelloWorld", | ||
}, | ||
} | ||
|
||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
result, err := HtmlReadability(tc.html) | ||
|
||
// 验证结果 | ||
assert.NoError(t, err) | ||
assert.Equal(t, tc.expected, result) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.