website/www/site/layouts/open-source/list.html (105 lines of code) (raw):
{{/*
Licensed 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. See accompanying LICENSE file.
*/}}
{{ define "main" }}
<div class="blog-content">
<h1>Open Source Projects</h1>
<p>Check out how the open source projects are using Apache Beam.</p>
{{ $pages := .Pages }}
{{ $.Scratch.Set "categories" (slice ) }}
{{ $.Scratch.Set "noCategories" 0 }}
{{ range .Pages}}
{{ with .Params.categories }}
{{ if eq ( printf "%T" . ) "string" }}
{{ if ( not ( in ($.Scratch.Get "categories") . ) ) }}
{{ $.Scratch.Add "categories" . }}
{{ end }}
{{ else if eq ( printf "%T" . ) "[]string" }}
{{ range . }}
{{ if ( not ( in ($.Scratch.Get "categories") . ) ) }}
{{ $.Scratch.Add "categories" . }}
{{ end }}
{{ end }}
{{ end }}
{{ else }}
{{ $.Scratch.Add "noCategories" 1 }}
{{ end }}
{{ end }}
<div class="category-buttons category-buttons_poweredBy">
{{ range $.Scratch.Get "categories" }}
<button xx class="category-button" id='category-{{ . | replaceRE "[.]" "_" | urlize }}' onclick="applyFilter(this)">
{{ . }}
</button>
{{ end }}
{{ if gt ( $.Scratch.Get "noCategories") 0 }}
<button xx class="category-button" id="category-no-author" onclick='ptf.checkFilter("no-author", "category-")'>
without category
</button>
{{ end }}
</div>
<div class="use_cases">
{{ range $pages.ByPublishDate.Reverse }}
<a href="{{ .RelPermalink }}">
<div class="use-card remove" data-categories='{{ with .Params.categories }}{{ if eq ( printf "%T" . ) "string" }}{{ . | replaceRE "[.]" "_" | urlize }}{{ else if eq ( printf "%T" . ) "[]string" }}{{ range . }}{{ . | replaceRE "[.]" "_" | urlize }} {{end}}{{end}}{{else}}no-author{{end}}'
>
<div class="use-icon">
<img src="{{.Params.icon}}"></i>
</div>
<div class="use-body">
<div>
<p class="use-category">
{{ delimit .Params.categories ", " " & " }}
</p>
<h5 class="use-title">{{ .Title }}</h5>
<p class="use-summary">{{ .Summary | plainify | chomp }}</p>
</div>
<a class="read-link" href="{{ .RelPermalink }}">{{ T "powered-read" }}</a>
</div>
</div>
</a>
{{ end }}
</div>
<div class="category-buttons category-buttons_center">
<button id="load-button" class="load-button">{{ T "blog-loadmore" }}</button>
</div>
</div>
<script src='{{ "js/categories-filter.js" | relURL }}'></script>
<script>
var ptfConfig={
filters:[
{
name:'categories',
prefix:'category-',
buttonClass:'category-button',
allSelector:'#selectAllAuthors',
attrName:'data-categories',
}
],
showItemClass:"show-item",
filterItemClass:"remove",
activeButtonClass:"active",
numberToView:3,
populateCount:true,
setDisabledButtonClass:"disable-button"
}
var ptf=new CategoriesFilter(ptfConfig);
$("#load-button").click(function(){
$(this).toggleClass('remove');
ptf.showMore();
ptf.showCheck(ptfConfig.filters[0].name,false);
});
function applyFilter(element){
var category=element.id.split('category-');
ptf.resetCount();
ptf.checkFilter(category[1],'category-');
}
</script>
{{ end }}