Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drupal 8 SASS Theme
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Composer
plugin
Drupal 8 SASS Theme
Commits
48c0100f
Commit
48c0100f
authored
8 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
#7
Bug fixes
parent
b3f782ef
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Handler.php
+17
-12
17 additions, 12 deletions
src/Handler.php
templates/gulpfile.js
+6
-6
6 additions, 6 deletions
templates/gulpfile.js
templates/sass/_bower-assets.scss
+5
-3
5 additions, 3 deletions
templates/sass/_bower-assets.scss
with
28 additions
and
21 deletions
src/Handler.php
+
17
−
12
View file @
48c0100f
...
...
@@ -135,7 +135,7 @@ class Handler
$dependencies
=
[];
$to
=
$this
->
buildInstallationPath
(
$this
->
options
[
'project_name'
]);
foreach
(
$this
->
options
[
'bower_assets'
]
as
$key
=>
$asset
s
)
{
foreach
(
$this
->
options
[
'bower_assets'
]
as
$key
=>
$asset
)
{
$package
=
$this
->
getPackage
(
'bower-asset/'
.
$key
);
$version
=
$package
?
$package
->
getVersion
()
:
(
isset
(
$asset
[
'version'
])
?
$asset
[
'version'
]
:
'latest'
);
if
(
$package
)
{
...
...
@@ -155,7 +155,7 @@ class Handler
$converter
=
new
Converter
(
$from
,
$to
);
foreach
([
'fonts'
,
'sass'
,
'js'
]
as
$type
)
{
if
(
isset
(
$asset
[
$type
]))
{
$this
->
options
[
'bower_assets'
][
$key
][
$type
][
'relative'
]
=
$converter
->
convert
(
$asset
[
'src'
]);
$this
->
options
[
'bower_assets'
][
$key
][
$type
][
'relative'
]
=
$converter
->
convert
(
$asset
[
$type
][
'src'
]);
}
}
}
...
...
@@ -209,20 +209,24 @@ class Handler
];
}
protected
function
twig
(
$string
)
{
if
(
empty
(
$string
))
{
return
''
;
}
protected
function
tweaks
(
$string
)
{
$string
=
str_replace
(
'THEMENAME'
,
'{{ project_name }}'
,
$string
);
$baseTheme
=
$this
->
getOption
(
'base_theme'
);
if
(
isset
(
$baseTheme
[
'sasspath'
]))
{
if
(
strpos
(
$baseTheme
[
'sasspath'
]
,
$string
)
===
0
)
{
if
(
strpos
(
$string
,
$baseTheme
[
'sasspath'
])
===
0
)
{
$string
=
'sass'
.
substr
(
$string
,
strlen
(
$baseTheme
[
'sasspath'
]));
}
}
return
$string
;
}
protected
function
twig
(
$string
)
{
if
(
empty
(
$string
))
{
return
''
;
}
$this
->
twig_loader
->
setTemplate
(
'fixed'
,
$string
);
$this
->
twig_loader
->
setTemplate
(
'fixed'
,
$this
->
tweaks
(
$string
)
)
;
return
str_replace
(
'"'
,
'"'
,
$this
->
twig
->
render
(
'fixed'
,
$this
->
getOptions
()));
}
...
...
@@ -292,19 +296,20 @@ class Handler
// Determine relative filename of destination
$relFilename
=
$file
->
getRelativePathname
();
$tweakedRelFilename
=
$this
->
tweaks
(
$relFilename
);
$filename
=
$destination
.
DIRECTORY_SEPARATOR
.
$this
->
twig
(
$relFilename
);
// Do not copy ignored files
if
(
in_array
(
$
r
elFilename
,
$this
->
getIgnoredFiles
()))
{
if
(
in_array
(
$
tweakedR
elFilename
,
$this
->
getIgnoredFiles
()))
{
continue
;
}
// Do not update custom files
if
(
$fs
->
exists
(
$filename
)
&&
in_array
(
$
r
elFilename
,
$this
->
getCustomFiles
()))
{
if
(
$fs
->
exists
(
$filename
)
&&
in_array
(
$
tweakedR
elFilename
,
$this
->
getCustomFiles
()))
{
continue
;
}
// Now create destination
if
(
in_array
(
$
r
elFilename
,
$this
->
getBinaryFiles
()))
{
if
(
in_array
(
$
tweakedR
elFilename
,
$this
->
getBinaryFiles
()))
{
$fs
->
copy
(
$file
->
getRealPath
(),
$filename
);
}
else
{
file_put_contents
(
$filename
,
$this
->
twig
(
file_get_contents
(
$file
->
getRealPath
())));
...
...
This diff is collapsed.
Click to expand it.
templates/gulpfile.js
+
6
−
6
View file @
48c0100f
...
...
@@ -22,28 +22,28 @@ var gulp = require('gulp'),
{
%
for
name
,
package
in
bower_assets
%
}
{
%
if
package
.
fonts
is
defined
%
}
// Provide fonts from {{ name }}
gulp
.
task
(
'
fonts-{{ name }}
'
,
function
()
{
gulp
.
task
(
'
fonts-{{
package.
name }}
'
,
function
()
{
return
gulp
.
src
(
'
{{ package.fonts.relative }}/**.*
'
)
.
pipe
(
gulp
.
dest
(
config
.
fontsPath
+
'
/{{ name }}
'
));
.
pipe
(
gulp
.
dest
(
config
.
fontsPath
+
'
/{{
package.
name }}
'
));
});
{
%
endif
%
}
{
%
endfor
%
}
// Provide fonts from all libraries
gulp
.
task
(
'
fonts
'
,
[{
%
for
name
,
package
in
bower_assets
%
}{
%
if
package
.
fonts
is
defined
%
}
'
fonts-{{ name }}
'
,
{
%
endif
%
}{
%
endfor
%
}]);
gulp
.
task
(
'
fonts
'
,
[{
%
for
name
,
package
in
bower_assets
%
}{
%
if
package
.
fonts
is
defined
%
}
'
fonts-{{
package.
name }}
'
,
{
%
endif
%
}{
%
endfor
%
}]);
{
%
for
name
,
package
in
bower_assets
%
}
{
%
if
package
.
js
is
defined
%
}
// Provide JS from {{ name }}
gulp
.
task
(
'
js-{{ name }}
'
,
function
()
{
gulp
.
task
(
'
js-{{
package.
name }}
'
,
function
()
{
return
gulp
.
src
(
'
{{ package.js.relative }}/**.*
'
)
.
pipe
(
gulp
.
dest
(
config
.
jsPath
+
'
/{{ name }}
'
));
.
pipe
(
gulp
.
dest
(
config
.
jsPath
+
'
/{{
package.
name }}
'
));
});
{
%
endif
%
}
{
%
endfor
%
}
// Provide JS from all libraries
gulp
.
task
(
'
js
'
,
[{
%
for
name
,
package
in
bower_assets
%
}{
%
if
package
.
js
is
defined
%
}
'
js-{{ name }}
'
,
{
%
endif
%
}{
%
endfor
%
}]);
gulp
.
task
(
'
js
'
,
[{
%
for
name
,
package
in
bower_assets
%
}{
%
if
package
.
js
is
defined
%
}
'
js-{{
package.
name }}
'
,
{
%
endif
%
}{
%
endfor
%
}]);
// Pre-process CSS
gulp
.
task
(
'
css
'
,
function
()
{
...
...
This diff is collapsed.
Click to expand it.
templates/sass/_bower-assets.scss
+
5
−
3
View file @
48c0100f
{
%
for
package
,
sass
in
bower_assets
.sass
%
}
// ============== Using {{ package }}============================
{
%
for
import
in
sass
.import
%
}
{
%
for
name
,
package
in
bower_assets
%
}
{
%
if
package
.sass
is
defined
%
}
// ============== Using {{ name }}============================
{
%
for
import
in
package
.sass.import
%
}
@import
'{{ import }}'
;
{
%
endfor
%
}
{
%
endif
%
}
{
%
endfor
%
}
// ============== Using base theme {{ base_theme.package }}============================
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment