Better Export Functionality [added in 2.4.2]

I see where your coming from Frank.. And I do like some of your points. This is why we are discussing it to fleshing out our ideas :)

One of the main things for me is that at work here we use .shtml file extensions in all our HTML files. And we have a few areas were our images are outside the "ROOT" of the project yet referenced in our code as if they were. All handled by the webservers use of symbolic linking.

So here's some ideas of mine after reading Franks post.

Maybe what could be done is that right clicking the Pages section in Design pane add an option for Default Properties.

In the Pages Default Properties you can set default extension and folder path. When you go to export, each file has an option where you change from the default if need be, such as the Destination input as @Martin described where it contains the full folder path/file.extension as indicated in the Default Properties, or if not changed then the BSS apps default setting.

Then for the Images section do something similar as the Default Properties where you can set the default path. Then on export similar to pages a Destination input where you can change specific files if need be to be different and add the checkbox of update source only.

I like your idea of saved config for each project as well as in the project if I move an image to a folder, update the projects HTML/CSS accordingly.

Saj

I find the fact that the Export function does not request an html filename and always creates index.html to be very bad. It wiped out our landing page. Fortunately, we had multiple backup copies. It definitely should request the name of the html file for the page you are creating.

@bilfly - did you change the name of the page you built in BSS before exporting?

By default BSS creates index.html on new designs and you have to edit the name yourself - if you do that it shouldn't export as index.html then

+1 to Franks comment about the app remembering where each project is exporting to. It's a good thing I check that closely before I save, I almost saved a project in another project's folder a couple times now. Would love it if the app could please remember the last place a project was exported to... per project setting.

The new export functionality was added to version 2.4.2, which we released yesterday. It supports remembering export destinations, minification and using CDN for jQuery, Bootstrap and the icon fonts.

After much deliberation, we decided that there is an impossible number of different transformations that people might require from the export. This is why instead of building a similarly complex interface to customize the file paths, we made something better - the ability to configure an Export Script, which is called after every export. This is more involved, as it requires writing code, but gives you a lot of control. You can write the script in any language. For Linux and macOS it should be marked as executable (+x).

For example you can write a script like this in bash to rename a specific file from .html to .php:

#!/bin/bash
cd $1 # the export path is passed as the first argument, which is why we cd there
mv index.html index.php

Similarly, you can move images to external folders, replace parts of your generated code, optimize your images and more. It all depends on what you are able to do with your script.

Hiya Martin,

Although this all sounds great, I'm not a programmer at all so this coding stuff is a bit lost on me. Will there be support examples to help those of us that are not programmers to create various scenarios to get us started?

VERY COOL IDEA!

I could even do something like copy to my server via ssh!

@Jo - There's lots of script help available on Google for this kinda stuff, you'll find it rather trivial to make complex stuff happen with this addition! This is the right solution for this application!

@Martin - maybe you can make an online snippet section like components that people can install or copy / paste. Like "Export as PHP", and it just works for people. "Export as ASP", etc.

Thanks Andrew, I'm sure there are a ton of places on google, but .... I would have to know what to search for to do that lol. As I said, I'm not a programmer, so I have no clue what language I'm looking at in many cases. Working on it, but it's a time consuming process for this old brain so it will be a while before I'm anywhere near using it lol. I like the idea of the Snippet section though, that would definitely make a difference.

Other than exporting to specific locations in a directory, I don't even know what I'd have a need for this for at this time lol. I think right now it would only be used for setting the export directory of specific folders (js, css, etc.) into the root directory rather than within the assets directory.

I have to say one thing on this though. I'm finding it more and more convenient to have the files where they export lol. It's more the importing of them that's giving me grief than the exporting lol. Thanks for your suggestions though Andrew. :)

I would assume that those of us with win10 anniversary update would need to install the Linux Bash Shell for win10 so that we could use the bash example as stated?

http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/

I am also one that doesn't know this method of scripting. I had tried making a .sh file with the above example to no avail. Any direction would be helpful.

Saj

I gave Bash as an example, as this is the most basic way of scripting things on Linux and macOS. Windows doesn't have bash installed, so you will need to write scripts using a different language. You can write scripts using CMD.exe (called Batch files). Here is an example. They have different commands and syntax than the code I wrote above. Another built-in alternative is PowerShell, but I don't have experience with it.

Ok so after several attempts on figuring out some powershell and or .bat usage, I find that I am limited based on security being able to run scripts on my work system. I tried running a .bat file that would execute a .ps1 file and would get security errors.

So I'm not going to go into how to subvert your windows OS security just to allow running these scripts as the potential danger and risk to making a very powerful tool automated and leaving your PC vulnerable.

So I have come away with doing this for me in win10 and using powershell. For now I won't use the Advanced part of the export function of the BSS app.

