TextArchive / README.md
mnoorchenar's picture
Local changes before HF merge
578f8ce

A newer version of the Gradio SDK is available: 6.5.1

Upgrade
metadata
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

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:

  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:

    git init
    git add .
    git commit -m "Initial commit"
    
  2. Add remotes:

    # 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:

    # 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):

    # 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