aboutsummaryrefslogtreecommitdiff
path: root/_posts/2021-12-30-wap-mobile-web-before-the-web.md
diff options
context:
space:
mode:
Diffstat (limited to '_posts/2021-12-30-wap-mobile-web-before-the-web.md')
-rw-r--r--_posts/2021-12-30-wap-mobile-web-before-the-web.md203
1 files changed, 203 insertions, 0 deletions
diff --git a/_posts/2021-12-30-wap-mobile-web-before-the-web.md b/_posts/2021-12-30-wap-mobile-web-before-the-web.md
new file mode 100644
index 0000000..058ad55
--- /dev/null
+++ b/_posts/2021-12-30-wap-mobile-web-before-the-web.md
@@ -0,0 +1,203 @@
1---
2title: Wireless Application Protocol and the mobile web before the web
3permalink: /wap-mobile-web-before-the-web.html
4date: 2021-12-30T12:00:00+02:00
5layout: post
6type: post
7draft: false
8---
9
10## A little stroll down the history lane
11
12About two weeks ago, I watched this outstanding documentary on YouTube
13[Springboard: the secret history of the first real
14smartphone](https://www.youtube.com/watch?v=b9_Vh9h3Ohw) about the history of
15smartphones and phones in general. It brought back so many memories. I never had
16an actual smartphone before the Android. The closest to smartphone was [Sony
17Ericsson P1](https://www.gsmarena.com/sony_ericsson_p1-1982.php). A fantastic
18phone and I broke it in Prague after a party and that was one of those rare
19occasions where I was actually mad at myself. But nevertheless, after that
20phone, the next one was an Android one.
21
22Before that, I only owned normal phones from Nokia and Siemens etc. Nothing
23special, actually. These are the phones we are talking about. Before 2007.
24Apple and Android phones didn't exist yet.
25
26These phones were rocking:
27
28- No selfie cameras.
29- ~2 inch displays.
30- ~120 MHz beast CPU's.
31- 144p main cameras.
32- But they had a headphone jack.
33
34Let's take a look at these beauties.
35
36![Old phones](/assets/posts/wap/phones.gif)
37
38## WAP - Wireless Application Protocol
39
40Not that one! We are talking about Wireless Application Protocol and not Cardi
41B's song 😃
42
43WAP stands for Wireless Application Protocol. It is a protocol designed for
44micro-browsers, and it enables the access of internet in the mobile devices. It
45uses the mark-up language WML (Wireless Markup Language and not HTML), WML is
46defined as XML 1.0 application. Furthermore, it enables creating web
47applications for mobile devices. In 1998, WAP Forum was founded by Ericson,
48Motorola, Nokia and Unwired Planet whose aim was to standardize the various
49wireless technologies via protocols.
50[(source)](https://www.geeksforgeeks.org/wireless-application-protocol/)
51
52WAP protocol was resulted by the joint efforts of the various members of WAP
53Forum. In 2002, WAP forum was merged with various other forums of the industry,
54resulting in the formation of Open Mobile Alliance (OMA).
55[(source)](https://www.geeksforgeeks.org/wireless-application-protocol/)
56
57These were some wild times. Devices had tiny screens and data transmission rates
58were abominable. But they were capable of rendering WML (Wireless Markup
59Language). This was very similar to HTML, actually. It is a markup language,
60after all.
61
62These pages could be served by [Apache](https://apache.org/) and could be
63generated by CGI scripts on the backend. The only difference was the limited
64markup language.
65
66## WML - Wireless Markup Language
67
68Just like web browsers use HTML for content structure, older mobile device
69browsers use WML - if you need to support really old mobile phones using WML
70browsers, you will need to know about it. WML is XML-based (an XML vocabulary
71just like XHTML and MathML, but not HTML) and does not use the same metaphor as
72HTML. HTML is a single document with some metadata packed away in the head, and
73a body encapsulating the visible page. With WML, the metaphor does not envisage
74a page, but rather a deck of cards. A WML file might have several pages or cards
75contained within it.
76[(source)](https://www.w3.org/wiki/Introduction_to_mobile_web)
77
78```html
79<?xml version="1.0"?>
80<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
81<wml>
82 <card id="home" title="Example Homepage">
83 <p>Welcome to the Example homepage</p>
84 </card>
85</wml>
86```
87
88There is an amazing tutorial on [Tutorialpoint about
89WML](https://www.tutorialspoint.com/wml/index.htm).
90
91## Converting Digg to WML
92
93This task is completely useless and not really feasible nowadays, but I had to
94give it a try for old-time sake. Since the data is already there in a form of
95RSS feed, I could take this feed and parse it and create a WML version of the
96homepage.
97
98We will need:
99
100- Python3 + Pip
101- ImageMagick
102- feedparser and mako templating
103
104```sh
105# for fedora 35
106sudo dnf install ImageMagick python3-pip
107
108# tempalting engine for python
109pip install mako --user
110
111# for parsing rss feeds
112pip install feedparser --user
113```
114
115Project folder structure should look like the following.
116
117```
11812:43:53 m@khan wap → tree -L 1
119.
120├── generate.py
121└── template.wml
122
123```
124
125After that, I created a small template for the homepage.
126
127```html
128<?xml version="1.0"?>
129<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml_1.2.xml">
130
131<wml>
132
133 <card title="Digg - What the Internet is talking about right now">
134
135 % for item in entries:
136 <p><img src="/images/${item.id}.jpg" width="175" height="95" alt="${item.title}" /></p>
137 <p><small>${item.kicker}</small></p>
138 <p><big><b>${item.title}</b></big></p>
139 <p>${item.description}</p>
140 % endfor
141
142 </card>
143
144</wml>
145```
146
147And the parser that parses RSS feed looks like this.
148
149```python
150import os
151import feedparser
152from mako.template import Template
153
154os.system('mkdir -p www/images')
155
156template = Template(filename='template.wml')
157
158feed = feedparser.parse('https://digg.com/rss/top.xml')
159
160entries = feed.entries[:15]
161
162for entry in entries:
163 print('Processing image with id {}'.format(entry.id))
164 os.system('wget -q -O www/images/{}.jpg "{}"'.format(entry.id, entry.links[1].href))
165 os.system('convert www/images/{}.jpg -type Grayscale -resize 175x -depth 3 -quality 30 www/images/{}.jpg'.format(entry.id, entry.id))
166
167html = template.render(entries = entries)
168
169with open('www/index.wml', 'w+') as fp:
170 fp.write(html)
171```
172
173This script will create a folder `www` and in the folder `www/images` for
174storing resized images.
175
176> Be sure you don't use SSL and use just normal HTTP for serving the content.
177> These old phones will have problems with TLS 1.3 etc.
178
179If you look at the python file, I convert all the images into tiny B&W images.
180They should be WBMP (Wireless BitMaP) but I choose JPEGs for this, and it seems
181to work properly.
182
183Because I currently don't have a phone old enough to test it on, I used an
184emulator. And it was really hard to find one. I found [WAP
185Proof](http://wap-proof.sharewarejunction.com/) on shareware junction, and it
186did the job well enough. I will try to find and actual device to test it on.
187
188<video src="/assets/posts/wap/emulator.mp4" controls></video>
189
190If you are using Nginx to serve the contents, add a directive to the hosts file
191that will automatically server `index.wml` file.
192
193```nginx
194server {
195 index index.wml index.html index.htm index.nginx-debian.html;
196}
197```
198
199## Conclusion
200
201Well, this was pointless, but very fun! I hope you enjoyed it as much as I did.
202I will try to find an old phone to test it on. If you have any questions, feel
203free to ask in the comments.