Re: How to implement D to HTML pages ?

2018-10-03 Thread aberba via Digitalmars-d-learn
On Monday, 1 October 2018 at 19:29:56 UTC, Aurélien Plazzotta 
wrote:

Hello guys,

I would like to implement a forum and a blog within my website 
(currently including only HTML, CSS and JS, written without 
CMS), using D and SQL but I really don't know how to proceed. 
How can I integrate D into HTML pages? Are there any kind of 
include's commands like PHP ?


Also, do I have to use vibe.d ? Or is it optional? I admit I 
didn't read the book yet (D Web Development), but only 
"Programming in D", which doesn't deal much with website 
workflow.


Finally, what database system do you recommand to interact with 
for data-oriented website purpose? Perhaps, there are some 
standard or tierce-party librairies or ORM for PostgreSQL or 
SQLite ?


Thanks for all the light anyone will be willing to spread :)


Nothing get you simpler with Vibe.d than my blog[1]. I've done a 
series of tutorials for beginners but straight to the point.


1. https://aberba.netlify.com/
2. 
https://aberba.netlify.com/2016/hello-world-app-with-the-vibe.d-web-framework/

3. https://aberba.netlify.com/2016/form-upload-in-vibe-d/
4. https://aberba.netlify.com/2017/multiple-file-upload-in-vibe-d/
5. https://aberba.netlify.com/2018/using-vibe-d-web-interface/


Re: How to implement D to HTML pages ?

2018-10-03 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 18:27:04 UTC, Aurélien Plazzotta 
wrote:
Thank you both for all the links! I guess DiamondMVC is very 
powerful but I would rather avoid using such heavy artillery. 
I'm expecting the learning curve to be very long.


I currently use two libraries I wrote to keep things easy.

https://code.dlang.org/packages/arrogant
https://code.dlang.org/packages/reserved

The first one is a html5 parser. So you don't need any template, 
you can directly read html and then edit them just like you are 
used to do in js, for example.


For example:
   auto src = `Hello 
World`;

   auto arrogant = Arrogant();
   auto tree = arrogant.parse(src);

   // Change div content from "Hello World!" to "Hello D!"
   tree.byTagName("div").front.innerText = "Hello D!";

   // Print the edited html
   writeln(tree.document);

The second library is a scgi library that allow you to send data 
to any webserver that support scgi (f.e. nginx). It works like 
php:


import reserved;

@ReservedResponse
private void response(Request req, Output output)
{
   output ~= "Hello ";

   if ("name" in req.get)
  output ~= req.get["name"];
   else
  output ~= "World";

   // Using the library above you can do something like this 
instead:

   // output ~= tree.document;
}

mixin Reserved!"awesome_d_webservice";

So if you combine those two libraries you can output a 
validated/well-formed html5 document in a easy way.


Andrea


Re: How to implement D to HTML pages ?

2018-10-02 Thread bauss via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 18:27:04 UTC, Aurélien Plazzotta 
wrote:

On Tuesday, 2 October 2018 at 06:56:33 UTC, bauss wrote:

On Monday, 1 October 2018 at 23:17:59 UTC, rjframe wrote:


vibe.d has more of a node.js feel. There's also 
DiamondMVC[1], which reminds me of ASP.NET (I'm not 100% sure 
whether that's intentional, and I haven't tried Diamond) and 
includes an ORM.


As the creator of Diamond, then I can say it's 100% 
intentional that it reminds of ASP.NET. It was originally just 
an alternative template engine to vibe.d to create views 
similar to razor, but now it's a full-stack web-framework 
specifically targeting enterprise development, hence why the 
similarities to ASP.NET.


