Pier bootstrap recipe (version 2)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Pier bootstrap recipe (version 2)

DiegoLont
Hi all,

Sergio ran into trouble using the bootstrap recipe, so this means the recipe isn’t good enough. I improved some parts (bold and blue)

First we need to load Pier, and since I also want to export my code, I used the following code:
Gofer new 
smalltalkhubUser: 'Pier'
project: 'Pier3Addons';
configurationOf: 'Pier3AddOns';
load.

((Smalltalk at: #ConfigurationOfPier3AddOns) project version: #'development') load: #( 'Pier-Exporter-Code' 'Pier-Bootstrap' ).

This gives us a clean Pier-site, that we can modify for our use. Since we need bootstrap loaded, we first need to register pier, using bootstrap, and of course start the web server:

PRKernel reset.
PRPierFrame registerAsBootstrapApplication: 'volkstuinen' kernel: (PRKernel named: 'pier').
ZnZincServerAdaptor startOn: 8088

Before we start, we first open the site, and click on “change owner”. Change the owner to admin and toggle the recursive button. This will allow us to set the site up properly, using rights and such. When you do so, you will see that the menu with commands becomes a lot shorter, and you will have to login using “pier”, “admin” to be able to proceed.

Our template is quite simple: in our site we have a navbar, a main page and a footer. But before we can change our template, we have to make sure that we can still edit, after changing everything. This is how I would do it, if I needed to do it again.

We start by modifying the template. We add the stuff we are going to need in the beginning. Since the footer will  be sticky, we want some room at the bottom anyways, so this will work fine.
+Navbar+
+MainPage+
+footer+
…. old pier stuff….

Since there is already a footer, the result of this, is that pier renders 2 missing links: “navbar” and “mainPage” where you can click on.

Now we start by adding the main page, just by clicking on main page. The main page has an alternative look, when we are logged in, because I do not want the pier navigation shown when we are logged out. This is a new component in Pier. I set it up with default (+contents+) and an alternate:
{{{<div class="jumbotron">
<div class="container">}}}
!!!Logged in
{{{</div></div>}}}
+contents+

+Sidebar+

Doing so, will result in a banner showing “logged in”. Try loging out again to test if the banner disappears.
Also Pier might try to match the sidebar, if it does so, first create a new sidebar and then correct it (removing the slash)

Now remember to select the main page, because otherwise everything will be added to the template. Now login and modify the contents and the sidebar. The contents and sidebar, are the “normal” contents and sidebar, displaying the contents and the navigation (Children (dynamic)). Change the navigation and set the level to 1 and recursive to true. This will give us better navigation.

Note that you now have 2 sidebars. The one we have added, and the original one.

Next step will be to edit the footer. Select the footer and click edit and fill out the following:

{{{<div id="footer">
<div class="navbar navbar-default navbar-fixed-bottom" role="navigation">
<div class="container-fluid">}}}
+Collapse+
{{{</div></div></div>}}}

And then the collapse looks like this:
{{{<button type="button" class="navbar-toggle" data-toggle=“.fcollapse" data-target=".footer-collapse">
<span class="se-only">Toggle footer</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>}}}
{{{<div class="footer-collapse fcollapse">}}}
+Menu+
+Commands+
{{{</div>}}}

As you can see, there is still quite a lot of bootstrap code in our pier content, but after we have set up our site, we do not need to bother with this any more. The menu is a component, that displays some static Children. I added here the possibility to add some css class. Fill out:
list class = nav navbar-nav navbar-right)
active class = active. 
It needs to point to the node where you add the children you want displayed in your footer. we leave this to default for now.

At this point the footer should be shown in the bottom of the screen. Since there are a lot of commands, it might be a bit cramps down there. I suggest you remove the commands you do not need. Do not remove “edit” “login” and “logout” or you will be stuck.

Now we change our navbar. This looks a lot like our footer.
{{{<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class=“container">}}}
+Title+
+Collapse+
{{{</div></div>}}}

With the collapse:
{{{<div class="navbar-collapse collapse">}}}
+Menu+
{{{</div>}}}

And the title
{{{<div class=“navbar-header”>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="se-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>}}}
{{{<a class="navbar-brand" href="/">}}}Your site{{{</a></div>}}}

The menu is the same as in the footer. It is a static children component with the list class set to "nav navbar-nav navbar-right” and the active class set to “active”, and pointing to the place where we have our content.

Since the next step is crucial, we need to check if everything is working fine. Test your site, by selecting several things. For instance: if you select the title from the navbar, it should display from top to bottom:
- a header
- the banner with “logged in”
- the title (since this is now the current context)
- the sidebar you have added
- the pier logo, the search box, the old side bar and commands
- the heading Pier
- the title (half hidden behind the footer)
- the footer

The site should look like this, when you have selected the menu:


We can now remove the unneeded things from our template and modify it into:
+Navbar+
+MainPage+
+footer+

Finally, for our pages, we still have the jumbotron to add, so here is some bootstrap code as well:
{{{<div class="jumbotron">
<div class="container">}}}
+Heading+
{{{</div></div>}}}
{{{<div class="container"><div class="row">
<div class="col-md-4">}}}+Page1+{{{</div>
<div class="col-md-4">}}}+Page2+{{{</div>
<div class="col-md-4">}}}+Page3+{{{</div>
</div></div>}}}

Note that for our static children you can only select nodes, that have children. You probably want to create them in a separate place, then add 1 child, and then go back to the menu to point it to the right place.

So this is still quite the manual, so maybe we should make some bootstrap specific components. But then I do not know what components we exactly need, so please let me know if you have ideas for this, or have better ways to do this.

As you can see, there are a few new components and options (static children, css options, altdoc page) we added, but basically this is it. If you have any trouble or suggestions for improvements, let me know.

Cheers,
Diego

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki