opengl 0.8.0-x86-mingw32 → 0.9.0-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +1 -0
  3. data.tar.gz.sig +2 -0
  4. data/.gitignore +2 -1
  5. data/.travis.yml +19 -0
  6. data/History.rdoc +26 -0
  7. data/Manifest.txt +3 -23
  8. data/README.rdoc +43 -37
  9. data/Rakefile +6 -62
  10. data/examples/NeHe/nehe_lesson02.rb +3 -2
  11. data/examples/NeHe/nehe_lesson03.rb +3 -2
  12. data/examples/NeHe/nehe_lesson04.rb +3 -1
  13. data/examples/NeHe/nehe_lesson05.rb +4 -1
  14. data/examples/NeHe/nehe_lesson06.rb +9 -6
  15. data/examples/NeHe/nehe_lesson07.rb +9 -6
  16. data/examples/NeHe/nehe_lesson08.rb +9 -6
  17. data/examples/NeHe/nehe_lesson09.rb +10 -6
  18. data/examples/NeHe/nehe_lesson11.rb +9 -6
  19. data/examples/NeHe/nehe_lesson12.rb +9 -6
  20. data/examples/NeHe/nehe_lesson16.rb +50 -47
  21. data/examples/NeHe/nehe_lesson19.rb +10 -7
  22. data/examples/NeHe/nehe_lesson36.rb +234 -229
  23. data/examples/OrangeBook/brick.rb +227 -225
  24. data/examples/OrangeBook/particle.rb +233 -231
  25. data/examples/RedBook/aapoly.rb +71 -70
  26. data/examples/RedBook/aargb.rb +54 -52
  27. data/examples/RedBook/accanti.rb +96 -94
  28. data/examples/RedBook/accpersp.rb +106 -104
  29. data/examples/RedBook/alpha.rb +54 -52
  30. data/examples/RedBook/alpha3D.rb +90 -88
  31. data/examples/RedBook/bezcurve.rb +48 -46
  32. data/examples/RedBook/bezmesh.rb +71 -69
  33. data/examples/RedBook/checker.rb +57 -55
  34. data/examples/RedBook/clip.rb +41 -39
  35. data/examples/RedBook/colormat.rb +72 -70
  36. data/examples/RedBook/cube.rb +39 -37
  37. data/examples/RedBook/depthcue.rb +37 -35
  38. data/examples/RedBook/dof.rb +110 -109
  39. data/examples/RedBook/double.rb +40 -38
  40. data/examples/RedBook/drawf.rb +30 -28
  41. data/examples/RedBook/feedback.rb +79 -77
  42. data/examples/RedBook/fog.rb +90 -89
  43. data/examples/RedBook/font.rb +78 -76
  44. data/examples/RedBook/hello.rb +29 -27
  45. data/examples/RedBook/image.rb +57 -55
  46. data/examples/RedBook/jitter.rb +131 -131
  47. data/examples/RedBook/light.rb +2 -1
  48. data/examples/RedBook/lines.rb +70 -68
  49. data/examples/RedBook/list.rb +48 -46
  50. data/examples/RedBook/material.rb +200 -199
  51. data/examples/RedBook/mipmap.rb +84 -82
  52. data/examples/RedBook/model.rb +55 -53
  53. data/examples/RedBook/movelight.rb +52 -50
  54. data/examples/RedBook/pickdepth.rb +103 -101
  55. data/examples/RedBook/planet.rb +46 -44
  56. data/examples/RedBook/quadric.rb +97 -95
  57. data/examples/RedBook/robot.rb +55 -53
  58. data/examples/RedBook/select.rb +118 -116
  59. data/examples/RedBook/smooth.rb +35 -33
  60. data/examples/RedBook/stencil.rb +96 -94
  61. data/examples/RedBook/stroke.rb +75 -73
  62. data/examples/RedBook/surface.rb +93 -91
  63. data/examples/RedBook/teaambient.rb +71 -69
  64. data/examples/RedBook/teapots.rb +105 -103
  65. data/examples/RedBook/tess.rb +96 -94
  66. data/examples/RedBook/texbind.rb +79 -77
  67. data/examples/RedBook/texgen.rb +88 -86
  68. data/examples/RedBook/texturesurf.rb +57 -55
  69. data/examples/RedBook/varray.rb +85 -83
  70. data/examples/RedBook/wrap.rb +76 -74
  71. data/examples/misc/OGLBench.rb +114 -113
  72. data/examples/misc/anisotropic.rb +154 -152
  73. data/examples/misc/fbo_test.rb +37 -36
  74. data/examples/misc/font-glut.rb +47 -46
  75. data/examples/misc/glfwtest.rb +16 -16
  76. data/examples/misc/plane.rb +13 -13
  77. data/examples/misc/readpixel.rb +66 -65
  78. data/examples/misc/sdltest.rb +21 -19
  79. data/examples/misc/trislam.rb +548 -547
  80. data/ext/opengl/common.h +16 -38
  81. data/ext/opengl/conv.h +39 -41
  82. data/ext/opengl/extconf.rb +4 -31
  83. data/ext/opengl/funcdef.h +126 -124
  84. data/ext/opengl/gl-1.0-1.1.c +1917 -1917
  85. data/ext/opengl/gl-1.2.c +4 -667
  86. data/ext/opengl/gl-1.3.c +9 -9
  87. data/ext/opengl/gl-1.4.c +8 -8
  88. data/ext/opengl/gl-1.5.c +1 -1
  89. data/ext/opengl/gl-2.0.c +392 -388
  90. data/ext/opengl/gl-3.0.c +493 -0
  91. data/ext/opengl/gl-enums.c +1523 -5
  92. data/ext/opengl/gl-enums.h +4679 -122
  93. data/ext/opengl/gl-error.c +7 -7
  94. data/ext/opengl/gl-error.h +4 -4
  95. data/ext/opengl/gl-ext-arb.c +468 -464
  96. data/ext/opengl/gl-ext-ext.c +18 -18
  97. data/ext/opengl/gl-ext-nv.c +15 -15
  98. data/ext/opengl/gl.c +2 -0
  99. data/ext/opengl/gl_buffer.c +92 -92
  100. data/ext/opengl/opengl.c +1 -7
  101. data/lib/opengl.rb +23 -59
  102. data/lib/opengl/1.9/opengl.so +0 -0
  103. data/lib/opengl/2.0/opengl.so +0 -0
  104. data/lib/opengl/2.1/opengl.so +0 -0
  105. data/lib/opengl/test_case.rb +1 -2
  106. data/test/dummy.xorg.conf +140 -0
  107. data/test/test_gl.rb +18 -22
  108. data/test/test_gl_10_11.rb +220 -220
  109. data/test/test_gl_12.rb +11 -122
  110. data/test/test_gl_13.rb +202 -210
  111. data/test/test_gl_14.rb +16 -19
  112. data/test/test_gl_15.rb +2 -4
  113. data/test/test_gl_20.rb +45 -58
  114. data/test/test_gl_21.rb +46 -163
  115. data/test/test_gl_ext_arb.rb +54 -72
  116. data/test/test_gl_ext_ati.rb +0 -2
  117. data/test/test_gl_ext_ext.rb +66 -66
  118. data/test/test_gl_ext_gremedy.rb +8 -15
  119. data/test/test_gl_ext_nv.rb +109 -112
  120. data/test/test_opengl_buffer.rb +8 -25
  121. data/utils/README +0 -5
  122. data/utils/enumgen.rb +72 -76
  123. data/utils/extlistgen.rb +55 -55
  124. metadata +90 -67
  125. metadata.gz.sig +0 -0
  126. data/Rakefile.cross +0 -107
  127. data/docs/build_install.txt +0 -119
  128. data/docs/extensions.txt.in +0 -348
  129. data/docs/history.txt +0 -66
  130. data/docs/requirements_and_design.txt +0 -117
  131. data/docs/roadmap.txt +0 -28
  132. data/docs/scientific_use.txt +0 -35
  133. data/docs/supplies/page_template.html +0 -71
  134. data/docs/thanks.txt +0 -29
  135. data/docs/tutorial.txt +0 -469
  136. data/ext/opengl/glu-enums.c +0 -164
  137. data/ext/opengl/glu-enums.h +0 -463
  138. data/ext/opengl/glu.c +0 -1534
  139. data/ext/opengl/glut.c +0 -1145
  140. data/ext/opengl/glut_callbacks.c +0 -845
  141. data/lib/glu.rb +0 -1
  142. data/lib/glut.rb +0 -1
  143. data/lib/opengl/opengl.so +0 -0
  144. data/test/test_glu.rb +0 -309
  145. data/utils/mkdn2html.rb +0 -59
  146. data/utils/post-mkdn2html.rb +0 -91
  147. data/website/images/ogl.jpg +0 -0
  148. data/website/images/tab_bottom.gif +0 -0
  149. data/website/style.css +0 -198