As described on the website (https://diamondmvvc.org/):

"Diamond is build on modern principles using vibe.d, inspired 
by ASP.NET and razor templates."


It can also be used in combination with vibe.d projects, in 
which you can just utilize the extra tools Diamond gives you 
such as some additional security, authentication, api 
creation, database management (ORM) etc.


Thank you both for all the links! I guess DiamondMVC is very 
powerful but I would rather avoid using such heavy artillery. 
I'm expecting the learning curve to be very long.


Do you know of template engines in D ? like Jinja2 in Python 
for example. It would be way more lightweight and 
free-dependancies compared to a fully featured framework like 
DiamondMVC, besides the gain in time thanks to the simplicity 
of use.


The learning curve is actually not that long since it's a 
relative small setup. It's a heavy beast, BUT everything is 
pretty much optional and opt-in, so you really only just use what 
you need.


So for templating, just setup a project, the configuration and 
then create views.


As soon as you're familiar with the template syntax then you're 
good to go without knowing the whole framework etc.


You can write templates using D in it.

Simple example: After 3.0.0 which is coming soon then @<> is 
replaced by @()


layout.dd:

```
@


  Website - @


  @


```

home.dd:

Notes: placeholders is equivalent to an associative array in D.

```
@[
  route:
home
---
  placeholders:
[
  "title": "Home"
]
]
Hello World!
```

Output:

```



  Website - Home


  Hello World!


```

It's pretty much plug and play too using this as an empty example 
project:


https://diamondmvc.org/download

See empty project.

It'll be ready to just compile and run.

After that you can just work with views if you just want to use 
simple templates. No need to know the whole framework or any long 
installation guides.


Re: How to implement D to HTML pages ?

2018-10-02 Thread Aurélien Plazzotta via Digitalmars-d-learn

On Tuesday, 2 October 2018 at 06:56:33 UTC, bauss wrote:

On Monday, 1 October 2018 at 23:17:59 UTC, rjframe wrote:


vibe.d has more of a node.js feel. There's also DiamondMVC[1], 
which reminds me of ASP.NET (I'm not 100% sure whether that's 
intentional, and I haven't tried Diamond) and includes an ORM.


As the creator of Diamond, then I can say it's 100% intentional 
that it reminds of ASP.NET. It was originally just an 
alternative template engine to vibe.d to create views similar 
to razor, but now it's a full-stack web-framework specifically 
targeting enterprise development, hence why the similarities to 
ASP.NET.


As described on the website (https://diamondmvvc.org/):

"Diamond is build on modern principles using vibe.d, inspired 
by ASP.NET and razor templates."


It can also be used in combination with vibe.d projects, in 
which you can just utilize the extra tools Diamond gives you 
such as some additional security, authentication, api creation, 
database management (ORM) etc.


Thank you both for all the links! I guess DiamondMVC is very 
powerful but I would rather avoid using such heavy artillery. I'm 
expecting the learning curve to be very long.


Do you know of template engines in D ? like Jinja2 in Python for 
example. It would be way more lightweight and free-dependancies 
compared to a fully featured framework like DiamondMVC, besides 
the gain in time thanks to the simplicity of use.


Re: How to implement D to HTML pages ?

2018-10-02 Thread bauss via Digitalmars-d-learn

On Monday, 1 October 2018 at 23:17:59 UTC, rjframe wrote:


vibe.d has more of a node.js feel. There's also DiamondMVC[1], 
which reminds me of ASP.NET (I'm not 100% sure whether that's 
intentional, and I haven't tried Diamond) and includes an ORM.


As the creator of Diamond, then I can say it's 100% intentional 
that it reminds of ASP.NET. It was originally just an alternative 
template engine to vibe.d to create views similar to razor, but 
now it's a full-stack web-framework specifically targeting 
enterprise development, hence why the similarities to ASP.NET.


As described on the website (https://diamondmvvc.org/):

"Diamond is build on modern principles using vibe.d, inspired by 
ASP.NET and razor templates."


It can also be used in combination with vibe.d projects, in which 
you can just utilize the extra tools Diamond gives you such as 
some additional security, authentication, api creation, database 
management (ORM) etc.




Re: How to implement D to HTML pages ?

2018-10-02 Thread bauss via Digitalmars-d-learn

On Tuesday, 2 October 2018 at 06:56:33 UTC, bauss wrote:


As described on the website (https://diamondmvvc.org/):



Minor typo sorry.

https://diamondmvc.org/


Re: How to implement D to HTML pages ?

2018-10-01 Thread rjframe via Digitalmars-d-learn
On Mon, 01 Oct 2018 19:29:56 +, Aurélien Plazzotta wrote:
On Mon, 01 Oct 2018 19:29:56 +, Aurélien Plazzotta wrote:

> Hello guys,
> 
> I would like to implement a forum and a blog within my website
> (currently including only HTML, CSS and JS, written without CMS), using
> D and SQL but I really don't know how to proceed. How can I integrate D
> into HTML pages? Are there any kind of include's commands like PHP ?
> 
> Also, do I have to use vibe.d ? Or is it optional? I admit I didn't read
> the book yet (D Web Development), but only "Programming in D", which
> doesn't deal much with website workflow.

If you're most comfortable with PHP you may want to look at Adam Ruppe's 
arsd[0]; the readme has an overview of web-related and database-related 
modules.

vibe.d has more of a node.js feel. There's also DiamondMVC[1], which 
reminds me of ASP.NET (I'm not 100% sure whether that's intentional, and I 
haven't tried Diamond) and includes an ORM.


> Finally, what database system do you recommand to interact with for
> data-oriented website purpose? Perhaps, there are some standard or
> tierce-party librairies or ORM for PostgreSQL or SQLite ?
> 
> Thanks for all the light anyone will be willing to spread :)

There are low-level bindings for MySQL/MariaDB, Postgres, SqLite, and some 
people have made higher-level libraries and ORMs[2]. You may want to 
browse a bit and see what you like. I believe the Diamond ORM can be used 
without the rest of the framework, and the hunt-entity ORM is actively 
developed.


[0]: Repo: https://github.com/adamdruppe/arsd
 Docs: https://arsd-official.dpldocs.info/index.html (note that not 
everything is documented)
[1]: https://github.com/DiamondMVC/Diamond
[2]: http://code.dlang.org/?sort=updated&limit=20&category=library.database


How to implement D to HTML pages ?

2018-10-01 Thread Aurélien Plazzotta via Digitalmars-d-learn

Hello guys,

I would like to implement a forum and a blog within my website 
(currently including only HTML, CSS and JS, written without CMS), 
using D and SQL but I really don't know how to proceed. How can I 
integrate D into HTML pages? Are there any kind of include's 
commands like PHP ?


Also, do I have to use vibe.d ? Or is it optional? I admit I 
didn't read the book yet (D Web Development), but only 
"Programming in D", which doesn't deal much with website workflow.


Finally, what database system do you recommand to interact with 
for data-oriented website purpose? Perhaps, there are some 
standard or tierce-party librairies or ORM for PostgreSQL or 
SQLite ?


Thanks for all the light anyone will be willing to spread :)