Skip to content

Commit

Permalink
增加host检测
Browse files Browse the repository at this point in the history
  • Loading branch information
Liudon committed Sep 27, 2024
1 parent dea5ecc commit 54b530c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 182 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ jobs:
ls -l ./
hugo --gc --minify --cleanDestinationDir
- name: Push
uses: peaceiris/actions-gh-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
github_token: ${{ secrets.TOKEN }}
publish_branch: master
force_orphan: true
publish_dir: ./public
cname: liudon.com
# Upload dist repository
path: './public'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
8 changes: 0 additions & 8 deletions .github/workflows/ipfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ jobs:
hugo-version: 'latest'
extended: true

- name: Update config.yml
uses: fjogeleit/yaml-update-action@main
with:
valueFile: 'config.yml'
propertyPath: 'params.robotsNoIndex'
value: "!!bool 'true'"
commitChange: false

- name: Build
run: |
hugo --gc --minify --cleanDestinationDir
Expand Down
23 changes: 23 additions & 0 deletions layouts/partials/extend_footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,29 @@
</script>
{{- end }}
<script>
const host = window.location.host
if (host !== 'blog.liudon.xyz' && ! host.startsWith('liudon.') && ! host.startsWith('localhost') && ! host.startsWith('127.0.0.1')) {
document.body.innerHTML = [
'<div style="margin: auto;">',
'<h1>即将在2秒后跳转到本人博客: https://liudon.com。</h1>',
'<br />',
'</div>',
].join('')
document.body.style = [
'background-color: white;',
'color: black;',
'text-align: center;',
'font-size: 50px;',
'width: 100vw;',
'height: 100vh;',
'display: flex;',
].join('')
setTimeout(() => {
window.location.href = 'https://liudon.com'
}, 2000)
}
</script>
<script>
enScroll=!1,enFdl=!1,extCurrent=void 0,filename=void 0,targetText=void 0,splitOrigin=void 0;const lStor=localStorage,sStor=sessionStorage,doc=document,docEl=document.documentElement,docBody=document.body,docLoc=document.location,w=window,s=screen,nav=navigator||{},extensions=["pdf","xls","xlsx","doc","docx","txt","rtf","csv","exe","key","pps","ppt","pptx","7z","pkg","rar","gz","zip","avi","mov","mp4","mpe","mpeg","wmv","mid","midi","mp3","wav","wma"];function a(e,t,n,o){const j="G-G9ZDJQN9E2",r=()=>Math.floor(Math.random()*1e9)+1,c=()=>Math.floor(Date.now()/1e3),F=()=>(sStor._p||(sStor._p=r()),sStor._p),E=()=>r()+"."+c(),_=()=>(lStor.cid_v4||(lStor.cid_v4=E()),lStor.cid_v4),m=lStor.getItem("cid_v4"),v=()=>m?void 0:enScroll==!0?void 0:"1",p=()=>(sStor.sid||(sStor.sid=c()),sStor.sid),O=()=>{if(!sStor._ss)return sStor._ss="1",sStor._ss;if(sStor.getItem("_ss")=="1")return void 0},a="1",g=()=>{if(sStor.sct)if(enScroll==!0)return sStor.sct;else x=+sStor.getItem("sct")+ +a,sStor.sct=x;else sStor.sct=a;return sStor.sct},i=docLoc.search,b=new URLSearchParams(i),h=["q","s","search","query","keyword"],y=h.some(e=>i.includes("&"+e+"=")||i.includes("?"+e+"=")),u=()=>y==!0?"view_search_results":enScroll==!0?"scroll":enFdl==!0?"file_download":"page_view",f=()=>enScroll==!0?"90":void 0,C=()=>{if(u()=="view_search_results"){for(let e of b)if(h.includes(e[0]))return e[1]}else return void 0},d=encodeURIComponent,k=e=>{let t=[];for(let n in e)e.hasOwnProperty(n)&&e[n]!==void 0&&t.push(d(n)+"="+d(e[n]));return t.join("&")},A=!1,S="https://liudon.com/analytics/post",M=k({tid:j,_p:F(),v:"2",sr:(s.width*w.devicePixelRatio+"x"+s.height*w.devicePixelRatio).toString(),ul:(nav.language||void 0).toLowerCase(),cid:_(),_fv:v(),_s:"1",dl:docLoc.origin+docLoc.pathname+i,dt:doc.title||void 0,dr:doc.referrer||void 0,sid:p(),sct:g(),seg:"1",en:u(),"epn.percent_scrolled":f(),"ep.search_term":C(),"ep.file_extension":e||void 0,"ep.file_name":t||void 0,"ep.link_text":n||void 0,"ep.link_url":o||void 0,_ss:O(),_dbg:A?1:void 0}),l=S+"?"+M;if(nav.sendBeacon)nav.sendBeacon(l);else{let e=new XMLHttpRequest;e.open("POST",l,!0)}}a();function sPr(){return(docEl.scrollTop||docBody.scrollTop)/((docEl.scrollHeight||docBody.scrollHeight)-docEl.clientHeight)*100}doc.addEventListener("scroll",sEv,{passive:!0});function sEv(){const e=sPr();if(e<90)return;enScroll=!0,a(),doc.removeEventListener("scroll",sEv,{passive:!0}),enScroll=!1}document.addEventListener("DOMContentLoaded",function(){let e=document.getElementsByTagName("a");for(let t=0;t<e.length;t++)if(e[t].getAttribute("href")!=null){const n=e[t].getAttribute("href"),s=n.substring(n.lastIndexOf("/")+1),o=s.split(".").pop();(e[t].hasAttribute("download")||extensions.includes(o))&&e[t].addEventListener("click",fDl,{passive:!0})}});function fDl(e){enFdl=!0;const t=e.currentTarget.getAttribute("href"),n=t.substring(t.lastIndexOf("/")+1),s=n.split(".").pop(),o=n.replace("."+s,""),i=e.currentTarget.text,r=t.replace(docLoc.origin,"");a(s,o,i,r),enFdl=!1}
</script>
<!--script src="//liudon.com/analytics/vue.js" async></script-->
Expand Down
167 changes: 0 additions & 167 deletions layouts/partials/head.html

This file was deleted.

0 comments on commit 54b530c

Please sign in to comment.