I have successfully created a static website using cakephp to create the static html files using the console.
However, what I want to do now is have a console script that can create multiple websites from the same shared data, with each website using data that is unique to it, but sharing the db as a source.
So, how do I set up the app folder in relation to each website? Do I need a separate installation of cakephp for each site? Or can I have a shared App folder in cgi-bin or something like that?
Thanks
You can share the CakePHP core between multiple apps, however you will need a separate 'app' folder for each website (with the appropriate structure). See this question for more details. Essentially you will need to modify the index.php file in each app/webroot folder to point to the CakePHP core. I use this technique and it's much easier to maintain with only one core as opposed to a whole separate installation of Cake for each site.
Related
Hello guys i need to download files from my database or my Onedrive and save them into react, this files is for my 3d models and the types is obj and mtl. For can i load dinamyc objects from database i need this feature, how can i do this ? I'm using three.js in this project.
Today the project is loading the files stored in project but i like to find a away to pick this from a database or a storage provider.
I tried to do using fetch or something like else but i can't find a away to do this correctly. I don't now if three.js supports url files i try to find but i don't see anything can help me.
Unless three.js provides a feature to take input from memory (in which case you can simply download the file into memory and pass it to three.js), doing this solely from a react app isn't possible. You will need to host your website on a server to have dynamic access to the public directory serving the react website.
Standalone react builds have static assets and can't be updated without creating another build
I have recently worked in a pure Scala-Play application and later in a pure AngularJS application. I'm very impressed with both and I'm wondering what is the sweet spot of combining the two frameworks together. Since the two frameworks can be complementary but also overlapping in different areas e.g. MVC and page routing, as far as I know these are some of the possibilities:
Single Page design, use AngularJS MVC-only and use Scala-Play as "dull" service layer backend with no full page refreshes.
Allow page reloads and each page reload becomes a different AngularJS root application. This seems quite flexible e.g. the client side is not bloatted with so much data for larger applications but better partitioned for the different use-cases. The downside is that I'd need different AngularJS MVC applications and I'm not even sure how to organize it as a project. Are there examples of this?
Typical server side Web App, use Play MVC-only and AngularJS for handling UI models for each separate page.
My choice of IDE for these types of architecture would of course be WebStorm but unfortunately I can't have all client-side (AngularJS and JavaScripts) and sever-side (Scala-Play) codes in a single project.
I believe that there is no the ultimate optimal architecture for combining Play and Angular. It depends on the specificity of the project, team etc.
The decision to develop UI part with Angular and the server side back-end with Play is very reasonable. Technically it may be done as following:
Development:
Both parts are developed as detached projects with the preferable IDE.
The client should have some entry point HTML page. It is reasonable to name it index.html, but is may be any other name.
For client-server integration do on the Play side as following:
Select a sub-folder under the play application root, which will serve as the "home" for the client files. The default solution is to use the folder public, since all files under it are automatically deployed.
All client files should be copied under the public folder. The files may be organized in any structure.
Add a route for the default URL as a route to the index.html. The argument path in the route should be the full path of the index.html relatively to the application root.
If index.html is directly in the public folder, the route is like this:
GET /defaultUrl controllers.Assets.at(path="/public", file ="index.html")
Add routing to the client files:
GET /*file controllers.Assets.at(path="/public", file)
Now the distribution package will include all the client files.
Putting of the client files into the public folder should be done automatically, for example by organizing the client directory structure and appropriate configuration of the client IDE.
You can find more examples in this post.
I'm using a properties file in project. I want to read the properties file both java and angularjs. suggest me a best location to place the properties file which can accessible by java and also by angularjs.
By design it should be src/resources folder.
Well by opportunity, it can be placed in webapp too.
From what I know angularjs is meant to execute on browser. I do not recommend downloading properties into browser as web assets similar to css/js. So I would recommend keeping properties in src/main/resources/. If you need, host a small rest end point giving these properties as a json map in response. This can be used by angularjs on client side(browser)
Ideally properties which have confidential information shoild never be sent to browser.
Any one can get access to those information by debugging in tools like chrome,etc.
Sending such information should not create problems for your system. In those cases you shld hv 2 properties in src/ resources folder. One contains db passwords etc. Other with open information.
I have a fully developed Angularjs frontend app (with the routes and everything set up) and would like to change the current backend to a Play 2 Java. What is the best approach to display the existing html files from Angular in Play? I have found a few examples of how to connect the routes, but I would rater not create an index.scala.html file as I would like to have the two frameworks separated as much as possible and having Play only working as backend.
If you don't want to dynamically generate views from Play using Twirl and you just want to serve your HTML static files publishing them as assets is the way to go. By default assets are designed to provide resource like CSS or JS files but nothing prevents you from serving ordinary HTML views as well.
Simply put your index.html in the public directory and modify the conf/routes files so it can handle all requests:
GET /*file controllers.Assets.at(path="/public", file)
This way your index.html will be accessible at www.yourdomain.com/index.html. Remember to put this line as the last mapping in the file as it matches all possible URLs. Other services should be declared above it.
I am going to implement routing feature in my asp.net4.0 application and following the given link:
URL-Routing
This is fine if an application has limited no. of pages but my application has lots of pages.
so i have to write code [ routes.MapPageRoute("","",""); ] many times.
Can we map all pages by looping through any collection classes or by any other method.
Thanks
If you have a standard pattern for your url and your file structure you can use the placeholders in the mapped url too
eg. If you can map every "{controller}/{action}/{id}" to "/Pages/{controler}/{action}.aspx"
For example, i build a site that has this folder structure
Under the root folder there is the Views folder where all my pages reside.
Under the Views folder there is one subfolder for every "controller" (there is no controllers in webforms, but I follow the MVC conventions here)
Under the controllers subfolders there are the aspx pages that represent different actions
The aspx page names are the same for each controller ("Index.aspx","Add.aspx","Edit.aspx" etc)
So I can have a general mapping rule
routes.MapPageRoute("GeneralAction", "{controler}/{action}/{id}", "~/Views/{controler}/{action}.aspx");
I don't need different rules for different pages as long as the folder structure follows this pattern
Now
"/Patient/Add" will map to "~/Views/Patient/Add.aspx"
"/Incident/Add" will map to "~/Views/Incident/Add.aspx"
"/Patient/Edit/31" will map to "~/Views/Patient/Edit.aspx" (with id=31)
etc, all matching this one rule above.
of course if you want to override this rule you can define more specific routes BEFORE defining this one.