Giter Site home page Giter Site logo

34ruby / glsl-sandbox Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mrdoob/glsl-sandbox

0.0 0.0 0.0 392 KB

Shader editor and gallery.

Home Page: https://glslsandbox.com/

License: MIT License

Shell 0.03% JavaScript 65.22% Go 19.17% CSS 1.23% HTML 14.23% Dockerfile 0.12%

glsl-sandbox's Introduction

glsl-sandbox

Server development

Setup

  • Fork repository
  • Download repository and create new development branch:
$ git clone [email protected]:<your user>/glsl-sandbox
$ cd glsl-sandbox
$ git checkout -b <feature name>
  • 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
$ ./glslsandbox

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:

Currently the page receives this data:

// 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:

<ul>
{{ range .Effects }}
    <li>{{ .ID }}</li>
{{ end }}
<ul>

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).

glsl-sandbox's People

Contributors

jfontan avatar mrdoob avatar emackey avatar kusma avatar dependabot[bot] avatar alteredq avatar edne avatar spongman avatar 983 avatar adammw avatar greggman avatar lj1102 avatar jdm avatar jolivain avatar tmcw avatar kaneta1992 avatar monsieurbadia avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.