File tree Expand file tree Collapse file tree 6 files changed +44
-18
lines changed Expand file tree Collapse file tree 6 files changed +44
-18
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,7 @@ pub fn crate_details_handler(req: &mut Request) -> IronResult<Response> {
178
178
. and_then ( |details| {
179
179
Page :: new ( details)
180
180
. set_true ( "show_package_navigation" )
181
+ . set_true ( "javascript_highlightjs" )
181
182
. set_true ( "package_navigation_crate_tab" )
182
183
. to_resp ( "crate_details" )
183
184
} )
Original file line number Diff line number Diff line change @@ -217,28 +217,31 @@ pub fn source_browser_handler(req: &mut Request) -> IronResult<Response> {
217
217
} ;
218
218
219
219
220
- let content = if let Some ( file) = file {
220
+ let ( content, is_rust_source ) = if let Some ( file) = file {
221
221
// serve the file with DatabaseFileHandler if file isn't text and not empty
222
222
if !file. mime . starts_with ( "text" ) && !file. is_empty ( ) {
223
223
return Ok ( file. serve ( ) ) ;
224
224
} else if file. mime . starts_with ( "text" ) && !file. is_empty ( ) {
225
- String :: from_utf8 ( file. content ) . ok ( )
225
+ ( String :: from_utf8 ( file. content ) . ok ( ) , file . path . ends_with ( ".rs" ) )
226
226
} else {
227
- None
227
+ ( None , false )
228
228
}
229
229
} else {
230
- None
230
+ ( None , false )
231
231
} ;
232
232
233
233
let list = FileList :: from_path ( & conn, & name, & version, & req_path) ;
234
234
235
235
let page = Page :: new ( list)
236
236
. set_bool ( "show_parent_link" , !req_path. is_empty ( ) )
237
+ . set_true ( "javascript_highlightjs" )
237
238
. set_true ( "show_package_navigation" )
238
239
. set_true ( "package_source_tab" ) ;
239
240
240
241
if let Some ( content) = content {
241
- page. set ( "file_content" , & content) . to_resp ( "source" )
242
+ page. set ( "file_content" , & content)
243
+ . set_bool ( "file_content_rust_source" , is_rust_source)
244
+ . to_resp ( "source" )
242
245
} else {
243
246
page. to_resp ( "source" )
244
247
}
Original file line number Diff line number Diff line change
1
+ {{ #if varsb.javascript_highlightjs }} <script type =" text/javascript" charset =" utf-8" >hljs .initHighlighting ();</script > {{ /if }}
1
2
</body >
2
3
</html >
Original file line number Diff line number Diff line change 10
10
<link rel =" stylesheet" href =" /rustdoc/rustdoc-20160526-1.10.0-nightly-97e3a2401.css" type =" text/css" media =" all" />
11
11
<link rel =" stylesheet" href =" /rustdoc/main-20160526-1.10.0-nightly-97e3a2401.css" type =" text/css" media =" all" />
12
12
<link rel =" stylesheet" href =" /style.css" type =" text/css" media =" all" />
13
+ {{ #if varsb.javascript_highlightjs }}
14
+ <link rel =" stylesheet" href =" https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/github.min.css" type =" text/css" media =" all" />
15
+ <script src =" https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/highlight.min.js" type =" text/javascript" charset =" utf-8" ></script >
16
+ <script src =" https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/languages/rust.min.js" type =" text/javascript" charset =" utf-8" ></script >
17
+ {{ /if }}
13
18
<title >{{ #if title }} {{ title }} - {{ /if }} {{ #if content.metadata.name }} {{ content.metadata.name }} {{ content.metadata.version }} - {{ /if }} Cratesfyi</title >
14
19
</head >
15
20
<body >
Original file line number Diff line number Diff line change 28
28
</div >
29
29
{{ #if ../varss.file_content }}
30
30
<div class =" pure-u-19-24" >
31
- <pre >{{ ../varss.file_content }} </pre >
31
+ <pre >< code {{ #if ../varsb.file_content_rust_source }} class = " rust " {{ /if }} > {{ ../ varss.file_content }} </ code > </pre >
32
32
</div >
33
33
{{ /if }}
34
34
</div >
Original file line number Diff line number Diff line change @@ -41,11 +41,6 @@ strong {
41
41
font-weight : 500 ;
42
42
}
43
43
44
- pre {
45
- background-color : $color-background-code ;
46
- padding : 14px ;
47
- }
48
-
49
44
.pure-button-normal {
50
45
background-color : #fff ;
51
46
box-sizing : border-box !important ;
@@ -149,7 +144,7 @@ div.recent-releases-container {
149
144
display : block ;
150
145
border-bottom : 1px solid $color-border ;
151
146
padding : .4em 1em ;
152
-
147
+
153
148
@media #{$media-lg } {
154
149
padding : .4em 0 ;
155
150
margin : 0 1em ;
@@ -168,7 +163,7 @@ div.recent-releases-container {
168
163
.description {
169
164
font-family : $font-family-serif ;
170
165
font-weight : normal ;
171
- @media #{$media-sm } {
166
+ @media #{$media-sm } {
172
167
font-size : 1em ;
173
168
white-space : nowrap ;
174
169
overflow : hidden ;
@@ -177,7 +172,7 @@ div.recent-releases-container {
177
172
}
178
173
179
174
.description :hover {
180
- @media #{$media-sm } {
175
+ @media #{$media-sm } {
181
176
overflow : visible ;
182
177
white-space : normal ;
183
178
}
@@ -304,8 +299,29 @@ div.package-page-container {
304
299
}
305
300
}
306
301
307
- div .package-details p {
308
- font-family : $font-family-serif ;
302
+ div .package-details {
303
+ p {
304
+ font-family : $font-family-serif ;
305
+ }
306
+
307
+ h1 :first-child ,
308
+ h2 :first-child ,
309
+ h3 :first-child ,
310
+ h4 :first-child ,
311
+ h5 :first-child ,
312
+ h6 :first-child {
313
+ margin-top : 0 ;
314
+ }
315
+ }
316
+
317
+ pre {
318
+ background-color : inherit ;
319
+ margin : 0 ;
320
+ padding : 0 ;
321
+
322
+ code {
323
+ white-space : pre ;
324
+ }
309
325
}
310
326
}
311
327
@@ -326,7 +342,7 @@ div.cratesfyi-package-container {
326
342
margin : 0 ;
327
343
padding : 0 0 20px 16px ;
328
344
329
- @media #{$media-sm } {
345
+ @media #{$media-sm } {
330
346
white-space : nowrap ;
331
347
overflow : hidden ;
332
348
text-overflow : ellipsis ;
@@ -388,6 +404,6 @@ div.search-page-search-form {
388
404
max-width : 300px ;
389
405
padding : .4em 1em ;
390
406
}
391
-
407
+
392
408
393
409
}
You can’t perform that action at this time.
0 commit comments