docs: Updated page creation guide for 'category-page' variable. bonus: bonus1 works for external links

git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@68 a672b425-5310-4d7a-af5c-997e18724b81
This commit is contained in:
Claudio Maggioni 2018-11-08 20:18:09 +00:00
parent f540e2beb1
commit 3c43e6f172
4 changed files with 26 additions and 11 deletions

View File

@ -39,7 +39,7 @@ fn find_urls(html: &str) -> Vec<String> {
results
}
fn is_url_working(url: &str) -> bool {
fn is_external_url_working(url: &str) -> bool {
let res: Result<reqwest::Response, reqwest::Error> = reqwest::get(url);
match res {
Ok(r) => r.status().is_success(),
@ -49,10 +49,10 @@ fn is_url_working(url: &str) -> bool {
#[test]
fn test_is_url_working() {
assert!(is_url_working("https://www.google.com"));
assert!(is_url_working("https://xkcd.com"));
assert!(!is_url_working("https://xkcd.com/404"));
assert!(!is_url_working("notaurl"));
assert!(is_external_url_working("https://www.google.com"));
assert!(is_external_url_working("https://xkcd.com"));
assert!(!is_external_url_working("https://xkcd.com/404"));
assert!(!is_external_url_working("notaurl"));
}
fn main() {
@ -75,9 +75,19 @@ fn main() {
lazy_static! {
static ref RE: Regex = Regex::new(".html$").unwrap();
}
if RE.is_match(en.file_name().to_str().unwrap()) {
println!("{}", en.path().display());
let file: &str = en.file_name().to_str().unwrap();
if RE.is_match(file) {
let path: &str = en.path().to_str().unwrap();
let contents: String = read_file(path)
.expect("cannot read");
let urls: Vec<String> = find_urls(contents.as_str());
for url in urls {
if !is_external_url_working(&url) {
println!("{}: '{}' is a broken link.", path, url);
}
}
}
}
Err(e) => {

View File

@ -54,7 +54,7 @@ This is an example for a page with the following stuff:
\texttt{topic} & The \textbf{ls} command & What the page is about\\
\texttt{author} & Claudio Maggioni & The main author of the page\\
\texttt{category\_title} & Basic commands & Name of the category (Your team full name)\\
\texttt{category} & basic & The name of the directory this file is in\\
\texttt{category-page} & basic & The name of the directory this file is in\\
\texttt{tags} & list file directory find & List of words separated by spaces that are relevant to this (Think of these as hashtags without the \#)\\
\end{tabular}
}
@ -65,7 +65,7 @@ This is an example for a page with the following stuff:
---
layout: page
category_title: Basic commands
category: basic
category-page: basic
tags: directory list
author: Claudio Maggioni
title: ls

View File

@ -47,6 +47,11 @@ main {
pre {
overflow-x: auto;
padding: .5em;
}
td pre {
padding: 0;
}
pre, code {

View File

@ -1,7 +1,7 @@
/*
* Syntax highlighting styles
*/
.highlight {
.highlight, pre {
background: #bdbdbd;
color: #212121;