Maintenance

Needed: (on HM)

  1. check on zfacts email help & steven should work, but not everything.
  2. find link to node/161.html page and correct
  3. control Watchdog
  4. control caches in db
  5. compare HotDrupal
  6. CDN for speed. Ameer Ghanie gameer@netdna.com at MaxCDN

Maintenance Checklist:

  • After a re-install or upgraded:
  1. ini_set('session.gc_maxlifetime', 100000);  (in sites/default/settings.php. 1-day login sessions)
  2.  

 

 

Theme & Setting

  • The Theme "z-Framework," is set as the default under "Appearance."
  • It is a subtheme of Framework, and is found in:  sites/all/themes/zframe.
  • The "! Notes" file in the folder tells some about how z-Framework has been tweaked, and there are comments in some zframe files.
  • Here's more info organized by looking at the page
  • .
  • Page layout
    • Column width is in zframe/styles.css [styles]. If a column is used, it appears.
    • Coumn widths = 220 0 525 20 175, with 10px of padding on the outside. Total width=960.
    • All the formatting is also in styles.
    • $site_name and $site_slogan are set by drupal / Configuration / System
    • favicon, logo, and header_image, are located in zframe/
      • header_image is named and controlled in zframe/styles.css in the Header section.
    • Main menu, is turned off in zframe/page.tpl.php. (It would run across the bottom of the header.)
  • Blocks
    • Structure > blocks
    • The Google Ad blocks contain PHP to turn them off when editing.
    • The Search form Block has two sets of permissions (dumb and hard to control).
      • Set #1:  People > Permissions-tab > use search, OR, Modules > Search-Permissions > use search
      • Set #2:  Blocks > Search form > Configure > Roles (near bottom)
      • Anonymous users need to have permission both places
  • Front page
    • The Read More footers have been turned off with jQuery in the About page. They looked funny and took too much space.
    • The top entry is from the about page, and it's header has been turned off with jQuery in that page.
  1. Theme Tweaks
    • /sites/all/themes/zframe     a subtheme of framework
    • zframe.info        creates the subtheme
    • style.css            contains most tweaks
    • my-jquery.js      contains js for Magic Blocks and popNotes
    • html.tpl.php       contains home page html-title
    • logo.png,  favicon.ico
    • reset                  essential, perhaps because it over-rides the updated reset
    • page.tpl.php     preventserror in top menu appearance -- why? blocks update?
    • The Horizontal Rule <hr /> gets a wide bottom margine.

 

 

Backup & Update

Move and Duplicate sites with unix:

 

To transfer files:
scp local-file-name carbonomics.org:new-file-name
This is a "Get" version that worked:   scp carbonom@carbonomics.org:file ./

The command that duplicated old zFacts:  time wget --limit-rate=600k -m -k -K -E http://zfacts.com -o log

Backup with Drupal

  1. How:   Configuration  /  System  / Backup & Migrate  or click here
  2. What:   This just backs up the MySQL DB (to the drupal server) in 
  3. Where:   /home/carbonom/public_html/private/backup_migrate/manual

Backup with C-Panel

  1. Start C-Panel ( see Google spreadsheet "Computer Notes" tab=Web Sites)
  2. Choose:  Files / Backups:
    1. Backup Home Directory (all Drupal except MySql)  160MB, Sept. 2011
    2. Download to:  MyDocuments  /  ! Web  /  Drupal Backup  /  Date
    3. Backup MySQL dbase.  Very small

Update Modules

  1. Click:   Modules / Update tab / Check the boxes /  "Download these updates" button
  2. Configuration / Development / Performance / Clear Cache    click here

Update Drupal Core (minor, e.g. 7.5 to 7.7)

  1. Download the tar.gz file
  2. upload it to Home/carbonom  and unpack it with the C-panel / Files / Extract to  publich_html.   It will land in it's own folder.
  3. Make a drupal_old folder and copy .htaccess and the six drupal folders (but not /sites).
  4. .htaccess has been modified a lot, but setting.php in sites/default/ has not been modified.
  5. Some instruction in google sheet: ComputerNotes / Drupal on how to get through setup if necessary.
  6. Overview of what's needed:
    1. Replace the drupal code folders: includes, mis, modules, profiles, scripts, themes.
    2. Replace the files in public_html except for .htaccess
    3. Replace /sites/default/default.setting.php   (this is needed)
    4. Don't replace the rest of the stuff in /sites
    5. Perhaps go through drupal set up and tell in the MySQL dbase name, owner, passwd

