mirror of https://github.com/searxng/searxng
Merge pull request #174 from searxng/static_script
[mod] add make targets to manage the build files in the /searx/static directorypull/185/head
commit
30e4a2a224
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,4 +1,2 @@
|
||||
/*! simple/searx.min.js | 22-06-2021 | https://github.com/searxng/searxng */
|
||||
|
||||
(function(t,e){"use strict";var a=e.currentScript||function(){var t=e.getElementsByTagName("script");return t[t.length-1]}();t.searx={touch:"ontouchstart"in t||t.DocumentTouch&&document instanceof DocumentTouch||false,method:a.getAttribute("data-method"),autocompleter:a.getAttribute("data-autocompleter")==="true",search_on_category_select:a.getAttribute("data-search-on-category-select")==="true",infinite_scroll:a.getAttribute("data-infinite-scroll")==="true",static_path:a.getAttribute("data-static-path"),translations:JSON.parse(a.getAttribute("data-translations"))};e.getElementsByTagName("html")[0].className=t.searx.touch?"js touch":"js"})(window,document);
|
||||
//# sourceMappingURL=searx.head.min.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"searx.head.min.js","sources":["searx.head.js"],"names":["w","d","script","currentScript","scripts","getElementsByTagName","length","searx","touch","DocumentTouch","document","method","getAttribute","autocompleter","search_on_category_select","infinite_scroll","static_path","translations","JSON","parse","className","window"],"mappings":";;CAiBA,SAAUA,EAAGC,gBAIT,IAAIC,EAASD,EAAEE,eAAkB,WAC7B,IAAIC,EAAUH,EAAEI,qBAAqB,UACrC,OAAOD,EAAQA,EAAQE,OAAS,GAFH,GAMjCN,EAAEO,MAAQ,CACNC,MAAS,iBAAkBR,GAAMA,EAAES,eAAiBC,oBAAoBD,eAAkB,MAC1FE,OAAQT,EAAOU,aAAa,eAC5BC,cAAeX,EAAOU,aAAa,wBAA0B,OAC7DE,0BAA2BZ,EAAOU,aAAa,oCAAsC,OACrFG,gBAAiBb,EAAOU,aAAa,0BAA4B,OACjEI,YAAad,EAAOU,aAAa,oBACjCK,aAAcC,KAAKC,MAAMjB,EAAOU,aAAa,uBAIjDX,EAAEI,qBAAqB,QAAQ,GAAGe,UAAapB,EAAEO,MAAW,MAAE,WAAW,MArB7E,CAsBGc,OAAQX"}
|
||||
{"version":3,"file":"searx.head.min.js","sources":["searx.head.js"],"names":["w","d","script","currentScript","scripts","getElementsByTagName","length","searx","touch","DocumentTouch","document","method","getAttribute","autocompleter","search_on_category_select","infinite_scroll","static_path","translations","JSON","parse","className","window"],"mappings":"CAiBA,SAAUA,EAAGC,gBAIT,IAAIC,EAASD,EAAEE,eAAkB,WAC7B,IAAIC,EAAUH,EAAEI,qBAAqB,UACrC,OAAOD,EAAQA,EAAQE,OAAS,GAFH,GAMjCN,EAAEO,MAAQ,CACNC,MAAS,iBAAkBR,GAAMA,EAAES,eAAiBC,oBAAoBD,eAAkB,MAC1FE,OAAQT,EAAOU,aAAa,eAC5BC,cAAeX,EAAOU,aAAa,wBAA0B,OAC7DE,0BAA2BZ,EAAOU,aAAa,oCAAsC,OACrFG,gBAAiBb,EAAOU,aAAa,0BAA4B,OACjEI,YAAad,EAAOU,aAAa,oBACjCK,aAAcC,KAAKC,MAAMjB,EAAOU,aAAa,uBAIjDX,EAAEI,qBAAqB,QAAQ,GAAGe,UAAapB,EAAEO,MAAW,MAAE,WAAW,MArB7E,CAsBGc,OAAQX"}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
|
||||
STATIC_BUILD_COMMIT="[build] /static"
|
||||
STATIC_BUILT_PATHS=(
|
||||
searx/static/themes/oscar/css
|
||||
searx/static/themes/oscar/js
|
||||
searx/static/themes/oscar/src/generated/pygments-logicodev.less
|
||||
searx/static/themes/oscar/src/generated/pygments-pointhi.less
|
||||
searx/static/themes/simple/css
|
||||
searx/static/themes/simple/js
|
||||
searx/static/themes/simple/src/generated/pygments.less
|
||||
)
|
||||
|
||||
static_help(){
|
||||
cat <<EOF
|
||||
static.build.: ${STATIC_BUILD_COMMIT}
|
||||
commit : build & commit /static folder
|
||||
drop : drop last commit if it was previously done by static.build.commit
|
||||
restore : git restore of the /static folder (after themes.all)
|
||||
EOF
|
||||
}
|
||||
|
||||
is.static.build.commit() {
|
||||
|
||||
local commit_sha="$1"
|
||||
local commit_message
|
||||
local commit_files
|
||||
|
||||
# check commit message
|
||||
commit_message=$(git show -s --format=%s "${commit_sha}")
|
||||
if [ "${commit_message}" != "${STATIC_BUILD_COMMIT}" ]; then
|
||||
err_msg "expecting commit message: '${STATIC_BUILD_COMMIT}'"
|
||||
err_msg "commit message of ${commit_sha} is: '${commit_message}'"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# check all files of the commit belongs to $STATIC_BUILT_PATHS
|
||||
commit_files=$(git diff-tree --no-commit-id --name-only -r "${commit_sha}")
|
||||
for i in ${STATIC_BUILT_PATHS[*]}; do
|
||||
# remove files of ${STATIC_BUILT_PATHS}
|
||||
commit_files=$(echo "${commit_files}" | grep -v "^${i}")
|
||||
done
|
||||
|
||||
if [ -n "${commit_files}" ]; then
|
||||
err_msg "commit ${commit_sha} contains files not a part of ${STATIC_BUILD_COMMIT}"
|
||||
echo "${commit_files}" | prefix_stdout " "
|
||||
return 2
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
static.build.drop() {
|
||||
# drop last commit if it was made by the static.build.commit command
|
||||
|
||||
local last_commit_id
|
||||
local branch
|
||||
|
||||
build_msg STATIC "drop last commit if it was previously done by static.build.commit"
|
||||
|
||||
# get only last (option -n1) local commit not in remotes
|
||||
branch="$(git branch --show-current)"
|
||||
last_commit_id="$(git log -n1 "${branch}" --pretty=format:'%h'\
|
||||
--not --exclude="${branch}" --branches --remotes)"
|
||||
|
||||
if [ -z "${last_commit_id}" ]; then
|
||||
err_msg "there are no local commits"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! is.static.build.commit "${last_commit_id}"; then
|
||||
return $?
|
||||
fi
|
||||
|
||||
build_msg STATIC "drop last commit ${last_commit_id}"
|
||||
git reset --hard HEAD~1
|
||||
}
|
||||
|
||||
static.build.commit() {
|
||||
# call the "static.build.drop" command, then "themes.all" then commit the
|
||||
# built files ($BUILT_PATHS).
|
||||
|
||||
build_msg STATIC "build & commit /static files"
|
||||
|
||||
# check for not commited files
|
||||
if [ -n "$(git diff --name-only)" ]; then
|
||||
err_msg "some files are not commited:"
|
||||
git diff --name-only | prefix_stdout " "
|
||||
return 1
|
||||
fi
|
||||
|
||||
# check for staged files
|
||||
if [ -n "$(git diff --name-only --cached)" ]; then
|
||||
err_msg "some files are staged:"
|
||||
git diff --name-only --cached | prefix_stdout " "
|
||||
return 1
|
||||
fi
|
||||
|
||||
# drop existing commit from previos build
|
||||
static.build.drop &>/dev/null
|
||||
|
||||
( set -e
|
||||
# build the themes
|
||||
themes.all
|
||||
|
||||
# add build files
|
||||
for built_path in "${STATIC_BUILT_PATHS[@]}"; do
|
||||
git add -v "${built_path}"
|
||||
done
|
||||
|
||||
# check for modified files that are not staged
|
||||
if [ -n "$(git diff --name-only)" ]; then
|
||||
die 42 "themes.all has created files that are not in STATIC_BUILT_PATHS"
|
||||
fi
|
||||
git commit -m "${STATIC_BUILD_COMMIT}"
|
||||
)
|
||||
}
|
||||
|
||||
static.build.restore() {
|
||||
build_msg STATIC "git-restore of the built files (/static)"
|
||||
git restore --staged "${STATIC_BUILT_PATHS[@]}"
|
||||
git restore --worktree "${STATIC_BUILT_PATHS[@]}"
|
||||
}
|
Loading…
Reference in New Issue