Browse Source

Allow use CDN for static resources of syzoj itself

pull/6/head
Menci 6 years ago
parent
commit
94281dad53
  1. 6
      config-example.json
  2. 0
      static/self/mathjax.css
  3. 0
      static/self/script.js
  4. 0
      static/self/style.css
  5. 0
      static/self/syzoj.svg
  6. 0
      static/self/tomorrow.css
  7. 2
      views/footer.ejs
  8. 21
      views/header.ejs
  9. 8
      views/util.ejs

6
config-example.json

@ -114,5 +114,9 @@
"email_jwt_secret": "@EMAIL_JWT_SECRET@", "email_jwt_secret": "@EMAIL_JWT_SECRET@",
"google_analytics": "UA-XXXXXXXX-X", "google_analytics": "UA-XXXXXXXX-X",
"cdnjs_url": "https://cdnjs.loli.net/ajax/libs", "cdnjs_url": "https://cdnjs.loli.net/ajax/libs",
"google_fonts_url": "https://fonts.loli.net" "self_cdn_url": "",
"google_fonts": {
"type": "like-google-fonts",
"url": "https://fonts.loli.net"
}
} }

0
static/mathjax.css → static/self/mathjax.css

0
static/script.js → static/self/script.js

0
static/style.css → static/self/style.css

0
static/syzoj.svg → static/self/syzoj.svg

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

0
static/tomorrow.css → static/self/tomorrow.css

2
views/footer.ejs

@ -7,6 +7,6 @@
</div> </div>
<script src="<%- lib('semantic-ui/2.4.1/semantic.min.js') %>"></script> <script src="<%- lib('semantic-ui/2.4.1/semantic.min.js') %>"></script>
<script src="<%- lib('Chart.js/2.7.3/Chart.bundle.min.js') %>"></script> <script src="<%- lib('Chart.js/2.7.3/Chart.bundle.min.js') %>"></script>
<script src="/script.js?20170710"></script> <script src="<%- selfLib('script.js') %>?20170710"></script>
</body> </body>
</html> </html>

21
views/header.ejs

@ -7,21 +7,26 @@
<meta name="viewport" content="width=1200"> <meta name="viewport" content="width=1200">
<title><%= title %> - <%= syzoj.config.title %></title> <title><%= title %> - <%= syzoj.config.title %></title>
<link href="<%- lib('semantic-ui/2.4.1/semantic.min.css') %>" rel="stylesheet"> <link href="<%- lib('semantic-ui/2.4.1/semantic.min.css') %>" rel="stylesheet">
<link href="/tomorrow.css" rel="stylesheet"> <link href="<%- selfLib('tomorrow.css') %>" rel="stylesheet">
<link href="/mathjax.css?20181105" rel="stylesheet"> <link href="<%- selfLib('mathjax.css') %>?20181105" rel="stylesheet">
<link href="<%- selfLib('style.css') %>?20181212" rel="stylesheet">
<link href="<%- lib('KaTeX/0.10.0/katex.min.css') %>" rel="stylesheet"> <link href="<%- lib('KaTeX/0.10.0/katex.min.css') %>" rel="stylesheet">
<link href="<%- lib('morris.js/0.5.1/morris.css') %>" rel="stylesheet"> <link href="<%- lib('morris.js/0.5.1/morris.css') %>" rel="stylesheet">
<link href="/style.css?20181212" rel="stylesheet"> <% if (useLocalLibs || !syzoj.config.google_fonts || !syzoj.config.google_fonts.url || !['like-google-fonts', 'like-local'].includes(syzoj.config.google_fonts.type)) { %>
<% if (useLocalLibs || !syzoj.config.google_fonts_url) { %>
<link href="<%- syzoj.utils.makeUrl(['google-fonts', 'fira-mono.css']) %>" rel="stylesheet"> <link href="<%- syzoj.utils.makeUrl(['google-fonts', 'fira-mono.css']) %>" rel="stylesheet">
<link href="<%- syzoj.utils.makeUrl(['google-fonts', 'lato.css']) %>" rel="stylesheet"> <link href="<%- syzoj.utils.makeUrl(['google-fonts', 'lato.css']) %>" rel="stylesheet">
<link href="<%- syzoj.utils.makeUrl(['google-fonts', 'open-sans.css']) %>" rel="stylesheet"> <link href="<%- syzoj.utils.makeUrl(['google-fonts', 'open-sans.css']) %>" rel="stylesheet">
<link href="<%- syzoj.utils.makeUrl(['google-fonts', 'exo-2.css']) %>" rel="stylesheet"> <link href="<%- syzoj.utils.makeUrl(['google-fonts', 'exo-2.css']) %>" rel="stylesheet">
<% } else if (syzoj.config.google_fonts.type === 'like-local') { %>
<link href="<%- syzoj.config.google_fonts.url %>/google-fonts/fira-mono.css" rel="stylesheet">
<link href="<%- syzoj.config.google_fonts.url %>/google-fonts/lato.css" rel="stylesheet">
<link href="<%- syzoj.config.google_fonts.url %>/google-fonts/open-sans.css" rel="stylesheet">
<link href="<%- syzoj.config.google_fonts.url %>/google-fonts/exo-2.css" rel="stylesheet">
<% } else { %> <% } else { %>
<link href="<%- syzoj.config.google_fonts_url %>/css?family=Fira+Mono" rel="stylesheet"> <link href="<%- syzoj.config.google_fonts.url %>/css?family=Fira+Mono" rel="stylesheet">
<link href="<%- syzoj.config.google_fonts_url %>/css?family=Lato:400,700,400italic,700italic&subset=latin" rel="stylesheet"> <link href="<%- syzoj.config.google_fonts.url %>/css?family=Lato:400,700,400italic,700italic&subset=latin" rel="stylesheet">
<link href="<%- syzoj.config.google_fonts_url %>/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i&amp;subset=latin-ext" rel="stylesheet"> <link href="<%- syzoj.config.google_fonts.url %>/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i&amp;subset=latin-ext" rel="stylesheet">
<link href="<%- syzoj.config.google_fonts_url %>/css?family=Exo+2:600" rel="stylesheet"> <link href="<%- syzoj.config.google_fonts.url %>/css?family=Exo+2:600" rel="stylesheet">
<% } %> <% } %>
<script src="<%- lib('jquery/3.3.1/jquery.min.js') %>"></script> <script src="<%- lib('jquery/3.3.1/jquery.min.js') %>"></script>
<% if (syzoj.config.google_analytics && syzoj.config.google_analytics !== 'UA-XXXXXXXX-X') { %> <% if (syzoj.config.google_analytics && syzoj.config.google_analytics !== 'UA-XXXXXXXX-X') { %>

8
views/util.ejs

@ -74,4 +74,12 @@ this.lib = uri => {
} }
} }
this.selfLib = uri => {
if (useLocalLibs || !syzoj.config.self_cdn_url) {
return syzoj.utils.makeUrl(['self', uri]);
} else {
return syzoj.config.self_cdn_url + '/' + uri;
}
}
%> %>

Loading…
Cancel
Save