W3C Jigsaw CSS-Validator.jar: how to pass CSS as parameter (not using file:file.css)? - css

I'm running a local version of W3C Jigsaw CSS-Validator, and I know that I can feed it a file path using java -jar css-validator.jar --output=soap12 file:file.css.
But what I'd much rather do is sending the CSS directly as an option, something like this:
java -jar css-validator.jar --output=soap12 --text="body { color: red }"
This seems to work, but the output doesn't show any validation errors:
$ java -jar lib/css-validator/css-validator.jar --text="body{color:red;}"
{vextwarning=false, output=text, lang=en, warning=2, medium=all, profile=css3}
$ java -jar lib/css-validator/css-validator.jar --text="unknowntag{unknownattribute:red;}"
{vextwarning=false, output=text, lang=en, warning=2, medium=all, profile=css3}
What am I doing wrong here?

Related

Atom opens a new file called ATOM_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT=false

Whenever I start Atom it opens two files, one called:
ATOM_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT=false
And the other one:
/usr/bin/atom
It's really annoying and I don't understand how to fix it. From what I understand it is some sort of environment configuration bug, but I can't find what's causing it.
I am going to make several assumptions. You are running on Ubuntu and you've installed Atom via Snap.
If these assumptions are correct the cause of the issue is a misconfigured application menu item from the Snap package author.
To fix it you just need to run this command:
sudo sed -i 's/Exec=env BAMF_DESKTOP_FILE_HINT=\/var\/lib\/snapd\/desktop\/applications\/atom_atom.desktop \/snap\/bin\/atom ATOM_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT=false \/usr\/bin\/atom %F/Exec=env BAMF_DESKTOP_FILE_HINT=\/var\/lib\/snapd\/desktop\/applications\/atom_atom.desktop ATOM_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT=false \/snap\/bin\/atom %F/' /var/lib/snapd/desktop/applications/atom_atom.desktop
TL;DR {
Here is a detailed explanation of what's causing the issue and what the command above does. It may be useful if the file has been changed since the answer was written.
The actual cause for the bug is that this menu item file:
/var/lib/snapd/desktop/applications/atom_atom.desktop
It has a typo in it and what should be environment variables are set after calling
the atom executable, resulting in Atom treating it as arguments in the form of
files that it should open.
# ▼ Executable ▼ Not an environment variable ▼ Not an executable
Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/atom_atom.desktop /snap/bin/atom ATOM_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT=false /usr/bin/atom %F
It should instead be:
# ▼ Environment variable ▼ Environment variable ▼ Executable
Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/atom_atom.desktop ATOM_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT=false /snap/bin/atom %F
The solution above uses sed to search and replace the file and fix the issue.
}
NOTE: The command will work until the Snap author updates the menu item file (.desktop) when hopefully the issue would have been resolved.

lesscss-maven-plugin from biz.gabrys.maven.plugins : using <compilerOptions>

I succeed to compile less to css. But i cannot figure out how pass Compiler Options to the compiler in order to generate the mapping source file too.
From the doc, it should be a thing like :
<compilerOptions>
<compilerOption>dumpLineNumbers:all</compilerOption>
</compilerOptions>
But i get :
[INFO] Compiling 1 source to C:\workspaces\neon-dev\project\src\main\webapp\css
lesscss: couldn't open file dumpLineNumbers:all
Any hints ?
You have to pass options in command line style, e.g.:
<compilerOptions>
<compilerOption>--line-numbers=all</compilerOption>
</compilerOptions>
See all available options: http://lesscss.org/usage/index.html#command-line-usage-options.
Version 2.0 of the biz.gabrys.maven.plugins:lesscss-maven-plugin will have a simpler configuration e.g.:
<options>
<lineNumbers>all</lineNumbers>
</options>

How can i detect user agent or browser in google closure compiler?

My Complier file is like that
cd /d %~dp0
java -jar ../../../../file/css-compiler.jar --pretty-print ^
--allowed-unrecognized-property -khtml-opacity ^
../source/abc.gss ^
> ../abc.css
pause
when i am adding following line in order to detect IE Compiler giving error
<!--[if IE]>
.vidizmo-widget .result-summary {width:0px;}
<![endif]-->
then I write following line
#if (BROWSER_IE) {
.vidizmo-widget .result-summary {width:0px;}
}#else{
.vidizmo-widget .result-summary {width:30%;}
}
it doesn't generate error but i didn't find any impact on IE.
how can i detect browser using google css compiler ?
Yes, your second approach is correct
#if (BROWSER_IE) {
.vidizmo-widget .result-summary {width:0px;}
}#else{
.vidizmo-widget .result-summary {width:30%;}
}
Then you need to compile the closure template (gss) for every browser (more precisely: for every flag) you defined:
java -jar closure-stylesheets.jar example.gss > example.css
java -jar closure-stylesheets.jar --define BROWSER_IE example.gss > example.ie.css
java -jar closure-stylesheets.jar --define BROWSER_FF2 example.gss > example.ff2.css
…
Then, you need to load the appropriate css; and this is easy:
either with JavScript
or with a server-side serving based on User-Agent

Does sbt have something like gradle's processResources task with ReplaceTokens support?

