Delete plugins no longer in use
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-docs/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-docs/commit/d3122d4f Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-docs/tree/d3122d4f Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-docs/diff/d3122d4f Branch: refs/heads/website Commit: d3122d4fe49237bb22990e7d038eab9a83b73bcb Parents: fd23931 Author: Richard Downer <rich...@apache.org> Authored: Thu Oct 12 14:53:43 2017 +0100 Committer: Richard Downer <rich...@apache.org> Committed: Tue Oct 17 13:26:06 2017 +0100 ---------------------------------------------------------------------- README.md | 3 -- _plugins/json.rb | 27 ---------- _plugins/jsonball.rb | 103 ------------------------------------ _plugins/regex_filter.rb | 118 ------------------------------------------ _plugins/stringTools.rb | 35 ------------- _plugins/trim.rb | 25 --------- 6 files changed, 311 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/d3122d4f/README.md ---------------------------------------------------------------------- diff --git a/README.md b/README.md index 10d41c2..3042698 100644 --- a/README.md +++ b/README.md @@ -278,9 +278,6 @@ We use some custom Jekyll plugins, in the `_plugins` dir: * include markdown files inside other files (see, for example, the `*.include.md` files which contain text which is used in multiple other files) * generate the site structure / menu objects -* parse JSON which we can loop over in our markdown docs (to build up models; previously used - for the TOC in the guide, but now replaced with site_structure) -* trim whitespace of ends of variables # Versions http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/d3122d4f/_plugins/json.rb ---------------------------------------------------------------------- diff --git a/_plugins/json.rb b/_plugins/json.rb deleted file mode 100644 index b36a6b2..0000000 --- a/_plugins/json.rb +++ /dev/null @@ -1,27 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -require 'json' - -module JsonFilter - def json(input) - input.to_json - end - - Liquid::Template.register_filter self -end http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/d3122d4f/_plugins/jsonball.rb ---------------------------------------------------------------------- diff --git a/_plugins/jsonball.rb b/_plugins/jsonball.rb deleted file mode 100644 index c12a441..0000000 --- a/_plugins/jsonball.rb +++ /dev/null @@ -1,103 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -require 'json' - -# JSON parser tag, creating map for use in jekyll markdown - -# usage: {% jsonball varname from TYPE PARAM %} -# -# where TYPE is one of {data,var,file,page}, described below - -# drop this into your _plugins/ folder, then you can write, e.g. -# -# {% jsonball foo from data { "a": "b" } %} -# -# and then later refer to {{ foo.a }} to get b inserted - -# more usefully, you can load it from a variable x, e.g. -# {% capture x %}{% include toc.json %}{% endcapture %} -# -# {% jsonball foo from var x %} - -# even better, to read from a file, say toc.json -# (absolute, or relative to the page being jekylled): -# -# {% jsonball foo from file toc.json %} -# -# then e.g. {% for record in jsonball %} {{ record.name }} {% endfor %} -# to print out all the name entries (or build a fancy TOC sidebar) - -# and finally, if that json file might itself contain liquid tags, -# or need jekylling, treat it as a page and it will get jekylled -# (we use this for toc.json reading from subdirs' toc.json files): -# -# {% jsonball foo from page toc.json %} - -module JekyllJsonball - class JsonballTag < Liquid::Tag - - def initialize(tag_name, text, tokens) - super - @text = text - end - - def render(context) - if /(.+) from var (.+)/.match(@text) - context[$1] = JSON context[$2] - return '' - end - if /(.+) from data (.+)/.match(@text) - context[$1] = JSON $2 - return '' - end - if /(.+) from file (.+)/.match(@text) - context[$1] = JSON page_relative_file_contents(context, $2.strip) - return '' - end - if /(.+) from page (.+)/.match(@text) - context[$1] = JSON jekylled_page_relative_file_contents(context, $2.strip) - return '' - end - # syntax error - return 'ERROR:bad_jsonball_syntax' - end - - def page_relative_file_contents(context, filename) - jekyllSite = context.registers[:site] - dir = jekyllSite.source+'/'+File.dirname(context['page']['url']) - filename = context[filename] || filename - if !filename.match(/\/.*/) - filename = dir + '/' + filename - end - file = File.open(filename, "rb") - return file.read - end - - def jekylled_page_relative_file_contents(context, filename) - jekyllSite = context.registers[:site] - filename = context[filename] || filename - targetPage = Jekyll::Page.new(jekyllSite, jekyllSite.source, File.dirname(context['page']['url']), filename) - targetPage.render(jekyllSite.layouts, jekyllSite.site_payload) - targetPage.output - end - - end -end - -Liquid::Template.register_tag('jsonball', JekyllJsonball::JsonballTag) http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/d3122d4f/_plugins/regex_filter.rb ---------------------------------------------------------------------- diff --git a/_plugins/regex_filter.rb b/_plugins/regex_filter.rb deleted file mode 100644 index 5a96223..0000000 --- a/_plugins/regex_filter.rb +++ /dev/null @@ -1,118 +0,0 @@ -module Jekyll - module RegexFilter - def replace_regex(input, reg_str, repl_str) - re = Regexp.new reg_str, Regexp::MULTILINE - - # This will be returned - input.gsub re, repl_str - end - end -end - -Liquid::Template.register_filter(Jekyll::RegexFilter) - - -####### -# This function rewrites a link in the following manner -# -# 1) If the link is fully external leave it as an unaltered link -# 2) If the link is an anchor, convert to the anchor scheme used in PDF generation -# 3) If the link target is in the PDF, change the link to point at the anchor in the PDF -# 4) If the link is pointing at somewhere on the brooklyn site which is not included in this PDF, point to the website with a specific version, so https://brooklyn.apache.org/v/0.9.0-SNAPSHOT/start/concept-quickstart.html for instance -# -# * Input - the document body, site - the jekyll site object, page - all pages, availablePages - ones included in this merge, mergePage - the root merge page, currentPage - the current page being merged -module RefactorURL - def refactorURL(input, reg_str, site, pages, availablePages, mergePage, currentPage) - if input == nil - return nil - end - - # generate document id, this will be used for the anchors - $pid = "id-undefined" - if currentPage['title'] != nil - $pid = currentPage['title'].downcase.delete('/') - $pid.gsub!(/\s+/, '-') - end - - # re-write any ids to our internal references - input.gsub!("id=\"", "id=\"internalLink_"+$pid+"_") - - # get rid of any opening in new tabs, they'll break our anchors - input.gsub!(" target=\"_blank\"", "") - - # make a multi-line regex for finding URLs within the document body - re = Regexp.new reg_str, Regexp::MULTILINE - - # for each url matched replace using the following rules - input.gsub(re) { - - $newLink = "#" - # there should only be one capturing group (the URL), so use the first - $match = Regexp.last_match.captures[0] - # the URL is now in match - if $match.start_with?('http') - # 1) it's an external link, leave it as it is - $newLink = $match - elsif $match.start_with?('#') - # 2) it's an anchor in the local document re-write with the local document id prefixed - $newLink = "#internalLink_"+$pid+"_"+($match.gsub! '#', '') - else - # 3/4) it's a link to a page within the site scope - - # -- Firstly clean up the URL - if $match =~ /#/ - # if there's an anchor remove it (anything after the #) - $match = $match[/[^#]+/] - end - # swap ./ for absolute path - if $match.start_with?('./') - $match = currentPage['dir']+"/"+$match[2, $match.length] - # if the string doesnt start with a / it cant be prefixed by the path, so prefix it - elsif !($match.start_with?('/')) - $match = currentPage['dir']+"/"+$match - end - # add index.html to the end if it's just a folder - if $match.end_with?('/') - $match = $match+"index.html" - end - - # -- now work out if the linked to page is within the page scope - $pageOutOfScope = true; - for page in availablePages - if (page['url'] == $match) - # 3) the page is within the scope of the document, swap it for an anchor - $pageOutOfScope = false; -# puts "In Scope "+$match - # get the pid for this specific page - $current_pid = page['title'].downcase.delete('/') - $current_pid.gsub!(/\s+/, '-') - # make the link an anchor to it - $newLink = "#contentsLink-"+$current_pid - end - end - # 4) page is out of scope of the document put an absolute URL - if $pageOutOfScope -# puts $match+" not in scope - "+$newLink - $notFoundPrefix = true - # go through the URL prefixes in the site and swap them for the website paths - for prefix in site['pdf-rewrite-prefixes'] - - # make an absolute external URL for the link - if $match.start_with?(prefix[0]) - $notFoundPrefix = false - $newLink = site['pdf-default-base-url']+prefix[1]+$match[prefix[0].length, $match.length] - end - end - if $notFoundPrefix - $newLink = site['pdf-default-base-url']+site['pdf-default-versioned-url-subpath']+$match - puts "PDF link to "+$match+" in "+currentPage['path']+" has unknown prefix, routing to "+$newLink - end - end - end - # return the re-written link wrapped in the property - "href=\""+$newLink+"\"" - } - end - - Liquid::Template.register_filter self -end http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/d3122d4f/_plugins/stringTools.rb ---------------------------------------------------------------------- diff --git a/_plugins/stringTools.rb b/_plugins/stringTools.rb deleted file mode 100644 index 96f001b..0000000 --- a/_plugins/stringTools.rb +++ /dev/null @@ -1,35 +0,0 @@ -module SliceFilter - def slice(input, length, start=0) - if length > input.length - length = input.length - end - input[start, length] - end - - Liquid::Template.register_filter self -end - -module StartsWithFilter - def startsWith(input, startStr) - startStr.length < input.length && input[0, startStr.length] == startStr - end - - Liquid::Template.register_filter self -end - -module RemovePrefixFilter - def removePrefix(input, prefix) - input[prefix.length, input.length] - end - - Liquid::Template.register_filter self -end - -module Append - def appendToArray(array, addition) - (array ||= []) << addition - "" - end - - Liquid::Template.register_filter self -end http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/d3122d4f/_plugins/trim.rb ---------------------------------------------------------------------- diff --git a/_plugins/trim.rb b/_plugins/trim.rb deleted file mode 100644 index 047a346..0000000 --- a/_plugins/trim.rb +++ /dev/null @@ -1,25 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -module TrimFilter - def trim(input) - input.strip - end - - Liquid::Template.register_filter self -end