L1g3r Logo           SignalQ Sites: NetAdminTools - Coprolite - SpotBridge - NAW
RoboCoop - AreWeDown - SolarPower - SysAdminTools
Xfig - Gold Loaf - GeekPapa - FixGMC - FixRambler
Solar Energy - Energy Efficiency - Solar Panels
Home Energy Savings
Part C - Common Rails Controller
Topic:MCJ Web Presentation   Date: 2010-01-05
Printer Friendly: Print   

spacerspacer
<<  <   >  >>

Subject

This is the main Rails application controller that all applications use.

module Commcont
  $artpre=""
  def bpage
# will need to add l1g/buildtab keywords back in again
  $rname=params[:controller]
  @realmrow = Realm.find(:first, :conditions=> ["name='"+$rname+"'"])
    @artrow=Art.where(
      :realm=>$rname, 
      :date => (Date.today - Integer(22000) .. Date.today)
    ).order("date DESC").limit("3")
    @catrowcol=[]
    @comrowcol=[]
    @artrowentries = Art.where(
      :realm=>$rname 
    ).order("date DESC").limit("3")
    @artrowentries.each {|artrowtemp| @artrowtemp=artrowtemp  
      @catrow = Cat.find :first,
        :conditions=> {
          :artnum=>@artrowtemp.artnum,
          :u1=>$rname }
      if @catrow != NIL   
        c = @catrow.cat[0,1]
      else c="s"
      end 
      $cattype = case c
        when "j" then "Journal"
        when "d" then "Dream"
        when "s" then "Subject"
        when "m" then "Memory"
        when "c" then "Conversation"
        else ""
      end
      if @catrow.u3=~/\w/  
        $comments = "<hr><b>Updates and Comments:</b><br />"+@catrow.u3+"<hr><p>"
      else
        $comments = " "
      end
      @catrowcol[@artrowtemp.artnum.to_int]= $cattype
      @comrowcol[@artrowtemp.artnum.to_int]= $comments
      }

# People ******************************
  @people_distinct = People.find(:all,
    :conditions=> ["(
    realm='"+$rname+"' )"],
    :select=> "DISTINCT person")
  @people_with_person = []
  for x in @people_distinct
    @people_with_arts = People.find :all,
      :conditions=> ["(
      person= '"+x.person+"' AND (
      realm='"+$rname+"'))"] 
    for y in @people_with_arts
        @arts_matching_people = Art.find :all,
        :conditions=> ["(
        artnum= "+y.artnum.to_s+" AND realm='"+y.realm+"')"] 
      for z in @arts_matching_people
        z.classification=x.person
        @people_with_person << z
      end
    end 
  end
  @people_with_person= @people_with_person.sort_by { |a| [ a.classification, a.date] }
  $lastperson="wukkawukka"
  @people_with_person_m=[]
  for zz in @people_with_person
    if zz.classification == $lastperson
      zz.classification = ""
    else
    $lastperson=zz.classification
    end
    @people_with_person_m << zz
  end
# Places  ****************************
  @places_distinct = Place.find(:all,
    :conditions=> ["(
    realm='"+$rname+"')"],
    :select=> "DISTINCT place")
  @places_with_place = []
  for x in @places_distinct
    @places_with_arts = Place.find :all,
      :conditions=> ["(
      place= '"+x.place+"' AND (
      realm='"+$rname+"'))"] 
    for y in @places_with_arts
        @arts_matching_places = Art.find :all,
        :conditions=> ["(
        artnum= "+y.artnum.to_s+" AND realm='"+y.realm+"')"] 
      for z in @arts_matching_places
        z.classification=x.place
        @places_with_place << z
      end
    end 
  end
  @places_with_place= @places_with_place.sort_by { |a| [ a.classification, a.date] }
  $lastplace="wukkawukka"
  @places_with_place_m =[]
  for zz in @places_with_place
    if zz.classification == $lastplace
      zz.classification = ""
    else
    $lastplace=zz.classification
    end
    @places_with_place_m << zz
  end

# Things
  @things_distinct = Thing.find(:all,
    :conditions=> ["(
    realm='"+$rname+"')"],
    :select=> "DISTINCT thing")
  @things_with_thing = []
  for x in @things_distinct
    @things_with_arts = Thing.find :all,
      :conditions=> ["(
      thing= '"+x.thing+"' AND (
      realm='"+$rname+"'))"] 
    for y in @things_with_arts
        @arts_matching_things = Art.find :all,
        :conditions=> ["(
        artnum= "+y.artnum.to_s+" AND realm='"+y.realm+"')"] 
      for z in @arts_matching_things
        z.classification=x.thing
        @things_with_thing << z
      end
    end 
  end
  @things_with_thing= @things_with_thing.sort_by { |a| [ a.classification, a.date] }
  $lastthing="wukkawukka"
  @things_with_thing_m=[]
  for zz in @things_with_thing
    if zz.classification == $lastthing
      zz.classification = ""
    else
    $lastthing=zz.classification
    end
    @things_with_thing_m << zz
  end

#Times
  @times_distinct= Tme.find(:all,
    :conditions=> ["(
    realm='"+$rname+"')"],
    :select=> "DISTINCT tme")
  @times_with_time = []
  for x in @times_distinct
    @times_with_arts = Tme.find :all,
      :conditions=> ["(
      tme= '"+x.tme+"' AND (
      realm='"+$rname+"'))"] 
    for y in @times_with_arts
        @arts_matching_times = Art.find :all,
        :conditions=> ["(
        artnum= "+y.artnum.to_s+" AND realm='"+y.realm+"')"] 
      for z in @arts_matching_times
        z.classification=x.tme
        @times_with_time << z
      end
    end 
  end
  @times_with_time= @times_with_time.sort_by { |a| [ a.classification, a.date] }
  $lasttime="wukkawukka"
  @times_with_time_m=[]
  for zz in @times_with_time
    if zz.classification == $lasttime
      zz.classification = ""
    else
    $lasttime=zz.classification
    end
    @times_with_time_m << zz
  end

  @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])

