possibly fixed sub path hosting issues

This commit is contained in:
vabene1111
2021-10-29 11:29:55 +02:00
parent 6c8843ca74
commit 6949e17a33
15 changed files with 36 additions and 6 deletions

View File

@ -41,10 +41,17 @@ SHOPPING_MIN_AUTOSYNC_INTERVAL=5
# Default for user setting sticky navbar # Default for user setting sticky navbar
# STICKY_NAV_PREF_DEFAULT=1 # STICKY_NAV_PREF_DEFAULT=1
# If staticfiles are stored at a different location uncomment and change accordingly # If base URL is something other than just / (you are serving a subfolder in your proxy for instance http://recipe_app/recipes/)
# SCRIPT_NAME=/recipes
# If staticfiles are stored at a different location uncomment and change accordingly, MUST END IN /
# this is not required if you are just using a subfolder
# This can either be a relative path from the applications base path or the url of an external host
# STATIC_URL=/static/ # STATIC_URL=/static/
# If mediafiles are stored at a different location uncomment and change accordingly # If mediafiles are stored at a different location uncomment and change accordingly, MUST END IN /
# this is not required if you are just using a subfolder
# This can either be a relative path from the applications base path or the url of an external host
# MEDIA_URL=/media/ # MEDIA_URL=/media/
# Serve mediafiles directly using gunicorn. Basically everyone recommends not doing this. Please use any of the examples # Serve mediafiles directly using gunicorn. Basically everyone recommends not doing this. Please use any of the examples
@ -79,8 +86,6 @@ GUNICORN_MEDIA=0
# when unset: 0 (false) # when unset: 0 (false)
REVERSE_PROXY_AUTH=0 REVERSE_PROXY_AUTH=0
# If base URL is something other than just / (you are serving a subfolder in your proxy for instance http://recipe_app/recipes/)
# SCRIPT_NAME=/recipes
# Default settings for spaces, apply per space and can be changed in the admin view # Default settings for spaces, apply per space and can be changed in the admin view
# SPACE_DEFAULT_MAX_RECIPES=0 # 0=unlimited recipes # SPACE_DEFAULT_MAX_RECIPES=0 # 0=unlimited recipes
# SPACE_DEFAULT_MAX_USERS=0 # 0=unlimited users per space # SPACE_DEFAULT_MAX_USERS=0 # 0=unlimited users per space

View File

@ -38,6 +38,8 @@ class ExtendedRecipeMixin(serializers.ModelSerializer):
return fields return fields
except AttributeError: except AttributeError:
pass pass
except KeyError:
pass
del fields['image'] del fields['image']
del fields['numrecipe'] del fields['numrecipe']
return fields return fields

View File

