mirror of
https://github.com/srid/nixos-config.git
synced 2025-12-26 15:04:59 +08:00
Simplify
This commit is contained in:
parent
af9786a87e
commit
10abd464ea
2 changed files with 14 additions and 19 deletions
|
|
@ -19,7 +19,13 @@ User wants to:
|
|||
|
||||
## Workflow
|
||||
|
||||
Extract article content and save it:
|
||||
|
||||
```bash
|
||||
@article-extractor@ "$URL"
|
||||
CONTENT=$(@article-extractor@ "$URL")
|
||||
```
|
||||
|
||||
Then use the Write tool to save `$CONTENT` to the desired location with an appropriate filename.
|
||||
|
||||
The script outputs clean markdown content to stdout. You decide where and how to save it based on the user's request.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
{ writeShellApplication, curl, reader }:
|
||||
|
||||
# Inspired by https://github.com/michalparkola/tapestry-skills-for-claude-code/blob/main/article-extractor/SKILL.md
|
||||
writeShellApplication {
|
||||
name = "article-extractor";
|
||||
|
||||
|
|
@ -9,26 +8,16 @@ writeShellApplication {
|
|||
text = ''
|
||||
URL="$1"
|
||||
|
||||
# Create unique temp file
|
||||
TEMP_HTML=$(mktemp)
|
||||
|
||||
# Download HTML
|
||||
curl -L "$URL" > /tmp/temp.html
|
||||
curl -s -L "$URL" > "$TEMP_HTML"
|
||||
|
||||
# Extract article
|
||||
reader /tmp/temp.html > /tmp/temp.txt
|
||||
|
||||
# Get title from first line
|
||||
TITLE=$(head -n 1 /tmp/temp.txt | sed 's/^# //')
|
||||
|
||||
# Clean filename
|
||||
FILENAME=$(echo "$TITLE" | tr '/:?"<>| ' '-' | cut -c 1-80 | sed 's/-*$//')".txt"
|
||||
|
||||
# Save
|
||||
mv /tmp/temp.txt "/tmp/$FILENAME"
|
||||
# Extract and output article to stdout
|
||||
reader "$TEMP_HTML"
|
||||
|
||||
# Clean up
|
||||
rm /tmp/temp.html
|
||||
|
||||
# Show preview
|
||||
echo "✓ Saved: /tmp/$FILENAME"
|
||||
head -n 10 "/tmp/$FILENAME"
|
||||
rm "$TEMP_HTML"
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue