Skip to content

Commit

Permalink
update file references for image folder instead of docroot
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronwmorris committed Feb 21, 2022
1 parent 43dc43a commit f016f4c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 9 deletions.
1 change: 1 addition & 0 deletions flask.json_template
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

"INDI_ALLSKY_CONFIG" : "%ALLSKY_ETC%/config.json",
"INDI_ALLSKY_DOCROOT" : "%HTDOCS_FOLDER%",
"INDI_ALLSKY_IMAGE_FOLDER" : "%IMAGE_FOLDER%",
"INDI_ALLSKY_STATUS" : "%DB_FOLDER%/indi_allsky_status.json",
"INDI_ALLSKY_PID" : "%DB_FOLDER%/indi-allsky.pid",

Expand Down
37 changes: 31 additions & 6 deletions indi_allsky/flask/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,14 @@ def getImages(self, year, month, day, hour):
images_choices = []
for i in images_query:
filename_p = Path(i.filename)
rel_filename_p = filename_p.relative_to(app.config['INDI_ALLSKY_DOCROOT'])

entry = (str(rel_filename_p), str(i.createDate.strftime('%H:%M:%S')))
try:
rel_filename_p = filename_p.relative_to(app.config['INDI_ALLSKY_IMAGE_FOLDER'])
except ValueError as e:
app.logger.error('Error determining relative file name: %s', str(e))
continue

entry = (str(Path('images').joinpath(rel_filename_p)), str(i.createDate.strftime('%H:%M:%S')))
images_choices.append(entry)


Expand Down Expand Up @@ -878,10 +883,15 @@ def getVideos(self, year, month, timeofday):
videos_data = []
for v in videos_query:
filename_p = Path(v.filename)
rel_filename_p = filename_p.relative_to(app.config['INDI_ALLSKY_DOCROOT'])

try:
rel_filename_p = filename_p.relative_to(app.config['INDI_ALLSKY_IMAGE_FOLDER'])
except ValueError as e:
app.logger.error('Error determining relative file name: %s', str(e))
continue

entry = {
'url' : str(rel_filename_p),
'url' : str(Path('images').joinpath(rel_filename_p)),
'dayDate' : v.dayDate.strftime('%B %d, %Y'),
'night' : v.night,
}
Expand All @@ -902,8 +912,16 @@ def getVideos(self, year, month, timeofday):
.order_by(IndiAllSkyDbKeogramTable.createDate.asc())\
.first() # use the oldest (asc)


if keogram_entry:
keogram_url = str(Path(keogram_entry.filename).relative_to(app.config['INDI_ALLSKY_DOCROOT']))
keogram_p = Path(keogram_entry.filename)

try:
rel_keogram_p = keogram_p.relative_to(app.config['INDI_ALLSKY_IMAGE_FOLDER'])
keogram_url = str(Path('images').joinpath(rel_keogram_p))
except ValueError as e:
app.logger.error('Error determining relative file name: %s', str(e))
keogram_url = None
else:
keogram_url = None

Expand All @@ -918,7 +936,14 @@ def getVideos(self, year, month, timeofday):


if startrail_entry:
startrail_url = str(Path(startrail_entry.filename).relative_to(app.config['INDI_ALLSKY_DOCROOT']))
startrail_p = Path(startrail_entry.filename)

try:
rel_startrail_p = startrail_p.relative_to(app.config['INDI_ALLSKY_IMAGE_FOLDER'])
startrail_url = str(Path('images').joinpath(rel_startrail_p))
except ValueError as e:
app.logger.error('Error determining relative file name: %s', str(e))
startrail_url = None
else:
startrail_url = None

Expand Down
9 changes: 7 additions & 2 deletions indi_allsky/flask/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,15 @@ def getLatestImages(self, history_seconds):
image_list = list()
for i in latest_images:
filename_p = Path(i.filename)
rel_filename_p = filename_p.relative_to(app.config['INDI_ALLSKY_DOCROOT'])

try:
rel_filename_p = filename_p.relative_to(app.config['INDI_ALLSKY_IMAGE_FOLDER'])
except ValueError as e:
app.logger.error('Error determining relative file name: %s', str(e))
continue

data = {
'file' : str(rel_filename_p),
'file' : str(Path('images').joinpath(rel_filename_p)),
'sqm' : i.sqm,
'stars' : i.stars,
}
Expand Down
1 change: 1 addition & 0 deletions service/apache_indi-allsky.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<Directory %IMAGE_FOLDER%>
Require all granted
Options +Indexes
</Directory>

<Location />
Expand Down
2 changes: 1 addition & 1 deletion service/nginx_astroberry_ssl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ server {

location /indi-allsky/images {
alias %IMAGE_FOLDER%;
autoindex off;
autoindex on;
}

location /indi-allsky/static {
Expand Down
1 change: 1 addition & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ sed \
-e "s|%SECRET_KEY%|$SECRET_KEY|g" \
-e "s|%ALLSKY_ETC%|$ALLSKY_ETC|g" \
-e "s|%HTDOCS_FOLDER%|$HTDOCS_FOLDER|g" \
-e "s|%IMAGE_FOLDER%|$IMAGE_FOLDER|g" \
-e "s|%INDISEVER_SERVICE_NAME%|$INDISEVER_SERVICE_NAME|g" \
-e "s|%ALLSKY_SERVICE_NAME%|$ALLSKY_SERVICE_NAME|g" \
-e "s|%GUNICORN_SERVICE_NAME%|$GUNICORN_SERVICE_NAME|g" \
Expand Down

0 comments on commit f016f4c

Please sign in to comment.