wicket/bookmarkable added after wicket migration - request

Im migrating a wicket webapplication from wicket 1.4 to wicket 6.8.
Im having some problems with the bookmarkable/non bookmarkable implementation introduced in wicket 1.5.
The application now adds wicket/bookmarkable to "bookmarkable" pages when setresponsepage is called. it does not matter if i provide a class or an instance of a page. My applications keeps adding wicket/bookmarkable.
I dont want to have the wicket/bookmarkable prefix in the url. I have tried to make a new implementation of imappercontext to override these prefixes. But i dont want them at all. Actually i dont bookmarkable pages in my application at all, besides some mounted pages.
Any ideas about how to remove this prefix?

You must mount page to remove wicket/bookmarkable in the url. Override the init method and configure on your WebApplication.
#Override
public void init() {
super.init();
...
mountPage(your_url, YOUR_PAGE.class);
}

I took a look at my code (we somewhat recently updated to Wicket 6.x) and did not notice it before, but I am also getting the 'bookmarkable' string in my url when I call
setResponsePage(SomePage.class);
however, in other places the link is set up as
setResponsePage(new SomePage());
and the 'bookmarkable' string is not included in the URL.
Hope this helps...

Related

How to add a Docusaurus website within Next.js Website as a route

Does anyone have any pointers on how to go about adding a /docs page for website documentation to a next.js app? I've looked up Docusaurus but it seems like it's already a react app itself. Is there a way to integrate it inside an existing next.js app or are there other solutions?
Many Thanks
One idea might be to intercept the request and send the html file that docusaurus builds out, and putting all other files in the public folder.
https://medium.com/wesionary-team/render-html-file-in-pages-of-next-js-59281c46c05
Also checkout this discussion about it.
https://github.com/vercel/next.js/discussions/12373
I have done this with React apps using express. But never with Next. At first it looks like it would be possible with multi-zone in Next but that doesn't seem to do the job. So my other recommendation would be to try to use a docs.domain.com instead and host it separately. Then you have a /docs url or a button that redirects to the doc domain instead.
Firebase has free hosting and allows you to setup multiple sites. So it should be fast to test this setup there
I'm going to actively try to get this to work with Next myself but I do not think it will work because of how they are developed. So I would do the above recommendation and if I find a workaround, I'll post an update.

What is the alternate way for "Request" class/object in .NET core?

I am migrating an existing ASP.NET Web API 2 project to ASP.NET Core. While migrating I am unable to find this.Request object. Can anyone help me solve out this issue?
This question was asked here, but since ASP.NET Core was still probably in an RC state then, I figured I'd answer here instead of referring to there because there is some stuff that's obsolete or completely gone from the official release.
Assuming your controller class inherits from Controller (or more specifically, ControllerBase) then it does have a this.Request property as you can see here and here. As Pawel noted, you can also access it from the this.HttpContext property.
The request's URL is broken up into several properties on HttpRequest. You can access the URL in a friendlier API by adding using Microsoft.AspNetCore.Http.Extensions; which gets you access to the following extension methods:
GetDisplayUrl()
GetEncodedUrl()
As far as the query string, HttpRequest provides QueryString and Query properties for you to interact with.
Side note: I just created an app from scratch targeting ASP.NET Core on .NET Core for the first time on this laptop, and it took a while for the Intellisense to work for the Request property, so I'm wondering if that could have been your issue.
You need to override your class like this to get this.Request
public partial class _Default : System.Web.UI.Page

CakePHP 3.x: how to implement event listener in plugin / plugins src-directory doesn't get loaded

In order to build an extendable blogging system with CakePHP I’d like to realize something like extension hooks in Wordpress. My plan is to have a base SQL to load the articles in the main application. This SQL should be possible to extend by a variable set of plugins (one plugin for each special article type).
I already know that CakePHP’s way to realize something like that is the events system. I have some trouble registering listeners residing in my plugins, though.
The official documentation (3.x Book; http://book.cakephp.org/3.0/en/core-libraries/events.html#registering-listeners) says, that a listener can be registered this way:
// Attach the UserStatistic object to the Order's event manager
$statistics = new UserStatistic();
$this->Orders->eventManager()->on($statistics);
Unfortunately it doesn’t tell where to place this code in order to register the listener automatically while bootstrapping. Placing the following lines in my plugin’s bootstrap.php like so:
$tester = new Lib\Tester();
$this->Orders->eventManager()->on($tester);
… (having a class Tester in plugins/MyPlugin/src/Lib of course) results in errors.
In the first line the listener class cannot be found (“Error: Class 'Lib\Tester' not found”). And in the second line $this must not be used in the context of bootstrap.php (“Error: Using $this when not in object context”).
In an old thread (Where to register event listeners) someone else asked for the same thing and got a pretty detailed answer. It was for CakePHP 2.x, though, and doesn’t work with CakePHP 3.x anymore. For example, the function App::uses doesn’t exist in CakePHP 3.x and I couldn’t find a replacement.
So: can someone please help me find the right way to set up a working listener within a plugin in CakePHP 3.x?
[UPDATE #1]
I've found a workaround that works for me (but is quite ugly). In the bootstrap.php of the plugin I was able to instantiate an object of my event listener class like this:
require __DIR__ . '/../src/Lib/Tester.php';
$tester = new MyPlugin\Lib\Tester();
After that I could register the listener on the Articles model (also in bootstrap.php of course):
Cake\ORM\TableRegistry::get('Articles')->eventManager()->on($tester);
That way I'm now able to build up a base request on the articles table and send it to several plugins. Then the plugins can enrich the request to join special tables or something like that.
So, one question remains: how can I avoid the use of the __DIR__ in bootstrap.php? How can the listener be instantiated properly?
[UPDATE #2]
It seems as if the complete src subdirectory of my plugin isn't part of the import path. None of the classes I put there gets loaded. That means that CakePHP doesn't find a simple Controller when I place one there.
Am I doing something wrong in general? Or might that be a bug in CakePHP?
Unfortunately I neither can find plugins for CakePHP 3.x whose source code could help me understand what I might do wrong.
... as ndm assumed in a comment above, there was something wrong with my manually inserted parts in the composer.json file. After fixing that and running dumpautoload again all classes get loaded, now.

How to separate public and private pages in AngularJS project?

I am developing a web app that has a sign in page for signing in. But also, for example, there is a public page for facebook sharing page.
If a user wants to go into the panel, url is:
http://127.0.0.1:3000/#/shops/:id/
If someone makes a Facebook share, we have a public page like:
http://127.0.0.1:3000/#/public/56af5229d0ae74e324c662f9
My problem is, I have 1 index.html for this app, and it includes css, js links and a ui-view for ui-router. For public page, all those unnecessary files are loaded.
In index page, I have:
<div ng-if="isPublic()" ng-include="'views/public.base.html'"></div>
Also, I cannot control the meta tags of the page.
How you can handle separation of pages in such a case?
I have a site with public/private parts, but I took a different approach in terms of resources. I did not separate them since it would be just to much work, instead I did this:
Minification
Bundling
Pre-compressing
Caching-forever with the hash-string
Putting all the html templates in a js bundle
Yes, this will make all the js/css that is not needed for everyone to load, but you can think of this as a standalone application: you have to download the whole executable/package and install it but you don't use all the functionality (e.g. think of Office). If you optimize all as much as possible, the few additional kilobytes won't do any difference and the data will be already there when the user logs on to private part.
P.S You can see how to do some of the points in here.

How can I tell whether a web app was built using Angular (or other technologies)?

How can I tell whether a (Drupal 7) web app was built using Angular by looking at the page source, and not having to ask the developers?
The best way to check is to write "angular" on browser console. If you get any object [With child objects as "bind","bootstrap","callbacks","module" etc.] then its an angular web app.
You can install a chrome or firefox extension called Wappalyzer. It tells you which site you are navigated on in your browser and the stack they use.
Find it here: https://www.wappalyzer.com
You could try: angular.version.full first. If this doesn't work, try getAllAngularRootElements()[0].attributes["ng-version"]. The reason being in Angular 1 the former will work and from angular 2 onwards the later will work.
If it's an online site you can use http://builtwith.com/ and it usually can give you a good and useful bunch of information about that site.
However if they are using angular you can take a look at their page sources to see if they are using any attributes of angular like ng-repeat for example
You can also take a look at the sources that your browser get while browsing that site to see if javascript files for angularjs are included among the sources.
Application declared using ng-app directive
very simple controller and directive
check for ng-model, ng-repeater attributes in the code. All these attibutes are written in small letters.
Also you can check by typing in the console(ctrl + shift + i) and navigate to console tab. There type in window.angular.version --> it displays the version of the site your are currently inspecting.
Try
https://builtwith.com/
This is the website that currently gives you the most detailed information about what technologies a site uses. They will let you do 5 free lookups a day.
https://wappalyzer.com/
is a good one too, and serve as a complement to builtwith. I don't think there is a limit of lookups, but the results are less detailed.
Those two used together may give you more insight.
use window.getAllAngularRootElements() in the browser console if it return some value its an angular application
For Angular, in Chrome's inspector, in the Elements tab, inside the body element is an element called app-root containing ng-version, which shows the Angular version it's using.
There is a Google Chrome extension called 'ng-detector'. It may be obtained from the Google webstore:
https://chrome.google.com/webstore/detail/ng-detector/fedicaemhcfcmelihceehhaodggfeffm
It creates a small icon next to the URL bar that indicates whether or not it thinks the page was created using Angular, although I have not thoroughly tested its validity.
Install chrome extension React-Detector, it works!
window.getAllAngularRootElements() worked for me
You can install a Chrome or Firefox extension called Augury. It tells you if app is an angular or not.

Resources