forked from HPR/hpr_generator
		
	Add baseurl feature
Allow an optional base url to be included in generation of html files.
This commit is contained in:
		| @@ -116,7 +116,11 @@ sub main { | ||||
| 		if (exists($config{$parsed_arg{'page'}})) { | ||||
| 			my $page_config = $config{$parsed_arg{'page'}};  | ||||
| 			$page_config->{'page'} = $parsed_arg{'page'}; | ||||
| 		 | ||||
| 			$page_config->{'root_template'} = $config{root_template}{content}; | ||||
| 			if (exists $config{root_template}{baseurl}) { | ||||
| 				$page_config->{'baseurl'} = $config{root_template}{baseurl}; | ||||
| 			} | ||||
|  | ||||
| 			if ($page_config->{'multipage'} && $page_config->{'multipage'} eq 'true') { | ||||
| 				if (scalar @{$parsed_arg{'ids'}} == 1) { | ||||
| 				  @{$parsed_arg{'ids'}} = get_ids_from_db($tt, \$page_config);	 | ||||
| @@ -124,13 +128,12 @@ sub main { | ||||
| 				foreach my $id (@{$parsed_arg{'ids'}}) { | ||||
| 					$page_config->{'id'} = $id; | ||||
| 					verbose ($verbose, "Generating page: $page_config->{'page'} with id: $id"); | ||||
| 					generate_page($tt, $config{root_template}{content}, \$page_config, $preview); | ||||
| 					print "$page_config->{'page'} $page_config->{'id'}\n"; | ||||
| 					generate_page($tt, \$page_config, $preview); | ||||
| 				} | ||||
| 			} | ||||
| 			else { | ||||
| 				verbose ($verbose, "Generating page: $page_config->{'page'}"); | ||||
| 				generate_page($tt, $config{root_template}{content}, \$page_config, $preview); | ||||
| 				generate_page($tt, \$page_config, $preview); | ||||
| 			} | ||||
| 		} | ||||
| 		else { | ||||
| @@ -164,12 +167,12 @@ sub get_template_html (\%@)  { | ||||
| } | ||||
|  | ||||
| sub generate_page  { | ||||
| 	my ($tt, $root_template, $config, $preview) = @_; | ||||
| 	my ($tt, $config, $preview) = @_; | ||||
| 	my $html; | ||||
| 	if (!$preview) { | ||||
| 		$html = get_filename($$config);  | ||||
| 	} | ||||
| 	$tt->process($root_template, $$config, $html) | ||||
| 	$tt->process($$config->{root_template}, $$config, $html) | ||||
| 	|| die $tt->error(), "\n"; | ||||
|  | ||||
| } | ||||
|   | ||||
							
								
								
									
										5
									
								
								site.cfg
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								site.cfg
									
									
									
									
									
								
							| @@ -7,9 +7,12 @@ user: | ||||
| password:  | ||||
|  | ||||
| # Configure the root template page which pulls in the navigation and  | ||||
| # content templates used by each page. | ||||
| # content templates used by each page. An optional baseurl property may  | ||||
| # be defined. This is useful when opening files directly from local  | ||||
| # filesystem to allow relative paths to work. | ||||
| [root_template] | ||||
| content: page.tpl.html | ||||
| #baseurl: OPTIONAL [i.e. file://<full path to local website directory>] | ||||
|  | ||||
| # Configure the navigation menu and the content templates for each page  | ||||
| # of the site: | ||||
|   | ||||
| @@ -2,6 +2,9 @@ | ||||
| <html lang="en"> | ||||
| <head> | ||||
|   <title>Hacker Public Radio ~ The Technology Community Podcast</title> | ||||
|   <!--% IF baseurl %--> | ||||
|   <base href="<!--% baseurl %-->"> | ||||
|   <!--% END %--> | ||||
|   <meta charset="utf-8" /> | ||||
|   <meta http-equiv="X-Clacks-Overhead" content="GNU Terry Pratchett" /> | ||||
|   <meta name="keywords" content="Technology, Tech News, Education, Training" /> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user