--- /tmp/s080811/samizdat/lib/samizdat/controllers/member_controller.rb	2008-05-11 12:02:00.000000000 +0200
+++ /usr/lib/ruby/1.8/samizdat/controllers/member_controller.rb	2008-08-17 15:07:09.000000000 +0200
@@ -45,7 +45,7 @@
   # store UI options in cookies
   #
   def set
-    %w[lang style nostatic ui].each do |param|
+    %w[lang monolanguage style nostatic ui].each do |param|
       value, = @request.values_at([param])
       if value
         @request.set_cookie(param, value, forever)
--- /tmp/s080703/samizdat/lib/samizdat/engine/request.rb	2008-06-27 15:59:02.000000000 +0200
+++ /usr/lib/ruby/1.8/samizdat/engine/request.rb	2008-08-17 15:08:08.000000000 +0200
@@ -85,6 +85,12 @@
   # current language
   attr_reader :language
 
+  # monolanguage - show content from preferred language only?
+  def monolanguage?
+    (cookie('monolanguage').to_s == 'mono')?
+      true : false
+  end
+
   # set default CGI headers (set charset to UTF-8)
   #
   # set id and refresh session if there's a valid session cookie,
--- /tmp/s080703/samizdat/lib/samizdat/helpers/application_helper.rb	2008-05-11 10:28:07.000000000 +0200
+++ /usr/lib/ruby/1.8/samizdat/helpers/application_helper.rb	2008-08-17 23:04:10.000000000 +0200
@@ -47,10 +47,22 @@
   # navigation link to a given page number
   #
   def nav(dataset, name = 'page', page = (@request[name] or 1).to_i, script = @request.route + '?')
+    if dataset.kind_of? DataSet
     return '' if page < 1 or dataset.size <= dataset.limit
 
     max_page = (dataset.size.to_f / dataset.limit).ceil
     return '' if page > max_page
+    elsif dataset.kind_of? Array and dataset[0].kind_of? DataSet
+      small = true
+      max_page = 0
+      dataset.each{|x| 
+        small = false if x.size > x.limit 
+        i = (x.size.to_f / x.limit).ceil
+        max_page = i if i > max_page
+      }
+      return '' if page < 1 or small
+      return '' if page > max_page      
+    end
 
     link = "#{script}#{name}="
     pages = []
--- /tmp/s080703/samizdat/lib/samizdat/controllers/frontpage_controller.rb	2008-05-10 18:35:32.000000000 +0200
+++ /usr/lib/ruby/1.8/samizdat/controllers/frontpage_controller.rb	2008-08-18 03:02:12.000000000 +0200
@@ -22,6 +22,7 @@
     full_front_page = (1 == page and 1 == features_page)
     render_features = (full_front_page or 1 == page)
     render_updates = (full_front_page or 1 == features_page)
+    set_monolanguage
 
     # provide rss links
     if full_front_page
@@ -32,7 +33,8 @@
 
     # try to run from cache
     cache_key = 'index' + @request.uri_prefix + '/' + @request.accept_language.join(':') +
-      %{/#{page}/#{features_page}/#{'yes' != @request.cookie('nostatic')}}
+      %{/#{page}/#{features_page}/#{'yes' != @request.cookie('nostatic')}} +
+      %{/#{@request.monolanguage?}}
     if body = cache[cache_key]
       return @content_for_layout = body
     end
@@ -54,25 +56,47 @@
 
     if render_features
       dataset = features_dataset(config['limit']['features'])
+      if @request.monolanguage? 
+        features = dataset[features_page - 1].collect {|msg, date|
+          [Resource.new(@request, msg).short, date] } 
+        dataset_t = translated_features_dataset(config['limit']['features'])
+        features += 
+          dataset_t[features_page - 1].collect {|msg, date|
+          [Resource.new(@request, msg).short, date] }  
+        features.sort!{|a,b| b[1].to_time <=> a[1].to_time}
+        features = features.collect{|short,| short}
+      else
       features = dataset[features_page - 1].collect {|msg,|
         Resource.new(@request, msg).short }
+      end
 
       features_title = _('Features') + page_number(features_page)
       features = features.join <<
         %{<div class="foot">} <<
         nav_rss(rss_features) <<
-        nav(dataset, 'features_page') <<
+        nav(@request.monolanguage? ? [dataset, dataset_t] : dataset, 'features_page') <<
         "</div>\n"
     end
 
     if render_updates
       dataset = updates_dataset
+      if @request.monolanguage?
+        updates = dataset[page - 1].collect {|msg,date|
+          [Resource.new(@request, msg).list_item, date] }
+        dataset_t = translated_updates_dataset
+        updates += dataset_t[page - 1].collect {|msg,date|
+          [Resource.new(@request, msg).list_item, date] }
+        updates.sort!{|a,b| b[1].to_time <=> a[1].to_time}
+        updates = updates.collect{|item,| item}
+      else
       updates = dataset[page - 1].collect {|msg,|
         Resource.new(@request, msg).list_item }
+      end
 
       updates_title = _('Recent Updates') + page_number(page)
       updates = list(updates,
-        nav_rss(rss_updates) << nav(dataset))
+        nav_rss(rss_updates) << 
+        nav(@request.monolanguage? ? [dataset, dataset_t] : dataset) )
     end
 
     body =
@@ -172,33 +197,79 @@
   #
   def features_dataset(limit)
     RdfDataSet.new(%{
-SELECT ?msg
+SELECT ?msg, ?date
 WHERE (rdf::predicate ?stmt dc::relation)
       (rdf::subject ?stmt ?msg)
       (rdf::object ?stmt ?focus)
       (dc::date ?stmt ?date)
+      (dc::language ?msg ?language)
+      (s::inReplyTo ?msg ?parent)
+      (dct::isVersionOf ?msg ?version_of)
+      (s::rating ?stmt ?rating FILTER ?rating >= :threshold)
+      (s::hidden ?msg ?hidden #{filter_hidden})
+LITERAL ?parent IS NULL AND ?version_of IS NULL #{@check_monolang}
+GROUP BY ?msg, ?date
+ORDER BY max(?date) DESC},
+      limit,
+      { :threshold => config['limit']['features_threshold'],
+        :accept_lang => @monolang})
+  end
+
+  def translated_features_dataset(limit)
+      RdfDataSet.new(%{
+SELECT ?parent, ?date
+WHERE (rdf::predicate ?stmt dc::relation)
+      (rdf::subject ?stmt ?parent)
+      (rdf::object ?stmt ?focus)
+      (dc::title ?parent ?dummy)
+      (rdf::predicate ?m_stmt dc::relation)
+      (rdf::subject ?m_stmt ?msg)
+      (rdf::object ?m_stmt focus::Translation)
       (s::inReplyTo ?msg ?parent)
+      (dc::date ?stmt ?date)
+      (dc::language ?msg ?language)
       (dct::isVersionOf ?msg ?version_of)
       (s::rating ?stmt ?rating FILTER ?rating >= :threshold)
       (s::hidden ?msg ?hidden #{filter_hidden})
-LITERAL ?parent IS NULL AND ?version_of IS NULL
-GROUP BY ?msg
+LITERAL NOT ?parent IS NULL AND ?version_of IS NULL #{@check_monolang}
+GROUP BY ?parent, ?date
 ORDER BY max(?date) DESC},
       limit,
-      { :threshold => config['limit']['features_threshold'] })
+      { :threshold => config['limit']['features_threshold'],
+        :accept_lang => @monolang})
   end
 
   # messages that are not comments or older version, sorted chronologically
   #
   def updates_dataset
     RdfDataSet.new(%{
-SELECT ?msg
+SELECT ?msg, ?date
 WHERE (dc::date ?msg ?date)
       (s::inReplyTo ?msg ?parent)
+      (dc::language ?msg ?language)
       (dct::isVersionOf ?msg ?version_of)
       (s::hidden ?msg ?hidden #{filter_hidden})
-LITERAL ?parent IS NULL AND ?version_of IS NULL
-ORDER BY ?date DESC})
+LITERAL ?parent IS NULL AND ?version_of IS NULL #{@check_monolang}
+ORDER BY ?date DESC}, 
+                   limit_page,
+                   { :accept_lang => @monolang})
+  end
+
+  def translated_updates_dataset
+    RdfDataSet.new(%{
+SELECT ?parent, ?date
+WHERE (dc::date ?msg ?date)
+      (s::inReplyTo ?msg ?parent)
+      (rdf::predicate ?m_stmt dc::relation)
+      (rdf::subject ?m_stmt ?msg)
+      (rdf::object ?m_stmt focus::Translation)
+      (dc::language ?msg ?language)
+      (dct::isVersionOf ?msg ?version_of)
+      (s::hidden ?msg ?hidden #{filter_hidden})
+LITERAL NOT ?parent IS NULL AND ?version_of IS NULL #{@check_monolang}
+ORDER BY ?date DESC}, 
+                   limit_page,
+                   { :accept_lang => @monolang})
   end
 
   # do Apache's job and include files in static headers
@@ -241,8 +316,25 @@
       next if 'English' == name and 'en' != lang   # broken localization
       name += _(' (default language)') if
         lang == default_language
-      name = %{<strong>#{name}</strong>} if lang == old_language
-      list += %{<a href="member/set?lang=#{lang}">#{name}</a>\n}
+      list += (lang == old_language) ? %{<strong>#{name}</strong>\n} :
+        %{<a href="member/set?lang=#{lang}">#{name}</a>\n}
+    end
+    if config['monolanguage']
+      list += ( (@request.monolanguage?)?
+                %{ | <strong>mono</strong>} +
+                  %{ <a href="member/set?monolanguage=multi">multi</a>\n} :
+                  %{ | <a href="member/set?monolanguage=mono">mono</a>} +
+                  %{ <strong>multi</strong> } )
     end
     %{<div id="languages">#{list}</div>}
   end
+
+  def set_monolanguage
+    if @request.monolanguage?
+      @monolang = @request.accept_language[0]
+      @check_monolang =  " AND  ?language = :accept_lang " 
+    else
+      @monolang = ''
+      @check_monolang = ''
+    end
+  end
