Skip to content
Permalink
Browse files

Merge pull request #74 from jenkins-infra/develop

Promote v1.9.0 and v1.9.1 to production
  • Loading branch information
oleg-nenashev committed Nov 26, 2019
2 parents 64787a0 + 743f07a commit bd2a5fe337ddf9526666ef5a7ad6a3f5bb388c6f
@@ -0,0 +1 @@
* @jenkins-infra/plugin-site
@@ -2,6 +2,7 @@

image:https://badges.gitter.im/jenkinsci/docs.svg[link="https://gitter.im/jenkinsci/docs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"]
image:https://img.shields.io/github/release/jenkins-infra/plugin-site-api.svg?label=release[link="https://github.com/jenkins-infra/plugin-site-api/releases/latest"]
image:https://img.shields.io/docker/pulls/jenkinsciinfra/plugin-site?label=jenkinsciinfra%2Fplugin-site&logo=docker&logoColor=white[link="https://hub.docker.com/r/jenkinsciinfra/plugin-site"]

:toc:
:toc-placement: preamble
@@ -20,7 +20,7 @@
*/
public static final String BOOTSTRAP_PADDING_5 = "p-5";
private static final Logger LOGGER = Logger.getLogger(GithubReadmeExtractor.class.getName());
private static final String API_URL_PATTERN =
private static final String API_URL_PATTERN =
"https://api.github.com/repos/jenkinsci/%s/%s?ref=%s&client_id=%s&client_secret=%s";

@Override
@@ -67,14 +67,20 @@ protected void convertLinksToAbsolute(HttpClientWikiService service, Element wik
String path = matcher.getDirectory();
String documentationHost = String.format("https://github.com/%s/%s/blob/%s", orgName, repoName, branch);
String imageHost = String.format("https://cdn.jsdelivr.net/gh/%s/%s@%s", orgName, repoName, branch);
Elements headings = wikiContent.getElementsByTag("H1");
if (headings.size() == 1) {
headings.get(0).remove();
Elements topLevelHeading = wikiContent.getElementsByTag("H1");
if (topLevelHeading.size() == 1) {
topLevelHeading.get(0).remove();
}

wikiContent.select("h1, h2, h3, h4, h5, h6")
.stream()
.filter(element -> StringUtils.contains(element.id(), "user-content"))
.forEach(service::stripUserContentIdPrefix);

wikiContent.getElementsByClass(BOOTSTRAP_PADDING_5).forEach(element -> element.removeClass(BOOTSTRAP_PADDING_5));
// Relative hyperlinks, we resolve "/docs/rest-api.adoc" as https://github.com/jenkinsci/folder-auth-plugin/blob/master/docs/rest-api.adoc
wikiContent.getElementsByAttribute("href").forEach(element -> service.replaceAttribute(element, "href", documentationHost, path));

// Relative image inclusions, we resolve /docs/images/screenshot.png as https://cdn.jsdelivr.net/gh/jenkinsci/folder-auth-plugin@master/docs/images/screenshot.png
wikiContent.getElementsByAttribute("src").forEach(element -> service.replaceAttribute(element, "src", imageHost, path));
}
@@ -146,6 +146,16 @@ public void replaceAttribute(Element element, String attributeName, String host,
}
}

/**
* GitHub adds user-content- to some html elements like links and headings, which breaks hyperlinking in ToCs
*
* @param element element to be processed
*/
public void stripUserContentIdPrefix(Element element) {
final String attribute = element.attr("id");
element.attr("id", attribute.replace("user-content-", ""));
}

public static String getNonWikiContent(String url) {
final Element body = Jsoup.parseBodyFragment("<div></div>").body();
final Element div = body.select("div").first();

0 comments on commit bd2a5fe

Please sign in to comment.
You can’t perform that action at this time.