end

  def printpage 
    $rname=params[:controller]
      @realmrow = Realm.find(:first, :conditions=> ["name='"+$rname+"'"])
      @imgrow = Img.find :first, 
        :conditions=> {
        :realm=>$rname,
        :alt=>'Print Logo'}
      artNum = params[:id]

      if $rname == "nonic" && artNum.to_i < 188 
      #Nonic specific stuff for build
   $artpre="b"
        @artrow = Art.find(:first,
        :conditions=> {
          :artnum=>artNum,
          :realm=>'mcjbuildtab1'},
          :order=>"date DESC")
        @b1artrow = Art.find(:first,
        :conditions=> {
          :artnum=>artNum,
          :realm=>'mcjbuildtab1'},
          :order=>"date DESC")
        @b2artrow = Art.find(:first,
        :conditions=> {
          :artnum=>artNum,
          :realm=>'mcjbuildtab2'},
          :order=>"date DESC")
        @b3artrow = Art.find(:first,
        :conditions=> {
          :artnum=>artNum,
          :realm=>'mcjbuildtab3'},
          :order=>"date DESC")

        @artrow.entry = @b1artrow.entry+"<br /><br />To compile and install, run these commands:"
        @artrow.entry = @artrow.entry+"<br /><br />"
        @artrow.entry = @artrow.entry+"<table cellpadding=\"10\" BGCOLOR=\"#E0E0E0\" "
        @artrow.entry = @artrow.entry+"WIDTH=\"99%\"><tr><td><pre>"
        @artrow.entry = @artrow.entry+@b2artrow.entry+"</pre></td></tr></table><br />"
        @artrow.entry = @artrow.entry+"The output should look something like this:"
        @artrow.entry = @artrow.entry+"<br /><br /><table cellpadding=\"10\" BGCOLOR=\"#E0E0E0\""
        @artrow.entry = @artrow.entry+" WIDTH=\"99%\">"
        @artrow.entry = @artrow.entry+"<tr><td><pre>"
        @artrow.entry = @artrow.entry+@b3artrow.entry
        @artrow.entry = @artrow.entry+"</pre></td></tr></table><br />"

    @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])
      @uresourcerowu = Uresource.find(:first, :conditions=> ["realm='"+$rname+"' 
        AND label='Print URL'"])
      @uresourcerowh = Uresource.find(:first, :conditions=> ["realm='"+$rname+"' 
        AND label='Print Home'"])
      @uresourcerowt = Uresource.find(:first, :conditions=> ["realm='"+$rname+"' 
        AND label='Terms of Use'"])
    @allarts = Art.find(:all,
      :conditions=> {
      :realm=>'mcjbuildtab1'},
      :order=>"artnum ASC")
    @weareat = @allarts.each_with_index.to_a
    @firstart = @weareat[0][0].artnum.to_i
    @lastart = @weareat[-1][0].artnum.to_i
    @previousart = @firstart
    @nextart = @lastart
    for i in(@weareat[0][1]..@weareat[-1][1])
      if @weareat[i][0].artnum == artNum.to_i
        if i > 0
          @previousart= @weareat[i-1][0].artnum
                               end
          if i < @weareat[-1][1]
            @nextart= @weareat[i+1][0].artnum
          end
        end
      end
    # end Nonic specific stuff for build
    else
      @artrow = Art.find(:first, :conditions=> ["artnum='" + artNum + "' 
        AND realm='"+$rname+"'"])

      @imgspacer=""
      if @artrow.classification== 'presconfig'
      @presrow= Presfile.find(:first,
        :conditions=> {
          :id=>artNum.to_i-3
          })

          @artrow.entry=@artrow.entry+"<center><br /><br /><table BGCOLOR=\"#E0E0E0\" BORDER=\"0\" " 
          @artrow.entry=@artrow.entry+"WIDTH=\"99%\" ><tr ><td><pre>"

        txt2htmlopts="--nomake_links --tab_width 2 --bold_delimiter \"\" --extract --prebegin 0 --preend 0 "
        system("txt2html "+txt2htmlopts+@presrow.prespath+"> "+@presrow.prespath+".txt")
  
        File.open(@presrow.prespath+".txt").each { |line|
              @artrow.entry=@artrow.entry+line
        }
        @artrow.entry=@artrow.entry+"</pre></td></tr></table></center><br />"
      end 

    @classrow = Classification.find(:first, :conditions=> ["name='"+@artrow.classification+"' 
        AND realm='"+$rname+"'"])
    @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])
      @uresourcerowu = Uresource.find(:first, :conditions=> ["realm='"+$rname+"' 
        AND label='Print URL'"])
      @uresourcerowh = Uresource.find(:first, :conditions=> ["realm='"+$rname+"'  
        AND label='Print Home'"])
      @uresourcerowt = Uresource.find(:first, :conditions=> ["realm='"+$rname+"' 
        AND label='Terms of Use'"])
    @allarts = Art.find(:all,
      :conditions=> {
      :realm=>$rname },
      :order=>"date ASC")
    @weareat = @allarts.each_with_index.to_a
    @firstart = @weareat[0][0].artnum.to_i
    @lastart = @weareat[-1][0].artnum.to_i
    @previousart = @firstart
    @nextart = @lastart
    for i in(@weareat[0][1]..@weareat[-1][1])
      if @weareat[i][0].artnum == artNum.to_i
        if i > 0
          @previousart= @weareat[i-1][0].artnum
                               end
          if i < @weareat[-1][1]
            @nextart= @weareat[i+1][0].artnum
          end
        end
      end
    end
  end

  def mobilepage 
    $rname=params[:controller]
      @realmrow = Realm.find(:first, :conditions=> ["name='"+$rname+"'"])
      @imgrow = Img.find :first, 
        :conditions=> {
        :realm=>$rname,
        :alt=>'Print Logo'}
      artNum = params[:id]
      if $rname == "nonic" && artNum.to_i <  188
      #begin nonic stuff
   $artpre="b"
        @artrow = Art.find(:first,
        :conditions=> {
          :artnum=>artNum,
          :realm=>'mcjbuildtab1'},
          :order=>"date DESC")
        @b1artrow = Art.find(:first,
        :conditions=> {
          :artnum=>artNum,
          :realm=>'mcjbuildtab1'},
          :order=>"date DESC")
        @b2artrow = Art.find(:first,
        :conditions=> {
          :artnum=>artNum,
          :realm=>'mcjbuildtab2'},
          :order=>"date DESC")
        @b3artrow = Art.find(:first,
        :conditions=> {
          :artnum=>artNum,
          :realm=>'mcjbuildtab3'},
          :order=>"date DESC")

        @artrow.entry = @b1artrow.entry+"<br /><br />To compile and install, run these commands:"
        @artrow.entry = @artrow.entry+"<br /><br />"
        @artrow.entry = @artrow.entry+"<table cellpadding=\"10\" BGCOLOR=\"#E0E0E0\" "
        @artrow.entry = @artrow.entry+"WIDTH=\"99%\"><tr><td><pre>"
        @artrow.entry = @artrow.entry+@b2artrow.entry+"</pre></td></tr></table><br />"
        @artrow.entry = @artrow.entry+"The output should look something like this:"
        @artrow.entry = @artrow.entry+"<br /><br /><table cellpadding=\"10\" BGCOLOR=\"#E0E0E0\""
        @artrow.entry = @artrow.entry+" WIDTH=\"99%\">"
        @artrow.entry = @artrow.entry+"<tr><td><pre>"
        @artrow.entry = @artrow.entry+@b3artrow.entry
        @artrow.entry = @artrow.entry+"</pre></td></tr></table><br />"

    @classrow = Classification.find(:first, :conditions=> ["name='refos' AND realm='mcjbuildtab1'"])
    @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])
    @uresourcerowu = Uresource.find(:first, :conditions=> ["realm='"+$rname+"' 
      AND label='Print URL'"])
    @mobile1 = "<a href=\""+@uresourcerowu.tag+"m/\">Main Articles</a>"
    @mobile2 = "<a href=\""+@uresourcerowu.tag+"m/bart1.html\">Build Articles</a>"
    @mobile3 = "<a href=\""+@uresourcerowu.tag+"\">Non-mobile Home</a>"
    @allarts = Art.find(:all,
      :conditions=> [
                       "classification <> 'termsofuse' and
                         classification <> 'privacypolicy' and
      realm= 'mcjbuildtab1'"],
      :order=>"artnum ASC")
    @weareat = @allarts.each_with_index.to_a
    @firstart = @weareat[0][0].artnum.to_i
    @lastart = @weareat[-1][0].artnum.to_i
    @previousart = @firstart
    @nextart = @lastart
    for i in(@weareat[0][1]..@weareat[-1][1])
      if @weareat[i][0].artnum == artNum.to_i
        if i > 0
          @previousart= @weareat[i-1][0].artnum
        end
        if i < @weareat[-1][1]
            @nextart= @weareat[i+1][0].artnum
        end
      end
    end
    #end nonic stuff
      else
      @artrow = Art.find(:first, :conditions=> ["artnum='" + artNum + "' AND realm='"+$rname+"' 
        AND classification <> 'termsofuse' AND classification <> 'privacypolicy'"])

      @imgspacer=""
      if @artrow.classification== 'presconfig'
      @presrow= Presfile.find(:first,
        :conditions=> {
          :id=>artNum.to_i-3 
          })

          @artrow.entry=@artrow.entry+"<center><br /><br /><table BGCOLOR=\"#E0E0E0\" BORDER=\"0\" " 
          @artrow.entry=@artrow.entry+"WIDTH=\"99%\" ><tr ><td><pre>"

        txt2htmlopts="--nomake_links --tab_width 2 --bold_delimiter \"\" --extract --prebegin 0 --preend 0 "
        system("txt2html "+txt2htmlopts+@presrow.prespath+"> "+@presrow.prespath+".txt")
  
        File.open(@presrow.prespath+".txt").each { |line|
              @artrow.entry=@artrow.entry+line
        }
        @artrow.entry=@artrow.entry+"</pre></td></tr></table></center><br />"
      end 

    @classrow = Classification.find(:first, :conditions=> ["name='"+@artrow.classification+"' 
      AND realm='"+$rname+"'"])
    @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])
    @uresourcerowu = Uresource.find(:first, :conditions=> ["realm='"+$rname+"' 
      AND label='Print URL'"])
    @mobile1 = "<a href=\""+@uresourcerowu.tag+"m/\">Main Articles</a>"
    @mobile3 = "<a href=\""+@uresourcerowu.tag+"\">Non-mobile Home</a>"
    @allarts = Art.find(:all,
      :conditions=> [
                       "classification <> 'termsofuse' and
                         classification <> 'privacypolicy' and
      realm= '"+$rname+"'"],
      :order=>"date ASC")
    @weareat = @allarts.each_with_index.to_a
    @firstart = @weareat[0][0].artnum.to_i
    @lastart = @weareat[-1][0].artnum.to_i
    @previousart = @firstart
    @nextart = @lastart
    for i in(@weareat[0][1]..@weareat[-1][1])
      if @weareat[i][0].artnum == artNum.to_i
        if i > 0
          @previousart= @weareat[i-1][0].artnum
        end
        if i < @weareat[-1][1]
            @nextart= @weareat[i+1][0].artnum
        end
      end
    end
  end
end

  def spage 
    $rname=params[:controller]
      @imgrow = Img.find :first, 
        :conditions=> {
        :realm=>$rname,
        :alt=>'Print Logo'}

      @realmrow = Realm.find(:first, :conditions=> ["name='"+$rname+"'"])
      @artrow = Art.find(:first,
        :conditions=> {
          :classification=>params[:id],
          :realm=>$rname },
        :order=>"date DESC")      
    @classrow = Classification.find(:first, :conditions=> ["name='"+@artrow.classification+"' 
      AND realm='"+$rname+"'"])
    @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])
    @uresourcerowu = Uresource.find(:first, :conditions=> ["realm='"+$rname+"' 
      AND label='Print URL'"])
    end
  def sqpage 
    $rname=params[:controller]
      @imgrow = Img.find :first, 
        :conditions=> {
        :realm=>$rname,
        :alt=>'Print Logo'}
      @realmrow = Realm.find(:first, :conditions=> ["name='"+$rname+"'"])
      @artrows = Art.find_by_sql "SELECT arts.title, arts.artnum, arts.date, cats.cat FROM 
          arts,cats WHERE 
          cat LIKE '%\,s%' 
          AND arts.artnum=cats.artnum 
          AND cats.u1='"+$rname+"' 
          AND arts.realm='"+$rname+"'" 
      @artrows.each do |artrow|
        artrow.cat.gsub! /\w+,\w/, ""
      end 
      @artrows = @artrows.sort_by { |a| [ a.cat, a.date ] }
      l=0
      @artrows.each do |artrow|
        k = artrow.cat.to_i
        if k > l
          l = artrow.cat.to_i
          artrow.cat="<tr><td><b>Sequence "+artrow.cat+":</b></td>"
        else
          artrow.cat=""
        end
      end
    @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])
    @uresourcerowu = Uresource.find(:first, :conditions=> ["realm='"+$rname+"' 
      AND label='Print URL'"])
    end
  def cpage 
    $rname=params[:controller]
      @imgrow = Img.find :first, 
        :conditions=> {
        :realm=>$rname,
        :alt=>'Print Logo'}

      @realmrow = Realm.find(:first, :conditions=> ["name='"+$rname+"'"])
      @artrow = Art.find(:first,
        :conditions=> {
          :classification=>params[:id],
          :realm=>$rname },
        :order=>"date DESC")      
    @classrow = Classification.find(:first, :conditions=> ["name='"+@artrow.classification+"' 
      AND realm='"+$rname+"'"])
    @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])
    @uresourcerowu = Uresource.find(:first, :conditions=> ["realm='"+$rname+"' 
      AND label='Print URL'"])
    end
  def zpage
    $zt=params[:id][0,1]
    $zttitle=params[:id]
    $rname=params[:controller]
      @imgrow = Img.find :first, 
        :conditions=> {
        :realm=>$rname,
        :alt=>'Print Logo'}

      @realmrow = Realm.find(:first, :conditions=> ["name='"+$rname+"'"])
      @artrows = Art.find_by_sql "SELECT arts.title, arts.entry, arts.artnum, arts.date, cats.cat FROM 
          arts,cats WHERE 
          cat LIKE '"+$zt+"%' 
          AND arts.artnum=cats.artnum 
          AND cats.u1='"+$rname+"' 
          AND arts.realm='"+$rname+"' order by date asc" 
    @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])
      @uresourcerowu = Uresource.find(:first, :conditions=> ["realm='"+$rname+"' AND label='Print URL'"])
  end
  def artpage 
    $rname=params[:controller]
      @realmrow = Realm.find(:all, :conditions=> ["name='"+$rname+"'"])
      artNum = params[:id]

      @artrow = Art.find(:all,
        :conditions=> {
          :artnum=>artNum,
          :realm=>$rname },
        :order=>"date DESC")

    for j in @artrow  
    @classrow = Classification.find(:all, :conditions=> ["name='"+j.classification+"' 
      AND realm='"+$rname+"'"])
    end 
  @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])
    end

def kpage 
  $rname=params[:controller]
  if $rname == 'l1g'
  @realmrow = Realm.find(:first, :conditions=> ["name='"+$rname+"'"])
# People ******************************
  @people_distinct = People.find(:all,
    :conditions=> ["(
    realm='l1g' OR realm='mcjbuildtab1')"],
    :select=> "DISTINCT person")
  @people_with_person = []
  for x in @people_distinct
    @people_with_arts = People.find :all,
      :conditions=> ["(
      person= '"+x.person+"' AND (
      realm='mcjbuildtab1' OR realm='l1g'))"] 
    for y in @people_with_arts
        @arts_matching_people = Art.find :all,
        :conditions=> ["(
        artnum= "+y.artnum.to_s+" AND realm='"+y.realm+"')"] 
      for z in @arts_matching_people
        z.classification=x.person
        @people_with_person << z
      end
    end 
  end
  @people_with_person= @people_with_person.sort_by { |a| [ a.classification, a.date] }
  $lastperson="wukkawukka"
  @people_with_person_m=[]
  for zz in @people_with_person
    if zz.classification == $lastperson
      zz.classification = ""
    else
    $lastperson=zz.classification
    end
    @people_with_person_m << zz
  end
# Places  ****************************
  @places_distinct = Place.find(:all,
    :conditions=> ["(
    realm='l1g' OR realm='mcjbuildtab1')"],
    :select=> "DISTINCT place")
  @places_with_place = []
  for x in @places_distinct
    @places_with_arts = Place.find :all,
      :conditions=> ["(
      place= '"+x.place+"' AND (
      realm='mcjbuildtab1' OR realm='l1g'))"] 
    for y in @places_with_arts
        @arts_matching_places = Art.find :all,
        :conditions=> ["(
        artnum= "+y.artnum.to_s+" AND realm='"+y.realm+"')"] 
      for z in @arts_matching_places
        z.classification=x.place
        @places_with_place << z
      end
    end 
  end
  @places_with_place= @places_with_place.sort_by { |a| [ a.classification, a.date] }
  $lastplace="wukkawukka"
  @places_with_place_m =[]
  for zz in @places_with_place
    if zz.classification == $lastplace
      zz.classification = ""
    else
    $lastplace=zz.classification
    end
    @places_with_place_m << zz
  end

# Things
  @things_distinct = Thing.find(:all,
    :conditions=> ["(
    realm='l1g' OR realm='mcjbuildtab1')"],
    :select=> "DISTINCT thing")
  @things_with_thing = []
  for x in @things_distinct
    @things_with_arts = Thing.find :all,
      :conditions=> ["(
      thing= '"+x.thing+"' AND (
      realm='mcjbuildtab1' OR realm='l1g'))"] 
    for y in @things_with_arts
        @arts_matching_things = Art.find :all,
        :conditions=> ["(
        artnum= "+y.artnum.to_s+" AND realm='"+y.realm+"')"] 
      for z in @arts_matching_things
        z.classification=x.thing
        @things_with_thing << z
      end
    end 
  end
  @things_with_thing= @things_with_thing.sort_by { |a| [ a.classification, a.date, "wukka"] }
  $lastthing="wukkawukka"
  @things_with_thing_m=[]
  for zz in @things_with_thing
    if zz.classification == $lastthing
      zz.classification = ""
    else
    $lastthing=zz.classification
    end
    @things_with_thing_m << zz
  end

#Times
  @times_distinct= Tme.find(:all,
    :conditions=> ["(
    realm='l1g' OR realm='mcjbuildtab1')"],
    :select=> "DISTINCT tme")
  @times_with_time = []
  for x in @times_distinct
    @times_with_arts = Tme.find :all,
      :conditions=> ["(
      tme= '"+x.tme+"' AND (
      realm='mcjbuildtab1' OR realm='l1g'))"] 
    for y in @times_with_arts
        @arts_matching_times = Art.find :all,
        :conditions=> ["(
        artnum= "+y.artnum.to_s+" AND realm='"+y.realm+"')"] 
      for z in @arts_matching_times
        z.classification=x.tme
        @times_with_time << z
      end
    end 
  end
  @times_with_time= @times_with_time.sort_by { |a| [ a.classification, a.date] }
  $lasttime="wukkawukka"
  @times_with_time_m=[]
  for zz in @times_with_time
    if zz.classification == $lasttime
      zz.classification = ""
    else
    $lasttime=zz.classification
    end
    @times_with_time_m << zz
  end

  @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])

else

  @realmrow = Realm.find(:first, :conditions=> ["name='"+$rname+"'"])
# People ******************************
  @people_distinct = People.find(:all,
    :conditions=> {
    :realm=>$rname },
    :select=> "DISTINCT person")
  @people_with_person = []
  for x in @people_distinct
    @people_with_arts = People.find :all,
      :conditions=> {
      :person=> x.person,
      :realm=>$rname }
    for y in @people_with_arts
        @arts_matching_people = Art.find :all,
        :conditions=> {
        :artnum=> y.artnum,
        :realm=>$rname }
      for z in @arts_matching_people
        z.classification=x.person
        @people_with_person << z
      end
    end 
  end
  @people_with_person= @people_with_person.sort_by { |a| [ a.classification, a.date] }
  $lastperson="wukkawukka"
  @people_with_person_m=[]
  for zz in @people_with_person
    if zz.classification == $lastperson
      zz.classification = ""
    else
    $lastperson=zz.classification
    end
    @people_with_person_m << zz
  end
# Places  ****************************
  @places_distinct = Place.find(:all,
    :conditions=> {
    :realm=>$rname },
    :select=> "DISTINCT place")
  @places_with_place = []
  for x in @places_distinct
    @places_with_arts = Place.find :all,
      :conditions=> {
      :place=> x.place,
      :realm=>$rname }
    for y in @places_with_arts
      @arts_matching_places = Art.find :all,
        :conditions=> {
        :artnum=> y.artnum,
        :realm=>$rname }
      for z in @arts_matching_places
        z.classification=x.place
        @places_with_place << z
      end
    end 
  end 
  @places_with_place= @places_with_place.sort_by { |a| [ a.classification, a.date] }
  $lastplace="wukkawukka"
  @places_with_place_m=[]
  for zz in @places_with_place
    if zz.classification == $lastplace
      zz.classification = ""
    else
    $lastplace=zz.classification
    end
    @places_with_place_m << zz
  end
# Things
  @things_distinct = Thing.find(:all,
    :conditions=> {
    :realm=>$rname },
    :select=> "DISTINCT thing")
  @things_with_thing = []
  for x in @things_distinct
    @things_with_arts = Thing.find :all,
      :conditions=> {
      :thing=> x.thing,
      :realm=>$rname }
    for y in @things_with_arts
        @arts_matching_things = Art.find :all,
        :conditions=> {
        :artnum=> y.artnum,
        :realm=>$rname }
      for z in @arts_matching_things
        z.classification=x.thing
        @things_with_thing << z
      end
    end 
  end
  @things_with_thing= @things_with_thing.sort_by { |a| [ a.classification, a.date] }
  $lastthing="wukkawukka"
  @things_with_thing_m=[]
  for zz in @things_with_thing
    if zz.classification == $lastthing
      zz.classification = ""
    else
    $lastthing=zz.classification
    end
    @things_with_thing_m << zz
  end
#Times
  @times_distinct = Tme.find(:all,
    :conditions=> {
    :realm=>$rname },
    :select=> "DISTINCT tme")
  @times_with_time = []
  for x in @times_distinct
    @times_with_arts = Tme.find :all,
      :conditions=> {
      :tme=> x.tme,
      :realm=>$rname }
    for y in @times_with_arts
        @arts_matching_times = Art.find :all,
        :conditions=> {
        :artnum=> y.artnum,
        :realm=>$rname }
      for z in @arts_matching_times
        z.classification=x.tme
        @times_with_time << z
      end
    end 
  end
  @times_with_time= @times_with_time.sort_by { |a| [ a.classification, a.date] }
  $lasttime="wukkawukka"
  @times_with_time_m=[]
  for zz in @times_with_time
    if zz.classification == $lasttime
      zz.classification = ""
    else
    $lasttime=zz.classification
    end
    @times_with_time_m << zz
  end

  @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])
  end
end

  def acrtpage 
        $comments = ""
        artNum = params[:id]
    $rname=params[:controller]
    if artNum =='mcjintro'
      @findmcjintro = Art.find(:first,
        :conditions=>{
          :realm=>$rname,
          :classification=>'mcjintro'})
      artNum=@findmcjintro.artnum
    end
      @realmrow = Realm.find(:first, :conditions=> ["name='"+$rname+"'"])
      if @realmrow.rectcode==""
        @realmrow.rectcode=" "
      end
      if $rname == "nonic" && artNum.to_i <  188
# Nonic specific stuff for the build only... sorry.  
# Certainly you could use it with a mod to your own realm
# This is to provide build steps.  We only have  188.  :)  
   $artpre="b"
        @artrow = Art.find(:first,
        :conditions=> {
          :artnum=>artNum,
          :realm=>'mcjbuildtab1'},
          :order=>"date DESC")
        @b1artrow = Art.find(:first,
        :conditions=> {
          :artnum=>artNum,
          :realm=>'mcjbuildtab1'},
          :order=>"date DESC")
        @b2artrow = Art.find(:first,
        :conditions=> {
          :artnum=>artNum,
          :realm=>'mcjbuildtab2'},
          :order=>"date DESC")
        @b3artrow = Art.find(:first,
        :conditions=> {
          :artnum=>artNum,
          :realm=>'mcjbuildtab3'},
          :order=>"date DESC")

        @artrow.entry = @b1artrow.entry+"<br /><br />To compile and install, run these commands:"
        @artrow.entry = @artrow.entry+"<br /><br />"
        @artrow.entry = @artrow.entry+"<table cellpadding=\"10\" BGCOLOR=\"#E0E0E0\" "
        @artrow.entry = @artrow.entry+"WIDTH=\"99%\"><tr><td><pre>"
        @artrow.entry = @artrow.entry+@b2artrow.entry+"</pre></td></tr></table><br />"
        @artrow.entry = @artrow.entry+"The output should look something like this:"
        @artrow.entry = @artrow.entry+"<br /><br /><table cellpadding=\"10\" BGCOLOR=\"#E0E0E0\""
        @artrow.entry = @artrow.entry+" WIDTH=\"99%\">"
        @artrow.entry = @artrow.entry+"<tr><td><pre>"
        @artrow.entry = @artrow.entry+@b3artrow.entry
        @artrow.entry = @artrow.entry+"</pre></td></tr></table><br />"

      # The code below an be rewritten when I actually understand ruby and arrays.
        @allarts = Art.find(:all,
            :conditions=> {
           :realm=>'mcjbuildtab1'},
           :order=>"artnum ASC")
        @weareat = @allarts.each_with_index.to_a
        @firstart = @weareat[0][0].artnum.to_i
        @lastart = @weareat[-1][0].artnum.to_i
        @previousart = @firstart  
        @nextart = @lastart
        for i in(@weareat[0][1]..@weareat[-1][1]) 
          if @weareat[i][0].artnum == artNum.to_i
            if i > 0 
              @previousart= @weareat[i-1][0].artnum
            end
            if i < @weareat[-1][1]
              @nextart= @weareat[i+1][0].artnum
            end
          end 
        end 
  
        @catrow = Cat.find :first,
          :conditions=> {
          :artnum=>2,
          :u1=>'mcjbuildtab1'}
        if @catrow != NIL   
      c = @catrow.cat[0,1]
      else c="s"
      end 
      $cattype = "Base Reference GNU/Linux Build Sequence"
@lowersec =[]
#find the individual people that are marked for the article 
    @perow = People.find(:all,
        :conditions=> {
        :artnum=>artNum,
        :realm=>'mcjbuildtab1'},
        :select=> "DISTINCT person")
@lowersec << "<tr><td><b>People:</b></td><td></td>"
#for each person reference, find all other articles with the same person reference
#within the same realm
    for x in @perow
    @lowersec << "<tr><td></td><td><b>"+x.person+"</b></td>"
      @perowa = Art.find_by_sql "SELECT arts.title, arts.artnum, arts.date FROM 
          arts,peoples WHERE 
          arts.artnum=peoples.artnum
          AND arts.artnum != #{artNum} 
          AND peoples.person=\"#{x.person}\"
          AND arts.realm='l1g'"+" 
          AND peoples.realm='l1g'" 
    for y in @perowa
      @lowersec << "<tr><td></td><td></td><td><a href=\"art"+y.artnum.to_s+".html\">"+y.title+"</a></td>"
    end
    end
      

    @plrow = Place.find(:all,
        :conditions=> {
        :artnum=>artNum,
        :realm=>'mcjbuildtab1'},
        :select=> "DISTINCT place")
@lowersec << "<tr><td><b>Places:</b></td><td></td>"
    
    for x in @plrow
    @lowersec << "<tr><td></td><td><b>"+x.place+"</b></td>"
      @plrowa = Art.find_by_sql "SELECT arts.title, arts.artnum, arts.date FROM 
          arts,places WHERE 
          arts.artnum=places.artnum
          AND arts.artnum != #{artNum} 
          AND places.place=\"#{x.place}\"
          AND arts.realm='l1g'"+" 
          AND places.realm='l1g'" 
    for y in @plrowa
      @lowersec << "<tr><td></td><td></td><td><a href=\"art"+y.artnum.to_s+".html\">"+y.title+"</a></td>"
    end
    end
  
    @throw = Thing.find(:all,
        :conditions=> {
        :artnum=>artNum,
        :realm=>'mcjbuildtab1' },
        :select=> "DISTINCT thing")
@lowersec << "<tr><td><b>Things:</b></td><td></td>"
    for x in @throw
    @lowersec << "<tr><td></td><td><b>"+x.thing+"</b></td>"
      @throwa = Art.find_by_sql "SELECT arts.title, arts.artnum, arts.date FROM 
          arts,things WHERE 
          arts.artnum=things.artnum
          AND arts.artnum != #{artNum} 
          AND things.thing=\"#{x.thing}\"
          AND arts.realm='l1g'"+" 
          AND things.realm='l1g'" 
    for y in @throwa
      @lowersec << "<tr><td></td><td></td><td><a href=\"art"+y.artnum.to_s+".html\">"+y.title+"</a></td>"
    end
    end 

    @tirow = Tme.find(:all,
        :conditions=> {
        :artnum=>artNum,
        :realm=>'mcjbuildtab1'},
        :select=> "DISTINCT tme")
@lowersec << "<tr><td><b>Times:</b></td><td></td>"
    for x in @tirow
    @lowersec << "<tr><td></td><td><b>"+x.tme+"</b></td>"
      @tirowa = Art.find_by_sql "SELECT arts.title, arts.artnum, arts.date FROM 
          arts,tmes WHERE 
          arts.artnum=tmes.artnum
          AND arts.artnum != #{artNum} 
          AND tmes.tme=\"#{x.tme}\"
          AND arts.realm='l1g'"+" 
          AND tmes.realm='l1g'" 
    for y in @tirowa
      @lowersec << "<tr><td></td><td></td><td><a href=\"art"+y.artnum.to_s+".html\">"+y.title+"</a></td>"
    end
    end 

    @classrow = Classification.find(:first, :conditions=> ["name='refos' AND realm='"+$rname+"'"])
    @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])

# End of Nonic nonic specific stuff

      else  
      @artrow = Art.find(:first,
        :conditions=> {
          :artnum=>artNum,
          :realm=>$rname },
          :order=>"date DESC")
      @imgspacer=""
        if @realmrow.style == "bio" && @artrow.classification == "design"
            $pdfavailable='<a href="http://l1g3r.com/design.pdf">View PDF of Design</a>'
          else
            $pdfavailable='' 
          end
      if @artrow.classification== 'presconfig'
      @presrow= Presfile.find(:first,
        :conditions=> {
          :id=>artNum.to_i-3 
          })

          @artrow.entry=@artrow.entry+"<br /><br /><table BORDER=\"0\" BGCOLOR=\"#E0E0E0\" " 
          @artrow.entry=@artrow.entry+"WIDTH=\"99%\" ><tr ><td>"

        txt2htmlopts="--nomake_links --tab_width 2 --bold_delimiter \"\" --extract --prebegin 0 --preend 0 "
        system("txt2html "+txt2htmlopts+@presrow.prespath+"> "+@presrow.prespath+".txt")
  
        File.open(@presrow.prespath+".txt").each { |line|
              @artrow.entry=@artrow.entry+line
        }
        @artrow.entry=@artrow.entry+"</td></tr></table><br />"
      end 
      # The code below an be rewritten when I actually understand ruby and arrays.
      @allarts = Art.find(:all,
          :conditions=> {
          :realm=>$rname },
          :order=>"date ASC")
      @weareat = @allarts.each_with_index.to_a
      @firstart = @weareat[0][0].artnum.to_i
      @lastart = @weareat[-1][0].artnum.to_i
      @previousart = @firstart  
      @nextart = @lastart
      for i in(@weareat[0][1]..@weareat[-1][1]) 
        if @weareat[i][0].artnum == artNum.to_i
          if i > 0 
            @previousart= @weareat[i-1][0].artnum
          end
          if i < @weareat[-1][1]
            @nextart= @weareat[i+1][0].artnum
          end
        end 
      end 

      @catrow = Cat.find :first,
        :conditions=> {
          :artnum=>artNum,
          :u1=>$rname }
      if @catrow != NIL   
        c = @catrow.cat[0,1]
      else c="s"
      end 
      $cattype = case c
        when "j" then "Journal"
        when "d" then "Dream"
        when "s" then "Subject"
        when "m" then "Memory"
        when "c" then "Conversation"
        else ""
      end
      if @catrow.u2 = ""
          @catrow.u2=" "
      end
      if @catrow.u3=~/\w/  
        $comments = "<hr><b>Updates and Comments:</b><br />"+@catrow.u3
      else
        $comments = " "
      end
@lowersec =[]
#find the individual people that are marked for the article 
    @perow = People.find(:all,
        :conditions=> {
        :artnum=>artNum,
        :realm=>$rname },
        :select=> "DISTINCT person")
@lowersec << "<tr><td><b>People:</b></td><td></td>"
#for each person reference, find all other articles with the same person reference
#within the same realm
    for x in @perow
    @lowersec << "<tr><td></td><td><b>"+x.person+"</b></td>"
      @perowa = Art.find_by_sql "SELECT arts.title, arts.artnum, arts.date FROM 
          arts,peoples WHERE 
          arts.artnum=peoples.artnum
          AND arts.artnum != #{artNum} 
          AND peoples.person=\"#{x.person}\"
          AND arts.realm='"+$rname+"'"+" 
          AND peoples.realm='"+$rname+"'" 
    for y in @perowa
      @lowersec << "<tr><td></td><td></td><td><a href=\"art"+y.artnum.to_s+".html\">"+y.title+"</a></td>"
    end
if $rname == "l1g"
          @perowa = Art.find_by_sql "SELECT arts.title, arts.artnum, arts.date FROM 
          arts,peoples WHERE 
          arts.artnum=peoples.artnum
          AND arts.artnum != #{artNum} 
          AND peoples.person=\"#{x.person}\"
          AND arts.realm='mcjbuildtab1'"+" 
          AND peoples.realm='mcjbuildtab1'" 
      for y in @perowa
        @lowersec << "<tr><td></td><td></td><td><a href=\"bart"+y.artnum.to_s+".html\">"+y.title+"</a></td>"
      end
end

    end
      

    @plrow = Place.find(:all,
        :conditions=> {
        :artnum=>artNum,
        :realm=>$rname },
        :select=> "DISTINCT place")
@lowersec << "<tr><td><b>Places:</b></td><td></td>"
    
    for x in @plrow
    @lowersec << "<tr><td></td><td><b>"+x.place+"</b></td>"
      @plrowa = Art.find_by_sql "SELECT arts.title, arts.artnum, arts.date FROM 
          arts,places WHERE 
          arts.artnum=places.artnum
          AND arts.artnum != #{artNum} 
          AND places.place=\"#{x.place}\"
          AND arts.realm='"+$rname+"'"+" 
          AND places.realm='"+$rname+"'" 
    for y in @plrowa
      @lowersec << "<tr><td></td><td></td><td><a href=\"art"+y.artnum.to_s+".html\">"+y.title+"</a></td>"
    end
if $rname == "l1g"
      @plrowa = Art.find_by_sql "SELECT arts.title, arts.artnum, arts.date FROM 
          arts,places WHERE 
          arts.artnum=places.artnum
          AND arts.artnum != #{artNum} 
          AND places.place=\"#{x.place}\"
          AND arts.realm='mcjbuildtab1'"+" 
          AND places.realm='mcjbuildtab1'" 
    for y in @plrowa
      @lowersec << "<tr><td></td><td></td><td><a href=\"bart"+y.artnum.to_s+".html\">"+y.title+"</a></td>"
    end

end
    end
  
    @throw = Thing.find(:all,
        :conditions=> {
        :artnum=>artNum,
        :realm=>$rname },
        :select=> "DISTINCT thing")
@lowersec << "<tr><td><b>Things:</b></td><td></td>"
    for x in @throw
    @lowersec << "<tr><td></td><td><b>"+x.thing+"</b></td>"
      @throwa = Art.find_by_sql "SELECT arts.title, arts.artnum, arts.date, arts.realm FROM 
          arts,things WHERE 
          arts.artnum=things.artnum
          AND things.thing=\"#{x.thing}\"
          AND arts.realm='"+$rname+"'
          AND things.realm='"+$rname+"'
          AND arts.artnum != #{artNum}" 
    for y in @throwa
      @lowersec << "<tr><td></td><td></td><td><a href=\"art"+y.artnum.to_s+".html\">"+y.title+"</a></td>"
    end
if $rname == "l1g"
      @throwa = Art.find_by_sql "SELECT arts.title, arts.artnum, arts.date FROM 
          arts,things WHERE 
          arts.artnum=things.artnum
          AND things.thing=\"#{x.thing}\"
          AND arts.realm='mcjbuildtab1'
          AND things.realm='mcjbuildtab1'
          AND arts.artnum != #{artNum}" 
    for y in @throwa
      @lowersec << "<tr><td></td><td></td><td><a href=\"bart"+y.artnum.to_s+".html\">"+y.title+"</a></td>"
    end
end

    end 

    @tirow = Tme.find(:all,
        :conditions=> {
        :artnum=>artNum,
        :realm=>$rname },
        :select=> "DISTINCT tme")
@lowersec << "<tr><td><b>Times:</b></td><td></td>"
    for x in @tirow
    @lowersec << "<tr><td></td><td><b>"+x.tme+"</b></td>"
      @tirowa = Art.find_by_sql "SELECT arts.title, arts.artnum, arts.date FROM 
          arts,tmes WHERE 
          arts.artnum=tmes.artnum
          AND arts.artnum != #{artNum} 
          AND tmes.tme=\"#{x.tme}\"
          AND arts.realm='"+$rname+"'"+" 
          AND tmes.realm='"+$rname+"'" 
    for y in @tirowa
      @lowersec << "<tr><td></td><td></td><td><a href=\"art"+y.artnum.to_s+".html\">"+y.title+"</a></td>"
    end
if $rname == "l1g"

 @tirowa = Art.find_by_sql "SELECT arts.title, arts.artnum, arts.date FROM 
          arts,tmes WHERE 
          arts.artnum=tmes.artnum
          AND arts.artnum != #{artNum} 
          AND tmes.tme=\"#{x.tme}\"
          AND arts.realm='"+$rname+"'"+" 
          AND tmes.realm='"+$rname+"'" 
    for y in @tirowa
      @lowersec << "<tr><td></td><td></td><td><a href=\"art"+y.artnum.to_s+".html\">"+y.title+"</a></td>"
    end
end

    end 

    @classrow = Classification.find(:first, :conditions=> ["name='"+@artrow.classification+"' 
      AND realm='"+$rname+"'"])
    @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])
    
end
  end

  def tpage
    $artpre=""
    $rname=params[:controller]
    @realmrow = Realm.find :first, :conditions=> {:name => $rname}
    classification = params[:id]
    if classification == "refos" and $rname == "nonic" 
    # begin nonic-specific stuff
      $artpre="b"
      if @realmrow.style == "bio" 
        @artrow = Art.find(:all, 
        :conditions=> {
          :realm=>'mcjbuildtab1'},
        :order=>"artnum ASC")
      end
      # end nonic-specific stuff
    else
        if @realmrow.style == "bio" && classification != "design" && classification != "presconfig"
          @artrow = Art.find(:all, 
            :conditions=> {
            :classification=> classification,
            :realm=>$rname },
            :order=>"date DESC")
        else
          @artrow = Art.find(:all, 
            :conditions=> {
            :classification=> classification,
            :realm=>$rname },
            :order=>"date ASC")
        end
    end
      @uresourcerow = Uresource.find :all, :conditions=> {
      :classification=>classification,
      :realm=>$rname
    }
    @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])
    @classrow = Classification.find :first, :conditions=> {
      :name=>params[:id],
      :realm=>$rname
    }
  end
  def dpage
    $rname=params[:controller]
    @realmrow = Realm.find(:first, :conditions=> ["name='"+$rname+"'"])
    if params[:id] == 'allarts' then 
      artNum='22000' # It's not a lot.  It's all you got.
      @dayslabel=@realmrow.shortitle+' - All Articles' 
    else 
      artNum = params[:id] 
      @dayslabel=@realmrow.shortitle+' - Last '+artNum+' Days' 
    end
    @artrow = Art.find(:all, 
      :conditions => { 
        :realm => $rname,
        :date => (Date.today - Integer(artNum) .. Date.today)},
      :order=>"date DESC")
  @settingrow = Setting.find(:first, :conditions=> ["parameter='mcjfoot'"])
  end
end


Updates and Comments:
On my GNU/Linux workstation this file is located at /opt/mcjr/lib/Commcont.rb
People:
Places:
Things:
Times:



None of this would be possible without the diligent work of the Linux From Scratch (LFS) project. A tip o' the hat to those intrepid hackers. Much of the OS buld configuration is taken directly from LFS and BLFS.
Get Mountain Climbing Journal at SourceForge.net. Fast, secure and Free Open Source software downloads