CK Editor

From Dan: file upload capabilities, and thought that I would pay $59 for the CKFinder file browser. But I had a lot of trouble getting it to work, and in searching for solutions to my difficulties, came across others with the same difficulties who solved them by using "KCFinder"

Double Quotes Bug:  They turn into "\&quot; in CKeditor. This is caused by PHP. See Drupal Installing

Installation:

  1. Do not install the Drupal's WysiWig module, only the Drupal ckEditor Module.
  2. Install the ckEditor drupal modual using the drupal modual installer (http://drupal.org/project/ckeditor), and read the README file.
  3. Put the files from http://ckeditor.com/download in all    /sites/all/libraries/ckeditor/
  4. Modify Toolbars for Filtered and Full HTML: ( http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Toolbar )
    1. Configuration > CKEditor > edit > Editor Appearance 
    2. Add:  ['DrupalPageBreak']  (the Drupal Teaser Break is already there.)
    3. Add:  ['mediaembed','IMCE'] (since the Plugins / IMCE check box does not seem to work.)
    4. Add:  Styles:   ['Styles','Format','Font','FontSize'],
  5. Other configurations:
    1. Configuration > CKEditor > edit > Advanced Options
    2. Spell checker is turned off (good--it times out in 30 days) (this might be due to the ABC SCAYT button in the toolbar. 
    3. Now at this " CKEDITOR.config.disableNativeSpellChecker = false; " to the bottom of   modules/ckeditor/ckeditor.config.js
    4. Some JS configuration and info about ckeditor.config.js is here.
  6. Add 'DrupalPageBreak'  and 'DrupalBreak' if missing.   Configure > CKEditor > Appearance > edit.  But DrupalPageBreak Need Paging module, which is not in 7 yet (maybe silly).
  7. Uncomment 2 pair of lines at bottom of ckeditor/ckeditor.config.js   for  mediaembed and IMCE. Then  Configure > CKEditor > Appearance > edit  ['mediaembed','IMCE']

Customizing:

  • sites/all/modules/ckeditor/ckeditor.styles.js
    • This file defines custom styles used with drop-down styles button while editing.
  • sites/all/modules/ckeditor/ckeditor.config.js
    • This file defines classes and styles that will be used in the CKEdidtor window to make it more wysiwig.
    • E.g. define CK style "DateLine" to apply class "dateline." Then define class .dateline in (1) themes/zframe/style.css and in (2) ckeditor.config.js
    • #1 styles the date for drupal users and #2 styles it the same in the CK editor window.
  • Alternative:  instead of modules/ckeditor/ckeditor.config.js, use  libraries/ckeditor/contents.css
    • I used this instead because I can cut and paste into it without any modification.
  •  
  • Paragraphs fully justified
  • Titles not indented

Full Toolbar:

 

[
    ['Source'],
    ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker', 'Scayt'],
    ['Undo','Redo','Find','Replace','-','SelectAll','RemoveFormat'],
    ['Image','Media','Flash','Table','HorizontalRule','Smiley','SpecialChar'],
    '/',
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
    ['DrupalPageBreak'],
    ['mediaembed','IMCE'],
    ['Link','Unlink','Anchor'],
    ['DrupalBreak'],
    '/',
    ['Styles','Format','Font','FontSize'],
    ['TextColor','BGColor'],
    ['Maximize', 'ShowBlocks']
]
 

Test CKEditor Styles

this
si
a fparjf
and break

Book Making

To Re-Organize a Book:

Login  /  Content  /  Click the "Books" tab  /  Click on "edit order & titles" 

To Re-Order the Books:

Select a book and then select its "Outine tab:

To Re-Order the Main-Menue (navigation bar)

Structure / Menus / Main Menue


To leave short titles in the TOC, but have long titles on the pages, I added a field to all of the content types: Node-Page (visible) Title, field_npagetitle.

Then I hacked   themes/bartik/templates/page.tpl.php  as follows:

<?php if (key($node->field_npagetitle)=='und') print $node->field_npagetitle['und'][0]['safe_value']; // <======= HACK 
else print $title ?>
 
This is the page I got the clue from: http://drupal.org/node/49768   There must be a better way.

Possibly helpful contributed modules:

For the html page title:  http://drupal.org/project/page_title  7.x-2.4-beta1, Nov, 2010. 55000 use it (1,400 D-7). 

For the html page title:  http://drupal.org/project/simple_page_title,  I think you can write your own. Not in  D-7, only 33 users.

 

File Storage

  • Images & IMCE
  • Configure IMCE -- #1 specify where the image files ae
    • <root> seems to be any of the three standard "files" folders all/files, default/files or [multiuser]/files
  • How to include images
  • Drupal Image Fields
    • Their problem is they give you almost no control over where the image goes.

 

  • File-System Standards
    • Folders:  ( <root> = sites/all/ files )
      • Documents:  /doc
      • Images: /image
    • Subfolders for doc and image = one for each "book" -- debt, econ, climate, energy, politics, war
    • General (zFacts / About / Iinfo / Free) files go directly into /doc or /image
    • File names:
      • Graphs, etc.,  that get updated don't include a date in the name
      • Docs start with creation date, e.g. 2011-09

 

Blogs & Users

Users: "User 1" owns the sight. Be careful. See who is user 1 at URL user/1

Don't blog as user 1 if you are ever going to let someone else help write the blog under your name.

User zFacts owns the only active blog (for now). It's listed as  zFacts Bog under "Don't Miss."

Supposedly the Bog module will compile all the user blogs into one big blog.

Blogs: Each user has one blog with all posts at user/whoever.

  • Each post has it's own page.
  • Each post can be promoted to the front page, or not.

 

Programming

Clearing Caches:

  1. Ctrl R, or maybe Sht-Ctrl-reload
  2. Open a new Incognito window
  3. in Chrome: Tools / Clear Browsing Data -- Shft-Ctrl-Del
  4. Clear Caches in Drupal

Widgets / Gizmos

  • See "Magic Content" under "About / Help Editing"

Making Pages to Teach Vistors How to Install Gizmos.

  • To display code for copying, first make a table cell
  • Style it in Editing Source Mode with:  style="font-size: 12px; background-color:#eeeeee; border:1px solid black;"
  • Return to normal editing moder
  • Copy code in using the "Paste as plain text" Icon.
  • Select the text and Style it "Computer Code."

CSS & PHP

CSS

  • Inline CSS can be used in an HTML tag:  <p style="font-size: 16pt;" >
  • Embedded CSS can be used in the head of an HTML file (for the whole file, like this:
    • <style type="text/CSS">
    • p {color:blue;}      /* This will turn all paragraphs blue. (This comment is OK in CSS.) */
    • </style>
  • Linked CSS is used for themes, and the CSS in in  file_name.css  files.
  • Link from an HTML file like so:  <link href="style_sheet.css" type="text/css" />
  • Link from a CSS file like so:  @import "file.css";
  • CSS "statements" look like this:

what-to-style { some styles; }
what-else-to-style {
  style 1;
  style 2;
}

  • What to Style can be defined in may ways. Some examples
  • p     All paragraphs
  • a     All anchors
  • p, em     All paragraphs and all emphasize tags
  • p em      All emphasize tags that occur within paragraph tags (children, grand-children, etc.)
  • p>em      All em tags that are childred (not grandchildren, etc) of paragraph tags
  • p * em      All em tags that are grand-, or great-grand-children, etc. of pragraph tags (but not children).
  • h1 + p       Paragraph tags that directly follow h1 tags.
  • .myclass     All tags that contain class="myclass"  (note the initial period).
  • p.myclass     All paragraphs with class="myclass"
  • p.mine.yours     All paragraphs with class="mine yours & possibly others"
  • #myid        The one and only tag that contains  id="myid"
  • a:link    All inactive links (link is a pseudo class, and you don't have to use class= )
    • a:visited, a:hover, a:active  --  these work as expected.
  • p:first-child     The first-child tag inside a pragraph
  • input:focus      An input field of a form that has focus
  • Some Styles
  • Most of these are easily understood from reading the theme CSS files you need to modify.
  • color: #00F; color: #1234EF; color:blue;
  • margin: 0 10px 0 20px;   (top, right, bottom, left)
  • border: 1px solid #ccc; 
  • font-family: Lucida Grande, Verdana, Arial, sans-serif;
  • font-size: 1.5em; line-height: 2em;
  • text-align: justify;   Or: left, center, right
  • Units: must go right next to the numbers (no space)
  • Units: in (1), cm (2.54), mm (25.4), pt (72), pc (6), px (72) --- (number of units per inch)
  • Units: em (the height of the character box), ex (the height of a lowercase x), %
  •  

jQuery, JS, PHP, unix

jQuery for mobile.

jQuery sites:  jQuery.com   jQuery4u.com   W3schools   jQuery Tools

JS:  Mozilla

  • Use Text format: PHP code for either PHP or JS
  • They both just work, but jQuery is prefered to JS.
  • In case of an error, the page (node) may only show an error message. To edit node 89:  www.site.com/89/edit

  PHP Snippets (and some about JS snippets):  http://drupal.org/node/337959 JavaScript in Drupal: http://drupal.org/node/121997 more on drupal_add_js() a php function to add JS to the head. JS in a block seems to just work. A JS-CSS Injection module:  http://drupal.org/project/customcssjs (not for 7 yet) A JS Injection module:  http://drupal.org/project/js_injector  (not for 7 yet)

How to program the unix BASH

 

jQuery Examples

Paragraph one.

Paragraph two

Paragraph three

[#2]

JavaScript

Unfortunately the Google Analytics method (below) avoids delaying image loads etc. But it still delays window- and body-loads and anything that depends on them. However, if the gizmo script is just completely missing (and not just slow) it does not delay anything. I think this seems good enough.


<script type="text/javascript">

var x = 2;
function f() { 
alert("inside x = " + x); 
y=3;
alert("z = " + z);
var z=4;
if (f.s == undefined ) f.s = 5;
alert("f.s = " + f.s);
f.s = f.s + 1;
}
f();
f();
alert("outside y = " + y);
alert("outside z = " + typeof(z));
alert("outside f.s = " + f.s);
</script>
This demonstrates that:
x, y and f.s  are global and permanent
z is local to function f().
Note:  f(q) { }  also make q a local variable within f().

The function statement is magic and causes its identifier to be bound before anything in its code-block* is executed. This differs from the function expression which is evaluated in normal top-down order, so if you changed the example to say:

internalFoo= function() { return true; };   It won't work the same

 

best lessons on basic objects and arrays,  object creation,  closures

Google jQuery

Google Ad, Stats, etc.

https://www.google.com/webmasters/tools/home?hl=en https://www.google.com/analytics/settings/ https://www.google.com/adsense/report/overview

Google Ads need a PHP window, and should only run not editing. Like so:
<?php if (!user_is_logged_in())
echo <<<END
<br /><br />
<div style="text-align: right;">
  - - - Google Ad Goes Here - - -
</div>
END;
?>

Google

Google Analytics     G Webmaster Tools

zfacts.com/stiemap.xml

  • Constructed by the XML Sitemap module and its associated XML sm Node module.
  • The associated XML sm engines module will submit it to Google and Bing
  • Use Configuration / Search / XML to set up, recompute or send out.
  • Everything is set to happen once per day (I think).
  • Check on Google sitemap here

I'm already using Google Analytics Asynchronous Tracking Code

For Filtering my out of the stats, my IP address is  24.130.80.17, but it varies, so I need to recheck several times.

AdSense: All ads below content except for one 468x15 link unit.

  • Left SB:
  • #1 Link unit below search
  • Content:
  • #2 468x15 link unit in content
  • #3 300x250 display below content
  • #4 728x90 Leader board at very bottom
  • Right SB:
  • #5 small link unit at top
  • #6 wide skyscraper below my gizmos

On important pages: Install #2, move #3 into my content body, turn off default #3

Google Speed Tools

Google Analytics

How I exclude myself from Google Analytic.

  1. Visit the page gAnalytics.html, which includes some Javascript that sets a cookie
    •  <body onLoad="javascript:pageTracker._setVar('test_value');">
    • Google help link 
  2. There is a Custom Google analytics filter to exclude me.
    • Filter Type: Custom filter > Exclude // Filter Field: User Defined // Filter Pattern: test_value // Case Sensitive: No
    • To set up a filter in Google Analytics Click "Admin" then click the "Filters" tab.

The PHP checks if you are logged in and if you are not then it adds the Google-Analytics JS to the HTML header.

<?php if (!user_is_logged_in())
drupal_add_js("
 
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-4419146-5']);
  _gaq.push(['_trackPageview']);
 
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
 
", "inline");  <=This is the end of the drupal_add_js( ) function (a PHP function)
?>
 
This code must be added with  "PHP code" Text format.
It is added to a block (I put the block in the left footer).

Making Videos

Resources:

freesound.org
library of congress
archive.org
jamendo/music/creative commons ??

Programs:

Adobe Premiere Elements
Song Vegas Elements
Pinnacle Studio Plus

Page Forwards

  • Select a bit extras at the top.
  • View source, view normal -- see if the font is OK.
  • Delete top empty paragrph
  • Delete side paddinig cells:   <td width="19">&nbsp;</td>  (use shift enter for a line break)
  • 10px => 0px ,   5px => 0px  (reduces vertical spacing between rows)

  Site setting for zfacts:  Left margin = right margin = 19, cell space height = 0.  

 

zFacts pages that are aliased by Drupal
(Aliased pages that have external links.) (alias created on page: URL Path Setting)
1 /p/461.html Debt Clock /p/35.html Gas Price
3 196.html Oil Price 318 Debt Graph
5 green-energy Green Energy 194 Carbon Dioxide
7 447 Cost of Iraq empty Home
9 784 SS Crisis 63 Eth Subsidies
11 1195 Debt % Graphs 576 CRS
13 1170 ReaganBush Debt 60 Ethanol
15 57 Reagan's Budgets 436 Eth = 2/3 Gas
17 775 Reason for Iraq 480 Presidents+Debt
19 49 Global Warming 486 Leninist SS strat
21 226 CO2 is cause 64 Fentun is here
23 789 National Debt Clock 85 Cellulose Ethanol
25 519 Bush Deficit 252 Iraq War
27 139 A Clean Break 1159 Depression ?
29 voodoo Voodoo Econ gross-nat... National Debt
31 1197 Video and Slides 477 Social Security
33 783 Top 10 GW facts    

 

zFacts pages with 301 Redirects in .htaccess
(Redirects are for pages that are much visited, but not aliased.)
1 581 iraq-war-quotes: WMD 108 242: Katrina Date
3 426 243: ADM & Ethanol 1117 85: Stimulus
5 1165 130: Save or Borrow 416 244: Wind
7 790 245: Debt Data 126 246: Stop Warming
9 364 247: Iraq Giz Instruct 222 249: Polar Melting
11 679 251: Bomb Cambodia 1136 164: Wars
13 190 253: Gulf Stream 202 280: Temperature
15 990 255: OPEC gas tax 483 193: Is SS safe?
17 54 89: Energy Policy 330 US-economy
19 87 iraq-war-quotes: 1196 p/1197.html: videos
21 800 220: ND clock 205 161: warming effects
23 295 286: Nuclear    

 

Gizmos

The Chron Jobs that run daily and keep the gizmos up to date are in /giz/G02.

The get_debt.php chron job updates:
/G26/GND_clock1.js";  /G26/GND_clock3.js";  /G05ndc.js";  /G12ndc.js";  /G04acct.js";
 
The National Debt Clock page runs on G04acct.js