Click start and for win10 just start typing in powershell, select "Windows Powershell" from the list. I right clicked it and pinned it to the task bar so I can launch it from there.

In powershell I'm going to use the following command (I haven't figured out the method to change directories and execute this in a single process)

Get-ChildItem -Filter "*.html" -Recurse | Rename-Item -NewName {$_.name -replace 'html','shtml'}

This command generally does the following based on how I understand it.

  1. Get all child elements with the file name .html [the asterisks is a wildcard character meaning any/all files with the ".html" extension]
  2. Recurse - find all files from with in the root AND sub folders, root is the current folder that powershell has as the command line
  3. Rename some items with a new name
  4. Replacing the [first value] with the [second value]

So you will need to use DOS/batch style commands to get to the appropriate directory in order to execute it.

If you are exporting to a network drive, it will be easiest to MAP the network drive first. Preferably the folder that is the root for your export. I will use "T:\bss_export" for example.

Once you start Powershell it most likely starts with the command line of PS C:\Users\[your username]

Using the networked drive example

  1. type in cd "T:" (hit enter) (I mapped my network drive to T)
  2. if it's a subfolder type in cd "bss_export" (hit enter) (I had a subfolder for test)

The Powershell commandline would look something like this for me PS T:\bss_export

If like me I need to change all the .html exported extension to .shtml then copy/paste in this command and hit enter

Get-ChildItem -Filter "*.html" -Recurse | Rename-Item -NewName {$_.name -replace 'html','shtml'}

For people that need to switch some of your files to .php then I think this would do for you. Before you export, rename the files you want to be php files by including "_php" in the file name before the .extension

So that you could then use these 2 commands.

Get-ChildItem -Filter "*_php*" -Recurse | Rename-Item -NewName {$_.name -replace 'html','php'}

Get-ChildItem -Filter "*.php" -Recurse | Rename-Item -NewName {$_.name -replace '_php',''}

First command will rename files that contain _php in the name it will rename it to a .php file then the second command will find those .php files and rename the file by removing the _php wording in the file name.

A Big thing here is that this does not replace/overwrite existing files.

I haven't figured out a way for that.

You could try the following below but I think I will export to a holding area rename the files like above and then move them where I need them.

<hr />

I could use these 2 commands to work around that BUT I would have to be sure that any editing is done in the BSS app not after because this will delete the old file.

Make my edits in the BSS app not outside it then export then run powershell etc and run this command to remove all files.

Get-ChildItem *.shtml -Recurse | Remove-Item

Then I could run this to get back to the correct file .extension

Get-ChildItem -Filter "*.html" -Recurse | Rename-Item -NewName {$_.name -replace 'html','shtml'}

I'll look into .bat file commands and see what I can up with for that.

Saj

Hi Saj,

take Linux... then you will have less problems. (e.g. www.linuxmint.com (its an Ubuntu and Debian System and easy to use))

I quit with MS at the point of Windows 8. With Windows 10 and all its System integrated Spyware my hole company stops any MS-Support.

Take Linuxmint, with an VirtualBox (www.virtualbox.org) running Window7 and Comodo Internetsecurity on it. Then you can run some special Windows-Software if this not available in Linux.

I am trying to make an Linux-Script for the things you need, because I need them, too, but I need some time before its ready to share

Thanks Frank,

Unfortunately it's a work PC and totally out of my control for most things like that. It's not a problem for me to export in a staging area of sorts because I still need to do a bunch of post editing as it is anyways with all the snippets I need to make and putting in programming tags etc...

I do appreciate all the info though :)

Saj

+1 to Franks comment. This is biting me often as I have numerous projects and they each have their own export location.

My post didn't show up where I thought it would. I was also voting for the ability to have the export destination be a project-level setting rather than a a global setting across all projects.

Hiya Jeff0401,

Project specific export settings have already been added to the app. Click the button and if you do not have a location set up it will ask you for one. That will happen for each project. Enjoy! :)

For those having difficulty in running .bat files as export script in windows I would recommend (as an alternative among other possible solutions) to write a simple python script like this:

import os import sys nwd=sys.argv[1] os.chdir(nwd) os.system('copy index.html index.php')

and make this python script an executable (.exe) file with py2exe as explained here py to exe in windows It worked quite fine in my system (win 7).

windows: create new file : ren.bat xcopy *.html *.php /y

To execute python script via Windows just put this line in BATCH file (*.bat) C:\path_to_python_directory\python.exe \full_path_to_your_script\

And it works, i don`t know why, but it do.

@eczo86

You can just put your python script in the same folder as your export folder and then create a batch file to run it.

Set export script link in Bootstrap Studio to the batch file in the same folder that has:

@echo off cd %1 pythonscript.py

This lets you edit the python script and not have to make a ".exe".

Beautiful Soup Html Parsing on the way...Nice