From 8f5f1b454212ad99d401f3988699048a4f56ebc1 Mon Sep 17 00:00:00 2001 From: Sam Rijs Date: Mon, 29 Jan 2018 18:34:22 +1100 Subject: [PATCH] design: custom build of bulma --- .gitmodules | 3 +++ Cargo.toml | 3 +++ assets/static/style.css | 2 -- assets/styles/bulma | 1 + assets/styles/main.sass | 19 +++++++++++++++++++ build.rs | 25 +++++++++++++++++++++++++ src/server/assets.rs | 2 +- src/server/views/status_html.rs | 3 +++ 8 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 .gitmodules delete mode 100644 assets/static/style.css create mode 160000 assets/styles/bulma create mode 100644 assets/styles/main.sass create mode 100644 build.rs diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..918f704 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "assets/styles/bulma"] + path = assets/styles/bulma + url = https://github.com/jgthms/bulma diff --git a/Cargo.toml b/Cargo.toml index 24f1a0c..95dd912 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,3 +20,6 @@ slog-json = "2.2.0" tokio-core = "0.1.12" tokio-service = "0.1.0" toml = "0.4.5" + +[build-dependencies] +sass-rs = "0.2.1" diff --git a/assets/static/style.css b/assets/static/style.css deleted file mode 100644 index 83d3f23..0000000 --- a/assets/static/style.css +++ /dev/null @@ -1,2 +0,0 @@ -@import url('https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'); -@import url('https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.2/css/bulma.min.css'); diff --git a/assets/styles/bulma b/assets/styles/bulma new file mode 160000 index 0000000..6078acd --- /dev/null +++ b/assets/styles/bulma @@ -0,0 +1 @@ +Subproject commit 6078acdd92f250d1c5ab3c512468e228c1b45630 diff --git a/assets/styles/main.sass b/assets/styles/main.sass new file mode 100644 index 0000000..0e7c3a1 --- /dev/null +++ b/assets/styles/main.sass @@ -0,0 +1,19 @@ +@charset "utf-8"; + +@import "utilities/initial-variables"; +@import "utilities/functions"; + +// make view narrower +$widescreen: $desktop; +$fullhd: $desktop; + +// custom fonts +$family-sans-serif: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; +$family-monospace: "Source Serif Pro", monospace; + +@import "utilities/_all"; +@import "base/_all"; +@import "elements/_all"; +@import "components/_all"; +@import "grid/_all"; +@import "layout/_all"; diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..a3e025c --- /dev/null +++ b/build.rs @@ -0,0 +1,25 @@ +extern crate sass_rs as sass; + +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::Path; + +fn build_style() -> String { + let options = sass::Options { + output_style: sass::OutputStyle::Compressed, + include_paths: vec!["./assets/styles/bulma/sass/".to_string()], + ..Default::default() + }; + + sass::compile_file("./assets/styles/main.sass", options) + .expect("failed to compile style sheet") +} + +fn main() { + let out_dir = env::var("OUT_DIR").unwrap(); + let dest_path = Path::new(&out_dir).join("style.css"); + let mut f = File::create(&dest_path).unwrap(); + + f.write_all(build_style().as_bytes()).unwrap(); +} diff --git a/src/server/assets.rs b/src/server/assets.rs index 7550b43..d92e5be 100644 --- a/src/server/assets.rs +++ b/src/server/assets.rs @@ -6,4 +6,4 @@ pub static BADGE_OUTDATED_SVG: &'static [u8; 974] = include_bytes!("../../assets/badges/outdated.svg"); pub static STATIC_STYLE_CSS: &'static str = - include_str!("../../assets/static/style.css"); + include_str!(concat!(env!("OUT_DIR"), "/style.css")); diff --git a/src/server/views/status_html.rs b/src/server/views/status_html.rs index ff5325c..b4fb557 100644 --- a/src/server/views/status_html.rs +++ b/src/server/views/status_html.rs @@ -89,6 +89,9 @@ pub fn status_html(analysis_outcome: AnalyzeDependenciesOutcome, repo_path: Repo meta name="viewport" content="width=device-width, initial-scale=1"; title (title) link rel="stylesheet" type="text/css" href="/static/style.css"; + link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Fira+Sans:400,500,600"; + link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Source+Code+Pro"; + link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"; } body { section class=(format!("hero {}", hero_class)) {