forked from KEMT/zpwiki
		
	gitsyncrepolink
This commit is contained in:
		
							parent
							
								
									5573c4a9cf
								
							
						
					
					
						commit
						641453858c
					
				| @ -16,3 +16,79 @@ license: MIT | |||||||
| 
 | 
 | ||||||
| dependencies: | dependencies: | ||||||
|   - { name: grav, version: '>=1.6.0' } |   - { name: grav, version: '>=1.6.0' } | ||||||
|  |   - git-sync | ||||||
|  | form: | ||||||
|  |   validation: loose | ||||||
|  |   fields: | ||||||
|  |     tabs: | ||||||
|  |       type: tabs | ||||||
|  |       active: 1 | ||||||
|  |       fields: | ||||||
|  |         gitsynclink_options: | ||||||
|  |           type: tab | ||||||
|  |           title: 'Git Sync Link' | ||||||
|  |           fields: | ||||||
|  |             gitsyncsetup: | ||||||
|  |               type: section | ||||||
|  |               title: Setup | ||||||
|  |               underline: true | ||||||
|  |             display_of_git_sync_repo_link: | ||||||
|  |               type: select | ||||||
|  |               size: medium | ||||||
|  |               classes: fancy | ||||||
|  |               label: 'Location of Git Sync Link' | ||||||
|  |               default: menu | ||||||
|  |               options: | ||||||
|  |                 menu: Menu | ||||||
|  |                 page: 'Page (visible when ''Chromeless'')' | ||||||
|  |                 footer: Footer | ||||||
|  |                 none: None | ||||||
|  |             type_of_git_sync_repo_link: | ||||||
|  |               type: select | ||||||
|  |               size: medium | ||||||
|  |               label: 'Type of Git Sync Link' | ||||||
|  |               default: view | ||||||
|  |               options: | ||||||
|  |                 view: 'View Git Repository' | ||||||
|  |                 edit: 'View/Edit Page in Git Repository' | ||||||
|  |             gitsyncoptions: | ||||||
|  |               type: section | ||||||
|  |               title: Appearance | ||||||
|  |               underline: true | ||||||
|  |             custom_git_sync_repo_link_icon: | ||||||
|  |               type: input.text | ||||||
|  |               size: small | ||||||
|  |               label: 'Custom Font Awesome Icon' | ||||||
|  |               description: 'Short name, e.g. ''code-fork''.' | ||||||
|  |               validate: | ||||||
|  |                 type: text | ||||||
|  |             custom_git_sync_repo_link_text: | ||||||
|  |               type: input.text | ||||||
|  |               size: long | ||||||
|  |               label: 'Custom Link Text' | ||||||
|  |               description: 'Link text, e.g. ''View Page in GitHub'' or ''View Page as Markdown''.' | ||||||
|  |               validate: | ||||||
|  |                 type: text | ||||||
|  |             git_sync_edit_note_text: | ||||||
|  |               type: input.text | ||||||
|  |               size: medium | ||||||
|  |               label: 'Text before Page Link' | ||||||
|  |               description: 'The text before Git Sync Link located on a Page, e.g. ''Have a suggestion or correction?'' or ''Want to reuse this open content?''.' | ||||||
|  |             custom_git_sync_repo_presentation_link_text: | ||||||
|  |               type: input.text | ||||||
|  |               size: long | ||||||
|  |               label: 'Custom Presentation Link Text' | ||||||
|  |               description: 'Link text for embedded Presentations, e.g. ''View Slides in GitHub'' or ''View Slides as Markdown''.' | ||||||
|  |               validate: | ||||||
|  |                 type: text | ||||||
|  |             gitsyncadvanced: | ||||||
|  |               type: section | ||||||
|  |               title: Advanced | ||||||
|  |               underline: true | ||||||
|  |             git_sync_repo_link: | ||||||
|  |               type: input.url | ||||||
|  |               label: 'Custom Git Repository Tree URL' | ||||||
|  |               help: 'Enter the URL that leads to the pages folder of your Git Repository.' | ||||||
|  |               description: 'URL path to pages folder for ''View/Edit Page in Git Repository'' option, but with ''/pages'' and everything following it removed. For example, ''https://github.com/paulhibbitts/demo-grav-course-hub/tree/master''.' | ||||||
|  |               validate: | ||||||
|  |                 type: URL | ||||||
|  | |||||||
| @ -42,7 +42,21 @@ | |||||||
| 		{% endif %} | 		{% endif %} | ||||||
| 		</div> | 		</div> | ||||||
| 	{% endif %} | 	{% endif %} | ||||||
|  | 
 | ||||||
|  |     {% if page.taxonomy.tag|length > 0 %} | ||||||
|  |     {% set taglist = [] %} | ||||||
|  |     {% for tag in page.taxonomy.tag %} | ||||||
|  |         {% set taglist = taglist|merge(['<a href="'~base_url~'/taxonomy?name=tag&val='~(tag|url_encode)~'">'~tag~'</a>']) %} | ||||||
|  |     {% endfor %} | ||||||
|  |     <div class="tags"> | ||||||
|  |         <i class="fa fa-tags rightpad"></i>{{ taglist|join(', ') }} | ||||||
|  |     </div> | ||||||
|  |     {% endif %} | ||||||
|  |     {% if theme_var('display_of_git_sync_repo_link') == 'page' and not (grav.uri.param('summaryonly') or grav.uri.param('onlysummary')) %} | ||||||
|  |         <p>{% include 'partials/git_sync_repo_link_note.html.twig' %}</p> | ||||||
|  |     {% endif %} | ||||||
| 	</section> | 	</section> | ||||||
|  | 
 | ||||||
| 	<section class="content"> | 	<section class="content"> | ||||||
|     	{{ page.content }} |     	{{ page.content }} | ||||||
| 	{% if not page.header.hide_mediasummary %}		 | 	{% if not page.header.hide_mediasummary %}		 | ||||||
| @ -54,15 +68,6 @@ | |||||||
| 
 | 
 | ||||||
