Skip to content

Commit fa4dc3a

Browse files
committed
Install bootstrap, setup automated gh-pages build process
1 parent 993f022 commit fa4dc3a

File tree

13 files changed

+233
-11
lines changed

13 files changed

+233
-11
lines changed

.circleci/config.yml

+36-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,41 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: circleci/ruby:2.5.1
5+
- image: circleci/ruby:2.5.1-node
6+
branches:
7+
only:
8+
- master
69
steps:
710
- checkout
8-
- run: echo "A first hello"
11+
12+
- restore_cache:
13+
keys:
14+
- pytorch-bundle-v2-{{ checksum "Gemfile.lock" }}
15+
- pytorch-bundle-v2-
16+
17+
- run:
18+
name: Bundle Install
19+
command: bundle check || bundle install --path vendor/cache
20+
21+
- save_cache:
22+
key: pytorch-bundle-v2-{{ checksum "Gemfile.lock" }}
23+
paths:
24+
- vendor/cache
25+
26+
- restore_cache:
27+
keys:
28+
- pytorch-yarn-{{ checksum "yarn.lock" }}
29+
- pytorch-yarn-
30+
31+
- run:
32+
name: Yarn Install
33+
command: yarn install --cache-folder ~/.cache/yarn
34+
35+
- save_cache:
36+
key: pytorch-yarn-{{ checksum "yarn.lock" }}
37+
paths:
38+
- ~/.cache/yarn
39+
40+
- run:
41+
name: Build Jekyll site and push to gh-pages
42+
command: ./scripts/deploy-ghpages.sh build

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9.8.0

Makefile

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
SHELL := /bin/bash
2+
BUNDLE := bundle
3+
YARN := yarn
4+
VENDOR_DIR = assets/vendor/
5+
JEKYLL := $(BUNDLE) exec jekyll
6+
7+
PROJECT_DEPS := Gemfile package.json
8+
9+
.PHONY: all clean install update
10+
11+
all : serve
12+
13+
check:
14+
$(JEKYLL) doctor
15+
$(HTMLPROOF) --check-html \
16+
--http-status-ignore 999 \
17+
--internal-domains localhost:4000 \
18+
--assume-extension \
19+
_site
20+
21+
install: $(PROJECT_DEPS)
22+
$(BUNDLE) install --path vendor/bundler
23+
$(YARN) install
24+
25+
update: $(PROJECT_DEPS)
26+
$(BUNDLE) update
27+
$(YARN) upgrade
28+
29+
include-yarn-deps:
30+
mkdir -p $(VENDOR_DIR)
31+
cp node_modules/jquery/dist/jquery.min.js $(VENDOR_DIR)
32+
cp node_modules/popper.js/dist/umd/popper.min.js $(VENDOR_DIR)
33+
cp node_modules/bootstrap/dist/js/bootstrap.min.js $(VENDOR_DIR)
34+
35+
build: install include-yarn-deps
36+
$(JEKYLL) build
37+
rm _site/Gemfile
38+
rm _site/Gemfile.lock
39+
rm _site/Makefile
40+
rm _site/package.json
41+
rm -f _site/yarn-error.log
42+
rm _site/yarn.lock
43+
rm -rf _site/scripts
44+
45+
serve: install include-yarn-deps
46+
JEKYLL_ENV=production $(JEKYLL) serve
47+
48+
build_deploy: include-yarn-deps
49+
$(JEKYLL) build
50+
rm _site/Gemfile
51+
rm _site/Gemfile.lock
52+
rm _site/Makefile
53+
rm _site/package.json
54+
rm -f _site/yarn-error.log
55+
rm _site/yarn.lock
56+
rm -rf _site/scripts

_config.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@
22
title: "PyTorch Website"
33
author: "Shift Lab"
44
description: "Static website for pytorch.org"
5-
url: "https://pytorch.org"
5+
url: "https://shiftlab.github.io/pytorch"
6+
sass:
7+
load_paths:
8+
- _sass
9+
- node_modules
10+
exclude: [vendor, node_modules]
11+
github: [metadata]
12+
baseurl: ""

_includes/footer.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<footer>
22
<p>Footer</p>
3-
</footer>
3+
</footer>

_includes/head.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
<meta name="viewport" content="width=device-width, initial-scale=1.0">
44
<meta http-equiv="X-UA-Compatible" content="ie=edge">
55
<title>PyTorch</title>
6-
<link rel="stylesheet" href="./css/main.css">
6+
<link rel="stylesheet" href="./assets/main.css">
77
</head>

