Software Development from Scratch

Twitter File System

Twitter File System

You can operate Twitter through file system operations on the Twitter File System

The Twitter File System is Linux application based on FUSE(Filesystem in USErspace).

You can develope file system in a userspace with FUSE. (refer to the FUSE.)

Labeled a "file system", the Twitter File System is just pesudo file system.

For example, with the Twitter File System, you can tweet to Twitter by writting a tweet file with vim,

follow a user by creating a symbolic link, display a timeline by read a timeline file with a cat command, etc.



Then, let's download a program and try it!



Download

Download from the following links.

Download links

Version 0.0.4: twfs64_0.0.4-1_amd64.deb

Version 0.0.3: twfs64_0.0.3-1_amd64.deb

Changes

About Installation

The Twitter File System is developed in Ubuntu. So, for Windows or Mac users, you can install

Ubuntu in a virtual PC (for example, VirtualBox, etc.) before installing the program.

(The installation package is Debian package and it needs only openssl and fuse library.

So, the program can be installed in any debian systems.)

The program is for 64 bit environment. (Please contact me if you need 32 bit binary.)

Then, download the program and save it at arbitrary directory in Ubuntu.

Here, it is assumed that you saved it at your home directory.

Installation

First of all, lauch a terminal and input the following commands.

The root authority is needed for the installation of the program.


$ sudo dpkg -i twfs64_0.0.1-1_amd64.deb
$ sudo apt-get -fy install



The program might be installed at /usr/bin/. Confirm the location of the command by inputting

the following command.


$ which twfs 



The arguments of Twitter File System are a screen name of Twitter, root directory of

Twitter File System, and it's mount point. Here, make root directory and mount point.


$ mkdir root
$ mkdir mount 



Actual files and directories are stored in root directory by Twitter File System.

Twitter File System mount root directory to mount point.

Then, you can operate Twitter functions via operations for files and directory under mount point.

Starting Twitter File System

The format of Twitter File Syste is the following format.


[SYNOPSIS]
    twfs screen_name root_directory mount_point

[DESCRIPTION]
    mount root_directory to mount_point
    
    screen_name
       your screen name of Twitter



To start Twitter File System, for example, input the following command.

You should execute the program as unprivileged user.


$ twfs yabusame2001 root mount



Here, these emamples are specified yabusame2001 as screen name.

You can also specify your screen name.

When the program is executed, the following messages are displayed.


$ twfs -u yabusame2001 root mount
Please input the following url to your browser, login twitter, and
take down a "PIN CODE" displayed on the browser.

https://api.twitter.com/oauth/authorize?oauth_token=8ZDGBkdsDDakjlkja

Then, enter the PIN CODE and the return key.
-> 



Copy displayed URL on a terminal by right-cliking and selecting "copy link address".

Next, paste the URL to your web browser like a "Firefox" and go to a site of the URL.

Then, the following screen is displayed.

Twitterクライアントがアカウントを利用することを許可します画面

Here, click "Authorize App" button.

Then, PIN CODE is displayed and take down these numbers.

Twitterのピンコード

Input your PIN CODE and Enter key on the terminal.

Then, Twitter File System is mounted. Finally return to the ordinary terminal operation.

Once the user is authenticated by proceeding these procedures,

the next time Twitter File System is started, these procedures are omitted.

If you input the other screen name next, these procedures are needed.

User home directory of Twitter File System

Once authenticated, you can find your screen name directory under mount point.

List mounted directory with ls command.


$ ls mount
yabusame2001



You can find your screen name directory.

The directory is user home directory of Twitter File System.

In above example, yabusame2001 has been specified as screen name.

User home directories of any users are created under mount point on Twitter File System.



Next, let's sett the configuration of user home directory.


$ ls mount/yabusame2001
account/          favorites/   home_timeline    retweet/   user_timeline
blocks/           follower/    lists/           status/
direct_message/   following/   notifications/   tweet



The descriptions of above directories are described at the following table.

The configuration of directory of Twitter File System
File/Directory Name Description
account directory profile file and setting file exist. You can read user profile.
blocks directory list file exits. You can block specified user and display users whom you blocked in this directory.
direct_message directory message file and send_to file exist. You can send a direct message to specified user, receive messages and display those.
favorites directory list file exists. You can make favorite and display your favorite tweets.
follower directory list file exits. You can display your followers.
following directory list file exits. You can display users whom you followed and follow a user.
home_timeline file Home timeline file. You can read a timeline that includes your tweets and tweets of following user.
lists directory You can manage lists.
notifications directory @tweet file and retweet_of_me file exist. You can read tweets which send to you and retweets of your tweets.
retweet directory Retweets which you retweet are stored in this directory. You can retweet by making a symbolic link at this directory.
status directory Your tweets are stored at this directory.
tweet file You can tweet to Twitter by writing this file.
user_timeline file You can read your tweets.


