Changeset 227
- Timestamp:
- 05/26/09 14:51:09 (3 years ago)
- Files:
-
- 1 modified
-
plone-export/trunk/plone-static-export.py (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plone-export/trunk/plone-static-export.py
r225 r227 53 53 fqsubdomain = 'http://%s' %(subdomain) 54 54 tmpfile_name = 'tempfile' 55 56 55 57 56 def DebugOutput(function, words): … … 108 107 'search_icon.gif', 109 108 's5_icon.jpg', 109 'base.css', 110 's5_slides.css', 111 's5_outline.css', 112 's5_print.css', 113 's5_opera.css', 114 's5_slides.js', 110 115 'spinner.gif', 111 116 'sitemap', … … 117 122 'headerBackground.png', 118 123 'topNavBackground.png',] 119 120 124 121 125 for file in add_files: 122 126 if file == 'index.html': … … 376 380 fileobj.close() 377 381 378 tmpfobj = open(tmpfile_name, 'w') 382 tmpfile = tmpfile_name + filename.split('/')[-1] 383 384 385 tmpfobj = open(tmpfile, 'w') 379 386 path_to_file = os.path.dirname(filename) 380 387 path_to_file = path_to_file.replace('/','/') … … 392 399 #remove completely, as it breaks relative pathing for local browsing 393 400 for tag in soup.findAll('base'): 394 soup.base.extract() 401 soup.base.extract() 395 402 396 397 403 for tag in soup.head.findAll('link'): 398 404 if tag.has_key('rel'): … … 413 419 #handle root url case 414 420 href = href.replace(fqsubdomain, rel_path) 415 tag['href'] = href 416 421 tag['href'] = href 417 422 418 423 #replace style tags subdomain … … 426 431 #replace script tags subdomain 427 432 for tag in soup.head.findAll('script'): 428 if fqsubdomain in tag.contents[0]: 429 #remove domain 430 tag.contents[0].replaceWith(tag.contents[0].replace(fqsubdomain, rel_path)) 431 #replace %20 432 tag.contents[0].replaceWith(tag.contents[0].replace('%20','_')) 433 434 435 for key, value in modifiers.items(): 436 #HANDLE IMAGES 437 for tag in soup.findAll('img'): 438 if tag.has_key('src'): 439 src = tag['src'] 440 #remove http://DOMAIN/ and replace w/ rel_path 441 tag['src'] = src.replace(fqsubdomain + '/', rel_path) 442 433 if tag.has_key('src'): 434 if fqsubdomain in tag['src']: 435 #remove domain 436 src = tag['src'].replace(fqsubdomain, rel_path) 437 #replace %20 438 src = src.replace('%20', '_') 439 tag['src'] = src 440 441 #image handler 442 for tag in soup.findAll('img'): 443 doc_action_icons = ['print_icon.gif', 444 'rss_icon.gif', 445 'document_icon.gif', 446 's5_icon.jpg', 447 'bookmarklets.gif'] 448 if tag.has_key('src'): 449 src = tag['src'] 450 #remove http://DOMAIN/ and replace w/ rel_path 451 tag['src'] = src.replace(fqsubdomain + '/', rel_path) 452 453 for icon in doc_action_icons: 454 if icon == src: 455 tag['src'] = src.replace(icon, rel_path + icon) 443 456 444 457 #Rebuild links to zip file download to always point to course, since there is no acquisition … … 455 468 456 469 457 for link in soup.findAll('a'): 458 470 for link in soup.findAll('a'): 459 471 if link.has_key('href'): 460 472 href = link['href'] … … 478 490 elif 'front-page' in href: 479 491 href = href.replace('front-page/', '') 492 #download skinless_view 493 elif href.endswith('skinless_view'): 494 source = href 495 target = href.replace('/skinless_view', '.skinless.html') 496 target = target.replace(fqsubdomain + '/', '') 497 href = '%s%s' % (rel_path, target) 498 DownloadResource(source, target) 499 #download presentation view 500 elif href.endswith('presentation_view'): 501 source = href 502 target = href.replace('/presentation_view', '.presentation.html') 503 target = target.replace(fqsubdomain + '/', '') 504 href = '%s%s' % (rel_path, target) 505 DownloadResource(source, target) 506 new_file_anz, new_file = ModifyForStaticHTML('./%s' % target, modifiers, folder_list) 507 508 480 509 #rewrite links to zip file downloads of courses 481 510 for folder in folder_list: … … 484 513 if debug_mode >= 4: 485 514 DebugOutput('ModifyForStaticHTML -3', href) 515 486 516 #remove odd courselist/rss on front page 487 517 elif 'courselist/rss' == href: … … 493 523 # append .html for links of documents if they do not end in .htm or .html 494 524 for page in html_pages: 495 if page in href:525 if href.endswith(page): 496 526 if '.htm' not in href: 497 527 href = href.replace(page, page + '.html') 498 528 link['href'] = href 499 529 500 501 502 530 tmpfobj.write(soup.prettify()) 503 531 tmpfobj.close() 504 532 505 533 os.remove(filename) 506 os.rename(tmpfile _name, filename)534 os.rename(tmpfile, filename) 507 535 return new_file_anz, new_file 508 536 … … 523 551 folder_list = FindFilesToModify() 524 552 553 #Modify presentation.html files? 554 555 #Modify RDF files? 556 525 557 # Create file sitemap.xml.gz 526 558 #CreateSearchSitemap(folder_list)
