Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持非根URL/Add support for non-base url #270

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<a class="not-found-link" href="javascript:history.back()">
{% fa_svg fas.fa-arrow-left %} 返回上一页
</a>
<a class="not-found-link" href="/">
<a class="not-found-link" href="{ '/' | relative_url }">
镜像列表 {% fa_svg fas.fa-arrow-right %}
</a>
</div>
Expand Down
14 changes: 12 additions & 2 deletions _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ <h4>Contact Us</h4>
<h4>Sponsor</h4>
<div class="img-responsive thuhidden">
{% for sponsor in site.sponsor %}
<img src="/static/img/{{ site.sponsors[sponsor].logo }}.png" srcset="/static/img/{{ site.sponsors[sponsor].logo }}.png 1x, /static/img/{{ site.sponsors[sponsor].logo }}@2x.png 2x, /static/img/{{ site.sponsors[sponsor].logo }}@3x.png 3x, /static/img/{{ site.sponsors[sponsor].logo }}@4x.png 4x" alt="{{ site.sponsors[sponsor].short }}" />
<img src="{{ '/static/img/' | append: site.sponsors[sponsor].logo | append: '.png' | relative_url }}" srcset="
{{ '/static/img/' | append: site.sponsors[sponsor].logo | append: '.png' | relative_url }} 1x,
{{ '/static/img/' | append: site.sponsors[sponsor].logo | append: '@2x.png' | relative_url }} 2x,
{{ '/static/img/' | append: site.sponsors[sponsor].logo | append: '@3x.png' | relative_url }} 3x,
{{ '/static/img/' | append: site.sponsors[sponsor].logo | append: '@4x.png' | relative_url }} 4x"
alt="{{ site.sponsors[sponsor].short }}" />
{% endfor %}
</div>
{% assign first_sponsor = site.sponsors[site.sponsor.first] %}
Expand All @@ -51,7 +56,12 @@ <h4>Sponsor</h4>
{% endif %}
</div>
<div class="col-lg-4 col-md-4{% if page.legacy %} col-xs-4{% endif %}">
<img class="img-responsive thuhidden center-block" style="margin-top:5%" src="/static/img/logo-white.png" srcset="/static/img/logo-white.png 1x, /static/img/[email protected] 2x, /static/img/[email protected] 3x, /static/img/[email protected] 4x" />
<img class="img-responsive thuhidden center-block" style="margin-top:5%"
src="{{ '/static/img/logo-white.png' | relative_url }}" srcset="
{{ '/static/img/logo-white.png' | relative_url }} 1x,
{{ '/static/img/[email protected]' | relative_url }} 2x,
{{ '/static/img/[email protected]' | relative_url }} 3x,
{{ '/static/img/[email protected]' | relative_url }} 4x" />
</div>
</div><!--/row -->
</div><!--/container -->
Expand Down
24 changes: 12 additions & 12 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta name="description" content="{{ page_desc }}">
<meta name="keywords" content="镜像站,镜像源,Linux,软件源,开源">
<meta name="author" content="{{ site.author }}">
<link rel="shortcut icon" href="/static/img/favicon.png">
<link rel="shortcut icon" href="{{ '/static/img/favicon.png' | relative_url}}">

<!-- Open Graph metadata -->
<meta property="og:title" content="{{ page_title }}" />
Expand All @@ -29,19 +29,19 @@

