forked from cadence/breezewiki
		
	Match style URLs better in style archive server
This commit is contained in:
		
							parent
							
								
									7f85ce776b
								
							
						
					
					
						commit
						0ba20c9e38
					
				
					 2 changed files with 3 additions and 3 deletions
				
			
		
							
								
								
									
										2
									
								
								info.rkt
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								info.rkt
									
										
									
									
									
								
							|  | @ -1,3 +1,3 @@ | ||||||
| #lang info | #lang info | ||||||
| 
 | 
 | ||||||
| (define build-deps '("rackunit-lib" "web-server-lib" "http-easy-lib" "html-parsing" "html-writing" "json-pointer" "ini-lib" "memo" "net-cookies-lib")) | (define build-deps '("rackunit-lib" "web-server-lib" "http-easy-lib" "html-parsing" "html-writing" "json-pointer" "typed-ini-lib" "memo" "net-cookies-lib")) | ||||||
|  |  | ||||||
|  | @ -41,14 +41,14 @@ | ||||||
|                  [(string-prefix? url "http://") (regexp-replace #rx"http:" url "https:")] |                  [(string-prefix? url "http://") (regexp-replace #rx"http:" url "https:")] | ||||||
|                  [(string-prefix? url "//") (string-append "https:" url)] |                  [(string-prefix? url "//") (string-append "https:" url)] | ||||||
|                  [(string-prefix? url "/") (format "https://~a.fandom.com~a" wikiname url)] |                  [(string-prefix? url "/") (format "https://~a.fandom.com~a" wikiname url)] | ||||||
|                  [else (raise-user-error "While calling replace-style-for-images, this URL had an unknown format and couldn't be saved:" url)])]) |                  [else (error 'replace-style-for-images "unknown URL format: ~a" url)])]) | ||||||
|          (define p (image-url->values norm-url)) |          (define p (image-url->values norm-url)) | ||||||
|          ;; (printf "hashed: ~a~n     -> ~a~n    #-> ~a~n" url (car p) (cdr p)) |          ;; (printf "hashed: ~a~n     -> ~a~n    #-> ~a~n" url (car p) (cdr p)) | ||||||
|          (format "/archive/~a/images/~a" wikiname (cdr p)))))) |          (format "/archive/~a/images/~a" wikiname (cdr p)))))) | ||||||
| 
 | 
 | ||||||
| (define (replace-style-for-images wikiname path) | (define (replace-style-for-images wikiname path) | ||||||
|   (define content (file->string path)) |   (define content (file->string path)) | ||||||
|   (regexp-replace* #rx"url\\(([^)]*)\\)" content (replacer wikiname))) |   (regexp-replace* #rx"url\\(\"?'?([^)]*)'?\"?\\)" content (replacer wikiname))) | ||||||
| 
 | 
 | ||||||
| (define (handle-style wikiname dest) | (define (handle-style wikiname dest) | ||||||
|   (when (config-true? 'debug) |   (when (config-true? 'debug) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue