Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ once_cell = { version = "1.4.0", features = ["parking_lot"] }
base64 = "0.12.1"
strum = { version = "0.18.0", features = ["derive"] }
lol_html = "0.2"
font-awesome-as-a-crate = { path = "crates/font-awesome-as-a-crate" }

# Async
tokio = { version = "0.2.22", features = ["rt-threaded"] }
Expand Down
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,9 @@ cargo run -- queue add <CRATE> <VERSION>

### Updating vendored sources

The instructions & links for updating Font Awesome can be found [on their website](https://fontawesome.com/how-to-use/on-the-web/using-with/sass). Similarly, Pure-CSS also [explains on theirs](https://purecss.io/start/).
The instructions & links for updating Font Awesome can be found [on their website](https://fontawesome.com/how-to-use/on-the-web/advanced/svg-sprites). Similarly, Pure-CSS also [explains on theirs](https://purecss.io/start/).

When updating Font Awesome, make sure to change `$fa-font-path` in `scss/_variables.scss` (it should be at the top of the file) to `../-/static`. This will point font awesome at the correct path from which to request font and icon resources.
<!--
TODO: Whenever scss modules are avaliable, use [scss modules](https://sass-lang.com/documentation/at-rules/use#configuration)
instead of manually editing the `_variables.scss` file. Something like this should work:
```scss
@use "fontawesome" with (
$fa-font-path: "../-/static"
);
```
-->

### Contact

Expand Down
6 changes: 1 addition & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ fn main() {
println!("cargo:rerun-if-changed=templates/menu.js");
println!("cargo:rerun-if-changed=templates/index.js");
println!("cargo:rerun-if-changed=vendor/");
println!("cargo:rerun-if-changed=vendor/fontawesome/scss/_variables.scss");
// TODO: are these right?
println!("cargo:rerun-if-changed=.git/HEAD");
println!("cargo:rerun-if-changed=.git/index");
Expand Down Expand Up @@ -91,10 +90,7 @@ fn compile_sass() -> Result<(), Box<dyn Error>> {
compile_sass_file(
"vendored",
"vendored",
&[
concat!(env!("CARGO_MANIFEST_DIR"), "/vendor/fontawesome/scss").to_owned(),
concat!(env!("CARGO_MANIFEST_DIR"), "/vendor/pure-css/css").to_owned(),
],
&[concat!(env!("CARGO_MANIFEST_DIR"), "/vendor/pure-css/css").to_owned()],
)?;

Ok(())
Expand Down
2 changes: 2 additions & 0 deletions crates/font-awesome-as-a-crate/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
Cargo.lock
10 changes: 10 additions & 0 deletions crates/font-awesome-as-a-crate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "font-awesome-as-a-crate"
version = "0.1.2"
# https://github.com/FortAwesome/Font-Awesome/blob/master/composer.json
authors = ["Michael Howell <michael@notriddle.com>", "Travis Chase", "Dave Gandy", "Rob Madole", "Jory Raphael", "Geremia Taglialatela", "Brian Talbot", "Mike Wilkerson", "Fonticons Inc <hello@fontawesome.com>"]
edition = "2018"
license = "CC-BY-4.0 AND MIT"
description = "Font Awesome Free, packaged as a crate"
repository = "https://github.com/rust-lang/docs.rs"

5 changes: 5 additions & 0 deletions crates/font-awesome-as-a-crate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# [Font Awesome Free](https://fontawesome.com/how-to-use/on-the-web/setup/hosting-font-awesome-yourself) SVG files as a crate

This is not officially supported by Fonticons, Inc.
If you have problems, [contact us](https://github.com/rust-lang/docs.rs), not them.

54 changes: 54 additions & 0 deletions crates/font-awesome-as-a-crate/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use std::{
env,
fs::{read_dir, File},
io::{Read, Write},
path::Path,
};

fn main() {
println!("cargo:rustc-cfg=font_awesome_out_dir");
write_fontawesome_sprite();
}

fn write_fontawesome_sprite() {
let dest_path = Path::new(&env::var("OUT_DIR").unwrap()).join("fontawesome.rs");
let mut dest_file = File::create(&dest_path).unwrap();
dest_file
.write_all(b"fn fontawesome_svg(dir:&str,file:&str)->&'static str{match(dir,file){")
.expect("fontawesome fn write");
for dirname in &["brands", "regular", "solid"] {
let dir = read_dir(Path::new("fontawesome-free-5.14.0-web/svgs").join(dirname)).unwrap();
let mut data = String::new();
for file in dir {
let file = file.expect("fontawesome directory access");
let filename = file
.file_name()
.into_string()
.expect("fontawesome filenames are unicode");
let mut file = File::open(file.path()).expect("fontawesome file access");
data.clear();
file.read_to_string(&mut data)
.expect("fontawesome file read");
// if this assert goes off, add more hashes here and in the format! below
assert!(
data.find("###").is_none(),
"file {} breaks raw string",
filename,
);
dest_file
.write_all(
format!(
r####"("{dirname}","{filename}")=>r###"{data}"###,"####,
data = data,
dirname = dirname,
filename = filename.replace(".svg", ""),
)
.as_bytes(),
)
.expect("write fontawesome file");
}
}
dest_file
.write_all(b"_=>\"\"}}")
.expect("fontawesome fn write");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The svgs folder was downloaded from https://fontawesome.com/how-to-use/on-the-web/setup/hosting-font-awesome-yourself
The rest of fontawesome was just deleted; this means that the font license and MIT license are not applicable, just the copyright license on the icon files themselves.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading