← BACK

Cosmeta2

HTML ⭐ 0

Cosmeta: Incarnate

A Flask web application designed to host the e-novel "Cosmeta: Incarnate" with features like Discord authentication, role-based access, and chapter management.

Features

  • User authentication via Discord OAuth2
  • Role-based access control (user, supporter, author, admin)
  • Chapter management system
  • User profiles with custom avatars
  • Reading progress tracking
  • Dark/light theme toggle
  • Responsive design

Environment Setup

This application requires several environment variables to function properly. A .env.example file has been included in the repository to show what variables are needed.

Required Environment Variables

Flask and Database Configuration
  • SESSION_SECRET: A secret key for the Flask application
  • Database credentials provided by Replit's PostgreSQL database:
    • DATABASE_URL: Full connection string
    • PGHOST: Database hostname
    • PGDATABASE: Database name
    • PGUSER: Database username
    • PGPASSWORD: Database password
    • PGPORT: Database port
Discord OAuth2 Configuration
  1. Create a Discord application at Discord Developer Portal
  2. Set up OAuth2 with the following settings:
    • Redirect URI: https://your-app-url.replit.app/callback
    • Scopes: identify and guilds
  3. Create a bot for your application if you need role synchronization

Then set these variables:

  • DISCORD_CLIENT_ID: Your Discord application's client ID
  • DISCORD_CLIENT_SECRET: Your Discord application's client secret
  • DISCORD_BOT_TOKEN: Your Discord bot token (for role synchronization)
  • DISCORD_REDIRECT_URI: Callback URL (usually https://your-app-url.replit.app/callback)
  • DISCORD_GUILD_ID: ID of your Discord server for role synchronization
Optional Configuration
  • DISQUS_SHORTNAME: If you want to enable Disqus comments
  • UPLOAD_FOLDER: Path for file uploads (default: static/uploads)
  • MAX_CONTENT_LENGTH: Maximum upload size in bytes (default: 16MB)

Setup Instructions

  1. Copy .env.example to a new file called .secrets.toml in Replit or set environment variables in your hosting environment
  2. Set up a Discord application and bot as described above
  3. Create a PostgreSQL database (automatic in Replit)
  4. Run the application

Running the Application

The application uses Gunicorn as the WSGI server and can be started with:

gunicorn --bind 0.0.0.0:5000 --reuse-port --reload main:app

Role-Based Access

The application has four roles with different permissions:

  1. user: Basic access to read chapters after 24 hours of publication
  2. supporter: Early access to all chapters immediately upon publication
  3. author: Can create, edit, and publish chapters
  4. admin: Full access to all features, including user management

Roles can be synchronized from Discord server roles or manually assigned in the application.

Developer Notes

  • Flask handles the web framework
  • SQLAlchemy manages database interactions
  • Flask-Login handles user sessions
  • Discord OAuth2 handles authentication
  • Bootstrap provides responsive UI components