Changeset 225
- Timestamp:
- 05/22/09 11:04:44 (3 years ago)
- Location:
- plone-export/trunk
- Files:
-
- 2 modified
-
plone-static-export.py (modified) (10 diffs)
-
static_export.cpy (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plone-export/trunk/plone-static-export.py
r206 r225 90 90 'bookmarklets.gif', 91 91 'bullet.gif', 92 'courselist',93 92 'document_icon.gif', 94 93 'eduCommonsDivision.gif', … … 105 104 'rss_icon.gif', 106 105 'py.png', 106 '@@rss_feeds', 107 107 'robots.txt', 108 108 'search_icon.gif', … … 127 127 if file in ['accessibility-info', 'sitemap']: 128 128 target += '.html' 129 if file == 'courselist':130 target += '.html'129 elif file == '@@rss_feeds': 130 target = target.replace('@@rss_feeds', 'courselist/@@rss_feeds.html') 131 131 DownloadResource(source, target) 132 132 … … 154 154 if not os.path.exists(directory): 155 155 CreateDirectory(directory) 156 DownloadResource(source, target) 156 DownloadResource(source, target) 157 157 if 'portal_css' in line: 158 158 DownloadCSSImages(source, target, css_images) … … 328 328 return link, target 329 329 330 331 332 330 def FindFilesToModify(): 333 331 ''' Find files to modify them ''' … … 350 348 for root, dirs, files in os.walk('./'): 351 349 for file in files: 352 353 350 # Files which are looking for changes 354 351 if file.find('.html') >= 0 or file.find('.htm') >= 0: … … 396 393 for tag in soup.findAll('base'): 397 394 soup.base.extract() 395 396 397 for tag in soup.head.findAll('link'): 398 if tag.has_key('rel'): 399 #find objects with RDF link tags, and download the associated RDF document 400 if tag['rel'] == 'alternate': 401 if tag['type'] == 'application/rss+xml': 402 href = tag['href'].replace('RSS', 'rss') 403 tag['href'] = href.replace(fqsubdomain, '') 404 elif tag['type'] == 'application/rdf+xml': 405 source = tag['href'] 406 rdf_file = tag['href'].replace('/rdf', '.rdf') 407 target = rdf_file.replace(fqsubdomain + '/', '') 408 tag['href'] = '../%s' % target 409 DownloadResource(source, target) 410 #generic URL rewriter 411 href = tag['href'] 412 href = href.replace(fqsubdomain + '/', rel_path) 413 #handle root url case 414 href = href.replace(fqsubdomain, rel_path) 415 tag['href'] = href 416 398 417 399 418 #replace style tags subdomain … … 423 442 424 443 444 #Rebuild links to zip file download to always point to course, since there is no acquisition 445 for dl in soup.findAll('dl'): 446 if dl.has_key('class'): 447 if dl['class'] == 'portlet portletReuseCourse': 448 path_parts = dl.dd.a['href'].replace(fqsubdomain + '/', '').split('/') 449 zip_path = path_parts[0:2] + path_parts[-1:] 450 zip_path = rel_path + string.join(zip_path, '/') 451 dl.dd.a['href'] = zip_path 452 453 for div in soup.findAll('div', id='portal-personaltools-wrapper'): 454 div.extract() 455 456 425 457 for link in soup.findAll('a'): 458 426 459 if link.has_key('href'): 427 460 href = link['href'] … … 430 463 if href == 'http://demo.educommons.com': 431 464 href = '%s/index.html' % href 465 # download rss feeds 466 elif href.endswith('/rss'): 467 DownloadResource(href, href.replace(fqsubdomain, '')) 468 #replace with static url 469 elif href.endswith('@@rss'): 470 #rewrite views in rss_feeds.html page, no need to create duplicate copies of RSS feeds 471 if 'courselist' in href: 472 href = replace('courselist/', '') 473 href = href.replace('@@rss', 'rss') 474 #convert spaces to _ 432 475 elif '%20' in href: 433 476 href = href.replace('%20','_') 434 # change folder links to folder/index.html if link ends in /folder 477 #remove front-page path 478 elif 'front-page' in href: 479 href = href.replace('front-page/', '') 480 #rewrite links to zip file downloads of courses 435 481 for folder in folder_list: 436 482 if folder in href and href.endswith(folder): … … 438 484 if debug_mode >= 4: 439 485 DebugOutput('ModifyForStaticHTML -3', href) 486 #remove odd courselist/rss on front page 487 elif 'courselist/rss' == href: 488 href = href.replace('courselist/', '') 440 489 441 490 #remove http://DOMAIN/ and replace w/ rel_path -
plone-export/trunk/static_export.cpy
r206 r225 13 13 for content in context.portal_catalog(portal_type='Course', review_state='Published', sort_order = 'Date'): 14 14 objects += [content.getURL(),] 15 16 # Add Courselist folder 17 objects += [context.courselist.absolute_url(),] 15 18 16 19 else: … … 60 63 objects[obj_url] = obj_url 61 64 65 # Generate list of FSS files 66 for content in context.portal_catalog(portal_type='FSSFile', review_state='Published', sort_order = 'Date'): 67 obj_url = content.getURL() 68 objects[obj_url] = obj_url 69 70 # Add courselist folder 71 obj_url = content.courselist.absolute_url() 72 tar_url = '%s/index.html' % obj_url 73 objects[obj_url] = tar_url 74 62 75 # return the list of objects 63 76 return objects 64
