mirror of
https://github.com/clockworkpi/wiki.clockworkpi.com.git
synced 2025-12-12 08:48:51 +01:00
Issue #6 List of pages per user
This commit is contained in:
parent
45bc42f572
commit
e285abc65b
@ -3,12 +3,11 @@ layout: default
|
||||
title: All pages
|
||||
menu: ['global']
|
||||
---
|
||||
{%- include /functions/wiki-pages.html -%}
|
||||
<ul class="columns">
|
||||
{%- for page in wiki_pages -%}
|
||||
{%- for page in site.data.wiki_pages -%}
|
||||
<li>
|
||||
<a href="{{ page.url }}.html">{{ page.title }}</a> [{{ page.bytes }} bytes]
|
||||
{%- if page.author -%} (by <a href="/{{ site.data.i18n[site.lang].prefix.user }}{{ page.author }}.html">{{ page.author }}</a>) {%- endif -%}
|
||||
{%- if page.author_full -%} (by <a href="{{ page.author_full.url }}.html">{{ page.author_full.name }}</a>) {%- endif -%}
|
||||
</li>
|
||||
{%- endfor -%}
|
||||
</ul>
|
||||
|
||||
@ -3,11 +3,10 @@ layout: default
|
||||
title: Tags
|
||||
menu: ['global']
|
||||
---
|
||||
{%- include /functions/wiki-tags.html -%}
|
||||
<ul>
|
||||
{%- for tag in tags -%}
|
||||
{%- for tag in site.data.wiki_tags -%}
|
||||
{%- assign counter = 0 -%}
|
||||
{%- for other_page in wiki_pages %}
|
||||
{%- for other_page in site.data.wiki_pages %}
|
||||
{%- if other_page.tags contains tag -%}
|
||||
{%- assign counter = counter | plus: 1 -%}
|
||||
{%- endif -%}
|
||||
|
||||
@ -3,14 +3,13 @@ layout: default
|
||||
title: Redirects
|
||||
menu: ['global']
|
||||
---
|
||||
{%- include /functions/wiki-pages.html -%}
|
||||
{%- assign redirect_pages = site.special | where_exp: 'page', 'page.redirect' -%}
|
||||
|
||||
<ul>
|
||||
{%- for source_page in redirect_pages -%}
|
||||
<li>
|
||||
{%- assign redirect = source_page.redirect | liquify | prepend: '/' -%}
|
||||
{%- for other_page in wiki_pages -%}
|
||||
{%- for other_page in site.data.wiki_pages -%}
|
||||
{%- if other_page.id == redirect -%}
|
||||
{%- assign redirect_page = other_page -%}
|
||||
{%- endif -%}
|
||||
|
||||
@ -3,15 +3,10 @@ layout: default
|
||||
title: Users
|
||||
menu: ['global']
|
||||
---
|
||||
{%- include /functions/wiki-tags.html -%}
|
||||
<ul>
|
||||
{%- for user in site.data.users -%}
|
||||
{%- assign counter = 0 -%}
|
||||
{%- for other_page in wiki_pages %}
|
||||
{%- if other_page.author == user[0] -%}
|
||||
{%- assign counter = counter | plus: 1 -%}
|
||||
{%- endif -%}
|
||||
{%- for author in site.data.authors -%}
|
||||
<li>
|
||||
<a href="{{ author.url }}.html">{{ author.name }}</a> (<a href="{{ author.contributions_url }}.html">{{author.contributions_count}} pages</a>)
|
||||
</li>
|
||||
{%- endfor -%}
|
||||
<li><a href="/{{ site.data.i18n[site.lang].prefix.user }}{{ user[0] }}.html">{{ user[1].name }}</a> ({{counter}} pages)</li>
|
||||
{%- endfor -%}
|
||||
</ul>
|
||||
|
||||
@ -3,8 +3,7 @@ layout: default
|
||||
title: Long pages
|
||||
menu: ['global']
|
||||
---
|
||||
{%- include /functions/wiki-pages.html -%}
|
||||
{%- assign long_pages = wiki_pages | sort: 'bytes' | reverse -%}
|
||||
{%- assign long_pages = site.data.wiki_pages | sort: 'bytes' | reverse -%}
|
||||
<ol>
|
||||
{%- for page in long_pages limit:50 -%}
|
||||
<li>
|
||||
|
||||
@ -3,8 +3,7 @@ layout: default
|
||||
title: Recent changes
|
||||
menu: ['global']
|
||||
---
|
||||
{%- include /functions/wiki-pages.html -%}
|
||||
{%- assign recent_changes = wiki_pages | where_exp: 'page', 'page.modified' | sort: 'modified' | reverse -%}
|
||||
{%- assign recent_changes = site.data.wiki_pages | where_exp: 'page', 'page.modified' | sort: 'modified' | reverse -%}
|
||||
<ul>
|
||||
{%- for page in recent_changes limit:20 -%}
|
||||
<li>
|
||||
|
||||
@ -3,8 +3,7 @@ layout: default
|
||||
title: Short pages
|
||||
menu: ['global']
|
||||
---
|
||||
{%- include /functions/wiki-pages.html -%}
|
||||
{%- assign long_pages = wiki_pages | sort: 'bytes' -%}
|
||||
{%- assign long_pages = site.data.wiki_pages | sort: 'bytes' -%}
|
||||
<ol>
|
||||
{%- for page in long_pages limit:50 -%}
|
||||
<li>
|
||||
|
||||
@ -7,8 +7,7 @@ layout: null
|
||||
<title>{{ site.title }}</title>
|
||||
<description>{{ site.description }}</description>
|
||||
<link>{{ site.url }}</link>
|
||||
{% include /functions/wiki-pages.html %}
|
||||
{% for post in wiki_pages reversed%}
|
||||
{% for post in site.data.wiki_pages reversed%}
|
||||
{% unless post.draft %}
|
||||
<item>
|
||||
<title>{{ post.title | xml_escape }}</title>
|
||||
|
||||
@ -2,46 +2,11 @@
|
||||
layout: default
|
||||
title: Tags
|
||||
---
|
||||
{% assign var = 10 %}
|
||||
|
||||
{% comment %}
|
||||
=======================
|
||||
The following part extracts all the tags from your posts and sort tags, so that you do not need to manually collect your tags to a place.
|
||||
=======================
|
||||
{% endcomment %}
|
||||
{% assign rawtags = "" %}
|
||||
|
||||
{% include /functions/wiki-pages.html %}
|
||||
|
||||
{% for wiki_page in wiki_pages %}
|
||||
{% assign ttags = wiki_page.tags | join:'|' | append:'|' %}
|
||||
{% assign rawtags = rawtags | append:ttags %}
|
||||
{% endfor %}
|
||||
{% assign rawtags = rawtags | split:'|' | sort %}
|
||||
|
||||
{% comment %}
|
||||
=======================
|
||||
The following part removes dulpicated tags and invalid tags like blank tag.
|
||||
=======================
|
||||
{% endcomment %}
|
||||
|
||||
{% assign tags = "" %}
|
||||
{% for tag in rawtags %}
|
||||
{% if tag != "" %}
|
||||
{% if tags == "" %}
|
||||
{% assign tags = tag | split:'|' %}
|
||||
{% endif %}
|
||||
{% unless tags contains tag %}
|
||||
{% assign tags = tags | join:'|' | append:'|' | append:tag | split:'|' %}
|
||||
{% endunless %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<ul>
|
||||
{% for tag in tags %}
|
||||
{% for tag in site.data.wiki_tags %}
|
||||
<li id="n-tag-{{ tag }}"><a href="/{{ site.data.i18n[site.lang].prefix.tag }}{{ tag }}.html">{{ tag }}</a></li>
|
||||
<ul>
|
||||
{% for other_page in wiki_pages %}
|
||||
{% for other_page in site.data.wiki_pages %}
|
||||
{% if other_page.tags contains tag %}
|
||||
<li><a href="{{ other_page.url }}">{{ other_page.title }}</a></li>
|
||||
{% endif %}
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
{%- include /functions/wiki-pages.html -%}
|
||||
|
||||
{%- if include.page -%}
|
||||
{%- assign source_page = include.source_page -%}
|
||||
{%- else -%}
|
||||
@ -7,7 +5,7 @@
|
||||
{%- endif -%}
|
||||
|
||||
{%- assign redirect = source_page.redirect | liquify -%}
|
||||
{%- for other_page in wiki_pages -%}
|
||||
{%- for other_page in site.data.wiki_pages -%}
|
||||
{%- if other_page.id == redirect -%}
|
||||
{%- assign redirect_page = other_page -%}
|
||||
{%- endif -%}
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
{%- assign wiki_pages = '' | split: '' -%}
|
||||
{%- for collection in site.collections -%}
|
||||
{%- assign prefix = collection.label | slice: 0, 4 -%}
|
||||
{%- if prefix == 'wiki' -%}
|
||||
{%- assign wiki_pages = wiki_pages | concat: collection.docs -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
@ -1,33 +0,0 @@
|
||||
{%- comment -%}
|
||||
=======================
|
||||
The following part extracts all the tags from your posts and sort tags, so that you do not need to manually collect your tags to a place.
|
||||
=======================
|
||||
{%- endcomment -%}
|
||||
{%- assign rawtags = "" -%}
|
||||
{%- include /functions/wiki-pages.html -%}
|
||||
|
||||
{%- for wiki_page in wiki_pages -%}
|
||||
{%- assign ttags = wiki_page.tags | join:'|' | append:'|' -%}
|
||||
{%- assign rawtags = rawtags | append:ttags -%}
|
||||
{%- endfor -%}
|
||||
{%- assign rawtags = rawtags | split:'|' | sort -%}
|
||||
|
||||
{%- comment -%}
|
||||
=======================
|
||||
The following part removes dulpicated tags and invalid tags like blank tag.
|
||||
=======================
|
||||
{%- endcomment -%}
|
||||
|
||||
{%- assign tags = "" -%}
|
||||
{%- for tag in rawtags -%}
|
||||
{%- if tag != "" -%}
|
||||
{%- if tags == "" -%}
|
||||
{%- assign tags = tag | split:'|' -%}
|
||||
{%- endif -%}
|
||||
{%- unless tags contains tag -%}
|
||||
{%- assign tags = tags | join:'|' | append:'|' | append:tag | split:'|' -%}
|
||||
{%- endunless -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
|
||||
{%- assign wiki_tags = tags -%}
|
||||
@ -3,11 +3,10 @@
|
||||
<h3>{{ site.data.i18n[site.lang].label.tags }}</h3>
|
||||
<div class="portlet-body">
|
||||
<ul>
|
||||
{%- include /functions/wiki-pages.html -%}
|
||||
{%- for tag in page.tags -%}
|
||||
<li id="n-tag-{{ tag }}"><a href="/{{ site.data.i18n[site.lang].prefix.tag }}{{ tag }}.html">{{ tag }}</a></li>
|
||||
<ul>
|
||||
{%- for other_page in wiki_pages -%}
|
||||
{%- for other_page in site.data.wiki_pages -%}
|
||||
{%- if other_page.tags contains tag and other_page.id != page.id -%}
|
||||
<li><a href="{{ other_page.url }}.html">{{ other_page.title }}</a></li>
|
||||
{%- endif -%}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
{%- if page.author -%}
|
||||
{%- if page.author_full -%}
|
||||
<div id="author" class="portlet">
|
||||
<div class="portlet-body">
|
||||
{%- assign author = site.data.users[page.author] -%}
|
||||
{%- assign author = page.author_full -%}
|
||||
<ul>
|
||||
<li><a href="/{{ site.data.i18n[site.lang].prefix.user }}{{ page.author }}">{{ author.name }}</a></li>
|
||||
<li><a href="{{ author.url }}">{{ author.name }}</a></li>
|
||||
</ul>
|
||||
{%- if author.logo -%}
|
||||
<img src="/{{ author.logo }}" style="max-width: 100%;margin: 3px" />
|
||||
|
||||
11
_layouts/contributions.html
Normal file
11
_layouts/contributions.html
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
layout: default
|
||||
menu: ['global']
|
||||
---
|
||||
<ul class="columns">
|
||||
{%- for doc in page.author_full.contributions -%}
|
||||
<li>
|
||||
<a href="{{ doc.url }}.html">{{ doc.title }}</a>
|
||||
</li>
|
||||
{%- endfor -%}
|
||||
</ul>
|
||||
@ -7,9 +7,8 @@ menu: ['global']
|
||||
<h3>{{ site.data.i18n[site.lang].label.tag_pages }} {{ page.tags }}</h3>
|
||||
<div class="columns">
|
||||
<ul>
|
||||
{% include /functions/wiki-pages.html %}
|
||||
{% for tag in page.tags %}
|
||||
{% for other_page in wiki_pages %}
|
||||
{% for other_page in site.data.wiki_pages %}
|
||||
{% if other_page.tags contains tag and other_page.id != page.id %}
|
||||
<li><a href="{{ other_page.url }}">{{ other_page.title }}</a></li>
|
||||
{% endif %}
|
||||
|
||||
5
_layouts/user.html
Normal file
5
_layouts/user.html
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
layout: default
|
||||
menu: ['global']
|
||||
---
|
||||
{{ content }}
|
||||
22
_plugins/contributions-page-generator.rb
Normal file
22
_plugins/contributions-page-generator.rb
Normal file
@ -0,0 +1,22 @@
|
||||
module Jekyll
|
||||
class ContributionsPageGenerator < Generator
|
||||
def generate(site)
|
||||
site.data['authors'].each do |author|
|
||||
site.pages << ContributionsPage.new(site, author)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ContributionsPage < Page
|
||||
def initialize(site, author)
|
||||
@site = site
|
||||
@base = site.source
|
||||
@name = "#{author['contributions_url']}.html"
|
||||
|
||||
self.process(@name)
|
||||
self.read_yaml(File.join(@base, '_layouts'), 'contributions.html')
|
||||
self.data['author_full'] = author
|
||||
self.data['title'] = "Contributions by <a href=\"/#{site.data['i18n'][site.config['lang']]['prefix']['user']}#{author['id']}.html\">#{author['name']}</a>"
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,8 +1,45 @@
|
||||
Jekyll::Hooks.register :documents, :pre_render do |post|
|
||||
Jekyll::Hooks.register :site, :post_read do |site|
|
||||
user_pages = site.collections
|
||||
.select { |key, collection| key.start_with?('special') }
|
||||
.map { |key, collection| collection.docs }
|
||||
.flatten
|
||||
.select { |page| page.data['layout'] == 'user' }
|
||||
|
||||
wiki_pages = site.collections
|
||||
.select { |key, collection| key.start_with?('wiki') }
|
||||
.map { |key, collection| collection.docs }
|
||||
.flatten
|
||||
site.data['wiki_pages'] = wiki_pages
|
||||
|
||||
wiki_tags = wiki_pages
|
||||
.map { |page| page.data['tags'] }
|
||||
.flatten
|
||||
.uniq
|
||||
site.data['wiki_tags'] = wiki_tags
|
||||
|
||||
prefix = site.data['i18n'][site.config['lang']]['prefix']['user']
|
||||
authors = site.data['users'].map do |user|
|
||||
contributions = wiki_pages.select { |page| page.data['author'] == user[0] }
|
||||
author = {'id' => user[0],
|
||||
'name' => user[1]['name'],
|
||||
'logo' => user[1]['logo'],
|
||||
'url' => "/#{prefix}#{user[0]}",
|
||||
'contributions' => contributions,
|
||||
'contributions_count' => contributions.length,
|
||||
'contributions_url' => "/#{prefix}#{user[0]}:Contributions"
|
||||
}
|
||||
user_pages.select { |page| page.url == author['url'] }
|
||||
.each { |page| page.data['author_full'] = author }
|
||||
author
|
||||
end
|
||||
site.data['authors'] = authors
|
||||
|
||||
wiki_pages.each do |page|
|
||||
page.data['author_full'] = authors.select { |author| author['id'] == page.data['author'] }.first
|
||||
end
|
||||
end
|
||||
|
||||
Jekyll::Hooks.register :documents, :post_render do |doc|
|
||||
# Jekyll.logger.info "Generating:", "Firing :pages, :post_render for : #{post.content}"
|
||||
if doc.content then
|
||||
doc.data['size']=doc.content.size
|
||||
doc.data['bytes']=doc.content.bytesize
|
||||
|
||||
@ -70,6 +70,10 @@ a {
|
||||
font-weight: bold;
|
||||
font-size: 210%;
|
||||
margin-bottom: 0.5em;
|
||||
|
||||
a {
|
||||
color: #424242;
|
||||
}
|
||||
}
|
||||
|
||||
pre, code {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
layout: simple
|
||||
layout: user
|
||||
title: Alexis
|
||||
created: 2019-04-12
|
||||
modified: 2019-04-12
|
||||
@ -8,4 +8,9 @@ revisions:
|
||||
date: 2019-04-12
|
||||
comment: First version
|
||||
---
|
||||
I'm a developer.
|
||||
<div>
|
||||
I'm a developer.
|
||||
</div>
|
||||
<div>
|
||||
I've written <a href="{{ page.author_full.contributions_url }}">{{ page.author_full.contributions_count }} pages</a>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user