Markdown caching system
This commit is contained in:
		
							parent
							
								
									99eebb00d5
								
							
						
					
					
						commit
						b2145a232f
					
				
					 2 changed files with 22 additions and 3 deletions
				
			
		|  | @ -8,6 +8,8 @@ ifs='/' { | ||||||
| cd .. | cd .. | ||||||
| 
 | 
 | ||||||
| # default config | # default config | ||||||
|  | formater=markdown.pl | ||||||
|  | formater=md_cache # markdown cacher | ||||||
| site=$SERVER_NAME | site=$SERVER_NAME | ||||||
| sitedir=sites/$site | sitedir=sites/$site | ||||||
| headers=inc/headers.tpl | headers=inc/headers.tpl | ||||||
|  | @ -83,8 +85,8 @@ fn blogTitle { | ||||||
| fn genbody { | fn genbody { | ||||||
|     if ( test -f $body.md ) { |     if ( test -f $body.md ) { | ||||||
|         if ( ! ~ $#inBlog 0 ) |         if ( ! ~ $#inBlog 0 ) | ||||||
|             blogTitle $body.md | markdown.pl |             blogTitle $body.md | $formater | ||||||
|         markdown.pl < $body.md |         $formater < $body.md | ||||||
|     } |     } | ||||||
|     if not if ( test -f $body.tpl ) |     if not if ( test -f $body.tpl ) | ||||||
|         template.awk $body.tpl | rc $rcargs |         template.awk $body.tpl | rc $rcargs | ||||||
|  | @ -116,7 +118,7 @@ fn genbody { | ||||||
|             blogTitle $f |             blogTitle $f | ||||||
|             cat $f  |             cat $f  | ||||||
|             echo  |             echo  | ||||||
|         } | markdown.pl  |         } | $formater | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										17
									
								
								bin/md_cache
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										17
									
								
								bin/md_cache
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,17 @@ | ||||||
|  | #!/bin/rc | ||||||
|  | . 9.rc | ||||||
|  | 
 | ||||||
|  | cachedir=/tmp/md_cache | ||||||
|  | mkdir -p $cachedir >[2]/dev/null | ||||||
|  | 
 | ||||||
|  | tmpfile=$cachedir/mdtmp.$pid | ||||||
|  | score=`{{tee $tmpfile || exit 1} | sha1sum} | ||||||
|  | cachefile=$cachedir/$score | ||||||
|  | 
 | ||||||
|  | if(test -f $cachefile) | ||||||
|  |     cat $cachefile | ||||||
|  | if not { | ||||||
|  |     markdown.pl < $tmpfile | tee $cachefile.$pid | ||||||
|  |     mv $cachefile.$pid $cachefile | ||||||
|  | } | ||||||
|  | rm $tmpfile >[2]/dev/null | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Uriel
						Uriel