Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit 8c1bdf9

Browse files
committed
Remove index code and redirect to ns
1 parent 5da0d54 commit 8c1bdf9

File tree

2 files changed

+2
-63
lines changed

2 files changed

+2
-63
lines changed

controllers/books.py

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -411,68 +411,7 @@ def index():
411411
412412
"""
413413

414-
book_list = os.listdir("applications/{}/books".format(request.application))
415-
book_list = [book for book in book_list if ".git" not in book]
416-
417-
res = []
418-
sections = ["Computer Science"]
419-
for book in sorted(book_list):
420-
try:
421-
# WARNING: This imports from ``applications.<runestone application name>.books.<book name>``. Since ``runestone/books/<book_name>`` lacks an ``__init__.py``, it will be treated as a `namespace package <https://www.python.org/dev/peps/pep-0420/>`_. Therefore, odd things will happen if there are other modules named ``applications.<runestone application name>.books.<book name>`` in the Python path.
422-
config = importlib.import_module(
423-
"applications.{}.books.{}.conf".format(request.application, book)
424-
)
425-
except Exception as e:
426-
logger.warn(f"Error adding book {book} to library list: {e}")
427-
continue
428-
book_info = {}
429-
book_info.update(course_description="")
430-
book_info.update(key_words="")
431-
if hasattr(config, "navbar_title"):
432-
book_info["title"] = config.navbar_title
433-
elif hasattr(config, "html_title"):
434-
book_info["title"] = config.html_title
435-
elif hasattr(config, "html_short_title"):
436-
book_info["title"] = config.html_short_title
437-
else:
438-
book_info["title"] = "Runestone Book"
439-
# update course description if found in the book's conf.py
440-
if hasattr(config, "course_description"):
441-
book_info.update(course_description=config.course_description)
442-
# update course key_words if found in book's conf.py
443-
if hasattr(config, "key_words"):
444-
book_info.update(key_words=config.key_words)
445-
if hasattr(config, "publisher") and config.publisher == "PTX":
446-
bks = settings.bks
447-
book_info["source"] = "PTX"
448-
else:
449-
bks = settings.bks
450-
book_info["source"] = "Runestone"
451-
452-
if hasattr(config, "shelf_section"):
453-
book_info["section"] = config.shelf_section
454-
if config.shelf_section not in sections:
455-
sections.append(config.shelf_section)
456-
else:
457-
book_info["section"] = "Computer Science"
458-
logger.debug(f"{book} is in section {book_info['section']}")
459-
460-
if book_info["source"] == "Runestone":
461-
book_info["url"] = "/{}/books/published/{}/index.html".format(bks, book)
462-
else:
463-
book_info["url"] = "/{}/books/published/{}/{}".format(
464-
bks,
465-
book,
466-
_find_real_url(f"applications/{request.application}/books", book),
467-
)
468-
book_info["regname"] = book
469-
sections.sort()
470-
if hasattr(config, "is_private") and config.is_private == True:
471-
pass
472-
else:
473-
res.append(book_info)
474-
475-
return dict(book_list=res, sections=sections)
414+
redirect("/ns/books/index")
476415

477416

478417
#

scripts/make_sitemap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def path_to_url(p):
1515
"""<?xml version="1.0" encoding="utf-8"?>
1616
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
1717
<url><loc>https://runestone.academy</loc></url>
18-
<url><loc>https://runestone.academy/runestone/books/index</loc></url>
18+
<url><loc>https://runestone.academy/ns/books/index</loc></url>
1919
"""
2020
)
2121
p = Path(home, "Runestone/books")

0 commit comments

Comments
 (0)