Browse Source

testing highlight

pull/1440/head
Fernando San Julián 10 years ago
parent
commit
bc3c9642a7
  1. 3
      public/ng/css/gogs-prism.css
  2. 3820
      public/ng/js/lib/prism.js
  3. 10
      public/ng/less/gogs/repository.less
  4. 3
      routers/repo/view.go
  5. 6
      templates/repo/view_file.tmpl

3
public/ng/css/gogs-prism.css

@ -209,7 +209,8 @@ pre.line-numbers > code {
} }
.line-numbers-rows > span { .line-numbers-rows > span {
pointer-events: none; pointer-events: auto;
cursor: pointer;
display: block; display: block;
counter-increment: linenumber; counter-increment: linenumber;
} }

3820
public/ng/js/lib/prism.js

File diff suppressed because one or more lines are too long

10
public/ng/less/gogs/repository.less

@ -92,6 +92,9 @@
#repo-content { #repo-content {
padding-top: 18px; padding-top: 18px;
padding-bottom: 18px; padding-bottom: 18px;
.panel-content {
padding: 0;
}
} }
.repo-wide-wrapper { .repo-wide-wrapper {
padding: 18px; padding: 18px;
@ -462,13 +465,6 @@
padding: 6px 8px; padding: 6px 8px;
} }
} }
pre {
padding-top: 0!important;
padding-bottom: 0!important;
code {
padding-top: 2px;
}
}
table { table {
width: 100%; width: 100%;
td { td {

3
routers/repo/view.go

@ -101,6 +101,9 @@ func Home(ctx *middleware.Context) {
if readmeExist { if readmeExist {
ctx.Data["FileContent"] = string(base.RenderMarkdown(buf, branchLink)) ctx.Data["FileContent"] = string(base.RenderMarkdown(buf, branchLink))
} else { } else {
lines := ctx.Query("lines")
//TODO: sanitization, remove spaces and validation if needed
ctx.Data["HighlightLines"] = lines
if err, content := base.ToUtf8WithErr(buf); err != nil { if err, content := base.ToUtf8WithErr(buf); err != nil {
if err != nil { if err != nil {
log.Error(4, "Convert content encoding: %s", err) log.Error(4, "Convert content encoding: %s", err)

6
templates/repo/view_file.tmpl

@ -25,7 +25,7 @@
</a> </a>
{{end}} {{end}}
</p> </p>
<div class="{{if .ReadmeExist}}panel-content{{end}}"> <div class="panel-content">
{{if .ReadmeExist}} {{if .ReadmeExist}}
<div class="markdown"> <div class="markdown">
{{if .FileContent}}{{.FileContent | Str2html}}{{end}} {{if .FileContent}}{{.FileContent | Str2html}}{{end}}
@ -40,7 +40,9 @@
</div> </div>
{{else if .FileSize}} {{else if .FileSize}}
<div class="code-view" id="repo-code-view"> <div class="code-view" id="repo-code-view">
<pre class="line-numbers"><code class="language-{{if .FileLanguage}}{{.FileLanguage}}{{else}}nohighlight{{end}}">{{.FileContent}}</code></pre> <pre class="line-numbers"{{if .HighlightLines}}data-line="{{.HighlightLines}}"{{end}}>
<code class="language-{{if .FileLanguage}}{{.FileLanguage}}{{else}}nohighlight{{end}}">{{.FileContent}}</code>
</pre>
</div> </div>
{{end}} {{end}}
</div> </div>

Loading…
Cancel
Save