@ -344,6 +344,7 @@
<script type="application/javascript"> <script type="application/javascript">
localStorage.setItem('SCRIPT_NAME', "{% base_path request 'script' %}") localStorage.setItem('SCRIPT_NAME', "{% base_path request 'script' %}")
localStorage.setItem('BASE_PATH', "{% base_path request 'base' %}") localStorage.setItem('BASE_PATH', "{% base_path request 'base' %}")
localStorage.setItem('STATIC_URL', "{% base_path request 'static_base' %}")
window.addEventListener("load", () => { window.addEventListener("load", () => {
if ("serviceWorker" in navigator) { if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("{% url 'service_worker' %}", {scope: "{% base_path request 'base' %}" + '/'}).then(function (reg) { navigator.serviceWorker.register("{% url 'service_worker' %}", {scope: "{% base_path request 'base' %}" + '/'}).then(function (reg) {

View File

@ -142,7 +142,7 @@ def bookmarklet(request):
localStorage.setItem('redirectURL', '" + server + reverse('data_import_url') + "'); \ localStorage.setItem('redirectURL', '" + server + reverse('data_import_url') + "'); \
localStorage.setItem('token', '" + api_token.__str__() + "'); \ localStorage.setItem('token', '" + api_token.__str__() + "'); \
document.body.appendChild(document.createElement(\'script\')).src=\'" \ document.body.appendChild(document.createElement(\'script\')).src=\'" \
+ server + prefix + static('js/bookmarklet.js') + "? \ + server + prefix + static('js/bookmarklet.js') + "? \
r=\'+Math.floor(Math.random()*999999999);}})();" r=\'+Math.floor(Math.random()*999999999);}})();"
return re.sub(r"[\n\t\s]*", "", bookmark) return re.sub(r"[\n\t\s]*", "", bookmark)
@ -153,3 +153,5 @@ def base_path(request, path_type):
return request._current_scheme_host + request.META.get('HTTP_X_SCRIPT_NAME', '') return request._current_scheme_host + request.META.get('HTTP_X_SCRIPT_NAME', '')
elif path_type == 'script': elif path_type == 'script':
return request.META.get('HTTP_X_SCRIPT_NAME', '') return request.META.get('HTTP_X_SCRIPT_NAME', '')
elif path_type == 'static_base':
return static('vue/manifest.json').replace('vue/manifest.json', '')

View File

@ -4,6 +4,8 @@ import i18n from '@/i18n'
Vue.config.productionTip = false Vue.config.productionTip = false
export default __webpack_public_path__ = localStorage.STATIC_URL + 'vue/' // eslint-disable-line
new Vue({ new Vue({
i18n, i18n,
render: h => h(App), render: h => h(App),

View File

@ -4,6 +4,8 @@ import i18n from '@/i18n'
Vue.config.productionTip = false Vue.config.productionTip = false
export default __webpack_public_path__ = localStorage.STATIC_URL + 'vue/' // eslint-disable-line
new Vue({ new Vue({
i18n, i18n,
render: h => h(App), render: h => h(App),

View File

@ -4,6 +4,8 @@ import i18n from '@/i18n'
Vue.config.productionTip = false Vue.config.productionTip = false
export default __webpack_public_path__ = localStorage.STATIC_URL + 'vue/' // eslint-disable-line
new Vue({ new Vue({
i18n, i18n,
render: h => h(App), render: h => h(App),

View File

@ -4,6 +4,8 @@ import i18n from '@/i18n'
Vue.config.productionTip = false Vue.config.productionTip = false
export default __webpack_public_path__ = localStorage.STATIC_URL + 'vue/' // eslint-disable-line
new Vue({ new Vue({
i18n, i18n,
render: h => h(App), render: h => h(App),

View File

@ -4,6 +4,8 @@ import i18n from '@/i18n'
Vue.config.productionTip = false Vue.config.productionTip = false
export default __webpack_public_path__ = localStorage.STATIC_URL + 'vue/' // eslint-disable-line
new Vue({ new Vue({
i18n, i18n,
render: h => h(App), render: h => h(App),

View File

@ -4,6 +4,8 @@ import i18n from "@/i18n";
Vue.config.productionTip = false Vue.config.productionTip = false
export default __webpack_public_path__ = localStorage.STATIC_URL + 'vue/' // eslint-disable-line
new Vue({ new Vue({
i18n, i18n,
render: h => h(App), render: h => h(App),

View File

@ -4,6 +4,8 @@ import i18n from '@/i18n'
Vue.config.productionTip = false Vue.config.productionTip = false
export default __webpack_public_path__ = localStorage.STATIC_URL + 'vue/' // eslint-disable-line
new Vue({ new Vue({
i18n, i18n,
render: h => h(App), render: h => h(App),

View File

@ -4,6 +4,8 @@ import i18n from '@/i18n'
Vue.config.productionTip = false Vue.config.productionTip = false
export default __webpack_public_path__ = localStorage.STATIC_URL + 'vue/' // eslint-disable-line
new Vue({ new Vue({
i18n, i18n,
render: h => h(App), render: h => h(App),

View File

@ -4,6 +4,8 @@ import i18n from "@/i18n";
Vue.config.productionTip = false Vue.config.productionTip = false
export default __webpack_public_path__ = localStorage.STATIC_URL + 'vue/' // eslint-disable-line
new Vue({ new Vue({
i18n, i18n,
render: h => h(App), render: h => h(App),

View File

@ -4,6 +4,8 @@ import i18n from '@/i18n'
Vue.config.productionTip = false Vue.config.productionTip = false
export default __webpack_public_path__ = localStorage.STATIC_URL + 'vue/' // eslint-disable-line
new Vue({ new Vue({
i18n, i18n,
render: h => h(App), render: h => h(App),

View File

@ -48,7 +48,7 @@ module.exports = {
filenameHashing: false, filenameHashing: false,
productionSourceMap: false, productionSourceMap: false,
publicPath: process.env.NODE_ENV === 'production' publicPath: process.env.NODE_ENV === 'production'
? '/static/vue' ? ''
: 'http://localhost:8080/', : 'http://localhost:8080/',
outputDir: '../cookbook/static/vue/', outputDir: '../cookbook/static/vue/',
runtimeCompiler: true, runtimeCompiler: true,