Files
obsidian_ollama/install.sh
T
fegger 810676ff21 feat: add Ollama icon and modern chat UI styling
- src/chat-view.ts: Add getIcon() returning 'bot' for the view tab icon.
  Improve render() with role-specific CSS classes (user vs assistant) and
  message header structure for better styling hooks.

- src/main.ts: Add ribbon icon ('bot') in the left sidebar that opens the
  chat view with a single click.

- styles.css (new): Modern chat UI with message bubbles, distinct user and
  assistant themes using Obsidian CSS variables, sticky input bar, styled
  send button with accent color, and emoji role indicators.

- install.sh: Copy styles.css into the plugin directory and verify its
  presence during installation.

- README.md: Include styles.css in manual install instructions.

- __mocks__/obsidian.ts: Add addRibbonIcon() mock for test compatibility.

- tests/chat-view.test.ts: Add getIcon() assertion.
2026-05-19 21:18:56 +02:00

132 lines
4.5 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# install.sh — Install the Ollama Plugin into an Obsidian vault
#
# Usage:
# ./install.sh /path/to/your/vault
#
# The script will:
# 1. Install npm dependencies (excluding Ollama itself — you need that separately)
# 2. Compile the TypeScript plugin
# 3. Copy the built plugin into <vault>/.obsidian/plugins/ollama-plugin/
#
# Prerequisites:
# - Node.js and npm
# - Ollama installed and running (https://ollama.ai)
#
set -euo pipefail
# ── Helpers ──────────────────────────────────────────────────────────────────
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BOLD='\033[1m'
NC='\033[0m' # No Color
info() { printf "${GREEN}${NC} %s\n" "$1"; }
warn() { printf "${YELLOW}${NC} %s\n" "$1"; }
error() { printf "${RED}${NC} %s\n" "$1"; }
step() { printf "\n${BOLD}══ %s ══${NC}\n" "$1"; }
# ── Argument validation ──────────────────────────────────────────────────────
VAULT_PATH="${1:-}"
if [ -z "$VAULT_PATH" ]; then
echo "Usage: ./install.sh /path/to/your/vault"
echo ""
echo " Provide the path to your Obsidian vault directory."
echo " The plugin will be installed into <vault>/.obsidian/plugins/ollama-plugin/"
exit 1
fi
if [ ! -d "$VAULT_PATH" ]; then
error "Vault directory does not exist: $VAULT_PATH"
exit 1
fi
if [ ! -d "$VAULT_PATH/.obsidian" ]; then
warn "No .obsidian folder found in $VAULT_PATH — this may not be a valid Obsidian vault."
warn "Continuing anyway, but the plugin may not load."
fi
PLUGIN_DIR="$VAULT_PATH/.obsidian/plugins/ollama-plugin"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# ── Check prerequisites ──────────────────────────────────────────────────────
step "Checking prerequisites"
if ! command -v node &> /dev/null; then
error "Node.js is required but not found. Install it from https://nodejs.org"
exit 1
fi
info "Node.js $(node --version)"
if ! command -v npm &> /dev/null; then
error "npm is required but not found."
exit 1
fi
info "npm $(npm --version)"
# ── Install dependencies ─────────────────────────────────────────────────────
step "Installing npm dependencies"
cd "$SCRIPT_DIR"
npm install
info "Dependencies installed"
# ── Build ────────────────────────────────────────────────────────────────────
step "Building the plugin"
npm run build
info "Build complete"
# ── Install into vault ───────────────────────────────────────────────────────
step "Installing into vault"
mkdir -p "$PLUGIN_DIR"
# Remove old dist/ directory from previous installations (no longer needed with bundling)
rm -rf "$PLUGIN_DIR/dist"
# Copy manifest, bundled entry point, and styles
cp "$SCRIPT_DIR/manifest.json" "$PLUGIN_DIR/"
cp "$SCRIPT_DIR/main.js" "$PLUGIN_DIR/"
cp "$SCRIPT_DIR/styles.css" "$PLUGIN_DIR/"
# All dependencies are now bundled into main.js; no runtime node_modules needed.
info "Plugin installed to $PLUGIN_DIR"
# ── Verify ────────────────────────────────────────────────────────────────────
step "Verifying installation"
if [ -f "$PLUGIN_DIR/manifest.json" ] && [ -f "$PLUGIN_DIR/main.js" ] && [ -f "$PLUGIN_DIR/styles.css" ]; then
info "manifest.json ✓"
info "main.js ✓"
info "styles.css ✓"
else
error "Installation verification failed — missing files in $PLUGIN_DIR"
exit 1
fi
echo ""
echo " ${GREEN}${BOLD}Done!${NC} The plugin has been installed."
echo ""
echo " Next steps:"
echo " 1. Restart Obsidian (or reload plugins: Ctrl+Shift+P → 'Reload app without saving')"
echo " 2. Go to Settings → Community plugins → enable 'Ollama Plugin'"
echo " 3. Configure the plugin: Settings → Ollama Settings"
echo ""
echo " Make sure Ollama is running:"
echo " ollama serve"
echo " ollama pull llama3 (or your preferred model)"
echo ""