mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2024-08-14 23:57:27 +00:00 
			
		
		
		
	Merge pull request #1870 from PrivacyDevel/master
added script to download and serve fonts locally by default
This commit is contained in:
		
						commit
						10bd1b482f
					
				
					 5 changed files with 18 additions and 4 deletions
				
			
		
							
								
								
									
										2
									
								
								.github/workflows/deploy-azure.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/deploy-azure.yml
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -24,7 +24,7 @@ jobs:
 | 
			
		|||
          ###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
 | 
			
		||||
          # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
 | 
			
		||||
          app_location: "/" # App source code path
 | 
			
		||||
          app_build_command: "yarn build && sed -i 's/fonts.gstatic.com/fonts.kavin.rocks/g' dist/assets/*.css"
 | 
			
		||||
          app_build_command: "yarn build && ./localizefonts.sh"
 | 
			
		||||
          api_location: "" # Api source code path - optional
 | 
			
		||||
          output_location: "dist" # Built app content directory - optional
 | 
			
		||||
          ###### End of Repository/Build Configurations ######
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								.github/workflows/docker-build.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/docker-build.yml
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -17,7 +17,7 @@ jobs:
 | 
			
		|||
              with:
 | 
			
		||||
                  cache: "yarn"
 | 
			
		||||
            - run: yarn install --prefer-offline
 | 
			
		||||
            - run: yarn build --out-dir dist-ci && sed -i 's/fonts.gstatic.com/fonts.kavin.rocks/g' dist-ci/assets/*.css
 | 
			
		||||
            - run: yarn build --out-dir dist-ci && ./localize-fonts.sh
 | 
			
		||||
            - name: Set up QEMU
 | 
			
		||||
              uses: docker/setup-qemu-action@v2
 | 
			
		||||
              with:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								.github/workflows/ipfs-build.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/ipfs-build.yml
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -17,7 +17,7 @@ jobs:
 | 
			
		|||
        with:
 | 
			
		||||
          cache: "yarn"
 | 
			
		||||
      - run: yarn install --prefer-offline
 | 
			
		||||
      - run: yarn build && sed -i 's/fonts.gstatic.com/fonts.kavin.rocks/g' dist/assets/*.css && cp dist/index.html dist/ipfs-404.html
 | 
			
		||||
      - run: yarn build && ./localizefonts.sh && cp dist/index.html dist/ipfs-404.html
 | 
			
		||||
      - uses: aquiladev/ipfs-action@v0.3.1-alpha.2
 | 
			
		||||
        id: ipfs-add
 | 
			
		||||
        with:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,12 +2,16 @@ FROM node:lts-alpine AS build
 | 
			
		|||
 | 
			
		||||
WORKDIR /app/
 | 
			
		||||
 | 
			
		||||
RUN --mount=type=cache,target=/var/cache/apk \
 | 
			
		||||
    apk add --no-cache \
 | 
			
		||||
    curl
 | 
			
		||||
 | 
			
		||||
COPY . .
 | 
			
		||||
 | 
			
		||||
RUN --mount=type=cache,target=/root/.cache/yarn \
 | 
			
		||||
    --mount=type=cache,target=/app/node_modules \
 | 
			
		||||
    yarn install --prefer-offline && \
 | 
			
		||||
    yarn build && sed -i 's/fonts.gstatic.com/fonts.kavin.rocks/g' dist/assets/*.css
 | 
			
		||||
    yarn build && ./localizefonts.sh
 | 
			
		||||
 | 
			
		||||
FROM nginx:alpine
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								localizefonts.sh
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								localizefonts.sh
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,10 @@
 | 
			
		|||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
base='https://fonts\.(gstatic\.com|kavin\.rocks)'
 | 
			
		||||
fonts=$(cat dist/assets/* | grep -Po "$base[^)]*" | sort | uniq)
 | 
			
		||||
for font in $fonts; do
 | 
			
		||||
	file="dist/fonts$(echo $font | sed -E "s#$base##")"
 | 
			
		||||
	mkdir -p "$(dirname "$file")"
 | 
			
		||||
	curl -L "$font" -o "$file"
 | 
			
		||||
done
 | 
			
		||||
sed -Ei "s#$base#/fonts#g" dist/assets/*
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue