Skip to content

Commit

Permalink
Version 1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jan 6, 2016
1 parent d2f2948 commit 94ccc0d
Show file tree
Hide file tree
Showing 8 changed files with 367 additions and 102 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ The `craftplugin` generator can also be passed arguments via the command line, b

## Changelog

### 1.0.5 -- 2016.01.06

* Added Widgets to the templates
* Added additional Record and Model templates if you select ElementTypes
* Minor generated code cleanup
* Updated README.md

### 1.0.4 -- 2016.01.06

* Added support for named Services and Controllers
Expand Down
42 changes: 42 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ const QUESTIONS = [
name: "Variables",
value: "variables"
},
{
key: "widgets",
name: "Wigets",
value: "widgets"
},
],
store: true
},
Expand Down Expand Up @@ -179,6 +184,16 @@ const QUESTIONS = [
default: '',
store: false
},
{
when: function (answers) {
return (typeof answers.pluginComponents != 'object') ? false : (answers.pluginComponents.indexOf('widgets') != -1);
},
type: "input",
name: 'widgetName',
message: 'Name of your Widget:',
default: '',
store: false
},

];

Expand Down Expand Up @@ -279,6 +294,14 @@ const TEMPLATE_FILES = [
subPrefix: "modelName",
prefix: true
},
{
src: "models/_ElementModel.php",
destDir: "models/",
dest: "Model.php",
requires: "elementtypes",
subPrefix: "elementName",
prefix: true
},
{
src: "records/_Record.php",
destDir: "records/",
Expand All @@ -287,6 +310,14 @@ const TEMPLATE_FILES = [
subPrefix: "recordName",
prefix: true
},
{
src: "records/_ElementRecord.php",
destDir: "records/",
dest: "Record.php",
requires: "elementtypes",
subPrefix: "elementName",
prefix: true
},
{
src: "services/_Service.php",
destDir: "services/",
Expand All @@ -295,6 +326,14 @@ const TEMPLATE_FILES = [
subPrefix: "serviceName",
prefix: true
},
{
src: "widgets/_Widget.php",
destDir: "widgets/",
dest: "Widget.php",
requires: "widgets",
subPrefix: "widgetName",
prefix: true
},
{
src: "templates/_settings.html",
destDir: "templates/",
Expand Down Expand Up @@ -455,6 +494,9 @@ module.exports = yo.generators.Base.extend({

if (typeof this.answers.serviceName != 'undefined')
this.answers.serviceName = this.answers.serviceName.prefixize();

if (typeof this.answers.widgetName != 'undefined')
this.answers.widgetName = this.answers.widgetName.prefixize();

done();
}.bind(this));;
Expand Down
182 changes: 99 additions & 83 deletions app/templates/_Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,160 +25,176 @@

class <%= pluginHandle %>Plugin extends BasePlugin
{
/**
* Called after the plugin class is instantiated; do any one-time initialization here, such as loading any
* third party Composer packages via:
*
* require_once __DIR__ . '/vendor/autoload.php';
*
* @return mixed
*/
/**
* Called after the plugin class is instantiated; do any one-time initialization here, such as loading any
* third party Composer packages via:
*
* require_once __DIR__ . '/vendor/autoload.php';
*
* @return mixed
*/
public function init()
{
}

/**
* Returns the user-facing name.
*
* @return mixed
*/
/**
* Returns the user-facing name.
*
* @return mixed
*/
public function getName()
{
return Craft::t('<%= pluginName %>');
}

/**
* Plugins can have descriptions of themselves displayed on the Plugins page by adding a getDescription() method
* on the primary plugin class:
*
* @return mixed
*/
/**
* Plugins can have descriptions of themselves displayed on the Plugins page by adding a getDescription() method
* on the primary plugin class:
*
* @return mixed
*/
public function getDescription()
{
return Craft::t('<%= pluginDescription %>');
}

/**
* Plugins can have links to their documentation on the Plugins page by adding a getDocumentationUrl() method on
* the primary plugin class:
*
* @return string
*/
/**
* Plugins can have links to their documentation on the Plugins page by adding a getDocumentationUrl() method on
* the primary plugin class:
*
* @return string
*/
public function getDocumentationUrl()
{
return '<%= pluginDocsUrl %>';
}

/**
* Plugins can now take part in Craft’s update notifications, and display release notes on the Updates page, by
* providing a JSON feed that describes new releases, and adding a getReleaseFeedUrl() method on the primary
* plugin class.
*
* @return string
*/
/**
* Plugins can now take part in Craft’s update notifications, and display release notes on the Updates page, by
* providing a JSON feed that describes new releases, and adding a getReleaseFeedUrl() method on the primary
* plugin class.
*
* @return string
*/
public function getReleaseFeedUrl()
{
return '<%= pluginReleasesUrl %>';
}

/**
* Returns the version number.
*
* @return string
*/
/**
* Returns the version number.
*
* @return string
*/
public function getVersion()
{
return '<%= pluginVersion %>';
}

/**
* As of Craft 2.5, Craft no longer takes the whole site down every time a plugin’s version number changes, in
* case there are any new migrations that need to be run. Instead plugins must explicitly tell Craft that they
* have new migrations by returning a new (higher) schema version number with a getSchemaVersion() method on
* their primary plugin class:
*
* @return string
*/
/**
* As of Craft 2.5, Craft no longer takes the whole site down every time a plugin’s version number changes, in
* case there are any new migrations that need to be run. Instead plugins must explicitly tell Craft that they
* have new migrations by returning a new (higher) schema version number with a getSchemaVersion() method on
* their primary plugin class:
*
* @return string
*/
public function getSchemaVersion()
{
return '<%= pluginVersion %>';
}

/**
* Returns the developer’s name.
*
* @return string
*/
/**
* Returns the developer’s name.
*
* @return string
*/
public function getDeveloper()
{
return '<%= pluginAuthorName %>';
}

/**
* Returns the developer’s website URL.
*
* @return string
*/
/**
* Returns the developer’s website URL.
*
* @return string
*/
public function getDeveloperUrl()
{
return '<%= pluginAuthorUrl %>';
}

/**
* Returns whether the plugin should get its own tab in the CP header.
*
* @return bool
*/
/**
* Returns whether the plugin should get its own tab in the CP header.
*
* @return bool
*/
public function hasCpSection()
{
return false;
}

/**
* Called right before your plugin’s row gets stored in the plugins database table, and tables have been created
* for it based on its records.
*/
/**
* Called right before your plugin’s row gets stored in the plugins database table, and tables have been created
* for it based on its records.
*/
public function onBeforeInstall()
{
}

/**
* Called right after your plugin’s row has been stored in the plugins database table, and tables have been
* created for it based on its records.
*/
/**
* Called right after your plugin’s row has been stored in the plugins database table, and tables have been
* created for it based on its records.
*/
public function onAfterInstall()
{
}

/**
* Called right after your plugin’s record-based tables have been deleted, and its row in the plugins table
* has been deleted.
*/
/**
* Called right after your plugin’s record-based tables have been deleted, and its row in the plugins table
* has been deleted.
*/
public function onBeforeUninstall()
{
}

/**
* Defines the attributes that model your plugin’s available settings.
*
* @return array
*/
protected function defineSettings()
/**
* Defines the attributes that model your plugin’s available settings.
*
* @return array
*/
protected function defineSettings()
{
return array(
'someSetting' => array(AttributeType::String, 'label' => 'Some Setting', 'default' => ''),
);
}

/**
* Returns the HTML that displays your plugin’s settings.
*
* @return mixed
*/
/**
* Returns the HTML that displays your plugin’s settings.
*
* @return mixed
*/
public function getSettingsHtml()
{
return craft()->templates->render('<%= pluginDirName %>/settings', array(
'settings' => $this->getSettings()
));
}

/**
* If you need to do any processing on your settings’ post data before they’re saved to the database, you can
* do it with the prepSettings() method:
*
* @param mixed $settings The Widget's settings
*
* @return mixed
*/
public function prepSettings($settings)
{
// Modify $settings here...

return $settings;
}

}
Loading

0 comments on commit 94ccc0d

Please sign in to comment.