<title>{{ page_title }}</title>
{% unless include.nostyle %}
<link rel="stylesheet" href="/static/css/bootstrap.min.css?{{ site.data['hash'] }}">
<link rel="stylesheet" href="/static/css/bootstrap-select.min.css?{{ site.data['hash'] }}">
<link rel="stylesheet" href="/static/css/style.css?{{ site.data['hash'] }}">
<script src="/static/js/jquery.min.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/bootstrap.min.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/bootstrap-select.min.js?{{ site.data['hash'] }}"></script>
<link rel="stylesheet" href="{{ 'static/css/bootstrap.min.css?' | append: site.data['hash'] | relative_url }}">
<link rel="stylesheet" href="{{ 'static/css/bootstrap-select.min.css?' | append: site.data['hash'] | relative_url }}">
<link rel="stylesheet" href="{{ 'static/css/style.css?' | append: site.data['hash'] | relative_url }}">
<script src="{{ 'static/js/jquery.min.js?' | append: site.data['hash'] | relative_url }}"></script>
<script src="{{ 'static/js/bootstrap.min.js?' | append: site.data['hash'] | relative_url }}"></script>
<script src="{{ 'static/js/bootstrap-select.min.js?' | append: site.data['hash'] | relative_url }}"></script>
{% unless page.legacy %}
<script src="/static/js/vue.min.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/timeago.min.js?{{ site.data['hash'] }}"></script>
<script src="{{ 'static/js/vue.min.js?' | append: site.data['hash'] | relative_url }}"></script>
<script src="{{ 'static/js/timeago.min.js?' | append: site.data['hash'] | relative_url }}"></script>
{% endunless %}
<script src="/static/js/markup.min.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/webfont.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/thuhidden.js?{{ site.data['hash'] }}"></script>
<script src="{{ 'static/js/markup.min.js?' | append: site.data['hash'] | relative_url }}"></script>
<script src="{{ 'static/js/webfont.js?' | append: site.data['hash'] | relative_url }}"></script>
<script src="{{ 'static/js/thuhidden.js?' | append: site.data['hash'] | relative_url }}"></script>
{% if page.legacy %}
<style>
.container {
Expand Down
8 changes: 4 additions & 4 deletions _includes/legacy_notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<p>Bonjour! </p>
<p>宜しくお願い致します。</p>
<p>&nbsp;</p>
<p>我们检测到您当前的浏览器不能正常显示我们的主页,请更新您的浏览器,并启用 Javascript,或者访问我们的<a href="/legacy_index">代用页面</a>。</p>
<p>Your browser is not compatible with our website. Please upgrade and enable Javascript, or visit our <a href="/legacy_index">alternative page</a>.</p>
<p>Votre navigateur n'est pas compatible avec notre site web. Mettez à niveau et activez Javascript, ou visitez notre <a href="/legacy_index">page alternative</a>.</p>
<p>お使いのブラウザは当サイトとの互換性はありません。ブラウザを更新しJavaScriptを有効にするか、或いはこちらの<a href="/legacy_index">代用ページ</a>をご利用ください。</p>
<p>我们检测到您当前的浏览器不能正常显示我们的主页,请更新您的浏览器,并启用 Javascript,或者访问我们的<a href="{{ '/legacy_index' | relative_url}}">代用页面</a>。</p>
<p>Your browser is not compatible with our website. Please upgrade and enable Javascript, or visit our <a href="{{ '/legacy_index' | relative_url}}">alternative page</a>.</p>
<p>Votre navigateur n'est pas compatible avec notre site web. Mettez à niveau et activez Javascript, ou visitez notre <a href="{{ '/legacy_index' | relative_url}}">page alternative</a>.</p>
<p>お使いのブラウザは当サイトとの互換性はありません。ブラウザを更新しJavaScriptを有効にするか、或いはこちらの<a href="{{ '/legacy_index' | relative_url}}">代用ページ</a>をご利用ください。</p>
</div>
</div>
{% endraw %}
20 changes: 10 additions & 10 deletions _includes/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<span class="icon-bar"></span>
</button>
{% endunless %}
<a class="navbar-brand" href="/">
<a class="navbar-brand" href="{{ '/' | relative_url}}">
<span class="thuhidden">
{% if site.logo %}
<picture>
Expand All @@ -18,21 +18,21 @@
{% else %}
<source
{% endif %}
srcset="/static/img/logo-small-dark.png 1x,
/static/img/[email protected] 2x,
/static/img/[email protected] 3x,
/static/img/[email protected] 4x"
srcset="{{ '/static/img/logo-small-dark.png'}} 1x,
{{ '/static/img/[email protected]' | relative_url}} 2x,
{{ '/static/img/[email protected]' | relative_url}} 3x,
{{ '/static/img/[email protected]' | relative_url}} 4x"
{% if site.issue %}
alt=""/>
{% else %}
media="(prefers-color-scheme: dark)"/>
{% endif %}
{% unless site.issue %}
<img src="/static/img/logo-small.png"
srcset="/static/img/logo-small.png 1x,
/static/img/[email protected] 2x,
/static/img/[email protected] 3x,
/static/img/[email protected] 4x"
<img src="{{ '/static/img/logo-small.png' | relative_url}}"
srcset="{{ '/static/img/logo-small.png' | relative_url}} 1x,
{{ '/static/img/[email protected]' | relative_url}} 2x,
{{ '/static/img/[email protected]' | relative_url}} 3x,
{{ '/static/img/[email protected]' | relative_url}}4x"
alt=""/>
{% endunless %}
</picture>
Expand Down
19 changes: 10 additions & 9 deletions _includes/status-pic.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<div class="col-md-6 col-xs-12">
<picture class="thumbnail">

<source
srcset="/static/status/{{include.name}}-day-dark.png 1x,
/static/status/{{include.name}}[email protected] 2x,
/static/status/{{include.name}}[email protected] 3x,
/static/status/{{include.name}}[email protected] 4x"
srcset="{{ '/static/status/' | append: include.name | append: '-day-dark.png' | relative_url }} 1x,
{{ '/static/status/' | append: include.name | append: '[email protected]' | relative_url }} 2x,
{{ '/static/status/' | append: include.name | append: '[email protected]' | relative_url }} 3x,
{{ '/static/status/' | append: include.name | append: '[email protected]' | relative_url }} 4x"
media="(prefers-color-scheme: dark)" />
<img class="img-responsive" src="/static/status/{{include.name}}-day.png"
srcset="/static/status/{{include.name}}-day.png 1x,
/static/status/{{include.name}}[email protected] 2x,
/static/status/{{include.name}}[email protected] 3x,
/static/status/{{include.name}}[email protected] 4x"
<img class="img-responsive" src="{{ '/static/status/' | append: include.name | append: '-day.png' | relative_url }}"
srcset="{{ '/static/status/' | append: include.name | append: '-day.png' | relative_url }} 1x,
{{ '/static/status/' | append: include.name | append: '[email protected]' | relative_url }} 2x,
{{ '/static/status/' | append: include.name | append: '[email protected]' | relative_url }} 3x,
{{ '/static/status/' | append: include.name | append: '[email protected]' | relative_url }} 4x"
/>
</picture>
</div>
6 changes: 3 additions & 3 deletions _layouts/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div class="col-sm-2 hidden-xs">
<ul class="nav nav-pills nav-stacked" id="help-nav">
{% for h in help_pages %}
<li{% if h.mirrorid == page.mirrorid or h.redirect_help_id == page.mirrorid %} class="active"{%endif%} id="toc-{{h.mirrorid}}"><a href="{{h.url}}">{{h.mirrorid}}</a></li>
<li{% if h.mirrorid == page.mirrorid or h.redirect_help_id == page.mirrorid %} class="active"{%endif%} id="toc-{{h.mirrorid}}"><a href="{{h.url | relative_url}}">{{h.mirrorid}}</a></li>
{% endfor %}
</ul>
</div><!-- sidenave -->
Expand Down Expand Up @@ -52,8 +52,8 @@
{% include footer.html %}
</body>

<script src="/static/js/highlight.min.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/help.js?{{ site.data['hash'] }}"></script>
<script src="{{ 'static/js/highlight.min.js?' | append: site.data['hash'] | relative_url }}"></script>
<script src="{{ 'static/js/help.js?' | append: site.data['hash'] | relative_url }}"></script>

</html>
<!--
Expand Down
36 changes: 19 additions & 17 deletions _layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<h1>{{ site.school }}开源软件镜像站</h1>
<h3>暂时无法提供服务</h3>
<div class="pull-right">
<img src="/static/img/candle.jpg"
srcset="/static/img/candle.jpg 1x,
/static/img/[email protected] 2x"
<img src="{{ '/static/img/candle.jpg' | relative_url }}"
srcset="{{ '/static/img/candle.jpg' | relative_url }} 1x,
{{ '/static/img/[email protected]' | relative_url }} 2x"
/>
</div>
<div class="clearfix"></div>
Expand Down Expand Up @@ -51,14 +51,14 @@ <h3 id="mirror-title">{% fa_svg fas.fa-cube %} 镜像列表 </h3>
{{mirs}}
<tr class="row status-{{status}}">
<td>
<a class="mirror-item-label" href="{{url}}" title="{{description}}">
<a class="mirror-item-label" href="{{ url | relative_url }}" title="{{description}}">
{{name}}
</a>
{{if is_new}}
<span class="label label-new">new</span>
{{/if}}
{{if help_url}}
<a href="{{help_url}}"><i aria-hidden="true" class="question-circle" title="Help">{% endraw %}{% fa_svg fas.fa-circle-question %}{% raw %}</i><span class="sr-only">[Help]</span></a>
<a href="{{ help_url | relative_url }}"><i aria-hidden="true" class="question-circle" title="Help">{% endraw %}{% fa_svg fas.fa-circle-question %}{% raw %}</i><span class="sr-only">[Help]</span></a>
{{/if}}
</td>
<td>
Expand All @@ -68,16 +68,18 @@ <h3 id="mirror-title">{% fa_svg fas.fa-cube %} 镜像列表 </h3>
{{/mirs}}
{% endraw %}
{% else %}
{% raw %}
<tr v-for="mir in filteredMirrorList" :class="['row', 'status-'+mir.status]" :key="mir.name">
<td class="col-md-8">
<a class="mirror-item-label" data-toggle="popover" data-trigger="hover" data-placement="right"
:data-content="mir.description" :href="getURL(mir)" :aria-label="mir.name + ', ' + mir.description">
{{mir.name}}
:data-content="mir.description" :href="'{{ site.baseurl }}' + getURL(mir)" :aria-label="mir.name + ', ' + mir.description">
{% raw %}
{{mir.name}}
{% endraw %}
<span class="label label-new" v-if='mir.is_new'>new</span>
<a v-if='mir.help_url' :href="mir.help_url"><i aria-hidden="true" class="question-circle" title="Help">{% endraw %}{% fa_svg fas.fa-circle-question %}{% raw %}</i><span class="sr-only">[Help]</span></a>
<a v-if='mir.github_release' href="javascript:void(0)"><i aria-hidden="true" title="GitHub Release">{% endraw %}{% fa_svg fab.fa-github %}{% raw %}</i><span class="sr-only">[GitHub Release]</span></a>
</td>
<a v-if='mir.help_url' :href="'{{ site.baseurl }}' + mir.help_url"><i aria-hidden="true" class="question-circle" title="Help">{% fa_svg fas.fa-circle-question %}</i><span class="sr-only">[Help]</span></a>
<a v-if='mir.github_release' href="javascript:void(0)"><i aria-hidden="true" title="GitHub Release">{% fa_svg fab.fa-github %}</i><span class="sr-only">[GitHub Release]</span></a>
</td>
{% raw %}
<td class="col-md-4">
{{mir.last_update}}<span v-if="mir.show_status" :class="['label', 'label-status', mir.label, 'hidden-xs']">{{mir.status}}</span>
</td>
Expand Down Expand Up @@ -107,10 +109,10 @@ <h3 id="mirror-title">{% fa_svg fas.fa-cube %} 镜像列表 </h3>
<h4>{% fa_svg fas.fa-bullhorn %} 新闻公告 </h4>
<ul>
{% for news in site.categories.news limit: 3%}
<li><a href="/news/#{{news.slug}}"><strong>{{news.date | date: "%Y-%m-%d"}}</strong> {{news.title}}</a></li>
<li><a href="{{ '/news/#' | append: news.slug | relative_url }}"><strong>{{news.date | date: "%Y-%m-%d"}}</strong> {{news.title}}</a></li>
{% endfor %}
</ul>
<div class="text-right"><a href="/news/"> more {% fa_svg fas.fa-angles-right %} </a></div>
<div class="text-right"><a href="{{ '/news/' | relative_url }}"> more {% fa_svg fas.fa-angles-right %} </a></div>
</div>
<div class="thuhidden {%if site.issue%}col-md-4{%endif%}">
<h4> {% fa_svg fas.fa-link %} 域名选择 </h4>
Expand Down Expand Up @@ -144,10 +146,10 @@ <h4> {% fa_svg far.fa-envelope %} 联系我们 </h4>
<div {%if site.issue%}class="col-md-2"{%endif%}>
<h4> {% fa_svg fas.fa-arrow-up-right-from-square %} 相关链接 </h4>
<ul>
<li><a href="/help/">使用帮助</a></li>
<li><a href="{{ '/help/' | relative_url }}">使用帮助</a></li>
{% unless site.issue %}
<li><a href="/status/#server-status">服务器状态</a></li>
<li><a href="/status/#syncing-status">同步状态</a></li>
<li><a href="{{ '/status/#server-status' | relative_url }}">服务器状态</a></li>
<li><a href="{{ '/status/#syncing-status' | relative_url }}">同步状态</a></li>
{% endunless %}
<li class="thuhidden"><a href="https://tuna.moe/">清华大学 TUNA 协会</a></li>
<li><a href="https://github.com/tuna/tunasync">镜像管理器源码</a></li>
Expand Down Expand Up @@ -215,7 +217,7 @@ <h3>{{selected.distro}}</h3>
{% raw %}
{% endraw %}
{% unless page.legacy or site.issue %}
<script src="/static/js/index.js?{{ site.data['hash'] }}"></script>
<script src="{{ 'static/js/index.js?' | append: site.data['hash'] | relative_url }}"></script>
{% endunless %}
</html>
<!--
Expand Down
2 changes: 1 addition & 1 deletion fancy-index/after.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</body>
{% raw %}
{% endraw %}
<script src="/static/js/index.js?{{ site.data['hash'] }}"></script>
<script src="{{ 'static/js/index.js?' | append: site.data['hash'] | relative_url }}"></script>
{% raw %}
<script>
document.getElementById("list").setAttribute("class", "table");
Expand Down
8 changes: 4 additions & 4 deletions static/js/help.es6
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ $(document).ready(() => {
for (const target_selector of target_selectors) {
const template_selector = $(target_selector).data("template");
const select_selectors = $(target_selector).data("select").split(",");
let url = "/" + window.mirrorId
let url = "{{ '/' | relative_url }}" + window.mirrorId
if (window.mirrorId.endsWith(".git")) {
url = "/git/" + window.mirrorId
url = "{{ '/git/' | relative_url }}" + window.mirrorId
}
const template_data = {
"mirror": "{{ site.hostname }}" + url,
Expand Down Expand Up @@ -49,7 +49,7 @@ $(document).ready(() => {
window.location = `${window.location.protocol}//${window.location.host}${help_url}`;
});

$.getJSON("/static/tunasync.json", (statusData) => {
$.getJSON("{{ '/static/tunasync.json' | relative_url }}", (statusData) => {
// remove help items for disabled/removed mirrors
let availableMirrorIds = new Set(statusData.map(x => x.name));
globalOptions.unlisted_mirrors.forEach(elem => {
Expand All @@ -58,7 +58,7 @@ $(document).ready(() => {
console.log(window.mirrorId);
if (!availableMirrorIds.has(window.mirrorId)) {
if ({{ site.hide_mirrorz }}) {
location.href = "/404-help-hidden.html"; // this will break 404 issue submission
location.href = "{{ '/404-help-hidden.html' | relative_url }}"; // this will break 404 issue submission
} else {
location.href = "{{ site.mirrorz_help_link }}" + window.mirrorId; // TODO: convert this to mirrorz cname
}
Expand Down
5 changes: 3 additions & 2 deletions static/js/index.es6
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ var vmMirList = new Vue({
methods: {
getURL (mir) {
if (mir.url !== undefined) {
console.log(mir)
return mir.url
}
return `/${mir.name}/`
},
refreshMirrorList () {
var self = this;
$.getJSON("/static/tunasync.json", (status_data) => {
$.getJSON("{{ '/static/tunasync.json' | relative_url}}", (status_data) => {
var unlisted_mir = unlisted.map(d => processMirrorItem(d))
status_data = status_data.map(d => processMirrorItem(d));
var mir_data = $.merge(unlisted_mir, status_data);
Expand Down Expand Up @@ -173,7 +174,7 @@ var vmIso = new Vue({
},
created: function () {
var self = this;
$.getJSON("/static/status/isoinfo.json", function (isoinfo) {
$.getJSON("{{ '/static/status/isoinfo.json' | relative_url}}", function (isoinfo) {
self.distroList = isoinfo;
self.selected = self.curDistroList[0];
if (window.location.hash.match(/#iso-download(\?.*)?/)) {
Expand Down
2 changes: 1 addition & 1 deletion static/js/status.es6
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $(document).ready(() => {
diskUsages: []
},
created () {
$.get("/static/status/disk.json", (d) => {
$.get("{{ '/static/status/disk.json' | relative_url }}", (d) => {
if(!Array.isArray(d)){
d = [d];
}
Expand Down
4 changes: 2 additions & 2 deletions status.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ <h3 id="syncing-status"># 同步状态</h3>
{% endunless %}
</div><!--/status -->
{% include footer.html %}
<script src="/static/js/status.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/index.js?{{ site.data['hash'] }}"></script>
<script src="{{ 'static/js/status.js?' | append: site.data['hash'] | relative_url }}"></script>
<script src="{{ 'static/js/index.js?' | append: site.data['hash'] | relative_url }}"></script>
</body>
</html>
<!--
Expand Down
Loading