data/lib/glu.rb DELETED
@@ -1 +0,0 @@
1
- require 'opengl'
@@ -1 +0,0 @@
1
- require 'opengl'
Binary file
@@ -1,309 +0,0 @@
1
- #
2
- # Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
3
- #
4
- # This program is distributed under the terms of the MIT license.
5
- # See the included MIT-LICENSE file for the terms of this license.
6
- #
7
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8
- # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
10
- # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
11
- # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
12
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
13
- # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
- #
15
-
16
- require 'opengl/test_case'
17
-
18
- class TestGlu < OpenGL::TestCase
19
-
20
- def test_gluortho
21
- res = [ [2.0/WINDOW_SIZE, 0, 0, 0],
22
- [0, 2.0/WINDOW_SIZE, 0, 0],
23
- [0, 0, -1, 0],
24
- [-1, -1, 0, 1] ]
25
-
26
- glMatrixMode(GL_PROJECTION)
27
- glLoadIdentity()
28
- gluOrtho2D(0, WINDOW_SIZE, 0, WINDOW_SIZE)
29
- assert_equal res, glGetDoublev(GL_PROJECTION_MATRIX)
30
- end
31
-
32
- def test_glugetstring
33
- refute_empty gluGetString GLU_VERSION
34
- end
35
-
36
- def test_gluerrorstring
37
- refute_empty gluErrorString GL_INVALID_VALUE
38
- end
39
-
40
- def test_glubuild2dmipmaps
41
- textures = glGenTextures(1)
42
- glBindTexture(GL_TEXTURE_2D, textures[0])
43
-
44
- image = ([0, 0, 0, 1, 1, 1] * 8).pack("f*") # 16 RGB pixels
45
-
46
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB8, 4, 4, GL_RGB, GL_FLOAT, image)
47
- im = glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT)
48
-
49
- assert_equal image, im
50
- assert_equal 4*4*3, im.unpack("f*").size
51
-
52
- im = glGetTexImage(GL_TEXTURE_2D, 1, GL_RGB, GL_FLOAT)
53
- assert_equal 2*2*3, im.unpack("f*").size
54
-
55
- im = glGetTexImage(GL_TEXTURE_2D, 2, GL_RGB, GL_FLOAT)
56
- assert_equal 1*1*3, im.unpack("f*").size
57
-
58
- glDeleteTextures(textures)
59
- end
60
-
61
- def test_glubuild1dmipmaps
62
- textures = glGenTextures(1)
63
- glBindTexture(GL_TEXTURE_1D, textures[0])
64
-
65
- image = ([0, 0, 0, 1, 1, 1] * 2).pack("f*") # 4 RGB pixels
66
-
67
- gluBuild1DMipmaps(GL_TEXTURE_1D, GL_RGB8, 4, GL_RGB, GL_FLOAT, image)
68
-
69
- im = glGetTexImage(GL_TEXTURE_1D, 0, GL_RGB, GL_FLOAT)
70
- assert_equal image, im
71
- assert_equal 4*3, im.unpack("f*").size
72
- im = glGetTexImage(GL_TEXTURE_1D, 1, GL_RGB, GL_FLOAT)
73
- assert_equal 2*3, im.unpack("f*").size
74
- im = glGetTexImage(GL_TEXTURE_1D, 2, GL_RGB, GL_FLOAT)
75
- assert_equal 1*3, im.unpack("f*").size
76
-
77
- glDeleteTextures(textures)
78
- end
79
-
80
- def test_glulookat
81
- m = [[0, 0, 1, 0], [0, 1, 0, 0], [-1, 0, 0, 0], [0, 0, -1, 1]]
82
- gluLookAt(1, 0, 0, 0, 0, 0, 0, 1, 0)
83
- assert_equal m, glGetDoublev(GL_PROJECTION_MATRIX)
84
- end
85
-
86
- def test_gluproject
87
- pos = gluProject(1, 1, 1)
88
- assert_equal [WINDOW_SIZE, WINDOW_SIZE, 1], pos
89
-
90
- mp = glGetDoublev(GL_PROJECTION_MATRIX)
91
- mm = Matrix.rows(glGetDoublev(GL_MODELVIEW_MATRIX))
92
- view = glGetDoublev(GL_VIEWPORT)
93
- pos = gluProject(1, 1, 1, mp, mm, view)
94
- assert_equal(pos, [WINDOW_SIZE, WINDOW_SIZE, 1])
95
-
96
- assert_raises ArgumentError do pos = gluProject(1, 1, 1, mp, [1, 2, 3, 4], view) end
97
- end
98
-
99
- def test_gluunproject
100
- pos = gluUnProject(WINDOW_SIZE, WINDOW_SIZE, 1)
101
- assert_equal(pos, [1, 1, 1])
102
-
103
- mp = glGetDoublev(GL_PROJECTION_MATRIX)
104
- mm = Matrix.rows(glGetDoublev(GL_MODELVIEW_MATRIX))
105
- view = glGetDoublev(GL_VIEWPORT)
106
- pos = gluUnProject(WINDOW_SIZE, WINDOW_SIZE, 1, mp, mm, view)
107
- assert_equal(pos, [1, 1, 1])
108
- assert_raises ArgumentError do pos = gluUnProject(WINDOW_SIZE, WINDOW_SIZE, 1, mp, [1, 2, 3, 4], view) end
109
- end
110
-
111
- def test_glupickmatrix
112
- t = WINDOW_SIZE / 5.0
113
- m = [[t, 0.0, 0.0, 0.0], [0.0, t, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [t, t, 0.0, 1.0]]
114
- glMatrixMode(GL_PROJECTION)
115
-
116
- glLoadIdentity()
117
- gluPickMatrix(0, 0)
118
- assert_each_in_delta m, glGetDoublev(GL_PROJECTION_MATRIX)
119
-
120
- glLoadIdentity()
121
- gluPickMatrix(0, 0, 5, 5)
122
- assert_each_in_delta m, glGetDoublev(GL_PROJECTION_MATRIX)
123
-
124
- glLoadIdentity()
125
- gluPickMatrix(0, 0, 5, 5, glGetDoublev(GL_VIEWPORT))
126
- assert_each_in_delta m, glGetDoublev(GL_PROJECTION_MATRIX)
127
- end
128
-
129
- def test_gluperspective
130
- m = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, -3, -1], [0, 0, -4, 0]]
131
- gluPerspective(90, 1, 1, 2)
132
- assert_equal m, glGetDoublev(GL_PROJECTION_MATRIX)
133
- end
134
-
135
- def test_gluscaleimage
136
- image = ([0, 0, 0, 1, 1, 1] * 8).pack("f*") # 16 RGB pixels
137
- scaled = gluScaleImage(GL_RGB, 4, 4, GL_FLOAT, image, 2, 2, GL_FLOAT)
138
- assert_equal(scaled.unpack("f*").length, 2*2*3)
139
- end
140
-
141
- def test_gluquadrics
142
- ecount = 0
143
- error_func = lambda do |error|
144
- ecount+=1
145
- end
146
-
147
- q = gluNewQuadric()
148
- gluQuadricDrawStyle(q, GL_LINE)
149
- gluQuadricNormals(q, GL_SMOOTH)
150
- gluQuadricOrientation(q, GLU_OUTSIDE)
151
- gluQuadricTexture(q, GL_FALSE)
152
- gluQuadricCallback(q, GLU_ERROR, error_func)
153
-
154
- buf = glFeedbackBuffer(1024, GL_3D)
155
- glRenderMode(GL_FEEDBACK)
156
- gluSphere(q, 1.0, 4, 3)
157
- count = glRenderMode(GL_RENDER)
158
- refute_equal 0, count
159
-
160
- glRenderMode(GL_FEEDBACK)
161
- gluCylinder(q, 1.0, 1.0, 1.0, 4, 3)
162
- count = glRenderMode(GL_RENDER)
163
- refute_equal 0, count
164
-
165
- glRenderMode(GL_FEEDBACK)
166
- gluDisk(q, 1.0, 2.0, 4, 3)
167
- count = glRenderMode(GL_RENDER)
168
- refute_equal 0, count
169
-
170
- glRenderMode(GL_FEEDBACK)
171
- gluPartialDisk(q, 1.0, 2.0, 4, 3, 0, 360)
172
- count = glRenderMode(GL_RENDER)
173
- refute_equal 0, count
174
-
175
- assert_equal 0, ecount
176
- gluSphere(q, 0.0, 0, 0)
177
- assert_equal 1, ecount
178
- gluDeleteQuadric(q)
179
- end
180
-
181
- def test_glunurbs
182
- ecount = 0
183
-
184
- glViewport(0, 0, WINDOW_SIZE, WINDOW_SIZE)
185
- glMatrixMode(GL_PROJECTION)
186
- glOrtho(0, WINDOW_SIZE, 0, WINDOW_SIZE, -1, 1)
187
-
188
- n_error = lambda do |error|
189
- ecount += 1
190
- end
191
-
192
- m = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
193
- m2 = Matrix.rows(m)
194
-
195
- n = gluNewNurbsRenderer()
196
- gluNurbsCallback(n, GLU_ERROR, n_error)
197
- gluNurbsProperty(n, GLU_SAMPLING_TOLERANCE, 40)
198
- assert_equal 40, gluGetNurbsProperty(n, GLU_SAMPLING_TOLERANCE)
199
-
200
- gluLoadSamplingMatrices(n, m, m2, glGetIntegerv(GL_VIEWPORT))
201
- assert_raises ArgumentError do gluLoadSamplingMatrices(n, m, [1, 2, 3, 4], glGetIntegerv(GL_VIEWPORT)) end
202
-
203
- knots = [0, 0, 0, 0, 1, 1, 1, 1]
204
- ctlpoints_curve = [[50, 50, 0], [400, 50, 0], [400, 400, 0], [50, 400, 0]]
205
-
206
- # generate surface control points
207
- ctlpoints = Array.new(4).collect { Array.new(4).collect { Array.new(3, nil) } } # 4*4*3 array
208
- 0.upto(3) do |u|
209
- 0.upto(3) do |v|
210
- ctlpoints[u][v][0]=2.0*(u-1.5)
211
- ctlpoints[u][v][1]=2.0*(v-1.5)
212
-
213
- if ((u==1 || u==2) && (v==1 || v==2))
214
- ctlpoints[u][v][2]=6.0
215
- else
216
- ctlpoints[u][v][2]=0.0
217
- end
218
- end
219
- end
220
-
221
- buf = glFeedbackBuffer(1024*1024*8, GL_3D) # large enough buffer for tesselated surface
222
- glRenderMode(GL_FEEDBACK)
223
- gluBeginCurve(n)
224
- gluNurbsCurve(n, knots, ctlpoints_curve, 4, GL_MAP1_VERTEX_3)
225
- gluEndCurve(n)
226
-
227
- gluBeginSurface(n)
228
- gluNurbsSurface(n, knots, knots, ctlpoints, 4, 4, GL_MAP2_VERTEX_3)
229
- gluEndSurface(n)
230
-
231
- count = glRenderMode(GL_RENDER)
232
- refute_equal 1, count
233
-
234
- assert_equal 0, ecount
235
- gluBeginTrim(n)
236
- gluPwlCurve(n, [[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]], GLU_MAP1_TRIM_2)
237
- gluEndTrim(n)
238
-
239
- gluDeleteNurbsRenderer(n)
240
- assert_equal 1, ecount
241
- end
242
-
243
- def test_glutess
244
- glViewport(0, 0, WINDOW_SIZE, WINDOW_SIZE)
245
- glMatrixMode(GL_PROJECTION)
246
- glOrtho(0, WINDOW_SIZE, 0, WINDOW_SIZE, -1, 1)
247
- vcount, bcount, ecount = 0, 0, 0
248
-
249
- cb_begin = lambda do |type|
250
- bcount += 1
251
- end
252
- cb_end = lambda do
253
- ecount += 1
254
- end
255
- cb_vertex = lambda do |data|
256
- vcount += 1
257
- end
258
- cb_error = lambda do |error|
259
- p gluErrorString(error)
260
- end
261
-
262
- t = gluNewTess()
263
- gluTessCallback(t, GLU_TESS_BEGIN, cb_begin)
264
- gluTessCallback(t, GLU_TESS_END, cb_end)
265
- gluTessCallback(t, GLU_TESS_ERROR, cb_error)
266
- gluTessCallback(t, GLU_TESS_VERTEX, cb_vertex)
267
- gluTessProperty(t, GLU_TESS_BOUNDARY_ONLY, GL_TRUE)
268
- assert_equal GL_TRUE, gluGetTessProperty(t, GLU_TESS_BOUNDARY_ONLY)
269
- gluTessProperty(t, GLU_TESS_BOUNDARY_ONLY, GL_FALSE)
270
- assert_equal GL_FALSE, gluGetTessProperty(t, GLU_TESS_BOUNDARY_ONLY)
271
-
272
- gluTessNormal(t, 0.0, 0.0, 0.0)
273
-
274
- rect = [[50.0, 50.0, 0.0],
275
- [200.0, 50.0, 0.0],
276
- [200.0, 200.0, 0.0],
277
- [50.0, 200.0, 0.0]]
278
- tri = [[75.0, 75.0, 0.0],
279
- [125.0, 175.0, 0.0],
280
- [175.0, 75.0, 0.0]]
281
-
282
- gluTessBeginPolygon(t, nil)
283
- gluTessBeginContour(t)
284
- gluTessVertex(t, rect[0], rect[0])
285
- gluTessVertex(t, rect[1], rect[1])
286
- gluTessVertex(t, rect[2], rect[2])
287
- gluTessVertex(t, rect[3], rect[3])
288
- gluTessEndContour(t)
289
- gluTessBeginContour(t)
290
- gluTessVertex(t, tri[0], tri[0])
291
- gluTessVertex(t, tri[1], tri[1])
292
- gluTessVertex(t, tri[2], tri[2])
293
- gluTessEndContour(t)
294
- gluTessEndPolygon(t)
295
-
296
- gluTessCallback(t, GLU_TESS_BEGIN, nil)
297
- gluTessCallback(t, GLU_TESS_END, nil)
298
- gluTessCallback(t, GLU_TESS_ERROR, nil)
299
- gluTessCallback(t, GLU_TESS_VERTEX, nil)
300
-
301
- gluDeleteTess(t)
302
-
303
- assert_equal 1, bcount
304
- assert_equal 1, ecount
305
- assert_equal 9, vcount
306
- end
307
-
308
- end
309
-
@@ -1,59 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
4
- #
5
- # This program is distributed under the terms of the MIT license.
6
- # See the included MIT-LICENSE file for the terms of this license.
7
- #
8
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9
- # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
11
- # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
12
- # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
13
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
14
- # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
-
16
- # Don't use -w for now -- too many warning re. the BlueCloth module.
17
-
18
- # Converts the named text file (containing plain text marked up with Markdown
19
- # markup) into a corresponding html file. The user must specify both filenames.
20
- # If the outfile already exists, it will be written over.
21
-
22
- require 'rubygems'
23
- require 'bluecloth'
24
-
25
- if ARGV.size != 2
26
- puts "Error: please pass exactly two args: the name of the file"
27
- puts "you want converted to html, and the name of the file:"
28
- puts "mkdn2html.rb infile.txt outfile.html"
29
- exit 1
30
- end
31
-
32
- infile_name = ARGV[0]
33
- outfile_name = ARGV[1]
34
-
35
- # Strip the last filename extension so we can use the basename in the
36
- # title of the page.
37
- base_filename = File.basename( infile_name, ".*" )
38
- puts "base_filename = #{base_filename}"
39
- if base_filename == 'README'
40
- base_filename = 'Home'
41
- end
42
- puts "base_filename = #{base_filename}"
43
-
44
- raw_markdown_text = IO.read( infile_name )
45
- bc = BlueCloth.new( raw_markdown_text )
46
- html_content = bc.to_html
47
-
48
- puts "outfile is #{File.expand_path( outfile_name )}"
49
-
50
- template_content = IO.read( './doc/supplies/page_template.html' )
51
- template_content.sub!( /\{\{content\}\}/, html_content )
52
- template_content.sub!( /\{\{title\}\}/, base_filename )
53
-
54
-
55
- File.open( outfile_name, 'w' ) do |file|
56
- file.write template_content
57
- end
58
-
59
- puts "Done creating plain #{base_filename} html file."
@@ -1,91 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # Copyright (C) 2006 John M. Gabriele <jmg3000@gmail.com>
4
- #
5
- # This program is distributed under the terms of the MIT license.
6
- # See the included MIT-LICENSE file for the terms of this license.
7
- #
8
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9
- # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
11
- # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
12
- # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
13
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
14
- # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
-
16
-
17
- # This script will modify the contents of the first html file you
18
- # pass it, and save the modifications in the 2nd file.
19
- #
20
- # What it does:
21
- #
22
- # It looks in the first file for patterns like this:
23
- #
24
- # <pre><code>{{name}}\nstuff</code></pre>
25
- #
26
- # and replaces "stuff" with "stuff" processed to include color syntax
27
- # highlighting, assuming it is code written in language "name".
28
- #
29
- # Prerequisites:
30
- # * This script expects that you have GNU source-highlight installed.
31
-
32
- require 'cgi'
33
-
34
- if ARGV.size != 2
35
- puts "Please don't trifle with me."
36
- exit 1
37
- end
38
-
39
- infile_name = ARGV[0]
40
- outfile_name = ARGV[1]
41
-
42
- # Open the file, slurp the whole thing into one long string.
43
- infile_content = IO.read( infile_name )
44
- outfile_content = infile_content.clone
45
- temp_content = infile_content.clone
46
-
47
- # Make sure we find all of them -- there could be more than 1 in
48
- # the given file. XXX (Just finding the first one here.)
49
-
50
- snippet_num = 0
51
-
52
- while true
53
- # If we get a match, process that snippet.
54
- if outfile_content =~ %r{<pre><code>\{\{(\w+)\}\}\n(.+?)</code></pre>}m
55
- pre_stuff = $`
56
- language = $1
57
- code_to_convert = $2
58
- post_stuff = $'
59
-
60
- # BlueCloth already escapes html tags, so this is to avoid
61
- # double escaping by source-highlight
62
- # - Jan
63
- code_to_convert = CGI::unescapeHTML(code_to_convert)
64
-
65
- # Quick usage note on source-highlight:
66
- #
67
- # source-highlight -s ruby -i $filename -o $filename
68
- #
69
- # where, if you omit -o filename, output goes to stdout.
70
-
71
- base_name = File.basename( outfile_name, '.*' )
72
- File.open( "doc/#{base_name}_#{snippet_num}.snip", 'w' ) do |file|
73
- file.write code_to_convert
74
- end
75
-
76
- highlighted_code =
77
- `source-highlight -s #{language} -i doc/#{base_name}_#{snippet_num}.snip -f html`
78
-
79
- temp_content = pre_stuff + highlighted_code + post_stuff
80
- snippet_num += 1
81
- outfile_content = temp_content.clone
82
- else
83
- break
84
- end
85
- end
86
-
87
- File.open( outfile_name, 'w' ) do |file|
88
- file.write outfile_content
89
- end
90
-
91
- puts "Done syntax highlighting #{snippet_num} snippets for #{infile_name}. Wrote #{outfile_name}."