I'm looking for some advice for adding d3.js charts to Wordpress.
My client has commissioned a forceSimulation - still in progress. It is currently organised as follows:
index.html
main_javascript.js
main_css.css
global_properties.js
data_file.csv
I'm totally clueless as to whether it is possible to add the chart to her Wordpress blog and if so how to do it.... Any advice would be much appreciated.
Many thanks.
For reference, here are the WordPress docs on Using JavaScript.
Making it easy for them
From past experience (though not in WordPress), I'd try to simplify the steps your client has to take to get the visualisation working well, just in case the person doing them has little technical skill.
Hence, as far as possible, I'd combine your files into one force-viz.js:
CSS rules can be inlined by using d3.style in JS on the appropriate elements.
CSV can be inlined as a JavaScript string, parsed with d3.csvParse.
global_properties.js can just be in the same JS file.
index.html is unnecessary if you use d3.select(...).append(...) to construct the DOM tree you want, and instruct your client to write—
<div id="force-viz"></div>
—where they want the chart to appear, then d3.select that in your script.
This would mean all your client has to do is:
Place force-viz.js in a scripts/ directory.
Paste—
<div id="force-viz"></div>
<script src="scripts/force-viz.js"></script>
—into the text of any page, wherever they want the chart to appear.
Making it easy for you
If being forced to program into a single file is annoying, I recommend Browserify. It's a tool that can process a set of JavaScript files with require('whatever.js')-calls to each other, combining them appropriately into one file. With a plugin, it can even turn fs.readSync('data.csv') calls into strings containing that file's contents, which you could use with that CSV file.
That way, you could continue programming the thing as separate files, then run browserify to bundle them up for your client.
Or just do it manually, if this is a one-off project. Your call.
This is annoying, I have a wordpress theme with a css file that is all in one long line. I wonder why anyone would do that. Now I have upgraded and I need to compare the old file with the new one so that I can take in the changes. Meld, diff and vimdiff show line difference. I wonder if there is some way to auto format/indent css files so that I can compare them line by line and make some sense to a simple task.
Pass it through a prettifier before comparing.
Its like this as it shouldnt need modification. you can use Styleneat to format it to multi-line. !Very hand tool
Styleneat
I recently installed WordPress and have been slowly learning how to use it. I've tried to solve this one problem for about an hour now, and I can't seem to find the problem.
No matter what feed I add to FeedWordPress, it just doesn't parse the images correctly. (But it does, see here): http://ttgdark.com/
It's like it's completely remove the path to the image in the src tag.
Does anyone know what's going on?
go to you source code find this:
<img src="http://ttgdark.com/wp-content/themes/Webly/timthumb.php?
http://feeds.feedburner.com/~r/ThatVideogameBlog/~4/PkjR8RbxWzQ
&h=200&w=200&zc=1&q=90" class="post-thumb">
and remove this line of code
http://ttgdark.com/wp-content/themes/Webly/timthumb.php?src=
it should help.
I'm looking for some tips to clean the code which is generated by WordPress and some plug-ins, because I'm not happy with the code generated by WordPress for two reasons:
The code isn't well formatted. I know, I know... It isn't important since that the browsers don't need to "parse" a well formatted code. However, I like to keep all codes well formatted and it includes HTML code generated by me or third-part systems.
Unfortunately, some parts of the code that WordPress puts on the <head> aren't well formatted and in some cases those parts aren't really necessary. By the way, I have no idea about how to clean-up it or how to hook the function which prints that code.
Is there some way to add tabs / spaces to the code generated by WordPress without change the core files / code?
Thank you!
Overlooking the overall ambiguity of your question, the file you need to edit to fix the <head> element is header.php. You will find it in your theme's folder in wp-contents.
I have a legacy application that I needed to implement a configuration page for to change text colors, fonts, etc.
This applications output is also replicated with a PHP web application, where the fonts, colors, etc. are configured in a style sheet.
I've not worked with CSS previously.
Is there a programatic way to modify the CSS and save it without resorting to string parsing or regex?
The application is VB6, but I could write a .net tool that would do the css manipulation if that was the only way.
You don't need to edit the existing one. You could have a new one that overrides the other -- you include this one after the other in your HTML. That's what the "Cascading" means.
It looks like someone's already done a VB.NET CSS parser which is F/OSS, so you could probably adapt it to your needs if you're comfortable with the license.
http://vbcssparser.sourceforge.net/
One hack is to create a PHP script that all output is passed through, which then replaces certain parts of CSS with configurable alternatives. If you use .htaccess you can make all output go through the script.
the best way i can think of solving this problem is creating an application that will get some values ( through the URL query ) and generate the appropriate css output based on a css templates
Check this out, it uses ASP.NET and C#.
In my work with the IE control (shadocvw.dll), it has an interesting ability to let you easily manage the CSS of a page and show the effects of modified CSS on a page in realtime. I've never dealt with the details of such implementations myself, but I recommend that as a possible solution worth looking at. Seeing as pretty much everyone is on IE 6 or later nowadays, you can skip the explanations about handling those who only have IE 5,4,3 or 2 installed.
Maybe the problem's solution, which is most simple for the programmer and a user is to edit css via html form, maybe. I suppose, to create css-file, which would be "default" or "standart" for this application, and just to read it, for example, by perl script, edit in html and to write it down. Here is just the simple example.
In css-file we have string like:
border-color: #008a77;
we have to to read this string, split it up, and send to a file, which will write it down. Get something like this in Perl:
tr/ / /s;
($vari, $value) = split(/:/, _$);
# # While you read file, you can just at the time to put this into html form
echo($vari.":<input type = text name = ".$vari." value = ".$value.">");
And here it is, you've got just simple html-form-data, you just shoul overwrite your css-file with new data like this:
...
print $vari[i].": ".$value.";\n";
...
and voila - you've got programmatical way of changing css. Ofcourse, you have to make it more universal, and more close to your particular problem.
Depending on how technically oriented your CSS editors are going to be, you could do it very simply by loading the whole thing up into a TextEdit field to let them edit it - then write it back to the file.
Parsing and creating an interface for all the possibilities of CSS would be an astronomical pain. :-)