Skip to content

Commit 5eaed2c

Browse files
KixironJoshua Nelson
authored andcommitted
Added tooltips to the About and Releases links
1 parent 232e7b6 commit 5eaed2c

File tree

9 files changed

+382
-312
lines changed

9 files changed

+382
-312
lines changed

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ log = "0.4"
1313
regex = "1"
1414
structopt = "0.3"
1515
crates-index-diff = "7"
16-
reqwest = { version = "0.10.6", features = ["blocking", "json"] } # TODO: Remove blocking when async is ready
16+
reqwest = { version = "0.10.6", features = ["blocking", "json"] }# TODO: Remove blocking when async is ready
1717
semver = { version = "0.9", features = ["serde"] }
1818
slug = "=0.1.1"
1919
env_logger = "0.7"
@@ -56,7 +56,7 @@ serde_json = "1.0"
5656
# iron dependencies
5757
iron = "0.5"
5858
router = "0.5"
59-
staticfile = { version = "0.4", features = [ "cache" ] }
59+
staticfile = { version = "0.4", features = ["cache"] }
6060
tempfile = "3.1.0"
6161

6262
# Templating
@@ -84,6 +84,11 @@ criterion = "0.3"
8484
kuchiki = "0.8"
8585
rand = "0.7.3"
8686

87+
[build-dependencies]
88+
time = "0.1"
89+
git2 = { version = "0.13", default-features = false }
90+
sass-rs = "0.2.2"
91+
8792
[[bench]]
8893
name = "html_parsing"
8994
harness = false
@@ -92,11 +97,6 @@ harness = false
9297
name = "compression"
9398
harness = false
9499

95-
[build-dependencies]
96-
time = "0.1"
97-
git2 = { version = "0.13", default-features = false }
98-
sass-rs = "0.2"
99-
100100
[[bin]]
101101
name = "cratesfyi"
102102
test = false

build.rs

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
use git2::Repository;
2-
use std::env;
3-
use std::fs::{self, File};
4-
use std::io::Write;
5-
use std::path::Path;
2+
use std::{
3+
env,
4+
error::Error,
5+
fs::{self, File},
6+
io::Write,
7+
path::Path,
8+
};
69

710
fn main() {
811
// Set the host target
912
println!(
1013
"cargo:rustc-env=CRATESFYI_HOST_TARGET={}",
11-
env::var("TARGET").unwrap()
14+
env::var("TARGET").unwrap(),
1215
);
1316

1417
// Don't rerun anytime a single change is made
15-
println!("cargo:rerun-if-changed=templates/style.scss");
18+
println!("cargo:rerun-if-changed=templates/style/base.scss");
19+
println!("cargo:rerun-if-changed=templates/style/_rustdoc.scss");
20+
println!("cargo:rerun-if-changed=templates/style/_vars.scss");
21+
println!("cargo:rerun-if-changed=templates/style/_utils.scss");
22+
println!("cargo:rerun-if-changed=templates/style/_navbar.scss");
1623
println!("cargo:rerun-if-changed=templates/menu.js");
1724
println!("cargo:rerun-if-changed=templates/index.js");
1825
// TODO: are these right?
1926
println!("cargo:rerun-if-changed=.git/HEAD");
2027
println!("cargo:rerun-if-changed=.git/index");
2128

2229
write_git_version();
23-
compile_sass();
30+
if let Err(sass_err) = compile_sass() {
31+
panic!("Error compiling SASS: {}", sass_err);
32+
}
2433
copy_js();
2534
}
2635

@@ -46,15 +55,24 @@ fn get_git_hash() -> Option<String> {
4655
})
4756
}
4857

49-
fn compile_sass() {
50-
use sass_rs::Context;
58+
fn compile_sass() -> Result<(), Box<dyn Error>> {
59+
use sass_rs::{Context, Options, OutputStyle};
5160

52-
let mut file_context =
53-
Context::new_file(concat!(env!("CARGO_MANIFEST_DIR"), "/templates/style.scss")).unwrap();
54-
let css = file_context.compile().unwrap();
55-
let dest_path = Path::new(&env::var("OUT_DIR").unwrap()).join("style.css");
56-
let mut file = File::create(&dest_path).unwrap();
57-
file.write_all(css.as_bytes()).unwrap();
61+
const STYLE_DIR: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/templates/style");
62+
63+
let mut context = Context::new_file(format!("{}/base.scss", STYLE_DIR))?;
64+
context.set_options(Options {
65+
output_style: OutputStyle::Compressed,
66+
include_paths: vec![STYLE_DIR.to_owned()],
67+
..Default::default()
68+
});
69+
70+
let css = context.compile()?;
71+
let dest_path = Path::new(&env::var("OUT_DIR")?).join("style.css");
72+
let mut file = File::create(&dest_path)?;
73+
file.write_all(css.as_bytes())?;
74+
75+
Ok(())
5876
}
5977

6078
fn copy_js() {

src/web/page/templates.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ impl TemplateData {
5454
template_data
5555
.templates
5656
.swap(Arc::new(load_templates(&mut conn)?));
57-
log::info!("Reloaded templates");
5857

5958
Ok(())
6059
}
@@ -65,7 +64,9 @@ impl TemplateData {
6564

6665
while rx.recv().is_ok() {
6766
if let Err(err) = reload(&template_data, &pool) {
68-
log::error!("failed to reload templates: {:?}", err);
67+
log::error!("Failed to reload templates:\n{}", err);
68+
} else {
69+
log::info!("Reloaded templates");
6970
}
7071
}
7172
});

templates/header/topbar.html

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,28 @@
2424
</a>
2525

2626
<ul class="pure-menu-list">
27-
<li class="pure-menu-item">
28-
<a href="/about" class="pure-menu-link">
27+
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover">
28+
<a href="/about" class="pure-menu-link disable-menu-arrow">
2929
About
3030
</a>
31+
32+
<ul class="pure-menu-children">
33+
<a href="/about" class="pure-menu-link">
34+
Documentation about builds, badges and more
35+
</a>
36+
</ul>
3137
</li>
3238

33-
<li class="pure-menu-item">
34-
<a href="/releases" class="pure-menu-link">
39+
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover">
40+
<a href="/releases" class="pure-menu-link disable-menu-arrow">
3541
Releases
3642
</a>
43+
44+
<ul class="pure-menu-children">
45+
<a href="/releases" class="pure-menu-link">
46+
Recent releases, the release queue and build failures
47+
</a>
48+
</ul>
3749
</li>
3850

3951
{# The Rust dropdown menu #}

templates/style/_navbar.scss

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
// FIXME: Use modules
2+
@import "vars", "utils";
3+
4+
div.nav-container {
5+
// Nothing is supposed to be over or hovering the top navbar. Maybe add a few others '('? :)
6+
z-index: 999;
7+
height: $top-navbar-height;
8+
border-bottom: 1px solid $color-border;
9+
background-color: #fff;
10+
left: 0;
11+
right: 0;
12+
top: 0;
13+
position: fixed;
14+
15+
li {
16+
border-left: 1px solid $color-border;
17+
}
18+
19+
.pure-menu-has-children > .pure-menu-link:after {
20+
font-size: 0.8em;
21+
}
22+
23+
.pure-menu-link {
24+
font-size: 0.8em;
25+
font-weight: 400;
26+
27+
&:hover {
28+
color: $color-standard;
29+
background-color: inherit;
30+
}
31+
}
32+
33+
form.landing-search-form-nav {
34+
max-width: 1200px;
35+
36+
#search-input-nav {
37+
float: right;
38+
max-width: 150px;
39+
display: none;
40+
border-left: 1px solid $color-border;
41+
42+
@media #{$media-sm} {
43+
display: block;
44+
}
45+
46+
@media #{$media-md} {
47+
max-width: 200px;
48+
}
49+
50+
label {
51+
color: #777;
52+
cursor: pointer;
53+
padding-left: 0.5rem;
54+
font-size: 0.8em;
55+
}
56+
57+
input {
58+
border: none;
59+
margin: 0 1em 0 0;
60+
font-size: 0.8em;
61+
box-shadow: none;
62+
background-color: #fff;
63+
height: 31px;
64+
}
65+
}
66+
67+
input.search-input-nav:focus {
68+
outline: unset;
69+
}
70+
}
71+
72+
.pure-menu-children {
73+
border: 1px solid $color-border;
74+
border-radius: 0 0 2px 2px;
75+
margin-left: -1px;
76+
77+
li {
78+
border-left: none;
79+
}
80+
}
81+
82+
// used for latest version warning
83+
.warn,
84+
.warn:hover {
85+
color: $color-type;
86+
}
87+
88+
a.warn:hover {
89+
color: darken($color-type, 10%);
90+
}
91+
92+
// used for global alerts
93+
.error {
94+
color: $color-red;
95+
96+
&:hover {
97+
color: darken($color-red, 10%);
98+
}
99+
}
100+
101+
div.rustdoc-navigation {
102+
span.title {
103+
display: none;
104+
105+
@media #{$media-sm} {
106+
display: inline;
107+
}
108+
}
109+
110+
div.package-details-menu {
111+
width: 350px;
112+
113+
p.description {
114+
font-family: $font-family-sans;
115+
font-size: 0.8em;
116+
color: #777; // color from pure
117+
padding: 0.5em 1em;
118+
margin: 0;
119+
}
120+
121+
ul.pure-menu-list {
122+
width: 100%;
123+
}
124+
125+
div.right-border {
126+
border-right: 1px solid $color-border;
127+
}
128+
129+
a.pure-menu-link {
130+
word-wrap: normal;
131+
white-space: normal;
132+
}
133+
134+
div.sub-menu {
135+
max-height: 150px;
136+
overflow-y: auto;
137+
138+
ul.pure-menu-list {
139+
border-top: none;
140+
}
141+
142+
li.pure-menu-item:last-child {
143+
border-bottom: none;
144+
}
145+
}
146+
}
147+
}
148+
}

templates/style/_rustdoc.scss

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// FIXME: Use modules
2+
@import "vars";
3+
4+
// rustdoc overrides
5+
div.rustdoc {
6+
font-family: $font-family-serif;
7+
padding: 10px 15px 20px 15px;
8+
position: relative;
9+
10+
@media (max-width: 700px) {
11+
padding-top: 0;
12+
}
13+
14+
.sidebar {
15+
@media (min-width: 701px) {
16+
margin-top: $top-navbar-height;
17+
}
18+
19+
.block > ul > li {
20+
margin-right: -10px;
21+
}
22+
23+
@media (max-width: 700px) {
24+
&.mobile {
25+
top: $top-navbar-height;
26+
27+
.sidebar-elems .show-it {
28+
top: 77px;
29+
}
30+
31+
#sidebar-filler {
32+
top: $top-navbar-height;
33+
}
34+
}
35+
}
36+
}
37+
38+
#source-sidebar {
39+
top: $top-navbar-height;
40+
}
41+
42+
#sidebar-toggle {
43+
top: 62px;
44+
}
45+
}

templates/style/_utils.scss

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// FIXME: Use modules
2+
@import "vars";
3+
4+
// Info and warning notifications
5+
div {
6+
.info {
7+
font-family: $font-family-sans;
8+
border-radius: 4px;
9+
background-color: $color-background-code;
10+
padding: 0.4em 1em;
11+
text-align: center;
12+
margin-bottom: 10px;
13+
14+
a {
15+
color: $color-url;
16+
text-decoration: underline;
17+
}
18+
}
19+
20+
.warning {
21+
@extend .info;
22+
23+
background-color: lighten($color-type, 45%);
24+
}
25+
}
26+
27+
// Disable the dropdown arrow for pure menu items
28+
// It's a wonderful hack, but it allows us to hijack pure's dropdown menus to
29+
// make tooltips that appear when you hover over them that don't have the little
30+
// arrow on the link itself
31+
.disable-menu-arrow,
32+
.pure-menu-has-children > .disable-menu-arrow.pure-menu-link:after {
33+
content: "" !important;
34+
}

0 commit comments

Comments
 (0)