Home

Awesome

animeshot2

release badge

An open, portable, searchable image repository with twitter card and telegram bot integration.

(using nodejs + sqlite)

What's New in V2

(v2 however isn't compatible with v1, due to image quality difference and database backend change)

First Time Setup

  1. Have nodejs installed.
  2. Download latest release
  1. Unzip and cd into your folder
  2. Run these commands in order:
  1. Edit the config (see guide below)
  2. Run these commands to start the server
  1. Access localhost or your domain
  2. To actually login and upload images: you need to create a GitHub or Twitter app for OAuth authentication. We recommend starting with GitHub as it's faster.

(we might add a local password login in future, but for now, you need an OAuth provider)

Updating to Latest

  1. Download latest release, and replace all files
  1. npm install
  2. npm run db:migrate
  3. Your site is now up-to-date.

Telegram Bot

  1. Make sure your site is up and running
  2. Apply for a bot with BotFather
  3. Edit the config (see guide below)
  4. npm run bot
  5. Now you should be able to type @yourbot some-text to search the animeshot database
  6. You can also register your domain with BotFather, and use the optional Telegram web login

Other Commands

Site Config

This is the full config with explanation, but since it's just a JSON file, you shouldn't copy this one, instead: cp animeshot-example.json animeshot.json.

{
  "site": {
    "meta": {
      "title": "AnimeShot", // site name
      "owner": "your twitter handle", // twitter handler for twitter card
      "tagline": "your site description", // site description
      "logo": "/images/logo.jpg", // site logo for twitter card
      "lang": "en", // language hint and translations, see i18n.json
      "base_url": "https://your.site.domain", // site domain name
      "version": "r20181016" // only used in static asset cache bursting
    },
    "service": {
      "source": "https://whatanime.ga/?url=", // finding out image origin
      "twitter": "https://twitter.com/intent/tweet?url=" // sharing image
    },
    "server": {
      "ssl_certificate": "/ssl/localhost.crt", // cert file location, see https guide below
      "ssl_key": "/ssl/localhost.key", // key file location, see https guide below
      "http_port": 80, // always redirect to https port, unless has_proxy is true
      "https_port": 443,
      "server_port": 3000, // only used when you set has_proxy to true
      "has_proxy": true // indicate whether server has a reverse proxy
    }
  },
  "cookie": {
    "keys": ["keep this string secret"], // cookie key for signature verification
    "session": {
      "signed": true, // check cookie signature
      "maxAge": 86400000, // cookie expire time
      "key": "animeshot:login" // cookie name
    }
  },
  "oauth": {
    "server": {
      "protocol": "https", // oauth callback protocol
      "host": "your.site.domain", // oauth callback domain
      "callback": "/oauth/callback", // oauth callback route, defined in routes.js
      "transport": "session", // use session for token transport
      "state": true // a random state for added security check
    },
    "twitter": {
      "key": "...apply for a twitter app...", // https://developer.twitter.com/
      "secret": "...apply for a twitter app..."
    },
    "github": {
      "key": "...apply for a github app...", // https://developer.github.com/
      "secret": "...apply for a github app..."
    }
  },
  "bot": {
    "telegram": "...apply for a telegram bot..." // https://telegram.me/BotFather
    "result_count": 10, // how many result to return per search
    "cache_time": 0, // how long to cache response (used by telegram)
    "is_personal": false, // whether to cache response by user (used by telegram)
    "callback": "/bot/callback" // callback route for telegram login
  }
}

OAuth Callback

When you are creating a GitHub or Twitter App for OAuth login, remember to fill in the callback or redirect url as following:

This is not the oauth callback route defined in your site config, and the redirect is actually handled internally by grant.

HTTPS Certificate

Continuous Service

forever

pre_hook = forever stop /full-path/index.js
post_hook = forever start /full-path/index.js

pm2

pre_hook = pm2 stop /full-path/index.js
post_hook = pm2 start /full-path/index.js

License

AGPL-3.0