How to organize mixed HTTP server + web client Dart project files? - project

I'm planning to create a pure Dart application where both the HTTP server and the web client side is written in Dart. Coming from Java and Eclipse the ultimate would be that i can open the whole project hierarchy in Dart Editor and be able to run the server which serves the client files and debug both sides of the app (server side with the DartVM and client side with Dartium).
I've fired up Dart Editor and after creating a simple Command-line application as the basis for the server side i got confused with the project layout.
The direct server side code files (web server boostrap class, handler and filter classes) are definietly going into the projects bin/ folder. Server side dependencies are going into the project's pubspec.yaml file.
The problem arrises when the server have to access the client application files (.dart files, static page source, etc.) in order to serve them to the browser. The easiest solution would be to create a web folder inside the server project and put client web files there, but this way (as far as i understood) server side dependencies are inherited into the client because we are still in the same pubspec scope. I don't want this.
I thought about creating a client library in the projects lib/ folder and put web files there but i don't know how good practice is to put a complete web application into there. I guess i have to put HTML and other client static files into the asset/ subfolder of the lib. I'm affraid that i'm loosing web application assist from the IDE this way.
What i might also be able to do is to put the client into a separate project, organize it like a Dart webapp project with it's very own pubspec.yaml and then make this the dependency of the server application somehow. I don't know if this way the server could access web files in the other project for serving. Probably this is the best way of doing it because it provides a clean separation of the client and server files.
Can somebody enlighten me what's the correct way of doing this?
Some more explanation.
Say i'm going with the separate project approach as others already suggesting in the answers but i still like to run the server which is able to serve the client in the development phase without any fancy hack. The server has to access the client files in the other project. It doesn't matter if its Javascript or Dart, the static files are there anyway. And during development i wish to serve the dart files since Dartium speeds up development with it's direct Dart running capability significantly.
With Java and Maven i can make the client package a runtime dependency of the server and i can simply serve the client files from the classpath. Does Dart support accessing a pub dependency's internal files the similar way or the only way for this is to put everything into the asset folder of the client or going with the relative path hack?

This is work in progress:
prepare a Dart app for server-side deployment
To improve the development experience you may use a symlink as a workaround so that you have the client files available in a directory of the server package.
I suggest creating a feature request at http://www.dartbug.com/new for better support.

I would go for two separate projects.
You won't need to make the client package a dependency on the server package.
The server only needs to know where the directory with the build output of the client package is.
Which files to serve is usually requested by the client.
The client requests e.g. index.html and all further dependencies (.dart, .hmtl, .js, .img, .css, ...) are hard-coded in this file and therefore the server should not need to know any further details beforehand.

I'd suggest organising two separate projects. There are a few things that you might profit from if you use this approach. The most obvious there's no coupling between client and server, you get a very clear separation. The other one is that your server can evolve independently of the client. Dart applications will need to be compiled to javascript. In the end you will have a dart server app serving javascript files (+ maybe dart files if you decide to do so). Some of the packages that you use on the server side are not available in dartium - you don't want to have to deal with this dependency mess. Your server might consist of more then just one app, maybe your server will have a module in java or some other language. Keeping this two project separately gives you a lot more flexibility.

Related

How to make use of common files across projects using an IIS7 virtual directory

The scenario:
I'm very new to ASP.Net MVC programming and running into a wall constantly trying to make use of common files (.js, .css) across multiple projects.
The idea is to have these generic files in 1 location which provides for easy future updates and avoids the "copy and paste" dilemma across all the projects. I've set this folder up in IIS7 as a virtual directory in the default website with an alias "CommonFiles".
The problem:
With MVC-4 I'm trying to add the js files to a script bundle but upon running the application it's not picking the files up at all. (checked in the page source and also added a js function as a test)
Code snippet in BundleConfig.cs:
bundles.Add(new ScriptBundle("~/bundles/test").Include("~/CommonFiles/test.js"));
Rendering in _Layout.cshtml:
#Scripts.Render("~/bundles/test")
I've read quite a few posts (
Script Bundling in WebForms with Virtual Directories (asp webforms though), How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app, ScriptBundle not rendering scripts that are in a VirtualDirectory) but i'm afraid my lack of knowledge on MVC is limiting my path forward and really hoping to get some insight into how MVC handles IIS virtual directories and if it's even an easy possibility given the last post i've read above.
Can this be done in MVC-4 and if not what is a second best alternative in reusing common code across projects?
After reading a post by kev (Using ServerManager to create Application within Application) it put me on the right path and the issue I had is actually embarrassing.
For the sake of other devs landing on this post with a similar issue in visual studio, this is what fixed my issue:
Problem:
I make use of a separate project which contains files that are used across multiple other projects. I created a virtual folder in IIS7 referencing these files. This means if a change is needed to the common files, it's updated once and all the other projects will automatically "see" the change.
My other individual projects make use of script bundling to include files relevant only to the said project, but also to reference the common files in the virtual folder as defined in IIS.
My MVC-4 web application wasn't picking up the common files given the syntax above, in neither debug or release..
Solution:
When developing in VS2012, under the project's properties, there's a setting under the web tab where you can specify whether you want to use local IIS web server or IIS Express to test your application. IIS Express adds a random port to the site in order to test, and to allow multiple instances of sites to run (on different ports). This seems to throw the virtual directory include off in the bundling.
Choosing to use the local IIS server is closer to what the "live" environment would be in my opinion. Just un-tick the "Use IIS Express" setting.
As a side note and for more info on what the difference between the usage of IIS and IIS express is and whether it's suitable for your environment (as it was for mine) see this link:
http://msdn.microsoft.com/en-us/library/58wxa9w5.aspx
Hope this helps someone in future and saves them the amount of time I wasted on this!

