patchSamizdat - Patches: patch #5883, calendar patch 0.6.1 [vs 080703-2]

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #5883: calendar patch 0.6.1 [vs 080703-2]

Submitter:  Dmitry Borodaenko <angdraug>
Submitted:  Sun 22 Apr 2007 06:24:21 PM UTC
   
 
Category:  None Priority:  7 - High
Status:  In Progress Privacy:  Public
Assigned to:  None Open/Closed:  Open

Jump to the original submission

Mon 30 Mar 2009 12:58:35 PM UTC, comment #7: 

Initial implementation of a calendar can be found in CVS commit at 2009-03-30 11:35. It is incomplete, so the new event controller is disabled with "not implemented" message for those who would stumble upon it accidentally, but the event model, helper and controller classes already have the design of the calendar layed out. Next step is to add second-level precision to TExp Ruby module to support full set of recurrence rules specified in RFC 2445.

Dmitry Borodaenko <angdraug>
Group administrator
Sat 23 Aug 2008 01:17:48 AM UTC, comment #6: 

Version 0.6.1 removes an overlap with the more_links patch, which caused one hunk to fail when patching with version 0.6. This seems to work (at least it patches OK) against 080811-1.


(file #16339)

Boud Roukema <boud>
Group Member
Wed 20 Aug 2008 03:12:47 AM UTC, comment #5: 

Version 0.6 is essentially the same as earlier versions,
apart from the fact that it's a patch against 20080703-2, and there
is some minor tidying up in the coding. The dataset functionality
and RdfDataSet works well for this patch (it doesn't have the
intrinsic difficulty of the monolanguage patch).

PATCH ORTHOGONALITY: A few hunks in the frontpage_controller.rb part of
the patch are likely to fail if applied directly to 20080703-2.
Read the code and judge where a hunk is expected to be placed and
whether or not it is really needed.

STORAGE.RB: added '~' to OPERATOR

TODO:



(file #16319)

Boud Roukema <boud>
Group Member
Thu 01 Nov 2007 02:07:38 PM UTC, comment #4: 

Version 0.5.2 of the calendar patch renders the config['calendar_days'] (default 30) days of future events as the first (upper) section of the left-hand column, followed by the top focuses as before. It's a patch against samizdat-0.6.0.070818-1.



(file #14270)

Boud Roukema <boud>
Group Member
Sat 29 Sep 2007 11:16:06 AM UTC, comment #3: 

Version 0.5.1, against 070818-1, fixes several small bugs
in 0.5, and is a diff against 070818 instead of 070618.





(file #14041)

Boud Roukema <boud>
Group Member
Mon 13 Aug 2007 12:17:14 AM UTC, comment #2: 

version 0.5 works against samizdat-0.6.0.20070618-1

NEW FEATURES:

  • Modifications to frontpage_controller so that the

list of top focuses is not full of dates (all date focuses are
now excluded) and so that the
calendar superfocus doesn't get overemphasised.

  • Calendar date focuses (the content of each is a list of

messages for that date) for today, tomorrow, ...
today + n_days are included at the top of the feature list
on the frontpage, but they are not included in the rss
out-feed. People at other websites interested in feeds of
calendar items can grab the out-feed for the calendar
superfocus.

  • A fontsize modification "tag style" for the list of focuses

on the frontpage is also introduced. This is hardwired due
to lack of time. Of course it should be made configurable
and (probably) turned off by default and possibly modularised
out into css (though it's not obvious to me how easy this would
be).

BUG HACKS:

  • The limit_page limit causes date focuses which were created as

focuses a long time ago to be missed out, even though the date
they refer to is not old, they just happen to have been created
a long time ago. This is probably a deep limitation of the
general approach of this basic calendar patch - the date
information is stored in the titles. The hack i've put in
collected_related and cal_collect_related in
resource_controller.rb is that when the calendar superfocus
is being considered, cal_limit_page = 100 * limit_page is
used. i'm not sure whether this would be a serious waste
of caching space or not. It seems to work as a short term hack.



(file #13655)

Boud Roukema <boud>
Group Member
Tue 08 May 2007 10:26:17 PM UTC, comment #1: 

version 0.4 works for samizdat-0.6.0.20070506

see the attached file



(file #12722)

Boud Roukema <boud>
Group Member
Sun 22 Apr 2007 06:24:21 PM UTC, original submission:  

http://lists.nongnu.org/archive/html/samizdat-devel/2007-03/msg00005.html

--- /tmp/tmp_snapshot/samizdat/lib/samizdat/engine/message.rb      
2007-02-18 18:24:29.000000000 +0100
+++ /usr/lib/ruby/1.8/samizdat/engine/message.rb        2007-02-25
01:37:24.000000000 +0100
@@ -554,7 +567,8 @@
        ]


        # select focus for new message
-      form.push(*t.focus_fields(nil, nil, false)) if
+#      form.push(*t.focus_fields(nil, nil, false)) if
+      form.push(*t.focus_fields(nil, nil, false, false)) if
          @session.access('vote') and @parent.nil?


        # advanced parameters


--- /tmp/tmp_snapshot/samizdat/lib/samizdat/engine/template.rb  2007-02-18
18:51:31.000000000 +0100
+++ /usr/lib/ruby/1.8/samizdat/engine/template.rb       2007-02-24
01:28:58.000000000 +0100
@@ -32,6 +32,31 @@
    # document navigation links (made, start, next, ...)
    attr_accessor :link


+
+ # some calendar constants
+ days_s = [ [0, _("SELECT DAY")] ]
+ for i in 1..31
+ days_s += [ [i, i.to_s] ]
+ end
+ Days_s = days_s
+
+ months_s = []
+ Months_inv = Date::MONTHS.invert
+ for i in 1..12
+# months_s += [ [i, Months_inv[i] ] ] # needs l10n
+ months_s += [ [i, i.to_s ] ]
+ end
+ Months_s = months_s
+
+ years_s = []
+ thisyear= Time.now.year +
+ for i in 0..3 # default 4 years' calendar
+ years_s += [ [thisyear+i, (thisyear+i).to_s] ]
+ end
+ Years_s = years_s
+
+
# HTML header, title, and style settings
#
def head(title='', options={})
@@ -276,6 +301,14 @@
fbox += box(nil,
'<p><a title="'+_('Click to relate this resource to another focus')+%{" href="resource.rb?id=#{related.id}&amp;focus=select">}+_('Add another focus')+'</a></p>'
)
+ if config['calendar']
+ fbox += box(nil,
+ '<p><a title="'+ + _('Click to put this resource in the calendar')+
+ %{"href="resource.rb?id=#{related.id}&amp;focus=select&amp;calendar=start">}+
+ _('Put this in the calendar')+ '</a></p>'
+ )
+ end # if config['calendar']
end
fbox
end
@@ -291,7 +324,18 @@

# form fields for vote on focus rating
#
- def focus_fields(id, focus, advanced=('advanced' == @session.cookie('ui')))
+ def focus_fields(id, focus, calendar, advanced=('advanced' == @session.cookie('ui')))
+ if 'start' == calendar
+ fields =
+ [ [:hidden, 'id', id],
+ [:label, 'calendar_date', _('Select the date at which this event is planned for')],
+ [:select, 'cal_year', Years_s, Time.now.year], + [:select, 'cal_month', Months_s, Time.now.month], + [:select, 'cal_day', Days_s, 0], # default day is invalid day
+ [:hidden, 'rating', 1], + [:hidden, 'calendar', 'send'],
+ ]
+ else
focuses = Focus.collect_focuses {|f,|
[f, Resource.new(@session, f).render(:title)]
}
@@ -318,6 +362,7 @@
else
fields.push([:hidden, 'rating', 1])
end
+ end #end if calendar
end

    # transform date to a standard string representation


--- /tmp/tmp_snapshot/samizdat/cgi-bin/resource.rb      2007-02-02
22:57:24.000000000 +0100
+++ /usr/share/samizdat/cgi-bin/resource.rb     2007-03-05 01:24:31.000000000
+0100
@@ -11,6 +11,7 @@
  # vim: et sw=2 sts=2 ts=8 tw=0


  require 'samizdat/engine'
+#require 'date'


# messages that are related to this focus
#
@@ -31,6 +32,25 @@
ORDER BY ?date DESC}, limit_page, limit_page * skip
).collect {|m,| m } # unwrap DBI::Row
end
+
+ if config['calendar'] and id.to_i == config['calendar']
+ # TODO rewrite this using .collect instead of .each
+ list_titles = []
+ today=Time.now.strftime("%Y-%m-%d") + list.each do |msg|
+ m_title, = rdf.select_one %{
+SELECT ?title
+WHERE (dc::title #{msg} ?title)}
+ if m_title >= today # ignore old events
+ list_titles += [[m_title, msg]] # add a pair
+ end
+ end
+ list_titles.sort! { |a,b| a[0] <=> b[0] }
+
+
+ list = list_titles.collect { |pair| pair[1] }
+
+ end
list.collect {|msg| yield msg }
end

@@ -81,26 +101,127 @@
    body = session.has_key?('skip')? r[:messages] : r.to_s


    # vote on focus rating
-  if session.has_key?('focus') or session.has_key?('focus_id')
+  if session.has_key?('focus') or session.has_key?('focus_id') or
+      (session.has_key?('calendar') and config['calendar'])
      session.access('vote') or raise AuthError,
        sprintf(_('Your current access level (%s) does not allow to vote'),
          _(session.role))


- focus, focus_id, rating = session.params %w[focus focus_id rating]
+ # focus, focus_id, rating = session.params %w[focus focus_id rating]
+ focus, focus_id, rating, calendar, cal_year, cal_month, cal_day, creator, format, description = + session.params %w[focus focus_id rating calendar cal_year cal_month cal_day creator format description]
+
focus = nil if 'select' == focus
+
+ # julian date if date is valid, otherwise set to nil
+ jd= Date::valid_civil?(cal_year.to_i, cal_month.to_i, cal_day.to_i) +
+ if 'send' == calendar and config['calendar'] + if jd
+ dd = cal_day.to_s
+ dd = "0" + dd if cal_day.to_i < 10
+ mm = cal_month.to_s + mm = "0" + mm if cal_month.to_i < 10 +
+ focus_title= cal_year.to_s + "-" + mm + "-" + dd
+
+ # find out if a message for this date already exists
+ db.transaction do |db|
+ focus_id, = db.select_one 'SELECT id FROM Message
+ WHERE title = ? AND version_of is NULL', focus_title
+ end
+ if focus_id
+ # do nothing
+ else
+ # calendar focus is created as open for editing by members
+ if config['locale']['languages'][0]
+ lang= config['locale']['languages'][0]
+ else
+ lang= NULL
+ end
+ + message = PublishMessage.new(session)
+
+ db.transaction do |db|
+ focus_id, = rdf.assert( %{
+INSERT ?msg
+WHERE (dc::creator ?msg :creator)
+ (dc::title ?msg :title)
+ (dc::language ?msg :language)
+ (dc::format ?msg :format)
+ (dc::description ?msg :desc)
+ (s::content ?msg :content)
+ (s::openForAll ?msg :open)
+ (s::inReplyTo ?msg :parent)
+},
+ { + :creator => creator, + :title => focus_title, + :language => lang,
+ :format => 'text/textile',
+ :desc => description, + :content => ' ',
+ :open => true, + :parent => nil
+ } )
+ end # db.transaction
+ end # if focus_id
+
+ # add link (editing is open, so this is not hardwiring) + db.transaction do |db|
+ f_content, = db.select_one 'SELECT content FROM Message
+ WHERE id = ? ', focus_id
+ m_title, = db.select_one 'SELECT title FROM Message
+ WHERE id = ? ', id
+ db.do 'UPDATE Message SET content = ? WHERE id = ? ', + f_content + %{\n"} + m_title + %{":/} + id.to_s + %{\n}, + focus_id + db.do 'UPDATE Message SET format = ? WHERE id = ? ', + "text/textile", focus_id + db.do 'UPDATE Message SET html_full = NULL WHERE id = ? ', + focus_id + db.do 'UPDATE Message SET html_short = NULL WHERE id = ? ', + focus_id + cache.flush # to regenerate html_full and html_short from new content
+ MessageContent.regenerate_html(focus_id)
+ end # db.transaction do |db|
+
+ calendar_superfocus = config['calendar']
+ else # invalid date - try again
+ calendar = 'start'
+ end
+ end # if 'send' == calendar
+
+
if focus_id = Resource.validate_id(focus_id)
# manual entry overrides selection
focus = focus_id
end
+ focus_id = focus # needed for Resource.new +# old_id = id # needed for session.redirect
focus = Focus.new(session, focus, resource) if focus

if focus.kind_of?(Focus) and rating # commit vote
# rating is validated by Focus#rating=
db.transaction {|db| focus.rating = rating }
- session.redirect(id.to_s)
+
+ if Resource.validate_id(calendar_superfocus)
+ focus_r = Resource.new(session, focus_id) # focus as Resource object
+ calendar_superfocus = Focus.new(session, calendar_superfocus, focus_r) + if calendar_superfocus.kind_of?(Focus)
+ db.transaction {|db| calendar_superfocus.rating = rating }
+ end
+ session.redirect(focus_id.to_s) # otherwise session may be confused
+ else
+ session.redirect(id.to_s)
+ end
+
+
+# session.redirect(old_id.to_s)
else # display vote form
vote_form = t.form( 'resource.rb',
- *t.focus_fields(id, focus) +
+# *t.focus_fields(id, focus) +
+ *t.focus_fields(id, focus, calendar) +
[ [:br], [:submit, nil, _('Submit')] ]
)
next t.page(_('Vote') + ': ' + r[:head],

Dmitry Borodaenko <angdraug>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #16339:  080823_calendar-0.6.1.patch added by boud (18KiB - text/x-patch)
file #16319:  080820_calendar-0.6.patch added by boud (18KiB - text/x-patch)
file #14270:  071101_calendar_0.5.2.patch added by boud (15KiB - text/x-patch)
file #14041:  070929_calendar_0.5.1.patch added by boud (13KiB - text/x-patch)
file #13655:  070813_calendar_0.5.patch added by boud (16KiB - text/x-patch)
file #12722:  calpatch added by boud (8KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by boud (Updated the item)
  • -email is unavailable- added by angdraug (Submitted the item)
  •  

    Follow 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2008-08-23 boud Attached File- Added 080823_calendar-0.6.1.patch, #16339
        Summarycalendar patch 0.6 [vs 080703-2] calendar patch 0.6.1 [vs 080703-2]
    2008-08-20 boud Summarycalendar patch 0.5.2 calendar patch 0.6 [vs 080703-2]
    2008-08-20 boud Attached File- Added 080820_calendar-0.6.patch, #16319
    2007-11-01 boud Attached File- Added 071101_calendar_0.5.2.patch, #14270
        Summarycalendar patch 0.5.1 calendar patch 0.5.2
    2007-09-29 boud Summarycalendar patch 0.5 calendar patch 0.5.1
    2007-09-29 boud Attached File- Added 070929_calendar_0.5.1.patch, #14041
    2007-08-13 boud Attached File- Added 070813_calendar_0.5.patch, #13655
        Summarycalendar patch 0.4 calendar patch 0.5
    2007-05-08 boud Attached File- Added calpatch, #12722
        Summarycalendar patch 0.3 calendar patch 0.4

    Back to the top

    Powered by Savane 3.13-269c.
    Corresponding source code