--- title: TextArchive emoji: 📚 colorFrom: blue colorTo: purple sdk: gradio python_version: "3.11" app_file: app.py pinned: false --- # TextArchive - Universal Text Management System A powerful and intuitive web application for managing all your text-based content with a clear hierarchical structure: **Category → Section → Content Type → Content**. ## 🎯 What is TextArchive? TextArchive is not just a prompt manager - it's a universal system for organizing ANY text-based content: - 💬 Prompts for AI models - 📝 Notes and documentation - 🐍 Code snippets (Python, JavaScript, SQL, etc.) - 📐 LaTeX documents - 💻 Bash scripts - ⚙️ Functions and utilities - 🌐 HTML/CSS templates - 📄 Any other text content ## 📐 Organization Structure Your content is organized in a clear three-level hierarchy: - **Category** (High-level grouping) - e.g., "Coding", "Writing", "Research" - **Section** (Subsection under category) - e.g., "Python", "JavaScript", "Blog Posts" - **Content Type** (What kind of content) - e.g., "python", "note", "prompt", "latex" - **Content** (Your actual text) Example hierarchy: ``` 📁 Coding (Category) └── 📄 Python (Section) └── 🐍 Python Code: "Function to calculate fibonacci..." └── 💬 Prompt: "Write a Python function that..." └── 📄 JavaScript (Section) └── 📜 JavaScript: "React component for login..." 📁 Research (Category) └── 📄 AI Papers (Section) └── 📝 Note: "Summary of transformer architecture..." └── 📐 LaTeX: "\documentclass{article}..." ``` ## ✨ Features ### Core Functionality - ✅ **Add New Items**: Create content with custom categories, sections, and types - 📋 **View All Items**: See all your content organized hierarchically - 🔍 **Auto-Filter**: Filters update automatically (AJAX-style, no search button needed) - 📄 **Easy Copy**: Click any row to preview, then use the copy button to copy just the text content - ✏️ **Edit Items**: Click any item to edit its details - 🗑️ **Delete Items**: Remove items you no longer need - 🎯 **Fixed Height Table**: Scrollable table maintains consistent size - 💾 **Persistent Storage**: SQLite database stores all your data ### Advanced Management - 🔄 **Rename Categories**: Rename categories and automatically update all items - 🔄 **Rename Sections**: Rename sections across all categories or within a specific category - 🗑️ **Bulk Delete**: Delete entire categories or sections at once (with confirmation) - 📊 **Statistics**: View insights about your content collection - 🏷️ **11 Content Types**: Prompt, Note, Python, JavaScript, LaTeX, SQL, Bash, Function, HTML, CSS, Other ### Smart UX - 🎯 **Filtered Dropdowns**: Section dropdown automatically filters by selected category - 🔄 **Auto-Refresh**: All dropdowns update automatically after changes - ⚠️ **Confirmation Dialogs**: Destructive actions require confirmation - 📦 **Auto-Generated Titles**: Leave title empty to auto-generate from content - 🎨 **Type Icons**: Visual icons for each content type ## 🚀 How to Use ### Adding Content 1. Go to the "➕ Add New Item" tab 2. Select or type a **Category** (high-level grouping) 3. Select or type a **Section** (subsection - dropdown auto-filters by category) 4. Choose **Content Type** (prompt, note, python, etc.) 5. (Optional) Enter a **Title** or leave empty for auto-generation 6. Enter your **Content** 7. Click "Add Item" ### Viewing and Filtering Content 1. Go to the "📋 View & Manage Items" tab 2. Use filters to narrow down items: - **Filter by Category**: Auto-updates table - **Filter by Section**: Auto-updates table (filtered by category) - **Filter by Type**: Auto-updates table 3. Click "Clear Filters" to reset ### Copying Content 1. In the "View & Manage Items" tab, click on any row in the table 2. The content appears in the **Content Preview** box below 3. Click the **copy button** (📋) in the preview box, OR 4. Click in the text box and press Ctrl+A (select all), then Ctrl+C (copy) 5. Only the text content is copied - NO ID, category, or section included! ### Editing Content 1. Click on a row in the table to load it 2. The item loads in the editing section below 3. Modify Category, Section, Type, Title, or Content as needed 4. Click "💾 Update Item" to save changes ### Deleting Content 1. Click on a row to select it 2. Click the "🗑️ Delete Item" button 3. The item will be removed immediately ### Managing Categories & Sections 1. Go to the "⚙️ Manage Categories & Sections" tab **Rename Category:** - Select the category to rename - Enter new name - Click "🔄 Rename Category" - All items in that category will be updated **Rename Section:** - (Optional) Select a category to limit scope - Select the section to rename - Enter new name - Click "🔄 Rename Section" **Delete Category:** - Select the category - Check the confirmation box - Click "🗑️ Delete Category" - ALL items in that category will be deleted **Delete Section:** - (Optional) Select a category to limit scope - Select the section - Check the confirmation box - Click "🗑️ Delete Section" ### Viewing Statistics 1. Go to the "📊 Statistics" tab 2. View total counts, top categories, and breakdown by type 3. Click "🔄 Refresh Statistics" to update ## 🎨 Content Types TextArchive supports 11 content types, each with its own icon and file extension: | Type | Icon | Extension | Use For | |------|------|-----------|---------| | prompt | 💬 | .txt | AI prompts and instructions | | note | 📝 | .md | Notes and documentation | | python | 🐍 | .py | Python code and scripts | | javascript | 📜 | .js | JavaScript code | | latex | 📐 | .tex | LaTeX documents | | sql | 🗄️ | .sql | SQL queries and scripts | | bash | 💻 | .sh | Bash shell scripts | | function | ⚙️ | .txt | Reusable functions | | html | 🌐 | .html | HTML markup | | css | 🎨 | .css | CSS stylesheets | | other | 📄 | .txt | Any other text content | ## 🔧 Technical Details - **Framework**: Gradio 4.44.0+ - **Database**: SQLite (automatically created as `textarchive.db`) - **Python**: 3.8+ - **Auto-Migration**: Automatically migrates from old `prompts.db` if exists ## 📊 Database Schema ```sql CREATE TABLE text_items ( id INTEGER PRIMARY KEY AUTOINCREMENT, category TEXT NOT NULL, section TEXT NOT NULL, title TEXT NOT NULL, content TEXT NOT NULL, content_type TEXT DEFAULT 'prompt', file_extension TEXT DEFAULT '.txt', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); ``` Indexes are created on `category`, `section`, and `content_type` for optimal performance. ## 🚀 Deployment to Hugging Face Spaces ### Method 1: Direct Upload 1. Create a new Space on Hugging Face: - Go to https://huggingface.co/new-space - Choose "Gradio" as the SDK - Set visibility (Public or Private) 2. Upload these files to your Space: - `app.py` - `requirements.txt` - `README.md` (optional) 3. Your app will automatically deploy! ### Method 2: Git (With Your Sync Script) 1. Initialize your local repository: ```bash git init git add . git commit -m "Initial commit" ``` 2. Add remotes: ```bash # Add GitHub remote git remote add github https://github.com/YOUR_USERNAME/textarchive.git # Add Hugging Face remote git remote add huggingface https://huggingface.co/spaces/YOUR_USERNAME/textarchive ``` 3. Use your sync script: ```powershell # Set your Hugging Face token $env:HF_TOKEN = "your_hf_token_here" # Run sync .\sync.ps1 "Initial deployment" ``` ## 🔄 Migration from Old "Prompt Manager" If you have an existing `prompts.db` from the old Prompt Manager: 1. **Automatic Migration**: Just run the new app - it will automatically: - Detect the old `prompts.db` - Create the new `textarchive.db` schema - Migrate all your data - Set content_type to "prompt" for all old items - Generate titles from the first 50 characters 2. **Manual Backup** (Recommended): ```bash # Backup your old database first cp prompts.db prompts.db.backup ``` 3. **Verify Migration**: - Open the app - Go to Statistics tab - Check that all items were migrated - Check a few items to ensure content is intact ## 📝 Notes - The database file persists between sessions - All users share the same database (unless you add authentication) - Backup your `textarchive.db` file regularly - Section dropdowns auto-filter by selected category for better UX - Auto-filtering eliminates the need for a search button - Fixed-height table with scrolling maintains clean interface ## 🎯 Use Cases ### For Developers - Store code snippets and functions - Organize SQL queries by project - Keep bash scripts and automation tools - Document API endpoints ### For Writers - Organize story prompts and ideas - Store article outlines - Keep writing templates - Manage blog post drafts ### For Researchers - Store LaTeX document snippets - Organize research notes by topic - Keep citation templates - Document methodologies ### For AI/ML Engineers - Organize prompts by use case - Store fine-tuning examples - Document model configurations - Keep evaluation templates ## 🔮 Future Enhancements (Suggestions) - Export individual items as files - Export category/section as ZIP - Import from files/folders - Tags system for cross-category organization - Full-text search within content - Syntax highlighting in preview - Markdown rendering for notes - Version history for items - User authentication for private libraries - API access for programmatic usage - Favorites/bookmarks - Sharing capabilities ## 📜 License MIT License - Feel free to modify and use as needed! ## 🤝 Contributing Contributions are welcome! Please feel free to submit issues or pull requests. --- **Built with ❤️ using Gradio and SQLite**