1
0
mirror of https://github.com/owenthereal/jqplay.git synced 2025-04-19 06:02:17 +03:00

Embed assets

This commit is contained in:
Owen Ou 2022-05-11 23:44:15 -07:00
parent e99aba7aef
commit b1cf816fd1
No known key found for this signature in database
GPG Key ID: 6CDA9490BEB1E446
19 changed files with 1690 additions and 4204 deletions

View File

@ -1,3 +0,0 @@
{
"directory" : "public/bower_components"
}

5
.gitignore vendored
View File

@ -1,9 +1,6 @@
gin-bin
node_modules
public/bower_components
public/css
public/js
public/index.tmpl
/public
assets/tmp
.env
*.c.out

View File

@ -1,13 +0,0 @@
sudo: false
language: go
go:
- 1.11.1
env:
- TRAVIS_NODE_VERSION="7"
install:
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
script:
- bin/build
- bin/test
notifications:
email: false

View File

@ -1,6 +1,6 @@
module.exports = function(grunt) {
grunt.loadTasks('tasks');
grunt.registerTask('build', "Builds the application.",
['clean', 'concat', 'cssmin', 'uglify', 'replace']);
['clean', 'concat', 'cssmin', 'copy', 'uglify', 'replace']);
grunt.option('ts', new Date().getTime());
}

View File

@ -3,8 +3,8 @@ SHELL=/bin/bash -o pipefail
GOBIN ?= $(CURDIR)/build
.PHONY: build
build:
yarn
go build -o $(GOBIN)/jqplay ./cmd/jqplay
npm install
.PHONY: test
test:

BIN
assets/images/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
assets/images/logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -160,7 +160,7 @@
<footer class="footer">
<hr>
<p><a href="https://github.com/jingweno/jqplay">View source</a> on GitHub</p>
<p><a href="https://github.com/owenthereal/jqplay">View source</a> on GitHub</p>
</footer>
<!-- Bootstrap core JavaScript

2
assets/robots.txt Normal file
View File

@ -0,0 +1,2 @@
User-agent: *
Allow: /

View File

@ -1,9 +0,0 @@
{
"name": "jqplay",
"version": "0.0.0",
"dependencies": {
"angular": "1.6.6",
"bootstrap": "3.3.7",
"angular-ui-ace": "0.2.3"
}
}

6
embed.go Normal file
View File

@ -0,0 +1,6 @@
package jqplay
import "embed"
//go:embed all:public
var PublicFS embed.FS

4149
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -22,9 +22,17 @@
"grunt-contrib-cssmin": "^3.0.0",
"grunt-contrib-uglify": "^2.0.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-text-replace": "^0.4.0"
"grunt-text-replace": "^0.4.0",
"@bower_components/ace-builds": "ajaxorg/ace-builds#^1",
"@bower_components/angular": "angular/bower-angular#1.6.6",
"@bower_components/angular-ui-ace": "angular-ui/ui-ace#0.2.3",
"@bower_components/bootstrap": "twbs/bootstrap#3.3.7",
"@bower_components/jquery": "jquery/jquery-dist#1.9.1 - 3"
},
"scripts": {
"postinstall": "bower install && rm -rf public/bower_components/ace-builds/demo/kitchen-sink/docs && grunt build"
"postinstall": "node -e \"try { require('fs').symlinkSync(require('path').resolve('node_modules/@bower_components'), 'public/bower_components', 'junction') } catch (e) { }\" && grunt build"
},
"engines": {
"yarn": ">= 1.0.0"
}
}

View File

@ -23,7 +23,7 @@ type JQHandlerContext struct {
}
func (c *JQHandlerContext) Asset(path string) string {
return fmt.Sprintf("%s/%s", c.AssetHost, path)
return fmt.Sprintf("%s/assets/public/%s", c.AssetHost, path)
}
func (c *JQHandlerContext) ShouldInitJQ() bool {

View File

@ -9,6 +9,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/oklog/run"
"github.com/owenthereal/jqplay"
"github.com/owenthereal/jqplay/config"
"github.com/owenthereal/jqplay/server/middleware"
log "github.com/sirupsen/logrus"
@ -71,13 +72,7 @@ func newHTTPServer(cfg *config.Config, db *DB) (*http.Server, error) {
)
router.SetHTMLTemplate(tmpl)
router.Static("/js", "public/js")
router.Static("/css", "public/css")
router.Static("/images", "public/images")
router.Static("/fonts", "public/bower_components/bootstrap/dist/fonts")
router.StaticFile("/worker-xquery.js", "public/bower_components/ace-builds/src-min-noconflict/worker-xquery.js")
router.StaticFile("/robots.txt", "public/robots.txt")
router.StaticFS("/assets", http.FS(jqplay.PublicFS))
router.GET("/", h.handleIndex)
router.GET("/jq", h.handleJqGet)
router.POST("/jq", h.handleJqPost)

View File

@ -1,7 +1,6 @@
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.config('clean', {
js: [ 'public/js/*.js' ],
css: [ 'public/css/*.css' ]
pubic: [ 'public/*' ]
});
}

View File

@ -3,19 +3,19 @@ module.exports = function(grunt) {
grunt.config('concat', {
css: {
src: [
'public/bower_components/bootstrap/dist/css/bootstrap.css',
'node_modules/@bower_components/bootstrap/dist/css/bootstrap.css',
'assets/css/app.css'
],
dest: 'assets/tmp/app.css'
},
js: {
src: [
'public/bower_components/ace-builds/src-noconflict/ace.js',
'public/bower_components/ace-builds/src-noconflict/ext-searchbox.js',
'public/bower_components/ace-builds/src-noconflict/theme-github.js',
'public/bower_components/ace-builds/src-noconflict/mode-jsoniq.js',
'public/bower_components/angular/angular.js',
'public/bower_components/angular-ui-ace/ui-ace.js',
'node_modules/@bower_components/ace-builds/src-noconflict/ace.js',
'node_modules/@bower_components/ace-builds/src-noconflict/ext-searchbox.js',
'node_modules/@bower_components/ace-builds/src-noconflict/theme-github.js',
'node_modules/@bower_components/ace-builds/src-noconflict/mode-jsoniq.js',
'node_modules/@bower_components/angular/angular.js',
'node_modules/@bower_components/angular-ui-ace/ui-ace.js',
'assets/js/app.js',
'assets/js/controllers.js',
'assets/js/services.js',

View File

@ -1,14 +1,19 @@
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.config('copy', {
scripts: {
fonts: {
files: [
{expand: true, flatten: true, src: 'assets/tmp/**/*.js', dest: 'public/js/'}
{expand: true, flatten: true, src: 'node_modules/@bower_components/bootstrap/dist/fonts/*.*', dest: 'public/fonts/'}
]
},
css: {
images: {
files: [
{expand: true, flatten: true, src: 'assets/css/**/*.css', dest: 'public/css/'}
{expand: true, flatten: true, src: 'assets/images/*.*', dest: 'public/images/'}
]
},
"robot.txt": {
files: [
{expand: true, flatten: true, src: 'assets/robots.txt', dest: 'public/'}
]
}
});

1648
yarn.lock Normal file

File diff suppressed because it is too large Load Diff