How to recognize programmatically that application is installed vs development mode?

I'm trying to get information about license info of my app and MSDN docs (http://msdn.microsoft.com/en-us/library/windows/apps/hh694065.aspx) advice to use Windows.ApplicationModel.Store.CurrentAppSimulator class for that purposes during development/testing and when submitting app to store replace that class with Windows.ApplicationModel.Store.CurrentApp.
I wonder if there is any way to check in code (javascript in my case) if app is already installed from store so my code should use proper class and I won't have to remember every time I submit update of app to store to replacing those classes properly.
As far as I know, I could not find such thing. In fact, LicenseInfo is what provides information about the store listing.
I use a config.js file to keep settings at place which change between development and production. For example - if your app talks to a service, service URL also will likely change between development and production; the service might be running at localhost for development and for production in azure environment. I keep a bool in here and change by hand.
I have not automated it fully. but it is likely possible. need to dig through the msbuild logs for the build created for the store. if there is configuration setting found, then project can have two config.dev.js and config.release.js and msbuild need to conditionally pick the right file. I haven't looked into this yet.
I think I found at solution as described here WinJS are there #DEBUG or #RELEASE directives? . Not ideal, but works for me.

Strut Framework

Recently i have completed my first project using strut framework. And i want to run the project in my web space (www.mywebsite.com) instead of running it as http://localhost . How do i run it in my website? Can someone guide me please.
Thanks
First, you need an application server, if your application only uses Servlet API (you don't have EJB's) I recommend you that install tomcat or jetty servers.
Second, you must package your application in a WAR file; depending on the build tool you are using, it probably offers you some facilites to do that
Third, deploy the WAR file in the application server

How do I publish php source code to a local web server in rational team concert?

I'll be using RTC in the near future here at work. My question is: where does it put the files the team members will be working on? I understand that each programmer will work on the projects files and they will push the changes to the main repository. We have a local web server where we test our work (php). So, do we have to configure RTC to publish the files to the web server? or the RTC server must be installed in the webserver so it can save the files?
We use Rational Team Concert almost exactly as you describe, and it works brilliantly. My small team of web developers collaborates on website source code and delivers it to two different streams depending on its readiness: production-stream and staging-stream. Then we have defined two builds that check out the source code, move some things around, and push the files to the web servers via SCP. So, with a few clicks we kick off a staging build, watch it finish in about two minutes and everyone can see the changes on the staging server. When the code is ready for prime-time, the change sets are delivered to production-stream and the production build is kicked off, which is configured to copy the files to the production web server.
But even before a staging or production build is run, any of us can simply configure a local web server in RTC using the Eclipse PDE and Web Tools add-ons and see the site running in localhost as we develop.
All our work is done within Rational Team Concert, from planning, to bug tracking, to source control, to builds. It's very well-suited for website management.
Your understanding is correct - you work on files locally, and they get uploaded on to the server when you checkin. Bear in mind that checkin in RTC terms really means back-up your files to the server, it is a Deliver command that shares the files with others (it is worth a quick look at the articles on jazz.net that explains how SCM works).
One way to pubish to your php server is to make that part of a build, or a build in its own right (which RTC also handles - in conjunction with your favourite build tool). The build would copy the files to the php server. The advantage of doing this as a build is you will know exactly what versions of your files are being copied, and you will be able to reproduce this copy at any point in the future.
You do not need to install the RTC server on the php server.
You can also try posting on the forums on http://jazz.net/ if you have questions on RTC.
Hope that helps.
Another alternative would be to use the command line interface to accept all changes into a workspace and run that with a cron job.
To handle discarded change sets, you'd probably want to use something like:
scm workspace replace-components <workspace-name> stream <uuid-of-stream> --all
after you had initially loaded the workspace on your web server.

URL shortening (tinyURL, Bit.ly) application for internal deployment (open source or commercial)

I'm looking for the equivalent of a URL shortening service such as http://bit.ly/ for an internal deployment in our organisation. Anyone know of any open source projects (especially Java ones) or commercial products which I can install internally rather than using an external service?
Thanks!
Shorty : http://get-shorty.com/
But there's several other url shortener .... most of them are in PHP/Mysql.
Don't know if a Java one exist.
http://monkeytooth.net/2010/12/htaccess-php-how-to-wordpress-slugs/
tells you the core basics of how to achieve the concept with PHP and Htaccess building up from there I can say would solely be on your own. However not all to hard a concept in general to build off of if you know php/mysql. That said your not likely to find anything directly built in JavaScript however using this with JavaScript again wouldn't be all that hard a concept. I say your not likely to find one JS based as you need some type of server-side script to communicate with a DB somewhere, where you have all your short URL identifiers, and JavaScript to my knowledge doesn't support directly at least database connectivity. You can go through any means of AJAX to communicate with a server-side script to then do what you want with the JavaScript though.