Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
searx-engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
searx-engine
Commits
ee080fea
Commit
ee080fea
authored
Jan 06, 2017
by
Alexandre Flament
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[mod] the static and templates directories can be defined in the settings.yml
parent
c233bf0d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
35 deletions
+40
-35
settings.yml
searx/settings.yml
+2
-1
settings_robot.yml
searx/settings_robot.yml
+2
-1
utils.py
searx/utils.py
+17
-15
webapp.py
searx/webapp.py
+19
-18
No files found.
searx/settings.yml
View file @
ee080fea
...
...
@@ -16,7 +16,8 @@ server:
http_protocol_version
:
"
1.0"
# 1.0 and 1.1 are supported
ui
:
themes_path
:
"
"
# Custom ui themes path - leave it blank if you didn't change
static_path
:
"
"
# Custom static path - leave it blank if you didn't change
templates_path
:
"
"
# Custom templates path - leave it blank if you didn't change
default_theme
:
oscar
# ui theme
default_locale
:
"
"
# Default interface locale - leave blank to detect from browser information or use codes from the 'locales' config section
...
...
searx/settings_robot.yml
View file @
ee080fea
...
...
@@ -16,7 +16,8 @@ server:
http_protocol_version
:
"
1.0"
ui
:
themes_path
:
"
"
static_path
:
"
"
templates_path
:
"
"
default_theme
:
oscar
default_locale
:
"
"
...
...
searx/utils.py
View file @
ee080fea
...
...
@@ -178,37 +178,39 @@ class UnicodeWriter:
self
.
writerow
(
row
)
def
get_themes
(
root
):
"""Returns available themes list."""
def
get_resources_directory
(
searx_directory
,
subdirectory
,
resources_directory
):
if
not
resources_directory
:
resources_directory
=
os
.
path
.
join
(
searx_directory
,
subdirectory
)
if
not
os
.
path
.
isdir
(
resources_directory
):
raise
Exception
(
directory
+
" is not a directory"
)
return
resources_directory
static_path
=
os
.
path
.
join
(
root
,
'static'
)
templates_path
=
os
.
path
.
join
(
root
,
'templates'
)
def
get_themes
(
static_path
):
"""Returns available themes list."""
themes
=
os
.
listdir
(
os
.
path
.
join
(
static_path
,
'themes'
))
if
'__common__'
in
themes
:
themes
.
remove
(
'__common__'
)
return
static_path
,
templates_path
,
themes
return
themes
def
get_static_files
(
base_path
):
base_path
=
os
.
path
.
join
(
base_path
,
'static'
)
def
get_static_files
(
static_path
):
static_files
=
set
()
base_path_length
=
len
(
base
_path
)
+
1
for
directory
,
_
,
files
in
os
.
walk
(
base
_path
):
static_path_length
=
len
(
static
_path
)
+
1
for
directory
,
_
,
files
in
os
.
walk
(
static
_path
):
for
filename
in
files
:
f
=
os
.
path
.
join
(
directory
[
base
_path_length
:],
filename
)
f
=
os
.
path
.
join
(
directory
[
static
_path_length
:],
filename
)
static_files
.
add
(
f
)
return
static_files
def
get_result_templates
(
base_path
):
base_path
=
os
.
path
.
join
(
base_path
,
'templates'
)
def
get_result_templates
(
templates_path
):
result_templates
=
set
()
base_path_length
=
len
(
base
_path
)
+
1
for
directory
,
_
,
files
in
os
.
walk
(
base
_path
):
templates_path_length
=
len
(
templates
_path
)
+
1
for
directory
,
_
,
files
in
os
.
walk
(
templates
_path
):
if
directory
.
endswith
(
'result_templates'
):
for
filename
in
files
:
f
=
os
.
path
.
join
(
directory
[
base
_path_length
:],
filename
)
f
=
os
.
path
.
join
(
directory
[
templates
_path_length
:],
filename
)
result_templates
.
add
(
f
)
return
result_templates
...
...
searx/webapp.py
View file @
ee080fea
...
...
@@ -56,9 +56,9 @@ from searx.engines import (
categories
,
engines
,
engine_shortcuts
,
get_engines_stats
,
initialize_engines
)
from
searx.utils
import
(
UnicodeWriter
,
highlight_content
,
html_to_text
,
get_
themes
,
get_static_files
,
get_result_templates
,
ge
n_useragent
,
dict_subse
t
,
prettify_url
UnicodeWriter
,
highlight_content
,
html_to_text
,
get_
resources_directory
,
get_static_files
,
get_result_templates
,
ge
t_themes
,
gen_useragen
t
,
dict_subset
,
prettify_url
)
from
searx.version
import
VERSION_STRING
from
searx.languages
import
language_codes
...
...
@@ -91,17 +91,25 @@ if sys.version_info[0] == 3:
from
werkzeug.serving
import
WSGIRequestHandler
WSGIRequestHandler
.
protocol_version
=
"HTTP/{}"
.
format
(
settings
[
'server'
]
.
get
(
'http_protocol_version'
,
'1.0'
))
static_path
,
templates_path
,
themes
=
\
get_themes
(
settings
[
'ui'
][
'themes_path'
]
if
settings
[
'ui'
][
'themes_path'
]
else
searx_dir
)
# about static
static_path
=
get_resources_directory
(
searx_dir
,
'static'
,
settings
[
'ui'
][
'static_path'
])
logger
.
debug
(
'static directory is
%
s'
,
static_path
)
static_files
=
get_static_files
(
static_path
)
# about templates
default_theme
=
settings
[
'ui'
][
'default_theme'
]
templates_path
=
get_resources_directory
(
searx_dir
,
'templates'
,
settings
[
'ui'
][
'templates_path'
])
logger
.
debug
(
'templates directory is
%
s'
,
templates_path
)
themes
=
get_themes
(
static_path
)
result_templates
=
get_result_templates
(
templates_path
)
global_favicons
=
[]
for
indice
,
theme
in
enumerate
(
themes
):
global_favicons
.
append
([])
theme_img_path
=
os
.
path
.
join
(
static_path
,
'themes'
,
theme
,
'img'
,
'icons'
)
for
(
dirpath
,
dirnames
,
filenames
)
in
os
.
walk
(
theme_img_path
):
global_favicons
[
indice
]
.
extend
(
filenames
)
static_files
=
get_static_files
(
searx_dir
)
result_templates
=
get_result_templates
(
searx_dir
)
# Flask app
app
=
Flask
(
__name__
,
static_folder
=
static_path
,
...
...
@@ -120,13 +128,6 @@ babel = Babel(app)
rtl_locales
=
[
'ar'
,
'arc'
,
'bcc'
,
'bqi'
,
'ckb'
,
'dv'
,
'fa'
,
'glk'
,
'he'
,
'ku'
,
'mzn'
,
'pnb'', ''ps'
,
'sd'
,
'ug'
,
'ur'
,
'yi'
]
global_favicons
=
[]
for
indice
,
theme
in
enumerate
(
themes
):
global_favicons
.
append
([])
theme_img_path
=
searx_dir
+
"/static/themes/"
+
theme
+
"/img/icons/"
for
(
dirpath
,
dirnames
,
filenames
)
in
os
.
walk
(
theme_img_path
):
global_favicons
[
indice
]
.
extend
(
filenames
)
# used when translating category names
_category_names
=
(
gettext
(
'files'
),
gettext
(
'general'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment