Skip to content
Snippets Groups Projects
Commit 37a62bb6 authored by Marcus Eibrink-Lunzenauer's avatar Marcus Eibrink-Lunzenauer
Browse files

Add templates

parent 0f7b2f5c
No related branches found
No related tags found
No related merge requests found
Showing
with 393 additions and 19 deletions
---
inject: true
to: <%= pluginclassname %>
skip_if: StandardPlugin,
after: \/\* Plugin Interfaces \*\/
---
StandardPlugin,
\ No newline at end of file
---
inject: true
to: <%= pluginclassname %>
skip_if: getInfoTemplate|getIconNavigation|getTabNavigation|getMetadata
after: \/\* Interface Methods \*\/
---
/**
* Return a template (an instance of the Flexi_Template class)
* to be rendered on the course summary page. Return NULL to
* render nothing for this plugin.
*
* The template will automatically get a standard layout, which
* can be configured via attributes set on the template:
*
* title title to display, defaults to plugin name
* icon_url icon for this plugin (if any)
* admin_url admin link for this plugin (if any)
* admin_title title for admin link (default: Administration)
*
* @return object template object to render or NULL
*/
function getInfoTemplate($course_id)
{
return null;
}
/**
* Return a navigation object representing this plugin in the
* course overview table or return NULL if you want to display
* no icon for this plugin (or course). The navigation object's
* title will not be shown, only the image (and its associated
* attributes like 'title') and the URL are actually used.
*
* By convention, new or changed plugin content is indicated
* by a different icon and a corresponding tooltip.
*
* @param string $course_id course or institute range id
* @param int $last_visit time of user's last visit
* @param string $user_id the user to get the navigation for
*
* @return object navigation item to render or NULL
*/
function getIconNavigation($course_id, $last_visit, $user_id)
{
return null;
}
/**
* Return a navigation object representing this plugin in the
* course overview table or return NULL if you want to display
* no icon for this plugin (or course). The navigation object's
* title will not be shown, only the image (and its associated
* attributes like 'title') and the URL are actually used.
*
* By convention, new or changed plugin content is indicated
* by a different icon and a corresponding tooltip.
*
* @param string $course_id course or institute range id
*
* @return array navigation item to render or NULL
*/
function getTabNavigation($course_id)
{
return null;
}
/**
* Provides metadata like a descriptional text for this module that
* is shown on the course "+" page to inform users about what the
* module acutally does. Additionally, a URL can be specified.
*
* @return array metadata containg description and/or url
*/
function getMetadata()
{
return [];
}
const fs = require("fs");
const path = require("path");
module.exports = [
{
type: "list",
name: "pluginclassname",
message: "Welche Plugin-Klasse?",
choices: function() {
const pluginDirectory = path.join(__dirname, "../../..");
const manifestFilename = pluginDirectory + "/plugin.manifest";
const manifest = fs.readFileSync(manifestFilename, "utf-8");
const result = manifest.match(/^pluginclassname=.*/gm);
if (!result) {
return null;
}
const x = result.reduce((memo, item) => {
const pluginClassname = item.substr("pluginclassname=".length);
console.log(pluginClassname);
const oldStyle = pluginClassname + ".class.php";
const newStyle = pluginClassname + ".php";
if (fs.existsSync(path.join(pluginDirectory, oldStyle))) {
memo.push(oldStyle);
} else if (fs.existsSync(path.join(pluginDirectory, newStyle))) {
memo.push(newStyle);
}
return memo;
}, []);
console.log(x);
return x;
}
}
];
---
message: |
hygen {bold generator new} --name [NAME] --action [ACTION]
hygen {bold generator with-prompt} --name [NAME] --action [ACTION]
---
\ No newline at end of file
---
to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs.t
---
---
to: app/hello.js
---
const hello = ```
Hello!
This is your first hygen template.
Learn what it can do here:
https://github.com/jondot/hygen
```
console.log(hello)
---
to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs.t
---
---
to: app/hello.js
---
const hello = ```
Hello!
This is your first prompt based hygen template.
Learn what it can do here:
https://github.com/jondot/hygen
```
console.log(hello)
---
to: _templates/<%= name %>/<%= action || 'new' %>/prompt.js
---
// see types of prompts:
// https://github.com/SBoudrias/Inquirer.js#prompt-types
//
// and for examples for prompts:
// https://github.com/SBoudrias/Inquirer.js/tree/master/examples
module.exports = [
{
type: 'input',
name: 'message',
message: "What's your message?"
}
]
---
to: <%= pluginclassname %>.php
---
<?php
/**
* Stud.IP plugin.
*/
class <%= pluginclassname %> extends StudIPPlugin implements
/* Plugin Interfaces */
<%= plugininterfaces.join(",\n ") %>
{
public function __construct()
{
parent::__construct();
require_once 'vendor/autoload.php';
}
/* Interface Methods */
}
const fs = require("fs");
const path = require("path");
module.exports = [
{
type: "input",
name: "pluginclassname",
message: "Wie soll die Plugin-Klasse heißen?",
validate: function(input) {
if (input.match(/^[A-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/)) {
return true;
}
return "Ungültiger Klassenname";
}
},
{
type: "checkbox",
name: "plugininterfaces",
message: "Welche Plugin-Interface?",
choices: ["StandardPlugin", "SystemPlugin"],
validate: function(input) {
if (input.length) {
return true;
}
return "Mindestens ein Plugin-Interface muss gewählt sein.";
}
}
];
---
inject: true
to: <%= pluginclassname %>.php
skip_if: getInfoTemplate
after: \/\* Interface Methods \*\/
---
/**
* Return a template (an instance of the Flexi_Template class)
* to be rendered on the course summary page. Return NULL to
* render nothing for this plugin.
*
* The template will automatically get a standard layout, which
* can be configured via attributes set on the template:
*
* title title to display, defaults to plugin name
* icon_url icon for this plugin (if any)
* admin_url admin link for this plugin (if any)
* admin_title title for admin link (default: Administration)
*
* @return object template object to render or NULL
*/
function getInfoTemplate($course_id)
{
return null;
}
/**
* Return a navigation object representing this plugin in the
* course overview table or return NULL if you want to display
* no icon for this plugin (or course). The navigation object's
* title will not be shown, only the image (and its associated
* attributes like 'title') and the URL are actually used.
*
* By convention, new or changed plugin content is indicated
* by a different icon and a corresponding tooltip.
*
* @param string $course_id course or institute range id
* @param int $last_visit time of user's last visit
* @param string $user_id the user to get the navigation for
*
* @return object navigation item to render or NULL
*/
public function getIconNavigation($course_id, $last_visit, $user_id)
{
return null;
}
/**
* Return a navigation object representing this plugin in the
* course overview table or return NULL if you want to display
* no icon for this plugin (or course). The navigation object's
* title will not be shown, only the image (and its associated
* attributes like 'title') and the URL are actually used.
*
* By convention, new or changed plugin content is indicated
* by a different icon and a corresponding tooltip.
*
* @param string $course_id course or institute range id
*
* @return array navigation item to render or NULL
*/
public function getTabNavigation($course_id)
{
return null;
}
---
inject: true
to: <%= pluginclassname %>.php
xskip_if: SystemPlugin,
after: \/\* Interface Methods \*\/
---
const fs = require("fs");
const path = require("path");
module.exports = [
{
type: "list",
name: "pluginclassname",
message: "Welche Plugin-Klasse?",
choices: function() {
const pluginDirectory = path.join(__dirname, "../../..");
const manifestFilename = pluginDirectory + "/plugin.manifest";
const manifest = fs.readFileSync(manifestFilename, "utf-8");
const result = manifest.match(/^pluginclassname=.*/gm);
if (!result) {
return null;
}
return result.reduce((memo, item) => {
const pluginClassname = item.substr("pluginclassname=".length);
const oldStyle = pluginClassname + ".class.php";
const newStyle = pluginClassname + ".php";
if (fs.existsSync(path.join(pluginDirectory, oldStyle))) {
memo.push(oldStyle);
} else if (fs.existsSync(path.join(pluginDirectory, newStyle))) {
memo.push(newStyle);
}
return memo;
}, []);
}
}
];
<?php
/**
* Example Stud.IP plugin.
*/
class ExamplePlugin extends StudIPPlugin implements
/* Plugin Interfaces */
SystemPlugin
{
public function __construct()
{
parent::__construct();
require_once 'vendor/autoload.php';
}
---
inject: true
to: <%= pluginclassname %>
skip_if: perform
before: \/\* Interface Methods \*\/
---
/**
* This method dispatches all actions.
*
......@@ -39,6 +29,3 @@ class ExamplePlugin extends StudIPPlugin implements
}
}
}
/* Interface Methods */
}
---
to: controllers/index.php
---
<?php
class IndexController extends \StudipController
{
public function before_filter(&$action, &$args)
{
}
protected function index_url()
{
}
}
---
to: views/index/index.php
---
<h1>Hallo, Welt!</h1>
<p>Find me in {pluginDirectory}/views/index/index.php</p>
---
to: app/hello.js
---
const hello = ```
Hello!
This is your first hygen template.
Learn what it can do here:
https://github.com/jondot/hygen
```
console.log(hello)
---
to: app/hello.js
---
const hello = ```
Hello!
This is your first hygen template.
Learn what it can do here:
https://github.com/jondot/hygen
```
console.log(hello)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment