Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrdoob/glsl-sandbox
Shader editor and gallery.
https://github.com/mrdoob/glsl-sandbox
Last synced: 6 days ago
JSON representation
Shader editor and gallery.
- Host: GitHub
- URL: https://github.com/mrdoob/glsl-sandbox
- Owner: mrdoob
- License: mit
- Created: 2011-11-09T15:29:49.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2024-04-20T15:12:15.000Z (8 months ago)
- Last Synced: 2024-11-29T17:05:16.677Z (13 days ago)
- Language: JavaScript
- Homepage: https://glslsandbox.com/
- Size: 400 KB
- Stars: 1,576
- Watchers: 73
- Forks: 264
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesomeLibrary - glsl-sandbox
README
# glsl-sandbox
## Server development
### Setup
* Fork repository
* Download repository and create new development branch:```
$ git clone [email protected]:/glsl-sandbox
$ cd glsl-sandbox
$ git checkout -b
```* Download and uncompress test data:
```
$ curl -O https://downloads.zooloo.org/glslsandbox-data.tar.gz
$ tar xvf glslsandbox-data.tar.gz
```* Build server binary needs go compiler:
```
$ go build ./server/cmd/glslsandbox
```* Alternatively you can download and uncompress the binary in the repository directory from https://github.com/mrdoob/glsl-sandbox/releases/latest
* Run server:
```
$ ./glslsandbox
```* The first time it starts it creates an admin user and the credentials are printed.
* The server should be accessible on http://localhost:8888
* Admin interface is on http://localhost:8888/admin
### Template and javascript modifications
The server reloads templates and assets on each query. This eases the development as you can modify the files and changes will take effect reloading the page.
There's only one template that is used for both the gallery (index) and admin page. The file is `server/assets/gallery.html` and uses go language templates. You can find more information about its syntax here:
* https://gohugo.io/templates/introduction/
* https://pkg.go.dev/text/template
* https://pkg.go.dev/html/templateCurrently the page receives this data:
```go
// galleryEffect has information about each effect displayed in the gallery.
type galleryEffect struct {
// ID is the effect identifyier.
ID int
// Version is the latest effect version.
Version int
// Image holds the thumbnail name.
Image string
// Hidden tells if the effect has been moderated.
Hidden bool
}// galleryData has information about the current gallery page.
type galleryData struct {
// Effects is an array with all the effects for the page.
Effects []galleryEffect
// URL is the path of the gallery. Can be "/" or "/admin".
URL string
// Page holds the current page number.
Page int
// IsPrevious is true if there is a previous page.
IsPrevious bool
// PreviousPage is the previous page number.
PreviousPage int
// IsNext is true if there is a next page.
IsNext bool
// NextPage is the next page number.
NextPage int
// Admin is true when accessing "/admin" path.
Admin bool
}
```This is, `galleryData` for the page and `galleryEffect` for each effect. For example, to print all the effect IDs you can use:
```html
- {{ .ID }}
{{ range .Effects }}
{{ end }}
```
The following directories are accessible from the server and can be modified if needed:
* `server/assets/css` -> `/css`
* `server/assets/js` -> `/js`
By default the data files are read from `./data`. This path can be hanged with the environment variable `DATA_PATH`. For example:
```
$ DATA_PATH=/my/data/directory ./glslsandbox
```
The data directory contains the sqlite database (`glslsandbox.db`) and the thumbnails (`thumbs` directory).