What is the best way to add a Dart hello world into my existing Node.js website? - html

I have been reading tutorials and guides concerning this but have not found a straight forward answer to this.
I currently have an existing website running on a node.js platform, locally on my computer.
Goal: Now I want to try and write a simple hello world in Dart, export it to plain JavaScript and see it work in my existing website.
Reading the documents, I read that I should create a new "Web Application" and to create some sample code up and running, I check the "Generate sample content" box.
And my project is now created in Dart Editor:
I can run the sample in Dartium, see it work, etc.
But the problem is that I have now a .html file in the Dart-project, while I have a real .html file for my existing node website in a totally different path. I don't want that. I want to try and use the existing .html instead, since.. thats my real website.
But when trying to create a new Dartium launcher, I can only refer to .html files within my Dart-project:
So my big question is; How do actually start using Dart with my existing developed website?
How do I create that bridge?

On the second image above in your original question, there is an option just below the HTML file, called URL - is this what you're looking for? You can set that to any arbitrary URL.
You'd also need to copy the helloworld.dart file into your node.js server path, and copy the bits inside the <body> tag into your existing HTML page. You'll also need to copy the packages\browser\dart.js file somewhere to your node.js server, too.
If you wanted to run the JS version, you'd also need to use the editor menu option to Generate JavaScript and copy the .js files into your node.js server path.
The script tag that refers to dart.js automatically detects if the browser supports Dart natively, and will either load the .dart version of your app, or the .dart.js version of your app (from the same folder location).
So what you're likely after is something like:
c:/nodejs_server_root
/existingIndex.html // containing the two script tags from helloworld.html
// and other tags referred to in helloworld.dart
/helloworld.dart
/dart.js
/helloworld.dart.js
And in the "URL" path in the launch configuration, you'd put something like http://localhost:<port>/existingIndex.html

https://pub.dartlang.org/packages/dev_compiler can compile Dart to Node.js modules with the --modules=node option.
See also https://github.com/dart-lang/dev_compiler/issues/291#issuecomment-176687849

Related

PHP Desktop - Access to local resources

can you help me with access to local reseources?
For example I want glob my images outside of www folder. PHP has access but chrome not show this images.
Thanks for your answer.
Martin
Browser cannot access anything outside of the www/ directory, but PHP scripts can access the whole file system. You can output images through a PHP script, see for an example:
Output an Image in PHP
What you're trying to achieve is possible with PHP Desktop and it is quite easy. In PHP Desktop you have full access to the filesystem in PHP scripts and you can replace the native "Choose file" dialog with your own custom implementation using PHP and js/jquery scripting. You could reuse or base your code on some existing PHP library that allows you to browse files,
see https://tinyfilemanager.github.io/demo/.
Or just do something simple, I think implementing a custom "Choose file" dialog with jquery and PHP is a matter of a few hours.

dartdocgen: how to view docs locally

I am having trouble using dartdocgen and dartdoc-viewer to pump my JSON files to the browser. I have had success getting all the JSON files from my application but haven't had any success actually viewing them in the browser. Based on my research, the best way to do this is hosting dartdoc-viewer on a local server as mentioned by this document:
https://www.dartlang.org/tools/dartdocgen/#deploy
However I just cannot seem to get it to work following these directions (I would like to approach it via dartium):
https://github.com/dart-lang/dartdoc-viewer/
I understand that once I am able to run pub build and compile to javascript that I dump the client/build folder into my server along with the docs folder under the URL, I am golden. That's where the issue is, how to get it from the docs folder to javascript to the browser.
I would like to be able to use dartdocgen to it's full potential so can I get some ideas?
Just run dartdocgen --serve .
see https://www.dartlang.org/tools/dartdocgen/#view-locally
Is not what you are looking for?

threepenny-gui - opening files

Dear Haskell community I have written my first gui application and decided to use
threepenny-gui to do so.
The task is the following search the files in a given folder for matches and provide links to open those files. In addition I made nice parse and render function as the files (mostly) have a special formatting.
But now I have stumbled upon a problem - most browsers prohibit links to local files by href="file://localhost/home/user/folder/file.pdf" being opened, for security reasons, which I do understand and find completely sensible.
I tried to use href="./file.pdf" when the program and the file are in the same folder, which also doesn't seem to work.
The code of the whole application is available at github/epsilonhalbe, I run it in a folder and access it via a browser at localhost:100000
The HTTP server provided by threepenny-gui will serve up static content from the directory you specify in tpStatic. Put your files in that directory, and make your links' paths be relative to it, and you'll be good to go!
As of threepenny-gui-0.4.*, there are also two functions loadFile and loadDirectory that can be used to serve a local file or directory at an automatically generated URL. This can be useful if the tpStatic field is not enough.

html directory listing formatting

So, I've been trying to get a web page to display links to videos (over a symbolic link) dynamically (i.e., without hardcoding an <a></a> tag for each one) I have, and I think I may have found a solution, albeit a hacky one:
Video
Ignoring that this is a horrible way to do this, does anyone know how to format the following?:
I'm guessing there is an apache config file somewhere, but it is extremely hard to search for it as I do not know what it is called when files are just listed in this manner.
i'm basically looking to resize the widths of columns, and maybe even do some pretty-fication.
this is all running on my web/file server and is being accessed form my local machine.
This is what you're looking for:
http://perishablepress.com/better-default-directory-views-with-htaccess/
This tutorial details how directory listing by Apache can be modified to suit your taste using HTAccess file.
Using Apache HeaderName and ReadmeName directives and the module "mod_autoindex.c" you can add custom markup to your directory listing pages.
For displaying links to A/V and other files, look at my website: https://wrcraig.com/ApacheDirectoryDescriptions.
It goes beyond the default directory description, providing a spreadsheet to assist in creating detailed descriptions and exporting them in FancyIndex/AddDescription format for inclusion in .htaccess.
It also provides a menu driven BASH scripted alternative, using the FancyIndex descriptive data above (automatically adding A/V durations) to recursively populate a custom index.html while retaining the security features of .htaccess.
The site has examples of the input spreadsheet and both the FancyIndex output and the optional BASH scripted output.

How do I show an external file creation date on website?

I am using this site template to create a mobile/iPhone friendly site. I want to have it link to files, and below the link I want it to show the creation date. Currently everything is working fine but everytime I upload the file I also have to go into the index.html and change the modification date. Is there any type of script to do this for me that will work on my site? I have very basic HTML understanding, hence why I am using a template.
Thanks!
you're going to need some server-side scripting like PHP or ASP.NET. Using that, there are built-in File IO libraries where you can get the creation/modified date.
There are 2 ways to show file's last modification date (and only one of them works for creation).
You can have a file list generated by the file-listing capability of your web server. Basically, any URL mapping to a directory that is permitted to show its contents will result in a web page listing the directory contents, like this:
Index of /images/appimages/MastheadButtons
Name Last modified Size Description
-------------------------------------------------------------------
Parent Directory 22-Jun-2010 09:35 -
GP.JPG [link] 22-Jun-2010 09:41 1k
web.jpg [link] 29-Jan-2003 15:28 17k
You can have a back-end (CGI) script which produces the HTML page print any info you wish.
If you only know HTML, the second approach would not be practical for you. If you know some programming language in which to write web apps (PHP, Perl, anything), you can ask a more targeted qyestion of how to achieve what you want in that language.
However, HTML by itself is running on your browser. It doesn't execute any code on the web server where the file lives and thus doesn't know anything about the files.
Found the solution: I changed the file extension to .php from the iPhone Website template and then inserted this code where I want the modification date to be:
<?= date("m/d/Y H:i:s",filemtime("filename.extension")) ?>