| 1 | [[PageOutline]] |
| 2 | |
| 3 | = New web interface |
| 4 | |
| 5 | In addition to the console UIs, we also maintain a browser based (remote, via HTTP) interface to the tool, which provides an even more convenient way for code grokking. The main features of the web interface are: |
| 6 | |
| 7 | * Running and exploring semantic queries (both normal and context-sensitive queries) |
| 8 | * Prev-next style browsing of query results |
| 9 | * Query construct assistant (auto-complete) |
| 10 | * Persistent queries |
| 11 | * Management of (possibly multiple) running queries |
| 12 | * Database operations |
| 13 | * Ability to mark files with error forms |
| 14 | * Dependency examinations |
| 15 | |
| 16 | ''Note that !JavaScript must be enabled in the browser to be able to use this interface.'' |
| 17 | |
| 18 | == Installation |
| 19 | |
| 20 | The web based UI is built upon the [http://yaws.hyber.org/ Yaws] web server. To be able to start this interface you need a Yaws web server installed. Installation help: http://yaws.hyber.org/yaws.pdf (see Chapter 2). |
| 21 | |
| 22 | * Recommended version: 1.92 |
| 23 | * Required version: 1.89 or higher. |
| 24 | |
| 25 | If you prefer using the 1.89 version of yaws, please use the -yaws_189 option during compilation: |
| 26 | |
| 27 | {{{ |
| 28 | bin/referl -build tool -yaws_189 |
| 29 | }}} |
| 30 | |
| 31 | '''If Erlang/OTP-R16B01 is used''', then none of the Yaws versions will be compiled from source. The problem is that every Erlang source of Yaws is compiled with the {{{-Werror}}} flag which causes build error when used with Erlang/OTP-R16B01 to compile Yaws. |
| 32 | |
| 33 | To fix this error, you should use this modified Makefile. Put [attachment:Makefile this Makefile] under the {{{src}}} directory of the downloaded sources of Yaws-1.96, then execute {{{make clean}}}. After the execution, the standard build procedure should be followed which is shown in LocalInstallLinux page. |
| 34 | |
| 35 | If Windows is used, then other opportunity exists. Use the installer binaries of different Yaws versions (Yaws-1.92 - Yaws-1.96) instead of compiling them from source. |
| 36 | |
| 37 | |
| 38 | For a step-by-step installation tutorial, which is including the installation guide of Yaws, please see LocalInstallLinux. |
| 39 | |
| 40 | == Starting up |
| 41 | |
| 42 | We can start the server either with the {{{referl}}} script using the {{{-web2}}} option, or from a running !RefactorErl shell. Both cases provide a default configuration: server name {{{localhost}}}, port {{{8001}}}, and address {{{127.0.0.1.}}}, which can be overridden. |
| 43 | |
| 44 | Possible options: |
| 45 | |
| 46 | * {{{yaws_path YPATH}}} |
| 47 | |
| 48 | The absolute location of your Yaws ebin directory. |
| 49 | |
| 50 | * {{{yaws_listen YLISTEN}}} |
| 51 | |
| 52 | Valid IP address, which Yaws will listen to. |
| 53 | |
| 54 | * {{{yaws_name YNAME}}} |
| 55 | |
| 56 | Valid domain name, which Yaws will be bound to. |
| 57 | |
| 58 | * {{{yaws_port YPORT}}} |
| 59 | |
| 60 | Valid port number, which Yaws will be bound to. |
| 61 | |
| 62 | * {{{browser_root BROOT}}} |
| 63 | |
| 64 | The web interface allows database operations. The root directory for those operations can be set with this parameter. |
| 65 | |
| 66 | * {{{images_dir IDIR}}} |
| 67 | |
| 68 | Path of the directory where the generated images (visualisation of dependency examinations) will be placed. |
| 69 | |
| 70 | * {{{restricted_mode RMODE}}} |
| 71 | |
| 72 | If set the interface starts in restricted mode, which means some features are blocked for non-admin users. |
| 73 | |
| 74 | |
| 75 | === Startup: referl script |
| 76 | |
| 77 | You can pass any of the above options via command-line arguments (note that {{{-nitrogen}}} is mandatory). |
| 78 | Example: |
| 79 | {{{ |
| 80 | bin/referl -nitrogen |
| 81 | -yaws_path /Users/V/yaws-1.89/ebin |
| 82 | -yaws_listen 127.0.0.1 |
| 83 | -yaws_port 8000 |
| 84 | -yaws_name localhost |
| 85 | -browser_root /Users/V/erlang |
| 86 | -images_dir /Users/V/graph_images |
| 87 | -restricted_mode |
| 88 | }}} |
| 89 | |
| 90 | === Startup: !RefactorErl shell |
| 91 | |
| 92 | We have two functions for starting the interface : {{{ri:start_web2/0}}} and {{{ri:start_web2/1}}}. Without passing any parameters the web server starts up with the default configuration. The 1-arity function allows the interface to be configured using an [http://www.erlang.org/doc/man/proplists.html Erlang proplist]. Example: |
| 93 | {{{ |
| 94 | #!erlang |
| 95 | |
| 96 | ri:start_web2([ |
| 97 | {yaws_path,"/Users/V/yaws-1.89/ebin"}, |
| 98 | {yaws_listen,"127.0.0.1"}, |
| 99 | {yaws_name, localhost}, |
| 100 | {yaws_port,"8000"}, |
| 101 | {browser_root,"/Users/V/erlang"}, |
| 102 | {images_dir,"/Users/V/graph_images"}, |
| 103 | {restricted_mode,true}]). |
| 104 | }}} |
| 105 | |
| 106 | |
| 107 | == Shutting down |
| 108 | |
| 109 | You are advised to always log out before shutting down the web server, because the log-out process deletes temporary, dynamically generated components of web pages. If the server has been started from the !RefactorErl shell, then {{{ri:stop_web2()}}} should be called in order to shut down the service. |
| 110 | |
| 111 | |
| 112 | == Logging in |
| 113 | |
| 114 | In your favourite browser, navigate to the server address defined by the configuration (the default is {{{http://localhost:8001}}}) after the web server has been successfully started. Services are allowed only to authorized people, so first you have to log in with a username. The browser will be redirected to the ''queries'' page. If restricted_mode is on, you have to use the username 'admin' to access restricted features, this will require you to provide a password as well. You can set the password with the {{{index:makeadminpassword/1}}} function, with a string as the parameter. |
| 115 | |
| 116 | == Global notifications |
| 117 | |
| 118 | When someone starts/finishes a modification of the database (e.g. adding files), a notification will appear stating what process has been started/finished. |
| 119 | During any modification process most functions on the web interface will not be available. This restriction is global for the whole system. Only things available are: |
| 120 | |
| 121 | * Browsing an already completed query's results (if source files were generated previously). |
| 122 | * Browsing files on the server. |
| 123 | |
| 124 | For further information, see: [wiki:ConfigurableJobServer Configurable Jobserver] |
| 125 | |
| 126 | == Database operations |
| 127 | |
| 128 | This service is available under the "Files" tab. {{{#!comment In restricted mode, this service is not available for non-admin users. It only works correctly if the server process has the appropriate access to files and directories. }}} The file browser panel is located at the left side of the page. You can either browse files which are located on the server ("Browse server"), or which had been loaded into the database ("Browse loaded files"). You can switch between these two options by clicking the button in the top right corner of the file browser box. |
| 129 | |
| 130 | === Browsing files on the server |
| 131 | |
| 132 | The root directory of the browser is an optional configuration parameter. Possible values are: |
| 133 | |
| 134 | * If the {{{browser_root}}} parameter is set during start up, the given value is the root directory. |
| 135 | * If the {{{browser_root}}} parameter is not set during start up |
| 136 | * If the database had contained files before start up, the root elements are the directories of these files. |
| 137 | * If the database had not contained files before start up, then !RefactorErl’s lib directory will be the root. |
| 138 | |
| 139 | In this mode, directories can be listed, the contents of files can be shown, and a selected directory or file can be added to the database. The selected directory or file is highlighted by a blue background. Database operations are indicated by a progress bar. |
| 140 | |
| 141 | Searching is possible in both file system files, and loaded files. |
| 142 | |
| 143 | === Browsing loaded files |
| 144 | |
| 145 | In this mode, directories' and files' contents can be listed, a selected file or directory can be reloaded to the database, dropped from the database, or can be pre-generated for the source code viewer. Status messages are displayed during the reloading/dropping/generating process, and also after the process has finished. |
| 146 | The file browser displays the last directory that contains all the loaded files. |
| 147 | |
| 148 | ''Dropping a file from the database does not imply removing it from the file system.'' |
| 149 | |
| 150 | == Running semantic queries |
| 151 | |
| 152 | See [wiki:Web2/RunningSemanticQueries Running semantic queries]. |
| 153 | |
| 154 | == Errors |
| 155 | |
| 156 | This service is available under the "Errors" tab. |
| 157 | |
| 158 | If the database contains file(s) with error form(s), the list of errors will be displayed in a table. Each row in the table shows an error. Clicking the file name shows the file and highlights the position of the error. |
| 159 | |
| 160 | If the database does not contain any files with error forms, a "No error" message is displayed. |
| 161 | |
| 162 | == Dependency examination |
| 163 | |
| 164 | See [wiki:Web2/DependencyExaminations Dependency examinations]. |
| 165 | {{{#!comment |
| 166 | == Code duplicates |
| 167 | |
| 168 | See [wiki:WebInterface/CodeDuplicates Code duplicates]. |
| 169 | }}} |
| 170 | |
| 171 | == Logging out |
| 172 | |
| 173 | You can log out by clicking the "Log out {{{username}}}" button. During the logout process the interface clears the users' session, deletes the dynamically generated images belonging to the user, and redirects the browser to the login page. The interface does not delete the queries executed by the user, nor their results, and also keeps the state of the database. |