本文整理汇总了Java中org.takes.rs.xe.XeDirectives类的典型用法代码示例。如果您正苦于以下问题:Java XeDirectives类的具体用法?Java XeDirectives怎么用?Java XeDirectives使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XeDirectives类属于org.takes.rs.xe包,在下文中一共展示了XeDirectives类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: act
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
@Override
public Response act(final Request request) throws IOException {
return new RsPage(
"/xsl/logs.xsl",
request,
() -> new StickyList<>(
new XeAppend("menu", "logs"),
new XeDirectives(
new Directives().add("logs").append(
new Joined<>(
new Limited<Iterable<Directive>>(
Tv.TWENTY,
new RqUser(this.base, request).logs()
)
)
)
)
)
);
}
开发者ID:yegor256,项目名称:threecopies,代码行数:21,代码来源:TkLogs.java
示例2: act
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
@Override
public Response act(final Request request) throws IOException {
return new RsPage(
"/xsl/scripts.xsl",
request,
() -> new StickyList<>(
new XeAppend("menu", "scripts"),
new XeAppend("stripe_cents", "500"),
new XeAppend(
"stripe_key",
Manifests.read("ThreeCopies-StripeKey")
),
new XeDirectives(
new Directives().add("scripts").append(
new Joined<>(
new RqUser(this.base, request).scripts()
)
)
)
)
);
}
开发者ID:yegor256,项目名称:threecopies,代码行数:23,代码来源:TkScripts.java
示例3: act
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
@Override
public Response act(final Request request) throws IOException {
final User user = new RqUser(this.base, request);
final RqHref href = new RqHref.Base(request);
final Iterator<String> name = href.href().param("name").iterator();
return new RsPage(
"/xsl/script.xsl",
request,
() -> new StickyList<>(
new XeAppend("menu", "scripts"),
new XeWhen(
name.hasNext(),
() -> new XeDirectives(
user.script(name.next()).toXembly()
)
)
)
);
}
开发者ID:yegor256,项目名称:threecopies,代码行数:20,代码来源:TkScript.java
示例4: act
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
@Override
public Response act(final Request req) {
return new RsPage(
req, "mistakes",
() -> new IterableOf<>(
new XeAppend(
"worst",
new XeDirectives(
new Joined<>(
new Limited<>(
// @checkstyle MagicNumber (1 line)
20, new Mistakes().worst()
)
)
)
)
)
);
}
开发者ID:yegor256,项目名称:jpeek,代码行数:20,代码来源:TkMistakes.java
示例5: act
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
@Override
public Response act(final Request req) {
return new RsPage(
req, "all",
() -> new IterableOf<>(
new XeAppend(
"recent",
new XeDirectives(
new Joined<>(
new Results().all()
)
)
)
)
);
}
开发者ID:yegor256,项目名称:jpeek,代码行数:17,代码来源:TkAll.java
示例6: source
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
/**
* Convert event to Xembly.
* @param domain The event
* @return Xembly
* @throws IOException If fails
*/
private static XeSource source(final Domain domain) throws IOException {
final String name = domain.name();
final Usage usage = domain.usage();
return new XeDirectives(
new Directives()
.add("domain")
.add("name").set(name).up()
.add("usage").set(usage.total()).up()
.append(
new XeLink(
"delete",
new Href("/delete").with("name", name)
).toXembly()
)
.up()
);
}
开发者ID:yegor256,项目名称:jare,代码行数:24,代码来源:TkDomains.java
示例7: act
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
final Iterable<Event> events = this.base.user(new RqUser(req).urn())
.events()
.iterate();
return new RsPage(
"/xsl/events.xsl",
req,
new XeAppend(
"events",
new XeChain(
new XeTransform<>(
Iterables.limit(events, Tv.TWENTY),
TkEvents::source
)
),
new XeDirectives(
new Directives().attr("total", Iterables.size(events))
)
)
);
}
开发者ID:yegor256,项目名称:wring,代码行数:23,代码来源:TkEvents.java
示例8: source
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
/**
* Convert event to Xembly.
* @param event The event
* @return Xembly
* @throws IOException If fails
*/
private static XeSource source(final Event event) throws IOException {
final Iterable<Directive> dirs = event.asXembly();
final String title = new XePrint(dirs).text("{/event/title/text()}");
return new XeDirectives(
new Directives()
.append(dirs)
.append(
new XeLink(
"delete",
new Href("/event-delete").with("title", title)
).toXembly()
)
.append(
new XeLink(
"down",
new Href("/event-down").with("title", title)
).toXembly()
)
);
}
开发者ID:yegor256,项目名称:wring,代码行数:27,代码来源:TkEvents.java
示例9: source
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
/**
* Convert friend into XE source.
* @param friend Name of the friend
* @param home Home of the doc
* @return Source
*/
private static XeSource source(final String friend,
final Href home) {
return new XeAppend(
"friend",
new XeChain(
new XeDirectives(
new Directives().add("name").set(friend)
),
new XeLink(
"eject",
home.path("eject-friend").with("friend", friend)
)
)
);
}
开发者ID:libreio,项目名称:libre,代码行数:22,代码来源:TkDocs.java
示例10: act
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
final URL url = new URL(new RqHref.Smart(req).single("u"));
return new RsPage(
"/xsl/info.xsl",
req,
() -> new ListOf<>(
new XeAppend("url", url.toString()),
new XeAppend(
"encoded_url",
URLEncoder.encode(
url.toString(), StandardCharsets.UTF_8.name()
)
),
new XeAppend(
"targets",
new XeDirectives(
new Joined<>(
new Limited<>(
this.base.status(url).failures(Long.MAX_VALUE),
Tv.TWENTY
)
)
)
),
new XeAppend(
"history",
new XeDirectives(
new Joined<>(
new Limited<>(
this.base.status(url).history(Long.MAX_VALUE),
Tv.TEN
)
)
)
)
)
);
}
开发者ID:yegor256,项目名称:rehttp,代码行数:40,代码来源:TkInfo.java
示例11: act
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
final URL url = new URL(new RqHref.Smart(req).single("u"));
final long time = Long.parseLong(new RqHref.Smart(req).single("t"));
return new RsPage(
"/xsl/details.xsl",
req,
() -> new ListOf<>(
new XeDirectives(
this.base.status(url).details(time)
)
)
);
}
开发者ID:yegor256,项目名称:rehttp,代码行数:15,代码来源:TkDetails.java
示例12: act
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
@Override
public Response act(final Request req) {
return new RsPage(
req, "index",
() -> new IterableOf<>(
new XeAppend(
"best",
new XeDirectives(
new Joined<>(
new Limited<Iterable<Directive>>(
// @checkstyle MagicNumber (1 line)
20, new Results().best()
)
)
)
),
new XeAppend(
"recent",
new XeDirectives(
new Joined<>(
new Limited<>(
// @checkstyle MagicNumber (1 line)
25, new Results().recent()
)
)
)
)
)
);
}
开发者ID:yegor256,项目名称:jpeek,代码行数:31,代码来源:TkIndex.java
示例13: make
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
/**
* Make it.
* @param req Request
* @param xsl XSL stylesheet
* @param src Sources
* @return Response
*/
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
private static Response make(final Request req, final String xsl,
final Scalar<Iterable<XeSource>> src) {
final Response raw = new RsXembly(
new XeChain(
new XeStylesheet(
String.format("/org/jpeek/web/%s.xsl", xsl)
),
new XeAppend(
"page",
new XeChain(
new XeMillis(),
new XeDirectives(new Header()),
new XeChain(src),
new XeMillis(true)
)
)
)
);
return new RsFork(
req,
new FkTypes(
"text/html",
new RsXslt(new RsWithType(raw, "text/html"))
),
new FkTypes(
"application/vnd.jpeek+xml",
new RsPrettyXml(new RsWithType(raw, "text/xml"))
),
new FkTypes("*/*", raw)
);
}
开发者ID:yegor256,项目名称:jpeek,代码行数:40,代码来源:RsPage.java
示例14: source
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
/**
* Convert event to Xembly.
* @param domain The event
* @return Xembly
* @throws IOException If fails
*/
private static XeSource source(final Domain domain) throws IOException {
return new XeDirectives(
new Directives()
.add("domain")
.add("name").set(domain.name()).up()
.add("owner").set(domain.owner()).up()
.add("usage").set(domain.usage().total()).up()
.up()
);
}
开发者ID:yegor256,项目名称:jare,代码行数:17,代码来源:TkIndex.java
示例15: source
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
/**
* Convert pipe to Xembly.
* @param pipe The pipe
* @return Xembly
* @throws IOException If fails
*/
private static XeSource source(final Pipe pipe) throws IOException {
final Iterable<Directive> dirs = pipe.asXembly();
return new XeDirectives(
new Directives().append(dirs).append(
new XeLink(
"delete",
new XePrint(pipe.asXembly()).text(
"/pipe-delete?id={/pipe/id/text()}"
)
).toXembly()
)
);
}
开发者ID:yegor256,项目名称:wring,代码行数:20,代码来源:TkPipes.java
示例16: act
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
return new RsPage(
"/xsl/index.xsl",
req,
new XeDirectives(
new Directives().add("total").set(this.base.pipes().size())
)
);
}
开发者ID:yegor256,项目名称:wring,代码行数:11,代码来源:TkIndex.java
示例17: act
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
final User user = this.base.user(new RqAuth(req).identity().urn());
final Docs docs = user.docs();
return new RsPage(
"/xsl/docs.xsl",
req,
this.base,
new XeLink("upload", "/doc/write"),
new XeAppend(
"user",
new XeAppend(
"balance",
new XeDirectives(
new Directives().set(
Integer.toString(user.account().balance())
)
)
)
),
new XeAppend(
"docs",
new XeTransform<>(
docs.names(),
new XeTransform.Func<String>() {
@Override
public XeSource transform(final String doc)
throws IOException {
return TkDocs.source(docs.doc(doc), doc, req);
}
}
)
),
new XeLink("mkdir", "/dir/create")
);
}
开发者ID:libreio,项目名称:libre,代码行数:37,代码来源:TkDocs.java
示例18: act
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
@Override
public Response act(final Request req) throws IOException {
final User user = this.base.user(new RqAuth(req).identity().urn());
return new RsPage(
"/xsl/admin.xsl",
req,
this.base,
new XeAppend(
"docs",
new XeTransform<>(
user.docs().names(),
new XeTransform.Func<String>() {
@Override
public XeSource transform(final String name) {
return new XeAppend(
"doc",
new XeDirectives(
new Directives()
.add("path").set(
String.format(
"%s/%s", user.urn(), name
)
)
)
);
}
}
)
)
);
}
开发者ID:libreio,项目名称:libre,代码行数:32,代码来源:TkAdmin.java
示例19: source
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
/**
* Deck as Xembly source.
* @param deck The deck
* @return Source
* @throws IOException If fails
*/
private static XeSource source(final Deck deck) throws IOException {
final Href home = new Href("/d");
return new XeAppend(
"item",
new XeDirectives(
Directives.copyOf(new Deck.Smart(deck).xml().node())
),
new XeChain(
new XeLink("open", home.path(deck.name())),
new XeLink("delete", home.path(deck.name()).path("delete"))
)
);
}
开发者ID:yegor256,项目名称:thindeck,代码行数:20,代码来源:TkDecks.java
示例20: performLogin
import org.takes.rs.xe.XeDirectives; //导入依赖的package包/类
/**
* Performs the basic login.
* @param directive The directive object.
* @throws IOException If some problem inside.
*/
private void performLogin(final Directives directive) throws IOException {
final String app = "app";
final String key = "key";
final Take take = new TkFork(
new FkRegex(
"/login/oauth/access_token",
new Take() {
@Override
public Response act(final Request req) throws IOException {
final Request greq = new RqGreedy(req);
final String code = "code";
PsGithubTest.assertParam(greq, code, code);
PsGithubTest.assertParam(greq, "client_id", app);
PsGithubTest.assertParam(greq, "client_secret", key);
return new RsXembly(
new XeDirectives(directive.toString())
);
}
}
),
new FkRegex(
"/user",
new TkFakeLogin()
)
);
new FtRemote(take).exec(
// @checkstyle AnonInnerLengthCheck (100 lines)
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
final Identity identity = new PsGithub(
app,
key,
home.toString(),
home.toString()
).enter(new RqFake("GET", "?code=code")).get();
MatcherAssert.assertThat(
identity.urn(),
Matchers.equalTo("urn:github:1")
);
MatcherAssert.assertThat(
identity.properties().get(PsGithubTest.LOGIN),
Matchers.equalTo(PsGithubTest.OCTOCAT)
);
MatcherAssert.assertThat(
identity.properties().get("avatar"),
Matchers.equalTo(PsGithubTest.OCTOCAT_GIF_URL)
);
}
}
);
}
开发者ID:yegor256,项目名称:takes,代码行数:58,代码来源:PsGithubTest.java
注:本文中的org.takes.rs.xe.XeDirectives类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论