Commit Graph

58 Commits

Author SHA1 Message Date
Christopher Joe
7b200a2a64 Fix add combinedFiles to clear logic 2017-08-29 12:57:41 +12:00
Patrick Nelson
a511e3511c FIX #6855: Mangled JS in Requirements, escaping replacement values prior to passing to preg_replace(). 2017-05-02 13:43:50 +12:00
Robbie Averill
55eb7ebdcc FIX Do not insert requirements more than once in includeInHTML
This change consolidates the string replacements used to insert requirements into the page content to help ensure
that they are not compounding and overwriting eachother.

The added test case includes where a user may have a Javascript snippet that contains a closing head tag, and the
test ensures that it does not get injected with requirements as well as the actual head tag in the DOM.
2017-04-07 17:04:17 +12:00
Daniel Hensby
272703b41a
Revert Requirements throwing exceptions from #5260 2016-12-08 13:25:50 +00:00
Daniel Hensby
9282662293
Fixing bad syntax from PR 2016-07-15 17:00:33 +01:00
Daniel Hensby
51e02e2ed7
Merge remote-tracking branch 'tony/patch-1' into 3 2016-07-15 16:58:48 +01:00
Cristian Torres
2f84c3431b UPDATE: Throw exceptions on file missing
The class will throw exceptions whenever the css or js file is not found in any context and the site is in development mode
2016-05-18 16:47:38 -06:00
Damian Mooyman
7041c5945c API Enable requirements to persist between flushes 2016-05-12 12:46:30 +12:00
Cristian Torres
d75de1369f themedScript Added
A function to call javascript files just by its name as it occurs with themedCSS
2016-04-02 11:20:27 -06:00
Sam Minnee
3ee8f505b7 MINORE: Remove training whitespace.
The main benefit of this is so that authors who make use of
.editorconfig don't end up with whitespace changes in their PRs.

Spaces vs. tabs has been left alone, although that could do with a
tidy-up in SS4 after the switch to PSR-1/2.

The command used was this:

for match in '*.ss' '*.css' '*.scss' '*.html' '*.yml' '*.php' '*.js' '*.csv' '*.inc' '*.php5'; do
	find . -path ./thirdparty -not -prune -o -path ./admin/thirdparty -not -prune -o -type f -name "$match" -exec sed -E -i '' 's/[[:space:]]+$//' {} \+
	find . -path ./thirdparty -not -prune -o -path ./admin/thirdparty -not -prune -o -type f -name "$match" | xargs perl -pi -e 's/ +$//'
done
2016-01-07 10:15:54 +13:00
Damian Mooyman
b195132407 Fix missing media parameter on Requirements::combine_files
Regression from #4136
2015-05-11 17:30:59 +12:00
Nik Rolls
8727f27f2a Documentation tidy for Requirements.php
Documentation-only changes, except where a couple of methods have been moved to live next to other related functions.
2015-04-29 20:17:40 +12:00
Will Morgan
7c9810bf49 Merge pull request #3432 from IgorNadj/3.1-fix-minify
FIX making minify javascript fail-safe
2015-02-06 11:17:59 +00:00
Igor Nadj
657606e8c8 Updating code to allow unit test to use try-catch block to catch warning
without stopping code execution inside try
2014-11-26 15:27:54 +13:00
Juri Demeschew
19f11e72b0 Update Requirements.php
Makes requirements inclusion work with old PCRE versions
2014-10-31 15:41:58 +01:00
Juri Demeschew
3eabd7d41a Fix #3356 js not properly included 2014-09-09 06:59:31 +02:00
Igor Nadj
f823831a63 FIX making minify javascript fail-safe 2014-08-25 11:49:38 +12:00
Sean Harvey
2b316e79e5 NEW Provide a consistent way of triggering flush
Provides an interface for classes to implement their own flush()
functionality. This function gets called early in a request on
all implementations of Flushable when flush=1|all is requested in the
URL.

