21491 Posts in 5783 Topics by 2621 members
| Go to End | Next > | |
| Author | Topic: | 2146 Views |
-
JS files copied to assets - why?

24 July 2009 at 2:47am
Three .js files are being copied to the assets folder - they are:
base.js /****** FILE: jsparty/prototype.js *****/
cmsmain.js /****** FILE: cms/javascript/CMSMain.js *****/
leftandmain.js /****** FILE: jsparty/loader.js *****/ + othersI don't want users to see these, and I don't know why they are there?
All I have done to a clean install of 2.3.2 is to create two new folders in assets/Uploads and upload one PDf and one JPG.
Any ideas? Thanks in advance.
-
Re: JS files copied to assets - why?

24 July 2009 at 3:35am
silverstripe combines javascript files for the purpose of faster loading.
see cms/code/LeftAndMain.php, i.e. at around line 260 some js files are combined in 'assets/base.js'.
the reason silverstripe chooses the assets folder i think is that it's a folder that needs to be writeable by the standard requirements.
it should be possible do set it to another folder (don't forget to make it writeable using chmod) but you have to take care of other code expecting these files in the assets folder. -
Re: JS files copied to assets - why?

24 July 2009 at 4:02am
Thanks very much for the reply - I understand.
Do you know why the developers choose to put these files in a folder that users can see?
-
Re: JS files copied to assets - why?

2 October 2009 at 11:44pm Last edited: 2 October 2009 11:45pm
my workaround for this "issue" is to hide files with the extension .js and .html (for the 404 page generated files), and therfore i put the following code at the end of the constructor of AssetTableField.php;
//hiding .js and .html files which are auto-generated by SS by default in /assets folder
$this->sourceFilter .= ($this->sourceFilter) ? " AND " : "";
$this->sourceFilter .= "(`Filename` NOT LIKE '%.js' AND `Filename` NOT LIKE '%.html')";it´s not a special or elegant solution but it solves this issue for me;
-
Re: JS files copied to assets - why?

27 October 2009 at 10:32pm
Please will you share exactly where these lines go?
TIA
-
Re: JS files copied to assets - why?

27 October 2009 at 10:44pm
just put these lines at the end of the constructor (function __construct in /cms/code/AssetTableField.php)
-
Re: JS files copied to assets - why?

27 October 2009 at 11:01pm
Thx so far Alex,
I can see that line but I really don't have a clue where the 'end of the constructor' is
-
Re: JS files copied to assets - why?

27 October 2009 at 11:20pm
well, that is my changed AssetTableField constructor:
function __construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter = "", $sourceSort = "", $sourceJoin = "") {
parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
$SNG_file = singleton('File');
// If search was request, filter the results here
$SQL_search = (!empty($_REQUEST['FileSearch'])) ? Convert::raw2sql($_REQUEST['FileSearch']) : null;
if($SQL_search) {
$searchFilters = array();
foreach($SNG_file->searchableFields() as $fieldName => $fieldSpec) {
if(strpos($fieldName, '.') === false) $searchFilters[] = "`$fieldName` LIKE '%{$SQL_search}%'";
}
$this->sourceFilter = '(' . implode(' OR ', $searchFilters) . ')';
$this->searchingFor = $_REQUEST['FileSearch'];
// @todo Integrate search form more closely and don't rely on deprecated
// $extraLinkParams.
$this->extraLinkParams = array(
'FileSearch' => $SQL_search
);
}
//hiding .js and .html files which are auto-generated by SS by default in /assets folder
$this->sourceFilter .= ($this->sourceFilter) ? " AND " : "";
$this->sourceFilter .= "(`Filename` NOT LIKE '%.js' AND `Filename` NOT LIKE '%.html')";
$this->sourceSort = 'Title';
$this->Markable = true;
}
| 2146 Views | ||
| Go to Top | Next > |