_layouts/default.html

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
<html lang="en">
33
{% include head.html %}
44
<body>
5-
{{ content }}
6-
{% include footer.html %}
5+
<div class="container">
6+
{{ content }}
7+
{% include footer.html %}
8+
</div>
9+
10+
<script src="{{'./assets/vendor/jquery.min.js'}}"></script>
11+
<script src="{{'./assets/vendor/popper.min.js'}}"></script>
12+
<script src="{{'./assets/vendor/bootstrap.min.js'}}"></script>
713
</body>
8-
</html>
14+
</html>

_sass/_variables.scss

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$custom-font-size: 20px;
2+
@import "../node_modules/bootstrap/scss/variables";

assets/main.scss

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
---
3+
4+
@import "bootstrap/scss/functions";
5+
@import "variables";
6+
@import "bootstrap/scss/bootstrap";
7+
8+
.content {
9+
font-size: $custom-font-size;
10+
}

index.html

+35-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,39 @@
22
layout: default
33
---
44

5-
<div id="outer">
6-
<h1>PyTorch</h1>
7-
<pre>Testing Jekyll auto-build</pre>
5+
<h1>PyTorch</h1>
6+
7+
<div class="alert alert-success" role="alert">
8+
Bootstrap installed
9+
</div>
10+
11+
<div class="alert alert-danger" role="alert">
12+
Error alert
13+
</div>
14+
15+
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
16+
Launch demo modal
17+
</button>
18+
19+
<!-- Modal -->
20+
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
21+
<div class="modal-dialog" role="document">
22+
<div class="modal-content">
23+
<div class="modal-header">
24+
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
25+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
26+
<span aria-hidden="true">&times;</span>
27+
</button>
28+
</div>
29+
<div class="modal-body">
30+
...
31+
</div>
32+
<div class="modal-footer">
33+
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
34+
<button type="button" class="btn btn-primary">Save changes</button>
35+
</div>
36+
</div>
37+
</div>
838
</div>
39+
40+

package.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"dependencies": {
3+
"bootstrap": "4.0.0",
4+
"jquery": "^3.3.1",
5+
"popper.js": "^1.14.3"
6+
}
7+
}

scripts/deploy-ghpages.sh

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/sh
2+
# ideas used from https://gist.github.com/motemen/8595451
3+
4+
# Based on https://github.com/eldarlabs/ghpages-deploy-script/blob/master/scripts/deploy-ghpages.sh
5+
# Used with their MIT license https://github.com/eldarlabs/ghpages-deploy-script/blob/master/LICENSE
6+
7+
# abort the script if there is a non-zero error
8+
set -e
9+
10+
# show where we are on the machine
11+
pwd
12+
remote=$(git config remote.origin.url)
13+
14+
# make a directory to put the gp-pages branch
15+
mkdir gh-pages-branch
16+
cd gh-pages-branch
17+
# now lets setup a new repo so we can update the gh-pages branch
18+
git config --global user.email "$GH_EMAIL" > /dev/null 2>&1
19+
git config --global user.name "$GH_NAME" > /dev/null 2>&1
20+
git init
21+
git remote add --fetch origin "$remote"
22+
23+
# switch into the the gh-pages branch
24+
if git rev-parse --verify origin/gh-pages > /dev/null 2>&1
25+
then
26+
git checkout gh-pages
27+
# delete any old site as we are going to replace it
28+
# Note: this explodes if there aren't any, so moving it here for now
29+
git rm -rf .
30+
else
31+
git checkout --orphan gh-pages
32+
fi
33+
34+
cd "../"
35+
make build_deploy
36+
cd gh-pages-branch
37+
38+
# copy over or recompile the new site
39+
cp -a "../_site/." .
40+
41+
# stage any changes and new files
42+
git add -A
43+
# now commit, ignoring branch gh-pages doesn't seem to work, so trying skip
44+
git commit --allow-empty -m "Deploy to GitHub pages [ci skip]"
45+
# and push, but send any output to /dev/null to hide anything sensitive
46+
git push --force --quiet origin gh-pages
47+
# go back to where we started and remove the gh-pages git repo we made and used
48+
# for deployment
49+
cd ..
50+
rm -rf gh-pages-branch
51+
52+
echo "Finished Deployment!"

yarn.lock

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
6+
version "4.0.0"
7+
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.0.0.tgz#ceb03842c145fcc1b9b4e15da2a05656ba68469a"
8+
9+
jquery@^3.3.1:
10+
version "3.3.1"
11+
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca"
12+
13+
popper.js@^1.14.3:
14+
version "1.14.3"
15+
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.14.3.tgz#1438f98d046acf7b4d78cd502bf418ac64d4f095"

0 commit comments

Comments
 (0)