Skip to content

Commit 4cd6f71

Browse files
committed
Make the CSS path relative
Instead of hard-coding libgit2's location, detect how deep the example is and use a relative path, allowing for use in different projects.
1 parent 51f6005 commit 4cd6f71

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/docurium.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,25 @@ def format_examples!(data, version)
6565
blob = @repo.lookup(ientry[:oid])
6666
blob.content
6767
end
68-
rocco_layout = Rocco::Layout.new(rocco, @tf)
69-
rocco_layout.version = version
70-
rf = rocco_layout.render
7168

7269
extlen = -(File.extname(file).length + 1)
7370
rf_path = file[0..extlen] + '.html'
7471
rel_path = "ex/#{version}/#{rf_path}"
7572

73+
rocco_layout = Rocco::Layout.new(rocco, @tf)
74+
# find out how deep our file is so we can use the right
75+
# number of ../ in the path
76+
depth = rel_path.count('/') - 1
77+
if depth == 0
78+
rocco_layout[:dirsup] = "./"
79+
else
80+
rocco_layout[:dirsup] = "../"*depth
81+
end
82+
83+
rocco_layout.version = version
84+
rf = rocco_layout.render
85+
86+
7687
# look for function names in the examples and link
7788
id_num = 0
7889
data[:functions].each do |f, fdata|

lib/docurium/layout.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="content-type" content="text/html;charset=utf-8">
55
<title>{{ title }}</title>
6-
<link rel="stylesheet" href="https://libgit2.github.com/libgit2/ex/css.css">
6+
<link rel="stylesheet" href="{{dirsup}}css.css">
77
<style type="text/css">
88
a.fnlink {text-decoration: none}
99
a.fnlink:hover {text-decoration: underline}

0 commit comments

Comments
 (0)