Skip to content

Commit b29d6ca

Browse files
committed
Move doc links to manifest
1 parent 34e804d commit b29d6ca

7 files changed

Lines changed: 50 additions & 36 deletions

File tree

‎assets/javascripts/models/doc.coffee‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class app.models.Doc extends app.Model
2-
# Attributes: name, slug, type, version, index_path, db_path, db_size, mtime
2+
# Attributes: name, slug, type, version, index_path, db_path, db_size, mtime, links
33

44
constructor: ->
55
super

‎assets/javascripts/views/content/entry_page.coffee‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ class app.views.EntryPage extends app.View
3636
@trigger 'loaded'
3737
return
3838

39+
LINKS =
40+
home: 'Homepage'
41+
code: 'Source code'
42+
43+
prepareContent: (content) ->
44+
return content unless @entry.isIndex() and @entry.doc.links
45+
46+
links = for link, url of @entry.doc.links
47+
"""<a href="#{url}" class="_links-link">#{LINKS[link]}</a>"""
48+
49+
"""<p class="_links">#{links.join('')}</p>#{content}"""
50+
3951
empty: ->
4052
@subview?.deactivate()
4153
@subview = null
@@ -78,7 +90,7 @@ class app.views.EntryPage extends app.View
7890

7991
onSuccess: (response) =>
8092
@xhr = null
81-
@render response
93+
@render @prepareContent(response)
8294
return
8395

8496
onError: =>

‎assets/stylesheets/components/_page.scss‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//
44

55
._page {
6+
position: relative;
7+
68
> h1 { @extend ._lined-heading; }
79
> h1:first-child { margin-top: 0; }
810

@@ -22,6 +24,35 @@
2224
}
2325
}
2426

27+
//
28+
// Links
29+
//
30+
31+
._links {
32+
position: absolute;
33+
top: 0;
34+
right: 0;
35+
margin: 0;
36+
line-height: 2em;
37+
text-align: right;
38+
39+
+ h1 { margin-top: 0; }
40+
41+
@media (max-width: 1023px) { display: none; }
42+
}
43+
44+
._links-link {
45+
display: inline-block;
46+
vertical-align: top;
47+
padding: 0 .5rem;
48+
background: white;
49+
@extend %internal-link;
50+
51+
& + & { margin-left: .75rem; }
52+
&:first-child { padding-left: 1rem; }
53+
&:last-child { padding-right: 0; }
54+
}
55+
2556
//
2657
// Attribution box
2758
//

‎lib/docs/core/doc.rb‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def as_json
3838
type: type,
3939
version: version,
4040
index_path: index_path,
41-
db_path: db_path }
41+
db_path: db_path,
42+
links: links }
4243
end
4344

4445
def store_page(store, id)

‎lib/docs/core/scraper.rb‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def filters
3434
self.text_filters = FilterStack.new
3535

3636
html_filters.push 'container', 'clean_html', 'normalize_urls', 'internal_urls', 'normalize_paths'
37-
text_filters.push 'inner_html', 'clean_text', 'links', 'attribution'
37+
text_filters.push 'inner_html', 'clean_text', 'attribution'
3838

3939
def build_page(path)
4040
response = request_one url_for(path)
@@ -65,10 +65,6 @@ def root_url
6565
@root_url ||= root_path? ? URL.parse(File.join(base_url.to_s, root_path)) : base_url.normalize
6666
end
6767

68-
def links
69-
self.class.links
70-
end
71-
7268
def root_path
7369
self.class.root_path
7470
end
@@ -93,7 +89,7 @@ def pipeline
9389

9490
def options
9591
@options ||= self.class.options.deep_dup.tap do |options|
96-
options.merge! base_url: base_url, root_url: root_url, links: links,
92+
options.merge! base_url: base_url, root_url: root_url,
9793
root_path: root_path, initial_paths: initial_paths
9894

9995
if root_path?

‎lib/docs/filters/core/links.rb‎

Lines changed: 0 additions & 26 deletions
This file was deleted.

‎test/lib/docs/core/doc_test.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class DocsDocTest < MiniTest::Spec
116116
end
117117

118118
it "includes the doc's name, slug, type, version, index_path and db_path" do
119-
%w(name slug type version index_path db_path).each do |attribute|
119+
%w(name slug type version index_path db_path links).each do |attribute|
120120
eval "stub(doc).#{attribute} { attribute }"
121121
assert_equal attribute, doc.as_json[attribute.to_sym]
122122
end

0 commit comments

Comments
 (0)