| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #!/bin/bash
- # CURL käsk transport_context sisestamisega - LIHTSUSTATUD VERSIOON
- # Kasutab jq-d JSON-i formateerimiseks
- # Salvestatakse markdown faili ja eksporditud PDF-ks VS Code Markdown PDF laiendusega
- set -e
- GRAPHQL_URL="http://100.80.222.54:9020/v1/graphql"
- OUTPUT_FILE="$HOME/Downloads/articles_with_transport_context.md"
- echo "📡 Toon artikleid GraphQL API-st..."
- curl -s "$GRAPHQL_URL" \
- -X POST \
- -H "Content-Type: application/json" \
- -d '{
- "query": "{ Get { ScientificArticle { title source_file summary_et transport_context } } }"
- }' \
- | jq -r '
- "<style>\n@media print {\n h2 {\n page-break-before: always;\n }\n h2:first-of-type {\n page-break-before: avoid;\n }\n}\n</style>\n\n# Teadusartiklite analüüs\n\nEksporditud: " + (now | strftime("%d.%m.%Y %H:%M")) + "\n\n---\n\n",
- (.data.Get.ScientificArticle[] |
- "\n## " + .title + "\n\n" +
- "**Allikfail:** `" + (.source_file | split("/") | .[-1]) + "`\n\n" +
- "### Kokkuvõte (eesti keeles)\n\n" +
- .summary_et + "\n\n" +
- "### Transpordiplaneerimise kontekst\n\n" +
- (
- if .transport_context then
- (
- .transport_context |
- if type == "string" then
- (
- gsub("```json\\s*"; "") |
- gsub("\\s*```"; "") |
- .
- )
- else
- @json
- end
- )
- else
- "Andmeid pole saadaval"
- end
- ) + "\n\n---\n"
- )' \
- > "$OUTPUT_FILE"
- if [ -f "$OUTPUT_FILE" ]; then
- echo "✅ Markdown fail salvestatud: $OUTPUT_FILE"
- echo ""
- echo "🚀 Järgmised sammud:"
- echo " 1. Avage fail VS Code'is: code $OUTPUT_FILE"
- echo " 2. Paremklõps failil → 'Markdown PDF: Export (pdf)'"
- echo " 3. PDF fail luuakse samasse kausta"
- echo ""
- echo "💡 Juhised: Vaata README_CURL_TRANSPORT_CONTEXT.md"
- else
- echo "❌ Viga: markdown faili ei õnnestunud luua"
- exit 1
- fi
|