Compare commits
15 Commits
claude
...
8aec22cc86
| Author | SHA1 | Date | |
|---|---|---|---|
|
8aec22cc86
|
|||
|
4862afe8d6
|
|||
|
0d745e2174
|
|||
|
00b4b8f21e
|
|||
|
b4ed1951d0
|
|||
|
a5a12a4310
|
|||
|
251984d1e7
|
|||
|
2f1f881ce1
|
|||
|
2029720006
|
|||
|
3ebc0c8aef
|
|||
|
e7f39a1894
|
|||
|
980e9c1259
|
|||
|
8f27cbb77b
|
|||
|
c4d225e643
|
|||
|
bc712a933b
|
@@ -1,33 +1,20 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"WebFetch(domain:card.syui.ai)",
|
||||
"Bash(git commit:*)",
|
||||
"Bash(git checkout:*)",
|
||||
"Bash(mkdir:*)",
|
||||
"Bash(chmod:*)",
|
||||
"Bash(./start_server.sh:*)",
|
||||
"Bash(npm run dev:*)",
|
||||
"Bash(npm install)",
|
||||
"WebFetch(domain:github.com)",
|
||||
"Bash(nvm use:*)",
|
||||
"Bash(npm run dev:*)",
|
||||
"Bash(npm run build:*)",
|
||||
"Bash(npm run preview:*)",
|
||||
"Bash(curl:*)",
|
||||
"Bash(sudo kill:*)",
|
||||
"Bash(launchctl:*)",
|
||||
"Bash(ls:*)",
|
||||
"Bash(cat:*)",
|
||||
"Bash(find:*)",
|
||||
"Bash(cloudflared:*)",
|
||||
"Bash(grep:*)",
|
||||
"Bash(nslookup:*)",
|
||||
"Bash(sqlite3:*)",
|
||||
"Bash(kill:*)",
|
||||
"Bash(pkill:*)",
|
||||
"WebFetch(domain:docs.bsky.app)",
|
||||
"Bash(npm install:*)",
|
||||
"WebFetch(domain:raw.githubusercontent.com)",
|
||||
"WebFetch(domain:www.npmjs.com)",
|
||||
"Bash(rm:*)",
|
||||
"Bash(cargo:*)"
|
||||
"Bash(npx serve:*)",
|
||||
"Bash(python3:*)",
|
||||
"Bash(git add:*)",
|
||||
"Bash(open:*)",
|
||||
"WebFetch(domain:api.syui.ai)"
|
||||
],
|
||||
"deny": []
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# Development configuration for ai.card
|
||||
# This file is used for local development
|
||||
|
||||
# Web Frontend Configuration
|
||||
VITE_WEB_HOST=http://localhost:5173
|
||||
VITE_API_HOST=http://localhost:8000
|
||||
VITE_WEB_PORT=5173
|
||||
|
||||
# API Backend Configuration
|
||||
API_HOST=localhost
|
||||
API_PORT=8000
|
||||
|
||||
# OAuth Configuration
|
||||
VITE_OAUTH_CLIENT_NAME=ai.card
|
||||
VITE_OAUTH_REDIRECT_PATH=/oauth/callback
|
||||
|
||||
# Feature Flags
|
||||
VITE_ENABLE_AI_FEATURES=true
|
||||
34
.github/workflows/gh-pages.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
name: github pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- react-migration
|
||||
|
||||
jobs:
|
||||
build-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 23
|
||||
ref: ${{ github.ref }}
|
||||
fetch-depth: 0
|
||||
- run: |
|
||||
npm install
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
TZ: "Asia/Tokyo"
|
||||
run: |
|
||||
npm run build
|
||||
|
||||
- name: Deploy
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./dist
|
||||
user_name: 'ai[bot]'
|
||||
user_email: '138105980+yui-syui-ai[bot]@users.noreply.github.com'
|
||||
58
.gitignore
vendored
@@ -1,60 +1,3 @@
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
*.so
|
||||
.Python
|
||||
env/
|
||||
venv/
|
||||
.venv/
|
||||
.env
|
||||
|
||||
# FastAPI
|
||||
.pytest_cache/
|
||||
.coverage
|
||||
htmlcov/
|
||||
*.log
|
||||
|
||||
# Database
|
||||
*.db
|
||||
*.sqlite3
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
# Node
|
||||
node_modules/
|
||||
dist/
|
||||
build/
|
||||
.next/
|
||||
.nuxt/
|
||||
*.log*
|
||||
|
||||
# iOS
|
||||
*.xcworkspace
|
||||
xcuserdata/
|
||||
*.xcscmblueprint
|
||||
*.xccheckout
|
||||
DerivedData/
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
Pods/
|
||||
|
||||
# Secrets
|
||||
.env.local
|
||||
.env.production
|
||||
secrets/
|
||||
*.key
|
||||
*.pem
|
||||
|
||||
# Origin
|
||||
node_modules
|
||||
dist
|
||||
tt
|
||||
@@ -63,4 +6,3 @@ yarn-error.log
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
**DS_Store
|
||||
cloudflared-config*
|
||||
|
||||
54
Cargo.toml
@@ -1,54 +0,0 @@
|
||||
[package]
|
||||
name = "aicard"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
description = "ai.card API server - Rust implementation of autonomous card collection system"
|
||||
authors = ["syui"]
|
||||
|
||||
[dependencies]
|
||||
# Core Web Framework
|
||||
axum = { version = "0.7", features = ["macros", "multipart"] }
|
||||
tokio = { version = "1.0", features = ["full"] }
|
||||
tower = { version = "0.4", features = ["full"] }
|
||||
tower-http = { version = "0.5", features = ["cors", "trace"] }
|
||||
|
||||
# Database & ORM
|
||||
sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "postgres", "sqlite", "uuid", "chrono", "migrate"] }
|
||||
uuid = { version = "1.0", features = ["v4", "serde"] }
|
||||
|
||||
# Serialization & Validation
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
validator = { version = "0.18", features = ["derive"] }
|
||||
|
||||
# Date/Time
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
|
||||
# Authentication & Security
|
||||
jsonwebtoken = "9.0"
|
||||
bcrypt = "0.15"
|
||||
|
||||
# HTTP Client (for atproto integration)
|
||||
reqwest = { version = "0.11", features = ["json"] }
|
||||
|
||||
# Configuration
|
||||
config = "0.13"
|
||||
dotenvy = "0.15"
|
||||
|
||||
# CLI
|
||||
clap = { version = "4.0", features = ["derive"] }
|
||||
|
||||
# Random (for gacha system)
|
||||
rand = "0.8"
|
||||
|
||||
# Error Handling
|
||||
anyhow = "1.0"
|
||||
thiserror = "1.0"
|
||||
|
||||
# Logging
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
|
||||
# Development
|
||||
serde_yaml = "0.9"
|
||||
dirs = "5.0"
|
||||
143
README.md
@@ -1,143 +0,0 @@
|
||||
# ai.card プロジェクト固有情報
|
||||
|
||||
## プロジェクト概要
|
||||
- **名前**: ai.card
|
||||
- **パッケージ**: aicard
|
||||
- **タイプ**: atproto基盤カードゲーム
|
||||
- **役割**: ユーザーデータ主権カードゲームシステム
|
||||
|
||||
## 実装状況
|
||||
|
||||
### 現在の状況
|
||||
- **ai.bot統合**: ai.botの機能として実装済み
|
||||
- **カード取得**: atproto accountでmentionすると1日1回カード取得可能
|
||||
- **データ管理**: ai.api (MCP server) でユーザー管理
|
||||
|
||||
### 独立MCPサーバー(ai.gpt連携)
|
||||
- **場所**: `/Users/syui/ai/gpt/card/`
|
||||
- **サーバー**: FastAPI + fastapi_mcp (port 8000)
|
||||
- **統合**: ai.gptサーバーからHTTP連携
|
||||
|
||||
## アーキテクチャ構成
|
||||
|
||||
### 技術スタック
|
||||
- **Backend**: FastAPI + MCP
|
||||
- **Frontend**: React Web UI + SwiftUI iOS app
|
||||
- **Data**: atproto collection record(ユーザー所有)
|
||||
- **Auth**: OAuth 2.1 scope(実装待ち)
|
||||
|
||||
### データフロー
|
||||
```
|
||||
ユーザー → ai.bot mention → カード生成 → atproto collection → ユーザー所有
|
||||
↑ ↓
|
||||
← iOS app表示 ← ai.card API ←
|
||||
```
|
||||
|
||||
## 移行計画
|
||||
|
||||
### Phase 1: 独立化
|
||||
- **iOS移植**: Claude担当予定
|
||||
- **Web UI**: React実装
|
||||
- **API独立**: ai.botからの分離
|
||||
|
||||
### Phase 2: データ主権実装
|
||||
- **atproto collection**: カードデータをユーザー所有に
|
||||
- **OAuth 2.1**: 不正防止機能実装
|
||||
- **画像ファイル**: Cloudflare Pages最適化
|
||||
|
||||
### Phase 3: ゲーム機能拡張
|
||||
- **ガチャシステム**: 確率・レアリティ管理
|
||||
- **トレード機能**: ユーザー間カード交換
|
||||
- **デッキ構築**: カードゲーム戦略要素
|
||||
|
||||
## yui system適用
|
||||
|
||||
### 唯一性担保
|
||||
- **カード効果**: アカウント固有の効果設定
|
||||
- **改ざん防止**: ハッシュ・署名による保証
|
||||
- **ゲームバランス**: 唯一性による公平性維持
|
||||
|
||||
### ai.verse連携
|
||||
- **ゲーム内アイテム**: ai.verseでのカード利用
|
||||
- **固有スキル**: カードとキャラクターの連動
|
||||
- **現実反映**: カード取得がゲーム内能力に影響
|
||||
|
||||
## ディレクトリ構成
|
||||
|
||||
```
|
||||
/Users/syui/ai/gpt/card/
|
||||
├── api/ # FastAPI + MCP server
|
||||
├── web/ # React Web UI
|
||||
├── ios/ # SwiftUI iOS app
|
||||
└── docs/ # 開発ドキュメント
|
||||
```
|
||||
|
||||
## MCPツール(ai.gpt連携)
|
||||
|
||||
### カード管理
|
||||
- **card_get_user_cards**: ユーザーカード取得
|
||||
- **card_draw_card**: ガチャ実行
|
||||
- **card_analyze_collection**: コレクション分析
|
||||
- **card_check_daily_limit**: 日次制限確認
|
||||
- **card_get_card_stats**: カード統計情報
|
||||
- **card_manage_deck**: デッキ管理
|
||||
|
||||
## 開発状況
|
||||
|
||||
### 完成済み機能
|
||||
- ✅ **基本カード生成**: ai.bot統合での1日1回取得
|
||||
- ✅ **atproto連携**: mention機能
|
||||
- ✅ **MCP統合**: ai.gptからの操作
|
||||
|
||||
### 開発中機能
|
||||
- 🔧 **iOS app**: SwiftUI実装
|
||||
- 🔧 **Web UI**: React実装
|
||||
- 🔧 **独立API**: FastAPI server
|
||||
|
||||
### 将来機能
|
||||
- 📋 **OAuth 2.1**: 不正防止強化
|
||||
- 📋 **画像最適化**: Cloudflare Pages
|
||||
- 📋 **ゲーム拡張**: トレード・デッキ戦略
|
||||
|
||||
## ai.botからの移行詳細
|
||||
|
||||
### 現在のai.bot実装
|
||||
- **Rust製**: seahorse CLI framework
|
||||
- **atproto連携**: mention機能でカード配布
|
||||
- **日次制限**: 1アカウント1日1回取得
|
||||
- **自動生成**: AI絵画(Leonardo.AI + Stable Diffusion)
|
||||
|
||||
### 独立化の理由
|
||||
- **iOS展開**: モバイルアプリでの独立した体験
|
||||
- **ゲーム拡張**: デッキ構築・バトル機能の追加
|
||||
- **データ主権**: ユーザーによる完全なデータ所有
|
||||
- **スケーラビリティ**: サーバー負荷分散
|
||||
|
||||
## 技術的課題と解決策
|
||||
|
||||
### データ改ざん防止
|
||||
- **短期**: MCP serverによる検証
|
||||
- **中期**: OAuth 2.1 scope実装待ち
|
||||
- **長期**: ブロックチェーン的整合性チェック
|
||||
|
||||
### スケーラビリティ
|
||||
- **画像配信**: Cloudflare Pages活用
|
||||
- **API負荷**: FastAPIによる高速処理
|
||||
- **データ保存**: atproto分散ストレージ
|
||||
|
||||
### ユーザー体験
|
||||
- **直感的UI**: iOS/Webでの統一UX
|
||||
- **リアルタイム更新**: WebSocketでの即座反映
|
||||
- **オフライン対応**: ローカルキャッシュ機能
|
||||
|
||||
## ai.game連携構想
|
||||
|
||||
### Play-to-Work統合
|
||||
- **カードゲームプレイ → 業務成果変換**: ai.gameデバイスでの労働ゲーム化
|
||||
- **デッキ構築戦略 → 企業戦略思考**: カード組み合わせが戦略思考を鍛練
|
||||
- **トレード交渉 → ビジネススキル**: 他プレイヤーとの交渉が実務能力向上
|
||||
|
||||
### メタバース展開
|
||||
- **ai.verse統合**: 3D世界でのカードバトル
|
||||
- **アバター連動**: 所有カードがキャラクター能力に影響
|
||||
- **配信コンテンツ**: カードゲームが配信可能なエンターテイメント
|
||||
143
claude.md
@@ -1,143 +0,0 @@
|
||||
# ai.card プロジェクト固有情報
|
||||
|
||||
## プロジェクト概要
|
||||
- **名前**: ai.card
|
||||
- **パッケージ**: aicard
|
||||
- **タイプ**: atproto基盤カードゲーム
|
||||
- **役割**: ユーザーデータ主権カードゲームシステム
|
||||
|
||||
## 実装状況
|
||||
|
||||
### 現在の状況
|
||||
- **ai.bot統合**: ai.botの機能として実装済み
|
||||
- **カード取得**: atproto accountでmentionすると1日1回カード取得可能
|
||||
- **データ管理**: ai.api (MCP server) でユーザー管理
|
||||
|
||||
### 独立MCPサーバー(ai.gpt連携)
|
||||
- **場所**: `/Users/syui/ai/gpt/card/`
|
||||
- **サーバー**: FastAPI + fastapi_mcp (port 8000)
|
||||
- **統合**: ai.gptサーバーからHTTP連携
|
||||
|
||||
## アーキテクチャ構成
|
||||
|
||||
### 技術スタック
|
||||
- **Backend**: FastAPI + MCP
|
||||
- **Frontend**: React Web UI + SwiftUI iOS app
|
||||
- **Data**: atproto collection record(ユーザー所有)
|
||||
- **Auth**: OAuth 2.1 scope(実装待ち)
|
||||
|
||||
### データフロー
|
||||
```
|
||||
ユーザー → ai.bot mention → カード生成 → atproto collection → ユーザー所有
|
||||
↑ ↓
|
||||
← iOS app表示 ← ai.card API ←
|
||||
```
|
||||
|
||||
## 移行計画
|
||||
|
||||
### Phase 1: 独立化
|
||||
- **iOS移植**: Claude担当予定
|
||||
- **Web UI**: React実装
|
||||
- **API独立**: ai.botからの分離
|
||||
|
||||
### Phase 2: データ主権実装
|
||||
- **atproto collection**: カードデータをユーザー所有に
|
||||
- **OAuth 2.1**: 不正防止機能実装
|
||||
- **画像ファイル**: Cloudflare Pages最適化
|
||||
|
||||
### Phase 3: ゲーム機能拡張
|
||||
- **ガチャシステム**: 確率・レアリティ管理
|
||||
- **トレード機能**: ユーザー間カード交換
|
||||
- **デッキ構築**: カードゲーム戦略要素
|
||||
|
||||
## yui system適用
|
||||
|
||||
### 唯一性担保
|
||||
- **カード効果**: アカウント固有の効果設定
|
||||
- **改ざん防止**: ハッシュ・署名による保証
|
||||
- **ゲームバランス**: 唯一性による公平性維持
|
||||
|
||||
### ai.verse連携
|
||||
- **ゲーム内アイテム**: ai.verseでのカード利用
|
||||
- **固有スキル**: カードとキャラクターの連動
|
||||
- **現実反映**: カード取得がゲーム内能力に影響
|
||||
|
||||
## ディレクトリ構成
|
||||
|
||||
```
|
||||
/Users/syui/ai/gpt/card/
|
||||
├── api/ # FastAPI + MCP server
|
||||
├── web/ # React Web UI
|
||||
├── ios/ # SwiftUI iOS app
|
||||
└── docs/ # 開発ドキュメント
|
||||
```
|
||||
|
||||
## MCPツール(ai.gpt連携)
|
||||
|
||||
### カード管理
|
||||
- **card_get_user_cards**: ユーザーカード取得
|
||||
- **card_draw_card**: ガチャ実行
|
||||
- **card_analyze_collection**: コレクション分析
|
||||
- **card_check_daily_limit**: 日次制限確認
|
||||
- **card_get_card_stats**: カード統計情報
|
||||
- **card_manage_deck**: デッキ管理
|
||||
|
||||
## 開発状況
|
||||
|
||||
### 完成済み機能
|
||||
- ✅ **基本カード生成**: ai.bot統合での1日1回取得
|
||||
- ✅ **atproto連携**: mention機能
|
||||
- ✅ **MCP統合**: ai.gptからの操作
|
||||
|
||||
### 開発中機能
|
||||
- 🔧 **iOS app**: SwiftUI実装
|
||||
- 🔧 **Web UI**: React実装
|
||||
- 🔧 **独立API**: FastAPI server
|
||||
|
||||
### 将来機能
|
||||
- 📋 **OAuth 2.1**: 不正防止強化
|
||||
- 📋 **画像最適化**: Cloudflare Pages
|
||||
- 📋 **ゲーム拡張**: トレード・デッキ戦略
|
||||
|
||||
## ai.botからの移行詳細
|
||||
|
||||
### 現在のai.bot実装
|
||||
- **Rust製**: seahorse CLI framework
|
||||
- **atproto連携**: mention機能でカード配布
|
||||
- **日次制限**: 1アカウント1日1回取得
|
||||
- **自動生成**: AI絵画(Leonardo.AI + Stable Diffusion)
|
||||
|
||||
### 独立化の理由
|
||||
- **iOS展開**: モバイルアプリでの独立した体験
|
||||
- **ゲーム拡張**: デッキ構築・バトル機能の追加
|
||||
- **データ主権**: ユーザーによる完全なデータ所有
|
||||
- **スケーラビリティ**: サーバー負荷分散
|
||||
|
||||
## 技術的課題と解決策
|
||||
|
||||
### データ改ざん防止
|
||||
- **短期**: MCP serverによる検証
|
||||
- **中期**: OAuth 2.1 scope実装待ち
|
||||
- **長期**: ブロックチェーン的整合性チェック
|
||||
|
||||
### スケーラビリティ
|
||||
- **画像配信**: Cloudflare Pages活用
|
||||
- **API負荷**: FastAPIによる高速処理
|
||||
- **データ保存**: atproto分散ストレージ
|
||||
|
||||
### ユーザー体験
|
||||
- **直感的UI**: iOS/Webでの統一UX
|
||||
- **リアルタイム更新**: WebSocketでの即座反映
|
||||
- **オフライン対応**: ローカルキャッシュ機能
|
||||
|
||||
## ai.game連携構想
|
||||
|
||||
### Play-to-Work統合
|
||||
- **カードゲームプレイ → 業務成果変換**: ai.gameデバイスでの労働ゲーム化
|
||||
- **デッキ構築戦略 → 企業戦略思考**: カード組み合わせが戦略思考を鍛練
|
||||
- **トレード交渉 → ビジネススキル**: 他プレイヤーとの交渉が実務能力向上
|
||||
|
||||
### メタバース展開
|
||||
- **ai.verse統合**: 3D世界でのカードバトル
|
||||
- **アバター連動**: 所有カードがキャラクター能力に影響
|
||||
- **配信コンテンツ**: カードゲームが配信可能なエンターテイメント
|
||||
@@ -1,64 +0,0 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: aicard
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
api:
|
||||
build:
|
||||
context: ./api
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
DATABASE_URL: postgresql+asyncpg://postgres:postgres@postgres:5432/aicard
|
||||
PYTHONPATH: /app
|
||||
ports:
|
||||
- "8000:8000"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
- ./api:/app
|
||||
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
|
||||
|
||||
web:
|
||||
build:
|
||||
context: ./web
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
depends_on:
|
||||
- api
|
||||
environment:
|
||||
- VITE_API_URL=http://api:8000
|
||||
|
||||
# Cloudflare Tunnel (optional)
|
||||
cloudflared:
|
||||
image: cloudflare/cloudflared:latest
|
||||
restart: unless-stopped
|
||||
command: tunnel --no-autoupdate run
|
||||
environment:
|
||||
- TUNNEL_TOKEN=${CLOUDFLARE_TUNNEL_TOKEN}
|
||||
depends_on:
|
||||
- api
|
||||
- web
|
||||
profiles:
|
||||
- tunnel
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
@@ -1,285 +0,0 @@
|
||||
# AI Context Document - ai.card プロジェクト
|
||||
|
||||
> **重要**: このドキュメントは、将来のAI開発者(Claude Code等)が迅速にプロジェクトを理解し、作業を継続できるよう設計されています。
|
||||
|
||||
## 🎯 プロジェクト概要
|
||||
|
||||
**ai.card** は、atprotoベースの分散型カードゲームです。ユーザーがデータを所有し、世界で一人だけが持てるuniqueカードが存在する革新的なシステムです。
|
||||
|
||||
### 中核思想
|
||||
- **存在子理論**: 世界の最小単位(ai)の探求がテーマ
|
||||
- **yui system**: 現実の個人とゲーム要素の1:1紐付け
|
||||
- **データ主権**: atproto PDSでユーザーがカードデータを所有
|
||||
- **現実の反映**: ゲームがプレイヤーの現実と連動
|
||||
|
||||
## 🏗️ システム構成
|
||||
|
||||
```
|
||||
[iOS App] ←→ [Web App] ←→ [FastAPI API] ←→ [PostgreSQL]
|
||||
↕
|
||||
[atproto PDS]
|
||||
↕
|
||||
[ai.verse(将来)]
|
||||
```
|
||||
|
||||
### 技術スタック(2025年6月1日現在)
|
||||
- **Backend**: Python 3.11 + FastAPI + PostgreSQL + Docker
|
||||
- **Frontend**: React 18 + TypeScript + Vite + Framer Motion
|
||||
- **Mobile**: SwiftUI + Combine + iOS 16.0+
|
||||
- **Identity**: atproto DID + JWT
|
||||
- **Infrastructure**: Docker Compose + Cloudflare Tunnel + Supabase
|
||||
|
||||
## 💎 uniqueカードシステム(最重要概念)
|
||||
|
||||
### 概念
|
||||
```
|
||||
通常のガチャ → キラカード(0.1%) → uniqueカード(0.0001%)
|
||||
↑表 ↑隠し機能
|
||||
ユーザーの目標 偶然の幸運
|
||||
```
|
||||
|
||||
### 実装
|
||||
- **確率**: 0.0001%(10万分の1)
|
||||
- **唯一性**: カードID 0-15の各種類につき、世界で1人のみ所有可能
|
||||
- **検証**: `unique_card_registry`テーブル + atproto PDS両方でチェック
|
||||
- **エフェクト**: 虹色オーラ + パーティクル + 特別UI
|
||||
|
||||
### データフロー
|
||||
```
|
||||
ガチャ実行 → レアリティ判定 → unique可能性チェック →
|
||||
atomic操作で確保 → DB保存 → atproto PDS同期 → アニメーション表示
|
||||
```
|
||||
|
||||
## 🔐 atproto統合
|
||||
|
||||
### 認証フロー
|
||||
```
|
||||
ユーザー: ハンドル + アプリパスワード
|
||||
↓
|
||||
atproto PDS認証
|
||||
↓
|
||||
JWT発行 → セッション管理
|
||||
↓
|
||||
API呼び出し認証
|
||||
```
|
||||
|
||||
### データ同期
|
||||
```
|
||||
カード取得 → DB保存 → atproto collection record作成
|
||||
↓
|
||||
レキシコン: ai.card.collection
|
||||
↓
|
||||
ユーザーPDSにデータ保存(ユーザーがデータ所有)
|
||||
```
|
||||
|
||||
## 📁 重要なファイル構造
|
||||
|
||||
### Backend(最重要)
|
||||
```
|
||||
api/app/
|
||||
├── models/card.py # カードデータ定義
|
||||
├── services/gacha.py # ガチャロジック(uniqueカード生成)
|
||||
├── services/atproto.py # atproto統合
|
||||
├── services/card_sync.py # PDS同期
|
||||
├── repositories/card.py # カードデータアクセス
|
||||
├── routes/auth.py # 認証API
|
||||
├── routes/cards.py # カードAPI
|
||||
└── db/models.py # データベースモデル
|
||||
```
|
||||
|
||||
### Frontend
|
||||
```
|
||||
web/src/
|
||||
├── components/Card.tsx # カード表示(エフェクト付き)
|
||||
├── components/GachaAnimation.tsx # ガチャ演出
|
||||
├── services/auth.ts # 認証管理
|
||||
└── services/api.ts # API通信
|
||||
|
||||
ios/AiCard/AiCard/
|
||||
├── Views/GachaView.swift # ガチャ画面
|
||||
├── Views/CardView.swift # カード表示
|
||||
├── Services/APIClient.swift # API通信
|
||||
└── Services/AuthManager.swift # 認証管理
|
||||
```
|
||||
|
||||
## 🎮 ゲーム仕様
|
||||
|
||||
### カードマスター(16種類)
|
||||
```json
|
||||
{
|
||||
"0": {"name": "アイ", "color": "fff700", "description": "世界の最小単位"},
|
||||
"1": {"name": "夢幻", "color": "b19cd9", "description": "意識が物質を作る"},
|
||||
...
|
||||
"15": {"name": "世界", "color": "54a0ff", "description": "存在と世界は同じもの"}
|
||||
}
|
||||
```
|
||||
|
||||
### レアリティ確率
|
||||
```
|
||||
Normal: 99.789% → グレー系
|
||||
Rare: 0.1% → ブルー系
|
||||
Super Rare: 0.01% → パープル系
|
||||
Kira: 0.1% → ゴールド系(スパークル)
|
||||
Unique: 0.0001% → マゼンタ系(オーラ)
|
||||
```
|
||||
|
||||
## 🚀 開発環境セットアップ
|
||||
|
||||
### 1. 基本起動
|
||||
```bash
|
||||
git clone [repository]
|
||||
cd ai.card
|
||||
|
||||
# Docker環境起動
|
||||
docker-compose up -d
|
||||
|
||||
# データベース初期化
|
||||
docker-compose exec api python init_db.py
|
||||
|
||||
# Web開発サーバー
|
||||
cd web && npm install && npm run dev
|
||||
|
||||
# iOS(Xcodeで開く)
|
||||
open ios/AiCard/AiCard.xcodeproj
|
||||
```
|
||||
|
||||
### 2. 環境変数設定(.env)
|
||||
```bash
|
||||
# PostgreSQL
|
||||
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/aicard
|
||||
|
||||
# atproto(テスト用)
|
||||
ATPROTO_HANDLE=test.bsky.social
|
||||
ATPROTO_PASSWORD=your-app-password
|
||||
|
||||
# JWT
|
||||
SECRET_KEY=your-secret-key
|
||||
```
|
||||
|
||||
### 3. atprotoアカウント準備
|
||||
1. Blueskyアカウント作成
|
||||
2. アプリパスワード生成(https://bsky.app/settings/app-passwords)
|
||||
3. 環境変数に設定
|
||||
|
||||
## 🔧 よくある実装パターン
|
||||
|
||||
### 1. 新しいAPIエンドポイント追加
|
||||
```python
|
||||
# 1. routes/に新しいルート定義
|
||||
@router.post("/new-endpoint")
|
||||
async def new_endpoint(db: AsyncSession = Depends(get_db)):
|
||||
# ロジック
|
||||
|
||||
# 2. main.pyにルーター追加
|
||||
app.include_router(new_router, prefix=settings.api_v1_prefix)
|
||||
```
|
||||
|
||||
### 2. データベーステーブル追加
|
||||
```python
|
||||
# 1. db/models.pyに新しいモデル
|
||||
class NewModel(Base):
|
||||
__tablename__ = "new_table"
|
||||
# フィールド定義
|
||||
|
||||
# 2. Alembicマイグレーション
|
||||
alembic revision --autogenerate -m "add new table"
|
||||
alembic upgrade head
|
||||
```
|
||||
|
||||
### 3. atproto新機能追加
|
||||
```python
|
||||
# services/atproto.pyに新しいメソッド
|
||||
async def new_atproto_feature(self, did: str, data: dict):
|
||||
# atproto SDK使用
|
||||
return self.client.some_new_api(data)
|
||||
```
|
||||
|
||||
## 🎨 UI/UXパターン
|
||||
|
||||
### カードエフェクト実装
|
||||
```typescript
|
||||
// Web(React + Framer Motion)
|
||||
<motion.div
|
||||
className={`card ${getRarityClass()}`}
|
||||
animate={isRevealing ? { rotateY: 0 } : {}}
|
||||
transition={{ duration: 0.8 }}
|
||||
>
|
||||
```
|
||||
|
||||
```swift
|
||||
// iOS(SwiftUI)
|
||||
CardView(card: card)
|
||||
.rotation3DEffect(.degrees(isRevealing ? 0 : 180), axis: (0, 1, 0))
|
||||
.animation(.easeInOut(duration: 0.8), value: isRevealing)
|
||||
```
|
||||
|
||||
## ⚠️ 重要な注意点
|
||||
|
||||
### 1. uniqueカードの整合性
|
||||
- **必須**: atomic操作でのunique確保
|
||||
- **必須**: DB + atproto PDS両方での検証
|
||||
- **注意**: レース条件の回避
|
||||
|
||||
### 2. atproto連携
|
||||
- **メインパスワード禁止**: 必ずアプリパスワード使用
|
||||
- **セッション管理**: JWTトークンの適切な管理
|
||||
- **エラーハンドリング**: atproto PDS接続失敗時の処理
|
||||
|
||||
### 3. 確率システム
|
||||
- **透明性**: 確率は隠さず設定ファイルで管理
|
||||
- **公平性**: サーバーサイドでの確率計算必須
|
||||
- **監査**: ガチャ履歴の完全記録
|
||||
|
||||
## 🔮 将来の拡張ポイント
|
||||
|
||||
### Phase 1: 運用安定化
|
||||
- 統合テスト自動化
|
||||
- モニタリング・アラート
|
||||
- パフォーマンス最適化
|
||||
|
||||
### Phase 2: 機能拡張
|
||||
- カード交換システム
|
||||
- プッシュ通知
|
||||
- リアルタイム同期
|
||||
|
||||
### Phase 3: エコシステム統合
|
||||
- ai.gpt連携(AI人格とカード連動)
|
||||
- ai.verse連携(3Dゲーム世界でunique skill)
|
||||
- 分散SNS連携
|
||||
|
||||
## 📋 デバッグ・トラブルシューティング
|
||||
|
||||
### よくある問題
|
||||
1. **ガチャでカードが生成されない**
|
||||
→ `services/gacha.py`のエラーログ確認
|
||||
|
||||
2. **atproto認証失敗**
|
||||
→ アプリパスワードとハンドルの確認
|
||||
|
||||
3. **uniqueカード重複**
|
||||
→ `unique_card_registry`テーブルの整合性チェック
|
||||
|
||||
4. **データベース接続失敗**
|
||||
→ Docker Composeの起動状態確認
|
||||
|
||||
### ログ確認
|
||||
```bash
|
||||
# API ログ
|
||||
docker-compose logs -f api
|
||||
|
||||
# データベース状態
|
||||
docker-compose exec postgres psql -U postgres -d aicard -c "SELECT * FROM unique_card_registry;"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📚 推奨読み込み順序(AI向け)
|
||||
|
||||
1. **このドキュメント全体** - プロジェクト概要把握
|
||||
2. **CLAUDE.md** - 哲学・思想の理解
|
||||
3. **IMPLEMENTATION_SUMMARY.md** - 具体的実装詳細
|
||||
4. **API.md** - APIエンドポイント仕様
|
||||
5. **DATABASE.md** - データベース設計
|
||||
6. **ATPROTO.md** - atproto連携詳細
|
||||
|
||||
新しいAI開発者は、この順序で読むことで迅速にプロジェクトを理解し、作業を開始できます。
|
||||
102
docs/API.md
@@ -1,102 +0,0 @@
|
||||
# ai.card API Documentation
|
||||
|
||||
## Base URL
|
||||
```
|
||||
http://localhost:8000/api/v1
|
||||
```
|
||||
|
||||
## Endpoints
|
||||
|
||||
### Draw Card
|
||||
カードを抽選します。
|
||||
|
||||
```
|
||||
POST /cards/draw
|
||||
```
|
||||
|
||||
#### Request Body
|
||||
```json
|
||||
{
|
||||
"user_did": "did:plc:example123",
|
||||
"is_paid": false
|
||||
}
|
||||
```
|
||||
|
||||
#### Response
|
||||
```json
|
||||
{
|
||||
"card": {
|
||||
"id": 0,
|
||||
"cp": 88,
|
||||
"status": "normal",
|
||||
"skill": null,
|
||||
"owner_did": "did:plc:example123",
|
||||
"obtained_at": "2025-01-01T00:00:00",
|
||||
"is_unique": false,
|
||||
"unique_id": null
|
||||
},
|
||||
"is_new": true,
|
||||
"animation_type": "normal"
|
||||
}
|
||||
```
|
||||
|
||||
### Get User Cards
|
||||
ユーザーの所有カード一覧を取得します。
|
||||
|
||||
```
|
||||
GET /cards/user/{user_did}
|
||||
```
|
||||
|
||||
#### Response
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": 0,
|
||||
"cp": 88,
|
||||
"status": "normal",
|
||||
"skill": null,
|
||||
"owner_did": "did:plc:example123",
|
||||
"obtained_at": "2025-01-01T00:00:00",
|
||||
"is_unique": false,
|
||||
"unique_id": null
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### Get Unique Cards
|
||||
全てのuniqueカード一覧を取得します。
|
||||
|
||||
```
|
||||
GET /cards/unique
|
||||
```
|
||||
|
||||
#### Response
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": 8,
|
||||
"cp": 500,
|
||||
"status": "unique",
|
||||
"skill": "skill_8_unique",
|
||||
"owner_did": "did:plc:example123",
|
||||
"obtained_at": "2025-01-01T00:00:00",
|
||||
"is_unique": true,
|
||||
"unique_id": "550e8400-e29b-41d4-a716-446655440000"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Card Rarity
|
||||
|
||||
- `normal`: 通常カード (99.789%)
|
||||
- `rare`: レアカード (0.1%)
|
||||
- `super_rare`: スーパーレアカード (0.01%)
|
||||
- `kira`: キラカード (0.1%)
|
||||
- `unique`: ユニークカード (0.0001%)
|
||||
|
||||
## Animation Types
|
||||
|
||||
- `normal`: 通常演出
|
||||
- `rare`: レア演出
|
||||
- `kira`: キラカード演出
|
||||
- `unique`: ユニークカード演出(特別演出)
|
||||
146
docs/ATPROTO.md
@@ -1,146 +0,0 @@
|
||||
# atproto連携ガイド
|
||||
|
||||
## 概要
|
||||
|
||||
ai.cardは、atproto(AT Protocol)と完全に統合されており、以下の機能を提供します:
|
||||
|
||||
1. **atproto認証**: DIDベースの分散型認証
|
||||
2. **データ主権**: カードデータをユーザーのPDSに保存
|
||||
3. **相互運用性**: 他のatproto対応アプリとの連携
|
||||
|
||||
## 認証フロー
|
||||
|
||||
### 1. ログイン
|
||||
|
||||
```javascript
|
||||
// フロントエンド
|
||||
const response = await authService.login(identifier, password);
|
||||
// identifier: ハンドル(user.bsky.social)またはDID
|
||||
// password: アプリパスワード(メインパスワードではない)
|
||||
```
|
||||
|
||||
### 2. アプリパスワードの作成
|
||||
|
||||
1. https://bsky.app/settings/app-passwords にアクセス
|
||||
2. 新しいアプリパスワードを作成
|
||||
3. ai.cardでそのパスワードを使用
|
||||
|
||||
### 3. セッション管理
|
||||
|
||||
- JWTトークンで24時間有効
|
||||
- Cookieとヘッダーの両方をサポート
|
||||
- 自動更新機能なし(再ログインが必要)
|
||||
|
||||
## データ保存
|
||||
|
||||
### カードコレクションのLexicon
|
||||
|
||||
```json
|
||||
{
|
||||
"lexicon": 1,
|
||||
"id": "ai.card.collection",
|
||||
"defs": {
|
||||
"main": {
|
||||
"type": "record",
|
||||
"record": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cardId": { "type": "integer" },
|
||||
"cp": { "type": "integer" },
|
||||
"status": { "type": "string" },
|
||||
"skill": { "type": "string" },
|
||||
"obtainedAt": { "type": "string" },
|
||||
"isUnique": { "type": "boolean" },
|
||||
"uniqueId": { "type": "string" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### データ同期
|
||||
|
||||
```bash
|
||||
# カードをPDSに同期
|
||||
POST /api/v1/sync/cards
|
||||
{
|
||||
"atproto_session": "session-string-from-login"
|
||||
}
|
||||
|
||||
# PDSからインポート
|
||||
POST /api/v1/sync/import
|
||||
|
||||
# PDSにエクスポート
|
||||
POST /api/v1/sync/export
|
||||
```
|
||||
|
||||
## セキュリティ
|
||||
|
||||
### 1. 認証情報の取り扱い
|
||||
|
||||
- **メインパスワードは使用しない**: 必ずアプリパスワードを使用
|
||||
- **セッション文字列の保護**: atprotoセッションは暗号化して保存
|
||||
- **HTTPS必須**: 本番環境では必ずHTTPS経由で通信
|
||||
|
||||
### 2. データ検証
|
||||
|
||||
- サーバー側でカードデータの整合性をチェック
|
||||
- uniqueカードはグローバルレジストリで重複防止
|
||||
- PDSのデータも信頼せず、常に検証
|
||||
|
||||
### 3. 権限管理
|
||||
|
||||
現在の制限:
|
||||
- ユーザーはPDSのデータを自由に編集可能
|
||||
- OAuth 2.1 scope実装待ち
|
||||
|
||||
対策:
|
||||
- サーバー側検証で不正データを無効化
|
||||
- ゲームプレイ時は常にサーバーチェック
|
||||
|
||||
## APIエンドポイント
|
||||
|
||||
### 認証
|
||||
|
||||
```
|
||||
POST /api/v1/auth/login - ログイン
|
||||
POST /api/v1/auth/logout - ログアウト
|
||||
GET /api/v1/auth/verify - セッション確認
|
||||
POST /api/v1/auth/verify-did - DID検証(公開)
|
||||
```
|
||||
|
||||
### 同期
|
||||
|
||||
```
|
||||
POST /api/v1/sync/cards - 双方向同期
|
||||
POST /api/v1/sync/export - PDSへエクスポート
|
||||
POST /api/v1/sync/import - PDSからインポート
|
||||
GET /api/v1/sync/verify/:id - カード所有確認
|
||||
```
|
||||
|
||||
## トラブルシューティング
|
||||
|
||||
### ログインできない
|
||||
|
||||
1. アプリパスワードを使用しているか確認
|
||||
2. ハンドルまたはDIDが正しいか確認
|
||||
3. PDSが稼働しているか確認
|
||||
|
||||
### データが同期されない
|
||||
|
||||
1. atprotoセッションが有効か確認
|
||||
2. PDSの容量制限を確認
|
||||
3. ネットワーク接続を確認
|
||||
|
||||
### カードが表示されない
|
||||
|
||||
1. `/api/v1/sync/import`でPDSからインポート
|
||||
2. ブラウザキャッシュをクリア
|
||||
3. 再ログイン
|
||||
|
||||
## 今後の予定
|
||||
|
||||
1. **OAuth 2.1対応**: より細かい権限管理
|
||||
2. **リアルタイム同期**: WebSocketでの即時反映
|
||||
3. **他アプリ連携**: atprotoエコシステムとの統合
|
||||
102
docs/DATABASE.md
@@ -1,102 +0,0 @@
|
||||
# データベース設定ガイド
|
||||
|
||||
## ローカル開発(Docker Compose)
|
||||
|
||||
### 1. 起動
|
||||
```bash
|
||||
# データベースとAPIを起動
|
||||
docker-compose up -d
|
||||
|
||||
# ログを確認
|
||||
docker-compose logs -f
|
||||
```
|
||||
|
||||
### 2. データベース初期化
|
||||
```bash
|
||||
# APIコンテナに入る
|
||||
docker-compose exec api bash
|
||||
|
||||
# マイグレーション実行
|
||||
alembic upgrade head
|
||||
|
||||
# マスタデータ投入
|
||||
python init_db.py
|
||||
```
|
||||
|
||||
## Supabase連携
|
||||
|
||||
### 1. Supabaseプロジェクト作成
|
||||
1. [Supabase](https://supabase.com)でプロジェクト作成
|
||||
2. Settings > Database から接続情報を取得
|
||||
|
||||
### 2. 環境変数設定
|
||||
```bash
|
||||
# .env
|
||||
DATABASE_URL_SUPABASE=postgresql+asyncpg://postgres.[project-ref]:[password]@aws-0-[region].pooler.supabase.com:5432/postgres
|
||||
USE_SUPABASE=true
|
||||
```
|
||||
|
||||
### 3. テーブル作成
|
||||
Supabase SQL Editorで以下を実行:
|
||||
|
||||
```sql
|
||||
-- Alembicのマイグレーションを実行
|
||||
-- または直接SQLでテーブル作成
|
||||
```
|
||||
|
||||
## Cloudflare Tunnel設定
|
||||
|
||||
### 1. トンネル作成
|
||||
```bash
|
||||
# Cloudflareダッシュボードでトンネル作成
|
||||
# トークンを取得
|
||||
```
|
||||
|
||||
### 2. 環境変数設定
|
||||
```bash
|
||||
# .env
|
||||
CLOUDFLARE_TUNNEL_TOKEN=your-tunnel-token
|
||||
```
|
||||
|
||||
### 3. 起動
|
||||
```bash
|
||||
# tunnelプロファイルを含めて起動
|
||||
docker-compose --profile tunnel up -d
|
||||
```
|
||||
|
||||
## データベーススキーマ
|
||||
|
||||
### users
|
||||
- ユーザー情報(DID、ハンドル)
|
||||
|
||||
### card_master
|
||||
- カードマスタデータ(16種類)
|
||||
|
||||
### user_cards
|
||||
- ユーザー所有カード
|
||||
- uniqueカードフラグ付き
|
||||
|
||||
### unique_card_registry
|
||||
- グローバルuniqueカード登録
|
||||
- 各カードIDにつき1人のみ所有可能
|
||||
|
||||
### draw_history
|
||||
- ガチャ履歴
|
||||
|
||||
### gacha_pools
|
||||
- ピックアップガチャ設定
|
||||
|
||||
## バックアップ
|
||||
|
||||
### ローカル
|
||||
```bash
|
||||
# バックアップ
|
||||
docker-compose exec postgres pg_dump -U postgres aicard > backup.sql
|
||||
|
||||
# リストア
|
||||
docker-compose exec -T postgres psql -U postgres aicard < backup.sql
|
||||
```
|
||||
|
||||
### Supabase
|
||||
- 自動バックアップが有効
|
||||
- ダッシュボードからダウンロード可能
|
||||
@@ -1,124 +0,0 @@
|
||||
# 開発ガイド
|
||||
|
||||
## セットアップ
|
||||
|
||||
### 1. API (FastAPI)
|
||||
|
||||
```bash
|
||||
cd api
|
||||
|
||||
# 仮想環境作成
|
||||
python -m venv venv
|
||||
source venv/bin/activate # macOS/Linux
|
||||
# or
|
||||
venv\Scripts\activate # Windows
|
||||
|
||||
# 依存関係インストール
|
||||
pip install -r requirements.txt
|
||||
|
||||
# 環境変数設定
|
||||
cp .env.example .env
|
||||
# .envを編集
|
||||
|
||||
# 開発サーバー起動
|
||||
uvicorn app.main:app --reload
|
||||
```
|
||||
|
||||
APIは http://localhost:8000 で起動します。
|
||||
APIドキュメントは http://localhost:8000/docs で確認できます。
|
||||
|
||||
### 2. Web (React + Vite)
|
||||
|
||||
```bash
|
||||
cd web
|
||||
|
||||
# 依存関係インストール
|
||||
npm install
|
||||
|
||||
# 開発サーバー起動
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Webアプリは http://localhost:3000 で起動します。
|
||||
|
||||
## プロジェクト構造
|
||||
|
||||
```
|
||||
ai.card/
|
||||
├── api/ # FastAPI backend
|
||||
│ ├── app/
|
||||
│ │ ├── core/ # 設定、共通処理
|
||||
│ │ ├── models/ # Pydanticモデル
|
||||
│ │ ├── routes/ # APIエンドポイント
|
||||
│ │ ├── services/ # ビジネスロジック
|
||||
│ │ └── main.py # アプリケーションエントリ
|
||||
│ └── requirements.txt
|
||||
│
|
||||
├── web/ # React frontend
|
||||
│ ├── src/
|
||||
│ │ ├── components/ # Reactコンポーネント
|
||||
│ │ ├── services/ # API通信
|
||||
│ │ ├── styles/ # CSS
|
||||
│ │ ├── types/ # TypeScript型定義
|
||||
│ │ └── App.tsx # メインコンポーネント
|
||||
│ └── package.json
|
||||
│
|
||||
├── ios/ # iOS app (今後実装)
|
||||
└── docs/ # ドキュメント
|
||||
```
|
||||
|
||||
## 技術スタック
|
||||
|
||||
### Backend
|
||||
- Python 3.9+
|
||||
- FastAPI
|
||||
- Pydantic
|
||||
- SQLAlchemy (今後実装)
|
||||
- atproto SDK
|
||||
|
||||
### Frontend
|
||||
- React 18
|
||||
- TypeScript
|
||||
- Vite
|
||||
- Framer Motion (アニメーション)
|
||||
- Axios
|
||||
|
||||
## 開発のポイント
|
||||
|
||||
### 1. カードデータ
|
||||
カードは0-15のIDを持ち、ai.jsonの定義に基づいています。
|
||||
|
||||
### 2. レアリティシステム
|
||||
- 通常のガチャではキラカードが最高レア
|
||||
- uniqueカードは隠し要素として実装
|
||||
- 確率は設定ファイルで調整可能
|
||||
|
||||
### 3. atproto連携
|
||||
- ユーザー認証はatproto OAuth(今後実装)
|
||||
- カードデータはユーザーのPDSに保存(今後実装)
|
||||
- 現在はローカルストレージのみ
|
||||
|
||||
### 4. アニメーション
|
||||
- ガチャ演出はレアリティに応じて変化
|
||||
- uniqueカードは特別な演出
|
||||
- Framer Motionで実装
|
||||
|
||||
## 今後の実装予定
|
||||
|
||||
1. **データベース連携**
|
||||
- SQLAlchemyでのモデル定義
|
||||
- ユーザーごとのカード管理
|
||||
|
||||
2. **atproto統合**
|
||||
- OAuth認証
|
||||
- PDSへのデータ保存
|
||||
- DID検証
|
||||
|
||||
3. **uniqueカード検証**
|
||||
- グローバルレジストリ
|
||||
- 重複チェック
|
||||
- ai.verse連携
|
||||
|
||||
4. **iOS app**
|
||||
- SwiftUIで実装
|
||||
- 共通APIを使用
|
||||
@@ -1,267 +0,0 @@
|
||||
# ai.card 実装完了サマリー
|
||||
|
||||
## 作業日: 2025年6月1日
|
||||
|
||||
### 📋 今日実装した内容
|
||||
|
||||
## 1. データベース実装(PostgreSQL + Supabase)
|
||||
|
||||
### 完成機能
|
||||
- **PostgreSQLスキーマ設計**: 7つのテーブル(users, card_master, user_cards, unique_card_registry等)
|
||||
- **Docker Compose環境**: 開発・本番両対応
|
||||
- **Supabase連携**: 環境変数で切り替え可能
|
||||
- **リポジトリパターン**: BaseRepository + 専用Repository
|
||||
- **マイグレーション**: Alembic設定 + 初期データ投入
|
||||
- **データ同期**: ガチャ時の自動データベース保存
|
||||
|
||||
### 重要ファイル
|
||||
```
|
||||
api/app/db/models.py # SQLAlchemyモデル
|
||||
api/app/repositories/ # リポジトリパターン実装
|
||||
api/init_db.py # データベース初期化
|
||||
docker-compose.yml # 開発環境
|
||||
docker-compose.production.yml # 本番環境
|
||||
```
|
||||
|
||||
## 2. atproto連携機能
|
||||
|
||||
### 完成機能
|
||||
- **認証システム**: DID/ハンドルログイン + JWTトークン
|
||||
- **PDSデータ保存**: カードをユーザーのPDSに自動同期
|
||||
- **Lexicon定義**: `ai.card.collection` スキーマ
|
||||
- **同期API**: 双方向同期・インポート・エクスポート
|
||||
- **データ検証**: サーバー側整合性チェック
|
||||
|
||||
### 重要ファイル
|
||||
```
|
||||
api/app/services/atproto.py # atproto統合サービス
|
||||
api/app/services/card_sync.py # カード同期サービス
|
||||
api/app/routes/auth.py # 認証API
|
||||
api/app/routes/sync.py # 同期API
|
||||
api/app/auth/dependencies.py # 認証依存関係
|
||||
```
|
||||
|
||||
## 3. iOS App完全実装
|
||||
|
||||
### 完成機能
|
||||
- **SwiftUI + MVVM**: Combineを使ったリアクティブアーキテクチャ
|
||||
- **認証画面**: atprotoログイン(アプリパスワード対応)
|
||||
- **ガチャシステム**: 通常・プレミアムガチャ + リッチアニメーション
|
||||
- **カードコレクション**: グリッド表示・検索・フィルタ・詳細画面
|
||||
- **プロフィール**: ユーザー情報・統計・設定
|
||||
- **視覚エフェクト**: レアリティ別アニメーション・3Dフリップ
|
||||
|
||||
### 重要ファイル
|
||||
```
|
||||
ios/AiCard/AiCard/
|
||||
├── Models/Card.swift # カードデータモデル
|
||||
├── Services/APIClient.swift # API通信(Combine使用)
|
||||
├── Services/AuthManager.swift # 認証管理
|
||||
├── Services/CardManager.swift # カード管理
|
||||
├── Views/LoginView.swift # ログイン画面
|
||||
├── Views/GachaView.swift # ガチャ画面
|
||||
├── Views/CollectionView.swift # コレクション画面
|
||||
├── Views/CardView.swift # カード表示コンポーネント
|
||||
└── Views/GachaAnimationView.swift # ガチャアニメーション
|
||||
```
|
||||
|
||||
## 4. プロジェクト統合
|
||||
|
||||
### アーキテクチャ概要
|
||||
```
|
||||
[iOS App] ←→ [Web App] ←→ [FastAPI] ←→ [PostgreSQL]
|
||||
↕
|
||||
[atproto PDS]
|
||||
```
|
||||
|
||||
### データフロー
|
||||
1. **ガチャ**: iOS/Web → API → DB保存 → atproto PDS同期
|
||||
2. **認証**: atproto DID → JWT → セッション管理
|
||||
3. **同期**: DB ↔ atproto PDS双方向同期
|
||||
|
||||
## 📊 実装済み機能一覧
|
||||
|
||||
### ✅ Backend (FastAPI)
|
||||
- [x] PostgreSQL + Supabase対応
|
||||
- [x] atproto認証・同期
|
||||
- [x] ガチャシステム(確率・unique管理)
|
||||
- [x] カードCRUD API
|
||||
- [x] Docker環境(開発・本番)
|
||||
- [x] リポジトリパターン
|
||||
- [x] データベースマイグレーション
|
||||
|
||||
### ✅ Frontend (React)
|
||||
- [x] atproto認証UI
|
||||
- [x] ガチャアニメーション(Framer Motion)
|
||||
- [x] カード表示・コレクション
|
||||
- [x] レスポンシブデザイン
|
||||
- [x] TypeScript対応
|
||||
|
||||
### ✅ Mobile (iOS)
|
||||
- [x] SwiftUI + MVVM + Combine
|
||||
- [x] atproto認証
|
||||
- [x] ガチャ(通常・プレミアム)
|
||||
- [x] カードコレクション(検索・フィルタ)
|
||||
- [x] リッチアニメーション
|
||||
- [x] iOS 16.0+ 対応
|
||||
|
||||
### ✅ DevOps
|
||||
- [x] Docker Compose
|
||||
- [x] Cloudflare Tunnel対応
|
||||
- [x] 環境別設定
|
||||
- [x] ヘルスチェック
|
||||
|
||||
## 🔧 技術スタック
|
||||
|
||||
### Backend
|
||||
- **Language**: Python 3.11
|
||||
- **Framework**: FastAPI 0.104.1
|
||||
- **Database**: PostgreSQL + SQLAlchemy
|
||||
- **ORM**: SQLAlchemy 2.0 (async)
|
||||
- **Migration**: Alembic
|
||||
- **Cloud**: Supabase対応
|
||||
- **atproto**: atproto SDK 0.0.46
|
||||
|
||||
### Frontend (Web)
|
||||
- **Language**: TypeScript
|
||||
- **Framework**: React 18 + Vite
|
||||
- **Animation**: Framer Motion
|
||||
- **HTTP**: Axios
|
||||
- **Styling**: CSS Modules
|
||||
|
||||
### Mobile (iOS)
|
||||
- **Language**: Swift 5.7+
|
||||
- **Framework**: SwiftUI
|
||||
- **Architecture**: MVVM + Combine
|
||||
- **HTTP**: URLSession
|
||||
- **Minimum**: iOS 16.0
|
||||
|
||||
### Infrastructure
|
||||
- **Container**: Docker + Docker Compose
|
||||
- **Proxy**: Nginx
|
||||
- **Tunnel**: Cloudflare Tunnel
|
||||
- **Database**: PostgreSQL 16
|
||||
|
||||
## 🎯 unique カードシステムの実装
|
||||
|
||||
### 概念
|
||||
- **確率**: 0.0001%(10万分の1)
|
||||
- **唯一性**: 各カードID(0-15)につき世界で1人のみ所有可能
|
||||
- **検証**: サーバー側 + atproto PDS両方でチェック
|
||||
- **将来**: ai.verse unique skillとの連携予定
|
||||
|
||||
### 実装詳細
|
||||
- `unique_card_registry`テーブルでグローバル管理
|
||||
- ガチャ時にatomic操作で重複防止
|
||||
- atproto PDSにも同期保存
|
||||
- Web/iOSで特別なエフェクト表示
|
||||
|
||||
## 🚀 デプロイメント準備
|
||||
|
||||
### 開発環境起動
|
||||
```bash
|
||||
# 全体起動
|
||||
docker-compose up -d
|
||||
|
||||
# データベース初期化
|
||||
docker-compose exec api python init_db.py
|
||||
|
||||
# Web開発サーバー
|
||||
cd web && npm run dev
|
||||
|
||||
# iOS(Xcodeで開く)
|
||||
open ios/AiCard/AiCard.xcodeproj
|
||||
```
|
||||
|
||||
### 本番環境起動
|
||||
```bash
|
||||
# 本番設定で起動
|
||||
docker-compose -f docker-compose.production.yml up -d
|
||||
```
|
||||
|
||||
## 📝 重要な設定ファイル
|
||||
|
||||
### 環境変数(.env)
|
||||
```bash
|
||||
# Database
|
||||
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/aicard
|
||||
DATABASE_URL_SUPABASE=postgresql+asyncpg://...
|
||||
USE_SUPABASE=false
|
||||
|
||||
# atproto
|
||||
ATPROTO_HANDLE=your.bsky.social
|
||||
ATPROTO_PASSWORD=your-app-password
|
||||
|
||||
# Security
|
||||
SECRET_KEY=your-secret-key
|
||||
|
||||
# Cloudflare Tunnel
|
||||
CLOUDFLARE_TUNNEL_TOKEN=your-tunnel-token
|
||||
```
|
||||
|
||||
### API設定
|
||||
- **開発**: `http://localhost:8000`
|
||||
- **本番**: `https://api.card.syui.ai`
|
||||
- **認証**: Bearer JWT token
|
||||
- **CORS**: Web/iOS対応
|
||||
|
||||
## 🔮 今後の実装候補
|
||||
|
||||
### Phase 1: 運用準備
|
||||
- [ ] 統合テスト(全システム連携)
|
||||
- [ ] パフォーマンス最適化
|
||||
- [ ] モニタリング・ログ
|
||||
- [ ] セキュリティ監査
|
||||
|
||||
### Phase 2: 機能拡張
|
||||
- [ ] カード交換システム
|
||||
- [ ] プッシュ通知(iOS)
|
||||
- [ ] リアルタイム同期(WebSocket)
|
||||
- [ ] バックアップ・復元
|
||||
|
||||
### Phase 3: エコシステム統合
|
||||
- [ ] ai.gpt連携
|
||||
- [ ] ai.verse unique skill連携
|
||||
- [ ] yui system実装
|
||||
- [ ] 分散SNS連携
|
||||
|
||||
## 🎮 ゲーム仕様
|
||||
|
||||
### カードシステム
|
||||
- **種類**: 16種類(ai, 夢幻, 光彩, 中性子, 太陽, 夜空, 雪, 雷, 超究, 剣, 破壊, 地球, 天の川, 創造, 超新星, 世界)
|
||||
- **CP**: 1-999(レアリティでボーナス)
|
||||
- **レアリティ**: 5段階(normal, rare, super_rare, kira, unique)
|
||||
|
||||
### ガチャ確率
|
||||
- **Normal**: 99.789%
|
||||
- **Rare**: 0.1%
|
||||
- **Super Rare**: 0.01%
|
||||
- **Kira**: 0.1%
|
||||
- **Unique**: 0.0001%(隠し機能)
|
||||
|
||||
### 演出
|
||||
- **Web**: CSS + Framer Motion
|
||||
- **iOS**: SwiftUI Animation + Particle Effects
|
||||
- **レアリティ別**: 色・エフェクト・音(予定)
|
||||
|
||||
---
|
||||
|
||||
## 💡 AI向けメモ
|
||||
|
||||
### プロジェクト理解のキーポイント
|
||||
1. **存在子理論**: 最小単位の意識がゲーム世界の根幹
|
||||
2. **yui system**: 現実の個人とゲーム内要素の1:1紐付け
|
||||
3. **データ主権**: atproto PDSでユーザーがデータを所有
|
||||
4. **uniqueカード**: NFT的だがブロックチェーン不使用
|
||||
|
||||
### 重要な実装パターン
|
||||
- **リポジトリパターン**: データアクセス層の抽象化
|
||||
- **atproto同期**: ガチャ時の自動PDS保存
|
||||
- **レアリティシステム**: 確率とエフェクトの連動
|
||||
- **認証フロー**: DID → JWT → セッション管理
|
||||
|
||||
### 次回作業時の注意点
|
||||
- 環境変数の設定確認
|
||||
- データベースの初期化
|
||||
- atprotoアカウントの準備
|
||||
- Docker環境の起動確認
|
||||
@@ -1,129 +0,0 @@
|
||||
# ai.card MCP Server統合作業報告 (2025/01/06)
|
||||
|
||||
## 作業概要
|
||||
ai.cardプロジェクトに独立したMCPサーバーを実装し、FastAPIベースのカードゲームAPIをMCPツールとして公開。
|
||||
|
||||
## 実装内容
|
||||
|
||||
### 1. 依存関係の解決
|
||||
**課題と対応:**
|
||||
- `atproto==0.0.46` → `atproto>=0.0.55` (Python 3.13対応)
|
||||
- `httpx` バージョン競合 → supabase一時無効化
|
||||
- `pydantic==2.5.0` → `pydantic>=2.7.0` (atproto要件)
|
||||
- PostgreSQL依存 → SQLiteベースに変更
|
||||
- `greenlet` 追加 (SQLAlchemy非同期処理)
|
||||
|
||||
**最終的な依存関係:**
|
||||
```txt
|
||||
fastapi>=0.104.1
|
||||
uvicorn[standard]>=0.24.0
|
||||
pydantic>=2.7.0,<3.0.0
|
||||
sqlalchemy>=2.0.23
|
||||
greenlet>=3.0.0
|
||||
aiosqlite>=0.19.0
|
||||
fastapi-mcp==0.1.0
|
||||
atproto>=0.0.55
|
||||
# supabase>=2.3.0 # httpx競合のため無効化
|
||||
# asyncpg, psycopg2-binary # コンパイル回避のため無効化
|
||||
```
|
||||
|
||||
### 2. MCP Server実装
|
||||
**ファイル:** `api/app/mcp_server.py`
|
||||
|
||||
**主要変更:**
|
||||
- `from mcp.server.fastmcp import FastMCP` (正しいインポート)
|
||||
- `FastMCP("aicard")` で初期化
|
||||
- 9個のMCPツール実装
|
||||
|
||||
**公開ツール:**
|
||||
1. `get_user_cards` - ユーザーカード一覧
|
||||
2. `draw_card` - ガチャ実行
|
||||
3. `get_card_details` - カード詳細情報
|
||||
4. `analyze_card_collection` - コレクション分析
|
||||
5. `get_unique_registry` - ユニークカード登録状況
|
||||
6. `sync_cards_atproto` - atproto同期(無効化中)
|
||||
7. `get_gacha_stats` - ガチャ統計
|
||||
|
||||
### 3. データベース設定
|
||||
**SQLite使用:**
|
||||
- 場所: `~/.config/syui/ai/card/aicard.db`
|
||||
- 理由: 依存関係シンプル化、開発環境最適化
|
||||
- PostgreSQL移行: 将来的にDocker利用で対応
|
||||
|
||||
### 4. 補助スクリプト
|
||||
- `setup_venv.sh` - 仮想環境セットアップ
|
||||
- `start_server.sh` - サーバー起動スクリプト
|
||||
- `docker-compose.dev.yml` - PostgreSQL開発環境
|
||||
|
||||
## 既知の問題と対応
|
||||
|
||||
### 解決済み
|
||||
- ✅ fastapi-mcp インポートエラー → 正しいパッケージ名に修正
|
||||
- ✅ get_db → get_session 関数名不一致
|
||||
- ✅ Optional型インポート漏れ
|
||||
- ✅ SQLAlchemy greenlet依存
|
||||
- ✅ データベース初期化エラー
|
||||
|
||||
### 未解決(将来対応)
|
||||
- atproto SessionString APIの変更
|
||||
- supabase httpxバージョン競合
|
||||
- ガチャ確率計算の精度問題
|
||||
|
||||
## 環境セットアップ手順
|
||||
|
||||
### 1. 仮想環境構築
|
||||
```bash
|
||||
cd /Users/syui/ai/gpt/card
|
||||
./setup_venv.sh
|
||||
```
|
||||
|
||||
### 2. データベース初期化
|
||||
```bash
|
||||
cd api
|
||||
~/.config/syui/ai/card/venv/bin/python init_db.py
|
||||
```
|
||||
|
||||
### 3. サーバー起動
|
||||
```bash
|
||||
./start_server.sh
|
||||
# または
|
||||
cd api
|
||||
~/.config/syui/ai/card/venv/bin/python -m app.main
|
||||
```
|
||||
|
||||
### 4. 動作確認
|
||||
```bash
|
||||
# ヘルスチェック
|
||||
curl http://localhost:8000/health
|
||||
|
||||
# API仕様書
|
||||
open http://localhost:8000/docs
|
||||
|
||||
# カード取得テスト
|
||||
curl -X POST "http://localhost:8000/draw_card?did=did:plc:test123"
|
||||
```
|
||||
|
||||
## PostgreSQL移行(将来)
|
||||
|
||||
### Docker開発環境
|
||||
```bash
|
||||
# PostgreSQLのみ起動
|
||||
docker-compose -f docker-compose.dev.yml up -d
|
||||
|
||||
# 環境変数設定
|
||||
export DATABASE_URL="postgresql+asyncpg://postgres:postgres@localhost:5432/aicard"
|
||||
|
||||
# APIサーバー起動
|
||||
./start_server.sh
|
||||
```
|
||||
|
||||
### 本番環境
|
||||
- iOS/Webアプリ → PostgreSQL必須
|
||||
- Docker Composeで全サービス管理
|
||||
- Cloudflare Tunnel経由で公開
|
||||
|
||||
## 成果
|
||||
- ai.card独立MCPサーバー稼働
|
||||
- SQLiteベースで依存関係問題解決
|
||||
- 自動リロード対応の開発環境構築
|
||||
- iOS/Web連携準備完了
|
||||
BIN
img/0.webp
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
img/1.webp
Normal file
|
After Width: | Height: | Size: 69 KiB |
BIN
img/10.png
Normal file
|
After Width: | Height: | Size: 933 KiB |
BIN
img/10.webp
Normal file
|
After Width: | Height: | Size: 160 KiB |
BIN
img/11.png
Normal file
|
After Width: | Height: | Size: 688 KiB |
BIN
img/11.webp
Normal file
|
After Width: | Height: | Size: 136 KiB |
BIN
img/12.png
Normal file
|
After Width: | Height: | Size: 516 KiB |
BIN
img/12.webp
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
img/13.png
Normal file
|
After Width: | Height: | Size: 416 KiB |
BIN
img/13.webp
Normal file
|
After Width: | Height: | Size: 58 KiB |
BIN
img/14.png
Normal file
|
After Width: | Height: | Size: 462 KiB |
BIN
img/14.webp
Normal file
|
After Width: | Height: | Size: 109 KiB |
BIN
img/15.png
Normal file
|
After Width: | Height: | Size: 642 KiB |
BIN
img/15.webp
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
img/2.webp
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
img/3.webp
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
img/4.webp
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
img/5.webp
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
img/6.webp
Normal file
|
After Width: | Height: | Size: 104 KiB |
BIN
img/7.webp
Normal file
|
After Width: | Height: | Size: 90 KiB |
BIN
img/8.webp
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
img/9.webp
Normal file
|
After Width: | Height: | Size: 103 KiB |
15
index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!doctype html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/ai.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>card.syui.ai</title>
|
||||
<link rel="stylesheet" href="/pkg/icomoon/style.css" />
|
||||
<link rel="stylesheet" href="/pkg/font-awesome/css/all.min.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,330 +0,0 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 56;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1A1234561234567890ABCDEF /* AiCardApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A1234551234567890ABCDEF /* AiCardApp.swift */; };
|
||||
1A1234581234567890ABCDEF /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A1234571234567890ABCDEF /* ContentView.swift */; };
|
||||
1A12345A1234567890ABCDEF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1A1234591234567890ABCDEF /* Assets.xcassets */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
1A1234521234567890ABCDEF /* AiCard.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AiCard.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
1A1234551234567890ABCDEF /* AiCardApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AiCardApp.swift; sourceTree = "<group>"; };
|
||||
1A1234571234567890ABCDEF /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
1A1234591234567890ABCDEF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
1A12344F1234567890ABCDEF /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
1A1234491234567890ABCDEF = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1A1234541234567890ABCDEF /* AiCard */,
|
||||
1A1234531234567890ABCDEF /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1A1234531234567890ABCDEF /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1A1234521234567890ABCDEF /* AiCard.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1A1234541234567890ABCDEF /* AiCard */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1A1234551234567890ABCDEF /* AiCardApp.swift */,
|
||||
1A1234571234567890ABCDEF /* ContentView.swift */,
|
||||
1A1234591234567890ABCDEF /* Assets.xcassets */,
|
||||
);
|
||||
path = AiCard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
1A1234511234567890ABCDEF /* AiCard */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 1A1234601234567890ABCDEF /* Build configuration list for PBXNativeTarget "AiCard" */;
|
||||
buildPhases = (
|
||||
1A12344E1234567890ABCDEF /* Sources */,
|
||||
1A12344F1234567890ABCDEF /* Frameworks */,
|
||||
1A1234501234567890ABCDEF /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = AiCard;
|
||||
productName = AiCard;
|
||||
productReference = 1A1234521234567890ABCDEF /* AiCard.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
1A12344A1234567890ABCDEF /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = 1;
|
||||
LastSwiftUpdateCheck = 1500;
|
||||
LastUpgradeCheck = 1500;
|
||||
TargetAttributes = {
|
||||
1A1234511234567890ABCDEF = {
|
||||
CreatedOnToolsVersion = 15.0;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 1A12344D1234567890ABCDEF /* Build configuration list for PBXProject "AiCard" */;
|
||||
compatibilityVersion = "Xcode 14.0";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 1A1234491234567890ABCDEF;
|
||||
productRefGroup = 1A1234531234567890ABCDEF /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
1A1234511234567890ABCDEF /* AiCard */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
1A1234501234567890ABCDEF /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1A12345A1234567890ABCDEF /* Assets.xcassets in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
1A12344E1234567890ABCDEF /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1A1234581234567890ABCDEF /* ContentView.swift in Sources */,
|
||||
1A1234561234567890ABCDEF /* AiCardApp.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
1A12345E1234567890ABCDEF /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1A12345F1234567890ABCDEF /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
1A1234611234567890ABCDEF /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "";
|
||||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ai.syui.card;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1A1234621234567890ABCDEF /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_ASSET_PATHS = "";
|
||||
ENABLE_PREVIEWS = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ai.syui.card;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
1A12344D1234567890ABCDEF /* Build configuration list for PBXProject "AiCard" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1A12345E1234567890ABCDEF /* Debug */,
|
||||
1A12345F1234567890ABCDEF /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
1A1234601234567890ABCDEF /* Build configuration list for PBXNativeTarget "AiCard" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1A1234611234567890ABCDEF /* Debug */,
|
||||
1A1234621234567890ABCDEF /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 1A12344A1234567890ABCDEF /* Project object */;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
struct AiCardApp: App {
|
||||
@StateObject private var authManager = AuthManager()
|
||||
@StateObject private var cardManager = CardManager()
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
.environmentObject(authManager)
|
||||
.environmentObject(cardManager)
|
||||
.preferredColorScheme(.dark)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
@EnvironmentObject var authManager: AuthManager
|
||||
@State private var selectedTab = 0
|
||||
|
||||
var body: some View {
|
||||
if authManager.isAuthenticated {
|
||||
TabView(selection: $selectedTab) {
|
||||
GachaView()
|
||||
.tabItem {
|
||||
Label("ガチャ", systemImage: "sparkles")
|
||||
}
|
||||
.tag(0)
|
||||
|
||||
CollectionView()
|
||||
.tabItem {
|
||||
Label("コレクション", systemImage: "square.grid.3x3")
|
||||
}
|
||||
.tag(1)
|
||||
|
||||
ProfileView()
|
||||
.tabItem {
|
||||
Label("プロフィール", systemImage: "person.circle")
|
||||
}
|
||||
.tag(2)
|
||||
}
|
||||
.accentColor(Color(hex: "fff700"))
|
||||
} else {
|
||||
LoginView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ContentView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ContentView()
|
||||
.environmentObject(AuthManager())
|
||||
.environmentObject(CardManager())
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
import Foundation
|
||||
|
||||
// MARK: - AI分析関連モデル
|
||||
|
||||
struct CollectionAnalysis: Codable {
|
||||
let totalCards: Int
|
||||
let uniqueCards: Int
|
||||
let rarityDistribution: [String: Int]
|
||||
let collectionScore: Double
|
||||
let recommendations: [String]
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case totalCards = "total_cards"
|
||||
case uniqueCards = "unique_cards"
|
||||
case rarityDistribution = "rarity_distribution"
|
||||
case collectionScore = "collection_score"
|
||||
case recommendations
|
||||
}
|
||||
}
|
||||
|
||||
struct GachaStats: Codable {
|
||||
let totalDraws: Int
|
||||
let cardsByRarity: [String: Int]
|
||||
let successRates: [String: Double]
|
||||
let recentActivity: [GachaActivity]
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case totalDraws = "total_draws"
|
||||
case cardsByRarity = "cards_by_rarity"
|
||||
case successRates = "success_rates"
|
||||
case recentActivity = "recent_activity"
|
||||
}
|
||||
}
|
||||
|
||||
struct GachaActivity: Codable {
|
||||
let timestamp: String
|
||||
let userDid: String
|
||||
let cardName: String
|
||||
let rarity: String
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case timestamp
|
||||
case userDid = "user_did"
|
||||
case cardName = "card_name"
|
||||
case rarity
|
||||
}
|
||||
}
|
||||
|
||||
struct UniqueRegistry: Codable {
|
||||
let registeredCards: [String: String]
|
||||
let totalUnique: Int
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case registeredCards = "registered_cards"
|
||||
case totalUnique = "total_unique"
|
||||
}
|
||||
}
|
||||
|
||||
struct SystemStatus: Codable {
|
||||
let status: String
|
||||
let mcpEnabled: Bool
|
||||
let mcpEndpoint: String?
|
||||
let databaseConnected: Bool
|
||||
let aiGptConnected: Bool
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case status
|
||||
case mcpEnabled = "mcp_enabled"
|
||||
case mcpEndpoint = "mcp_endpoint"
|
||||
case databaseConnected = "database_connected"
|
||||
case aiGptConnected = "ai_gpt_connected"
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
import Foundation
|
||||
|
||||
enum CardRarity: String, Codable, CaseIterable {
|
||||
case normal = "normal"
|
||||
case rare = "rare"
|
||||
case superRare = "super_rare"
|
||||
case kira = "kira"
|
||||
case unique = "unique"
|
||||
|
||||
var displayName: String {
|
||||
switch self {
|
||||
case .normal: return "ノーマル"
|
||||
case .rare: return "レア"
|
||||
case .superRare: return "スーパーレア"
|
||||
case .kira: return "キラ"
|
||||
case .unique: return "ユニーク"
|
||||
}
|
||||
}
|
||||
|
||||
var gradientColors: [String] {
|
||||
switch self {
|
||||
case .normal: return ["666666", "333333"]
|
||||
case .rare: return ["4a90e2", "16213e"]
|
||||
case .superRare: return ["9c27b0", "0f0c29"]
|
||||
case .kira: return ["ffd700", "414345"]
|
||||
case .unique: return ["ff00ff", "1a0033"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Card: Identifiable, Codable {
|
||||
let id: Int
|
||||
let cp: Int
|
||||
let status: CardRarity
|
||||
let skill: String?
|
||||
let ownerDid: String
|
||||
let obtainedAt: Date
|
||||
let isUnique: Bool
|
||||
let uniqueId: String?
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case cp
|
||||
case status
|
||||
case skill
|
||||
case ownerDid = "owner_did"
|
||||
case obtainedAt = "obtained_at"
|
||||
case isUnique = "is_unique"
|
||||
case uniqueId = "unique_id"
|
||||
}
|
||||
}
|
||||
|
||||
struct CardDrawResult: Codable {
|
||||
let card: Card
|
||||
let isNew: Bool
|
||||
let animationType: String
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case card
|
||||
case isNew = "is_new"
|
||||
case animationType = "animation_type"
|
||||
}
|
||||
}
|
||||
|
||||
// Card master data
|
||||
struct CardInfo {
|
||||
let id: Int
|
||||
let name: String
|
||||
let color: String
|
||||
let description: String
|
||||
|
||||
static let all: [Int: CardInfo] = [
|
||||
0: CardInfo(id: 0, name: "アイ", color: "fff700", description: "世界の最小単位"),
|
||||
1: CardInfo(id: 1, name: "夢幻", color: "b19cd9", description: "意識が物質を作る"),
|
||||
2: CardInfo(id: 2, name: "光彩", color: "ffd700", description: "存在は光に向かう"),
|
||||
3: CardInfo(id: 3, name: "中性子", color: "cacfd2", description: "中性子"),
|
||||
4: CardInfo(id: 4, name: "太陽", color: "ff6b35", description: "太陽"),
|
||||
5: CardInfo(id: 5, name: "夜空", color: "1a1a2e", description: "夜空"),
|
||||
6: CardInfo(id: 6, name: "雪", color: "e3f2fd", description: "雪"),
|
||||
7: CardInfo(id: 7, name: "雷", color: "ffd93d", description: "雷"),
|
||||
8: CardInfo(id: 8, name: "超究", color: "6c5ce7", description: "超究"),
|
||||
9: CardInfo(id: 9, name: "剣", color: "a8e6cf", description: "剣"),
|
||||
10: CardInfo(id: 10, name: "破壊", color: "ff4757", description: "破壊"),
|
||||
11: CardInfo(id: 11, name: "地球", color: "4834d4", description: "地球"),
|
||||
12: CardInfo(id: 12, name: "天の川", color: "9c88ff", description: "天の川"),
|
||||
13: CardInfo(id: 13, name: "創造", color: "00d2d3", description: "創造"),
|
||||
14: CardInfo(id: 14, name: "超新星", color: "ff9ff3", description: "超新星"),
|
||||
15: CardInfo(id: 15, name: "世界", color: "54a0ff", description: "存在と世界は同じもの")
|
||||
]
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import Foundation
|
||||
|
||||
struct User: Codable {
|
||||
let did: String
|
||||
let handle: String
|
||||
}
|
||||
|
||||
struct LoginRequest: Codable {
|
||||
let identifier: String
|
||||
let password: String
|
||||
}
|
||||
|
||||
struct LoginResponse: Codable {
|
||||
let accessToken: String
|
||||
let tokenType: String
|
||||
let did: String
|
||||
let handle: String
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case accessToken = "access_token"
|
||||
case tokenType = "token_type"
|
||||
case did
|
||||
case handle
|
||||
}
|
||||
}
|
||||
@@ -1,237 +0,0 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
|
||||
enum APIError: Error {
|
||||
case invalidURL
|
||||
case noData
|
||||
case decodingError
|
||||
case networkError(String)
|
||||
case unauthorized
|
||||
}
|
||||
|
||||
// MCP Server response format
|
||||
struct MCPResponse<T: Decodable>: Decodable {
|
||||
let data: T?
|
||||
let error: String?
|
||||
}
|
||||
|
||||
class APIClient {
|
||||
static let shared = APIClient()
|
||||
|
||||
#if DEBUG
|
||||
private let baseURL = "http://localhost:8000/api/v1" // ai.card direct access
|
||||
private let aiGptBaseURL = "http://localhost:8001" // ai.gpt MCP server (optional)
|
||||
#else
|
||||
private let baseURL = "https://api.card.syui.ai/api/v1" // ai.card direct access
|
||||
private let aiGptBaseURL = "https://ai.gpt.syui.ai" // ai.gpt MCP server (optional)
|
||||
#endif
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
private init() {}
|
||||
|
||||
private var authToken: String? {
|
||||
get { UserDefaults.standard.string(forKey: "authToken") }
|
||||
set { UserDefaults.standard.set(newValue, forKey: "authToken") }
|
||||
}
|
||||
|
||||
// ai.gpt MCP経由でのリクエスト(推奨)
|
||||
private func mcpRequest<T: Decodable>(_ endpoint: String,
|
||||
parameters: [String: Any] = [:]) -> AnyPublisher<T, APIError> {
|
||||
guard let url = URL(string: "\(aiGptBaseURL)\(endpoint)") else {
|
||||
return Fail(error: APIError.invalidURL).eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
var components = URLComponents(url: url, resolvingAgainstBaseURL: false)
|
||||
components?.queryItems = parameters.map { URLQueryItem(name: $0.key, value: "\($0.value)") }
|
||||
|
||||
guard let finalURL = components?.url else {
|
||||
return Fail(error: APIError.invalidURL).eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
var request = URLRequest(url: finalURL)
|
||||
request.httpMethod = "GET"
|
||||
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
||||
|
||||
return URLSession.shared.dataTaskPublisher(for: request)
|
||||
.tryMap { data, response in
|
||||
guard let httpResponse = response as? HTTPURLResponse else {
|
||||
throw APIError.networkError("Invalid response")
|
||||
}
|
||||
|
||||
if !(200...299).contains(httpResponse.statusCode) {
|
||||
throw APIError.networkError("MCP Server error: \(httpResponse.statusCode)")
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
.decode(type: MCPResponse<T>.self, decoder: JSONDecoder())
|
||||
.tryMap { mcpResponse in
|
||||
if let data = mcpResponse.data {
|
||||
return data
|
||||
} else if let error = mcpResponse.error {
|
||||
throw APIError.networkError(error)
|
||||
} else {
|
||||
throw APIError.networkError("Invalid MCP response")
|
||||
}
|
||||
}
|
||||
.mapError { error in
|
||||
if error is DecodingError {
|
||||
return APIError.decodingError
|
||||
} else if let apiError = error as? APIError {
|
||||
return apiError
|
||||
} else {
|
||||
return APIError.networkError(error.localizedDescription)
|
||||
}
|
||||
}
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
// ai.card直接リクエスト(メイン)
|
||||
private func request<T: Decodable>(_ endpoint: String,
|
||||
method: String = "GET",
|
||||
body: Data? = nil,
|
||||
authenticated: Bool = true) -> AnyPublisher<T, APIError> {
|
||||
guard let url = URL(string: "\(baseURL)\(endpoint)") else {
|
||||
return Fail(error: APIError.invalidURL).eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
var request = URLRequest(url: url)
|
||||
request.httpMethod = method
|
||||
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
||||
|
||||
if authenticated, let token = authToken {
|
||||
request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
|
||||
}
|
||||
|
||||
if let body = body {
|
||||
request.httpBody = body
|
||||
}
|
||||
|
||||
return URLSession.shared.dataTaskPublisher(for: request)
|
||||
.tryMap { data, response in
|
||||
guard let httpResponse = response as? HTTPURLResponse else {
|
||||
throw APIError.networkError("Invalid response")
|
||||
}
|
||||
|
||||
if httpResponse.statusCode == 401 {
|
||||
throw APIError.unauthorized
|
||||
}
|
||||
|
||||
if !(200...299).contains(httpResponse.statusCode) {
|
||||
throw APIError.networkError("Status code: \(httpResponse.statusCode)")
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
.decode(type: T.self, decoder: JSONDecoder())
|
||||
.mapError { error in
|
||||
if error is DecodingError {
|
||||
return APIError.decodingError
|
||||
} else if let apiError = error as? APIError {
|
||||
return apiError
|
||||
} else {
|
||||
return APIError.networkError(error.localizedDescription)
|
||||
}
|
||||
}
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
// MARK: - Auth
|
||||
|
||||
func login(identifier: String, password: String) -> AnyPublisher<LoginResponse, APIError> {
|
||||
let loginRequest = LoginRequest(identifier: identifier, password: password)
|
||||
guard let body = try? JSONEncoder().encode(loginRequest) else {
|
||||
return Fail(error: APIError.decodingError).eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
return request("/auth/login", method: "POST", body: body, authenticated: false)
|
||||
.handleEvents(receiveOutput: { [weak self] (response: LoginResponse) in
|
||||
self?.authToken = response.accessToken
|
||||
})
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
func logout() -> AnyPublisher<Void, APIError> {
|
||||
request("/auth/logout", method: "POST")
|
||||
.map { (_: [String: String]) in () }
|
||||
.handleEvents(receiveCompletion: { [weak self] _ in
|
||||
self?.authToken = nil
|
||||
})
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
func verify() -> AnyPublisher<User, APIError> {
|
||||
request("/auth/verify")
|
||||
}
|
||||
|
||||
// MARK: - Cards (ai.card直接アクセス)
|
||||
|
||||
func drawCard(userDid: String, isPaid: Bool = false) -> AnyPublisher<CardDrawResult, APIError> {
|
||||
let body = try? JSONEncoder().encode([
|
||||
"user_did": userDid,
|
||||
"is_paid": isPaid
|
||||
])
|
||||
|
||||
return request("/cards/draw", method: "POST", body: body)
|
||||
}
|
||||
|
||||
func getUserCards(userDid: String) -> AnyPublisher<[Card], APIError> {
|
||||
return request("/cards/user/\(userDid)")
|
||||
}
|
||||
|
||||
func getCardDetails(cardId: Int) -> AnyPublisher<Card, APIError> {
|
||||
return request("/cards/\(cardId)")
|
||||
}
|
||||
|
||||
func getGachaStats() -> AnyPublisher<GachaStats, APIError> {
|
||||
return request("/cards/stats")
|
||||
}
|
||||
|
||||
func getUniqueCards() -> AnyPublisher<[[String: Any]], APIError> {
|
||||
return request("/cards/unique")
|
||||
}
|
||||
|
||||
func getSystemStatus() -> AnyPublisher<[String: Any], APIError> {
|
||||
return request("/health")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - AI Enhanced API (Optional ai.gpt integration)
|
||||
|
||||
extension APIClient {
|
||||
|
||||
func analyzeCollection(userDid: String) -> AnyPublisher<CollectionAnalysis, APIError> {
|
||||
let parameters: [String: Any] = [
|
||||
"did": userDid
|
||||
]
|
||||
|
||||
return mcpRequest("/card_analyze_collection", parameters: parameters)
|
||||
.catch { error -> AnyPublisher<CollectionAnalysis, APIError> in
|
||||
// AI機能が利用できない場合のエラー
|
||||
return Fail(error: APIError.networkError("AI分析機能を利用するにはai.gptサーバーが必要です")).eraseToAnyPublisher()
|
||||
}
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
func getEnhancedStats() -> AnyPublisher<GachaStats, APIError> {
|
||||
return mcpRequest("/card_get_gacha_stats", parameters: [:])
|
||||
.catch { [weak self] error -> AnyPublisher<GachaStats, APIError> in
|
||||
// AI機能が利用できない場合は基本統計にフォールバック
|
||||
print("AI統計が利用できません、基本統計に切り替えます: \(error)")
|
||||
return self?.getGachaStats() ?? Fail(error: error).eraseToAnyPublisher()
|
||||
}
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
func isAIAvailable() -> AnyPublisher<Bool, Never> {
|
||||
guard let url = URL(string: "\(aiGptBaseURL)/health") else {
|
||||
return Just(false).eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
return URLSession.shared.dataTaskPublisher(for: url)
|
||||
.map { _ in true }
|
||||
.catch { _ in Just(false) }
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
}
|
||||
@@ -1,355 +0,0 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
import AuthenticationServices
|
||||
|
||||
struct AtprotoSession: Codable {
|
||||
let did: String
|
||||
let handle: String
|
||||
let accessJwt: String
|
||||
let refreshJwt: String
|
||||
let email: String?
|
||||
let emailConfirmed: Bool?
|
||||
}
|
||||
|
||||
class AtprotoOAuthService: NSObject, ObservableObject {
|
||||
static let shared = AtprotoOAuthService()
|
||||
|
||||
@Published var session: AtprotoSession?
|
||||
@Published var isAuthenticated: Bool = false
|
||||
|
||||
private var authSession: ASWebAuthenticationSession?
|
||||
private let clientId: String
|
||||
private let redirectUri: String
|
||||
private let scope = "atproto transition:generic"
|
||||
|
||||
override init() {
|
||||
// Generate client metadata URL
|
||||
self.clientId = "\(Bundle.main.bundleIdentifier ?? "ai.card")/client-metadata.json"
|
||||
self.redirectUri = "aicard://oauth/callback"
|
||||
|
||||
super.init()
|
||||
loadSessionFromKeychain()
|
||||
}
|
||||
|
||||
// MARK: - OAuth Flow
|
||||
|
||||
func initiateOAuthFlow() -> AnyPublisher<AtprotoSession, Error> {
|
||||
return Future { [weak self] promise in
|
||||
guard let self = self else {
|
||||
promise(.failure(OAuthError.invalidState))
|
||||
return
|
||||
}
|
||||
|
||||
Task {
|
||||
do {
|
||||
let authURL = try await self.buildAuthorizationURL()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.startWebAuthenticationSession(url: authURL) { result in
|
||||
switch result {
|
||||
case .success(let session):
|
||||
self.session = session
|
||||
self.isAuthenticated = true
|
||||
self.saveSessionToKeychain(session)
|
||||
promise(.success(session))
|
||||
|
||||
case .failure(let error):
|
||||
promise(.failure(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
promise(.failure(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
private func buildAuthorizationURL() async throws -> URL {
|
||||
// Generate PKCE parameters
|
||||
let state = generateRandomString(32)
|
||||
let codeVerifier = generateRandomString(128)
|
||||
let codeChallenge = try generateCodeChallenge(from: codeVerifier)
|
||||
|
||||
// Store PKCE parameters
|
||||
UserDefaults.standard.set(state, forKey: "oauth_state")
|
||||
UserDefaults.standard.set(codeVerifier, forKey: "oauth_code_verifier")
|
||||
|
||||
// For development: use mock authorization server
|
||||
// In production, this would discover the actual atproto authorization server
|
||||
let authServer = "https://bsky.social" // Mock - should be discovered
|
||||
|
||||
var components = URLComponents(string: "\(authServer)/oauth/authorize")!
|
||||
components.queryItems = [
|
||||
URLQueryItem(name: "response_type", value: "code"),
|
||||
URLQueryItem(name: "client_id", value: clientId),
|
||||
URLQueryItem(name: "redirect_uri", value: redirectUri),
|
||||
URLQueryItem(name: "scope", value: scope),
|
||||
URLQueryItem(name: "state", value: state),
|
||||
URLQueryItem(name: "code_challenge", value: codeChallenge),
|
||||
URLQueryItem(name: "code_challenge_method", value: "S256")
|
||||
]
|
||||
|
||||
guard let url = components.url else {
|
||||
throw OAuthError.invalidURL
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
private func startWebAuthenticationSession(url: URL, completion: @escaping (Result<AtprotoSession, Error>) -> Void) {
|
||||
authSession = ASWebAuthenticationSession(url: url, callbackURLScheme: "aicard") { [weak self] callbackURL, error in
|
||||
|
||||
if let error = error {
|
||||
if case ASWebAuthenticationSessionError.canceledLogin = error {
|
||||
completion(.failure(OAuthError.userCancelled))
|
||||
} else {
|
||||
completion(.failure(error))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
guard let callbackURL = callbackURL else {
|
||||
completion(.failure(OAuthError.invalidCallback))
|
||||
return
|
||||
}
|
||||
|
||||
Task {
|
||||
do {
|
||||
let session = try await self?.handleOAuthCallback(callbackURL: callbackURL)
|
||||
if let session = session {
|
||||
completion(.success(session))
|
||||
} else {
|
||||
completion(.failure(OAuthError.invalidState))
|
||||
}
|
||||
} catch {
|
||||
completion(.failure(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
authSession?.presentationContextProvider = self
|
||||
authSession?.prefersEphemeralWebBrowserSession = false
|
||||
authSession?.start()
|
||||
}
|
||||
|
||||
private func handleOAuthCallback(callbackURL: URL) async throws -> AtprotoSession {
|
||||
guard let components = URLComponents(url: callbackURL, resolvingAgainstBaseURL: false),
|
||||
let queryItems = components.queryItems else {
|
||||
throw OAuthError.invalidCallback
|
||||
}
|
||||
|
||||
var code: String?
|
||||
var state: String?
|
||||
var error: String?
|
||||
|
||||
for item in queryItems {
|
||||
switch item.name {
|
||||
case "code":
|
||||
code = item.value
|
||||
case "state":
|
||||
state = item.value
|
||||
case "error":
|
||||
error = item.value
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if let error = error {
|
||||
throw OAuthError.authorizationFailed(error)
|
||||
}
|
||||
|
||||
guard let code = code, let state = state else {
|
||||
throw OAuthError.missingParameters
|
||||
}
|
||||
|
||||
// Verify state
|
||||
let storedState = UserDefaults.standard.string(forKey: "oauth_state")
|
||||
guard state == storedState else {
|
||||
throw OAuthError.invalidState
|
||||
}
|
||||
|
||||
// Get code verifier
|
||||
guard let codeVerifier = UserDefaults.standard.string(forKey: "oauth_code_verifier") else {
|
||||
throw OAuthError.missingCodeVerifier
|
||||
}
|
||||
|
||||
// Exchange code for tokens
|
||||
let session = try await exchangeCodeForTokens(code: code, codeVerifier: codeVerifier)
|
||||
|
||||
// Clean up temporary data
|
||||
UserDefaults.standard.removeObject(forKey: "oauth_state")
|
||||
UserDefaults.standard.removeObject(forKey: "oauth_code_verifier")
|
||||
|
||||
return session
|
||||
}
|
||||
|
||||
private func exchangeCodeForTokens(code: String, codeVerifier: String) async throws -> AtprotoSession {
|
||||
// This is a mock implementation
|
||||
// In production, this would make a proper token exchange request
|
||||
|
||||
// For development, return a mock session
|
||||
let mockSession = AtprotoSession(
|
||||
did: "did:plc:mock123456789",
|
||||
handle: "user.bsky.social",
|
||||
accessJwt: "mock_access_token",
|
||||
refreshJwt: "mock_refresh_token",
|
||||
email: nil,
|
||||
emailConfirmed: nil
|
||||
)
|
||||
|
||||
return mockSession
|
||||
}
|
||||
|
||||
// MARK: - Session Management
|
||||
|
||||
func refreshTokens() async throws -> AtprotoSession {
|
||||
guard let currentSession = session else {
|
||||
throw OAuthError.noSession
|
||||
}
|
||||
|
||||
// This would make a proper token refresh request
|
||||
// For now, return the existing session
|
||||
return currentSession
|
||||
}
|
||||
|
||||
func logout() {
|
||||
session = nil
|
||||
isAuthenticated = false
|
||||
deleteSessionFromKeychain()
|
||||
|
||||
// Cancel any ongoing auth session
|
||||
authSession?.cancel()
|
||||
authSession = nil
|
||||
}
|
||||
|
||||
// MARK: - Keychain Storage
|
||||
|
||||
private func saveSessionToKeychain(_ session: AtprotoSession) {
|
||||
guard let data = try? JSONEncoder().encode(session) else { return }
|
||||
|
||||
let query: [String: Any] = [
|
||||
kSecClass as String: kSecClassGenericPassword,
|
||||
kSecAttrAccount as String: "atproto_session",
|
||||
kSecValueData as String: data
|
||||
]
|
||||
|
||||
// Delete existing item
|
||||
SecItemDelete(query as CFDictionary)
|
||||
|
||||
// Add new item
|
||||
SecItemAdd(query as CFDictionary, nil)
|
||||
}
|
||||
|
||||
private func loadSessionFromKeychain() {
|
||||
let query: [String: Any] = [
|
||||
kSecClass as String: kSecClassGenericPassword,
|
||||
kSecAttrAccount as String: "atproto_session",
|
||||
kSecReturnData as String: true,
|
||||
kSecMatchLimit as String: kSecMatchLimitOne
|
||||
]
|
||||
|
||||
var result: AnyObject?
|
||||
let status = SecItemCopyMatching(query as CFDictionary, &result)
|
||||
|
||||
if status == errSecSuccess,
|
||||
let data = result as? Data,
|
||||
let session = try? JSONDecoder().decode(AtprotoSession.self, from: data) {
|
||||
self.session = session
|
||||
self.isAuthenticated = true
|
||||
}
|
||||
}
|
||||
|
||||
private func deleteSessionFromKeychain() {
|
||||
let query: [String: Any] = [
|
||||
kSecClass as String: kSecClassGenericPassword,
|
||||
kSecAttrAccount as String: "atproto_session"
|
||||
]
|
||||
|
||||
SecItemDelete(query as CFDictionary)
|
||||
}
|
||||
|
||||
// MARK: - Utility Methods
|
||||
|
||||
private func generateRandomString(_ length: Int) -> String {
|
||||
let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"
|
||||
return String((0..<length).map { _ in chars.randomElement()! })
|
||||
}
|
||||
|
||||
private func generateCodeChallenge(from verifier: String) throws -> String {
|
||||
guard let data = verifier.data(using: .utf8) else {
|
||||
throw OAuthError.encodingError
|
||||
}
|
||||
|
||||
let digest = SHA256.hash(data: data)
|
||||
return Data(digest).base64URLEncodedString()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - ASWebAuthenticationPresentationContextProviding
|
||||
|
||||
extension AtprotoOAuthService: ASWebAuthenticationPresentationContextProviding {
|
||||
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
|
||||
return UIApplication.shared.windows.first { $0.isKeyWindow } ?? ASPresentationAnchor()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Errors
|
||||
|
||||
enum OAuthError: LocalizedError {
|
||||
case invalidURL
|
||||
case invalidState
|
||||
case invalidCallback
|
||||
case missingParameters
|
||||
case missingCodeVerifier
|
||||
case authorizationFailed(String)
|
||||
case userCancelled
|
||||
case noSession
|
||||
case encodingError
|
||||
|
||||
var errorDescription: String? {
|
||||
switch self {
|
||||
case .invalidURL:
|
||||
return "無効なURLです"
|
||||
case .invalidState:
|
||||
return "無効な状態パラメータです"
|
||||
case .invalidCallback:
|
||||
return "無効なコールバックです"
|
||||
case .missingParameters:
|
||||
return "必要なパラメータが不足しています"
|
||||
case .missingCodeVerifier:
|
||||
return "コード検証子が見つかりません"
|
||||
case .authorizationFailed(let error):
|
||||
return "認証に失敗しました: \(error)"
|
||||
case .userCancelled:
|
||||
return "ユーザーによってキャンセルされました"
|
||||
case .noSession:
|
||||
return "セッションがありません"
|
||||
case .encodingError:
|
||||
return "エンコードエラーです"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Data Extension for Base64URL
|
||||
|
||||
extension Data {
|
||||
func base64URLEncodedString() -> String {
|
||||
return base64EncodedString()
|
||||
.replacingOccurrences(of: "+", with: "-")
|
||||
.replacingOccurrences(of: "/", with: "_")
|
||||
.replacingOccurrences(of: "=", with: "")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - SHA256 (simplified for demo)
|
||||
|
||||
import CryptoKit
|
||||
|
||||
extension SHA256 {
|
||||
static func hash(data: Data) -> SHA256.Digest {
|
||||
return SHA256.hash(data: data)
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
import SwiftUI
|
||||
|
||||
class AuthManager: ObservableObject {
|
||||
@Published var isAuthenticated = false
|
||||
@Published var currentUser: User?
|
||||
@Published var isLoading = false
|
||||
@Published var errorMessage: String?
|
||||
@Published var authMode: AuthMode = .oauth
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
private let apiClient = APIClient.shared
|
||||
private let oauthService = AtprotoOAuthService.shared
|
||||
|
||||
enum AuthMode {
|
||||
case oauth
|
||||
case legacy
|
||||
}
|
||||
|
||||
init() {
|
||||
// Monitor OAuth service
|
||||
oauthService.$isAuthenticated
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] isAuth in
|
||||
if isAuth, let session = self?.oauthService.session {
|
||||
self?.isAuthenticated = true
|
||||
self?.currentUser = User(did: session.did, handle: session.handle)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
checkAuthStatus()
|
||||
}
|
||||
|
||||
private func checkAuthStatus() {
|
||||
isLoading = true
|
||||
|
||||
// Check OAuth session first
|
||||
if oauthService.isAuthenticated, let session = oauthService.session {
|
||||
isAuthenticated = true
|
||||
currentUser = User(did: session.did, handle: session.handle)
|
||||
isLoading = false
|
||||
return
|
||||
}
|
||||
|
||||
// Fallback to legacy auth
|
||||
apiClient.verify()
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink(
|
||||
receiveCompletion: { [weak self] completion in
|
||||
self?.isLoading = false
|
||||
if case .failure = completion {
|
||||
self?.isAuthenticated = false
|
||||
self?.currentUser = nil
|
||||
}
|
||||
},
|
||||
receiveValue: { [weak self] user in
|
||||
self?.isAuthenticated = true
|
||||
self?.currentUser = user
|
||||
}
|
||||
)
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func loginWithOAuth() {
|
||||
isLoading = true
|
||||
errorMessage = nil
|
||||
|
||||
oauthService.initiateOAuthFlow()
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink(
|
||||
receiveCompletion: { [weak self] completion in
|
||||
self?.isLoading = false
|
||||
if case .failure(let error) = completion {
|
||||
self?.errorMessage = error.localizedDescription
|
||||
}
|
||||
},
|
||||
receiveValue: { [weak self] session in
|
||||
self?.isAuthenticated = true
|
||||
self?.currentUser = User(did: session.did, handle: session.handle)
|
||||
}
|
||||
)
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func loginWithPassword(identifier: String, password: String) {
|
||||
isLoading = true
|
||||
errorMessage = nil
|
||||
|
||||
apiClient.login(identifier: identifier, password: password)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink(
|
||||
receiveCompletion: { [weak self] completion in
|
||||
self?.isLoading = false
|
||||
if case .failure(let error) = completion {
|
||||
self?.errorMessage = self?.getErrorMessage(from: error)
|
||||
}
|
||||
},
|
||||
receiveValue: { [weak self] response in
|
||||
self?.isAuthenticated = true
|
||||
self?.currentUser = User(did: response.did, handle: response.handle)
|
||||
}
|
||||
)
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func logout() {
|
||||
isLoading = true
|
||||
|
||||
// Logout from both services
|
||||
oauthService.logout()
|
||||
|
||||
apiClient.logout()
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink(
|
||||
receiveCompletion: { [weak self] _ in
|
||||
self?.isLoading = false
|
||||
self?.isAuthenticated = false
|
||||
self?.currentUser = nil
|
||||
UserDefaults.standard.removeObject(forKey: "authToken")
|
||||
},
|
||||
receiveValue: { _ in }
|
||||
)
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
private func getErrorMessage(from error: APIError) -> String {
|
||||
switch error {
|
||||
case .unauthorized:
|
||||
return "認証情報が正しくありません"
|
||||
case .networkError:
|
||||
return "ネットワークエラーが発生しました"
|
||||
default:
|
||||
return "エラーが発生しました"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
import SwiftUI
|
||||
|
||||
class CardManager: ObservableObject {
|
||||
@Published var userCards: [Card] = []
|
||||
@Published var isLoading = false
|
||||
@Published var errorMessage: String?
|
||||
@Published var currentDraw: CardDrawResult?
|
||||
@Published var isDrawing = false
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
private let apiClient = APIClient.shared
|
||||
|
||||
func loadUserCards(userDid: String) {
|
||||
isLoading = true
|
||||
|
||||
apiClient.getUserCards(userDid: userDid)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink(
|
||||
receiveCompletion: { [weak self] completion in
|
||||
self?.isLoading = false
|
||||
if case .failure(let error) = completion {
|
||||
self?.errorMessage = self?.getErrorMessage(from: error)
|
||||
}
|
||||
},
|
||||
receiveValue: { [weak self] cards in
|
||||
self?.userCards = cards
|
||||
}
|
||||
)
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func drawCard(userDid: String, isPaid: Bool = false) {
|
||||
isDrawing = true
|
||||
errorMessage = nil
|
||||
|
||||
apiClient.drawCard(userDid: userDid, isPaid: isPaid)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink(
|
||||
receiveCompletion: { [weak self] completion in
|
||||
if case .failure(let error) = completion {
|
||||
self?.isDrawing = false
|
||||
self?.errorMessage = self?.getErrorMessage(from: error)
|
||||
}
|
||||
},
|
||||
receiveValue: { [weak self] result in
|
||||
self?.currentDraw = result
|
||||
// アニメーション終了後にカードを追加
|
||||
}
|
||||
)
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func completeCardDraw() {
|
||||
if let newCard = currentDraw?.card {
|
||||
userCards.append(newCard)
|
||||
}
|
||||
currentDraw = nil
|
||||
isDrawing = false
|
||||
}
|
||||
|
||||
private func getErrorMessage(from error: APIError) -> String {
|
||||
switch error {
|
||||
case .unauthorized:
|
||||
return "認証が必要です"
|
||||
case .networkError:
|
||||
return "ネットワークエラーが発生しました"
|
||||
default:
|
||||
return "エラーが発生しました"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import SwiftUI
|
||||
|
||||
extension Color {
|
||||
init(hex: String) {
|
||||
let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
|
||||
var int: UInt64 = 0
|
||||
Scanner(string: hex).scanHexInt64(&int)
|
||||
let a, r, g, b: UInt64
|
||||
switch hex.count {
|
||||
case 3: // RGB (12-bit)
|
||||
(a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17)
|
||||
case 6: // RGB (24-bit)
|
||||
(a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF)
|
||||
case 8: // ARGB (32-bit)
|
||||
(a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF)
|
||||
default:
|
||||
(a, r, g, b) = (1, 1, 1, 0)
|
||||
}
|
||||
|
||||
self.init(
|
||||
.sRGB,
|
||||
red: Double(r) / 255,
|
||||
green: Double(g) / 255,
|
||||
blue: Double(b) / 255,
|
||||
opacity: Double(a) / 255
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,247 +0,0 @@
|
||||
import SwiftUI
|
||||
|
||||
struct CardView: View {
|
||||
let card: Card
|
||||
let isRevealing: Bool
|
||||
@State private var isFlipped = false
|
||||
|
||||
init(card: Card, isRevealing: Bool = false) {
|
||||
self.card = card
|
||||
self.isRevealing = isRevealing
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
// Card background
|
||||
RoundedRectangle(cornerRadius: 16)
|
||||
.fill(
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: gradientColors),
|
||||
startPoint: .topLeading,
|
||||
endPoint: .bottomTrailing
|
||||
)
|
||||
)
|
||||
.frame(width: 200, height: 280)
|
||||
|
||||
// Card content
|
||||
VStack(spacing: 16) {
|
||||
// Header
|
||||
HStack {
|
||||
Text("#\(card.id)")
|
||||
.font(.caption)
|
||||
.foregroundColor(.white.opacity(0.7))
|
||||
|
||||
Spacer()
|
||||
|
||||
Text("CP: \(card.cp)")
|
||||
.font(.caption)
|
||||
.foregroundColor(.white.opacity(0.7))
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
// Card name and icon
|
||||
VStack(spacing: 12) {
|
||||
// Card icon (could be an image)
|
||||
Circle()
|
||||
.fill(Color(hex: cardInfo.color))
|
||||
.frame(width: 60, height: 60)
|
||||
.overlay(
|
||||
Text(cardInfo.name.prefix(1))
|
||||
.font(.title)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(.white)
|
||||
)
|
||||
|
||||
Text(cardInfo.name)
|
||||
.font(.title2)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(.white)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
if card.isUnique {
|
||||
UniqueBadge()
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
// Skill
|
||||
if let skill = card.skill, !skill.isEmpty {
|
||||
Text(skill)
|
||||
.font(.caption)
|
||||
.foregroundColor(.white.opacity(0.8))
|
||||
.padding(.horizontal, 8)
|
||||
.padding(.vertical, 4)
|
||||
.background(Color.black.opacity(0.3))
|
||||
.cornerRadius(8)
|
||||
}
|
||||
|
||||
// Rarity
|
||||
Text(card.status.displayName)
|
||||
.font(.caption)
|
||||
.foregroundColor(.white.opacity(0.7))
|
||||
.textCase(.uppercase)
|
||||
.tracking(1)
|
||||
}
|
||||
.padding(20)
|
||||
|
||||
// Special effects
|
||||
if card.status == .kira {
|
||||
KiraEffect()
|
||||
} else if card.status == .unique {
|
||||
UniqueEffect()
|
||||
}
|
||||
}
|
||||
.rotation3DEffect(
|
||||
.degrees(isRevealing && !isFlipped ? 180 : 0),
|
||||
axis: (x: 0, y: 1, z: 0)
|
||||
)
|
||||
.onAppear {
|
||||
if isRevealing {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
withAnimation(.easeInOut(duration: 0.8)) {
|
||||
isFlipped = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.scaleEffect(isRevealing ? 1.1 : 1.0)
|
||||
.shadow(color: .black.opacity(0.3), radius: 10, x: 0, y: 5)
|
||||
}
|
||||
|
||||
private var cardInfo: CardInfo {
|
||||
CardInfo.all[card.id] ?? CardInfo(id: card.id, name: "Unknown", color: "666666", description: "")
|
||||
}
|
||||
|
||||
private var gradientColors: [Color] {
|
||||
card.status.gradientColors.map { Color(hex: $0) }
|
||||
}
|
||||
}
|
||||
|
||||
struct UniqueBadge: View {
|
||||
@State private var phase: CGFloat = 0
|
||||
|
||||
var body: some View {
|
||||
Text("UNIQUE")
|
||||
.font(.caption2)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(.white)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 4)
|
||||
.background(
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color(hex: "ff00ff"),
|
||||
Color(hex: "00ffff")
|
||||
]),
|
||||
startPoint: .leading,
|
||||
endPoint: .trailing
|
||||
)
|
||||
.hueRotation(.degrees(phase))
|
||||
)
|
||||
.cornerRadius(12)
|
||||
.onAppear {
|
||||
withAnimation(.linear(duration: 2).repeatForever(autoreverses: false)) {
|
||||
phase = 360
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct KiraEffect: View {
|
||||
@State private var sparkles: [SparkleData] = []
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
ForEach(sparkles, id: \.id) { sparkle in
|
||||
Image(systemName: "sparkle")
|
||||
.foregroundColor(.yellow)
|
||||
.font(.system(size: sparkle.size))
|
||||
.position(x: sparkle.x, y: sparkle.y)
|
||||
.opacity(sparkle.opacity)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
generateSparkles()
|
||||
}
|
||||
}
|
||||
|
||||
private func generateSparkles() {
|
||||
for i in 0..<10 {
|
||||
let sparkle = SparkleData(
|
||||
id: i,
|
||||
x: CGFloat.random(in: 20...180),
|
||||
y: CGFloat.random(in: 20...260),
|
||||
size: CGFloat.random(in: 8...16),
|
||||
opacity: Double.random(in: 0.3...0.8)
|
||||
)
|
||||
sparkles.append(sparkle)
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + Double.random(in: 0...2)) {
|
||||
withAnimation(.easeInOut(duration: 1).repeatForever(autoreverses: true)) {
|
||||
if let index = sparkles.firstIndex(where: { $0.id == sparkle.id }) {
|
||||
sparkles[index].opacity = sparkles[index].opacity > 0.5 ? 0.2 : 0.8
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct UniqueEffect: View {
|
||||
@State private var pulseScale: CGFloat = 1.0
|
||||
|
||||
var body: some View {
|
||||
RoundedRectangle(cornerRadius: 16)
|
||||
.stroke(
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color(hex: "ff00ff"),
|
||||
Color(hex: "00ffff"),
|
||||
Color(hex: "ff00ff")
|
||||
]),
|
||||
startPoint: .topLeading,
|
||||
endPoint: .bottomTrailing
|
||||
),
|
||||
lineWidth: 3
|
||||
)
|
||||
.scaleEffect(pulseScale)
|
||||
.opacity(0.8)
|
||||
.onAppear {
|
||||
withAnimation(.easeInOut(duration: 1.5).repeatForever(autoreverses: true)) {
|
||||
pulseScale = 1.05
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SparkleData {
|
||||
let id: Int
|
||||
let x: CGFloat
|
||||
let y: CGFloat
|
||||
let size: CGFloat
|
||||
var opacity: Double
|
||||
}
|
||||
|
||||
struct CardView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let sampleCard = Card(
|
||||
id: 0,
|
||||
cp: 100,
|
||||
status: .unique,
|
||||
skill: "サンプルスキル",
|
||||
ownerDid: "did:plc:example",
|
||||
obtainedAt: Date(),
|
||||
isUnique: true,
|
||||
uniqueId: "unique-123"
|
||||
)
|
||||
|
||||
VStack {
|
||||
CardView(card: sampleCard)
|
||||
CardView(card: sampleCard, isRevealing: true)
|
||||
}
|
||||
.padding()
|
||||
.background(Color.black)
|
||||
}
|
||||
}
|
||||
@@ -1,341 +0,0 @@
|
||||
import SwiftUI
|
||||
|
||||
struct CollectionView: View {
|
||||
@EnvironmentObject var authManager: AuthManager
|
||||
@EnvironmentObject var cardManager: CardManager
|
||||
@State private var selectedCard: Card?
|
||||
@State private var searchText = ""
|
||||
@State private var selectedRarity: CardRarity?
|
||||
@State private var showingFilters = false
|
||||
|
||||
var filteredCards: [Card] {
|
||||
var cards = cardManager.userCards
|
||||
|
||||
// Search filter
|
||||
if !searchText.isEmpty {
|
||||
cards = cards.filter { card in
|
||||
let cardInfo = CardInfo.all[card.id]
|
||||
return cardInfo?.name.localizedCaseInsensitiveContains(searchText) ?? false
|
||||
}
|
||||
}
|
||||
|
||||
// Rarity filter
|
||||
if let selectedRarity = selectedRarity {
|
||||
cards = cards.filter { $0.status == selectedRarity }
|
||||
}
|
||||
|
||||
return cards.sorted { $0.obtainedAt > $1.obtainedAt }
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ZStack {
|
||||
// Background
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color(hex: "0a0a0a"),
|
||||
Color(hex: "1a1a1a")
|
||||
]),
|
||||
startPoint: .top,
|
||||
endPoint: .bottom
|
||||
)
|
||||
.ignoresSafeArea()
|
||||
|
||||
VStack(spacing: 0) {
|
||||
// Search and filter bar
|
||||
VStack(spacing: 12) {
|
||||
HStack {
|
||||
// Search field
|
||||
HStack {
|
||||
Image(systemName: "magnifyingglass")
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
TextField("カードを検索...", text: $searchText)
|
||||
.textFieldStyle(PlainTextFieldStyle())
|
||||
|
||||
if !searchText.isEmpty {
|
||||
Button(action: {
|
||||
searchText = ""
|
||||
}) {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(12)
|
||||
.background(Color.white.opacity(0.1))
|
||||
.cornerRadius(12)
|
||||
|
||||
// Filter button
|
||||
Button(action: {
|
||||
showingFilters.toggle()
|
||||
}) {
|
||||
Image(systemName: "line.3.horizontal.decrease.circle")
|
||||
.font(.title2)
|
||||
.foregroundColor(Color(hex: "fff700"))
|
||||
}
|
||||
}
|
||||
|
||||
// Filter chips
|
||||
if showingFilters {
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack(spacing: 8) {
|
||||
FilterChip(
|
||||
title: "すべて",
|
||||
isSelected: selectedRarity == nil
|
||||
) {
|
||||
selectedRarity = nil
|
||||
}
|
||||
|
||||
ForEach(CardRarity.allCases, id: \.self) { rarity in
|
||||
FilterChip(
|
||||
title: rarity.displayName,
|
||||
isSelected: selectedRarity == rarity
|
||||
) {
|
||||
selectedRarity = selectedRarity == rarity ? nil : rarity
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal)
|
||||
.padding(.top)
|
||||
|
||||
// Collection stats
|
||||
CollectionStatsView(cards: cardManager.userCards)
|
||||
.padding(.horizontal)
|
||||
.padding(.vertical, 8)
|
||||
|
||||
// Card grid
|
||||
if cardManager.isLoading {
|
||||
Spacer()
|
||||
ProgressView()
|
||||
.progressViewStyle(CircularProgressViewStyle(tint: Color(hex: "fff700")))
|
||||
Spacer()
|
||||
} else if filteredCards.isEmpty {
|
||||
Spacer()
|
||||
EmptyCollectionView(hasCards: !cardManager.userCards.isEmpty)
|
||||
Spacer()
|
||||
} else {
|
||||
ScrollView {
|
||||
LazyVGrid(
|
||||
columns: [
|
||||
GridItem(.flexible(), spacing: 16),
|
||||
GridItem(.flexible(), spacing: 16)
|
||||
],
|
||||
spacing: 20
|
||||
) {
|
||||
ForEach(filteredCards) { card in
|
||||
CardView(card: card)
|
||||
.scaleEffect(0.8)
|
||||
.onTapGesture {
|
||||
selectedCard = card
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal)
|
||||
.padding(.bottom, 100)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("コレクション")
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
.onAppear {
|
||||
if let userDid = authManager.currentUser?.did {
|
||||
cardManager.loadUserCards(userDid: userDid)
|
||||
}
|
||||
}
|
||||
.sheet(item: $selectedCard) { card in
|
||||
CardDetailView(card: card)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct FilterChip: View {
|
||||
let title: String
|
||||
let isSelected: Bool
|
||||
let action: () -> Void
|
||||
|
||||
var body: some View {
|
||||
Button(action: action) {
|
||||
Text(title)
|
||||
.font(.caption)
|
||||
.fontWeight(isSelected ? .bold : .medium)
|
||||
.foregroundColor(isSelected ? .black : .white)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 6)
|
||||
.background(
|
||||
isSelected
|
||||
? Color(hex: "fff700")
|
||||
: Color.white.opacity(0.1)
|
||||
)
|
||||
.cornerRadius(16)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct CollectionStatsView: View {
|
||||
let cards: [Card]
|
||||
|
||||
private var stats: (total: Int, unique: Int, completion: Double) {
|
||||
let total = cards.count
|
||||
let uniqueCards = Set(cards.map { $0.id }).count
|
||||
let completion = Double(uniqueCards) / 16.0 * 100
|
||||
|
||||
return (total, uniqueCards, completion)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 20) {
|
||||
StatItem(title: "総枚数", value: "\(stats.total)")
|
||||
StatItem(title: "種類", value: "\(stats.unique)/16")
|
||||
StatItem(title: "完成度", value: String(format: "%.1f%%", stats.completion))
|
||||
}
|
||||
.padding(.vertical, 12)
|
||||
.padding(.horizontal, 16)
|
||||
.background(Color.white.opacity(0.05))
|
||||
.cornerRadius(12)
|
||||
}
|
||||
}
|
||||
|
||||
struct StatItem: View {
|
||||
let title: String
|
||||
let value: String
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 4) {
|
||||
Text(value)
|
||||
.font(.headline)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(Color(hex: "fff700"))
|
||||
|
||||
Text(title)
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct EmptyCollectionView: View {
|
||||
let hasCards: Bool
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 16) {
|
||||
Image(systemName: hasCards ? "magnifyingglass" : "square.stack.3d.up")
|
||||
.font(.system(size: 48))
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Text(hasCards ? "検索結果がありません" : "カードがありません")
|
||||
.font(.title2)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.white)
|
||||
|
||||
Text(hasCards ? "検索条件を変更してください" : "ガチャでカードを引いてみましょう")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
struct CardDetailView: View {
|
||||
let card: Card
|
||||
@Environment(\.presentationMode) var presentationMode
|
||||
|
||||
private var cardInfo: CardInfo {
|
||||
CardInfo.all[card.id] ?? CardInfo(id: card.id, name: "Unknown", color: "666666", description: "")
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ZStack {
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color(hex: "0a0a0a"),
|
||||
Color(hex: "1a1a1a")
|
||||
]),
|
||||
startPoint: .top,
|
||||
endPoint: .bottom
|
||||
)
|
||||
.ignoresSafeArea()
|
||||
|
||||
ScrollView {
|
||||
VStack(spacing: 24) {
|
||||
// Card display
|
||||
CardView(card: card)
|
||||
.scaleEffect(1.2)
|
||||
.padding(.top, 20)
|
||||
|
||||
// Card details
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
DetailRow(title: "ID", value: "#\(card.id)")
|
||||
DetailRow(title: "名前", value: cardInfo.name)
|
||||
DetailRow(title: "CP", value: "\(card.cp)")
|
||||
DetailRow(title: "レアリティ", value: card.status.displayName)
|
||||
|
||||
if let skill = card.skill, !skill.isEmpty {
|
||||
DetailRow(title: "スキル", value: skill)
|
||||
}
|
||||
|
||||
if card.isUnique, let uniqueId = card.uniqueId {
|
||||
DetailRow(title: "ユニークID", value: uniqueId)
|
||||
}
|
||||
|
||||
DetailRow(
|
||||
title: "取得日時",
|
||||
value: DateFormatter.localizedString(
|
||||
from: card.obtainedAt,
|
||||
dateStyle: .medium,
|
||||
timeStyle: .short
|
||||
)
|
||||
)
|
||||
}
|
||||
.padding(.horizontal)
|
||||
}
|
||||
.padding(.bottom, 100)
|
||||
}
|
||||
}
|
||||
.navigationTitle(cardInfo.name)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.navigationBarItems(
|
||||
trailing: Button("閉じる") {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct DetailRow: View {
|
||||
let title: String
|
||||
let value: String
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
Text(title)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Spacer()
|
||||
|
||||
Text(value)
|
||||
.font(.subheadline)
|
||||
.fontWeight(.medium)
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
.padding(.vertical, 4)
|
||||
}
|
||||
}
|
||||
|
||||
struct CollectionView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
CollectionView()
|
||||
.environmentObject(AuthManager())
|
||||
.environmentObject(CardManager())
|
||||
}
|
||||
}
|
||||
@@ -1,310 +0,0 @@
|
||||
import SwiftUI
|
||||
|
||||
struct GachaAnimationView: View {
|
||||
let drawResult: CardDrawResult
|
||||
let onComplete: () -> Void
|
||||
|
||||
@State private var phase: AnimationPhase = .opening
|
||||
@State private var packScale: CGFloat = 0
|
||||
@State private var packOpacity: Double = 0
|
||||
@State private var cardScale: CGFloat = 0
|
||||
@State private var cardOpacity: Double = 0
|
||||
@State private var showCard = false
|
||||
@State private var effectOpacity: Double = 0
|
||||
|
||||
enum AnimationPhase {
|
||||
case opening
|
||||
case revealing
|
||||
case complete
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
// Dark overlay
|
||||
Rectangle()
|
||||
.fill(Color.black.opacity(0.9))
|
||||
.ignoresSafeArea()
|
||||
.onTapGesture {
|
||||
if phase == .complete {
|
||||
onComplete()
|
||||
}
|
||||
}
|
||||
|
||||
// Background effects based on card rarity
|
||||
if phase != .opening {
|
||||
backgroundEffect
|
||||
.opacity(effectOpacity)
|
||||
}
|
||||
|
||||
// Pack animation
|
||||
if phase == .opening {
|
||||
GachaPackView()
|
||||
.scaleEffect(packScale)
|
||||
.opacity(packOpacity)
|
||||
}
|
||||
|
||||
// Card reveal
|
||||
if showCard {
|
||||
CardView(card: drawResult.card, isRevealing: true)
|
||||
.scaleEffect(cardScale)
|
||||
.opacity(cardOpacity)
|
||||
}
|
||||
|
||||
// Complete state overlay
|
||||
if phase == .complete {
|
||||
VStack {
|
||||
Spacer()
|
||||
|
||||
VStack(spacing: 16) {
|
||||
if drawResult.isNew {
|
||||
Text("新しいカードを獲得!")
|
||||
.font(.title2)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(Color(hex: "fff700"))
|
||||
}
|
||||
|
||||
Text("タップして続ける")
|
||||
.font(.caption)
|
||||
.foregroundColor(.white.opacity(0.7))
|
||||
}
|
||||
.padding(.bottom, 50)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
startAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
private var backgroundEffect: some View {
|
||||
Group {
|
||||
switch drawResult.animationType {
|
||||
case "unique":
|
||||
UniqueBackgroundEffect()
|
||||
case "kira":
|
||||
KiraBackgroundEffect()
|
||||
case "rare":
|
||||
RareBackgroundEffect()
|
||||
default:
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func startAnimation() {
|
||||
// Phase 1: Pack appears
|
||||
withAnimation(.spring(response: 0.6, dampingFraction: 0.8)) {
|
||||
packScale = 1.0
|
||||
packOpacity = 1.0
|
||||
}
|
||||
|
||||
// Phase 2: Pack disappears, card appears
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
|
||||
withAnimation(.easeOut(duration: 0.3)) {
|
||||
packOpacity = 0
|
||||
}
|
||||
|
||||
phase = .revealing
|
||||
showCard = true
|
||||
|
||||
withAnimation(.spring(response: 0.8, dampingFraction: 0.6)) {
|
||||
cardScale = 1.0
|
||||
cardOpacity = 1.0
|
||||
effectOpacity = 1.0
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 3: Animation complete
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 3.5) {
|
||||
phase = .complete
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct GachaPackView: View {
|
||||
@State private var glowIntensity: Double = 0.5
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
// Pack background
|
||||
RoundedRectangle(cornerRadius: 20)
|
||||
.fill(
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color(hex: "667eea"),
|
||||
Color(hex: "764ba2")
|
||||
]),
|
||||
startPoint: .topLeading,
|
||||
endPoint: .bottomTrailing
|
||||
)
|
||||
)
|
||||
.frame(width: 150, height: 200)
|
||||
|
||||
// Pack glow
|
||||
RoundedRectangle(cornerRadius: 20)
|
||||
.stroke(Color.white, lineWidth: 2)
|
||||
.frame(width: 150, height: 200)
|
||||
.blur(radius: 10)
|
||||
.opacity(glowIntensity)
|
||||
|
||||
// Pack label
|
||||
VStack {
|
||||
Image(systemName: "sparkles")
|
||||
.font(.title)
|
||||
.foregroundColor(.white)
|
||||
|
||||
Text("ai.card")
|
||||
.font(.headline)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
withAnimation(.easeInOut(duration: 1).repeatForever(autoreverses: true)) {
|
||||
glowIntensity = 1.0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct UniqueBackgroundEffect: View {
|
||||
@State private var particles: [ParticleData] = []
|
||||
@State private var burstScale: CGFloat = 0
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
// Radial burst
|
||||
Circle()
|
||||
.fill(
|
||||
RadialGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color(hex: "ff00ff").opacity(0.8),
|
||||
Color.clear
|
||||
]),
|
||||
center: .center,
|
||||
startRadius: 0,
|
||||
endRadius: 200
|
||||
)
|
||||
)
|
||||
.scaleEffect(burstScale)
|
||||
.onAppear {
|
||||
withAnimation(.easeOut(duration: 1)) {
|
||||
burstScale = 3
|
||||
}
|
||||
}
|
||||
|
||||
// Floating particles
|
||||
ForEach(particles, id: \.id) { particle in
|
||||
Circle()
|
||||
.fill(Color(hex: particle.color))
|
||||
.frame(width: particle.size, height: particle.size)
|
||||
.position(x: particle.x, y: particle.y)
|
||||
.opacity(particle.opacity)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
generateParticles()
|
||||
}
|
||||
}
|
||||
|
||||
private func generateParticles() {
|
||||
for i in 0..<20 {
|
||||
let particle = ParticleData(
|
||||
id: i,
|
||||
x: CGFloat.random(in: 0...UIScreen.main.bounds.width),
|
||||
y: CGFloat.random(in: 0...UIScreen.main.bounds.height),
|
||||
size: CGFloat.random(in: 4...12),
|
||||
color: ["ff00ff", "00ffff", "ffffff"].randomElement() ?? "ffffff",
|
||||
opacity: Double.random(in: 0.3...0.8)
|
||||
)
|
||||
particles.append(particle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct KiraBackgroundEffect: View {
|
||||
@State private var sparkleOffset: CGFloat = -100
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
ForEach(0..<5, id: \.self) { i in
|
||||
Rectangle()
|
||||
.fill(
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color.clear,
|
||||
Color.yellow.opacity(0.3),
|
||||
Color.clear
|
||||
]),
|
||||
startPoint: .leading,
|
||||
endPoint: .trailing
|
||||
)
|
||||
)
|
||||
.frame(width: 2, height: UIScreen.main.bounds.height)
|
||||
.rotationEffect(.degrees(45))
|
||||
.offset(x: sparkleOffset + CGFloat(i * 50))
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
withAnimation(.linear(duration: 2).repeatForever(autoreverses: false)) {
|
||||
sparkleOffset = UIScreen.main.bounds.width + 100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct RareBackgroundEffect: View {
|
||||
@State private var rippleScale: CGFloat = 0
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
ForEach(0..<3, id: \.self) { i in
|
||||
Circle()
|
||||
.stroke(Color.blue.opacity(0.3), lineWidth: 2)
|
||||
.scaleEffect(rippleScale)
|
||||
.opacity(1 - rippleScale)
|
||||
.animation(
|
||||
.easeOut(duration: 2)
|
||||
.delay(Double(i) * 0.3)
|
||||
.repeatForever(autoreverses: false),
|
||||
value: rippleScale
|
||||
)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
rippleScale = 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ParticleData {
|
||||
let id: Int
|
||||
let x: CGFloat
|
||||
let y: CGFloat
|
||||
let size: CGFloat
|
||||
let color: String
|
||||
let opacity: Double
|
||||
}
|
||||
|
||||
struct GachaAnimationView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let sampleResult = CardDrawResult(
|
||||
card: Card(
|
||||
id: 0,
|
||||
cp: 500,
|
||||
status: .unique,
|
||||
skill: "サンプルスキル",
|
||||
ownerDid: "did:plc:example",
|
||||
obtainedAt: Date(),
|
||||
isUnique: true,
|
||||
uniqueId: "unique-123"
|
||||
),
|
||||
isNew: true,
|
||||
animationType: "unique"
|
||||
)
|
||||
|
||||
GachaAnimationView(drawResult: sampleResult) {
|
||||
print("Animation complete")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
import SwiftUI
|
||||
|
||||
struct GachaView: View {
|
||||
@EnvironmentObject var authManager: AuthManager
|
||||
@EnvironmentObject var cardManager: CardManager
|
||||
@State private var showingAnimation = false
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
// Background
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color(hex: "0a0a0a"),
|
||||
Color(hex: "1a1a1a")
|
||||
]),
|
||||
startPoint: .top,
|
||||
endPoint: .bottom
|
||||
)
|
||||
.ignoresSafeArea()
|
||||
|
||||
VStack(spacing: 40) {
|
||||
// Title
|
||||
VStack(spacing: 16) {
|
||||
Text("カードを引く")
|
||||
.font(.largeTitle)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(.white)
|
||||
|
||||
if let user = authManager.currentUser {
|
||||
Text("@\(user.handle)")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(Color(hex: "fff700"))
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
// Gacha buttons
|
||||
VStack(spacing: 20) {
|
||||
GachaButton(
|
||||
title: "通常ガチャ",
|
||||
subtitle: "無料でカードを1枚引く",
|
||||
colors: [Color(hex: "667eea"), Color(hex: "764ba2")],
|
||||
action: {
|
||||
drawCard(isPaid: false)
|
||||
},
|
||||
isLoading: cardManager.isDrawing
|
||||
)
|
||||
|
||||
GachaButton(
|
||||
title: "プレミアムガチャ",
|
||||
subtitle: "レア確率アップ!",
|
||||
colors: [Color(hex: "f093fb"), Color(hex: "f5576c")],
|
||||
action: {
|
||||
drawCard(isPaid: true)
|
||||
},
|
||||
isLoading: cardManager.isDrawing,
|
||||
isPremium: true
|
||||
)
|
||||
}
|
||||
.padding(.horizontal, 32)
|
||||
|
||||
if let errorMessage = cardManager.errorMessage {
|
||||
Text(errorMessage)
|
||||
.font(.caption)
|
||||
.foregroundColor(.red)
|
||||
.padding()
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
|
||||
// Gacha animation overlay
|
||||
if let currentDraw = cardManager.currentDraw {
|
||||
GachaAnimationView(
|
||||
drawResult: currentDraw,
|
||||
onComplete: {
|
||||
cardManager.completeCardDraw()
|
||||
}
|
||||
)
|
||||
.transition(.opacity)
|
||||
.zIndex(1000)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
if let userDid = authManager.currentUser?.did {
|
||||
cardManager.loadUserCards(userDid: userDid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func drawCard(isPaid: Bool) {
|
||||
guard let userDid = authManager.currentUser?.did else { return }
|
||||
cardManager.drawCard(userDid: userDid, isPaid: isPaid)
|
||||
}
|
||||
}
|
||||
|
||||
struct GachaButton: View {
|
||||
let title: String
|
||||
let subtitle: String
|
||||
let colors: [Color]
|
||||
let action: () -> Void
|
||||
let isLoading: Bool
|
||||
let isPremium: Bool
|
||||
|
||||
init(title: String, subtitle: String, colors: [Color], action: @escaping () -> Void, isLoading: Bool, isPremium: Bool = false) {
|
||||
self.title = title
|
||||
self.subtitle = subtitle
|
||||
self.colors = colors
|
||||
self.action = action
|
||||
self.isLoading = isLoading
|
||||
self.isPremium = isPremium
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Button(action: action) {
|
||||
VStack(spacing: 8) {
|
||||
Text(title)
|
||||
.font(.title2)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(.white)
|
||||
|
||||
Text(subtitle)
|
||||
.font(.caption)
|
||||
.foregroundColor(.white.opacity(0.8))
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 80)
|
||||
.background(
|
||||
ZStack {
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: colors),
|
||||
startPoint: .leading,
|
||||
endPoint: .trailing
|
||||
)
|
||||
|
||||
if isPremium {
|
||||
// Shimmer effect for premium
|
||||
ShimmerView()
|
||||
}
|
||||
}
|
||||
)
|
||||
.cornerRadius(16)
|
||||
.shadow(color: colors.first?.opacity(0.3) ?? .clear, radius: 10, x: 0, y: 5)
|
||||
.overlay(
|
||||
Group {
|
||||
if isLoading {
|
||||
ProgressView()
|
||||
.progressViewStyle(CircularProgressViewStyle(tint: .white))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
.disabled(isLoading)
|
||||
.scaleEffect(isLoading ? 0.95 : 1.0)
|
||||
.animation(.easeInOut(duration: 0.1), value: isLoading)
|
||||
}
|
||||
}
|
||||
|
||||
struct ShimmerView: View {
|
||||
@State private var phase: CGFloat = 0
|
||||
|
||||
var body: some View {
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
.clear,
|
||||
.white.opacity(0.2),
|
||||
.clear
|
||||
]),
|
||||
startPoint: .leading,
|
||||
endPoint: .trailing
|
||||
)
|
||||
.rotationEffect(.degrees(45))
|
||||
.offset(x: phase)
|
||||
.onAppear {
|
||||
withAnimation(.linear(duration: 2).repeatForever(autoreverses: false)) {
|
||||
phase = 300
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct GachaView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
GachaView()
|
||||
.environmentObject(AuthManager())
|
||||
.environmentObject(CardManager())
|
||||
}
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
import SwiftUI
|
||||
|
||||
struct LoginView: View {
|
||||
@EnvironmentObject var authManager: AuthManager
|
||||
@State private var identifier = ""
|
||||
@State private var password = ""
|
||||
@State private var showingPassword = false
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
// Background
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color(hex: "0a0a0a"),
|
||||
Color(hex: "1a1a1a")
|
||||
]),
|
||||
startPoint: .top,
|
||||
endPoint: .bottom
|
||||
)
|
||||
.ignoresSafeArea()
|
||||
|
||||
VStack(spacing: 40) {
|
||||
// Logo and title
|
||||
VStack(spacing: 20) {
|
||||
Text("ai.card")
|
||||
.font(.system(size: 48, weight: .bold, design: .rounded))
|
||||
.foregroundStyle(
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color(hex: "fff700"),
|
||||
Color(hex: "ff00ff")
|
||||
]),
|
||||
startPoint: .leading,
|
||||
endPoint: .trailing
|
||||
)
|
||||
)
|
||||
|
||||
Text("atprotoベースカードゲーム")
|
||||
.font(.title3)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
||||
// Login form
|
||||
VStack(spacing: 24) {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text("ハンドル または DID")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
TextField("your.bsky.social", text: $identifier)
|
||||
.textFieldStyle(CustomTextFieldStyle())
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text("アプリパスワード")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
HStack {
|
||||
if showingPassword {
|
||||
TextField("アプリパスワード", text: $password)
|
||||
} else {
|
||||
SecureField("アプリパスワード", text: $password)
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
showingPassword.toggle()
|
||||
}) {
|
||||
Image(systemName: showingPassword ? "eye.slash" : "eye")
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
.textFieldStyle(CustomTextFieldStyle())
|
||||
|
||||
Text("メインパスワードではなく、アプリパスワードを使用してください")
|
||||
.font(.caption2)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
||||
if let errorMessage = authManager.errorMessage {
|
||||
Text(errorMessage)
|
||||
.font(.caption)
|
||||
.foregroundColor(.red)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
authManager.login(identifier: identifier, password: password)
|
||||
}) {
|
||||
HStack {
|
||||
if authManager.isLoading {
|
||||
ProgressView()
|
||||
.progressViewStyle(CircularProgressViewStyle(tint: .black))
|
||||
.scaleEffect(0.8)
|
||||
}
|
||||
|
||||
Text(authManager.isLoading ? "ログイン中..." : "ログイン")
|
||||
.font(.headline)
|
||||
.foregroundColor(.black)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 50)
|
||||
.background(
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color(hex: "fff700"),
|
||||
Color(hex: "ffd700")
|
||||
]),
|
||||
startPoint: .leading,
|
||||
endPoint: .trailing
|
||||
)
|
||||
)
|
||||
.cornerRadius(12)
|
||||
}
|
||||
.disabled(authManager.isLoading || identifier.isEmpty || password.isEmpty)
|
||||
.opacity(authManager.isLoading || identifier.isEmpty || password.isEmpty ? 0.6 : 1.0)
|
||||
}
|
||||
.padding(.horizontal, 32)
|
||||
|
||||
Spacer()
|
||||
|
||||
VStack(spacing: 12) {
|
||||
Text("ai.cardはatprotoアカウントを使用します")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Text("データはあなたのPDSに保存されます")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct CustomTextFieldStyle: TextFieldStyle {
|
||||
func _body(configuration: TextField<Self._Label>) -> some View {
|
||||
configuration
|
||||
.padding()
|
||||
.background(Color.white.opacity(0.1))
|
||||
.cornerRadius(12)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 12)
|
||||
.stroke(Color.white.opacity(0.2), lineWidth: 1)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
struct LoginView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
LoginView()
|
||||
.environmentObject(AuthManager())
|
||||
}
|
||||
}
|
||||
@@ -1,265 +0,0 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ProfileView: View {
|
||||
@EnvironmentObject var authManager: AuthManager
|
||||
@EnvironmentObject var cardManager: CardManager
|
||||
@State private var showingLogoutAlert = false
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ZStack {
|
||||
// Background
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color(hex: "0a0a0a"),
|
||||
Color(hex: "1a1a1a")
|
||||
]),
|
||||
startPoint: .top,
|
||||
endPoint: .bottom
|
||||
)
|
||||
.ignoresSafeArea()
|
||||
|
||||
ScrollView {
|
||||
VStack(spacing: 24) {
|
||||
// Profile header
|
||||
if let user = authManager.currentUser {
|
||||
ProfileHeaderView(user: user)
|
||||
}
|
||||
|
||||
// Collection summary
|
||||
CollectionSummaryView(cards: cardManager.userCards)
|
||||
|
||||
// Menu items
|
||||
VStack(spacing: 1) {
|
||||
MenuRow(
|
||||
icon: "arrow.triangle.2.circlepath",
|
||||
title: "データ同期",
|
||||
subtitle: "atproto PDSと同期"
|
||||
) {
|
||||
// TODO: Implement sync
|
||||
}
|
||||
|
||||
MenuRow(
|
||||
icon: "crown",
|
||||
title: "ユニークカード",
|
||||
subtitle: "所有しているユニークカード"
|
||||
) {
|
||||
// TODO: Show unique cards
|
||||
}
|
||||
|
||||
MenuRow(
|
||||
icon: "info.circle",
|
||||
title: "アプリについて",
|
||||
subtitle: "バージョン情報"
|
||||
) {
|
||||
// TODO: Show about
|
||||
}
|
||||
}
|
||||
.background(Color.white.opacity(0.05))
|
||||
.cornerRadius(12)
|
||||
|
||||
Spacer(minLength: 40)
|
||||
|
||||
// Logout button
|
||||
Button(action: {
|
||||
showingLogoutAlert = true
|
||||
}) {
|
||||
HStack {
|
||||
Image(systemName: "rectangle.portrait.and.arrow.right")
|
||||
Text("ログアウト")
|
||||
}
|
||||
.font(.headline)
|
||||
.foregroundColor(.red)
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(height: 50)
|
||||
.background(Color.red.opacity(0.1))
|
||||
.cornerRadius(12)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 12)
|
||||
.stroke(Color.red.opacity(0.3), lineWidth: 1)
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(minLength: 100)
|
||||
}
|
||||
.padding(.horizontal)
|
||||
}
|
||||
}
|
||||
.navigationTitle("プロフィール")
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
.alert("ログアウト", isPresented: $showingLogoutAlert) {
|
||||
Button("キャンセル", role: .cancel) { }
|
||||
Button("ログアウト", role: .destructive) {
|
||||
authManager.logout()
|
||||
}
|
||||
} message: {
|
||||
Text("ログアウトしますか?")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ProfileHeaderView: View {
|
||||
let user: User
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 16) {
|
||||
// Avatar
|
||||
Circle()
|
||||
.fill(
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color(hex: "fff700"),
|
||||
Color(hex: "ff00ff")
|
||||
]),
|
||||
startPoint: .topLeading,
|
||||
endPoint: .bottomTrailing
|
||||
)
|
||||
)
|
||||
.frame(width: 80, height: 80)
|
||||
.overlay(
|
||||
Text(user.handle.prefix(1).uppercased())
|
||||
.font(.title)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(.black)
|
||||
)
|
||||
|
||||
// User info
|
||||
VStack(spacing: 4) {
|
||||
Text("@\(user.handle)")
|
||||
.font(.title2)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(.white)
|
||||
|
||||
Text(user.did)
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.middle)
|
||||
}
|
||||
}
|
||||
.padding(.vertical, 20)
|
||||
}
|
||||
}
|
||||
|
||||
struct CollectionSummaryView: View {
|
||||
let cards: [Card]
|
||||
|
||||
private var summary: (total: Int, unique: Int, rarest: CardRarity?) {
|
||||
let total = cards.count
|
||||
let uniqueCount = cards.filter { $0.isUnique }.count
|
||||
let rarest = cards.map { $0.status }.max { lhs, rhs in
|
||||
rarityOrder(lhs) < rarityOrder(rhs)
|
||||
}
|
||||
|
||||
return (total, uniqueCount, rarest)
|
||||
}
|
||||
|
||||
private func rarityOrder(_ rarity: CardRarity) -> Int {
|
||||
switch rarity {
|
||||
case .normal: return 0
|
||||
case .rare: return 1
|
||||
case .superRare: return 2
|
||||
case .kira: return 3
|
||||
case .unique: return 4
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 16) {
|
||||
Text("コレクション統計")
|
||||
.font(.headline)
|
||||
.foregroundColor(.white)
|
||||
|
||||
HStack(spacing: 20) {
|
||||
SummaryItem(
|
||||
title: "総カード数",
|
||||
value: "\(summary.total)",
|
||||
color: Color(hex: "fff700")
|
||||
)
|
||||
|
||||
SummaryItem(
|
||||
title: "ユニーク",
|
||||
value: "\(summary.unique)",
|
||||
color: Color(hex: "ff00ff")
|
||||
)
|
||||
|
||||
if let rarest = summary.rarest {
|
||||
SummaryItem(
|
||||
title: "最高レア",
|
||||
value: rarest.displayName,
|
||||
color: Color(hex: rarest.gradientColors.first ?? "ffffff")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.background(Color.white.opacity(0.05))
|
||||
.cornerRadius(12)
|
||||
}
|
||||
}
|
||||
|
||||
struct SummaryItem: View {
|
||||
let title: String
|
||||
let value: String
|
||||
let color: Color
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 8) {
|
||||
Text(value)
|
||||
.font(.title2)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(color)
|
||||
|
||||
Text(title)
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
|
||||
struct MenuRow: View {
|
||||
let icon: String
|
||||
let title: String
|
||||
let subtitle: String
|
||||
let action: () -> Void
|
||||
|
||||
var body: some View {
|
||||
Button(action: action) {
|
||||
HStack(spacing: 12) {
|
||||
Image(systemName: icon)
|
||||
.font(.title2)
|
||||
.foregroundColor(Color(hex: "fff700"))
|
||||
.frame(width: 24)
|
||||
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(title)
|
||||
.font(.headline)
|
||||
.foregroundColor(.white)
|
||||
|
||||
Text(subtitle)
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(systemName: "chevron.right")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
}
|
||||
}
|
||||
|
||||
struct ProfileView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ProfileView()
|
||||
.environmentObject(AuthManager())
|
||||
.environmentObject(CardManager())
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
// swift-tools-version: 5.7
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "AiCard",
|
||||
platforms: [
|
||||
.iOS(.v16)
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
name: "AiCard",
|
||||
targets: ["AiCard"]
|
||||
),
|
||||
],
|
||||
dependencies: [
|
||||
// SwiftUI is included by default
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "AiCard",
|
||||
dependencies: []
|
||||
),
|
||||
.testTarget(
|
||||
name: "AiCardTests",
|
||||
dependencies: ["AiCard"]
|
||||
),
|
||||
]
|
||||
)
|
||||
121
ios/README.md
@@ -1,121 +0,0 @@
|
||||
# ai.card iOS App
|
||||
|
||||
atprotoベースのカードゲーム「ai.card」のiOSアプリです。
|
||||
|
||||
## 特徴
|
||||
|
||||
- **atproto統合**: 分散型認証とデータ主権
|
||||
- **リッチなアニメーション**: ガチャの迫力ある演出
|
||||
- **カードコレクション**: 美しいカード表示とフィルタリング
|
||||
- **ユニークカードシステム**: 世界で一人だけが所有できるカード
|
||||
|
||||
## アーキテクチャ
|
||||
|
||||
### MVVM + Combine
|
||||
|
||||
```
|
||||
Views/
|
||||
├── LoginView # atprotoログイン
|
||||
├── GachaView # ガチャ画面
|
||||
├── CollectionView # コレクション画面
|
||||
├── ProfileView # プロフィール画面
|
||||
├── CardView # カード表示コンポーネント
|
||||
└── GachaAnimationView # ガチャアニメーション
|
||||
|
||||
Services/
|
||||
├── APIClient # REST API通信
|
||||
├── AuthManager # 認証管理
|
||||
└── CardManager # カード管理
|
||||
|
||||
Models/
|
||||
├── Card # カードデータモデル
|
||||
└── User # ユーザーデータモデル
|
||||
```
|
||||
|
||||
### 技術スタック
|
||||
|
||||
- **UI**: SwiftUI
|
||||
- **データフロー**: Combine
|
||||
- **ネットワーク**: URLSession
|
||||
- **認証**: atproto (JWT)
|
||||
- **最小対応OS**: iOS 16.0
|
||||
|
||||
## セットアップ
|
||||
|
||||
### 1. Xcodeプロジェクトを開く
|
||||
|
||||
```bash
|
||||
cd ios/AiCard
|
||||
open AiCard.xcodeproj
|
||||
```
|
||||
|
||||
### 2. API設定
|
||||
|
||||
開発環境では自動的に `localhost:8000` に接続します。
|
||||
本番環境では `api.card.syui.ai` に接続します。
|
||||
|
||||
### 3. ビルド & 実行
|
||||
|
||||
- シミュレーターまたは実機でビルド
|
||||
- atprotoアカウントでログイン
|
||||
- ガチャを引いてカードを集める
|
||||
|
||||
## 主要機能
|
||||
|
||||
### 認証
|
||||
|
||||
- atproto DIDベース認証
|
||||
- アプリパスワード使用
|
||||
- 自動セッション管理
|
||||
|
||||
### ガチャシステム
|
||||
|
||||
- 通常ガチャ(無料)
|
||||
- プレミアムガチャ(確率アップ)
|
||||
- レアリティ別アニメーション
|
||||
- ユニークカード対応
|
||||
|
||||
### カードコレクション
|
||||
|
||||
- グリッド表示
|
||||
- 検索機能
|
||||
- レアリティフィルタ
|
||||
- 詳細表示
|
||||
|
||||
### プロフィール
|
||||
|
||||
- ユーザー情報表示
|
||||
- コレクション統計
|
||||
- データ同期機能
|
||||
|
||||
## カードシステム
|
||||
|
||||
### レアリティ
|
||||
|
||||
- **ノーマル**: 基本カード
|
||||
- **レア**: 少し珍しいカード
|
||||
- **スーパーレア**: とても珍しいカード
|
||||
- **キラ**: 光る演出付きカード(0.1%)
|
||||
- **ユニーク**: 世界で一人だけ(0.0001%)
|
||||
|
||||
### 視覚効果
|
||||
|
||||
- レアリティ別グラデーション
|
||||
- キラカードのスパークル効果
|
||||
- ユニークカードのオーラ効果
|
||||
- 3Dフリップアニメーション
|
||||
|
||||
## 今後の実装予定
|
||||
|
||||
- [ ] Push通知
|
||||
- [ ] カード交換機能
|
||||
- [ ] AI.verse連携
|
||||
- [ ] ダークモード対応
|
||||
- [ ] iPad最適化
|
||||
- [ ] ウィジェット対応
|
||||
|
||||
## 注意事項
|
||||
|
||||
- iOS 16.0以上が必要
|
||||
- atprotoアカウントが必要
|
||||
- インターネット接続が必要
|
||||
@@ -1,134 +0,0 @@
|
||||
-- PostgreSQL migration for ai.card database schema
|
||||
|
||||
-- Create custom types
|
||||
CREATE TYPE card_rarity AS ENUM ('normal', 'rare', 'super_rare', 'kira', 'unique');
|
||||
|
||||
-- Enable UUID extension
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
|
||||
-- Users table - stores atproto DID-based user information
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
did TEXT NOT NULL UNIQUE, -- atproto Decentralized Identifier
|
||||
handle TEXT NOT NULL, -- atproto handle (e.g., alice.bsky.social)
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_users_did ON users(did);
|
||||
CREATE INDEX IF NOT EXISTS idx_users_handle ON users(handle);
|
||||
|
||||
-- Card master data - template definitions for all card types
|
||||
CREATE TABLE IF NOT EXISTS card_master (
|
||||
id INTEGER PRIMARY KEY, -- Card ID (0-15 in current system)
|
||||
name TEXT NOT NULL, -- Card name (e.g., "ai", "dream", "radiance")
|
||||
base_cp_min INTEGER NOT NULL, -- Minimum base CP for this card
|
||||
base_cp_max INTEGER NOT NULL, -- Maximum base CP for this card
|
||||
color TEXT NOT NULL, -- Card color theme
|
||||
description TEXT NOT NULL -- Card description/lore
|
||||
);
|
||||
|
||||
-- User cards - actual card instances owned by users
|
||||
CREATE TABLE IF NOT EXISTS user_cards (
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id INTEGER NOT NULL,
|
||||
card_id INTEGER NOT NULL, -- References card_master.id
|
||||
cp INTEGER NOT NULL, -- Calculated CP (base_cp * rarity_multiplier)
|
||||
status card_rarity NOT NULL, -- Card rarity
|
||||
skill TEXT, -- Optional skill description
|
||||
obtained_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
|
||||
is_unique BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
unique_id UUID, -- UUID for unique cards
|
||||
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (card_id) REFERENCES card_master(id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_user_cards_user_id ON user_cards(user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_user_cards_card_id ON user_cards(card_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_user_cards_status ON user_cards(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_user_cards_unique_id ON user_cards(unique_id);
|
||||
|
||||
-- Global unique card registry - tracks ownership of unique cards
|
||||
CREATE TABLE IF NOT EXISTS unique_card_registry (
|
||||
id SERIAL PRIMARY KEY,
|
||||
unique_id UUID NOT NULL UNIQUE, -- UUID from user_cards.unique_id
|
||||
card_id INTEGER NOT NULL, -- Which card type is unique
|
||||
owner_did TEXT NOT NULL, -- Current owner's atproto DID
|
||||
obtained_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
verse_skill_id TEXT, -- Optional verse skill reference
|
||||
|
||||
FOREIGN KEY (card_id) REFERENCES card_master(id),
|
||||
UNIQUE(card_id) -- Only one unique per card_id allowed
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_unique_registry_card_id ON unique_card_registry(card_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_unique_registry_owner_did ON unique_card_registry(owner_did);
|
||||
|
||||
-- Draw history - tracks all gacha draws for statistics
|
||||
CREATE TABLE IF NOT EXISTS draw_history (
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id INTEGER NOT NULL,
|
||||
card_id INTEGER NOT NULL,
|
||||
status card_rarity NOT NULL,
|
||||
cp INTEGER NOT NULL,
|
||||
is_paid BOOLEAN NOT NULL DEFAULT FALSE, -- Paid vs free gacha
|
||||
drawn_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
|
||||
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (card_id) REFERENCES card_master(id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_draw_history_user_id ON draw_history(user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_draw_history_drawn_at ON draw_history(drawn_at);
|
||||
CREATE INDEX IF NOT EXISTS idx_draw_history_status ON draw_history(status);
|
||||
|
||||
-- Gacha pools - special event pools with rate-ups
|
||||
CREATE TABLE IF NOT EXISTS gacha_pools (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
start_at TIMESTAMP WITH TIME ZONE,
|
||||
end_at TIMESTAMP WITH TIME ZONE,
|
||||
pickup_card_ids INTEGER[], -- Array of card IDs
|
||||
rate_up_multiplier DECIMAL(4,2) NOT NULL DEFAULT 1.0
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_gacha_pools_active ON gacha_pools(is_active);
|
||||
CREATE INDEX IF NOT EXISTS idx_gacha_pools_dates ON gacha_pools(start_at, end_at);
|
||||
|
||||
-- Insert default card master data (0-15 cards from ai.json)
|
||||
INSERT INTO card_master (id, name, base_cp_min, base_cp_max, color, description) VALUES
|
||||
(0, 'ai', 100, 200, '#4A90E2', 'The core essence of existence'),
|
||||
(1, 'dream', 90, 180, '#9B59B6', 'Visions of possibility'),
|
||||
(2, 'radiance', 110, 220, '#F39C12', 'Brilliant light energy'),
|
||||
(3, 'neutron', 120, 240, '#34495E', 'Dense stellar core'),
|
||||
(4, 'sun', 130, 260, '#E74C3C', 'Solar radiance'),
|
||||
(5, 'night', 80, 160, '#2C3E50', 'Darkness and mystery'),
|
||||
(6, 'snow', 70, 140, '#ECF0F1', 'Pure frozen crystalline'),
|
||||
(7, 'thunder', 140, 280, '#F1C40F', 'Electric storm energy'),
|
||||
(8, 'ultimate', 150, 300, '#8E44AD', 'The highest form'),
|
||||
(9, 'sword', 160, 320, '#95A5A6', 'Blade of cutting truth'),
|
||||
(10, 'destruction', 170, 340, '#C0392B', 'Force of entropy'),
|
||||
(11, 'earth', 90, 180, '#27AE60', 'Grounding foundation'),
|
||||
(12, 'galaxy', 180, 360, '#3498DB', 'Cosmic expanse'),
|
||||
(13, 'create', 100, 200, '#16A085', 'Power of generation'),
|
||||
(14, 'supernova', 200, 400, '#E67E22', 'Stellar explosion'),
|
||||
(15, 'world', 250, 500, '#9B59B6', 'Reality itself')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- Create function for updating updated_at timestamp
|
||||
CREATE OR REPLACE FUNCTION update_updated_at_column()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
NEW.updated_at = NOW();
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ language 'plpgsql';
|
||||
|
||||
-- Create trigger for updating users.updated_at
|
||||
CREATE TRIGGER trigger_users_updated_at
|
||||
BEFORE UPDATE ON users
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION update_updated_at_column();
|
||||
@@ -1,130 +0,0 @@
|
||||
-- SQLite migration for ai.card database schema
|
||||
|
||||
-- Create custom types (SQLite uses CHECK constraints instead of ENUMs)
|
||||
-- Card rarity levels
|
||||
CREATE TABLE IF NOT EXISTS card_rarity_enum (
|
||||
value TEXT PRIMARY KEY CHECK (value IN ('normal', 'rare', 'super_rare', 'kira', 'unique'))
|
||||
);
|
||||
|
||||
INSERT OR IGNORE INTO card_rarity_enum (value) VALUES
|
||||
('normal'), ('rare'), ('super_rare'), ('kira'), ('unique');
|
||||
|
||||
-- Users table - stores atproto DID-based user information
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
did TEXT NOT NULL UNIQUE, -- atproto Decentralized Identifier
|
||||
handle TEXT NOT NULL, -- atproto handle (e.g., alice.bsky.social)
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_users_did ON users(did);
|
||||
CREATE INDEX IF NOT EXISTS idx_users_handle ON users(handle);
|
||||
|
||||
-- Card master data - template definitions for all card types
|
||||
CREATE TABLE IF NOT EXISTS card_master (
|
||||
id INTEGER PRIMARY KEY, -- Card ID (0-15 in current system)
|
||||
name TEXT NOT NULL, -- Card name (e.g., "ai", "dream", "radiance")
|
||||
base_cp_min INTEGER NOT NULL, -- Minimum base CP for this card
|
||||
base_cp_max INTEGER NOT NULL, -- Maximum base CP for this card
|
||||
color TEXT NOT NULL, -- Card color theme
|
||||
description TEXT NOT NULL -- Card description/lore
|
||||
);
|
||||
|
||||
-- User cards - actual card instances owned by users
|
||||
CREATE TABLE IF NOT EXISTS user_cards (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
card_id INTEGER NOT NULL, -- References card_master.id
|
||||
cp INTEGER NOT NULL, -- Calculated CP (base_cp * rarity_multiplier)
|
||||
status TEXT NOT NULL -- Card rarity
|
||||
CHECK (status IN ('normal', 'rare', 'super_rare', 'kira', 'unique')),
|
||||
skill TEXT, -- Optional skill description
|
||||
obtained_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
is_unique BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
unique_id TEXT, -- UUID for unique cards
|
||||
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (card_id) REFERENCES card_master(id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_user_cards_user_id ON user_cards(user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_user_cards_card_id ON user_cards(card_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_user_cards_status ON user_cards(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_user_cards_unique_id ON user_cards(unique_id);
|
||||
|
||||
-- Global unique card registry - tracks ownership of unique cards
|
||||
CREATE TABLE IF NOT EXISTS unique_card_registry (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
unique_id TEXT NOT NULL UNIQUE, -- UUID from user_cards.unique_id
|
||||
card_id INTEGER NOT NULL, -- Which card type is unique
|
||||
owner_did TEXT NOT NULL, -- Current owner's atproto DID
|
||||
obtained_at DATETIME NOT NULL,
|
||||
verse_skill_id TEXT, -- Optional verse skill reference
|
||||
|
||||
FOREIGN KEY (card_id) REFERENCES card_master(id),
|
||||
UNIQUE(card_id) -- Only one unique per card_id allowed
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_unique_registry_card_id ON unique_card_registry(card_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_unique_registry_owner_did ON unique_card_registry(owner_did);
|
||||
|
||||
-- Draw history - tracks all gacha draws for statistics
|
||||
CREATE TABLE IF NOT EXISTS draw_history (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
card_id INTEGER NOT NULL,
|
||||
status TEXT NOT NULL
|
||||
CHECK (status IN ('normal', 'rare', 'super_rare', 'kira', 'unique')),
|
||||
cp INTEGER NOT NULL,
|
||||
is_paid BOOLEAN NOT NULL DEFAULT FALSE, -- Paid vs free gacha
|
||||
drawn_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (card_id) REFERENCES card_master(id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_draw_history_user_id ON draw_history(user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_draw_history_drawn_at ON draw_history(drawn_at);
|
||||
CREATE INDEX IF NOT EXISTS idx_draw_history_status ON draw_history(status);
|
||||
|
||||
-- Gacha pools - special event pools with rate-ups
|
||||
CREATE TABLE IF NOT EXISTS gacha_pools (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
start_at DATETIME,
|
||||
end_at DATETIME,
|
||||
pickup_card_ids TEXT, -- JSON array of card IDs
|
||||
rate_up_multiplier REAL NOT NULL DEFAULT 1.0
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_gacha_pools_active ON gacha_pools(is_active);
|
||||
CREATE INDEX IF NOT EXISTS idx_gacha_pools_dates ON gacha_pools(start_at, end_at);
|
||||
|
||||
-- Insert default card master data (0-15 cards from ai.json)
|
||||
INSERT OR IGNORE INTO card_master (id, name, base_cp_min, base_cp_max, color, description) VALUES
|
||||
(0, 'ai', 100, 200, '#4A90E2', 'The core essence of existence'),
|
||||
(1, 'dream', 90, 180, '#9B59B6', 'Visions of possibility'),
|
||||
(2, 'radiance', 110, 220, '#F39C12', 'Brilliant light energy'),
|
||||
(3, 'neutron', 120, 240, '#34495E', 'Dense stellar core'),
|
||||
(4, 'sun', 130, 260, '#E74C3C', 'Solar radiance'),
|
||||
(5, 'night', 80, 160, '#2C3E50', 'Darkness and mystery'),
|
||||
(6, 'snow', 70, 140, '#ECF0F1', 'Pure frozen crystalline'),
|
||||
(7, 'thunder', 140, 280, '#F1C40F', 'Electric storm energy'),
|
||||
(8, 'ultimate', 150, 300, '#8E44AD', 'The highest form'),
|
||||
(9, 'sword', 160, 320, '#95A5A6', 'Blade of cutting truth'),
|
||||
(10, 'destruction', 170, 340, '#C0392B', 'Force of entropy'),
|
||||
(11, 'earth', 90, 180, '#27AE60', 'Grounding foundation'),
|
||||
(12, 'galaxy', 180, 360, '#3498DB', 'Cosmic expanse'),
|
||||
(13, 'create', 100, 200, '#16A085', 'Power of generation'),
|
||||
(14, 'supernova', 200, 400, '#E67E22', 'Stellar explosion'),
|
||||
(15, 'world', 250, 500, '#9B59B6', 'Reality itself');
|
||||
|
||||
-- Create trigger for updating users.updated_at
|
||||
CREATE TRIGGER IF NOT EXISTS trigger_users_updated_at
|
||||
AFTER UPDATE ON users
|
||||
BEGIN
|
||||
UPDATE users SET updated_at = CURRENT_TIMESTAMP WHERE id = NEW.id;
|
||||
END;
|
||||
38
package.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "card",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"preview": "vite preview",
|
||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@google/model-viewer": "^3.4.0",
|
||||
"@tanstack/react-query": "^5.17.19",
|
||||
"axios": "^1.6.8",
|
||||
"moment": "^2.29.4",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-router-dom": "^6.20.1",
|
||||
"three": "^0.163.0",
|
||||
"zustand": "^4.4.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.2.43",
|
||||
"@types/react-dom": "^18.2.17",
|
||||
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
||||
"@typescript-eslint/parser": "^6.14.0",
|
||||
"@vitejs/plugin-react": "^4.2.1",
|
||||
"autoprefixer": "^10.4.16",
|
||||
"eslint": "^8.55.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.5",
|
||||
"postcss": "^8.4.32",
|
||||
"tailwindcss": "^3.3.6",
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.0.8"
|
||||
}
|
||||
}
|
||||
6
postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
||||
12
public/404.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>card.syui.ai</title><link href="app.css" rel="preload" as="style"><link href="app.js" rel="preload" as="script"><link href="chunk-vendors.js" rel="preload" as="script"><link href="app.css" rel="stylesheet">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta property="og:url" content="https://card.syui.aiL">
|
||||
<meta property="og:title" content="card.syui.ai">
|
||||
<meta property="og:description" content="@yui.bsky.social /card">
|
||||
<meta property="og:image" content="https://card.syui.ai/card/card_0.png">
|
||||
</head>
|
||||
<body><div id="app"></div><script src="chunk-vendors.js"></script><script src="app.js"></script></body>
|
||||
</html>
|
||||
1
public/CNAME
Normal file
@@ -0,0 +1 @@
|
||||
card.syui.ai
|
||||
0
public/README.md
Normal file
BIN
public/ai.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
1882
public/ai.svg
Normal file
|
After Width: | Height: | Size: 50 KiB |
BIN
public/apple-touch-icon.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
public/avatar.png
Normal file
|
After Width: | Height: | Size: 193 KiB |
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"author": "syui",
|
||||
"root": "./",
|
||||
"plugins": ["-sharing", "codeblock-filename","mermaid-gb3","diff"],
|
||||
"title": "hello world! bluesky",
|
||||
"description": "This is a bluesky ai-card example, and first rust"
|
||||
}
|
||||
@@ -0,0 +1,561 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>quick start · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="2.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="./" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter active" data-level="1.2.1" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="../c2/">
|
||||
|
||||
<a href="../c2/">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="../c2/1.html">
|
||||
|
||||
<a href="../c2/1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="../c2/2.html">
|
||||
|
||||
<a href="../c2/2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="../c2/3.html">
|
||||
|
||||
<a href="../c2/3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="../c2/4.html">
|
||||
|
||||
<a href="../c2/4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../c3/">
|
||||
|
||||
<a href="../c3/">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="../c3/1.html">
|
||||
|
||||
<a href="../c3/1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="../c3/2.html">
|
||||
|
||||
<a href="../c3/2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="../c3/3.html">
|
||||
|
||||
<a href="../c3/3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="../c4/">
|
||||
|
||||
<a href="../c4/">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="../c4/0.html">
|
||||
|
||||
<a href="../c4/0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="../c4/1.html">
|
||||
|
||||
<a href="../c4/1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="../c4/2.html">
|
||||
|
||||
<a href="../c4/2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="../c4/3.html">
|
||||
|
||||
<a href="../c4/3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >quick start</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="quick-start">quick start</h3>
|
||||
<pre><code class="lang-sh">handle=yui.syui.ai
|
||||
curl <span class="hljs-_">-s</span>L <span class="hljs-string">"https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=<span class="hljs-variable">${handle}</span>&collection=app.bsky.feed.post&limit=1"</span>
|
||||
</code></pre>
|
||||
<p>Send the following mention to <a href="https://bsky.app/profile/did:plc:4hqjfn7m6n5hno3doamuhgef" target="_blank">@yui.syui.ai</a>.</p>
|
||||
<pre><code class="lang-sh"><span class="hljs-comment"># card account create</span>
|
||||
@yui.syui.ai /card
|
||||
|
||||
<span class="hljs-comment"># get egg card</span>
|
||||
@yui.syui.ai /card egg
|
||||
</code></pre>
|
||||
<p>You will then receive an egg card. Anyone can perform this hidden command. If you already have one, it will be displayed.</p>
|
||||
<p>This card can be grown by converting your did to <code>base64</code> and sending it to <code>@yui.syui.ai</code>.</p>
|
||||
<pre><code class="lang-sh">$ <span class="hljs-built_in">echo</span> did:plc:4hqjfn7m6n5hno3doamuhgef|base64
|
||||
ZGlkOnBsYzo0aHFqZm43bTZuNWhubzNkb2FtdWhnZWYK
|
||||
</code></pre>
|
||||
<pre><code class="lang-sh">@yui.syui.ai /egg ZGlkOnBsYzo0aHFqZm43bTZuNWhubzNkb2FtdWhnZWYK
|
||||
</code></pre>
|
||||
<p>Note that this will consume one day's battle points.</p>
|
||||
<p>If you send this by command, it will look like this</p>
|
||||
<div><p class="code-filename">env</p></div>
|
||||
<pre><code class="lang-sh">data=`curl <span class="hljs-_">-s</span>L -X POST -H <span class="hljs-string">"Content-Type: application/json"</span> <span class="hljs-_">-d</span> <span class="hljs-string">"{\"identifier\":\"<span class="hljs-variable">$handle</span>\",\"password\":\"<span class="hljs-variable">$pass</span>\"}"</span> https://bsky.social/xrpc/com.atproto.server.createSession`
|
||||
token=`<span class="hljs-built_in">echo</span> <span class="hljs-variable">$data</span>|jq -r .accessJwt`
|
||||
did=`<span class="hljs-built_in">echo</span> <span class="hljs-variable">$data</span>|jq -r .did`
|
||||
base=`<span class="hljs-built_in">echo</span> <span class="hljs-variable">$did</span>|base64`
|
||||
|
||||
handle_m=yui.syui.ai
|
||||
did_m=`curl <span class="hljs-_">-s</span>L -X GET -H <span class="hljs-string">"Content-Type: application/json"</span> -H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> <span class="hljs-string">"https://bsky.social/xrpc/app.bsky.actor.getProfile?actor=<span class="hljs-variable">${handle_m}</span>"</span>|jq -r .did`
|
||||
at=@<span class="hljs-variable">${handle_m}</span>
|
||||
s=0
|
||||
e=`<span class="hljs-built_in">echo</span> <span class="hljs-variable">$at</span>|wc -c`
|
||||
text=<span class="hljs-string">"<span class="hljs-variable">$at</span> /egg <span class="hljs-variable">$base</span>"</span>
|
||||
col=app.bsky.feed.post
|
||||
created_at=`date --iso-8601=seconds`
|
||||
</code></pre>
|
||||
<div><p class="code-filename">json</p></div>
|
||||
<pre><code class="lang-sh">json=<span class="hljs-string">"{
|
||||
\"did\": \"<span class="hljs-variable">$did</span>\",
|
||||
\"repo\": \"<span class="hljs-variable">$handle</span>\",
|
||||
\"collection\": \"<span class="hljs-variable">$col</span>\",
|
||||
\"record\": {
|
||||
\"text\": \"<span class="hljs-variable">$text</span>\",
|
||||
\"\$type\": \"<span class="hljs-variable">$col</span>\",
|
||||
\"createdAt\": \"<span class="hljs-variable">$created_at</span>\",
|
||||
\"facets\": [
|
||||
{
|
||||
\"\$type\": \"app.bsky.richtext.facet\",
|
||||
\"index\": {
|
||||
\"byteEnd\": <span class="hljs-variable">$e</span>,
|
||||
\"byteStart\": <span class="hljs-variable">$s</span>
|
||||
},\"features\": [
|
||||
{
|
||||
\"did\": \"<span class="hljs-variable">$did_m</span>\",
|
||||
\"\$type\": \"app.bsky.richtext.facet#mention\"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}"</span>
|
||||
</code></pre>
|
||||
<div><p class="code-filename">post</p></div>
|
||||
<pre><code class="lang-sh">curl <span class="hljs-_">-s</span>L -X POST -H <span class="hljs-string">"Content-Type: application/json"</span> \
|
||||
-H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> \
|
||||
<span class="hljs-_">-d</span> <span class="hljs-string">"<span class="hljs-variable">$json</span>"</span> \
|
||||
https://bsky.social/xrpc/com.atproto.repo.createRecord
|
||||
</code></pre>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="./" class="navigation navigation-prev " aria-label="Previous page: part 1">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="2.html" class="navigation navigation-next " aria-label="Next page: example">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"quick start","level":"1.2.1","depth":2,"next":{"title":"example","level":"1.2.2","depth":2,"path":"c1/2.md","ref":"c1/2.md","articles":[]},"previous":{"title":"part 1","level":"1.2","depth":1,"path":"c1/README.md","ref":"c1/README.md","articles":[{"title":"quick start","level":"1.2.1","depth":2,"path":"c1/1.md","ref":"c1/1.md","articles":[]},{"title":"example","level":"1.2.2","depth":2,"path":"c1/2.md","ref":"c1/2.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c1/1.md","mtime":"2023-07-31T06:55:02.821Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,748 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>example · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="../c2/" />
|
||||
|
||||
|
||||
<link rel="prev" href="1.html" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.2.2" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="../c2/">
|
||||
|
||||
<a href="../c2/">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="../c2/1.html">
|
||||
|
||||
<a href="../c2/1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="../c2/2.html">
|
||||
|
||||
<a href="../c2/2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="../c2/3.html">
|
||||
|
||||
<a href="../c2/3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="../c2/4.html">
|
||||
|
||||
<a href="../c2/4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../c3/">
|
||||
|
||||
<a href="../c3/">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="../c3/1.html">
|
||||
|
||||
<a href="../c3/1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="../c3/2.html">
|
||||
|
||||
<a href="../c3/2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="../c3/3.html">
|
||||
|
||||
<a href="../c3/3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="../c4/">
|
||||
|
||||
<a href="../c4/">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="../c4/0.html">
|
||||
|
||||
<a href="../c4/0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="../c4/1.html">
|
||||
|
||||
<a href="../c4/1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="../c4/2.html">
|
||||
|
||||
<a href="../c4/2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="../c4/3.html">
|
||||
|
||||
<a href="../c4/3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >example</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="example">example</h3>
|
||||
<p>Here is an example of the use of <a href="https://github.com/bluesky-social/atproto/tree/main/lexicons" target="_blank">lexicons</a>.</p>
|
||||
<h4 id="option">option</h4>
|
||||
<pre><code class="lang-sh"><span class="hljs-comment"># reverse</span>
|
||||
curl <span class="hljs-_">-s</span>L <span class="hljs-string">"https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=<span class="hljs-variable">${handle}</span>&collection=app.bsky.feed.post&reverse=true"</span>
|
||||
</code></pre>
|
||||
<h4 id="login">login</h4>
|
||||
<pre><code class="lang-sh">handle=yui.syui.ai
|
||||
pass=xxx
|
||||
curl <span class="hljs-_">-s</span>L -X POST -H <span class="hljs-string">"Content-Type: application/json"</span> \
|
||||
<span class="hljs-_">-d</span> <span class="hljs-string">"{\"identifier\":\"<span class="hljs-variable">$handle</span>\",\"password\":\"<span class="hljs-variable">$pass</span>\"}"</span> \
|
||||
https://bsky.social/xrpc/com.atproto.server.createSession
|
||||
|
||||
<span class="hljs-comment"># token</span>
|
||||
token=`curl <span class="hljs-_">-s</span>L -X POST -H <span class="hljs-string">"Content-Type: application/json"</span> <span class="hljs-_">-d</span> <span class="hljs-string">"{\"identifier\":\"<span class="hljs-variable">$handle</span>\",\"password\":\"<span class="hljs-variable">$pass</span>\"}"</span> https://bsky.social/xrpc/com.atproto.server.createSession|jq -r .accessJwt`
|
||||
|
||||
<span class="hljs-comment"># did</span>
|
||||
did=`curl <span class="hljs-_">-s</span>L -X POST -H <span class="hljs-string">"Content-Type: application/json"</span> <span class="hljs-_">-d</span> <span class="hljs-string">"{\"identifier\":\"<span class="hljs-variable">$handle</span>\",\"password\":\"<span class="hljs-variable">$pass</span>\"}"</span> https://bsky.social/xrpc/com.atproto.server.createSession|jq -r .did`
|
||||
|
||||
<span class="hljs-comment"># profile</span>
|
||||
curl <span class="hljs-_">-s</span>L -X GET -H <span class="hljs-string">"Content-Type: application/json"</span> \
|
||||
-H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> \
|
||||
<span class="hljs-string">"https://bsky.social/xrpc/app.bsky.actor.getProfile?actor=<span class="hljs-variable">${handle}</span>"</span>
|
||||
|
||||
<span class="hljs-comment"># notify</span>
|
||||
curl <span class="hljs-_">-s</span>L -X GET -H <span class="hljs-string">"Content-Type: application/json"</span> \
|
||||
-H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> \
|
||||
https://bsky.social/xrpc/app.bsky.notification.listNotifications
|
||||
</code></pre>
|
||||
<h4 id="post">post</h4>
|
||||
<pre><code class="lang-sh">col=app.bsky.feed.post
|
||||
|
||||
created_at=`date --iso-8601=seconds`
|
||||
|
||||
json=<span class="hljs-string">"{
|
||||
\"repo\": \"<span class="hljs-variable">$handle</span>\",
|
||||
\"did\": \"<span class="hljs-variable">$did</span>\",
|
||||
\"collection\": \"<span class="hljs-variable">$col</span>\",
|
||||
\"record\": {
|
||||
\"text\": \"hello world\",
|
||||
\"createdAt\": \"<span class="hljs-variable">$created_at</span>\"
|
||||
}
|
||||
}"</span>
|
||||
|
||||
<span class="hljs-comment"># post</span>
|
||||
curl <span class="hljs-_">-s</span>L -X POST -H <span class="hljs-string">"Content-Type: application/json"</span> \
|
||||
-H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> \
|
||||
<span class="hljs-_">-d</span> <span class="hljs-string">"<span class="hljs-variable">$json</span>"</span> \
|
||||
https://bsky.social/xrpc/com.atproto.repo.createRecord
|
||||
</code></pre>
|
||||
<h4 id="mention">mention</h4>
|
||||
<div><p class="code-filename">example.json</p></div>
|
||||
<pre><code class="lang-json">{
|
||||
<span class="hljs-string">"did"</span>: <span class="hljs-string">"did:plc:4hqjfn7m6n5hno3doamuhgef"</span>,
|
||||
<span class="hljs-string">"repo"</span>: <span class="hljs-string">"yui.syui.ai"</span>,
|
||||
<span class="hljs-string">"collection"</span>: <span class="hljs-string">"app.bsky.feed.post"</span>,
|
||||
<span class="hljs-string">"record"</span>: {
|
||||
<span class="hljs-string">"text"</span>: <span class="hljs-string">"test"</span>,
|
||||
<span class="hljs-string">"$type"</span>: <span class="hljs-string">"app.bsky.feed.post"</span>,
|
||||
<span class="hljs-string">"createdAt"</span>: <span class="hljs-string">"2023-07-20T13:05:45+09:00"</span>,
|
||||
<span class="hljs-string">"facets"</span>: [
|
||||
{
|
||||
<span class="hljs-string">"$type"</span>: <span class="hljs-string">"app.bsky.richtext.facet"</span>,
|
||||
<span class="hljs-string">"index"</span>: {
|
||||
<span class="hljs-string">"byteEnd"</span>: <span class="hljs-number">13</span>,
|
||||
<span class="hljs-string">"byteStart"</span>: <span class="hljs-number">0</span>
|
||||
},
|
||||
<span class="hljs-string">"features"</span>: [
|
||||
{
|
||||
<span class="hljs-string">"did"</span>: <span class="hljs-string">"did:plc:4hqjfn7m6n5hno3doamuhgef"</span>,
|
||||
<span class="hljs-string">"$type"</span>: <span class="hljs-string">"app.bsky.richtext.facet#mention"</span>
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
<pre><code class="lang-sh"><span class="hljs-comment"># mention</span>
|
||||
col=app.bsky.feed.post
|
||||
handle_m=yui.syui.ai
|
||||
did_m=`curl <span class="hljs-_">-s</span>L -X GET -H <span class="hljs-string">"Content-Type: application/json"</span> -H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> <span class="hljs-string">"https://bsky.social/xrpc/app.bsky.actor.getProfile?actor=<span class="hljs-variable">${handle_m}</span>"</span>|jq -r .did`
|
||||
at=@<span class="hljs-variable">${handle_m}</span>
|
||||
s=0
|
||||
e=`<span class="hljs-built_in">echo</span> <span class="hljs-variable">$at</span>|wc -c`
|
||||
|
||||
json=<span class="hljs-string">"{
|
||||
\"did\": \"<span class="hljs-variable">$did</span>\",
|
||||
\"repo\": \"<span class="hljs-variable">$handle</span>\",
|
||||
\"collection\": \"<span class="hljs-variable">$col</span>\",
|
||||
\"record\": {
|
||||
\"text\": \"<span class="hljs-variable">$text</span>\",
|
||||
\"\$type\": \"app.bsky.feed.post\",
|
||||
\"createdAt\": \"<span class="hljs-variable">$created_at</span>\",
|
||||
\"facets\": [
|
||||
{
|
||||
\"\$type\": \"app.bsky.richtext.facet\",
|
||||
\"index\": {
|
||||
\"byteEnd\": <span class="hljs-variable">$e</span>,
|
||||
\"byteStart\": <span class="hljs-variable">$s</span>
|
||||
},\"features\": [
|
||||
{
|
||||
\"did\": \"<span class="hljs-variable">$did_m</span>\",
|
||||
\"\$type\": \"app.bsky.richtext.facet#mention\"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}"</span>
|
||||
|
||||
curl <span class="hljs-_">-s</span>L -X POST -H <span class="hljs-string">"Content-Type: application/json"</span> \
|
||||
-H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> \
|
||||
<span class="hljs-_">-d</span> <span class="hljs-string">"<span class="hljs-variable">$json</span>"</span> \
|
||||
https://bsky.social/xrpc/com.atproto.repo.createRecord
|
||||
</code></pre>
|
||||
<div><p class="code-filename">output</p></div>
|
||||
<pre><code class="lang-sh">{<span class="hljs-string">"uri"</span>:<span class="hljs-string">"at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.post/3k2wkbvcasf24"</span>,<span class="hljs-string">"cid"</span>:<span class="hljs-string">"bafyreiecswq5qhk7f4xxztevzbfynocsgmjrmr3hwqoluhhzvqgowalivi"</span>}
|
||||
</code></pre>
|
||||
<h4 id="reply">reply</h4>
|
||||
<div><p class="code-filename">example.json</p></div>
|
||||
<pre><code class="lang-json">{
|
||||
<span class="hljs-string">"repo"</span>: <span class="hljs-string">"yui.syui.ai"</span>,
|
||||
<span class="hljs-string">"did"</span>: <span class="hljs-string">"did:plc:4hqjfn7m6n5hno3doamuhgef"</span>,
|
||||
<span class="hljs-string">"collection"</span>: <span class="hljs-string">"app.bsky.feed.post"</span>,
|
||||
<span class="hljs-string">"record"</span>: {
|
||||
<span class="hljs-string">"text"</span>: <span class="hljs-string">"reply"</span>,
|
||||
<span class="hljs-string">"createdAt"</span>: <span class="hljs-string">"2023-07-20T13:05:45+09:00"</span>,
|
||||
<span class="hljs-string">"reply"</span>: {
|
||||
<span class="hljs-string">"root"</span>: {
|
||||
<span class="hljs-string">"cid"</span>: <span class="hljs-string">"bafyreiecswq5qhk7f4xxztevzbfynocsgmjrmr3hwqoluhhzvqgowalivi"</span>,
|
||||
<span class="hljs-string">"uri"</span>: <span class="hljs-string">"at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.post/3k2wkbvcasf24"</span>
|
||||
},
|
||||
<span class="hljs-string">"parent"</span>: {
|
||||
<span class="hljs-string">"cid"</span>: <span class="hljs-string">"bafyreiecswq5qhk7f4xxztevzbfynocsgmjrmr3hwqoluhhzvqgowalivi"</span>,
|
||||
<span class="hljs-string">"uri"</span>: <span class="hljs-string">"at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.post/3k2wkbvcasf24"</span>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
<pre><code class="lang-sh"><span class="hljs-comment"># reply</span>
|
||||
col=app.bsky.feed.post
|
||||
uri=at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.post/3k2wkbvcasf24
|
||||
cid=bafyreiecswq5qhk7f4xxztevzbfynocsgmjrmr3hwqoluhhzvqgowalivi
|
||||
|
||||
json=<span class="hljs-string">"{
|
||||
\"repo\": \"<span class="hljs-variable">$handle</span>\",
|
||||
\"did\": \"<span class="hljs-variable">$did</span>\",
|
||||
\"collection\": \"<span class="hljs-variable">$col</span>\",
|
||||
\"record\": {
|
||||
\"text\": \"reply\",
|
||||
\"createdAt\": \"<span class="hljs-variable">$created_at</span>\",
|
||||
\"reply\": {
|
||||
\"root\": {
|
||||
\"cid\": \"<span class="hljs-variable">$cid</span>\",
|
||||
\"uri\": \"<span class="hljs-variable">$uri</span>\"
|
||||
},
|
||||
\"parent\": {
|
||||
\"cid\": \"<span class="hljs-variable">$cid</span>\",
|
||||
\"uri\": \"<span class="hljs-variable">$uri</span>\"
|
||||
}
|
||||
}
|
||||
}
|
||||
}"</span>
|
||||
|
||||
curl <span class="hljs-_">-s</span>L -X POST -H <span class="hljs-string">"Content-Type: application/json"</span> \
|
||||
-H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> \
|
||||
<span class="hljs-_">-d</span> <span class="hljs-string">"<span class="hljs-variable">$json</span>"</span> \
|
||||
https://bsky.social/xrpc/com.atproto.repo.createRecord
|
||||
</code></pre>
|
||||
<h4 id="like">like</h4>
|
||||
<pre><code class="lang-sh"><span class="hljs-comment"># reply</span>
|
||||
col=app.bsky.feed.like
|
||||
uri=at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.post/3k2wkbvcasf24
|
||||
cid=bafyreiecswq5qhk7f4xxztevzbfynocsgmjrmr3hwqoluhhzvqgowalivi
|
||||
|
||||
json=<span class="hljs-string">"{
|
||||
\"repo\": \"<span class="hljs-variable">$handle</span>\",
|
||||
\"did\": \"<span class="hljs-variable">$did</span>\",
|
||||
\"collection\": \"<span class="hljs-variable">$col</span>\",
|
||||
\"record\": {
|
||||
\"createdAt\": \"<span class="hljs-variable">$created_at</span>\",
|
||||
\"subject\": {
|
||||
\"cid\": \"<span class="hljs-variable">$cid</span>\",
|
||||
\"uri\": \"<span class="hljs-variable">$uri</span>\"
|
||||
}
|
||||
}
|
||||
}"</span>
|
||||
|
||||
curl <span class="hljs-_">-s</span>L -X POST -H <span class="hljs-string">"Content-Type: application/json"</span> \
|
||||
-H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> \
|
||||
<span class="hljs-_">-d</span> <span class="hljs-string">"<span class="hljs-variable">$json</span>"</span> \
|
||||
https://bsky.social/xrpc/com.atproto.repo.createRecord
|
||||
</code></pre>
|
||||
<h4 id="follow">follow</h4>
|
||||
<pre><code class="lang-sh">col=app.bsky.graph.follow
|
||||
handle_m=yui.syui.ai
|
||||
did_m=`curl <span class="hljs-_">-s</span>L -X GET -H <span class="hljs-string">"Content-Type: application/json"</span> -H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> <span class="hljs-string">"https://bsky.social/xrpc/app.bsky.actor.getProfile?actor=<span class="hljs-variable">${handle_m}</span>"</span>|jq -r .did`
|
||||
|
||||
json=<span class="hljs-string">"{
|
||||
\"repo\": \"<span class="hljs-variable">$handle</span>\",
|
||||
\"did\": \"<span class="hljs-variable">$did</span>\",
|
||||
\"collection\": \"<span class="hljs-variable">$col</span>\",
|
||||
\"record\": {
|
||||
\"createdAt\": \"<span class="hljs-variable">$created_at</span>\",
|
||||
\"subject\": \"<span class="hljs-variable">$did_m</span>\"
|
||||
}
|
||||
}"</span>
|
||||
|
||||
curl <span class="hljs-_">-s</span>L -X POST -H <span class="hljs-string">"Content-Type: application/json"</span> \
|
||||
-H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> \
|
||||
<span class="hljs-_">-d</span> <span class="hljs-string">"<span class="hljs-variable">$json</span>"</span> \
|
||||
https://bsky.social/xrpc/com.atproto.repo.createRecord
|
||||
</code></pre>
|
||||
<h4 id="unfollow">unfollow</h4>
|
||||
<pre><code class="lang-sh">$ curl <span class="hljs-_">-s</span>L -X GET -H <span class="hljs-string">"Content-Type: application/json"</span> \
|
||||
-H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> \
|
||||
<span class="hljs-string">"https://bsky.social/xrpc/app.bsky.graph.getFollowers?actor=<span class="hljs-variable">${handle}</span>&cursor=<span class="hljs-variable">${cursor}</span>"</span> \
|
||||
|jq -r <span class="hljs-string">".cursor"</span>
|
||||
|
||||
1688489398761::bafyreieie7opxd5mojipvk3xe3h65u3qvpungskqxamldepctfbd6xhdcu
|
||||
</code></pre>
|
||||
<pre><code class="lang-sh">cursor=1688489398761::bafyreieie7opxd5mojipvk3xe3h65u3qvpungskqxamldepctfbd6xhdcu
|
||||
|
||||
$ curl <span class="hljs-_">-s</span>L -X GET -H <span class="hljs-string">"Content-Type: application/json"</span> \
|
||||
-H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> \
|
||||
<span class="hljs-string">"https://bsky.social/xrpc/app.bsky.graph.getFollowers?actor=<span class="hljs-variable">${handle}</span>&cursor=<span class="hljs-variable">${cursor}</span>"</span> \
|
||||
|jq -r <span class="hljs-string">".followers|.[0].viewer.followedBy"</span>
|
||||
|
||||
at://did:plc:uqzpqmrjnptsxezjx4xuh2mn/app.bsky.graph.follow/3k2wkjr6cnj2x
|
||||
</code></pre>
|
||||
<pre><code class="lang-sh">col=app.bsky.graph.follow
|
||||
rkey=at://did:plc:uqzpqmrjnptsxezjx4xuh2mn/app.bsky.graph.follow/3k2wkjr6cnj2x
|
||||
|
||||
handle_m=yui.syui.ai
|
||||
did_m=`curl <span class="hljs-_">-s</span>L -X GET -H <span class="hljs-string">"Content-Type: application/json"</span> -H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> <span class="hljs-string">"https://bsky.social/xrpc/app.bsky.actor.getProfile?actor=<span class="hljs-variable">${handle_m}</span>"</span>|jq -r .did`
|
||||
|
||||
json=<span class="hljs-string">"{
|
||||
\"repo\": \"<span class="hljs-variable">$handle</span>\",
|
||||
\"did\": \"<span class="hljs-variable">$did</span>\",
|
||||
\"collection\": \"<span class="hljs-variable">$col</span>\",
|
||||
\"rkey\":\"<span class="hljs-variable">$rkey</span>\",
|
||||
\"record\": {
|
||||
\"createdAt\": \"<span class="hljs-variable">$created_at</span>\",
|
||||
\"subject\": \"<span class="hljs-variable">$did_m</span>\"
|
||||
}
|
||||
}"</span>
|
||||
|
||||
curl <span class="hljs-_">-s</span>L -X POST -H <span class="hljs-string">"Content-Type: application/json"</span> \
|
||||
-H <span class="hljs-string">"Authorization: Bearer <span class="hljs-variable">$token</span>"</span> \
|
||||
<span class="hljs-_">-d</span> <span class="hljs-string">"<span class="hljs-variable">$json</span>"</span> \
|
||||
https://bsky.social/xrpc/com.atproto.repo.deleteRecord
|
||||
</code></pre>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="1.html" class="navigation navigation-prev " aria-label="Previous page: quick start">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="../c2/" class="navigation navigation-next " aria-label="Next page: part 2">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"example","level":"1.2.2","depth":2,"next":{"title":"part 2","level":"1.3","depth":1,"path":"c2/README.md","ref":"c2/README.md","articles":[{"title":"bluesky","level":"1.3.1","depth":2,"path":"c2/1.md","ref":"c2/1.md","articles":[]},{"title":"terminal","level":"1.3.2","depth":2,"path":"c2/2.md","ref":"c2/2.md","articles":[]},{"title":"shell","level":"1.3.3","depth":2,"path":"c2/3.md","ref":"c2/3.md","articles":[]},{"title":"rust","level":"1.3.4","depth":2,"path":"c2/4.md","ref":"c2/4.md","articles":[]}]},"previous":{"title":"quick start","level":"1.2.1","depth":2,"path":"c1/1.md","ref":"c1/1.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c1/2.md","mtime":"2023-07-31T06:40:55.453Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,503 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>part 1 · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="1.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="../" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.2" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="../c2/">
|
||||
|
||||
<a href="../c2/">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="../c2/1.html">
|
||||
|
||||
<a href="../c2/1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="../c2/2.html">
|
||||
|
||||
<a href="../c2/2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="../c2/3.html">
|
||||
|
||||
<a href="../c2/3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="../c2/4.html">
|
||||
|
||||
<a href="../c2/4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../c3/">
|
||||
|
||||
<a href="../c3/">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="../c3/1.html">
|
||||
|
||||
<a href="../c3/1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="../c3/2.html">
|
||||
|
||||
<a href="../c3/2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="../c3/3.html">
|
||||
|
||||
<a href="../c3/3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="../c4/">
|
||||
|
||||
<a href="../c4/">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="../c4/0.html">
|
||||
|
||||
<a href="../c4/0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="../c4/1.html">
|
||||
|
||||
<a href="../c4/1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="../c4/2.html">
|
||||
|
||||
<a href="../c4/2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="../c4/3.html">
|
||||
|
||||
<a href="../c4/3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >part 1</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h2 id="part-1">part 1</h2>
|
||||
<p>This book is an introduction to programming for users of <a href="https://bsky.app" target="_blank">bluesky</a>.</p>
|
||||
<p>It mainly uses the <code>rust</code> programming language and the os terminal environment.</p>
|
||||
<p>The content is to create a simple program for <a href="https://card.syui.ai" target="_blank">card game</a> that can be played on <code>bluesky</code> or <code>mastodon</code>.</p>
|
||||
<p>If you make this program, you can train the cards you have.</p>
|
||||
<p>In this manual, you will learn to hit the bluesky api, create commands in rust, and so on.</p>
|
||||
<p>The <a href="1.html">Quick Start</a> in this chapter provides the minimum necessary explanation for technicians.</p>
|
||||
<p>First-time users should skip this chapter and start with <a href="../c2/">part 2</a>.</p>
|
||||
<p>updated : 2023-07-29</p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="../" class="navigation navigation-prev " aria-label="Previous page: hello world! bluesky">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="1.html" class="navigation navigation-next " aria-label="Next page: quick start">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"part 1","level":"1.2","depth":1,"next":{"title":"quick start","level":"1.2.1","depth":2,"path":"c1/1.md","ref":"c1/1.md","articles":[]},"previous":{"title":"hello world! bluesky","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c1/README.md","mtime":"2023-07-31T06:41:25.197Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,569 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>bluesky · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="2.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="./" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter active" data-level="1.3.1" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="4.html">
|
||||
|
||||
<a href="4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../c3/">
|
||||
|
||||
<a href="../c3/">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="../c3/1.html">
|
||||
|
||||
<a href="../c3/1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="../c3/2.html">
|
||||
|
||||
<a href="../c3/2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="../c3/3.html">
|
||||
|
||||
<a href="../c3/3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="../c4/">
|
||||
|
||||
<a href="../c4/">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="../c4/0.html">
|
||||
|
||||
<a href="../c4/0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="../c4/1.html">
|
||||
|
||||
<a href="../c4/1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="../c4/2.html">
|
||||
|
||||
<a href="../c4/2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="../c4/3.html">
|
||||
|
||||
<a href="../c4/3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >bluesky</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="bluesky">bluesky</h3>
|
||||
<p>The <code>at</code> will henceforth be <code>atproto</code>.</p>
|
||||
<p>bluesky is positioned as a model service for <code>atproto</code>, which is currently being developed and operated by <a href="https://bsky.app/profile/did:plc:oc6vwdlmk2kqyida5i74d3p5/follows" target="_blank">bsky.team</a>.</p>
|
||||
<p>The goal of bsky.team is to enable <code>atproto</code> to be adopted behind the scenes of various services and to allow communication between services.</p>
|
||||
<p>Until now, accounts were only valid within a service. Therefore, it was necessary to switch accounts for each service. This is an attempt to change this.</p>
|
||||
<p>bluesky will work with <code>pds</code>, <code>plc</code>, and <code>bgs</code>.</p>
|
||||
<p>To describe the role of each, <code>pds</code> is the main body of bluesky.</p>
|
||||
<p>plc is like <code>dns</code> and registers handle and did, and performs name resolution.</p>
|
||||
<p>Basically, bluesky works only with pds.</p>
|
||||
<p>However, when an account is created, it connects to plc, so if there is no connection to plc, an error will occur.</p>
|
||||
<p>plc is not necessarily needed when an account is created; it is needed when a handle is registered or changed.</p>
|
||||
<p>bgs builds the timeline of the account when connecting to other pds.</p>
|
||||
<div class="mermaid">
|
||||
graph TD;
|
||||
A[pds]-->B[plc];
|
||||
C[pds]-->B[plc];
|
||||
D[pds]-->B[plc];
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mermaid">
|
||||
graph TD;
|
||||
A[pds]-->B[bgs];
|
||||
C[pds]-->B[bgs];
|
||||
D[pds]-->B[bgs];
|
||||
</div>
|
||||
|
||||
<h4 id="dns">dns</h4>
|
||||
<p>What is a dns above is a server that performs name resolution on the Internet.</p>
|
||||
<p>You connect to the internet by the number <code>ip address</code>.</p>
|
||||
<p>For example, to connect to google, it is <code>172.217.25.174</code>.</p>
|
||||
<pre><code class="lang-sh">$ dig google.com
|
||||
google.com. 291 IN A 172.217.25.174
|
||||
</code></pre>
|
||||
<p>Try this number in your browser to see if it works. It should lead to <code>google.com</code>.</p>
|
||||
<p>However, since numbers are difficult for humans to remember and handle, they are usually given names that are replaced by letters of the alphabet.</p>
|
||||
<p>The server responsible for connecting the name to the number <code>ip address</code> is called dns.</p>
|
||||
<p>The following is a command that displays the route to the desired host. You can see that it is connected via several servers.</p>
|
||||
<pre><code class="lang-sh">$ traceroute google.com
|
||||
20.27.177.113
|
||||
17.253.144.10
|
||||
172.217.25.174
|
||||
</code></pre>
|
||||
<p>If you want to know your ip address, you can use <code>ipinfo.io</code>.</p>
|
||||
<pre><code class="lang-sh">$ curl <span class="hljs-_">-s</span>L ipinfo.io
|
||||
20.27.177.113
|
||||
</code></pre>
|
||||
<h4 id="plc">plc</h4>
|
||||
<p>These are the most commonly used plc's at this time. All are provided by bsky.team.</p>
|
||||
<p><a href="https://plc.directory" target="_blank">https://plc.directory</a></p>
|
||||
<p><a href="https://plc.bsky-sandbox.dev" target="_blank">https://plc.bsky-sandbox.dev</a></p>
|
||||
<p>Specifically, it is used as follows</p>
|
||||
<pre><code class="lang-sh">https://plc.directory/<span class="hljs-built_in">export</span>
|
||||
|
||||
https://plc.directory/<span class="hljs-built_in">export</span>?after=1970-01-01T00:00:00.000Z
|
||||
|
||||
https://plc.directory/did:plc:oc6vwdlmk2kqyida5i74d3p5
|
||||
|
||||
https://plc.directory/did:plc:oc6vwdlmk2kqyida5i74d3p5/<span class="hljs-built_in">log</span>
|
||||
</code></pre>
|
||||
<div><p class="code-filename">.env</p></div>
|
||||
<pre><code class="lang-sh"><span class="hljs-comment">#DID_PLC_URL=https://plc.directory</span>
|
||||
DID_PLC_URL=https://plc.bsky-sandbox.dev
|
||||
</code></pre>
|
||||
<h4 id="bast-service">bast service</h4>
|
||||
<p>Since both api and pds are publicly available for bluesky, various services are being developed.</p>
|
||||
<p>The following is a list of representative services.</p>
|
||||
<p><a href="https://firesky.tv" target="_blank">https://firesky.tv</a> : Global Timeline Stream. You can configure and filter it in many ways.</p>
|
||||
<p><a href="https://bsky.jazco.dev" target="_blank">https://bsky.jazco.dev</a> : User Visualization</p>
|
||||
<p><a href="https://bsky.jazco.dev/stats" target="_blank">https://bsky.jazco.dev/stats</a> : Number of user posts</p>
|
||||
<p><a href="https://vqv.app" target="_blank">https://vqv.app</a> : User profile aggregation, etc.</p>
|
||||
<p><a href="https://atscan.net" target="_blank">https://atscan.net</a> : Scanning of pds and did</p>
|
||||
<p><a href="https://skybridge.fly.dev" target="_blank">https://skybridge.fly.dev</a> : url to do bluesky in mastodon client</p>
|
||||
<p><a href="https://tapbots.com/ivory" target="_blank">https://tapbots.com/ivory</a> : Support for mastodon client ivory</p>
|
||||
<p><a href="https://skyfeed.app" target="_blank">https://skyfeed.app</a> : Generation of feeds</p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="./" class="navigation navigation-prev " aria-label="Previous page: part 2">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="2.html" class="navigation navigation-next " aria-label="Next page: terminal">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"bluesky","level":"1.3.1","depth":2,"next":{"title":"terminal","level":"1.3.2","depth":2,"path":"c2/2.md","ref":"c2/2.md","articles":[]},"previous":{"title":"part 2","level":"1.3","depth":1,"path":"c2/README.md","ref":"c2/README.md","articles":[{"title":"bluesky","level":"1.3.1","depth":2,"path":"c2/1.md","ref":"c2/1.md","articles":[]},{"title":"terminal","level":"1.3.2","depth":2,"path":"c2/2.md","ref":"c2/2.md","articles":[]},{"title":"shell","level":"1.3.3","depth":2,"path":"c2/3.md","ref":"c2/3.md","articles":[]},{"title":"rust","level":"1.3.4","depth":2,"path":"c2/4.md","ref":"c2/4.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c2/1.md","mtime":"2023-07-31T06:56:02.235Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,595 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>terminal · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="3.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="1.html" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.3.2" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="4.html">
|
||||
|
||||
<a href="4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../c3/">
|
||||
|
||||
<a href="../c3/">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="../c3/1.html">
|
||||
|
||||
<a href="../c3/1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="../c3/2.html">
|
||||
|
||||
<a href="../c3/2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="../c3/3.html">
|
||||
|
||||
<a href="../c3/3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="../c4/">
|
||||
|
||||
<a href="../c4/">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="../c4/0.html">
|
||||
|
||||
<a href="../c4/0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="../c4/1.html">
|
||||
|
||||
<a href="../c4/1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="../c4/2.html">
|
||||
|
||||
<a href="../c4/2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="../c4/3.html">
|
||||
|
||||
<a href="../c4/3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >terminal</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="terminal">terminal</h3>
|
||||
<p>The goal here is to provide the necessary commands and environment for each OS.</p>
|
||||
<p>The <code>terminal</code> is the famous cmd (command prompt) in windows. In simple terms, it refers to a black screen. It is also called <code>terminal</code> or `term.</p>
|
||||
<p>There are various terminals, or applications (software) in `terminal'.</p>
|
||||
<p>Personally, I recommend <a href="https://wezfurlong.org/wezterm/installation.html" target="_blank">wezterm</a>, but here we will use an os-specific one.</p>
|
||||
<h4 id="package-manager">package manager</h4>
|
||||
<p>First, we will explain <code>package manager</code>.</p>
|
||||
<p>In this case, you need to install a package manager for each OS.</p>
|
||||
<p>Note that packages and programs here can also be referred to as apps.</p>
|
||||
<p>Think of a package manager as something that simplifies the installation of an app.</p>
|
||||
<p>Usually, an app works by building or compiling a source (source) and executing the binary that is created.</p>
|
||||
<p>In the case of windows, <code>.exe</code> is a binary.</p>
|
||||
<p>Binaries differ depending on the operating system.</p>
|
||||
<p>Incidentally, source is often abbreviated to <code>src</code> and binary is often abbreviated to <code>bin</code>.</p>
|
||||
<p>To return to the topic, the package manager automatically handles which packages (binaries) are downloaded from where and where they are placed.</p>
|
||||
<p>The reason why this is done is that it takes time to build a source.</p>
|
||||
<p>Therefore, most packages are simply downloaded from the server (server) as binaries that have already been built on the OS in question.</p>
|
||||
<p>Most of them are called package managers.</p>
|
||||
<p>From now on, you will install this package manager and use it from the <code>terminal</code>.</p>
|
||||
<h4 id="windows">windows</h4>
|
||||
<p>This section describes the required environment for windows users.</p>
|
||||
<ul>
|
||||
<li><p>winget</p>
|
||||
</li>
|
||||
<li><p>scoop</p>
|
||||
</li>
|
||||
<li><p>windows terminal</p>
|
||||
</li>
|
||||
<li><p>wsl</p>
|
||||
</li>
|
||||
</ul>
|
||||
<p>Be careful with the windows environment; remember that windows basically does not work as per the docs.</p>
|
||||
<p>For example, most of the commands in <a href="https://github.com/microsoft" target="_blank">github/microsoft</a> will not work. It may not work.</p>
|
||||
<p>Therefore, you will need to configure and read them according to your environment.</p>
|
||||
<p>First, install <a href="https://github.com/microsoft/winget-cli" target="_blank">winget</a> as a windows package manager.</p>
|
||||
<p>Press <code>win+r</code> and type <code>powershell</code> to start <a href="https://github.com/PowerShell/PowerShell/releases/" target="_blank">powershell</a>. powershell will henceforth be abbreviated as <code>pwsh</code>.</p>
|
||||
<p>Execute the following command.</p>
|
||||
<div><p class="code-filename">pwsh</p></div>
|
||||
<pre><code class="lang-sh">Install-Module -Name Microsoft.W<span class="hljs-keyword">in</span>Get.Client
|
||||
</code></pre>
|
||||
<pre><code class="lang-sh">Untrusted repository
|
||||
You are installing the modules from an untrusted repository. If you trust this repository, change its
|
||||
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
|
||||
<span class="hljs-string">'PSGallery'</span>?
|
||||
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is <span class="hljs-string">"N"</span>): A
|
||||
</code></pre>
|
||||
<p>Next, install <a href="https://github.com/microsoft/terminal" target="_blank">windows terminal</a>.</p>
|
||||
<div><p class="code-filename">search package</p></div>
|
||||
<pre><code class="lang-sh">winget search <span class="hljs-string">"windows terminal"</span>
|
||||
</code></pre>
|
||||
<pre><code> Name Id Version Source
|
||||
--------------------------------------------------------------------------------
|
||||
Windows Terminal 9N0DX20HK701 Unknown msstore
|
||||
Windows Terminal Preview 9N8G5RFZ9XK3 Unknown msstore
|
||||
Windows Terminal Microsoft.WindowsTerminal 1.16.10261.0 winget
|
||||
Windows Terminal Preview Microsoft.WindowsTerminal.Preview 1.17.10234.0 winget
|
||||
</code></pre><div><p class="code-filename">install terminal</p></div>
|
||||
<pre><code class="lang-sh">winget install 9N0DX20HK701
|
||||
or
|
||||
winget install Microsoft.WindowsTerminal
|
||||
</code></pre>
|
||||
<p>Since windows is very unwieldy with shell, we will run linux (ubuntu) with wsl. Basically, rust and shell are explained assuming a linux environment.</p>
|
||||
<div><p class="code-filename">setting wsl</p></div>
|
||||
<pre><code class="lang-sh">wsl --install
|
||||
wsl --install <span class="hljs-_">-d</span> Ubuntu
|
||||
</code></pre>
|
||||
<p>If you prefer a windows environment instead of linux, you can install <code>curl</code> etc. from <a href="https://scoop.sh/" target="_blank">scoop</a> or other package managers.</p>
|
||||
<div><p class="code-filename">install scoop</p></div>
|
||||
<pre><code class="lang-sh">Set-ExecutionPolicy RemoteSigned -Scope CurrentUser <span class="hljs-comment"># Optional: Needed to run a remote script the first time</span>
|
||||
irm get.scoop.sh | iex
|
||||
</code></pre>
|
||||
<div><p class="code-filename">pwsh</p></div>
|
||||
<pre><code class="lang-sh">scoop install curl git rust
|
||||
</code></pre>
|
||||
<p>Install and update <code>pwsh</code>.</p>
|
||||
<pre><code class="lang-sh">winget install Microsoft.PowerShell
|
||||
winget upgrade --all
|
||||
</code></pre>
|
||||
<h4 id="mac">mac</h4>
|
||||
<ul>
|
||||
<li><p>terminal</p>
|
||||
</li>
|
||||
<li><p>homebrew</p>
|
||||
</li>
|
||||
</ul>
|
||||
<p>For <code>mac</code>, use the default terminal.</p>
|
||||
<p>Open <code>finder</code> and press <code>cmd+shift+u</code>. You will find `terminal(terminal.app)' in it.</p>
|
||||
<p>First install the package manager <a href="https://brew.sh" target="_blank">homebrew</a>.</p>
|
||||
<div><p class="code-filename">install brew</p></div>
|
||||
<pre><code class="lang-sh">/bin/bash -c <span class="hljs-string">"<span class="hljs-variable">$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)</span>"</span>
|
||||
</code></pre>
|
||||
<pre><code class="lang-sh">brew install curl git zsh rust
|
||||
</code></pre>
|
||||
<h4 id="linux">linux</h4>
|
||||
<p>I will omit the description for linux users as it needs no explanation.</p>
|
||||
<p>I will use <a href="https://www.archlinux.org/" target="_blank">archlinux</a>.</p>
|
||||
<pre><code class="lang-sh">pacman -Syu curl git zsh rust
|
||||
</code></pre>
|
||||
<pre><code class="lang-sh">$ cargo version
|
||||
cargo 1.70.0
|
||||
</code></pre>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="1.html" class="navigation navigation-prev " aria-label="Previous page: bluesky">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="3.html" class="navigation navigation-next " aria-label="Next page: shell">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"terminal","level":"1.3.2","depth":2,"next":{"title":"shell","level":"1.3.3","depth":2,"path":"c2/3.md","ref":"c2/3.md","articles":[]},"previous":{"title":"bluesky","level":"1.3.1","depth":2,"path":"c2/1.md","ref":"c2/1.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c2/2.md","mtime":"2023-07-31T06:47:31.511Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,571 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>shell · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="4.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="2.html" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.3.3" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="4.html">
|
||||
|
||||
<a href="4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../c3/">
|
||||
|
||||
<a href="../c3/">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="../c3/1.html">
|
||||
|
||||
<a href="../c3/1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="../c3/2.html">
|
||||
|
||||
<a href="../c3/2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="../c3/3.html">
|
||||
|
||||
<a href="../c3/3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="../c4/">
|
||||
|
||||
<a href="../c4/">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="../c4/0.html">
|
||||
|
||||
<a href="../c4/0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="../c4/1.html">
|
||||
|
||||
<a href="../c4/1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="../c4/2.html">
|
||||
|
||||
<a href="../c4/2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="../c4/3.html">
|
||||
|
||||
<a href="../c4/3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >shell</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="shell">shell</h3>
|
||||
<p>Now that you think you have the package manager installed, try installing <code>curl</code> first.</p>
|
||||
<pre><code class="lang-sh"><span class="hljs-comment"># windows</span>
|
||||
scoop install curl
|
||||
|
||||
<span class="hljs-comment"># mac</span>
|
||||
brew install curl
|
||||
|
||||
<span class="hljs-comment"># linux(ubuntu)</span>
|
||||
sudo apt install curl
|
||||
</code></pre>
|
||||
<p>Then, execute the following command in terminal.</p>
|
||||
<pre><code class="lang-sh">curl https://bsky.social/xrpc/_health
|
||||
</code></pre>
|
||||
<p>The result should return the pds version of bluesky(bsky.social) as follows</p>
|
||||
<div><p class="code-filename">output</p></div>
|
||||
<pre><code class="lang-sh">{<span class="hljs-string">"version"</span>:<span class="hljs-string">"b2ef3865bc143bfe4eef4a46dbd6a44053fa270d"</span>}
|
||||
</code></pre>
|
||||
<p>If <code>curl</code> does not work properly, it may be that the installed binaries do not have a path.</p>
|
||||
<p>This is also likely to occur mainly on windows.</p>
|
||||
<p>Here is a little explanation about paths.</p>
|
||||
<h4 id="path">path</h4>
|
||||
<p>When the terminal is started, a program called shell is waiting there.</p>
|
||||
<p>The user executes commands through this shell.</p>
|
||||
<p>There are various kinds of shells.</p>
|
||||
<p>For example, windows has microsoft's <code>cmd</code> and <code>pwsh</code> shells.</p>
|
||||
<p>For unix(mac), linux(ubuntu), there are <code>bash</code>, <code>zsh</code> and so on.</p>
|
||||
<p>The shell can omit directories added to <code>PATH</code> when executing commands.</p>
|
||||
<p>For example, suppose <code>curl</code> is installed in <code>/usr/bin/curl</code>. In this case, shell should execute the following command</p>
|
||||
<pre><code class="lang-sh">/usr/bin/curl --help
|
||||
</code></pre>
|
||||
<p>However, if <code>/usr/bin</code> is added to the <code>PATH</code>, the directory description can be omitted.</p>
|
||||
<pre><code class="lang-sh">curl --help
|
||||
</code></pre>
|
||||
<p>To find the location of the main body of the program (binary), use the following command.</p>
|
||||
<pre><code class="lang-sh"><span class="hljs-built_in">which</span> curl
|
||||
</code></pre>
|
||||
<p>However, it cannot be used unless the path is passed.</p>
|
||||
<p>To pass path, put the directory in question in an environment variable.</p>
|
||||
<pre><code class="lang-sh">PATH=<span class="hljs-variable">$PATH</span>:/usr/bin
|
||||
</code></pre>
|
||||
<p>Note that a directory is sometimes called a <code>dir</code> or <code>folder</code>.</p>
|
||||
<h4 id="notation-">Notation "$"</h4>
|
||||
<p>Next, a note on the description format of shell.</p>
|
||||
<pre><code class="lang-sh"><span class="hljs-built_in">which</span> curl
|
||||
</code></pre>
|
||||
<pre><code class="lang-sh">$ <span class="hljs-built_in">which</span> curl
|
||||
`
|
||||
</code></pre>
|
||||
<p>These have the same meaning.</p>
|
||||
<p>If you are describing the execution of a shell in writing, it is customary to prefix it with <code>`$</code>.</p>
|
||||
<p>This <code>`$</code> means "run in shell".</p>
|
||||
<p>For example, if you want to include the result of the command with the execution, it would be as follows.</p>
|
||||
<pre><code class="lang-sh">$ <span class="hljs-built_in">which</span> curl
|
||||
/usr/bin/curl
|
||||
</code></pre>
|
||||
<p>This is because it is often the case that you want to put the command and the result together, and if there is no <code>$</code>, it will be difficult to tell which is the command and which is the result.</p>
|
||||
<p>In this manual, <code>`$</code> is omitted as much as possible to avoid the harm of copying.</p>
|
||||
<p>However, it is believed that all code layouts should include <code>$</code> when executed in shell.</p>
|
||||
<h4 id="shebang">shebang</h4>
|
||||
<p>Next, we will discuss shell script and shebang.</p>
|
||||
<p>This area varies from shell to shell, but we will assume <code>bash</code>.</p>
|
||||
<p>Please write the following in a text file, give it execute permission, and run it.</p>
|
||||
<div><p class="code-filename">test.sh</p></div>
|
||||
<pre><code class="lang-sh"><span class="hljs-meta">#! /bin/bash</span>
|
||||
curl https://bsky.social/xrpc/_health
|
||||
</code></pre>
|
||||
<p>The following command grants execute permission and executes it.</p>
|
||||
<pre><code class="lang-sh">chmod +x test.sh
|
||||
. /test.sh
|
||||
</code></pre>
|
||||
<p>Then the version of bsky.social will be output.</p>
|
||||
<pre><code class="lang-sh">{<span class="hljs-string">"version"</span>: <span class="hljs-string">"b2ef3865bc143bfe4eef4a46dbd6a44053fa270d"</span>}
|
||||
</code></pre>
|
||||
<p>The first line of the text file <code>#!/bin/bash</code> is what is called a shiban.</p>
|
||||
<p>Here, it specifies which programming language the text file is to be executed in.</p>
|
||||
<p>The following is a brief description of the programming language.</p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="2.html" class="navigation navigation-prev " aria-label="Previous page: terminal">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="4.html" class="navigation navigation-next " aria-label="Next page: rust">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"shell","level":"1.3.3","depth":2,"next":{"title":"rust","level":"1.3.4","depth":2,"path":"c2/4.md","ref":"c2/4.md","articles":[]},"previous":{"title":"terminal","level":"1.3.2","depth":2,"path":"c2/2.md","ref":"c2/2.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c2/3.md","mtime":"2023-07-31T07:00:31.619Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,510 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>rust · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="../c3/" />
|
||||
|
||||
|
||||
<link rel="prev" href="3.html" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.3.4" data-path="4.html">
|
||||
|
||||
<a href="4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../c3/">
|
||||
|
||||
<a href="../c3/">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="../c3/1.html">
|
||||
|
||||
<a href="../c3/1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="../c3/2.html">
|
||||
|
||||
<a href="../c3/2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="../c3/3.html">
|
||||
|
||||
<a href="../c3/3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="../c4/">
|
||||
|
||||
<a href="../c4/">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="../c4/0.html">
|
||||
|
||||
<a href="../c4/0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="../c4/1.html">
|
||||
|
||||
<a href="../c4/1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="../c4/2.html">
|
||||
|
||||
<a href="../c4/2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="../c4/3.html">
|
||||
|
||||
<a href="../c4/3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >rust</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="rust">rust</h3>
|
||||
<p>Next, install the programming language <code>rust</code>.</p>
|
||||
<pre><code class="lang-sh">brew install rust
|
||||
</code></pre>
|
||||
<p>Rust runs through a package manager called <code>cargo</code>.</p>
|
||||
<p>Use <code>cargo</code> to check the version.</p>
|
||||
<pre><code class="lang-sh">$ cargo version
|
||||
cargo 1.71.0
|
||||
</code></pre>
|
||||
<p>Rust is said to be a very difficult language among various programming languages.</p>
|
||||
<p>Its characteristics are that it is stable and works once built, but it takes a long time to get it running.</p>
|
||||
<p>It may also take longer than other languages to add new implementations.</p>
|
||||
<h4 id="lang">lang</h4>
|
||||
<p>Programming languages are sometimes abbreviated as <code>lang</code>.</p>
|
||||
<p>For example, there is a programming language called <code>go</code>.</p>
|
||||
<p>However, the word <code>go</code> has many meanings. Therefore, it is sometimes called <code>golang</code> or <code>go-lang</code>.</p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="3.html" class="navigation navigation-prev " aria-label="Previous page: shell">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="../c3/" class="navigation navigation-next " aria-label="Next page: part 3">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"rust","level":"1.3.4","depth":2,"next":{"title":"part 3","level":"1.4","depth":1,"path":"c3/README.md","ref":"c3/README.md","articles":[{"title":"hello world","level":"1.4.1","depth":2,"path":"c3/1.md","ref":"c3/1.md","articles":[]},{"title":"seahorse","level":"1.4.2","depth":2,"path":"c3/2.md","ref":"c3/2.md","articles":[]},{"title":"reqwest","level":"1.4.3","depth":2,"path":"c3/3.md","ref":"c3/3.md","articles":[]}]},"previous":{"title":"shell","level":"1.3.3","depth":2,"path":"c2/3.md","ref":"c2/3.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c2/4.md","mtime":"2023-07-31T07:06:12.634Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,499 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>part 2 · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="1.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="../c1/2.html" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.3" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="4.html">
|
||||
|
||||
<a href="4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../c3/">
|
||||
|
||||
<a href="../c3/">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="../c3/1.html">
|
||||
|
||||
<a href="../c3/1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="../c3/2.html">
|
||||
|
||||
<a href="../c3/2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="../c3/3.html">
|
||||
|
||||
<a href="../c3/3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="../c4/">
|
||||
|
||||
<a href="../c4/">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="../c4/0.html">
|
||||
|
||||
<a href="../c4/0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="../c4/1.html">
|
||||
|
||||
<a href="../c4/1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="../c4/2.html">
|
||||
|
||||
<a href="../c4/2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="../c4/3.html">
|
||||
|
||||
<a href="../c4/3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >part 2</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h2 id="part-2">part 2</h2>
|
||||
<p>In this chapter, we will explain the most commonly used words and the environment.</p>
|
||||
<p>Mainly, this explanation is aimed at the different operating environments for different OSs.</p>
|
||||
<p>This chapter provides a summary of the installation of packages and other information used in this manual.</p>
|
||||
<p>Please refer to this chapter if you are not familiar with it.</p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="../c1/2.html" class="navigation navigation-prev " aria-label="Previous page: example">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="1.html" class="navigation navigation-next " aria-label="Next page: bluesky">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"part 2","level":"1.3","depth":1,"next":{"title":"bluesky","level":"1.3.1","depth":2,"path":"c2/1.md","ref":"c2/1.md","articles":[]},"previous":{"title":"example","level":"1.2.2","depth":2,"path":"c1/2.md","ref":"c1/2.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c2/README.md","mtime":"2023-07-31T06:49:40.589Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,547 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>hello world · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="2.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="./" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="../c2/">
|
||||
|
||||
<a href="../c2/">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="../c2/1.html">
|
||||
|
||||
<a href="../c2/1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="../c2/2.html">
|
||||
|
||||
<a href="../c2/2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="../c2/3.html">
|
||||
|
||||
<a href="../c2/3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="../c2/4.html">
|
||||
|
||||
<a href="../c2/4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter active" data-level="1.4.1" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="../c4/">
|
||||
|
||||
<a href="../c4/">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="../c4/0.html">
|
||||
|
||||
<a href="../c4/0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="../c4/1.html">
|
||||
|
||||
<a href="../c4/1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="../c4/2.html">
|
||||
|
||||
<a href="../c4/2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="../c4/3.html">
|
||||
|
||||
<a href="../c4/3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >hello world</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="init">init</h3>
|
||||
<p>First, create a program template in rust.</p>
|
||||
<pre><code class="lang-sh">mkdir -p ~/rust
|
||||
<span class="hljs-built_in">cd</span> ~/rust
|
||||
cargo init
|
||||
</code></pre>
|
||||
<pre><code class="lang-sh">.
|
||||
├── Cargo.toml
|
||||
└── src
|
||||
└── main.rs
|
||||
</code></pre>
|
||||
<p>You can create these files yourself or with <code>init</code>.</p>
|
||||
<div><p class="code-filename">Cargo.toml</p></div>
|
||||
<pre><code class="lang-toml"><span class="hljs-section">[package]</span>
|
||||
<span class="hljs-attr">name</span> = <span class="hljs-string">"rust"</span>
|
||||
<span class="hljs-attr">version</span> = <span class="hljs-string">"0.1.0"</span>
|
||||
<span class="hljs-attr">edition</span> = <span class="hljs-string">"2021"</span>
|
||||
|
||||
<span class="hljs-comment"># See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html</span>
|
||||
<span class="hljs-section">
|
||||
[dependencies]</span>
|
||||
</code></pre>
|
||||
<div><p class="code-filename">src/main.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">main</span></span>() {
|
||||
<span class="hljs-built_in">println!</span>(<span class="hljs-string">"Hello, world!"</span>);
|
||||
}
|
||||
</code></pre>
|
||||
<h4 id="editor">editor</h4>
|
||||
<p>Next, let's check the contents of the program.</p>
|
||||
<p>To check, use <code>editor</code> (editor). I use <code>vim</code>, but I would recommend <a href="https://visualstudio.microsoft.com" target="_blank">visual studio</a>.</p>
|
||||
<pre><code class="lang-sh">brew install vim
|
||||
vim src/main.rs
|
||||
</code></pre>
|
||||
<div><p class="code-filename">src/main.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">main</span></span>() {
|
||||
<span class="hljs-built_in">println!</span>(<span class="hljs-string">"Hello, world!"</span>);
|
||||
}
|
||||
</code></pre>
|
||||
<p>This is a program that outputs the string `hello world!</p>
|
||||
<h4 id="build">build</h4>
|
||||
<p>You can <code>build</code> this src and convert it to <code>binary</code>, i.e., the app itself, so that you can run it on that computer.</p>
|
||||
<pre><code class="lang-sh">cargo build
|
||||
</code></pre>
|
||||
<div><p class="code-filename">target/debug/rust</p></div>
|
||||
<pre><code class="lang-sh">target
|
||||
└── debug
|
||||
├── rust ← binary
|
||||
└── rust.d
|
||||
</code></pre>
|
||||
<p>rust is a very good language because it is one-binary, meaning that the compiled result is a single file.</p>
|
||||
<pre><code class="lang-sh">$ ./target/debug/rust
|
||||
Hello, world!
|
||||
</code></pre>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="./" class="navigation navigation-prev " aria-label="Previous page: part 3">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="2.html" class="navigation navigation-next " aria-label="Next page: seahorse">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"hello world","level":"1.4.1","depth":2,"next":{"title":"seahorse","level":"1.4.2","depth":2,"path":"c3/2.md","ref":"c3/2.md","articles":[]},"previous":{"title":"part 3","level":"1.4","depth":1,"path":"c3/README.md","ref":"c3/README.md","articles":[{"title":"hello world","level":"1.4.1","depth":2,"path":"c3/1.md","ref":"c3/1.md","articles":[]},{"title":"seahorse","level":"1.4.2","depth":2,"path":"c3/2.md","ref":"c3/2.md","articles":[]},{"title":"reqwest","level":"1.4.3","depth":2,"path":"c3/3.md","ref":"c3/3.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c3/1.md","mtime":"2023-07-31T06:58:21.884Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,636 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>seahorse · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="3.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="1.html" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="../c2/">
|
||||
|
||||
<a href="../c2/">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="../c2/1.html">
|
||||
|
||||
<a href="../c2/1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="../c2/2.html">
|
||||
|
||||
<a href="../c2/2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="../c2/3.html">
|
||||
|
||||
<a href="../c2/3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="../c2/4.html">
|
||||
|
||||
<a href="../c2/4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.4.2" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="../c4/">
|
||||
|
||||
<a href="../c4/">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="../c4/0.html">
|
||||
|
||||
<a href="../c4/0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="../c4/1.html">
|
||||
|
||||
<a href="../c4/1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="../c4/2.html">
|
||||
|
||||
<a href="../c4/2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="../c4/3.html">
|
||||
|
||||
<a href="../c4/3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >seahorse</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="seahorse">seahorse</h3>
|
||||
<p>Next, introduce the framework <a href="https://github.com/ksk001100/seahorse" target="_blank">ksk001100/seahorse</a>.</p>
|
||||
<p>This framework is for writing a cli (command line interface).</p>
|
||||
<p>A cli is simply the same command as <code>which</code> or <code>curl</code> that you have been executing. We will now create our own command.</p>
|
||||
<p>It may sound difficult to some, but it is easy if you use a wonderful framework called <code>seahorse</code>.</p>
|
||||
<p>First you install <code>seahorse</code>, but to install the library in rust, write the package name in <code>Cargo.toml</code>. This will automatically install the library when you build.</p>
|
||||
<p>Note that library is sometimes abbreviated as <code>lib</code>.</p>
|
||||
<div><p class="code-filename">Cargo.toml</p></div>
|
||||
<pre><code class="lang-toml"><span class="hljs-section">[package]</span>
|
||||
<span class="hljs-attr">name</span> = <span class="hljs-string">"rust"</span>
|
||||
<span class="hljs-attr">version</span> = <span class="hljs-string">"0.1.0"</span>
|
||||
<span class="hljs-attr">edition</span> = <span class="hljs-string">"2021"</span>
|
||||
<span class="hljs-section">
|
||||
[dependencies]</span>
|
||||
<span class="hljs-attr">seahorse</span> = <span class="hljs-string">"*"</span>
|
||||
</code></pre>
|
||||
<p>Then we write the body code that uses <code>seahorse</code>.</p>
|
||||
<div><p class="code-filename">src/main.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-keyword">use</span> seahorse::{App, Context};
|
||||
<span class="hljs-keyword">use</span> std::env;
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">main</span></span>() {
|
||||
<span class="hljs-keyword">let</span> args: <span class="hljs-built_in">Vec</span><<span class="hljs-built_in">String</span>> = env::args().collect();
|
||||
<span class="hljs-keyword">let</span> app = App::new(<span class="hljs-built_in">env!</span>(<span class="hljs-string">"CARGO_PKG_NAME"</span>))
|
||||
.action(s)
|
||||
|
||||
;
|
||||
app.run(args);
|
||||
}
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">s</span></span>(_c: &Context) {
|
||||
<span class="hljs-built_in">println!</span>(<span class="hljs-string">"Hello, world!"</span>);
|
||||
}
|
||||
</code></pre>
|
||||
<p>The contents are very simple. When the command is executed, <code>Hello, world!</code> is output.</p>
|
||||
<pre><code class="lang-sh">$ cargo build
|
||||
$ ./target/debug/rust
|
||||
Hello, world!
|
||||
</code></pre>
|
||||
<p>What is different now, for example, is that the <code>help</code> option is automatic.</p>
|
||||
<pre><code class="lang-sh">$ ./target/debug/rust -h
|
||||
|
||||
Name:
|
||||
rust
|
||||
Flags:
|
||||
-h, --help : Show <span class="hljs-built_in">help</span>
|
||||
</code></pre>
|
||||
<p>To help readers understand the awesomeness of <code>seahorse</code>, ask them to think about the application themselves.</p>
|
||||
<div><p class="code-filename">src/main.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-keyword">use</span> seahorse::{App, Context, Command};
|
||||
<span class="hljs-keyword">use</span> std::env;
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">main</span></span>() {
|
||||
<span class="hljs-keyword">let</span> args: <span class="hljs-built_in">Vec</span><<span class="hljs-built_in">String</span>> = env::args().collect();
|
||||
<span class="hljs-keyword">let</span> app = App::new(<span class="hljs-built_in">env!</span>(<span class="hljs-string">"CARGO_PKG_NAME"</span>))
|
||||
.action(s)
|
||||
|
||||
.command(
|
||||
Command::new(<span class="hljs-string">"yes"</span>)
|
||||
.alias(<span class="hljs-string">"y"</span>)
|
||||
.action(y),
|
||||
)
|
||||
.command(
|
||||
Command::new(<span class="hljs-string">"no"</span>)
|
||||
.alias(<span class="hljs-string">"n"</span>)
|
||||
.action(n),
|
||||
)
|
||||
|
||||
;
|
||||
app.run(args);
|
||||
}
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">s</span></span>(_c: &Context) {
|
||||
<span class="hljs-built_in">println!</span>(<span class="hljs-string">"Hello, world!"</span>);
|
||||
}
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">y</span></span>(_c: &Context) {
|
||||
<span class="hljs-built_in">println!</span>(<span class="hljs-string">"yes"</span>);
|
||||
}
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">n</span></span>(_c: &Context) {
|
||||
<span class="hljs-built_in">println!</span>(<span class="hljs-string">"no"</span>);
|
||||
}
|
||||
</code></pre>
|
||||
<p>Try writing this and executing the command you created.</p>
|
||||
<pre><code class="lang-sh">$ ./target/debug/rust
|
||||
|
||||
$ ./target/debug/rust y
|
||||
|
||||
$ ./target/debug/rust n
|
||||
</code></pre>
|
||||
<p>The differences and key points of the code are as follows</p>
|
||||
<p><pre><code class="lang-diff"> use seahorse::{App, Context
|
||||
<span class="hljs-addition">+ , Command</span>
|
||||
};
|
||||
|
||||
<span class="hljs-addition">+ </span>
|
||||
.command(
|
||||
Command::new("yes")
|
||||
.alias("y")
|
||||
.action(y),
|
||||
)
|
||||
|
||||
fn y(_c: &Context) {
|
||||
println!("yes");
|
||||
}
|
||||
</code></pre>
|
||||
</p>
|
||||
<p>Feel free to rewrite or add these values to create your own commands.</p>
|
||||
<p>Here, the value specified in <code>Command::new</code> means the option name.</p>
|
||||
<p>In this case, <code>rust yes</code> is the issue of this command.</p>
|
||||
<p>You can specify omission by <code>alias("y")</code>. In this case, <code>rust y</code>.</p>
|
||||
<p>The <code>action(y)</code> specifies the function <code>fn y</code>, the contents of which will be executed. The processing of the command body is written in <code>action</code>.</p>
|
||||
<p>By the way, <code>action</code> does not necessarily have to be a function.</p>
|
||||
<p>For example, try adding the following code in place. The command is <code>rust t</code> or <code>rust t foo</code>.</p>
|
||||
<div><p class="code-filename">src/main.rs</p></div>
|
||||
<pre><code class="lang-rust">.command(
|
||||
Command::new(<span class="hljs-string">"test"</span>)
|
||||
.alias(<span class="hljs-string">"t"</span>)
|
||||
.action(|c| <span class="hljs-built_in">println!</span>(<span class="hljs-string">"Hello, {:?}"</span>, c.args)),
|
||||
)
|
||||
</code></pre>
|
||||
<pre><code class="lang-sh">$ ./target/debug/rust t bluesky
|
||||
Hello, [<span class="hljs-string">"bluesky"</span>]
|
||||
</code></pre>
|
||||
<h4 id="cli">cli</h4>
|
||||
<ul>
|
||||
<li>CLI</li>
|
||||
</ul>
|
||||
<p>The term <code>cli</code> has many meanings. It can refer to the cli tool as described above, or it can refer to terminal operations in general.</p>
|
||||
<h4 id="cui-and-gui">cui and gui</h4>
|
||||
<ul>
|
||||
<li>CUI, GUI</li>
|
||||
</ul>
|
||||
<p>There are two kinds of cui and gui. The one we are using now is <code>cui</code>.</p>
|
||||
<p>The term <code>cli</code> is used in almost the same way.</p>
|
||||
<p>cui means terminal operation, and gui means operation on graphical os.</p>
|
||||
<p>It is divided into c-ui and ui, which is just ui. ui stands for user interface.</p>
|
||||
<p>All common os such as windows and mac are based on gui operation.</p>
|
||||
<h4 id="author">author</h4>
|
||||
<p>The author of <a href="https://github.com/ksk001100/seahorse" target="_blank">seahorse</a> is <a href="https://twitter.com/ksk001100" target="_blank">ksk</a>.</p>
|
||||
<p>Thanks for creating a great framework.</p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="1.html" class="navigation navigation-prev " aria-label="Previous page: hello world">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="3.html" class="navigation navigation-next " aria-label="Next page: reqwest">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"seahorse","level":"1.4.2","depth":2,"next":{"title":"reqwest","level":"1.4.3","depth":2,"path":"c3/3.md","ref":"c3/3.md","articles":[]},"previous":{"title":"hello world","level":"1.4.1","depth":2,"path":"c3/1.md","ref":"c3/1.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c3/2.md","mtime":"2023-07-31T07:00:11.330Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,623 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>reqwest · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="../c4/" />
|
||||
|
||||
|
||||
<link rel="prev" href="2.html" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="../c2/">
|
||||
|
||||
<a href="../c2/">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="../c2/1.html">
|
||||
|
||||
<a href="../c2/1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="../c2/2.html">
|
||||
|
||||
<a href="../c2/2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="../c2/3.html">
|
||||
|
||||
<a href="../c2/3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="../c2/4.html">
|
||||
|
||||
<a href="../c2/4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.4.3" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="../c4/">
|
||||
|
||||
<a href="../c4/">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="../c4/0.html">
|
||||
|
||||
<a href="../c4/0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="../c4/1.html">
|
||||
|
||||
<a href="../c4/1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="../c4/2.html">
|
||||
|
||||
<a href="../c4/2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="../c4/3.html">
|
||||
|
||||
<a href="../c4/3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >reqwest</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="reqwest">reqwest</h3>
|
||||
<p>Before explaining <a href="https://github.com/seanmonstar/reqwest" target="_blank">seanmonstar/reqwest</a> in RUST, try the following command.</p>
|
||||
<pre><code class="lang-sh">$ curl <span class="hljs-_">-s</span>L <span class="hljs-string">"https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=support.bsky.team&collection=app.bsky.feed.post"</span>
|
||||
</code></pre>
|
||||
<p>This hits the api to get the timeline for <a href="https://bsky.app/profile/did:plc:oc6vwdlmk2kqyida5i74d3p5" target="_blank">support.bsky.social</a>.</p>
|
||||
<p>You can understand that <code>reqwest</code> is mainly a rust lib to hit the api.</p>
|
||||
<p>Now, let's write the actual code.</p>
|
||||
<div><p class="code-filename">Cargo.toml</p></div>
|
||||
<pre><code class="lang-toml"><span class="hljs-section">[package]</span>
|
||||
<span class="hljs-attr">name</span> = <span class="hljs-string">"rust"</span>
|
||||
<span class="hljs-attr">version</span> = <span class="hljs-string">"0.1.0"</span>
|
||||
<span class="hljs-attr">edition</span> = <span class="hljs-string">"2021"</span>
|
||||
<span class="hljs-section">
|
||||
[dependencies]</span>
|
||||
<span class="hljs-attr">seahorse</span> = <span class="hljs-string">"*"</span>
|
||||
<span class="hljs-attr">reqwest</span> = <span class="hljs-string">"*"</span>
|
||||
<span class="hljs-attr">tokio</span> = { version = <span class="hljs-string">"1"</span>, features = [<span class="hljs-string">"full"</span>] }
|
||||
</code></pre>
|
||||
<pre><code class="lang-src/main.rs">use seahorse::{App, Context, Command};
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let app = App::new(env!("CARGO_PKG_NAME"))
|
||||
.action(s)
|
||||
.command(
|
||||
Command::new("yes")
|
||||
.alias("y")
|
||||
.action(y),
|
||||
)
|
||||
.command(
|
||||
Command::new("no")
|
||||
.alias("n")
|
||||
.action(n),
|
||||
)
|
||||
.command(
|
||||
Command::new("test")
|
||||
.alias("t")
|
||||
.action(|c| println!("Hello, {:?}", c.args)),
|
||||
)
|
||||
.command(
|
||||
Command::new("bluesky")
|
||||
.alias("b")
|
||||
.action(c_list_records),
|
||||
)
|
||||
|
||||
;
|
||||
app.run(args);
|
||||
}
|
||||
|
||||
fn s(_c: &Context) {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
||||
fn y(_c: &Context) {
|
||||
println!("yes");
|
||||
}
|
||||
|
||||
fn n(_c: &Context) {
|
||||
println!("no");
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn list_records() -> reqwest::Result<()> {
|
||||
let client = reqwest::Client::new();
|
||||
let handle= "support.bsky.team";
|
||||
let col = "app.bsky.feed.post";
|
||||
let body = client.get("https://bsky.social/xrpc/com.atproto.repo.listRecords")
|
||||
.query(&[("repo", &handle),("collection", &col)])
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
println!("{}", body);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn c_list_records(_c: &Context) {
|
||||
list_records().unwrap();
|
||||
}
|
||||
</code></pre>
|
||||
<p>This is then <code>cargo build</code> and run the command as usual.</p>
|
||||
<pre><code class="lang-sh">$ ./target/debug/rust b
|
||||
</code></pre>
|
||||
<p>The following is an <code>example</code>, i.e., code with useless command options removed.</p>
|
||||
<p>The main points of the code are as follows.</p>
|
||||
<pre><code class="lang-src/main.rs">.command(
|
||||
Command::new("bluesky")
|
||||
.alias("b")
|
||||
.action(c_list_records),
|
||||
)
|
||||
|
||||
#[tokio::main]
|
||||
async fn list_records() -> reqwest::Result<()> {
|
||||
let client = reqwest::Client::new();
|
||||
let handle= "support.bsky.team";
|
||||
let col = "app.bsky.feed.post";
|
||||
let body = client.get("https://bsky.social/xrpc/com.atproto.repo.listRecords")
|
||||
.query(&[("repo", &handle),("collection", &col)])
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
println!("{}", body);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn c_list_records(_c: &Context) {
|
||||
list_records().unwrap();
|
||||
}
|
||||
</code></pre>
|
||||
<h4 id="query">query</h4>
|
||||
<p>Try adding <code>query</code>. Now the output will be on one line and in order of oldest to newest.</p>
|
||||
<div><p class="code-filename">src/main.rs</p></div>
|
||||
<pre><code class="lang-rust">async <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">list_records</span></span>() -> reqwest::<span class="hljs-built_in">Result</span><()> {
|
||||
<span class="hljs-keyword">let</span> client = reqwest::Client::new();
|
||||
<span class="hljs-keyword">let</span> handle= <span class="hljs-string">"support.bsky.team"</span>;
|
||||
<span class="hljs-keyword">let</span> col = <span class="hljs-string">"app.bsky.feed.post"</span>;
|
||||
<span class="hljs-keyword">let</span> body = client.get(<span class="hljs-string">"https://bsky.social/xrpc/com.atproto.repo.listRecords"</span>)
|
||||
<span class="hljs-comment">//.query(&[("repo", &handle),("collection", &col)])</span>
|
||||
.query(&[(<span class="hljs-string">"repo"</span>, &handle),(<span class="hljs-string">"collection"</span>, &col),(<span class="hljs-string">"limit"</span>, &<span class="hljs-string">"1"</span>),(<span class="hljs-string">"revert"</span>, &<span class="hljs-string">"true"</span>)])
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
<span class="hljs-built_in">println!</span>(<span class="hljs-string">"{}"</span>, body);
|
||||
<span class="hljs-literal">Ok</span>(())
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="2.html" class="navigation navigation-prev " aria-label="Previous page: seahorse">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="../c4/" class="navigation navigation-next " aria-label="Next page: part 4">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"reqwest","level":"1.4.3","depth":2,"next":{"title":"part 4","level":"1.5","depth":1,"path":"c4/README.md","ref":"c4/README.md","articles":[{"title":"ai","level":"1.5.1","depth":2,"path":"c4/0.md","ref":"c4/0.md","articles":[]},{"title":"config","level":"1.5.2","depth":2,"path":"c4/1.md","ref":"c4/1.md","articles":[]},{"title":"mention","level":"1.5.3","depth":2,"path":"c4/2.md","ref":"c4/2.md","articles":[]},{"title":"base64","level":"1.5.4","depth":2,"path":"c4/3.md","ref":"c4/3.md","articles":[]}]},"previous":{"title":"seahorse","level":"1.4.2","depth":2,"path":"c3/2.md","ref":"c3/2.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c3/3.md","mtime":"2023-07-31T07:01:29.133Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,496 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>part 3 · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="1.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="../c2/4.html" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="../c2/">
|
||||
|
||||
<a href="../c2/">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="../c2/1.html">
|
||||
|
||||
<a href="../c2/1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="../c2/2.html">
|
||||
|
||||
<a href="../c2/2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="../c2/3.html">
|
||||
|
||||
<a href="../c2/3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="../c2/4.html">
|
||||
|
||||
<a href="../c2/4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.4" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="../c4/">
|
||||
|
||||
<a href="../c4/">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="../c4/0.html">
|
||||
|
||||
<a href="../c4/0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="../c4/1.html">
|
||||
|
||||
<a href="../c4/1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="../c4/2.html">
|
||||
|
||||
<a href="../c4/2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="../c4/3.html">
|
||||
|
||||
<a href="../c4/3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >part 3</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h2 id="part-3">part 3</h2>
|
||||
<p>In this chapter, we will write specific code in <code>rust</code> to get the program moving.</p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="../c2/4.html" class="navigation navigation-prev " aria-label="Previous page: rust">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="1.html" class="navigation navigation-next " aria-label="Next page: hello world">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"part 3","level":"1.4","depth":1,"next":{"title":"hello world","level":"1.4.1","depth":2,"path":"c3/1.md","ref":"c3/1.md","articles":[]},"previous":{"title":"rust","level":"1.3.4","depth":2,"path":"c2/4.md","ref":"c2/4.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c3/README.md","mtime":"2023-07-31T07:01:38.810Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,627 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>ai · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="1.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="./" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="../c2/">
|
||||
|
||||
<a href="../c2/">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="../c2/1.html">
|
||||
|
||||
<a href="../c2/1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="../c2/2.html">
|
||||
|
||||
<a href="../c2/2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="../c2/3.html">
|
||||
|
||||
<a href="../c2/3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="../c2/4.html">
|
||||
|
||||
<a href="../c2/4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../c3/">
|
||||
|
||||
<a href="../c3/">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="../c3/1.html">
|
||||
|
||||
<a href="../c3/1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="../c3/2.html">
|
||||
|
||||
<a href="../c3/2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="../c3/3.html">
|
||||
|
||||
<a href="../c3/3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter active" data-level="1.5.1" data-path="0.html">
|
||||
|
||||
<a href="0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >ai</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="ai">ai</h3>
|
||||
<p>This section is designed to be original with playful elements. Each of you can set it to whatever you like.</p>
|
||||
<p>First of all, the name of the command application. So far we have used <code>rust</code>. Because the program name created by <code>cargo init</code> is <code>rust</code>. This will automatically give you a folder name.</p>
|
||||
<p>Let's change this to <code>ai</code>.</p>
|
||||
<div><p class="code-filename">Cargo.toml</p></div>
|
||||
<pre><code class="lang-toml"><span class="hljs-section">[package]</span>
|
||||
<span class="hljs-attr">name</span> = <span class="hljs-string">"ai"</span>
|
||||
</code></pre>
|
||||
<p>If you set any name you like, please read the command name, etc. differently in the following explanations.</p>
|
||||
<pre><code class="lang-sh">$ cargo build
|
||||
$ ./target/debug/ai -h
|
||||
|
||||
Name:
|
||||
ai
|
||||
Flags:
|
||||
-h, --help : Show <span class="hljs-built_in">help</span>
|
||||
Commands:
|
||||
y, yes :
|
||||
n, no :
|
||||
t, <span class="hljs-built_in">test</span> :
|
||||
b, bluesky :
|
||||
</code></pre>
|
||||
<h4 id="cleanup">cleanup</h4>
|
||||
<p>Next, let's reduce the number of command options that we don't need, although we don't want to leave any behind.</p>
|
||||
<pre><code class="lang-src/main.rs">use seahorse::{App, Context, Command};
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let app = App::new(env!("CARGO_PKG_NAME"))
|
||||
.action(c_list_records)
|
||||
.command(
|
||||
Command::new("bluesky")
|
||||
.alias("b")
|
||||
.action(c_list_records),
|
||||
)
|
||||
|
||||
;
|
||||
app.run(args);
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn list_records() -> reqwest::Result<()> {
|
||||
let client = reqwest::Client::new();
|
||||
let handle= "support.bsky.team";
|
||||
let col = "app.bsky.feed.post";
|
||||
let body = client.get("https://bsky.social/xrpc/com.atproto.repo.listRecords")
|
||||
.query(&[("repo", &handle),("collection", &col),("limit", &"1"),("revert", &"true")])
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
println!("{}", body);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn c_list_records(_c: &Context) {
|
||||
list_records().unwrap();
|
||||
}
|
||||
</code></pre>
|
||||
<h4 id="ascii">ascii</h4>
|
||||
<p>I will include the so-called <code>ascii art</code>.</p>
|
||||
<p>Generate it using <a href="https://github.com/TheZoraiz/ascii-image-converter" target="_blank">TheZoraiz/ascii-image-converter</a>.</p>
|
||||
<pre><code class="lang-sh">$ ascii-image-converter ai.png -H 50
|
||||
</code></pre>
|
||||
<p>Change <code>.action(c_list_records)</code> to <code>.action(c_ascii_art)</code> in <code>src/main.rs</code>.</p>
|
||||
<div><p class="code-filename">src/main.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-comment">//.action(c_list_records)</span>
|
||||
.action(c_ascii_art)
|
||||
</code></pre>
|
||||
<p>Note that in rust, the <code>//</code> at the beginning of a sentence is a comment.</p>
|
||||
<p>Comments are not interpreted as code. Therefore, when you write a note, use this.</p>
|
||||
<div><p class="code-filename">src/main.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-comment">// This is the ASCII art of the eye</span>
|
||||
<span class="hljs-comment">// See the function "c_ascii_art" for the contents</span>
|
||||
.action(c_ascii_art)
|
||||
</code></pre>
|
||||
<p>Then, add the following code (function) to the last line of <code>src/main.rs</code>.</p>
|
||||
<div><p class="code-filename">src/main.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">c_ascii_art</span></span>(_c: &Context) {
|
||||
<span class="hljs-keyword">let</span> body = <span class="hljs-string">"
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠉⣁⠉⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠟⠛⠋⣉⣉⠡⠤⠤⠤⠤⠤⠤⠤⠤⠬⠤⣁⣉⡉⠛⠻⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢉⣤⡖⠚⣉⣡⣤⣦⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣴⣤⣤⠉⠑⣦⣌⠙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⣾⣿⣦⣄⣅⣌⣄⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣶⣾⣿⣿⣁⣘⡙⠻⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⢃⣤⣨⣿⡿⡿⠟⠟⠛⠻⠚⠛⠛⠛⠛⠛⠛⠋⡋⡋⠛⠛⠉⠉⠼⠿⠿⠿⠿⠿⠷⢶⢤⣈⠙⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⢋⡡⠞⠛⣉⣉⣤⣤⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣶⣶⣶⣶⣶⣶⣦⣦⣦⣦⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⢁⣀⣤⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠟⠛⠋⡉⣉⣉⣁⣨⣀⣅⣉⣉⢉⠛⠛⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠋⣁⡤⣴⣲⢯⢯⡯⣗⡯⣞⡾⣺⣺⢵⢯⢯⣟⢶⢦⣤⣀⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠉⣠⣔⡯⣗⡯⣗⡯⡯⣟⣞⣗⡯⣗⡯⣗⡯⡯⣟⣽⣺⢽⢽⣺⣳⢯⣟⡦⣌⡙⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁⣠⣻⣺⣺⢽⣳⢯⣗⡯⡯⣗⡯⡾⣝⣗⡯⣗⡯⡯⣗⣗⡯⣟⣽⣺⣺⢽⣺⢽⣳⣻⢦⣈⠛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⢠⣺⣳⢽⣺⣺⢽⣺⢽⣺⢽⣫⣗⡯⡯⣗⣗⡯⣗⡯⡯⣗⣗⡯⣗⣗⡯⡾⣽⣺⢽⡽⣾⣽⣺⢵⡀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠁⣔⣟⣞⡾⣽⣺⣺⢽⣺⢽⣺⢽⣺⣺⢽⣫⣗⣗⡯⣗⡯⡯⣗⣗⡯⣗⣗⡯⡯⣗⡯⣟⣞⣗⡿⣾⣽⢽⢦⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⡮⣗⡯⡾⣝⡷⣽⣺⢽⣺⢽⣺⢽⣺⣺⢽⣺⣺⢵⢯⣗⡯⡯⣗⣗⡯⣗⣗⡯⡯⣗⡯⣗⣟⡾⣽⣻⣿⣯⣟⢷⡀⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢀⡾⣝⣗⡯⡯⣗⡯⣗⡯⣟⡾⣽⣺⢽⣺⣺⢽⣺⣺⢽⢽⣺⢽⣫⣗⣗⡯⣗⣗⡯⡯⣗⡯⣗⡷⣻⣗⡷⣿⣟⣿⣽⣳⠈⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⣼⢽⣳⢗⡯⡯⣗⡯⣗⡯⣗⡯⣗⡯⠛⣞⡾⣽⣺⣺⢽⢽⣺⢽⣺⣺⢵⢯⣗⣗⡏⠙⣗⡯⣗⣯⢯⣷⢿⣽⣿⣿⡾⡽⣇⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⢸⣳⢽⣺⢽⢽⣫⣗⡯⣗⡯⣗⣯⡓⢡⡂⢵⢯⣗⡯⡾⣽⢽⣺⢽⣺⣺⢽⢽⣺⡞⢀⢇⠸⣽⣳⢽⣯⢿⣿⣿⣽⣷⣿⢯⢿⠀⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⣞⡾⣽⣺⢽⢽⣺⣺⢽⣳⢯⣗⠇⢠⣿⠆⢸⢽⣺⢽⢽⣳⣻⣺⢽⣺⣺⢽⢽⡺⠁⡬⣿⡀⢳⡽⡽⣾⡯⢿⣯⣿⣽⣿⣻⢽⡃⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠠⣗⡯⣗⡯⣟⣽⣺⣺⢽⣺⢽⡺⢀⣿⣿⢅⠈⣟⡾⣽⢽⣺⢵⢯⣻⣺⣺⢽⢽⠃⡰⣽⣿⡇⢸⡽⡽⣿⢝⣽⣿⣿⣺⣿⡯⣯⡇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣳⢯⣗⡯⣗⣗⡯⡾⣽⣺⢽⠂⣸⣿⣾⡕⡀⢗⡯⣗⣟⡾⡽⣽⣺⣳⢽⢽⠃⢰⣱⣿⣷⡇⢸⡯⣟⠟⠀⣿⡿⣞⣾⣻⣽⡳⡇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣺⢽⣺⢽⣳⢗⡯⡯⣗⡯⡏⢀⣿⢿⣾⣗⠆⠸⣽⡳⣗⡯⡯⣗⣗⡯⣯⠏⢠⢣⣿⣿⣾⡇⢸⢯⠏⣰⠀⣿⣻⣳⣳⣿⣺⢽⠅⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠸⣺⢽⣺⢽⣺⢽⢽⣫⢷⠉⡇⠰⣿⣿⣻⣽⣎⠀⢗⡯⡗⢙⣽⡳⣗⡯⡏⢀⣗⣿⣿⣷⣿⠂⣺⠋⣠⣿⠀⣿⣺⢵⣫⣿⣺⢽⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠈⣗⣟⡾⣽⣺⢽⢽⣺⠍⠀⡇⠘⣉⣤⣬⣈⣑⣅⠘⣽⠂⠘⣮⢯⣗⠏⢠⡟⣉⣡⠤⢤⠄⢠⠃⢴⡟⣯⠀⣗⡯⠟⡾⣗⡯⡇⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀⢸⣳⢯⣗⡯⣟⣽⡺⢀⠃⠀⠸⠋⢡⢡⡉⠻⣷⡄⠸⢀⡆⢹⣳⠃⣴⣿⣿⠋⣠⠐⡔⠀⠂⢳⡄⢰⣟⠀⠉⣠⣦⠘⣷⡻⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢡⡀⢯⣗⣗⡯⣗⣷⡃⠀⣼⠀⠀⠓⠀⠓⢽⠄⢹⣿⡄⢐⣧⠘⢁⣾⣿⣯⡯⢐⢌⠀⠁⣜⠆⢸⣿⡀⢟⠀⢨⣄⠙⡇⢹⠃⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣌⠣⡈⢾⢵⢯⣗⢷⡃⢰⣿⡧⠈⣟⡀⠀⡸⡅⢸⡿⣿⣦⣹⣶⣻⣿⣷⣿⣇⠨⣫⢀⢀⢎⠃⣼⡿⣇⡾⠀⡢⠘⣨⠇⠈⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⡐⠈⢫⣟⢾⢽⡂⢹⣿⣿⡄⠱⢕⢵⠝⢀⣾⣿⣿⣻⣿⣻⣿⣻⣾⣟⣿⣆⠑⡕⠗⣁⣴⣿⡿⣿⠃⠄⣾⣵⡟⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠫⣟⡽⡃⢸⣿⣾⣿⡷⣾⣴⣻⡿⣯⣷⣿⣿⣻⣿⣽⣿⣟⣿⣻⣿⣟⣷⡿⣿⣽⣾⣿⡏⢠⠴⠟⠁⠄⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡈⢯⢧⠈⢿⣿⣾⣿⣿⣾⣿⢿⣿⣟⣿⣾⣿⣼⣿⣾⢿⣻⣿⣽⣿⣻⣿⣿⣻⣯⡿⠀⡄⡔⡔⠅⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠙⢆⠈⠻⣾⣿⣾⢿⣾⣿⣿⣽⠻⢷⣿⣻⣾⠿⠟⢿⣻⣽⣾⣿⢿⣾⡿⠋⡁⡜⠌⠈⣠⠪⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⡂⠀⣤⡈⠻⣾⣿⢿⣷⡿⣯⣷⣤⣤⣤⣤⣶⣾⣿⣿⢿⣻⠽⠛⢉⢠⠸⠈⡠⣰⠀⣿⡀⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⠀⢨⣗⡯⣖⡄⢈⠉⠓⠻⠿⢿⣟⣿⣻⣿⠽⠟⠞⠋⢉⢠⠀⡰⠑⢁⢰⠀⡯⣪⠀⣳⣇⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡗⠨⠀⣻⢮⡯⢺⠀⢜⠈⡊⢐⢶⢔⡤⡤⣤⢤⢖⣖⢷⠅⢸⠀⠐⢁⡴⡇⡘⢠⡫⡎⡇⢸⣺⡄⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⡯⣗⠇⡪⠀⡃⠠⡃⠨⣿⣷⣯⣿⣾⣽⣷⣯⣿⠂⠀⡠⠀⣻⣺⡇⠀⢸⡂⢝⢦⠐⣗⣧⠈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⣜⠀⡯⡿⠀⠆⢐⠁⢜⠌⢨⣿⣾⣿⣽⣯⣿⣷⣿⢿⡁⢌⠐⠀⣳⣳⡃⠀⡪⡇⢸⢕⠄⢳⢽⡆⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠁⡰⢱⠀⡯⡏⠨⠂⢀⡈⢈⡄⢸⣷⣿⣷⢿⣯⣷⣿⣾⣿⣆⠙⠅⠀⣞⣾⠀⢀⢯⡢⠘⣎⢇⠘⡽⣽⡀⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀⣰⡹⠀⢯⠇⢘⠀⠍⣴⣿⣤⣿⡿⣷⣿⢿⣻⣽⣷⣿⡿⣿⣷⡂⢀⣗⣿⠀⠰⠣⢯⡀⢗⡝⡄⠹⣳⢧⠈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⢁⠔⢁⠞⣈⣴⠀⣫⠃⡐⢀⢞⣿⡿⣾⣟⣿⣿⣽⣿⡿⣟⣿⣾⡿⣿⣽⡂⢐⣗⡗⢀⣶⣦⣦⣤⣄⣉⠘⠀⠹⡽⣆⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⡠⠃⡔⢁⣼⣿⡿⠀⢸⠀⡂⢸⢸⣿⡿⣟⣿⢿⣞⡿⣾⣿⢿⣟⣷⢿⣿⣷⠁⢰⢯⡇⢰⣿⣯⣿⣟⣿⡿⣿⣷⣤⣈⠛⢆⠘⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⢠⠊⡠⢊⣰⣿⣿⠟⣰⠀⢸⠀⠀⡎⣾⠿⠟⠛⣉⢉⠚⢮⢿⣾⢿⣝⠮⢋⣠⣈⠂⣸⢽⠀⢼⣟⣯⣷⣿⣟⣿⣿⣽⣿⣿⡷⡌⢣⡈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠁⡔⢁⡔⢡⣾⣿⣿⣧⡐⢿⠀⣞⠀⠀⣏⢦⡶⣞⣿⣽⣳⣳⣽⣿⢿⣻⣾⣴⣳⣷⣿⠀⣺⡝⠀⣽⣿⢿⣻⣽⣿⣽⣾⡿⣯⣿⣿⣿⡀⢳⡀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⢀⠎⢠⠎⣠⣿⣿⣿⣿⣿⣿⣦⠀⡯⠀⠐⠧⠻⠛⠛⢋⢋⠋⠙⠛⠿⣿⢿⣷⡿⣿⣽⡿⠀⣷⠃⠀⣿⡿⣿⡿⣿⣽⣯⣷⣿⣿⡿⣿⣻⡇⢀⠹⣆⠘⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
|
||||
"</span>;
|
||||
<span class="hljs-built_in">println!</span>(<span class="hljs-string">"{}"</span>, body);
|
||||
}
|
||||
</code></pre>
|
||||
<p>Done. Now when you run <code>ai</code>, you will see <a href="https://bsky.app/profile/did:plc:4hqjfn7m6n5hno3doamuhgef" target="_blank">ai</a>.</p>
|
||||
<pre><code class="lang-sh">$ cargo build
|
||||
$ ./target/debug/ai
|
||||
</code></pre>
|
||||
<p><img src="../img/ascii.png" alt></p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="./" class="navigation navigation-prev " aria-label="Previous page: part 4">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="1.html" class="navigation navigation-next " aria-label="Next page: config">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"ai","level":"1.5.1","depth":2,"next":{"title":"config","level":"1.5.2","depth":2,"path":"c4/1.md","ref":"c4/1.md","articles":[]},"previous":{"title":"part 4","level":"1.5","depth":1,"path":"c4/README.md","ref":"c4/README.md","articles":[{"title":"ai","level":"1.5.1","depth":2,"path":"c4/0.md","ref":"c4/0.md","articles":[]},{"title":"config","level":"1.5.2","depth":2,"path":"c4/1.md","ref":"c4/1.md","articles":[]},{"title":"mention","level":"1.5.3","depth":2,"path":"c4/2.md","ref":"c4/2.md","articles":[]},{"title":"base64","level":"1.5.4","depth":2,"path":"c4/3.md","ref":"c4/3.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c4/0.md","mtime":"2023-07-31T07:03:19.152Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,656 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>config · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="2.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="0.html" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="../c2/">
|
||||
|
||||
<a href="../c2/">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="../c2/1.html">
|
||||
|
||||
<a href="../c2/1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="../c2/2.html">
|
||||
|
||||
<a href="../c2/2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="../c2/3.html">
|
||||
|
||||
<a href="../c2/3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="../c2/4.html">
|
||||
|
||||
<a href="../c2/4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../c3/">
|
||||
|
||||
<a href="../c3/">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="../c3/1.html">
|
||||
|
||||
<a href="../c3/1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="../c3/2.html">
|
||||
|
||||
<a href="../c3/2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="../c3/3.html">
|
||||
|
||||
<a href="../c3/3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="0.html">
|
||||
|
||||
<a href="0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.5.2" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >config</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="config">config</h3>
|
||||
<p>Add the code for bluesky's authentication system.</p>
|
||||
<p>Specifically, write information in <code>~/.config/ai/config.toml</code> and create a command option to put authentication information in <code>~/.config/ai/token.toml</code>.</p>
|
||||
<div><p class="code-filename">~/.config/ai/config.toml</p></div>
|
||||
<pre><code class="lang-toml"><span class="hljs-attr">handle</span> = <span class="hljs-string">"yui.syui.ai"</span>
|
||||
<span class="hljs-attr">pass</span> = <span class="hljs-string">"xxx"</span>
|
||||
<span class="hljs-attr">host</span> = <span class="hljs-string">"bsky.social"</span>
|
||||
</code></pre>
|
||||
<div><p class="code-filename">Cargo.toml</p></div>
|
||||
<pre><code class="lang-toml"><span class="hljs-section">[package]</span>
|
||||
<span class="hljs-attr">name</span> = <span class="hljs-string">"ai"</span>
|
||||
<span class="hljs-attr">version</span> = <span class="hljs-string">"0.1.0"</span>
|
||||
<span class="hljs-attr">edition</span> = <span class="hljs-string">"2021"</span>
|
||||
<span class="hljs-section">
|
||||
[dependencies]</span>
|
||||
<span class="hljs-attr">seahorse</span> = <span class="hljs-string">"*"</span>
|
||||
<span class="hljs-attr">reqwest</span> = { version = <span class="hljs-string">"*"</span>, features = [<span class="hljs-string">"blocking"</span>, <span class="hljs-string">"json"</span>] }
|
||||
<span class="hljs-attr">tokio</span> = { version = <span class="hljs-string">"1"</span>, features = [<span class="hljs-string">"full"</span>] }
|
||||
<span class="hljs-attr">serde_derive</span> = <span class="hljs-string">"1.0"</span>
|
||||
<span class="hljs-attr">serde_json</span> = <span class="hljs-string">"1.0"</span>
|
||||
<span class="hljs-attr">serde</span> = <span class="hljs-string">"*"</span>
|
||||
<span class="hljs-attr">config</span> = { git = <span class="hljs-string">"https://github.com/mehcode/config-rs"</span>, branch = <span class="hljs-string">"master"</span> }
|
||||
<span class="hljs-attr">shellexpand</span> = <span class="hljs-string">"*"</span>
|
||||
<span class="hljs-attr">toml</span> = <span class="hljs-string">"*"</span>
|
||||
</code></pre>
|
||||
<div><p class="code-filename">src/data.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-keyword">use</span> config::{Config, ConfigError, File};
|
||||
<span class="hljs-keyword">use</span> serde_derive::{Deserialize, Serialize};
|
||||
|
||||
<span class="hljs-meta">#[derive(Debug, Deserialize)]</span>
|
||||
<span class="hljs-meta">#[allow(unused)]</span>
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Data</span></span> {
|
||||
<span class="hljs-keyword">pub</span> host: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> pass: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> handle: <span class="hljs-built_in">String</span>,
|
||||
}
|
||||
|
||||
<span class="hljs-meta">#[derive(Serialize, Deserialize)]</span>
|
||||
<span class="hljs-meta">#[allow(non_snake_case)]</span>
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Token</span></span> {
|
||||
<span class="hljs-keyword">pub</span> did: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> accessJwt: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> refreshJwt: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> handle: <span class="hljs-built_in">String</span>,
|
||||
}
|
||||
|
||||
<span class="hljs-meta">#[derive(Serialize, Deserialize)]</span>
|
||||
<span class="hljs-meta">#[allow(non_snake_case)]</span>
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Tokens</span></span> {
|
||||
<span class="hljs-keyword">pub</span> did: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> access: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> refresh: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> handle: <span class="hljs-built_in">String</span>,
|
||||
}
|
||||
|
||||
<span class="hljs-keyword">impl</span> Data {
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">new</span></span>() -> <span class="hljs-built_in">Result</span><<span class="hljs-keyword">Self</span>, ConfigError> {
|
||||
<span class="hljs-keyword">let</span> d = shellexpand::tilde(<span class="hljs-string">"~"</span>) + <span class="hljs-string">"/.config/ai/config.toml"</span>;
|
||||
<span class="hljs-keyword">let</span> s = Config::builder()
|
||||
.add_source(File::with_name(&d))
|
||||
.add_source(config::Environment::with_prefix(<span class="hljs-string">"APP"</span>))
|
||||
.build()?;
|
||||
s.try_deserialize()
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
<div><p class="code-filename">src/main.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-keyword">pub</span> <span class="hljs-keyword">mod</span> data;
|
||||
<span class="hljs-keyword">use</span> seahorse::{App, Context, Command};
|
||||
<span class="hljs-keyword">use</span> std::env;
|
||||
<span class="hljs-keyword">use</span> std::fs;
|
||||
<span class="hljs-keyword">use</span> std::io::Write;
|
||||
<span class="hljs-keyword">use</span> std::collections::HashMap;
|
||||
|
||||
<span class="hljs-keyword">use</span> data::Data <span class="hljs-keyword">as</span> Datas;
|
||||
<span class="hljs-keyword">use</span> crate::data::Token;
|
||||
<span class="hljs-keyword">use</span> crate::data::Tokens;
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">main</span></span>() {
|
||||
<span class="hljs-keyword">let</span> args: <span class="hljs-built_in">Vec</span><<span class="hljs-built_in">String</span>> = env::args().collect();
|
||||
<span class="hljs-keyword">let</span> app = App::new(<span class="hljs-built_in">env!</span>(<span class="hljs-string">"CARGO_PKG_NAME"</span>))
|
||||
<span class="hljs-comment">//.action(c_ascii_art)</span>
|
||||
.command(
|
||||
Command::new(<span class="hljs-string">"bluesky"</span>)
|
||||
.alias(<span class="hljs-string">"b"</span>)
|
||||
.action(c_list_records),
|
||||
)
|
||||
.command(
|
||||
Command::new(<span class="hljs-string">"login"</span>)
|
||||
.alias(<span class="hljs-string">"l"</span>)
|
||||
.action(c_access_token),
|
||||
)
|
||||
|
||||
;
|
||||
app.run(args);
|
||||
}
|
||||
|
||||
<span class="hljs-meta">#[tokio::main]</span>
|
||||
async <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">list_records</span></span>() -> reqwest::<span class="hljs-built_in">Result</span><()> {
|
||||
<span class="hljs-keyword">let</span> client = reqwest::Client::new();
|
||||
<span class="hljs-keyword">let</span> handle= <span class="hljs-string">"support.bsky.team"</span>;
|
||||
<span class="hljs-keyword">let</span> col = <span class="hljs-string">"app.bsky.feed.post"</span>;
|
||||
<span class="hljs-keyword">let</span> body = client.get(<span class="hljs-string">"https://bsky.social/xrpc/com.atproto.repo.listRecords"</span>)
|
||||
.query(&[(<span class="hljs-string">"repo"</span>, &handle),(<span class="hljs-string">"collection"</span>, &col),(<span class="hljs-string">"limit"</span>, &<span class="hljs-string">"1"</span>),(<span class="hljs-string">"revert"</span>, &<span class="hljs-string">"true"</span>)])
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
<span class="hljs-built_in">println!</span>(<span class="hljs-string">"{}"</span>, body);
|
||||
<span class="hljs-literal">Ok</span>(())
|
||||
}
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">c_list_records</span></span>(_c: &Context) {
|
||||
list_records().unwrap();
|
||||
}
|
||||
|
||||
<span class="hljs-meta">#[tokio::main]</span>
|
||||
async <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">access_token</span></span>() -> reqwest::<span class="hljs-built_in">Result</span><()> {
|
||||
<span class="hljs-keyword">let</span> file = <span class="hljs-string">"/.config/ai/token.toml"</span>;
|
||||
<span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> f = shellexpand::tilde(<span class="hljs-string">"~"</span>).to_string();
|
||||
f.push_str(&file);
|
||||
|
||||
<span class="hljs-keyword">let</span> data = Datas::new().unwrap();
|
||||
<span class="hljs-keyword">let</span> data = Datas {
|
||||
host: data.host,
|
||||
handle: data.handle,
|
||||
pass: data.pass,
|
||||
};
|
||||
<span class="hljs-keyword">let</span> url = <span class="hljs-string">"https://"</span>.to_owned() + &data.host + &<span class="hljs-string">"/xrpc/com.atproto.server.createSession"</span>;
|
||||
|
||||
<span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> map = HashMap::new();
|
||||
map.insert(<span class="hljs-string">"identifier"</span>, &data.handle);
|
||||
map.insert(<span class="hljs-string">"password"</span>, &data.pass);
|
||||
|
||||
<span class="hljs-keyword">let</span> client = reqwest::Client::new();
|
||||
<span class="hljs-keyword">let</span> res = client
|
||||
.post(url)
|
||||
.json(&map)
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
|
||||
<span class="hljs-keyword">let</span> json: Token = serde_json::from_str(&res).unwrap();
|
||||
<span class="hljs-keyword">let</span> tokens = Tokens {
|
||||
did: json.did.to_string(),
|
||||
access: json.accessJwt.to_string(),
|
||||
refresh: json.refreshJwt.to_string(),
|
||||
handle: json.handle.to_string(),
|
||||
};
|
||||
|
||||
<span class="hljs-keyword">let</span> toml = toml::to_string(&tokens).unwrap();
|
||||
<span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> f = fs::File::create(f.clone()).unwrap();
|
||||
f.write_all(&toml.as_bytes()).unwrap();
|
||||
|
||||
<span class="hljs-literal">Ok</span>(())
|
||||
}
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">c_access_token</span></span>(_c: &Context) {
|
||||
access_token().unwrap();
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="0.html" class="navigation navigation-prev " aria-label="Previous page: ai">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="2.html" class="navigation navigation-next " aria-label="Next page: mention">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"config","level":"1.5.2","depth":2,"next":{"title":"mention","level":"1.5.3","depth":2,"path":"c4/2.md","ref":"c4/2.md","articles":[]},"previous":{"title":"ai","level":"1.5.1","depth":2,"path":"c4/0.md","ref":"c4/0.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c4/1.md","mtime":"2023-07-31T07:03:50.324Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,857 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>mention · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="3.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="1.html" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="../c2/">
|
||||
|
||||
<a href="../c2/">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="../c2/1.html">
|
||||
|
||||
<a href="../c2/1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="../c2/2.html">
|
||||
|
||||
<a href="../c2/2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="../c2/3.html">
|
||||
|
||||
<a href="../c2/3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="../c2/4.html">
|
||||
|
||||
<a href="../c2/4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../c3/">
|
||||
|
||||
<a href="../c3/">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="../c3/1.html">
|
||||
|
||||
<a href="../c3/1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="../c3/2.html">
|
||||
|
||||
<a href="../c3/2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="../c3/3.html">
|
||||
|
||||
<a href="../c3/3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="0.html">
|
||||
|
||||
<a href="0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.5.3" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >mention</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="mention">mention</h3>
|
||||
<p>Now it's time to create a command to <code>post</code> to bluesky. To be precise, it is <code>mention</code>.</p>
|
||||
<p>Now, let's create a new file and read it in <code>src/main.rs</code>.</p>
|
||||
<div><p class="code-filename">Cargo.toml</p></div>
|
||||
<pre><code class="lang-toml"><span class="hljs-section">[package]</span>
|
||||
<span class="hljs-attr">name</span> = <span class="hljs-string">"ai"</span>
|
||||
<span class="hljs-attr">version</span> = <span class="hljs-string">"0.1.0"</span>
|
||||
<span class="hljs-attr">edition</span> = <span class="hljs-string">"2021"</span>
|
||||
<span class="hljs-section">
|
||||
[dependencies]</span>
|
||||
<span class="hljs-attr">seahorse</span> = <span class="hljs-string">"*"</span>
|
||||
<span class="hljs-attr">reqwest</span> = { version = <span class="hljs-string">"*"</span>, features = [<span class="hljs-string">"blocking"</span>, <span class="hljs-string">"json"</span>] }
|
||||
<span class="hljs-attr">tokio</span> = { version = <span class="hljs-string">"1"</span>, features = [<span class="hljs-string">"full"</span>] }
|
||||
<span class="hljs-attr">serde_derive</span> = <span class="hljs-string">"1.0"</span>
|
||||
<span class="hljs-attr">serde_json</span> = <span class="hljs-string">"1.0"</span>
|
||||
<span class="hljs-attr">serde</span> = <span class="hljs-string">"*"</span>
|
||||
<span class="hljs-attr">config</span> = { git = <span class="hljs-string">"https://github.com/mehcode/config-rs"</span>, branch = <span class="hljs-string">"master"</span> }
|
||||
<span class="hljs-attr">shellexpand</span> = <span class="hljs-string">"*"</span>
|
||||
<span class="hljs-attr">toml</span> = <span class="hljs-string">"*"</span>
|
||||
<span class="hljs-attr">iso8601-timestamp</span> = <span class="hljs-string">"0.2.10"</span>
|
||||
</code></pre>
|
||||
<div><p class="code-filename">src/data.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-keyword">use</span> config::{Config, ConfigError, File};
|
||||
<span class="hljs-keyword">use</span> serde_derive::{Deserialize, Serialize};
|
||||
|
||||
<span class="hljs-meta">#[derive(Debug, Deserialize)]</span>
|
||||
<span class="hljs-meta">#[allow(unused)]</span>
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Data</span></span> {
|
||||
<span class="hljs-keyword">pub</span> host: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> pass: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> handle: <span class="hljs-built_in">String</span>,
|
||||
}
|
||||
|
||||
<span class="hljs-meta">#[derive(Serialize, Deserialize)]</span>
|
||||
<span class="hljs-meta">#[allow(non_snake_case)]</span>
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Token</span></span> {
|
||||
<span class="hljs-keyword">pub</span> did: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> accessJwt: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> refreshJwt: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> handle: <span class="hljs-built_in">String</span>,
|
||||
}
|
||||
|
||||
<span class="hljs-meta">#[derive(Serialize, Deserialize)]</span>
|
||||
<span class="hljs-meta">#[allow(non_snake_case)]</span>
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Tokens</span></span> {
|
||||
<span class="hljs-keyword">pub</span> did: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> access: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> refresh: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> handle: <span class="hljs-built_in">String</span>,
|
||||
}
|
||||
|
||||
<span class="hljs-meta">#[derive(Serialize, Deserialize)]</span>
|
||||
<span class="hljs-meta">#[allow(non_snake_case)]</span>
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Labels</span></span> {
|
||||
}
|
||||
|
||||
<span class="hljs-meta">#[derive(Serialize, Deserialize)]</span>
|
||||
<span class="hljs-meta">#[allow(non_snake_case)]</span>
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Declaration</span></span> {
|
||||
<span class="hljs-keyword">pub</span> actorType: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> cid: <span class="hljs-built_in">String</span>,
|
||||
}
|
||||
|
||||
<span class="hljs-meta">#[derive(Serialize, Deserialize)]</span>
|
||||
<span class="hljs-meta">#[allow(non_snake_case)]</span>
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Viewer</span></span> {
|
||||
<span class="hljs-keyword">pub</span> muted: <span class="hljs-keyword">bool</span>,
|
||||
}
|
||||
|
||||
<span class="hljs-meta">#[derive(Serialize, Deserialize)]</span>
|
||||
<span class="hljs-meta">#[allow(non_snake_case)]</span>
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Profile</span></span> {
|
||||
<span class="hljs-keyword">pub</span> did: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> handle: <span class="hljs-built_in">String</span>,
|
||||
<span class="hljs-keyword">pub</span> followsCount: <span class="hljs-built_in">Option</span><<span class="hljs-keyword">i32</span>>,
|
||||
<span class="hljs-keyword">pub</span> followersCount: <span class="hljs-built_in">Option</span><<span class="hljs-keyword">i32</span>>,
|
||||
<span class="hljs-keyword">pub</span> postsCount: <span class="hljs-keyword">i32</span>,
|
||||
<span class="hljs-keyword">pub</span> indexedAt: <span class="hljs-built_in">Option</span><<span class="hljs-built_in">String</span>>,
|
||||
<span class="hljs-keyword">pub</span> avatar: <span class="hljs-built_in">Option</span><<span class="hljs-built_in">String</span>>,
|
||||
<span class="hljs-keyword">pub</span> banner: <span class="hljs-built_in">Option</span><<span class="hljs-built_in">String</span>>,
|
||||
<span class="hljs-keyword">pub</span> displayName: <span class="hljs-built_in">Option</span><<span class="hljs-built_in">String</span>>,
|
||||
<span class="hljs-keyword">pub</span> description: <span class="hljs-built_in">Option</span><<span class="hljs-built_in">String</span>>,
|
||||
<span class="hljs-keyword">pub</span> viewer: Viewer,
|
||||
<span class="hljs-keyword">pub</span> labels: Labels,
|
||||
}
|
||||
|
||||
<span class="hljs-keyword">impl</span> Data {
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">new</span></span>() -> <span class="hljs-built_in">Result</span><<span class="hljs-keyword">Self</span>, ConfigError> {
|
||||
<span class="hljs-keyword">let</span> d = shellexpand::tilde(<span class="hljs-string">"~"</span>) + <span class="hljs-string">"/.config/ai/config.toml"</span>;
|
||||
<span class="hljs-keyword">let</span> s = Config::builder()
|
||||
.add_source(File::with_name(&d))
|
||||
.add_source(config::Environment::with_prefix(<span class="hljs-string">"APP"</span>))
|
||||
.build()?;
|
||||
s.try_deserialize()
|
||||
}
|
||||
}
|
||||
|
||||
<span class="hljs-keyword">impl</span> Tokens {
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">new</span></span>() -> <span class="hljs-built_in">Result</span><<span class="hljs-keyword">Self</span>, ConfigError> {
|
||||
<span class="hljs-keyword">let</span> d = shellexpand::tilde(<span class="hljs-string">"~"</span>) + <span class="hljs-string">"/.config/ai/token.toml"</span>;
|
||||
<span class="hljs-keyword">let</span> s = Config::builder()
|
||||
.add_source(File::with_name(&d))
|
||||
.add_source(config::Environment::with_prefix(<span class="hljs-string">"APP"</span>))
|
||||
.build()?;
|
||||
s.try_deserialize()
|
||||
}
|
||||
}
|
||||
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">token_toml</span></span>(s: &<span class="hljs-keyword">str</span>) -> <span class="hljs-built_in">String</span> {
|
||||
<span class="hljs-keyword">let</span> s = <span class="hljs-built_in">String</span>::from(s);
|
||||
<span class="hljs-keyword">let</span> tokens = Tokens::new().unwrap();
|
||||
<span class="hljs-keyword">let</span> tokens = Tokens {
|
||||
did: tokens.did,
|
||||
access: tokens.access,
|
||||
refresh: tokens.refresh,
|
||||
handle: tokens.handle,
|
||||
};
|
||||
<span class="hljs-keyword">match</span> &*s {
|
||||
<span class="hljs-string">"did"</span> => tokens.did,
|
||||
<span class="hljs-string">"access"</span> => tokens.access,
|
||||
<span class="hljs-string">"refresh"</span> => tokens.refresh,
|
||||
<span class="hljs-string">"handle"</span> => tokens.handle,
|
||||
_ => s,
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
<div><p class="code-filename">src/profile.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-keyword">extern</span> <span class="hljs-keyword">crate</span> reqwest;
|
||||
<span class="hljs-keyword">use</span> crate::token_toml;
|
||||
|
||||
<span class="hljs-keyword">pub</span> async <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">get_request</span></span>(handle: <span class="hljs-built_in">String</span>) -> <span class="hljs-built_in">String</span> {
|
||||
|
||||
<span class="hljs-keyword">let</span> token = token_toml(&<span class="hljs-string">"access"</span>);
|
||||
<span class="hljs-keyword">let</span> url = <span class="hljs-string">"https://bsky.social/xrpc/app.bsky.actor.getProfile"</span>.to_owned() + &<span class="hljs-string">"?actor="</span> + &handle;
|
||||
<span class="hljs-keyword">let</span> client = reqwest::Client::new();
|
||||
<span class="hljs-keyword">let</span> res = client
|
||||
.get(url)
|
||||
.header(<span class="hljs-string">"Authorization"</span>, <span class="hljs-string">"Bearer "</span>.to_owned() + &token)
|
||||
.send()
|
||||
.await
|
||||
.unwrap()
|
||||
.text()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
<span class="hljs-keyword">return</span> res
|
||||
}
|
||||
</code></pre>
|
||||
<div><p class="code-filename">src/mention.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-keyword">extern</span> <span class="hljs-keyword">crate</span> reqwest;
|
||||
<span class="hljs-keyword">use</span> crate::token_toml;
|
||||
<span class="hljs-keyword">use</span> serde_json::json;
|
||||
<span class="hljs-keyword">use</span> iso8601_timestamp::Timestamp;
|
||||
|
||||
<span class="hljs-keyword">pub</span> async <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">post_request</span></span>(text: <span class="hljs-built_in">String</span>, at: <span class="hljs-built_in">String</span>, udid: <span class="hljs-built_in">String</span>, s: <span class="hljs-keyword">i32</span>, e: <span class="hljs-keyword">i32</span>) -> <span class="hljs-built_in">String</span> {
|
||||
|
||||
<span class="hljs-keyword">let</span> token = token_toml(&<span class="hljs-string">"access"</span>);
|
||||
<span class="hljs-keyword">let</span> did = token_toml(&<span class="hljs-string">"did"</span>);
|
||||
<span class="hljs-keyword">let</span> handle = token_toml(&<span class="hljs-string">"handle"</span>);
|
||||
|
||||
<span class="hljs-keyword">let</span> url = <span class="hljs-string">"https://bsky.social/xrpc/com.atproto.repo.createRecord"</span>;
|
||||
<span class="hljs-keyword">let</span> col = <span class="hljs-string">"app.bsky.feed.post"</span>.to_string();
|
||||
|
||||
<span class="hljs-keyword">let</span> d = Timestamp::now_utc();
|
||||
<span class="hljs-keyword">let</span> d = d.to_string();
|
||||
|
||||
<span class="hljs-keyword">let</span> post = <span class="hljs-literal">Some</span>(json!({
|
||||
<span class="hljs-string">"did"</span>: did.to_string(),
|
||||
<span class="hljs-string">"repo"</span>: handle.to_string(),
|
||||
<span class="hljs-string">"collection"</span>: col.to_string(),
|
||||
<span class="hljs-string">"record"</span>: {
|
||||
<span class="hljs-string">"text"</span>: at.to_string() + &<span class="hljs-string">" "</span>.to_string() + &text.to_string(),
|
||||
<span class="hljs-string">"$type"</span>: <span class="hljs-string">"app.bsky.feed.post"</span>,
|
||||
<span class="hljs-string">"createdAt"</span>: d.to_string(),
|
||||
<span class="hljs-string">"facets"</span>: [
|
||||
{
|
||||
<span class="hljs-string">"$type"</span>: <span class="hljs-string">"app.bsky.richtext.facet"</span>,
|
||||
<span class="hljs-string">"index"</span>: {
|
||||
<span class="hljs-string">"byteEnd"</span>: e,
|
||||
<span class="hljs-string">"byteStart"</span>: s
|
||||
},<span class="hljs-string">"features"</span>: [
|
||||
{
|
||||
<span class="hljs-string">"did"</span>: udid.to_string(),
|
||||
<span class="hljs-string">"$type"</span>: <span class="hljs-string">"app.bsky.richtext.facet#mention"</span>
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
}));
|
||||
|
||||
<span class="hljs-keyword">let</span> client = reqwest::Client::new();
|
||||
<span class="hljs-keyword">let</span> res = client
|
||||
.post(url)
|
||||
.json(&post)
|
||||
.header(<span class="hljs-string">"Authorization"</span>, <span class="hljs-string">"Bearer "</span>.to_owned() + &token)
|
||||
.send()
|
||||
.await
|
||||
.unwrap()
|
||||
.text()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
<span class="hljs-keyword">return</span> res
|
||||
}
|
||||
</code></pre>
|
||||
<div><p class="code-filename">src/main.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-keyword">pub</span> <span class="hljs-keyword">mod</span> data;
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-keyword">mod</span> mention;
|
||||
<span class="hljs-keyword">pub</span> <span class="hljs-keyword">mod</span> profile;
|
||||
|
||||
<span class="hljs-keyword">use</span> seahorse::{App, Command, Context, Flag, FlagType};
|
||||
<span class="hljs-keyword">use</span> std::env;
|
||||
<span class="hljs-keyword">use</span> std::fs;
|
||||
<span class="hljs-keyword">use</span> std::io::Write;
|
||||
<span class="hljs-keyword">use</span> std::collections::HashMap;
|
||||
|
||||
<span class="hljs-keyword">use</span> data::Data <span class="hljs-keyword">as</span> Datas;
|
||||
<span class="hljs-keyword">use</span> crate::data::Token;
|
||||
<span class="hljs-keyword">use</span> crate::data::Tokens;
|
||||
<span class="hljs-keyword">use</span> crate::data::Profile;
|
||||
<span class="hljs-keyword">use</span> crate::data::token_toml;
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">main</span></span>() {
|
||||
<span class="hljs-keyword">let</span> args: <span class="hljs-built_in">Vec</span><<span class="hljs-built_in">String</span>> = env::args().collect();
|
||||
<span class="hljs-keyword">let</span> app = App::new(<span class="hljs-built_in">env!</span>(<span class="hljs-string">"CARGO_PKG_NAME"</span>))
|
||||
<span class="hljs-comment">//.action(c_ascii_art)</span>
|
||||
.command(
|
||||
Command::new(<span class="hljs-string">"bluesky"</span>)
|
||||
.alias(<span class="hljs-string">"b"</span>)
|
||||
.action(c_list_records),
|
||||
)
|
||||
.command(
|
||||
Command::new(<span class="hljs-string">"login"</span>)
|
||||
.alias(<span class="hljs-string">"l"</span>)
|
||||
.action(c_access_token),
|
||||
)
|
||||
.command(
|
||||
Command::new(<span class="hljs-string">"profile"</span>)
|
||||
.alias(<span class="hljs-string">"p"</span>)
|
||||
.action(c_profile),
|
||||
)
|
||||
.command(
|
||||
Command::new(<span class="hljs-string">"mention"</span>)
|
||||
.alias(<span class="hljs-string">"m"</span>)
|
||||
.action(c_mention)
|
||||
.flag(
|
||||
Flag::new(<span class="hljs-string">"post"</span>, FlagType::<span class="hljs-built_in">String</span>)
|
||||
.description(<span class="hljs-string">"post flag\n\t\t\t$ ai m syui.bsky.social -p text"</span>)
|
||||
.alias(<span class="hljs-string">"p"</span>),
|
||||
)
|
||||
)
|
||||
|
||||
;
|
||||
app.run(args);
|
||||
}
|
||||
|
||||
<span class="hljs-meta">#[tokio::main]</span>
|
||||
async <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">list_records</span></span>() -> reqwest::<span class="hljs-built_in">Result</span><()> {
|
||||
<span class="hljs-keyword">let</span> client = reqwest::Client::new();
|
||||
<span class="hljs-keyword">let</span> handle= <span class="hljs-string">"support.bsky.team"</span>;
|
||||
<span class="hljs-keyword">let</span> col = <span class="hljs-string">"app.bsky.feed.post"</span>;
|
||||
<span class="hljs-keyword">let</span> body = client.get(<span class="hljs-string">"https://bsky.social/xrpc/com.atproto.repo.listRecords"</span>)
|
||||
.query(&[(<span class="hljs-string">"repo"</span>, &handle),(<span class="hljs-string">"collection"</span>, &col),(<span class="hljs-string">"limit"</span>, &<span class="hljs-string">"1"</span>),(<span class="hljs-string">"revert"</span>, &<span class="hljs-string">"true"</span>)])
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
<span class="hljs-built_in">println!</span>(<span class="hljs-string">"{}"</span>, body);
|
||||
<span class="hljs-literal">Ok</span>(())
|
||||
}
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">c_list_records</span></span>(_c: &Context) {
|
||||
list_records().unwrap();
|
||||
}
|
||||
|
||||
<span class="hljs-meta">#[tokio::main]</span>
|
||||
async <span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">access_token</span></span>() -> reqwest::<span class="hljs-built_in">Result</span><()> {
|
||||
<span class="hljs-keyword">let</span> file = <span class="hljs-string">"/.config/ai/token.toml"</span>;
|
||||
<span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> f = shellexpand::tilde(<span class="hljs-string">"~"</span>).to_string();
|
||||
f.push_str(&file);
|
||||
|
||||
<span class="hljs-keyword">let</span> data = Datas::new().unwrap();
|
||||
<span class="hljs-keyword">let</span> data = Datas {
|
||||
host: data.host,
|
||||
handle: data.handle,
|
||||
pass: data.pass,
|
||||
};
|
||||
<span class="hljs-keyword">let</span> url = <span class="hljs-string">"https://"</span>.to_owned() + &data.host + &<span class="hljs-string">"/xrpc/com.atproto.server.createSession"</span>;
|
||||
|
||||
<span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> map = HashMap::new();
|
||||
map.insert(<span class="hljs-string">"identifier"</span>, &data.handle);
|
||||
map.insert(<span class="hljs-string">"password"</span>, &data.pass);
|
||||
<span class="hljs-keyword">let</span> client = reqwest::Client::new();
|
||||
<span class="hljs-keyword">let</span> res = client
|
||||
.post(url)
|
||||
.json(&map)
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
<span class="hljs-keyword">let</span> json: Token = serde_json::from_str(&res).unwrap();
|
||||
<span class="hljs-keyword">let</span> tokens = Tokens {
|
||||
did: json.did.to_string(),
|
||||
access: json.accessJwt.to_string(),
|
||||
refresh: json.refreshJwt.to_string(),
|
||||
handle: json.handle.to_string(),
|
||||
};
|
||||
<span class="hljs-keyword">let</span> toml = toml::to_string(&tokens).unwrap();
|
||||
<span class="hljs-keyword">let</span> <span class="hljs-keyword">mut</span> f = fs::File::create(f.clone()).unwrap();
|
||||
f.write_all(&toml.as_bytes()).unwrap();
|
||||
|
||||
<span class="hljs-literal">Ok</span>(())
|
||||
}
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">c_access_token</span></span>(_c: &Context) {
|
||||
access_token().unwrap();
|
||||
}
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">profile</span></span>(c: &Context) {
|
||||
<span class="hljs-keyword">let</span> m = c.args[<span class="hljs-number">0</span>].to_string();
|
||||
<span class="hljs-keyword">let</span> h = async {
|
||||
<span class="hljs-keyword">let</span> <span class="hljs-keyword">str</span> = profile::get_request(m.to_string()).await;
|
||||
<span class="hljs-built_in">println!</span>(<span class="hljs-string">"{}"</span>,<span class="hljs-keyword">str</span>);
|
||||
};
|
||||
<span class="hljs-keyword">let</span> res = tokio::runtime::Runtime::new().unwrap().block_on(h);
|
||||
<span class="hljs-keyword">return</span> res
|
||||
}
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">c_profile</span></span>(c: &Context) {
|
||||
access_token().unwrap();
|
||||
profile(c);
|
||||
}
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">mention</span></span>(c: &Context) {
|
||||
<span class="hljs-keyword">let</span> m = c.args[<span class="hljs-number">0</span>].to_string();
|
||||
<span class="hljs-keyword">let</span> h = async {
|
||||
<span class="hljs-keyword">let</span> <span class="hljs-keyword">str</span> = profile::get_request(m.to_string()).await;
|
||||
<span class="hljs-built_in">println!</span>(<span class="hljs-string">"{}"</span>,<span class="hljs-keyword">str</span>);
|
||||
<span class="hljs-keyword">let</span> profile: Profile = serde_json::from_str(&<span class="hljs-keyword">str</span>).unwrap();
|
||||
<span class="hljs-keyword">let</span> udid = profile.did;
|
||||
<span class="hljs-keyword">let</span> handle = profile.handle;
|
||||
<span class="hljs-keyword">let</span> at = <span class="hljs-string">"@"</span>.to_owned() + &handle;
|
||||
<span class="hljs-keyword">let</span> e = at.chars().count();
|
||||
<span class="hljs-keyword">let</span> s = <span class="hljs-number">0</span>;
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-keyword">let</span> <span class="hljs-literal">Ok</span>(post) = c.string_flag(<span class="hljs-string">"post"</span>) {
|
||||
<span class="hljs-keyword">let</span> <span class="hljs-keyword">str</span> = mention::post_request(post.to_string(), at.to_string(), udid.to_string(), s, e.try_into().unwrap()).await;
|
||||
<span class="hljs-built_in">println!</span>(<span class="hljs-string">"{}"</span>,<span class="hljs-keyword">str</span>);
|
||||
}
|
||||
};
|
||||
<span class="hljs-keyword">let</span> res = tokio::runtime::Runtime::new().unwrap().block_on(h);
|
||||
<span class="hljs-keyword">return</span> res
|
||||
}
|
||||
|
||||
<span class="hljs-function"><span class="hljs-keyword">fn</span> <span class="hljs-title">c_mention</span></span>(c: &Context) {
|
||||
access_token().unwrap();
|
||||
mention(c);
|
||||
}
|
||||
</code></pre>
|
||||
<p>This time, we don't support any hosts other than <code>bsky.social</code> because it is troublesome. Mainly <code>profile.rs</code> and <code>mention.rs</code>. Please be careful about that.</p>
|
||||
<div><p class="code-filename">src/profile.rs</p></div>
|
||||
<pre><code class="lang-rust"><span class="hljs-keyword">let</span> url = <span class="hljs-string">"https://bsky.social/xrpc/app.bsky.actor.getProfile"</span>.to_owned() + &<span class="hljs-string">"?actor="</span> + &handle;
|
||||
</code></pre>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="1.html" class="navigation navigation-prev " aria-label="Previous page: config">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="3.html" class="navigation navigation-next " aria-label="Next page: base64">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"mention","level":"1.5.3","depth":2,"next":{"title":"base64","level":"1.5.4","depth":2,"path":"c4/3.md","ref":"c4/3.md","articles":[]},"previous":{"title":"config","level":"1.5.2","depth":2,"path":"c4/1.md","ref":"c4/1.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c4/2.md","mtime":"2023-07-31T07:04:35.715Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,770 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>base64 · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="../end/" />
|
||||
|
||||
|
||||
<link rel="prev" href="2.html" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="../c2/">
|
||||
|
||||
<a href="../c2/">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="../c2/1.html">
|
||||
|
||||
<a href="../c2/1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="../c2/2.html">
|
||||
|
||||
<a href="../c2/2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="../c2/3.html">
|
||||
|
||||
<a href="../c2/3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="../c2/4.html">
|
||||
|
||||
<a href="../c2/4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../c3/">
|
||||
|
||||
<a href="../c3/">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="../c3/1.html">
|
||||
|
||||
<a href="../c3/1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="../c3/2.html">
|
||||
|
||||
<a href="../c3/2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="../c3/3.html">
|
||||
|
||||
<a href="../c3/3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="0.html">
|
||||
|
||||
<a href="0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.5.4" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >base64</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="base64">base64</h3>
|
||||
<p>Next, write the code to convert the characters specified in the command options to <a href="https://uma0317.github.io/rust-cookbook-ja/encoding/strings.html" target="_blank">base64</a> and <code>mention</code>.</p>
|
||||
<p>This completes the program.</p>
|
||||
<p>First, add the <code>base64</code> package.</p>
|
||||
<div><p class="code-filename">Cargo.toml</p></div>
|
||||
<pre><code class="lang-toml"><span class="hljs-section">[package]</span>
|
||||
<span class="hljs-attr">name</span> = <span class="hljs-string">"ai"</span>
|
||||
<span class="hljs-attr">version</span> = <span class="hljs-string">"0.1.0"</span>
|
||||
<span class="hljs-attr">edition</span> = <span class="hljs-string">"2021"</span>
|
||||
<span class="hljs-section">
|
||||
[dependencies]</span>
|
||||
<span class="hljs-attr">seahorse</span> = <span class="hljs-string">"*"</span>
|
||||
<span class="hljs-attr">reqwest</span> = { version = <span class="hljs-string">"*"</span>, features = [<span class="hljs-string">"blocking"</span>, <span class="hljs-string">"json"</span>] }
|
||||
<span class="hljs-attr">tokio</span> = { version = <span class="hljs-string">"1"</span>, features = [<span class="hljs-string">"full"</span>] }
|
||||
<span class="hljs-attr">serde_derive</span> = <span class="hljs-string">"1.0"</span>
|
||||
<span class="hljs-attr">serde_json</span> = <span class="hljs-string">"1.0"</span>
|
||||
<span class="hljs-attr">serde</span> = <span class="hljs-string">"*"</span>
|
||||
<span class="hljs-attr">config</span> = { git = <span class="hljs-string">"https://github.com/mehcode/config-rs"</span>, branch = <span class="hljs-string">"master"</span> }
|
||||
<span class="hljs-attr">shellexpand</span> = <span class="hljs-string">"*"</span>
|
||||
<span class="hljs-attr">toml</span> = <span class="hljs-string">"*"</span>
|
||||
<span class="hljs-attr">iso8601-timestamp</span> = <span class="hljs-string">"0.2.10"</span>
|
||||
<span class="hljs-attr">base64</span> = <span class="hljs-string">"*"</span>
|
||||
</code></pre>
|
||||
<p>Then, in <code>src/main.rs</code>, in the <code>mention</code>, write the code to convert the <code>did</code> to base64.</p>
|
||||
<p>These are set to suboptions.</p>
|
||||
<p>Here is a summary of the main points.</p>
|
||||
<div><p class="code-filename">example</p></div>
|
||||
<pre><code class="lang-rust">.command(
|
||||
Command::new(<span class="hljs-string">"mention"</span>)
|
||||
.alias(<span class="hljs-string">"m"</span>)
|
||||
.action(c_mention)
|
||||
.flag(
|
||||
Flag::new(<span class="hljs-string">"base"</span>, FlagType::<span class="hljs-built_in">String</span>)
|
||||
.description(<span class="hljs-string">"base flag\n\t\t\t$ ai m syui.bsky.social -p text -b 123"</span>)
|
||||
.alias(<span class="hljs-string">"b"</span>),
|
||||
)
|
||||
.flag(
|
||||
Flag::new(<span class="hljs-string">"egg"</span>, FlagType::Bool)
|
||||
.description(<span class="hljs-string">"egg flag\n\t\t\t$ ai m syui.bsky.social -e"</span>)
|
||||
.alias(<span class="hljs-string">"e"</span>),
|
||||
)
|
||||
|
||||
<span class="hljs-keyword">let</span> did = token_toml(&<span class="hljs-string">"did"</span>);
|
||||
<span class="hljs-keyword">let</span> body = <span class="hljs-string">"/egg "</span>.to_owned() + &encode(did.as_bytes());
|
||||
</code></pre>
|
||||
<p>Allow <code>-b</code> to specify the string to be converted. Be sure to enclose the string in double quotation marks, for example <code>-b "foo bar"</code>. Use <code>-e</code> to get the <code>did</code> and convert it automatically for mention.</p>
|
||||
<p>``sh</p>
|
||||
<h1 id="convert-the-specified-string-to-base64-for-mention">convert the specified string to base64 for mention</h1>
|
||||
<p>$ ai m yui.syui.ai -b "did:plc:4hqjfn7m6n5hno3doamuhgef"
|
||||
@yui.syui.ai /egg ZGlkOnBsYzo0aHFqZm43bTZuNWhubzNkb2FtdWhnZWY=</p>
|
||||
<h1 id="mention-your-did-as-base64">MENTION your did as base64</h1>
|
||||
<p>$ ai m yui.syui.ai -e
|
||||
@yui.syui.ai /egg ZGlkOnBsYzo0aHFqZm43bTZuNWhubzNkb2FtdWhnZWY=</p>
|
||||
<pre><code class="lang-`">
|
||||
Now, let's write the whole code.
|
||||
|
||||
|
||||
!FILENAME src/main.rs
|
||||
```rust
|
||||
pub mod data;
|
||||
pub mod mention;
|
||||
pub mod profile;
|
||||
//pub mod ascii;
|
||||
|
||||
use seahorse::{App, Command, Context, Flag, FlagType};
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use data::Data as Datas;
|
||||
use crate::data::Token;
|
||||
use crate::data::Tokens;
|
||||
use crate::data::Profile;
|
||||
use crate::data::token_toml;
|
||||
//use crate::ascii::c_ascii;
|
||||
|
||||
extern crate base64;
|
||||
use base64::encode;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let app = App::new(env!("CARGO_PKG_NAME"))
|
||||
//.action(c_ascii_art)
|
||||
.command(
|
||||
Command::new("bluesky")
|
||||
.alias("b")
|
||||
.action(c_list_records),
|
||||
)
|
||||
.command(
|
||||
Command::new("login")
|
||||
.alias("l")
|
||||
.action(c_access_token),
|
||||
)
|
||||
.command(
|
||||
Command::new("profile")
|
||||
.alias("p")
|
||||
.action(c_profile),
|
||||
)
|
||||
.command(
|
||||
Command::new("mention")
|
||||
.alias("m")
|
||||
.action(c_mention)
|
||||
.flag(
|
||||
Flag::new("post", FlagType::String)
|
||||
.description("post flag\n\t\t\t$ ai m syui.bsky.social -p text")
|
||||
.alias("p"),
|
||||
)
|
||||
.flag(
|
||||
Flag::new("base", FlagType::String)
|
||||
.description("base flag\n\t\t\t$ ai m syui.bsky.social -p text -b 123")
|
||||
.alias("b"),
|
||||
)
|
||||
.flag(
|
||||
Flag::new("egg", FlagType::Bool)
|
||||
.description("egg flag\n\t\t\t$ ai m syui.bsky.social -e")
|
||||
.alias("e"),
|
||||
)
|
||||
)
|
||||
|
||||
;
|
||||
app.run(args);
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn list_records() -> reqwest::Result<()> {
|
||||
let client = reqwest::Client::new();
|
||||
let handle= "support.bsky.team";
|
||||
let col = "app.bsky.feed.post";
|
||||
let body = client.get("https://bsky.social/xrpc/com.atproto.repo.listRecords")
|
||||
.query(&[("repo", &handle),("collection", &col),("limit", &"1"),("revert", &"true")])
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
println!("{}", body);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn c_list_records(_c: &Context) {
|
||||
list_records().unwrap();
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn access_token() -> reqwest::Result<()> {
|
||||
let file = "/.config/ai/token.toml";
|
||||
let mut f = shellexpand::tilde("~").to_string();
|
||||
f.push_str(&file);
|
||||
|
||||
let data = Datas::new().unwrap();
|
||||
let data = Datas {
|
||||
host: data.host,
|
||||
handle: data.handle,
|
||||
pass: data.pass,
|
||||
};
|
||||
let url = "https://".to_owned() + &data.host + &"/xrpc/com.atproto.server.createSession";
|
||||
|
||||
let mut map = HashMap::new();
|
||||
map.insert("identifier", &data.handle);
|
||||
map.insert("password", &data.pass);
|
||||
let client = reqwest::Client::new();
|
||||
let res = client
|
||||
.post(url)
|
||||
.json(&map)
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
let json: Token = serde_json::from_str(&res).unwrap();
|
||||
let tokens = Tokens {
|
||||
did: json.did.to_string(),
|
||||
access: json.accessJwt.to_string(),
|
||||
refresh: json.refreshJwt.to_string(),
|
||||
handle: json.handle.to_string(),
|
||||
};
|
||||
let toml = toml::to_string(&tokens).unwrap();
|
||||
let mut f = fs::File::create(f.clone()).unwrap();
|
||||
f.write_all(&toml.as_bytes()).unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn c_access_token(_c: &Context) {
|
||||
access_token().unwrap();
|
||||
}
|
||||
|
||||
fn profile(c: &Context) {
|
||||
let m = c.args[0].to_string();
|
||||
let h = async {
|
||||
let str = profile::get_request(m.to_string()).await;
|
||||
println!("{}",str);
|
||||
};
|
||||
let res = tokio::runtime::Runtime::new().unwrap().block_on(h);
|
||||
return res
|
||||
}
|
||||
|
||||
fn c_profile(c: &Context) {
|
||||
access_token().unwrap();
|
||||
profile(c);
|
||||
}
|
||||
|
||||
fn mention(c: &Context) {
|
||||
let m = c.args[0].to_string();
|
||||
let h = async {
|
||||
let str = profile::get_request(m.to_string()).await;
|
||||
let profile: Profile = serde_json::from_str(&str).unwrap();
|
||||
let udid = profile.did;
|
||||
let handle = profile.handle;
|
||||
let at = "@".to_owned() + &handle;
|
||||
let e = at.chars().count();
|
||||
let s = 0;
|
||||
if let Ok(base) = c.string_flag("base") {
|
||||
let body = "/egg ".to_owned() + &encode(base.as_bytes());
|
||||
let str = mention::post_request(body.to_string(), at.to_string(), udid.to_string(), s, e.try_into().unwrap()).await;
|
||||
println!("{}",str);
|
||||
}
|
||||
if let Ok(post) = c.string_flag("post") {
|
||||
|
||||
let str = mention::post_request(post.to_string(), at.to_string(), udid.to_string(), s, e.try_into().unwrap()).await;
|
||||
println!("{}",str);
|
||||
}
|
||||
if c.bool_flag("egg") {
|
||||
let did = token_toml(&"did");
|
||||
let body = "/egg ".to_owned() + &encode(did.as_bytes());
|
||||
println!("{}", body);
|
||||
let str = mention::post_request(body.to_string(), at.to_string(), udid.to_string(), s, e.try_into().unwrap()).await;
|
||||
println!("{}",str);
|
||||
}
|
||||
};
|
||||
let res = tokio::runtime::Runtime::new().unwrap().block_on(h);
|
||||
return res
|
||||
}
|
||||
|
||||
fn c_mention(c: &Context) {
|
||||
access_token().unwrap();
|
||||
mention(c);
|
||||
}
|
||||
|
||||
//fn c_ascii_art(_c: &Context) {
|
||||
// c_ascii();
|
||||
//}
|
||||
</code></pre>
|
||||
<pre><code class="lang-sh">cargo build
|
||||
</code></pre>
|
||||
<p>Done.</p>
|
||||
<p>Now, if you specify <code>yui.syui.ai</code> as the <code>mention</code> and use the <code>-e</code> option, it will automatically convert your did to base64 and send it to you.</p>
|
||||
<pre><code class="lang-sh">./target/debug/ai m yui.syui.ai <span class="hljs-_">-e</span>
|
||||
</code></pre>
|
||||
<p>However, this makes it difficult to execute the command.</p>
|
||||
<p>In order to be able to run this command from anywhere, we will put <code>binary</code>, i.e., <code>.ai</code>, which we can do when we <code>cargo build</code>. /target/debug/ai<code>in</code>$PATH`.</p>
|
||||
<div><p class="code-filename">linux</p></div>
|
||||
<pre><code class="lang-sh">$ <span class="hljs-built_in">echo</span> <span class="hljs-variable">$PATH</span>|tr : <span class="hljs-string">'\n'</span>
|
||||
/usr/bin
|
||||
/usr/<span class="hljs-built_in">local</span>/bin
|
||||
|
||||
$ sudo cp -rf ./target/debug/ai /usr/<span class="hljs-built_in">local</span>/bin/
|
||||
$ ai -h
|
||||
|
||||
Name:
|
||||
ai
|
||||
Flags:
|
||||
-h, --help : Show <span class="hljs-built_in">help</span>
|
||||
Commands:
|
||||
b, bluesky :
|
||||
l, login :
|
||||
p, profile :
|
||||
m, mention :
|
||||
</code></pre>
|
||||
<div><p class="code-filename">windows</p></div>
|
||||
<pre><code class="lang-sh"><span class="hljs-variable">$ENV</span>:Path.Split(<span class="hljs-string">";"</span>)
|
||||
C:\Users\syui\scoop\apps\rust\current\bin
|
||||
|
||||
cp ~/scoop/rust/current/bin/
|
||||
ai -h
|
||||
</code></pre>
|
||||
<p>Let's play around with making your own commands with <code>rust</code> like this.</p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="2.html" class="navigation navigation-prev " aria-label="Previous page: mention">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="../end/" class="navigation navigation-next " aria-label="Next page: end">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"base64","level":"1.5.4","depth":2,"next":{"title":"end","level":"1.6","depth":1,"path":"end/README.md","ref":"end/README.md","articles":[]},"previous":{"title":"mention","level":"1.5.3","depth":2,"path":"c4/2.md","ref":"c4/2.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c4/3.md","mtime":"2023-07-31T06:51:05.927Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,498 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>part 4 · hello world! bluesky</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="@gitbook-ng/gitbook 3.3.6">
|
||||
<meta name="author" content="syui">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-codeblock-filename/block.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="0.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="../c3/3.html" />
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
hello world! bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../c1/">
|
||||
|
||||
<a href="../c1/">
|
||||
|
||||
|
||||
part 1
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../c1/1.html">
|
||||
|
||||
<a href="../c1/1.html">
|
||||
|
||||
|
||||
quick start
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2.2" data-path="../c1/2.html">
|
||||
|
||||
<a href="../c1/2.html">
|
||||
|
||||
|
||||
example
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3" data-path="../c2/">
|
||||
|
||||
<a href="../c2/">
|
||||
|
||||
|
||||
part 2
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.3.1" data-path="../c2/1.html">
|
||||
|
||||
<a href="../c2/1.html">
|
||||
|
||||
|
||||
bluesky
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.2" data-path="../c2/2.html">
|
||||
|
||||
<a href="../c2/2.html">
|
||||
|
||||
|
||||
terminal
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.3" data-path="../c2/3.html">
|
||||
|
||||
<a href="../c2/3.html">
|
||||
|
||||
|
||||
shell
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.3.4" data-path="../c2/4.html">
|
||||
|
||||
<a href="../c2/4.html">
|
||||
|
||||
|
||||
rust
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4" data-path="../c3/">
|
||||
|
||||
<a href="../c3/">
|
||||
|
||||
|
||||
part 3
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.4.1" data-path="../c3/1.html">
|
||||
|
||||
<a href="../c3/1.html">
|
||||
|
||||
|
||||
hello world
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.2" data-path="../c3/2.html">
|
||||
|
||||
<a href="../c3/2.html">
|
||||
|
||||
|
||||
seahorse
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.4.3" data-path="../c3/3.html">
|
||||
|
||||
<a href="../c3/3.html">
|
||||
|
||||
|
||||
reqwest
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.5" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
part 4
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.5.1" data-path="0.html">
|
||||
|
||||
<a href="0.html">
|
||||
|
||||
|
||||
ai
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.2" data-path="1.html">
|
||||
|
||||
<a href="1.html">
|
||||
|
||||
|
||||
config
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.3" data-path="2.html">
|
||||
|
||||
<a href="2.html">
|
||||
|
||||
|
||||
mention
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.5.4" data-path="3.html">
|
||||
|
||||
<a href="3.html">
|
||||
|
||||
|
||||
base64
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.6" data-path="../end/">
|
||||
|
||||
<a href="../end/">
|
||||
|
||||
|
||||
end
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >part 4</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h2 id="part-4">part 4</h2>
|
||||
<p>In this chapter, you will write up the RUST code using <code>seahorse</code>, <code>reqwest</code>, and bring the program to completion.</p>
|
||||
<p>bluesky's <a href="https://github.com/bluesky-social/atproto/tree/main/lexicons" target="_blank">lexicons</a> will be important.</p>
|
||||
<p>If you are not sure, please refer to <a href="../c1/">part 1</a>.</p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="../c3/3.html" class="navigation navigation-prev " aria-label="Previous page: reqwest">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="0.html" class="navigation navigation-next " aria-label="Next page: ai">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"part 4","level":"1.5","depth":1,"next":{"title":"ai","level":"1.5.1","depth":2,"path":"c4/0.md","ref":"c4/0.md","articles":[]},"previous":{"title":"reqwest","level":"1.4.3","depth":2,"path":"c3/3.md","ref":"c3/3.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-sharing","codeblock-filename","mermaid-gb3","diff"],"root":"./","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"codeblock-filename":{},"mermaid-gb3":{},"diff":{"type":"markdown","method":"diffChars","options":{}},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"syui","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"hello world! bluesky","gitbook":"*","description":"This is a bluesky ai-card example, and first rust"},"file":{"path":"c4/README.md","mtime":"2023-07-31T07:03:34.953Z","type":"markdown"},"gitbook":{"version":"3.3.6","time":"2023-07-31T07:16:09.509Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
### card
|
||||
|
||||
この書籍の`第一版`にはリアルカードが付属しています。
|
||||
|
||||
全3種類のうち1枚がランダムで当たります。
|
||||
|
||||
|card|%|
|
||||
|---|---|
|
||||
|龍卵|14/20|
|
||||
|青空|5/20|
|
||||
|???|1/20|
|
||||
|
||||
#### ランダムの仕組み
|
||||
|
||||
発送順の数字とカードの数字が紐付けられています。
|
||||
|
||||
この情報は暗号化され公開されています。
|
||||
|
||||
```sh:/card/book_0_public.pem
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIC4TCCAcmgAwIBAgIUS5jY7UgomgdXw17v9c1DPCjFd78wDQYJKoZIhvcNAQEL
|
||||
BQAwADAeFw0yMzA3MjMwOTE1MTVaFw0yMzA4MjIwOTE1MTVaMAAwggEiMA0GCSqG
|
||||
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDJktVVRo5n2GvwwJFSeKGj7tnQsCTDLSpr
|
||||
1Q62zwXh4VsgGjoyo5+2QfXwQourEfDW/up4yG5YrO7m0utc0PF0DQKbsnzeqdkg
|
||||
HWMUAiZGk1qI9QFE9jSs2O+O5+tljHQYxLNhHfcQ+dIF0kUWDpVer0k1t4xc4HjJ
|
||||
xvlUUEfOybMe2D44vLSjMWNcf61yzTkJWuMEn/ICK6/WzhH/1fGqn56F93s/Lo1B
|
||||
lc514Cioa9MMsLFb91wTqNPkoF3QHz4GuOC+DxHz5cKi9TtdztQ33Kh372hU4Lkf
|
||||
VXi8/61aKxLWbaly9UISJLbNgBkyX8pEtZRzwVmm8dVTr5Sh/a7DAgMBAAGjUzBR
|
||||
MB0GA1UdDgQWBBSHTOQhmfrn2ENIjPscI8ZFINFTdTAfBgNVHSMEGDAWgBSHTOQh
|
||||
mfrn2ENIjPscI8ZFINFTdTAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUA
|
||||
A4IBAQAqa8d/wkBWzB6xBgD9GBewnKrstxoLg8K0fcxfIUS1EeBchkdpepeq6UkG
|
||||
blrHjibfPwFJ822oSy71vUTNcPt1Hpdp93xrz7DBD3Q5EdLsgJNH65vDA0KJK9nj
|
||||
UfTYvU4Wt4xL9DxL/WqDsbNFPkNaztGWtZG41nFRKuGj0714e9G3RiImWjO8mFpg
|
||||
OI+/qQKlF6DdDXjuzNJJ7QDZ4gsxg5HqmCc8OjQRWDuVhJrvS4JH2O+4TH591CPA
|
||||
VrSPWuw6kSAbY7iVNXlpAOWM6jGOu37ZEdyhlmYpXGG7SbX2lswUoIqkm8eovjHt
|
||||
RYI2FkFATbwxAdNp9aNFdamFKF+s
|
||||
-----END CERTIFICATE-----
|
||||
```
|
||||
|
||||
<a href="/card/book_0.enc" target="_blank">encrypt</a>
|
||||
|
||||
すべての発送が決まった段階で<a href="/card/book_0_private.pem" target="_blank">秘密鍵</a>が公開され、復号化できるようになります。
|
||||
|
||||
```sh:認証手順
|
||||
pri=book_0_private.pem
|
||||
enc=book_0.enc
|
||||
openssl smime -decrypt -in $enc -binary -inform DEM -inkey $pri
|
||||
```
|
||||
|
||||
```sh:作成手順
|
||||
f=book_0.json
|
||||
pri=book_0_private.pem
|
||||
pub=book_0_public.pem
|
||||
enc=book_0.enc
|
||||
openssl req -x509 -nodes -newkey rsa:2048 -keyout $pri -out $pub -subj '/'
|
||||
openssl smime -encrypt -aes256 -in $f -binary -outform DEM -out $enc $pub
|
||||
openssl smime -decrypt -in $enc -binary -inform DEM -inkey $pri
|
||||
```
|
||||