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