Codesnug is a web-based repository for storing, organizing, and sharing reusable code snippets. Originally developed as a Master's Degree Final Project, it provides developers with a platform to manage their code knowledge base efficiently.
- Code Snippets Management: Store and organize code snippets with syntax highlighting for 80+ programming languages
- Goals: Group related snippets into "Goals" for better organization
- Workspaces: Create workspaces to organize goals by project or topic
- Tags: Categorize and filter snippets using custom tags
- User Groups: Share workspaces with team members with different permission levels (Admin, Editor, Subscriber)
- Full-Text Search: Powered by Haystack and Whoosh for fast code discovery
- REST API: Access your data programmatically via RESTful endpoints
- User Authentication: Complete registration system with email verification
- Data Export: Download your snippets and goals in various formats
- Internationalization: Available in English and Spanish
- SSL Security: Built-in HTTPS support with security best practices
Codesnug supports syntax highlighting for 80+ programming languages including:
Python, JavaScript, Java, C/C++, C#, Ruby, Go, Rust, PHP, TypeScript, Swift, Kotlin, Scala, Haskell, SQL, HTML, CSS, SASS/SCSS, Markdown, JSON, XML, YAML, Shell/Bash, and many more.
- Backend: Django 1.6
- Database: PostgreSQL
- Search Engine: Haystack with Whoosh backend
- API: Django REST Framework
- Frontend: Bootstrap (Bootflat theme)
- Authentication: django-registration
- Code Editor: ACE Editor
- Python 2.7
- PostgreSQL
- pip
git clone https://github.com/renefs/codesnug.git
cd codesnugvirtualenv venv
source venv/bin/activatepip install -r requirements.txtNote: If
requirements.txtis not present, install the following packages:pip install django==1.6 psycopg2 south django-registration django-bootstrap-breadcrumbs django-widget-tweaks django-uuidfield django-ajax-selectable django-awesome-avatar django-cookielaw django-braces django-recaptcha django-haystack whoosh djangorestframework django-sslserver djangosecure sslify
Create a PostgreSQL database:
createdb codesnugUpdate the database settings in codesnug_project/codesnug/settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'codesnug',
'USER': 'your_username',
'PASSWORD': 'your_password',
'HOST': 'localhost',
'PORT': '5432',
}
}cd codesnug_project
python manage.py syncdb
python manage.py migratepython manage.py rebuild_indexFor HTTPS (recommended):
python manage.py runsslserverOr for HTTP (development only):
python manage.py runserverVisit https://localhost:8000 (or http://localhost:8000 for HTTP) in your browser.
codesnug_project/
├── codesnug/
│ ├── api/ # REST API endpoints
│ ├── goals/ # Goals, Snippets, Workspaces, Tags
│ ├── search/ # Search functionality (Haystack)
│ ├── users/ # User management and authentication
│ ├── templates/ # HTML templates
│ ├── templatetags/ # Custom template filters
│ ├── settings.py # Django settings
│ ├── urls.py # URL routing
│ └── views.py # Main views
├── locale/ # Internationalization files (en, es)
├── static/ # Static assets (CSS, JS, images)
└── manage.py # Django management script
Codesnug provides a RESTful API for programmatic access:
| Endpoint | Method | Description |
|---|---|---|
/api/goals/ |
GET | List all goals |
/api/goals/<uuid> |
GET | Get goal details |
/api/snippets/ |
GET | List all snippets |
/api/snippets/<uuid> |
GET | Get snippet details |
/api/workspaces/ |
GET | List all workspaces |
/api/workspaces/<uuid> |
GET | Get workspace details |
/api/tags/ |
GET | List all tags |
/api/tags/<uuid> |
GET | Get tag details |
/api/users/<username> |
GET | Get user details |
Authentication: All API endpoints require authentication. Use the browsable API at /api-auth/login/ for session-based authentication.
For production, configure the following in settings.py:
# Security
DEBUG = False
SECRET_KEY = 'your-secret-key'
ALLOWED_HOSTS = ['your-domain.com']
# Email (for registration)
EMAIL_HOST = 'smtp.your-provider.com'
EMAIL_HOST_USER = 'your-email'
EMAIL_HOST_PASSWORD = 'your-password'
# reCAPTCHA
RECAPTCHA_PUBLIC_KEY = 'your-public-key'
RECAPTCHA_PRIVATE_KEY = 'your-private-key'- Admin: Full control over workspace
- Editor: Can add and modify content
- Subscriber: Read-only access
cd codesnug_project
python manage.py test goals
python manage.py test users
python manage.py test searchContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
René Fernández - GitHub
- Built with Django
- Code editor powered by ACE Editor
- UI framework: Bootflat
- Search powered by Haystack and Whoosh