I am trying to implement my custom View with secure social
"ws.securesocial" % "securesocial_2.11" % "3.0-M3",
But I am getting some error:
object TemplatesPlugin is not a member of package securesocial.controllers
So I visit the github project and found there is no TemplatesPlugin
https://github.com/jaliss/securesocial/tree/3.0-M3/module-code/app/securesocial/controllers
package app.com.myApp.plugin;
import play.api.mvc.{RequestHeader, Request};
import play.api.templates.Html;
import securesocial.controllers.TemplatesPlugin;
import securesocial.core.{SecuredRequest, SocialUser};
import play.api.data.Form;
import securesocial.core.SecureSocial._;
import securesocial.controllers.PasswordChange.ChangeInfo;
class MyViews(application: App) extends TemplatesPlugin {
override def getLoginPage[A](implicit request: Request[A], form: Form[(String, String)],
msg: Option[String] = None): Html =
{
views.html.Secure.login(form, msg)
}
//...
}
and my play.plugins
1500:com.typesafe.plugin.CommonsMailerPlugin
9997:app.com.myApp.plugin.MyViews
Then How I go further, What to change?
The module does not use Play plugins any more. All what used to be a plugin is now a service that needs to get configured in the RuntimeEnvironment for your app.
Check out the sample apps to see how they provide their environments. You will need to override the viewTemplates attribute to use your custom views.
Related
I have a Java Application that implements a hook using the Atlassian Bitbucket API.
The class that implements the hook is defined as follows:
import com.atlassian.plugin.spring.scanner.annotation.export.ExportAsService;
import com.atlassian.bitbucket.hook.repository.PreRepositoryHook;
import com.atlassian.bitbucket.hook.repository.RepositoryHookRequest;
import com.atlassian.bitbucket.hook.repository.PreRepositoryHookContext;
import com.atlassian.bitbucket.hook.repository.RepositoryHookResult;
import com.atlassian.bitbucket.hook.repository.PreRepositoryHookRequest;
import com.atlassian.bitbucket.repository.Repository;
import javax.annotation.Nonnull;
/* Other imports */
#ExportAsService({SCMAdapter.class})
public class SCMAdapter implements PreRepositoryHook<RepositoryHookRequest>, ISCMAdapter{
/*Methods from both interfaces*/
}
The methods from the ISCMAdapter interface are irrelevant for this problem.
The PreRepositoryHook interface contains two methods. One of them is the following:
public RepositoryHookResult preUpdate(#Nonnull PreRepositoryHookContext context, #Nonnull RepositoryHookRequest request){
/*Returns a RepositoryHookResult object */
}
I can obtain the repository involved in the hook with the following call:
Repository repo = request.getRepository();
From that object, I can obtain the project's key, the slug, the ID, the name and the state:
String pkey=repo.getProject().getKey();
String slug=repo.getSlug();
String name=repo.getName();
int id=repo.getId();
Repository.State state=repo.getState();
The method is currently working fine. However, I got a requirement that each repository must have a hidden directory with the same name for all repositories (lets say ".myHiddenDir") and that directory must contain a YAML file named config.yml
Is it possible, with the information obtained as listed above to obtain the content of an specific file in the repo?
Thanks in advance.
P.D.: If you find that this description is lacking more info, please let me know and I will check the code.
Specifically, I am trying to enable .SVG files to be usable by the core image component.
Right now I am making a sling model that ideally I would like to access the returned values of the getSrc() and getFileReference() classes in the core AEM Component interface located here.
I am very new to AEM development and Sling models. Am I missing some vital functionality that would let me do this?
Here is my code, which probably isn't at all helpful at this point.
package com.site.core.models;
import com.adobe.cq.wcm.core.components.models.Image;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.models.annotations.*;
import org.apache.sling.models.annotations.injectorspecific.*;
import org.apache.sling.settings.SlingSettingsService;
import javax.jcr.Node;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.inject.Inject;
#Model(adaptables = SlingHttpServletRequest.class)
public class ImageModel {
private String src = Image.getSrc();
return src;
}
As I mentioned in my comment, the link you are referring to is an interface, the implementation of that interface is here
In order to use your own implementation, you have two options:
In the image component html, change the data-sly-use to refer to your impl: com.site.core.models.ImageModel
Create a separate model that implements the Image interface and give it a high ranking to be picked up instead of the existing impl.
Disclaimer: I have not tested #2 but the documentation suggests that it's possible.
I'm using json4s in a play project, and I'm also using a library called sbt-buildinfo which generates Scala source from your build definitions.
Now, in the sbt-buildinfo library the say you need to add some line of code: buildInfoOptions += BuildInfoOption.ToJson so you can use .toJson, but from some reason I can use .toJson.
this is how I do it:
import _root_.util.{AuthenticatedAction}
import buildinfo.BuildInfo
import com.google.inject.Inject
import org.json4s.BuildInfo
import play.api._
import play.api.mvc._
class AppInfo #Inject()(implicit configuration: Configuration) extends Controller {
def appVerion = AuthenticatedAction {
Ok(BuildInfo.toJson)
}
but the import buildinfo.BuildInfo stays gray....so it looks like I'm not using it. I refreshed the build.sbt and all, what could it be?
You have multiple imports to a BuildInfo object. org.json4s.BuildInfo will probably shadow your buildInfo.BuildInfo import and therefore, it does not have the required member. Try writing out the entire package name that you need:
Ok(buildinfo.BuildInfo.toJson)
I am using play 2.2.1 and trying to implement Page for 404 requests.
For that I have created a errorPage.scala.html in my views and created a Global class inside MyProject->app->controller
Global.java (Source)
import play.*;
import play.mvc.*;
import play.mvc.Http.*;
import play.libs.F.*;
import static play.mvc.Results.*;
public class Global extends GlobalSettings {
public Promise<SimpleResult> onHandlerNotFound(RequestHeader request) {
return Promise.<SimpleResult>pure(notFound(
views.html.errorPage.render(request.uri())
));
}
}
But Its not working.When I am entering the wrong url it shows action not found page and display my routes file in browser.
Is there anything I am missing?
I have been trying other stack threds also but din't get any solution.
Thanks
Your Global class needs to be at the root package, i.e. within app and not wihtin the controller package. The link you posted documents that in the second sentence:
Defining a Global object in your project allows you to handle global
settings for your application. This object must be defined in the root package.
I'am trying to run multiple independent Play Framework 2.2 projects on one single Play server.
Problem is that when I use run or start to start the application, then the "sub"-project shows the content of the "root"-project. I have read everything avaliable, but I can't figure out a solution :/
Here's the build.sbt:
lazy val aaaroot = project.in(file(".")).aggregate(project1).dependsOn(project1)
lazy val project1 = project.in(file("project1"))
The routes file of the "root"-project:
GET / controllers.Application.index()
GET /assets/*file controllers.Assets.at(path="/public", file)
-> /project1 project1.Routes
The routes file (called project1.routes) of the "sub"-project:
GET / controllers.project1.Application.index()
GET /assets/*file controllers.project1.Assets.at(path="/public", file)
The Application.java Controller of the subproject uses package controllers.project1;
I also tried to set up the "Router object" in the application.conf file of the "sub"-project ( application.router=project1.Routes ). As described here.
Every suggestion is highly appreciated!!!
Found the error. The controller is used correctly, but there is a name-conflict with the views.
My Application.java says:
package controllers.project1;
import play.*;
import play.mvc.*;
import views.html.*;
public class Application extends Controller {
public static Result index() {
return ok(index.render("Project1"));
}
}
The error is the line import views.html.*;. This calls the views from the main-project. To avoid it I had to rename the view-folder to something else and edit the import like import viewsofproject1.html.*;