← Back to team overview

mahara-contributors team mailing list archive

[Bug 1912709] [NEW] Having 'js' folder in theme breaks HTML exports

 

Public bug reported:

We've created a custom theme for a client and added some JavaScript to
tweak something minor when viewing a collection. This file was put in
`<siteroot>/mahara/htdocs/theme/customtheme/js/theme.js`.

When exporting a portfolio, it looks like the HTML files are exported with the assumption that all the necessary js files are in the active theme's `js` folder.
For example, in the attached HTML file you'll see the below references in the `<head>` element - files which are not present in the export under the modern theme, but rather the raw theme (I just tested the core theme 'modern' in this case, but the same happens with custom themes):
```
<script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/jquery.js'></script>
<script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/bootstrap.min.js'></script>
<script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/dock.js'></script>
<script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/modal.js'></script>
<script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/lodash.js'></script>
<script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/gridstack.js'></script>
<script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/gridlayout.js'></script>
<script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/masonry.min.js'></script>
<script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/select2.full.js'></script>
<script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/theme.js'></script>
```

>From what I can tell, it's due to the code starting at around about `htdocs/export/html/lib.php:876`:
```
$jsdir =  $staticdir . 'theme/' . $theme . '/static/js/';
```

It appears to be preventing the blocks from being rendered/populated
correctly on the page and the page appears mostly blank.

As a workaround, we added the snippet of JS to
`$cfg->additionalhtmlhead` for now and removed the `js` folder from the
theme.

Not sure if this is expected behaviour or a bug or enhancement I'm recommending! :)
But hope it helps.


------------------------------
Application/System version(s):
Mahara
$config->version = 2020013013;
$config->series = '20.04';
$config->release = '20.04.2';

OS
Ubuntu 18.04.5 LTS

DB
MySQL 5.7
------------------------------

** Affects: mahara
     Importance: Undecided
         Status: New


** Tags: export html javascript links theme

** Attachment added: "Example of exported portfolio"
   https://bugs.launchpad.net/bugs/1912709/+attachment/5455345/+files/mahara-export-user1-2021-01-19_02-42%201.zip

** Description changed:

  We've created a custom theme for a client and added some JavaScript to
  tweak something minor when viewing a collection. This file was put in
  `<siteroot>/mahara/htdocs/theme/customtheme/js/theme.js`.
  
  When exporting a portfolio, it looks like the HTML files are exported with the assumption that all the necessary js files are in the active theme's `js` folder.
  For example, in the attached HTML file you'll see the below references in the `<head>` element - files which are not present in the export under the modern theme, but rather the raw theme (I just tested the core theme 'modern' in this case, but the same happens with custom themes):
  ```
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/jquery.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/bootstrap.min.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/dock.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/modal.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/lodash.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/gridstack.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/gridlayout.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/masonry.min.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/select2.full.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/theme.js'></script>
  ```
  
  From what I can tell, it's due to the code starting at around about `htdocs/export/html/lib.php:876`:
  ```
  $jsdir =  $staticdir . 'theme/' . $theme . '/static/js/';
  ```
  
  It appears to be preventing the blocks from being rendered/populated
  correctly on the page and the page appears mostly blank.
  
  As a workaround, we added the snippet of JS to
  `$cfg->additionalhtmlhead` for now and removed the `js` folder from the
  theme.
  
  Not sure if this is expected behaviour or a bug or enhancement I'm recommending! :)
  But hope it helps.
+ 
+ 
+ ------------------------------
+ Application/System version(s):
+ Mahara
+ $config->version = 2020013013;
+ $config->series = '20.04';
+ $config->release = '20.04.2';
+ 
+ OS
+ Ubuntu 18.04.5 LTS
+ 
+ DB
+ MySQL 5.7
+ ------------------------------

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1912709

Title:
  Having 'js' folder in theme breaks HTML exports

Status in Mahara:
  New

Bug description:
  We've created a custom theme for a client and added some JavaScript to
  tweak something minor when viewing a collection. This file was put in
  `<siteroot>/mahara/htdocs/theme/customtheme/js/theme.js`.

  When exporting a portfolio, it looks like the HTML files are exported with the assumption that all the necessary js files are in the active theme's `js` folder.
  For example, in the attached HTML file you'll see the below references in the `<head>` element - files which are not present in the export under the modern theme, but rather the raw theme (I just tested the core theme 'modern' in this case, but the same happens with custom themes):
  ```
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/jquery.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/bootstrap.min.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/dock.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/modal.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/lodash.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/gridstack.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/gridlayout.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/masonry.min.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/select2.full.js'></script>
  <script type='text/javascript' src='../../../HTML/static/theme/modern/static/js/theme.js'></script>
  ```

  From what I can tell, it's due to the code starting at around about `htdocs/export/html/lib.php:876`:
  ```
  $jsdir =  $staticdir . 'theme/' . $theme . '/static/js/';
  ```

  It appears to be preventing the blocks from being rendered/populated
  correctly on the page and the page appears mostly blank.

  As a workaround, we added the snippet of JS to
  `$cfg->additionalhtmlhead` for now and removed the `js` folder from
  the theme.

  Not sure if this is expected behaviour or a bug or enhancement I'm recommending! :)
  But hope it helps.

  
  ------------------------------
  Application/System version(s):
  Mahara
  $config->version = 2020013013;
  $config->series = '20.04';
  $config->release = '20.04.2';

  OS
  Ubuntu 18.04.5 LTS

  DB
  MySQL 5.7
  ------------------------------

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1912709/+subscriptions


Follow ups