This fix came out of an issue where Requirements combined files were not
being cleaned up after dev/build?flush=1, due to the fact that flush
would only occur when you called it while on a page that used those
combined files, but not in any other contexts. This will now call flush
on any implementors of Flushable regardless of the context of where
flush was called.
2014-08-22 09:24:27 +12:00
Ingo Schommer
78a530524b Merge pull request #2684 from Firesphere/feature/force_write_js_to_bottom
NEW Forcefully write javascripts to the end of the HTML if wished
2013-12-19 09:21:06 -08:00
Firesphere
af7afbe918 IMPROVEMENT/FEATURE Forcefully write javascripts to the end of the HTML if wanted.
It's defaulted to false. But when set to true, the JS is written to the end of the HTML, even though there are earlier scripts.
This results in faster page-loading if the JS isn't needed earlier-on.
2013-12-14 14:04:03 +01:00
Ryan Wachtl
b260e5e29c FIX Check for file in project() folder when calling Requirements::themedCSS() #2613
Allows overriding of theme and module css files by looking in project() folder first. Consistent with documented behavior.
2013-12-13 11:12:22 -06:00
Firesphere
41371fea72 NEW Force the javascripts to be put before the closing body tag 2013-12-07 15:47:31 +01:00
Firesphere
14447b167a IMPROVEMENT/FEATURE Forcefully write javascripts to the end of the HTML if wanted.
It's defaulted to false. But when set to true, the JS is written to the end of the HTML, even though there are earlier scripts.
This results in faster page-loading if the JS isn't needed earlier-on.
2013-12-07 15:47:27 +01:00
Ingo Schommer
2c145cd454 API JS i18n files with short locale names, generated by build task
The files are uploaded to transifex.com now, which means we needed
to consolidate the file names (= locales). Since Transifex doesn't allow
arbitrary JavaScript structures, we're using an intermediary JSON
format which gets transformed into the JS used by the framework.

See b59f3858af for generator logic.

