-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testikus example plugin and juno plugin generator (#1110)
* first use of juno-ui-components * [testikus] add juno variant to SearchField * [testikus] change juno-ui-component release to latest. add tailwind, postcss, autoprefixer * [testikus] clean up usage of juno-ui-components in example * [testikus] item fixes * [testikus] action buttons in item. searchbar in toolbar. show dialog with DataGrid. * [testikus] use Badge for item uid * [testikus] remove obsolete class name * add example for os proxy requests to testikus * finish the generator for juno plugins * [testikus] prettify catalog/show. update juno-ui-components. Co-authored-by: d064310 <[email protected]>
- Loading branch information
Showing
80 changed files
with
2,468 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Spring: | ||
# (Note: using gem "spring", git: "..." won't work and is not a supported way of using Spring.) | ||
# So we have to disable spring for generate tasks! | ||
|
||
full_path=$(realpath "$0") | ||
dir=$(dirname "$full_path") | ||
|
||
DISABLE_SPRING=1 "$dir"/rails db:create | ||
DISABLE_SPRING=1 "$dir"/rails db:migrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
class JunoPluginGenerator | ||
extend Forwardable | ||
def_delegators :@context, :options, :copy_file, :remove_file, :gsub_file, | ||
:create_file, :name, :remove_dir, :directory, :source_paths, | ||
:append_to_file | ||
attr_reader :plugin_path | ||
|
||
def initialize(context, plugin_path) | ||
@context = context | ||
@plugin_path = plugin_path | ||
end | ||
|
||
def run | ||
add_packs | ||
return unless options.mountable? | ||
|
||
modify_app | ||
add_routes | ||
update_assets | ||
end | ||
|
||
private | ||
|
||
def update_assets | ||
remove_file "#{plugin_path}/#{name}/app/assets/stylesheets/#{name}/application.css" | ||
remove_dir "#{plugin_path}/#{name}/app/assets/javascripts" | ||
copy_file 'juno/app/assets/stylesheets/_application.scss', "#{plugin_path}/#{name}/app/assets/stylesheets/#{name}/_application.scss" | ||
end | ||
|
||
def add_packs | ||
directory 'juno/app/javascript', "#{plugin_path}/#{name}/app/javascript" | ||
end | ||
|
||
def modify_app | ||
remove_dir "#{plugin_path}/#{name}/app/controllers" | ||
directory 'juno/app/controllers', "#{plugin_path}/#{name}/app/controllers/#{name}" | ||
remove_dir "#{plugin_path}/#{name}/app/views" | ||
directory 'juno/app/views', "#{plugin_path}/#{name}/app/views/#{name}" | ||
end | ||
|
||
def add_routes | ||
remove_file "#{plugin_path}/#{name}/config/routes.rb" | ||
copy_file 'juno/config/routes.rb', "#{plugin_path}/#{name}/config/routes.rb" | ||
end | ||
end |
22 changes: 22 additions & 0 deletions
22
lib/generators/templates/juno/app/assets/stylesheets/_application.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/**************************************************** | ||
We are using SASS! | ||
DO NOT USE require, require_tree, and require_self. | ||
*************************************************** | ||
Instead require further sass files by calling the "@import" directive. | ||
e.g. @import "mixins"; | ||
FYI: | ||
The core app automatically namespaces a plugin's css with the plugin name. I.e. it encapsulates a plugin's css in a class with the same name as plugin (e.g. a plugin with name "myplugin" gets surrounded with css class ".myplugin"). | ||
This means that in the compiled css e.g. .test { color: #f00; } becomes .myplugin .test { color: #f00; } | ||
The core app also ensures that the content div surrounding the plugin views gets a css class with the name of current plugin. | ||
This way we ensure that your styles take effect only inside the content of your plugin and don't accidentally overwrite styles defined elsewhere (either in the core or in another plugin). | ||
*************************************************** | ||
IMPORTANT | ||
--------------------------------------------------- | ||
1) The namespacing happens automatically. There is no special action required from the plugin author. The only thing you need to pay attention to is that you write styles only for elements in the context of your plugin's views. | ||
2) Make sure all your scss files are partials (i.e. the file name starts with an underscore, e.g. "_application.scss"). Otherwise the base imports in the main stylesheet won't be available in your engine stylesheets! | ||
*************************************************** | ||
*/ |
6 changes: 6 additions & 0 deletions
6
lib/generators/templates/juno/app/controllers/application_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
module %{PLUGIN_NAME_CAMELIZE} | ||
class ApplicationController < AjaxController | ||
end | ||
end |
33 changes: 33 additions & 0 deletions
33
lib/generators/templates/juno/app/controllers/entries_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
module %{PLUGIN_NAME_CAMELIZE} | ||
class EntriesController < AjaxController | ||
def index | ||
render json: [ | ||
{ id: SecureRandom.uuid, name: 'Entry1', description: 'Test Entry 1'}, | ||
{ id: SecureRandom.uuid, name: 'Entry2', description: 'Test Entry 2'}, | ||
{ id: SecureRandom.uuid, name: 'Entry3', description: 'Test Entry 3'} | ||
] | ||
end | ||
|
||
def create | ||
render json: { | ||
id: SecureRandom.uuid, | ||
name: params[:entry][:name], | ||
description: params[:entry][:description] | ||
} | ||
end | ||
|
||
def update | ||
render json: { | ||
id: params[:id], | ||
name: params[:entry][:name], | ||
description: params[:entry][:description] | ||
} | ||
end | ||
|
||
def destroy | ||
head :no_content | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// This is always executed on page load. | ||
$(document).ready(function () { | ||
// ... | ||
}) |
5 changes: 5 additions & 0 deletions
5
lib/generators/templates/juno/app/javascript/widgets/app/apiClient.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { createAjaxHelper } from "lib/ajax_helper" | ||
import { widgetBasePath } from "lib/widget" | ||
|
||
const baseURL = widgetBasePath("%{PLUGIN_NAME}") | ||
export default createAjaxHelper({ baseURL }) |
Oops, something went wrong.