2024-06-09 18:14:53 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $siteSourceUrl := site.Params.siteSourceUrl -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{{- $submoduleLinks := site.Data.submodules -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:50:00 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $hostData := site.Data.hosts -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $scratch := .scratch -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:50:00 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $lines := .lines -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $scratch.Set "bestLength" -1 -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:14:53 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $scratch.Set "bestUrl" (printf "%s/code/%s" $siteSourceUrl .path) -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-22 16:35:04 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $scratch.Set "bestPath" "" -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- $filePath := .path -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:14:53 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- range $path, $url := $submoduleLinks -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:50:00 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    {{- $bestLength := $scratch.Get "bestLength" -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {{- if and (le $bestLength (len $path)) (hasPrefix $filePath $path) -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        {{- $scratch.Set "bestLength" (len $path) -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        {{- $scratch.Set "bestPath" $path -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        {{- $scratch.Set "bestUrl" (printf "%s%s" $url (strings.TrimPrefix $path $filePath)) -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {{- end -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- end -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-06-09 18:50:00 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- if .lines -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{{- /* If the user provided a line range, see if we can tack it on to the end of the link. */ -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {{- range $host, $data := $hostData -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        {{- if hasPrefix ($scratch.Get "bestUrl") $host -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            {{- with $data.linesSuffix -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                {{- $scratch.Add "bestUrl" (printf . (index $lines 0) (index $lines 1)) -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            {{- end -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        {{- end -}}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {{- end -}}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-21 21:42:35 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								{{- end -}}
							 |