Creating custom polymer element - polymer-cli

I am trying to create a new template such that if I do this:
polymer init <custom-element>
I get a new project created in the development system.
Is there any documentation on how I can do this?

To create a custom option in polymer init command, we have to build a new Yeoman generator. Here is a guide on how to do that.
The only condition that generator should satisfy so that it is recognized by polymer cli is:
The generator should be named generator-polymer-init followed by the name that we use in polymer init command.
For example, let us say we want polymer init custom-build option, we need to create a Yeoman generator with name generator-polymer-init-custom-build. In fact, polymer developers have created a generator with the same name that we can take a look: generator-polymer-init-custom-build

Related

How to use API resources in Laravel Inertia?

I am using Laravel 9, Jetstream, Inertia, Vue 3.
I have created an Api Resource for my Model Project
$projects = ProjectResource::collection(Project::get());
return Inertia::render('Project/Edit', compact('projects'));
In Vue, in the props "project" i get a nested array "data" and only the objects I need are already in it.
projects: Reactive
data:Array[2]
0:Object
1:Object
And it should be like this
projects:Reactive
0:Object
1:Object
I don't want to access props in vue via "projects.data"
I want it to be: "projects"
How to achieve this?
Taken from the official laravel docs (Data Wrapping)
By default, your outermost resource is wrapped in a data key when the resource response is converted to JSON.
In order to turn off this behaviour:
If you would like to disable the wrapping of the outermost resource, you should invoke the withoutWrapping method on the base Illuminate\Http\Resources\Json\JsonResource class.
So basically you need to run:
JsonResource::withoutWrapping();
In the boot method of your AppServiceProvider.

call twirl template from ScalaJs

The play framework documentation says (https://www.playframework.com/documentation/2.6.x/ScalaTemplates): You can then call this from any Scala code as you would normally call a method on a class:
val content = views.html.Application.index(c, o)
Is there an easy way to call twirl templates within ScalaJs for a
crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
Given that Twirl, the templating framework of Play, supports Scala.js, it should relatively simple. The only thing is that, by default, Twirl will not look for templates in the shared source directory. So you'll need to configure its source directories, as explained in its readme, using something like:
sourceDirectories in (Compile, TwirlKeys.compileTemplates) +=
baseDirectory.value.getParentFile / "src/main/twirl"

Setting up the Polymer with Firebase for production

I am using Polymerfire library and a native javascript API in my project and I need to set up the production environment. I searched through multiple posts (for example this one) and I came to a conclusion that I need to create a separate project. However since I am using Polymerfire library I have my app name specified all over the project.
<firebase-auth id="auth" user="{{user}}" app-name="project-name" provider="password"
signed-in="{{signedIn}}"></firebase-auth>
To deploy in production it is required to change this name everywhere. I was thinking that I could create a computeAppName function which would return the app name according to the environment but I hope there is a better solution.
The same issue doesn't occur when I use the native javascript API because I am simply selecting the first app in the array (I'll never use multiple apps in my project).
Example
var actionCode = this.route.__queryParams["oobCode"],
auth = firebase.apps[0].auth();
In my opinion ideal, behavior would be if Polymerfire library automatically selected the only existing app in firebase.apps array. If that would be the case I could initialize one firebase-app element with app name in index.html and leave the app name unspecified deeper in the DOM tree.
This issue would be eliminated if I stopped using the Polymerfire library entirely but that would not follow the "Polymer way" of doing things.
Another option would be to create a task in a build system (like gulp) to replace the app name for production but that would be probably overly complicated.
What do you think?
Edit:
For now I am using a workaround:
firebase-app element in index.html:
<firebase-app id="main_app"
name="project-id"
api-key="key"
auth-domain="project-id.firebaseapp.com"
database-url="https://project-id.firebaseio.com"
storage-bucket="project-id.appspot.com">
</firebase-app>
In every element where Polymerfire is used I created a appName property which uses document selector to get the app name from element in the index:
appName: {
type: String,
value: function () {
return document.getElementById("main_app").name;
}
}
<firebase-auth id="auth" user="{{user}}" app-name="[[appName]]" provider="password"
signed-in="{{signedIn}}"></firebase-auth>
Thanks Jan
Name property of firebase-app element is only used as a name for the firebase app object, which can be arbitrary and there is no need to change it when switching to production project.

Is it possible to override/extend onNewFolder in Alfresco?

I'm using Alfresco 5. I have create a custom type (parent type is cm:folder) and
added an entry for this type in the Document Library "Create" menu.
I would like to override the default folder create function so that I can do
some custom processing.
I would like to create some content within the new folder each time.
You can use alfresco behaviour/policies for your requirement.
For creating policy you need to create below things.
1.Spring Bean in context file
2.One class which implements onCreateNode from org.alfresco.repo.node.NodeServicePolicies
For more information regarding policies read below blog written by Jeff Potts
http://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html
Apart from behaviour/policies easier option would be using rule and script.
You can create a rule which will be executed on creation of new
folder.
Create alfresco java script which will do processing you required on creation of
new folder.
Hook up script with rule.

How do I change test stub framework?

When I stub out a test with CodeRush, it is automatically inserting a using statement for NUnit when I already have a using statement for MBUnit. Is there a way to change the default test framework used when using the templates? I was unable to find it if so.
In the templates you can change the default test namespace used. You can also add conditional logic to check if the project references MBunit.Framework, if so add the MBUnit.Framework using statement, else use Nunit.

Resources