shoefiti

Check-in [c732c2af6c]
Login

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

Overview
Comment: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.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | master
Files: files | file ages | folders
SHA3-256: c732c2af6cecd208761731581f7425b291df8af059695b0bcebeb680b0eb2367
User & Date: i5ivem@gmail.com 2010-04-29 16:13:05
Context
2010-05-26
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

2010-04-23
13:50
Fix layout again Leaf check-in: 87dd659f52 user: i5ivem@gmail.com tags: trunk, v0.0.1
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to shoefiti.rb.

1
2
3
4
5













































6
7
8
9
10
11
12
..
98
99
100
101
102
103
104
105


106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

123
124


125
126
127

128
129
130
131
132
133
134
...
171
172
173
174
175
176
177









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

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













































	

	#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
................................................................................
		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]
			#debug(emails.length)


			@messagelist.clear{
			stack  do
			emails.each do |message|
				download(url+message) do |data|
					js = JSON.parse(data.response.body)
					@messagelist.append{
						stack :margin => 30, :width => 550 do
								border black, :strokewidth => 2 
								inscription js["headers"]["Date"]
								inscription js["headers"]["From"]
								inscription js["headers"]["Subject"]
								#message body can end up in one of two places
								if js["body"] 
									para js["body"].to_s #Need to sanatize this a bit for output??
								else 
									para js["parts"][0]["body"].to_s
								end

						end
					}


				end
			end
			end}

		end
	end
	
	
	#Actual app stuff
	URL = "http://librelist.com/archives/"

................................................................................
			para " "
		end
	end
	@messagelist = stack :height => 425, :scroll => true 
	init 	

end














>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<
>
>

|
|
|
|
<
|
<
|
|
|
<

|

|

>

<
>
>
|
|
|
>







 







>
>
>
>
>
>
>
>
>
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
...
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
180
...
217
218
219
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
................................................................................
		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/"

................................................................................
			para " "
		end
	end
	@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