Skip to content

Commit

Permalink
Changed plugin name and split functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
Moonlight63 committed Aug 2, 2017
1 parent 3210fc3 commit 6f003cf
Show file tree
Hide file tree
Showing 20 changed files with 250 additions and 495 deletions.
6 changes: 0 additions & 6 deletions .gitignore

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# v0.9.0
## 08/01/17
1. [](#new)
* Changed the whole plugin structure and name.

# v0.8.8
## 07/07/17
1. [](#improved)
Expand Down
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# Grav Users Admin Managment Plugin
# Grav Users Page Ownership

## UPDATE:

I have decided to change the direction of this plugin due to the advancements of the other "Admin Users Managment" plugin by david-szabo97. This plugin no longer adds the user managment functionallity, but instead is best used in conjunction with the aforementioned plugin. It now simply adds the page ownership functionallity, useful for blog style implementations of grav on blogs with multiple authors. I will expand on more detailed information in the future. For now, here is a basic use case:


All pages now have a 'creator' frontmatter that can be used in a twig template like so:

~~~~
{{ page.header.creator }}
~~~~

However, this only returns the username of the creator. Fear not! You can use the username to retrive the grave user object of that user with the "users" twig variable:

~~~~
{{ users.getUser(page.header.creator) }}
~~~~

Other information about this user can be fetched like so:

~~~~
{{ users.getUser(page.header.creator).fullname }}
{{ users.getUser(page.header.creator).username }}
{{ users.getUser(page.header.creator).email }}
{{ users.getUser(page.header.creator).title }}
{{ users.getUser(page.header.creator).about }}
{{ users.getUser(page.header.creator).avatar }}
{{ users.getUser(page.header.creator).language }}
~~~~

This information can be used in any twig template. I have included an "Authors Bio" page with the plugin (named 'userpage.html.twig') but you should probably override it for your needs, as I used bootstrap and matched it to my pre-existing website. Accessing this page is easy enough, it works exactly like the 'simple search' plugin, but without the searchbar. Just travel to YOURBLOG.com/authors/query:YOURUSERNAME.
I may add the ability to change this link in the future if it is requested enough. This page holds a collection of all 'item' pages created by the specified user.

You can create links back to this page from eg: a blog post, like so:

~~~~
<strong>Posted By: </strong><a href="{{ home_url }}/authors/query{{ config.system.param_sep }}{{ users.getUser(page.header.creator).username }}">{{ users.getUser(page.header.creator).fullname }}</a>
~~~~

Users can be restricted to only see pages that they have created. Pages can be set to be gloably viewable and/or editable by a group. Users can only create subpages to pages they can view or edit. Allowing Users to create pages at -ROOT- is optional. Users can be banned from deleting pages.





# OLD VERSION
ok, so I saw that someone released a "users plugin" not too long ago. Im uploading this one anyway because I had been working on it for a while. I could have uploaded it months ago, but I took a hiatus on programming, so I didn't bother to upload knowing that I wouldn't be back to it for a while. If someone ever wanted to take over this one, go for it.

## Basic rundown:
Expand Down
7 changes: 0 additions & 7 deletions admin/pages/groups.md

This file was deleted.

7 changes: 0 additions & 7 deletions admin/pages/users.md

This file was deleted.

6 changes: 3 additions & 3 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Advanced Admin Users Managment
version: 0.8.7
description: Adds user managment functionality to your admin interface
name: Users Page Ownership
version: 0.9.0
description: Adds user ownership functionality to your pages
icon: user
author:
name: Dalen Catt
Expand Down
7 changes: 2 additions & 5 deletions blueprints/admin/pages/new.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@

form:
fields:

route:
replace@: true
type: select
type: filteredparent
label: PLUGIN_ADMIN.PARENT_PAGE
classes: fancy
data-options@: '\Grav\Plugin\TwigUsers::parentsRawRoutes'
data-default@: '\Grav\Plugin\Admin\Admin::getLastPageRoute'
validate:
required: true

Expand Down
60 changes: 9 additions & 51 deletions blueprints/pages/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ form:
fields:
advanced:
fields:
columns:
fields:
column1:
fields:
route:
type: filteredparent
label: PLUGIN_ADMIN.PARENT
classes: fancy

admin_only:
fields:
header.creator:
Expand Down Expand Up @@ -37,54 +46,3 @@ form:
help: PLUGIN_ADMIN.GROUPS_HELP
validate:
type: commalist

overrides:
fields:
header.markdown.extra:
ordering@: header.process
toggleable: true
type: toggle
label: Markdown extra
help: PLUGIN_ADMIN.MARKDOWN_EXTRA_HELP
highlight: 0
options:
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
validate:
type: bool
header.markdown.auto_line_breaks:
ordering@: header.markdown.extra
toggleable: true
type: toggle
label: PLUGIN_ADMIN.AUTO_LINE_BREAKS
help: PLUGIN_ADMIN.AUTO_LINE_BREAKS_HELP
highlight: 0
options:
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
validate:
type: bool
header.markdown.auto_url_links:
ordering@: header.markdown.auto_line_breaks
toggleable: true
type: toggle
label: PLUGIN_ADMIN.AUTO_URL_LINKS
help: PLUGIN_ADMIN.AUTO_URL_LINKS_HELP
highlight: 0
options:
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
validate:
type: bool
header.markdown.escape_markup:
ordering@: header.markdown.auto_url_links
toggleable: true
type: toggle
label: PLUGIN_ADMIN.ESCAPE_MARKUP
help: PLUGIN_ADMIN.ESCAPE_MARKUP_HELP
highlight: 0
options:
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
validate:
type: bool
29 changes: 0 additions & 29 deletions blueprints/pages/new.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions blueprints/user/account.yaml

This file was deleted.

31 changes: 0 additions & 31 deletions css/users.css

This file was deleted.

11 changes: 0 additions & 11 deletions pages/user.md

This file was deleted.

45 changes: 45 additions & 0 deletions templates/forms/fields/filteredparent/filteredparent.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% extends "forms/fields/pages/pages.html.twig" %}
{% import "forms/fields/pages/pages.html.twig" as parent %}

{% block input %}

{% set last_page_route = admin.page.getLastPageRoute %}
{% set show_slug_val = true %}
{% set show_fullpath_val = false %}

{% set show_parents = config.get('plugins.admin.pages.show_parents') %}
{% if show_parents == 'folder' %}
{% set show_slug_val = false %}
{% elseif show_parents == 'fullpath' %}
{% set show_fullpath_val = true %}
{% endif %}

{% set defaults = {show_root:true, show_all:true, show_slug:show_slug_val, show_fullpath:show_fullpath_val, default:last_page_route} %}
{% set field = field|merge(defaults) %}


{% set start_page = field.start_route ? pages.find(field.start_route) : null %}
{% set show_all = field.show_all is same as(false) ? false : true %}
{% set show_fullpath = field.show_fullpath is same as(true) ? true : false %}
{% set show_slug = field.show_slug is same as(true) ? true : false %}
{% set show_modular = field.show_modular is same as(true) ? true : false %}
{% set limit_levels = field.limit_levels ?: false %}

{% set page_list = users.parentsRawRoutes(start_page, show_all, show_fullpath, show_slug, show_modular, limit_levels) %}

<div class="form-select-wrapper {{ field.size }}">
<select class="{{ field.classes }}" name="{{ (scope ~ field.name)|fieldName ~ (field.multiple ? '[]' : '') }}"
{% if field.autofocus in ['on', 'true', 1] %}autofocus="autofocus"{% endif %}
{% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
{% if field.multiple in ['on', 'true', 1] %}multiple="multiple"{% endif %}
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
>
{% if field.show_root and (authorize('users.canPostToRoot') or authorize('admin.super')) %}
<option value="/">/ ({{ "PLUGIN_ADMIN.DEFAULT_OPTION_ROOT"|tu }})</option>
{% endif %}
{{ parent.page_options(_context, page_list) }}
</select>
</div>
{% endblock %}

Loading

0 comments on commit 6f003cf

Please sign in to comment.