Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 150 lines (127 sloc) 3.542 kb
9441946 @nedry first commit
authored
1 require "messagestrings.rb"
2
3 class Session
4
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
5 def displaybull(number)
6 bulletin = fetch_bulletin(number)
7 print
c732cce @nedry color fixes prompt fixes menu fixes
authored
8 print "%R;#%W;#{number} %G; #{bulletin.name}"
98f6676 @nedry fixed the colour codes
authored
9 print "%C;Path: %G;#{bulletin.path}"
87c7ba1 @martindemello undo accidental overwriting of commit 6262136dd5358a97287158c98c745c5bb0...
martindemello authored
10 end
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
11
12 def bullmaint
13
14 readmenu(
87c7ba1 @martindemello undo accidental overwriting of commit 6262136dd5358a97287158c98c745c5bb0...
martindemello authored
15 :initval => 1,
16 :range => 1..(b_total),
8be7097 @nedry themes basically working
authored
17 :loc => BULLETIN
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
18 ) {|sel, bpointer, moved|
19 if !sel.integer?
20 parameters = Parse.parse(sel)
21 sel.gsub!(/[-\d]/,"")
22 end
23
24 displaybull(bpointer) if moved
25
26 case sel
27 when "/"; showbulletin(bpointer)
106ec2a @nedry email, userconfig, web updates
authored
28 when "Q"; bpointer = true
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
29 when "W"; displaywho
30 when "PU";page
31 when "A"; addbulletin
32 when "P"; changebulletinpath(bpointer)
33 when "N"; changebulletinname(bpointer)
34 when "K"; deletebulletin(bpointer)
35 when "G"; leave
36 when "?"; gfileout ("bullmnu")
37 end # of case
38 p_return = [bpointer,(b_total)]
39 }
87c7ba1 @martindemello undo accidental overwriting of commit 6262136dd5358a97287158c98c745c5bb0...
martindemello authored
40 end
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
41
42 def addbulletin
43
ba4aa75 @nedry datamapper updates
authored
44 name = getinp("Enter new bulletin name: ",:nonempty)
45 path = getinp("Enter new bulletin path: ",:nonempty)
c732cce @nedry color fixes prompt fixes menu fixes
authored
46 if yes("Are you sure #{YESNO}", true, false,true)
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
47 add_bulletin(name, path)
48 else
c732cce @nedry color fixes prompt fixes menu fixes
authored
49 print "%WR; Aborted. %W;"
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
50 end
51 print
9441946 @nedry first commit
authored
52 end
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
53
54 def changebulletinname(bpointer)
55
56 bulletin = fetch_bulletin(bpointer)
87c7ba1 @martindemello undo accidental overwriting of commit 6262136dd5358a97287158c98c745c5bb0...
martindemello authored
57 name = getinp("Enter new bulletin name: ")
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
58 if name !='' then
59 bulletin.name = name
60 update_bulletin(bulletin)
87c7ba1 @martindemello undo accidental overwriting of commit 6262136dd5358a97287158c98c745c5bb0...
martindemello authored
61 else
98f6676 @nedry fixed the colour codes
authored
62 print "%WR;Not Changed.%W;"
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
63 end
64 print
65 end
66
67 def changebulletinpath(bpointer)
68
69 bulletin = fetch_bulletin(bpointer)
70 print CHANGEBULLETINPATHWARNING
87c7ba1 @martindemello undo accidental overwriting of commit 6262136dd5358a97287158c98c745c5bb0...
martindemello authored
71 path = getinp("Enter new bulletin path: ")
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
72 if path != ""
73 bulletin.path = path
74 update_bulletin(bulletin)
75 print
76 else
c732cce @nedry color fixes prompt fixes menu fixes
authored
77 print "%WR; Not Changed. %W;"
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
78 end
9441946 @nedry first commit
authored
79 end
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
80
81 def deletebulletin(bpointer)
82 if bpointer > 0 then
83 delete_bulletin(bpointer)
84 renumber_bulletins
85 bpointer = b_total if bpointer > b_total
86 else
87 print NOBULLETINERROR
88 end
89 end
90
91 def showbulletin(bpointer)
92 if b_total > 0 then
93 displaybull(bpointer)
87c7ba1 @martindemello undo accidental overwriting of commit 6262136dd5358a97287158c98c745c5bb0...
martindemello authored
94 else
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
95 print
c732cce @nedry color fixes prompt fixes menu fixes
authored
96 print "%WR; No bulletins. Why not add one? %W;"
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
97 end
98 end
99
100 #-------------------Bulletin Section-------------------
101
102 def displaybullet
a5d4b17 @nedry you can select a theme. it doesn't do anything yet...
authored
103
104
105
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
106 i = 0
107 if b_total < 1 then
c732cce @nedry color fixes prompt fixes menu fixes
authored
108 print "%WR; No Bulletins %W;"
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
109 return
110 end
a5d4b17 @nedry you can select a theme. it doesn't do anything yet...
authored
111 ogfileout("bullethdr",0,true)
112 if !existfileout('bulletins',0,true)
98f6676 @nedry fixed the colour codes
authored
113 print "%G;Bulletins Available:"
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
114 for i in 1..(b_total)
115 bulletin = fetch_bulletin(i)
98f6676 @nedry fixed the colour codes
authored
116 print " %B;#{i}...%G;#{bulletin.name}"
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
117 end
a5d4b17 @nedry you can select a theme. it doesn't do anything yet...
authored
118 end
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
119 print
120 end
121
122 def bullets(parameters)
87c7ba1 @martindemello undo accidental overwriting of commit 6262136dd5358a97287158c98c745c5bb0...
martindemello authored
123 t = (parameters[0] > 0) ? parameters[0] : 0
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
124
125 if t == 0 then
126 displaybullet if !existfileout('bulletins',0,true)
98f6676 @nedry fixed the colour codes
authored
127 prompt = "\r\n%W;Bulletin #[1-#{b_total}] ? #{RET} to quit: "
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
128 while true
106ec2a @nedry email, userconfig, web updates
authored
129 # getinp(prompt, :nonempty) {|inp| <-- removed :nonempty which prevents the loop from exiting on <return>
130 getinp(prompt) {|inp|
87c7ba1 @martindemello undo accidental overwriting of commit 6262136dd5358a97287158c98c745c5bb0...
martindemello authored
131 happy = inp.upcase
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
132 t = happy.to_i
133 case happy
134 when "CR"; crerror
8be7097 @nedry themes basically working
authored
135 when @cmd_hash["bullquit"] ; run_if_ulevel("bullquit") {return}
5930585 @nedry configurable commands
authored
136 when @cmd_hash["bullmenu"] ; run_if_ulevel("bullmenu") {displaybullet}
8be7097 @nedry themes basically working
authored
137 when ""; return
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
138 else
87c7ba1 @martindemello undo accidental overwriting of commit 6262136dd5358a97287158c98c745c5bb0...
martindemello authored
139 if t > 0 and t <= b_total then
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
140 bulletin = fetch_bulletin(t)
879cc95 @nedry adding customizable commands
authored
141 ogfileout(bulletin.path,1,true) #if @bulletins.has_index?(t)
4e69942 @martindemello run rbeautify over the .rb files and remove executable bit
martindemello authored
142 end
143 end #of case
144 }
145 end
146 end
87c7ba1 @martindemello undo accidental overwriting of commit 6262136dd5358a97287158c98c745c5bb0...
martindemello authored
147 end
9441946 @nedry first commit
authored
148
149 end #class Session
Something went wrong with that request. Please try again.