Skip to content

ignacio/luarocks-site

 
 

Repository files navigation

LuaRocks.org

http://luarocks.org

A webpage for hosting and serving Lua modules.

This was formerly called MoonRocks, but has since taken over as the official LuaRocks website. This naming history is apparent in its implementation.

The entire site runs on OpenResty, an Nginx based platform with Lua support. The site itself is coded in MoonScript and uses Lapis as a web framework.

Files are stored on Google Cloud Storage. PostgreSQL is used as a database.

Tup is the build system.

How To Run Locally

This is a bit complicated, tell me if you are doing this and I'll assist you.

Install sassc. (Optionally you can install SASS but you'll need to modify a Tupfile)

Install coffeescript.

Install discount (or something that provides markdown binary).

Install PostgreSQL. Create a database called moonrocks.

Install OpenResty.

Install Redis.

Check out this repository.

Install the dependencies listed in https://github.com/leafo/moonrocks-site/blob/master/BoxFile.

If you use MoonBox then you can install all of the files in one go:

moonbox install
source moonbox env enter

Run these commands to build.

tup init
tup upd

Create the schema:

make init_schema

Start the server:

lapis server

Now http://localhost:8080 should load.

Running tests

This site uses Busted for its tests:

make test_db
busted

The make test_db command will copy the schema of the moonrocks local database into the test database, wiping out what whatever was there. You'll only need to run this command once and the beginning any any time the schema has changed.

Setting up Google Cloud Storage

In production all files are stored on Google Cloud Storage. With no configuration (default), files are stored on the file system using the storage bucket mock provided by the cloud_storage rock.

To configure cloud_storage to talk to a live bucket make a file secret/storage_bucket.moon, it must return a bucket instance. It might look something like:

-- secret/storage_bucket.moon
import OAuth from require "cloud_storage.oauth"
import CloudStorage from require "cloud_storage.google"

o = OAuth "NUMBER@developer.gserviceaccount.com", "PRIVATEKEY.pem"
CloudStorage(o, "PROJECT_ID")\bucket "BUCKET_NAME"

Setting up email

If you want to test sending emails you'll have to provide Mailgun credentials. A test account is free. Create a file secret/email.moon and make it look something like this: (it must return a table of options)

{ -- secret/email.moon
  key: "api:key-MY_KEY"
  domain: "mydomain.mailgun.org"
  sender: "MoonRocks <postmaster@mydomain.mailgun.org>"
}

Why Tup?

Tup has a filesystem monitor, it can rebuild any assets or moon files automatically as you change them. Better than running individual watch scripts for each component.

To use it run:

tup monitor -a -f

About

a website for submitting and hosting lua rocks

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • MoonScript 78.4%
  • Lua 9.3%
  • CSS 7.3%
  • Nginx 2.2%
  • CoffeeScript 1.9%
  • Makefile 0.6%
  • Shell 0.3%