@@ -276,6 +276,13 @@ def lesson_static_generator():
276
276
yield from lesson_static_generator_dir (lesson .slug , static , static )
277
277
278
278
279
+ def record_content_urls (data_from_fork , prefix ):
280
+ # Freeze URLs generated by the code in fork, but only if
281
+ # they start with the given prefix
282
+ for url in data_from_fork .get ("urls" , ()):
283
+ if url .startswith (prefix ):
284
+ record_url (url )
285
+
279
286
def course_content (course ):
280
287
def lesson_url (lesson , * args , ** kwargs ):
281
288
if kwargs .get ("page" ) == "index" :
@@ -319,6 +326,7 @@ def course(course):
319
326
root_slug = model .meta .slug ,
320
327
travis_build_id = os .environ .get ("TRAVIS_BUILD_ID" ),
321
328
)
329
+ record_content_urls (data_from_fork , f"/{ course .slug } /" )
322
330
kwargs = {
323
331
"course_content" : content ,
324
332
"edit_info" : edit_info ,
@@ -464,7 +472,6 @@ def content_creator():
464
472
subpage_url = subpage_url ,
465
473
vars = variables
466
474
)
467
-
468
475
absolute_urls = [url_for (logged [0 ], ** logged [1 ]) for logged in logger .logged_calls ]
469
476
470
477
relative_urls = [get_relative_url (request .path , x ) for x in absolute_urls ]
@@ -529,7 +536,10 @@ def course_page(course, lesson, page, solution=None):
529
536
if content_offer :
530
537
fork_kwargs ["content_key" ] = content_key
531
538
532
- data_from_fork = course .render_page (lesson_slug , page , solution , ** fork_kwargs )
539
+ data_from_fork = course .render_page (
540
+ lesson_slug , page , solution ,
541
+ ** fork_kwargs )
542
+ record_content_urls (data_from_fork , f"/{ course .slug } /" )
533
543
534
544
content = data_from_fork ["content" ]
535
545
@@ -572,8 +582,17 @@ def course_page(course, lesson, page, solution=None):
572
582
title = '{}: {}' .format (course .title , page .title )
573
583
574
584
try :
575
- prev_link , session_link , next_link = course .get_footer_links (lesson .slug , page_slug ,
576
- request_url = request .path )
585
+ footer_links = course .get_footer_links (
586
+ lesson .slug ,
587
+ page_slug ,
588
+ request_url = request .path ,
589
+ )
590
+ for link in footer_links :
591
+ _prefix = f"/{ course .slug } /"
592
+ if link and link ["url" ].startswith (_prefix ):
593
+ record_url (link ["url" ])
594
+ prev_link , session_link , next_link = footer_links
595
+
577
596
except POSSIBLE_FORK_EXCEPTIONS as e :
578
597
if raise_errors_from_forks ():
579
598
raise
@@ -725,7 +744,9 @@ def session_coverpage(course, session, coverpage):
725
744
naucse .utils .views .forks_raise_if_disabled ()
726
745
727
746
try :
728
- data_from_fork = course .render_session_coverpage (session , coverpage , request_url = request .path )
747
+ data_from_fork = course .render_session_coverpage (
748
+ session , coverpage , request_url = request .path )
749
+ record_content_urls (data_from_fork , f"/{ course .slug } /" )
729
750
730
751
content = data_from_fork .get ("content" )
731
752
if content is None :
@@ -789,6 +810,7 @@ def course_calendar(course):
789
810
790
811
try :
791
812
data_from_fork = course .render_calendar (request_url = request .path )
813
+ record_content_urls (data_from_fork , f"/{ course .slug } /" )
792
814
793
815
course = process_course_data (data_from_fork .get ("course" ), slug = course .slug )
794
816
edit_info = links .process_edit_info (data_from_fork .get ("edit_info" ))
@@ -864,7 +886,9 @@ def course_calendar_ics(course):
864
886
naucse .utils .views .forks_raise_if_disabled ()
865
887
866
888
try :
867
- data_from_fork = course .render_calendar_ics (request_url = request .path )
889
+ data_from_fork = course .render_calendar_ics (
890
+ request_url = request .path )
891
+ record_content_urls (data_from_fork , f"/{ course .slug } /" )
868
892
869
893
calendar = data_from_fork .get ("calendar" )
870
894
0 commit comments