I'm trying to set up a theme system for my project, what I have currently takes a theme file in stylus like theme\default.theme.styl that only includes variables storing colors and applies it to whatever other component style files we have included (e.g. button.styl). The idea is that I can have more than one theme file, say blue.theme.styl and red.theme.styl and gulp will output two separate css files based on the component styling. So I'd get button.blue.styl and button.red.styl as two separate files.
We want to be able to tell gulp which themes to compile through the CLI, so I set up the gulp task to take a build option of 'theme', and I'm using gulp-rename to add the theme name to the output files. But, I can't get gulp to output multiple theme files if I give it more than one theme option.
TaskManager.createTask
name: 'css'
description: 'Build the component CSS files'
options: buildOptions.concat
name: 'theme'
type: 'Array'
description: 'themes to compile'
default: 'default'
supported: ['default', 'blue', 'red']
hide: true
fn: ->
themeName = TaskManager.getArg('theme')
DEST = 'dest'
nib = require 'nib'
stream = gulp.src ["src/**/*.styl", "!src/theme/*", "!src/global/*"]
.pipe(plugins.plumber(errorHandler: TaskManager.error))
.pipe(plugins.stylus
use: [
nib()
]
include: [
'src/util'
'src/global'
'src/theme'
]
import: themeName.map (val) -> "#{val}.theme"
)
.pipe(rename (path) ->
path.extname = ".#{themeName}.css"
undefined
)
.pipe(plugins.filelog 'css')
.pipe(gulp.dest 'dest')
This works as expected if I give it only one option at build so that gulp --theme='blue' will output button.blue.css with the appropriate theme styling. But if I give it more than one option like gulp --theme='blue,red' I get files named button.blue,red.css that have whichever theme's file variables were included last as the colors that were applied.
Makes sense from what I understand of gulp and gulp-rename, but I want to be able to split the pipe at this point to get two different files. I don't want to actually copy the files into a new directory, and solutions that manually create multiple streams to concatenate are not a satisfactory since I might only have one theme or there might be twelve, and I don't want to have to edit the build file to add new themes. So how can I get multiple files compiled separately out of one stream?
Turns out it works to just return an array of streams:
TaskManager.createTask
name: 'css'
description: 'Build the component CSS files'
options: buildOptions.concat
name: 'theme'
type: 'Array'
description: 'themes to compile'
default: 'default'
supported: ['default', 'blue', 'red']
hide: true
fn: ->
themes = TaskManager.getArg('theme')
DEST = 'dest/components'
nib = require 'nib'
stream = []
createTask = (themeName) ->
return gulp.src ["src/**/*.styl", "!src/theme/*", "!src/global/*"]
.pipe(plugins.plumber(errorHandler: TaskManager.error))
.pipe(plugins.stylus
use: [
nib()
]
include: [
'src/util'
'src/global'
'src/theme'
]
import: "#{themeName}.theme"
)
.pipe(rename (path) ->
path.extname = ".#{themeName}.css"
undefined
)
.pipe(plugins.filelog 'css')
.pipe(gulp.dest 'dest')
themes.map (name) ->
task = createTask name
stream.push task
return stream
Related
I'm using yii2 in local server but I face error like this
Undefined class constant 'TYPE_LIST'
...
...
'type' => DepDrop::TYPE_LIST
...
...
So, I check vendor/kartik-v/yii2-widget-depdrop/DepDrop.php
There is no const TYPE_LIST but when I check thus file in production server there is const TYPE_LIST = 3
Package version is yii2-widget-depdrop 1.0.4 for both server, production and local
But when I check official package repo https://github.com/kartik-v/yii2-widget-depdrop/blob/master/DepDrop.php
There is no const TYPE_LIST
How I can fix this error?
Thanks in advance
You are looking to the wrong component
for depdrop the type is
type: int the type of dropdown list to be generated. Should be one of
the following values:
1 or DepDrop::TYPE_DEFAULT: render a default HTML select using
\yii\helpers\Html::dropDownList.
2 or DepDrop::TYPE_SELECT2: render advanced Select2 using
\kartik\widgets\Select2 widget.
If not set the type will default to 1 or DepDrop::TYPE_DEFAULT.
for sortable type is
The Sortable widget allows you to configure the following properties:
type: string, the type of the sortable widget. Defaults to
Sortable::TYPE_LIST. Should be one of
Sortable::TYPE_LIST or list
Sortable::TYPE_GRID or grid
http://demos.krajee.com/sortable
http://demos.krajee.com/widget-details/depdrop
I have an Rmd file that renders into html correctly almost all of the time. However, it does not render correctly when pandoc (used in the rendering process) finds 4 spaces in the html and at that point, interprets that I want to render a markdown code snippet instead of html.
I have been told that I can turn off the markdown_in_html_blocks feature by doing something like this:
pandoc -f markdown-markdown_in_html_blocks.
I have tried calling pandoc directly rather than it being called implicitly by
rmarkdown::render()
but couldn't get that syntax to work and being able to specify this option (-markdown_in_html_blocks) directly as I call render() is preferred. Here is the latest of I have tried without success:
Base case: works but HTML output file is malformed / has a code block instead of the data that I want to display in the table.
render("reports/Pacing.Rmd")
Attempted fix: not working
rmdFmt <- rmarkdown_format("-markdown_in_html_blocks")
pandocOpts <- pandoc_options(to = "html", from = rmdFmt)
render("reports/Pacing.Rmd",output_format = "html_document",output_file = NULL, output_dir = NULL, output_options = pandocOpts)
Error message: Error in (function (toc = FALSE, toc_depth = 3, toc_float = FALSE, number_sections = FALSE, :
argument 1 matches multiple formal arguments
I have tried other syntax to express that I want to turn off markdown_in_html_blocks but no luck.
Given the following document test.Rmd...
---
title: Test
output: html_document
---
<table>
<tr>
<td>*one*</td>
<td>[a link](https://google.com)</td>
</tr>
</table>
...you can disable the markdown_in_html_blocks extension via
rmarkdown::render("test.Rmd",
output_options = list(md_extensions = "-markdown_in_html_blocks"))
md_extensions is one of the arguments that can be passed to rmarkdown::html_document (see ?rmarkdown::html_document for other arguments).
That seems to be an open issue, but a simpler way to turn off/on such a feature is to directly update the YAML in Rmd file. This should work in your case:
output:
html_document:
pandoc_args: [
"-f", "markdown-markdown_in_html_blocks"
]
I am looking to import a lot of filenames into a graph database, using Neo4j. The data is from an external source and available in CSV file. I'd like to create a tree structure from the data, so that I can easily 'navigate' the structure in queries later on (i.e. find all files underneath a certain directory, all file that occur in multiple directories etc.).
So, given the example input:
/foo/bar/example.txt
/bar/baz/another.csv
/example.txt
/foo/bar/onemore.txt
I'd like the create the following graph:
( / ) <-[:in]- ( foo ) <-[:in]- ( bar ) <-[:in]- ( example.txt )
<-[:in]- ( onemore.txt )
<-[:in]- ( bar ) <-[:in]- ( baz ) <-[:in]- ( another.csv )
<-[:in]- ( example.txt )
(where each node label is actually an attribute, e.g. path:).
I've been able to achieve the desired effect when using a fixed number of directory levels; for example when each file is at three levels deep, I could create a CSV file with 4 columns:
dir_a,dir_b,dir_c,file
foo,bar,baz,example.txt
foo,bar,ban,example.csv
foo,bar,baz,another.txt
And import it using a cypher query:
LOAD CSV WITH HEADERS FROM "file:///sample.csv" AS row
MERGE (dir_a:Path {name: row.dir_a})
MERGE (dir_b:Path {name: row.dir_b}) <-[:in]- (dir_a)
MERGE (dir_c:Path {name: row.dir_c}) <-[:in]- (dir_b)
MERGE (:Path {name: row.file}) <-[:in]- (dir_c)
But I'd like to have a general solution that works for any level of sub-directories (and combinations of levels in one dataset). Note that I am able to pre-process my input if necessary, so I can create any desirable structure in the input CSV file.
I've looked at gists or plugins, but cannot seem to find anything that works. I think/hope that I should be able to do something with the split() function, i.e. use split('/',row.path) to get a list of path elements, but I do not know how to process this list into a chain of MERGE operations.
Here is a first cut at something more generalized.
The premise is that you can split the fully qualified path into components and then use each component of it to split the path so you can struct the fully qualified path for each individual component of the larger path. Use this as the key to merge items on and set the individual component after they are merged. In the case that something is not the root level then find the parent of an individual component and create the relationship back to it. This will break down if there are duplicate component names in a fully qualified path.
First, i started by creating a uniqueness constraint on fq_path
create constraint on (c:Component) assert c.fq_path is unique;
Here is the load statement.
load csv from 'file:///path.csv' as line
with line[0] as line, split(line[0],'/') as path_components
unwind range(0, size(path_components)-1) as idx
with case
when idx = 0 then '/'
else
path_components[idx]
end as component
, case
when idx = 0 then '/'
else
split(line, path_components[idx])[0] + path_components[idx]
end as fq_path
, case
when idx = 0 then
null
when idx = 1 then
'/'
else
substring(split(line, path_components[idx])[0],0,size(split(line, path_components[idx])[0])-1)
end as parent
, case
when idx = 0 then
[]
else
[1]
end as find_parent
merge (new_comp:Component {fq_path: fq_path})
set new_comp.name = component
foreach ( y in find_parent |
merge (theparent:Component {fq_path: parent} )
merge (theparent)<-[:IN]-(new_comp)
)
return *
If you want to differentiate between files and folders here are a few queries you can run afterwards to set another label on the respective nodes.
Find the files and set them as File
// find the last Components in a tree (no inbound IN)
// and set them as Files
match (c:Component)
where not (c)<-[:IN]-(:Component)
set c:File
return c
Find the folders and set them as Folder
// find all Components with an inbound IN
// and set them as Folders
match (c:Component)
where (c)<-[:IN]-(:Component)
set c:Folder
return c
I'm using jade templates for my templating system, passing a json file in as the jade locals via my gulpfile.js, but I can't seem to deep dive into the json. I feel like I'm overlooking something basic, but can't find an example online anywhere.
gulpfile.js:
Passes the json file into jade
gulp.task('html', function() {
gulp.src('./markup/*.jade')
.pipe(jade({
pretty: true,
locals: JSON.parse( fs.readFileSync('./markup/data/website_data.json', { encoding: 'utf8' }) )
}).on('error', gutil.log))
.pipe(gulp.dest('../'))
});
Then in my jade, I just pass the locals into a variable for the sake of readability.
- var employees = locals
And I can loop through json that is one level deep:
jade:
for employee in employees
if employee.Tier === 'Founder'
li
button(data-bio="#{employee.LastName.toLowerCase()}")
img(src="/public/img/employees/#{employee.FirstName.toLowerCase()}-#{employee.LastName.toLowerCase()}.jpg", alt="#{employee.FirstName} #{employee.LastName} | #{employee.Title}")
strong #{employee.FirstName} #{employee.LastName}
| #{employee.Title}
json:
[
{
"FirstName":"John",
"LastName":"Doe",
"Title":"Strategist",
"Tier":"Founder",
"Description":"",
"Email":"",
"Links":""
},
...
]
But that has only worked for me if the items I loop through are in the root, as soon as I make the json one level deeper, I can't get it to work based on the key. I want to make the json deeper so I can different sections of a site in it instead of just the employees.
[{
"employees": [
{
"FirstName":"Jason",
"LastName":"Bellinger",
"Title":"Lorem Ipsum",
"Tier":"",
"Description":"",
"Email":"",
"Links":""
},
...
]
}]
I tried a few different approaches to to dig into the json and have failed thus far.
ATTEMPT 1: adjust the variable call and keep the same loop
- var employees = locals.employees
And I get 'Cannot read property 'length' of undefined' in the terminal running $gulp watch
Also try:
- var employees = locals['employees']
to the same result.
ATTEMPT 2: don't use the var and call locals directly in my loop
for employee in locals.employees
AND
for employee in locals["employees"]
And I end up with the same error.
ATTEMPT 3:
keep the var and adjust the loop
- var employees = locals
...
for employee in employees
li #{employee.LastName}
Then I don't get an error in Terminal, but I don't get any content. It produces one empty li.
So then, I try to go a layer deeper in the loop with:
for employee in employees[0]
li #{employee.LastName}
AND
for employee in employees['employees']
li #{employee.LastName}
AND I still get no error and one empty li
I've parsed enough json in my day and jade seems simple enough, I have to be overlooking something basic. Someone please humble me.
I also dabbled in gulp-data, but I'm getting the data into jade with my approach, so I think it's my approach in jade...
You need to access the array inside you locals variable.
The length of local = 1 and that is the entire array of employees.
You'll need to set employees = to the array inside of the locals variable with:
"- var employees = locals[0].employees"
I knew it was something basic. I reverted everything back to the original setup and changed the var and this is working.
- var employees = locals[0]['employees']
Truth be told, I thought I already tried this, but went back and tried again...
I will try to be very succinct with my problem. I have the node Person that I loaded using a .csv file and I have another .csv file to be loaded - person_speaks_language_0.csv
(got this header: idPerson|languagePSL )
How can I relate this? How can I create this relationship?
Grabbing another example, that is very similar to the previous one, and that I can't solve. I have the Comment node loaded in Neo4j an I need to load another .csv file, that file is - comment_replyOf_comment_0.csv
(got his header: idComment|idComment)
How can I load this file? How can I connect a relation that goes "in and out" from the same node - that connects the same node?
For the first example. there is 2 options.
If you want Language to be a separate node, try this cypher:
LOAD CSV FROM 'person_speaks_language_0.csv' AS line
MATCH (p:Person)
WHERE p.id=line[0]
MERGE (p)-[r:Speaks]->(l:Language { name: line[1])})
RETURN p, l, r
Or, probably, better option
LOAD CSV FROM 'person_speaks_language_0.csv' AS line
MERGE (p:Person { id:line[0] })-[r:Speaks]->(l:Language { name: line[1]) })
RETURN p, l, r
If you want Language to be a property, try this:
LOAD CSV FROM 'person_speaks_language_0.csv' AS line
MERGE (p { id:line[0], language:line[1] })
RETURN p
The RETURN statement is optional and you don't want to include it for a big csv files (although it could be useful for debug).
For the second example, try this:
LOAD CSV FROM 'comment_replyOf_comment_0.csv' AS line
MERGE (c1:Comment { id:line[0] })-[r:Commented]->(c2:Comment { id:line[1]) })
RETURN c1, r, c2