shoefiti

Check-in [1a9d98c852]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Not working - further attempts to get Class approach working

* Can't get the message list to draw properly using this class approach.
The Shoes para, etc bits seem to get ignored. As does the @messagelist
(the whole window scrolls)
* Perhaps a class is not the best thing to use: Ideally need to flush each
time as at the moment objects just get added to it for each date that is
clicked on, but old ones aren't removed. Perhaps should use a hash or
array for potential thread sorting, etc.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | master
Files: files | file ages | folders
SHA3-256: 1a9d98c8526ac7084ba34f0cab09795382f0ec8a315ad171770df32201694144
User & Date: i5ivem@gmail.com 2010-05-26 13:02:39
Context
2010-05-26
13:33
Adding README and screenshot check-in: 8a0c949b73 user: i5ivem@gmail.com tags: trunk, master
13:02
Not working - further attempts to get Class approach working

* Can't get the message list to draw properly using this class approach.
The Shoes para, etc bits seem to get ignored. As does the @messagelist
(the whole window scrolls)
* Perhaps a class is not the best thing to use: Ideally need to flush each
time as at the moment objects just get added to it for each date that is
clicked on, but old ones aren't removed. Perhaps should use a hash or
array for potential thread sorting, etc. check-in: 1a9d98c852 user: i5ivem@gmail.com tags: trunk, master

2010-04-29
16:13
WIP! Start using Class for emails, drawing/layout broken

* Have started developing a class for the emails
* Although it still works-ish the layout is a bit broken again
such as the message list now resulting in the whole window scrolling
also message list is not being drawn properly
* Likely due to the class cuasing shoes objects to be out of scope, etc
Need to read and understand Shoes rules. check-in: c732c2af6c user: i5ivem@gmail.com tags: trunk, master

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to shoefiti.rb.

1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
...
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169



170
171
172
173
174
175
176
177
178
179
...
220
221
222
223
224
225
226
227
228
229
230
231
232
require 'rubygems'
require 'date'
require 'json'

Shoes.app :title => "Shoefiti - Librelist Browser", :height => 700, :scroll => false do

class Email

	#What about what class retains in memory? Do I need to flush the class?
	#Perhaps need to hand list, month, day, year attributes. 
	#don't need to rely on time in email. Just set an index based on order that librelist presents them??


	attr_accessor :date, :from, :subject, :body

	def initialize(date, from, subject, body)
		@date = date
		@from = from
		@subject = subject
		@body = body
		#@thread = subject.strip of RE, FW, etc. 
		#Want to set thread. Based on subject?
	end

=begin
	def self.sort_by_thread(thread) ???
		#!
		ObjectSpace.each_object(Email) do |e|
			e.thread == 

	end
=end

	def self.draw_all
		ObjectSpace.each_object(Email) do |e|

			#@messagelist.append{
				stack :margin => 30, :width => 550 do #Is this understood here? Some of this is not working.
					border black, :strokewidth => 2 
					inscription e.date
					inscription e.from
					inscription e.subject
					para e.body.to_s
				end
			#}
		end
	end

end


	

	#Need to be careful not to get months that don't exist (think ok back in time, within reason??)
	def changemonth(direction)
		if direction == :backward
			if @month == 1 #tempting to do "12/".next but no corresponding previous
				@year -= 1
				@month = 12
................................................................................
		else
			day = day.to_s
		end
		url = "http://librelist.com/archives/"+list+"/"+year.to_s+"/"+month.to_s+"/"+day.to_s+"/json/"
		#debug(url)
		download(url) do |data|
			emails = eval(data.response.body)[1]
			
		
			@messagelist.clear{
				stack do
					emails.each do |message|
						download(url+message) do |data|
							js = JSON.parse(data.response.body)
							Email.new(
								js["headers"]["Date"], 
								js["headers"]["From"], 
								js["headers"]["Subject"],
								if js["body"] 
									para js["body"]
								else 
									para js["parts"][0]["body"]
								end
							)
						end
						#Ah but need to be sure thread finished! Could still draw one at a time.
						#Assuming finished:



						Email.draw_all #list, date?
					end
				end
			}
		end
	end
	
	
	#Actual app stuff
	URL = "http://librelist.com/archives/"
................................................................................
	@messagelist = stack :height => 425, :scroll => true 
	init 	

end

#What would make this useful?? 
#Grouping by thread/subject - collapsible sections. 
#
#For now really have to keep everything to "one day" 
#
#How to do this ? Could set up a class! for messages








|
<
|
|
<
>

|

|
|
|
|
|
|
|
|


|
|
|
|

|

|
|
|

|
|
|
|
|
|
|
|
|
|
|

|

<
<







 







<
<
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
<
>
>
>
|
|
<







 







<

|
<

<
1
2
3
4
5
6
7

8
9

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48


49
50
51
52
53
54
55
...
140
141
142
143
144
145
146




147
148
149
150
151
152
153
154
155
156
157
158
159
160


161
162
163
164
165

166
167
168
169
170
171
172
...
213
214
215
216
217
218
219

220
221

222

require 'rubygems'
require 'date'
require 'json'

Shoes.app :title => "Shoefiti - Librelist Browser", :height => 700, :scroll => false do

	class Email 

		#What about what class retains in memory? Do I need to flush the class? Is that even possible?
		#Perhaps need to hand list, month, day, year attributes to draw_all. 

		#Perhaps using a class is not the best way... Use hash or array.

		attr_accessor :date, :from, :subject, :body

		def initialize(date, from, subject, body)
			@date = date
			@from = from
			@subject = subject
			@body = body
			#@thread = subject.strip of RE, FW, etc. 
			#Want to set thread. Based on subject?
		end

=begin
		def self.sort_by_thread(thread) ???
			#!
			ObjectSpace.each_object(Email) do |e|
				e.thread == 

		end
=end
		
		def self.draw_all
			ObjectSpace.each_object(Email) do |e|

				#@messagelist.append{
					$app.stack :margin => 30, :width => 550 do #Is this understood here? Some of this is not working.
						$app.border black, :strokewidth => 2 
						$app.inscription e.date
						$app.inscription e.from
						$app.inscription e.subject
						$app.para e.body.to_s
					end
				#}
			end
		end

	end




	#Need to be careful not to get months that don't exist (think ok back in time, within reason??)
	def changemonth(direction)
		if direction == :backward
			if @month == 1 #tempting to do "12/".next but no corresponding previous
				@year -= 1
				@month = 12
................................................................................
		else
			day = day.to_s
		end
		url = "http://librelist.com/archives/"+list+"/"+year.to_s+"/"+month.to_s+"/"+day.to_s+"/json/"
		#debug(url)
		download(url) do |data|
			emails = eval(data.response.body)[1]




			emails.each do |message|
				download(url+message) do |data|
					js = JSON.parse(data.response.body)
					Email.new(
						js["headers"]["Date"], 
						js["headers"]["From"], 
						js["headers"]["Subject"],
						if js["body"] 
							para js["body"]
						else 
							para js["parts"][0]["body"]
						end
					)
				end


			end
			@messagelist.clear{
				#stack do
					Email.draw_all #list, date?
				#end

			}
		end
	end
	
	
	#Actual app stuff
	URL = "http://librelist.com/archives/"
................................................................................
	@messagelist = stack :height => 425, :scroll => true 
	init 	

end

#What would make this useful?? 
#Grouping by thread/subject - collapsible sections. 

#For now really have to keep everything to "one day"