Unmount the Twitter File System

To unmmount, you can use FUSE mount command.


$ fusermount -u mount



How to operate Twitter File System

Tweet to Twitter

To tweet to Twitter, you write text to the tweet file.

For example:


$ echo -n "tweet test" > tweet



Next, change current directory to other user home directory and

write the tweet file of other user.

For example:


$ cd mount/[someone's directory]
$ vi tweet



In the above example, you can @tweet to the user whose screen name is automatically

specified by user home directory name. When you open a other user's tweet file with

using vim, the contents of tweet file is automatically shown as bellow exmple.

The content of other user's tweet file:


@someone test tweet



Here, input ":w" command of vim, then text of the tweet file is tweeted to Twitter.

Displya a timeline

To display a timeline, you can read home_timeline file or user_timeline file.


$ cat home_timeline




$ cat user_timeline



Here, list files with ls command at mount point.


$ ls mount



Then, you can find each user's home directory is created after reading timeline file.

timeline

display tweets and delete a tweet

Next, list files at status directory under user home directory with ls command.


$ ls status



Then, you can find numerical file names. Each file is tweet file.

Numbers of file name means tweet id of Tweitter.If you delete a tweet file,

the corresponding tweet on Twitter is deleted.



Note: you can delete tweet on Twitter under status directory of authenticated user's home directory.

If you delete a tweet file which other user has, the corresponding tweet on Twitter is NOT deleted.



To delete your tweet, For example:


$ cd status
$ rm 432298907987



display retweets and retweet a tweet

Next, list retweet directory with ls command. If retweets exist, each retweet is represented by

sinbolic link to its tweet file after reading timeline file.


$ ls retweet



To retweet to Twitter, create a symbolic link to tweet file (under status directory) at your

retweet directory. To make a symbolic link, first you change current directory to your retweet

directory. Also you can not retweet under other user's retweet directory.



For example:


$ cd retweet
$ ln -s ../../yabusame2001/status/432298907987 .



In the above example, tweet id 432298907987 of yabusame2001 is retweeted to Twitter.



To cancell your retweet, delete a symbolic link.

For example:


$ cd retweet
$ rm 432298907987



Display your favorite tweets and register a favorite tweet

This functions are implemented at (Version0.0.2).

To register a favorite tweet, create a symbolic link to tweet file (under status directory)

at your favorites directory.



For example:


$ cd favorites
$ ln -s ../../yabusame2001/status/432298907987 .



In the above example, tweet id 432298907987 of yabusame2001 is registered to Twitter.



You can display your favorite tweet by reading list file.



For example:


$ cd favorites
$ cat list



display favorite tweets

You can also unregister your favorite tweet by deleting corresponding symbolic file.



For example:


$ cd favorites
$ rm 432298907987



Profile

You can read user's profile by reading account/profile file.

For example:


$ cd mount/yabusame2001/account
$ cat profile



Editing profile and setting are not implemented.

Block operations

You can block operations under authenticated user home directory.

To display blocked users, read blocks/list file.



For example:


$ cd blocks
$ cat list



After reading list file, each symbolic link to blocked user's home directory is created.

To block a specified user, create a symbolic link to user's home directory.

For example:


$ cd blocks
$ ln -s ../../yabusame2001 .



To unblock, remove a symbolic link.

For example:


$ cd blocks
$ rm yabusame2001



Send and receive a direct message

To receive direct messages, read a message file under direct_message directory.



For example:


$ cd direct_message
$ cat message



If direct messages exist, directory of screen name who exchange direct messages is

created under direct_message directory.



To send a direct message, write a send_to file. If you write a send_to file under

direct_message directory, you should insert @[screen_name]+[space] at head of direct message.

If @[screen_name]+[space] header is not inserted, the direct message is not sent to Twitter.



For example of senda a direct message:


$ cd direct_message
$ ehoc -n "@yabusame2001 hello" > send_to



Next, list files of user name directory under direct_message directory with ls command.


$ ls direct_message/yabusame2001
message send_to 123456789



Here, message files also exits. You can read direct messages which are exchanged between

specified user and authenticated user with reading message file under specified user name directory.

And, you can send a direct message to a specified user by writing a send_to file under specified

user name directory. This time user screen name is already specified, you should not insert

@[screen_name]+[space] in a message.



For example of sending to yabusame2001 by writing a send_to file under [yabusame2001] directory:


$ cd direct_message/yabusame2001
$ echo -n "hello!" > send_to



Display followers

To display followers, read follower/list file.


$ cd follower
$ cat list



After reading a follower/list file, each symbolic link to follower's home directory has been created.

Display following users, follow and unfollow

To display following users, read a following/list file.


$ cd following
$ cat list



After reading a following/list file, each symbolic link to following user home directory is created.



To follow a specified user, create a symbolic link to home directory of user which you want to follow.

(If there is not user home directory, create a his home directory under mount point before following. )



You can do following operation under following directory of authendicated user.



For example:

$ cd following
$ ln -s ../../yabusame2001 .



In the above example, yabusame2001 has been followed by creating a symbolic link.

To unfollow a specified user, remove a symbolic link under following directory of authenticated user.

For example:


$ cd following
$ rm yabusame2001



Lists operations

To manage lists, you can operate for lists directory.

The configuration of lists directory is described bellow.

Each directory has its list file. To display lists, read it.

Information of displayed lists are stored to owner's lists/my_list directory.

After reading a list file of subscriptions and added directory,

each symbolic link to the list directory under owner's lists/my_list directory is created.

Display lists of owner's list

To display, read a lists/my_list/list file.

For example:


$ cd lists
$ cd my_list
$ cat list



If lists exist, list name directories are created under my_list directory.

For example:


$ cd lists
$ cd my_list
$ ls



Display subscriptions of lists

To display, read a lists/subscriptions/list file.



For example:


$ cd lists
$ cd subscriptions
$ cat list



If lists exist, list name directories are created under owner's my_list directory.

And, each symbolic link to owner's list directory has been created.



For example:


$ cd lists
$ cd subscriptions
$ ls



Display added lists

To display, read a lists/added/list file.

For example:


$ cd lists
$ cd added
$ cat list



If lists exist, list name directories are created under owner's my_list directory.

And, each symbolic link to owner's list directory has been created.



For example:


$ cd lists
$ cd added
$ ls



Operations for a description, timeline, members and subscribers of list

To operate for each list file, you can do file operations for list name directory under my_list,

subscriptions and added directory. List name directory has the following files and directories.



Display a description of the list

To display, read a lists/{my_list, subscriptions, added}/[list name]/description file.



For example:


$ cd lists
$ cd my_list
$ cd list_name
$ cat description



Display timeline of the list

To display, read a lists/{my_list, subscriptions, added}/[list name]/timeline file.



For example:


$ cd lists
$ cd my_list
$ cd list_name
$ cat timeline



Display members of the list

To display, read a lists/{my_list, subscriptions, added}/[list name]/members/list file.



For example:


$ cd lists
$ cd my_list
$ cd list_name
$ cd members
$ cat list



After reading a list file, each symbolic link to member's home directory has been created.

Display subscribers of the list

To display, read a lists/{my_list, subscriptions, added}/[リスト名]/subscribers/list file.



For example:


$ cd lists
$ cd my_list
$ cd list_name
$ cd subscribers
$ cat list



After reading a list file, each symbolic link to member's home directory has been created.

Create a list

To create a list, create a list name directory under lists/my_list of authenticated user's home directory.



For example:


$ cd lists
$ cd my_list
$ mkdir new_list



Remove a list

To delete a list, remove a list name direcotry under lists/my_list of authenticated user's home directory.



For example:


$ cd lists
$ cd my_list
$ rm -fr new_list



Subscribe a list

To subscribe, create a symbolic link to list name directory to subscribe under lists/subscriptions

directory of authenticated user's home directory.



For example:


$ cd lists
$ cd subscriptions
$ ln -s ../../../user/lists/my_list/test_list .



Stop subscribing a list

To stop, remove a symbolic link to list name directory.

For example:


$ cd lists
$ cd subscriptions
$ rm test_list



About notifications

To display @tweets, read a @tweet file under notifications directory of authenticated user.



For example:


$ cd notifications
$ cat @tweet



And, to display retweets of you tweet, read retweet_of_me file under notifications directory of

authenticated user.



For example:


$ cd notifications
$ cat retweet_of_me



Others

If you would like any functions of Twitter or there are anything in particular that you noticed,

feel free to let me know about it vi mail or Twitter.

Thanks!

inserted by FC2 system