Skip to content

Commit 13a9813

Browse files
committed
Add README.md with project overview, features, usage instructions, and API documentation
1 parent daa2b23 commit 13a9813

File tree

1 file changed

+271
-0
lines changed

1 file changed

+271
-0
lines changed

README.md

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
# ClipShare
2+
3+
A minimalist online clipboard for sharing text and files with temporary access codes.
4+
5+
## Features
6+
7+
- **Text Sharing**: Share text content with syntax highlighting for various programming languages
8+
- **File Upload**: Upload and share multiple files (images, documents, code files, etc.)
9+
- **Temporary Access**: Content expires automatically (configurable expiration time)
10+
- **Access Codes**: Simple 4-digit numeric codes for easy sharing
11+
- **File Download**: Download individual files or all files as a ZIP archive
12+
- **Image Preview**: Built-in image viewing for common image formats
13+
- **Syntax Highlighting**: Automatic language detection and syntax highlighting for code files
14+
- **Clean UI**: Minimalist, responsive web interface
15+
16+
## Supported File Types
17+
18+
### Programming Languages (with syntax highlighting)
19+
- JavaScript (`.js`)
20+
- Python (`.py`)
21+
- Java (`.java`)
22+
- C# (`.cs`)
23+
- C++ (`.cpp`, `.c`)
24+
- HTML (`.html`)
25+
- CSS (`.css`)
26+
- JSON (`.json`)
27+
- XML (`.xml`)
28+
- Markdown (`.md`)
29+
- SQL (`.sql`)
30+
- Bash (`.sh`)
31+
- Plain text (`.txt`)
32+
33+
### Image Formats
34+
- JPEG (`.jpg`, `.jpeg`)
35+
- PNG (`.png`)
36+
- GIF (`.gif`)
37+
- BMP (`.bmp`)
38+
- WebP (`.webp`)
39+
- SVG (`.svg`)
40+
41+
## Quick Start
42+
43+
### Using Docker (Recommended)
44+
45+
1. Clone the repository:
46+
```bash
47+
git clone <repository-url>
48+
cd clip-rewrite
49+
```
50+
51+
2. Run with Docker Compose:
52+
```bash
53+
docker-compose up -d
54+
```
55+
56+
The application will be available at `http://localhost:8000`.
57+
58+
### Manual Installation
59+
60+
1. **Prerequisites**:
61+
- Python 3.9+
62+
- pip
63+
64+
2. **Install dependencies**:
65+
```bash
66+
pip install -r requirements.txt
67+
```
68+
69+
3. **Initialize database**:
70+
```bash
71+
python init_db.py
72+
```
73+
74+
4. **Run the application**:
75+
```bash
76+
python main.py
77+
```
78+
79+
The application will be available at `http://localhost:8000`.
80+
81+
## Usage
82+
83+
### Creating a Clip
84+
85+
1. **Via Web Interface**:
86+
- Visit the homepage
87+
- Paste text or upload files
88+
- Set expiration time (default: 24 hours)
89+
- Click "Create Clip"
90+
- Save the 4-digit access code
91+
92+
2. **Via API**:
93+
```bash
94+
# Text content
95+
curl -X POST "http://localhost:8000/api/clips" \
96+
-F "content=Your text here" \
97+
-F "expiration_hours=24"
98+
99+
# File upload
100+
curl -X POST "http://localhost:8000/api/clips" \
101+
-F "files=@example.txt" \
102+
-F "expiration_hours=48"
103+
```
104+
105+
### Accessing a Clip
106+
107+
1. **Via Web Interface**:
108+
- Go to `/retrieve`
109+
- Enter the 4-digit access code
110+
- View or download content
111+
112+
2. **Via API**:
113+
```bash
114+
# Get clip info
115+
curl "http://localhost:8000/api/clips/1234"
116+
117+
# Download file
118+
curl "http://localhost:8000/api/clips/1234/download"
119+
120+
# Download all files as ZIP
121+
curl "http://localhost:8000/api/clips/1234/download?download_all=true"
122+
```
123+
124+
## API Endpoints
125+
126+
### POST `/api/clips`
127+
Create a new clip with text content or files.
128+
129+
**Parameters**:
130+
- `content` (optional): Text content
131+
- `language` (optional): Programming language for syntax highlighting
132+
- `expiration_hours` (optional, default: 24): Hours until expiration
133+
- `files` (optional): Multiple files to upload
134+
135+
**Response**:
136+
```json
137+
{
138+
"access_code": "1234",
139+
"content": "Your text here",
140+
"language": "python",
141+
"filename": null,
142+
"filenames": null,
143+
"created_at": "2025-05-26T10:00:00",
144+
"expires_at": "2025-05-27T10:00:00",
145+
"is_file": false,
146+
"is_image": false
147+
}
148+
```
149+
150+
### GET `/api/clips/{access_code}`
151+
Retrieve clip information.
152+
153+
### GET `/api/clips/{access_code}/download`
154+
Download clip files.
155+
156+
**Query Parameters**:
157+
- `filename` (optional): Download specific file
158+
- `download_all` (optional): Download all files as ZIP
159+
- `as_text` (optional): Force download as text file
160+
161+
## Configuration
162+
163+
### Environment Variables
164+
165+
- `HOST`: Server host (default: `0.0.0.0`)
166+
- `PORT`: Server port (default: `8000`)
167+
- `RELOAD`: Enable auto-reload for development (default: `true`)
168+
169+
### Docker Configuration
170+
171+
The application can be configured via environment variables in `docker-compose.yml`:
172+
173+
```yaml
174+
environment:
175+
- HOST=0.0.0.0
176+
- PORT=8000
177+
- RELOAD=false
178+
```
179+
180+
## File Storage
181+
182+
- Files are stored in the `uploads/` directory
183+
- Each clip gets its own subdirectory named after the access code
184+
- Database stores metadata and file paths
185+
- Files are automatically cleaned up when clips expire
186+
187+
## Database
188+
189+
The application uses SQLite by default with the following schema:
190+
191+
**Clips Table**:
192+
- `id`: Primary key
193+
- `access_code`: 4-digit unique code
194+
- `content`: Text content
195+
- `filename`: Single filename (legacy)
196+
- `filenames`: Comma-separated list of filenames
197+
- `file_path`: Path to file storage
198+
- `language`: Programming language for syntax highlighting
199+
- `created_at`: Creation timestamp
200+
- `expires_at`: Expiration timestamp
201+
- `is_file`: Boolean flag for file uploads
202+
- `is_image`: Boolean flag for image files
203+
204+
## Development
205+
206+
### Project Structure
207+
208+
```
209+
clip-rewrite/
210+
├── app/
211+
│ ├── __init__.py # FastAPI app factory
212+
│ ├── models/
213+
│ │ ├── clip.py # Database model
214+
│ │ ├── database.py # Database configuration
215+
│ │ └── schemas.py # Pydantic schemas
216+
│ ├── routers/
217+
│ │ ├── clips.py # API endpoints
218+
│ │ └── pages.py # Web pages
219+
│ ├── static/ # CSS, JS assets
220+
│ └── templates/ # Jinja2 templates
221+
├── uploads/ # File storage
222+
├── main.py # Application entry point
223+
├── init_db.py # Database initialization
224+
├── requirements.txt # Python dependencies
225+
└── docker-compose.yml # Docker configuration
226+
```
227+
228+
### Running in Development Mode
229+
230+
```bash
231+
# Enable auto-reload
232+
export RELOAD=true
233+
python main.py
234+
```
235+
236+
### Adding New Features
237+
238+
1. **Database Changes**: Update `app/models/clip.py` and run migrations
239+
2. **API Endpoints**: Add routes in `app/routers/clips.py`
240+
3. **Web Pages**: Add templates in `app/templates/` and routes in `app/routers/pages.py`
241+
4. **Frontend**: Update templates and static assets
242+
243+
## Dependencies
244+
245+
- **FastAPI**: Web framework
246+
- **SQLAlchemy**: Database ORM
247+
- **Jinja2**: Template engine
248+
- **Uvicorn**: ASGI server
249+
- **Pydantic**: Data validation
250+
- **python-multipart**: File upload support
251+
- **aiofiles**: Async file operations
252+
- **Pygments**: Syntax highlighting
253+
254+
## License
255+
256+
This project is open source. Please check the license file for details.
257+
258+
## Contributing
259+
260+
1. Fork the repository
261+
2. Create a feature branch
262+
3. Make your changes
263+
4. Add tests if applicable
264+
5. Submit a pull request
265+
266+
## Support
267+
268+
For issues and questions:
269+
- Check existing issues in the repository
270+
- Create a new issue with detailed information
271+
- Include logs and error messages when reporting bugs

0 commit comments

Comments
 (0)