We are moving into Scala/SBT from a Java/Gradle stack. Our gradle builds were leveraging a task called processResources and some Ant filter thing named ReplaceTokens to dynamically replace tokens in a checked-in .properties file without actually changing the .properties file (just changing the output). The gradle task looks like:
processResources {
def whoami = System.getProperty( 'user.name' );
def hostname = InetAddress.getLocalHost().getHostName()
def buildTimestamp = new Date().format('yyyy-MM-dd HH:mm:ss z')
filter ReplaceTokens, tokens: [
"buildsig.version" : project.version,
"buildsig.classifier" : project.classifier,
"buildsig.timestamp" : buildTimestamp,
"buildsig.user" : whoami,
"buildsig.system" : hostname,
"buildsig.tag" : buildTag
]
}
This task locates all the template files in the src/main/resources directory, performs the requisite substitutions and outputs the results at build/resources/main. In other words it transforms src/main/resources/buildsig.properties from...
buildsig.version=#buildsig.version#
buildsig.classifier=#buildsig.classifier#
buildsig.timestamp=#buildsig.timestamp#
buildsig.user=#buildsig.user#
buildsig.system=#buildsig.system#
buildsig.tag=#buildsig.tag#
...to build/resources/main/buildsig.properties...
buildsig.version=1.6.5
buildsig.classifier=RELEASE
buildsig.timestamp=2013-05-06 09:46:52 PDT
buildsig.user=jenkins
buildsig.system=bobk-mbp.local
buildsig.tag=dev
Which, ultimately, finds its way into the WAR file at WEB-INF/classes/buildsig.properties. This works like a champ to record build specific information in a Properties file which gets loaded from the classpath at runtime.
What do I do in SBT to get something like this done? I'm new to Scala / SBT so please forgive me if this seems a stupid question. At the end of the day what I need is a means of pulling some information from the environment on which I build and placing that information into a properties file that is classpath loadable at runtime. Any insights you can give to help me get this done are greatly appreciated.
The sbt-buildinfo is a good option. The README shows an example of how to define custom mappings and mappings that should run on each compile. In addition to the straightforward addition of normal settings like version shown there, you want a section like this:
buildInfoKeys ++= Seq[BuildInfoKey](
"hostname" -> java.net.InetAddress.getLocalHost().getHostName(),
"whoami" -> System.getProperty("user.name"),
BuildInfoKey.action("buildTimestamp") {
java.text.DateFormat.getDateTimeInstance.format(new java.util.Date())
}
)
Would the following be what you're looking for:
sbt-editsource: An SBT plugin for editing files
sbt-editsource is a text substitution plugin for SBT 0.11.x and
greater. In a way, it’s a poor man’s sed(1), for SBT. It provides the
ability to apply line-by-line substitutions to a source text file,
producing an edited output file. It supports two kinds of edits:
Variable substitution, where ${var} is replaced by a value. sed-like
regular expression substitution.
This is from Community Plugins.

cmake command syntax question

I require the syntax of a CMAKE macro that generates .cc and .h files from a tool like lex/yacc.
Could someone please show me the syntax for the following contrived example:
say I have a file y.cc that depends on x.cc and x.h, the two files mentioned are generated by tool z_tool from file x.z. What would the syntax for this be ?
For this example assume that y.cc will be turned into a static library, and as I am quite new to CMAKE the full CMakellist.txt for this contrived example would be very helpful.I'm looking for a portable solution as the tools I am using are available on windows as well as UNIX variants.
Rather than give you the answer to a contrived example, here is the way you would generate an executable using flex and bison
find_package(BISON)
find_package(FLEX)
BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cc)
FLEX_TARGET(MyScanner lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.cc)
ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(Foo
Foo.cc
${BISON_MyParser_OUTPUTS}
${FLEX_MyScanner_OUTPUTS})
target_link_libraries(Foo ${FLEX_LIBRARIES} ${BISON_LIBRARIES})
The CMake find packages for bison/flex are included in the default installation, so this is cross platform.
In general to create an output that will later be used as an input you can use the add_custom_command function. If you use an output from the custom command as an input to a library or executable, then CMake knows to run your custom command before compiling the sources for the library/executable target.
The following line has Typo
FLEX_TARGET(MyScanner lexer.l ${CMAKE_CURRENT_BIANRY_DIR}/lexer.cc)
BIANRY should be spelled as BINARY.
Note: CMake Documentation has this typo there as well. ( in 2.8.0, this is fixed in 2.8.10 documentation)..
/* To make it work on my Mac with Lion. I changed the files names to y.tab.c and lex.yy.c, which are the output files if you run lex lex.l and yacc -D yacc.y from command line. See below.
*/
cmake_minimum_required(VERSION 2.8)
project (LexYacc)
find_package(BISON)
find_package(FLEX)
BISON_TARGET(MyParser yacc.y ${CMAKE_CURRENT_BINARY_DIR}/y.tab.c)
FLEX_TARGET(MyScanner lex.l ${CMAKE_CURRENT_BINARY_DIR}/lex.yy.c)
ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(LexYacc
${BISON_MyParser_OUTPUTS}
${FLEX_MyScanner_OUTPUTS})
target_link_libraries(LexYacc ${FLEX_LIBRARIES} ${BISON_LIBRARIES})

Resources