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