Fixes https://github.com/silverstripe/silverstripe-framework/issues/2499
2013-10-25 12:05:46 +02:00
Jeremy Thomerson
4c0b452c0f ENHANCEMENT: allow overridable JS/CSS minification
This allows someone to extends Requirements_Backend and plug in their own minification
of files, including CSS minification.  It also allows them to override whether or not
the header comment is written for each file.
2013-06-04 12:52:11 +00:00
Ingo Schommer
cef955c8b9 Removed stray ampersand in Requirements (fixes #1809)
Only happens with suffix_requirements=true
2013-04-30 00:35:25 +02:00
Ingo Schommer
3334eafcb1 API Marked statics private, use Config API instead (#8317)
See "Static configuration properties are now immutable, you must use Config API." in the 3.1 change log for details.
2013-03-24 17:20:53 +01:00
g4b0
2f16951634 BUG: ampersand escaping 2013-03-11 09:58:14 +01:00
Ingo Schommer
b44720179c Merge pull request #1180 from mateusz/css-combining-media
API Add possibility to combine media-targeting stylesheets.
2013-02-12 14:13:45 -08:00
Mateusz Uzdowski
53feb3a5ae API Add possibility to combine media-targeting stylesheets. 2013-02-13 11:04:05 +13:00
Ingo Schommer
14a56c18e9 Merge remote-tracking branch 'origin/3.0' into 3.1
Conflicts:
	control/Director.php
2013-02-07 21:45:16 +01:00
Ingo Schommer
b381e9933d Include "media" attr for module customCSS() (fixes #8219) 2013-02-01 10:23:16 +01:00
Ingo Schommer
5f8115f4c7 BUGFIX Hard fallback to en_US.js in Requirements
Ideally we'll have region-less locales like en.js as fallbacks,
but for now this prevents the UI becoming non-operational
e.g. when both i18n::set_locale() and i18n::default_locale()
are set to 'en_NZ'.
2013-01-09 22:31:19 +01:00
Ingo Schommer
618a3d0314 Requirements acces to files with query strings (fixes #7735)
Originally authored by florian.thoma, tests added
by Ingo Schommer. Also removed query params from
file paths before calling mtime() on it.

See https://github.com/silverstripe/sapphire/pull/1023
2012-12-18 01:01:19 +01:00
Matt Lewis
af6eccea96 Fixing typo in Requirements allowing access to files requested with query strings 2012-12-18 00:53:54 +01:00
Simon Welsh
b0121b541c Add codesniffer that ensures indentation is with tabs. 2012-12-12 17:33:31 +13:00
Simon Welsh
fc5dd2994c Add codesniffer that ensures indentation is with tabs. 2012-12-12 00:12:11 +13:00
Ingo Schommer
c55c7c33f8 Merge branch '3.0'
Conflicts:
	admin/code/CMSProfileController.php
	composer.json
	tests/model/DataObjectTest.php
2012-11-22 23:51:28 +01:00
Sander van Dragt
8f89aa9171 BUG only call filemtime if file exists
Added file_exists check before calling filemtime as this results in
'filemtime(): stat failed'
2012-11-21 13:11:53 +13:00
Sean Harvey
6a868e79e1 Removing deprecated prototype/behaviour libraries 2012-11-16 11:37:56 +13:00
Ingo Schommer
56f7ce1dcf Merge remote-tracking branch 'origin/3.0'
Conflicts:
	control/Cookie.php
	control/Director.php
	control/HTTPResponse.php
	model/Database.php
	model/MySQLDatabase.php
	model/SQLQuery.php
	view/Requirements.php
	view/SSViewer.php
2012-10-03 16:16:19 +02:00
Sam Minnee
1f7fc1f76a FIX Remove instances of lines longer than 120c
The entire framework repo (with the exception of system-generated files) has been amended to respect the 120c line-length limit.  This is in preparation for the enforcement of this rule with PHP_CodeSniffer.
2012-09-30 17:18:13 +13:00
Simon Welsh
1e629f4585 Merge branch '3.0'
Conflicts:
	control/Cookie.php
	control/Director.php
	dev/Profiler.php
	view/Requirements.php
2012-09-21 14:56:56 +12:00
Ingo Schommer
e2f073f38a Method visibility according to coding conventions 2012-09-20 10:46:59 +02:00
Sean Harvey
954eb60983 BUG If combined files can't be written, fallback instantly to uncombined 2012-09-20 14:01:45 +12:00
Sam Minnee
824afffd2e Merge branch '3.0' 2012-08-23 12:39:41 +12:00
Fred Condo
3e0782267c Allow scheme-relative URLs in requirements
The Requirements class currently treats only absolute URLs as URLs, and
tries to interpret anything else as a filesystem path. This prevents
using scheme-relative URLs for requirements.

Example:
<% require javascript(//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js) %>

This forces the unfortunate choice of not using a CDN for common
scripts, always using an https absolute URL, or accepting that some
browsers will throw a security warning when viewing the site in https.

This change allows scheme-relative URLs & updates RequirementsTest.
2012-08-22 16:49:55 -07:00
Ingo Schommer
e00c87541e Merge pull request #618 from chillu/pull/deprecate-profiler
API Deprecated Profiler class, removed related debug GET params
2012-07-05 13:43:37 -07:00
Ingo Schommer
0fe515e182 API Deprecated Profiler class, removed related debug GET params
Use third party tools like XHProf instead.
Removed defunct or unnecessary debug GET parameters:
debug_profile, debug_memory, profile_trace, debug_javascript, debug_behaviour
2012-07-05 12:02:06 +02:00
Simon Welsh
9f6eeb4d0e FIX: insert javascript requirements before the first inline script.
From http://open.silverstripe.org/ticket/6648.
2012-07-01 18:34:24 +12:00