|     </section> |     </section> | ||||||
|     <section class="foot"> |     <section class="foot"> | ||||||
|     	{% if page.taxonomy.tag|length > 0 %} |  | ||||||
|     	{% set taglist = [] %} |  | ||||||
| 		{% for tag in page.taxonomy.tag %} |  | ||||||
| 			{% set taglist = taglist|merge(['<a href="'~base_url~'/taxonomy?name=tag&val='~(tag|url_encode)~'">'~tag~'</a>']) %} |  | ||||||
| 		{% endfor %} |  | ||||||
|     	<div class="tags"> |  | ||||||
|     		<i class="fa fa-tags rightpad"></i>{{ taglist|join(', ') }} |  | ||||||
|     	</div> |  | ||||||
|     	{% endif %} |  | ||||||
| 		{% if config.plugins.relatedpages.enabled and related_pages|length > 0 %} | 		{% if config.plugins.relatedpages.enabled and related_pages|length > 0 %} | ||||||
|     	<div class="related topiclist"> |     	<div class="related topiclist"> | ||||||
|     		<h2>{{ 'RELATED_ARTICLES'|t }}</h2> |     		<h2>{{ 'RELATED_ARTICLES'|t }}</h2> | ||||||
|  | |||||||
							
								
								
									
										147
									
								
								themes/mytheme/templates/partials/git_sync_repo_link.html.twig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										147
									
								
								themes/mytheme/templates/partials/git_sync_repo_link.html.twig
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,147 @@ | |||||||
|  | {% if theme_var('git_sync_repo_link') %} | ||||||
|  |   {% if not (page.header.hide_git_sync_repo_link and not (presentationslides)) %} | ||||||
|  |     {% set git_repo_link_url = theme_var('git_sync_repo_link') %} | ||||||
|  |     {% if theme_var('custom_git_sync_repo_link_icon') is empty %} | ||||||
|  |       {% if 'github' in git_repo_link_url %} | ||||||
|  |         {% set git_repo_link_icon = "github" %} | ||||||
|  |       {% elseif 'gitlab' in git_repo_link_url %} | ||||||
|  |         {% set git_repo_link_icon = "gitlab" %} | ||||||
|  |       {% elseif 'bitbucket' in git_repo_link_url %} | ||||||
|  |         {% set git_repo_link_icon = "bitbucket" %} | ||||||
|  |       {% else %} | ||||||
|  |         {% set git_repo_link_icon = "git" %} | ||||||
|  |       {% endif %} | ||||||
|  |     {% else %} | ||||||
|  |       {% set git_repo_link_icon = theme_var('custom_git_sync_repo_link_icon') %} | ||||||
|  |     {% endif %} | ||||||
|  |     {% if theme_var('type_of_git_sync_repo_link') == 'view' or theme_var('type_of_git_sync_repo_link') is empty %} | ||||||
|  |       {% if page.header.git_sync_repo_link_text %} | ||||||
|  |         {% set git_repo_link_text = page.header.git_sync_repo_link_text %} | ||||||
|  |       {% else %} | ||||||
|  |         {% if theme_var('custom_git_sync_repo_link_text') is empty %} | ||||||
|  |           {% set git_repo_link_text = 'View Content Repository' %} | ||||||
|  |         {% else %} | ||||||
|  |           {% if not presentationslides %} | ||||||
|  |             {% set git_repo_link_text = theme_var('custom_git_sync_repo_link_text') %} | ||||||
|  |           {% else %} | ||||||
|  |             {% set git_repo_link_text = theme_var('custom_git_sync_repo_presentation_link_text') %} | ||||||
|  |           {% endif %} | ||||||
|  |         {% endif %} | ||||||
|  |       {% endif %} | ||||||
|  |       {% if not presentationslides %} | ||||||
|  |         <a class="{{ link_classes }}" href="{{ git_repo_link_url }}" title="{{ git_repo_link_text }}" target="_blank"> | ||||||
|  |           <i class="fa fa-{{ git_repo_link_icon }}" aria-hidden="true"></i>{{ git_repo_link_text }}</a> | ||||||
|  |       {% endif %} | ||||||
|  |     {% else %} | ||||||
|  |       {% if page.header.git_sync_repo_link %} | ||||||
|  |         {% set git_repo_link_url = page.header.git_sync_repo_link %} | ||||||
|  |       {% elseif presentationpagepath %} | ||||||
|  |         {% set git_repo_link_url = git_repo_link_url ~ presentationpagepath %} | ||||||
|  |       {% else %} | ||||||
|  |         {% set git_repo_link_url = git_repo_link_url ~ ('/' ~ page.filePathClean) | replace({'/user/': '/'}) %} | ||||||
|  |       {% endif %} | ||||||
|  |       {% if (page.children.count) and (not presentationslides) %} | ||||||
|  |         {% set git_repo_link_url = (git_repo_link_url | replace({ | ||||||
|  |           ('/' ~ page.template ~ '.md'): '/' | ||||||
|  |         })) %} | ||||||
|  |       {% endif %} | ||||||
|  |       {% if page.header.git_sync_repo_link_text %} | ||||||
|  |         {% set git_repo_link_text = page.header.git_sync_repo_link_text %} | ||||||
|  |       {% else %} | ||||||
|  |         {% if not presentationslides %} | ||||||
|  |           {% if theme_var('custom_git_sync_repo_link_text') is empty %} | ||||||
|  |             {% set git_repo_link_text = 'Edit this Page' %} | ||||||
|  |           {% else %} | ||||||
|  |             {% set git_repo_link_text = theme_var('custom_git_sync_repo_link_text') %} | ||||||
|  |           {% endif %} | ||||||
|  |         {% else %} | ||||||
|  |           {% if theme_var('custom_git_sync_repo_presentation_link_text') is empty %} | ||||||
|  |             {% set git_repo_link_text = 'Edit these Slides' %} | ||||||
|  |           {% else %} | ||||||
|  |             {% set git_repo_link_text = theme_var('custom_git_sync_repo_presentation_link_text') %} | ||||||
|  |           {% endif %} | ||||||
|  |         {% endif %} | ||||||
|  |       {% endif %} | ||||||
|  |       {% if presentationslides %}({% endif %}<a class="{{ link_classes }}" href="{{ git_repo_link_url }}" title="{{ git_repo_link_text }}" target="_blank"><i class="fa fa-{{ git_repo_link_icon }}" aria-hidden="true"></i>{{ git_repo_link_text }}</a>{% if presentationslides %}){% endif %} | ||||||
|  |     {% endif %} | ||||||
|  |   {% endif %} | ||||||
|  | {% else %} | ||||||
|  |   {% if not (config.plugins['git-sync'].enabled) or (config.plugins['git-sync'].enabled and config.plugins['git-sync'].repository is empty) %} | ||||||
|  |     {% set admin_panel_appearance_url = grav.base_url ~ '/admin/plugins/git-sync' %} | ||||||
|  |     {% if not presentationslides %} | ||||||
|  |       <a class="{{ link_classes }}" href="{{ admin_panel_appearance_url }}" title="Setup Git Sync"> | ||||||
|  |         <i class="fa fa-cog" aria-hidden="true"></i>Setup Git Sync</a> | ||||||
|  |     {% endif %} | ||||||
|  |   {% else %} | ||||||
|  |     {% if not (page.header.hide_git_sync_repo_link and not (presentationslides)) %} | ||||||
|  |       {% set git_sync_repo = config.plugins['git-sync'].repository %} | ||||||
|  |       {% set git_sync_repo_link = (git_sync_repo | replace({'.git': '/'})) %} | ||||||
|  |       {% if 'github' in git_sync_repo_link %} | ||||||
|  |         {% set git_repo_link_icon = "github" %} | ||||||
|  |         {% set git_repo_link_url = (git_sync_repo | replace({'.git': '/'})) ~ 'blob/master' | replace({'user/': '/'}) %} | ||||||
|  |       {% elseif 'gitlab' in git_sync_repo_link %} | ||||||
|  |         {% set git_repo_link_icon = "gitlab" %} | ||||||
|  |         {% set git_repo_link_url = (git_sync_repo | replace({'.git': '/'})) ~ 'blob/master' | replace({'user/': '/'}) %} | ||||||
|  |       {% elseif 'bitbucket' in git_sync_repo_link %} | ||||||
|  |         {% set git_repo_link_icon = "bitbucket" %} | ||||||
|  |         {% set git_repo_link_url = (git_sync_repo | replace({'.git': '/'})) ~ 'src/master' | replace({'user/': '/'}) %} | ||||||
|  |       {% else %} | ||||||
|  |         {% set git_repo_link_icon = "git" %} | ||||||
|  |         {% set git_repo_link_url = (git_sync_repo | replace({'.git': '/'})) ~ 'blob/master' | replace({'user/': '/'}) %} | ||||||
|  |       {% endif %} | ||||||
|  |       {% if page.header.git_sync_repo_link %} | ||||||
|  |         {% set git_repo_link_url = page.header.git_sync_repo_link %} | ||||||
|  |       {% elseif presentationpagepath %} | ||||||
|  |         {% set git_repo_link_url = git_repo_link_url ~ presentationpagepath %} | ||||||
|  |       {% else %} | ||||||
|  |         {% set git_repo_link_url = git_repo_link_url ~ ('/' ~ page.filePathClean) | replace({'/user/': '/'}) %} | ||||||
|  |       {% endif %} | ||||||
|  |       {% if theme_var('custom_git_sync_repo_link_icon') is not empty %} | ||||||
|  |         {% set git_repo_link_icon = theme_var('custom_git_sync_repo_link_icon') %} | ||||||
|  |       {% endif %} | ||||||
|  |       {% if theme_var('type_of_git_sync_repo_link') == 'view' or theme_var('type_of_git_sync_repo_link') is empty %} | ||||||
|  |         {% if page.header.git_sync_repo_link_text %} | ||||||
|  |           {% set git_repo_link_text = page.header.git_sync_repo_link_text %} | ||||||
|  |         {% else %} | ||||||
|  |           {% if theme_var('git_sync_repo_link_text') is empty %} | ||||||
|  |             {% set git_repo_link_text = 'View Content Repository' %} | ||||||
|  |           {% else %} | ||||||
|  |             {% if not presentationslides %} | ||||||
|  |               {% set git_repo_link_text = theme_var('custom_git_sync_repo_link_text') %} | ||||||
|  |             {% else %} | ||||||
|  |               {% set git_repo_link_text = theme_var('custom_git_sync_repo_presentation_link_text') %} | ||||||
|  |             {% endif %} | ||||||
|  |           {% endif %} | ||||||
|  |         {% endif %} | ||||||
|  |         {% if not presentationslides %} | ||||||
|  |           <a class="{{ link_classes }}" href="{{ git_sync_repo_link}}" title="{{ git_repo_link_text }}" target="_blank"> | ||||||
|  |             <i class="fa fa-{{ git_repo_link_icon }}" aria-hidden="true"></i>{{ git_repo_link_text }}</a> | ||||||
|  |         {% endif %} | ||||||
|  |       {% else %} | ||||||
|  |         {% if (page.children.count) and (not presentationslides) %} | ||||||
|  |           {% set git_repo_link_url = (git_repo_link_url | replace({ | ||||||
|  |             ('/' ~ page.template ~ '.md'): '/' | ||||||
|  |           })) %} | ||||||
|  |         {% endif %} | ||||||
|  |         {% if page.header.git_sync_repo_link_text %} | ||||||
|  |           {% set git_repo_link_text = page.header.git_sync_repo_link_text %} | ||||||
|  |         {% else %} | ||||||
|  |           {% if not presentationslides %} | ||||||
|  |             {% if theme_var('custom_git_sync_repo_link_text') is empty %} | ||||||
|  |               {% set git_repo_link_text = 'Edit this Page' %} | ||||||
|  |             {% else %} | ||||||
|  |               {% set git_repo_link_text = theme_var('custom_git_sync_repo_link_text') %} | ||||||
|  |             {% endif %} | ||||||
|  |           {% else %} | ||||||
|  |             {% if theme_var('custom_git_sync_repo_presentation_link_text') is empty %} | ||||||
|  |               {% set git_repo_link_text = 'Edit these Slides' %} | ||||||
|  |             {% else %} | ||||||
|  |               {% set git_repo_link_text = theme_var('custom_git_sync_repo_presentation_link_text') %} | ||||||
|  |             {% endif %} | ||||||
|  |           {% endif %} | ||||||
|  |         {% endif %} | ||||||
|  |         {% if presentationslides %}({% endif %}<a class="{{ link_classes }}" href="{{ git_repo_link_url }}" title="{{ git_repo_link_text }}" target="_blank"><i class="fa fa-{{ git_repo_link_icon }}" aria-hidden="true"></i>{{ git_repo_link_text }}</a>{% if presentationslides %}){% endif %} | ||||||
|  |       {% endif %} | ||||||
|  |     {% endif %} | ||||||
|  |   {% endif %} | ||||||
|  | {% endif %} | ||||||
| @ -0,0 +1,7 @@ | |||||||
|  | {% if not page.header.hide_git_sync_repo_link %} | ||||||
|  |     <div class="gitrepo-link-note"> | ||||||
|  |         <p>{{ theme_var('git_sync_edit_note_text') }} | ||||||
|  |             {% include 'partials/git_sync_repo_link.html.twig' %} | ||||||
|  |         </p> | ||||||
|  |     </div> | ||||||
|  | {% endif %} | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user