docker: avoid rebuilding CSS/JS assets on every commit.
Restructure the Dockerfile and the CSS/JS files so that we only rebuild the CSS and JS when they change, not on every commit. Before it took several minutes to rebuild the Docker image after every commit, even when the JS/CSS files didn't change. This also made pulling images slower. This requires refactoring the CSS and JS to not use embedded Ruby (ERB) templates, since this made the CSS and JS dependent on the Ruby codebase, which is why we had to rebuild the assets after every Ruby change.
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
let Autocomplete = {};
|
||||
|
||||
/* eslint-disable */
|
||||
Autocomplete.TAG_CATEGORIES = <%= TagCategory.mapping.to_json.html_safe %>;
|
||||
/* eslint-enable */
|
||||
|
||||
Autocomplete.TAG_PREFIXES = "-|~|" + Object.keys(Autocomplete.TAG_CATEGORIES).map(category => category + ":").join("|");
|
||||
Autocomplete.MAX_RESULTS = 10;
|
||||
|
||||
Autocomplete.initialize_all = function() {
|
||||
@@ -117,7 +112,7 @@ Autocomplete.insert_completion = function(input, completion) {
|
||||
var before_caret_text = input.value.substring(0, input.selectionStart).replace(/^[ \t]+|[ \t]+$/gm, "");
|
||||
var after_caret_text = input.value.substring(input.selectionStart).replace(/^[ \t]+|[ \t]+$/gm, "");
|
||||
|
||||
var regexp = new RegExp("(" + Autocomplete.TAG_PREFIXES + ")?\\S+$", "g");
|
||||
var regexp = new RegExp("(" + Autocomplete.tag_prefixes().join("|") + ")?\\S+$", "g");
|
||||
before_caret_text = before_caret_text.replace(regexp, "$1") + completion + " ";
|
||||
|
||||
input.value = before_caret_text + after_caret_text;
|
||||
@@ -208,6 +203,10 @@ Autocomplete.autocomplete_source = function(query, type) {
|
||||
});
|
||||
}
|
||||
|
||||
Autocomplete.tag_prefixes = function() {
|
||||
return JSON.parse($("meta[name=autocomplete-tag-prefixes]").attr("content"));
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
Autocomplete.initialize_all();
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import Post from './posts.js.erb'
|
||||
import Post from './posts.js'
|
||||
import Utility from './utility'
|
||||
|
||||
let PostModeMenu = {};
|
||||
|
||||
@@ -3,8 +3,6 @@ import SparkMD5 from 'spark-md5';
|
||||
|
||||
let Upload = {};
|
||||
|
||||
Upload.MAX_FILE_SIZE_BYTES = <%= Danbooru.config.max_file_size.to_json %>;
|
||||
Upload.MAX_FILE_SIZE = Upload.MAX_FILE_SIZE_BYTES / (1024 * 1024);
|
||||
Upload.IQDB_LIMIT = 5;
|
||||
Upload.IQDB_MIN_SIMILARITY = 50;
|
||||
Upload.IQDB_HIGH_SIMILARITY = 70;
|
||||
@@ -183,8 +181,8 @@ Upload.initialize_dropzone = function() {
|
||||
thumbnailMethod: "contain",
|
||||
addRemoveLinks: false,
|
||||
maxFiles: 1,
|
||||
maxFilesize: Upload.MAX_FILE_SIZE,
|
||||
maxThumbnailFilesize: Upload.MAX_FILE_SIZE,
|
||||
maxFilesize: Upload.max_file_size(),
|
||||
maxThumbnailFilesize: Upload.max_file_size(),
|
||||
timeout: 0,
|
||||
acceptedFiles: "image/jpeg,image/png,image/gif,video/mp4,video/webm",
|
||||
previewTemplate: $("#dropzone-preview-template").html(),
|
||||
@@ -226,6 +224,10 @@ Upload.batch_open_all = function() {
|
||||
$(".upload-preview > a").each((_i, link) => window.open(link.href));
|
||||
};
|
||||
|
||||
Upload.max_file_size = function() {
|
||||
return Number($("meta[name=max-file-size]").attr("content")) / (1024 * 1024);
|
||||
};
|
||||
|
||||
$(function() {
|
||||
Upload.initialize_all();
|
||||
});
|
||||
Reference in New Issue
Block a user