|
- <div class="{{TabSizeClass .Editorconfig .FileName}} non-diff-file-content">
- <h4 class="file-header ui top attached header">
- <div class="file-header-left">
- {{if .ReadmeInList}}
- {{if .FileIsSymlink}}
- <i class="icons"><i class="book icon"></i><i class="bottom left corner tiny inverted share icon"></i></i>
- {{else}}
- <i class="book icon"></i>
- {{end}}
- <strong>{{.FileName}}</strong>
- {{else}}
- <div class="file-info text grey normal mono">
- {{if .FileIsSymlink}}
- <div class="file-info-entry">
- {{.i18n.Tr "repo.symbolic_link"}}
- </div>
- {{end}}
- {{if .NumLinesSet}}
- <div class="file-info-entry">
- {{.NumLines}} {{.i18n.Tr (TrN .i18n.Lang .NumLines "repo.line" "repo.lines") }}
- </div>
- {{end}}
- {{if .FileSize}}
- <div class="file-info-entry">
- {{FileSize .FileSize}}{{if .IsLFSFile}} ({{.i18n.Tr "repo.stored_lfs"}}){{end}}
- </div>
- {{end}}
- {{if .LFSLock}}
- <div class="file-info-entry">
- <i class="fa fa-lock poping up disabled" data-content="{{.LFSLockHint}}" data-position="bottom center" data-variation="tiny inverted"></i>
- <a href="{{AppSubUrl}}/{{.LFSLock.Owner.Name}}">{{.LFSLockOwner}}</a>
- </div>
- {{end}}
- </div>
- {{end}}
- </div>
-
- {{if .ReadmeInList}}
- <div class="file-header-right">
- <div class="ui right file-actions">
- {{if .Repository.CanEnableEditor}}
- {{if .CanEditFile}}
- <a href="{{.RepoLink}}/_edit/{{EscapePound .BranchName}}/{{EscapePound .ReadmeRelativePath}}"><span class="btn-octicon poping up" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-pencil" 16}}</span></a>
- {{else}}
- <span class="btn-octicon poping up disabled" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-pencil" 16}}</span>
- {{end}}
- {{end}}
- </div>
- </div>
- {{end}}
-
- {{if not .ReadmeInList}}
- <div class="file-header-right">
- <div class="ui right file-actions">
- <div class="ui buttons">
- <a class="ui button" href="{{EscapePound $.RawFileLink}}">{{.i18n.Tr "repo.file_raw"}}</a>
- {{if not .IsViewCommit}}
- <a class="ui button" href="{{.RepoLink}}/src/commit/{{.CommitID}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_permalink"}}</a>
- {{end}}
- {{if .IsTextFile}}
- <a class="ui button" href="{{.RepoLink}}/blame/{{EscapePound .BranchNameSubURL}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.blame"}}</a>
- {{end}}
- <a class="ui button" href="{{.RepoLink}}/commits/{{EscapePound .BranchNameSubURL}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.file_history"}}</a>
- </div>
- {{if .Repository.CanEnableEditor}}
- {{if .CanEditFile}}
- <a href="{{.RepoLink}}/_edit/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><span class="btn-octicon poping up" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-pencil" 16}}</span></a>
- {{else}}
- <span class="btn-octicon poping up disabled" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-pencil" 16}}</span>
- {{end}}
- {{if .CanDeleteFile}}
- <a href="{{.RepoLink}}/_delete/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><span class="btn-octicon btn-octicon-danger poping up" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-trashcan" 16}}</span></a>
- {{else}}
- <span class="btn-octicon poping up disabled" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-trashcan" 16}}</span>
- {{end}}
- {{end}}
- </div>
- </div>
- {{end}}
- </h4>
- <div class="ui attached table unstackable segment">
- <div class="file-view {{if .IsMarkup}}{{.MarkupType}} markdown{{else if .IsRenderedHTML}}plain-text{{else if .IsTextFile}}code-view{{end}}">
- {{if .IsMarkup}}
- {{if .FileContent}}{{.FileContent | Safe}}{{end}}
- {{else if .IsRenderedHTML}}
- <pre>{{if .FileContent}}{{.FileContent | Str2html}}{{end}}</pre>
- {{else if not .IsTextFile}}
- <div class="view-raw ui center">
- {{if .IsImageFile}}
- <img src="{{EscapePound $.RawFileLink}}">
- {{else if .IsVideoFile}}
- <video controls src="{{EscapePound $.RawFileLink}}">
- <strong>{{.i18n.Tr "repo.video_not_supported_in_browser"}}</strong>
- </video>
- {{else if .IsAudioFile}}
- <audio controls src="{{EscapePound $.RawFileLink}}">
- <strong>{{.i18n.Tr "repo.audio_not_supported_in_browser"}}</strong>
- </audio>
- {{else if .IsPDFFile}}
- <iframe width="100%" height="600px" src="{{StaticUrlPrefix}}/vendor/plugins/pdfjs/web/viewer.html?file={{EscapePound $.RawFileLink}}"></iframe>
- {{else}}
- <a href="{{EscapePound $.RawFileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{.i18n.Tr "repo.file_view_raw"}}</a>
- {{end}}
- </div>
- {{else if .FileSize}}
- {{if .IsNoteBook}}
- <div id="notebook"></div>
-
- {{else}}
- <table>
- <tbody>
- <tr>
- {{if .IsFileTooLarge}}
- <td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td>
- {{else}}
- <td class="lines-num">{{.LineNums}}</td>
- <td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.FileContent}}</ol></code></pre></td>
- {{end}}
- </tr>
- </tbody>
- </table>
- {{end}}
- {{end}}
- </div>
- </div>
- </div>
-
- <script>
- function submitDeleteForm() {
- var message = prompt("{{.i18n.Tr "repo.delete_confirm_message"}}\n\n{{.i18n.Tr "repo.delete_commit_summary"}}", "Delete '{{.TreeName}}'");
- if (message != null) {
- $("#delete-message").val(message);
- $("#delete-file-form").submit()
- }
- }
-
-
- const baseUrls = {};
- const justDomain = /^[^:]+:\/*[^/]*$/;
- const protocol = /^([^:]+:)[\s\S]*$/;
- const domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
- const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
- function rtrim(str, c, invert) {
- const l = str.length;
- if (l === 0) {
- return '';
- }
- let suffLen = 0;
- while (suffLen < l) {
- const currChar = str.charAt(l - suffLen - 1);
- if (currChar === c && !invert) {
- suffLen++;
- } else if (currChar !== c && invert) {
- suffLen++;
- } else {
- break;
- }
- }
-
- return str.slice(0, l - suffLen);
- }
- function resolveUrl(base, href) {
- if (!baseUrls[' ' + base]) {
- if (justDomain.test(base)) {
- baseUrls[' ' + base] = base + '/';
- } else {
- baseUrls[' ' + base] = rtrim(base, '/', true);
- }
- }
- base = baseUrls[' ' + base];
- const relativeBase = base.indexOf(':') === -1;
-
- if (href.substring(0, 2) === '//') {
- if (relativeBase) {
- return href;
- }
- return base.replace(protocol, '$1') + href;
- } else if (href.charAt(0) === '/') {
- if (relativeBase) {
- return href;
- }
- return base.replace(domain, '$1') + href;
- } else {
- return base + href;
- }
- }
- function showNoteBook(){
- var isNoteBook = {{.IsNoteBook}};
- if (isNoteBook) {
- var jsonStr = "{{.FileContent}}";
- var baseUrl={{.FileParentURL}};
- nb.markdown.setOptions({
- baseUrl: baseUrl
- });
- var notebook = nb.parse(JSON.parse(jsonStr));
- var rendered = notebook.render();
- $("#notebook").append(rendered);
-
- $("#notebook img").each(function(){
-
- var oldSrc = $(this).attr('src');
- if (!originIndependentUrl.test(oldSrc)){
- var newSrc=resolveUrl(baseUrl,oldSrc);
- $(this).attr('src', newSrc);
-
- }
-
- });
- Prism.highlightAll();
- }
- }
- showNoteBook()
-
- </script>
|